[w3m-dev 03458] Re: mouse menu

* display.c (displayBuffer): nTab2 -> nTab, mouse_menu
* fm.h (nTab2): deleted
	(MouseMenuMap): added
	(MouseMenu): added
	(LIMIT_MOUSE_MENU): added
* func.c (initMouseMenu): delete mouse_menu_map initialization
		conv_from_system
		mouse_menu->width
* main.c (main): mouse_menu->in_action = FALSE
	(posTab): check mouse_menu
	(mouse_menu_action): add y arg
		mouse_menu_width check
	(process_mouse): nTab2 -> nTab, mouse_menu
	(nTabLine): deleted
	(calcTabPos): check mouse_menu
* menu.c (mainMn): x, y
	(selMn): mouse_menu check
	(tabMn): mosue_menu check
* proto.h (nTabLine): deleted
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
This commit is contained in:
Fumitoshi UKAI
2002-11-22 15:43:13 +00:00
parent 4da0ac0fb9
commit 82901953d3
7 changed files with 136 additions and 67 deletions
+24 -1
View File
@@ -1,3 +1,26 @@
2002-11-23 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
* [w3m-dev 03458] Re: mouse menu
* display.c (displayBuffer): nTab2 -> nTab, mouse_menu
* fm.h (nTab2): deleted
(MouseMenuMap): added
(MouseMenu): added
(LIMIT_MOUSE_MENU): added
* func.c (initMouseMenu): delete mouse_menu_map initialization
conv_from_system
mouse_menu->width
* main.c (main): mouse_menu->in_action = FALSE
(posTab): check mouse_menu
(mouse_menu_action): add y arg
mouse_menu_width check
(process_mouse): nTab2 -> nTab, mouse_menu
(nTabLine): deleted
(calcTabPos): check mouse_menu
* menu.c (mainMn): x, y
(selMn): mouse_menu check
(tabMn): mosue_menu check
* proto.h (nTabLine): deleted
2002-11-22 Fumitoshi UKAI <ukai@debian.or.jp> 2002-11-22 Fumitoshi UKAI <ukai@debian.or.jp>
* NEWS: options: -N * NEWS: options: -N
@@ -5004,4 +5027,4 @@ a * [w3m-dev 03276] compile error on EWS4800
* release-0-2-1 * release-0-2-1
* import w3m-0.2.1 * import w3m-0.2.1
$Id: ChangeLog,v 1.545 2002/11/21 17:13:27 ukai Exp $ $Id: ChangeLog,v 1.546 2002/11/22 15:43:13 ukai Exp $
+9 -9
View File
@@ -1,4 +1,4 @@
/* $Id: display.c,v 1.37 2002/11/21 17:05:01 ukai Exp $ */ /* $Id: display.c,v 1.38 2002/11/22 15:43:13 ukai Exp $ */
#include <signal.h> #include <signal.h>
#include "fm.h" #include "fm.h"
@@ -254,7 +254,7 @@ displayBuffer(Buffer *buf, int mode)
else else
buf->rootX = 0; buf->rootX = 0;
buf->COLS = COLS - buf->rootX; buf->COLS = COLS - buf->rootX;
if (nTab2 > 1) { if (nTab > 1 || mouse_menu) {
ny = LastTab->y + 2; ny = LastTab->y + 2;
if (ny > LASTLINE) if (ny > LASTLINE)
ny = LASTLINE; ny = LASTLINE;
@@ -445,17 +445,15 @@ redrawNLine(Buffer *buf, int n)
#endif /* USE_BG_COLOR */ #endif /* USE_BG_COLOR */
} }
#endif /* USE_COLOR */ #endif /* USE_COLOR */
if (nTab2 > 1) { if (nTab > 1 || mouse_menu) {
TabBuffer *t; TabBuffer *t;
int l; int l;
i = 0;
move(0, 0); move(0, 0);
if (mouse_menu) { #ifdef USE_MOUSE
addstr(mouse_menu); if (mouse_menu && mouse_menu->str)
clrtoeolx(); addstr(mouse_menu->str);
i++; #endif
}
clrtoeolx(); clrtoeolx();
for (t = FirstTab; t; t = t->nextTab) { for (t = FirstTab; t; t = t->nextTab) {
move(t->y, t->x1); move(t->y, t->x1);
@@ -477,8 +475,10 @@ redrawNLine(Buffer *buf, int n)
boldend(); boldend();
clrtoeolx(); clrtoeolx();
} }
#if 0
move(0, COLS - 2); move(0, COLS - 2);
addstr(" x"); addstr(" x");
#endif
move(LastTab->y + 1, 0); move(LastTab->y + 1, 0);
for (i = 0; i < COLS; i++) for (i = 0; i < COLS; i++)
addch('~'); addch('~');
+15 -5
View File
@@ -1,4 +1,4 @@
/* $Id: fm.h,v 1.86 2002/11/21 17:05:01 ukai Exp $ */ /* $Id: fm.h,v 1.87 2002/11/22 15:43:14 ukai Exp $ */
/* /*
* w3m: WWW wo Miru utility * w3m: WWW wo Miru utility
* *
@@ -808,7 +808,6 @@ global int open_tab_blank init(FALSE);
global int open_tab_dl_list init(FALSE); global int open_tab_dl_list init(FALSE);
global int close_tab_back init(FALSE); global int close_tab_back init(FALSE);
global int nTab; global int nTab;
#define nTab2 (mouse_menu ? (nTab + 1) : nTab)
global int TabCols init(10); global int TabCols init(10);
#define NO_TABBUFFER ((TabBuffer *)1) #define NO_TABBUFFER ((TabBuffer *)1)
#define Currentbuf (CurrentTab->currentBuffer) #define Currentbuf (CurrentTab->currentBuffer)
@@ -994,12 +993,23 @@ global int reverse_mouse init(FALSE);
global int relative_wheel_scroll init(FALSE); global int relative_wheel_scroll init(FALSE);
global int fixed_wheel_scroll_count init(5); global int fixed_wheel_scroll_count init(5);
global int relative_wheel_scroll_ratio init(30); global int relative_wheel_scroll_ratio init(30);
struct _MouseMenu { typedef struct _MouseMenuMap {
void (*func) (); void (*func) ();
char *data; char *data;
} mouse_menu_map[3][10]; } MouseMenuMap;
typedef struct _MouseMenu {
char *str;
int width;
int in_action;
int cursorX;
int cursorY;
MouseMenuMap *map[3];
} MouseMenu;
global MouseMenu *mouse_menu init(NULL);
#define LIMIT_MOUSE_MENU 100
#else
#define mouse_menu NULL
#endif /* USE_MOUSE */ #endif /* USE_MOUSE */
global char *mouse_menu init(NULL);
#ifdef USE_COOKIE #ifdef USE_COOKIE
global int default_use_cookie init(TRUE); global int default_use_cookie init(TRUE);
+23 -15
View File
@@ -1,4 +1,4 @@
/* $Id: func.c,v 1.12 2002/11/21 16:32:29 ukai Exp $ */ /* $Id: func.c,v 1.13 2002/11/22 15:43:14 ukai Exp $ */
/* /*
* w3m func.c * w3m func.c
*/ */
@@ -331,12 +331,6 @@ initMouseMenu(void)
int f, b, x, x2; int f, b, x, x2;
mouse_menu = NULL; 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) if ((mf = fopen(rcFile(MOUSE_FILE), "rt")) == NULL)
return; return;
@@ -346,16 +340,30 @@ initMouseMenu(void)
Strremovefirstspaces(line); Strremovefirstspaces(line);
if (line->length == 0) if (line->length == 0)
continue; continue;
p = line->ptr; p = conv_from_system(line->ptr);
s = getWord(&p); s = getWord(&p);
if (*s == '#') /* comment */ if (*s == '#') /* comment */
continue; continue;
if (!strcmp(s, "menu")) { if (!strcmp(s, "menu")) {
s = getQWord(&p); s = getQWord(&p);
if (*s) if (!*s)
mouse_menu = Strnew_charp(s)->ptr; continue; /* error */
continue; mouse_menu = New(MouseMenu);
mouse_menu->str = s;
mouse_menu->width = strlen(s);
mouse_menu->in_action = FALSE;
if (mouse_menu->width >= LIMIT_MOUSE_MENU)
mouse_menu->width = LIMIT_MOUSE_MENU;
for (b = 0; b < 3; b++) {
mouse_menu->map[b] = New_N(MouseMenuMap, mouse_menu->width);
for (x = 0; x < mouse_menu->width; x++) {
mouse_menu->map[b][x].func = NULL;
mouse_menu->map[b][x].data = NULL;
} }
}
}
if (!mouse_menu)
continue; /* "menu" is not set */
if (strcmp(s, "button")) if (strcmp(s, "button"))
continue; /* error */ continue; /* error */
s = getWord(&p); s = getWord(&p);
@@ -364,11 +372,11 @@ initMouseMenu(void)
continue; /* error */ continue; /* error */
s = getWord(&p); s = getWord(&p);
x = atoi(s); x = atoi(s);
if (!(IS_DIGIT(*s) && x >= 0 && x <= 9)) if (!(IS_DIGIT(*s) && x >= 0 && x < mouse_menu->width))
continue; /* error */ continue; /* error */
s = getWord(&p); s = getWord(&p);
x2 = atoi(s); x2 = atoi(s);
if (!(IS_DIGIT(*s) && x2 >= 0 && x2 <= 9)) if (!(IS_DIGIT(*s) && x2 >= 0 && x2 < mouse_menu->width))
continue; /* error */ continue; /* error */
s = getWord(&p); s = getWord(&p);
f = getFuncList(s); f = getFuncList(s);
@@ -378,8 +386,8 @@ initMouseMenu(void)
if (!*s) if (!*s)
s = NULL; s = NULL;
for (; x <= x2; x++) { for (; x <= x2; x++) {
mouse_menu_map[b - 1][x].func = w3mFuncList[f].func; mouse_menu->map[b - 1][x].func = w3mFuncList[f].func;
mouse_menu_map[b - 1][x].data = s; mouse_menu->map[b - 1][x].data = s;
} }
} }
fclose(mf); fclose(mf);
+31 -25
View File
@@ -1,4 +1,4 @@
/* $Id: main.c,v 1.151 2002/11/21 17:12:18 ukai Exp $ */ /* $Id: main.c,v 1.152 2002/11/22 15:43:14 ukai Exp $ */
#define MAINPROGRAM #define MAINPROGRAM
#include "fm.h" #include "fm.h"
#include <signal.h> #include <signal.h>
@@ -1017,6 +1017,8 @@ main(int argc, char **argv, char **envp)
CurrentKeyData = NULL; CurrentKeyData = NULL;
/* get keypress event */ /* get keypress event */
#ifdef USE_MOUSE #ifdef USE_MOUSE
if (mouse_menu)
mouse_menu->in_action = FALSE;
if (use_mouse) if (use_mouse)
mouse_active(); mouse_active();
#endif /* USE_MOUSE */ #endif /* USE_MOUSE */
@@ -4804,6 +4806,8 @@ posTab(int x, int y)
{ {
TabBuffer *tab; TabBuffer *tab;
if (mouse_menu && x < mouse_menu->width && y == 0)
return NO_TABBUFFER;
for (tab = FirstTab; tab; tab = tab->nextTab) { for (tab = FirstTab; tab; tab = tab->nextTab) {
if (tab->x1 <= x && x <= tab->x2 && tab->y == y) if (tab->x1 <= x && x <= tab->x2 && tab->y == y)
return tab; return tab;
@@ -4812,8 +4816,10 @@ posTab(int x, int y)
} }
static void static void
mouse_menu_action(int btn, int x) mouse_menu_action(int btn, int x, int y)
{ {
if (!mouse_menu)
return;
switch (btn) { switch (btn) {
case MOUSE_BTN1_DOWN: case MOUSE_BTN1_DOWN:
btn = 0; btn = 0;
@@ -4827,11 +4833,14 @@ mouse_menu_action(int btn, int x)
default: default:
return; return;
} }
if (x >= 0 && x <= 9 && mouse_menu_map[btn][x].func) { if (x >= 0 && x < mouse_menu->width && mouse_menu->map[btn][x].func) {
mouse_menu->in_action = TRUE;
mouse_menu->cursorX = x;
mouse_menu->cursorY = y;
CurrentKey = -1; CurrentKey = -1;
CurrentKeyData = NULL; CurrentKeyData = NULL;
CurrentCmdData = mouse_menu_map[btn][x].data; CurrentCmdData = mouse_menu->map[btn][x].data;
(*mouse_menu_map[btn][x].func) (); (*mouse_menu->map[btn][x].func) ();
CurrentCmdData = NULL; CurrentCmdData = NULL;
} }
} }
@@ -4844,23 +4853,25 @@ process_mouse(int btn, int x, int y)
TabBuffer *t; TabBuffer *t;
int ny = 0; int ny = 0;
if (nTab2 > 1) if (nTab > 1 || mouse_menu)
ny = LastTab->y + 1; ny = LastTab->y + 1;
if (btn == MOUSE_BTN_UP) { if (btn == MOUSE_BTN_UP) {
switch (press_btn) { switch (press_btn) {
case MOUSE_BTN1_DOWN: case MOUSE_BTN1_DOWN:
if (ny && y < ny) { if (ny && y < ny) {
if (press_y == y && press_x == x) { if (press_y == y && press_x == x) {
#if 0
if (y == 0 && x >= COLS - 2) { if (y == 0 && x >= COLS - 2) {
deleteTab(CurrentTab); deleteTab(CurrentTab);
displayBuffer(Currentbuf, B_FORCE_REDRAW); displayBuffer(Currentbuf, B_FORCE_REDRAW);
return; return;
} }
#endif
t = posTab(x, y); t = posTab(x, y);
if (t == NULL) if (t == NULL)
return; return;
if (t == NO_TABBUFFER) { if (t == NO_TABBUFFER) {
mouse_menu_action(press_btn, x); mouse_menu_action(press_btn, x, y);
return; return;
} }
CurrentTab = t; CurrentTab = t;
@@ -4970,25 +4981,25 @@ process_mouse(int btn, int x, int y)
if (ny && y < ny) { if (ny && y < ny) {
if (press_y == y && press_x == x) { if (press_y == y && press_x == x) {
t = posTab(x, y); t = posTab(x, y);
if (t == NULL)
return;
if (t == NO_TABBUFFER) { if (t == NO_TABBUFFER) {
mouse_menu_action(press_btn, x); mouse_menu_action(press_btn, x, y);
return; return;
} }
if (t) {
deleteTab(t); deleteTab(t);
displayBuffer(Currentbuf, B_FORCE_REDRAW); displayBuffer(Currentbuf, B_FORCE_REDRAW);
} }
}
return; return;
} }
backBf(); backBf();
break; break;
case MOUSE_BTN3_DOWN: case MOUSE_BTN3_DOWN:
if (nTab2 > 1 && y < ny) { if (ny && y < ny) {
if (press_y == y && press_x == x) { if (press_y == y && press_x == x) {
t = posTab(x, y); t = posTab(x, y);
if (t == NO_TABBUFFER) { if (t == NO_TABBUFFER) {
mouse_menu_action(press_btn, x); mouse_menu_action(press_btn, x, y);
return; return;
} }
} }
@@ -5635,19 +5646,6 @@ newT(void)
displayBuffer(Currentbuf, B_REDRAW_IMAGE); 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 * TabBuffer *
numTab(int n) numTab(int n)
{ {
@@ -5668,9 +5666,17 @@ static void
calcTabPos(void) calcTabPos(void)
{ {
TabBuffer *tab; TabBuffer *tab;
#if 0
int lcol = 0, rcol = 2, col; int lcol = 0, rcol = 2, col;
#else
int lcol = 0, rcol = 0, col;
#endif
int n1, n2, na, nx, ny, ix, iy; int n1, n2, na, nx, ny, ix, iy;
#ifdef USE_MOUSE
lcol = mouse_menu ? mouse_menu->width : 0;
#endif
if (nTab <= 0) if (nTab <= 0)
return; return;
n1 = (COLS - rcol - lcol) / TabCols; n1 = (COLS - rcol - lcol) / TabCols;
+30 -7
View File
@@ -1,4 +1,4 @@
/* $Id: menu.c,v 1.18 2002/11/15 15:36:48 ukai Exp $ */ /* $Id: menu.c,v 1.19 2002/11/22 15:43:14 ukai Exp $ */
/* /*
* w3m menu.c * w3m menu.c
*/ */
@@ -1252,6 +1252,8 @@ mainMn(void)
Menu *menu = &MainMenu; Menu *menu = &MainMenu;
char *data; char *data;
int n; int n;
int x = Currentbuf->cursorX + Currentbuf->rootX,
y = Currentbuf->cursorY + Currentbuf->rootY;
data = searchKeyData(); data = searchKeyData();
if (data != NULL) { if (data != NULL) {
@@ -1260,8 +1262,13 @@ mainMn(void)
return; return;
menu = w3mMenuList[n].menu; menu = w3mMenuList[n].menu;
} }
popupMenu(Currentbuf->cursorX + Currentbuf->rootX, #ifdef USE_MOUSE
Currentbuf->cursorY + Currentbuf->rootY, menu); if (mouse_menu && mouse_menu->in_action) {
x = mouse_menu->cursorX - FRAME_WIDTH - 1;
y = mouse_menu->cursorY;
}
#endif
popupMenu(x, y, menu);
} }
/* --- MainMenu (END) --- */ /* --- MainMenu (END) --- */
@@ -1271,8 +1278,16 @@ mainMn(void)
void void
selMn(void) selMn(void)
{ {
popupMenu(Currentbuf->cursorX + Currentbuf->rootX, int x = Currentbuf->cursorX + Currentbuf->rootX,
Currentbuf->cursorY + Currentbuf->rootY, &SelectMenu); y = Currentbuf->cursorY + Currentbuf->rootY;
#ifdef USE_MOUSE
if (mouse_menu && mouse_menu->in_action) {
x = mouse_menu->cursorX - FRAME_WIDTH - 1;
y = mouse_menu->cursorY;
}
#endif
popupMenu(x, y, &SelectMenu);
} }
static void static void
@@ -1408,8 +1423,16 @@ smDelBuf(char c)
void void
tabMn(void) tabMn(void)
{ {
popupMenu(Currentbuf->cursorX + Currentbuf->rootX, int x = Currentbuf->cursorX + Currentbuf->rootX,
Currentbuf->cursorY + Currentbuf->rootY, &SelTabMenu); y = Currentbuf->cursorY + Currentbuf->rootY;
#ifdef USE_MOUSE
if (mouse_menu && mouse_menu->in_action) {
x = mouse_menu->cursorX - FRAME_WIDTH - 1;
y = mouse_menu->cursorY;
}
#endif
popupMenu(x, y, &SelTabMenu);
} }
static void static void
+1 -2
View File
@@ -1,4 +1,4 @@
/* $Id: proto.h,v 1.58 2002/11/21 16:31:36 ukai Exp $ */ /* $Id: proto.h,v 1.59 2002/11/22 15:43:14 ukai Exp $ */
/* /*
* This file was automatically generated by version 1.7 of cextract. * This file was automatically generated by version 1.7 of cextract.
* Manual editing not recommended. * Manual editing not recommended.
@@ -225,7 +225,6 @@ extern char *inputAnswer(char *prompt);
extern int matchattr(char *p, char *attr, int len, Str *value); extern int matchattr(char *p, char *attr, int len, Str *value);
extern void readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu); extern void readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu);
extern char *checkHeader(Buffer *buf, char *field); extern char *checkHeader(Buffer *buf, char *field);
extern int nTabLine(void);
extern TabBuffer *newTab(void); extern TabBuffer *newTab(void);
extern TabBuffer *deleteTab(TabBuffer *tab); extern TabBuffer *deleteTab(TabBuffer *tab);
extern void addDownloadList(pid_t pid, char *url, char *save, char *lock, extern void addDownloadList(pid_t pid, char *url, char *save, char *lock,