28 #define G_LOG_DOMAIN "Dialogs.Combi" 38 #include <pango/pango.h> 69 const char *
const sep =
",#";
71 for (
char *token = strtok_r ( switcher_str, sep, &savept ); token != NULL;
72 token = strtok_r ( NULL, sep, &savept ) ) {
91 g_warning (
"Invalid script switcher: %s", token );
97 g_free ( switcher_str );
106 pd->starts = g_malloc0 (
sizeof (
int ) * pd->num_switchers );
107 pd->lengths = g_malloc0 (
sizeof (
int ) * pd->num_switchers );
108 for (
unsigned int i = 0; i < pd->num_switchers; i++ ) {
109 if ( !
mode_init ( pd->switchers[i].mode ) ) {
113 if ( pd->cmd_list_length == 0 ) {
114 pd->cmd_list_length = 0;
115 for (
unsigned int i = 0; i < pd->num_switchers; i++ ) {
117 pd->starts[i] = pd->cmd_list_length;
118 pd->lengths[i] = length;
119 pd->cmd_list_length += length;
128 unsigned int length = 0;
156 if ( input[0][0] ==
'!' ) {
158 char *eob = strchrnul ( input[0],
' ' );
159 ssize_t bang_len = g_utf8_pointer_to_offset ( input[0], eob ) - 1;
160 if ( bang_len > 0 ) {
161 for (
unsigned i = 0; switcher == -1 && i < pd->
num_switchers; i++ ) {
163 size_t mode_name_len = g_utf8_strlen ( mode_name, -1 );
164 if ( (
size_t) bang_len <= mode_name_len &&
utf8_strncmp ( &input[0][1], mode_name, bang_len ) == 0 ) {
169 if ( switcher >= 0 ) {
170 if ( eob[0] ==
' ' ) {
173 selected_line - pd->
starts[switcher] );
183 if ( selected_line >= pd->
starts[i] &&
203 static char *
combi_mgrv (
const Mode *sw,
unsigned int selected_line,
int *state, GList **attr_list,
int get_entry )
208 if ( selected_line >= pd->
starts[i] && selected_line < ( pd->
starts[i] + pd->
lengths[i] ) ) {
216 if ( selected_line >= pd->
starts[i] && selected_line < ( pd->
starts[i] + pd->
lengths[i] ) ) {
221 retv = g_strdup_printf (
"%s %s", dname, str );
225 if ( attr_list != NULL ) {
229 PangoAttribute *pa = pango_attr_foreground_new (
233 pa->start_index = PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING;
234 pa->end_index = strlen ( dname );
235 *attr_list = g_list_append ( *attr_list, pa );
256 g_assert_not_reached ();
278 if ( input != NULL && input[0] ==
'!' ) {
279 char *eob = strchrnul ( input,
' ' );
280 ssize_t bang_len = g_utf8_pointer_to_offset ( input, eob ) - 1;
281 if ( bang_len > 0 ) {
284 size_t mode_name_len = g_utf8_strlen ( mode_name, -1 );
285 if ( !( (
size_t) bang_len <= mode_name_len &&
utf8_strncmp ( &input[1], mode_name, bang_len ) == 0 ) ) {
290 if ( eob[0] ==
'\0' || eob[1] ==
'\0' ) {
293 return g_strdup ( eob + 1 );
296 return g_strdup ( input );
302 .cfg_name_key =
"display-combi",
312 .private_data = NULL,
static char * combi_preprocess_input(Mode *sw, const char *input)
int mode_token_match(const Mode *mode, rofi_int_matcher **tokens, unsigned int selected_line)
static cairo_surface_t * combi_get_icon(const Mode *sw, unsigned int index, int height)
int utf8_strncmp(const char *a, const char *b, size_t n)
ThemeWidget * rofi_theme_find_widget(const char *name, const char *state, gboolean exact)
static int combi_mode_init(Mode *sw)
cairo_surface_t * mode_get_icon(const Mode *mode, unsigned int selected_line, int height)
Property * rofi_theme_find_property(ThemeWidget *widget, PropertyType type, const char *property, gboolean exact)
gboolean combi_hide_mode_prefix
static ModeMode combi_mode_result(Mode *sw, int mretv, char **input, unsigned int selected_line)
static void combi_mode_destroy(Mode *sw)
void * mode_get_private_data(const Mode *mode)
unsigned int num_switchers
Mode * rofi_collect_modi_search(const char *name)
void mode_destroy(Mode *mode)
static unsigned int combi_mode_get_num_entries(const Mode *sw)
unsigned int cmd_list_length
static void combi_mode_parse_switchers(Mode *sw)
unsigned int mode_get_num_entries(const Mode *mode)
char * mode_get_display_value(const Mode *mode, unsigned int selected_line, int *state, GList **attribute_list, int get_entry)
const char * mode_get_name(const Mode *mode)
void mode_set_private_data(Mode *mode, void *pd)
Mode * script_switcher_parse_setup(const char *str)
ModeMode mode_result(Mode *mode, int menu_retv, char **input, unsigned int selected_line)
static char * combi_get_completion(const Mode *sw, unsigned int index)
const char * mode_get_display_name(const Mode *mode)
static char * combi_mgrv(const Mode *sw, unsigned int selected_line, int *state, GList **attr_list, int get_entry)
static int combi_mode_match(const Mode *sw, rofi_int_matcher **tokens, unsigned int index)
char * mode_get_completion(const Mode *mode, unsigned int selected_line)
int mode_init(Mode *mode)