diff options
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | buffer.c | 1 | ||||
-rw-r--r-- | display.c | 64 | ||||
-rw-r--r-- | etc.c | 4 | ||||
-rw-r--r-- | file.c | 25 | ||||
-rw-r--r-- | fm.h | 4 | ||||
-rw-r--r-- | main.c | 33 | ||||
-rw-r--r-- | menu.c | 6 |
8 files changed, 90 insertions, 63 deletions
@@ -1,3 +1,19 @@ +2001-11-21 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp> + + * buffer.c (newBuffer): set COLS + * display.c (displayBuffer redrawLine redrawLineRegion + cursorRight arrangeCursor cursorXY): + new showLineNumber implementation + * main.c (ctrCsrH shiftvisualpos shiftl shiftr _movL _movR + _followForm follow_map process_mouse): + use buf->COLS, buf->rootX + * menu.c (popupMenu mainMn initSelectMenu): + use buf->rootX + * etc.c (columnSkip): use buf->COLS + * file.c (HTMLlineproc2body loadBuffer saveBufferDelNum getNextPage) + remove old showLineNumber codes + * fm.h (Buffer): add rootX, COLS + 2001-11-21 Fumitoshi UKAI <ukai@debian.or.jp> * XMakefile (clean): rm tagtable.c @@ -31,6 +31,7 @@ newBuffer(int width) return NULL; bzero((void *) n, sizeof(Buffer)); n->width = width; + n->COLS = COLS; n->currentURL.scheme = SCM_UNKNOWN; n->baseURL = NULL; n->baseTarget = NULL; @@ -1,4 +1,4 @@ -/* $Id: display.c,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */ +/* $Id: display.c,v 1.4 2001/11/20 16:46:32 ukai Exp $ */ #include <signal.h> #include "fm.h" @@ -209,6 +209,17 @@ displayBuffer(Buffer * buf, int mode) reshapeBuffer(buf); in_check_url = FALSE; } + if (showLineNum) { + if (buf->lastLine && buf->lastLine->real_linenumber > 0) + buf->rootX = (int)(log(buf->lastLine->real_linenumber + 0.1) + / log(10)) + 2; + if (buf->rootX < 5) + buf->rootX = 5; + if (buf->rootX > COLS) + buf->rootX = COLS; + } else + buf->rootX = 0; + buf->COLS = COLS - buf->rootX; if (mode == B_FORCE_REDRAW || mode == B_SCROLL || cline != buf->topLine || @@ -299,7 +310,7 @@ displayBuffer(Buffer * buf, int mode) clear(); } standout(); - message(msg->ptr, buf->cursorX, buf->cursorY); + message(msg->ptr, buf->cursorX + buf->rootX, buf->cursorY); standend(); refresh(); #ifdef BUFINFO @@ -372,6 +383,25 @@ redrawLine(Buffer * buf, Line * l, int i) return NULL; } move(i, 0); + if (showLineNum) { + char tmp[16]; + if (! buf->rootX) { + if (buf->lastLine->real_linenumber > 0) + buf->rootX = (int)(log(buf->lastLine->real_linenumber + 0.1) + / log(10)) + 2; + if (buf->rootX < 5) + buf->rootX = 5; + if (buf->rootX > COLS) + buf->rootX = COLS; + buf->COLS = COLS - buf->rootX; + } + if (l->real_linenumber) + sprintf(tmp, "%*d:", buf->rootX - 1, l->real_linenumber); + else + sprintf(tmp, "%*s ", buf->rootX - 1, ""); + addstr(tmp); + } + move(i, buf->rootX); if (l->width < 0) l->width = COLPOS(l, l->len); if (l->len == 0 || l->width - 1 < column) { @@ -393,7 +423,7 @@ redrawLine(Buffer * buf, Line * l, int i) #ifndef JP_CHARSET delta = 1; #endif - for (j = 0; rcol - column < COLS && pos + j < l->len; j += delta) { + for (j = 0; rcol - column < buf->COLS && pos + j < l->len; j += delta) { #ifdef COLOR if (useVisitedColor && vpos <= pos + j && !(pr[j] & PE_VISITED)) { a = retrieveAnchor(buf->href, l->linenumber, pos + j); @@ -414,7 +444,7 @@ redrawLine(Buffer * buf, Line * l, int i) delta = 1; #endif ncol = COLPOS(l, pos + j + delta); - if (ncol - column > COLS) + if (ncol - column > buf->COLS) break; #ifdef ANSI_COLOR if (pc) @@ -486,7 +516,7 @@ redrawLine(Buffer * buf, Line * l, int i) if (color_mode) do_color(0); #endif - if (rcol - column < COLS) + if (rcol - column < buf->COLS) clrtoeolx(); return l->next; } @@ -526,7 +556,7 @@ redrawLineRegion(Buffer * buf, Line * l, int i, int bpos, int epos) #ifndef JP_CHARSET delta = 1; #endif - for (j = 0; rcol - column < COLS && pos + j < l->len; j += delta) { + for (j = 0; rcol - column < buf->COLS && pos + j < l->len; j += delta) { #ifdef COLOR if (useVisitedColor && vpos <= pos + j && !(pr[j] & PE_VISITED)) { a = retrieveAnchor(buf->href, l->linenumber, pos + j); @@ -547,7 +577,7 @@ redrawLineRegion(Buffer * buf, Line * l, int i, int bpos, int epos) delta = 1; #endif ncol = COLPOS(l, pos + j + delta); - if (ncol - column > COLS) + if (ncol - column > buf->COLS) break; #ifdef ANSI_COLOR if (pc) @@ -555,12 +585,12 @@ redrawLineRegion(Buffer * buf, Line * l, int i, int bpos, int epos) #endif if (j >= bcol && j < ecol) { if (rcol < column) { - move(i, 0); + move(i, buf->rootX); for (rcol = column; rcol < ncol; rcol++) addChar(' ', 0); continue; } - move(i, rcol - column); + move(i, rcol - column + buf->rootX); if (p[j] == '\t') { for (; rcol < ncol; rcol++) addChar(' ', 0); @@ -787,7 +817,7 @@ disp_message_nsec(char *s, int redraw_current, int sec, int purge, int mouse) return; } if (Currentbuf != NULL) - message(s, Currentbuf->cursorX, Currentbuf->cursorY); + message(s, Currentbuf->cursorX + Currentbuf->rootX, Currentbuf->cursorY); else message(s, LASTLINE, 0); refresh(); @@ -897,8 +927,8 @@ cursorRight(Buffer * buf, int n) delta = 2; #endif /* JP_CHARSET */ vpos2 = COLPOS(l, buf->pos + delta) - buf->currentColumn - 1; - if (vpos2 >= COLS && n) { - columnSkip(buf, n + (vpos2 - COLS) - (vpos2 - COLS) % n); + if (vpos2 >= buf->COLS && n) { + columnSkip(buf, n + (vpos2 - buf->COLS) - (vpos2 - buf->COLS) % n); buf->visualpos = cpos - buf->currentColumn; } buf->cursorX = buf->visualpos; @@ -971,9 +1001,9 @@ arrangeCursor(Buffer * buf) delta = 2; #endif /* JP_CHARSET */ col2 = COLPOS(buf->currentLine, buf->pos + delta); - if (col < buf->currentColumn || col2 > COLS + buf->currentColumn) { + if (col < buf->currentColumn || col2 > buf->COLS + buf->currentColumn) { buf->currentColumn = 0; - if (col2 > COLS) + if (col2 > buf->COLS) columnSkip(buf, col); } /* Arrange cursor */ @@ -1032,19 +1062,19 @@ cursorXY(Buffer * buf, int x, int y) if (buf->cursorX > x) { while (buf->cursorX > x) - cursorLeft(buf, COLS / 2); + cursorLeft(buf, buf->COLS / 2); } else if (buf->cursorX < x) { while (buf->cursorX < x) { oldX = buf->cursorX; - cursorRight(buf, COLS / 2); + cursorRight(buf, buf->COLS / 2); if (oldX == buf->cursorX) break; } if (buf->cursorX > x) - cursorLeft(buf, COLS / 2); + cursorLeft(buf, buf->COLS / 2); } } @@ -1,4 +1,4 @@ -/* $Id: etc.c,v 1.4 2001/11/16 22:02:00 ukai Exp $ */ +/* $Id: etc.c,v 1.5 2001/11/20 16:46:32 ukai Exp $ */ #include "fm.h" #include <pwd.h> #include "myctype.h" @@ -102,7 +102,7 @@ columnSkip(Buffer * buf, int offset) if (l->width - 1 > maxColumn) maxColumn = l->width - 1; } - maxColumn -= COLS - 1; + maxColumn -= buf->COLS - 1; if (column < maxColumn) maxColumn = column; if (maxColumn < 0) @@ -1,4 +1,4 @@ -/* $Id: file.c,v 1.8 2001/11/20 08:20:56 ukai Exp $ */ +/* $Id: file.c,v 1.9 2001/11/20 16:46:32 ukai Exp $ */ #include "fm.h" #include <sys/types.h> #include "myctype.h" @@ -3722,12 +3722,6 @@ HTMLlineproc2body(Buffer * buf, Str (*feed) (), int llimit) if (++nlines == llimit) break; pos = 0; - if (showLineNum) { - tmp = Sprintf("%4d:", nlines); - for (p = tmp->ptr; *p; p++) { - PPUSH(PC_ASCII, *p); - } - } #ifdef ENABLE_REMOVE_TRAILINGSPACES Strremovetrailingspaces(line); #endif @@ -5154,11 +5148,6 @@ loadBuffer(URLFile * uf, Buffer * newBuf) pre_lbuf = lineBuf2->ptr[0]; } ++nlines; - if (showLineNum) { - Str tmp = Sprintf("%4d:", nlines); - Strcat(tmp, lineBuf2); - lineBuf2 = tmp; - } #ifdef USE_NNTP if (uf->scheme == SCM_NEWS) { if (Str_news_endline(lineBuf2)) { @@ -5254,8 +5243,6 @@ saveBufferDelNum(Buffer * buf, FILE * f, int del) else #endif tmp = Strnew_charp_n(l->lineBuf, l->len); - if (del && l->real_linenumber && (p = strchr(tmp->ptr, ':')) != NULL) - Strdelete(tmp, 0, p - tmp->ptr + 1); #ifdef JP_CHARSET tmp = conv_str(tmp, InnerCode, DisplayCode); #endif @@ -5434,11 +5421,6 @@ getNextPage(Buffer * buf, int plen) if (pl != NULL) { nlines = pl->real_linenumber; pre_lbuf = *(pl->lineBuf); - if (showLineNum) { - char *p; - if ((p = strchr(pl->lineBuf, ':')) != NULL) - pre_lbuf = *(p + 1); - } if (pre_lbuf == '\0') pre_lbuf = '\n'; } @@ -5475,11 +5457,6 @@ getNextPage(Buffer * buf, int plen) pre_lbuf = lineBuf2->ptr[0]; } ++nlines; - if (showLineNum) { - Str tmp = Sprintf("%4d:", nlines); - Strcat(tmp, lineBuf2); - lineBuf2 = tmp; - } Strchop(lineBuf2); lineBuf2 = checkType(lineBuf2, propBuffer, #ifdef ANSI_COLOR @@ -1,4 +1,4 @@ -/* $Id: fm.h,v 1.6 2001/11/20 08:20:56 ukai Exp $ */ +/* $Id: fm.h,v 1.7 2001/11/20 16:46:33 ukai Exp $ */ /* * w3m: WWW wo Miru utility * @@ -333,6 +333,8 @@ typedef struct _Buffer { short cursorY; short pos; short visualpos; + short rootX; + short COLS; InputStream pagerSource; AnchorList *href; AnchorList *name; @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.10 2001/11/20 08:20:56 ukai Exp $ */ +/* $Id: main.c,v 1.11 2001/11/20 16:46:33 ukai Exp $ */ #define MAINPROGRAM #include "fm.h" #include <signal.h> @@ -1204,7 +1204,7 @@ ctrCsrH(void) int offsetx; if (Currentbuf->firstLine == NULL) return; - offsetx = Currentbuf->cursorX - COLS / 2; + offsetx = Currentbuf->cursorX - Currentbuf->COLS / 2; if (offsetx != 0) { columnSkip(Currentbuf, offsetx); arrangeCursor(Currentbuf); @@ -1341,8 +1341,8 @@ static void shiftvisualpos(Buffer * buf, int shift) { buf->visualpos -= shift; - if (buf->visualpos >= COLS) - buf->visualpos = COLS - 1; + if (buf->visualpos >= buf->COLS) + buf->visualpos = buf->COLS - 1; else if (buf->visualpos < 0) buf->visualpos = 0; arrangeLine(buf); @@ -1359,7 +1359,7 @@ shiftl(void) if (Currentbuf->firstLine == NULL) return; column = Currentbuf->currentColumn; - columnSkip(Currentbuf, searchKeyNum() * (-COLS + 1) + 1); + columnSkip(Currentbuf, searchKeyNum() * (- Currentbuf->COLS + 1) + 1); shiftvisualpos(Currentbuf, Currentbuf->currentColumn - column); displayBuffer(Currentbuf, B_NORMAL); } @@ -1373,7 +1373,7 @@ shiftr(void) if (Currentbuf->firstLine == NULL) return; column = Currentbuf->currentColumn; - columnSkip(Currentbuf, searchKeyNum() * (COLS - 1) - 1); + columnSkip(Currentbuf, searchKeyNum() * (Currentbuf->COLS - 1) - 1); shiftvisualpos(Currentbuf, Currentbuf->currentColumn - column); displayBuffer(Currentbuf, B_NORMAL); } @@ -1632,7 +1632,7 @@ _movL(int n) void movL(void) { - _movL(COLS / 2); + _movL(Currentbuf->COLS / 2); } void @@ -1704,7 +1704,7 @@ _movR(int n) void movR(void) { - _movR(COLS / 2); + _movR(Currentbuf->COLS / 2); } void @@ -2821,7 +2821,7 @@ _followForm(int submit) if (submit) goto do_submit; if (! formChooseOptionByMenu(fi, - Currentbuf->cursorX - Currentbuf->pos + a->start.pos, + Currentbuf->cursorX - Currentbuf->pos + a->start.pos + Currentbuf->rootX, Currentbuf->cursorY)) break; formUpdateBuffer(a, Currentbuf, fi); @@ -3581,9 +3581,9 @@ follow_map(struct parsed_tagarg *arg) a = retrieveCurrentImg(Currentbuf); if (a != NULL) - x = Currentbuf->cursorX - Currentbuf->pos + a->start.pos; + x = Currentbuf->cursorX - Currentbuf->pos + a->start.pos + Currentbuf->rootX; else - x = Currentbuf->cursorX; + x = Currentbuf->cursorX + Currentbuf->rootX; url = follow_map_menu(Currentbuf, arg, x, Currentbuf->cursorY + 2); if (url == NULL || *url == '\0') return; @@ -4273,18 +4273,18 @@ process_mouse(int btn, int x, int y) return; } if (y == Currentbuf->cursorY && - (x == Currentbuf->cursorX + (x == Currentbuf->cursorX + Currentbuf->rootX #ifdef JP_CHARSET || (Currentbuf->currentLine != NULL && (Currentbuf->currentLine->propBuf[Currentbuf->pos] & PC_KANJI1) - && x == Currentbuf->cursorX + 1) + && x == Currentbuf->cursorX + Currentbuf->rootX + 1) #endif /* JP_CHARSET */ )) { followA(); return; } - - cursorXY(Currentbuf, x, y); + if (x >= Currentbuf->rootX) + cursorXY(Currentbuf, x - Currentbuf->rootX, y); displayBuffer(Currentbuf, B_NORMAL); } @@ -4294,7 +4294,8 @@ process_mouse(int btn, int x, int y) break; case MOUSE_BTN3_DOWN: #ifdef MENU - cursorXY(Currentbuf, x, y); + if (x >= Currentbuf->rootX) + cursorXY(Currentbuf, x - Currentbuf->rootX, y); onA(); mainMenu(x, y); #endif /* MENU */ @@ -1219,7 +1219,7 @@ popupMenu(int x, int y, Menu *menu) { initSelectMenu(); - menu->cursorX = Currentbuf->cursorX; + menu->cursorX = Currentbuf->cursorX + Currentbuf->rootX; menu->cursorY = Currentbuf->cursorY; menu->x = x + FRAME_WIDTH + 1; menu->y = y + 2; @@ -1247,7 +1247,7 @@ mainMn(void) return; menu = w3mMenuList[n].menu; } - popupMenu(Currentbuf->cursorX, Currentbuf->cursorY, menu); + popupMenu(Currentbuf->cursorX + Currentbuf->rootX, Currentbuf->cursorY, menu); } /* --- MainMenu (END) --- */ @@ -1318,7 +1318,7 @@ initSelectMenu(void) new_option_menu(&SelectMenu, label, &SelectV, smChBuf); SelectMenu.initial = SelectV; - SelectMenu.cursorX = Currentbuf->cursorX; + SelectMenu.cursorX = Currentbuf->cursorX + Currentbuf->rootX; SelectMenu.cursorY = Currentbuf->cursorY; SelectMenu.keymap['D'] = smDelBuf; SelectMenu.item[nitem].type = MENU_NOP; |