aboutsummaryrefslogtreecommitdiff
path: root/chinese/irssi
diff options
context:
space:
mode:
authorVanilla I. Shu <vanilla@FreeBSD.org>2003-12-13 18:04:40 +0000
committerVanilla I. Shu <vanilla@FreeBSD.org>2003-12-13 18:04:40 +0000
commit7626ab6130f457a4c7f9d5c09d05ab305f2adcea (patch)
treeac242063dda2a711e84f0f7489bc3f4c3c573c8c /chinese/irssi
parentf289e5d8c1f72829d573342c9f7ea3dbc7daa158 (diff)
downloadports-7626ab6130f457a4c7f9d5c09d05ab305f2adcea.tar.gz
ports-7626ab6130f457a4c7f9d5c09d05ab305f2adcea.zip
Notes
Diffstat (limited to 'chinese/irssi')
-rw-r--r--chinese/irssi/Makefile9
-rw-r--r--chinese/irssi/files/patch-src::fe-text::gui-entry.c285
-rw-r--r--chinese/irssi/files/patch-src::fe-text::gui-readline.c51
3 files changed, 288 insertions, 57 deletions
diff --git a/chinese/irssi/Makefile b/chinese/irssi/Makefile
index ebaab525ae6a..249611804b07 100644
--- a/chinese/irssi/Makefile
+++ b/chinese/irssi/Makefile
@@ -5,7 +5,7 @@
# $FreeBSD$
#
-PORTREVISION= 0
+PORTREVISION= 1
CATEGORIES= chinese
MAINTAINER= vanilla@FreeBSD.org
@@ -15,8 +15,11 @@ MASTERDIR= ${.CURDIR}/../../irc/irssi
EXTRA_PATCHES= ${.CURDIR}/files/patch-irssi.conf \
${.CURDIR}/files/patch-src::fe-text::gui-entry.c \
- ${.CURDIR}/files/patch-src::fe-text::gui-entry.h \
- ${.CURDIR}/files/patch-src::fe-text::gui-readline.c
+ ${.CURDIR}/files/patch-src::fe-text::gui-printtext.c \
+ ${.CURDIR}/files/patch-src::fe-text::gui-readline.c \
+ ${.CURDIR}/files/patch-src::fe-text::term-terminfo.c \
+ ${.CURDIR}/files/patch-src::fe-text::textbuffer-view.c
+
.include "${MASTERDIR}/Makefile"
diff --git a/chinese/irssi/files/patch-src::fe-text::gui-entry.c b/chinese/irssi/files/patch-src::fe-text::gui-entry.c
index 050838b17708..4cfc86372d8c 100644
--- a/chinese/irssi/files/patch-src::fe-text::gui-entry.c
+++ b/chinese/irssi/files/patch-src::fe-text::gui-entry.c
@@ -1,29 +1,280 @@
--- src/fe-text/gui-entry.c.orig Sun Oct 26 13:45:02 2003
-+++ src/fe-text/gui-entry.c Sun Dec 7 16:33:14 2003
-@@ -226,7 +226,7 @@
++++ src/fe-text/gui-entry.c Sun Dec 14 01:54:28 2003
+@@ -68,28 +68,89 @@
+ g_free(entry);
+ }
+
+-/* Fixes the cursor position if it at big5_lo .
+- Direct: -1 , left shift 1 byte.
+- Direct: 0, +1 , right shift 1 byte.
+-*/
+-static int _fix_big5_pos(unichar *p, int pos, int direct)
+-{
+- int newpos;
+-
+- if (term_type != TERM_TYPE_BIG5)
+- return pos;
+-
+- for (newpos = 0; newpos < pos && p[newpos] != 0; ) {
+- if (is_big5(p[newpos], p[newpos+1]))
+- newpos += 2;
+- else
+- newpos++;
++/* big5 functions */
++#define big5_width(ch) ((ch)>0xff ? 2:1)
++
++void unichars_to_big5(const unichar *str, char *out)
++{
++ for (; *str != '\0'; str++) {
++ if(*str>0xff)
++ *out++ = (*str>>8)&0xff;
++ *out++ = *str&0xff;
++ }
++ *out = '\0';
++}
++
++int strlen_big5(const unsigned char *str)
++{
++ int len=0;
++
++ if(term_type!=TERM_TYPE_BIG5)
++ return strlen(str);
++ while(*str != '\0') {
++ if(is_big5(str[0],str[1]))
++ str++;
++ len++;
++ str++;
}
++ return len;
++}
++
++void big5_to_unichars(const char *str, unichar *out)
++{
++ const unsigned char *p = (const unsigned char *) str;
++
++ while(*p != '\0')
++ if (is_big5(p[0], p[1])) {
++ *out++ = p[0] << 8 | p[1];
++ p += 2;
++ } else
++ *out++ = *p++;
++ *out = '\0';
++}
++
++/* ----------------------------- */
++
++static int pos2scrpos(GUI_ENTRY_REC *entry, int pos)
++{
++ unichar *p;
++ int xpos=0;
++
++ for (p=entry->text;p-entry->text<pos;p++)
++ if (term_type == TERM_TYPE_BIG5)
++ xpos += big5_width(*p);
++ else if(entry->utf8)
++ xpos += utf8_width(*p);
++ else
++ xpos ++;
++
++ return xpos;
++}
++
++static int scrpos2pos(GUI_ENTRY_REC *entry, int pos)
++{
++ int i;
++ int xpos=0;
+
+- if (newpos != pos)
+- pos += direct > 0 ? 1 : -1;
++ for(i=0; entry->text[i]; i++) {
++ int width;
++ unichar *p=entry->text+i;
++
++ if(term_type == TERM_TYPE_BIG5)
++ width = big5_width(*p);
++ else if(entry->utf8)
++ width = utf8_width(*p);
++ else
++ width = 1;
++ if(xpos+width>pos)
++ break;
++ xpos+=width;
++ }
+
+- return pos;
++ if(xpos==pos)
++ return i;
++ else
++ return i-1;
}
--void gui_entry_set_prompt(GUI_ENTRY_REC *entry, const char *str)
-+void gui_entry_set_prompt(GUI_ENTRY_REC *entry, const unsigned char *str)
+ /* Fixes the cursor position in screen */
+@@ -97,20 +158,23 @@
{
- int oldlen;
+ int old_scrstart;
-@@ -262,7 +262,7 @@
- entry->utf8 = utf8;
+- old_scrstart = entry->scrstart;
+- if (entry->pos - entry->scrstart < entry->width-2 - entry->promptlen &&
+- entry->pos - entry->scrstart > 0) {
+- entry->scrpos = entry->pos - entry->scrstart;
+- } else if (entry->pos < entry->width-1 - entry->promptlen) {
++ /* assume prompt len == prompt scrlen */
++ int start=pos2scrpos(entry,entry->scrstart);
++ int now=pos2scrpos(entry,entry->pos);
++
++ old_scrstart = entry->scrstart;
++ if (now-start < entry->width-2-entry->promptlen &&
++ now-start > 0)
++ entry->scrpos=now-start;
++ else if(now < entry->width-1-entry->promptlen) {
+ entry->scrstart = 0;
+- entry->scrpos = entry->pos;
++ entry->scrpos=now;
+ } else {
+- entry->scrpos = (entry->width - entry->promptlen)*2/3;
+- entry->scrstart = entry->pos - entry->scrpos;
++ entry->scrstart = scrpos2pos(entry,now-(entry->width - entry->promptlen)*2/3);
++ start=pos2scrpos(entry,entry->scrstart);
++ entry->scrpos=now-start;
+ }
+
+- entry->scrstart = _fix_big5_pos(entry->text, entry->scrstart, -1);
+-
+ if (old_scrstart != entry->scrstart)
+ entry->redraw_needed_from = 0;
}
+@@ -120,7 +184,9 @@
+ const unichar *p;
+ int xpos, end_xpos;
--void gui_entry_set_text(GUI_ENTRY_REC *entry, const char *str)
-+void gui_entry_set_text(GUI_ENTRY_REC *entry, const unsigned char *str)
- {
- g_return_if_fail(entry != NULL);
- g_return_if_fail(str != NULL);
-@@ -291,7 +291,7 @@
+- xpos = entry->xpos + entry->promptlen + pos;
++ xpos = entry->xpos + entry->promptlen +
++ pos2scrpos(entry, pos + entry->scrstart) -
++ pos2scrpos(entry, entry->scrstart);
+ end_xpos = entry->xpos + entry->width;
+ if (xpos > end_xpos)
+ return;
+@@ -131,7 +197,15 @@
+ p = entry->scrstart + pos < entry->text_len ?
+ entry->text + entry->scrstart + pos : empty_str;
+ for (; *p != '\0'; p++) {
+- xpos += utf8_width(*p);
++ if (entry->hidden)
++ xpos++;
++ else if(term_type == TERM_TYPE_BIG5)
++ xpos += big5_width(*p);
++ else if(entry->utf8)
++ xpos += utf8_width(*p);
++ else
++ xpos++;
++
+ if (xpos > end_xpos)
+ break;
+
+@@ -285,8 +359,11 @@
+ if (entry->utf8)
+ utf16_to_utf8(entry->text, buf);
+ else {
+- for (i = 0; i <= entry->text_len; i++)
+- buf[i] = entry->text[i];
++ if(term_type==TERM_TYPE_BIG5)
++ unichars_to_big5(entry->text, buf);
++ else
++ for (i = 0; i <= entry->text_len; i++)
++ buf[i] = entry->text[i];
+ }
+ return buf;
+ }
+@@ -301,7 +378,7 @@
+
+ gui_entry_redraw_from(entry, entry->pos);
+
+- len = !entry->utf8 ? strlen(str) : strlen_utf8(str);
++ len = !entry->utf8 ? strlen_big5(str) : strlen_utf8(str);
+ entry_text_grow(entry, len);
+
+ /* make space for the string */
+@@ -309,8 +386,13 @@
+ (entry->text_len-entry->pos + 1) * sizeof(unichar));
+
+ if (!entry->utf8) {
+- for (i = 0; i < len; i++)
+- entry->text[entry->pos+i] = str[i];
++ if (term_type == TERM_TYPE_BIG5) {
++ chr = entry->text[entry->pos+len];
++ big5_to_unichars(str, entry->text+entry->pos);
++ entry->text[entry->pos+len] = chr;
++ } else
++ for (i = 0; i < len; i++)
++ entry->text[entry->pos + i] = str[i];
+ } else {
+ chr = entry->text[entry->pos+len];
+ utf8_to_utf16(str, entry->text+entry->pos);
+@@ -361,8 +443,12 @@
+ if (entry->utf8)
+ utf16_to_utf8(entry->cutbuffer, buf);
+ else {
+- for (i = 0; i <= entry->cutbuffer_len; i++)
+- buf[i] = entry->cutbuffer[i];
++ if(term_type==TERM_TYPE_BIG5) {
++ unichars_to_big5(entry->cutbuffer, buf);
++ } else
++ for (i = 0; i <= entry->cutbuffer_len; i++) {
++ buf[i] = entry->cutbuffer[i];
++ }
+ }
return buf;
}
+@@ -374,24 +460,17 @@
+ g_return_if_fail(entry != NULL);
+
+ for (newpos = gui_entry_get_pos(entry); newpos > pos; size++)
+- newpos = _fix_big5_pos(entry->text, newpos - 1, -1);
++ newpos = newpos - 1;
+ gui_entry_erase(entry, size, update_cutbuffer);
+ }
--void gui_entry_insert_text(GUI_ENTRY_REC *entry, const char *str)
-+void gui_entry_insert_text(GUI_ENTRY_REC *entry, const unsigned char *str)
+ void gui_entry_erase(GUI_ENTRY_REC *entry, int size, int update_cutbuffer)
{
- unichar chr;
- int i, len;
+- int newpos;
+-
+ g_return_if_fail(entry != NULL);
+
+ if (entry->pos < size)
+ return;
+
+- /* recount the erase size with big5 charsets */
+- for (newpos = entry->pos; newpos > 0 && size > 0; size--)
+- newpos = _fix_big5_pos(entry->text, newpos-1, -1);
+- size = entry->pos - newpos;
+-
+ if (update_cutbuffer) {
+ /* put erased text to cutbuffer */
+ if (entry->cutbuffer == NULL || entry->cutbuffer_len < size) {
+@@ -515,24 +594,10 @@
+
+ void gui_entry_move_pos(GUI_ENTRY_REC *entry, int pos)
+ {
+- int newpos;
+-
+ g_return_if_fail(entry != NULL);
+
+- /* move cursor with big5 charset */
+- newpos = _fix_big5_pos(entry->text, entry->pos, -1);
+- if (pos > 0) {
+- while (pos > 0 && newpos < entry->text_len) {
+- newpos = _fix_big5_pos(entry->text, newpos+1, 1);
+- pos--;
+- }
+- } else {
+- while (pos < 0 && newpos > 0) {
+- newpos = _fix_big5_pos(entry->text, newpos-1, -1);
+- pos++;
+- }
+- }
+- entry->pos = newpos;
++ if (entry->pos+pos >= 0 && entry->pos+pos <= entry->text_len)
++ entry->pos += pos;
+
+ gui_entry_fix_cursor(entry);
+ gui_entry_draw(entry);
diff --git a/chinese/irssi/files/patch-src::fe-text::gui-readline.c b/chinese/irssi/files/patch-src::fe-text::gui-readline.c
index 29bf1948fd10..64be698943fe 100644
--- a/chinese/irssi/files/patch-src::fe-text::gui-readline.c
+++ b/chinese/irssi/files/patch-src::fe-text::gui-readline.c
@@ -1,39 +1,16 @@
---- src/fe-text/gui-readline.c.orig Sun Nov 23 20:30:02 2003
-+++ src/fe-text/gui-readline.c Sun Dec 7 16:35:50 2003
-@@ -53,6 +53,9 @@
- static ENTRY_REDIRECT_REC *redir;
- static int escape_next_key;
-
-+static int big5high = FALSE;
-+static unichar prekey = '\0';
-+
- static int readtag;
- static unichar prev_key;
- static GTimeVal last_keypress;
-@@ -339,7 +342,25 @@
- return;
+--- src/fe-text/gui-readline.c.orig Thu Nov 27 01:30:03 2003
++++ src/fe-text/gui-readline.c Sun Dec 14 01:54:28 2003
+@@ -187,7 +187,12 @@
+ out[utf16_char_to_utf8(arr[i], out)] = '\0';
+ g_string_append(str, out);
+ } else {
+- g_string_append_c(str, arr[i]);
++ if(term_type==TERM_TYPE_BIG5) {
++ if(arr[i]>0xff)
++ g_string_append_c(str, arr[i]>>8&0xff);
++ g_string_append_c(str, arr[i]&0xff);
++ } else
++ g_string_append_c(str, arr[i]);
+ }
}
-- if (key < 32) {
-+ if(big5high || is_big5_hi(key))
-+ {
-+ if(big5high)
-+ {
-+ big5high = FALSE;
-+ str[0] = prekey;
-+ str[1] = key;
-+ str[2] = '\0';
-+ gui_entry_insert_text(active_entry, str);
-+ return;
-+ }
-+ else
-+ {
-+ big5high = TRUE;
-+ prekey = key;
-+ return;
-+ }
-+ }
-+ else if (key < 32) {
- /* control key */
- str[0] = '^';
- str[1] = (char)key+'@';