From c6a2bb8a906ab3074f84ffa3e59681c2543f2159 Mon Sep 17 00:00:00 2001 From: Marvin Ewald Date: Sun, 28 Feb 2016 21:53:33 +0100 Subject: [PATCH] Add settings option to set paste-mode key and update docs --- doc/toxic.conf.5 | 5 +++++ doc/toxic.conf.5.asc | 3 +++ misc/toxic.conf.example | 1 + src/help.c | 6 ++++-- src/input.c | 21 +++++++++++---------- src/settings.c | 5 +++++ src/settings.h | 1 + 7 files changed, 30 insertions(+), 12 deletions(-) diff --git a/doc/toxic.conf.5 b/doc/toxic.conf.5 index 24a2f5d..a3698ec 100644 --- a/doc/toxic.conf.5 +++ b/doc/toxic.conf.5 @@ -313,6 +313,11 @@ Key combination to scroll contacts list down\&. .RS 4 Toggle the peer list on and off\&. .RE +.PP +\fBtoggle_paste_mode\fR +.RS 4 +Toggle treating linebreaks as enter key press\&. +.RE .RE .SH "FILES" .PP diff --git a/doc/toxic.conf.5.asc b/doc/toxic.conf.5.asc index a90e964..376a992 100644 --- a/doc/toxic.conf.5.asc +++ b/doc/toxic.conf.5.asc @@ -201,6 +201,9 @@ OPTIONS *toggle_peerlist*;; Toggle the peer list on and off. + *toggle_paste_mode*;; + Toggle treating linebreaks as enter key press. + FILES ----- diff --git a/misc/toxic.conf.example b/misc/toxic.conf.example index fa2f8b7..a6419d0 100644 --- a/misc/toxic.conf.example +++ b/misc/toxic.conf.example @@ -101,5 +101,6 @@ keys = { peer_list_up="Ctrl+["; peer_list_down="Ctrl+]"; toggle_peerlist="Ctrl+b"; + toggle_paste_mode="Ctrl+T"; }; diff --git a/src/help.c b/src/help.c index d986ee7..86d48b1 100644 --- a/src/help.c +++ b/src/help.c @@ -245,7 +245,9 @@ static void help_draw_keys(ToxWindow *self) wprintw(win, " Ctrl+F and Ctrl+V : Scroll window history half a page\n"); wprintw(win, " Ctrl+H : Move to the bottom of window history\n"); wprintw(win, " Ctrl+[ and Ctrl+] : Scroll peer list in groupchats\n"); - wprintw(win, " Ctrl+B : Toggle the groupchat peerlist\n\n"); + wprintw(win, " Ctrl+B : Toggle the groupchat peerlist\n"); + wprintw(win, " Ctrl+J : Insert new line\n"); + wprintw(win, " Ctrl+T : Toggle paste mode\n\n"); wprintw(win, " (Note: Custom keybindings override these defaults.)\n\n"); help_draw_bottom_menu(win); @@ -335,7 +337,7 @@ void help_onKey(ToxWindow *self, wint_t key) break; case 'k': - help_init_window(self, 13, 80); + help_init_window(self, 15, 80); self->help->type = HELP_KEYS; break; diff --git a/src/input.c b/src/input.c index df24156..649dad9 100644 --- a/src/input.c +++ b/src/input.c @@ -262,10 +262,6 @@ bool input_handle(ToxWindow *self, wint_t key, int x, int y, int mx_x, int mx_y) force_refresh(self->chatwin->history); break; - case T_KEY_C_T: - self->chatwin->pastemode ^= 1; - break; - default: match = false; break; @@ -273,13 +269,18 @@ bool input_handle(ToxWindow *self, wint_t key, int x, int y, int mx_x, int mx_y) /* TODO: this special case is ugly. maybe convert entire function to if/else and make them all customizable keys? */ - if (!match && key == user_settings->key_toggle_peerlist) { - if (self->is_groupchat) { - self->show_peerlist ^= 1; - redraw_groupchat_win(self); + if (!match) { + if (key == user_settings->key_toggle_peerlist) { + if (self->is_groupchat) { + self->show_peerlist ^= 1; + redraw_groupchat_win(self); + } + match = true; + } + else if (key == user_settings->key_toggle_pastemode) { + self->chatwin->pastemode ^= 1; + match = true; } - - match = true; } return match; diff --git a/src/settings.c b/src/settings.c index b6d896c..1cbd6e2 100644 --- a/src/settings.c +++ b/src/settings.c @@ -127,6 +127,7 @@ static const struct keys_strings { const char* peer_list_up; const char* peer_list_down; const char* toggle_peerlist; + const char* toggle_pastemode; } key_strings = { "keys", "next_tab", @@ -139,6 +140,7 @@ static const struct keys_strings { "peer_list_up", "peer_list_down", "toggle_peerlist", + "toggle_paste_mode", }; /* defines from toxic.h */ @@ -154,6 +156,7 @@ static void key_defaults(struct user_settings* settings) settings->key_peer_list_up = T_KEY_C_LB; settings->key_peer_list_down = T_KEY_C_RB; settings->key_toggle_peerlist = T_KEY_C_B; + settings->key_toggle_pastemode = T_KEY_C_T; } static const struct tox_strings { @@ -399,6 +402,8 @@ int settings_load(struct user_settings *s, const char *patharg) s->key_peer_list_down = key_parse(&tmp); if (config_setting_lookup_string(setting, key_strings.toggle_peerlist, &tmp)) s->key_toggle_peerlist = key_parse(&tmp); + if (config_setting_lookup_string(setting, key_strings.toggle_pastemode, &tmp)) + s->key_toggle_pastemode = key_parse(&tmp); } #ifdef AUDIO diff --git a/src/settings.h b/src/settings.h index 696eb01..53418af 100644 --- a/src/settings.h +++ b/src/settings.h @@ -68,6 +68,7 @@ struct user_settings { int key_peer_list_up; int key_peer_list_down; int key_toggle_peerlist; + int key_toggle_pastemode; int mplex_away; /* boolean (1 for reaction to terminal attach/detach) */ char mplex_away_note [TOX_MAX_STATUS_MESSAGE_LENGTH];