aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ChangeLog27
-rwxr-xr-xconfigure3
-rw-r--r--display.c20
-rw-r--r--fm.h11
-rw-r--r--func.c67
-rw-r--r--main.c103
-rw-r--r--proto.h6
-rw-r--r--rc.c5
8 files changed, 216 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 8ea71ce..e5d0e33 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2002-11-22 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
+
+ * [w3m-dev 03455] mouse menu
+ * configure (config.h): MOUSE_FILE
+ * display.c (displayBuffer): nTab -> nTab2, N_TAB -> nTabLine()
+ (redrawNLine): nTab -> nTab2, N_TAB -> nTabLine()
+ mouse_menu support
+ * fm.h (nTab2): added
+ (N_TAB): deleted
+ (NO_TABBUFFER): added
+ (struct _MouseMenu): added
+ (mouse_menu_map): added
+ (mouse_menu): added
+ * func.c (initMouseMenu): added
+ * main.c (main): initMouseMenu()
+ (posTab): mouse_menu support
+ (mouse_menu_action): added
+ (process_mouse): mouse_menu support
+ (reinit): initMouseMenu()
+ (nTabLine): added
+ (moveTab): check NO_TABBUFFER
+ * proto.h (nTabLine): added
+ (initMouseMenu): added
+ * rc.c (sync_with_option): initMouseMenu()
+
2002-11-22 Fumitoshi UKAI <ukai@debian.or.jp>
* NEWS: func: NEXT, PREV
@@ -4948,4 +4973,4 @@ a * [w3m-dev 03276] compile error on EWS4800
* release-0-2-1
* import w3m-0.2.1
-$Id: ChangeLog,v 1.540 2002/11/21 16:17:15 ukai Exp $
+$Id: ChangeLog,v 1.541 2002/11/21 16:31:35 ukai Exp $
diff --git a/configure b/configure
index 3b8b366..40061a8 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
#!/bin/sh
-# $Id: configure,v 1.87 2002/11/15 15:36:48 ukai Exp $
+# $Id: configure,v 1.88 2002/11/21 16:31:35 ukai Exp $
# Configuration.
#
@@ -2420,6 +2420,7 @@ $def_use_xface
#define CONFIG_FILE "config"
#define KEYMAP_FILE "keymap"
#define MENU_FILE "menu"
+#define MOUSE_FILE "mouse"
#define COOKIE_FILE "cookie"
#define HISTORY_FILE "history"
diff --git a/display.c b/display.c
index 9936b55..4bbc2e8 100644
--- a/display.c
+++ b/display.c
@@ -1,4 +1,4 @@
-/* $Id: display.c,v 1.34 2002/11/19 17:40:31 ukai Exp $ */
+/* $Id: display.c,v 1.35 2002/11/21 16:31:35 ukai Exp $ */
#include <signal.h>
#include "fm.h"
@@ -254,8 +254,8 @@ displayBuffer(Buffer *buf, int mode)
else
buf->rootX = 0;
buf->COLS = COLS - buf->rootX;
- if (nTab > 1) {
- ny = (nTab - 1) / N_TAB + 2;
+ if (nTab2 > 1) {
+ ny = (nTab2 - 1) / nTabLine() + 2;
if (ny > LASTLINE)
ny = LASTLINE;
}
@@ -445,12 +445,18 @@ redrawNLine(Buffer *buf, int n)
#endif /* USE_BG_COLOR */
}
#endif /* USE_COLOR */
- if (nTab > 1) {
+ if (nTab2 > 1) {
TabBuffer *t;
- int nx = N_TAB, col = COLS - 2, x, l;
+ int nx = nTabLine(), col = COLS - 2, x, l;
+ i = 0;
move(0, 0);
- for (t = FirstTab, i = 0; t; t = t->nextTab, i++) {
+ if (mouse_menu) {
+ addstr(mouse_menu);
+ clrtoeolx();
+ i++;
+ }
+ for (t = FirstTab; t; t = t->nextTab, i++) {
x = col * (i % nx) / nx;
move(i / nx, x);
if (t == CurrentTab)
@@ -474,7 +480,7 @@ redrawNLine(Buffer *buf, int n)
}
move(0, col);
addstr(" x");
- move((nTab - 1) / nx + 1, 0);
+ move((nTab2 - 1) / nx + 1, 0);
for (i = 0; i < COLS; i++)
addch('~');
}
diff --git a/fm.h b/fm.h
index 6408859..58d0b81 100644
--- a/fm.h
+++ b/fm.h
@@ -1,4 +1,4 @@
-/* $Id: fm.h,v 1.84 2002/11/19 17:40:32 ukai Exp $ */
+/* $Id: fm.h,v 1.85 2002/11/21 16:31:36 ukai Exp $ */
/*
* w3m: WWW wo Miru utility
*
@@ -805,9 +805,9 @@ global int open_tab_blank init(FALSE);
global int open_tab_dl_list init(FALSE);
global int close_tab_back init(FALSE);
global int nTab;
+#define nTab2 (mouse_menu ? (nTab + 1) : nTab)
global int TabCols init(10);
-#define N_TAB ((COLS - 2 > TabCols * nTab) ? nTab \
- : (nTab - 1) / ((nTab * TabCols - 1) / (COLS - 2) + 1) + 1)
+#define NO_TABBUFFER ((TabBuffer *)1)
#define Currentbuf (CurrentTab->currentBuffer)
#define Firstbuf (CurrentTab->firstBuffer)
global DownloadList *FirstDL init(NULL);
@@ -991,7 +991,12 @@ global int reverse_mouse init(FALSE);
global int relative_wheel_scroll init(FALSE);
global int fixed_wheel_scroll_count init(5);
global int relative_wheel_scroll_ratio init(30);
+struct _MouseMenu {
+ void (*func) ();
+ char *data;
+} mouse_menu_map[3][10];
#endif /* USE_MOUSE */
+global char *mouse_menu init(NULL);
#ifdef USE_COOKIE
global int default_use_cookie init(TRUE);
diff --git a/func.c b/func.c
index 8afa0c2..6c4dee2 100644
--- a/func.c
+++ b/func.c
@@ -1,4 +1,4 @@
-/* $Id: func.c,v 1.10 2002/06/01 16:50:16 ukai Exp $ */
+/* $Id: func.c,v 1.11 2002/11/21 16:31:36 ukai Exp $ */
/*
* w3m func.c
*/
@@ -320,3 +320,68 @@ getQWord(char **str)
*str = p;
return tmp->ptr;
}
+
+#ifdef USE_MOUSE
+void
+initMouseMenu(void)
+{
+ FILE *mf;
+ Str line;
+ char *p, *s;
+ int f, b, x, x2;
+
+ mouse_menu = NULL;
+ for (b = 1; b <= 3; b++) {
+ for (x = 0; x < 10; x++) {
+ mouse_menu_map[b - 1][x].func = NULL;
+ mouse_menu_map[b - 1][x].data = NULL;
+ }
+ }
+ if ((mf = fopen(rcFile(MOUSE_FILE), "rt")) == NULL)
+ return;
+
+ while (!feof(mf)) {
+ line = Strfgets(mf);
+ Strchop(line);
+ Strremovefirstspaces(line);
+ if (line->length == 0)
+ continue;
+ p = line->ptr;
+ s = getWord(&p);
+ if (*s == '#') /* comment */
+ continue;
+ if (!strcmp(s, "menu")) {
+ s = getQWord(&p);
+ if (*s)
+ mouse_menu = Strnew_charp(s)->ptr;
+ continue;
+ }
+ if (strcmp(s, "button"))
+ continue; /* error */
+ s = getWord(&p);
+ b = atoi(s);
+ if (!(b >= 1 && b <= 3))
+ continue; /* error */
+ s = getWord(&p);
+ x = atoi(s);
+ if (!(IS_DIGIT(*s) && x >= 0 && x <= 9))
+ continue; /* error */
+ s = getWord(&p);
+ x2 = atoi(s);
+ if (!(IS_DIGIT(*s) && x2 >= 0 && x2 <= 9))
+ continue; /* error */
+ s = getWord(&p);
+ f = getFuncList(s);
+ if (f < 0)
+ continue; /* error */
+ s = getQWord(&p);
+ if (!*s)
+ s = NULL;
+ for (; x <= x2; x++) {
+ mouse_menu_map[b - 1][x].func = w3mFuncList[f].func;
+ mouse_menu_map[b - 1][x].data = s;
+ }
+ }
+ fclose(mf);
+}
+#endif
diff --git a/main.c b/main.c
index 048ada3..4b6314f 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.146 2002/11/21 16:15:58 ukai Exp $ */
+/* $Id: main.c,v 1.147 2002/11/21 16:31:36 ukai Exp $ */
#define MAINPROGRAM
#include "fm.h"
#include <signal.h>
@@ -746,6 +746,9 @@ main(int argc, char **argv, char **envp)
setupscreen();
#endif /* not SIGWINCH */
initKeymap(TRUE);
+#ifdef USE_MOUSE
+ initMouseMenu();
+#endif /* MOUSE */
#ifdef USE_MENU
initMenu();
#endif /* MENU */
@@ -4787,12 +4790,44 @@ posTab(int x, int y)
if (col <= 0)
return NULL;
- n = x * N_TAB / col + y * N_TAB;
- for (t = FirstTab, i = 0; t && i < n; t = t->nextTab, i++) ;
+ n = nTabLine();
+ n = x * n / col + y * n;
+ i = 0;
+ if (mouse_menu) {
+ if (n == 0)
+ return NO_TABBUFFER;
+ i++;
+ }
+ for (t = FirstTab; t && i < n; t = t->nextTab, i++) ;
return t;
}
static void
+mouse_menu_action(int btn, int x)
+{
+ switch (btn) {
+ case MOUSE_BTN1_DOWN:
+ btn = 0;
+ break;
+ case MOUSE_BTN2_DOWN:
+ btn = 1;
+ break;
+ case MOUSE_BTN3_DOWN:
+ btn = 2;
+ break;
+ default:
+ return;
+ }
+ if (x >= 0 && x <= 9 && mouse_menu_map[btn][x].func) {
+ CurrentKey = -1;
+ CurrentKeyData = NULL;
+ CurrentCmdData = mouse_menu_map[btn][x].data;
+ (*mouse_menu_map[btn][x].func) ();
+ CurrentCmdData = NULL;
+ }
+}
+
+static void
process_mouse(int btn, int x, int y)
{
int delta_x, delta_y, i;
@@ -4800,20 +4835,26 @@ process_mouse(int btn, int x, int y)
TabBuffer *t;
int ny = 0;
- if (nTab > 1)
- ny = (nTab - 1) / N_TAB + 1;
+ if (nTab2 > 1)
+ ny = (nTab2 - 1) / nTabLine() + 1;
if (btn == MOUSE_BTN_UP) {
switch (press_btn) {
case MOUSE_BTN1_DOWN:
- if (nTab > 1 && y < ny) {
+ if (nTab2 > 1 && y < ny) {
if (press_y == y && press_x == x) {
if (y == 0 && x >= COLS - 2) {
deleteTab(CurrentTab);
- displayBuffer(Currentbuf, B_NORMAL);
+ displayBuffer(Currentbuf, B_FORCE_REDRAW);
+ return;
}
t = posTab(x, y);
- if (t)
- CurrentTab = t;
+ if (t == NULL)
+ return;
+ if (t == NO_TABBUFFER) {
+ mouse_menu_action(press_btn, x);
+ return;
+ }
+ CurrentTab = t;
displayBuffer(Currentbuf, B_FORCE_REDRAW);
return;
}
@@ -4829,6 +4870,8 @@ process_mouse(int btn, int x, int y)
t = posTab(x, y);
if (t == NULL)
return;
+ if (t == NO_TABBUFFER)
+ t = NULL; /* open new tab */
cursorXY(Currentbuf, press_x - Currentbuf->rootX,
press_y - Currentbuf->rootY);
if (Currentbuf->cursorY == press_y - Currentbuf->rootY &&
@@ -4915,9 +4958,13 @@ process_mouse(int btn, int x, int y)
}
break;
case MOUSE_BTN2_DOWN:
- if (nTab > 1 && y < ny) {
+ if (nTab2 > 1 && y < ny) {
if (press_y == y && press_x == x) {
t = posTab(x, y);
+ if (t == NO_TABBUFFER) {
+ mouse_menu_action(press_btn, x);
+ return;
+ }
if (t) {
deleteTab(t);
displayBuffer(Currentbuf, B_FORCE_REDRAW);
@@ -4928,6 +4975,15 @@ process_mouse(int btn, int x, int y)
backBf();
break;
case MOUSE_BTN3_DOWN:
+ if (nTab2 > 1 && y < ny) {
+ if (press_y == y && press_x == x) {
+ t = posTab(x, y);
+ if (t == NO_TABBUFFER) {
+ mouse_menu_action(press_btn, x);
+ return;
+ }
+ }
+ }
#ifdef USE_MENU
if (x >= Currentbuf->rootX && y > ny)
cursorXY(Currentbuf, x - Currentbuf->rootX,
@@ -5438,6 +5494,9 @@ reinit()
initCookie();
#endif
initKeymap(TRUE);
+#ifdef USE_MOUSE
+ initMouseMenu();
+#endif
#ifdef USE_MENU
initMenu();
#endif
@@ -5467,6 +5526,13 @@ reinit()
return;
}
+#ifdef USE_MOUSE
+ if (!strcasecmp(resource, "MOUSE_MENU")) {
+ initMouseMenu();
+ return;
+ }
+#endif
+
#ifdef USE_MENU
if (!strcasecmp(resource, "MENU")) {
initMenu();
@@ -5559,6 +5625,19 @@ newT(void)
displayBuffer(Currentbuf, B_REDRAW_IMAGE);
}
+int
+nTabLine(void)
+{
+ int n = nTab2;
+
+ if (COLS - 2 > TabCols * n)
+ return n;
+ n = (n - 1) / ((n * TabCols - 1) / (COLS - 2) + 1) + 1;
+ if (n > (COLS - 2) / TabCols)
+ n = (COLS - 2) / TabCols;
+ return n ? n : 1;
+}
+
TabBuffer *
numTab(int n)
{
@@ -5763,7 +5842,9 @@ tabrURL(void)
void
moveTab(TabBuffer * t, TabBuffer * t2, int right)
{
- if (!t || !t2 || t == t2)
+ if (t2 == NO_TABBUFFER)
+ t2 = FirstTab;
+ if (!t || !t2 || t == t2 || t == NO_TABBUFFER)
return;
if (t->prevTab) {
if (t->nextTab)
diff --git a/proto.h b/proto.h
index 28f1387..8389c4a 100644
--- a/proto.h
+++ b/proto.h
@@ -1,4 +1,4 @@
-/* $Id: proto.h,v 1.57 2002/11/21 16:15:58 ukai Exp $ */
+/* $Id: proto.h,v 1.58 2002/11/21 16:31:36 ukai Exp $ */
/*
* This file was automatically generated by version 1.7 of cextract.
* Manual editing not recommended.
@@ -225,6 +225,7 @@ extern char *inputAnswer(char *prompt);
extern int matchattr(char *p, char *attr, int len, Str *value);
extern void readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu);
extern char *checkHeader(Buffer *buf, char *field);
+extern int nTabLine(void);
extern TabBuffer *newTab(void);
extern TabBuffer *deleteTab(TabBuffer *tab);
extern void addDownloadList(pid_t pid, char *url, char *save, char *lock,
@@ -626,6 +627,9 @@ extern int getKey(char *s);
extern char *getKeyData(int key);
extern char *getWord(char **str);
extern char *getQWord(char **str);
+#ifdef USE_MOUSE
+extern void initMouseMenu(void);
+#endif
#ifdef USE_MENU
extern void new_menu(Menu *menu, MenuItem *item);
diff --git a/rc.c b/rc.c
index 0aeb428..47f79dd 100644
--- a/rc.c
+++ b/rc.c
@@ -1,4 +1,4 @@
-/* $Id: rc.c,v 1.65 2002/11/19 17:40:34 ukai Exp $ */
+/* $Id: rc.c,v 1.66 2002/11/21 16:31:36 ukai Exp $ */
/*
* Initialization file etc.
*/
@@ -1322,6 +1322,9 @@ sync_with_option(void)
AcceptMedia = acceptableMimeTypes();
if (fmInitialized) {
initKeymap(FALSE);
+#ifdef USE_MOUSE
+ initMouseMenu();
+#endif /* MOUSE */
#ifdef USE_MENU
initMenu();
#endif /* MENU */