From 82901953d32cc52a688be47d0594e2df0395b2cc Mon Sep 17 00:00:00 2001 From: Fumitoshi UKAI Date: Fri, 22 Nov 2002 15:43:13 +0000 Subject: [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 --- main.c | 60 +++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 27 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 53c5303..6b6c9ab 100644 --- a/main.c +++ b/main.c @@ -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 @@ -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; -- cgit v1.2.3