qemacs-commit
[Top][All Lists]
Advanced

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

[Qemacs-commit] qemacs buffer.c clang.c hex.c list.c qe-doc.htm...


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs buffer.c clang.c hex.c list.c qe-doc.htm...
Date: Wed, 09 Jan 2008 13:41:42 +0000

CVSROOT:        /cvsroot/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        08/01/09 13:41:41

Modified files:
        .              : buffer.c clang.c hex.c list.c qe-doc.html qe.c 
                         qe.h qestyles.h shell.c unihex.c 

Log message:
        removed EditBuffer.yank_mark and QEmacsState.mark_yank_region
        changed API for GetColorizedLineFunc: offset passed by address,
          updated to start of next line
        added check_readonly(EditState *s)
        added tentative code for unregistring bindings, cycling modes and 
charsets
        experiment alternate method for region highlighting:
          added EditState.region_style and EditState.curline_style
          added QEmacsState.hilite_region
          added DisplayState.style
          added clear_color to reset style bits in unicode array
          display_char_bidir takes style from DisplayState, code point is bare.
          fixed problem in text_display where line_num was not computed in 
shell mode
          handle region coloring in text_display (tentative)
        display line numbers and hex dump offsets as QE_STYLE_COMMENT
        display hex dump as QE_STYLE_FUNCTION

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/buffer.c?cvsroot=qemacs&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/qemacs/clang.c?cvsroot=qemacs&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/qemacs/hex.c?cvsroot=qemacs&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/qemacs/list.c?cvsroot=qemacs&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe-doc.html?cvsroot=qemacs&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.63&r2=1.64
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.59&r2=1.60
http://cvs.savannah.gnu.org/viewcvs/qemacs/qestyles.h?cvsroot=qemacs&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/qemacs/shell.c?cvsroot=qemacs&r1=1.41&r2=1.42
http://cvs.savannah.gnu.org/viewcvs/qemacs/unihex.c?cvsroot=qemacs&r1=1.12&r2=1.13

Patches:
Index: buffer.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/buffer.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- buffer.c    8 Jan 2008 16:37:54 -0000       1.33
+++ buffer.c    9 Jan 2008 13:41:40 -0000       1.34
@@ -1186,7 +1186,7 @@
         }
         pos += get_chars(p->data, offset, b->charset);
         /* Should adjust if offset falls in the middle of a character */
-        // {
+        //{
         //    int c = p->data[offset];
         //    if (c >= 0x80 && c < 0xc0)
         //        pos--;

Index: clang.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/clang.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- clang.c     8 Jan 2008 16:37:54 -0000       1.28
+++ clang.c     9 Jan 2008 13:41:41 -0000       1.29
@@ -378,7 +378,8 @@
             break;
         line_num--;
         offsetl = eb_prev_line(s->b, offsetl);
-        len = get_colorized_line(s, buf, countof(buf), offsetl, line_num);
+        offset1 = offsetl;
+        len = get_colorized_line(s, buf, countof(buf), &offset1, line_num);
         /* store indent position */
         pos1 = find_indent1(s, buf);
         p = buf + len;
@@ -495,7 +496,8 @@
     }
  end_parse:
     /* compute special cases which depend on the chars on the current line */
