Showing posts with label margins. Show all posts
Showing posts with label margins. Show all posts

Circuitous Logic

, , , , , Thursday, March 12, 2009 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 ;
}

dh_Fileinfo

, , , , , , , , , , , , , , , , Monday, December 1, 2008 0 comments

The dh_fileinfo macro displays an informational dialog box with
various
details about the file currently being edited. I cobbled the macro
together from code available on the Slickedit Web site and elsewhere.
I've since forgotten where everything came from. This macro can be
greatly improved. You might notice, for example, that the value of some
of the variables, such as 'cc' (character count) are not yet included in the
message box.

I invite your improvements and suggestions, including ideas on stats to
add to the existing dialog.


The dh_fileinfo dialog lists:
  • fully qualified filename and path
  • file's current date and time
  • file size in bytes
  • file attributes
  • total number of lines in file
  • current margin setting
  • file's mode (e.g., Slick-C, HTML, C, etc.)
  • number of windows open in the editor
  • number of buffers open
  • number of the current View id
  • decimal and hex values of character under the cursor
// detailed fileinfo message box
_command dh_fileinfo() name_info(FILE_ARG'*,'READ_ONLY_ARG2)
{
_str filename=arg(1)
if (filename=='') {
filename=p_buf_name;
}
filename=absolute(filename);
_str filedate=file_date(filename);
_str filetime=file_time(filename);
_str fileattr=file_list_field(filename,DIR_ATTR_COL,DIR_ATTR_WIDTH);
int filelen=p_Noflines;
int bufcou=_Nofbuffers();
int wincou=Nofwindows();
get_view_id view_id
parse p_margins with left_ma right_ma new_para_ma;

// info on current character
get_line(line);
char=substr(line,p_col,1);
chr_num=_asc(get_text());

cc = 0; /* chars */
wc = 0; /* words */
lc = 0; /* lines */
dc = 0; /* displayed lines */
hc = 0; /* hidden lines */

int item = 0;
save_pos(p);
top_of_buffer();
for (;;) {
get_line line;
lc++;
for (i = 1; i < length(line); i++) {
cc++;
if (isalnum(substr(line,i,1))) {
item = 1;
} else if (item && !isalnum(substr(line,i,1))) {
wc++;
item = 0;
}
}
status=down();
bytesize = fsize();
dc = (p_Noflines - p_NofSelDispBitmaps);
hc = p_Nofhidden;
sc = p_NofSelDispBitmaps;
pc = ( filelen intdiv 55 );
_message_box(filename \r filedate' 'filetime \r bytesize ' bytes; ' fileattr \r\
'Lines: 'filelen' '\r\
'Margins: 'left_ma' 'right_ma' 'new_para_ma \r\
'Mode: 'p_mode_name \r 'Windows: 'wincou', Buffers: 'bufcou \r\
'Viewid 'view_id \r\
'Ascii char "'char'" dec='chr_num', hex='dec2hex(chr_num),' ':+
'FileInfo: '
p_buf_name, MB_ICONINFORMATION);

restore_pos(p);
break;
}
}

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