lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev [PATCH 2.8.4dev.10] styles in text-edit fields


From: Ilya Zakharevich
Subject: lynx-dev [PATCH 2.8.4dev.10] styles in text-edit fields
Date: Sun, 22 Oct 2000 04:47:16 -0400
User-agent: Mutt/1.2i

This patch implements styles in "dynamic areas" of documents.  Three
flavors of them are active text-edit fields, non-active ones, and
links/radiobuttons etc.

This patch is concerned with the first flavor only.  Two subflavors
are document's text-edit areas, and Lynx's ones (such as where you
input the URL after `g').  Each one of them has 3 elements: scroll
symbols ("arrows"), after-the-end padding, and the actually input string.

The patch

  a) makes styles for these 2*3 elements customizable;

  b) uses ACS chars (if available) for the arrows (instead of `{'/`}').

[It would be nice to make non-active text-areas to have customizable
 styles for padding, and have scroll arrows too...]

Btw, it so happens that scroll arrows are already mouse-sensible. ;-)

Enjoy,
Ilya

P.S.  Here is my customization for testing:

  edit.active:normal:red:cyan
  edit.prompt:normal:green:cyan
  edit.active.arrow:normal:yellow:cyan
  edit.prompt.arrow:normal:yellow:gray
  edit.active.pad:normal:gray:cyan
  edit.prompt.pad:normal:white:black

