Skip to content

Commit

Permalink
Merge branch 'davatorium:next' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
giomatfois62 committed Mar 2, 2024
2 parents 3284837 + 8061e4e commit dcf7505
Show file tree
Hide file tree
Showing 23 changed files with 158 additions and 94 deletions.
47 changes: 22 additions & 25 deletions Examples/test_script_mode.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
#!/usr/bin/env bash

if [ "$*" = "quit" ]
then
exit 0
if [ "$*" = "quit" ]; then
exit 0
fi

if [ "$@" ]
then
# Override the previously set prompt.
echo -en "\x00prompt\x1fChange prompt\n"
for a in {1..10}
do
echo "$a"
done
echo "quit"
if [ "$@" ]; then
# Override the previously set prompt.
echo -en "\x00prompt\x1fChange prompt\n"
for a in {1..10}; do
echo "$a"
done
echo "quit"
else
echo -en "\x00prompt\x1ftesting\n"
echo -en "\0urgent\x1f0,2\n"
echo -en "\0active\x1f1\n"
echo -en "\0markup-rows\x1ftrue\n"
echo -en "\0message\x1fSpecial <b>bold</b>message\n"
echo -en "\x00prompt\x1ftesting\n"
echo -en "\0urgent\x1f0,2\n"
echo -en "\0active\x1f1\n"
echo -en "\0markup-rows\x1ftrue\n"
echo -en "\0message\x1fSpecial <b>bold</b>message\n"

