qemacs-commit
[Top][All Lists]
Advanced

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

[Qemacs-commit] qemacs bufed.c clang.c parser.c qe.h buffer.c e...


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs bufed.c clang.c parser.c qe.h buffer.c e...
Date: Sun, 26 Mar 2017 11:57:25 -0400 (EDT)

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        17/03/26 11:57:24

Modified files:
        .              : bufed.c clang.c parser.c qe.h buffer.c extras.c 
                         qe.c x11.c 

Log message:
        basic: changed API for popup windows
        - pass current window to show_popup()
        - remove show_ptr argument from new_help_buffer()
        - call show_popup() unconditionally
        - add int eb_vprintf(EditBuffer *b, const char *fmt, va_list ap);

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/bufed.c?cvsroot=qemacs&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/qemacs/clang.c?cvsroot=qemacs&r1=1.116&r2=1.117
http://cvs.savannah.gnu.org/viewcvs/qemacs/parser.c?cvsroot=qemacs&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.241&r2=1.242
http://cvs.savannah.gnu.org/viewcvs/qemacs/buffer.c?cvsroot=qemacs&r1=1.106&r2=1.107
http://cvs.savannah.gnu.org/viewcvs/qemacs/extras.c?cvsroot=qemacs&r1=1.59&r2=1.60
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.256&r2=1.257
http://cvs.savannah.gnu.org/viewcvs/qemacs/x11.c?cvsroot=qemacs&r1=1.46&r2=1.47

Patches:
Index: bufed.c
===================================================================
RCS file: /sources/qemacs/qemacs/bufed.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- bufed.c     25 Mar 2017 18:14:59 -0000      1.43
+++ bufed.c     26 Mar 2017 15:57:24 -0000      1.44
@@ -286,7 +286,7 @@
     if (!b)
         return;
 
-    e = show_popup(b);
+    e = show_popup(s, b);
     if (!e)
         return;
 

Index: clang.c
===================================================================
RCS file: /sources/qemacs/qemacs/clang.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -b -r1.116 -r1.117
--- clang.c     25 Mar 2017 18:00:52 -0000      1.116
+++ clang.c     26 Mar 2017 15:57:24 -0000      1.117
@@ -1162,7 +1162,7 @@
         }
     }
     if (b->total_size > 0) {
-        show_popup(b);
+        show_popup(s, b);
     } else {
         eb_free(&b);
         put_status(s, "Not in a #if conditional");

Index: parser.c
===================================================================
RCS file: /sources/qemacs/qemacs/parser.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- parser.c    25 Mar 2017 18:15:01 -0000      1.7
+++ parser.c    26 Mar 2017 15:57:24 -0000      1.8
@@ -419,7 +419,7 @@
         b->flags |= BF_READONLY;
 
         /* Should show window caption "qemacs session" */
-        show_popup(b);
+        show_popup(s, b);
     } else {
         eb_write_buffer(b, 0, b->total_size, ".qesession");
         eb_free(&b);

Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.241
retrieving revision 1.242
diff -u -b -r1.241 -r1.242
--- qe.h        25 Mar 2017 18:00:52 -0000      1.241
+++ qe.h        26 Mar 2017 15:57:24 -0000      1.242
@@ -1061,6 +1061,7 @@
 int eb_match_uchar(EditBuffer *b, int offset, int c, int *offsetp);
 int eb_match_str(EditBuffer *b, int offset, const char *str, int *offsetp);
 int eb_match_istr(EditBuffer *b, int offset, const char *str, int *offsetp);
+int eb_vprintf(EditBuffer *b, const char *fmt, va_list ap) 
qe__attr_printf(2,0);
 int eb_printf(EditBuffer *b, const char *fmt, ...) qe__attr_printf(2,3);
 int eb_puts(EditBuffer *b, const char *s);
 int eb_putc(EditBuffer *b, int c);
@@ -1842,7 +1843,7 @@
 void do_add_resource_path(EditState *s, const char *path);
 
 /* popup / low level window handling */
-EditState *show_popup(EditBuffer *b);
+EditState *show_popup(EditState *s, EditBuffer *b);
 int check_read_only(EditState *s);
 EditState *insert_window_left(EditBuffer *b, int width, int flags);
 EditState *find_window(EditState *s, int key, EditState *def);
@@ -2069,7 +2070,7 @@
 void do_describe_key_briefly(EditState *s);
 void do_show_bindings(EditState *s, const char *cmd_name);
 void do_apropos(EditState *s, const char *str);
-EditBuffer *new_help_buffer(int *show_ptr);
+EditBuffer *new_help_buffer(void);
 void do_describe_bindings(EditState *s);
 void do_help_for_help(EditState *s);
 void qe_event_init(void);

Index: buffer.c
===================================================================
RCS file: /sources/qemacs/qemacs/buffer.c,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -b -r1.106 -r1.107
--- buffer.c    25 Mar 2017 18:14:59 -0000      1.106
+++ buffer.c    26 Mar 2017 15:57:24 -0000      1.107
@@ -2213,20 +2213,19 @@
     return eb_insert_utf8_buf(b, b->total_size, s, strlen(s));
 }
 
