qemacs-commit
[Top][All Lists]
Advanced

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

[Qemacs-commit] qemacs dired.c


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs dired.c
Date: Wed, 26 Aug 2015 01:12:21 +0000

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        15/08/26 01:12:21

Modified files:
        .              : dired.c 

Log message:
        bufed: improve dired display
        - use static colors and styles

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/dired.c?cvsroot=qemacs&r1=1.57&r2=1.58

Patches:
Index: dired.c
===================================================================
RCS file: /sources/qemacs/qemacs/dired.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -b -r1.57 -r1.58
--- dired.c     19 Aug 2015 19:20:57 -0000      1.57
+++ dired.c     26 Aug 2015 01:12:21 -0000      1.58
@@ -26,9 +26,10 @@
 #include <pwd.h>
 
 enum {
+    DIRED_STYLE_NORMAL = QE_STYLE_DEFAULT,
     DIRED_STYLE_HEADER = QE_STYLE_STRING,
     DIRED_STYLE_DIRECTORY = QE_STYLE_COMMENT,
-    DIRED_STYLE_FILE = QE_STYLE_FUNCTION,
+    DIRED_STYLE_FILENAME = QE_STYLE_FUNCTION,
 };
 
 enum { DIRED_HEADER = 2 };
@@ -503,12 +504,17 @@
     eb_clear(b);
 
     if (DIRED_HEADER) {
-        eb_printf(b, "  Directory of %s\n", ds->path);
-        eb_printf(b, "    %d director%s, %d file%s, %lld byte%s\n",
+        b->cur_style = DIRED_STYLE_HEADER;
+        eb_printf(b, "  Directory of ");
+        b->cur_style = DIRED_STYLE_DIRECTORY;
+        eb_printf(b, "%s", ds->path);
+        b->cur_style = DIRED_STYLE_HEADER;
+        eb_printf(b, "\n    %d director%s, %d file%s, %lld byte%s\n",
                   ds->ndirs, ds->ndirs == 1 ? "y" : "ies",
                   ds->nfiles, &"s"[ds->nfiles == 1],
                   (long long)ds->total_bytes, &"s"[ds->total_bytes == 1]);
     }
+    b->cur_style = DIRED_STYLE_NORMAL;
 
     /* XXX: should use screen specific space_width, separator_width or 
em_width */
     ds->last_width = width;
@@ -563,6 +569,11 @@
         }
         ds->fnamecol = col - 1;
 
+        if (S_ISDIR(dip->mode))
+            b->cur_style = DIRED_STYLE_DIRECTORY;
+        else
+            b->cur_style = DIRED_STYLE_FILENAME;
+
         eb_printf(b, "%s", dip->name);
 
         if (1) {
@@ -575,6 +586,7 @@
         &&  getentryslink(buf, sizeof(buf), ds->path, dip->name)) {
             eb_printf(b, " -> %s", buf);
         }
+        b->cur_style = DIRED_STYLE_NORMAL;
         eb_printf(b, "\n");
     }
     b->modified = 0;
@@ -1032,6 +1044,7 @@
             s->b->priv_data = ds;
             s->b->close = dired_close;
 
+            eb_create_style_buffer(b, BF_STYLE1);
             /* XXX: should be built by buffer_load API */
             dired_build_list(ds, s->b->filename, NULL, s->b, s);
             /* XXX: File system charset should be detected automatically */
@@ -1061,36 +1074,6 @@
         return 0;
 }
 
-static void dired_colorize_line(QEColorizeContext *cp,
-                                unsigned int *str, int n, ModeDef *syn)
-{
-    int i = 0, start = i, style;
-
-    if (ustrstart(str + start, "  Directory of ", &i)) {
-        i += start;
-        SET_COLOR(str, start, i, DIRED_STYLE_HEADER);
-        style = DIRED_STYLE_DIRECTORY;
-        start = i;
-        i = n;
-        SET_COLOR(str, start, i, style);
-    } else
-    if (n >= 6 && ustrstart(str + n - 6, " bytes", NULL)) {
-        style = DIRED_STYLE_HEADER;
-        i = n;
-        SET_COLOR(str, start, i, style);
-    } else {
-        style = DIRED_STYLE_FILE;
-        if (n > 0 && str[n - 1] == '/')
-            style = DIRED_STYLE_DIRECTORY;
-        for (start = n; start > 2; start--) {
-            if (str[start - 1] == ' ' && str[start - 2] == ' ')
-                break;
-        }
-        i = n;
-        SET_COLOR(str, start, i, style);
-    }
-}
-
 /* open dired window on the left. The directory of the current file is
    used */
 void do_dired(EditState *s)
@@ -1214,7 +1197,6 @@
     dired_mode.name = "dired";
     dired_mode.mode_probe = dired_mode_probe;
     dired_mode.mode_init = dired_mode_init;
-    dired_mode.colorize_func = dired_colorize_line;
     /* CG: not a good idea, display hook has side effect on layout */
     dired_mode.display_hook = dired_display_hook;
 



reply via email to

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