version 1.40, 2018/12/26 07:01:22 |
version 1.41, 2019/06/07 07:54:05 |
|
|
* Display a bunch of useful information about the current location of dot. |
* Display a bunch of useful information about the current location of dot. |
* The character under the cursor (in octal), the current line, row, and |
* The character under the cursor (in octal), the current line, row, and |
* column, and approximate position of the cursor in the file (as a |
* column, and approximate position of the cursor in the file (as a |
* percentage) is displayed. The column position assumes an infinite |
* percentage) is displayed. |
|
* Also included at the moment are some values in parenthesis for debugging |
|
* explicit newline inclusion into the buffer. |
|
* The column position assumes an infinite |
* position display; it does not truncate just because the screen does. |
* position display; it does not truncate just because the screen does. |
* This is normally bound to "C-X =". |
* This is normally bound to "C-x =". |
*/ |
*/ |
/* ARGSUSED */ |
/* ARGSUSED */ |
int |
int |
showcpos(int f, int n) |
showcpos(int f, int n) |
{ |
{ |
struct line *clp; |
struct line *clp; |
|
char *msg; |
long nchar, cchar; |
long nchar, cchar; |
int nline, row; |
int nline, row; |
int cline, cbyte; /* Current line/char/byte */ |
int cline, cbyte; /* Current line/char/byte */ |
|
|
|
|
/* collect the data */ |
/* collect the data */ |
clp = bfirstlp(curbp); |
clp = bfirstlp(curbp); |
|
msg = "Char:"; |
cchar = 0; |
cchar = 0; |
cline = 0; |
cline = 0; |
cbyte = 0; |
cbyte = 0; |
nchar = 0; |
nchar = 0; |
nline = 0; |
nline = 0; |
for (;;) { |
for (;;) { |
/* count this line */ |
/* count lines and display total as (raw) 'lines' and |
|
compare with b_lines */ |
++nline; |
++nline; |
if (clp == curwp->w_dotp) { |
if (clp == curwp->w_dotp) { |
/* mark line */ |
/* obtain (raw) dot line # and compare with w_dotline */ |
cline = nline; |
cline = nline; |
cchar = nchar + curwp->w_doto; |
cchar = nchar + curwp->w_doto; |
if (curwp->w_doto == llength(clp)) |
if (curwp->w_doto == llength(clp)) |
|
/* fake a \n at end of line */ |
cbyte = '\n'; |
cbyte = '\n'; |
else |
else |
cbyte = lgetc(clp, curwp->w_doto); |
cbyte = lgetc(clp, curwp->w_doto); |
} |
} |
/* now count the chars */ |
/* include # of chars in this line for point-thru-buff ratio */ |
nchar += llength(clp); |
nchar += llength(clp); |
clp = lforw(clp); |
clp = lforw(clp); |
if (clp == curbp->b_headp) |
if (clp == curbp->b_headp) { |
|
if (cbyte == '\n' && cline == curbp->b_lines) { |
|
/* swap faked \n for EOB msg */ |
|
cbyte = EOF; |
|
msg = "(EOB)"; |
|
} |
break; |
break; |
/* count the newline */ |
} |
|
/* count the implied newline */ |
nchar++; |
nchar++; |
} |
} |
/* determine row */ |
/* determine row # within current window */ |
row = curwp->w_toprow + 1; |
row = curwp->w_toprow + 1; |
clp = curwp->w_linep; |
clp = curwp->w_linep; |
while (clp != curbp->b_headp && clp != curwp->w_dotp) { |
while (clp != curbp->b_headp && clp != curwp->w_dotp) { |
|
|
clp = lforw(clp); |
clp = lforw(clp); |
} |
} |
ratio = nchar ? (100L * cchar) / nchar : 100; |
ratio = nchar ? (100L * cchar) / nchar : 100; |
ewprintf("Char: %c (0%o) point=%ld(%d%%) line=%d row=%d col=%d", |
ewprintf("%s %c (0%o) point=%ld(%d%%) line=%d row=%d col=%d" \ |
cbyte, cbyte, cchar, ratio, cline, row, getcolpos(curwp)); |
" (blines=%d rlines=%d l_size=%d)", msg, |
|
cbyte, cbyte, cchar, ratio, cline, row, getcolpos(curwp), |
|
curbp->b_lines, nline, clp->l_size); |
return (TRUE); |
return (TRUE); |
} |
} |
|
|