rofi  1.7.0
helper.h
Go to the documentation of this file.
1 /*
2  * rofi
3  *
4  * MIT/X11 License
5  * Copyright © 2013-2021 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 "rofi-types.h"
31 #include <cairo.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 
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 
169 int config_sanity_check(void);
170 
178 char helper_parse_char(const char *arg);
179 
186 void cmd_set_arguments(int argc, char **argv);
187 
195 char *rofi_expand_path(const char *input);
196 
207 unsigned int levenshtein(const char *needle, const glong needlelen,
208  const char *haystack, const glong haystacklen);
209 
219 char *rofi_force_utf8(const gchar *data, ssize_t length);
220 
229 char *rofi_latin_to_utf8_strdup(const char *input, gssize length);
230 
238 gchar *rofi_escape_markup(gchar *text);
239 
273 int rofi_scorer_fuzzy_evaluate(const char *pattern, glong plen, const char *str,
274  glong slen);
288 int utf8_strncmp(const char *a, const char *b, size_t n)
289  __attribute__((nonnull(1, 2)));
290 
294 typedef struct {
296  const gchar *name;
298  const gchar *binary;
300  const gchar *description;
302  const gchar *icon;
304  const gchar *app_id;
306  const gchar *wmclass;
308  const gchar *command;
310 
322 gboolean helper_execute(const char *wd, char **args, const char *error_precmd,
323  const char *error_cmd,
324  RofiHelperExecuteContext *context);
325 
337 gboolean helper_execute_command(const char *wd, const char *cmd,
338  gboolean run_in_term,
339  RofiHelperExecuteContext *context);
340 
348 cairo_surface_t *cairo_image_surface_create_from_svg(const gchar *file,
349  int height);
350 
362 void parse_ranges(char *input, rofi_range_pair **list, unsigned int *length);
363 
382 void rofi_output_formatted_line(const char *format, const char *string,
383  int selected_line, const char *filter);
384 
400 char *helper_string_replace_if_exists(char *string, ...);
401 
408 char *helper_get_theme_path(const char *file, const char *ext);
409 
410 G_END_DECLS
411 
413 #endif // ROFI_HELPER_H
void parse_ranges(char *input, rofi_range_pair **list, unsigned int *length)
Definition: helper.c:1146
void cmd_set_arguments(int argc, char **argv)
Definition: helper.c:70
int find_arg_char(const char *const key, char *val)
Definition: helper.c:407
gboolean helper_execute_command(const char *wd, const char *cmd, gboolean run_in_term, RofiHelperExecuteContext *context)
Definition: helper.c:1012
void helper_tokenize_free(rofi_int_matcher **tokens)
Definition: helper.c:119
char helper_parse_char(const char *arg)
Definition: helper.c:359
void rofi_output_formatted_line(const char *format, const char *string, int selected_line, const char *filter)
Definition: helper.c:1163
gboolean helper_execute(const char *wd, char **args, const char *error_precmd, const char *error_cmd, RofiHelperExecuteContext *context)
Definition: helper.c:984
unsigned int levenshtein(const char *needle, const glong needlelen, const char *haystack, const glong haystacklen)
Definition: helper.c:745
char * rofi_latin_to_utf8_strdup(const char *input, gssize length)
Definition: helper.c:781
int create_pid_file(const char *pidfile)
Definition: helper.c:538
const char ** find_arg_strv(const char *const key)
Definition: helper.c:320
int helper_parse_setup(char *string, char ***output, int *length,...)
Definition: helper.c:75
int execute_generator(const char *cmd) __attribute__((nonnull))
Definition: helper.c:515
gchar * rofi_escape_markup(gchar *text)
Definition: helper.c:787
int find_arg_int(const char *const key, int *val)
Definition: helper.c:340
void remove_pid_file(int fd)
Definition: helper.c:576
cairo_surface_t * cairo_image_surface_create_from_svg(const gchar *file, int height)
int rofi_scorer_fuzzy_evaluate(const char *pattern, glong plen, const char *str, glong slen)
Definition: helper.c:902
char * rofi_expand_path(const char *input)
Definition: helper.c:713
int find_arg_str(const char *const key, char **val)
Definition: helper.c:310
int utf8_strncmp(const char *a, const char *b, size_t n) __attribute__((nonnull(1
rofi_int_matcher ** helper_tokenize(const char *input, int case_sensitive)
Definition: helper.c:262
char * helper_get_theme_path(const char *file, const char *ext)
Definition: helper.c:1052
int find_arg_uint(const char *const key, unsigned int *val)
Definition: helper.c:349
char * helper_string_replace_if_exists(char *string,...)
Definition: helper.c:1249
int find_arg(const char *const key)
Definition: helper.c:301
int helper_token_match(rofi_int_matcher *const *tokens, const char *input)
Definition: helper.c:494
int config_sanity_check(void)
Definition: helper.c:603
char * rofi_force_utf8(const gchar *data, ssize_t length)
Definition: helper.c:796
char * pidfile
Definition: rofi.c:81
const gchar * binary
Definition: helper.h:298
const gchar * wmclass
Definition: helper.h:306
const gchar * app_id
Definition: helper.h:304
const gchar * description
Definition: helper.h:300
const gchar * name
Definition: helper.h:296
const gchar * icon
Definition: helper.h:302
const gchar * command
Definition: helper.h:308