-    len = get_colorized_line(s, buf, countof(buf), offset, line_num1);
+    offset1 = offset;
+    len = get_colorized_line(s, buf, countof(buf), &offset1, line_num1);
 
     if (stack_ptr == 0) {
         if (!pos && lpos >= 0) {
@@ -598,11 +600,12 @@
 {
     unsigned int buf[MAX_BUF_SIZE];
     char balance[MAX_LEVEL];
-    int line_num, col_num, offset, len, pos, style, c, c1, level;
+    int line_num, col_num, offset, offset1, len, pos, style, c, c1, level;
 
     eb_get_pos(s->b, &line_num, &col_num, s->offset);
     offset = eb_goto_bol2(s->b, s->offset, &pos);
-    len = get_colorized_line(s, buf, countof(buf), offset, line_num);
+    offset1 = offset;
+    len = get_colorized_line(s, buf, countof(buf), &offset1, line_num);
     style = buf[pos] >> STYLE_SHIFT;
     level = 0;
 
@@ -613,7 +616,8 @@
                     break;
                 line_num--;
                 offset = eb_prev_line(s->b, offset);
-                pos = get_colorized_line(s, buf, countof(buf), offset, 
line_num);
+                offset1 = offset;
+                pos = get_colorized_line(s, buf, countof(buf), &offset1, 
line_num);
                 continue;
             }
             c = buf[--pos];
@@ -657,12 +661,16 @@
     } else {
         for (;;) {
             if (pos >= len) {
+                /* Should simplify with get_colorized_line updating
+                 * offset
+                 */
                 line_num++;
                 pos = 0;
                 offset = eb_next_line(s->b, offset);
                 if (offset >= s->b->total_size)
                     break;
-                len = get_colorized_line(s, buf, countof(buf), offset, 
line_num);
+                offset1 = offset;
+                len = get_colorized_line(s, buf, countof(buf), &offset1, 
line_num);
                 continue;
             }
             c = buf[pos];

Index: hex.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/hex.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- hex.c       8 Jan 2008 16:37:54 -0000       1.19
+++ hex.c       9 Jan 2008 13:41:41 -0000       1.20
@@ -49,7 +49,11 @@
 
     display_bol(ds);
 
+    ds->style = QE_STYLE_COMMENT;
     display_printf(ds, -1, -1, "%08x ", offset);
+
+    ds->style = QE_STYLE_FUNCTION;
+
     eof = 0;
     len = s->b->total_size - offset;
     if (len > s->disp_width)
@@ -69,12 +73,14 @@
                 }
                 display_printf(ds, offset1, offset1 + 1, "  ");
             }
-            if ((j & 7)== 7)
+            if ((j & 7) == 7)
                 display_char(ds, -1, -1, ' ');
         }
         display_char(ds, -1, -1, ' ');
         display_char(ds, -1, -1, ' ');
     }
+    ds->style = 0;
+
     eof = 0;
     for (j = 0; j < s->disp_width; j++) {
         offset1 = offset + j;

Index: list.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/list.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- list.c      7 Jan 2008 16:25:22 -0000       1.7
+++ list.c      9 Jan 2008 13:41:41 -0000       1.8
@@ -22,17 +22,17 @@
 
 static int list_get_colorized_line(EditState *s,
                                    unsigned int *buf, int buf_size,
-                                   int offset, __unused__ int line_num)
+                                   int *offsetp, __unused__ int line_num)
 {
     QEmacsState *qs = s->qe_state;
-    int len;
-    int offset1;
+    int offset, len;
 
-    offset1 = offset;
-    len = eb_get_line(s->b, buf, buf_size, &offset1);
+    offset = *offsetp;
+    len = eb_get_line(s->b, buf, buf_size, offsetp);
 
     if (((qs->active_window == s) || s->force_highlight) &&
-        s->offset >= offset && s->offset < offset1) {
+          s->offset >= offset && s->offset < *offsetp)
+    {
         /* highlight the line if the cursor is inside */
         set_color(buf, buf + len, QE_STYLE_HIGHLIGHT);
     } else

Index: qe-doc.html
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe-doc.html,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- qe-doc.html 3 Jan 2008 09:51:31 -0000       1.7
+++ qe-doc.html 9 Jan 2008 13:41:41 -0000       1.8
@@ -1,6 +1,6 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html401/loose.dtd";>
 <html>
-<!-- Created on January, 3 2008 by texi2html 1.76 -->
+<!-- Created on January, 9 2008 by texi2html 1.76 -->
 <!--
 Written by: Lionel Cons <address@hidden> (original author)
             Karl Berry  <address@hidden>
@@ -1810,7 +1810,7 @@
 </tr></table>
 <h1>About This Document</h1>
 <p>
-  This document was generated by <em>Charlie Gordon</em> on <em>January, 3 
2008</em> using <a href="http://texi2html.cvshome.org/";><em>texi2html 
1.76</em></a>.
+  This document was generated by <em>Charlie Gordon</em> on <em>January, 9 
2008</em> using <a href="http://texi2html.cvshome.org/";><em>texi2html 
1.76</em></a>.
 </p>
 <p>
   The buttons in the navigation panels have the following meaning:
@@ -1912,7 +1912,7 @@
 <hr size="1">
 <p>
  <font size="-1">
-  This document was generated by <em>Charlie Gordon</em> on <em>January, 3 
2008</em> using <a href="http://texi2html.cvshome.org/";><em>texi2html 
1.76</em></a>.
+  This document was generated by <em>Charlie Gordon</em> on <em>January, 9 
2008</em> using <a href="http://texi2html.cvshome.org/";><em>texi2html 
1.76</em></a>.
  </font>
  <br>
 

Index: qe.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -b -r1.63 -r1.64
--- qe.c        8 Jan 2008 16:37:55 -0000       1.63
+++ qe.c        9 Jan 2008 13:41:41 -0000       1.64
@@ -204,6 +204,28 @@
     qe_register_binding1(keys, nb_keys, d, m);
 }
 
