qemacs-commit
[Top][All Lists]
Advanced

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

[Qemacs-commit] qemacs buffer.c qe.c qe.h shell.c tty.c


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs buffer.c qe.c qe.h shell.c tty.c
Date: Fri, 21 Dec 2007 12:30:56 +0000

CVSROOT:        /cvsroot/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        07/12/21 12:30:56

Modified files:
        .              : buffer.c qe.c qe.h shell.c tty.c 

Log message:
        moved global variables to QEmacsState structure:
         - first_mode, first_key, first_cmd, 
         - first_completion, first_history
         - trace_buffer, trace_buffer_state, 
         - backspace_is_control_h

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/buffer.c?cvsroot=qemacs&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.48&r2=1.49
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/qemacs/shell.c?cvsroot=qemacs&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/qemacs/tty.c?cvsroot=qemacs&r1=1.29&r2=1.30

Patches:
Index: buffer.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/buffer.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- buffer.c    20 Dec 2007 20:39:18 -0000      1.23
+++ buffer.c    21 Dec 2007 12:30:55 -0000      1.24
@@ -486,7 +486,7 @@
     eb_add_callback(b, eb_offset_callback, &b->mark);
 
     if (!strcmp(name, "*trace*"))
-        trace_buffer = b;
+        qs->trace_buffer = b;
 
     return b;
 }
@@ -554,8 +554,8 @@
     }
     *pb = (*pb)->next;
 
-    if (b == trace_buffer)
-        trace_buffer = NULL;
+    if (b == qs->trace_buffer)
+        qs->trace_buffer = NULL;
 
     qe_free(&b);
 }
