29 #define G_LOG_DOMAIN "Dialogs.Combi"
39 #include <pango/pango.h>
66 const char *
const sep =
",#";
68 for (
char *token = strtok_r(switcher_str, sep, &savept); token != NULL;
69 token = strtok_r(NULL, sep, &savept)) {
88 g_warning(
"Invalid script switcher: %s", token);
97 unsigned int length = 0;
140 unsigned int selected_line) {
143 if (input[0][0] ==
'!') {
146 char *eob = g_utf8_strchr(input[0], -1,
' ');
148 eob = &(input[0][strlen(input[0])]);
150 ssize_t bang_len = g_utf8_pointer_to_offset(input[0], eob) - 1;
154 size_t mode_name_len = g_utf8_strlen(mode_name, -1);
155 if ((
size_t)bang_len <= mode_name_len &&
166 selected_line - pd->
starts[switcher]);
175 if (selected_line >= pd->
starts[i] &&
178 selected_line - pd->
starts[i]);
187 unsigned int index) {
201 GList **attr_list,
int get_entry) {
205 if (selected_line >= pd->
starts[i] &&
208 selected_line - pd->
starts[i], state, attr_list,
216 if (selected_line >= pd->
starts[i] &&
220 selected_line - pd->
starts[i],
221 state, attr_list, TRUE);
224 retv = g_strdup_printf(
"%s %s", dname, str);
227 if (attr_list != NULL) {
232 PangoAttribute *pa = pango_attr_foreground_new(
235 pa->start_index = PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING;
236 pa->end_index = strlen(dname);
237 *attr_list = g_list_append(*attr_list, pa);
260 g_assert_not_reached();
269 cairo_surface_t *
icon =
282 if (input != NULL && input[0] ==
'!') {
284 const char *eob = g_utf8_strchr(input, -1,
' ');
287 eob = &(input[strlen(input)]);
289 ssize_t bang_len = g_utf8_pointer_to_offset(input, eob) - 1;
293 size_t mode_name_len = g_utf8_strlen(mode_name, -1);
294 if (!((
size_t)bang_len <= mode_name_len &&
300 if (eob[0] ==
'\0' || eob[1] ==
'\0') {
303 return g_strdup(eob + 1);
306 return g_strdup(input);
310 .cfg_name_key =
"display-combi",
320 .private_data = NULL,
static ModeMode combi_mode_result(Mode *sw, int mretv, char **input, unsigned int selected_line)
static unsigned int combi_mode_get_num_entries(const Mode *sw)
static char * combi_get_completion(const Mode *sw, unsigned int index)
static int combi_mode_init(Mode *sw)
static char * combi_preprocess_input(Mode *sw, const char *input)
static void combi_mode_parse_switchers(Mode *sw)
static cairo_surface_t * combi_get_icon(const Mode *sw, unsigned int index, int height)
static void combi_mode_destroy(Mode *sw)
static int combi_mode_match(const Mode *sw, rofi_int_matcher **tokens, unsigned int index)
static char * combi_mgrv(const Mode *sw, unsigned int selected_line, int *state, GList **attr_list, int get_entry)
char * mode_get_completion(const Mode *mode, unsigned int selected_line)
void mode_destroy(Mode *mode)
int mode_init(Mode *mode)
unsigned int mode_get_num_entries(const Mode *mode)
const char * mode_get_display_name(const Mode *mode)
ModeMode mode_result(Mode *mode, int menu_retv, char **input, unsigned int selected_line)
char * mode_get_display_value(const Mode *mode, unsigned int selected_line, int *state, GList **attribute_list, int get_entry)
void mode_set_private_data(Mode *mode, void *pd)
int mode_token_match(const Mode *mode, rofi_int_matcher **tokens, unsigned int selected_line)
void * mode_get_private_data(const Mode *mode)
const char * mode_get_name(const Mode *mode)
cairo_surface_t * mode_get_icon(const Mode *mode, unsigned int selected_line, int height)
Mode * rofi_collect_modi_search(const char *name)
Mode * script_switcher_parse_setup(const char *str)
int utf8_strncmp(const char *a, const char *b, size_t n)
unsigned int cmd_list_length
unsigned int num_switchers
gboolean combi_hide_mode_prefix
ThemeWidget * rofi_config_find_widget(const char *name, const char *state, gboolean exact)
Property * rofi_theme_find_property(ThemeWidget *widget, PropertyType type, const char *property, gboolean exact)