From bb5868199f5dd3a42a6ce0d672d4a15887d8a7e2 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sun, 26 Mar 2023 13:19:58 +0200 Subject: Re-indent the code using clang-format --- include/helper.h | 3 +- include/view.h | 1 - include/widgets/textbox.h | 6 +- source/helper.c | 3 +- source/modes/dmenu.c | 6 +- source/modes/filebrowser.c | 8 +- source/modes/help-keys.c | 2 +- source/modes/script.c | 10 +-- source/modes/ssh.c | 2 +- source/modes/window.c | 6 +- source/rofi.c | 5 +- source/theme.c | 2 +- source/view.c | 196 +++++++++++++++++++++++++-------------------- source/widgets/container.c | 2 +- source/widgets/icon.c | 2 +- source/widgets/listview.c | 22 ++--- source/widgets/textbox.c | 22 +++-- source/widgets/widget.c | 2 +- 18 files changed, 160 insertions(+), 140 deletions(-) diff --git a/include/helper.h b/include/helper.h index 146ad46b..52af0600 100644 --- a/include/helper.h +++ b/include/helper.h @@ -397,7 +397,8 @@ char *helper_string_replace_if_exists(char *string, ...); * * @returns path to theme or copy of filename if not found. */ -char *helper_get_theme_path(const char *file, const char **ext) __attribute__((nonnull)); +char *helper_get_theme_path(const char *file, const char **ext) + __attribute__((nonnull)); /** * @param name The name of the element to find. diff --git a/include/view.h b/include/view.h index 503a6180..31373340 100644 --- a/include/view.h +++ b/include/view.h @@ -356,7 +356,6 @@ void rofi_view_ellipsize_listview(RofiViewState *state, */ gboolean rofi_set_im_window_pos(int new_x, int new_y); - WidgetTriggerActionResult textbox_button_trigger_action( widget *wid, MouseBindingMouseDefaultAction action, G_GNUC_UNUSED gint x, G_GNUC_UNUSED gint y, G_GNUC_UNUSED void *user_data); diff --git a/include/widgets/textbox.h b/include/widgets/textbox.h index 01b67a75..85331b20 100644 --- a/include/widgets/textbox.h +++ b/include/widgets/textbox.h @@ -351,13 +351,13 @@ int textbox_get_cursor_x_pos(const textbox *tb); * * @returns gets a newly allocated copy of the content of the entrybox. */ -char *textbox_get_text ( const textbox *tb ); +char *textbox_get_text(const textbox *tb); /** * @param tb Handle to the textbox * - * @returns the position of the cursor. + * @returns the position of the cursor. */ -int textbox_get_cursor ( const textbox *tb ); +int textbox_get_cursor(const textbox *tb); /**@}*/ #endif // ROFI_TEXTBOX_H diff --git a/source/helper.c b/source/helper.c index a84a7d9e..ad6541a8 100644 --- a/source/helper.c +++ b/source/helper.c @@ -180,7 +180,8 @@ static char *utf8_helper_simplify_string(const char *os) { 0, }; - // Normalize the string to a fully decomposed form, then filter out mark/accent characters. + // Normalize the string to a fully decomposed form, then filter out + // mark/accent characters. char *s = g_utf8_normalize(os, -1, G_NORMALIZE_ALL); ssize_t str_size = (g_utf8_strlen(s, -1) * 6 + 2 + 1) * sizeof(char); char *str = g_malloc0(str_size); diff --git a/source/modes/dmenu.c b/source/modes/dmenu.c index c9b55d10..85dda8e5 100644 --- a/source/modes/dmenu.c +++ b/source/modes/dmenu.c @@ -450,10 +450,10 @@ static char *get_display_data(const Mode *data, unsigned int index, int *state, if (pd->do_markup) { *state |= MARKUP; } - if ( pd->cmd_list[index].urgent ) { + if (pd->cmd_list[index].urgent) { *state |= URGENT; } - if ( pd->cmd_list[index].active ) { + if (pd->cmd_list[index].active) { *state |= ACTIVE; } char *my_retv = @@ -523,7 +523,7 @@ static int dmenu_mode_init(Mode *sw) { find_arg("-selected-row") >= 0) { pd->async = FALSE; } - if ( find_arg("-multi-select") >= 0 ) { + if (find_arg("-multi-select") >= 0) { pd->multi_select = TRUE; pd->async = FALSE; } diff --git a/source/modes/filebrowser.c b/source/modes/filebrowser.c index b8ee2161..f9930ee7 100644 --- a/source/modes/filebrowser.c +++ b/source/modes/filebrowser.c @@ -346,7 +346,8 @@ static void get_file_browser(Mode *sw) { } static void file_browser_mode_init_config(Mode *sw) { - FileBrowserModePrivateData * pd = (FileBrowserModePrivateData*)mode_get_private_data(sw); + FileBrowserModePrivateData *pd = + (FileBrowserModePrivateData *)mode_get_private_data(sw); char *msg = NULL; gboolean found_error = FALSE; @@ -384,13 +385,12 @@ static void file_browser_mode_init_config(Mode *sw) { } p = rofi_theme_find_property(wid, P_STRING, "command", TRUE); - if ( p != NULL && p->type == P_STRING ) { + if (p != NULL && p->type == P_STRING) { pd->command = g_strdup(p->value.s); } else { pd->command = g_strdup(DEFAULT_OPEN); } - if (found_error) { rofi_view_error_dialog(msg, FALSE); @@ -495,7 +495,7 @@ static ModeMode file_browser_mode_result(Mode *sw, int mretv, char **input, (pd->array[selected_line].type == DIRECTORY && special_command)) { char *d_esc = g_shell_quote(pd->array[selected_line].path); - char *cmd = g_strdup_printf("%s %s",pd->command, d_esc); + char *cmd = g_strdup_printf("%s %s", pd->command, d_esc); g_free(d_esc); char *cdir = g_file_get_path(pd->current_dir); helper_execute_command(cdir, cmd, FALSE, NULL); diff --git a/source/modes/help-keys.c b/source/modes/help-keys.c index a3053e5b..728219ea 100644 --- a/source/modes/help-keys.c +++ b/source/modes/help-keys.c @@ -38,8 +38,8 @@ #include #include -#include "modes/help-keys.h" #include "helper.h" +#include "modes/help-keys.h" #include "rofi.h" #include "settings.h" #include "widgets/textbox.h" diff --git a/source/modes/script.c b/source/modes/script.c index 8771e4d2..f1f87486 100644 --- a/source/modes/script.c +++ b/source/modes/script.c @@ -89,7 +89,7 @@ void dmenuscript_parse_entry_extras(G_GNUC_UNUSED Mode *sw, gchar *value = *(extra + 1); // Mark NULL *(extra) = NULL; - *(extra+1) = NULL; + *(extra + 1) = NULL; if (strcasecmp(key, "icon") == 0) { entry->icon_name = value; } else if (strcasecmp(key, "meta") == 0) { @@ -111,7 +111,7 @@ void dmenuscript_parse_entry_extras(G_GNUC_UNUSED Mode *sw, g_free(key); } // Got an extra entry.. lets free it. - if ( *extras != NULL ) { + if (*extras != NULL) { g_free(*extras); } g_free(extras); @@ -254,7 +254,7 @@ static DmenuScriptEntry *execute_executor(Mode *sw, char *arg, buffer + buf_length, read_length - buf_length); } - memset(&(retv[(*length)+1]), 0, sizeof(DmenuScriptEntry)); + memset(&(retv[(*length) + 1]), 0, sizeof(DmenuScriptEntry)); (*length)++; } } @@ -429,10 +429,10 @@ static char *_get_display_value(const Mode *sw, unsigned int selected_line, *state |= URGENT; } } - if ( pd->cmd_list[selected_line].urgent ) { + if (pd->cmd_list[selected_line].urgent) { *state |= URGENT; } - if ( pd->cmd_list[selected_line].active ) { + if (pd->cmd_list[selected_line].active) { *state |= ACTIVE; } if (pd->do_markup) { diff --git a/source/modes/ssh.c b/source/modes/ssh.c index 4fe36b5d..aca8f7ad 100644 --- a/source/modes/ssh.c +++ b/source/modes/ssh.c @@ -51,8 +51,8 @@ #include #include -#include "modes/ssh.h" #include "history.h" +#include "modes/ssh.h" #include "rofi.h" #include "settings.h" diff --git a/source/modes/window.c b/source/modes/window.c index 2bd7e847..1d48759a 100644 --- a/source/modes/window.c +++ b/source/modes/window.c @@ -356,10 +356,10 @@ static client *window_client(WindowModePrivateData *pd, xcb_window_t win) { if (tmp_title == NULL) { tmp_title = window_get_text_prop(c->window, XCB_ATOM_WM_NAME); } - if ( tmp_title != NULL ) { - c->title = g_markup_escape_text(tmp_title, -1); + if (tmp_title != NULL) { + c->title = g_markup_escape_text(tmp_title, -1); } else { - c->title = g_strdup("no title set"); + c->title = g_strdup("no title set"); } pd->title_len = MAX(c->title ? g_utf8_strlen(c->title, -1) : 0, pd->title_len); diff --git a/source/rofi.c b/source/rofi.c index 861f1be4..9dd4697e 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -804,8 +804,7 @@ static gboolean startup(G_GNUC_UNUSED gpointer data) { return G_SOURCE_REMOVE; } -static gboolean take_screenshot_quit ( G_GNUC_UNUSED void *data) -{ +static gboolean take_screenshot_quit(G_GNUC_UNUSED void *data) { rofi_capture_screenshot(); rofi_quit_main_loop(); return G_SOURCE_REMOVE; @@ -1121,7 +1120,7 @@ int main(int argc, char *argv[]) { if (find_arg_uint("-record-screenshots", &interval)) { g_timeout_add((guint)(1000 / (double)interval), record, NULL); } - if ( find_arg_uint("-take-screenshot-quit", &interval)) { + if (find_arg_uint("-take-screenshot-quit", &interval)) { g_timeout_add(interval, take_screenshot_quit, NULL); } if (find_arg("-benchmark-ui") >= 0) { diff --git a/source/theme.c b/source/theme.c index 984e10a8..615c6fb9 100644 --- a/source/theme.c +++ b/source/theme.c @@ -1360,7 +1360,7 @@ static double get_pixels(RofiDistanceUnit *unit, RofiOrientation ori) { } static double distance_unit_get_pixel(RofiDistanceUnit *unit, - RofiOrientation ori) { + RofiOrientation ori) { switch (unit->modtype) { case ROFI_DISTANCE_MODIFIER_GROUP: return distance_unit_get_pixel(unit->left, ori); diff --git a/source/view.c b/source/view.c index 3861f6b5..16ecb088 100644 --- a/source/view.c +++ b/source/view.c @@ -103,7 +103,6 @@ GThreadPool *tpool = NULL; /** Global pointer to the currently active RofiViewState */ RofiViewState *current_active_menu = NULL; - typedef struct { char *string; int index; @@ -159,28 +158,26 @@ struct { EntryHistoryIndex *entry_history; gssize entry_history_length; gssize entry_history_index; -} CacheState = { - .main_window = XCB_WINDOW_NONE, - .fake_bg = NULL, - .edit_surf = NULL, - .edit_draw = NULL, - .fake_bgrel = FALSE, - .flags = MENU_NORMAL, - .views = G_QUEUE_INIT, - .idle_timeout = 0, - .refilter_timeout = 0, - .refilter_timeout_count = 0, - .max_refilter_time = 0.0, - .delayed_mode = FALSE, - .user_timeout = 0, - .count = 0L, - .repaint_source = 0, - .fullscreen = FALSE, - .entry_history_enable = TRUE, - .entry_history = NULL, - .entry_history_length = 0, - .entry_history_index = 0 -}; +} CacheState = {.main_window = XCB_WINDOW_NONE, + .fake_bg = NULL, + .edit_surf = NULL, + .edit_draw = NULL, + .fake_bgrel = FALSE, + .flags = MENU_NORMAL, + .views = G_QUEUE_INIT, + .idle_timeout = 0, + .refilter_timeout = 0, + .refilter_timeout_count = 0, + .max_refilter_time = 0.0, + .delayed_mode = FALSE, + .user_timeout = 0, + .count = 0L, + .repaint_source = 0, + .fullscreen = FALSE, + .entry_history_enable = TRUE, + .entry_history = NULL, + .entry_history_length = 0, + .entry_history_index = 0}; void rofi_view_get_current_monitor(int *width, int *height) { if (width) { @@ -900,31 +897,33 @@ static void open_xim_callback(xcb_xim_t *im, G_GNUC_UNUSED void *user_data) { } #endif -static void input_history_initialize ( void ) -{ - if ( CacheState.entry_history_enable == FALSE ) { +static void input_history_initialize(void) { + if (CacheState.entry_history_enable == FALSE) { return; } CacheState.entry_history = NULL; - CacheState.entry_history_index = 0; + CacheState.entry_history_index = 0; CacheState.entry_history_length = 0; gchar *path = g_build_filename(cache_dir, "rofi-entry-history.txt", NULL); - if ( g_file_test(path, G_FILE_TEST_EXISTS ) ) { + if (g_file_test(path, G_FILE_TEST_EXISTS)) { FILE *fp = fopen(path, "r"); - if ( fp ) { + if (fp) { char *line = NULL; size_t len = 0; ssize_t nread; while ((nread = getline(&line, &len, fp)) != -1) { - CacheState.entry_history = g_realloc(CacheState.entry_history, - sizeof(EntryHistoryIndex)*(CacheState.entry_history_length+1)); - if ( line[nread-1] == '\n' ) { - line[nread-1] = '\0'; + CacheState.entry_history = g_realloc( + CacheState.entry_history, + sizeof(EntryHistoryIndex) * (CacheState.entry_history_length + 1)); + if (line[nread - 1] == '\n') { + line[nread - 1] = '\0'; nread--; } - CacheState.entry_history[CacheState.entry_history_length].string = g_strdup(line); - CacheState.entry_history[CacheState.entry_history_length].index = strlen(line); + CacheState.entry_history[CacheState.entry_history_length].string = + g_strdup(line); + CacheState.entry_history[CacheState.entry_history_length].index = + strlen(line); CacheState.entry_history_length++; CacheState.entry_history_index++; } @@ -933,35 +932,36 @@ static void input_history_initialize ( void ) } } g_free(path); - CacheState.entry_history = g_realloc(CacheState.entry_history, - sizeof(EntryHistoryIndex)*(CacheState.entry_history_length+1)); - CacheState.entry_history[CacheState.entry_history_length].string = g_strdup(""); - CacheState.entry_history[CacheState.entry_history_length].index = 0; + CacheState.entry_history = g_realloc( + CacheState.entry_history, + sizeof(EntryHistoryIndex) * (CacheState.entry_history_length + 1)); + CacheState.entry_history[CacheState.entry_history_length].string = + g_strdup(""); + CacheState.entry_history[CacheState.entry_history_length].index = 0; CacheState.entry_history_length++; - } -static void input_history_save ( void ) -{ - if ( CacheState.entry_history_enable == FALSE ) { +static void input_history_save(void) { + if (CacheState.entry_history_enable == FALSE) { return; } - if ( CacheState.entry_history_length > 0 ){ + if (CacheState.entry_history_length > 0) { // History max. int max_history = 20; ThemeWidget *wid = rofi_config_find_widget("entry", NULL, TRUE); - if ( wid ) { - Property *p = rofi_theme_find_property(wid, P_INTEGER, "max-history", TRUE); - if ( p != NULL && p->type == P_INTEGER ){ + if (wid) { + Property *p = + rofi_theme_find_property(wid, P_INTEGER, "max-history", TRUE); + if (p != NULL && p->type == P_INTEGER) { max_history = p->value.i; } } gchar *path = g_build_filename(cache_dir, "rofi-entry-history.txt", NULL); g_debug("Entry filename output: '%s'", path); FILE *fp = fopen(path, "w"); - if ( fp ) { - gssize start = MAX(0, (CacheState.entry_history_length-max_history)); - for ( gssize i = start; i < CacheState.entry_history_length; i++){ - if ( strlen(CacheState.entry_history[i].string) > 0 ){ + if (fp) { + gssize start = MAX(0, (CacheState.entry_history_length - max_history)); + for (gssize i = start; i < CacheState.entry_history_length; i++) { + if (strlen(CacheState.entry_history[i].string) > 0) { fprintf(fp, "%s\n", CacheState.entry_history[i].string); } } @@ -970,17 +970,17 @@ static void input_history_save ( void ) g_free(path); } // Cleanups. - if ( CacheState.entry_history != NULL ) { + if (CacheState.entry_history != NULL) { g_free(CacheState.entry_history); CacheState.entry_history = NULL; CacheState.entry_history_length = 0; - CacheState.entry_history_index = 0; + CacheState.entry_history_index = 0; } } void __create_window(MenuFlags menu_flags) { // In password mode, disable the entry history. - if ( (menu_flags&MENU_PASSWORD) == MENU_PASSWORD ) { + if ((menu_flags & MENU_PASSWORD) == MENU_PASSWORD) { CacheState.entry_history_enable = FALSE; } input_history_initialize(); @@ -1578,13 +1578,16 @@ void rofi_view_finalize(RofiViewState *state) { static void rofi_view_input_changed() { rofi_view_take_action("inputchange"); - RofiViewState * state = current_active_menu; - if ( CacheState.entry_history_enable && state ) { - if ( CacheState.entry_history[CacheState.entry_history_index].string != NULL) { + RofiViewState *state = current_active_menu; + if (CacheState.entry_history_enable && state) { + if (CacheState.entry_history[CacheState.entry_history_index].string != + NULL) { g_free(CacheState.entry_history[CacheState.entry_history_index].string); } - CacheState.entry_history[CacheState.entry_history_index].string = textbox_get_text(state->text); - CacheState.entry_history[CacheState.entry_history_index].index = textbox_get_cursor(state->text); + CacheState.entry_history[CacheState.entry_history_index].string = + textbox_get_text(state->text); + CacheState.entry_history[CacheState.entry_history_index].index = + textbox_get_cursor(state->text); } } @@ -1842,41 +1845,58 @@ static void rofi_view_trigger_global_action(KeyBindingAction action) { break; } case ENTRY_HISTORY_DOWN: { - if ( CacheState.entry_history_enable && state->text ) { - CacheState.entry_history[CacheState.entry_history_index].index = textbox_get_cursor(state->text); - if ( CacheState.entry_history_index > 0 ) { - CacheState.entry_history_index--; - } - if ( state->text ) { - textbox_text(state->text, CacheState.entry_history[CacheState.entry_history_index].string); - textbox_cursor(state->text,CacheState.entry_history[CacheState.entry_history_index].index ); - state->refilter = TRUE; - } + if (CacheState.entry_history_enable && state->text) { + CacheState.entry_history[CacheState.entry_history_index].index = + textbox_get_cursor(state->text); + if (CacheState.entry_history_index > 0) { + CacheState.entry_history_index--; + } + if (state->text) { + textbox_text( + state->text, + CacheState.entry_history[CacheState.entry_history_index].string); + textbox_cursor( + state->text, + CacheState.entry_history[CacheState.entry_history_index].index); + state->refilter = TRUE; } + } break; } case ENTRY_HISTORY_UP: { - if ( CacheState.entry_history_enable && state->text ) { - if ( CacheState.entry_history[CacheState.entry_history_index].string != NULL) { - g_free(CacheState.entry_history[CacheState.entry_history_index].string); - } - CacheState.entry_history[CacheState.entry_history_index].string = textbox_get_text(state->text); - CacheState.entry_history[CacheState.entry_history_index].index = textbox_get_cursor(state->text); - // Don't create up if current is empty. - if ( strlen(CacheState.entry_history[CacheState.entry_history_index].string) > 0 ) { - CacheState.entry_history_index++; - if ( CacheState.entry_history_index >= CacheState.entry_history_length ) { - CacheState.entry_history = g_realloc(CacheState.entry_history, - sizeof(EntryHistoryIndex)*(CacheState.entry_history_length+1)); - CacheState.entry_history[CacheState.entry_history_length].string = g_strdup(""); - CacheState.entry_history[CacheState.entry_history_length].index = 0; - CacheState.entry_history_length++; - } + if (CacheState.entry_history_enable && state->text) { + if (CacheState.entry_history[CacheState.entry_history_index].string != + NULL) { + g_free(CacheState.entry_history[CacheState.entry_history_index].string); + } + CacheState.entry_history[CacheState.entry_history_index].string = + textbox_get_text(state->text); + CacheState.entry_history[CacheState.entry_history_index].index = + textbox_get_cursor(state->text); + // Don't create up if current is empty. + if (strlen( + CacheState.entry_history[CacheState.entry_history_index].string) > + 0) { + CacheState.entry_history_index++; + if (CacheState.entry_history_index >= CacheState.entry_history_length) { + CacheState.entry_history = + g_realloc(CacheState.entry_history, + sizeof(EntryHistoryIndex) * + (CacheState.entry_history_length + 1)); + CacheState.entry_history[CacheState.entry_history_length].string = + g_strdup(""); + CacheState.entry_history[CacheState.entry_history_length].index = 0; + CacheState.entry_history_length++; } - textbox_text(state->text, CacheState.entry_history[CacheState.entry_history_index].string); - textbox_cursor(state->text,CacheState.entry_history[CacheState.entry_history_index].index ); - state->refilter = TRUE; } + textbox_text( + state->text, + CacheState.entry_history[CacheState.entry_history_index].string); + textbox_cursor( + state->text, + CacheState.entry_history[CacheState.entry_history_index].index); + state->refilter = TRUE; + } break; } } diff --git a/source/widgets/container.c b/source/widgets/container.c index 904772e7..63e04495 100644 --- a/source/widgets/container.c +++ b/source/widgets/container.c @@ -29,8 +29,8 @@ #define G_LOG_DOMAIN "Widgets.Container" #include "config.h" -#include "widgets/container.h" #include "theme.h" +#include "widgets/container.h" #include "widgets/widget-internal.h" #include "widgets/widget.h" #include diff --git a/source/widgets/icon.c b/source/widgets/icon.c index 0900fff4..ebdd62f5 100644 --- a/source/widgets/icon.c +++ b/source/widgets/icon.c @@ -29,8 +29,8 @@ #define G_LOG_DOMAIN "Widgets.Icon" #include "config.h" -#include "widgets/icon.h" #include "theme.h" +#include "widgets/icon.h" #include "widgets/widget-internal.h" #include "widgets/widget.h" #include diff --git a/source/widgets/listview.c b/source/widgets/listview.c index c1be8760..05f6f273 100644 --- a/source/widgets/listview.c +++ b/source/widgets/listview.c @@ -190,21 +190,22 @@ static void listview_add_widget(listview *lv, _listview_row *row, widget *wid, box_add((box *)wid, WIDGET(textbox_custom), TRUE); } else if (strncasecmp(label, "button", 6) == 0) { textbox *button_custom = - textbox_create(wid, WIDGET_TYPE_EDITBOX, label, - TB_AUTOHEIGHT | TB_WRAP, NORMAL, "", 0, 0); + textbox_create(wid, WIDGET_TYPE_EDITBOX, label, TB_AUTOHEIGHT | TB_WRAP, + NORMAL, "", 0, 0); box_add((box *)wid, WIDGET(button_custom), TRUE); - widget_set_trigger_action_handler(WIDGET(button_custom), textbox_button_trigger_action, - lv->udata); + widget_set_trigger_action_handler(WIDGET(button_custom), + textbox_button_trigger_action, lv->udata); } else if (strncasecmp(label, "icon", 4) == 0) { icon *icon_custom = icon_create(wid, label); /* small hack to make it clickable */ - const char *type = rofi_theme_get_string(WIDGET(icon_custom), "action", NULL); + const char *type = + rofi_theme_get_string(WIDGET(icon_custom), "action", NULL); if (type) { WIDGET(icon_custom)->type = WIDGET_TYPE_EDITBOX; } box_add((box *)wid, WIDGET(icon_custom), TRUE); - widget_set_trigger_action_handler(WIDGET(icon_custom), textbox_button_trigger_action, - lv->udata); + widget_set_trigger_action_handler(WIDGET(icon_custom), + textbox_button_trigger_action, lv->udata); } else { widget *wid2 = (widget *)box_create(wid, label, ROFI_ORIENTATION_VERTICAL); box_add((box *)wid, WIDGET(wid2), TRUE); @@ -630,10 +631,11 @@ static void listview_resize(widget *wid, short w, short h) { lv->widget.h = MAX(0, h); int height = lv->widget.h - widget_padding_get_padding_height(WIDGET(lv)); int spacing_vert = distance_get_pixel(lv->spacing, ROFI_ORIENTATION_VERTICAL); - if ( lv->widget.h == 0 ) { - lv->max_rows = lv->menu_lines; + if (lv->widget.h == 0) { + lv->max_rows = lv->menu_lines; } else { - lv->max_rows = (spacing_vert + height) / (lv->element_height + spacing_vert); + lv->max_rows = + (spacing_vert + height) / (lv->element_height + spacing_vert); } lv->max_elements = lv->max_rows * lv->menu_columns; diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c index f7d861fc..28f91489 100644 --- a/source/widgets/textbox.c +++ b/source/widgets/textbox.c @@ -359,15 +359,13 @@ void textbox_set_pango_attributes(textbox *tb, PangoAttrList *list) { pango_layout_set_attributes(tb->layout, list); } -char *textbox_get_text ( const textbox *tb ) { - if ( tb->text == NULL ) { +char *textbox_get_text(const textbox *tb) { + if (tb->text == NULL) { return g_strdup(""); } - return g_strdup( tb->text ); -} -int textbox_get_cursor ( const textbox *tb ) { - return tb->cursor; + return g_strdup(tb->text); } +int textbox_get_cursor(const textbox *tb) { return tb->cursor; } // set the default text to display void textbox_text(textbox *tb, const char *text) { if (tb == NULL) { @@ -544,12 +542,12 @@ static void textbox_draw(widget *wid, cairo_t *draw) { if ((x + cursor_x) != tb->cursor_x_pos) { tb->cursor_x_pos = x + cursor_x; } - if ( tb->blink) { + if (tb->blink) { // use text color as fallback for themes that don't specify the cursor // color rofi_theme_get_color(WIDGET(tb), "cursor-color", draw); cairo_rectangle(draw, x + cursor_x, y + cursor_y, cursor_pixel_width, - cursor_height); + cursor_height); if (rofi_theme_get_boolean(WIDGET(tb), "cursor-outline", FALSE)) { cairo_fill_preserve(draw); rofi_theme_get_color(WIDGET(tb), "cursor-outline-color", draw); @@ -894,15 +892,15 @@ gboolean textbox_append_text(textbox *tb, const char *pad, const int pad_len) { for (w = pad, n = g_utf8_next_char(w), e = w + pad_len; w < e; w = n, n = g_utf8_next_char(n)) { gunichar c = g_utf8_get_char(w); - if ( g_unichar_isspace(c)){ + if (g_unichar_isspace(c)) { /** Replace tabs, newlines and others with a normal space. */ textbox_insert(tb, tb->cursor, " ", 1); textbox_cursor(tb, tb->cursor + 1); used_something = TRUE; - } else if ( g_unichar_iscntrl(c) ){ + } else if (g_unichar_iscntrl(c)) { /* skip control characters. */ - g_info("Got an invalid character: %08X",c); - } else { + g_info("Got an invalid character: %08X", c); + } else { /** Insert the text */ textbox_insert(tb, tb->cursor, w, n - w); textbox_cursor(tb, tb->cursor + 1); diff --git a/source/widgets/widget.c b/source/widgets/widget.c index 9fb71f64..ace426e6 100644 --- a/source/widgets/widget.c +++ b/source/widgets/widget.c @@ -26,9 +26,9 @@ */ #include "config.h" -#include "widgets/widget.h" #include "theme.h" #include "widgets/widget-internal.h" +#include "widgets/widget.h" #include #include -- cgit v1.2.3