29#define G_LOG_DOMAIN "Modes.Combi"
40#include <pango/pango.h>
66 char *switcher_str = g_strdup(
config.combi_modes);
67 const char *
const sep =
",#";
69 for (
char *token = strtok_r(switcher_str, sep, &savept); token != NULL;
70 token = strtok_r(NULL, sep, &savept)) {
72 if (g_strcmp0(token, sw->
name) == 0) {
73 g_warning(
"You cannot add '%s' to the list of combined modes.", sw->
name);
94 g_warning(
"Invalid script switcher: %s", token);
103 unsigned int length = 0;
146 unsigned int selected_line) {
149 if (input[0][0] ==
'!') {
152 char *eob = g_utf8_strchr(input[0], -1,
' ');
154 eob = &(input[0][strlen(input[0])]);
156 ssize_t bang_len = g_utf8_pointer_to_offset(input[0], eob) - 1;
160 size_t mode_name_len = g_utf8_strlen(mode_name, -1);
161 if ((
size_t)bang_len <= mode_name_len &&
170 char *n = g_strdup(eob + 1);
172 selected_line - pd->
starts[switcher]);
175 }
else if (eob[0] ==
'\0') {
178 selected_line - pd->
starts[switcher]);
189 if (selected_line >= pd->
starts[i] &&
192 selected_line - pd->
starts[i]);
201 unsigned int index) {
215 GList **attr_list,
int get_entry) {
219 if (selected_line >= pd->
starts[i] &&
222 selected_line - pd->
starts[i], state, attr_list,
230 if (selected_line >= pd->
starts[i] &&
234 selected_line - pd->
starts[i],
235 state, attr_list, TRUE);
238 if (!
config.combi_hide_mode_prefix) {
241 str = g_markup_escape_text(tmp, -1);
247 "{mode}", dname,
"{text}", str,
251 if (attr_list != NULL) {
256 PangoAttribute *pa = pango_attr_foreground_new(
259 pa->start_index = PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING;
260 pa->end_index = strlen(dname);
261 *attr_list = g_list_append(*attr_list, pa);
284 g_assert_not_reached();
289 unsigned int height) {
293 cairo_surface_t *
icon =
306 if (input != NULL && input[0] ==
'!') {
308 const char *eob = g_utf8_strchr(input, -1,
' ');
311 eob = &(input[strlen(input)]);
313 ssize_t bang_len = g_utf8_pointer_to_offset(input, eob) - 1;
317 size_t mode_name_len = g_utf8_strlen(mode_name, -1);
318 if (!((
size_t)bang_len <= mode_name_len &&
324 if (eob[0] ==
'\0' || eob[1] ==
'\0') {
327 return g_strdup(eob + 1);
330 return g_strdup(input);
334 .cfg_name_key =
"display-combi",
344 .private_data = NULL,
static char * combi_mgrv(const Mode *sw, unsigned int selected_line, int *state, GList **attr_list, int get_entry)
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 cairo_surface_t * combi_get_icon(const Mode *sw, unsigned int index, unsigned int height)
static int combi_mode_init(Mode *sw)
static char * combi_get_completion(const Mode *sw, unsigned int index)
static void combi_mode_parse_switchers(Mode *sw)
static void combi_mode_destroy(Mode *sw)
static char * combi_preprocess_input(Mode *sw, const char *input)
static int combi_mode_match(const Mode *sw, rofi_int_matcher **tokens, unsigned int index)
Property * rofi_theme_find_property(ThemeWidget *wid, PropertyType type, const char *property, gboolean exact)
char * helper_string_replace_if_exists(char *string,...)
ThemeWidget * rofi_config_find_widget(const char *name, const char *state, gboolean exact)
void mode_destroy(Mode *mode)
const char * mode_get_name(const Mode *mode)
int mode_init(Mode *mode)
cairo_surface_t * mode_get_icon(Mode *mode, unsigned int selected_line, unsigned int height)
const char * mode_get_display_name(const Mode *mode)
unsigned int mode_get_num_entries(const Mode *mode)
ModeMode mode_result(Mode *mode, int menu_retv, char **input, unsigned int selected_line)
void * mode_get_private_data(const Mode *mode)
void mode_set_private_data(Mode *mode, void *pd)
int mode_token_match(const Mode *mode, rofi_int_matcher **tokens, unsigned int selected_line)
char * mode_get_display_value(const Mode *mode, unsigned int selected_line, int *state, GList **attribute_list, int get_entry)
char * mode_get_completion(const Mode *mode, unsigned int selected_line)
Mode * rofi_collect_modes_search(const char *name)
Mode * script_mode_parse_setup(const char *str)
int utf8_strncmp(const char *a, const char *b, size_t n)
struct rofi_int_matcher_t rofi_int_matcher
unsigned int cmd_list_length
unsigned int num_switchers