diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-11-21 17:05:00 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-11-21 17:05:00 +0000 |
commit | edf793a00b0ac0ab492a9ff799185cf41bca382b (patch) | |
tree | 51b63d08279025b072a30148dce01904ed65fe2f | |
parent | * doc/README.mouse_menu: added (diff) | |
download | w3m-edf793a00b0ac0ab492a9ff799185cf41bca382b.tar.gz w3m-edf793a00b0ac0ab492a9ff799185cf41bca382b.zip |
[w3m-dev 03456] tiling of tab
* display.c (displayBuffer): use LastTab->y
(redrawNLine): fix column calculation
* fm.h (TabBuffer): add x1, x2, y
* main.c (calcTabPos): added
(main): calcTabPos()
(mouse_scroll_line): rewrite
(process_mouse): use LastTab->y
(_newT): calcTabPos()
(calcTabPos): added
(deleteTab): calcTabPos()
(moveTab): calcTabPos()
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
Diffstat (limited to '')
-rw-r--r-- | ChangeLog | 17 | ||||
-rw-r--r-- | display.c | 23 | ||||
-rw-r--r-- | fm.h | 5 | ||||
-rw-r--r-- | main.c | 83 |
4 files changed, 96 insertions, 32 deletions
@@ -1,3 +1,18 @@ +2002-11-22 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + + * [w3m-dev 03456] tiling of tab + * display.c (displayBuffer): use LastTab->y + (redrawNLine): fix column calculation + * fm.h (TabBuffer): add x1, x2, y + * main.c (calcTabPos): added + (main): calcTabPos() + (mouse_scroll_line): rewrite + (process_mouse): use LastTab->y + (_newT): calcTabPos() + (calcTabPos): added + (deleteTab): calcTabPos() + (moveTab): calcTabPos() + 2002-11-22 Fumitoshi UKAI <ukai@debian.or.jp> * doc/README.mouse_menu: added @@ -4978,4 +4993,4 @@ a * [w3m-dev 03276] compile error on EWS4800 * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.542 2002/11/21 16:47:13 ukai Exp $ +$Id: ChangeLog,v 1.543 2002/11/21 17:05:00 ukai Exp $ @@ -1,4 +1,4 @@ -/* $Id: display.c,v 1.36 2002/11/21 16:32:29 ukai Exp $ */ +/* $Id: display.c,v 1.37 2002/11/21 17:05:01 ukai Exp $ */ #include <signal.h> #include "fm.h" @@ -255,7 +255,7 @@ displayBuffer(Buffer *buf, int mode) buf->rootX = 0; buf->COLS = COLS - buf->rootX; if (nTab2 > 1) { - ny = (nTab2 - 1) / nTabLine() + 2; + ny = LastTab->y + 2; if (ny > LASTLINE) ny = LASTLINE; } @@ -447,7 +447,7 @@ redrawNLine(Buffer *buf, int n) #endif /* USE_COLOR */ if (nTab2 > 1) { TabBuffer *t; - int nx = nTabLine(), col = COLS - 2, x, l; + int l; i = 0; move(0, 0); @@ -456,31 +456,30 @@ redrawNLine(Buffer *buf, int n) clrtoeolx(); i++; } - for (t = FirstTab; t; t = t->nextTab, i++) { - x = col * (i % nx) / nx; - move(i / nx, x); + clrtoeolx(); + for (t = FirstTab; t; t = t->nextTab) { + move(t->y, t->x1); if (t == CurrentTab) bold(); addch('['); l = strlen(t->currentBuffer->buffername); - if (col / nx - 2 > l) - addnstr_sup(" ", (col / nx - 2 - l) / 2); + if (t->x2 - t->x1 - 2 > l) + addnstr_sup(" ", (t->x2 - t->x1 - 1 - l) / 2); if (t == CurrentTab) EFFECT_ACTIVE_START; addstr(t->currentBuffer->buffername); if (t == CurrentTab) EFFECT_ACTIVE_END; clrtoeolx(); - x = col * (i % nx + 1) / nx - 1; - move(i / nx, x); + move(t->y, t->x2); addch(']'); if (t == CurrentTab) boldend(); clrtoeolx(); } - move(0, col); + move(0, COLS - 2); addstr(" x"); - move((nTab2 - 1) / nx + 1, 0); + move(LastTab->y + 1, 0); for (i = 0; i < COLS; i++) addch('~'); } @@ -1,4 +1,4 @@ -/* $Id: fm.h,v 1.85 2002/11/21 16:31:36 ukai Exp $ */ +/* $Id: fm.h,v 1.86 2002/11/21 17:05:01 ukai Exp $ */ /* * w3m: WWW wo Miru utility * @@ -452,6 +452,9 @@ typedef struct _TabBuffer { struct _TabBuffer *prevTab; Buffer *currentBuffer; Buffer *firstBuffer; + short x1; + short x2; + short y; } TabBuffer; typedef struct _DownloadList { @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.147 2002/11/21 16:31:36 ukai Exp $ */ +/* $Id: main.c,v 1.148 2002/11/21 17:05:01 ukai Exp $ */ #define MAINPROGRAM #include "fm.h" #include <signal.h> @@ -101,6 +101,7 @@ void set_buffer_environ(Buffer *); static void _followForm(int); static void _goLine(char *); static void _newT(void); +static void calcTabPos(void); static void followTab(TabBuffer * tab); static void moveTab(TabBuffer * t, TabBuffer * t2, int right); static int check_target = TRUE; @@ -895,6 +896,7 @@ main(int argc, char **argv, char **envp) if (CurrentTab == NULL) { FirstTab = LastTab = CurrentTab = newTab(); nTab = 1; + calcTabPos(); Firstbuf = Currentbuf = newbuf; } else { @@ -935,6 +937,7 @@ main(int argc, char **argv, char **envp) if (!FirstTab) { FirstTab = LastTab = CurrentTab = newTab(); nTab = 1; + calcTabPos(); } if (!Firstbuf || Firstbuf == NO_BUFFER) { Firstbuf = Currentbuf = newBuffer(INIT_BUFFER_WIDTH); @@ -4785,21 +4788,13 @@ mouse_scroll_line(void) static TabBuffer * posTab(int x, int y) { - TabBuffer *t; - int i, n, col = COLS - 2; - - if (col <= 0) - return NULL; - n = nTabLine(); - n = x * n / col + y * n; - i = 0; - if (mouse_menu) { - if (n == 0) - return NO_TABBUFFER; - i++; + TabBuffer *tab; + + for (tab = FirstTab; tab; tab = tab->nextTab) { + if (tab->x1 <= x && x <= tab->x2 && tab->y == y) + return tab; } - for (t = FirstTab; t && i < n; t = t->nextTab, i++) ; - return t; + return NULL; } static void @@ -4836,11 +4831,11 @@ process_mouse(int btn, int x, int y) int ny = 0; if (nTab2 > 1) - ny = (nTab2 - 1) / nTabLine() + 1; + ny = LastTab->y + 1; if (btn == MOUSE_BTN_UP) { switch (press_btn) { case MOUSE_BTN1_DOWN: - if (nTab2 > 1 && y < ny) { + if (ny && y < ny) { if (press_y == y && press_x == x) { if (y == 0 && x >= COLS - 2) { deleteTab(CurrentTab); @@ -4958,7 +4953,7 @@ process_mouse(int btn, int x, int y) } break; case MOUSE_BTN2_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) { @@ -5616,6 +5611,7 @@ _newT(void) CurrentTab->nextTab = tag; CurrentTab = tag; nTab++; + calcTabPos(); } void @@ -5654,6 +5650,55 @@ numTab(int n) return tab; } +static void +calcTabPos(void) +{ + TabBuffer *tab; + int lcol = 0, rcol = 2, col; + int n1, n2, na, nx, ny, ix, iy; + + if (nTab <= 0) + return; + n1 = (COLS - rcol - lcol) / TabCols; + if (n1 >= nTab) { + n2 = 1; + ny = 1; + } + else { + if (n1 < 0) + n1 = 0; + n2 = COLS / TabCols; + if (n2 == 0) + n2 = 1; + ny = (nTab - n1 - 1) / n2 + 2; + } + na = n1 + n2 * (ny - 1); + n1 -= (na - nTab) / ny; + if (n1 < 0) + n1 = 0; + na = n1 + n2 * (ny - 1); + tab = FirstTab; + for (iy = 0; iy < ny && tab; iy++) { + if (iy == 0) { + nx = n1; + col = COLS - rcol - lcol; + } + else { + nx = n2 - (na - nTab + (iy - 1)) / (ny - 1); + col = COLS; + } + for (ix = 0; ix < nx && tab; ix++, tab = tab->nextTab) { + tab->x1 = col * ix / nx; + tab->x2 = col * (ix + 1) / nx - 1; + tab->y = iy; + if (iy == 0) { + tab->x1 += lcol; + tab->x2 += lcol; + } + } + } +} + TabBuffer * deleteTab(TabBuffer * tab) { @@ -5677,6 +5722,7 @@ deleteTab(TabBuffer * tab) CurrentTab = tab->nextTab; } nTab--; + calcTabPos(); buf = tab->firstBuffer; while (buf && buf != NO_BUFFER) { next = buf->nextBuffer; @@ -5875,6 +5921,7 @@ moveTab(TabBuffer * t, TabBuffer * t2, int right) FirstTab = t; t2->prevTab = t; } + calcTabPos(); displayBuffer(Currentbuf, B_FORCE_REDRAW); } |