qemacs-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemacs-commit] qemacs qe.c qe.h qestyles.h shell.c tty.c varia...


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs qe.c qe.h qestyles.h shell.c tty.c varia...
Date: Wed, 21 Oct 2020 05:55:02 -0400 (EDT)

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        20/10/21 05:55:02

Modified files:
        .              : qe.c qe.h qestyles.h shell.c tty.c variables.c 

Log message:
        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

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.299&r2=1.300
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.280&r2=1.281
http://cvs.savannah.gnu.org/viewcvs/qemacs/qestyles.h?cvsroot=qemacs&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/qemacs/shell.c?cvsroot=qemacs&r1=1.143&r2=1.144
http://cvs.savannah.gnu.org/viewcvs/qemacs/tty.c?cvsroot=qemacs&r1=1.91&r2=1.92
http://cvs.savannah.gnu.org/viewcvs/qemacs/variables.c?cvsroot=qemacs&r1=1.28&r2=1.29

Patches:
Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.299
retrieving revision 1.300
diff -u -b -r1.299 -r1.300
--- qe.c        17 Oct 2020 21:09:49 -0000      1.299
+++ qe.c        21 Oct 2020 09:55:01 -0000      1.300
@@ -71,6 +71,7 @@
 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 @@
                     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 @@
             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 @@
     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,

Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.280
retrieving revision 1.281
diff -u -b -r1.280 -r1.281
--- qe.h        17 Oct 2020 21:09:49 -0000      1.280
+++ qe.h        21 Oct 2020 09:55:01 -0000      1.281
@@ -1364,6 +1364,8 @@
 
 /* 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 @@
 #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 */
 

Index: qestyles.h
===================================================================
RCS file: /sources/qemacs/qemacs/qestyles.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- qestyles.h  9 Oct 2020 00:00:55 -0000       1.14
+++ qestyles.h  21 Oct 2020 09:55:01 -0000      1.15
@@ -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 */

Index: shell.c
===================================================================
RCS file: /sources/qemacs/qemacs/shell.c,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -b -r1.143 -r1.144
--- shell.c     20 Oct 2020 08:44:46 -0000      1.143
+++ shell.c     21 Oct 2020 09:55:02 -0000      1.144
@@ -3092,6 +3092,14 @@
             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 @@
     /* 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);

Index: tty.c
===================================================================
RCS file: /sources/qemacs/qemacs/tty.c,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -b -r1.91 -r1.92
--- tty.c       17 Oct 2020 21:09:49 -0000      1.91
+++ tty.c       21 Oct 2020 09:55:02 -0000      1.92
@@ -276,14 +276,22 @@
     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);
 

Index: variables.c
===================================================================
RCS file: /sources/qemacs/qemacs/variables.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- variables.c 17 Oct 2020 21:09:49 -0000      1.28
+++ variables.c 21 Oct 2020 09:55:02 -0000      1.29
@@ -79,6 +79,7 @@
 
     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 */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]