dh_Fileinfo

, , , , , , , , , , , , , , , , Monday, December 1, 2008

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;
}
}

0 comments:

Post a Comment

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