[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lynx-dev [PATCH 2.8.4dev.10] Saner style assignment
From: |
Ilya Zakharevich |
Subject: |
lynx-dev [PATCH 2.8.4dev.10] Saner style assignment |
Date: |
Sat, 21 Oct 2000 18:23:44 -0400 |
User-agent: |
Mutt/1.2i |
This patch:
a) reverts to the style "foo" (from "foo.classname") if the style
"foo.classname" was not configured;
b) For input elements of type=typename uses style
"input.type.typename" if this style is configured (but
"input.classname" is not!);
c) Same for typeless elements, with typename="".
This allows the following:
input.type.submit:normal:blue:black
# match "link":
input:normal:green
textarea:normal:white:cyan
# type-less input is the same as type=text (similar to textarea)
input.type.:normal:white:cyan
input.type.text:normal:white:cyan
If your "link" is configured as normal:green, then input elements of
types other than typeless, text, or submit will be shown in the same
style as link. The textareas and text input elements are shown in the
same style (but different from "link" style), and submit "buttons" are
shown yet in another style.
Enjoy,
Ilya
[This fixes "static" stuff only. Some changes to "dynamic" stuff may
be needed to make things yet more intuitive.]
--- ./src/HTML.c-pretype Fri Oct 20 01:34:28 2000
+++ ./src/HTML.c Sat Oct 21 04:48:20 2000
@@ -955,6 +955,7 @@ PRIVATE int HTML_start_element ARGS6(
int status = HT_OK;
#ifdef USE_COLOR_STYLE
char* class_name;
+ int class_used = 0;
# if OPT_SCN
# if !OMIT_SCN_KEEPING
char* Style_className_end_was = Style_className_end+1;
@@ -1102,7 +1103,7 @@ PRIVATE int HTML_start_element ARGS6(
CTRACE((tfp, "CSS.elt:<%s>\n", HTML_dtd.tags[element_number].name));
- if (current_tag_style == -1) {
+ if (current_tag_style == -1) { /* Append class_name */
#if !OPT_SCN
strcpy (myHash, HTML_dtd.tags[element_number].name);
#else
@@ -1110,6 +1111,8 @@ PRIVATE int HTML_start_element ARGS6(
#endif
if (class_name[0])
{
+ int ohcode = hcode;
+ char *oend = Style_className_end;
#if !OPT_SCN
int len = strlen(myHash);
sprintf(myHash, ".%.*s", (int)sizeof(myHash) - len - 2, class_name);
@@ -1125,13 +1128,22 @@ PRIVATE int HTML_start_element ARGS6(
hcode = hash_code_aggregate_char('.', hcode);
hcode = hash_code_aggregate_lower_str(class_name, hcode);
#endif
+ if (!hashStyles[hcode].name) { /* None such -> classless version */
+ hcode = ohcode;
+ *oend = '\0';
+ CTRACE((tfp, "STYLE.start_element: <%s> (class <%s> not
configured), hcode=%d.\n",
+ HTML_dtd.tags[element_number].name, class_name, hcode));
+ } else {
+ CTRACE((tfp, "STYLE.start_element: <%s>.<%s>, hcode=%d.\n",
+ HTML_dtd.tags[element_number].name, class_name, hcode));
+ class_used = 1;
+ }
}
+
#if !OPT_SCN
strtolower(myHash);
hcode = hash_code(myHash);
#endif
- CTRACE((tfp, "STYLE.start_element: <%s>.<%s>, hcode=%d.\n",
- HTML_dtd.tags[element_number].name, class_name, hcode));
class_string[0] = '\0';
#if !OPT_SCN
@@ -1158,10 +1170,6 @@ PRIVATE int HTML_start_element ARGS6(
fprintf(tfp, " ca=%d\n", hashStyles[hcode].color);
}
#endif
-
- /* seems that this condition is always true - HV */
- if (displayStyles[element_number + STARTAT].color > -2) /* actually set
*/
- HText_characterStyle(me->text, hcode, 1);
} else { /* (current_tag_style!=-1) */
if (class_name[0]) {
#if !OPT_SCN
@@ -1181,7 +1189,6 @@ PRIVATE int HTML_start_element ARGS6(
hcode = current_tag_style;
CTRACE((tfp, "STYLE.start_element: <%s>, hcode=%d.\n",
HTML_dtd.tags[element_number].name, hcode));
- HText_characterStyle(me->text, hcode , 1);
current_tag_style = -1;
}
@@ -1194,8 +1201,33 @@ PRIVATE int HTML_start_element ARGS6(
# endif
#endif
+#if OPT_SCN && !OMIT_SCN_KEEPING /* Can be done in other cases too... */
+ if (!class_used && ElementNumber == HTML_INPUT) { /* For some other too? */
+ char *type = "", *oend = Style_className_end;
+ int l, ohcode = hcode;
+
+ if (present && present[HTML_INPUT_TYPE] && value[HTML_INPUT_TYPE])
+ type = (char *)value[HTML_INPUT_TYPE];
+ l = strlen(type);
+
+ *Style_className_end = '.';
+ memcpy(Style_className_end+1, "type.", 5 );
+ memcpy(Style_className_end+6, type, l+1 );
+ Style_className_end += l+6;
+ hcode = hash_code_aggregate_lower_str(".type.", hcode);
+ hcode = hash_code_aggregate_lower_str(type, hcode);
+ if (!hashStyles[hcode].name) { /* None such -> classless version */
+ hcode = ohcode;
+ *oend = '\0';
+ CTRACE((tfp, "STYLE.start_element: type <%s> not configured.\n",
type));
+ } else {
+ CTRACE((tfp, "STYLE.start_element: <%s>.type.<%s>, hcode=%d.\n",
+ HTML_dtd.tags[element_number].name, type, hcode));
+ }
+ }
+#endif /* OPT_SCN && !OMIT_SCN_KEEPING */
-
+ HText_characterStyle(me->text, hcode , 1);
#endif /* USE_COLOR_STYLE */
/*
; To UNSUBSCRIBE: Send "unsubscribe lynx-dev" to address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- lynx-dev [PATCH 2.8.4dev.10] Saner style assignment,
Ilya Zakharevich <=