qemacs-commit
[Top][All Lists]
Advanced

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

[Qemacs-commit] qemacs x11.c


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs x11.c
Date: Sun, 25 Dec 2016 18:39:31 -0500 (EST)

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        16/12/25 18:39:31

Modified files:
        .              : x11.c 

Log message:
        x11: add x11-list-fonts on C-h f

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/x11.c?cvsroot=qemacs&r1=1.42&r2=1.43

Patches:
Index: x11.c
===================================================================
RCS file: /sources/qemacs/qemacs/x11.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- x11.c       26 Jul 2016 09:43:14 -0000      1.42
+++ x11.c       25 Dec 2016 23:39:30 -0000      1.43
@@ -180,8 +180,7 @@
 
     /* if no env variable DISPLAY, we do not use x11 */
     dpy = getenv("DISPLAY");
-    if (dpy == NULL ||
-        dpy[0] == '\0')
+    if (dpy == NULL || dpy[0] == '\0')
         return 0;
     return 1;
 }
@@ -560,6 +559,7 @@
     slant = XFT_SLANT_ROMAN;
     if (style & QE_STYLE_ITALIC)
         slant = XFT_SLANT_ITALIC;
+
     renderFont = XftFontOpen(display, xscreen,
                              XFT_FAMILY, XftTypeString, family,
                              XFT_SIZE, XftTypeInteger, size,
@@ -1873,6 +1873,45 @@
     NULL, /* next */
 };
 
+static void x11_list_fonts(EditState *s, int argval)
+{
+    char buf[80];
+    EditBuffer *b;
+    int show, i, count;
+    char **list;
+
+    b = new_help_buffer(&show);
+    if (!b)
+        return;
+
+    if (argval == NO_ARG) {
+        snprintf(buf, sizeof(buf), "-*-*-*-*-*-*-*-*-*-*-*-*-iso10646-1");
+    } else {
+        snprintf(buf, sizeof(buf), "-*-*-*-*-*-*-*-%d-*-*-*-*-iso10646-1", 
argval);
+    }
+    list = XListFonts(display, buf, 20000, &count);
+
+    eb_printf(b, "X11 Font list: %d entries\n\n", count);
+
+    for (i = 0; i < count; i++) {
+        eb_printf(b, "%d: %s\n", i, list[i]);
+    }
+    XFreeFontNames(list);
+
+    b->flags |= BF_READONLY;
+    if (show) {
+        show_popup(b);
+    }
+}
+
+static CmdDef x11_commands[] = {
+
+    CMD2( KEY_CTRLH('f'), KEY_CTRLH(KEY_CTRL('F')),
+          "x11-list-fonts", x11_list_fonts, ESi, "ui")
+
+    CMD_DEF_END,
+};
+
 static CmdOptionDef cmd_options[] = {
     { "display", "d", "display", CMD_OPT_STRING | CMD_OPT_ARG, "set X11 
display",
       { .string_ptr = &display_str }},
@@ -1886,6 +1925,7 @@
 static int x11_init(void)
 {
     qe_register_cmd_line_options(cmd_options);
+    qe_register_cmd_table(x11_commands, NULL);
     if (force_tty)
         return 0;
     return qe_register_display(&x11_dpy);



reply via email to

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