[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[giFTcurs-commits] giFTcurs/src .indent.pro Makefile.am giftcurs.h...
From: |
Göran Weinholt |
Subject: |
[giFTcurs-commits] giFTcurs/src .indent.pro Makefile.am giftcurs.h... |
Date: |
Sun, 16 Nov 2003 11:15:38 -0500 |
CVSROOT: /cvsroot/giftcurs
Module name: giFTcurs
Branch:
Changes by: Göran Weinholt <address@hidden> 03/11/16 11:15:37
Modified files:
src : .indent.pro Makefile.am giftcurs.h list.c
main.c parse.c ui.c ui.h ui_draw.c ui_draw.h
ui_main.c
Added files:
src : ui_input.c ui_input.h
Log message:
The input fields are now dealt with in ui_input.c, and now work with
UTF-8.
Patches:
Index: giFTcurs/src/.indent.pro
diff -u giFTcurs/src/.indent.pro:1.2 giFTcurs/src/.indent.pro:1.3
--- giFTcurs/src/.indent.pro:1.2 Tue Jul 22 19:58:37 2003
+++ giFTcurs/src/.indent.pro Sun Nov 16 11:15:35 2003
@@ -12,4 +12,7 @@
-T GString
-T gboolean
-T guchar
+-T gchar
+-T wchar_t
-T ui_methods
+-T ui_input
Index: giFTcurs/src/Makefile.am
diff -u giFTcurs/src/Makefile.am:1.63 giFTcurs/src/Makefile.am:1.64
--- giFTcurs/src/Makefile.am:1.63 Tue Nov 4 18:40:44 2003
+++ giFTcurs/src/Makefile.am Sun Nov 16 11:15:35 2003
@@ -27,6 +27,7 @@
ui_console.c \
ui_draw.c ui_draw.h \
ui_help.c \
+ ui_input.c ui_input.h \
ui_main.c ui_main.h \
ui_mouse.c ui_mouse.h \
ui_settings.c \
Index: giFTcurs/src/giftcurs.h
diff -u giFTcurs/src/giftcurs.h:1.64 giFTcurs/src/giftcurs.h:1.65
--- giFTcurs/src/giftcurs.h:1.64 Tue Oct 14 15:47:59 2003
+++ giFTcurs/src/giftcurs.h Sun Nov 16 11:15:35 2003
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: giftcurs.h,v 1.64 2003/10/14 19:47:59 weinholt Exp $
+ * $Id: giftcurs.h,v 1.65 2003/11/16 16:15:35 weinholt Exp $
*/
#ifndef _GIFTCURS_H
#define _GIFTCURS_H
@@ -44,6 +44,7 @@
extern const char *server_port; /* Allow symbolic port specification */
extern const char *profile_name;
extern gboolean verbose;
+
#ifdef WIDE_NCURSES
extern gboolean utf8; /* Are we using UTF-8? */
extern gboolean fancy_utf8; /* Use cool UTF-8 line drawing chars. */
Index: giFTcurs/src/list.c
diff -u giFTcurs/src/list.c:1.86 giFTcurs/src/list.c:1.87
--- giFTcurs/src/list.c:1.86 Mon Sep 15 17:28:19 2003
+++ giFTcurs/src/list.c Sun Nov 16 11:15:35 2003
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: list.c,v 1.86 2003/09/15 21:28:19 saturn Exp $
+ * $Id: list.c,v 1.87 2003/11/16 16:15:35 weinholt Exp $
*/
#include "giftcurs.h"
@@ -173,14 +173,8 @@
int soff;
/* Do sanity check on values */
- if (snafu->start < 0)
- snafu->start = 0;
- if (snafu->start > snafu->num - 1)
- snafu->start = snafu->num - 1;
- if (snafu->sel < 0)
- snafu->sel = 0;
- if (snafu->sel > snafu->num - 1)
- snafu->sel = snafu->num - 1;
+ snafu->sel = CLAMP(snafu->sel, 0, snafu->num - 1);
+/* snafu->start = CLAMP(snafu->start, 0, snafu->num - 1); */
soff = scrolloff;
@@ -188,15 +182,9 @@
if (h <= soff * 2)
soff = (h - 1) / 2;
/* check against bottom */
- if (snafu->start < snafu->sel - h + 1 + soff)
- snafu->start = snafu->sel - h + 1 + soff;
- if (snafu->start > snafu->num - h)
- snafu->start = snafu->num - h;
+ snafu->start = CLAMP(snafu->start, snafu->sel - h + 1 + soff,
snafu->num - h);
/* check against top */
- if (snafu->start > snafu->sel - soff)
- snafu->start = snafu->sel - soff;
- if (snafu->start < 0)
- snafu->start = 0;
+ snafu->start = CLAMP(snafu->start, 0, snafu->sel - soff);
}
/* This is for list that don't have a selector */
Index: giFTcurs/src/main.c
diff -u giFTcurs/src/main.c:1.139 giFTcurs/src/main.c:1.140
--- giFTcurs/src/main.c:1.139 Tue Nov 4 18:40:44 2003
+++ giFTcurs/src/main.c Sun Nov 16 11:15:35 2003
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: main.c,v 1.139 2003/11/04 23:40:44 weinholt Exp $
+ * $Id: main.c,v 1.140 2003/11/16 16:15:35 weinholt Exp $
*/
#include "giftcurs.h"
@@ -46,6 +46,7 @@
const char *server_port = "1213";
const char *profile_name = NULL;
gboolean verbose = FALSE;
+
#ifdef WIDE_NCURSES
gboolean fancy_utf8 = FALSE;
#endif
Index: giFTcurs/src/parse.c
diff -u giFTcurs/src/parse.c:1.156 giFTcurs/src/parse.c:1.157
--- giFTcurs/src/parse.c:1.156 Thu Nov 6 18:36:36 2003
+++ giFTcurs/src/parse.c Sun Nov 16 11:15:36 2003
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: parse.c,v 1.156 2003/11/06 23:36:36 weinholt Exp $
+ * $Id: parse.c,v 1.157 2003/11/16 16:15:36 weinholt Exp $
*/
#include "giftcurs.h"
@@ -177,6 +177,7 @@
return NULL;
}
+/* FIXME: make this one recognize G_UNICODE_BREAK_SPACE or something? */
void remove_word(GString *foo, int *posp)
{
int i = *posp;
@@ -380,6 +381,7 @@
for (p = str; *p; p = g_utf8_next_char(p)) {
int w = mk_wcwidth(g_utf8_get_char(p));
+
if (visual == 1 && w == 2 && greedy)
visual--;
else if ((visual -= w) < 0)
Index: giFTcurs/src/ui.c
diff -u giFTcurs/src/ui.c:1.116 giFTcurs/src/ui.c:1.117
--- giFTcurs/src/ui.c:1.116 Thu Nov 6 18:36:36 2003
+++ giFTcurs/src/ui.c Sun Nov 16 11:15:36 2003
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: ui.c,v 1.116 2003/11/06 23:36:36 weinholt Exp $
+ * $Id: ui.c,v 1.117 2003/11/16 16:15:36 weinholt Exp $
*/
#include "giftcurs.h"
@@ -47,6 +47,7 @@
#endif
static int nr_screens = 0;
+int curs_x = 0, curs_y = 0;
gboolean show_buttonbar = 0;
/* These variables tells if an update is scheduled */
@@ -309,6 +310,7 @@
screens[active_screen].methods->draw();
ui_draw_buttonbar();
show_status(NULL);
+ move(curs_y, curs_x);
}
/* This changes position in a list. */
@@ -347,110 +349,9 @@
return foo->sel != old_sel;
}
-/* This handles keys written into a inputbox. */
-int ui_input_handler(GString *foo, int *posp, int *vposp, int key)
+void ui_cursor_move(gint x, gint y)
{
- int ret = 1, pos = *posp;
- int use_utf8;
-
- use_utf8 = utf8 && g_utf8_validate(foo->str, foo->len, NULL);
-
- switch (key) {
- case 0:
- break;
- case KEY_HOME:
- case XCTRL('a'):
- pos = 0;
- break;
- case KEY_END:
- case XCTRL('e'):
- pos = foo->len;
- break;
- case XCTRL('k'):
- g_string_truncate(foo, pos);
- break;
- case XCTRL('u'):
- g_string_erase(foo, 0, pos);
- pos = 0;
- break;
- case XCTRL('w'):
- /* FIXME: make this one recognize G_UNICODE_BREAK_SPACE or
something? */
- remove_word(foo, &pos);
- break;
- case KEY_LEFT:
- if (use_utf8) {
- char *prevc = utf8_find_prev_char(foo->str, foo->str +
pos);
-
- if (!prevc)
- pos = 0;
- else
- pos = prevc - foo->str;
- } else {
- pos--;
- }
- break;
- case KEY_RIGHT:
- if (use_utf8) {
- char *nextc = utf8_find_next_char(foo->str + pos, NULL);
-
- if (!nextc)
- pos = foo->len;
- else
- pos = nextc - foo->str;
- } else {
- pos++;
- }
- break;
- case '\177':
- case '\b':
- case KEY_BACKSPACE:
- case KEY_DC: /* delete char */
- if ((pos == 0 && key != KEY_DC) || (pos == foo->len && key ==
KEY_DC))
- break;
- if (use_utf8) {
- if (key == KEY_DC) {
- char *nextc = utf8_find_next_char(foo->str +
pos, NULL);
- int npos = nextc - foo->str;
-
- g_string_erase(foo, pos, npos - pos);
- } else {
- char *prevc = utf8_find_prev_char(foo->str,
foo->str + pos);
- int npos = prevc - foo->str;
-
- g_string_erase(foo, npos, pos - npos);
- pos = npos;
- }
- } else {
- if (key != KEY_DC)
- pos--;
- g_string_erase(foo, pos, 1);
- }
- break;
- default:
- if (key > 255 || key < ' ') {
- ret = 0;
- break;
- }
- g_string_insert_c(foo, pos, key);
- pos++;
- break;
- }
- if (pos < 0)
- pos = 0;
- else if (pos > foo->len)
- pos = foo->len;
-
- *posp = pos;
- if (use_utf8) {
-#ifdef WIDE_NCURSES
- char *p;
-
- for (p = foo->str, *vposp = 0; *p && p < foo->str + pos; p =
g_utf8_next_char(p))
- *vposp += mk_wcwidth(g_utf8_get_char(p));
-#endif
- } else {
- *vposp = pos;
- }
-
- return ret;
+ curs_x = x;
+ curs_y = y;
+ move(curs_y, curs_x);
}
Index: giFTcurs/src/ui.h
diff -u giFTcurs/src/ui.h:1.45 giFTcurs/src/ui.h:1.46
--- giFTcurs/src/ui.h:1.45 Mon Oct 13 17:42:37 2003
+++ giFTcurs/src/ui.h Sun Nov 16 11:15:36 2003
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: ui.h,v 1.45 2003/10/13 21:42:37 weinholt Exp $
+ * $Id: ui.h,v 1.46 2003/11/16 16:15:36 weinholt Exp $
*/
#ifndef _UI_H
#define _UI_H
@@ -39,6 +39,7 @@
} ui_methods;
extern gboolean show_buttonbar;
+extern int curs_x, curs_y;
#ifndef NDEBUG
extern int active_screen; /* only for debugging! */
@@ -57,8 +58,9 @@
void ui_handler(int key);
int ui_list_handler(list *foo, int key, int page_len);
-int ui_input_handler(GString *foo, int *pos, int *vposp, int key);
void ui_draw(void);
+
+void ui_cursor_move(gint x, gint y);
#endif
Index: giFTcurs/src/ui_draw.c
diff -u giFTcurs/src/ui_draw.c:1.114 giFTcurs/src/ui_draw.c:1.115
--- giFTcurs/src/ui_draw.c:1.114 Tue Nov 4 18:29:45 2003
+++ giFTcurs/src/ui_draw.c Sun Nov 16 11:15:36 2003
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: ui_draw.c,v 1.114 2003/11/04 23:29:45 weinholt Exp $
+ * $Id: ui_draw.c,v 1.115 2003/11/16 16:15:36 weinholt Exp $
*/
#include "giftcurs.h"
@@ -83,46 +83,6 @@
g_free(s);
}
-/* Returns the x-position of the end of the printed value */
-int draw_input(int x, int y, int w, const char *header, const char *value, int
attr)
-{
- int p;
- int print; /* This is how many
columns from "value" we can print */
-
- move(y, x);
- if (header) {
- attrset(COLOR_PAIR(COLOR_HEADER) | A_BOLD);
- addstr(header);
- addstr(": ");
- }
-
- /* Decoration */
- attrset(attr);
- addch('[');
- getyx(stdscr, y, p);
- attrset(COLOR_PAIR(COLOR_STAT_DATA));
- hline('_', x + w - p - 1); /* Trailing '_' */
- move(y, x + w - 1);
- attrset(attr);
- addch(']');
-
- /* Value */
- attrset(COLOR_PAIR(COLOR_STAT_DATA));
- print = w - p;
- if (utf8) {
- const char *i = value;
- int len;
-
- for (len = 0; *i && len < print; i = g_utf8_next_char(i))
- len += g_unichar_iswide(g_utf8_get_char(i)) ? 2 : 1;
-
- print = i - value;
- }
- mvaddnstr(y, p, value, print);
-
- return p;
-}
-
G_INLINE_FUNC int selection_color(int selected, int color)
{
if (INVERT_SEL)
@@ -165,9 +125,9 @@
continue;
}
- /* No printing control-chars here */
- if ((unsigned char) *u < 32 || ((unsigned char) *u >= 0x7f &&
(unsigned char) *u < 0xa0)) {
- addch(' ');
+ if (((unsigned char) *u >= 0x7f && (unsigned char) *u < 0xa0)) {
+ /* Filter out C1 (8-bit) control characters */
+ addch('?');
printed++;
} else {
if (utf8) {
@@ -179,14 +139,22 @@
wch[0] = g_utf8_get_char_validated(u, -1);
wch[1] = L'\0';
if (wch[0] < 0)
- continue; /* invalid
utf-8 sequence */
+ continue; /* invalid utf-8
sequence */
+ if (wch[0] < 32)
+ wch[0] = 0x2400 + wch[0]; /*
control char symbols */
setcchar(&cc, wch, A_NORMAL, 0, NULL);
add_wch(&cc);
printed += mk_wcwidth(wch[0]);
u = g_utf8_next_char(u) - 1;
#endif
} else {
- addnstr(u, 1);
+ if ((unsigned char) *u < 32) {
+ /* Represent control chars as e.g. ^G */
+ addch('^');
+ addch(*u + 64);
+ printed++;
+ } else
+ addnstr(u, 1);
printed++;
}
}
Index: giFTcurs/src/ui_draw.h
diff -u giFTcurs/src/ui_draw.h:1.43 giFTcurs/src/ui_draw.h:1.44
--- giFTcurs/src/ui_draw.h:1.43 Fri Oct 31 19:11:34 2003
+++ giFTcurs/src/ui_draw.h Sun Nov 16 11:15:37 2003
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: ui_draw.h,v 1.43 2003/11/01 00:11:34 saturn Exp $
+ * $Id: ui_draw.h,v 1.44 2003/11/16 16:15:37 weinholt Exp $
*/
#ifndef _UI_DRAW_H
#define _UI_DRAW_H
@@ -35,7 +35,6 @@
/* mkpretty is a function that generates the string if it is NULL */
void draw_list_pretty(int x, int y, int w, int h, int draw_sel, list *snafu);
void draw_box(int x, int y, int w, int h, const char *title, int attr);
-int draw_input(int x, int y, int w, const char *header, const char *value, int
attr);
void draw_button(int x, int y, const char *str, int attr
#ifdef MOUSE
, MFunc callback, void *data
Index: giFTcurs/src/ui_main.c
diff -u giFTcurs/src/ui_main.c:1.349 giFTcurs/src/ui_main.c:1.350
--- giFTcurs/src/ui_main.c:1.349 Sat Oct 18 09:20:10 2003
+++ giFTcurs/src/ui_main.c Sun Nov 16 11:15:37 2003
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: ui_main.c,v 1.349 2003/10/18 13:20:10 saturn Exp $
+ * $Id: ui_main.c,v 1.350 2003/11/16 16:15:37 weinholt Exp $
*/
#include "giftcurs.h"
@@ -36,6 +36,7 @@
#include "ui.h"
#include "ui_draw.h"
#include "ui_main.h"
+#include "ui_input.h"
#include "get.h"
#include "format.h"
#include "settings.h"
@@ -54,15 +55,13 @@
};
static int active_field = FIELD_SEARCH_TERM;
-static GString search_term = { 0 };
-static unsigned int search_pos = 0, search_vpos = 0;
-static int curs_x, curs_y;
static list search_realm = LIST_INITIALIZER;
-static GString slash_search_term = { 0 };
static char *last_search_term = NULL;
-static int slash_search_pos, slash_search_vpos;
static format_t hit_fmt;
static format_t subhit_fmt;
+static ui_input search_input = { 0 };
+static ui_input slash_input = { 0 };
+static ui_input realm_input = { 0 };
static const ui_methods main_screen_methods;
@@ -136,9 +135,11 @@
search_realm.sel = 0;
active_field = 0;
- /* initialize the GStrings */
- g_string_append(&search_term, "");
- g_string_append(&slash_search_term, "");
+ /* initialize the ui_input's */
+ ui_input_init(&search_input);
+ ui_input_init(&slash_input);
+ ui_input_init(&realm_input);
+ ui_input_assign(&realm_input, list_selected(&search_realm));
/* Load the default formats */
format_load("$expanded", "{if expanded}-{else}+{endif}");
@@ -180,8 +181,9 @@
static void main_screen_destroy(void)
{
gift_unregister(NULL, (EventCallback) detach_handle, NULL);
- g_free(slash_search_term.str);
- g_free(search_term.str);
+ ui_input_deinit(&search_input);
+ ui_input_deinit(&slash_input);
+ ui_input_deinit(&realm_input);
list_remove_all(&search_realm);
gift_search_cleanup();
format_unref(hit_fmt);
@@ -204,16 +206,12 @@
int i;
query *q;
- /* trim it and make cursor inside */
- trim(search_term.str);
- g_string_set_size(&search_term, strlen(search_term.str));
- search_pos = search_term.len;
/* add query to history if it's not already there */
/* skip the last dummy entry */
for (i = 0; i < queries.num - 1; i++) {
q = list_index(&queries, i);
- if (!strcmp(search_term.str, q->search_term) &&
search_realm.sel == q->realm) {
+ if (!strcmp(search_input.str->str, q->search_term) &&
search_realm.sel == q->realm) {
queries.sel = i;
gift_query_stop(q);
/* This line is commented out because some protocols
return more
@@ -224,7 +222,7 @@
}
/* create a new query structure and append to list */
- q = new_query(search_term.str, search_realm.sel);
+ q = new_query(search_input.str->str, search_realm.sel);
q->formatting = browse ? format_get("browse", NULL) : NULL;
q->callback = my_screen_nr | 0200;
@@ -241,7 +239,7 @@
query *q;
ntree *packet = NULL;
- g_string_assign(&search_term, user);
+ ui_input_assign(&search_input, user);
search_realm.sel = 6; /* BROWSE */
q = prepare_search(1);
@@ -309,7 +307,7 @@
{
query *q = HITS;
int prev, i;
- char *pattern = slash_search_term.str;
+ char *pattern = slash_input.str->str;
hit *h;
list *l;
@@ -347,7 +345,7 @@
h = list_index(l, i);
if (stristr(h->filename, pattern)) {
tree_select_top(q, i);
- show_status(slash_search_term.str);
+ show_status(slash_input.str->str);
return;
}
}
@@ -399,18 +397,18 @@
query *q;
case FIELD_SEARCH_TERM:
- if (!ui_input_handler(&search_term, &search_pos, &search_vpos,
key))
+ if (!ui_input_handler(&search_input, key))
if (ui_list_handler(&queries, key, 5)) {
q = list_selected(&queries);
- g_string_assign(&search_term, q->search_term);
- search_pos = search_term.len; /* place cursor
at the end */
+ ui_input_assign(&search_input, q->search_term);
search_realm.sel = q->realm;
+ ui_input_assign(&realm_input,
list_selected(&search_realm));
incoming_search_item();
}
/* Check values */
- ui_input_handler(&search_term, &search_pos, &search_vpos, 0);
- if (key == KEY_ENTER && search_term.len) {
+ ui_input_validate(&search_input);
+ if (key == KEY_ENTER && search_input.str->len) {
active_field = FIELD_SEARCH_BUTTON;
start_search_pressed();
main_screen_update_results();
@@ -422,7 +420,8 @@
case FIELD_SEARCH_REALM:
if (ui_list_handler(&search_realm, key, 1)) {
list_check_values(&search_realm, 1);
- } else if (key == KEY_ENTER && search_term.len) {
+ ui_input_assign(&realm_input,
list_selected(&search_realm));
+ } else if (key == KEY_ENTER && search_input.str->len) {
active_field = FIELD_SEARCH_BUTTON;
start_search_pressed();
main_screen_update_results();
@@ -495,9 +494,10 @@
} else if (key == '/' || key == '?') {
active_field = FIELD_STATUSBAR;
g_free(last_search_term);
- last_search_term = g_strdup(slash_search_term.str);
- g_string_printf(&slash_search_term, "%c", key);
- slash_search_pos = slash_search_vpos = 1;
+ last_search_term = g_strdup(slash_input.str->str);
+ ui_input_init(&slash_input);
+ ui_input_handler(&slash_input, key);
+ ui_input_validate(&slash_input);
main_screen_update_results();
} else if (key == 'n' || key == 'N') {
slash_find_next(key == 'n' ? 1 : -1);
@@ -536,13 +536,14 @@
refresh();
return 1;
case FIELD_STATUSBAR:
- if (!ui_input_handler(&slash_search_term, &slash_search_pos,
&slash_search_vpos, key)) {
+ if (!ui_input_handler(&slash_input, key)) {
active_field = FIELD_RESULT_LIST;
- if (!slash_search_term.str[0] ||
!slash_search_term.str[1])
- g_string_assign(&slash_search_term,
last_search_term);
+ if (!slash_input.str->str[0] ||
!slash_input.str->str[1])
+ ui_input_assign(&slash_input, last_search_term);
if (PRESSED(key))
slash_find_next(1);
}
+ ui_input_validate(&slash_input);
main_screen_update_results();
refresh();
return 1;
@@ -584,7 +585,7 @@
draw_box(0, STAT_BOX_H, max_x, RESULT_H + 2, _("Search Results"),
COLOR(COLOR_RESULT_BOX, FIELD_RESULT_LIST));
if (active_field == FIELD_RESULT_LIST)
- curs_x = curs_y = 0;
+ ui_cursor_move(0, 0);
main_screen_update_results();
mouse_register(0, STAT_BOX_H, max_x, RESULT_H + 2, BUTTON1_PRESSED,
mouse_resultclick, NULL, 0);
mouse_register(0, STAT_BOX_H, max_x, RESULT_H + 2,
BUTTON1_DOUBLE_CLICKED,
@@ -600,26 +601,6 @@
move(curs_y, curs_x);
}
-static void draw_input_special(int x, int y, int w, const char *header, const
char *value,
- int field, int pos)
-{
- int xx, offset = 0, headlen = vstrlen(header);
-
- if (active_field == field && pos > w - headlen - 5)
- offset = pos - (w - headlen - 5);
-
- xx = draw_input(x, y, w, header, value + offset,
COLOR(COLOR_SEARCH_BOX, field));
-
- if (active_field == field) {
- curs_x = xx;
- if (pos >= 0)
- curs_x = x + pos - offset + headlen + 3;
- getyx(stdscr, curs_y, xx);
- curs_set(1);
- leaveok(stdscr, FALSE);
- }
-}
-
static void main_screen_update_searchbox(void)
{
int len;
@@ -627,11 +608,11 @@
curs_set(0);
leaveok(stdscr, TRUE);
- draw_input_special(2, 1, SEARCH_BOX_W - 4, _("Query"),
- search_term.str, FIELD_SEARCH_TERM,
search_vpos);
+ ui_input_draw(2, 1, SEARCH_BOX_W - 4, COLOR(COLOR_SEARCH_BOX,
FIELD_SEARCH_TERM), _("Query"),
+ &search_input, active_field ==
FIELD_SEARCH_TERM);
- draw_input_special(2, 2, SEARCH_BOX_W - 4, _("Realm"),
- list_selected(&search_realm),
FIELD_SEARCH_REALM, -1);
+ ui_input_draw(2, 2, SEARCH_BOX_W - 4, COLOR(COLOR_SEARCH_BOX,
FIELD_SEARCH_REALM), _("Realm"),
+ &realm_input, active_field ==
FIELD_SEARCH_REALM);
len = vstrlen(_("Query"));
mouse_register(len + 4, 1, max_x - STAT_BOX_W - len - 8, 1,
BUTTON1_PRESSED, mouse_inputclick,
@@ -827,9 +808,8 @@
addch(ACS_HLINE);
if (active_field == FIELD_STATUSBAR) {
- show_status(slash_search_term.str);
- curs_y = max_y - 1 - show_buttonbar;
- curs_x = slash_search_vpos;
+ show_status(slash_input.str->str);
+ ui_cursor_move(slash_input.vpos, max_y - 1 - show_buttonbar);
curs_set(1);
leaveok(stdscr, FALSE);
} else if (active_field == FIELD_RESULT_LIST) {
@@ -929,10 +909,8 @@
g_assert(active_screen == my_screen_nr);
- if (field == FIELD_SEARCH_TERM) {
- search_pos = rx - 1;
- ui_input_handler(&search_term, &search_pos, &search_vpos, 0);
- }
+ if (field == FIELD_SEARCH_TERM)
+ ui_input_setvpos(&search_input, rx - 1);
active_field = field;
main_screen_draw();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [giFTcurs-commits] giFTcurs/src .indent.pro Makefile.am giftcurs.h...,
Göran Weinholt <=