summaryrefslogtreecommitdiffstats
path: root/mbbsd/pfterm.c
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-01-13 08:55:09 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-01-13 08:55:09 +0800
commitaf8f62d5f4f18a60ad4230b38a74e1f26f71ce30 (patch)
tree55cc2b0ac5c3b9d8d8c97786ef04b5886232d02d /mbbsd/pfterm.c
parent3037e00cf92dbe072c02ab46e930007fef201d54 (diff)
downloadpttbbs-af8f62d5f4f18a60ad4230b38a74e1f26f71ce30.tar
pttbbs-af8f62d5f4f18a60ad4230b38a74e1f26f71ce30.tar.gz
pttbbs-af8f62d5f4f18a60ad4230b38a74e1f26f71ce30.tar.bz2
pttbbs-af8f62d5f4f18a60ad4230b38a74e1f26f71ce30.tar.lz
pttbbs-af8f62d5f4f18a60ad4230b38a74e1f26f71ce30.tar.xz
pttbbs-af8f62d5f4f18a60ad4230b38a74e1f26f71ce30.tar.zst
pttbbs-af8f62d5f4f18a60ad4230b38a74e1f26f71ce30.zip
- enable ncurses 'typeahead' API
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3832 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/pfterm.c')
-rw-r--r--mbbsd/pfterm.c48
1 files changed, 41 insertions, 7 deletions
diff --git a/mbbsd/pfterm.c b/mbbsd/pfterm.c
index faf2ffd0..08dec655 100644
--- a/mbbsd/pfterm.c
+++ b/mbbsd/pfterm.c
@@ -72,6 +72,14 @@
#endif // GRAYOUT_DARK
//////////////////////////////////////////////////////////////////////////
+// Typeahead
+//////////////////////////////////////////////////////////////////////////
+#ifndef TYPEAHEAD_NONE
+#define TYPEAHEAD_NONE (-1)
+#define TYPEAHEAD_STDIN (0)
+#endif // TYPEAHEAD
+
+//////////////////////////////////////////////////////////////////////////
// pfterm: piaip's flat terminal system, a new replacement for 'screen'.
// pfterm can also be read as "Perfect Term"
//
@@ -86,10 +94,10 @@
//
// Copyright(c) 2007-2008 Hung-Te Lin <piaip@csie.ntu.edu.tw>
// All Rights Reserved.
-// You are free to use, modify, redistribute this program
-// in any non-commercial usage (including network service).
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
+// You are free to use, modify, redistribute this program in any
+// non-commercial usage (including network service).
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
//
// MAJOR IMPROVEMENTS:
// - Interpret ANSI code and maintain a virtual terminal
@@ -205,16 +213,20 @@ typedef struct
int dirty;
int scroll;
+ // memory allocation
+ int mrows, mcols;
+
// raw terminal status
int ry, rx;
ftattr rattr;
- // memory allocation
- int mrows, mcols;
+ // typeahead
+ char typeahead;
// escape command
ftchar cmd[FTCMD_MAXLEN+1];
int szcmd;
+
} FlatTerm;
static FlatTerm ft;
@@ -331,6 +343,7 @@ void newwin (int nlines, int ncols, int y, int x);
void refresh (void); // optimized refresh
void doupdate (void); // optimized refresh, ignore input queue
void redrawwin (void); // invalidate whole screen
+int typeahead (int fd);// prevent refresh if input queue is not empty
// scrolling
void scroll (void); // scroll up
@@ -417,6 +430,9 @@ initscr(void)
ft.mi = 1; clrscr();
ft.mi = 0;
+ // typeahead
+ ft.typeahead = 1;
+
fterm_rawclear();
move(0, 0);
}
@@ -704,11 +720,29 @@ redrawwin(void)
fterm_markdirty();
}
+int
+typeahead(int fd)
+{
+ switch(fd)
+ {
+ case TYPEAHEAD_NONE:
+ ft.typeahead = 0;
+ break;
+ case TYPEAHEAD_STDIN:
+ ft.typeahead = 1;
+ break;
+ default: // shall never reach here
+ assert(NULL);
+ break;
+ }
+ return 0;
+}
+
void
refresh(void)
{
// prevent passive update
- if(fterm_inbuf())
+ if(fterm_inbuf() && ft.typeahead)
return;
doupdate();
}