diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-04-12 19:52:28 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-04-12 19:52:28 +0800 |
commit | 0c4c72121c0afc0cca3a4cac6ac70b120cd235c3 (patch) | |
tree | abf61fc583cc1eebfe80aea67cc101802efc6651 /mbbsd | |
parent | 2b0055b710b9dde906533fb8ff116ac75bbe2b95 (diff) | |
download | pttbbs-0c4c72121c0afc0cca3a4cac6ac70b120cd235c3.tar pttbbs-0c4c72121c0afc0cca3a4cac6ac70b120cd235c3.tar.gz pttbbs-0c4c72121c0afc0cca3a4cac6ac70b120cd235c3.tar.bz2 pttbbs-0c4c72121c0afc0cca3a4cac6ac70b120cd235c3.tar.lz pttbbs-0c4c72121c0afc0cca3a4cac6ac70b120cd235c3.tar.xz pttbbs-0c4c72121c0afc0cca3a4cac6ac70b120cd235c3.tar.zst pttbbs-0c4c72121c0afc0cca3a4cac6ac70b120cd235c3.zip |
- visio: add vfooter() high level API.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4145 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/Makefile | 2 | ||||
-rw-r--r-- | mbbsd/visio.c | 83 |
2 files changed, 84 insertions, 1 deletions
diff --git a/mbbsd/Makefile b/mbbsd/Makefile index 41bd4863..df76bdaa 100644 --- a/mbbsd/Makefile +++ b/mbbsd/Makefile @@ -17,7 +17,7 @@ PAGEROBJS= more.o pmore.o PLUGOBJS = lovepaper.o calendar.o topsong.o gamble.o vice.o angel.o CHESSOBJS= chc.o chc_tab.o chess.o go.o gomo.o dark.o reversi.o GAMEOBJS = card.o guess.o chicken.o othello.o -OBJS= admin.o assess.o edit.o menu.o xyz.o var.o \ +OBJS= admin.o assess.o edit.o menu.o xyz.o var.o visio.o \ vote.o voteboard.o \ $(COREOBJS) $(ACCOBJS) $(NETOBJS) $(TALKOBJS) $(UTILOBJS) \ $(PAGEROBJS) $(PLUGOBJS) \ diff --git a/mbbsd/visio.c b/mbbsd/visio.c new file mode 100644 index 00000000..3c8114d1 --- /dev/null +++ b/mbbsd/visio.c @@ -0,0 +1,83 @@ +/* $Id$ */ +#include "bbs.h" + +/* + * visio.c + * High-level virtual screen input output control + * + * This is not the original visio.c from maple3. + * m3 visio = (ptt) visio+screen. + * This visio contains only high level UI element/widgets. + * In fact the only APIs from m3 are vmsg/vget... + * + * To add API here, please... + * (1) name the API in prefix of 'v'. + * (2) use only screen.c APIs. + * (3) take care of wide screen. + * (4) utilize the colos in visio.h, and name asa VCLR_* (visio color) + */ + +// ---- DEFINITION --------------------------------------------------- +#define MAX_COL (t_columns-1) +#define SAFE_MAX_COL (MAX_COL-1) + +// ---- UTILITIES ---------------------------------------------------- +inline void +outnc(int n, unsigned char c) +{ + while (n-- > 0) + outc(c); +} + +inline void +nblank(int n) +{ + outnc(n, ' '); +} + +// ---- HIGH LEVEL API ----------------------------------------------- + +/** + * 在最底部印出 caption msg 的形式 + * msg 中若有 () 則會變色為, \t 後的文字會靠右。 + * 最後面會自動留一個空白 (以避免自動偵測中文字的問題)。 + */ +void +vfooter(const char *caption, const char *msg) +{ + int i = 0; + move(b_lines, 0); clrtoeol(); + + if (caption) + { + outs(VCLR_FOOTER_CAPTION); + outs(caption); i+= strlen(caption); + } + + if (!msg) msg = ""; + outs(VCLR_FOOTER); + + while (*msg && i < SAFE_MAX_COL) + { + if (*msg == '(') + outs(VCLR_FOOTER_QUOTE); + else if (*msg == '\t') + { + // if we don't have enough space, ignore whole. + int l = strlen(++msg); + if (i + l > SAFE_MAX_COL) break; + l = SAFE_MAX_COL - l - i; + nblank(l); + i += l; + continue; + } + outc(*msg); i++; + if (*msg == ')') + outs(VCLR_FOOTER); + msg ++; + } + nblank(SAFE_MAX_COL-i); + outc(' '); + outs(ANSI_RESET); +} + |