qemacs-commit
[Top][All Lists]
Advanced

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

[Qemacs-commit] qemacs TODO.org dired.c qe.c qe.h qeconfig.h qe...


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs TODO.org dired.c qe.c qe.h qeconfig.h qe...
Date: Wed, 10 May 2017 11:46:17 -0400 (EDT)

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        17/05/10 11:46:17

Modified files:
        .              : TODO.org dired.c qe.c qe.h qeconfig.h 
                         qestyles.h shell.c 

Log message:
        display: fix various old bugs
        - add st_errno in ModeProbeData so dired only matches wildcards if no
          file exists with that exact name (argument passed probe_mode())
        - add LF_NOWILDCARD qe_load_file flag to prevent wildcard handling
        - display line numbers and terminal right margin in new gutter style
        - free EditState:line_shadow display CRCs when changing modes:
          this fixes an old display bug when switching between html and text 
mode
        - added convenient default bindings:
          C-c ~     -> toggle-read-only
          C-c c     -> set-buffer-file-coding-system
          C-c b     -> toggle-bidir
          C-c C-\   -> set-input-method
          C-c l     -> toggle-line-numbers
          C-c t     -> toggle-truncate-lines
          C-c w     -> word-wrap
        - disable terminal emulation on shell buffers without the SF_COLOR flag
        - only update mark on process output in interactive terminal emulator 
buffers
        - only compute shell current directory on terminal emulator buffers
        - auto select mode and character set after 3MB of output
        - update wrap_cols on all windows upon shell-refresh (C-l in shell-mode)
        - improve shell_get_curpath(): handle debian default prompt
        - updated TODOs

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/TODO.org?cvsroot=qemacs&r1=1.39&r2=1.40
http://cvs.savannah.gnu.org/viewcvs/qemacs/dired.c?cvsroot=qemacs&r1=1.80&r2=1.81
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.284&r2=1.285
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.264&r2=1.265
http://cvs.savannah.gnu.org/viewcvs/qemacs/qeconfig.h?cvsroot=qemacs&r1=1.70&r2=1.71
http://cvs.savannah.gnu.org/viewcvs/qemacs/qestyles.h?cvsroot=qemacs&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/qemacs/shell.c?cvsroot=qemacs&r1=1.134&r2=1.135

Patches:
Index: TODO.org
===================================================================
RCS file: /sources/qemacs/qemacs/TODO.org,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- TODO.org    25 Apr 2017 17:41:27 -0000      1.39
+++ TODO.org    10 May 2017 15:46:16 -0000      1.40
@@ -1,7 +1,7 @@
 ; TODO list for qemacs
 ;
 ; Author: Charles Gordon
-; Updated: 2017-04-24
+; Updated: 2017-05-10
 
 * Recent bugs and ideas
 
@@ -636,4 +636,10 @@
 find-file-read-only-other-window on C-x 4 r
 save-modified-buffers on C-x s
 show-matching-delimiters
-
+vim-mode on .vim*
+toggle-full-screen -> unsupported if screen->dpy_full_screen is NULL
+find-file: should support scp syntax for remote loading
+ssh: should use the host name and get files via scp syntax
+charset: set-eol-type should take a string: auto/binary/dos/unix/mac/0/1/2...
+archive: use window/buffer caption for output description
+files: handle files with embedded spaces

Index: dired.c
===================================================================
RCS file: /sources/qemacs/qemacs/dired.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -b -r1.80 -r1.81
--- dired.c     8 May 2017 10:47:23 -0000       1.80
+++ dired.c     10 May 2017 15:46:16 -0000      1.81
@@ -1070,7 +1070,7 @@
      * new buffer as BF_PREVIEW, to trigger paging mode and so that it
      * will get freed if closed.
      */
