forked from PsychoticNinja/irssi
Simplify.
git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@4941 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
a065f97f87
commit
a266ce8d97
@ -52,8 +52,6 @@ static int i_isalnum(unichar c)
|
|||||||
return (c >= 0 && c <= 255) ? isalnum(c) : 0;
|
return (c >= 0 && c <= 255) ? isalnum(c) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unichar empty_str[] = { 0 };
|
|
||||||
|
|
||||||
GUI_ENTRY_REC *active_entry;
|
GUI_ENTRY_REC *active_entry;
|
||||||
|
|
||||||
static void entry_text_grow(GUI_ENTRY_REC *entry, int grow_size)
|
static void entry_text_grow(GUI_ENTRY_REC *entry, int grow_size)
|
||||||
@ -156,14 +154,16 @@ void big5_to_unichars(const char *str, unichar *out)
|
|||||||
|
|
||||||
static int pos2scrpos(GUI_ENTRY_REC *entry, int pos)
|
static int pos2scrpos(GUI_ENTRY_REC *entry, int pos)
|
||||||
{
|
{
|
||||||
unichar *p;
|
int i;
|
||||||
int xpos = 0;
|
int xpos = 0;
|
||||||
|
|
||||||
for (p = entry->text; p - entry->text < pos; p++) {
|
for (i = 0; i < pos; i++) {
|
||||||
|
unichar c = entry->text[i];
|
||||||
|
|
||||||
if (term_type == TERM_TYPE_BIG5)
|
if (term_type == TERM_TYPE_BIG5)
|
||||||
xpos += big5_width(*p);
|
xpos += big5_width(c);
|
||||||
else if (entry->utf8)
|
else if (entry->utf8)
|
||||||
xpos += unichar_isprint(*p) ? mk_wcwidth(*p) : 1;
|
xpos += unichar_isprint(c) ? mk_wcwidth(c) : 1;
|
||||||
else
|
else
|
||||||
xpos++;
|
xpos++;
|
||||||
}
|
}
|
||||||
@ -174,13 +174,13 @@ static int scrpos2pos(GUI_ENTRY_REC *entry, int pos)
|
|||||||
{
|
{
|
||||||
int i, width, xpos;
|
int i, width, xpos;
|
||||||
|
|
||||||
for (i = 0, xpos = 0; entry->text[i]; i++) {
|
for (i = 0, xpos = 0; i < entry->text_len; i++) {
|
||||||
unichar *p = entry->text+i;
|
unichar c = entry->text[i];
|
||||||
|
|
||||||
if (term_type == TERM_TYPE_BIG5)
|
if (term_type == TERM_TYPE_BIG5)
|
||||||
width = big5_width(*p);
|
width = big5_width(c);
|
||||||
else if (entry->utf8)
|
else if (entry->utf8)
|
||||||
width = unichar_isprint(*p) ? mk_wcwidth(*p) : 1;
|
width = unichar_isprint(c) ? mk_wcwidth(c) : 1;
|
||||||
else
|
else
|
||||||
width = 1;
|
width = 1;
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ static void gui_entry_fix_cursor(GUI_ENTRY_REC *entry)
|
|||||||
|
|
||||||
static void gui_entry_draw_from(GUI_ENTRY_REC *entry, int pos)
|
static void gui_entry_draw_from(GUI_ENTRY_REC *entry, int pos)
|
||||||
{
|
{
|
||||||
const unichar *p;
|
int i;
|
||||||
int xpos, end_xpos;
|
int xpos, end_xpos;
|
||||||
|
|
||||||
xpos = entry->xpos + entry->promptlen +
|
xpos = entry->xpos + entry->promptlen +
|
||||||
@ -237,15 +237,15 @@ static void gui_entry_draw_from(GUI_ENTRY_REC *entry, int pos)
|
|||||||
term_set_color(root_window, ATTR_RESET);
|
term_set_color(root_window, ATTR_RESET);
|
||||||
term_move(root_window, xpos, entry->ypos);
|
term_move(root_window, xpos, entry->ypos);
|
||||||
|
|
||||||
p = entry->scrstart + pos < entry->text_len ?
|
for (i = entry->scrstart + pos; i < entry->text_len; i++) {
|
||||||
entry->text + entry->scrstart + pos : empty_str;
|
unichar c = entry->text[i];
|
||||||
for (; *p != '\0'; p++) {
|
|
||||||
if (entry->hidden)
|
if (entry->hidden)
|
||||||
xpos++;
|
xpos++;
|
||||||
else if (term_type == TERM_TYPE_BIG5)
|
else if (term_type == TERM_TYPE_BIG5)
|
||||||
xpos += big5_width(*p);
|
xpos += big5_width(c);
|
||||||
else if (entry->utf8)
|
else if (entry->utf8)
|
||||||
xpos += unichar_isprint(*p) ? mk_wcwidth(*p) : 1;
|
xpos += unichar_isprint(c) ? mk_wcwidth(c) : 1;
|
||||||
else
|
else
|
||||||
xpos++;
|
xpos++;
|
||||||
|
|
||||||
@ -254,11 +254,11 @@ static void gui_entry_draw_from(GUI_ENTRY_REC *entry, int pos)
|
|||||||
|
|
||||||
if (entry->hidden)
|
if (entry->hidden)
|
||||||
term_addch(root_window, ' ');
|
term_addch(root_window, ' ');
|
||||||
else if (unichar_isprint(*p))
|
else if (unichar_isprint(c))
|
||||||
term_add_unichar(root_window, *p);
|
term_add_unichar(root_window, c);
|
||||||
else {
|
else {
|
||||||
term_set_color(root_window, ATTR_RESET|ATTR_REVERSE);
|
term_set_color(root_window, ATTR_RESET|ATTR_REVERSE);
|
||||||
term_addch(root_window, (*p & 127)+'A'-1);
|
term_addch(root_window, (c & 127)+'A'-1);
|
||||||
term_set_color(root_window, ATTR_RESET);
|
term_set_color(root_window, ATTR_RESET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user