diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-06-04 20:53:18 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-06-04 20:53:18 +0800 |
commit | 1b0dbadf7d9151cc57fe7ffc10fcf749a375ed6c (patch) | |
tree | 743f8b3a30142c7ad4261ae85ffab635bf273c58 | |
parent | cac7c3c652830457b696298d9edd7e5c56111f24 (diff) | |
download | pttbbs-1b0dbadf7d9151cc57fe7ffc10fcf749a375ed6c.tar pttbbs-1b0dbadf7d9151cc57fe7ffc10fcf749a375ed6c.tar.gz pttbbs-1b0dbadf7d9151cc57fe7ffc10fcf749a375ed6c.tar.bz2 pttbbs-1b0dbadf7d9151cc57fe7ffc10fcf749a375ed6c.tar.lz pttbbs-1b0dbadf7d9151cc57fe7ffc10fcf749a375ed6c.tar.xz pttbbs-1b0dbadf7d9151cc57fe7ffc10fcf749a375ed6c.tar.zst pttbbs-1b0dbadf7d9151cc57fe7ffc10fcf749a375ed6c.zip |
pmore: more update on traditional mode
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2759 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/pmore.c | 202 |
1 files changed, 110 insertions, 92 deletions
diff --git a/mbbsd/pmore.c b/mbbsd/pmore.c index c856fbd4..59075b1a 100644 --- a/mbbsd/pmore.c +++ b/mbbsd/pmore.c @@ -32,8 +32,8 @@ * > old style: increase one line to show seperator * > pmore style: use blank line for seperator. * - However I've changed my mind. Now this can be simulated - * with wrapping. See Features section to enable - * PMORE_TRADITIONAL_SEPERATOR if you REALLY eager for this. + * with wrapping. So it's in preference now. + * Make it default if you REALLY eager for this. * HOWEVER IT MAY BE SLOW BECAUSE OPTIMIZED SCROLL IS DISABLED * IN WRAPPING MODE. * @@ -66,8 +66,6 @@ #define PMORE_USE_OPT_SCROLL // optimized scroll #define PMORE_PRELOAD_SIZE (128*1024L) // on busy system set smaller or undef -//#define PMORE_TRADITIONAL_SEPERATOR // display seperator with extra space -//#define PMORE_TRADITIONAL_STATUSBAR // if you really love that #define PMORE_TRADITIONAL_PROMPTEND // when prompt=NA, show only page 1 // -------------------------------------------------------------- </FEATURES> @@ -162,13 +160,17 @@ typedef struct { /* mode flags */ unsigned short int - rawmode, // show file as-is. wrapmode, // wrap? - indicator; // show wrap indicators? + indicator, // show wrap indicators + + oldwrapmode, // traditional wrap + oldseperator, // traditional seperator + oldstatusbar, // traditional statusbar + rawmode; // show file as-is. } MF_BrowsingPrefrence; MF_BrowsingPrefrence bpref = -{ 0, MFDISP_WRAP_WRAP, 1, }; +{ MFDISP_WRAP_WRAP, 1, 0, 0, 0, 0, }; /* pretty format header */ #define FH_HEADERS (4) // how many headers do we know? @@ -778,7 +780,6 @@ mf_disp() } outs(ANSI_RESET); -#ifdef PMORE_TRADITIONAL_SEPERATOR /* Traditional 'more' adds seperator as a newline. * This is buggy, however we can support this * by using wrapping features. @@ -786,7 +787,7 @@ mf_disp() * leads to slow display (we cannt speed it up with * optimized scrolling. */ - if(bpref.wrapmode == MFDISP_WRAP_WRAP) + if(bpref.oldseperator && bpref.wrapmode == MFDISP_WRAP_WRAP) { /* we have to do all wrapping stuff * in normal text section. @@ -801,7 +802,6 @@ mf_disp() mf.dispe --; } else -#endif MFDISP_SKIPCURLINE(); } else if (!bpref.rawmode && currline < fh.lines) @@ -868,7 +868,7 @@ mf_disp() { if (!strchr(STR_ANSICODE, *mf.dispe)) inAnsi = 0; - if(col <= maxcol) + // if(col <= maxcol) outc(*mf.dispe); } else { if(*mf.dispe == ESC_CHR) @@ -914,14 +914,25 @@ mf_disp() } else #endif { + int canOutput = 0; /* if col > maxcol, * because we have the space for * "indicators" (one byte), * so we can tolerate one more byte. */ - if(col <= maxcol || - (mf.dispe < mf.end-1 && - *(mf.dispe+1) == '\n')) + if(col <= maxcol) // normal case + canOutput = 1; + else if (mf.dispe < mf.end-1 && // indicator space + *(mf.dispe+1) == '\n') + canOutput = 1; + else if (bpref.oldwrapmode && // oldwrapmode + col < t_columns) + { + canOutput = 1; + newline = MFDISP_NEWLINE_MOVE; + } + + if(canOutput) outc(*mf.dispe); else switch (bpref.wrapmode) { @@ -962,12 +973,14 @@ mf_disp() if(wrapping) endline = MFDISP_PAGE-1; - if(bpref.indicator) + if(!bpref.oldwrapmode && bpref.indicator) { if(wrapping) outs(MFDISP_WRAP_INDICATOR); else outs(MFDISP_TRUNC_INDICATOR); + } else { + outs(ANSI_RESET); } } else @@ -1009,22 +1022,23 @@ mf_disp() static const char * const pmore_help[] = { "\0�\\Ū�峹�\\����ϥλ���", "\01��в��ʥ\\����", - "(j)(��) �W���@��", - "(k)(��)(Enter) �U���@��", + "(j/��) (k/��/Enter) �W��/�U���@��", "(^B)(PgUp)(BackSpace) �W���@��", "(^F)(PgDn)(Space)(��) �U���@��", - "(0)(g)(Home) �ɮ}�Y", - "($)(G)(End) �ɮ���", + "(0/g/Home) ($/G/End) �ɮ}�Y/����", "(;/:) ���ܬY��/�Y��", "�Ʀr�� 1-9 ���ܿ�J���渹", "\01��L�\\����", - "(/) �j�M�r��", + "(/" ANSI_COLOR(1;30) "/" ANSI_RESET "s) �j�M�r��", "(n/N) ���ƥ�/�ϦV�j�M", "(Ctrl-T) �s��Ȧs��", "(f/b) ���ܤU/�W�g", "(a/A) ���ܦP�@�@�̤U/�W�g", "(t/[-/]+) �D�D���\\Ū:�`��/�e/��g", - "(\\/w/W) ������ܭ�l���e/�۰ʧ��/���Ÿ�", // this IS already aligned! +// "(\\/w/W) ������ܭ�l���e/�۰ʧ��/���Ÿ�", // this IS already aligned! + "(\\) ������ܭ�l���e", // this IS already aligned! + "(w/W) �����۰ʧ��/��ܧ��Ÿ�", + "(o) �Dz���ܤ覡(���j�u��ťզ�P��浥)", "(q)(��) ����", "(h)(H)(?) �������e��", #ifdef DEBUG @@ -1081,7 +1095,6 @@ pmore(char *fpath, int promptend) // clrtoeol(); // this shall be done in mf_disp to speed up. /* PRINT BOTTOM STATUS BAR */ - #ifdef DEBUG if(debug) { @@ -1105,12 +1118,13 @@ pmore(char *fpath, int promptend) { char *printcolor; -#ifndef PMORE_TRADITIONAL_STATUSBAR char buf[256]; // orz int prefixlen = 0; int barlen = 0; int postfix1len = 0, postfix2len = 0; -#endif + + int progress = + (int)((unsigned long)(mf.dispe-mf.start) * 100 / mf.len); if(mf_viewedAll()) printcolor = ANSI_COLOR(37;44); @@ -1122,68 +1136,72 @@ pmore(char *fpath, int promptend) outs(ANSI_RESET); outs(printcolor); -#ifdef PMORE_TRADITIONAL_STATUSBAR - prints(" �s�� P.%d(%d%%) %s %-30.30s%s", - (int)(mf.lineno / MFNAV_PAGE)+1, - (int)((unsigned long)(mf.dispe-mf.start) * 100 / mf.len), - ANSI_COLOR(31;47), - "(h)" - ANSI_COLOR(30) "�D�U " - ANSI_COLOR(31) "����[PgUp][", - "PgDn][Home][End]" - ANSI_COLOR(30) "��в��� " - ANSI_COLOR(31) "��[q]" - ANSI_COLOR(30) "���� "); -#else - if(mf.maxlinenoS >= 0) - sprintf(buf, - " �s�� �� %1d/%1d �� ", + if(bpref.oldstatusbar) + { + + prints(" �s�� P.%d(%d%%) %s %-30.30s%s", (int)(mf.lineno / MFNAV_PAGE)+1, - (int)(mf.maxlinenoS / MFNAV_PAGE)+1 - ); - else - sprintf(buf, - " �s�� �� %1d �� ", - (int)(mf.lineno / MFNAV_PAGE)+1 - ); - outs(buf); prefixlen += strlen(buf); + progress, + ANSI_COLOR(31;47), + "(h)" + ANSI_COLOR(30) "�D�U " + ANSI_COLOR(31) "����[PgUp][", + "PgDn][Home][End]" + ANSI_COLOR(30) "��в��� " + ANSI_COLOR(31) "��[q]" + ANSI_COLOR(30) "���� "); - outs(ANSI_COLOR(1;30;47)); + } else { - sprintf(buf, - " �\\Ū�i��%3d%%, �ثe���: �� %02d~%02d ��", - (int)((unsigned long)(mf.dispe-mf.start) * 100 / mf.len), - (int)(mf.lineno + 1), - (int)(mf.lineno + mf.dispedlines) - ); + if(mf.maxlinenoS >= 0) + sprintf(buf, + " �s�� �� %1d/%1d �� ", + (int)(mf.lineno / MFNAV_PAGE)+1, + (int)(mf.maxlinenoS / MFNAV_PAGE)+1 + ); + else + sprintf(buf, + " �s�� �� %1d �� ", + (int)(mf.lineno / MFNAV_PAGE)+1 + ); + outs(buf); prefixlen += strlen(buf); - outs(buf); prefixlen += strlen(buf); + outs(ANSI_COLOR(1;30;47)); - postfix1len = 12; // check msg below - postfix2len = 10; + sprintf(buf, + " �\\Ū�i��%3d%%, �ثe���: �� %02d~%02d ��", + progress, + (int)(mf.lineno + 1), + (int)(mf.lineno + mf.dispedlines) + ); + + outs(buf); prefixlen += strlen(buf); + + postfix1len = 12; // check msg below + postfix2len = 10; - if (prefixlen + postfix1len + postfix2len + 1 > t_columns) - { - postfix1len = 0; if (prefixlen + postfix1len + postfix2len + 1 > t_columns) - postfix2len = 0; + { + postfix1len = 0; + if (prefixlen + postfix1len + postfix2len + 1 > t_columns) + postfix2len = 0; + } + barlen = t_columns - 1 - postfix1len - postfix2len - prefixlen; + + while(barlen-- > 0) + outc(' '); + + if(postfix1len > 0) + outs( + ANSI_COLOR(0;31;47) "(h)" + ANSI_COLOR(30) "���仡�� " + ); + if(postfix2len > 0) + outs( + ANSI_COLOR(0;31;47) "��[q]" + ANSI_COLOR(30) "���} " + ); } - barlen = t_columns - 1 - postfix1len - postfix2len - prefixlen; - - while(barlen-- > 0) - outc(' '); - - if(postfix1len > 0) - outs( - ANSI_COLOR(0;31;47) "(h)" - ANSI_COLOR(30) "���仡�� " - ); - if(postfix2len > 0) - outs( - ANSI_COLOR(0;31;47) "��[q]" - ANSI_COLOR(30) "���} " - ); -#endif outs(ANSI_RESET); FORCE_CLRTOEOL(); } @@ -1192,10 +1210,8 @@ pmore(char *fpath, int promptend) ch = igetch(); switch (ch) { /* ------------------ EXITING KEYS ------------------ */ - case 'r': - case 'R': - case 'Y': - case 'y': + case 'r': case 'R': + case 'Y': case 'y': flExit = 1, retval = 999; break; case 'X': @@ -1207,12 +1223,10 @@ pmore(char *fpath, int promptend) case 'a': flExit = 1, retval = AUTHOR_NEXT; break; - case 'F': - case 'f': + case 'F': case 'f': flExit = 1, retval = READ_NEXT; break; - case 'B': - case 'b': + case 'B': case 'b': flExit = 1, retval = READ_PREV; break; case KEY_LEFT: @@ -1234,12 +1248,10 @@ pmore(char *fpath, int promptend) break; /* ------------------ NAVIGATION KEYS ------------------ */ /* Simple Navigation */ - case 'j': - case 'J': + case 'j': case 'J': mf_backward(1); break; - case 'k': - case 'K': + case 'k': case 'K': mf_forward(1); break; @@ -1307,6 +1319,7 @@ pmore(char *fpath, int promptend) PMORE_UINAV_FORWARDPAGE(); break; /* ------------------ SEARCH KEYS ------------------ */ + case 's': case '/': { char ans[4] = "n"; @@ -1370,8 +1383,7 @@ pmore(char *fpath, int promptend) } break; - case 'h': - case 'H': + case 'h': case 'H': case '?': // help show_help(pmore_help); @@ -1402,6 +1414,12 @@ pmore(char *fpath, int promptend) bpref.indicator = !bpref.indicator; MFDISP_DIRTY(); break; + case 'o': + bpref.oldwrapmode = !bpref.oldwrapmode; + bpref.oldseperator = !bpref.oldseperator; + bpref.oldstatusbar = !bpref.oldstatusbar; + MFDISP_DIRTY(); + break; case '\\': bpref.rawmode = !bpref.rawmode; MFDISP_DIRTY(); |