-    rc = qe_load_file(e, filename, 0, BF_PREVIEW);
+    rc = qe_load_file(e, filename, LF_NOWILDCARD, BF_PREVIEW);
     if (rc >= 0) {
         return e;
     } else {
@@ -1242,7 +1242,7 @@
     if (S_ISDIR(p->st_mode))
         return 95;
 
-    if (is_filepattern(p->real_filename))
+    if (p->st_errno == ENOENT && is_filepattern(p->real_filename))
         return 90;
 
     return 0;

Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.284
retrieving revision 1.285
diff -u -b -r1.284 -r1.285
--- qe.c        8 May 2017 10:47:23 -0000       1.284
+++ qe.c        10 May 2017 15:46:16 -0000      1.285
@@ -3181,23 +3181,24 @@
     ds->default_line_height = font->ascent + font->descent;
     ds->space_width = glyph_width(e->screen, font, ' ');
     ds->tab_width = ds->space_width * e->b->tab_width;
+    ds->height = e->height;
+    ds->hex_mode = e->hex_mode;
+    ds->cur_hex_mode = 0;
+    ds->y = e->y_disp;
+    ds->line_num = 0;
+    ds->line_numbers = e->line_numbers * ds->space_width * 8;
+    if (ds->line_numbers > e->width / 2)
+        ds->line_numbers = 0;
     if (ds->wrap == WRAP_TERM) {
         ds->eol_width = 0;
-        ds->width = e->wrap_cols * glyph_width(e->screen, font, '0');
+        ds->width = ds->line_numbers +
+            e->wrap_cols * glyph_width(e->screen, font, '0');
     } else {
         ds->eol_width = max3(glyph_width(e->screen, font, '/'),
                              glyph_width(e->screen, font, '\\'),
                              glyph_width(e->screen, font, '$'));
         ds->width = e->width - ds->eol_width;
     }
-    ds->height = e->height;
-    ds->hex_mode = e->hex_mode;
-    ds->cur_hex_mode = 0;
-    ds->y = e->y_disp;
-    ds->line_num = 0;
-    ds->line_numbers = e->line_numbers * ds->space_width * 8;
-    if (ds->line_numbers > ds->width / 2)
-        ds->line_numbers = 0;
     ds->eol_reached = 0;
     ds->eod = 0;
     display_bol(ds);
@@ -3345,9 +3346,9 @@
             /* XXX: should coalesce rectangles with identical style */
             if (ds->left_gutter > 0) {
                 /* erase space before the line display, aka left gutter */
+                get_style(e, &styledef, QE_STYLE_GUTTER);
                 fill_rectangle(screen, e->xleft + x, e->ytop + y,
-                               ds->left_gutter, line_height,
-                               default_style.bg_color);
+                               ds->left_gutter, line_height, 
styledef.bg_color);
             }
             x = ds->x_line;
             x1 = ds->width + ds->eol_width;
@@ -3359,9 +3360,16 @@
                 x += frag->width;
             }
             if (x < x1 && last != -1) {
+                /* XXX: color may be inappropriate for terminal mode */
                 fill_rectangle(screen, e->xleft + x, e->ytop + y,
                                x1 - x, line_height, default_style.bg_color);
             }
+            if (x1 < e->width) {
+                /* right gutter like space beyond terminal right margin */
+                get_style(e, &styledef, QE_STYLE_GUTTER);
+                fill_rectangle(screen, e->xleft + x1, e->ytop + y,
+                               e->width - x1, line_height, styledef.bg_color);
+            }
 
             /* then display text */
             x = ds->x_line;
@@ -4198,12 +4206,12 @@
 
     /* line numbers */
     if (ds->line_numbers) {
-        ds->style = QE_STYLE_COMMENT;
+        ds->style = QE_STYLE_GUTTER;
         display_printf(ds, -1, -1, "%6d  ", line_num + 1);
         ds->style = 0;
     }
 
