qemacs-commit
[Top][All Lists]
Advanced

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

[Qemacs-commit] qemacs qe.c shell.c


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs qe.c shell.c
Date: Sun, 05 Jan 2014 12:51:42 +0000

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        14/01/05 12:51:41

Modified files:
        .              : qe.c shell.c 

Log message:
        small improvements
        
        * show new charset in set-buffer-file-coding-system
        * do not use double negative if/else constructs
        * ignore new extensions in file_completion
        * pass filename to probe_mode, no longer need buffer reference
        * fix support for line drawing characters in utf8 shell window

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.108&r2=1.109
http://cvs.savannah.gnu.org/viewcvs/qemacs/shell.c?cvsroot=qemacs&r1=1.72&r2=1.73

Patches:
Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -b -r1.108 -r1.109
--- qe.c        4 Jan 2014 17:35:12 -0000       1.108
+++ qe.c        5 Jan 2014 12:51:41 -0000       1.109
@@ -1779,6 +1779,7 @@
     if (!charset)
         return;
     eb_set_charset(s->b, charset);
+    put_status(s, "Charset is now %s for this buffer", s->b->charset->name);
 }
 
 /* convert the charset of a buffer to another charset */
@@ -4488,7 +4489,10 @@
             if (e != s && e->b == b1)
                 break;
         }
-        if (!e) {
+        if (e) {
+            /* no need to save mode data */
+            /* CG: bogus! e and s might have different modes */
+        } else {
             /* if no more window uses the buffer, then save the data
                in the buffer */
             /* CG: Should free previous such data ? */
@@ -4508,12 +4512,12 @@
             if (e != s && e->b == b)
                 break;
         }
-        if (!e) {
-            psaved_data = &b->saved_data;
-            saved_data = *psaved_data;
-        } else {
+        if (e) {
             psaved_data = NULL;
             saved_data = e->mode->mode_save_data(e);
+        } else {
+            psaved_data = &b->saved_data;
+            saved_data = *psaved_data;
         }
 
         /* find the mode */
@@ -4654,7 +4658,7 @@
 }
 
 static const char *file_completion_ignore_extensions =
-    "|bak|bin|dll|exe|o|so|obj|a|gz|tgz";
+    "|bak|bin|obj|dll|exe|o|so|a|gz|tgz|bz2|bzip2|xz";
 
 void file_completion(CompleteState *cp)
 {
@@ -5364,30 +5368,29 @@
     splitpath(buf, buf_size, NULL, 0, buf1);
 }
 
-static ModeDef *probe_mode(EditState *s, int st_mode, const uint8_t *buf,
-                           int len, long total_size)
+static ModeDef *probe_mode(EditState *s,
+                           const char *filename, int st_mode, long total_size,
+                           const uint8_t *buf, int len)
 {
     QEmacsState *qs = s->qe_state;
     char fname[MAX_FILENAME_SIZE];
-    EditBuffer *b;
     ModeDef *m, *selected_mode;
     ModeProbeData probe_data;
     int best_probe_score, score;
     const uint8_t *p;
 
-    b = s->b;
-
     selected_mode = NULL;
     best_probe_score = 0;
+
     probe_data.buf = buf;
     probe_data.buf_size = len;
     p = memchr(buf, '\n', len);
     probe_data.line_len = p ? p - buf : len;
-    probe_data.real_filename = b->filename;
+    probe_data.real_filename = filename;
     probe_data.st_mode = st_mode;
     probe_data.total_size = total_size;
     probe_data.filename = reduce_filename(fname, sizeof(fname),
-                                          get_basename(b->filename));
+                                          get_basename(filename));
     /* CG: should pass EditState? QEmacsState ? */
 
     m = qs->first_mode;
@@ -5418,8 +5421,10 @@
     struct stat st;
 
     if (load_resource) {
-        if (find_resource_file(filename, sizeof(filename), filename1))
+        if (find_resource_file(filename, sizeof(filename), filename1)) {
+            /* XXX: issue error message? */
             return;
+        }
     } else {
         /* compute full name */
         canonicalize_absolute_path(filename, sizeof(filename), filename1);
@@ -5471,7 +5476,7 @@
         /* Try to determine the desired mode based on the filename.
          * This avoids having to set c-mode for each new .c or .h file. */
         buf[0] = '\0';
-        selected_mode = probe_mode(s, S_IFREG, buf, 0, 0);
+        selected_mode = probe_mode(s, filename, S_IFREG, 0, buf, 0);
         /* XXX: avoid loading file */
         if (selected_mode)
             edit_set_mode(s, selected_mode);
@@ -5480,6 +5485,7 @@
         st_mode = st.st_mode;
         buf_size = 0;
         f = NULL;
+
         /* CG: should check for ISDIR and do dired */
         if (S_ISREG(st_mode)) {
             f = fopen(filename, "r");
@@ -5495,9 +5501,10 @@
         }
     }
     buf[buf_size] = '\0';
-    selected_mode = probe_mode(s, st_mode, buf, buf_size, st.st_size);
+    selected_mode = probe_mode(s, filename, st_mode, st.st_size, buf, 
buf_size);
     if (!selected_mode)
         goto fail1;
+
     bdt = selected_mode->data_type;
 
     /* autodetect buffer charset (could move it to raw buffer loader) */
@@ -5530,7 +5537,7 @@
     EditState *s = opaque;
     EditBuffer *b = s->b;
     if (size >= 1024 && !b->probed)
-        probe_mode(s, S_IFREG);
+        edit_set_mode(s, probe_mode(s, b->filename, S_IFREG, b->total_size, 
buf, size));
 }
 
 static void load_completion_cb(void *opaque, int err)
