[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>
* NEWS: options: -N
@@ -5004,4 +5027,4 @@ a * [w3m-dev 03276] compile error on EWS4800
* release-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 "fm.h"
@@ -254,7 +254,7 @@ displayBuffer(Buffer *buf, int mode)
else
buf->rootX = 0;
buf->COLS = COLS - buf->rootX;
if (nTab2 > 1) {
if (nTab > 1 || mouse_menu) {
ny = LastTab->y + 2;
if (ny > LASTLINE)
ny = LASTLINE;
@@ -445,17 +445,15 @@ redrawNLine(Buffer *buf, int n)
#endif /* USE_BG_COLOR */
}
#endif /* USE_COLOR */
if (nTab2 > 1) {
if (nTab > 1 || mouse_menu) {
TabBuffer *t;
int l;
i = 0;
move(0, 0);
if (mouse_menu) {
addstr(mouse_menu);
clrtoeolx();
i++;
}
#ifdef USE_MOUSE
if (mouse_menu && mouse_menu->str)
addstr(mouse_menu->str);
#endif
clrtoeolx();
for (t = FirstTab; t; t = t->nextTab) {
move(t->y, t->x1);
@@ -477,8 +475,10 @@ redrawNLine(Buffer *buf, int n)
boldend();
clrtoeolx();
}
#if 0
move(0, COLS - 2);
addstr(" x");
#endif
move(LastTab->y + 1, 0);
for (i = 0; i < COLS; i++)
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
*
@@ -808,7 +808,6 @@ 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 NO_TABBUFFER ((TabBuffer *)1)
#define Currentbuf (CurrentTab->currentBuffer)
@@ -994,12 +993,23 @@ 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 {
typedef struct _MouseMenuMap {
void (*func) ();
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 */
global char *mouse_menu init(NULL);
#ifdef USE_COOKIE
global int default_use_cookie init(TRUE);
+24 -16
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
*/
@@ -331,12 +331,6 @@ initMouseMenu(void)
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;
@@ -346,17 +340,31 @@ initMouseMenu(void)
Strremovefirstspaces(line);
if (line->length == 0)
continue;
p = line->ptr;
p = conv_from_system(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 (!*s)
continue; /* error */
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 (strcmp(s, "button"))
if (!mouse_menu)
continue; /* "menu" is not set */
if (strcmp(s, "button"))
continue; /* error */
s = getWord(&p);
b = atoi(s);
@@ -364,11 +372,11 @@ initMouseMenu(void)
continue; /* error */
s = getWord(&p);
x = atoi(s);
if (!(IS_DIGIT(*s) && x >= 0 && x <= 9))
if (!(IS_DIGIT(*s) && x >= 0 && x < mouse_menu->width))
continue; /* error */
s = getWord(&p);
x2 = atoi(s);
if (!(IS_DIGIT(*s) && x2 >= 0 && x2 <= 9))
if (!(IS_DIGIT(*s) && x2 >= 0 && x2 < mouse_menu->width))
continue; /* error */
s = getWord(&p);
f = getFuncList(s);
@@ -378,8 +386,8 @@ initMouseMenu(void)
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;
mouse_menu->map[b - 1][x].func = w3mFuncList[f].func;
mouse_menu->map[b - 1][x].data = s;
}
}
fclose(mf);
+33 -27
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
#include "fm.h"
#include <signal.h>
@@ -1017,6 +1017,8 @@ main(int argc, char **argv, char **envp)
CurrentKeyData = NULL;
/* get keypress event */
#ifdef USE_MOUSE
if (mouse_menu)
mouse_menu->in_action = FALSE;
if (use_mouse)
mouse_active();
#endif /* USE_MOUSE */
@@ -4804,6 +4806,8 @@ posTab(int x, int y)
{
TabBuffer *tab;
if (mouse_menu && x < mouse_menu->width && y == 0)
return NO_TABBUFFER;
for (tab = FirstTab; tab; tab = tab->nextTab) {
if (tab->x1 <= x && x <= tab->x2 && tab->y == y)
return tab;
@@ -4812,8 +4816,10 @@ posTab(int x, int y)
}
static void
mouse_menu_action(int btn, int x)
mouse_menu_action(int btn, int x, int y)
{
if (!mouse_menu)
return;
switch (btn) {
case MOUSE_BTN1_DOWN:
btn = 0;
@@ -4827,11 +4833,14 @@ mouse_menu_action(int btn, int x)
default:
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;
CurrentKeyData = NULL;
CurrentCmdData = mouse_menu_map[btn][x].data;
(*mouse_menu_map[btn][x].func) ();
CurrentCmdData = mouse_menu->map[btn][x].data;
(*mouse_menu->map[btn][x].func) ();
CurrentCmdData = NULL;
}
}
@@ -4844,23 +4853,25 @@ process_mouse(int btn, int x, int y)
TabBuffer *t;
int ny = 0;
if (nTab2 > 1)
if (nTab > 1 || mouse_menu)
ny = LastTab->y + 1;
if (btn == MOUSE_BTN_UP) {
switch (press_btn) {
case MOUSE_BTN1_DOWN:
if (ny && y < ny) {
if (press_y == y && press_x == x) {
#if 0
if (y == 0 && x >= COLS - 2) {
deleteTab(CurrentTab);
displayBuffer(Currentbuf, B_FORCE_REDRAW);
return;
}
#endif
t = posTab(x, y);
if (t == NULL)
return;
if (t == NO_TABBUFFER) {
mouse_menu_action(press_btn, x);
mouse_menu_action(press_btn, x, y);
return;
}
CurrentTab = t;
@@ -4970,25 +4981,25 @@ process_mouse(int btn, int x, int y)
if (ny && y < ny) {
if (press_y == y && press_x == x) {
t = posTab(x, y);
if (t == NULL)
return;
if (t == NO_TABBUFFER) {
mouse_menu_action(press_btn, x);
mouse_menu_action(press_btn, x, y);
return;
}
if (t) {
deleteTab(t);
displayBuffer(Currentbuf, B_FORCE_REDRAW);
}
deleteTab(t);
displayBuffer(Currentbuf, B_FORCE_REDRAW);
}
return;
}
backBf();
break;
case MOUSE_BTN3_DOWN:
if (nTab2 > 1 && y < ny) {
if (ny && y < ny) {
if (press_y == y && press_x == x) {
t = posTab(x, y);
if (t == NO_TABBUFFER) {
mouse_menu_action(press_btn, x);
mouse_menu_action(press_btn, x, y);
return;
}
}
@@ -5635,19 +5646,6 @@ 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)
{
@@ -5668,9 +5666,17 @@ static void
calcTabPos(void)
{
TabBuffer *tab;
#if 0
int lcol = 0, rcol = 2, col;
#else
int lcol = 0, rcol = 0, col;
#endif
int n1, n2, na, nx, ny, ix, iy;
#ifdef USE_MOUSE
lcol = mouse_menu ? mouse_menu->width : 0;
#endif
if (nTab <= 0)
return;
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
*/
@@ -1252,6 +1252,8 @@ mainMn(void)
Menu *menu = &MainMenu;
char *data;
int n;
int x = Currentbuf->cursorX + Currentbuf->rootX,
y = Currentbuf->cursorY + Currentbuf->rootY;
data = searchKeyData();
if (data != NULL) {
@@ -1260,8 +1262,13 @@ mainMn(void)
return;
menu = w3mMenuList[n].menu;
}
popupMenu(Currentbuf->cursorX + Currentbuf->rootX,
Currentbuf->cursorY + Currentbuf->rootY, menu);
#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, menu);
}
/* --- MainMenu (END) --- */
@@ -1271,8 +1278,16 @@ mainMn(void)
void
selMn(void)
{
popupMenu(Currentbuf->cursorX + Currentbuf->rootX,
Currentbuf->cursorY + Currentbuf->rootY, &SelectMenu);
int x = Currentbuf->cursorX + Currentbuf->rootX,
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
@@ -1408,8 +1423,16 @@ smDelBuf(char c)
void
tabMn(void)
{
popupMenu(Currentbuf->cursorX + Currentbuf->rootX,
Currentbuf->cursorY + Currentbuf->rootY, &SelTabMenu);
int x = Currentbuf->cursorX + Currentbuf->rootX,
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
+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.
* 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 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,