-    /* prompt display */
+    /* prompt display, only on first line */
     if (s->prompt && offset1 == 0) {
         const char *p = s->prompt;
 
@@ -6768,8 +6776,8 @@
 static int probe_mode(EditState *s, EditBuffer *b,
                       ModeDef **modes, int nb_modes,
                       int *scores, int min_score,
-                      const char *filename, int st_mode, long total_size,
-                      const uint8_t *rawbuf, int len,
+                      const char *filename, int st_errno, int st_mode,
+                      long total_size, const uint8_t *rawbuf, int len,
                       QECharset *charset, EOLType eol_type)
 {
     u8 buf[4097];
@@ -6791,6 +6799,7 @@
     probe_data.buf = buf;
     probe_data.buf_size = len;
     probe_data.real_filename = filename;
+    probe_data.st_errno = st_errno;
     probe_data.st_mode = st_mode;
     probe_data.total_size = total_size;
     probe_data.filename = reduce_filename(fname, sizeof(fname),
@@ -6944,7 +6953,7 @@
     buf[size] = '\0';
 
     nb = probe_mode(s, b, modes, countof(modes), scores, 2,
-                    b->filename, b->st_mode, b->total_size,
+                    b->filename, 0, b->st_mode, b->total_size,
                     buf, size, b->charset, b->eol_type);
     found = 0;
     if (dir && nb > 0) {
@@ -6988,7 +6997,8 @@
      * file pattern into the same pane, but load a regular file into the view 
pane
      */
     if ((s->flags & WF_POPUP)
-    ||  (!is_directory(filename) && !is_filepattern(filename))) {
+    ||  (!is_directory(filename) &&
+         ((lflags & LF_NOWILDCARD) || !is_filepattern(filename)))) {
         s = qe_find_target_window(s, 1);
     }
 #endif
@@ -7042,6 +7052,7 @@
 
     /* First we try to read the first block to determine the data type */
     if (stat(filename, &st) < 0) {
+        int st_errno = errno;
         /* XXX: default charset should be selectable.  Should have auto
          * charset transparent support for both utf8 and latin1.
          * Use utf8 for now */
@@ -7052,7 +7063,7 @@
         buf[0] = '\0';
         buf_size = 0;
         probe_mode(s, b, &selected_mode, 1, &mode_score, 2,
-                   b->filename, b->st_mode, b->total_size,
+                   b->filename, st_errno, b->st_mode, b->total_size,
                    buf, buf_size, b->charset, b->eol_type);
 
         /* Attach buffer to window, will set default_mode
@@ -7085,7 +7096,7 @@
         }
         buf[buf_size] = '\0';
         if (!probe_mode(s, b, &selected_mode, 1, &mode_score, 2,
-                        filename, b->st_mode, st.st_size,
+                        filename, 0, b->st_mode, st.st_size,
                         buf, buf_size, charset, eol_type)) {
             fclose(f);
             f = NULL;
@@ -8367,6 +8378,10 @@
     set_colorize_func(s, NULL);
     eb_free_callback(s->b, eb_offset_callback, &s->offset);
     eb_free_callback(s->b, eb_offset_callback, &s->offset_top);
+
+    /* Free crcs should when switching display modes */
+    qe_free(&s->line_shadow);
+    s->shadow_nb_lines = 0;
 }
 
 ModeDef text_mode = {

Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.264
retrieving revision 1.265
diff -u -b -r1.264 -r1.265
--- qe.h        8 May 2017 10:47:23 -0000       1.264
+++ qe.h        10 May 2017 15:46:16 -0000      1.265
@@ -1481,6 +1481,7 @@
     const u8 *buf;
     int buf_size;
     int line_len;
+    int st_errno;    /* errno from the stat system call */
     int st_mode;     /* unix file mode */
     long total_size;
     EOLType eol_type;
@@ -2023,6 +2024,7 @@
 #define LF_CWD_RELATIVE   0x04
 #define LF_SPLIT_WINDOW   0x08
 #define LF_NOSELECT       0x10
+#define LF_NOWILDCARD     0x20
 int qe_load_file(EditState *s, const char *filename, int lflags, int bflags);
 
 /* config file support */

Index: qeconfig.h
===================================================================
RCS file: /sources/qemacs/qemacs/qeconfig.h,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -b -r1.70 -r1.71
--- qeconfig.h  3 May 2017 10:50:49 -0000       1.70
+++ qeconfig.h  10 May 2017 15:46:16 -0000      1.71
@@ -164,7 +164,7 @@
           "kill-buffer", do_kill_buffer, ESsi, 0,
           "s{Kill buffer: }[buffer]|buffer|"
           "v")
-    CMD0( KEY_CTRLX(KEY_CTRL('q')), KEY_NONE,
+    CMD0( KEY_CTRLX(KEY_CTRL('q')), KEY_CTRLC('~'),
           "toggle-read-only", do_toggle_read_only)
     CMD2( KEY_META('~'), KEY_NONE,
           "not-modified", do_not_modified, ESi, "ui")
@@ -299,15 +299,15 @@
 
     /*---------------- International ----------------*/
 
-    CMD2( KEY_CTRLXRET('f'), KEY_NONE,
+    CMD2( KEY_CTRLXRET('f'), KEY_CTRL('c'),
           "set-buffer-file-coding-system", do_set_buffer_file_coding_system, 
ESs,
           "s{Charset: }[charset]|charset|")
     CMD2( KEY_NONE, KEY_NONE,
           "convert-buffer-file-coding-system", 
do_convert_buffer_file_coding_system, ESs,
           "*" "s{Charset: }[charset]|charset|")
-    CMD0( KEY_CTRLXRET('b'), KEY_NONE,
+    CMD0( KEY_CTRLXRET('b'), KEY_CTRL('b'),
           "toggle-bidir", do_toggle_bidir)
-    CMD2( KEY_CTRLXRET(KEY_CTRL('\\')), KEY_NONE,
+    CMD2( KEY_CTRLXRET(KEY_CTRL('\\')), KEY_CTRLC(KEY_CTRL('\\')),
           "set-input-method", do_set_input_method, ESs,
           "s{Input method: }[input]")
     CMD0( KEY_CTRLX(KEY_CTRL('\\')), KEY_NONE,
@@ -358,11 +358,11 @@
           "what-cursor-position", do_what_cursor_position)
 
     /* non standard mappings */
-    CMD0( KEY_CTRLXRET('l'), KEY_NONE,
+    CMD0( KEY_CTRLXRET('l'), KEY_CTRLC('l'),
           "toggle-line-numbers", do_toggle_line_numbers)
-    CMD0( KEY_CTRLXRET('t'), KEY_NONE,
+    CMD0( KEY_CTRLXRET('t'), KEY_CTRLC('t'),
           "toggle-truncate-lines", do_toggle_truncate_lines)
-    CMD0( KEY_CTRLXRET('w'), KEY_NONE,
+    CMD0( KEY_CTRLXRET('w'), KEY_CTRLC('w'),
           "word-wrap", do_word_wrap)
     CMD1( KEY_NONE, KEY_NONE,
           "toggle-control-h", do_toggle_control_h, 0)

Index: qestyles.h
===================================================================
RCS file: /sources/qemacs/qemacs/qestyles.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- qestyles.h  11 Apr 2017 06:46:13 -0000      1.12
+++ qestyles.h  10 May 2017 15:46:17 -0000      1.13
@@ -16,6 +16,9 @@
     STYLE_DEF(QE_STYLE_STATUS, "status",
               QERGB(0xff, 0xff, 0x00), COLOR_TRANSPARENT,
               0, 0)
+    STYLE_DEF(QE_STYLE_GUTTER, "gutter",
+              QERGB(0xf8, 0x44, 0x00), QERGB(0x3f, 0x3f, 0x3f),
+              0, 0)
 
     /* default style for HTML/CSS2 pages */
     STYLE_DEF(QE_STYLE_CSS_DEFAULT, "css-default",

Index: shell.c
===================================================================
RCS file: /sources/qemacs/qemacs/shell.c,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -b -r1.134 -r1.135
--- shell.c     8 May 2017 10:47:23 -0000       1.134
+++ shell.c     10 May 2017 15:46:17 -0000      1.135
@@ -1859,39 +1859,32 @@
 {
     ShellState *s = opaque;
     QEmacsState *qs;
+    EditBuffer *b;
     unsigned char buf[16 * 1024];
-    int len, i;
+    int len, i, save_readonly;
 
     if (!s || s->base.mode != &shell_mode)
         return;
 
-    qs = s->qe_state;
     len = read(s->pty_fd, buf, sizeof(buf));
     if (len <= 0)
         return;
 
-    if (qs->trace_buffer)
+    b = s->b;
+    qs = s->qe_state;
+    if (qs->trace_buffer) {
         eb_trace_bytes(buf, len, EB_TRACE_SHELL);
+    }
 
-    {
         /* Suspend BF_READONLY flag to allow shell output to readonly buffer */
-        int save_readonly = s->b->flags & BF_READONLY;
-        s->b->flags &= ~BF_READONLY;
-        s->b->last_log = 0;
-
-#if 0
-        /* XXX: tty emulation should be optional */
-        if (!emulate) {
-            eb_write(s->b, s->b->total_size, buf, len);
-        } else
-#endif
-        for (i = 0; i < len; i++)
+    save_readonly = b->flags & BF_READONLY;
+    b->flags &= ~BF_READONLY;
+    b->last_log = 0;
+
+    if (s->shell_flags & SF_COLOR) {
+        /* optional terminal emulation (shell, ssh, make, latex, man modes) */
+        for (i = 0; i < len; i++) {
             qe_term_emulate(s, buf[i]);
-
-        if (save_readonly) {
-            s->b->modified = 0;
-            s->b->flags |= save_readonly;
-        }
     }
     if (s->last_char == '\000' || s->last_char == '\001'
     ||  s->last_char == '\003'
@@ -1902,11 +1895,37 @@
          * prompting for input and save the current input position as
          * the start of input.
          */
-        s->b->mark = s->cur_prompt = s->cur_offset;
+            s->cur_prompt = s->cur_offset;
+            if (qs->active_window
+            &&  qs->active_window->b == b
+            &&  qs->active_window->interactive) {
+                /* Set mark to potential tentative position (useful?) */
+                b->mark = s->cur_prompt;
+            }
+        }
+        shell_get_curpath(b, s->cur_offset, s->curpath, sizeof(s->curpath));
+    } else {
+        int pos = b->total_size;
+        int threshold = 3 << 20;    /* 3MB for large pictures */
+        eb_write(b, b->total_size, buf, len);
+        if (pos < threshold && pos + len >= threshold) {
+            EditState *e;
+            for (e = qs->first_window; e != NULL; e = e->next_window) {
+                if (e->b == b) {
+                    if (s->shell_flags & SF_AUTO_CODING)
+                        do_set_auto_coding(e, 0);
+                    if (s->shell_flags & SF_AUTO_MODE)
+                        qe_set_next_mode(e, 0, 0);
+                }
+            }
+        }
+    }
+    if (save_readonly) {
+        b->modified = 0;
+        b->flags |= save_readonly;
     }
-    shell_get_curpath(s->b, s->cur_offset, s->curpath, sizeof(s->curpath));
 
-    /* now we do some refresh */
+    /* now we do some refresh (should just invalidate?) */
     edit_display(qs);
     dpy_flush(qs->screen);
 }
@@ -2006,13 +2025,14 @@
     s->grab_keys = 0;
     qe_ungrab_keys();
     for (e = qs->first_window; e != NULL; e = e->next_window) {
-        if (e->b == b)
+        if (e->b == b) {
             e->interactive = 0;
         if (s->shell_flags & SF_AUTO_CODING)
             do_set_auto_coding(e, 0);
         if (s->shell_flags & SF_AUTO_MODE)
             qe_set_next_mode(e, 0, 0);
     }
+    }
     if (!(s->shell_flags & SF_INTERACTIVE)) {
         /* Must Unlink the shell data to avoid potential crash */
         //shell_mode_free(b, s);  // called by qe_free_mode_data
@@ -2647,9 +2667,19 @@
     ShellState *s;
 
     if ((s = shell_get_state(e, 1)) != NULL) {
+        QEmacsState *qs = e->qe_state;
+        EditState *e1;
+
         /* update the terminal size and notify process */
         s->cols = e->wrap_cols = e->cols;
         s->rows = e->rows;
+
+        for (e1 = qs->first_window; e1 != NULL; e1 = e1->next_window) {
+            if (e1->b == e->b) {
+                e1->wrap_cols = s->cols;
+            }
+        }
+
         if (s->pty_fd > 0) {
             struct winsize ws;
             ws.ws_col = s->cols;
@@ -2694,21 +2724,24 @@
 {
     char line[1024];
     char curpath[MAX_FILENAME_SIZE];
-    int start, first_blank, last_blank, stop, i, len;
+    int start, last_blank, stop, i, len;
     
     len = eb_fgets(b, line, sizeof(line), eb_goto_bol(b, offset), &offset);
     line[len] = '\0';   /* strip the trailing newline if any */
 
-    first_blank = last_blank = 0;
+    start = 0;
+    last_blank = 0;
     for (i = 0;; i++) {
         int c = line[i];
         if (c == '\0')
             return NULL;
-        if (c == '$' || c == '>')
+        if (c == '#' || c == '$' || c == '>')
             break;
+        if (c == ':' && !start)
+            start = i + 1;
         if (c == ' ') {
-            if (!first_blank)
-                first_blank = i + 1;
+            if (!start)
+                start = i + 1;
             last_blank = i;
         }
     }
@@ -2716,10 +2749,6 @@
     if (last_blank == i - 1)
         stop = last_blank;
 
-    start = 0;
-    if (first_blank < last_blank)
-        start = first_blank;
-
     line[stop] = '\0';
 
     if (start == stop)



reply via email to

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