@@ -5548,7 +5555,7 @@
         put_status(s, "Could not read file");
     }
     if (!s->b->probed)
-        probe_mode(s, st_mode);
+        edit_set_mode(s, probe_mode(s, b->filename, st_mode, b->total_size, 
buf, size));
     edit_display(s->qe_state);
     dpy_flush(&global_screen);
 }
@@ -5588,6 +5595,9 @@
         return;
     }
     /* CG: file charset will not be converted to buffer charset */
+    /* CG: should load in a separate buffer, auto-detect charset and
+     * copy buffer contents with charset translation
+     */
     size = raw_buffer_load1(s->b, f, s->offset);
     fclose(f);
 

Index: shell.c
===================================================================
RCS file: /sources/qemacs/qemacs/shell.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -b -r1.72 -r1.73
--- shell.c     2 Jan 2014 10:22:48 -0000       1.72
+++ shell.c     5 Jan 2014 12:51:41 -0000       1.73
@@ -822,6 +822,10 @@
                 if (s->shifted && c >= 96 && c < 128) {
 #if 0
                     /* Should actually use these tables: */
+                    static const wchar_t unitab_xterm_poorman[32] =
+                        "*#****o~**+++++-----++++|****L. ";
+#endif
+                    if (s->b->charset == &charset_utf8) {
                     static const wchar_t unitab_xterm_std[32] = {
                         0x2666, 0x2592, 0x2409, 0x240c,
                         0x240d, 0x240a, 0x00b0, 0x00b1,
@@ -832,11 +836,19 @@
                         0x2502, 0x2264, 0x2265, 0x03c0,
                         0x2260, 0x00a3, 0x00b7, 0x0020
                     };
-                    static const wchar_t unitab_xterm_poorman[32] =
-                        "*#****o~**+++++-----++++|****L. ";
-#endif
+                        c = unitab_xterm_std[c - 96];
+                        len = utf8_encode(buf1, c);
+                    } else {
+                        /* CG: quick 8 bit hack: store line drawing
+                         * characters in [96..127] as meta control
+                         * characters in [128..159].
+                         * This hack is reversed in tty_term_flush().
+                         */
                     c += 32;
+                        buf1[0] = c;
+                        len = 1;
                 }
+                } else {
                 /* write char (should factorize with do_char() code */
                 /* CG: Charset support is inherently broken here because
                  * bytes are inserted one at a time and charset conversion
@@ -859,6 +871,7 @@
                 //len = unicode_to_charset(buf1, c, s->b->charset);
                 buf1[0] = c;
                 len = 1;
+                }
                 c1 = eb_nextc(s->b, s->cur_offset, &offset);
                 /* Should simplify with tty_put_char */
                 if (c1 == '\n') {



reply via email to

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