summaryrefslogtreecommitdiff
path: root/src/gui/curses
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2005-07-09 15:30:51 +0000
committerSebastien Helleu <flashcode@flashtux.org>2005-07-09 15:30:51 +0000
commit54d4fc12a69ca6398f8f5d41d73bba22cf6788aa (patch)
tree1ec405acd240e1b3b9ac69ba4ded5e35028bda05 /src/gui/curses
parent55125beee4aa5489f6976521f8ac899398fea836 (diff)
downloadweechat-54d4fc12a69ca6398f8f5d41d73bba22cf6788aa.zip
- new keyboard management: keys are setup in config file, new command /key was added and some new default keys were added
- added seconds in infobar time (optional with new config flag) - fixed some curses refreshs
Diffstat (limited to 'src/gui/curses')
-rw-r--r--src/gui/curses/Makefile.am4
-rw-r--r--src/gui/curses/gui-display.c310
-rw-r--r--src/gui/curses/gui-input.c778
3 files changed, 293 insertions, 799 deletions
diff --git a/src/gui/curses/Makefile.am b/src/gui/curses/Makefile.am
index 01eaaa35d..4bef0cdc9 100644
--- a/src/gui/curses/Makefile.am
+++ b/src/gui/curses/Makefile.am
@@ -19,7 +19,7 @@ INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\"
bin_PROGRAMS = weechat-curses
-weechat_curses_LDADD = ../lib_weechat_gui_common.a \
+weechat_curses_LDADD = ../gui-common.o ../gui-keyboard.o \
../../common/lib_weechat_main.a \
../../irc/lib_weechat_irc.a \
$(NCURSES_LIBS) \
@@ -27,4 +27,4 @@ weechat_curses_LDADD = ../lib_weechat_gui_common.a \
$(GNUTLS_LIBS)
weechat_curses_SOURCES = gui-display.c \
- gui-input.c
+ gui-input.c
diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c
index a9873c601..6bfef6c0c 100644
--- a/src/gui/curses/gui-display.c
+++ b/src/gui/curses/gui-display.c
@@ -318,7 +318,7 @@ gui_draw_window_separator (t_gui_window *window)
window->win_x - 1);
gui_window_set_color (window->win_separator, COLOR_WIN_TITLE);
wborder (window->win_separator, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
- wrefresh (window->win_separator);
+ wnoutrefresh (window->win_separator);
refresh ();
}
}
@@ -341,15 +341,9 @@ gui_draw_buffer_title (t_gui_buffer *buffer, int erase)
if (ptr_win->buffer == buffer)
{
if (erase)
- gui_curses_window_clear (ptr_win->win_title);
+ gui_curses_window_clear (ptr_win->win_title);
- if (has_colors ())
- {
- gui_window_set_color (ptr_win->win_title, COLOR_WIN_TITLE);
- wborder (ptr_win->win_title, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
- wrefresh (ptr_win->win_title);
- refresh ();
- }
+ gui_window_set_color (ptr_win->win_title, COLOR_WIN_TITLE);
snprintf (format, 32, "%%-%ds", ptr_win->win_width);
if (CHANNEL(buffer))
{
@@ -362,6 +356,8 @@ gui_draw_buffer_title (t_gui_buffer *buffer, int erase)
mvwprintw (ptr_win->win_title, 0, 0, format, buf);
free (buf);
}
+ else
+ mvwprintw (ptr_win->win_title, 0, 0, format, " ");
}
else
{
@@ -372,8 +368,10 @@ gui_draw_buffer_title (t_gui_buffer *buffer, int erase)
PACKAGE_STRING " " WEECHAT_COPYRIGHT_DATE " - "
WEECHAT_WEBSITE);
}
+ else
+ mvwprintw (ptr_win->win_title, 0, 0, format, " ");
}
- wrefresh (ptr_win->win_title);
+ wnoutrefresh (ptr_win->win_title);
refresh ();
}
}
@@ -860,7 +858,7 @@ gui_draw_buffer_chat (t_gui_buffer *buffer, int erase)
ptr_win->win_chat_cursor_y = ptr_win->win_chat_height - 1;
}
}
- wrefresh (ptr_win->win_chat);
+ wnoutrefresh (ptr_win->win_chat);
refresh ();
}
}
@@ -1058,7 +1056,7 @@ gui_draw_buffer_nick (t_gui_buffer *buffer, int erase)
}
}
}
- wrefresh (ptr_win->win_nick);
+ wnoutrefresh (ptr_win->win_nick);
refresh ();
}
}
@@ -1087,12 +1085,8 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase)
if (erase)
gui_curses_window_clear (ptr_win->win_status);
- if (has_colors ())
- {
- gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS);
- wborder (ptr_win->win_status, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
- wrefresh (ptr_win->win_status);
- }
+ gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS);
+ wborder (ptr_win->win_status, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
wmove (ptr_win->win_status, 0, 0);
/* display number of buffers */
@@ -1224,17 +1218,20 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase)
if (!SERVER(ptr_win->buffer))
{
gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS);
+ wprintw (ptr_win->win_status, "%d",
+ ptr_win->buffer->number);
+ gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS_DELIMITERS);
+ wprintw (ptr_win->win_status, ":");
+ gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS);
if (ptr_win->buffer->dcc)
- wprintw (ptr_win->win_status, "%d:<DCC> ",
- ptr_win->buffer->number);
+ wprintw (ptr_win->win_status, "<DCC> ");
else
{
string = weechat_convert_encoding (cfg_look_charset_decode,
(cfg_look_charset_internal && cfg_look_charset_internal[0]) ?
cfg_look_charset_internal : local_charset,
- _("%d:[not connected] "));
- wprintw (ptr_win->win_status, string,
- ptr_win->buffer->number);
+ _("[not connected]"));
+ wprintw (ptr_win->win_status, "%s " , string);
free (string);
}
}
@@ -1344,12 +1341,49 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase)
}
free (string);
- wrefresh (ptr_win->win_status);
+ wnoutrefresh (ptr_win->win_status);
refresh ();
}
}
/*
+ * gui_draw_buffer_infobar_time: draw time in infobar window
+ */
+
+void
+gui_draw_buffer_infobar_time (t_gui_buffer *buffer)
+{
+ t_gui_window *ptr_win;
+ time_t time_seconds;
+ struct tm *local_time;
+
+ /* make gcc happy */
+ (void) buffer;
+
+ if (!gui_ok)
+ return;
+
+ for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
+ {
+ time_seconds = time (NULL);
+ local_time = localtime (&time_seconds);
+ if (local_time)
+ {
+ gui_window_set_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR);
+ mvwprintw (ptr_win->win_infobar,
+ 0, 1,
+ "%02d:%02d",
+ local_time->tm_hour, local_time->tm_min);
+ if (cfg_look_infobar_seconds)
+ wprintw (ptr_win->win_infobar,
+ ":%02d",
+ local_time->tm_sec);
+ }
+ wnoutrefresh (ptr_win->win_infobar);
+ }
+}
+
+/*
* gui_draw_buffer_infobar: draw infobar window for a buffer
*/
@@ -1376,7 +1410,7 @@ gui_draw_buffer_infobar (t_gui_buffer *buffer, int erase)
{
gui_window_set_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR);
wborder (ptr_win->win_infobar, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
- wrefresh (ptr_win->win_infobar);
+ wnoutrefresh (ptr_win->win_infobar);
}
wmove (ptr_win->win_infobar, 0, 0);
@@ -1385,16 +1419,31 @@ gui_draw_buffer_infobar (t_gui_buffer *buffer, int erase)
if (local_time)
{
strftime (text_time, 1024, cfg_look_infobar_timestamp, local_time);
+ gui_window_set_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS);
+ wprintw (ptr_win->win_infobar, "[");
+ gui_window_set_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR);
+ wprintw (ptr_win->win_infobar,
+ "%02d:%02d",
+ local_time->tm_hour, local_time->tm_min);
+ if (cfg_look_infobar_seconds)
+ wprintw (ptr_win->win_infobar,
+ ":%02d",
+ local_time->tm_sec);
+ gui_window_set_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS);
+ wprintw (ptr_win->win_infobar, "]");
gui_window_set_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR);
- wprintw (ptr_win->win_infobar, "%s", text_time);
+ wprintw (ptr_win->win_infobar,
+ " %s", text_time);
}
if (gui_infobar)
{
+ gui_window_set_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS);
+ wprintw (ptr_win->win_infobar, " | ");
gui_window_set_color (ptr_win->win_infobar, gui_infobar->color);
- wprintw (ptr_win->win_infobar, " | %s", gui_infobar->text);
+ wprintw (ptr_win->win_infobar, "%s", gui_infobar->text);
}
- wrefresh (ptr_win->win_infobar);
+ wnoutrefresh (ptr_win->win_infobar);
refresh ();
}
}
@@ -1445,7 +1494,7 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
{
gui_window_set_color (ptr_win->win_input, COLOR_WIN_INPUT);
wborder (ptr_win->win_input, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
- wrefresh (ptr_win->win_input);
+ wnoutrefresh (ptr_win->win_input);
}
if (buffer->input_buffer_size == 0)
@@ -1488,11 +1537,12 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
SERVER(buffer)->nick,
"");
wclrtoeol (ptr_win->win_input);
+ ptr_win->win_input_x = strlen (CHANNEL(buffer)->name) +
+ strlen (SERVER(buffer)->nick) + 3 +
+ (buffer->input_buffer_pos - buffer->input_buffer_1st_display);
if (ptr_win == gui_current_window)
move (ptr_win->win_y + ptr_win->win_height - 1,
- ptr_win->win_x + strlen (CHANNEL(buffer)->name) +
- strlen (SERVER(buffer)->nick) + 3 +
- (buffer->input_buffer_pos - buffer->input_buffer_1st_display));
+ ptr_win->win_x + ptr_win->win_input_x);
}
else
{
@@ -1523,6 +1573,7 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
wprintw (ptr_win->win_input, _(" [P] Purge old DCC"));
wprintw (ptr_win->win_input, _(" [Q] Close DCC view"));
wclrtoeol (ptr_win->win_input);
+ ptr_win->win_input_x = 0;
if (ptr_win == gui_current_window)
move (ptr_win->win_y + ptr_win->win_height - 1,
ptr_win->win_x);
@@ -1543,14 +1594,15 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
ptr_nickname,
"");
wclrtoeol (ptr_win->win_input);
+ ptr_win->win_input_x = strlen (ptr_nickname) + 2 +
+ (buffer->input_buffer_pos - buffer->input_buffer_1st_display);
if (ptr_win == gui_current_window)
move (ptr_win->win_y + ptr_win->win_height - 1,
- ptr_win->win_x + strlen (ptr_nickname) + 2 +
- (buffer->input_buffer_pos - buffer->input_buffer_1st_display));
+ ptr_win->win_x + ptr_win->win_input_x);
}
}
- wrefresh (ptr_win->win_input);
+ wnoutrefresh (ptr_win->win_input);
refresh ();
}
}
@@ -1728,215 +1780,143 @@ gui_switch_to_dcc_buffer ()
}
/*
- * gui_switch_to_previous_buffer: switch to previous buffer
- */
-
-void
-gui_switch_to_previous_buffer (t_gui_window *window)
-{
- if (!gui_ok)
- return;
-
- /* if only one buffer then return */
- if (gui_buffers == last_gui_buffer)
- return;
-
- if (window->buffer->prev_buffer)
- gui_switch_to_buffer (window, window->buffer->prev_buffer);
- else
- gui_switch_to_buffer (window, last_gui_buffer);
-
- gui_redraw_buffer (window->buffer);
-}
-
-/*
- * gui_switch_to_next_buffer: switch to next buffer
- */
-
-void
-gui_switch_to_next_buffer (t_gui_window *window)
-{
- if (!gui_ok)
- return;
-
- /* if only one buffer then return */
- if (gui_buffers == last_gui_buffer)
- return;
-
- if (window->buffer->next_buffer)
- gui_switch_to_buffer (window, window->buffer->next_buffer);
- else
- gui_switch_to_buffer (window, gui_buffers);
-
- gui_redraw_buffer (window->buffer);
-}
-
-/*
- * gui_switch_to_previous_window: switch to previous window
- */
-
-void
-gui_switch_to_previous_window (t_gui_window *window)
-{
- if (!gui_ok)
- return;
-
- /* if only one window then return */
- if (gui_windows == last_gui_window)
- return;
-
- gui_current_window = (window->prev_window) ? window->prev_window : last_gui_window;
- gui_switch_to_buffer (gui_current_window, gui_current_window->buffer);
- gui_redraw_buffer (gui_current_window->buffer);
-}
-
-/*
- * gui_switch_to_next_window: switch to next window
+ * gui_input_page_up: display previous page on buffer
*/
void
-gui_switch_to_next_window (t_gui_window *window)
+gui_input_page_up ()
{
if (!gui_ok)
return;
- /* if only one window then return */
- if (gui_windows == last_gui_window)
- return;
-
- gui_current_window = (window->next_window) ? window->next_window : gui_windows;
- gui_switch_to_buffer (gui_current_window, gui_current_window->buffer);
- gui_redraw_buffer (gui_current_window->buffer);
-}
-
-/*
- * gui_move_page_up: display previous page on buffer
- */
-
-void
-gui_move_page_up (t_gui_window *window)
-{
- if (!gui_ok)
- return;
-
- if (!window->first_line_displayed)
+ if (!gui_current_window->first_line_displayed)
{
- window->sub_lines += window->win_chat_height - 1;
- gui_draw_buffer_chat (window->buffer, 0);
- gui_draw_buffer_status (window->buffer, 0);
+ gui_current_window->sub_lines +=
+ gui_current_window->win_chat_height - 1;
+ gui_draw_buffer_chat (gui_current_window->buffer, 0);
+ gui_draw_buffer_status (gui_current_window->buffer, 0);
}
}
/*
- * gui_move_page_down: display next page on buffer
+ * gui_input_page_down: display next page on buffer
*/
void
-gui_move_page_down (t_gui_window *window)
+gui_input_page_down ()
{
if (!gui_ok)
return;
- if (window->sub_lines > 0)
+ if (gui_current_window->sub_lines > 0)
{
- window->sub_lines -= window->win_chat_height - 1;
- if (window->sub_lines < 0)
- window->sub_lines = 0;
- gui_draw_buffer_chat (window->buffer, 0);
- gui_draw_buffer_status (window->buffer, 0);
+ gui_current_window->sub_lines -=
+ gui_current_window->win_chat_height - 1;
+ if (gui_current_window->sub_lines < 0)
+ gui_current_window->sub_lines = 0;
+ gui_draw_buffer_chat (gui_current_window->buffer, 0);
+ gui_draw_buffer_status (gui_current_window->buffer, 0);
}
}
/*
- * gui_nick_move_beginning: go to beginning of nicklist
+ * gui_input_nick_beginning: go to beginning of nicklist
*/
void
-gui_nick_move_beginning (t_gui_window *window)
+gui_input_nick_beginning ()
{
if (!gui_ok)
return;
- if (gui_buffer_has_nicklist (window->buffer))
+ if (gui_buffer_has_nicklist (gui_current_window->buffer))
{
- if (window->win_nick_start > 0)
+ if (gui_current_window->win_nick_start > 0)
{
- window->win_nick_start = 0;
- gui_draw_buffer_nick (window->buffer, 1);
+ gui_current_window->win_nick_start = 0;
+ gui_draw_buffer_nick (gui_current_window->buffer, 1);
}
}
}
/*
- * gui_nick_move_end: go to the end of nicklist
+ * gui_input_nick_end: go to the end of nicklist
*/
void
-gui_nick_move_end (t_gui_window *window)
+gui_input_nick_end ()
{
int new_start;
if (!gui_ok)
return;
- if (gui_buffer_has_nicklist (window->buffer))
+ if (gui_buffer_has_nicklist (gui_current_window->buffer))
{
- new_start = CHANNEL(window->buffer)->nicks_count - window->win_nick_height;
+ new_start =
+ CHANNEL(gui_current_window->buffer)->nicks_count -
+ gui_current_window->win_nick_height;
if (new_start < 0)
new_start = 0;
else if (new_start >= 1)
new_start++;
- if (new_start != window->win_nick_start)
+ if (new_start != gui_current_window->win_nick_start)
{
- window->win_nick_start = new_start;
- gui_draw_buffer_nick (window->buffer, 1);
+ gui_current_window->win_nick_start = new_start;
+ gui_draw_buffer_nick (gui_current_window->buffer, 1);
}
}
}
/*
- * gui_nick_move_page_up: scroll one page up in nicklist
+ * gui_input_nick_page_up: scroll one page up in nicklist
*/
void
-gui_nick_move_page_up (t_gui_window *window)
+gui_input_nick_page_up ()
{
if (!gui_ok)
return;
- if (gui_buffer_has_nicklist (window->buffer))
+ if (gui_buffer_has_nicklist (gui_current_window->buffer))
{
- if (window->win_nick_start > 0)
+ if (gui_current_window->win_nick_start > 0)
{
- window->win_nick_start -= (window->win_nick_height - 1);
- if (window->win_nick_start <= 1)
- window->win_nick_start = 0;
- gui_draw_buffer_nick (window->buffer, 1);
+ gui_current_window->win_nick_start -=
+ (gui_current_window->win_nick_height - 1);
+ if (gui_current_window->win_nick_start <= 1)
+ gui_current_window->win_nick_start = 0;
+ gui_draw_buffer_nick (gui_current_window->buffer, 1);
}
}
}
/*
- * gui_nick_move_page_down: scroll one page down in nicklist
+ * gui_input_nick_page_down: scroll one page down in nicklist
*/
void
-gui_nick_move_page_down (t_gui_window *window)
+gui_input_nick_page_down ()
{
if (!gui_ok)
return;
- if (gui_buffer_has_nicklist (window->buffer))
+ if (gui_buffer_has_nicklist (gui_current_window->buffer))
{
- if ((CHANNEL(window->buffer)->nicks_count > window->win_nick_height)
- && (window->win_nick_start + window->win_nick_height - 1 < CHANNEL(window->buffer)->nicks_count))
+ if ((CHANNEL(gui_current_window->buffer)->nicks_count >
+ gui_current_window->win_nick_height)
+ && (gui_current_window->win_nick_start +
+ gui_current_window->win_nick_height - 1
+ < CHANNEL(gui_current_window->buffer)->nicks_count))
{
- if (window->win_nick_start == 0)
- window->win_nick_start += (window->win_nick_height - 1);
+ if (gui_current_window->win_nick_start == 0)
+ gui_current_window->win_nick_start +=
+ (gui_current_window->win_nick_height - 1);
else
- window->win_nick_start += (window->win_nick_height - 2);
- gui_draw_buffer_nick (window->buffer, 1);
+ gui_current_window->win_nick_start +=
+ (gui_current_window->win_nick_height - 2);
+ gui_draw_buffer_nick (gui_current_window->buffer, 1);
}
}
}
@@ -2306,6 +2286,8 @@ gui_init_colors ()
cfg_col_status_more, cfg_col_status_bg);
init_pair (COLOR_WIN_INFOBAR,
cfg_col_infobar, cfg_col_infobar_bg);
+ init_pair (COLOR_WIN_INFOBAR_DELIMITERS,
+ cfg_col_infobar_delimiters, cfg_col_infobar_bg);
init_pair (COLOR_WIN_INFOBAR_HIGHLIGHT,
cfg_col_infobar_highlight, cfg_col_infobar_bg);
init_pair (COLOR_WIN_INPUT,
@@ -2378,6 +2360,7 @@ gui_init_colors ()
color_attr[COLOR_WIN_STATUS_DATA_OTHER - 1] = (cfg_col_status_data_other >= 0) ? cfg_col_status_data_other & A_BOLD : 0;
color_attr[COLOR_WIN_STATUS_MORE - 1] = (cfg_col_status_more >= 0) ? cfg_col_status_more & A_BOLD : 0;
color_attr[COLOR_WIN_INFOBAR - 1] = (cfg_col_infobar >= 0) ? cfg_col_infobar & A_BOLD : 0;
+ color_attr[COLOR_WIN_INFOBAR_DELIMITERS - 1] = (cfg_col_infobar_delimiters >= 0) ? cfg_col_infobar_delimiters & A_BOLD : 0;
color_attr[COLOR_WIN_INFOBAR_HIGHLIGHT - 1] = (cfg_col_infobar_highlight >= 0) ? cfg_col_infobar_highlight & A_BOLD : 0;
color_attr[COLOR_WIN_INPUT - 1] = (cfg_col_input >= 0) ? cfg_col_input & A_BOLD : 0;
color_attr[COLOR_WIN_INPUT_CHANNEL - 1] = (cfg_col_input_channel >= 0) ? cfg_col_input_channel & A_BOLD : 0;
@@ -2427,15 +2410,16 @@ gui_init ()
initscr ();
curs_set (1);
- keypad (stdscr, TRUE);
noecho ();
nodelay (stdscr, TRUE);
gui_init_colors ();
-
+
gui_infobar = NULL;
gui_ok = ((COLS > 5) && (LINES > 5));
+
+ refresh ();
/* create new window/buffer */
if (gui_window_new (0, 0, COLS, LINES))
diff --git a/src/gui/curses/gui-input.c b/src/gui/curses/gui-input.c
index 89793d4ee..85eda8858 100644
--- a/src/gui/curses/gui-input.c
+++ b/src/gui/curses/gui-input.c
@@ -41,649 +41,151 @@
#include "../../common/fifo.h"
#include "../../irc/irc.h"
-#define KEY_ESCAPE 27
/*
- * gui_read_keyb: read keyboard line
+ * gui_input_default_key_bindings: create default key bindings
*/
void
-gui_read_keyb ()
+gui_input_default_key_bindings ()
{
- int key, i;
- t_gui_buffer *ptr_buffer;
- t_irc_server *ptr_server;
- t_irc_dcc *ptr_dcc, *ptr_dcc_next;
- char new_char[3], *decoded_string;
- t_irc_dcc *dcc_selected;
+ int i;
+ char key_str[32], command[32];
+
+ /* keys binded with internal functions */
+ gui_key_bind ( /* RC */ "ctrl-M", "return");
+ gui_key_bind ( /* RC */ "ctrl-J", "return");
+ gui_key_bind ( /* tab */ "ctrl-I", "tab");
+ gui_key_bind ( /* basckp */ "ctrl-H", "backspace");
+ gui_key_bind ( /* basckp */ "ctrl-?", "backspace");
+ gui_key_bind ( /* del */ "meta2-3~", "delete");
+ gui_key_bind ( /* ^K */ "ctrl-K", "delete_end_line");
+ gui_key_bind ( /* ^U */ "ctrl-U", "delete_beginning_line");
+ gui_key_bind ( /* ^W */ "ctrl-W", "delete_previous_word");
+ gui_key_bind ( /* home */ "meta2-1~", "home");
+ gui_key_bind ( /* home */ "meta2-H", "home");
+ gui_key_bind ( /* home */ "meta2-7~", "home");
+ gui_key_bind ( /* ^A */ "ctrl-A", "home");
+ gui_key_bind ( /* end */ "meta2-4~", "end");
+ gui_key_bind ( /* end */ "meta2-F", "end");
+ gui_key_bind ( /* end */ "meta2-8~", "end");
+ gui_key_bind ( /* ^E */ "ctrl-E", "end");
+ gui_key_bind ( /* left */ "meta2-D", "left");
+ gui_key_bind ( /* right */ "meta2-C", "right");
+ gui_key_bind ( /* up */ "meta2-A", "up");
+ gui_key_bind ( /* down */ "meta2-B", "down");
+ gui_key_bind ( /* pgup */ "meta2-5~", "page_up");
+ gui_key_bind ( /* pgdn */ "meta2-6~", "page_down");
+ gui_key_bind ( /* F10 */ "meta2-21~", "infobar_clear");
+ gui_key_bind ( /* F11 */ "meta2-23~", "nick_page_up");
+ gui_key_bind ( /* F12 */ "meta2-24~", "nick_page_down");
+ gui_key_bind ( /* m-F11 */ "meta-meta2-1~", "nick_beginning");
+ gui_key_bind ( /* m-F12 */ "meta-meta2-4~", "nick_end");
+ gui_key_bind ( /* ^L */ "ctrl-L", "refresh");
+ gui_key_bind ( /* m-a */ "meta-a", "jump_smart");
+ gui_key_bind ( /* m-b */ "meta-b", "previous_word");
+ gui_key_bind ( /* ^left */ "meta-Od", "previous_word");
+ gui_key_bind ( /* m-d */ "meta-d", "delete_next_word");
+ gui_key_bind ( /* m-f */ "meta-f", "next_word");
+ gui_key_bind ( /* ^right */ "meta-Oc", "next_word");
+ gui_key_bind ( /* m-h */ "meta-h", "hotlist_clear");
+ gui_key_bind ( /* m-j,m-d */ "meta-jmeta-d", "jump_dcc");
+ gui_key_bind ( /* m-r */ "meta-r", "delete_line");
+ gui_key_bind ( /* m-s */ "meta-s", "jump_server");
+ gui_key_bind ( /* m-x */ "meta-x", "jump_next_server");
+
+ /* keys binded with commands */
+ gui_key_bind ( /* m-left */ "meta-meta2-D", "/buffer -1");
+ gui_key_bind ( /* F5 */ "meta2-15~", "/buffer -1");
+ gui_key_bind ( /* m-right */ "meta-meta2-C", "/buffer +1");
+ gui_key_bind ( /* F6 */ "meta2-17~", "/buffer +1");
+ gui_key_bind ( /* F7 */ "meta2-18~", "/window -1");
+ gui_key_bind ( /* F8 */ "meta2-19~", "/window +1");
+ gui_key_bind ( /* m-0 */ "meta-0", "/buffer 10");
+ gui_key_bind ( /* m-1 */ "meta-1", "/buffer 1");
+ gui_key_bind ( /* m-2 */ "meta-2", "/buffer 2");
+ gui_key_bind ( /* m-3 */ "meta-3", "/buffer 3");
+ gui_key_bind ( /* m-4 */ "meta-4", "/buffer 4");
+ gui_key_bind ( /* m-5 */ "meta-5", "/buffer 5");
+ gui_key_bind ( /* m-6 */ "meta-6", "/buffer 6");
+ gui_key_bind ( /* m-7 */ "meta-7", "/buffer 7");
+ gui_key_bind ( /* m-8 */ "meta-8", "/buffer 8");
+ gui_key_bind ( /* m-9 */ "meta-9", "/buffer 9");
+
+ /* bind meta-j + {01..99} to switch to buffers # > 10 */
+ for (i = 1; i < 100; i++)
+ {
+ sprintf (key_str, "meta-j%02d", i);
+ sprintf (command, "/buffer %d", i);
+ gui_key_bind (key_str, command);
+ }
+}
+
+/*
+ * gui_input_read: read keyboard chars
+ */
- key = getch ();
- if (key != ERR)
+void
+gui_input_read ()
+{
+ int key, i;
+ char key_str[32];
+
+ i = 0;
+ /* do not loop too much here (for example when big paste was made),
+ to read also socket & co */
+ while (i < 8)
{
- switch (key)
+ key = getch ();
+
+ if (key == ERR)
+ break;
+
+ if (key == KEY_RESIZE)
{
- /* resize event */
- case KEY_RESIZE:
- gui_curses_resize_handler ();
- break;
- /* inactive function keys */
- case KEY_F(1):
- case KEY_F(2):
- case KEY_F(3):
- case KEY_F(4):
- case KEY_F(9):
- break;
- /* previous buffer in window */
- case KEY_F(5):
- gui_switch_to_previous_buffer (gui_current_window);
- break;
- /* next buffer in window */
- case KEY_F(6):
- gui_switch_to_next_buffer (gui_current_window);
- break;
- /* previous window */
- case KEY_F(7):
- gui_switch_to_previous_window (gui_current_window);
- break;
- /* next window */
- case KEY_F(8):
- gui_switch_to_next_window (gui_current_window);
- break;
- /* remove last infobar message */
- case KEY_F(10):
- gui_infobar_remove ();
- gui_draw_buffer_infobar (gui_current_window->buffer, 1);
- break;
- case KEY_F(11):
- gui_nick_move_page_up (gui_current_window);
- break;
- case KEY_F(12):
- gui_nick_move_page_down (gui_current_window);
- break;
- /* cursor up */
- case KEY_UP:
- if (gui_current_window->buffer->dcc)
- {
- if (dcc_list)
- {
- if (gui_current_window->dcc_selected
- && ((t_irc_dcc *)(gui_current_window->dcc_selected))->prev_dcc)
- {
- if (gui_current_window->dcc_selected ==
- gui_current_window->dcc_first)
- gui_current_window->dcc_first =
- ((t_irc_dcc *)(gui_current_window->dcc_first))->prev_dcc;
- gui_current_window->dcc_selected =
- ((t_irc_dcc *)(gui_current_window->dcc_selected))->prev_dcc;
- gui_draw_buffer_chat (gui_current_window->buffer, 1);
- gui_draw_buffer_input (gui_current_window->buffer, 1);
- }
- }
- }
- else
- {
- if (gui_current_window->buffer->ptr_history)
- {
- gui_current_window->buffer->ptr_history =
- gui_current_window->buffer->ptr_history->next_history;
- if (!gui_current_window->buffer->ptr_history)
- gui_current_window->buffer->ptr_history =
- gui_current_window->buffer->history;
- }
- else
- gui_current_window->buffer->ptr_history =
- gui_current_window->buffer->history;
- if (gui_current_window->buffer->ptr_history)
- {
- gui_current_window->buffer->input_buffer_size =
- strlen (gui_current_window->buffer->ptr_history->text);
- gui_optimize_input_buffer_size (gui_current_window->buffer);
- gui_current_window->buffer->input_buffer_pos =
- gui_current_window->buffer->input_buffer_size;
- strcpy (gui_current_window->buffer->input_buffer,
- gui_current_window->buffer->ptr_history->text);
- gui_draw_buffer_input (gui_current_window->buffer, 0);
- }
- }
- break;
- /* cursor down */
- case KEY_DOWN:
- if (gui_current_window->buffer->dcc)
- {
- if (dcc_list)
- {
- if (!gui_current_window->dcc_selected
- || ((t_irc_dcc *)(gui_current_window->dcc_selected))->next_dcc)
- {
- if (gui_current_window->dcc_last_displayed
- && (gui_current_window->dcc_selected ==
- gui_current_window->dcc_last_displayed))
- {
- if (gui_current_window->dcc_first)
- gui_current_window->dcc_first =
- ((t_irc_dcc *)(gui_current_window->dcc_first))->next_dcc;
- else
- gui_current_window->dcc_first =
- dcc_list->next_dcc;
- }
- if (gui_current_window->dcc_selected)
- gui_current_window->dcc_selected =
- ((t_irc_dcc *)(gui_current_window->dcc_selected))->next_dcc;
- else
- gui_current_window->dcc_selected =
- dcc_list->next_dcc;
- gui_draw_buffer_chat (gui_current_window->buffer, 1);
- gui_draw_buffer_input (gui_current_window->buffer, 1);
- }
- }
- }
- else
- {
- if (gui_current_window->buffer->ptr_history)
- {
- gui_current_window->buffer->ptr_history =
- gui_current_window->buffer->ptr_history->prev_history;
- if (gui_current_window->buffer->ptr_history)
- gui_current_window->buffer->input_buffer_size =
- strlen (gui_current_window->buffer->ptr_history->text);
- else
- gui_current_window->buffer->input_buffer_size = 0;
- gui_optimize_input_buffer_size (gui_current_window->buffer);
- gui_current_window->buffer->input_buffer_pos =
- gui_current_window->buffer->input_buffer_size;
- if (gui_current_window->buffer->ptr_history)
- strcpy (gui_current_window->buffer->input_buffer,
- gui_current_window->buffer->ptr_history->text);
- gui_draw_buffer_input (gui_current_window->buffer, 0);
- }
- }
- break;
- /* cursor left */
- case KEY_LEFT:
- if (!gui_current_window->buffer->dcc)
- {
- if (gui_current_window->buffer->input_buffer_pos > 0)
- {
- gui_current_window->buffer->input_buffer_pos--;
- gui_draw_buffer_input (gui_current_window->buffer, 0);
- }
- }
- break;
- /* cursor right */
- case KEY_RIGHT:
- if (!gui_current_window->buffer->dcc)
- {
- if (gui_current_window->buffer->input_buffer_pos <
- gui_current_window->buffer->input_buffer_size)
- {
- gui_current_window->buffer->input_buffer_pos++;
- gui_draw_buffer_input (gui_current_window->buffer, 0);
- }
- }
- break;
- /* home key or Control + A */
- case KEY_HOME:
- case 0x01:
- if (!gui_current_window->buffer->dcc)
- {
- if (gui_current_window->buffer->input_buffer_pos > 0)
- {
- gui_current_window->buffer->input_buffer_pos = 0;
- gui_draw_buffer_input (gui_current_window->buffer, 0);
- }
- }
- break;
- /* end key or Control + E */
- case KEY_END:
- case 0x05:
- if (!gui_current_window->buffer->dcc)
- {
- if (gui_current_window->buffer->input_buffer_pos <
- gui_current_window->buffer->input_buffer_size)
- {
- gui_current_window->buffer->input_buffer_pos =
- gui_current_window->buffer->input_buffer_size;
- gui_draw_buffer_input (gui_current_window->buffer, 0);
- }
- }
- break;
- /* page up */
- case KEY_PPAGE:
- if (!gui_current_window->buffer->dcc)
- gui_move_page_up (gui_current_window);
- break;
- /* page down */
- case KEY_NPAGE:
- if (!gui_current_window->buffer->dcc)
- gui_move_page_down (gui_current_window);
- break;
- /* erase before cursor and move cursor to the left */
- case 127:
- case KEY_BACKSPACE:
- if (!gui_current_window->buffer->dcc)
- {
- if (gui_current_window->buffer->input_buffer_pos > 0)
- {
- i = gui_current_window->buffer->input_buffer_pos-1;
- while (gui_current_window->buffer->input_buffer[i])
- {
- gui_current_window->buffer->input_buffer[i] =
- gui_current_window->buffer->input_buffer[i+1];
- i++;
- }
- gui_current_window->buffer->input_buffer_size--;
- gui_current_window->buffer->input_buffer_pos--;
- gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_size] = '\0';
- gui_draw_buffer_input (gui_current_window->buffer, 0);
- gui_optimize_input_buffer_size (gui_current_window->buffer);
- gui_current_window->buffer->completion.position = -1;
- }
- }
- break;
- /* Control + Backspace or Control + W */
- case 0x08:
- case 0x17:
- if (!gui_current_window->buffer->dcc)
- gui_delete_previous_word (gui_current_window->buffer);
- break;
- /* Control + L */
- case 0x0C:
- gui_curses_resize_handler ();
- break;
- /* erase char under cursor */
- case KEY_DC:
- if (!gui_current_window->buffer->dcc)
- {
- if (gui_current_window->buffer->input_buffer_pos <
- gui_current_window->buffer->input_buffer_size)
- {
- i = gui_current_window->buffer->input_buffer_pos;
- while (gui_current_window->buffer->input_buffer[i])
- {
- gui_current_window->buffer->input_buffer[i] =
- gui_current_window->buffer->input_buffer[i+1];
- i++;
- }
- gui_current_window->buffer->input_buffer_size--;
- gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_size] = '\0';
- gui_draw_buffer_input (gui_current_window->buffer, 0);
- gui_optimize_input_buffer_size (gui_current_window->buffer);
- gui_current_window->buffer->completion.position = -1;
- }
- }
- break;
- /* Tab : completion */
- case '\t':
- if (!gui_current_window->buffer->dcc)
- {
- completion_search (&(gui_current_window->buffer->completion),
- CHANNEL(gui_current_window->buffer),
- gui_current_window->buffer->input_buffer,
- gui_current_window->buffer->input_buffer_size,
- gui_current_window->buffer->input_buffer_pos);
-
- if (gui_current_window->buffer->completion.word_found)
- {
- /* replace word with new completed word into input buffer */
- if (gui_current_window->buffer->completion.diff_size > 0)
- {
- gui_current_window->buffer->input_buffer_size +=
- gui_current_window->buffer->completion.diff_size;
- gui_optimize_input_buffer_size (gui_current_window->buffer);
- gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_size] = '\0';
- for (i = gui_current_window->buffer->input_buffer_size - 1;
- i >= gui_current_window->buffer->completion.position_replace +
- (int)strlen (gui_current_window->buffer->completion.word_found); i--)
- gui_current_window->buffer->input_buffer[i] =
- gui_current_window->buffer->input_buffer[i -
- gui_current_window->buffer->completion.diff_size];
- }
- else
- {
- for (i = gui_current_window->buffer->completion.position_replace +
- strlen (gui_current_window->buffer->completion.word_found);
- i < gui_current_window->buffer->input_buffer_size; i++)
- gui_current_window->buffer->input_buffer[i] =
- gui_current_window->buffer->input_buffer[i -
- gui_current_window->buffer->completion.diff_size];
- gui_current_window->buffer->input_buffer_size +=
- gui_current_window->buffer->completion.diff_size;
- gui_optimize_input_buffer_size (gui_current_window->buffer);
- gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_size] = '\0';
- }
-
- strncpy (gui_current_window->buffer->input_buffer + gui_current_window->buffer->completion.position_replace,
- gui_current_window->buffer->completion.word_found,
- strlen (gui_current_window->buffer->completion.word_found));
- gui_current_window->buffer->input_buffer_pos =
- gui_current_window->buffer->completion.position_replace +
- strlen (gui_current_window->buffer->completion.word_found);
-
- /* position is < 0 this means only one word was found to complete,
- so reinit to stop completion */
- if (gui_current_window->buffer->completion.position >= 0)
- gui_current_window->buffer->completion.position =
- gui_current_window->buffer->input_buffer_pos;
-
- /* add space or completor to the end of completion, if needed */
- if ((gui_current_window->buffer->completion.context == COMPLETION_COMMAND)
- || (gui_current_window->buffer->completion.context == COMPLETION_COMMAND_ARG))
- {
- if (gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_pos] != ' ')
- gui_buffer_insert_string (gui_current_window->buffer,
- " ",
- gui_current_window->buffer->input_buffer_pos);
- if (gui_current_window->buffer->completion.position >= 0)
- gui_current_window->buffer->completion.position++;
- gui_current_window->buffer->input_buffer_pos++;
- }
- else
- {
- /* add nick completor if position 0 and completing nick */
- if ((gui_current_window->buffer->completion.base_word_pos == 0)
- && (gui_current_window->buffer->completion.context == COMPLETION_NICK))
- {
- if (strncmp (gui_current_window->buffer->input_buffer + gui_current_window->buffer->input_buffer_pos,
- cfg_look_completor, strlen (cfg_look_completor)) != 0)
- gui_buffer_insert_string (gui_current_window->buffer,
- cfg_look_completor,
- gui_current_window->buffer->input_buffer_pos);
- if (gui_current_window->buffer->completion.position >= 0)
- gui_current_window->buffer->completion.position += strlen (cfg_look_completor);
- gui_current_window->buffer->input_buffer_pos += strlen (cfg_look_completor);
- if (gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_pos] != ' ')
- gui_buffer_insert_string (gui_current_window->buffer,
- " ",
- gui_current_window->buffer->input_buffer_pos);
- if (gui_current_window->buffer->completion.position >= 0)
- gui_current_window->buffer->completion.position++;
- gui_current_window->buffer->input_buffer_pos++;
- }
- }
- gui_draw_buffer_input (gui_current_window->buffer, 0);
- }
- }
- break;
- /* escape code (for control-key) */
- case KEY_ESCAPE:
- if ((key = getch()) != ERR)
- {
- /*gui_printf (gui_current_window->buffer,
- "[Debug] key pressed = %d, hex = %02X, octal = %o\n", key, key, key);*/
- switch (key)
- {
- /* Alt + left arrow */
- case KEY_LEFT:
- gui_switch_to_previous_buffer (gui_current_window);
- break;
- /* Alt + right arrow */
- case KEY_RIGHT:
- gui_switch_to_next_buffer (gui_current_window);
- break;
- /* Alt + home */
- case KEY_HOME:
- gui_nick_move_beginning (gui_current_window);
- break;
- /* Alt + end */
- case KEY_END:
- gui_nick_move_end (gui_current_window);
- break;
- /* Alt + page up */
- case KEY_PPAGE:
- gui_nick_move_page_up (gui_current_window);
- break;
- /* Alt + page down */
- case KEY_NPAGE:
- gui_nick_move_page_down (gui_current_window);
- break;
- case 79:
- /* TODO: replace 79 by constant name! */
- if ((key = getch()) != ERR)
- {
- switch (key)
- {
- /* Control + Right */
- case 99:
- if (!gui_current_window->buffer->dcc)
- gui_move_next_word (gui_current_window->buffer);
- break;
- /* Control + Left */
- case 100:
- if (!gui_current_window->buffer->dcc)
- gui_move_previous_word (gui_current_window->buffer);
- break;
- }
- }
- break;
- /* Alt-number: jump to window by number */
- case 48: /* Alt-0 */
- case 49: /* Alt-1 */
- case 50: /* Alt-2 */
- case 51: /* Alt-3 */
- case 52: /* Alt-4 */
- case 53: /* Alt-5 */
- case 54: /* Alt-6 */
- case 55: /* Alt-7 */
- case 56: /* Alt-8 */
- case 57: /* Alt-9 */
- gui_switch_to_buffer_by_number (gui_current_window, (key == 48) ? 10 : key - 48);
- break;
- /* Alt-A: jump to buffer with activity */
- case 'a':
- case 'A':
- if (hotlist)
- {
- if (!hotlist_initial_buffer)
- hotlist_initial_buffer = gui_current_window->buffer;
- gui_switch_to_buffer (gui_current_window, hotlist->buffer);
- gui_redraw_buffer (gui_current_window->buffer);
- }
- else
- {
- if (hotlist_initial_buffer)
- {
- gui_switch_to_buffer (gui_current_window, hotlist_initial_buffer);
- gui_redraw_buffer (gui_current_window->buffer);
- hotlist_initial_buffer = NULL;
- }
- }
- break;
- /* Alt-D: jump to DCC buffer */
- case 'd':
- case 'D':
- if (gui_current_window->buffer->dcc)
- {
- if (buffer_before_dcc)
- {
- gui_switch_to_buffer (gui_current_window,
- buffer_before_dcc);
- gui_redraw_buffer (gui_current_window->buffer);
- }
- }
- else
- {
- buffer_before_dcc = gui_current_window->buffer;
- gui_switch_to_dcc_buffer ();
- }
- break;
- /* Alt-R: clear hotlist */
- case 'r':
- case 'R':
- if (hotlist)
- {
- hotlist_free_all ();
- gui_redraw_buffer (gui_current_window->buffer);
- }
- hotlist_initial_buffer = gui_current_window->buffer;
- break;
- /* Alt-S: jump to server buffer */
- case 's':
- case 'S':
- if (!gui_current_window->buffer->dcc)
- {
- if (SERVER(gui_current_window->buffer)->buffer !=
- gui_current_window->buffer)
- {
- gui_switch_to_buffer (gui_current_window,
- SERVER(gui_current_window->buffer)->buffer);
- gui_redraw_buffer (gui_current_window->buffer);
- }
- }
- break;
- /* Alt-X: jump to first channel/private of next server */
- case 'x':
- case 'X':
- if (!gui_current_window->buffer->dcc)
- {
- ptr_server = SERVER(gui_current_window->buffer)->next_server;
- if (!ptr_server)
- ptr_server = irc_servers;
- while (ptr_server != SERVER(gui_current_window->buffer))
- {
- if (ptr_server->buffer)
- break;
- ptr_server = (ptr_server->next_server) ?
- ptr_server->next_server : irc_servers;
- }
- if (ptr_server != SERVER(gui_current_window->buffer))
- {
- ptr_buffer = (ptr_server->channels) ?
- ptr_server->channels->buffer : ptr_server->buffer;
- gui_switch_to_buffer (gui_current_window, ptr_buffer);
- gui_redraw_buffer (gui_current_window->buffer);
- }
- }
- break;
- }
- }
- break;
- /* send command/message */
- case '\n':
- if (!gui_current_window->buffer->dcc)
- {
- if (gui_current_window->buffer->input_buffer_size > 0)
- {
- gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_size] = '\0';
- history_add (gui_current_window->buffer, gui_current_window->buffer->input_buffer);
- gui_current_window->buffer->input_buffer_size = 0;
- gui_current_window->buffer->input_buffer_pos = 0;
- gui_current_window->buffer->input_buffer_1st_display = 0;
- gui_current_window->buffer->completion.position = -1;
- gui_current_window->buffer->ptr_history = NULL;
- ptr_buffer = gui_current_window->buffer;
- user_command (SERVER(gui_current_window->buffer),
- gui_current_window->buffer,
- gui_current_window->buffer->input_buffer);
- if (ptr_buffer == gui_current_window->buffer)
- {
- ptr_buffer->input_buffer[0] = '\0';
- gui_draw_buffer_input (ptr_buffer, 0);
- }
- }
- }
- break;
- /* other key => add to input buffer */
- default:
- if (gui_current_window->buffer->dcc)
- {
- dcc_selected = (gui_current_window->dcc_selected) ?
- (t_irc_dcc *) gui_current_window->dcc_selected : dcc_list;
- switch (key)
- {
- /* accept DCC */
- case 'a':
- case 'A':
- if (dcc_selected
- && (DCC_IS_RECV(dcc_selected->status))
- && (dcc_selected->status == DCC_WAITING))
- {
- dcc_accept (dcc_selected);
- }
- break;
- /* cancel DCC */
- case 'c':
- case 'C':
- if (dcc_selected
- && (!DCC_ENDED(dcc_selected->status)))
- {
- dcc_close (dcc_selected, DCC_ABORTED);
- gui_redraw_buffer (gui_current_window->buffer);
- }
- break;
- /* purge old DCC */
- case 'p':
- case 'P':
- gui_current_window->dcc_selected = NULL;
- ptr_dcc = dcc_list;
- while (ptr_dcc)
- {
- ptr_dcc_next = ptr_dcc->next_dcc;
- if (DCC_ENDED(ptr_dcc->status))
- dcc_free (ptr_dcc);
- ptr_dcc = ptr_dcc_next;
- }
- gui_redraw_buffer (gui_current_window->buffer);
- break;
- /* close DCC window */
- case 'q':
- case 'Q':
- if (buffer_before_dcc)
- {
- gui_buffer_free (gui_current_window->buffer, 1);
- gui_switch_to_buffer (gui_current_window,
- buffer_before_dcc);
- }
- else
- gui_buffer_free (gui_current_window->buffer, 1);
- gui_redraw_buffer (gui_current_window->buffer);
- break;
- /* remove from DCC list */
- case 'r':
- case 'R':
- if (dcc_selected
- && (DCC_ENDED(dcc_selected->status)))
- {
- if (dcc_selected->next_dcc)
- gui_current_window->dcc_selected = dcc_selected->next_dcc;
- else
- gui_current_window->dcc_selected = NULL;
- dcc_free (dcc_selected);
- gui_redraw_buffer (gui_current_window->buffer);
- }
- break;
- }
- }
- else
- {
- /*gui_printf (gui_current_window->buffer,
- "[Debug] key pressed = %d, hex = %02X, octal = %o\n", key, key, key);*/
- new_char[0] = key;
- new_char[1] = '\0';
- decoded_string = NULL;
-
- /* UTF-8 input */
- if (key == 0xC3)
- {
- if ((key = getch()) != ERR)
- {
- new_char[1] = key;
- new_char[2] = '\0';
- decoded_string = weechat_convert_encoding (local_charset, cfg_look_charset_internal, new_char);
- }
- }
-
- gui_buffer_insert_string (gui_current_window->buffer,
- (decoded_string) ? decoded_string : new_char,
- gui_current_window->buffer->input_buffer_pos);
- gui_current_window->buffer->input_buffer_pos++;
- gui_draw_buffer_input (gui_current_window->buffer, 0);
- gui_current_window->buffer->completion.position = -1;
-
- if (decoded_string)
- free (decoded_string);
- }
- break;
+ gui_curses_resize_handler ();
+ continue;
+ }
+
+ if (key < 32)
+ {
+ key_str[0] = '^';
+ key_str[1] = (char) key + '@';
+ key_str[2] = '\0';
+ }
+ else if (key == 127)
+ {
+ key_str[0] = '^';
+ key_str[1] = '?';
+ key_str[2] = '\0';
+ }
+ else
+ {
+ if (key > 0xff)
+ {
+ key_str[0] = (char) (key >> 8);
+ key_str[1] = (char) (key & 0xff);
+ key_str[2] = '\0';
+ }
+ else
+ {
+ key_str[0] = (char) key;
+ key_str[1] = '\0';
+ }
}
+
+ if (strcmp (key_str, "^") == 0)
+ {
+ key_str[1] = '^';
+ key_str[2] = '\0';
+ }
+
+ /*gui_printf (gui_current_window->buffer, "gui_input_read: key = %s (%d)\n", key_str, key);*/
+
+ if (gui_key_pressed (key_str) != 0)
+ gui_input_insert_char (key);
+
+ i++;
}
}
@@ -723,6 +225,14 @@ gui_main_loop ()
{
old_sec = local_time->tm_sec;
+ if (cfg_look_infobar_seconds)
+ {
+ gui_draw_buffer_infobar_time (gui_current_window->buffer);
+ wmove (gui_current_window->win_input,
+ 0, gui_current_window->win_input_x);
+ wrefresh (gui_current_window->win_input);
+ }
+
/* infobar count down */
if (gui_infobar && gui_infobar->remaining_time > 0)
{
@@ -807,7 +317,7 @@ gui_main_loop ()
{
if (FD_ISSET (STDIN_FILENO, &read_fd))
{
- gui_read_keyb ();
+ gui_input_read ();
}
if ((weechat_fifo != -1) && (FD_ISSET (weechat_fifo, &read_fd)))
{