diff options
-rw-r--r-- | mbbsd/pmore.c | 127 |
1 files changed, 77 insertions, 50 deletions
diff --git a/mbbsd/pmore.c b/mbbsd/pmore.c index 80c1b382..849b556e 100644 --- a/mbbsd/pmore.c +++ b/mbbsd/pmore.c @@ -49,7 +49,8 @@ #define MAP_NOSYNC MAP_SHARED #endif -//#define DEBUG +#define DEBUG +int debug = 0; // -------------------------- <FEATURES> #define PMORE_USE_PTT_PRINTS @@ -397,6 +398,13 @@ void mf_disp() { int lines = 0, col = 0, currline = 0; int startline = 0, endline = MFDISP_PAGE-1; + // int x_min = 0; + int x_max = t_columns - 2; + int x_max_dbcs = (x_max+1) >> 1 << 1; + /* + * it seems like that BBS scroll has some bug + * if we scroll a fulfilled buffer, so leave one space. + */ #ifdef PMORE_USE_SCROLL /* process scrolling */ @@ -419,16 +427,6 @@ void mf_disp() if(scrll > MFDISP_PAGE) scrll = MFDISP_PAGE; - if(reverse) - { - // clear the line which will be scrolled - // to bottom (status line position). - move(b_lines - scrll, 0); - clrtoeol(); - // move(b_lines, 0); - // clrtoeol(); - } - i = scrll; while(i-- > 0) if (reverse) @@ -440,6 +438,10 @@ void mf_disp() { startline = 0; // v endline = scrll-1; + // clear the line which will be scrolled + // to bottom (status line position). + move(b_lines, 0); + clrtoeol(); } else { @@ -457,6 +459,7 @@ void mf_disp() while (lines < MFDISP_PAGE) { int inAnsi = 0; + int skip = 0; currline = mf.lineno + lines; col = 0; @@ -466,7 +469,7 @@ void mf_disp() { while(mf.dispe < mf.end && *mf.dispe != '\n') mf.dispe++; - col = t_columns; /* prevent printing trailing '\n' */ + skip = 1; /* prevent printing trailing '\n' */ } /* Now, consider what kind of line * (header, seperator, or normal text) @@ -476,7 +479,7 @@ void mf_disp() { /* case 1, header seperator line */ outs("\033[36m"); - for(col = 0; col < t_columns -2; col+=2) + for(col = 0; col < x_max_dbcs; col+=2) { outs("�w"); } @@ -487,7 +490,7 @@ void mf_disp() else if (currline < ah.lines) { /* case 2, we're printing headers */ - int w = t_columns - 2, i_author = 0; + int w = x_max_dbcs, i_author = 0; int flDrawBoard = 0, flDrawAuthor = 0; const char *ph = disp_heads[currline]; @@ -495,9 +498,9 @@ void mf_disp() flDrawAuthor = 1; draw_header: if(flDrawAuthor) - w = t_columns - 2 - ah.boardlen - 6; + w = x_max_dbcs - ah.boardlen - 6; else - w = t_columns - 2; + w = x_max_dbcs; outs("\033[47;34m "); col++; @@ -509,7 +512,7 @@ draw_header: } else { /* display as-is */ while (*mf.dispe != ':' && *mf.dispe != '\n') - if(col++ < t_columns) + if(col++ <= x_max_dbcs) outc(*mf.dispe++); } @@ -587,7 +590,7 @@ draw_header: { if (!strchr(STR_ANSICODE, *mf.dispe)) inAnsi = 0; - if(col < t_columns) + if(col <= x_max) outc(*mf.dispe); } else { if(*mf.dispe == ANSI_ESC) @@ -618,8 +621,8 @@ draw_header: Ptt_prints(buf, NO_RELOAD); // result in buf i = strlen(buf); - if (col + i >= t_columns) - i = t_columns - col; + if (col + i > x_max) + i = x_max - col; if(i > 0) { buf[i] = 0; @@ -630,7 +633,7 @@ draw_header: } else #endif { - if(col < t_columns) + if(col <= x_max) outc(*mf.dispe); if(!inAnsi) { @@ -650,10 +653,15 @@ draw_header: if(mf.dispe < mf.end) mf.dispe ++; - if(col < t_columns-1) /* can we do so? */ - outc('\n'); - else - move(lines+1, 0); + + if(!skip) + { + if(col < x_max) /* can we do so? */ + outc('\n'); + else + // outc('>'), + move(lines+1, 0); + } lines ++; } mf.oldlineno = mf.lineno; @@ -664,23 +672,26 @@ draw_header: static const char * const pmore_help[] = { "\0�\\Ū�峹�\\����ϥλ���", "\01��в��ʥ\\����", - "(��) �W���@��", - "(��)(Enter) �U���@��", + "(j)(��) �W���@��", + "(k)(��)(Enter) �U���@��", "(^B)(PgUp)(BackSpace) �W���@��", "(��)(PgDn)(Space) �U���@��", "(0)(g)(Home) �ɮ}�Y", "($)(G) (End) �ɮ���", + "(;/:) ���ܬY��/�Y��", + "�Ʀr�� 1-9 ���ܿ�J���渹", "\01��L�\\����", "(/) �j�M�r��", "(n/N) ���ƥ�/�ϦV�j�M", -// "(TAB) URL�s��", "(Ctrl-T) �s��Ȧs��", - "(;/:/f/b) ���ܬY��/�Y��/�U/�W�g", + "(f/b) ���ܤU/�W�g", "(a/A) ���ܦP�@�@�̤U/�W�g", - "([-/]+) �D�D���\\Ū �W/�U", - "(t) �D�D���`�Ǿ\\Ū", + "(t/[-/]+) �D�D���\\Ū �`��/�W/�U�g", "(q)(��) ����", "(h)(H)(?) ���U�����e��", +#ifdef DEBUG + "(d) ��������(debug)�Ҧ�", +#endif "\01���t�Ψϥ� piaip ���s���s���{��", NULL }; @@ -711,7 +722,8 @@ int pmore(char *fpath, int promptend) move(b_lines, 0); // clrtoeol(); // this shall be done in mf_disp to speed up. -#ifdef DEBUG + /* PRINT BOTTOM STATUS BAR */ + if(debug) prints("L#%d prmpt=%d Disp:%08X/%08X/%08X, File:%08X/%08X(%d)", (int)mf.lineno, promptend, @@ -720,8 +732,7 @@ int pmore(char *fpath, int promptend) (unsigned int)mf.dispe, (unsigned int)mf.start, (unsigned int)mf.end, (int)mf.len); -#else - if(mf.len) + else { char *printcolor; char buf[256]; // orz @@ -745,21 +756,20 @@ int pmore(char *fpath, int promptend) outs(buf); i = strlen(buf); i -= 8; // ANSI codes in buf - i += 22; // trailing msg columns - i = t_columns - i - 2; + i += 23; // trailing msg columns + i = t_columns - i - 1; while(i-- > 0) outc(' '); if(i == -1) /* enough buffer */ outs( "\033[31;47m(h)\033[30m���仡�� " - "\033[31m��[q]\033[30m���} "); + "\033[31m��[q]\033[30m���} "); outs("\033[m"); } -#endif ch = igetch(); switch (ch) { /* ------------------ EXITING KEYS ------------------ */ - case 'r': // Ptt: put all reply/recommend function here + case 'r': case 'R': case 'Y': case 'y': @@ -799,14 +809,17 @@ int pmore(char *fpath, int promptend) case '=': flExit = 1, retval = RELATE_FIRST; break; - case 't': - if (mf_viewedAll()) - flExit = 1, retval = RELATE_NEXT; - else - mf_forward(MFNAV_PAGE); - break; /* ------------------ NAVIGATION KEYS ------------------ */ /* Simple Navigation */ + case 'j': + case 'J': + mf_backward(1); + break; + case 'k': + case 'K': + mf_forward(1); + break; + case Ctrl('F'): case KEY_PGDN: mf_forward(MFNAV_PAGE); @@ -864,6 +877,12 @@ int pmore(char *fpath, int promptend) mf_backward(MFNAV_PAGE); break; + case 't': + if (mf_viewedAll()) + flExit = 1, retval = RELATE_NEXT; + else + mf_forward(MFNAV_PAGE); + break; /* ------------------ SEARCH KEYS ------------------ */ case '/': { @@ -893,15 +912,18 @@ int pmore(char *fpath, int promptend) mf_search(MFSEARCH_BACKWARD); break; /* ------------------ SPECIAL KEYS ------------------ */ - case ';': - case ':': + case '1': case '2': case '3': case '4': case '5': + case '6': case '7': case '8': case '9': + case ';': case ':': { - char buf[10]; + char buf[10] = ""; int i = 0; int pageMode = (ch == ':'); + if (ch >= '1' && ch <= '9') + buf[0] = ch, buf[1] = 0; - getdata(b_lines-1, 0, - (pageMode ? "Goto Page: " : "Goto Line: "), + getdata_buf(b_lines-1, 0, + (pageMode ? "���ܦ���: " : "���ܦ���: "), buf, 5, DOECHO); if(buf[0]) { i = atoi(buf); @@ -941,6 +963,11 @@ int pmore(char *fpath, int promptend) return 0; } break; +#ifdef DEBUG + case 'd': + debug = !debug; + break; +#endif } } |