lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev [PATCH 2.8.4dev.20] Consolidate mouse menu


From: Ilya Zakharevich
Subject: lynx-dev [PATCH 2.8.4dev.20] Consolidate mouse menu
Date: Wed, 2 May 2001 03:53:23 -0400
User-agent: Mutt/1.2.5i

Currently the context-sensitive mouse-menu is not sufficiently
context-sensitive.  However, the organization of the code is not
sufficiently flexible to enable better context-sensitivity.  This
patch has one user-visible change only (Edit Doc/Link URL entries),
but makes it much easier to attach different menus to different places.

Enjoy,
Ilya

--- ./src/LYStrings.c-pre       Sun Apr  1 16:51:46 2001
+++ ./src/LYStrings.c   Tue May  1 23:42:58 2001
@@ -1356,81 +1356,60 @@ PUBLIC int lynx_initialize_keymaps NOARG
 #if defined(USE_MOUSE) && (defined(NCURSES) || defined(PDCURSES))
 PRIVATE int LYmouse_menu ARGS4(int, x, int, y, int, atlink, int, code)
 {
-    static char *choices[] = {
-       "Quit",
-       "Home page",
-       "Previous document",
-       "Beginning of document",
-       "Page up",
-       "Half page up",
-       "Two lines up",
-       "History",
-       "Help",
-       "Do nothing (refresh)",
-       "Load again",
-       "Edit URL and load",
-       "Show info",
-       "Search",
-       "Print",
-       "Two lines down",
-       "Half page down",
-       "Page down",
-       "End of document",
-       "Bookmarks",
-       "Cookie jar",
-       "Search index",
-       "Set Options",
-       NULL
+#define ENT_ONLY_DOC   1
+#define ENT_ONLY_LINK  2
+    static const struct {
+       char *txt;
+       int  action;
+       unsigned int  flag;
+    } possible_entries[] = {
+       {"Quit",                        LYK_ABORT,              ENT_ONLY_DOC},
+       {"Home page",                   LYK_MAIN_MENU,          ENT_ONLY_DOC},
+       {"Previous document",           LYK_PREV_DOC,           ENT_ONLY_DOC},
+       {"Beginning of document",       LYK_HOME,               ENT_ONLY_DOC},
+       {"Page up",                     LYK_PREV_PAGE,          ENT_ONLY_DOC},
+       {"Half page up",                LYK_UP_HALF,            ENT_ONLY_DOC},
+       {"Two lines up",                LYK_UP_TWO,             ENT_ONLY_DOC},
+       {"History",                     LYK_HISTORY,            ENT_ONLY_DOC},
+       {"Help",                        LYK_HELP,               0},
+       {"Do nothing (refresh)",        LYK_REFRESH,            0},
+       {"Load again",                  LYK_RELOAD,             ENT_ONLY_DOC},
+       {"Edit Doc URL and load",       LYK_ECGOTO,             ENT_ONLY_DOC},
+       {"Edit Link URL and load",      LYK_ELGOTO,             ENT_ONLY_LINK},
+       {"Show info",                   LYK_INFO,               0},
+       {"Search",                      LYK_WHEREIS,            ENT_ONLY_DOC},
+       {"Print",                       LYK_PRINT,              ENT_ONLY_DOC},
+       {"Two lines down",              LYK_DOWN_TWO,           ENT_ONLY_DOC},
+       {"Half page down",              LYK_DOWN_HALF,          ENT_ONLY_DOC},
+       {"Page down",                   LYK_NEXT_PAGE,          ENT_ONLY_DOC},
+       {"End of document",             LYK_END,                ENT_ONLY_DOC},
+       {"Bookmarks",                   LYK_VIEW_BOOKMARK,      ENT_ONLY_DOC},
+       {"Cookie jar",                  LYK_COOKIE_JAR,         ENT_ONLY_DOC},
+       {"Search index",                LYK_INDEX_SEARCH,       ENT_ONLY_DOC},
+       {"Set Options",                 LYK_OPTIONS,            ENT_ONLY_DOC},
+       {"Activate this link",          LYK_SUBMIT,             ENT_ONLY_LINK},
+       {"Download",                    LYK_DOWNLOAD,           ENT_ONLY_LINK}
     };
-    static char *choices_link[] = {
-       "Help",
-       "Do nothing",
-       "Activate this link",
-       "Show info",
-       "Download",
-       NULL
-    };
-    static int actions[] = {
-       LYK_ABORT,
-       LYK_MAIN_MENU,
-       LYK_PREV_DOC,
-       LYK_HOME,
-       LYK_PREV_PAGE,
-       LYK_UP_HALF,
-       LYK_UP_TWO,
-       LYK_HISTORY,
-       LYK_HELP,
-       LYK_REFRESH,
-       LYK_RELOAD,
-       LYK_ECGOTO,
-       LYK_INFO,
-       LYK_WHEREIS,
-       LYK_PRINT,
-       LYK_DOWN_TWO,
-       LYK_DOWN_HALF,
-       LYK_NEXT_PAGE,
-       LYK_END,
-       LYK_VIEW_BOOKMARK,
-       LYK_COOKIE_JAR,
-       LYK_INDEX_SEARCH,
-       LYK_OPTIONS
-    };
-    static int actions_link[] = {
-       LYK_HELP,
-       LYK_DO_NOTHING,
-       LYK_SUBMIT,
-       LYK_INFO,
-       LYK_DOWNLOAD
-    };
-    int c, retlac;
+#define TOTAL_MENUENTRIES      TABLESIZE(possible_entries)
+    char *choices[TOTAL_MENUENTRIES + 1];
+    int actions[TOTAL_MENUENTRIES];
+
+    int c, c1, retlac, filter_out = (atlink ? ENT_ONLY_DOC : ENT_ONLY_LINK);
+
+    c = c1 = 0;
+    while (c < TOTAL_MENUENTRIES) {
+       if (!(possible_entries[c].flag & filter_out)) {
+           choices[c1] = possible_entries[c].txt;
+           actions[c1++] = possible_entries[c].action;
+       }
+       c++;
+    }
+    choices[c1] = NULL;
 
     /* Somehow the mouse is over the number instead of being over the
        name, so we decrease x. */
     c = LYChoosePopup((atlink ? 2 : 10) - 1, y, (x > 5 ? x-5 : 1),
-                    (atlink ? choices_link : choices),
-                    (atlink
-                     ? TABLESIZE(actions_link)
-                     : TABLESIZE(actions)), FALSE, TRUE);
+                    choices, c1, FALSE, TRUE);
 
     /*
      *  LYhandlePopupList() wasn't really meant to be used
@@ -1443,7 +1422,7 @@ PRIVATE int LYmouse_menu ARGS4(int, x, i
        retlac = LYK_DO_NOTHING;
        term_options = FALSE;
     } else {
-       retlac = atlink ? (actions_link[c]) : (actions[c]);
+       retlac = actions[c];
     }
 
     if (code == FOR_INPUT && mouse_link == -1) {

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

reply via email to

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