--- ./src/LYCurses.c-prestyle   Sat Oct 21 22:43:02 2000
+++ ./src/LYCurses.c    Sat Oct 21 23:36:18 2000
@@ -393,16 +393,11 @@ PUBLIC void curses_w_style ARGS3(
         */
        if (!ds->name) break;
 #endif
-       if (style != s_alink) {
-           CTRACE((tfp, "CACHED: <%s> @(%d,%d)\n", ds->name, YP, XP));
-           if (win == stdscr) cached_styles[YP][XP] = style;
-       }
-       LYAttrset(win, ds->color, ds->mono);
-       break;
-
+       /* FALL THROUGH */
     case ABS_ON: /* change without remembering the previous style */
-           /* don't cache style changes for active links */
-       if (style != s_alink) {
+           /* don't cache style changes for active links and edits */
+       if ( style != s_alink && style != s_aedit
+            && style != s_aedit_pad && style != s_aedit_arr ) {
            CTRACE((tfp, "CACHED: <%s> @(%d,%d)\n", ds->name, YP, XP));
            if (win == stdscr) cached_styles[YP][XP] = style;
        }
--- ./src/LYHash.h-prestyle     Sun Jul 16 22:16:12 2000
+++ ./src/LYHash.h      Sat Oct 21 21:49:10 2000
@@ -42,7 +42,8 @@ extern int    s_alink, s_a, s_status,
 #ifdef USE_SCROLLBAR
                s_sb_bar, s_sb_bg, s_sb_aa, s_sb_naa,
 #endif
-               s_whereis;
+               s_whereis, s_aedit, s_aedit_pad, s_aedit_arr, 
+               s_prompt_edit, s_prompt_edit_pad, s_prompt_edit_arr;
 #define CACHEW 128
 #define CACHEH 64
 
--- ./src/LYStrings.c-prestyle  Fri Oct 20 22:46:30 2000
+++ ./src/LYStrings.c   Sun Oct 22 00:03:06 2000
@@ -3175,6 +3175,20 @@ PUBLIC int get_popup_number ARGS3(
     return num;
 }
 
+#ifdef USE_COLOR_STYLE
+#  define TmpStyleOn(s)                curses_style((s), STACK_ON)
+#  define TmpStyleOff(s)       curses_style((s), STACK_OFF)
+#else
+#  define TmpStyleOn(s)
+#  define TmpStyleOff(s)
+#endif /* defined USE_COLOR_STYLE */
+
+#ifndef ACS_LARROW
+#  define ACS_LARROW '{'
+#endif
+#ifndef ACS_RARROW
+#  define ACS_RARROW '}'
+#endif
 
 PUBLIC void LYRefreshEdit ARGS1(
        EDREC *,        edit)
@@ -3189,6 +3203,7 @@ PUBLIC void LYRefreshEdit ARGS1(
     int begin_multi = 0;
     int end_multi = 0;
 #endif /* SUPPORT_MULTIBYTE_EDIT */
+    int estyle, prompting = 0;
 
     buffer[0] = buffer[1] = buffer[2] = '\0';
     if (!edit->dirty || (DspWdth == 0))
@@ -3272,16 +3287,18 @@ PUBLIC void LYRefreshEdit ARGS1(
      *  should only be needed for color styles.  The curses function
      *  may be used directly to avoid complications. - kw
      */
-    if (edit->sy == (LYlines - 1)) {
-       CTRACE((tfp, "STYLE.getstr: switching to NORMAL style.\n"));
-       if (s_normal != NOSTYLE) {
-           curses_style(s_normal, ABS_ON);
-       } else {
-           attrset(A_NORMAL);  /* need to do something about colors? */
-       }
-    } else {
-       CTRACE((tfp, "STYLE.getstr: no style switch.\n"));
-    }
+    if (edit->sy == (LYlines - 1))
+       prompting = 1;
+    if (prompting)
+       estyle = s_prompt_edit;
+    else
+       estyle = s_aedit;
+    CTRACE((tfp, "STYLE.getstr: switching to <edit.%s>.\n",
+           prompting ? "prompt" : "active"));
+    if (estyle != NOSTYLE)
+       curses_style(estyle, STACK_ON);
+    else
+       attrset(A_NORMAL);      /* need to do something about colors? */
 #endif
     if (edit->hidden) {
        for (i = 0; i < nrdisplayed; i++)
@@ -3326,37 +3343,40 @@ PUBLIC void LYRefreshEdit ARGS1(
      * Erase rest of input area.
      */
     padsize = DspWdth-nrdisplayed;
-    while (padsize--)
-       addch((unsigned char)edit->pad);
+    if (padsize) {
+       TmpStyleOn(prompting ? s_prompt_edit_pad : s_aedit_pad);
+       while (padsize--)
+           addch((unsigned char)edit->pad);
+       TmpStyleOff(prompting ? s_prompt_edit_pad : s_aedit_pad);
+    }
 
     /*
      * Scrolling indicators.
      */
     if (edit->panon) {
        if ((DspStart + nrdisplayed) < length) {
-#ifndef SUPPORT_MULTIBYTE_EDIT
-           move(edit->sy, edit->sx+nrdisplayed-1);
-           addch('}');
-#else /* SUPPORT_MULTIBYTE_EDIT */
-           if (end_multi) {
-               move(edit->sy, edit->sx+nrdisplayed-2);
-               addstr(" }");
-           } else {
-               move(edit->sy, edit->sx+nrdisplayed-1);
-               addch('}');
-       }
-#endif /* SUPPORT_MULTIBYTE_EDIT */
+           int add_space = 0;
+
+           TmpStyleOn(prompting ? s_prompt_edit_arr : s_aedit_arr);
+#ifdef SUPPORT_MULTIBYTE_EDIT
+           if (end_multi)
+               add_space = 1;
+#endif
+           move(edit->sy, edit->sx + nrdisplayed - 1 - add_space);
+           if (add_space)
+               addch(' ');             /* Needed with styles? */
+           addch(ACS_RARROW);
+           TmpStyleOff(prompting ? s_prompt_edit_arr : s_aedit_arr);
        }
        if (DspStart) {
+           TmpStyleOn(prompting ? s_prompt_edit_arr : s_aedit_arr);
            move(edit->sy, edit->sx);
-#ifndef SUPPORT_MULTIBYTE_EDIT
-           addch('{');
-#else /* SUPPORT_MULTIBYTE_EDIT */
+           addch(ACS_LARROW);
+#ifdef SUPPORT_MULTIBYTE_EDIT
            if (begin_multi)
-               addstr("{ ");
-           else
-           addch('{');
+               addch(' ');             /* Needed with styles? */
 #endif /* SUPPORT_MULTIBYTE_EDIT */
+           TmpStyleOff(prompting ? s_prompt_edit_arr : s_aedit_arr);
        }
     }
 
@@ -3367,6 +3387,11 @@ PUBLIC void LYRefreshEdit ARGS1(
        lynx_force_repaint();
 #endif /* !USE_SLANG && !defined(USE_MULTIBYTE_CURSES) */
 #endif /* SUPPORT_MULTIBYTE_EDIT */
+
+#ifdef USE_COLOR_STYLE
+    if (estyle != NOSTYLE)
+       curses_style(estyle, STACK_OFF);
+#endif
     refresh();
 }
 
--- ./src/LYStyle.c-prestyle    Fri Oct 20 01:20:06 2000
+++ ./src/LYStyle.c     Sat Oct 21 23:27:06 2000
@@ -70,7 +70,10 @@ PUBLIC int   s_alink  = NOSTYLE, s_a     =
                s_sb_bar = NOSTYLE, s_sb_bg = NOSTYLE,
                s_sb_aa = NOSTYLE, s_sb_naa = NOSTYLE,
 #endif
-               s_whereis= NOSTYLE;
+               s_whereis = NOSTYLE, s_aedit = NOSTYLE,
+               s_aedit_pad = NOSTYLE, s_aedit_arr = NOSTYLE, 
+               s_prompt_edit = NOSTYLE, s_prompt_edit_pad = NOSTYLE,
+               s_prompt_edit_arr = NOSTYLE;
 
 /* start somewhere safe */
 #define MAX_COLOR 16
@@ -289,6 +292,36 @@ where OBJECT is one of EM,STRONG,B,I,U,B
        parse_attributes(mono,fg,bg,DSTYLE_WHEREIS,"whereis");
        s_whereis  = hash_code("whereis");
     }
+    else if (!strncasecomp(element, "edit.active.pad", 15))
+    {
+       parse_attributes(mono,fg,bg,DSTYLE_ELEMENTS,"edit.active.pad");
+       s_aedit_pad = hash_code("edit.active.pad");
+    }
+    else if (!strncasecomp(element, "edit.active.arrow", 17))
+    {
+       parse_attributes(mono,fg,bg,DSTYLE_ELEMENTS,"edit.active.arrow");
+       s_aedit_arr  = hash_code("edit.active.arrow");
+    }
+    else if (!strncasecomp(element, "edit.active", 11))
+    {
+       parse_attributes(mono,fg,bg,DSTYLE_ELEMENTS,"edit.active");
+       s_aedit  = hash_code("edit.active");
+    }
+    else if (!strncasecomp(element, "edit.prompt.pad", 15))
+    {
+       parse_attributes(mono,fg,bg,DSTYLE_ELEMENTS,"edit.prompt.pad");
+       s_prompt_edit_pad = hash_code("edit.prompt.pad");
+    }
+    else if (!strncasecomp(element, "edit.prompt.arrow", 17))
+    {
+       parse_attributes(mono,fg,bg,DSTYLE_ELEMENTS,"edit.prompt.arrow");
+       s_prompt_edit_arr  = hash_code("edit.prompt.arrow");
+    }
+    else if (!strncasecomp(element, "edit.prompt", 11))
+    {
+       parse_attributes(mono,fg,bg,DSTYLE_ELEMENTS,"edit.prompt");
+       s_prompt_edit  = hash_code("edit.prompt");
+    }
     /* Ok, it must be a HTML element, so look through the list until we
     * find it
     */
@@ -409,6 +442,18 @@ PUBLIC void parse_userstyles NOARGS
                parse_style(name);
        }
     }
+    if (s_prompt_edit == NOSTYLE)
+       s_prompt_edit = s_normal;
+    if (s_prompt_edit_arr == NOSTYLE)
+       s_prompt_edit_arr = s_prompt_edit;
+    if (s_prompt_edit_pad == NOSTYLE)
+       s_prompt_edit_pad = s_prompt_edit;
+    if (s_aedit == NOSTYLE)
+       s_aedit = s_alink;
+    if (s_aedit_arr == NOSTYLE)
+       s_aedit_arr = s_aedit;
+    if (s_aedit_pad == NOSTYLE)
+       s_aedit_pad = s_aedit;
 }
 
 

; To UNSUBSCRIBE: Send "unsubscribe lynx-dev" to address@hidden

reply via email to

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