diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/command.c | 21 | ||||
-rw-r--r-- | src/preferences.c | 17 | ||||
-rw-r--r-- | src/preferences.h | 2 | ||||
-rw-r--r-- | src/windows.c | 58 |
4 files changed, 74 insertions, 24 deletions
diff --git a/src/command.c b/src/command.c index ba69da15..e0c18e8e 100644 --- a/src/command.c +++ b/src/command.c @@ -119,6 +119,7 @@ static gboolean _cmd_set_gone(gchar **args, struct cmd_help_t help); static gboolean _cmd_set_autoping(gchar **args, struct cmd_help_t help); static gboolean _cmd_set_titlebar(gchar **args, struct cmd_help_t help); static gboolean _cmd_set_autoaway(gchar **args, struct cmd_help_t help); +static gboolean _cmd_set_mouse(gchar **args, struct cmd_help_t help); static gboolean _cmd_vercheck(gchar **args, struct cmd_help_t help); static gboolean _cmd_away(gchar **args, struct cmd_help_t help); static gboolean _cmd_online(gchar **args, struct cmd_help_t help); @@ -438,6 +439,17 @@ static struct cmd_t setting_commands[] = "Possible properties are 'version'.", NULL } } }, + { "/mouse", + _cmd_set_mouse, parse_args, 1, 1, + { "/mouse on|off", "Use profanity mouse handling.", + { "/mouse on|off", + "-------------", + "If set to 'on', profanity will handle mouse actions, which enabled scrolling the main window with the mouse wheel.", + "To select text, use the shift key while selcting an area.", + "If set to 'off', profanity leaves mouse handling to the terminal implementation.", + "The default is 'on', if you have strange behaviour with mouse actions, set to 'off'.", + NULL } } }, + { "/chlog", _cmd_set_chlog, parse_args, 1, 1, { "/chlog on|off", "Chat logging to file", @@ -911,6 +923,8 @@ _cmd_complete_parameters(char *input, int *size) prefs_autocomplete_boolean_choice); _parameter_autocomplete(input, size, "/chlog", prefs_autocomplete_boolean_choice); + _parameter_autocomplete(input, size, "/mouse", + prefs_autocomplete_boolean_choice); _parameter_autocomplete(input, size, "/history", prefs_autocomplete_boolean_choice); _parameter_autocomplete(input, size, "/vercheck", @@ -2090,6 +2104,13 @@ _cmd_set_chlog(gchar **args, struct cmd_help_t help) } static gboolean +_cmd_set_mouse(gchar **args, struct cmd_help_t help) +{ + return _cmd_set_boolean_preference(args[0], help, + "Mouse handling", prefs_set_mouse); +} + +static gboolean _cmd_set_history(gchar **args, struct cmd_help_t help) { return _cmd_set_boolean_preference(args[0], help, diff --git a/src/preferences.c b/src/preferences.c index e8c727b5..f8862aa9 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -410,6 +410,23 @@ prefs_set_splash(gboolean value) _save_prefs(); } +gboolean +prefs_get_mouse(void) +{ + // default to true + if (!g_key_file_has_key(prefs, "ui", "mouse", NULL)) { + return TRUE; + } else { + return g_key_file_get_boolean(prefs, "ui", "mouse", NULL); + } +} + +void +prefs_set_mouse(gboolean value) +{ + g_key_file_set_boolean(prefs, "ui", "mouse", value); + _save_prefs(); +} static void _save_prefs(void) { diff --git a/src/preferences.h b/src/preferences.h index f9bb8f45..aa748634 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -68,6 +68,8 @@ gint prefs_get_gone(void); void prefs_set_gone(gint value); gchar * prefs_get_theme(void); void prefs_set_theme(gchar *value); +gboolean prefs_get_mouse(void); +void prefs_set_mouse(gboolean value); void prefs_set_notify_message(gboolean value); gboolean prefs_get_notify_message(void); diff --git a/src/windows.c b/src/windows.c index 5659cc20..f708b4a3 100644 --- a/src/windows.c +++ b/src/windows.c @@ -125,8 +125,10 @@ ui_init(void) initscr(); raw(); keypad(stdscr, TRUE); - mousemask(ALL_MOUSE_EVENTS, NULL); - mouseinterval(5); + if (prefs_get_mouse()) { + mousemask(ALL_MOUSE_EVENTS, NULL); + mouseinterval(5); + } ui_load_colours(); refresh(); create_title_bar(); @@ -1251,6 +1253,11 @@ cons_show_ui_prefs(void) cons_show("Version checking (/vercheck) : ON"); else cons_show("Version checking (/vercheck) : OFF"); + + if (prefs_get_mouse()) + cons_show("Mouse handling (/mouse) : ON"); + else + cons_show("Mouse handling (/mouse) : OFF"); } void @@ -2192,42 +2199,45 @@ _win_handle_page(const wint_t * const ch) int page_space = rows - 4; int *page_start = &(current->y_pos); - MEVENT mouse_event; + if (prefs_get_mouse()) { + MEVENT mouse_event; - if (*ch == KEY_MOUSE) { - if (getmouse(&mouse_event) == OK) { + if (*ch == KEY_MOUSE) { + if (getmouse(&mouse_event) == OK) { #ifdef PLATFORM_CYGWIN - if (mouse_event.bstate & BUTTON5_PRESSED) { // mouse wheel down + if (mouse_event.bstate & BUTTON5_PRESSED) { // mouse wheel down #else - if (mouse_event.bstate & BUTTON2_PRESSED) { // mouse wheel down + if (mouse_event.bstate & BUTTON2_PRESSED) { // mouse wheel down #endif - *page_start += 4; + *page_start += 4; - // only got half a screen, show full screen - if ((y - (*page_start)) < page_space) - *page_start = y - page_space; + // only got half a screen, show full screen + if ((y - (*page_start)) < page_space) + *page_start = y - page_space; - // went past end, show full screen - else if (*page_start >= y) - *page_start = y - page_space; + // went past end, show full screen + else if (*page_start >= y) + *page_start = y - page_space; - current->paged = 1; - dirty = TRUE; - } else if (mouse_event.bstate & BUTTON4_PRESSED) { // mouse wheel up - *page_start -= 4; + current->paged = 1; + dirty = TRUE; + } else if (mouse_event.bstate & BUTTON4_PRESSED) { // mouse wheel up + *page_start -= 4; - // went past beginning, show first page - if (*page_start < 0) - *page_start = 0; + // went past beginning, show first page + if (*page_start < 0) + *page_start = 0; - current->paged = 1; - dirty = TRUE; + current->paged = 1; + dirty = TRUE; + } } } + } // page up - } else if (*ch == KEY_PPAGE) { + if (*ch == KEY_PPAGE) { *page_start -= page_space; // went past beginning, show first page |