[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs qe.h qe.c
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs qe.h qe.c |
Date: |
Wed, 21 Oct 2020 19:22:25 -0400 (EDT) |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 20/10/21 19:22:25
Modified files:
. : qe.h qe.c
Log message:
Improve colorization
- add cur_pos in QEColorizeContext to track cursor position if on
current line
- highlight trailing blanks except before the cursor
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.282&r2=1.283
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.301&r2=1.302
Patches:
Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.282
retrieving revision 1.283
diff -u -b -r1.282 -r1.283
--- qe.h 21 Oct 2020 15:01:56 -0000 1.282
+++ qe.h 21 Oct 2020 23:22:25 -0000 1.283
@@ -989,6 +989,7 @@
int colorize_state;
int state_only;
int combine_start, combine_stop; /* region for
combine_static_colorized_line() */
+ int cur_pos; /* position of cursor in line or -1 if outside line */
};
/* colorize a line: this function modifies buf to set the char
Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.301
retrieving revision 1.302
diff -u -b -r1.301 -r1.302
--- qe.c 21 Oct 2020 15:01:56 -0000 1.301
+++ qe.c 21 Oct 2020 23:22:25 -0000 1.302
@@ -4179,9 +4179,15 @@
if (buf[len] != '\n') {
/* line was truncated */
/* XXX: should use reallocatable buffer */
- *offsetp = eb_goto_pos(b, line_num + 1, 0);
+ *offsetp = eb_next_line(b, offset);
}
buf[len] = '\0';
+ if (s->offset >= offset && s->offset < *offsetp) {
+ /* compute cursor position */
+ int offset1 = offset;
+ for (cctx.cur_pos = 0; offset1 < s->offset; cctx.cur_pos++)
+ offset1 = eb_next(b, offset1);
+ }
bom = (buf[0] == 0xFEFF);
if (bom) {
@@ -4189,7 +4195,9 @@
cctx.offset = eb_next(b, cctx.offset);
}
cctx.combine_stop = len - bom;
+ cctx.cur_pos -= bom;
s->colorize_func(&cctx, buf + bom, len - bom, s->colorize_mode);
+ cctx.cur_pos += bom;
/* buf[len] has char '\0' but may hold style, force buf ending */
buf[len + 1] = 0;
@@ -4219,13 +4227,11 @@
}
}
if (!(s->colorize_mode->flags & MODEF_NO_TRAILING_BLANKS)) {
- /* Mark trailing blanks as errors if cursor is not on same line */
- if (!(s->offset >= offset && s->offset < *offsetp)) {
- for (i = len; i > 0 && qe_isblank(buf[i - 1]); i--) {
+ /* Mark trailing blanks as errors if cursor is not at end of line */
+ for (i = len; i > 0 && qe_isblank(buf[i - 1]) && i != cctx.cur_pos;
i--) {
sbuf[i - 1] = QE_STYLE_BLANK_HILITE;
}
}
- }
return len;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs qe.h qe.c,
Charlie Gordon <=