lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev +/- suffixes in popup menu number commands


From: Laura Eaves
Subject: lynx-dev +/- suffixes in popup menu number commands
Date: Sat, 27 Feb 1999 15:17:52 -0500 (EST)

For completeness, here is a patch to LYForms.c to implement
123[+|-][g|p] while in a popup menu.  This is independent of the previous patch.
Paatch agains dev17.
--le

Index: LYForms.c
--- old/LYForms.c       Wed Feb 17 07:29:34 1999
+++ src/LYForms.c       Sat Feb 27 15:06:16 1999
@@ -515,10 +515,12 @@
 **  If a 'g' or 'p' suffix is included, that will be
 **  loaded into c.  Otherwise, c is zeroed. - FM & LE
 */
-PRIVATE int get_popup_option_number ARGS1(
-       int *,          c)
+PRIVATE int get_popup_option_number ARGS2(
+       int *,          c,
+       int *,          rel)
 {
     char temp[120];
+    char *p = temp;
 
     /*
      *  Load the c argument into the prompt buffer.
@@ -533,16 +535,25 @@
     if (LYgetstr(temp, VISIBLE, sizeof(temp), NORECALL) < 0 || *temp == 0) {
        HTInfoMsg(CANCELLED);
        *c = '\0';
+       *rel = '\0';
        return(0);
     }
 
+    while ( isdigit(*p) ) ++p;
+
+    /* if we have a + or - suffix, save it */
+    if ( *p == '+' || *p == '-' )
+       *rel = *p++;
+    else
+       *rel = '\0';
+
     /*
      *  If we had a 'g' or 'p' suffix, load it into c.
      *  Otherwise, zero c.  Then return the number.
      */
-    if (strchr(temp, 'g') != NULL || strchr(temp, 'G') != NULL) {
+    if ( *p == 'g' || *p == 'G' ) {
        *c = 'g';
-    } else if (strchr(temp, 'p') != NULL || strchr(temp, 'P') != NULL) {
+    } else if (*p == 'p' || *p == 'P' ) {
        *c = 'p';
     } else {
        *c = '\0';
@@ -585,7 +596,7 @@
      *  and to position the popup window appropriately,
      *  taking the user_mode setting into account. -- FM
      */
-    int c = 0, cmd = 0, i = 0, j = 0;
+    int c = 0, cmd = 0, i = 0, j = 0, rel = 0;
     int orig_selection = cur_selection;
 #ifndef USE_SLANG
     WINDOW * form_window;
@@ -887,8 +898,26 @@
                 *  a 'g' or 'p' suffix (which will be loaded
                 *  into c). - FM & LE
                 */
-               number = get_popup_option_number((int *)&c);
+               number = get_popup_option_number((int *)&c,(int *)&rel);
 
+               /* handle + or - suffix */
+               CTRACE(tfp,"got popup option number %d, ",number);
+               CTRACE(tfp,"rel='%c', c='%c', cur_selection=%d\n",
+                               rel,c,cur_selection);
+               if ( c == 'p' ) {
+                   int curpage = ((cur_selection + 1) > length) ?
+                       (((cur_selection + 1) + (length - 1))/(length))
+                                         : 1;
+                   CTRACE(tfp,"  curpage=%d\n",curpage);
+                   if ( rel == '+' )
+                       number = curpage + number;
+                   else if ( rel == '-' )
+                       number = curpage - number;
+               } else if ( rel == '+' )
+                   number = cur_selection + number + 1;
+               else if ( rel == '-' )
+                   number = cur_selection - number + 1;
+               if ( rel ) CTRACE(tfp,"new number=%d\n",number);
                /*
                 *  Check for a 'p' suffix. - FM
                 */

reply via email to

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