line_wrap now takes the wrapping mode instead of a boolean

This commit is contained in:
Scoopta 2020-02-21 00:43:44 -08:00
parent 33a69e713a
commit a1beb82635
2 changed files with 12 additions and 6 deletions

View File

@ -142,8 +142,8 @@ Specifies the key to use in order to submit an action. Default is Return. See \f
.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.
.B line_wrap=\fIMODE\fR
Specifies the line wrap mode to use. The options are off, word, char, and word_char. Default is off.
.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.

View File

@ -70,7 +70,7 @@ 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 int8_t 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;
@ -268,7 +268,10 @@ 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);
if(line_wrap >= 0) {
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
gtk_label_set_line_wrap_mode(GTK_LABEL(label), line_wrap);
}
gtk_container_add(GTK_CONTAINER(box), label);
} else {
char* tmp = ret;
@ -321,7 +324,10 @@ 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);
if(line_wrap >= 0) {
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
gtk_label_set_line_wrap_mode(GTK_LABEL(label), line_wrap);
}
gtk_container_add(GTK_CONTAINER(box), label);
}
if(parse_search) {
@ -1214,7 +1220,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;
line_wrap = config_get_mnemonic(config, "line_wrap", "off", 4, "off", "word", "char", "word_char") - 1;
key_up = config_get(config, "key_up", "Up");
key_down = config_get(config, "key_down", "Down");