summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-10-10 20:46:27 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-10-10 20:46:27 +0800
commitbfec28b24b15ecffe4c5d6cc2db44bccbdab2f16 (patch)
tree4f430e93ebf33ef03a24e94dafa4a51fc76a2636
parent7e79a3d99812c3547e464b9f8fa7b38829c443e4 (diff)
downloadpttbbs-bfec28b24b15ecffe4c5d6cc2db44bccbdab2f16.tar
pttbbs-bfec28b24b15ecffe4c5d6cc2db44bccbdab2f16.tar.gz
pttbbs-bfec28b24b15ecffe4c5d6cc2db44bccbdab2f16.tar.bz2
pttbbs-bfec28b24b15ecffe4c5d6cc2db44bccbdab2f16.tar.lz
pttbbs-bfec28b24b15ecffe4c5d6cc2db44bccbdab2f16.tar.xz
pttbbs-bfec28b24b15ecffe4c5d6cc2db44bccbdab2f16.tar.zst
pttbbs-bfec28b24b15ecffe4c5d6cc2db44bccbdab2f16.zip
* refine pager prompt
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@4925 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/mbbsd/more.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/pttbbs/mbbsd/more.c b/pttbbs/mbbsd/more.c
index 8fed9ee2..a2df01b6 100644
--- a/pttbbs/mbbsd/more.c
+++ b/pttbbs/mbbsd/more.c
@@ -318,46 +318,54 @@ display_hotkey_footer(const char *caption, const char *kattr, const char *vattr)
}
#define MACROSTRLEN(x) (sizeof(x)-1)
+
static int
common_pmore_footer_handler(int ratio, int width, void *ctx)
{
-#define FOOTERMSG_READ_LONG "(y)回應(X%)推文(h)說明(←)離開 "
#define FOOTERMSG_MAIL_LONG "(y)回信 (h)說明 (←/q)離開 "
+#define FOOTERMSG_READ_LONG "(y)回應(X%)推文(h)說明(←)離開 "
+#define FOOTERMSG_READ_MID "(y)回應(X/%)推文 (←)離開 "
#define FOOTERMSG_SHORT "(h)說明 (←/q)離開 "
#define FOOTERMSG_VERYSHORT "(←q)離開 "
+#define FOOTERATTR_KEY ANSI_COLOR(31)
+#define FOOTERATTR_TEXT ANSI_COLOR(30)
int w;
+ // XXX if you want to refine code here to use for-loop,
+ // remember to use a pre-calculated array to hold MACROSTRLEN
+ // or use real strlen(). do not pass string pointer to MACROSTRLEN.
if (currstat == RMAIL && (w = MACROSTRLEN(FOOTERMSG_MAIL_LONG)) <= width)
{
- if (width > w) prints("%*s", width-w, "");
+ while (width-- > w) outc(' ');
display_hotkey_footer(FOOTERMSG_MAIL_LONG,
- ANSI_COLOR(31), ANSI_COLOR(30));
- return 0;
+ FOOTERATTR_KEY, FOOTERATTR_TEXT);
}
- if (currstat == READING && (w = MACROSTRLEN(FOOTERMSG_READ_LONG)) <= width)
+ else if (currstat == READING && (w = MACROSTRLEN(FOOTERMSG_READ_LONG)) <= width)
{
- if (width > w) prints("%*s", width-w, "");
+ while (width-- > w) outc(' ');
display_hotkey_footer(FOOTERMSG_READ_LONG,
- ANSI_COLOR(31), ANSI_COLOR(30));
- return 0;
+ FOOTERATTR_KEY, FOOTERATTR_TEXT);
}
- if ( (w = MACROSTRLEN(FOOTERMSG_SHORT)) <= width)
+ else if (currstat == READING && (w = MACROSTRLEN(FOOTERMSG_READ_MID)) <= width)
{
- if (width > w) prints("%*s", width-w, "");
+ while (width-- > w) outc(' ');
+ display_hotkey_footer(FOOTERMSG_READ_MID,
+ FOOTERATTR_KEY, FOOTERATTR_TEXT);
+ }
+ else if ( (w = MACROSTRLEN(FOOTERMSG_SHORT)) <= width)
+ {
+ while (width-- > w) outc(' ');
display_hotkey_footer(FOOTERMSG_SHORT,
- ANSI_COLOR(31), ANSI_COLOR(30));
- return 0;
+ FOOTERATTR_KEY, FOOTERATTR_TEXT);
}
- if ( (w = MACROSTRLEN(FOOTERMSG_VERYSHORT)) <= width)
+ else if ( (w = MACROSTRLEN(FOOTERMSG_VERYSHORT)) <= width)
{
- if (width > w) prints("%*s", width-w, "");
+ while (width-- > w) outc(' ');
display_hotkey_footer(FOOTERMSG_VERYSHORT,
- ANSI_COLOR(31), ANSI_COLOR(30));
- return 0;
+ FOOTERATTR_KEY, FOOTERATTR_TEXT);
}
-
- if (width > w) prints("%*s", width-w, "");
- return -1;
+ else while (width-- > w) outc(' ');
+ return 0;
}
/* use new pager: piaip's more. */