diff --git a/src/command/command.c b/src/command/command.c index c898f4b7..3300097f 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -578,6 +578,14 @@ static struct cmd_t command_defs[] = "Switch display of the contacts presence on or off.", NULL } } }, + { "/wrap", + cmd_wrap, parse_args, 1, 1, &cons_wrap_setting, + { "/wrap on|off", "Word wrapping.", + { "/wrap on|off", + "------------", + "Enable or disable word wrapping.", + NULL } } }, + { "/notify", cmd_notify, parse_args, 2, 3, &cons_notify_setting, { "/notify [type value]|[type setting value]", "Control various desktop noficiations.", @@ -1773,7 +1781,7 @@ _cmd_complete_parameters(char *input, int *size) // autocomplete boolean settings gchar *boolean_choices[] = { "/beep", "/intype", "/states", "/outtype", "/flash", "/splash", "/chlog", "/grlog", "/mouse", "/history", "/titlebar", - "/vercheck", "/privileges", "/presence" }; + "/vercheck", "/privileges", "/presence", "/wrap" }; for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) { result = autocomplete_param_with_func(input, size, boolean_choices[i], diff --git a/src/command/commands.c b/src/command/commands.c index 45421829..98ebe90c 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -620,7 +620,7 @@ cmd_help(gchar **args, struct cmd_help_t help) "/chlog", "/flash", "/gone", "/grlog", "/history", "/intype", "/log", "/mouse", "/notify", "/outtype", "/prefs", "/priority", "/reconnect", "/roster", "/splash", "/states", "/statuses", "/theme", - "/titlebar", "/vercheck", "/privileges", "/occupants", "/presence" }; + "/titlebar", "/vercheck", "/privileges", "/occupants", "/presence", "/wrap" }; _cmd_show_filtered_help("Settings commands", filter, ARRAY_SIZE(filter)); } else if (strcmp(args[0], "navigation") == 0) { @@ -2928,6 +2928,16 @@ cmd_presence(gchar **args, struct cmd_help_t help) return _cmd_set_boolean_preference(args[0], help, "Contact presence", PREF_PRESENCE); } +gboolean +cmd_wrap(gchar **args, struct cmd_help_t help) +{ + gboolean result = _cmd_set_boolean_preference(args[0], help, "Word wrap", PREF_WRAP); + + wins_resize_all(); + + return result; +} + gboolean cmd_states(gchar **args, struct cmd_help_t help) { diff --git a/src/command/commands.h b/src/command/commands.h index 245a2944..87c05453 100644 --- a/src/command/commands.h +++ b/src/command/commands.h @@ -133,6 +133,7 @@ gboolean cmd_affiliation(gchar **args, struct cmd_help_t help); gboolean cmd_role(gchar **args, struct cmd_help_t help); gboolean cmd_privileges(gchar **args, struct cmd_help_t help); gboolean cmd_presence(gchar **args, struct cmd_help_t help); +gboolean cmd_wrap(gchar **args, struct cmd_help_t help); gboolean cmd_form_field(char *tag, gchar **args); diff --git a/src/config/preferences.c b/src/config/preferences.c index 1447160b..5b00efac 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -452,6 +452,7 @@ _get_group(preference_t pref) case PREF_STATUSES_MUC: case PREF_MUC_PRIVILEGES: case PREF_PRESENCE: + case PREF_WRAP: return PREF_GROUP_UI; case PREF_STATES: case PREF_OUTTYPE: @@ -570,6 +571,8 @@ _get_key(preference_t pref) return "shared"; case PREF_PRESENCE: return "presence"; + case PREF_WRAP: + return "wrap"; default: return NULL; } @@ -592,6 +595,7 @@ _get_default_boolean(preference_t pref) case PREF_OCCUPANTS: case PREF_MUC_PRIVILEGES: case PREF_PRESENCE: + case PREF_WRAP: return TRUE; default: return FALSE; diff --git a/src/config/preferences.h b/src/config/preferences.h index a4dfa1f1..11d93feb 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -60,6 +60,7 @@ typedef enum { PREF_OCCUPANTS, PREF_MUC_PRIVILEGES, PREF_PRESENCE, + PREF_WRAP, PREF_STATUSES, PREF_STATUSES_CONSOLE, PREF_STATUSES_CHAT, diff --git a/src/ui/console.c b/src/ui/console.c index 2b5dec8a..6a995a1a 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -840,6 +840,15 @@ _cons_beep_setting(void) cons_show("Terminal beep (/beep) : OFF"); } +static void +_cons_wrap_setting(void) +{ + if (prefs_get_boolean(PREF_WRAP)) + cons_show("Word wrap (/wrap) : ON"); + else + cons_show("Word wrap (/wrap) : OFF"); +} + static void _cons_presence_setting(void) { @@ -941,6 +950,7 @@ _cons_show_ui_prefs(void) cons_beep_setting(); cons_flash_setting(); cons_splash_setting(); + cons_wrap_setting(); cons_vercheck_setting(); cons_mouse_setting(); cons_statuses_setting(); @@ -1557,6 +1567,7 @@ console_init_module(void) cons_theme_setting = _cons_theme_setting; cons_privileges_setting = _cons_privileges_setting; cons_beep_setting = _cons_beep_setting; + cons_wrap_setting = _cons_wrap_setting; cons_presence_setting = _cons_presence_setting; cons_flash_setting = _cons_flash_setting; cons_splash_setting = _cons_splash_setting; diff --git a/src/ui/ui.h b/src/ui/ui.h index f5c9b621..e2ede545 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -300,6 +300,7 @@ void (*cons_splash_setting)(void); void (*cons_vercheck_setting)(void); void (*cons_occupants_setting)(void); void (*cons_presence_setting)(void); +void (*cons_wrap_setting)(void); void (*cons_mouse_setting)(void); void (*cons_statuses_setting)(void); void (*cons_titlebar_setting)(void); diff --git a/src/ui/window.c b/src/ui/window.c index 6f224a04..d245a333 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -583,10 +583,13 @@ _win_print(ProfWin *window, const char show_char, const char * const date_fmt, wattron(window->win, attrs); - if (flags & NO_EOL) { + if (prefs_get_boolean(PREF_WRAP)) { _win_print_wrapped(window->win, message+offset); } else { - _win_print_wrapped(window->win, message+offset); + wprintw(window->win, "%s", message+offset); + } + + if ((flags & NO_EOL) == 0) { wprintw(window->win, "\n"); }