From d5b24eed395d4c949e05d675fcf3028cd21b8b4f Mon Sep 17 00:00:00 2001 From: piaip Date: Sat, 4 Jun 2005 15:50:34 +0000 Subject: pmore: fix line calculation git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2762 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/pmore.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'mbbsd/pmore.c') diff --git a/mbbsd/pmore.c b/mbbsd/pmore.c index 16c89f7e..c168c304 100644 --- a/mbbsd/pmore.c +++ b/mbbsd/pmore.c @@ -1163,6 +1163,29 @@ pmore(char *fpath, int promptend) int progress = (int)((unsigned long)(mf.dispe-mf.start) * 100 / mf.len); + /* + * page determination is hard. + * should we use starting line, or finishing line? + */ + int nowpage = + (int)((mf.lineno + mf.dispedlines/2) / MFNAV_PAGE)+1; + int allpages = -1; /* unknown yet */ + if (mf.maxlinenoS >= 0) + { + allpages = + (int)((mf.maxlinenoS + mf.lastpagelines-1) / MFNAV_PAGE)+1; + if (mf.lineno >= mf.maxlinenoS || nowpage > allpages) + nowpage = allpages; + /* + nowpage = + (int)((mf.lineno + mf.dispedlines-2) / MFNAV_PAGE)+1 ; + */ + } + /* why -2 and -1? + * because we want to determine by nav_page, + * and mf.dispedlines is based on disp_page (nav_page+1) + * mf.lastpagelines is based on nav_page + */ if(mf_viewedAll()) printcolor = ANSI_COLOR(37;44); @@ -1178,7 +1201,7 @@ pmore(char *fpath, int promptend) { prints(" ÂsÄý P.%d(%d%%) %s %-30.30s%s", - (int)(mf.lineno / MFNAV_PAGE)+1, + nowpage, progress, ANSI_COLOR(31;47), "(h)" @@ -1191,16 +1214,16 @@ pmore(char *fpath, int promptend) } else { - if(mf.maxlinenoS >= 0) + if(allpages >= 0) sprintf(buf, " ÂsÄý ²Ä %1d/%1d ­¶ ", - (int)(mf.lineno / MFNAV_PAGE)+1, - (int)(mf.maxlinenoS / MFNAV_PAGE)+1 + nowpage, + allpages ); else sprintf(buf, " ÂsÄý ²Ä %1d ­¶ ", - (int)(mf.lineno / MFNAV_PAGE)+1 + nowpage ); outs(buf); prefixlen += strlen(buf); -- cgit v1.2.3