summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-06-11 02:46:52 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-06-11 02:46:52 +0800
commitf787c8fdfd24555801e2be483d13baaf610298c2 (patch)
tree4934e52fa6f4f5d2ddf5eb428f1abd022874b836
parentdda5af373350d4b6649335e4ec8600a0baf2afe7 (diff)
downloadpttbbs-f787c8fdfd24555801e2be483d13baaf610298c2.tar
pttbbs-f787c8fdfd24555801e2be483d13baaf610298c2.tar.gz
pttbbs-f787c8fdfd24555801e2be483d13baaf610298c2.tar.bz2
pttbbs-f787c8fdfd24555801e2be483d13baaf610298c2.tar.lz
pttbbs-f787c8fdfd24555801e2be483d13baaf610298c2.tar.xz
pttbbs-f787c8fdfd24555801e2be483d13baaf610298c2.tar.zst
pttbbs-f787c8fdfd24555801e2be483d13baaf610298c2.zip
update ansi escape scanner
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2824 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--include/ansi.h3
-rw-r--r--mbbsd/edit.c9
-rw-r--r--mbbsd/pmore.c12
3 files changed, 13 insertions, 11 deletions
diff --git a/include/ansi.h b/include/ansi.h
index cb7e86cd..d75df914 100644
--- a/include/ansi.h
+++ b/include/ansi.h
@@ -19,6 +19,9 @@
#define ANSI_MOVETO(y,x) ESC_STR "[" #y ";" #x "H"
#define ANSI_CLRTOEND ESC_STR "[K"
+#define ANSI_IN_ESCAPE(x) (((x) >= '0' && (x) <= '9') || \
+ (x) == ';' || (x) == ',' || (x) == '[')
+
#endif /* INCLUDE_ANSI_H */
/* vim:sw=4
diff --git a/mbbsd/edit.c b/mbbsd/edit.c
index fb085284..ec041eab 100644
--- a/mbbsd/edit.c
+++ b/mbbsd/edit.c
@@ -1842,9 +1842,6 @@ block_select(void)
*
* FIXME column could not start from 0
*/
-#ifndef STR_ANSICODE
-#define STR_ANSICODE "[0123456789;,"
-#endif
void
edit_outs(const char *text)
@@ -1870,7 +1867,7 @@ edit_outs_n(const char *text, int n)
if(inAnsi)
{
outc(ch);
- if(strchr(STR_ANSICODE, ch) == 0)
+ if(!ANSI_IN_ESCAPE(ch))
{
inAnsi = 0;
outs(ANSI_RESET);
@@ -3198,8 +3195,8 @@ vedit(char *fpath, int saveheader, int *islocal)
edit_outs(&curr_buf->currline->data[curr_buf->edit_margin]);
edit_msg();
}
- }
- }
+ } /* redraw */
+ } /* main event loop */
exit_edit_buffer();
}
diff --git a/mbbsd/pmore.c b/mbbsd/pmore.c
index 2412eb39..3816a82b 100644
--- a/mbbsd/pmore.c
+++ b/mbbsd/pmore.c
@@ -134,8 +134,6 @@ int debug = 0;
// --------------------------- <Display>
/* ANSI COMMAND SYSTEM */
-#define STR_ANSICODE "[0123456789;,"
-
/* On some systems with pmore style ANSI system applied,
* we don't have to define these again.
*/
@@ -153,6 +151,9 @@ int debug = 0;
#define ANSI_MOVETO(y,x) ESC_STR "[" #y ";" #x "H"
#define ANSI_CLRTOEND ESC_STR "[K"
+#define ANSI_IN_ESCAPE(x) (((x) >= '0' && (x) <= '9') || \
+ (x) == ';' || (x) == ',' || (x) == '[')
+
#endif /* PMORE_STYLE_ANSI */
// Poor BBS terminal system Workarounds
@@ -679,7 +680,8 @@ pmore_str_strip_ansi(unsigned char *p) // warning: p is NULL terminated
{
// ansi code sequence, ignore them.
pb = p++;
- while (*p && strchr(STR_ANSICODE, *p++));
+ while (ANSI_IN_ESCAPE(*p))
+ p++;
memmove(pb, p, strlen(p)+1);
p = pb;
}
@@ -855,7 +857,7 @@ MFDISP_PREDICT_LINEWIDTH(unsigned char *p)
{
if(inAnsi)
{
- if(!strchr(STR_ANSICODE, *p))
+ if(!ANSI_IN_ESCAPE(*p))
inAnsi = 0;
} else {
if(*p == ESC_CHR)
@@ -1139,7 +1141,7 @@ mf_display()
{
if(inAnsi)
{
- if (!strchr(STR_ANSICODE, c))
+ if (!ANSI_IN_ESCAPE(c))
inAnsi = 0;
/* whatever this is, output! */
mf.dispe ++;