aboutsummaryrefslogtreecommitdiffstats
path: root/menu.c
diff options
context:
space:
mode:
authorFumitoshi UKAI <ukai@debian.or.jp>2002-12-02 17:27:34 +0000
committerFumitoshi UKAI <ukai@debian.or.jp>2002-12-02 17:27:34 +0000
commiteb44b171c3aeeeca0c7af5fde7be3cd1c7456795 (patch)
treef5294559ebe099cffc7f838d71f69ad89f8fec02 /menu.c
parent[w3m-dev 03498] Re: parse <!-- ... --> in <script> (diff)
downloadw3m-eb44b171c3aeeeca0c7af5fde7be3cd1c7456795.tar.gz
w3m-eb44b171c3aeeeca0c7af5fde7be3cd1c7456795.zip
[w3m-dev 03501] link tag support
* buffer.c (reshapeBuffer): initialize formlist, linklist, maplist, hmarklist, imarklist * file.c (addLink): added (HTMLlineproc2body): add HTML_LINK (loadHTMLstream): use HTMLlineproc0 not in R_ST_NORMAL (reloadBuffer): initialize linklist, maplist, hmarklist, imarklist * fm.h (LINK_TYPE_NONE): added (LINK_TYPE_REL): added (LINK_TYPE_REV): added (LinkList): added (Buffer): add linklist * html.c (ALST_LINK): added (TagMAP): add link (AtrMAP): add rel, rev, title * html.h (HTML_LINK): added (ATTR_REL): added (ATTR_REV): added (ATTR_TITLE): added * map.c (append_map_info): anchor (append_link_info): added (page_info_panel): append_link_info * menu.c (LinkMenu): added (linkV): added (initLinkMenu): added (lmGoURL): added (popupMenu): initLinkMenu() (initMenu): w3mMenuList new 4 add "Link" * tagtable.tab (link): added From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c78
1 files changed, 75 insertions, 3 deletions
diff --git a/menu.c b/menu.c
index 884c98d..0a6439c 100644
--- a/menu.c
+++ b/menu.c
@@ -1,4 +1,4 @@
-/* $Id: menu.c,v 1.22 2002/11/27 16:29:14 ukai Exp $ */
+/* $Id: menu.c,v 1.23 2002/12/02 17:27:41 ukai Exp $ */
/*
* w3m menu.c
*/
@@ -288,6 +288,11 @@ static int smDelTab(char c);
/* --- SelTabMenu (END) --- */
+static Menu LinkMenu;
+static int LinkV = 0;
+static void initLinkMenu(void);
+static void lmGoURL(void);
+
/* --- MainMenu --- */
static Menu MainMenu;
@@ -1313,6 +1318,7 @@ popupMenu(int x, int y, Menu *menu)
{
initSelectMenu();
initSelTabMenu();
+ initLinkMenu();
menu->cursorX = Currentbuf->cursorX + Currentbuf->rootX;
menu->cursorY = Currentbuf->cursorY + Currentbuf->rootY;
@@ -1642,6 +1648,69 @@ smDelTab(char c)
/* --- SelectMenu (END) --- */
+/* --- LinkMenu --- */
+
+static void
+initLinkMenu(void)
+{
+ LinkList *l;
+ int i, nitem, len = 0;
+ char **label;
+ Str str;
+
+ if (!Currentbuf->linklist) {
+ LinkMenu.item = NULL;
+ LinkMenu.nitem = 0;
+ return;
+ }
+ for (i = 0, l = Currentbuf->linklist; l; i++, l = l->next) ;
+ nitem = i;
+
+ label = New_N(char *, nitem + 1);
+ for (i = 0, l = Currentbuf->linklist; l; i++, l = l->next) {
+ str = Strnew_charp(l->title ? l->title : "(empty)");
+ if (l->type == LINK_TYPE_REL)
+ Strcat_charp(str, " [Rel] ");
+ else if (l->type == LINK_TYPE_REV)
+ Strcat_charp(str, " [Rev] ");
+ else
+ Strcat_charp(str, " ");
+ Strcat_charp(str, l->url ? l->url : "");
+ label[i] = str->ptr;
+ if (len < str->length)
+ len = str->length;
+ }
+ label[nitem + 1] = NULL;
+ LinkV = 0;
+
+ new_option_menu(&LinkMenu, label, &LinkV, lmGoURL);
+ LinkMenu.initial = LinkV;
+ LinkMenu.cursorX = Currentbuf->cursorX + Currentbuf->rootX;
+ LinkMenu.cursorY = Currentbuf->cursorY + Currentbuf->rootY;
+}
+
+static void
+lmGoURL(void)
+{
+ LinkList *l;
+ int i;
+ ParsedURL pu;
+
+ for (i = 0, l = Currentbuf->linklist; l; i++, l = l->next) {
+ if (i == LinkV)
+ break;
+ }
+ if (l == NULL || l->url == NULL)
+ return;
+ CurrentKey = -1;
+ CurrentKeyData = NULL;
+ CurrentCmdData = l->url;
+ gorURL();
+ CurrentCmdData = NULL;
+}
+
+/* --- LinkMenu (END) --- */
+
/* --- OptionMenu --- */
void
@@ -1674,7 +1743,7 @@ initMenu(void)
MenuItem *item = NULL;
MenuList *list;
- w3mMenuList = New_N(MenuList, 3);
+ w3mMenuList = New_N(MenuList, 4);
w3mMenuList[0].id = "Main";
w3mMenuList[0].menu = &MainMenu;
w3mMenuList[0].item = MainMenuItem;
@@ -1684,7 +1753,10 @@ initMenu(void)
w3mMenuList[2].id = "SelectTab";
w3mMenuList[2].menu = &SelTabMenu;
w3mMenuList[2].item = NULL;
- w3mMenuList[3].id = NULL;
+ w3mMenuList[3].id = "Link";
+ w3mMenuList[3].menu = &LinkMenu;
+ w3mMenuList[3].item = NULL;
+ w3mMenuList[4].id = NULL;
if ((mf = fopen(rcFile(MENU_FILE), "rt")) == NULL)
goto create_menu;