summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-01-04 20:30:07 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-01-04 20:30:07 +0800
commitced1701cea3dabd64bf51f9ba3a24bc41ce81626 (patch)
tree1cba8616d74cf1445bb6787f1cbba48ecef0941b
parent0fcc819f8baceb9b3866be806cca51f22586a1ad (diff)
downloadpttbbs-ced1701cea3dabd64bf51f9ba3a24bc41ce81626.tar
pttbbs-ced1701cea3dabd64bf51f9ba3a24bc41ce81626.tar.gz
pttbbs-ced1701cea3dabd64bf51f9ba3a24bc41ce81626.tar.bz2
pttbbs-ced1701cea3dabd64bf51f9ba3a24bc41ce81626.tar.lz
pttbbs-ced1701cea3dabd64bf51f9ba3a24bc41ce81626.tar.xz
pttbbs-ced1701cea3dabd64bf51f9ba3a24bc41ce81626.tar.zst
pttbbs-ced1701cea3dabd64bf51f9ba3a24bc41ce81626.zip
- pfterm/screen: add more ncurses like API (add*)
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3785 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/pfterm.c40
-rw-r--r--mbbsd/screen.c35
2 files changed, 75 insertions, 0 deletions
diff --git a/mbbsd/pfterm.c b/mbbsd/pfterm.c
index d82a22ef..9c988ea2 100644
--- a/mbbsd/pfterm.c
+++ b/mbbsd/pfterm.c
@@ -322,10 +322,17 @@ void scroll (void); // scroll up
void rscroll (void); // scroll down
void scrl (int rows);
+// output (ncurses flavor)
+void addch (unsigned char c); // equivalent to outc()
+void addstr (const char *s); // equivalent to outs()
+void addnstr (const char *s, int n);
+
// output (non-ncurses)
void outc (unsigned char c);
void outs (const char *s);
+void outns (const char *s, int n);
void outstr (const char *str); // prepare and print a complete string.
+void addstring (const char *str); // ncurses-like of outstr().
// readback
int instr (char *str);
@@ -982,6 +989,30 @@ rscroll()
// output
void
+addch (unsigned char c)
+{
+ outc(c);
+}
+
+void
+addstr (const char *s)
+{
+ outs(s);
+}
+
+void
+addnstr(const char *s, int n)
+{
+ outns(s, n);
+}
+
+void
+addstring(const char *s)
+{
+ outstr(s);
+}
+
+void
outs(const char *s)
{
if (!s)
@@ -990,6 +1021,15 @@ outs(const char *s)
outc(*s++);
}
+void
+outns(const char *s, int n)
+{
+ if (!s)
+ return;
+ while (*s && n-- > 0)
+ outc(*s++);
+}
+
void
outstr(const char *str)
{
diff --git a/mbbsd/screen.c b/mbbsd/screen.c
index 3de85631..88696f8a 100644
--- a/mbbsd/screen.c
+++ b/mbbsd/screen.c
@@ -449,6 +449,16 @@ outs(const char *str)
}
void
+outns(const char *str, int n)
+{
+ if (!str)
+ return;
+ while (*str && n-- > 0) {
+ outc(*str++);
+ }
+}
+
+void
outstr(const char *str)
{
// XXX TODO cannot prepare DBCS-ready environment?
@@ -457,6 +467,31 @@ outstr(const char *str)
}
void
+addch(unsigned char c)
+{
+ outc(c);
+}
+
+void
+addstr(const char *s)
+{
+ outs(s);
+}
+
+void
+addnstr(const char *s, int n)
+{
+ outns(s, n);
+}
+
+void
+addstring(const char *s)
+{
+ outs(s);
+}
+
+
+void
scroll(void)
{
scrollcnt++;