1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-11-17 18:16:22 -05:00

buffer-position reports character under cursor according to type (either 0xXX or \uXXXX).

This commit is contained in:
Renaud 2015-02-08 14:47:56 +08:00
parent bdbd2d5437
commit 356a003194

View File

@ -74,6 +74,7 @@ int showcpos(int f, int n)
long predchars; /* # chars preceding point */ long predchars; /* # chars preceding point */
int predlines; /* # lines preceding point */ int predlines; /* # lines preceding point */
unicode_t curchar ; /* character under cursor */ unicode_t curchar ; /* character under cursor */
unsigned bytes ; /* length of unicode sequence */
int ratio; int ratio;
int col; int col;
int savepos; /* temp save for current offset */ int savepos; /* temp save for current offset */
@ -88,6 +89,7 @@ int showcpos(int f, int n)
predchars = 0; predchars = 0;
predlines = 0; predlines = 0;
curchar = 0; curchar = 0;
bytes = 1 ;
while (lp != curbp->b_linep) { while (lp != curbp->b_linep) {
/* if we are on the current line, record it */ /* if we are on the current line, record it */
if (lp == curwp->w_dotp) { if (lp == curwp->w_dotp) {
@ -99,7 +101,7 @@ int showcpos(int f, int n)
if( (curwp->w_doto) == len) if( (curwp->w_doto) == len)
curchar = '\n'; curchar = '\n';
else else
(void) utf8_to_unicode( lp->l_text, curwp->w_doto, len, &curchar) ; bytes = utf8_to_unicode( lp->l_text, curwp->w_doto, len, &curchar) ;
} }
/* on to the next line */ /* on to the next line */
++numlines; ++numlines;
@ -128,9 +130,9 @@ int showcpos(int f, int n)
ratio = (100L * predchars) / numchars; ratio = (100L * predchars) / numchars;
/* summarize and report the info */ /* summarize and report the info */
mlwrite("Line %d/%d Col %d/%d Char %D/%D (%d%%) char = 0x%x", mlwrite("Line %d/%d Col %d/%d Char %D/%D (%d%%) char = %s%x",
predlines + 1, numlines + 1, col, ecol, predlines + 1, numlines + 1, col, ecol,
predchars, numchars, ratio, curchar); predchars, numchars, ratio, (bytes > 1) ? "\\u" : "0x", curchar);
return TRUE; return TRUE;
} }