summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-05-01 09:38:06 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-05-01 09:38:06 +0000
commit6d4f2ab6fa7ac126765a3d7f4acca1a0c2ff6a09 (patch)
tree70e70c7c620cb865358f3b2b52f2433cc30cc7e0
parent53474a2163f36bec81e89c655e0b9ef95f09a8cc (diff)
downloadirssi-6d4f2ab6fa7ac126765a3d7f4acca1a0c2ff6a09.zip
--with-big5 enables Chinese Big5 charset support. Patch by vanilla@freebsd.org
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1458 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r--configure.in21
-rw-r--r--src/fe-text/gui-entry.c12
-rw-r--r--src/fe-text/screen.h15
3 files changed, 48 insertions, 0 deletions
diff --git a/configure.in b/configure.in
index 4ba083cc..0d82e8ad 100644
--- a/configure.in
+++ b/configure.in
@@ -37,6 +37,19 @@ AC_CHECK_HEADERS(string.h stdlib.h unistd.h dirent.h sys/ioctl.h libintl.h)
# check posix headers..
AC_CHECK_HEADERS(sys/time.h sys/utsname.h regex.h)
+AC_ARG_WITH(big5,
+[ --with-big5 Build with tr-Chinese Big5 support],
+ if test x$withval = xyes; then
+ want_big5=yes
+ else
+ if test "x$withval" = xno; then
+ want_big5=no
+ else
+ want_big5=yes
+ fi
+ fi,
+ want_big5=no)
+
AC_ARG_WITH(socks,
[ --with-socks Build with socks support],
if test x$withval = xyes; then
@@ -684,6 +697,14 @@ fi
AM_CONDITIONAL(BUILD_MEMDEBUG, test "x$want_memdebug" = "xyes")
dnl **
+dnl ** tr-Chinese Big5 support
+dnl **
+
+if test "x$want_big5" = "xyes"; then
+ AC_DEFINE(WANT_BIG5)
+fi
+
+dnl **
dnl ** IPv6 support
dnl **
diff --git a/src/fe-text/gui-entry.c b/src/fe-text/gui-entry.c
index f60525b9..7544539a 100644
--- a/src/fe-text/gui-entry.c
+++ b/src/fe-text/gui-entry.c
@@ -152,6 +152,11 @@ void gui_entry_erase(int size)
{
if (pos < size) return;
+#ifdef WANT_BIG5
+ if (is_big5(entry->str[pos-2], entry->str[pos-1]))
+ size++;
+#endif WANT_BIG5
+
pos -= size;
g_string_erase(entry, pos, size);
@@ -217,6 +222,13 @@ void gui_entry_set_pos(int p)
void gui_entry_move_pos(int p)
{
+#ifdef WANT_BIG5
+ if (p > 0 && is_big5 (entry->str[pos], entry->str[pos+1]))
+ p++;
+ else if (p < 0 && is_big5 (entry->str[pos-1], entry->str[pos]))
+ p--;
+#endif WANT_BIG5
+
if (pos+p >= 0 && pos+p <= entry->len)
pos += p;
diff --git a/src/fe-text/screen.h b/src/fe-text/screen.h
index 49ae79eb..c1449bfb 100644
--- a/src/fe-text/screen.h
+++ b/src/fe-text/screen.h
@@ -16,6 +16,21 @@
#define ATTR_COLOR8 0x200
#define ATTR_REVERSE 0x400
+/* XXX I hope this could be integrated into BX.
+ * XXX Well, this should be done via libc,
+ * but FreeBSD libc support is quite LAME.
+ * Macro below are copied from lynx.
+ *
+ * clive@FreeBSD.org
+ */
+#ifdef WANT_BIG5
+/* XXX I didn't check the encoding range of big5+. This is standard big5. */
+#define is_big5_los(lo) (((char)0x40<=lo)&&(lo<=(char)0x7E)) /* standard */
+#define is_big5_lox(lo) (((char)0x80<=lo)&&(lo<=(char)0xFE)) /* extended */
+#define is_big5_hi(hi) (((char)0x81<=hi)&&(hi<=(char)0xFE))
+#define is_big5(hi,lo) is_big5_hi(hi) && (is_big5_los(lo) || is_big5_lox(lo))
+#endif WANT_BIG5
+
int init_screen(void); /* Initialize screen, detect screen length */
void deinit_screen(void); /* Deinitialize screen */