[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs display.c display.h hex.c html2png.c ima...
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs display.c display.h hex.c html2png.c ima... |
Date: |
Fri, 11 Jan 2008 11:29:29 +0000 |
CVSROOT: /cvsroot/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 08/01/11 11:29:29
Modified files:
. : display.c display.h hex.c html2png.c image.c
input.c qe.c qe.h tty.c unihex.c util.c video.c
win32.c x11.c
Log message:
moved input_methods to QEmacsState
qe_register_binding takes ModeDef* and returns status
cosmetic changes in QEDisplay API
added int dpy_init(QEditScreen *s, QEDisplay *dpy, int w, int h);
copies *dpy (or dummy_dpy if NULL) to QEditScreen and calls method
simplified dpy_init methods and calls
inlined 5 more methods
moved dummy_dpy to display.c and simplified
simplified to_hex
simplified qe_colors array handling
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/display.c?cvsroot=qemacs&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/qemacs/display.h?cvsroot=qemacs&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/qemacs/hex.c?cvsroot=qemacs&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/qemacs/html2png.c?cvsroot=qemacs&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/qemacs/image.c?cvsroot=qemacs&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/qemacs/input.c?cvsroot=qemacs&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.65&r2=1.66
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.61&r2=1.62
http://cvs.savannah.gnu.org/viewcvs/qemacs/tty.c?cvsroot=qemacs&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/qemacs/unihex.c?cvsroot=qemacs&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/qemacs/util.c?cvsroot=qemacs&r1=1.36&r2=1.37
http://cvs.savannah.gnu.org/viewcvs/qemacs/video.c?cvsroot=qemacs&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/qemacs/win32.c?cvsroot=qemacs&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/qemacs/x11.c?cvsroot=qemacs&r1=1.23&r2=1.24
Patches:
Index: display.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/display.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- display.c 3 Jan 2008 09:51:30 -0000 1.11
+++ display.c 11 Jan 2008 11:29:28 -0000 1.12
@@ -22,6 +22,101 @@
static QEDisplay *first_dpy;
+/* dummy display driver for initialization time */
+
+static int dummy_dpy_init(QEditScreen *s, __unused__ int w, __unused__ int h)
+{
+ s->charset = &charset_8859_1;
+
+ return 0;
+}
+
+static void dummy_dpy_close(__unused__ QEditScreen *s)
+{
+}
+
+static void dummy_dpy_flush(__unused__ QEditScreen *s)
+{
+}
+
+static int dummy_dpy_is_user_input_pending(__unused__ QEditScreen *s)
+{
+ return 0;
+}
+
+static void dummy_dpy_fill_rectangle(__unused__ QEditScreen *s,
+ __unused__ int x1, __unused__ int y1,
+ __unused__ int w, __unused__ int h,
+ __unused__ QEColor color)
+{
+}
+
+static QEFont *dummy_dpy_open_font(__unused__ QEditScreen *s,
+ __unused__ int style, __unused__ int size)
+{
+ return NULL;
+}
+
+static void dummy_dpy_close_font(__unused__ QEditScreen *s,
+ __unused__ QEFont *font)
+{
+}
+
+static void dummy_dpy_text_metrics(__unused__ QEditScreen *s,
+ __unused__ QEFont *font,
+ QECharMetrics *metrics,
+ __unused__ const unsigned int *str,
+ __unused__ int len)
+{
+ metrics->font_ascent = 1;
+ metrics->font_descent = 0;
+ metrics->width = len;
+}
+
+static void dummy_dpy_draw_text(__unused__ QEditScreen *s,
+ __unused__ QEFont *font,
+ __unused__ int x, __unused__ int y,
+ __unused__ const unsigned int *str,
+ __unused__ int len,
+ __unused__ QEColor color)
+{
+}
+
+static void dummy_dpy_set_clip(__unused__ QEditScreen *s,
+ __unused__ int x, __unused__ int y,
+ __unused__ int w, __unused__ int h)
+{
+}
+
+static QEDisplay const dummy_dpy = {
+ "dummy",
+ NULL,
+ dummy_dpy_init,
+ dummy_dpy_close,
+ dummy_dpy_flush,
+ dummy_dpy_is_user_input_pending,
+ dummy_dpy_fill_rectangle,
+ dummy_dpy_open_font,
+ dummy_dpy_close_font,
+ dummy_dpy_text_metrics,
+ dummy_dpy_draw_text,
+ dummy_dpy_set_clip,
+
+ NULL, /* dpy_selection_activate */
+ NULL, /* dpy_selection_request */
+ NULL, /* dpy_invalidate */
+ NULL, /* dpy_cursor_at */
+ NULL, /* dpy_bmp_alloc */
+ NULL, /* dpy_bmp_free */
+ NULL, /* dpy_bmp_draw */
+ NULL, /* dpy_bmp_lock */
+ NULL, /* dpy_bmp_unlock */
+ NULL, /* dpy_full_screen */
+ NULL, /* next */
+};
+
+/*----------------*/
+
void fill_rectangle(QEditScreen *s,
int x1, int y1, int w, int h, QEColor color)
{
@@ -113,12 +208,12 @@
int qe_register_display(QEDisplay *dpy)
{
- QEDisplay **p;
+ QEDisplay **pp;
- p = &first_dpy;
- while (*p != NULL)
- p = &(*p)->next;
- *p = dpy;
+ pp = &first_dpy;
+ while (*pp != NULL)
+ pp = &(*pp)->next;
+ *pp = dpy;
dpy->next = NULL;
return 0;
}
@@ -132,8 +227,7 @@
dpy = NULL;
probe_max = 0;
while (p != NULL) {
- // CG: probe = p->dpy_probe ? p->dpy_probe() : 0;
- probe = p->dpy_probe();
+ probe = p->dpy_probe ? p->dpy_probe() : 0;
if (probe >= probe_max) {
probe_max = probe;
dpy = p;
@@ -143,6 +237,12 @@
return dpy;
}
+int dpy_init(QEditScreen *s, QEDisplay *dpy, int w, int h)
+{
+ s->dpy = dpy ? *dpy : dummy_dpy;
+ return s->dpy.dpy_init(s, w, h);
+}
+
/* simple font cache */
#define FONT_CACHE_SIZE 32
@@ -205,18 +305,6 @@
return fc;
}
-void selection_activate(QEditScreen *s)
-{
- if (s->dpy.dpy_selection_activate)
- s->dpy.dpy_selection_activate(s);
-}
-
-void selection_request(QEditScreen *s)
-{
- if (s->dpy.dpy_selection_request)
- s->dpy.dpy_selection_request(s);
-}
-
QEBitmap *bmp_alloc(QEditScreen *s, int width, int height, int flags)
{
QEBitmap *b;
@@ -244,27 +332,6 @@
}
}
-void bmp_draw(QEditScreen *s, QEBitmap *b,
- int dst_x, int dst_y, int dst_w, int dst_h,
- int offset_x, int offset_y, int flags)
-{
- s->dpy.dpy_bmp_draw(s, b, dst_x, dst_y, dst_w, dst_h,
- offset_x, offset_y, flags);
-}
-
-/* used to access the bitmap data. Return the necessary pointers to
- modify the image in 'pict'. */
-void bmp_lock(QEditScreen *s, QEBitmap *bitmap, QEPicture *pict,
- int x1, int y1, int w1, int h1)
-{
- s->dpy.dpy_bmp_lock(s, bitmap, pict, x1, y1, w1, h1);
-}
-
-void bmp_unlock(QEditScreen *s, QEBitmap *bitmap)
-{
- s->dpy.dpy_bmp_unlock(s, bitmap);
-}
-
#if 0
/* bitmap cache */
typedef struct QECachedBitmap {
Index: display.h
===================================================================
RCS file: /cvsroot/qemacs/qemacs/display.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- display.h 3 Jan 2008 09:51:30 -0000 1.10
+++ display.h 11 Jan 2008 11:29:28 -0000 1.11
@@ -106,7 +106,6 @@
int (*dpy_probe)(void);
int (*dpy_init)(QEditScreen *s, int w, int h);
void (*dpy_close)(QEditScreen *s);
- void (*dpy_cursor_at)(QEditScreen *s, int x1, int y1, int w, int h);
void (*dpy_flush)(QEditScreen *s);
int (*dpy_is_user_input_pending)(QEditScreen *s);
void (*dpy_fill_rectangle)(QEditScreen *s,
@@ -121,9 +120,13 @@
QEColor color);
void (*dpy_set_clip)(QEditScreen *s,
int x, int y, int w, int h);
+
+ /* These are optional, may be NULL */
void (*dpy_selection_activate)(QEditScreen *s);
void (*dpy_selection_request)(QEditScreen *s);
- void (*dpy_invalidate)(void);
+ void (*dpy_invalidate)(QEditScreen *s);
+ void (*dpy_cursor_at)(QEditScreen *s, int x1, int y1, int w, int h);
+
/* bitmap support */
int (*dpy_bmp_alloc)(QEditScreen *s, QEBitmap *b);
void (*dpy_bmp_free)(QEditScreen *s, QEBitmap *b);
@@ -139,7 +142,7 @@
};
struct QEditScreen {
- struct QEDisplay dpy;
+ QEDisplay dpy;
FILE *STDIN, *STDOUT;
int width, height;
QECharset *charset; /* the charset of the TTY, XXX: suppress that,
@@ -153,11 +156,19 @@
void *private;
};
-static inline void draw_text(QEditScreen *s, QEFont *font,
- int x, int y, const unsigned int *str, int len,
- QEColor color)
+int qe_register_display(QEDisplay *dpy);
+QEDisplay *probe_display(void);
+
+int dpy_init(QEditScreen *s, QEDisplay *dpy, int w, int h);
+
+static inline void dpy_close(QEditScreen *s)
{
- s->dpy.dpy_draw_text(s, font, x, y, str, len, color);
+ s->dpy.dpy_close(s);
+}
+
+static inline void dpy_flush(QEditScreen *s)
+{
+ s->dpy.dpy_flush(s);
}
static inline QEFont *open_font(QEditScreen *s,
@@ -179,6 +190,55 @@
s->dpy.dpy_text_metrics(s, font, metrics, str, len);
}
+static inline void draw_text(QEditScreen *s, QEFont *font,
+ int x, int y, const unsigned int *str, int len,
+ QEColor color)
+{
+ s->dpy.dpy_draw_text(s, font, x, y, str, len, color);
+}
+
+static inline void selection_activate(QEditScreen *s)
+{
+ if (s->dpy.dpy_selection_activate)
+ s->dpy.dpy_selection_activate(s);
+}
+
+static inline void selection_request(QEditScreen *s)
+{
+ if (s->dpy.dpy_selection_request)
+ s->dpy.dpy_selection_request(s);
+}
+
+static inline void dpy_invalidate(QEditScreen *s)
+{
+ if (s->dpy.dpy_invalidate)
+ s->dpy.dpy_invalidate(s);
+}
+
+QEBitmap *bmp_alloc(QEditScreen *s, int width, int height, int flags);
+void bmp_free(QEditScreen *s, QEBitmap **bp);
+
+static inline void bmp_draw(QEditScreen *s, QEBitmap *b,
+ int dst_x, int dst_y, int dst_w, int dst_h,
+ int offset_x, int offset_y, int flags)
+{
+ s->dpy.dpy_bmp_draw(s, b, dst_x, dst_y, dst_w, dst_h,
+ offset_x, offset_y, flags);
+}
+
+/* used to access the bitmap data. Return the necessary pointers to
+ modify the image in 'pict'. */
+static inline void bmp_lock(QEditScreen *s, QEBitmap *bitmap, QEPicture *pict,
+ int x1, int y1, int w1, int h1)
+{
+ s->dpy.dpy_bmp_lock(s, bitmap, pict, x1, y1, w1, h1);
+}
+
+static inline void bmp_unlock(QEditScreen *s, QEBitmap *bitmap)
+{
+ s->dpy.dpy_bmp_unlock(s, bitmap);
+}
+
/* XXX: only needed for backward compatibility */
static inline int glyph_width(QEditScreen *s, QEFont *font, int ch)
{
@@ -189,23 +249,11 @@
return metrics.width;
}
-static inline void dpy_flush(QEditScreen *s)
-{
- s->dpy.dpy_flush(s);
-}
-
-static inline void dpy_close(QEditScreen *s)
-{
- s->dpy.dpy_close(s);
-}
-
void fill_rectangle(QEditScreen *s,
int x1, int y1, int w, int h, QEColor color);
void set_clip_rectangle(QEditScreen *s, CSSRect *r);
void push_clip_rectangle(QEditScreen *s, CSSRect *or, CSSRect *r);
-int qe_register_display(QEDisplay *dpy);
-QEDisplay *probe_display(void);
QEFont *select_font(QEditScreen *s, int style, int size);
static inline QEFont *lock_font(__unused__ QEditScreen *s, QEFont *font) {
@@ -218,16 +266,4 @@
font->refcount--;
}
-void selection_activate(QEditScreen *s);
-void selection_request(QEditScreen *s);
-
-QEBitmap *bmp_alloc(QEditScreen *s, int width, int height, int flags);
-void bmp_free(QEditScreen *s, QEBitmap **bp);
-void bmp_draw(QEditScreen *s, QEBitmap *b,
- int dst_x, int dst_y, int dst_w, int dst_h,
- int offset_x, int offset_y, int flags);
-void bmp_lock(QEditScreen *s, QEBitmap *bitmap, QEPicture *pict,
- int x1, int y1, int w1, int h1);
-void bmp_unlock(QEditScreen *s, QEBitmap *bitmap);
-
#endif
Index: hex.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/hex.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- hex.c 9 Jan 2008 13:41:41 -0000 1.20
+++ hex.c 11 Jan 2008 11:29:28 -0000 1.21
@@ -367,8 +367,8 @@
qe_register_cmd_table(hex_commands, &ascii_mode);
/* additional mode specific keys */
- qe_register_binding(KEY_TAB, "toggle-hex", "hex");
- qe_register_binding(KEY_SHIFT_TAB, "toggle-hex", "hex");
+ qe_register_binding(KEY_TAB, "toggle-hex", &hex_mode);
+ qe_register_binding(KEY_SHIFT_TAB, "toggle-hex", &hex_mode);
return 0;
}
Index: html2png.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/html2png.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- html2png.c 3 Jan 2008 09:51:31 -0000 1.11
+++ html2png.c 11 Jan 2008 11:29:28 -0000 1.12
@@ -111,7 +111,6 @@
NULL,
ppm_init,
ppm_close,
- NULL, /* dpy_cursor_at */
NULL, /* dpy_flush */
NULL, /* dpy_is_user_input_pending */
NULL, /* dpy_fill_rectangle */
@@ -123,6 +122,7 @@
NULL, /* dpy_selection_activate */
NULL, /* dpy_selection_request */
NULL, /* dpy_invalidate */
+ NULL, /* dpy_cursor_at */
NULL, /* dpy_bmp_alloc */
NULL, /* dpy_bmp_free */
NULL, /* dpy_bmp_draw */
@@ -156,8 +156,6 @@
{
CFBContext *cfb;
- memcpy(&s->dpy, &ppm_dpy, sizeof(QEDisplay));
-
cfb = qe_malloc(CFBContext);
if (!cfb)
return -1;
@@ -430,7 +428,6 @@
int main(int argc, char **argv)
{
- QEDisplay *dpy;
QEditScreen screen1, *screen = &screen1;
int page_width, c, strict_xml, flags;
const char *outfilename, *infilename;
@@ -485,8 +482,7 @@
infilename = argv[optind];
/* init display driver with dummy height */
- dpy = &ppm_dpy;
- if (dpy->dpy_init(screen, page_width, 1) < 0) {
+ if (dpy_init(screen, &ppm_dpy, page_width, 1) < 0) {
fprintf(stderr, "Could not init display driver\n");
exit(1);
}
@@ -508,6 +504,6 @@
#endif
/* close screen */
- screen->dpy.dpy_close(screen);
+ dpy_close(screen);
return 0;
}
Index: image.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/image.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- image.c 8 Jan 2008 03:42:55 -0000 1.17
+++ image.c 11 Jan 2008 11:29:29 -0000 1.18
@@ -855,7 +855,7 @@
qe_register_cmd_table(image_commands, &image_mode);
register_completion("pixel_format", pixel_format_completion);
/* additional mode specific keys */
- qe_register_binding('f', "toggle-full-screen", "image");
+ qe_register_binding('f', "toggle-full-screen", &image_mode);
return 0;
}
Index: input.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/input.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- input.c 10 Jan 2008 12:21:05 -0000 1.19
+++ input.c 11 Jan 2008 11:29:29 -0000 1.20
@@ -24,8 +24,6 @@
#include <sys/mman.h>
#endif
-static InputMethod *input_methods;
-
static int default_input(__unused__ int *match_buf,
__unused__ int match_buf_size,
__unused__ int *match_len_ptr,
@@ -74,9 +72,10 @@
void register_input_method(InputMethod *m)
{
+ QEmacsState *qs = &qe_state;
InputMethod **p;
- p = &input_methods;
+ p = &qs->input_methods;
while (*p != NULL) {
p = &(*p)->next;
}
@@ -86,18 +85,20 @@
static void input_completion(CompleteState *cp)
{
+ QEmacsState *qs = cp->s->qe_state;
InputMethod *m;
- for (m = input_methods; m != NULL; m = m->next) {
+ for (m = qs->input_methods; m != NULL; m = m->next) {
complete_test(cp, m->name);
}
}
static InputMethod *find_input_method(const char *name)
{
+ QEmacsState *qs = &qe_state;
InputMethod *m;
- for (m = input_methods; m != NULL; m = m->next) {
+ for (m = qs->input_methods; m != NULL; m = m->next) {
if (strequal(m->name, name))
return m;
}
@@ -118,10 +119,10 @@
void do_switch_input_method(EditState *s)
{
- if (!s->input_method)
- s->input_method = s->selected_input_method;
- else
+ if (s->input_method)
s->input_method = NULL;
+ else
+ s->input_method = s->selected_input_method;
}
void init_input_methods(void)
Index: qe.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -b -r1.65 -r1.66
--- qe.c 10 Jan 2008 12:21:05 -0000 1.65
+++ qe.c 11 Jan 2008 11:29:29 -0000 1.66
@@ -61,7 +61,6 @@
static void save_selection(void);
#endif
static CompletionFunc find_completion(const char *name);
-static int dummy_dpy_init(QEditScreen *s, int w, int h);
QEmacsState qe_state;
/* should handle multiple screens, and multiple sessions */
@@ -166,6 +165,9 @@
KeyDef **lp, *p;
int i;
+ if (!d)
+ return -1;
+
/* add key */
p = qe_malloc_hack(KeyDef, (nb_keys - 1) * sizeof(p->keys[0]));
if (!p)
@@ -190,7 +192,7 @@
}
/* convert compressed mappings to real ones */
-static void qe_register_binding2(int key, CmdDef *d, ModeDef *m)
+static int qe_register_binding2(int key, CmdDef *d, ModeDef *m)
{
int nb_keys;
unsigned int keys[3];
@@ -209,7 +211,7 @@
} else {
keys[nb_keys++] = key;
}
- qe_register_binding1(keys, nb_keys, d, m);
+ return qe_register_binding1(keys, nb_keys, d, m);
}
#if 0
@@ -278,36 +280,9 @@
/* key binding handling */
-void qe_register_binding(int key, const char *cmd_name, const char *mode_names)
+int qe_register_binding(int key, const char *cmd_name, ModeDef *m)
{
- CmdDef *d;
- ModeDef *m;
- const char *p, *r;
- char mode_name[64];
-
- d = qe_find_cmd(cmd_name);
- if (!d)
- return;
- if (!mode_names || mode_names[0] == '\0') {
- qe_register_binding2(key, d, NULL);
- } else {
- p = mode_names;
- for (;;) {
- r = strchr(p, '|');
- if (r) {
- pstrncpy(mode_name, sizeof(mode_name), p, r - p);
- } else {
- pstrcpy(mode_name, sizeof(mode_name), p);
- }
- m = find_mode(mode_name);
- if (m) {
- qe_register_binding2(key, d, m);
- }
- if (!r)
- break;
- p = r + 1;
- }
- }
+ return qe_register_binding2(key, qe_find_cmd(cmd_name), m);
}
void command_completion(CompleteState *cp)
@@ -2123,6 +2098,9 @@
}
}
+#if 1
+/* Should move all this to display.c */
+
/* compute style */
static void apply_style(QEStyleDef *style, int style_index)
{
@@ -2173,8 +2151,8 @@
int i;
QEStyleDef *style;
- for (i = 0; i < QE_STYLE_NB; i++) {
- style = &qe_styles[i];
+ style = qe_styles;
+ for (i = 0; i < QE_STYLE_NB; i++, style++) {
complete_test(cp, style->name);
}
}
@@ -2184,20 +2162,14 @@
int i;
QEStyleDef *style;
- for (i = 0; i < QE_STYLE_NB; i++) {
- style = &qe_styles[i];
+ style = qe_styles;
+ for (i = 0; i < QE_STYLE_NB; i++, style++) {
if (strequal(style->name, name))
return style;
}
return NULL;
}
-void do_define_color(EditState *e, const char *name, const char *value)
-{
- if (css_define_color(name, value))
- put_status(e, "Invalid color '%s'", value);
-}
-
/* Note: we use the same syntax as CSS styles to ease merging */
void do_set_style(EditState *e, const char *stylestr,
const char *propstr, const char *value)
@@ -2212,7 +2184,9 @@
}
prop_index = css_get_enum(propstr,
-
"color,background-color,font-family,font-style,font-weight,font-size,text-decoration");
+ "color,background-color,font-family,"
+ "font-style,font-weight,font-size,"
+ "text-decoration");
if (prop_index < 0) {
put_status(e, "Unknown property '%s'", propstr);
return;
@@ -2274,6 +2248,13 @@
}
}
+void do_define_color(EditState *e, const char *name, const char *value)
+{
+ if (css_define_color(name, value))
+ put_status(e, "Invalid color '%s'", value);
+}
+#endif
+
void do_set_display_size(__unused__ EditState *s, int w, int h)
{
if (w != NO_ARG && h != NO_ARG) {
@@ -4279,7 +4260,7 @@
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
- if (qs->screen->dpy.dpy_init == dummy_dpy_init) {
+ if (!qs->screen->dpy.dpy_probe) {
eb_format_message(qs, "*errors*", buf);
} else {
if (!strequal(buf, qs->status_shadow)) {
@@ -6119,8 +6100,7 @@
int width, height, resized;
if (qs->complete_refresh) {
- if (qs->screen->dpy.dpy_invalidate)
- qs->screen->dpy.dpy_invalidate();
+ dpy_invalidate(qs->screen);
}
/* recompute various dimensions */
@@ -7388,115 +7368,6 @@
#include "qeconfig.h"
-/* dummy display driver for initialization time */
-
-static int dummy_dpy_probe(void)
-{
- return 1;
-}
-
-extern QEDisplay dummy_dpy;
-
-static int dummy_dpy_init(QEditScreen *s, __unused__ int w, __unused__ int h)
-{
- memcpy(&s->dpy, &dummy_dpy, sizeof(QEDisplay));
-
- s->charset = &charset_8859_1;
-
- return 0;
-}
-
-static void dummy_dpy_close(__unused__ QEditScreen *s)
-{
-}
-
-static void dummy_dpy_cursor_at(__unused__ QEditScreen *s,
- __unused__ int x1, __unused__ int y1,
- __unused__ int w, __unused__ int h)
-{
-}
-
-static int dummy_dpy_is_user_input_pending(__unused__ QEditScreen *s)
-{
- return 0;
-}
-
-static void dummy_dpy_fill_rectangle(__unused__ QEditScreen *s,
- __unused__ int x1, __unused__ int y1,
- __unused__ int w, __unused__ int h,
- __unused__ QEColor color)
-{
-}
-
-static QEFont *dummy_dpy_open_font(__unused__ QEditScreen *s,
- __unused__ int style, __unused__ int size)
-{
- return NULL;
-}
-
-static void dummy_dpy_close_font(__unused__ QEditScreen *s,
- __unused__ QEFont *font)
-{
-}
-
-static void dummy_dpy_text_metrics(__unused__ QEditScreen *s,
- __unused__ QEFont *font,
- QECharMetrics *metrics,
- __unused__ const unsigned int *str,
- __unused__ int len)
-{
- metrics->font_ascent = 1;
- metrics->font_descent = 0;
- metrics->width = len;
-}
-
-static void dummy_dpy_draw_text(__unused__ QEditScreen *s,
- __unused__ QEFont *font,
- __unused__ int x, __unused__ int y,
- __unused__ const unsigned int *str,
- __unused__ int len,
- __unused__ QEColor color)
-{
-}
-
-static void dummy_dpy_set_clip(__unused__ QEditScreen *s,
- __unused__ int x, __unused__ int y,
- __unused__ int w, __unused__ int h)
-{
-}
-
-static void dummy_dpy_flush(__unused__ QEditScreen *s)
-{
-}
-
-QEDisplay dummy_dpy = {
- "dummy",
- dummy_dpy_probe,
- dummy_dpy_init,
- dummy_dpy_close,
- dummy_dpy_cursor_at,
- dummy_dpy_flush,
- dummy_dpy_is_user_input_pending,
- dummy_dpy_fill_rectangle,
- dummy_dpy_open_font,
- dummy_dpy_close_font,
- dummy_dpy_text_metrics,
- dummy_dpy_draw_text,
- dummy_dpy_set_clip,
-
- NULL, /* dpy_selection_activate */
- NULL, /* dpy_selection_request */
- NULL, /* dpy_invalidate */
- NULL, /* dpy_bmp_alloc */
- NULL, /* dpy_bmp_free */
- NULL, /* dpy_bmp_draw */
- NULL, /* dpy_bmp_lock */
- NULL, /* dpy_bmp_unlock */
- NULL, /* dpy_full_screen */
- NULL, /* next */
-};
-
-
#if (defined(__GNUC__) || defined(__TINYC__)) && defined(CONFIG_INIT_CALLS)
static void init_all_modules(void)
@@ -7675,10 +7546,10 @@
s = edit_new(b, 0, 0, 0, 0, WF_MODELINE);
/* at this stage, no screen is defined. Initialize a
- * dummy display driver to have a consistent state
+ * null display driver to have a consistent state
* else many commands such as put_status would crash.
*/
- dummy_dpy.dpy_init(&global_screen, screen_width, screen_height);
+ dpy_init(&global_screen, NULL, screen_width, screen_height);
/* handle options */
_optind = parse_command_line(argc, argv);
@@ -7696,7 +7567,7 @@
fprintf(stderr, "No suitable display found, exiting\n");
exit(1);
}
- if (dpy->dpy_init(&global_screen, screen_width, screen_height) < 0) {
+ if (dpy_init(&global_screen, dpy, screen_width, screen_height) < 0) {
/* Just disable the display and try another */
//fprintf(stderr, "Could not initialize display '%s', exiting\n",
// dpy->name);
Index: qe.h
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.h,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -b -r1.61 -r1.62
--- qe.h 10 Jan 2008 12:21:06 -0000 1.61
+++ qe.h 11 Jan 2008 11:29:29 -0000 1.62
@@ -1121,7 +1121,7 @@
//struct QECharset *first_charset;
//struct QETimer *first_timer;
//struct VarDef *first_variable;
- //struct InputMethod *input_methods;
+ struct InputMethod *input_methods;
EditState *first_window;
EditState *active_window; /* window in which we edit */
EditBuffer *first_buffer;
@@ -1264,8 +1264,7 @@
void qe_register_mode(ModeDef *m);
void mode_completion(CompleteState *cp);
void qe_register_cmd_table(CmdDef *cmds, ModeDef *m);
-void qe_register_binding(int key, const char *cmd_name,
- const char *mode_names);
+int qe_register_binding(int key, const char *cmd_name, ModeDef *m);
CmdDef *qe_find_cmd(const char *cmd_name);
/* text display system */
Index: tty.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/tty.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- tty.c 8 Jan 2008 16:37:55 -0000 1.35
+++ tty.c 11 Jan 2008 11:29:29 -0000 1.36
@@ -101,8 +101,6 @@
return 1;
}
-static QEDisplay tty_dpy;
-
static int tty_term_init(QEditScreen *s,
__unused__ int w, __unused__ int h)
{
@@ -110,8 +108,6 @@
struct termios tty;
struct sigaction sig;
- memcpy(&s->dpy, &tty_dpy, sizeof(QEDisplay));
-
s->STDIN = stdin;
s->STDOUT = stdout;
@@ -295,7 +291,7 @@
s->clip_y2 = s->height;
}
-static void tty_term_invalidate(void)
+static void tty_term_invalidate(QEditScreen *s)
{
tty_resize(0);
}
@@ -841,7 +837,6 @@
tty_term_probe,
tty_term_init,
tty_term_close,
- tty_term_cursor_at,
tty_term_flush,
tty_term_is_user_input_pending,
tty_term_fill_rectangle,
@@ -853,6 +848,7 @@
NULL, /* dpy_selection_activate */
NULL, /* dpy_selection_request */
tty_term_invalidate,
+ tty_term_cursor_at,
NULL, /* dpy_bmp_alloc */
NULL, /* dpy_bmp_free */
NULL, /* dpy_bmp_draw */
Index: unihex.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/unihex.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- unihex.c 9 Jan 2008 13:41:41 -0000 1.13
+++ unihex.c 11 Jan 2008 11:29:29 -0000 1.14
@@ -187,10 +187,10 @@
qe_register_mode(&unihex_mode);
/* additional mode specific keys */
- qe_register_binding(KEY_CTRL_LEFT, "decrease-width", "unihex");
- qe_register_binding(KEY_CTRL_RIGHT, "increase-width", "unihex");
- qe_register_binding(KEY_TAB, "toggle-hex", "unihex");
- qe_register_binding(KEY_SHIFT_TAB, "toggle-hex", "unihex");
+ qe_register_binding(KEY_CTRL_LEFT, "decrease-width", &unihex_mode);
+ qe_register_binding(KEY_CTRL_RIGHT, "increase-width", &unihex_mode);
+ qe_register_binding(KEY_TAB, "toggle-hex", &unihex_mode);
+ qe_register_binding(KEY_SHIFT_TAB, "toggle-hex", &unihex_mode);
return 0;
}
Index: util.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/util.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- util.c 8 Jan 2008 16:37:55 -0000 1.36
+++ util.c 11 Jan 2008 11:29:29 -0000 1.37
@@ -909,23 +909,26 @@
int to_hex(int key)
{
+ /* Only ASCII supported */
if (qe_isdigit(key))
return key - '0';
- else if (key >= 'a' && key <= 'f')
- return key - 'a' + 10;
- else if (key >= 'A' && key <= 'F')
- return key - 'A' + 10;
+ else
+ if (qe_inrange(key | ('a' - 'A'), 'a', 'f'))
+ return (key & 7) + 9;
else
return -1;
}
+#if 1
+/* Should move all this to display.c */
+
typedef struct ColorDef {
const char *name;
unsigned int color;
} ColorDef;
-static ColorDef const css_colors[] = {
- /*from HTML 4.0 spec */
+static ColorDef const default_colors[] = {
+ /* From HTML 4.0 spec */
{ "black", QERGB(0x00, 0x00, 0x00) },
{ "green", QERGB(0x00, 0x80, 0x00) },
{ "silver", QERGB(0xc0, 0xc0, 0xc0) },
@@ -952,22 +955,18 @@
{ "grey", QERGB(0xbe, 0xbe, 0xbe) },
{ "transparent", COLOR_TRANSPARENT },
};
-#define nb_css_colors countof(css_colors)
+#define nb_default_colors countof(default_colors)
-static ColorDef *custom_colors;
-static int nb_custom_colors;
+static ColorDef *qe_colors = (ColorDef *)default_colors;
+static int nb_qe_colors = nb_default_colors;
void color_completion(CompleteState *cp)
{
ColorDef const *def;
int count;
- def = custom_colors;
- count = nb_custom_colors;
- if (!count) {
- def = css_colors;
- count = nb_css_colors;
- }
+ def = qe_colors;
+ count = nb_qe_colors;
while (count > 0) {
if (strxstart(def->name, cp->current, NULL))
add_string(&cp->cs, def->name);
@@ -998,32 +997,29 @@
if (css_get_color(&color, value))
return -1;
- /* First color definition: allocate custom_colors array */
- if (!nb_custom_colors) {
- custom_colors = qe_malloc_dup(css_colors, sizeof(css_colors));
- if (!custom_colors)
- return -1;
- nb_custom_colors = nb_css_colors;
+ /* First color definition: allocate modifiable array */
+ if (qe_colors == default_colors) {
+ qe_colors = qe_malloc_dup(default_colors, sizeof(default_colors));
}
/* Make room: reallocate table in chunks of 8 entries */
- if (((nb_custom_colors - nb_css_colors) & 7) == 0) {
- if (!qe_realloc(&custom_colors,
- (nb_custom_colors + 8) * sizeof(ColorDef))) {
+ if (((nb_qe_colors - nb_default_colors) & 7) == 0) {
+ if (!qe_realloc(&qe_colors,
+ (nb_qe_colors + 8) * sizeof(ColorDef))) {
return -1;
}
}
/* Check for redefinition */
- index = css_lookup_color(custom_colors, nb_custom_colors, name);
+ index = css_lookup_color(qe_colors, nb_qe_colors, name);
if (index >= 0) {
- custom_colors[index].color = color;
+ qe_colors[index].color = color;
return 0;
}
- def = &custom_colors[nb_custom_colors];
+ def = &qe_colors[nb_qe_colors];
def->name = qe_strdup(name);
def->color = color;
- nb_custom_colors++;
+ nb_qe_colors++;
return 0;
}
@@ -1036,12 +1032,8 @@
unsigned char rgba[4];
/* search in tables */
- def = custom_colors;
- count = nb_custom_colors;
- if (!count) {
- def = css_colors;
- count = nb_css_colors;
- }
+ def = qe_colors;
+ count = nb_qe_colors;
index = css_lookup_color(def, count, p);
if (index >= 0) {
*color_ptr = def[index].color;
@@ -1127,6 +1119,7 @@
v = 0; /* inherit */
return v;
}
+#endif /* style stuff */
/* a = a union b */
void css_union_rect(CSSRect *a, const CSSRect *b)
Index: video.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/video.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- video.c 4 Jan 2008 23:04:11 -0000 1.11
+++ video.c 11 Jan 2008 11:29:29 -0000 1.12
@@ -973,7 +973,7 @@
qe_register_mode(&video_mode);
qe_register_cmd_table(video_commands, &video_mode);
/* additional mode specific keys */
- qe_register_binding('f', "toggle-full-screen", "av");
+ qe_register_binding('f', "toggle-full-screen", &video_mode);
return 0;
}
Index: win32.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/win32.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- win32.c 3 Jan 2008 09:51:32 -0000 1.11
+++ win32.c 11 Jan 2008 11:29:29 -0000 1.12
@@ -25,8 +25,6 @@
extern int main1(int argc, char **argv);
LRESULT CALLBACK qe_wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
lParam);
-extern QEDisplay win32_dpy;
-
static HINSTANCE _hPrev, _hInstance;
static int font_xsize;
@@ -141,8 +139,6 @@
if (!_hPrev)
init_application();
- memcpy(&s->dpy, &win32_dpy, sizeof(QEDisplay));
-
s->private = NULL;
s->media = CSS_MEDIA_SCREEN;
@@ -504,7 +500,6 @@
win_probe,
win_init,
win_close,
- NULL,
win_flush,
win_is_user_input_pending,
win_fill_rectangle,
@@ -516,6 +511,7 @@
NULL, /* dpy_selection_activate */
NULL, /* dpy_selection_request */
NULL, /* dpy_invalidate */
+ NULL, /* dpy_cursor_at */
NULL, /* dpy_bmp_alloc */
NULL, /* dpy_bmp_free */
NULL, /* dpy_bmp_draw */
Index: x11.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/x11.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- x11.c 8 Jan 2008 16:37:55 -0000 1.23
+++ x11.c 11 Jan 2008 11:29:29 -0000 1.24
@@ -80,7 +80,6 @@
static CSSRect update_rects[UPDATE_MAX_REGIONS];
#endif
-static QEDisplay x11_dpy;
static int visual_depth;
static int force_tty;
@@ -193,8 +192,6 @@
QEStyleDef default_style;
XGCValues gc_val;
- memcpy(&s->dpy, &x11_dpy, sizeof(QEDisplay));
-
s->private = NULL;
s->media = CSS_MEDIA_SCREEN;
@@ -1679,7 +1676,6 @@
term_probe,
term_init,
term_close,
- NULL,
term_flush,
x11_is_user_input_pending,
term_fill_rectangle,
@@ -1691,6 +1687,7 @@
term_selection_activate,
term_selection_request,
NULL, /* dpy_invalidate */
+ NULL, /* dpy_cursor_at */
x11_bmp_alloc,
x11_bmp_free,
x11_bmp_draw,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs display.c display.h hex.c html2png.c ima...,
Charlie Gordon <=