I repeat myself when under stress, I repeat myself when under stress . . .

, , , , , , Thursday, March 12, 2009 0 comments

// repeat_n [how many times] [command name]
// Repeats a command the number of times specified.

// Args are "n command", where n is the number of times
// to execute the command, and command is the name of
// the command to run.
//
// Usage example: repeat_n 15 cursor_down
// This will execute the cursor-down command 15 times, with the
// expected results.

// Source: Professional Slickedit by John Hurst
// Copyright 2007 Wiley Publishing Inc, Indianapolis, Indiana, USA.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0

_command void repeat_n(_str args = null) \\
name_info(','VSARG2_EDITORCTL)
{
if (args == null) {
message("Specify number of times and " \\
"command to run."
);
return;
}
_str n;
_str command;
parse args with n command;
if (n <= 0 || command == null) {
message("Specify number of times and " \\
"command to run."
);
return;
}
int i;
for (i = 0; i < n; i++) {
execute(command);
}
}

// repeat_n_last_macro [how many times]
// Repeats the last recorded macro the number of times specified
// Usage example: repeat_n_last_macro 25
// Executes the last recorded macro 25 times

//
Source: Professional Slickedit by John Hurst
// Copyright 2007 Wiley Publishing Inc, Indianapolis, Indiana, USA.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0

_command void repeat_n_last_macro(_str args = null) \\
name_info
(','VSARG2_EDITORCTL)
{
repeat_n(args :+ " last_macro");
}


Circuitous Logic

, , , , , 0 comments

// (1) Get and set your margin settings at desired increments.
// Assign this macro to a key combination.
// Stick your favorite margin presets into the macro code.
// I like to use 1 80 1, 1 128 1, 1 256 1, 1 512 1 and 1 1024 1.

// The same "cycling" method can be used on almost any setting.
// For example, you can easily modify this macro to take a text
// selection and cycle the text through all caps, initial caps,
// all lower case, and so on.

// Currently the macro will automatically increment to the next
// setting each time the key combo is pressed (including the
// first press). If the margins are currently 1 256 1, executing
// the command will increment the setting to 1 512 1. If 512
// is not the setting you want, just press the key combo again
// to set your desired value.
//

// (2) Cycle through display modes: hex, line hex, normal edit.
//


_command cycle_right_margin() name_info(','VSARG2_REQUIRES_EDITORCTL, VSARG2_READ_ONLY)
{
parse p_margins with left_ma right_ma new_para_ma;
// message("Current margin settings "left_ma' 'right_ma' 'new_para_ma);
switch (right_ma) {
case 80:
p_margins=left_ma' '128' 'new_para_ma;
message('Margins 'p_margins);
break;
case 128:
p_margins=left_ma' '256' 'new_para_ma;
message('Margins 'p_margins);
break;
case 256:
p_margins=left_ma' '512' 'new_para_ma;
message('Margins 'p_margins);
break;
case 512:
p_margins=left_ma' '1024' 'new_para_ma;
message('Margins 'p_margins);
break;
case 1024:
p_margins=left_ma' '80' 'new_para_ma;
message('Margins 'p_margins);
break;
default:
p_margins=left_ma' '80' 'new_para_ma;
message('Margins 'p_margins);
break;
}
}


// (2) Cycle through display modes: hex, line hex, normal edit.
// From Thom Little & Associates, www.tlanet.net


#define TLA_DISPLAY_EDIT 0
#define TLA_DISPLAY_HEX 1
#define TLA_DISPLAY_LINE_HEX 2

_command void tlaViewCycle( ) name_info( ',' VSARG2_ICON | VSARG2_REQUIRES_MDI_EDITORCTL )
{
switch ( p_hex_mode )
{
case TLA_DISPLAY_EDIT :
p_hex_mode = TLA_DISPLAY_HEX ;
break ;
case TLA_DISPLAY_HEX :
p_hex_mode = TLA_DISPLAY_LINE_HEX ;
break ;
case TLA_DISPLAY_LINE_HEX :
p_hex_mode = TLA_DISPLAY_EDIT ;
break ;
default :
tlaError( "tlaViewCycle", "Unknown view state" );
break ;
}
return ;
}

GlossyBlue Blogger by Black Quanta. Theme & Icons by N.Design Studio
Entries RSS Comments RSS