@@ -606,15 +606,16 @@
 
 void eb_trace_bytes(const void *buf, int size, int state)
 {
-    EditBuffer *b = trace_buffer;
+    QEmacsState *qs = &qe_state;
+    EditBuffer *b = qs->trace_buffer;
     EditState *e;
     int point;
 
     if (b) {
         point = b->total_size;
-        if (trace_buffer_state != state) {
+        if (qs->trace_buffer_state != state) {
             const char *str = NULL;
-            switch (trace_buffer_state) {
+            switch (qs->trace_buffer_state) {
             case EB_TRACE_TTY:
                 str = "|\n";
                 break;
@@ -628,8 +629,8 @@
             if (str) {
                 eb_write(b, b->total_size, str, strlen(str));
             }
-            trace_buffer_state = state;
-            switch (trace_buffer_state) {
+            qs->trace_buffer_state = state;
+            switch (qs->trace_buffer_state) {
             case EB_TRACE_TTY:
                 str = "--|";
                 break;

Index: qe.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -b -r1.48 -r1.49
--- qe.c        21 Dec 2007 12:20:18 -0000      1.48
+++ qe.c        21 Dec 2007 12:30:56 -0000      1.49
@@ -58,20 +58,13 @@
 static int dummy_dpy_init(QEditScreen *s, int w, int h);
 
 QEmacsState qe_state;
-static ModeDef *first_mode = NULL;
-static KeyDef *first_key = NULL;
-static CmdDef *first_cmd = NULL;
-static CompletionEntry *first_completion = NULL;
-static HistoryEntry *first_history = NULL;
+/* should handle multiple screens, and multiple sessions */
 static QEditScreen global_screen;
 static int screen_width = 0;
 static int screen_height = 0;
 static int no_init_file;
 static const char *user_option;
 
-EditBuffer *trace_buffer;
-int trace_buffer_state;
-
 /* mode handling */
 
 void qe_register_mode(ModeDef *m)
@@ -80,7 +73,7 @@
     CmdDef *table;
 
     /* record mode in mode list */
-    p = &first_mode;
+    p = &qe_state.first_mode;
     while (*p != NULL) p = &(*p)->next;
     m->next = NULL;
     *p = m;
@@ -123,7 +116,7 @@
 {
     ModeDef *m;
     
-    for (m = first_mode; m != NULL; m = m->next) {
+    for (m = qe_state.first_mode; m != NULL; m = m->next) {
         if (strstart(m->name, input, NULL))
             add_string(cs, m->name);
     }
@@ -133,7 +126,7 @@
 {
     ModeDef *m;
 
-    for (m = first_mode; m != NULL; m = m->next) {
+    for (m = qe_state.first_mode; m != NULL; m = m->next) {
         if (!strcmp(m->name, name))
             return m;
     }
@@ -146,7 +139,7 @@
 {
     CmdDef *d;
     
-    d = first_cmd;
+    d = qe_state.first_cmd;
     while (d != NULL) {
         while (d->name != NULL) {
             if (!strcmp(cmd_name, d->name))
@@ -173,13 +166,13 @@
     memcpy(p->keys, keys, nb_keys * sizeof(unsigned int));
     /* find position : mode keys should be before generic keys */
     if (m == NULL) {
-        lp = &first_key;
+        lp = &qe_state.first_key;
         while (*lp != NULL) lp = &(*lp)->next;
         *lp = p;
         p->next = NULL;
     } else {
-        p->next = first_key;
-        first_key = p;
+        p->next = qe_state.first_key;
+        qe_state.first_key = p;
     }
     return 0;
 }
@@ -208,24 +201,23 @@
     qe_register_binding1(keys, nb_keys, d, m);
 }
 
-static int backspace_is_control_h;
-
-void do_toggle_control_h(__unused__ EditState *s, int set)
+void do_toggle_control_h(EditState *s, int set)
 {
+    QEmacsState *qs = s->qe_state;
     KeyDef *p;
     int i;
 
     if (set)
         set = (set > 0);
     else
-        set = !backspace_is_control_h;
+        set = !qs->backspace_is_control_h;
 
-    if (backspace_is_control_h == set)
+    if (qs->backspace_is_control_h == set)
         return;
     
-    backspace_is_control_h = set;
+    qs->backspace_is_control_h = set;
 
-    for (p = first_key; p; p = p->next) {
+    for (p = qs->first_key; p; p = p->next) {
         for (i = 0; i < p->nb_keys; i++) {
             switch (p->keys[i]) {
             case KEY_CTRL('h'):
@@ -286,7 +278,7 @@
         m = find_mode(mode);
 
     /* find last command table */
-    for (ld = &first_cmd;;) {
+    for (ld = &qe_state.first_cmd;;) {
         d = *ld;
         if (d == NULL) {
             /* link new command table */
@@ -361,7 +353,7 @@
 {
     CmdDef *d;
     
-    d = first_cmd;
+    d = qe_state.first_cmd;
     while (d != NULL) {
         while (d->name != NULL) {
             if (strstart(d->name, input, NULL))
@@ -3894,7 +3886,7 @@
     }
 
     /* see if one command is found */
-    for (kd = first_key; kd != NULL; kd = kd->next) {
+    for (kd = qs->first_key; kd != NULL; kd = kd->next) {
         if (kd->nb_keys >= c->nb_keys) {
             if (!memcmp(kd->keys, c->keys, 
                         c->nb_keys * sizeof(unsigned int)) && 
@@ -3920,7 +3912,7 @@
                         goto next;
                     }
                 }
-                for (kd = first_key; kd != NULL; kd = kd->next) {
+                for (kd = qs->first_key; kd != NULL; kd = kd->next) {
                     if (kd->nb_keys == 1 &&
                         kd->keys[0] == KEY_DEFAULT &&
                         (kd->mode == NULL || kd->mode == s->mode)) {
@@ -4338,7 +4330,7 @@
     p->completion_func = completion_func;
     p->next = NULL;
 
-    lp = &first_completion;
+    lp = &qe_state.first_completion;
     while (*lp != NULL)
         lp = &(*lp)->next;
     *lp = p;
@@ -4349,7 +4341,7 @@
     CompletionEntry *p;
 
     if (name[0] != '\0') {
-        for (p = first_completion; p != NULL; p = p->next)
+        for (p = qe_state.first_completion; p != NULL; p = p->next)
             if (!strcmp(p->name, name))
                 return p->completion_func;
     }
@@ -4493,7 +4485,7 @@
 
     if (name[0] == '\0')
         return NULL;
-    for (p = first_history; p != NULL; p = p->next) {
+    for (p = qe_state.first_history; p != NULL; p = p->next) {
         if (!strcmp(p->name, name))
             return &p->history;
     }
@@ -4502,8 +4494,8 @@
     if (!p)
         return NULL;
     pstrcpy(p->name, sizeof(p->name), name);
-    p->next = first_history;
-    first_history = p;
+    p->next = qe_state.first_history;
+    qe_state.first_history = p;
     return &p->history;
 }
 
@@ -4952,7 +4944,7 @@
     ModeProbeData probe_data;
     int best_probe_percent, percent;
 
-    m = first_mode;
+    m = s->qe_state->first_mode;
     selected_mode = NULL;
     best_probe_percent = 0;
     probe_data.buf = buf;
@@ -6079,13 +6071,13 @@
     char buf[64];
     int found, gfound;
 
-    d = first_cmd;
+    d = qe_state.first_cmd;
     gfound = 0;
     while (d != NULL) {
         while (d->name != NULL) {
             /* find each key mapping pointing to this command */
             found = 0;
-            for (k = first_key; k != NULL; k = k->next) {
+            for (k = qe_state.first_key; k != NULL; k = k->next) {
                 if (k->cmd == d && k->mode == mode) {
                     if (!gfound)
                         eb_printf(b, "%s:\n\n", title);

Index: qe.h
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- qe.h        21 Dec 2007 10:30:24 -0000      1.43
+++ qe.h        21 Dec 2007 12:30:56 -0000      1.44
@@ -724,11 +724,6 @@
     int size;
 } LogBuffer;
 
-extern EditBuffer *trace_buffer;
-extern int trace_buffer_state;
-#define EB_TRACE_TTY    1
-#define EB_TRACE_SHELL  2
-#define EB_TRACE_PTY    4
 void eb_trace_bytes(const void *buf, int size, int state);
 
 void eb_init(void);
@@ -1068,15 +1063,26 @@
 
 struct QEmacsState {
     QEditScreen *screen;
-    //struct ModeDef *first_mode;
-    //struct KeyDef *first_key;
-    //struct CmdDef *first_cmd;
+    //struct QEDisplay *first_dpy;
+    struct ModeDef *first_mode;
+    struct KeyDef *first_key;
+    struct CmdDef *first_cmd;
+    struct CompletionEntry *first_completion;
+    struct HistoryEntry *first_history;
+    //struct QECharset *first_charset;
+    //struct QETimer *first_timer;
     //struct VarDef *first_variable;
     //struct InputMethod *input_methods;
     EditState *first_window;
     EditState *active_window; /* window in which we edit */
     EditBuffer *first_buffer;
     //EditBuffer *message_buffer;
+    EditBuffer *trace_buffer;
+    int trace_buffer_state;
+#define EB_TRACE_TTY    1
+#define EB_TRACE_SHELL  2
+#define EB_TRACE_PTY    4
+
     /* global layout info : DO NOT modify these directly. do_refresh
        does it */
     int status_height;
@@ -1091,6 +1097,7 @@
     int is_full_screen;
     /* commands */
     int flag_split_window_change_focus;
+    int backspace_is_control_h;
     /* XXX: move these to ec */
     void *last_cmd_func; /* last executed command function call */
     void *this_cmd_func; /* current executing command */
@@ -1421,7 +1428,9 @@
 void switch_to_buffer(EditState *s, EditBuffer *b);
 
 /* text mode */
+
 extern ModeDef text_mode;
+
 int text_mode_init(EditState *s, ModeSavedData *saved_data);
 void text_mode_close(EditState *s);
 int text_backward_offset(EditState *s, int offset);
@@ -1590,6 +1599,7 @@
 int xml_mode_probe(ModeProbeData *p1);
 
 /* html.c */
+
 extern ModeDef html_mode;
 
 int gxml_mode_init(EditState *s, 

Index: shell.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/shell.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- shell.c     20 Dec 2007 20:37:16 -0000      1.31
+++ shell.c     21 Dec 2007 12:30:56 -0000      1.32
@@ -331,7 +331,7 @@
     if (len < 0)
         len = strlen(buf);
 
-    if (trace_buffer)
+    if (s->qe_state->trace_buffer)
         eb_trace_bytes(buf, len, EB_TRACE_PTY);
 
     while (len > 0) {
@@ -970,7 +970,7 @@
     if (len <= 0)
         return;
     
-    if (trace_buffer)
+    if (qs->trace_buffer)
         eb_trace_bytes(buf, len, EB_TRACE_SHELL);
 
     for (i = 0; i < len; i++)

Index: tty.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/tty.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- tty.c       21 Dec 2007 10:32:27 -0000      1.29
+++ tty.c       21 Dec 2007 12:30:56 -0000      1.30
@@ -371,9 +371,9 @@
     if (read(fileno(s->STDIN), ts->buf + ts->utf8_index, 1) != 1)
         return;
 
-    if (trace_buffer &&
+    if (qs->trace_buffer &&
         qs->active_window &&
-        qs->active_window->b != trace_buffer) {
+        qs->active_window->b != qs->trace_buffer) {
         eb_trace_bytes(ts->buf + ts->utf8_index, 1, EB_TRACE_TTY);
     }
 




reply via email to

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