-int eb_printf(EditBuffer *b, const char *fmt, ...)
+int eb_vprintf(EditBuffer *b, const char *fmt, va_list ap)
 {
     char buf0[1024];
     char *buf;
     int len, size, written;
-    va_list ap;
+    va_list ap2;
 
-    va_start(ap, fmt);
+    va_copy(ap2, ap);
     size = sizeof(buf0);
     buf = buf0;
-    len = vsnprintf(buf, size, fmt, ap);
-    va_end(ap);
+    len = vsnprintf(buf, size, fmt, ap2);
+    va_end(ap2);
     if (len >= size) {
-        va_start(ap, fmt);
         size = len + 1;
 #ifdef CONFIG_WIN32
         buf = qe_malloc_bytes(size);
@@ -2234,7 +2233,6 @@
         buf = alloca(size);
 #endif
         vsnprintf(buf, size, fmt, ap);
-        va_end(ap);
     }
     /* CG: insert buf encoding according to b->charset and b->eol_type.
      * buf may contain \0 characters via the %c modifer.
@@ -2248,6 +2246,17 @@
     return written;
 }
 
+int eb_printf(EditBuffer *b, const char *fmt, ...)
+{
+    va_list ap;
+    int written;
+
+    va_start(ap, fmt);
+    written = eb_vprintf(b, fmt, ap);
+    va_end(ap);
+    return written;
+}
+
 #if 0
 /* pad current line with spaces so that it reaches column n */
 void eb_line_pad(EditBuffer *b, int n)

Index: extras.c
===================================================================
RCS file: /sources/qemacs/qemacs/extras.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -b -r1.59 -r1.60
--- extras.c    19 Mar 2017 13:20:34 -0000      1.59
+++ extras.c    26 Mar 2017 15:57:24 -0000      1.60
@@ -912,9 +912,8 @@
 void do_describe_bindings(EditState *s)
 {
     EditBuffer *b;
-    int show;
 
-    b = new_help_buffer(&show);
+    b = new_help_buffer();
     if (!b)
         return;
 
@@ -922,9 +921,7 @@
     print_bindings(b, "\nGlobal bindings", 0, NULL);
 
     b->flags |= BF_READONLY;
-    if (show) {
-        show_popup(b);
-    }
+    show_popup(s, b);
 }
 
 void do_apropos(EditState *s, const char *str)
@@ -934,11 +931,12 @@
     EditBuffer *b;
     CmdDef *d;
     VarDef *vp;
-    int found, show;
+    int found;
 
-    b = new_help_buffer(&show);
+    b = new_help_buffer();
     if (!b)
         return;
+
     eb_printf(b, "apropos '%s':\n\n", str);
 
     found = 0;
@@ -973,11 +971,8 @@
     }
     if (found) {
         b->flags |= BF_READONLY;
-        if (show) {
-            show_popup(b);
-        }
+        show_popup(s, b);
     } else {
-        if (show)
             eb_free(&b);
         put_status(s, "No apropos matches for `%s'", str);
     }
@@ -1035,7 +1030,7 @@
     b->flags |= BF_READONLY;
 
     /* Should show window caption "About QEmacs" */
-    show_popup(b);
+    show_popup(s, b);
 }
 
 static void do_set_region_color(EditState *s, const char *str)
@@ -1107,9 +1102,8 @@
     buf_t descbuf, *desc;
     EditBuffer *b = s->b;
     EditBuffer *b1;
-    int show;
 
-    b1 = new_help_buffer(&show);
+    b1 = new_help_buffer();
     if (!b1)
         return;
 
@@ -1299,18 +1293,15 @@
     }
 
     b1->flags |= BF_READONLY;
-    if (show) {
-        show_popup(b1);
-    }
+    show_popup(s, b1);
 }
 
 static void do_describe_window(EditState *s, int argval)
 {
     EditBuffer *b1;
-    int show;
     int w;
 
-    b1 = new_help_buffer(&show);
+    b1 = new_help_buffer();
     if (!b1)
         return;
 
@@ -1369,19 +1360,16 @@
     eb_printf(b1, "\n");
 
     b1->flags |= BF_READONLY;
-    if (show) {
-        show_popup(b1);
-    }
+    show_popup(s, b1);
 }
 
 static void do_describe_screen(EditState *e, int argval)
 {
     QEditScreen *s = e->screen;
     EditBuffer *b1;
-    int show;
     int w;
 
-    b1 = new_help_buffer(&show);
+    b1 = new_help_buffer();
     if (!b1)
         return;
 
@@ -1400,9 +1388,7 @@
     }
 
     b1->flags |= BF_READONLY;
-    if (show) {
-        show_popup(b1);
-    }
+    show_popup(e, b1);
 }
 
 /*---------------- buffer contents sorting ----------------*/

Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.256
retrieving revision 1.257
diff -u -b -r1.256 -r1.257
--- qe.c        25 Mar 2017 18:00:52 -0000      1.256
+++ qe.c        26 Mar 2017 15:57:24 -0000      1.257
@@ -6159,10 +6159,10 @@
 }
 
 /* show a popup on a readonly buffer */
-EditState *show_popup(EditBuffer *b)
+EditState *show_popup(EditState *s, EditBuffer *b)
 {
     QEmacsState *qs = &qe_state;
-    EditState *s = qs->active_window;
+    EditState *e;
     int w, h, w1, h1;
 
     /* Prevent recursion */
@@ -6175,14 +6175,14 @@
     w = (w1 * 4) / 5;
     h = (h1 * 3) / 4;
 
-    s = edit_new(b, (w1 - w) / 2, (h1 - h) / 2, w, h, WF_POPUP);
-    edit_set_mode(s, &popup_mode);
-    s->wrap = WRAP_TRUNCATE;
+    e = edit_new(b, (w1 - w) / 2, (h1 - h) / 2, w, h, WF_POPUP);
+    edit_set_mode(e, &popup_mode);
+    e->wrap = WRAP_TRUNCATE;
 
     popup_saved_active = qs->active_window;
-    qs->active_window = s;
-    do_refresh(s);
-    return s;
+    qs->active_window = e;
+    do_refresh(e);
+    return e;
 }
 
 static void popup_init(void)
@@ -7526,29 +7526,27 @@
     key_ctx.describe_key = 1;
 }
 
-EditBuffer *new_help_buffer(int *show_ptr)
+EditBuffer *new_help_buffer(void)
 {
     EditBuffer *b;
 
-    *show_ptr = 0;
     b = eb_find("*Help*");
     if (b) {
         eb_clear(b);
     } else {
         b = eb_new("*Help*", BF_UTF8);
-        *show_ptr = 1;
     }
     return b;
 }
 
-void do_help_for_help(qe__unused__ EditState *s)
+void do_help_for_help(EditState *s)
 {
     EditBuffer *b;
-    int show;
 
-    b = new_help_buffer(&show);
+    b = new_help_buffer();
     if (!b)
         return;
+
     eb_printf(b,
               "QEmacs help for help - Press q to quit:\n"
               "\n"
@@ -7557,9 +7555,7 @@
               "C-h c     Describe key briefly\n"
               );
     b->flags |= BF_READONLY;
-    if (show) {
-        show_popup(b);
-    }
+    show_popup(s, b);
 }
 
 #ifdef CONFIG_WIN32
@@ -8623,7 +8619,7 @@
 
     b = eb_find("*errors*");
     if (b != NULL) {
-        show_popup(b);
+        show_popup(s, b);
         edit_display(qs);
         dpy_flush(&global_screen);
     }

Index: x11.c
===================================================================
RCS file: /sources/qemacs/qemacs/x11.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- x11.c       25 Mar 2017 18:15:00 -0000      1.46
+++ x11.c       26 Mar 2017 15:57:24 -0000      1.47
@@ -1878,10 +1878,10 @@
 {
     char buf[80];
     EditBuffer *b;
-    int show, i, count;
+    int i, count;
     char **list;
 
-    b = new_help_buffer(&show);
+    b = new_help_buffer();
     if (!b)
         return;
 
@@ -1900,9 +1900,7 @@
     XFreeFontNames(list);
 
     b->flags |= BF_READONLY;
-    if (show) {
-        show_popup(b);
-    }
+    show_popup(s, b);
 }
 
 static CmdDef x11_commands[] = {



reply via email to

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