+#if 0
+/* remove a key binding from mode or globally */
+/* should take key sequence */
+int qe_unregister_binding1(int key, ModeDef *m)
+{
+    QEmacsState *qs = &qe_state;
+    KeyDef **lp, *p;
+
+    lp = (m) ? &m->first_key : &qs->first_key;
+    while (*lp) {
+        if ((*lp)->key == key) {
+            p = *lp;
+            *lp = (*lp)->next;
+            free(p);
+            break;
+        }
+        lp = &(*lp)->next;
+    }
+    return 0;
+}
+#endif
+
 /* if mode is non NULL, the defined keys are only active in this mode */
 void qe_register_cmd_table(CmdDef *cmds, ModeDef *m)
 {
@@ -316,6 +338,24 @@
     qe_register_binding1(keys, nb_keys, d, local ? s->mode : NULL);
 }
 
+#if 0
+void do_unset_key(EditState *s, const char *keystr, int local)
+{
+    int key;
+
+    if (!keystr) {
+        edit_display(s->qe_state);
+        put_status(s, "Unset key %s: ", local ? "locally" : "globally");
+        dpy_flush(s->screen);
+        key = get_key(s->screen);
+    } else {
+        key = strtokey(&keystr);
+    }
+    qe_unregister_binding1(key, local ? s->mode : NULL);
+    do_describe_key(s, NULL, key);
+}
+#endif
+
 void do_toggle_control_h(EditState *s, int set)
 {
     /* Achtung Minen! do_toggle_control_h can be called from tty_init
@@ -734,6 +774,11 @@
         return;
     }
 
+    /* XXX: Should delete hilighted region */
+
+    /* deactivate region hilite */
+    s->region_style = 0;
+
     if (argval == NO_ARG) {
         eb_prevc(s->b, s->offset, &offset1);
         if (offset1 < s->offset) {
@@ -1213,6 +1258,11 @@
     if (s->b->flags & BF_READONLY)
         return;
 
+    /* XXX: Should delete hilighted region */
+
+    /* deactivate region hilite */
+    s->region_style = 0;
+
     for (;;) {
         if (s->mode->write_char)
             s->mode->write_char(s, key);
@@ -1226,8 +1276,13 @@
     int cur_ch, len, cur_len, offset1, ret, insert;
     char buf[MAX_CHAR_BYTES];
 
-    //if (s->b->flags & BF_READONLY)
-    //    return;
+    if (check_read_only(s))
+        return;
+
+    /* XXX: Should delete hilighted region */
+
+    /* deactivate region hilite */
+    s->region_style = 0;
 
     cur_ch = eb_nextc(s->b, s->offset, &offset1);
     cur_len = offset1 - s->offset;
@@ -1350,11 +1405,24 @@
     s->offset += move;
 }
 
+#if 0
+void do_space(EditState *s, int key, int argval)
+{
+    if (s->b->flags & BF_READONLY) {
+        do_scroll_up_down(s, 1, argval);
+        return;
+    }
+    do_char(s, key, argval);
+}
+#endif
+
 void do_break(EditState *s)
 {
+    /* deactivate region hilite */
+    s->region_style = 0;
+
     /* well, currently nothing needs to be aborted in global context */
-    /* CG: Should remove popups, sidepanes, helppanes...
-     * deactivate region hilite */
+    /* CG: Should remove popups, sidepanes, helppanes... */
     put_status(s, "Quit");
 }
 
@@ -1363,7 +1431,11 @@
 {
     /* CG: Should have local and global mark rings */
     s->b->mark = s->offset;
-    /* CG: should activate the region hilite */
+
+    /* activate region hilite */
+    if (s->qe_state->hilite_region)
+        s->region_style = QE_STYLE_REGION_HILITE;
+
     put_status(s, "Mark set");
 }
 
@@ -1405,6 +1477,9 @@
     int len, tmp;
     EditBuffer *b;
 
+    /* deactivate region hilite */
+    s->region_style = 0;
+
     if (s->b->flags & BF_READONLY)
         return;
 
@@ -1668,6 +1743,44 @@
 }
 
 /* CG: should have commands to cycle modes and charsets */
+#if 0
+/* cycle modes appropriate for buffer */
+void do_next_mode(EditState *s)
+{
+    QEmacsState *qs = s->qe_state;
+    u8 buf[1024];
+    ModeProbeData probe_data;
+    int size;
+    ModeDef *m, *m0;
+
+    size = eb_read(s->b, 0, buf, sizeof(buf));
+    probe_data.buf = buf;
+    probe_data.buf_size = size;
+    probe_data.filename = s->b->filename;
+    probe_data.total_size = s->b->total_size;
+    /* CG: should pass EditState? QEmacsState ? */
+
+    m = m0 = s->mode;
+    for (;;) {
+        m = m->next;
+        if (!m)
+            m = qs->first_mode;
+        if (m == m0)
+            break;
+        if (!m->mode_probe
+        ||  m->mode_probe(&probe_data) > 0) {
+            edit_set_mode(s, m, 0);
+            break;
+        }
+    }
+}
+
+void do_cycle_charset(EditState *s)
+{
+    if (++s->b->charset == CHARSET_NB)
+        s->b->charset = 0;
+}
+#endif
 
 QECharset *read_charset(EditState *s, const char *charset_str)
 {
@@ -1946,14 +2059,15 @@
 
 void display_mode_line(EditState *s)
 {
-    char buf[512];
+    char buf[MAX_SCREEN_WIDTH];
+    int y = s->ytop + s->height;
 
     if (s->flags & WF_MODELINE) {
         s->mode->mode_line(s, buf, sizeof(buf));
         if (!strequal(buf, s->modeline_shadow)) {
             print_at_byte(s->screen,
                           s->xleft,
-                          s->ytop + s->height,
+                          y,
                           s->width,
                           s->qe_state->mode_line_height,
                           buf, QE_STYLE_MODE_LINE);
@@ -2233,6 +2347,8 @@
     s->base = base;
     s->x_disp = s->edit_state->x_disp[base];
     s->x = s->x_disp;
+    s->style = 0;
+    s->last_style = 0;
     s->fragment_index = 0;
     s->line_index = 0;
     s->nb_fragments = 0;
@@ -2648,6 +2764,9 @@
             /* move the remaining fragment to next line */
             s->nb_fragments = 0;
             s->x = 0;
+            if (s->edit_state->line_numbers) {
+                /* should skip line number column if present */
+            }
             if (len1 > 0) {
                 memmove(s->fragments, frag, sizeof(TextFragment));
                 frag = s->fragments;
@@ -2691,7 +2810,7 @@
     int space, style, istab;
     EditState *e;
 
-    style = (ch >> STYLE_SHIFT);
+    style = s->style;
 
     /* special code to colorize block */
     e = s->edit_state;
@@ -2709,7 +2828,6 @@
         offset2 = -1;
     }
 
-    ch = ch & ~STYLE_MASK;
     space = (ch == ' ');
     istab = (ch == '\t');
     /* a fragment is a part of word where style/embedding_level do not
@@ -2893,7 +3011,7 @@
 #define COLORIZED_LINE_PREALLOC_SIZE 64
 
 int get_colorized_line(EditState *s, unsigned int *buf, int buf_size,
-                       int offset1, int line_num)
+                       int *offsetp, int line_num)
 {
     int len, l, line, col, offset;
     int colorize_state;
@@ -2934,7 +3052,7 @@
     }
 
     /* compute line color */
-    len = eb_get_line(s->b, buf, buf_size, &offset1);
+    len = eb_get_line(s->b, buf, buf_size, offsetp);
     // XXX: should force \0 instead of \n
     buf[len] = '\n';
 
@@ -2999,7 +3117,7 @@
     int char_index, colored_nb_chars;
 
     line_num = 0; /* avoid warning */
-    if (s->line_numbers || s->colorize_func) {
+    if (s->line_numbers || s->get_colorized_line_func) {
         eb_get_pos(s->b, &line_num, &col_num, offset);
     }
 
@@ -3035,7 +3153,9 @@
 
     /* line numbers */
     if (s->line_numbers) {
+        ds->style = QE_STYLE_COMMENT;
         display_printf(ds, -1, -1, "%6d  ", line_num + 1);
+        ds->style = 0;
     }
 
     /* prompt display */
@@ -3048,15 +3168,52 @@
     }
 
     /* colorize */
+    colored_nb_chars = 0;
+    offset0 = offset;
     if (s->get_colorized_line_func) {
         colored_nb_chars = s->get_colorized_line_func(s, colored_chars,
                                                       countof(colored_chars),
-                                                      offset, line_num);
-    } else {
-        colored_nb_chars = 0;
+                                                      &offset0, line_num);
     }
 
-    /* CG: should colorize regions: s->curline_style, s->region_style */
+#if 1
+    /* colorize regions */
+    if (s->curline_style || s->region_style) {
+        if (!s->get_colorized_line_func) {
+            offset0 = offset;
+            colored_nb_chars = eb_get_line(s->b, colored_chars,
+                countof(colored_chars), &offset0);
+        }
+        /* CG: Should combine styles instead of replacing */
+        if (s->region_style) {
+            int line, start, stop;
+
+            if (s->b->mark < s->offset) {
+                start = max(offset, s->b->mark);
+                stop = min(offset0, s->offset);
+            } else {
+                start = max(offset, s->offset);
+                stop = min(offset0, s->b->mark);
+            }
+            if (start < stop) {
+                /* Compute character positions */
+                eb_get_pos(s->b, &line, &start, start);
+                if (stop >= offset0)
+                    stop = colored_nb_chars;
+                else
+                    eb_get_pos(s->b, &line, &stop, stop);
+                clear_color(colored_chars + start, stop - start);
+                set_color(colored_chars + start, colored_chars + stop,
+                          s->region_style);
+            }
+        } else
+        if (s->curline_style && s->offset >= offset && s->offset <= offset0) {
+            clear_color(colored_chars, colored_nb_chars);
+            set_color(colored_chars, colored_chars + colored_nb_chars,
+                      s->curline_style);
+        }
+    }
+#endif
 
     bd = embeds + 1;
     char_index = 0;
@@ -3067,12 +3224,18 @@
             offset = -1; /* signal end of text */
             break;
         } else {
+            /* Should simplify this if colored line was computed */
+            ds->style = 0;
+            if (char_index < colored_nb_chars) {
+                /* colored_chars should just be a style array */
+                c = colored_chars[char_index];
+                ds->style = c >> STYLE_SHIFT;
+            }
             c = eb_nextc(s->b, offset, &offset);
             if (c == '\n') {
                 display_eol(ds, offset0, offset);
                 break;
             }
-
             /* compute embedding from RLE embedding list */
             if (offset0 >= bd[1].pos)
                 bd++;
@@ -3089,8 +3252,6 @@
             if (c >= 256 && s->screen->charset != &charset_utf8) {
                 display_printf(ds, offset0, offset, "\\u%04x", c);
             } else {
-                if (char_index < colored_nb_chars)
-                    c = colored_chars[char_index];
                 display_char_bidir(ds, offset0, offset, embedding_level, c);
             }
             char_index++;
@@ -3581,6 +3742,16 @@
     parse_args(es);
 }
 
+int check_read_only(EditState *s)
+{
+    if (s->b->flags & BF_READONLY) {
+        put_status(s, "Buffer is read-only");
+        return 1;
+    } else {
+        return 0;
+    }
+}
+
 void do_execute_command(EditState *s, const char *cmd, int argval)
 {
     CmdDef *d;
@@ -4006,7 +4177,7 @@
                    int x, int y, int width, int height,
                    const char *str, int style_index)
 {
-    unsigned int ubuf[256];
+    unsigned int ubuf[MAX_SCREEN_WIDTH];
     int len;
     QEStyleDef style;
     QEFont *font;
@@ -4098,6 +4269,20 @@
     }
 }
 
+#if 0
+EditState *find_file_window(const char *filename)
+{
+    QEmacsState *qs = &qe_state;
+    EditState *s;
+
+    for (s = qs->first_window; s; s = s->next_window) {
+        if (strequal(s->b->filename, filename))
+            return s;
+    }
+    return NULL;
+}
+#endif
+
 void switch_to_buffer(EditState *s, EditBuffer *b)
 {
     QEmacsState *qs = s->qe_state;
@@ -5068,6 +5253,8 @@
     /* First we try to read the first block to determine the data type */
     if (stat(filename, &st) < 0) {
         /* CG: should check for wildcards and do dired */
+        //if (strchr(filename, '*') || strchr(filename, '?'))
+        //    goto dired;
         put_status(s, "(New file)");
         /* Try to determine the desired mode based on the filename.
          * This avoids having to set c-mode for each new .c or .h file. */
@@ -7308,7 +7495,7 @@
 
     ffst = find_file_open(qs->res_path, "*.so");
     if (!ffst)
-        return;
+        goto done;
 
     while (!find_file_next(ffst, filename, sizeof(filename))) {
         h = dlopen(filename, RTLD_LAZY);
@@ -7331,6 +7518,8 @@
         init_func();
     }
     find_file_close(ffst);
+
+done:
     qs->ec = ec;
 }
 
@@ -7360,6 +7549,8 @@
     qs->argc = argc;
     qs->argv = argv;
 
+    qs->hilite_region = 1;
+
     /* setup resource path */
     set_user_option(NULL);
 

Index: qe.h
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.h,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -b -r1.59 -r1.60
--- qe.h        8 Jan 2008 16:37:55 -0000       1.59
+++ qe.h        9 Jan 2008 13:41:41 -0000       1.60
@@ -683,7 +683,6 @@
     Page *page_table;
     int nb_pages;
     int mark;       /* current mark (moved with text) */
-    //int yank_mark;  /* start of last yank (emacs) */
     int total_size; /* total size of the buffer */
     int modified;
 
@@ -881,7 +880,7 @@
 /* colorize & transform a line, lower level then ColorizeFunc */
 typedef int (*GetColorizedLineFunc)(EditState *s,
                                     unsigned int *buf, int buf_size,
-                                    int offset1, int line_num);
+                                    int *offset1, int line_num);
 
 /* colorize a line : this function modifies buf to set the char
    styles. 'buf' is guaranted to have one more char after its len
@@ -964,8 +963,8 @@
     int borders_invalid; /* true if window borders should be redrawn */
     int show_selection;  /* if true, the selection is displayed */
 
-    //int region_style;
-    //int curline_style;
+    int region_style;
+    int curline_style;
 
     /* display area info */
     int width, height;
@@ -1000,7 +999,7 @@
 /* Ugly patch for saving/restoring window data upon switching buffer */
 #define SAVED_DATA_SIZE  offsetof(EditState, end_of_saved_data)
 
-struct DisplayState;
+typedef struct DisplayState DisplayState;
 
 typedef struct ModeProbeData {
     const char *filename;
@@ -1037,7 +1036,7 @@
     void (*display)(EditState *);
 
     /* text related functions */
-    int (*text_display)(EditState *, struct DisplayState *, int);
+    int (*text_display)(EditState *, DisplayState *, int);
     int (*text_backward_offset)(EditState *, int);
 
     /* common functions are defined here */
@@ -1174,8 +1173,7 @@
     //int no_config;      /* prevent config file eval */
     //int force_refresh;  /* force a complete screen refresh */
     //int ignore_spaces;  /* ignore spaces when comparing windows */
-    //int mark_yank_region; /* set mark at opposite end of yanked block */
-    //int hilite_region;  /* hilite the current region when selecting */
+    int hilite_region;  /* hilite the current region when selecting */
     //int mmap_threshold; /* minimum file size for mmap */
 };
 
@@ -1291,7 +1289,7 @@
 #define STYLE_MASK       (((1 << STYLE_BITS) - 1) << STYLE_SHIFT)
 #define CHAR_MASK        ((1 << STYLE_SHIFT) - 1)
 
-typedef struct DisplayState {
+struct DisplayState {
     int do_disp; /* true if real display */
     int width;   /* display window width */
     int height;  /* display window height */
@@ -1315,6 +1313,7 @@
     int wrap;
     int eol_reached;
     EditState *edit_state;
+    int style;  /* css display style */
 
     /* fragment buffers */
     TextFragment fragments[MAX_SCREEN_WIDTH];
@@ -1337,7 +1336,7 @@
     int last_space;
     int last_style;
     int last_embedding_level;
-} DisplayState;
+};
 
 enum DisplayType {
     DISP_CURSOR,
@@ -1373,6 +1372,13 @@
     *p |= style << STYLE_SHIFT;
 }
 
+static inline void clear_color(unsigned int *p, int count) {
+    int i;
+
+    for (i = 0; i < count; i++)
+        p[i] &= ~STYLE_MASK;
+}
+
 /* input.c */
 
 #define INPUTMETHOD_NOMATCH   (-1)
@@ -1464,6 +1470,7 @@
 
 /* popup / low level window handling */
 void show_popup(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);
 void do_find_window(EditState *s, int key);
@@ -1520,7 +1527,7 @@
 
 void set_colorize_func(EditState *s, ColorizeFunc colorize_func);
 int get_colorized_line(EditState *s, unsigned int *buf, int buf_size,
-                       int offset1, int line_num);
+                       int *offsetp, int line_num);
 
 void do_char(EditState *s, int key, int argval);
 void do_set_mode(EditState *s, const char *name);

Index: qestyles.h
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qestyles.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- qestyles.h  3 Jan 2008 09:51:31 -0000       1.6
+++ qestyles.h  9 Jan 2008 13:41:41 -0000       1.7
@@ -63,6 +63,11 @@
               QERGB(0x98, 0xf8, 0x98), COLOR_TRANSPARENT,
               0, 0)
 
+    /* popup / region styles */
+    STYLE_DEF(QE_STYLE_REGION_HILITE, "region-hilite",
+              COLOR_TRANSPARENT, QERGB(0x80, 0xf0, 0xf0),
+              0, 0)
+
     /* HTML coloring styles */
     STYLE_DEF(QE_STYLE_HTML_COMMENT, "html-comment",
               QERGB(0xf8, 0x44, 0x00), COLOR_TRANSPARENT,

Index: shell.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/shell.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- shell.c     8 Jan 2008 16:37:55 -0000       1.41
+++ shell.c     9 Jan 2008 13:41:41 -0000       1.42
@@ -77,23 +77,9 @@
 
 } ShellState;
 
-static int shell_get_colorized_line(EditState *e,
-                                    unsigned int *buf, int buf_size,
-                                    int offset, int line_num);
-
 /* move to mode */
 static int shell_launched = 0;
 
-static int shell_mode_init(EditState *s, __unused__ ModeSavedData *saved_data)
-{
-    s->tab_size = 8;
-    s->wrap = WRAP_TRUNCATE;
-    s->interactive = 1;
-    set_colorize_func(s, NULL);
-    s->get_colorized_line_func = shell_get_colorized_line;
-    return 0;
-}
-
 #define PTYCHAR1 "pqrstuvwxyz"
 #define PTYCHAR2 "0123456789abcdef"
 
@@ -936,18 +922,19 @@
 
 static int shell_get_colorized_line(EditState *e,
                                     unsigned int *buf, int buf_size,
-                                    int offset, __unused__ int line_num)
+                                    int *offsetp, __unused__ int line_num)
 {
     EditBuffer *b = e->b;
     ShellState *s = b->priv_data;
     EditBuffer *b_color = s->b_color;
-    int color, offset1, c;
+    int color, offset, offset1, c;
     unsigned int *buf_ptr, *buf_end;
     unsigned char buf1[1];
 
     /* record line */
+    offset = *offsetp;
     buf_ptr = buf;
-    buf_end = buf + buf_size;
+    buf_end = buf + buf_size - 1;
     for (;;) {
         eb_read(b_color, offset, buf1, 1);
         color = buf1[0];
@@ -963,6 +950,9 @@
         }
         offset = offset1;
     }
