From 33a69e713ab79748a20f23661d110ccb6444f400 Mon Sep 17 00:00:00 2001 From: Scoopta Date: Fri, 21 Feb 2020 00:17:59 -0800 Subject: [PATCH] Added line_wrap config option --- man/wofi.5 | 3 +++ src/wofi.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/man/wofi.5 b/man/wofi.5 index ed5688d..95713e0 100644 --- a/man/wofi.5 +++ b/man/wofi.5 @@ -141,6 +141,9 @@ Specifies the key to use in order to submit an action. Default is Return. See \f .TP .B key_exit=\fIKEY\fR Specifies the key to use in order to exit wofi. Default is Escape. See \fBwofi\-keys\fR(7) for the key codes. +.TP +.B line_wrap=\fIBOOL\fR +Enables line wrap mode. If enabled lines will be wrapped to avoid scrolling. Default is false. .SH CSS SELECTORS Any GTK widget can be selected by using the name of its CSS node, these however might change with updates and are not guarenteed to stay constant. Wofi also provides certain widgets with names and classes which can be referenced from CSS to give access to the most important widgets easily. \fBwofi\fR(7) contains the current widget layout used by wofi so if you want to get into CSS directly using GTK widget names look there for info. diff --git a/src/wofi.c b/src/wofi.c index d217f65..8d176d2 100644 --- a/src/wofi.c +++ b/src/wofi.c @@ -70,6 +70,8 @@ static uint16_t widget_count = 0; static enum sort_order sort_order; static int64_t min_height = INT64_MAX; static uint64_t lines; +static bool line_wrap; + static char* key_up, *key_down, *key_left, *key_right, *key_forward, *key_backward, *key_submit, *key_exit; static char* mod_up, *mod_down, *mod_left, *mod_right, *mod_forward, *mod_backward, *mod_exit; @@ -266,6 +268,7 @@ static char* parse_images(WofiPropertyBox* box, const char* text, bool create_wi gtk_widget_set_name(label, "text"); gtk_label_set_use_markup(GTK_LABEL(label), allow_markup); gtk_label_set_xalign(GTK_LABEL(label), 0); + gtk_label_set_line_wrap(GTK_LABEL(label), line_wrap); gtk_container_add(GTK_CONTAINER(box), label); } else { char* tmp = ret; @@ -318,6 +321,7 @@ static GtkWidget* create_label(char* mode, char* text, char* search_text, char* gtk_widget_set_name(label, "text"); gtk_label_set_use_markup(GTK_LABEL(label), allow_markup); gtk_label_set_xalign(GTK_LABEL(label), 0); + gtk_label_set_line_wrap(GTK_LABEL(label), line_wrap); gtk_container_add(GTK_CONTAINER(box), label); } if(parse_search) { @@ -1210,6 +1214,7 @@ void wofi_init(struct map* _config) { lines = strtol(config_get(config, "lines", "0"), NULL, 10); columns = strtol(config_get(config, "columns", "1"), NULL, 10); sort_order = config_get_mnemonic(config, "sort_order", "default", 2, "default", "alphabetical"); + line_wrap = strcmp(config_get(config, "line_wrap", "false"), "true") == 0; key_up = config_get(config, "key_up", "Up"); key_down = config_get(config, "key_down", "Down");