summaryrefslogtreecommitdiff
path: root/lib/libcurses/tinfo/lib_tputs.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2000-06-19 03:54:00 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2000-06-19 03:54:00 +0000
commitd6e8f609245bfd13a1aee14a2347d3a3a6125319 (patch)
tree5633e2c339f330e0db835a1a8834519826c9f921 /lib/libcurses/tinfo/lib_tputs.c
parente11e5df3fd5c0ef8be778b1ae185ee1842790d3e (diff)
ncurses-5.0-20000617
Diffstat (limited to 'lib/libcurses/tinfo/lib_tputs.c')
-rw-r--r--lib/libcurses/tinfo/lib_tputs.c70
1 files changed, 68 insertions, 2 deletions
diff --git a/lib/libcurses/tinfo/lib_tputs.c b/lib/libcurses/tinfo/lib_tputs.c
index 7bed4f9cdb8..4a5aa118864 100644
--- a/lib/libcurses/tinfo/lib_tputs.c
+++ b/lib/libcurses/tinfo/lib_tputs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_tputs.c,v 1.5 2000/03/10 01:35:04 millert Exp $ */
+/* $OpenBSD: lib_tputs.c,v 1.6 2000/06/19 03:53:50 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -47,7 +47,7 @@
#include <termcap.h> /* ospeed */
#include <tic.h>
-MODULE_ID("$From: lib_tputs.c,v 1.45 2000/02/27 02:33:24 tom Exp $")
+MODULE_ID("$From: lib_tputs.c,v 1.47 2000/05/27 23:08:41 tom Exp $")
char PC = 0; /* used by termcap library */
speed_t ospeed = 0; /* used by termcap library */
@@ -77,6 +77,12 @@ delay_output(int ms)
returnCode(OK);
}
+void
+_nc_flush(void)
+{
+ (void)fflush(NC_OUTPUT);
+}
+
int
_nc_outch(int ch)
{
@@ -98,6 +104,66 @@ _nc_outch(int ch)
return OK;
}
+#ifdef USE_WIDEC_SUPPORT
+/*
+ * Reference: The Unicode Standard 2.0
+ *
+ * No surrogates supported (we're storing only one 16-bit Unicode value per
+ * cell).
+ */
+int
+_nc_utf8_outch(int ch)
+{
+ static const unsigned byteMask = 0xBF;
+ static const unsigned otherMark = 0x80;
+ static const unsigned firstMark[] =
+ {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC};
+
+ int result[7], *ptr;
+ int count = 0;
+
+ if (ch < 0x80)
+ count = 1;
+ else if (ch < 0x800)
+ count = 2;
+ else if (ch < 0x10000)
+ count = 3;
+ else if (ch < 0x200000)
+ count = 4;
+ else if (ch < 0x4000000)
+ count = 5;
+ else if (ch <= 0x7FFFFFFF)
+ count = 6;
+ else {
+ count = 2;
+ ch = 0xFFFD;
+ }
+ ptr = result + count;
+ switch (count) {
+ case 6:
+ *--ptr = (ch | otherMark) & byteMask;
+ ch >>= 6;
+ case 5:
+ *--ptr = (ch | otherMark) & byteMask;
+ ch >>= 6;
+ case 4:
+ *--ptr = (ch | otherMark) & byteMask;
+ ch >>= 6;
+ case 3:
+ *--ptr = (ch | otherMark) & byteMask;
+ ch >>= 6;
+ case 2:
+ *--ptr = (ch | otherMark) & byteMask;
+ ch >>= 6;
+ case 1:
+ *--ptr = (ch | firstMark[count]);
+ }
+ while (count--)
+ _nc_outch(*ptr++);
+ return OK;
+}
+#endif
+
int
putp(const char *string)
{