+    *buf_ptr = '\0';
+    *offsetp = offset1;
+
     return buf_ptr - buf;
 }
 
@@ -1439,6 +1429,16 @@
     CMD_DEF_END,
 };
 
+static int shell_mode_init(EditState *s, __unused__ ModeSavedData *saved_data)
+{
+    s->tab_size = 8;
+    s->wrap = WRAP_TRUNCATE;
+    s->interactive = 1;
+    set_colorize_func(s, NULL);
+    s->get_colorized_line_func = shell_get_colorized_line;
+    return 0;
+}
+
 static int shell_init(void)
 {
     /* first register mode */

Index: unihex.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/unihex.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- unihex.c    8 Jan 2008 16:37:55 -0000       1.12
+++ unihex.c    9 Jan 2008 13:41:41 -0000       1.13
@@ -58,6 +58,7 @@
     eof = 0;
     display_bol(ds);
 
+    ds->style = QE_STYLE_COMMENT;
     display_printf(ds, -1, -1, "%08x ", offset);
 
     len = 0;
@@ -72,6 +73,8 @@
     }
     pos[len] = offset;
 
+    ds->style = QE_STYLE_FUNCTION;
+
     for (j = 0; j < s->disp_width; j++) {
         display_char(ds, -1, -1, ' ');
         if (j < len) {
@@ -87,6 +90,8 @@
         if ((j & 7) == 7)
             display_char(ds, -1, -1, ' ');
     }
+    ds->style = 0;
+
     display_char(ds, -1, -1, ' ');
     display_char(ds, -1, -1, ' ');
 
@@ -106,6 +111,7 @@
             }
         }
     }
+    ds->style = 0;
     display_eol(ds, -1, -1);
 
     if (len >= s->disp_width)




reply via email to

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