29#define G_LOG_DOMAIN "Modes.Combi"
40#include <pango/pango.h>
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 &&
172 selected_line - pd->
starts[switcher]);
181 if (selected_line >= pd->
starts[i] &&
184 selected_line - pd->
starts[i]);
193 unsigned int index) {
207 GList **attr_list,
int get_entry) {
211 if (selected_line >= pd->
starts[i] &&
214 selected_line - pd->
starts[i], state, attr_list,
222 if (selected_line >= pd->
starts[i] &&
226 selected_line - pd->
starts[i],
227 state, attr_list, TRUE);
233 str = g_markup_escape_text(tmp, -1);
242 if (attr_list != NULL) {
247 PangoAttribute *pa = pango_attr_foreground_new(
250 pa->start_index = PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING;
251 pa->end_index = strlen(dname);
252 *attr_list = g_list_append(*attr_list, pa);
275 g_assert_not_reached();
280 unsigned int height) {
284 cairo_surface_t *
icon =
297 if (input != NULL && input[0] ==
'!') {
299 const char *eob = g_utf8_strchr(input, -1,
' ');
302 eob = &(input[strlen(input)]);
304 ssize_t bang_len = g_utf8_pointer_to_offset(input, eob) - 1;
308 size_t mode_name_len = g_utf8_strlen(mode_name, -1);
309 if (!((
size_t)bang_len <= mode_name_len &&
315 if (eob[0] ==
'\0' || eob[1] ==
'\0') {
318 return g_strdup(eob + 1);
321 return g_strdup(input);
325 .cfg_name_key =
"display-combi",
335 .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)
char * helper_string_replace_if_exists(char *string,...)
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)
unsigned int cmd_list_length
unsigned int num_switchers
gboolean combi_hide_mode_prefix
char * combi_display_format
Property * rofi_theme_find_property(ThemeWidget *widget, PropertyType type, const char *property, gboolean exact)
ThemeWidget * rofi_config_find_widget(const char *name, const char *state, gboolean exact)