rofi  1.5.1
helper.h
Go to the documentation of this file.
1 /*
2  * rofi
3  *
4  * MIT/X11 License
5  * Copyright © 2013-2017 Qball Cow <qball@gmpclient.org>
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining
8  * a copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sublicense, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  *
26  */
27 
28 #ifndef ROFI_HELPER_H
29 #define ROFI_HELPER_H
30 #include <cairo.h>
31 #include "rofi-types.h"
32 G_BEGIN_DECLS
33 
54 int helper_parse_setup ( char * string, char ***output, int *length, ... );
55 
64 rofi_int_matcher **helper_tokenize ( const char *input, int case_sensitive );
65 
71 void helper_tokenize_free ( rofi_int_matcher ** tokens );
72 
82 int find_arg_char ( const char * const key, char *val );
83 
92 int find_arg_uint ( const char * const key, unsigned int *val );
93 
102 int find_arg_int ( const char * const key, int *val );
103 
112 int find_arg_str ( const char * const key, char** val );
113 
121 const char ** find_arg_strv ( const char *const key );
129 int find_arg ( const char * const key );
130 
139 int helper_token_match ( rofi_int_matcher * const *tokens, const char *input );
148 int execute_generator ( const char * cmd ) __attribute__( ( nonnull ) );
149 
155 int create_pid_file ( const char *pidfile );
156 
160 void remove_pid_file ( int fd );
161 
168 int config_sanity_check ( void );
169 
177 char helper_parse_char ( const char *arg );
178 
185 void cmd_set_arguments ( int argc, char **argv );
186 
194 char *rofi_expand_path ( const char *input );
195 
206 unsigned int levenshtein ( const char *needle, const glong needlelen, const char *haystack, const glong haystacklen );
207 
216 char * rofi_force_utf8 ( const gchar *data, ssize_t length );
217 
226 char * rofi_latin_to_utf8_strdup ( const char *input, gssize length );
227 
235 gchar *rofi_escape_markup ( gchar *text );
236 
247 int rofi_scorer_fuzzy_evaluate ( const char *pattern, glong plen, const char *str, glong slen );
261 int utf8_strncmp ( const char *a, const char* b, size_t n ) __attribute__( ( nonnull ( 1, 2 ) ) );
262 
266 typedef struct
267 {
269  const gchar *name;
271  const gchar *binary;
273  const gchar *description;
275  const gchar *icon;
277  const gchar *app_id;
279  const gchar *wmclass;
281  const gchar *command;
283 
295 gboolean helper_execute ( const char *wd, char **args, const char *error_precmd, const char *error_cmd, RofiHelperExecuteContext *context );
296 
308 gboolean helper_execute_command ( const char *wd, const char *cmd, gboolean run_in_term, RofiHelperExecuteContext *context );
309 
317 cairo_surface_t *cairo_image_surface_create_from_svg ( const gchar* file, int height );
318 
330 void parse_ranges ( char *input, rofi_range_pair **list, unsigned int *length );
331 
338 void rofi_output_formatted_line ( const char *format, const char *string, int selected_line, const char *filter );
339 G_END_DECLS
340 #endif // ROFI_HELPER_H
unsigned int levenshtein(const char *needle, const glong needlelen, const char *haystack, const glong haystacklen)
Definition: helper.c:702
const gchar * wmclass
Definition: helper.h:279
void parse_ranges(char *input, rofi_range_pair **list, unsigned int *length)
Definition: helper.c:1148
int find_arg_char(const char *const key, char *val)
Definition: helper.c:399
void rofi_output_formatted_line(const char *format, const char *string, int selected_line, const char *filter)
Definition: helper.c:1182
int config_sanity_check(void)
Definition: helper.c:574
int find_arg_uint(const char *const key, unsigned int *val)
Definition: helper.c:347
int find_arg_str(const char *const key, char **val)
Definition: helper.c:305
int find_arg_int(const char *const key, int *val)
Definition: helper.c:337
const char ** find_arg_strv(const char *const key)
Definition: helper.c:316
rofi_int_matcher ** helper_tokenize(const char *input, int case_sensitive)
Definition: helper.c:256
void remove_pid_file(int fd)
Definition: helper.c:547
int utf8_strncmp(const char *a, const char *b, size_t n) __attribute__((nonnull(1
const gchar * binary
Definition: helper.h:271
int helper_token_match(rofi_int_matcher *const *tokens, const char *input)
Definition: helper.c:473
char * rofi_latin_to_utf8_strdup(const char *input, gssize length)
Definition: helper.c:737
gboolean helper_execute_command(const char *wd, const char *cmd, gboolean run_in_term, RofiHelperExecuteContext *context)
Definition: helper.c:1000
const gchar * app_id
Definition: helper.h:277
void cmd_set_arguments(int argc, char **argv)
Definition: helper.c:73
char * rofi_expand_path(const char *input)
Definition: helper.c:669
const gchar * command
Definition: helper.h:281
const gchar * description
Definition: helper.h:273
int create_pid_file(const char *pidfile)
Definition: helper.c:508
int execute_generator(const char *cmd) __attribute__((nonnull))
Definition: helper.c:486
int helper_parse_setup(char *string, char ***output, int *length,...)
Definition: helper.c:107
char * rofi_force_utf8(const gchar *data, ssize_t length)
Definition: helper.c:753
gchar * rofi_escape_markup(gchar *text)
Definition: helper.c:743
void helper_tokenize_free(rofi_int_matcher **tokens)
Definition: helper.c:155
const gchar * name
Definition: helper.h:269
gboolean helper_execute(const char *wd, char **args, const char *error_precmd, const char *error_cmd, RofiHelperExecuteContext *context)
Definition: helper.c:975
cairo_surface_t * cairo_image_surface_create_from_svg(const gchar *file, int height)
Definition: helper.c:1085
int find_arg(const char *const key)
Definition: helper.c:295
char * pidfile
Definition: rofi.c:79
char helper_parse_char(const char *arg)
Definition: helper.c:358
const gchar * icon
Definition: helper.h:275
int rofi_scorer_fuzzy_evaluate(const char *pattern, glong plen, const char *str, glong slen)
Definition: helper.c:891