echo -en "aap\0icon\x1ffolder\n"
echo -en "blob\0icon\x1ffolder\x1fdisplay\x1fblub\n"
echo "noot"
echo "mies"
echo -en "-------------\0nonselectable\x1ftrue\n"
echo "testing"
echo "<b>Bold</b>"
echo "quit"
echo -en "aap\0icon\x1ffolder\n"
echo -en "blob\0icon\x1ffolder\x1fdisplay\x1fblub\n"
echo "noot"
echo "mies"
echo -en "-------------\0nonselectable\x1ftrue\x1fpermanent\x1ftrue\n"
echo "testing"
echo "<b>Bold</b>"
echo "quit"
fi
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ You can also use [Meson](https://mesonbuild.com/) as an alternative.

- libcairo-xcb

- libglib2.0 >= 2.68
- libglib2.0 >= 2.72
- gmodule-2.0
- gio-unix-2.0

Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ AM_PROG_AR
dnl ---------------------------------------------------------------------
dnl Base CFLAGS
dnl ---------------------------------------------------------------------
AM_CFLAGS="-Wall -Wextra -Wparentheses -Winline -pedantic -Wunreachable-code"
AM_CFLAGS="-Wall -Wextra -Wparentheses -Winline -pedantic -Wno-overlength-strings -Wunreachable-code"

dnl ---------------------------------------------------------------------
dnl Enable source code coverage reporting for GCC
Expand Down Expand Up @@ -139,7 +139,7 @@ dnl ---------------------------------------------------------------------
dnl PKG_CONFIG based dependencies
dnl ---------------------------------------------------------------------
glib_min_major="2"
glib_min_minor="40"
glib_min_minor="72"
glib_min_version="${glib_min_major}.${glib_min_minor}"
NK_INIT([bindings xdg-theme])
PKG_CHECK_MODULES([glib], [glib-2.0 >= ${glib_min_version} gio-unix-2.0 gmodule-2.0])
Expand Down
4 changes: 2 additions & 2 deletions doc/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ endif
doxy_conf = configuration_data()
doxy_conf.set('PACKAGE', meson.project_name())
doxy_conf.set('VERSION', meson.project_version())
doxy_conf.set('abs_builddir', join_paths(meson.build_root(), meson.current_build_dir()))
doxy_conf.set('abs_top_srcdir', meson.source_root())
doxy_conf.set('abs_builddir', join_paths(meson.project_build_root(), meson.current_build_dir()))
doxy_conf.set('abs_top_srcdir', meson.project_source_root())

doxyfile = configure_file(
input: 'rofi.doxy.in',
Expand Down
2 changes: 2 additions & 0 deletions doc/rofi-script.5
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ The following options are supported:
.IP \(bu 2
\fBnonselectable\fP: If true the row cannot activated.
.IP \(bu 2
\fBpermantent\fP: If true the row always shows, independent of filter.
.IP \(bu 2
\fBinfo\fP: Info that, on selection, gets placed in the \fB\fCROFI_INFO\fR
environment variable. This entry does not get searched for filtering.
.IP \(bu 2
Expand Down
2 changes: 2 additions & 0 deletions doc/rofi-script.5.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ The following options are supported:

- **nonselectable**: If true the row cannot activated.

- **permantent**: If true the row always shows, independent of filter.

- **info**: Info that, on selection, gets placed in the `ROFI_INFO`
environment variable. This entry does not get searched for filtering.

Expand Down
3 changes: 3 additions & 0 deletions include/modes/dmenuscriptshared.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ typedef struct {
/** non-selectable */
gboolean nonselectable;

/** permanent */
gboolean permanent;

/** urgent */
gboolean urgent;
/** active */
Expand Down
1 change: 1 addition & 0 deletions include/rofi-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ typedef struct rofi_int_matcher_t {
*/
typedef struct _thread_state {
void (*callback)(struct _thread_state *t, gpointer data);
void (*free)(void *);
int priority;
} thread_state;

Expand Down
4 changes: 2 additions & 2 deletions lexer/theme-parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -672,11 +672,11 @@ t_property_scale_type

t_color_list
: t_property_color {
$$ = g_list_append ( NULL, g_memdup ( (gconstpointer)&($1), sizeof ( ThemeColor )));
$$ = g_list_append ( NULL, g_memdup2 ( (gconstpointer)&($1), sizeof ( ThemeColor )));
}
| t_color_list T_COMMA t_property_color {

$$ = g_list_append ($1, g_memdup ( (gconstpointer)&($3), sizeof ( ThemeColor )));
$$ = g_list_append ($1, g_memdup2 ( (gconstpointer)&($3), sizeof ( ThemeColor )));
}
;

Expand Down
13 changes: 7 additions & 6 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project('rofi', 'c',
version: '1.7.5-dev',
meson_version: '>=0.47.0',
meson_version: '>=0.59.0',
license: [ 'MIT' ],
default_options: [
'c_std=c99',
Expand All @@ -11,8 +11,8 @@ project('rofi', 'c',
c_compiler = meson.get_compiler('c')

add_project_arguments(
'-I@0@'.format(meson.build_root()),
'-I@0@'.format(join_paths(meson.source_root(), 'include')),
'-I@0@'.format(meson.project_build_root()),
'-I@0@'.format(join_paths(meson.project_source_root(), 'include')),
'-D_DEFAULT_SOURCE=1',
language: 'c'
)
Expand All @@ -22,6 +22,7 @@ flags = [
'-Winline',
'-Wunreachable-code',
'-Werror=missing-prototypes',
'-Wno-overlength-strings',
'-Wno-inline' # A bit too noisy with Bison…
]
foreach f : flags
Expand All @@ -42,7 +43,7 @@ desktop_install_dir = join_paths(get_option('datadir'), 'applications')
icondir = join_paths(get_option('datadir'), 'icons','hicolor', 'scalable', 'apps')

glib_min_major=2
glib_min_minor=40
glib_min_minor=72
glib_min_version='@0@.@1@'.format(glib_min_major, glib_min_minor)
plugins_deps = [
dependency('glib-2.0', version: '>= @0@'.format(glib_min_version)),
Expand Down Expand Up @@ -129,7 +130,7 @@ config_h = configure_file(output: 'config.h', configuration: header_conf)

nk_options = [
'bindings=true',
'git-work-tree=@0@'.format(meson.source_root()),
'git-work-tree=@0@'.format(meson.project_source_root()),
]
nk = subproject('libnkutils', default_options: nk_options)
nk_subproject_options = nk.get_variable('nk_options')
Expand Down Expand Up @@ -538,7 +539,7 @@ if cppcheck.found()
'--enable=all',
'-Uerror_dialog',
'--inconclusive',
'-I@0@'.format(join_paths(meson.source_root(), 'include')),
'-I@0@'.format(join_paths(meson.project_source_root(), 'include')),
rofi_sources
],
)
Expand Down
2 changes: 1 addition & 1 deletion source/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ char *rofi_force_utf8(const gchar *data, ssize_t length) {
GString *string;

if (g_utf8_validate(data, length, &end)) {
return g_memdup(data, length + 1);
return g_memdup2(data, length + 1);
}
string = g_string_sized_new(length + 16);

Expand Down
6 changes: 6 additions & 0 deletions source/modes/dmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ static void read_add_block(DmenuModePrivateData *pd, Block **block, char *data,
(*block)->values[(*block)->length].meta = NULL;
(*block)->values[(*block)->length].info = NULL;
(*block)->values[(*block)->length].nonselectable = FALSE;
(*block)->values[(*block)->length].permanent = FALSE;
char *end = data;
while (end < data + len && *end != '\0') {
end++;
Expand Down Expand Up @@ -668,6 +669,11 @@ static int dmenu_token_match(const Mode *sw, rofi_int_matcher **tokens,

/** Strip out the markup when matching. */
char *esc = NULL;
if (rmpd->cmd_list[index].permanent == TRUE) {
// Always match
return 1;
}

if (rmpd->do_markup) {
pango_parse_markup(rmpd->cmd_list[index].entry, -1, 0, NULL, &esc, NULL,
NULL);
Expand Down
5 changes: 3 additions & 2 deletions source/modes/drun.c
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,7 @@ static gboolean drun_read_cache(DRunModePrivateData *pd,
drun_read_stringv(fd, &(entry->keywords));

drun_read_string(fd, &(entry->comment));
drun_read_string(fd, &(entry->url));
int32_t type = 0;
drun_read_integer(fd, &(type));
entry->type = type;
Expand Down Expand Up @@ -1081,7 +1082,7 @@ static void get_apps(DRunModePrivateData *pd) {
g_free(cache_file);
}

static void drun_mode_parse_entry_fields() {
static void drun_mode_parse_entry_fields(void) {
char *savept = NULL;
// Make a copy, as strtok will modify it.
char *switcher_str = g_strdup(config.drun_match_fields);
Expand Down Expand Up @@ -1117,7 +1118,7 @@ static void drun_mode_parse_entry_fields() {
g_free(switcher_str);
}

static void drun_mode_parse_display_format() {
static void drun_mode_parse_display_format(void) {
for (int i = 0; i < DRUN_MATCH_NUM_FIELDS; i++) {
if (matching_entry_fields[i].enabled_display)
continue;
Expand Down
2 changes: 1 addition & 1 deletion source/modes/recursivebrowser.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ static unsigned int recursive_browser_mode_get_num_entries(const Mode *sw) {
return pd->array_length;
}

static ModeMode recursive_browser_mode_result(Mode *sw, int mretv, char **input,
static ModeMode recursive_browser_mode_result(Mode *sw, int mretv, G_GNUC_UNUSED char **input,
unsigned int selected_line) {
ModeMode retv = MODE_EXIT;
FileBrowserModePrivateData *pd =
Expand Down
28 changes: 19 additions & 9 deletions source/modes/run.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,13 @@ typedef struct {
/**
* @param cmd The cmd to execute
* @param run_in_term Indicate if command should be run in a terminal
* @param orig The cmd to store in history
*
* Execute command and add to history.
* Exact entries should be stored unquoted any custom or with filename
* should be saved in history quoted.
*/
static gboolean exec_cmd(const char *cmd, int run_in_term) {
static gboolean exec_cmd(const char *cmd, int run_in_term, const char *orig) {
GError *error = NULL;
if (!cmd || !cmd[0]) {
return FALSE;
Expand All @@ -118,12 +121,12 @@ static gboolean exec_cmd(const char *cmd, int run_in_term) {
* It is allowed to be a bit slower.
*/

history_set(path, cmd);
history_set(path, orig);
g_free(path);
g_free(lf_cmd);
return TRUE;
}
history_remove(path, cmd);
history_remove(path, orig);
g_free(path);
g_free(lf_cmd);
return FALSE;
Expand Down Expand Up @@ -444,12 +447,17 @@ static ModeMode run_mode_result(Mode *sw, int mretv, char **input,
&path);
if (retv == MODE_EXIT) {
if (path == NULL) {
exec_cmd(rmpd->cmd_list[rmpd->selected_line].entry, run_in_term);
char *arg = g_shell_quote(rmpd->cmd_list[rmpd->selected_line].entry);
exec_cmd(arg, run_in_term, rmpd->cmd_list[rmpd->selected_line].entry);
g_free(arg);
} else {
char *arg = g_strdup_printf(
"%s '%s'", rmpd->cmd_list[rmpd->selected_line].entry, path);
exec_cmd(arg, run_in_term);
char *earg = g_shell_quote(rmpd->cmd_list[rmpd->selected_line].entry);
char *epath = g_shell_quote(path);
char *arg = g_strdup_printf("%s %s", earg, epath);
exec_cmd(arg, run_in_term, arg);
g_free(arg);
g_free(earg);
g_free(epath);
}
}
g_free(path);
Expand All @@ -458,12 +466,14 @@ static ModeMode run_mode_result(Mode *sw, int mretv, char **input,
}

if ((mretv & MENU_OK) && rmpd->cmd_list[selected_line].entry != NULL) {
if (!exec_cmd(rmpd->cmd_list[selected_line].entry, run_in_term)) {
char *earg = g_shell_quote(rmpd->cmd_list[selected_line].entry);
if (!exec_cmd(earg, run_in_term, rmpd->cmd_list[selected_line].entry)) {
retv = RELOAD_DIALOG;
}
g_free(earg);
} else if ((mretv & MENU_CUSTOM_INPUT) && *input != NULL &&
*input[0] != '\0') {
if (!exec_cmd(*input, run_in_term)) {
if (!exec_cmd(*input, run_in_term, *input)) {
retv = RELOAD_DIALOG;
}
} else if ((mretv & MENU_ENTRY_DELETE) &&
Expand Down
10 changes: 10 additions & 0 deletions source/modes/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ void dmenuscript_parse_entry_extras(G_GNUC_UNUSED Mode *sw,
} else if (strcasecmp(key, "nonselectable") == 0) {
entry->nonselectable = g_ascii_strcasecmp(value, "true") == 0;
g_free(value);
} else if (strcasecmp(key, "permanent") == 0) {
entry->permanent = g_ascii_strcasecmp(value, "true") == 0;
g_free(value);
} else if (strcasecmp(key, "urgent") == 0) {
entry->urgent = g_ascii_strcasecmp(value, "true") == 0;
g_free(value);
Expand Down Expand Up @@ -252,6 +255,7 @@ static DmenuScriptEntry *execute_executor(Mode *sw, char *arg,
retv[(*length)].icon_fetch_uid = 0;
retv[(*length)].icon_fetch_size = 0;
retv[(*length)].nonselectable = FALSE;
retv[(*length)].permanent = FALSE;
if (buf_length > 0 && (read_length > (ssize_t)buf_length)) {
dmenuscript_parse_entry_extras(sw, &(retv[(*length)]),
buffer + buf_length,
Expand Down Expand Up @@ -454,6 +458,12 @@ static int script_token_match(const Mode *sw, rofi_int_matcher **tokens,
ScriptModePrivateData *rmpd = sw->private_data;
/** Strip out the markup when matching. */
char *esc = NULL;

if (rmpd->cmd_list[index].permanent == TRUE) {
// Always match
return 1;
}

if (rmpd->do_markup) {
pango_parse_markup(rmpd->cmd_list[index].entry, -1, 0, NULL, &esc, NULL,
NULL);
Expand Down
Loading

0 comments on commit dcf7505

Please sign in to comment.