mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Re-indent the code using clang-format
This commit is contained in:
parent
7d3a365ccf
commit
bb5868199f
18 changed files with 161 additions and 141 deletions
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "modes/help-keys.h"
|
||||
#include "helper.h"
|
||||
#include "modes/help-keys.h"
|
||||
#include "rofi.h"
|
||||
#include "settings.h"
|
||||
#include "widgets/textbox.h"
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -51,8 +51,8 @@
|
|||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "modes/ssh.h"
|
||||
#include "history.h"
|
||||
#include "modes/ssh.h"
|
||||
#include "rofi.h"
|
||||
#include "settings.h"
|
||||
|
||||
|
|
|
@ -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("<i>no title set</i>");
|
||||
c->title = g_strdup("<i>no title set</i>");
|
||||
}
|
||||
pd->title_len =
|
||||
MAX(c->title ? g_utf8_strlen(c->title, -1) : 0, pd->title_len);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
198
source/view.c
198
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++;
|
||||
}
|
||||
}
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 <stdio.h>
|
||||
|
|
|
@ -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 <stdio.h>
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include "widgets/widget.h"
|
||||
#include "theme.h"
|
||||
#include "widgets/widget-internal.h"
|
||||
#include "widgets/widget.h"
|
||||
#include <glib.h>
|
||||
#include <math.h>
|
||||
|
||||
|
|
Loading…
Reference in a new issue