[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs qe.c qe.h qeconfig.h
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs qe.c qe.h qeconfig.h |
Date: |
Fri, 04 Apr 2008 12:06:08 +0000 |
CVSROOT: /cvsroot/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 08/04/04 12:06:08
Modified files:
. : qe.c qe.h qeconfig.h
Log message:
added completion on style property names
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.76&r2=1.77
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.73&r2=1.74
http://cvs.savannah.gnu.org/viewcvs/qemacs/qeconfig.h?cvsroot=qemacs&r1=1.31&r2=1.32
Patches:
Index: qe.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -b -r1.76 -r1.77
--- qe.c 31 Mar 2008 21:52:01 -0000 1.76
+++ qe.c 4 Apr 2008 12:06:07 -0000 1.77
@@ -2196,6 +2196,43 @@
return NULL;
}
+const char * const qe_style_properties[] = {
+#define CSS_PROP_COLOR 0
+ "color",
+#define CSS_PROP_BACKGROUND_COLOR 1
+ "background-color",
+#define CSS_PROP_FONT_FAMILY 2
+ "font-family",
+#define CSS_PROP_FONT_STYLE 3
+ "font-style",
+#define CSS_PROP_FONT_WEIGHT 4
+ "font-weight",
+#define CSS_PROP_FONT_SIZE 5
+ "font-size,"
+#define CSS_PROP_TEXT_DECORATION 6
+ "text-decoration",
+};
+
+void style_property_completion(CompleteState *cp)
+{
+ int i;
+
+ for (i = 0; i < countof(qe_style_properties); i++) {
+ complete_test(cp, qe_style_properties[i]);
+ }
+}
+
+int find_style_property(const char *name)
+{
+ int i;
+
+ for (i = 0; i < countof(qe_style_properties); i++) {
+ if (strequal(qe_style_properties[i], name))
+ return i;
+ }
+ return -1;
+}
+
/* 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)
@@ -2209,31 +2246,29 @@
return;
}
- prop_index = css_get_enum(propstr,
- "color,background-color,font-family,"
- "font-style,font-weight,font-size,"
- "text-decoration");
+ prop_index = find_style_property(propstr);
if (prop_index < 0) {
put_status(e, "Unknown property '%s'", propstr);
return;
}
+
switch (prop_index) {
- case 0:
+ case CSS_PROP_COLOR:
if (css_get_color(&style->fg_color, value))
goto bad_color;
break;
- case 1:
+ case CSS_PROP_BACKGROUND_COLOR:
if (css_get_color(&style->bg_color, value))
goto bad_color;
break;
bad_color:
put_status(e, "Unknown color '%s'", value);
return;
- case 2:
+ case CSS_PROP_FONT_FAMILY:
v = css_get_font_family(value);
style->font_style = (style->font_style & ~QE_FAMILY_MASK) | v;
break;
- case 3:
+ case CSS_PROP_FONT_STYLE:
/* XXX: cannot handle inherit correctly */
v = style->font_style;
if (strequal(value, "italic")) {
@@ -2244,7 +2279,7 @@
}
style->font_style = v;
break;
- case 4:
+ case CSS_PROP_FONT_WEIGHT:
/* XXX: cannot handle inherit correctly */
v = style->font_style;
if (strequal(value, "bold")) {
@@ -2255,14 +2290,14 @@
}
style->font_style = v;
break;
- case 5:
+ case CSS_PROP_FONT_SIZE:
if (strequal(value, "inherit")) {
style->font_size = 0;
} else {
style->font_size = strtol(value, NULL, 0);
}
break;
- case 6:
+ case CSS_PROP_TEXT_DECORATION:
/* XXX: cannot handle inherit correctly */
if (strequal(value, "none")) {
style->font_style &= ~QE_STYLE_UNDERLINE;
@@ -7646,6 +7681,7 @@
register_completion("charset", charset_completion);
register_completion("mode", mode_completion);
register_completion("style", style_completion);
+ register_completion("style-property", style_property_completion);
register_completion("file", file_completion);
register_completion("buffer", buffer_completion);
register_completion("color", color_completion);
Index: qe.h
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.h,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -b -r1.73 -r1.74
--- qe.h 31 Mar 2008 21:52:01 -0000 1.73
+++ qe.h 4 Apr 2008 12:06:07 -0000 1.74
@@ -1635,6 +1635,9 @@
void display_window_borders(EditState *e);
QEStyleDef *find_style(const char *name);
void style_completion(CompleteState *cp);
+void get_style(EditState *e, QEStyleDef *style, int style_index);
+void style_property_completion(CompleteState *cp);
+int find_style_property(const char *name);
void do_define_color(EditState *e, const char *name, const char *value);
void do_set_style(EditState *e, const char *stylestr,
const char *propstr, const char *value);
@@ -1706,8 +1709,6 @@
int list_get_pos(EditState *s);
int list_get_offset(EditState *s);
-void get_style(EditState *e, QEStyleDef *style, int style_index);
-
/* dired.c */
void do_dired(EditState *s);
Index: qeconfig.h
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qeconfig.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- qeconfig.h 31 Mar 2008 20:35:31 -0000 1.31
+++ qeconfig.h 4 Apr 2008 12:06:08 -0000 1.32
@@ -294,7 +294,7 @@
CMD_( KEY_NONE, KEY_NONE,
"set-style", do_set_style, ESsss,
"s{Style: }[style]|style|"
- "s{CSS Property Name: }"
+ "s{CSS Property Name: }[style-property]|style-property|"
"s{CSS Property Value: }")
CMD_( KEY_NONE, KEY_NONE,
"set-display-size", do_set_display_size, ESii,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs qe.c qe.h qeconfig.h,
Charlie Gordon <=