2000-04-26 08:03:38 +00:00
/*
gui - readline . c : irssi
Copyright ( C ) 1999 Timo Sirainen
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2007-05-08 18:41:10 +00:00
You should have received a copy of the GNU General Public License along
with this program ; if not , write to the Free Software Foundation , Inc . ,
51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA .
2000-04-26 08:03:38 +00:00
*/
# include "module.h"
2003-11-17 14:09:15 +00:00
# include "module-formats.h"
2000-04-26 08:03:38 +00:00
# include "signals.h"
# include "misc.h"
2000-12-04 13:11:44 +00:00
# include "settings.h"
2001-05-11 13:44:23 +00:00
# include "special-vars.h"
2003-11-16 21:49:15 +00:00
# include "levels.h"
2001-12-20 02:17:35 +00:00
# include "servers.h"
2000-04-26 08:03:38 +00:00
# include "completion.h"
# include "command-history.h"
# include "keyboard.h"
2003-11-16 21:49:15 +00:00
# include "printtext.h"
2000-04-26 08:03:38 +00:00
2001-10-28 11:30:26 +00:00
# include "term.h"
2000-04-26 08:03:38 +00:00
# include "gui-entry.h"
# include "gui-windows.h"
2002-02-15 13:38:24 +00:00
# include "utf8.h"
2000-04-26 08:03:38 +00:00
2015-09-08 00:40:25 +02:00
# include <string.h>
2000-04-26 08:03:38 +00:00
# include <signal.h>
2016-02-24 00:35:27 +05:30
/* After LINE_SPLIT_LIMIT characters, the message will be split into multiple lines */
# define LINE_SPLIT_LIMIT 400
2000-05-04 10:32:42 +00:00
typedef void ( * ENTRY_REDIRECT_KEY_FUNC ) ( int key , void * data , SERVER_REC * server , WI_ITEM_REC * item ) ;
typedef void ( * ENTRY_REDIRECT_ENTRY_FUNC ) ( const char * line , void * data , SERVER_REC * server , WI_ITEM_REC * item ) ;
typedef struct {
SIGNAL_FUNC func ;
2001-01-04 18:01:51 +00:00
int flags ;
2000-05-04 10:32:42 +00:00
void * data ;
} ENTRY_REDIRECT_REC ;
2001-05-06 19:28:15 +00:00
static KEYBOARD_REC * keyboard ;
2000-05-04 10:32:42 +00:00
static ENTRY_REDIRECT_REC * redir ;
2002-02-18 20:59:40 +00:00
static int escape_next_key ;
2000-05-04 10:32:42 +00:00
2001-05-17 11:47:21 +00:00
static int readtag ;
2003-11-16 21:49:15 +00:00
static unichar prev_key ;
2003-11-16 19:37:31 +00:00
static GTimeVal last_keypress ;
2003-11-16 21:49:15 +00:00
2010-02-27 14:57:16 +00:00
static int paste_detect_time , paste_verify_line_count ;
2008-03-10 09:48:02 +00:00
static char * paste_entry ;
static int paste_entry_pos ;
2003-11-16 21:49:15 +00:00
static GArray * paste_buffer ;
2015-09-17 00:54:13 -03:00
static GArray * paste_buffer_rest ;
2003-11-16 21:49:15 +00:00
static char * paste_old_prompt ;
static int paste_prompt , paste_line_count ;
2004-01-19 18:59:17 +00:00
static int paste_join_multiline ;
2010-02-27 14:57:16 +00:00
static int paste_timeout_id ;
2015-09-08 00:48:13 +02:00
static int paste_use_bracketed_mode ;
2015-09-08 00:40:25 +02:00
static int paste_bracketed_mode ;
2015-09-25 02:21:27 -03:00
static int paste_was_bracketed_mode ;
2016-03-21 09:14:01 +01:00
static int previous_yank_preceded ;
2015-09-08 00:40:25 +02:00
/* Terminal sequences that surround the input when the terminal has the
* bracketed paste mode active . Fror more details see
* https : //cirw.in/blog/bracketed-paste */
static const unichar bp_start [ ] = { 0x1b , ' [ ' , ' 2 ' , ' 0 ' , ' 0 ' , ' ~ ' } ;
static const unichar bp_end [ ] = { 0x1b , ' [ ' , ' 2 ' , ' 0 ' , ' 1 ' , ' ~ ' } ;
2000-04-26 08:03:38 +00:00
2001-12-17 22:13:18 +00:00
static void sig_input ( void ) ;
void input_listen_init ( int handle )
{
2008-04-25 08:42:47 +00:00
readtag = g_input_add_poll ( handle ,
2001-12-17 22:13:18 +00:00
G_PRIORITY_HIGH , G_INPUT_READ ,
( GInputFunction ) sig_input , NULL ) ;
}
void input_listen_deinit ( void )
{
g_source_remove ( readtag ) ;
readtag = - 1 ;
}
2000-05-04 10:32:42 +00:00
static void handle_key_redirect ( int key )
{
ENTRY_REDIRECT_KEY_FUNC func ;
void * data ;
func = ( ENTRY_REDIRECT_KEY_FUNC ) redir - > func ;
data = redir - > data ;
g_free_and_null ( redir ) ;
2002-11-11 06:54:32 +00:00
gui_entry_set_prompt ( active_entry , " " ) ;
2000-05-04 10:32:42 +00:00
if ( func ! = NULL )
func ( key , data , active_win - > active_server , active_win - > active ) ;
}
static void handle_entry_redirect ( const char * line )
{
ENTRY_REDIRECT_ENTRY_FUNC func ;
void * data ;
2001-10-13 16:11:13 +00:00
gui_entry_set_hidden ( active_entry , FALSE ) ;
2001-01-04 18:01:51 +00:00
2000-05-04 10:32:42 +00:00
func = ( ENTRY_REDIRECT_ENTRY_FUNC ) redir - > func ;
data = redir - > data ;
g_free_and_null ( redir ) ;
2002-11-11 06:54:32 +00:00
gui_entry_set_prompt ( active_entry , " " ) ;
2001-01-04 18:01:51 +00:00
if ( func ! = NULL ) {
func ( line , data , active_win - > active_server ,
active_win - > active ) ;
}
2000-05-04 10:32:42 +00:00
}
2000-12-04 13:11:44 +00:00
static int get_scroll_count ( void )
{
const char * str ;
2001-03-08 00:27:40 +00:00
double count ;
2000-12-04 13:11:44 +00:00
str = settings_get_str ( " scroll_page_count " ) ;
2001-03-08 00:27:40 +00:00
count = atof ( str + ( * str = = ' / ' ) ) ;
2006-02-01 09:56:42 +00:00
if ( count = = 0 )
2001-03-08 00:27:40 +00:00
count = 1 ;
2006-02-01 09:56:42 +00:00
else if ( count < 0 )
count = active_mainwin - > height - active_mainwin - > statusbar_lines + count ;
2001-03-08 00:27:40 +00:00
else if ( count < 1 )
count = 1.0 / count ;
2001-10-27 11:47:59 +00:00
if ( * str = = ' / ' ) {
count = ( active_mainwin - > height - active_mainwin - > statusbar_lines ) / count ;
}
2001-03-08 00:27:40 +00:00
return ( int ) count ;
2000-12-04 13:11:44 +00:00
}
2000-04-26 08:03:38 +00:00
static void window_prev_page ( void )
{
2000-12-04 13:11:44 +00:00
gui_window_scroll ( active_win , - get_scroll_count ( ) ) ;
2000-04-26 08:03:38 +00:00
}
static void window_next_page ( void )
{
2000-12-04 13:11:44 +00:00
gui_window_scroll ( active_win , get_scroll_count ( ) ) ;
2000-04-26 08:03:38 +00:00
}
2004-01-19 18:59:17 +00:00
static void paste_buffer_join_lines ( GArray * buf )
{
unsigned int i , count , indent , line_len ;
unichar * arr , * dest , * last_lf_pos ;
int last_lf ;
/* first check if we actually want to join anything. This is assuming
that we only want to join lines if
a ) first line doesn ' t begin with whitespace
b ) subsequent lines begin with same amount of whitespace
c ) whenever there ' s no whitespace , goto a )
For example :
line 1
line 2
line 3
line 4
line 5
line 6
- >
line1 line2 line 3
line4
line5 line 6
*/
if ( buf - > len = = 0 )
return ;
2015-11-22 21:24:05 +01:00
arr = ( unichar * ) buf - > data ;
2004-01-19 18:59:17 +00:00
/* first line */
2015-11-22 21:33:44 +01:00
if ( isblank ( arr [ 0 ] ) )
2004-01-19 18:59:17 +00:00
return ;
/* find the first beginning of indented line */
for ( i = 1 ; i < buf - > len ; i + + ) {
2015-11-22 21:33:44 +01:00
if ( arr [ i - 1 ] = = ' \n ' & & isblank ( arr [ i ] ) )
2004-01-19 18:59:17 +00:00
break ;
}
if ( i = = buf - > len )
return ;
/* get how much indentation we have.. */
for ( indent = 0 ; i < buf - > len ; i + + , indent + + ) {
2015-11-22 21:33:44 +01:00
if ( ! isblank ( arr [ i ] ) )
2004-01-19 18:59:17 +00:00
break ;
}
if ( i = = buf - > len )
return ;
/* now, enforce these to all subsequent lines */
count = indent ; last_lf = TRUE ;
for ( ; i < buf - > len ; i + + ) {
if ( last_lf ) {
2015-11-22 21:33:44 +01:00
if ( isblank ( arr [ i ] ) )
2004-01-19 18:59:17 +00:00
count + + ;
else {
last_lf = FALSE ;
if ( count ! = 0 & & count ! = indent )
return ;
count = 0 ;
}
}
if ( arr [ i ] = = ' \n ' )
last_lf = TRUE ;
}
/* all looks fine - now remove the whitespace, but don't let lines
2016-02-24 00:35:27 +05:30
get longer than LINE_SPLIT_LIMIT chars */
2004-01-19 18:59:17 +00:00
dest = arr ; last_lf = TRUE ; last_lf_pos = NULL ; line_len = 0 ;
for ( i = 0 ; i < buf - > len ; i + + ) {
2015-11-22 21:33:44 +01:00
if ( last_lf & & isblank ( arr [ i ] ) ) {
2004-01-19 18:59:17 +00:00
/* whitespace, ignore */
} else if ( arr [ i ] = = ' \n ' ) {
if ( ! last_lf & & i + 1 ! = buf - > len & &
2015-11-22 21:33:44 +01:00
isblank ( arr [ i + 1 ] ) ) {
2004-01-19 18:59:17 +00:00
last_lf_pos = dest ;
2004-01-24 22:08:56 +00:00
* dest + + = ' ' ;
} else {
2004-01-19 18:59:17 +00:00
* dest + + = ' \n ' ; /* double-LF */
line_len = 0 ;
last_lf_pos = NULL ;
}
last_lf = TRUE ;
} else {
last_lf = FALSE ;
2016-02-24 00:35:27 +05:30
if ( + + line_len > = LINE_SPLIT_LIMIT & & last_lf_pos ! = NULL ) {
2004-01-19 18:59:17 +00:00
memmove ( last_lf_pos + 1 , last_lf_pos ,
2015-09-17 00:55:31 -03:00
( dest - last_lf_pos ) * sizeof ( unichar ) ) ;
2004-01-19 18:59:17 +00:00
* last_lf_pos = ' \n ' ; last_lf_pos = NULL ;
2004-01-19 19:00:25 +00:00
line_len = 0 ;
2004-01-19 18:59:17 +00:00
dest + + ;
}
* dest + + = arr [ i ] ;
}
}
2004-01-19 19:28:15 +00:00
g_array_set_size ( buf , dest - arr ) ;
2004-01-19 18:59:17 +00:00
}
2015-09-25 02:21:27 -03:00
static void paste_send_line ( char * text )
{
/* we need to get the current history every time because it might change between calls */
command_history_add ( command_history_current ( active_win ) , text ) ;
signal_emit ( " send command " , 3 , text , active_win - > active_server , active_win - > active ) ;
}
2003-11-16 22:56:26 +00:00
static void paste_send ( void )
2003-11-16 21:49:15 +00:00
{
unichar * arr ;
GString * str ;
2008-11-18 09:21:36 +00:00
char out [ 10 ] , * text ;
2003-11-16 21:49:15 +00:00
unsigned int i ;
2004-01-19 18:59:17 +00:00
if ( paste_join_multiline )
paste_buffer_join_lines ( paste_buffer ) ;
2003-11-16 22:56:26 +00:00
arr = ( unichar * ) paste_buffer - > data ;
2003-11-21 18:15:11 +00:00
if ( active_entry - > text_len = = 0 )
i = 0 ;
else {
/* first line has to be kludged kind of to get pasting in the
middle of line right . . */
for ( i = 0 ; i < paste_buffer - > len ; i + + ) {
if ( arr [ i ] = = ' \r ' | | arr [ i ] = = ' \n ' ) {
i + + ;
break ;
}
2008-11-18 09:21:36 +00:00
gui_entry_insert_char ( active_entry , arr [ i ] ) ;
2003-11-16 22:56:26 +00:00
}
2008-11-18 09:21:36 +00:00
text = gui_entry_get_text ( active_entry ) ;
2015-09-25 02:21:27 -03:00
paste_send_line ( text ) ;
2008-11-18 09:21:36 +00:00
g_free ( text ) ;
2003-11-16 22:56:26 +00:00
}
/* rest of the lines */
2008-11-18 09:21:36 +00:00
str = g_string_new ( NULL ) ;
2003-11-16 22:56:26 +00:00
for ( ; i < paste_buffer - > len ; i + + ) {
2003-11-16 21:49:15 +00:00
if ( arr [ i ] = = ' \r ' | | arr [ i ] = = ' \n ' ) {
2015-09-25 02:21:27 -03:00
paste_send_line ( str - > str ) ;
2003-11-16 21:49:15 +00:00
g_string_truncate ( str , 0 ) ;
2003-11-21 18:15:11 +00:00
} else if ( active_entry - > utf8 ) {
2008-11-10 11:59:31 +00:00
out [ g_unichar_to_utf8 ( arr [ i ] , out ) ] = ' \0 ' ;
2003-11-16 21:49:15 +00:00
g_string_append ( str , out ) ;
2004-03-24 17:28:55 +00:00
} else 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 ) ;
2003-11-21 18:15:11 +00:00
} else {
g_string_append_c ( str , arr [ i ] ) ;
2003-11-16 21:49:15 +00:00
}
}
2015-09-25 02:21:27 -03:00
if ( paste_was_bracketed_mode ) {
/* the text before the bracket end should be sent along with the rest */
paste_send_line ( str - > str ) ;
gui_entry_set_text ( active_entry , " " ) ;
} else {
gui_entry_set_text ( active_entry , str - > str ) ;
}
2003-11-16 21:49:15 +00:00
g_string_free ( str , TRUE ) ;
}
static void paste_flush ( int send )
{
2010-02-27 14:57:16 +00:00
if ( paste_prompt ) {
gui_entry_set_text ( active_entry , paste_entry ) ;
gui_entry_set_pos ( active_entry , paste_entry_pos ) ;
g_free_and_null ( paste_entry ) ;
}
2008-11-18 09:21:36 +00:00
2003-11-16 21:49:15 +00:00
if ( send )
2003-11-16 22:56:26 +00:00
paste_send ( ) ;
2003-11-16 21:49:15 +00:00
g_array_set_size ( paste_buffer , 0 ) ;
2015-09-17 00:54:13 -03:00
/* re-add anything that may have been after the bracketed paste end */
2015-12-13 13:56:09 -03:00
if ( paste_buffer_rest - > len > 0 ) {
2015-09-17 00:54:13 -03:00
g_array_append_vals ( paste_buffer , paste_buffer_rest - > data , paste_buffer_rest - > len ) ;
g_array_set_size ( paste_buffer_rest , 0 ) ;
}
2003-11-16 21:49:15 +00:00
gui_entry_set_prompt ( active_entry ,
paste_old_prompt = = NULL ? " " : paste_old_prompt ) ;
g_free ( paste_old_prompt ) ; paste_old_prompt = NULL ;
paste_prompt = FALSE ;
paste_line_count = 0 ;
gui_entry_redraw ( active_entry ) ;
}
2008-01-21 10:50:50 +00:00
static void insert_paste_prompt ( void )
{
char * str ;
2016-02-24 00:36:35 +05:30
/* The actual number of lines that will show up post-line-split */
int actual_line_count = paste_line_count ;
int split_lines = paste_buffer - > len / LINE_SPLIT_LIMIT ;
/* in case this prompt is happening due to line-splitting, calculate the
number of lines obtained from this . The number isn ' t entirely accurate ;
we just choose the greater of the two since the exact value isn ' t
important */
if ( split_lines > paste_verify_line_count & &
split_lines > paste_line_count ) {
actual_line_count = split_lines ;
}
2008-01-21 10:50:50 +00:00
paste_prompt = TRUE ;
paste_old_prompt = g_strdup ( active_entry - > prompt ) ;
printformat_window ( active_win , MSGLEVEL_CLIENTNOTICE ,
TXT_PASTE_WARNING ,
2016-02-24 00:36:35 +05:30
actual_line_count ,
2008-01-21 10:50:50 +00:00
active_win - > active = = NULL ? " window " :
active_win - > active - > visible_name ) ;
str = format_get_text ( MODULE_NAME , active_win , NULL , NULL ,
TXT_PASTE_PROMPT , 0 , 0 ) ;
gui_entry_set_prompt ( active_entry , str ) ;
2010-02-27 14:57:16 +00:00
paste_entry = gui_entry_get_text ( active_entry ) ;
paste_entry_pos = gui_entry_get_pos ( active_entry ) ;
2008-01-21 10:50:50 +00:00
gui_entry_set_text ( active_entry , " " ) ;
g_free ( str ) ;
}
2002-11-05 13:34:31 +00:00
static void sig_gui_key_pressed ( gpointer keyp )
2000-04-26 08:03:38 +00:00
{
2003-11-16 19:37:31 +00:00
GTimeVal now ;
2002-11-05 13:34:31 +00:00
unichar key ;
2002-02-15 13:38:24 +00:00
char str [ 20 ] ;
2010-02-27 14:57:16 +00:00
int ret ;
2000-04-26 08:03:38 +00:00
2002-11-05 13:34:31 +00:00
key = GPOINTER_TO_INT ( keyp ) ;
2000-04-26 08:03:38 +00:00
2001-01-04 18:01:51 +00:00
if ( redir ! = NULL & & redir - > flags & ENTRY_REDIRECT_FLAG_HOTKEY ) {
2000-05-04 10:32:42 +00:00
handle_key_redirect ( key ) ;
return ;
}
2000-04-26 08:03:38 +00:00
2003-11-16 19:37:31 +00:00
g_get_current_time ( & now ) ;
2002-11-05 13:34:31 +00:00
2002-02-17 14:25:10 +00:00
if ( key < 32 ) {
2001-05-06 19:28:15 +00:00
/* control key */
str [ 0 ] = ' ^ ' ;
2002-02-15 13:38:24 +00:00
str [ 1 ] = ( char ) key + ' @ ' ;
2001-05-06 19:28:15 +00:00
str [ 2 ] = ' \0 ' ;
} else if ( key = = 127 ) {
str [ 0 ] = ' ^ ' ;
str [ 1 ] = ' ? ' ;
str [ 2 ] = ' \0 ' ;
2002-02-15 13:38:24 +00:00
} else if ( ! active_entry - > utf8 ) {
2003-10-26 05:31:19 +00:00
if ( key < = 0xff ) {
str [ 0 ] = ( char ) key ;
str [ 1 ] = ' \0 ' ;
} else {
str [ 0 ] = ( char ) ( key > > 8 ) ;
str [ 1 ] = ( char ) ( key & 0xff ) ;
str [ 2 ] = ' \0 ' ;
}
2002-02-15 13:38:24 +00:00
} else {
/* need to convert to utf8 */
2008-11-10 11:59:31 +00:00
str [ g_unichar_to_utf8 ( key , str ) ] = ' \0 ' ;
2000-05-04 10:32:42 +00:00
}
2001-05-06 19:28:15 +00:00
2015-04-07 22:39:05 -03:00
if ( g_strcmp0 ( str , " ^ " ) = = 0 ) {
2014-07-28 13:58:13 +02:00
/* change it as ^-, that is an invalid control char */
str [ 1 ] = ' - ' ;
2002-05-15 23:20:19 +00:00
str [ 2 ] = ' \0 ' ;
}
2004-03-23 20:52:33 +00:00
if ( escape_next_key ) {
escape_next_key = FALSE ;
2002-02-15 13:38:24 +00:00
gui_entry_insert_char ( active_entry , key ) ;
2004-03-23 20:52:33 +00:00
ret = 1 ;
} else {
2016-03-21 09:14:01 +01:00
previous_yank_preceded = active_entry - > yank_preceded ;
active_entry - > yank_preceded = FALSE ;
active_entry - > previous_append_next_kill = active_entry - > append_next_kill ;
active_entry - > append_next_kill = FALSE ;
2004-03-23 20:52:33 +00:00
ret = key_pressed ( keyboard , str ) ;
if ( ret < 0 ) {
/* key wasn't used for anything, print it */
gui_entry_insert_char ( active_entry , key ) ;
}
2016-03-21 09:14:01 +01:00
if ( ret = = 0 ) {
/* combo not complete, ignore append_next_kill and yank_preceded */
active_entry - > append_next_kill = active_entry - > previous_append_next_kill ;
active_entry - > yank_preceded = previous_yank_preceded ;
}
2001-05-06 19:28:15 +00:00
}
2003-11-17 12:17:57 +00:00
2003-11-23 12:17:16 +00:00
/* ret = 0 : some key create multiple characters - we're in the middle
of one . try to detect the keycombo as a single keypress rather than
multiple small onces to avoid incorrect paste detection .
2004-03-23 21:17:40 +00:00
don ' t count repeated keys so paste detection won ' t go on when
you ' re holding some key down */
if ( ret ! = 0 & & key ! = prev_key ) {
2003-11-17 12:17:57 +00:00
last_keypress = now ;
2004-03-23 21:17:40 +00:00
}
prev_key = key ;
2001-05-06 19:28:15 +00:00
}
static void key_send_line ( void )
{
2001-12-20 13:29:20 +00:00
HISTORY_REC * history ;
2008-03-09 23:03:45 +00:00
char * str ;
int add_history ;
2001-05-06 19:28:15 +00:00
2001-10-13 16:11:13 +00:00
str = gui_entry_get_text ( active_entry ) ;
2001-05-06 19:28:15 +00:00
2001-10-14 11:17:13 +00:00
/* we can't use gui_entry_get_text() later, since the entry might
have been destroyed after we get back */
2008-03-09 23:03:45 +00:00
add_history = * str ! = ' \0 ' ;
2001-12-20 13:29:20 +00:00
history = command_history_current ( active_win ) ;
2016-01-08 15:42:59 +01:00
if ( redir ! = NULL & & redir - > flags & ENTRY_REDIRECT_FLAG_HIDDEN )
add_history = 0 ;
if ( add_history & & history ! = NULL ) {
command_history_add ( history , str ) ;
}
2001-05-06 19:28:15 +00:00
if ( redir = = NULL ) {
signal_emit ( " send command " , 3 , str ,
active_win - > active_server ,
active_win - > active ) ;
} else {
handle_entry_redirect ( str ) ;
}
2001-11-19 12:46:15 +00:00
if ( active_entry ! = NULL )
gui_entry_set_text ( active_entry , " " ) ;
2001-05-06 19:28:15 +00:00
command_history_clear_pos ( active_win ) ;
2002-02-15 13:38:24 +00:00
g_free ( str ) ;
2001-05-06 19:28:15 +00:00
}
static void key_combo ( void )
{
2000-04-26 08:03:38 +00:00
}
2000-07-23 00:29:31 +00:00
static void key_backward_history ( void )
{
const char * text ;
2002-02-15 13:38:24 +00:00
char * line ;
2000-07-23 00:29:31 +00:00
2002-02-15 13:38:24 +00:00
line = gui_entry_get_text ( active_entry ) ;
text = command_history_prev ( active_win , line ) ;
2001-10-13 16:11:13 +00:00
gui_entry_set_text ( active_entry , text ) ;
2002-02-15 13:38:24 +00:00
g_free ( line ) ;
2000-07-23 00:29:31 +00:00
}
static void key_forward_history ( void )
{
const char * text ;
2002-02-15 13:38:24 +00:00
char * line ;
2000-07-23 00:29:31 +00:00
2002-02-15 13:38:24 +00:00
line = gui_entry_get_text ( active_entry ) ;
text = command_history_next ( active_win , line ) ;
2001-10-13 16:11:13 +00:00
gui_entry_set_text ( active_entry , text ) ;
2002-02-15 13:38:24 +00:00
g_free ( line ) ;
2000-07-23 00:29:31 +00:00
}
static void key_beginning_of_line ( void )
{
2001-10-13 16:11:13 +00:00
gui_entry_set_pos ( active_entry , 0 ) ;
2000-07-23 00:29:31 +00:00
}
static void key_end_of_line ( void )
{
2002-02-15 13:38:24 +00:00
gui_entry_set_pos ( active_entry , active_entry - > text_len ) ;
2000-07-23 00:29:31 +00:00
}
static void key_backward_character ( void )
{
2001-10-13 16:11:13 +00:00
gui_entry_move_pos ( active_entry , - 1 ) ;
2000-07-23 00:29:31 +00:00
}
static void key_forward_character ( void )
{
2001-10-13 16:11:13 +00:00
gui_entry_move_pos ( active_entry , 1 ) ;
2000-07-23 00:29:31 +00:00
}
static void key_backward_word ( void )
{
2001-10-25 14:39:36 +00:00
gui_entry_move_words ( active_entry , - 1 , FALSE ) ;
2000-07-23 00:29:31 +00:00
}
static void key_forward_word ( void )
{
2001-10-25 14:39:36 +00:00
gui_entry_move_words ( active_entry , 1 , FALSE ) ;
}
static void key_backward_to_space ( void )
{
gui_entry_move_words ( active_entry , - 1 , TRUE ) ;
}
static void key_forward_to_space ( void )
{
gui_entry_move_words ( active_entry , 1 , TRUE ) ;
2000-07-23 00:29:31 +00:00
}
static void key_erase_line ( void )
{
2002-02-15 13:38:24 +00:00
gui_entry_set_pos ( active_entry , active_entry - > text_len ) ;
2015-11-13 13:42:28 -05:00
gui_entry_erase ( active_entry , active_entry - > text_len , CUTBUFFER_UPDATE_REPLACE ) ;
2000-07-23 00:29:31 +00:00
}
static void key_erase_to_beg_of_line ( void )
{
int pos ;
2001-10-13 16:11:13 +00:00
pos = gui_entry_get_pos ( active_entry ) ;
2016-03-21 09:14:01 +01:00
gui_entry_erase ( active_entry , pos , CUTBUFFER_UPDATE_PREPEND ) ;
2000-07-23 00:29:31 +00:00
}
static void key_erase_to_end_of_line ( void )
{
int pos ;
2001-10-13 16:11:13 +00:00
pos = gui_entry_get_pos ( active_entry ) ;
2002-02-15 13:38:24 +00:00
gui_entry_set_pos ( active_entry , active_entry - > text_len ) ;
2016-03-21 09:14:01 +01:00
gui_entry_erase ( active_entry , active_entry - > text_len - pos , CUTBUFFER_UPDATE_APPEND ) ;
2000-07-23 00:29:31 +00:00
}
static void key_yank_from_cutbuffer ( void )
{
2002-02-15 13:38:24 +00:00
char * cutbuffer ;
cutbuffer = gui_entry_get_cutbuffer ( active_entry ) ;
2002-03-09 09:25:06 +00:00
if ( cutbuffer ! = NULL ) {
2001-10-13 16:11:13 +00:00
gui_entry_insert_text ( active_entry , cutbuffer ) ;
2016-03-21 09:14:01 +01:00
active_entry - > yank_preceded = TRUE ;
g_free ( cutbuffer ) ;
}
}
static void key_yank_next_cutbuffer ( void )
{
GUI_ENTRY_CUTBUFFER_REC * rec ;
guint length = 0 ;
char * cutbuffer ;
if ( ! previous_yank_preceded ) {
if ( settings_get_bool ( " bell_beeps " ) ) {
signal_emit ( " beep " , 0 ) ;
}
return ;
}
if ( active_entry - > kill_ring = = NULL )
return ;
rec = active_entry - > kill_ring - > data ;
if ( rec ! = NULL ) length = rec - > cutbuffer_len ;
cutbuffer = gui_entry_get_next_cutbuffer ( active_entry ) ;
if ( cutbuffer ! = NULL ) {
gui_entry_erase ( active_entry , length , CUTBUFFER_UPDATE_NOOP ) ;
gui_entry_insert_text ( active_entry , cutbuffer ) ;
active_entry - > yank_preceded = TRUE ;
g_free ( cutbuffer ) ;
2002-03-09 09:25:06 +00:00
}
2000-07-23 00:29:31 +00:00
}
2000-11-11 01:46:15 +00:00
static void key_transpose_characters ( void )
{
2002-02-15 16:02:14 +00:00
gui_entry_transpose_chars ( active_entry ) ;
2000-11-11 01:46:15 +00:00
}
2005-08-27 22:06:34 +00:00
static void key_transpose_words ( void )
{
gui_entry_transpose_words ( active_entry ) ;
}
static void key_capitalize_word ( void )
{
gui_entry_capitalize_word ( active_entry ) ;
}
static void key_downcase_word ( void )
{
gui_entry_downcase_word ( active_entry ) ;
}
static void key_upcase_word ( void )
{
gui_entry_upcase_word ( active_entry ) ;
}
2000-07-23 00:29:31 +00:00
static void key_delete_character ( void )
{
2002-02-15 13:38:24 +00:00
if ( gui_entry_get_pos ( active_entry ) < active_entry - > text_len ) {
2007-05-25 22:21:39 +00:00
gui_entry_erase_cell ( active_entry ) ;
2000-07-23 00:29:31 +00:00
}
}
static void key_backspace ( void )
{
2015-11-13 13:42:28 -05:00
gui_entry_erase ( active_entry , 1 , CUTBUFFER_UPDATE_NOOP ) ;
2000-07-23 00:29:31 +00:00
}
static void key_delete_previous_word ( void )
{
2016-03-21 09:14:01 +01:00
gui_entry_erase_word ( active_entry , FALSE , CUTBUFFER_UPDATE_PREPEND ) ;
2000-07-23 00:29:31 +00:00
}
static void key_delete_next_word ( void )
{
2016-03-21 09:14:01 +01:00
gui_entry_erase_next_word ( active_entry , FALSE , CUTBUFFER_UPDATE_APPEND ) ;
2000-07-23 00:29:31 +00:00
}
static void key_delete_to_previous_space ( void )
{
2016-03-21 09:14:01 +01:00
gui_entry_erase_word ( active_entry , TRUE , CUTBUFFER_UPDATE_PREPEND ) ;
2001-10-14 11:32:06 +00:00
}
static void key_delete_to_next_space ( void )
{
2016-03-21 09:14:01 +01:00
gui_entry_erase_next_word ( active_entry , TRUE , CUTBUFFER_UPDATE_APPEND ) ;
}
static void key_append_next_kill ( void )
{
active_entry - > append_next_kill = TRUE ;
2000-07-23 00:29:31 +00:00
}
2010-02-27 14:57:16 +00:00
static gboolean paste_timeout ( gpointer data )
{
2015-09-25 02:21:27 -03:00
paste_was_bracketed_mode = paste_bracketed_mode ;
2016-02-24 00:36:35 +05:30
/* number of lines after splitting extra-long messages */
int split_lines = paste_buffer - > len / LINE_SPLIT_LIMIT ;
/* Take into account the fact that a line may be split every LINE_SPLIT_LIMIT characters */
if ( paste_line_count = = 0 & & split_lines < = paste_verify_line_count ) {
2010-02-27 14:57:16 +00:00
int i ;
for ( i = 0 ; i < paste_buffer - > len ; i + + ) {
unichar key = g_array_index ( paste_buffer , unichar , i ) ;
signal_emit ( " gui key pressed " , 1 , GINT_TO_POINTER ( key ) ) ;
}
g_array_set_size ( paste_buffer , 0 ) ;
} else if ( paste_verify_line_count > 0 & &
2016-02-24 00:36:35 +05:30
( paste_line_count > = paste_verify_line_count | |
split_lines > paste_verify_line_count ) & &
active_win - > active ! = NULL )
2010-02-27 14:57:16 +00:00
insert_paste_prompt ( ) ;
else
paste_flush ( TRUE ) ;
paste_timeout_id = - 1 ;
return FALSE ;
}
2015-09-17 00:54:13 -03:00
static void paste_bracketed_end ( int i , gboolean rest )
{
2015-12-12 01:44:05 -03:00
unichar last_char ;
2015-09-17 00:54:13 -03:00
/* if there's stuff after the end bracket, save it for later */
if ( rest ) {
unichar * start = ( ( unichar * ) paste_buffer - > data ) + i + G_N_ELEMENTS ( bp_end ) ;
2015-09-25 01:37:06 -03:00
int len = paste_buffer - > len - i - G_N_ELEMENTS ( bp_end ) ;
2015-09-17 00:54:13 -03:00
g_array_set_size ( paste_buffer_rest , 0 ) ;
g_array_append_vals ( paste_buffer_rest , start , len ) ;
}
/* remove the rest, including the trailing sequence chars */
g_array_set_size ( paste_buffer , i ) ;
2015-12-12 01:44:05 -03:00
last_char = g_array_index ( paste_buffer , unichar , i - 1 ) ;
if ( paste_line_count > 0 & & last_char ! = ' \n ' & & last_char ! = ' \r ' ) {
/* there are newlines, but there's also stuff after the newline
* adjust line count to reflect this */
paste_line_count + + ;
}
2015-09-17 00:54:13 -03:00
/* decide what to do with the buffer */
paste_timeout ( NULL ) ;
paste_bracketed_mode = FALSE ;
}
2015-09-25 02:27:59 -03:00
static void paste_bracketed_middle ( )
{
int i ;
2015-09-25 03:09:14 -03:00
int marklen = G_N_ELEMENTS ( bp_end ) ;
int len = paste_buffer - > len - marklen ;
2015-09-25 02:27:59 -03:00
unichar * ptr = ( unichar * ) paste_buffer - > data ;
2015-09-25 03:22:02 -03:00
if ( len < 0 ) {
2015-09-25 02:27:59 -03:00
return ;
}
for ( i = 0 ; i < = len ; i + + , ptr + + ) {
if ( ptr [ 0 ] = = bp_end [ 0 ] & & memcmp ( ptr , bp_end , sizeof ( bp_end ) ) = = 0 ) {
2015-09-25 03:09:14 -03:00
/* if there are at least 6 bytes after the end,
* check for another start marker right afterwards */
if ( i < = ( len - marklen ) & &
memcmp ( ptr + marklen , bp_start , sizeof ( bp_start ) ) = = 0 ) {
/* remove both markers*/
g_array_remove_range ( paste_buffer , i , marklen * 2 ) ;
len - = marklen * 2 ;
/* go one step back */
2015-09-25 03:22:02 -03:00
i - - ;
ptr - - ;
2015-09-25 03:09:14 -03:00
continue ;
}
2015-09-25 02:27:59 -03:00
paste_bracketed_end ( i , i ! = len ) ;
break ;
}
}
}
2001-12-17 22:13:18 +00:00
static void sig_input ( void )
2000-04-26 08:03:38 +00:00
{
2001-11-18 18:12:28 +00:00
if ( ! active_entry ) {
/* no active entry yet - wait until we have it */
return ;
}
2010-02-27 14:57:16 +00:00
if ( paste_prompt ) {
GArray * buffer = g_array_new ( FALSE , FALSE , sizeof ( unichar ) ) ;
int line_count = 0 ;
unichar key ;
term_gets ( buffer , & line_count ) ;
key = g_array_index ( buffer , unichar , 0 ) ;
2015-09-08 00:40:25 +02:00
/* Either Ctrl-k or Ctrl-c is pressed */
2010-02-27 14:57:16 +00:00
if ( key = = 11 | | key = = 3 )
paste_flush ( key = = 11 ) ;
g_array_free ( buffer , TRUE ) ;
} else {
term_gets ( paste_buffer , & paste_line_count ) ;
2015-09-08 00:40:25 +02:00
2015-09-08 00:48:13 +02:00
/* use the bracketed paste mode to detect when the user pastes
* some text into the entry */
2015-09-17 00:52:55 -03:00
if ( paste_bracketed_mode ) {
2015-09-25 02:27:59 -03:00
paste_bracketed_middle ( ) ;
2015-09-08 00:40:25 +02:00
2015-12-12 01:17:48 -03:00
} else if ( ! paste_use_bracketed_mode & & paste_detect_time > 0 & & paste_buffer - > len > = 3 ) {
2010-02-27 14:57:16 +00:00
if ( paste_timeout_id ! = - 1 )
g_source_remove ( paste_timeout_id ) ;
paste_timeout_id = g_timeout_add ( paste_detect_time , paste_timeout , NULL ) ;
2015-09-17 00:52:55 -03:00
} else if ( ! paste_bracketed_mode ) {
2010-02-27 14:57:16 +00:00
int i ;
for ( i = 0 ; i < paste_buffer - > len ; i + + ) {
unichar key = g_array_index ( paste_buffer , unichar , i ) ;
signal_emit ( " gui key pressed " , 1 , GINT_TO_POINTER ( key ) ) ;
2015-09-17 00:52:55 -03:00
if ( paste_bracketed_mode ) {
/* just enabled by the signal, remove what was processed so far */
g_array_remove_range ( paste_buffer , 0 , i + 1 ) ;
2015-09-25 02:27:59 -03:00
/* handle single-line / small pastes here */
paste_bracketed_middle ( ) ;
2015-09-17 00:52:55 -03:00
return ;
}
2010-02-27 14:57:16 +00:00
}
g_array_set_size ( paste_buffer , 0 ) ;
paste_line_count = 0 ;
}
}
2000-04-26 08:03:38 +00:00
}
2015-09-17 00:52:55 -03:00
static void key_paste_start ( void )
{
paste_bracketed_mode = TRUE ;
}
2000-04-26 08:03:38 +00:00
time_t get_idle_time ( void )
{
2003-11-16 19:37:31 +00:00
return last_keypress . tv_sec ;
2000-04-26 08:03:38 +00:00
}
2000-07-23 00:29:31 +00:00
static void key_scroll_backward ( void )
2000-04-26 08:03:38 +00:00
{
2000-05-04 10:32:42 +00:00
window_prev_page ( ) ;
2000-04-26 08:03:38 +00:00
}
2000-07-23 00:29:31 +00:00
static void key_scroll_forward ( void )
2000-04-26 08:03:38 +00:00
{
2000-05-04 10:32:42 +00:00
window_next_page ( ) ;
2000-04-26 08:03:38 +00:00
}
2000-07-23 00:29:31 +00:00
static void key_scroll_start ( void )
{
signal_emit ( " command scrollback home " , 3 , NULL , active_win - > active_server , active_win - > active ) ;
}
static void key_scroll_end ( void )
{
signal_emit ( " command scrollback end " , 3 , NULL , active_win - > active_server , active_win - > active ) ;
}
static void key_change_window ( const char * data )
2000-04-26 08:03:38 +00:00
{
2000-05-04 10:32:42 +00:00
signal_emit ( " command window goto " , 3 , data , active_win - > active_server , active_win - > active ) ;
2000-04-26 08:03:38 +00:00
}
2008-05-17 13:12:21 +00:00
static void key_completion ( int erase , int backward )
2000-04-26 08:03:38 +00:00
{
2002-02-15 13:38:24 +00:00
char * text , * line ;
2000-05-04 10:32:42 +00:00
int pos ;
2000-04-26 08:03:38 +00:00
2006-01-29 22:37:24 +00:00
text = gui_entry_get_text_and_pos ( active_entry , & pos ) ;
2008-05-17 13:12:21 +00:00
line = word_complete ( active_win , text , & pos , erase , backward ) ;
2002-02-15 13:38:24 +00:00
g_free ( text ) ;
2000-05-04 10:32:42 +00:00
if ( line ! = NULL ) {
2001-10-13 16:11:13 +00:00
gui_entry_set_text ( active_entry , line ) ;
gui_entry_set_pos ( active_entry , pos ) ;
2000-05-04 10:32:42 +00:00
g_free ( line ) ;
}
2000-04-26 08:03:38 +00:00
}
2008-05-17 13:12:21 +00:00
static void key_word_completion_backward ( void )
{
key_completion ( FALSE , TRUE ) ;
}
2002-02-10 10:07:12 +00:00
static void key_word_completion ( void )
{
2008-05-17 13:12:21 +00:00
key_completion ( FALSE , FALSE ) ;
2002-02-10 10:07:12 +00:00
}
static void key_erase_completion ( void )
{
2008-05-17 13:12:21 +00:00
key_completion ( TRUE , FALSE ) ;
2002-02-10 10:07:12 +00:00
}
2000-07-23 00:29:31 +00:00
static void key_check_replaces ( void )
2000-04-26 08:03:38 +00:00
{
2002-02-15 13:38:24 +00:00
char * text , * line ;
2000-05-04 10:32:42 +00:00
int pos ;
2000-04-26 08:03:38 +00:00
2006-01-29 22:37:24 +00:00
text = gui_entry_get_text_and_pos ( active_entry , & pos ) ;
2002-02-15 13:38:24 +00:00
line = auto_word_complete ( text , & pos ) ;
g_free ( text ) ;
2000-05-04 10:32:42 +00:00
if ( line ! = NULL ) {
2001-10-13 16:11:13 +00:00
gui_entry_set_text ( active_entry , line ) ;
gui_entry_set_pos ( active_entry , pos ) ;
2000-05-04 10:32:42 +00:00
g_free ( line ) ;
}
2000-04-26 08:03:38 +00:00
}
2000-07-23 00:29:31 +00:00
static void key_previous_window ( void )
2000-04-26 08:03:38 +00:00
{
2001-03-04 08:10:45 +00:00
signal_emit ( " command window previous " , 3 , " " , active_win - > active_server , active_win - > active ) ;
2000-04-26 08:03:38 +00:00
}
2000-07-23 00:29:31 +00:00
static void key_next_window ( void )
2000-04-26 08:03:38 +00:00
{
2000-05-04 10:32:42 +00:00
signal_emit ( " command window next " , 3 , " " , active_win - > active_server , active_win - > active ) ;
}
2001-02-10 04:43:21 +00:00
static void key_left_window ( void )
{
signal_emit ( " command window left " , 3 , " " , active_win - > active_server , active_win - > active ) ;
}
static void key_right_window ( void )
{
signal_emit ( " command window right " , 3 , " " , active_win - > active_server , active_win - > active ) ;
}
2000-07-23 00:29:31 +00:00
static void key_upper_window ( void )
2000-05-04 10:32:42 +00:00
{
signal_emit ( " command window up " , 3 , " " , active_win - > active_server , active_win - > active ) ;
}
2000-07-23 00:29:31 +00:00
static void key_lower_window ( void )
2000-05-04 10:32:42 +00:00
{
signal_emit ( " command window down " , 3 , " " , active_win - > active_server , active_win - > active ) ;
2000-04-26 08:03:38 +00:00
}
2000-07-23 00:29:31 +00:00
static void key_active_window ( void )
2000-04-26 08:03:38 +00:00
{
2000-05-04 10:32:42 +00:00
signal_emit ( " command window goto " , 3 , " active " , active_win - > active_server , active_win - > active ) ;
2000-04-26 08:03:38 +00:00
}
2002-09-14 23:14:04 +00:00
static SERVER_REC * get_prev_server ( SERVER_REC * current )
{
int pos ;
if ( current = = NULL ) {
return servers ! = NULL ? g_slist_last ( servers ) - > data :
lookup_servers ! = NULL ?
g_slist_last ( lookup_servers ) - > data : NULL ;
}
/* connect2 -> connect1 -> server2 -> server1 -> connect2 -> .. */
pos = g_slist_index ( servers , current ) ;
if ( pos ! = - 1 ) {
if ( pos > 0 )
return g_slist_nth ( servers , pos - 1 ) - > data ;
if ( lookup_servers ! = NULL )
return g_slist_last ( lookup_servers ) - > data ;
return g_slist_last ( servers ) - > data ;
}
pos = g_slist_index ( lookup_servers , current ) ;
g_assert ( pos > = 0 ) ;
if ( pos > 0 )
return g_slist_nth ( lookup_servers , pos - 1 ) - > data ;
if ( servers ! = NULL )
return g_slist_last ( servers ) - > data ;
return g_slist_last ( lookup_servers ) - > data ;
}
static SERVER_REC * get_next_server ( SERVER_REC * current )
{
GSList * pos ;
if ( current = = NULL ) {
return servers ! = NULL ? servers - > data :
lookup_servers ! = NULL ? lookup_servers - > data : NULL ;
}
/* server1 -> server2 -> connect1 -> connect2 -> server1 -> .. */
pos = g_slist_find ( servers , current ) ;
if ( pos ! = NULL ) {
if ( pos - > next ! = NULL )
return pos - > next - > data ;
if ( lookup_servers ! = NULL )
return lookup_servers - > data ;
return servers - > data ;
}
pos = g_slist_find ( lookup_servers , current ) ;
g_assert ( pos ! = NULL ) ;
if ( pos - > next ! = NULL )
return pos - > next - > data ;
if ( servers ! = NULL )
return servers - > data ;
return lookup_servers - > data ;
}
2000-07-23 00:29:31 +00:00
static void key_previous_window_item ( void )
2000-04-26 08:03:38 +00:00
{
2000-06-10 19:16:25 +00:00
SERVER_REC * server ;
2002-09-14 23:14:04 +00:00
if ( active_win - > items ! = NULL ) {
signal_emit ( " command window item prev " , 3 , " " ,
active_win - > active_server , active_win - > active ) ;
} else if ( servers ! = NULL | | lookup_servers ! = NULL ) {
2000-06-10 19:16:25 +00:00
/* change server */
2002-09-14 23:14:04 +00:00
server = active_win - > active_server ;
if ( server = = NULL )
server = active_win - > connect_server ;
server = get_prev_server ( server ) ;
signal_emit ( " command window server " , 3 , server - > tag ,
active_win - > active_server , active_win - > active ) ;
2000-06-10 19:16:25 +00:00
}
2000-04-26 08:03:38 +00:00
}
2000-07-23 00:29:31 +00:00
static void key_next_window_item ( void )
2000-04-26 08:03:38 +00:00
{
2000-06-10 19:16:25 +00:00
SERVER_REC * server ;
2001-05-11 13:44:23 +00:00
if ( active_win - > items ! = NULL ) {
signal_emit ( " command window item next " , 3 , " " ,
active_win - > active_server , active_win - > active ) ;
2002-09-14 23:14:04 +00:00
} else if ( servers ! = NULL | | lookup_servers ! = NULL ) {
2000-06-10 19:16:25 +00:00
/* change server */
2002-09-14 23:14:04 +00:00
server = active_win - > active_server ;
if ( server = = NULL )
server = active_win - > connect_server ;
server = get_next_server ( server ) ;
2001-05-11 13:44:23 +00:00
signal_emit ( " command window server " , 3 , server - > tag ,
active_win - > active_server , active_win - > active ) ;
2000-06-10 19:16:25 +00:00
}
2000-04-26 08:03:38 +00:00
}
2002-02-18 20:59:40 +00:00
static void key_escape ( void )
{
escape_next_key = TRUE ;
}
2001-05-11 13:44:23 +00:00
static void key_insert_text ( const char * data )
2000-04-26 08:03:38 +00:00
{
2001-05-11 13:44:23 +00:00
char * str ;
str = parse_special_string ( data , active_win - > active_server ,
active_win - > active , " " , NULL , 0 ) ;
2001-10-13 16:11:13 +00:00
gui_entry_insert_text ( active_entry , str ) ;
2001-05-11 13:44:23 +00:00
g_free ( str ) ;
2000-04-26 08:03:38 +00:00
}
2001-10-28 11:30:26 +00:00
static void key_sig_stop ( void )
{
term_stop ( ) ;
}
2000-07-10 23:00:56 +00:00
static void sig_window_auto_changed ( void )
2000-04-26 08:03:38 +00:00
{
2002-02-15 13:38:24 +00:00
char * text ;
2001-11-19 15:59:55 +00:00
if ( active_entry = = NULL )
return ;
2002-02-15 13:38:24 +00:00
text = gui_entry_get_text ( active_entry ) ;
command_history_next ( active_win , text ) ;
2001-10-13 16:11:13 +00:00
gui_entry_set_text ( active_entry , " " ) ;
2002-02-15 13:38:24 +00:00
g_free ( text ) ;
2000-04-26 08:03:38 +00:00
}
2001-01-04 18:01:51 +00:00
static void sig_gui_entry_redirect ( SIGNAL_FUNC func , const char * entry ,
void * flags , void * data )
2000-05-04 10:32:42 +00:00
{
redir = g_new0 ( ENTRY_REDIRECT_REC , 1 ) ;
redir - > func = func ;
2001-01-04 18:01:51 +00:00
redir - > flags = GPOINTER_TO_INT ( flags ) ;
2000-05-04 10:32:42 +00:00
redir - > data = data ;
2001-01-04 18:01:51 +00:00
if ( redir - > flags & ENTRY_REDIRECT_FLAG_HIDDEN )
2001-10-13 16:11:13 +00:00
gui_entry_set_hidden ( active_entry , TRUE ) ;
gui_entry_set_prompt ( active_entry , entry ) ;
2000-05-04 10:32:42 +00:00
}
2003-11-16 19:37:31 +00:00
static void setup_changed ( void )
{
paste_detect_time = settings_get_time ( " paste_detect_time " ) ;
2004-03-23 21:17:40 +00:00
2004-01-19 18:59:17 +00:00
paste_verify_line_count = settings_get_int ( " paste_verify_line_count " ) ;
paste_join_multiline = settings_get_bool ( " paste_join_multiline " ) ;
2015-09-08 00:48:13 +02:00
paste_use_bracketed_mode = settings_get_bool ( " paste_use_bracketed_mode " ) ;
2015-09-09 22:35:11 +02:00
2016-03-22 16:54:34 +01:00
term_set_appkey_mode ( settings_get_bool ( " term_appkey_mode " ) ) ;
2015-09-09 22:35:11 +02:00
/* Enable the bracketed paste mode on demand */
term_set_bracketed_paste_mode ( paste_use_bracketed_mode ) ;
2003-11-16 19:37:31 +00:00
}
2000-04-26 08:03:38 +00:00
void gui_readline_init ( void )
{
2001-05-06 19:28:15 +00:00
static char changekeys [ ] = " 1234567890qwertyuio " ;
2000-05-04 10:32:42 +00:00
char * key , data [ MAX_INT_STRLEN ] ;
int n ;
2000-04-26 08:03:38 +00:00
2002-02-18 20:59:40 +00:00
escape_next_key = FALSE ;
2000-05-04 10:32:42 +00:00
redir = NULL ;
2003-11-16 19:37:31 +00:00
paste_entry = NULL ;
paste_entry_pos = 0 ;
2003-11-17 00:01:17 +00:00
paste_buffer = g_array_new ( FALSE , FALSE , sizeof ( unichar ) ) ;
2015-09-17 00:54:13 -03:00
paste_buffer_rest = g_array_new ( FALSE , FALSE , sizeof ( unichar ) ) ;
2003-11-17 00:02:51 +00:00
paste_old_prompt = NULL ;
2010-02-27 14:57:16 +00:00
paste_timeout_id = - 1 ;
2015-09-08 00:40:25 +02:00
paste_bracketed_mode = FALSE ;
2003-11-16 19:37:31 +00:00
g_get_current_time ( & last_keypress ) ;
2001-12-17 22:13:18 +00:00
input_listen_init ( STDIN_FILENO ) ;
2000-04-26 08:03:38 +00:00
2016-03-22 16:54:34 +01:00
settings_add_bool ( " lookandfeel " , " term_appkey_mode " , TRUE ) ;
2000-12-04 13:11:44 +00:00
settings_add_str ( " history " , " scroll_page_count " , " /2 " ) ;
2003-11-17 18:20:35 +00:00
settings_add_time ( " misc " , " paste_detect_time " , " 5msecs " ) ;
2015-09-08 00:48:13 +02:00
settings_add_bool ( " misc " , " paste_use_bracketed_mode " , FALSE ) ;
2003-11-16 20:33:17 +00:00
/* NOTE: function keys can generate at least 5 characters long
keycodes . this must be larger to allow them to work . */
2003-11-16 21:49:15 +00:00
settings_add_int ( " misc " , " paste_verify_line_count " , 5 ) ;
2004-01-19 18:59:17 +00:00
settings_add_bool ( " misc " , " paste_join_multiline " , TRUE ) ;
2003-11-16 19:37:31 +00:00
setup_changed ( ) ;
2000-12-04 13:11:44 +00:00
2001-05-06 19:28:15 +00:00
keyboard = keyboard_create ( NULL ) ;
key_configure_freeze ( ) ;
2000-04-26 08:03:38 +00:00
2001-09-11 18:15:17 +00:00
key_bind ( " key " , NULL , " " , " space " , ( SIGNAL_FUNC ) key_combo ) ;
2001-05-06 19:28:15 +00:00
key_bind ( " key " , NULL , " ^M " , " return " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " ^J " , " return " , ( SIGNAL_FUNC ) key_combo ) ;
2002-02-02 02:22:29 +00:00
key_bind ( " key " , NULL , " ^H " , " backspace " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " ^? " , " backspace " , ( SIGNAL_FUNC ) key_combo ) ;
2002-02-17 10:09:04 +00:00
key_bind ( " key " , NULL , " ^I " , " tab " , ( SIGNAL_FUNC ) key_combo ) ;
2000-04-26 08:03:38 +00:00
2001-05-06 19:28:15 +00:00
/* meta */
key_bind ( " key " , NULL , " ^[ " , " meta " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta-[ " , " meta2 " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta-O " , " meta2 " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta-[O " , " meta2 " , ( SIGNAL_FUNC ) key_combo ) ;
/* arrow keys */
key_bind ( " key " , NULL , " meta2-A " , " up " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-B " , " down " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-C " , " right " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-D " , " left " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-1~ " , " home " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-7~ " , " home " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-H " , " home " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-4~ " , " end " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-8~ " , " end " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-F " , " end " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-5~ " , " prior " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-I " , " prior " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-6~ " , " next " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-G " , " next " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-2~ " , " insert " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-3~ " , " delete " , ( SIGNAL_FUNC ) key_combo ) ;
2001-11-19 23:57:29 +00:00
key_bind ( " key " , NULL , " meta2-d " , " cleft " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-c " , " cright " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-5D " , " cleft " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-5C " , " cright " , ( SIGNAL_FUNC ) key_combo ) ;
2007-04-07 14:57:58 +00:00
key_bind ( " key " , NULL , " meta2-1;5D " , " cleft " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-1;5C " , " cright " , ( SIGNAL_FUNC ) key_combo ) ;
2001-11-19 23:57:29 +00:00
2007-08-24 17:13:21 +00:00
key_bind ( " key " , NULL , " meta2-1;3A " , " mup " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-1;3B " , " mdown " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-1;3D " , " mleft " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-1;3C " , " mright " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta-up " , " mup " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta-down " , " mdown " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta-left " , " mleft " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta-right " , " mright " , ( SIGNAL_FUNC ) key_combo ) ;
2009-05-22 12:48:02 +00:00
key_bind ( " key " , NULL , " meta2-1;5~ " , " chome " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-7;5~ " , " chome " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-5H " , " chome " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-1;5H " , " chome " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-4;5~ " , " cend " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-8;5~ " , " cend " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-5F " , " cend " , ( SIGNAL_FUNC ) key_combo ) ;
key_bind ( " key " , NULL , " meta2-1;5F " , " cend " , ( SIGNAL_FUNC ) key_combo ) ;
2015-10-06 04:51:16 -03:00
key_bind ( " key " , NULL , " meta-O-M " , " return " , ( SIGNAL_FUNC ) key_combo ) ;
2015-09-17 00:52:55 -03:00
key_bind ( " paste_start " , " Bracketed paste start " , " meta2-200~ " , " paste_start " , ( SIGNAL_FUNC ) key_paste_start ) ;
2001-11-19 23:57:29 +00:00
/* cursor movement */
2008-05-18 20:49:20 +00:00
key_bind ( " backward_character " , " Move the cursor a character backward " , " left " , NULL , ( SIGNAL_FUNC ) key_backward_character ) ;
key_bind ( " forward_character " , " Move the cursor a character forward " , " right " , NULL , ( SIGNAL_FUNC ) key_forward_character ) ;
key_bind ( " backward_word " , " Move the cursor a word backward " , " cleft " , NULL , ( SIGNAL_FUNC ) key_backward_word ) ;
2002-02-15 15:54:59 +00:00
key_bind ( " backward_word " , NULL , " meta-b " , NULL , ( SIGNAL_FUNC ) key_backward_word ) ;
2008-05-18 20:49:20 +00:00
key_bind ( " forward_word " , " Move the cursor a word forward " , " cright " , NULL , ( SIGNAL_FUNC ) key_forward_word ) ;
2002-02-15 15:54:59 +00:00
key_bind ( " forward_word " , NULL , " meta-f " , NULL , ( SIGNAL_FUNC ) key_forward_word ) ;
2008-05-18 20:49:20 +00:00
key_bind ( " backward_to_space " , " Move the cursor backward to a space " , NULL , NULL , ( SIGNAL_FUNC ) key_backward_to_space ) ;
key_bind ( " forward_to_space " , " Move the cursor forward to a space " , NULL , NULL , ( SIGNAL_FUNC ) key_forward_to_space ) ;
key_bind ( " beginning_of_line " , " Move the cursor to the beginning of the line " , " home " , NULL , ( SIGNAL_FUNC ) key_beginning_of_line ) ;
2001-05-06 19:28:15 +00:00
key_bind ( " beginning_of_line " , NULL , " ^A " , NULL , ( SIGNAL_FUNC ) key_beginning_of_line ) ;
2008-05-18 20:49:20 +00:00
key_bind ( " end_of_line " , " Move the cursor to the end of the line " , " end " , NULL , ( SIGNAL_FUNC ) key_end_of_line ) ;
2001-05-06 19:28:15 +00:00
key_bind ( " end_of_line " , NULL , " ^E " , NULL , ( SIGNAL_FUNC ) key_end_of_line ) ;
/* history */
2008-05-18 20:49:20 +00:00
key_bind ( " backward_history " , " Go back one line in the history " , " up " , NULL , ( SIGNAL_FUNC ) key_backward_history ) ;
key_bind ( " forward_history " , " Go forward one line in the history " , " down " , NULL , ( SIGNAL_FUNC ) key_forward_history ) ;
2001-05-06 19:28:15 +00:00
/* line editing */
2008-05-18 20:49:20 +00:00
key_bind ( " backspace " , " Delete the previous character " , " backspace " , NULL , ( SIGNAL_FUNC ) key_backspace ) ;
key_bind ( " delete_character " , " Delete the current character " , " delete " , NULL , ( SIGNAL_FUNC ) key_delete_character ) ;
2001-05-06 19:28:15 +00:00
key_bind ( " delete_character " , NULL , " ^D " , NULL , ( SIGNAL_FUNC ) key_delete_character ) ;
2008-05-18 20:49:20 +00:00
key_bind ( " delete_next_word " , " Delete the word after the cursor " , " meta-d " , NULL , ( SIGNAL_FUNC ) key_delete_next_word ) ;
key_bind ( " delete_previous_word " , " Delete the word before the cursor " , " meta-backspace " , NULL , ( SIGNAL_FUNC ) key_delete_previous_word ) ;
key_bind ( " delete_to_previous_space " , " Delete up to the previous space " , " ^W " , NULL , ( SIGNAL_FUNC ) key_delete_to_previous_space ) ;
key_bind ( " delete_to_next_space " , " Delete up to the next space " , " " , NULL , ( SIGNAL_FUNC ) key_delete_to_next_space ) ;
key_bind ( " erase_line " , " Erase the whole input line " , " ^U " , NULL , ( SIGNAL_FUNC ) key_erase_line ) ;
key_bind ( " erase_to_beg_of_line " , " Erase everything before the cursor " , NULL , NULL , ( SIGNAL_FUNC ) key_erase_to_beg_of_line ) ;
key_bind ( " erase_to_end_of_line " , " Erase everything after the cursor " , " ^K " , NULL , ( SIGNAL_FUNC ) key_erase_to_end_of_line ) ;
key_bind ( " yank_from_cutbuffer " , " \" Undelete \" , paste the last deleted text " , " ^Y " , NULL , ( SIGNAL_FUNC ) key_yank_from_cutbuffer ) ;
2016-03-21 09:14:01 +01:00
key_bind ( " yank_next_cutbuffer " , " Revert to the previous last deleted text " , NULL , NULL , ( SIGNAL_FUNC ) key_yank_next_cutbuffer ) ;
key_bind ( " append_next_kill " , " Append next deletion " , NULL , NULL , ( SIGNAL_FUNC ) key_append_next_kill ) ;
2001-05-06 19:28:15 +00:00
key_bind ( " transpose_characters " , " Swap current and previous character " , " ^T " , NULL , ( SIGNAL_FUNC ) key_transpose_characters ) ;
2005-08-27 22:06:34 +00:00
key_bind ( " transpose_words " , " Swap current and previous word " , NULL , NULL , ( SIGNAL_FUNC ) key_transpose_words ) ;
2008-05-18 20:49:20 +00:00
key_bind ( " capitalize_word " , " Capitalize the current word " , NULL , NULL , ( SIGNAL_FUNC ) key_capitalize_word ) ;
key_bind ( " downcase_word " , " Downcase the current word " , NULL , NULL , ( SIGNAL_FUNC ) key_downcase_word ) ;
key_bind ( " upcase_word " , " Upcase the current word " , NULL , NULL , ( SIGNAL_FUNC ) key_upcase_word ) ;
2000-07-23 00:29:31 +00:00
2001-05-06 19:28:15 +00:00
/* line transmitting */
key_bind ( " send_line " , " Execute the input line " , " return " , NULL , ( SIGNAL_FUNC ) key_send_line ) ;
2008-05-17 13:12:21 +00:00
key_bind ( " word_completion_backward " , " " , NULL , NULL , ( SIGNAL_FUNC ) key_word_completion_backward ) ;
2008-05-18 20:49:20 +00:00
key_bind ( " word_completion " , " Complete the current word " , " tab " , NULL , ( SIGNAL_FUNC ) key_word_completion ) ;
key_bind ( " erase_completion " , " Remove the completion added by word_completion " , " meta-k " , NULL , ( SIGNAL_FUNC ) key_erase_completion ) ;
2001-09-11 18:15:17 +00:00
key_bind ( " check_replaces " , " Check word replaces " , NULL , NULL , ( SIGNAL_FUNC ) key_check_replaces ) ;
2001-05-06 19:28:15 +00:00
/* window managing */
2008-05-18 20:49:20 +00:00
key_bind ( " previous_window " , " Go to the previous window " , " ^P " , NULL , ( SIGNAL_FUNC ) key_previous_window ) ;
key_bind ( " next_window " , " Go to the next window " , " ^N " , NULL , ( SIGNAL_FUNC ) key_next_window ) ;
key_bind ( " upper_window " , " Go to the split window above " , " mup " , NULL , ( SIGNAL_FUNC ) key_upper_window ) ;
key_bind ( " lower_window " , " Go to the split window below " , " mdown " , NULL , ( SIGNAL_FUNC ) key_lower_window ) ;
key_bind ( " left_window " , " Go to the previous window in the current split window " , " mleft " , NULL , ( SIGNAL_FUNC ) key_left_window ) ;
key_bind ( " right_window " , " Go to the next window in the current split window " , " mright " , NULL , ( SIGNAL_FUNC ) key_right_window ) ;
2001-05-06 19:28:15 +00:00
key_bind ( " active_window " , " Go to next window with the highest activity " , " meta-a " , NULL , ( SIGNAL_FUNC ) key_active_window ) ;
2008-05-18 20:49:20 +00:00
key_bind ( " next_window_item " , " Go to the next channel/query. In empty windows change to the next server " , " ^X " , NULL , ( SIGNAL_FUNC ) key_next_window_item ) ;
key_bind ( " previous_window_item " , " Go to the previous channel/query. In empty windows change to the previous server " , NULL , NULL , ( SIGNAL_FUNC ) key_previous_window_item ) ;
2000-07-23 00:29:31 +00:00
2001-05-06 19:28:15 +00:00
key_bind ( " refresh_screen " , " Redraw screen " , " ^L " , NULL , ( SIGNAL_FUNC ) irssi_redraw ) ;
2008-05-18 20:49:20 +00:00
key_bind ( " scroll_backward " , " Scroll to previous page " , " prior " , NULL , ( SIGNAL_FUNC ) key_scroll_backward ) ;
2001-05-06 19:28:15 +00:00
key_bind ( " scroll_backward " , NULL , " meta-p " , NULL , ( SIGNAL_FUNC ) key_scroll_backward ) ;
2008-05-18 20:49:20 +00:00
key_bind ( " scroll_forward " , " Scroll to next page " , " next " , NULL , ( SIGNAL_FUNC ) key_scroll_forward ) ;
2001-05-06 19:28:15 +00:00
key_bind ( " scroll_forward " , NULL , " meta-n " , NULL , ( SIGNAL_FUNC ) key_scroll_forward ) ;
2009-05-22 12:48:02 +00:00
key_bind ( " scroll_start " , " Scroll to the beginning of the window " , " chome " , NULL , ( SIGNAL_FUNC ) key_scroll_start ) ;
key_bind ( " scroll_end " , " Scroll to the end of the window " , " cend " , NULL , ( SIGNAL_FUNC ) key_scroll_end ) ;
2000-07-23 00:29:31 +00:00
2001-05-06 19:28:15 +00:00
/* inserting special input characters to line.. */
2008-05-18 20:49:20 +00:00
key_bind ( " escape_char " , " Insert the next character exactly as-is to input line " , NULL , NULL , ( SIGNAL_FUNC ) key_escape ) ;
2001-05-11 13:44:23 +00:00
key_bind ( " insert_text " , " Append text to line " , NULL , NULL , ( SIGNAL_FUNC ) key_insert_text ) ;
2001-05-06 19:28:15 +00:00
2001-10-28 11:30:26 +00:00
/* autoreplaces */
2001-05-06 19:28:15 +00:00
key_bind ( " multi " , NULL , " return " , " check_replaces;send_line " , NULL ) ;
2001-09-11 18:15:17 +00:00
key_bind ( " multi " , NULL , " space " , " check_replaces;insert_text " , NULL ) ;
2000-04-26 08:03:38 +00:00
2001-10-28 11:30:26 +00:00
/* moving between windows */
2000-05-04 10:32:42 +00:00
for ( n = 0 ; changekeys [ n ] ! = ' \0 ' ; n + + ) {
2001-05-06 19:28:15 +00:00
key = g_strdup_printf ( " meta-%c " , changekeys [ n ] ) ;
2000-05-04 10:32:42 +00:00
ltoa ( data , n + 1 ) ;
2000-07-23 00:29:31 +00:00
key_bind ( " change_window " , " Change window " , key , data , ( SIGNAL_FUNC ) key_change_window ) ;
2000-05-04 10:32:42 +00:00
g_free ( key ) ;
}
2000-04-26 08:03:38 +00:00
2001-10-28 11:30:26 +00:00
/* misc */
key_bind ( " stop_irc " , " Send SIGSTOP to client " , " ^Z " , NULL , ( SIGNAL_FUNC ) key_sig_stop ) ;
2001-05-06 19:28:15 +00:00
key_configure_thaw ( ) ;
2000-05-04 10:32:42 +00:00
signal_add ( " window changed automatic " , ( SIGNAL_FUNC ) sig_window_auto_changed ) ;
signal_add ( " gui entry redirect " , ( SIGNAL_FUNC ) sig_gui_entry_redirect ) ;
2002-11-05 13:34:31 +00:00
signal_add ( " gui key pressed " , ( SIGNAL_FUNC ) sig_gui_key_pressed ) ;
2003-11-16 19:37:31 +00:00
signal_add ( " setup changed " , ( SIGNAL_FUNC ) setup_changed ) ;
2000-04-26 08:03:38 +00:00
}
void gui_readline_deinit ( void )
{
2001-12-17 22:13:18 +00:00
input_listen_deinit ( ) ;
2000-04-26 08:03:38 +00:00
2001-05-06 19:28:15 +00:00
key_configure_freeze ( ) ;
2015-09-17 00:52:55 -03:00
key_unbind ( " paste_start " , ( SIGNAL_FUNC ) key_paste_start ) ;
2000-07-23 23:46:41 +00:00
key_unbind ( " backward_character " , ( SIGNAL_FUNC ) key_backward_character ) ;
key_unbind ( " forward_character " , ( SIGNAL_FUNC ) key_forward_character ) ;
key_unbind ( " backward_word " , ( SIGNAL_FUNC ) key_backward_word ) ;
key_unbind ( " forward_word " , ( SIGNAL_FUNC ) key_forward_word ) ;
2001-10-25 14:39:36 +00:00
key_unbind ( " backward_to_space " , ( SIGNAL_FUNC ) key_backward_to_space ) ;
key_unbind ( " forward_to_space " , ( SIGNAL_FUNC ) key_forward_to_space ) ;
2000-07-23 23:46:41 +00:00
key_unbind ( " beginning_of_line " , ( SIGNAL_FUNC ) key_beginning_of_line ) ;
key_unbind ( " end_of_line " , ( SIGNAL_FUNC ) key_end_of_line ) ;
2000-04-26 08:03:38 +00:00
2000-07-23 23:46:41 +00:00
key_unbind ( " backward_history " , ( SIGNAL_FUNC ) key_backward_history ) ;
key_unbind ( " forward_history " , ( SIGNAL_FUNC ) key_forward_history ) ;
2000-04-26 08:03:38 +00:00
2000-07-23 23:46:41 +00:00
key_unbind ( " backspace " , ( SIGNAL_FUNC ) key_backspace ) ;
key_unbind ( " delete_character " , ( SIGNAL_FUNC ) key_delete_character ) ;
key_unbind ( " delete_next_word " , ( SIGNAL_FUNC ) key_delete_next_word ) ;
key_unbind ( " delete_previous_word " , ( SIGNAL_FUNC ) key_delete_previous_word ) ;
2001-10-25 14:39:36 +00:00
key_unbind ( " delete_to_next_space " , ( SIGNAL_FUNC ) key_delete_to_next_space ) ;
2000-07-23 23:46:41 +00:00
key_unbind ( " delete_to_previous_space " , ( SIGNAL_FUNC ) key_delete_to_previous_space ) ;
key_unbind ( " erase_line " , ( SIGNAL_FUNC ) key_erase_line ) ;
key_unbind ( " erase_to_beg_of_line " , ( SIGNAL_FUNC ) key_erase_to_beg_of_line ) ;
key_unbind ( " erase_to_end_of_line " , ( SIGNAL_FUNC ) key_erase_to_end_of_line ) ;
key_unbind ( " yank_from_cutbuffer " , ( SIGNAL_FUNC ) key_yank_from_cutbuffer ) ;
2016-03-21 09:14:01 +01:00
key_unbind ( " yank_next_cutbuffer " , ( SIGNAL_FUNC ) key_yank_next_cutbuffer ) ;
key_unbind ( " append_next_kill " , ( SIGNAL_FUNC ) key_append_next_kill ) ;
2000-11-11 01:46:15 +00:00
key_unbind ( " transpose_characters " , ( SIGNAL_FUNC ) key_transpose_characters ) ;
2005-08-27 22:06:34 +00:00
key_unbind ( " transpose_words " , ( SIGNAL_FUNC ) key_transpose_words ) ;
key_unbind ( " capitalize_word " , ( SIGNAL_FUNC ) key_capitalize_word ) ;
key_unbind ( " downcase_word " , ( SIGNAL_FUNC ) key_downcase_word ) ;
key_unbind ( " upcase_word " , ( SIGNAL_FUNC ) key_upcase_word ) ;
2000-07-23 23:46:41 +00:00
2002-04-15 14:06:57 +00:00
key_unbind ( " send_line " , ( SIGNAL_FUNC ) key_send_line ) ;
2008-05-17 13:12:21 +00:00
key_unbind ( " word_completion_backward " , ( SIGNAL_FUNC ) key_word_completion_backward ) ;
2000-07-23 23:46:41 +00:00
key_unbind ( " word_completion " , ( SIGNAL_FUNC ) key_word_completion ) ;
2002-04-15 14:06:57 +00:00
key_unbind ( " erase_completion " , ( SIGNAL_FUNC ) key_erase_completion ) ;
2000-07-23 23:46:41 +00:00
key_unbind ( " check_replaces " , ( SIGNAL_FUNC ) key_check_replaces ) ;
key_unbind ( " previous_window " , ( SIGNAL_FUNC ) key_previous_window ) ;
key_unbind ( " next_window " , ( SIGNAL_FUNC ) key_next_window ) ;
key_unbind ( " upper_window " , ( SIGNAL_FUNC ) key_upper_window ) ;
key_unbind ( " lower_window " , ( SIGNAL_FUNC ) key_lower_window ) ;
2002-04-15 14:06:57 +00:00
key_unbind ( " left_window " , ( SIGNAL_FUNC ) key_left_window ) ;
key_unbind ( " right_window " , ( SIGNAL_FUNC ) key_right_window ) ;
2000-07-23 23:46:41 +00:00
key_unbind ( " active_window " , ( SIGNAL_FUNC ) key_active_window ) ;
key_unbind ( " next_window_item " , ( SIGNAL_FUNC ) key_next_window_item ) ;
key_unbind ( " previous_window_item " , ( SIGNAL_FUNC ) key_previous_window_item ) ;
key_unbind ( " refresh_screen " , ( SIGNAL_FUNC ) irssi_redraw ) ;
key_unbind ( " scroll_backward " , ( SIGNAL_FUNC ) key_scroll_backward ) ;
key_unbind ( " scroll_forward " , ( SIGNAL_FUNC ) key_scroll_forward ) ;
key_unbind ( " scroll_start " , ( SIGNAL_FUNC ) key_scroll_start ) ;
key_unbind ( " scroll_end " , ( SIGNAL_FUNC ) key_scroll_end ) ;
2002-02-18 20:59:40 +00:00
key_unbind ( " escape_char " , ( SIGNAL_FUNC ) key_escape ) ;
2001-05-11 13:44:23 +00:00
key_unbind ( " insert_text " , ( SIGNAL_FUNC ) key_insert_text ) ;
2000-07-23 23:46:41 +00:00
key_unbind ( " change_window " , ( SIGNAL_FUNC ) key_change_window ) ;
2001-10-28 11:30:26 +00:00
key_unbind ( " stop_irc " , ( SIGNAL_FUNC ) key_sig_stop ) ;
2003-11-16 21:49:15 +00:00
keyboard_destroy ( keyboard ) ;
g_array_free ( paste_buffer , TRUE ) ;
2015-09-17 00:54:13 -03:00
g_array_free ( paste_buffer_rest , TRUE ) ;
2001-05-06 19:28:15 +00:00
key_configure_thaw ( ) ;
2000-04-26 08:03:38 +00:00
2000-05-04 10:32:42 +00:00
signal_remove ( " window changed automatic " , ( SIGNAL_FUNC ) sig_window_auto_changed ) ;
signal_remove ( " gui entry redirect " , ( SIGNAL_FUNC ) sig_gui_entry_redirect ) ;
2002-11-05 13:34:31 +00:00
signal_remove ( " gui key pressed " , ( SIGNAL_FUNC ) sig_gui_key_pressed ) ;
2003-11-16 19:37:31 +00:00
signal_remove ( " setup changed " , ( SIGNAL_FUNC ) setup_changed ) ;
2000-04-26 08:03:38 +00:00
}