Improve colorization
- add QE_STYLE_BLANK_HILITE style for extra blanks at end of lines - add MODEF_NO_TRAILING_BLANKS flag to control this feature on a mode basis - add -nc (--no-crc) command line option du disable CRC based update cache - add disable-crc global variable for the same purpose - fix termios c_oflag flags in raw mode
This commit is contained in:
parent
0735453f67
commit
2c85e017fd
6 changed files with 38 additions and 4 deletions
13
qe.c
13
qe.c
|
|
@ -71,6 +71,7 @@ static int screen_height = 0;
|
|||
static int no_init_file;
|
||||
static int single_window;
|
||||
int force_tty;
|
||||
int disable_crc;
|
||||
int use_session_file;
|
||||
int use_html = 1;
|
||||
#ifndef CONFIG_TINY
|
||||
|
|
@ -3440,7 +3441,7 @@ static void flush_line(DisplayState *ds,
|
|||
e->shadow_nb_lines = n;
|
||||
}
|
||||
}
|
||||
if (ds->line_num < e->shadow_nb_lines) {
|
||||
if (ds->line_num < e->shadow_nb_lines && !disable_crc) {
|
||||
QELineShadow *ls;
|
||||
uint64_t crc;
|
||||
|
||||
|
|
@ -4217,6 +4218,14 @@ static int syntax_get_colorized_line(EditState *s,
|
|||
offset = eb_next(b, offset);
|
||||
}
|
||||
}
|
||||
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--) {
|
||||
sbuf[i - 1] = QE_STYLE_BLANK_HILITE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
|
|
@ -8925,6 +8934,8 @@ static CmdLineOptionDef cmd_options[] = {
|
|||
CMD_LINE_FVOID("?", "", show_usage, ""),
|
||||
CMD_LINE_BOOL("q", "no-init-file", &no_init_file,
|
||||
"do not load config files"),
|
||||
CMD_LINE_BOOL("nc", "no-crc", &disable_crc,
|
||||
"do not use crc based display cacheing"),
|
||||
CMD_LINE_BOOL("1", "single-window", &single_window,
|
||||
"keep a single window when loading multiple files"),
|
||||
CMD_LINE_BOOL("nw", "no-windows", &force_tty,
|
||||
|
|
|
|||
3
qe.h
3
qe.h
|
|
@ -1364,6 +1364,8 @@ void eb_delete_properties(EditBuffer *b, int offset, int offset2);
|
|||
|
||||
/* qe.c */
|
||||
|
||||
extern int disable_crc; /* Prevent CRC based display cacheing */
|
||||
|
||||
/* contains all the information necessary to uniquely identify a line,
|
||||
to avoid displaying it */
|
||||
typedef struct QELineShadow {
|
||||
|
|
@ -1531,6 +1533,7 @@ struct ModeDef {
|
|||
#define MODEF_DATATYPE 0x10
|
||||
#define MODEF_SHELLPROC 0x20
|
||||
#define MODEF_NEWINSTANCE 0x100
|
||||
#define MODEF_NO_TRAILING_BLANKS 0x200
|
||||
int buffer_instance_size; /* size of malloced buffer state */
|
||||
int window_instance_size; /* size of malloced window state */
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@
|
|||
QERGB(0x00, 0x00, 0x00), QERGB(0x00, 0x80, 0x80), 0, 0)
|
||||
STYLE_DEF(QE_STYLE_SEARCH_MATCH, "search-match", /* grey88 on #f000f0 */
|
||||
QERGB(0xe0, 0xe0, 0xe0), QERGB(0xf0, 0x00, 0xf0), 0, 0)
|
||||
STYLE_DEF(QE_STYLE_BLANK_HILITE, "blank-hilite", /* black on red */
|
||||
QERGB(0x00, 0x00, 0x00), QERGB(0xff, 0x00, 0x00), 0, 0)
|
||||
|
||||
/* HTML coloring styles */
|
||||
STYLE_DEF(QE_STYLE_HTML_COMMENT, "html-comment", /* #f84400 */
|
||||
|
|
|
|||
9
shell.c
9
shell.c
|
|
@ -3092,6 +3092,14 @@ void shell_colorize_line(QEColorizeContext *cp,
|
|||
cp->colorize_state = 0;
|
||||
m->colorize_func(cp, str + i, n - i, m);
|
||||
cp->combine_stop = i;
|
||||
if (!(m->flags & MODEF_NO_TRAILING_BLANKS)) {
|
||||
/* Mark trailing blanks as errors if cursor is not on same line */
|
||||
int j;
|
||||
for (j = n; j > i && qe_isblank(str[j - 1] & CHAR_MASK); j--) {
|
||||
str[j - 1] &= CHAR_MASK;
|
||||
SET_COLOR1(str, j - 1, QE_STYLE_BLANK_HILITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
cp->colorize_state = 0;
|
||||
}
|
||||
|
|
@ -3212,6 +3220,7 @@ static int shell_init(void)
|
|||
/* populate and register shell mode and commands */
|
||||
memcpy(&shell_mode, &text_mode, sizeof(ModeDef));
|
||||
shell_mode.name = "shell";
|
||||
shell_mode.flags |= MODEF_NO_TRAILING_BLANKS;
|
||||
shell_mode.mode_probe = shell_mode_probe;
|
||||
shell_mode.colorize_func = shell_colorize_line,
|
||||
shell_mode.buffer_instance_size = sizeof(ShellState);
|
||||
|
|
|
|||
14
tty.c
14
tty.c
|
|
@ -276,14 +276,22 @@ static int tty_dpy_init(QEditScreen *s,
|
|||
tcgetattr(fileno(s->STDIN), &tty);
|
||||
ts->oldtty = tty;
|
||||
|
||||
/* input modes: no break, no CR to NL, no parity check, no strip char,
|
||||
* no start/stop output control. */
|
||||
tty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP |
|
||||
INLCR | IGNCR | ICRNL | IXON);
|
||||
tty.c_oflag |= OPOST;
|
||||
/* output modes - disable post processing */
|
||||
tty.c_oflag &= ~(OPOST);
|
||||
/* local modes - echoing off, canonical off, no extended functions,
|
||||
* no signal chars (^Z,^C) */
|
||||
tty.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN | ISIG);
|
||||
/* control modes - set 8 bit chars, disable parity handling */
|
||||
tty.c_cflag &= ~(CSIZE | PARENB);
|
||||
tty.c_cflag |= CS8;
|
||||
tty.c_cc[VMIN] = 1;
|
||||
tty.c_cc[VTIME] = 0;
|
||||
/* control chars - set return condition: min number of bytes and timer.
|
||||
* We want read to return every single byte, without timeout. */
|
||||
tty.c_cc[VMIN] = 1; /* 1 byte */
|
||||
tty.c_cc[VTIME] = 0; /* no timer */
|
||||
|
||||
tcsetattr(fileno(s->STDIN), TCSANOW, &tty);
|
||||
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ static VarDef var_table[] = {
|
|||
|
||||
G_VAR( "use-session-file", use_session_file, VAR_NUMBER, VAR_RW )
|
||||
G_VAR( "force-tty", force_tty, VAR_NUMBER, VAR_RW )
|
||||
G_VAR( "disable-crc", disable_crc, VAR_NUMBER, VAR_RW_SAVE )
|
||||
G_VAR( "use-html", use_html, VAR_NUMBER, VAR_RW )
|
||||
|
||||
/* more buffer fields: modified, readonly, binary, charset */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue