qemacs-commit
[Top][All Lists]
Advanced

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

[Qemacs-commit] qemacs html.c qe.c qe.h util.c


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs html.c qe.c qe.h util.c
Date: Sun, 16 Apr 2017 13:31:15 -0400 (EDT)

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        17/04/16 13:31:15

Modified files:
        .              : html.c qe.c qe.h util.c 

Log message:
        basic: move some global variables
        - move up_down_last_x to an EditState member
        - make single_window static in qe.c
        - move user_option to the QEmacsState structure
        - move minibuffer and completion state to a MinibufState structure
        - remove static state in do_minibuffer_exit
        - add key name: LB for `{`, RB for `}` and VB for `|`

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/html.c?cvsroot=qemacs&r1=1.40&r2=1.41
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.267&r2=1.268
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.249&r2=1.250
http://cvs.savannah.gnu.org/viewcvs/qemacs/util.c?cvsroot=qemacs&r1=1.81&r2=1.82

Patches:
Index: html.c
===================================================================
RCS file: /sources/qemacs/qemacs/html.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- html.c      15 Mar 2017 23:17:58 -0000      1.40
+++ html.c      16 Apr 2017 17:31:14 -0000      1.41
@@ -503,8 +503,6 @@
     return 0;
 }
 
-static int up_down_last_x = -1;
-
 static void html_move_up_down1(EditState *s, int dir, int xtarget)
 {
     HTMLState *hs;
@@ -522,8 +520,8 @@
 
     /* compute the position to which we would like to go */
     if (xtarget == 0) {
-        if (up_down_last_x == -1)
-            up_down_last_x = cursor_pos.x1;
+        if (s->up_down_last_x == -1)
+            s->up_down_last_x = cursor_pos.x1;
     }
 
     if (dir > 0)
@@ -533,7 +531,7 @@
 
     /* find a suitable box upward or downward */
     if (xtarget == 0) {
-        m->xd = up_down_last_x;
+        m->xd = s->up_down_last_x;
     } else {
         m->xd = xtarget;
     }
@@ -566,7 +564,7 @@
         return;
 
     if (s->qe_state->last_cmd_func != (CmdFunc)do_up_down)
-        up_down_last_x = -1;
+        s->up_down_last_x = -1;
 
     html_move_up_down1(s, dir, 0);
 }

Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.267
retrieving revision 1.268
diff -u -b -r1.267 -r1.268
--- qe.c        16 Apr 2017 17:20:49 -0000      1.267
+++ qe.c        16 Apr 2017 17:31:14 -0000      1.268
@@ -72,13 +72,12 @@
 static int screen_width = 0;
 static int screen_height = 0;
 static int no_init_file;
+static int single_window;
 int force_tty;
-int single_window;
 int use_session_file;
 #ifndef CONFIG_TINY
 static int free_everything;
 #endif
-static const char *user_option;
 
 /* mode handling */
 
@@ -1043,9 +1042,6 @@
         s->mode->move_left_right(s, dir);
 }
 
-/* CG: Should move this to EditState */
-static int up_down_last_x = -1;
-
 void text_move_up_down(EditState *s, int dir)
 {
     MoveContext m1, *m = &m1;
@@ -1053,14 +1049,14 @@
     CursorContext cm;
 
     if (s->qe_state->last_cmd_func != (CmdFunc)do_up_down)
-        up_down_last_x = -1;
+        s->up_down_last_x = -1;
 
     get_cursor_pos(s, &cm);
     if (cm.xc == NO_CURSOR)
         return;
 
-    if (up_down_last_x == -1)
-        up_down_last_x = cm.xc;
+    if (s->up_down_last_x == -1)
+        s->up_down_last_x = cm.xc;
 
     if (dir < 0) {
         /* difficult case: we need to go backward on displayed text */
@@ -1082,7 +1078,7 @@
 
     /* find cursor offset */
     m->yd = cm.linec + dir;
-    m->xd = up_down_last_x;
+    m->xd = s->up_down_last_x;
     m->xdmin = 0x7fffffff;
     /* if no cursor position is found, we go to bof or eof according
        to dir */
@@ -5772,18 +5768,21 @@
 
 /* mini buffer stuff */
 
-static ModeDef minibuffer_mode;
+struct MinibufState {
+    void (*cb)(void *opaque, char *buf);
+    void *opaque;
+    EditState *saved_active;
+
+    EditState *completion_popup_window;
+    CompletionFunc completion_function;
+
+    StringArray *history;
+    int history_index;
+    int history_saved_offset;
+};
 
-static void (*minibuffer_cb)(void *opaque, char *buf);
-static void *minibuffer_opaque;
-static EditState *minibuffer_saved_active;
-
-static EditState *completion_popup_window;
-static CompletionFunc completion_function;
-
-static StringArray *minibuffer_history;
-static int minibuffer_history_index;
-static int minibuffer_history_saved_offset;
+static struct MinibufState minibuffer;
+static ModeDef minibuffer_mode;
 
 void do_completion(EditState *s, int type)
 {
@@ -5795,7 +5794,7 @@
     EditBuffer *b;
     int w, h, h1, w1;
 
-    if (!completion_function)
+    if (!minibuffer.completion_function)
         return;
 
     /* Remove highlighted selection. */
@@ -5809,18 +5808,18 @@
      */
 
     /* check completion window */
-    check_window(&completion_popup_window);
-    if (completion_popup_window
+    check_window(&minibuffer.completion_popup_window);
+    if (minibuffer.completion_popup_window
     &&  type == COMPLETION_TAB
     &&  qs->last_cmd_func == qs->this_cmd_func) {
         /* toggle cpmpletion popup on TAB */
-        edit_close(&completion_popup_window);
+        edit_close(&minibuffer.completion_popup_window);
         do_refresh(s);
         return;
     }
 
-    complete_start(&cs, s, check_window(&minibuffer_saved_active));
-    (*completion_function)(&cs);
+    complete_start(&cs, s, check_window(&minibuffer.saved_active));
+    (*minibuffer.completion_function)(&cs);
     count = cs.cs.nb_items;
     outputs = cs.cs.items;
 #if 0
@@ -5861,7 +5860,7 @@
         if (count > 1) {
             /* if more than one match, then display them in a new popup
                buffer */
-            if (!completion_popup_window) {
+            if (!minibuffer.completion_popup_window) {
                 b = eb_new("*completion*", 
                            BF_SYSTEM | BF_UTF8 | BF_TRANSIENT | BF_STYLE1);
                 b->default_mode = &list_mode;
@@ -5871,18 +5870,18 @@
                 h = (h1 * 3) / 4;
                 e = edit_new(b, (w1 - w) / 2, (h1 - h) / 2, w, h, WF_POPUP);
                 do_refresh(e);
-                completion_popup_window = e;
+                minibuffer.completion_popup_window = e;
             }
         } else
         if (count == 0 || type != COMPLETION_OTHER) {
             /* close the popup when minibuf contents matches nothing */
-            edit_close(&completion_popup_window);
+            edit_close(&minibuffer.completion_popup_window);
             do_refresh(s);
         }
     }
-    if (completion_popup_window) {
+    if (minibuffer.completion_popup_window) {
         /* modify the list with the current matches */
-        e = completion_popup_window;
+        e = minibuffer.completion_popup_window;
         b = e->b;
         qsort(outputs, count, sizeof(StringItem *), completion_sort_func);
         b->flags &= ~BF_READONLY;
@@ -5917,7 +5916,7 @@
 {
     int c, offset, stop;
 
-    if (completion_function == file_completion) {
+    if (minibuffer.completion_function == file_completion) {
         stop = s->offset;
         c = eb_prevc(s->b, s->offset, &offset);
         if (c == '/') {
@@ -5937,13 +5936,13 @@
 {
     QEmacsState *qs = s->qe_state;
 
-    if (!completion_function) {
+    if (!minibuffer.completion_function) {
         do_char(s, ' ', 1);
     } else
-    if (completion_popup_window && qs->last_cmd_func == qs->this_cmd_func) {
+    if (minibuffer.completion_popup_window && qs->last_cmd_func == 
qs->this_cmd_func) {
         /* page through the list */
         // XXX: should close the popup at the bottom of the list
-        do_scroll_up_down(completion_popup_window, 2);
+        do_scroll_up_down(minibuffer.completion_popup_window, 2);
     } else {
         do_completion(s, COMPLETION_SPACE);
     }
@@ -5952,7 +5951,7 @@
 static void do_minibuffer_char(EditState *s, int key, int argval)
 {
     do_char(s, key, argval);
-    if (completion_popup_window) {
+    if (minibuffer.completion_popup_window) {
         /* automatic filtering of completion list */
         // XXX: should prevent auto-completion
         do_completion(s, COMPLETION_OTHER);
@@ -5962,9 +5961,9 @@
 /* scroll in completion popup */
 void minibuf_complete_scroll_up_down(qe__unused__ EditState *s, int dir)
 {
-    if (completion_popup_window) {
-        completion_popup_window->force_highlight = 1;
-        do_scroll_up_down(completion_popup_window, dir);
+    if (minibuffer.completion_popup_window) {
+        minibuffer.completion_popup_window->force_highlight = 1;
+        do_scroll_up_down(minibuffer.completion_popup_window, dir);
     }
 }
 
@@ -6004,35 +6003,35 @@
 void do_history(EditState *s, int dir)
 {
     QEmacsState *qs = s->qe_state;
-    StringArray *hist = minibuffer_history;
+    StringArray *hist = minibuffer.history;
     int index;
     char *str;
     char buf[1024];
 
     /* if completion visible, move in it */
-    if (completion_popup_window) {
-        completion_popup_window->force_highlight = 1;
-        do_up_down(completion_popup_window, dir);
+    if (minibuffer.completion_popup_window) {
+        minibuffer.completion_popup_window->force_highlight = 1;
+        do_up_down(minibuffer.completion_popup_window, dir);
         return;
     }
 
     if (!hist)
         return;
-    index = minibuffer_history_index + dir;
+    index = minibuffer.history_index + dir;
     if (index < 0 || index >= hist->nb_items)
         return;
     if (qs->last_cmd_func != (CmdFunc)do_history) {
         /* save currently edited line */
         eb_get_contents(s->b, buf, sizeof(buf));
         set_string(hist, hist->nb_items - 1, buf, 0);
-        minibuffer_history_saved_offset = s->offset;
+        minibuffer.history_saved_offset = s->offset;
     }
     /* insert history text */
-    minibuffer_history_index = index;
+    minibuffer.history_index = index;
     str = hist->items[index]->str;
     set_minibuffer_str(s, str);
     if (index == hist->nb_items - 1) {
-        s->offset = minibuffer_history_saved_offset;
+        s->offset = minibuffer.history_saved_offset;
     }
 }
 
@@ -6040,9 +6039,9 @@
 {
     unsigned long offset;
 
-    if (minibuffer_saved_active) {
-        eb_read(minibuffer_saved_active->b,
-                minibuffer_saved_active->offset,
+    if (minibuffer.saved_active) {
+        eb_read(minibuffer.saved_active->b,
+                minibuffer.saved_active->offset,
                 &offset, sizeof(offset));
         eb_printf(s->b, "%lu", offset);
     }
@@ -6051,11 +6050,11 @@
 void do_minibuffer_exit(EditState *s, int do_abort)
 {
     QEmacsState *qs = s->qe_state;
-    StringArray *hist = minibuffer_history;
-    static void (*cb)(void *opaque, char *buf);
-    static void *opaque;
+    StringArray *hist = minibuffer.history;
+    void (*cb)(void *opaque, char *buf);
+    void *opaque;
     char buf[4096], *retstr;
-    EditState *cw = completion_popup_window;
+    EditState *cw = minibuffer.completion_popup_window;
 
     /* if completion is activated, then select current file only if
        the selection is highlighted */
@@ -6070,9 +6069,9 @@
     }
 
     /* remove completion popup if present */
-    /* CG: assuming completion_popup_window != s */
+    /* CG: assuming minibuffer.completion_popup_window != s */
     if (cw) {
-        edit_close(&completion_popup_window);
+        edit_close(&minibuffer.completion_popup_window);
         cw = NULL;
         do_refresh(s);
     }
@@ -6091,8 +6090,8 @@
     edit_close(&s);
 
     /* restore active window */
-    qs->active_window = check_window(&minibuffer_saved_active);
-    minibuffer_saved_active = NULL;
+    qs->active_window = check_window(&minibuffer.saved_active);
+    minibuffer.saved_active = NULL;
 
     /* force status update */
     //pstrcpy(qs->status_shadow, sizeof(qs->status_shadow), " ");
@@ -6102,10 +6101,10 @@
         put_status(NULL, "");
 
     /* call the callback */
-    cb = minibuffer_cb;
-    opaque = minibuffer_opaque;
-    minibuffer_cb = NULL;
-    minibuffer_opaque = NULL;
+    cb = minibuffer.cb;
+    opaque = minibuffer.opaque;
+    minibuffer.cb = NULL;
+    minibuffer.opaque = NULL;
 
     if (do_abort) {
         cb(opaque, NULL);
@@ -6129,14 +6128,14 @@
     int len;
 
     /* check if already in minibuffer editing */
-    if (minibuffer_cb) {
+    if (minibuffer.cb) {
         put_status(NULL, "Already editing in minibuffer");
         cb(opaque, NULL);
         return;
     }
 
-    minibuffer_cb = cb;
-    minibuffer_opaque = opaque;
+    minibuffer.cb = cb;
+    minibuffer.opaque = opaque;
 
     b = eb_new("*minibuf*", BF_SYSTEM | BF_SAVELOG | BF_UTF8);
     b->default_mode = &minibuffer_mode;
@@ -6159,15 +6158,15 @@
         s->offset = len;
     }
 
-    minibuffer_saved_active = qs->active_window;
+    minibuffer.saved_active = qs->active_window;
     qs->active_window = s;
 
-    completion_popup_window = NULL;
-    completion_function = completion_func;
-    minibuffer_history = hist;
-    minibuffer_history_saved_offset = 0;
+    minibuffer.completion_popup_window = NULL;
+    minibuffer.completion_function = completion_func;
+    minibuffer.history = hist;
+    minibuffer.history_saved_offset = 0;
     if (hist) {
-        minibuffer_history_index = hist->nb_items;
+        minibuffer.history_index = hist->nb_items;
         add_string(hist, "", 0);
     }
 }
@@ -8342,7 +8341,7 @@
     char path[MAX_FILENAME_SIZE];
     const char *home_path;
 
-    user_option = user;
+    qs->user_option = user;
 
     /* compute resources path */
     qs->res_path[0] = '\0';

Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.249
retrieving revision 1.250
diff -u -b -r1.249 -r1.250
--- qe.h        16 Apr 2017 17:20:49 -0000      1.249
+++ qe.h        16 Apr 2017 17:31:15 -0000      1.250
@@ -1359,6 +1359,8 @@
                              window not focused (list mode only) */
     int mouse_force_highlight; /* if true, mouse can force highlight
                                   (list mode only) */
+    int up_down_last_x; /* last x offset for vertical movement */
+
     /* low level colorization function */
     GetColorizedLineFunc get_colorized_line;
     ColorizeFunc colorize_func; /* colorization function */
@@ -1660,6 +1662,7 @@
     int backspace_is_control_h;
     int backup_inhibited;  /* prevent qemacs from backing up files */
     int fuzzy_search;    /* use fuzzy search for completion matcher */
+    const char *user_option;
 };
 
 extern QEmacsState qe_state;

Index: util.c
===================================================================
RCS file: /sources/qemacs/qemacs/util.c,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -b -r1.81 -r1.82
--- util.c      16 Apr 2017 17:20:49 -0000      1.81
+++ util.c      16 Apr 2017 17:31:15 -0000      1.82
@@ -975,6 +975,7 @@
     KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10,
     KEY_F11, KEY_F12, KEY_F13, KEY_F14, KEY_F15,
     KEY_F16, KEY_F17, KEY_F18, KEY_F19, KEY_F20,
+    '{', '}', '|',
 };
 
 static const char * const keystr[] = {
@@ -990,6 +991,7 @@
     "f6",     "f7",       "f8",       "f9",    "f10",
     "f11",    "f12",      "f13",      "f14",   "f15",
     "f16",    "f17",      "f18",      "f19",   "f20",
+    "LB",     "RB",       "VB",
 };
 
 int compose_keys(unsigned int *keys, int *nb_keys)



reply via email to

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