Merge branch 'configurable-modifiers' into 'develop'

Make modifiers configurable

See merge request pwmt/zathura!83
This commit is contained in:
Sebastian Ramacher 2023-12-04 00:55:21 +01:00
commit 1e9b6a904f
6 changed files with 327 additions and 276 deletions

View file

@ -448,18 +448,18 @@ girara
* Value type: String * Value type: String
* Default value: #232323 * Default value: #232323
*default-fg*
Defines the default foreground color
* Value type: String
* Default value: #DDDDDD
*default-bg* *default-bg*
Defines the default background color Defines the default background color
* Value type: String * Value type: String
* Default value: #000000 * Default value: #000000
*default-fg*
Defines the default foreground color
* Value type: String
* Default value: #DDDDDD
*exec-command* *exec-command*
Defines a command the should be prepended to any command run with exec. Defines a command the should be prepended to any command run with exec.
@ -611,16 +611,16 @@ zathura
* Value type: String * Value type: String
* Default value: plain * Default value: plain
*dbus-service* *dbus-raise-window*
En/Disables the D-Bus service. If the services is disabled, SyncTeX forward Defines whether zathura's window should be raised when receiving certain
synchronization is not available. commands via D-Bus.
* Value type: Boolean * Value type: Boolean
* Default value: true * Default value: true
*dbus-raise-window* *dbus-service*
Defines whether zathura's window should be raised when receiving certain En/Disables the D-Bus service. If the services is disabled, SyncTeX forward
commands via D-Bus. synchronization is not available.
* Value type: Boolean * Value type: Boolean
* Default value: true * Default value: true
@ -639,11 +639,27 @@ zathura
* Value type: String * Value type: String
* Default value: glib * Default value: glib
*incremental-search* *first-page-column*
En/Disables incremental search (search while typing). Defines the column in which the first page will be displayed.
This setting is stored separately for every value of pages-per-row according to
the following pattern <1 page per row>:[<2 pages per row>[: ...]]. The last
value in the list will be used for all other number of pages per row if not set
explicitly.
* Value type: Boolean Per default, the first column is set to 2 for double-page layout, i.e. the value
* Default value: true is set to 1:2. A value of 1:1:3 would put the first page in dual-page layout in
the first column, and for layouts with more columns the first page would be put
in the 3rd column.
* Value type: String
* Default value: 1:2
*highlight-active-color*
Defines the color that is used to show the current selected highlighted element
(e.g: current search result)
* Value type: String
* Default value: #00BC00
*highlight-color* *highlight-color*
Defines the color that is used for highlighting parts of the document (e.g.: Defines the color that is used for highlighting parts of the document (e.g.:
@ -659,24 +675,61 @@ zathura
* Value type: String * Value type: String
* Default value: #9FBC00 * Default value: #9FBC00
*highlight-active-color*
Defines the color that is used to show the current selected highlighted element
(e.g: current search result)
* Value type: String
* Default value: #00BC00
*highlight-transparency* *highlight-transparency*
Defines the opacity of a highlighted element Defines the opacity of a highlighted element
* Value type: Float * Value type: Float
* Default value: 0.5 * Default value: 0.5
*page-padding* *highlighter-modifier*
The page padding defines the gap in pixels between each rendered page. Defines the modifier that needs to be pressed together with the left mouse button
to draw the highlighter. Possible values are "shift", "ctrl" and "alt".
* Value type: Integer * Value type: String
* Default value: 1 * Default value: shift
*incremental-search*
En/Disables incremental search (search while typing).
* Value type: Boolean
* Default value: true
*index-active-bg*
Define the background color of the selected element in index mode.
* Value type: String
* Default value: #9FBC00
*index-active-fg*
Defines the foreground color of the selected element in index mode.
* Value type: String
* Default value: #232323
*index-bg*
Define the background color of the index mode.
* Value type: String
* Default value: #232323
*index-fg*
Defines the foreground color of the index mode.
* Value type: String
* Default value: #DDDDDD
*link-hadjust*
En/Disables aligning to the left internal link targets, for example from the
index.
* Value type: Boolean
* Default value: true
*link-zoom*
En/Disables the ability of changing zoom when following links.
* Value type: Boolean
* Default value: true
*page-cache-size* *page-cache-size*
Defines the maximum number of pages that could be kept in the page cache. When Defines the maximum number of pages that could be kept in the page cache. When
@ -688,6 +741,18 @@ zathura
* Value type: Integer * Value type: Integer
* Default value: 15 * Default value: 15
*page-padding*
The page padding defines the gap in pixels between each rendered page.
* Value type: Integer
* Default value: 1
*page-right-to-left*
Defines whether pages in multi-column view should start from the right side.
* Value type: Boolean
* Default value: false
*page-thumbnail-size* *page-thumbnail-size*
Defines the maximum size in pixels of the thumbnail that could be kept in the Defines the maximum size in pixels of the thumbnail that could be kept in the
thumbnail cache per page. The thumbnail is scaled for a quick preview during thumbnail cache per page. The thumbnail is scaled for a quick preview during
@ -705,39 +770,24 @@ zathura
* Value type: Integer * Value type: Integer
* Default value: 1 * Default value: 1
*first-page-column*
Defines the column in which the first page will be displayed.
This setting is stored separately for every value of pages-per-row according to
the following pattern <1 page per row>:[<2 pages per row>[: ...]]. The last
value in the list will be used for all other number of pages per row if not set
explicitly.
Per default, the first column is set to 2 for double-page layout, i.e. the value
is set to 1:2. A value of 1:1:3 would put the first page in dual-page layout in
the first column, and for layouts with more columns the first page would be put
in the 3rd column.
* Value type: String
* Default value: 1:2
*recolor* *recolor*
En/Disables recoloring En/Disables recoloring
* Value type: Boolean * Value type: Boolean
* Default value: false * Default value: false
*recolor-keephue*
En/Disables keeping original hue when recoloring
* Value type: Boolean
* Default value: false
*recolor-darkcolor* *recolor-darkcolor*
Defines the color value that is used to represent dark colors in recoloring mode Defines the color value that is used to represent dark colors in recoloring mode
* Value type: String * Value type: String
* Default value: #FFFFFF * Default value: #FFFFFF
*recolor-keephue*
En/Disables keeping original hue when recoloring
* Value type: Boolean
* Default value: false
*recolor-lightcolor* *recolor-lightcolor*
Defines the color value that is used to represent light colors in recoloring mode Defines the color value that is used to represent light colors in recoloring mode
@ -750,13 +800,6 @@ zathura
* Value type: Boolean * Value type: Boolean
* Default value: false * Default value: false
*smooth-reload*
Defines if flickering will be removed when a file is reloaded on change. This
option might increase memory usage.
* Value type: Boolean
* Default value: true
*render-loading* *render-loading*
Defines if the "Loading..." text should be displayed if a page is rendered. Defines if the "Loading..." text should be displayed if a page is rendered.
@ -775,195 +818,6 @@ zathura
* Value type: String * Value type: String
* Default value: #000000 * Default value: #000000
*scroll-hstep*
Defines the horizontal step size of scrolling by calling the scroll command once
* Value type: Float
* Default value: -1
*scroll-step*
Defines the step size of scrolling by calling the scroll command once
* Value type: Float
* Default value: 40
*scroll-full-overlap*
Defines the proportion of the current viewing area that should be
visible after scrolling a full page.
* Value type: Float
* Default value: 0
*scroll-wrap*
Defines if the last/first page should be wrapped
* Value type: Boolean
* Default value: false
*show-directories*
Defines if the directories should be displayed in completion.
* Value type: Boolean
* Default value: true
*show-hidden*
Defines if hidden files and directories should be displayed in completion.
* Value type: Boolean
* Default value: false
*show-recent*
Defines the number of recent files that should be displayed in completion.
If the value is negative, no upper bounds are applied. If the value is 0, no
recent files are shown.
* Value type: Integer
* Default value: 10
*scroll-page-aware*
Defines if scrolling by half or full pages stops at page boundaries.
* Value type: Boolean
* Default value: false
*link-zoom*
En/Disables the ability of changing zoom when following links.
* Value type: Boolean
* Default value: true
*link-hadjust*
En/Disables aligning to the left internal link targets, for example from the
index.
* Value type: Boolean
* Default value: true
*search-hadjust*
En/Disables horizontally centered search results.
* Value type: Boolean
* Default value: true
*window-title-basename*
Use basename of the file in the window title.
* Value type: Boolean
* Default value: false
*window-title-home-tilde*
Display a short version of the file path, which replaces $HOME with ~, in the window title.
* Value type: Boolean
* Default value: false
*window-title-page*
Display the page number in the window title.
* Value type: Boolean
* Default value: false
*statusbar-basename*
Use basename of the file in the statusbar.
* Value type: Boolean
* Default value: false
*statusbar-page-percent*
Display (current page / total pages) as a percent in the statusbar.
* Value type: Boolean
* Default value: false
*statusbar-home-tilde*
Display a short version of the file path, which replaces $HOME with ~, in the statusbar.
* Value type: Boolean
* Default value: false
*zoom-center*
En/Disables horizontally centered zooming.
* Value type: Boolean
* Default value: false
*vertical-center*
Center the screen at the vertical midpoint of the page by default.
* Value type: Boolean
* Default value: false
*zoom-max*
Defines the maximum percentage that the zoom level can be.
* Value type: Integer
* Default value: 1000
*zoom-min*
Defines the minimum percentage that the zoom level can be.
* Value type: Integer
* Default value: 10
*zoom-step*
Defines the amount of percent that is zoomed in or out on each command.
* Value type: Integer
* Default value: 10
*selection-clipboard*
Defines the X clipboard into which mouse-selected data will be written. When it
is "clipboard", selected data will be written to the CLIPBOARD clipboard, and
can be pasted using the Ctrl+v key combination. When it is "primary", selected
data will be written to the PRIMARY clipboard, and can be pasted using the
middle mouse button, or the Shift-Insert key combination.
* Value type: String
* Default value: primary
*selection-notification*
Defines if a notification should be displayed after selecting text.
* Value type: Boolean
* Default value: true
*synctex*
En/Disables SyncTeX backward synchronization support.
* Value type: Boolean
* Default value: true
*synctex-editor-command*
Defines the command executed for SyncTeX backward synchronization.
* Value type: String
* Default value:
*index-fg*
Defines the foreground color of the index mode.
* Value type: String
* Default value: #DDDDDD
*index-bg*
Define the background color of the index mode.
* Value type: String
* Default value: #232323
*index-active-fg*
Defines the foreground color of the selected element in index mode.
* Value type: String
* Default value: #232323
*index-active-bg*
Define the background color of the selected element in index mode.
* Value type: String
* Default value: #9FBC00
*sandbox* *sandbox*
Defines the sandbox mode to use for the seccomp syscall filter. Possible Defines the sandbox mode to use for the seccomp syscall filter. Possible
values are "none", "normal" and "strict". If "none" is used, the sandbox values are "none", "normal" and "strict". If "none" is used, the sandbox
@ -989,6 +843,130 @@ zathura
When running under WSL, the default is "none" since seccomp is not supported in When running under WSL, the default is "none" since seccomp is not supported in
that environment. that environment.
*scroll-full-overlap*
Defines the proportion of the current viewing area that should be
visible after scrolling a full page.
* Value type: Float
* Default value: 0
*scroll-hstep*
Defines the horizontal step size of scrolling by calling the scroll command once
* Value type: Float
* Default value: -1
*scroll-step*
Defines the step size of scrolling by calling the scroll command once
* Value type: Float
* Default value: 40
*scroll-page-aware*
Defines if scrolling by half or full pages stops at page boundaries.
* Value type: Boolean
* Default value: false
*scroll-wrap*
Defines if the last/first page should be wrapped
* Value type: Boolean
* Default value: false
*search-hadjust*
En/Disables horizontally centered search results.
* Value type: Boolean
* Default value: true
*selection-clipboard*
Defines the X clipboard into which mouse-selected data will be written. When it
is "clipboard", selected data will be written to the CLIPBOARD clipboard, and
can be pasted using the Ctrl+v key combination. When it is "primary", selected
data will be written to the PRIMARY clipboard, and can be pasted using the
middle mouse button, or the Shift-Insert key combination.
* Value type: String
* Default value: primary
*selection-notification*
Defines if a notification should be displayed after selecting text.
* Value type: Boolean
* Default value: true
*show-directories*
Defines if the directories should be displayed in completion.
* Value type: Boolean
* Default value: true
*show-hidden*
Defines if hidden files and directories should be displayed in completion.
* Value type: Boolean
* Default value: false
*show-recent*
Defines the number of recent files that should be displayed in completion.
If the value is negative, no upper bounds are applied. If the value is 0, no
recent files are shown.
* Value type: Integer
* Default value: 10
*smooth-reload*
Defines if flickering will be removed when a file is reloaded on change. This
option might increase memory usage.
* Value type: Boolean
* Default value: true
*statusbar-basename*
Use basename of the file in the statusbar.
* Value type: Boolean
* Default value: false
*statusbar-home-tilde*
Display a short version of the file path, which replaces $HOME with ~, in the statusbar.
* Value type: Boolean
* Default value: false
*statusbar-page-percent*
Display (current page / total pages) as a percent in the statusbar.
* Value type: Boolean
* Default value: false
*synctex*
En/Disables SyncTeX backward synchronization support.
* Value type: Boolean
* Default value: true
*synctex-edit-modifier*
Defines the modifier that needs to be pressed together with the left mouse button
to trigger the SyncTeX backward synchronization. Possible values are "shift",
"ctrl" and "alt".
* Value type: String
* Default value: ctrl
*synctex-editor-command*
Defines the command executed for SyncTeX backward synchronization.
* Value type: String
* Default value:
*vertical-center*
Center the screen at the vertical midpoint of the page by default.
* Value type: Boolean
* Default value: false
*window-icon-document* *window-icon-document*
Defines whether the window document should be updated based on the first page of Defines whether the window document should be updated based on the first page of
a dcument. a dcument.
@ -996,12 +974,48 @@ zathura
* Value type: Boolean * Value type: Boolean
* Default value: false * Default value: false
*page-right-to-left* *window-title-basename*
Defines whether pages in multi-column view should start from the right side. Use basename of the file in the window title.
* Value type: Boolean * Value type: Boolean
* Default value: false * Default value: false
*window-title-home-tilde*
Display a short version of the file path, which replaces $HOME with ~, in the window title.
* Value type: Boolean
* Default value: false
*window-title-page*
Display the page number in the window title.
* Value type: Boolean
* Default value: false
*zoom-center*
En/Disables horizontally centered zooming.
* Value type: Boolean
* Default value: false
*zoom-max*
Defines the maximum percentage that the zoom level can be.
* Value type: Integer
* Default value: 1000
*zoom-min*
Defines the minimum percentage that the zoom level can be.
* Value type: Integer
* Default value: 10
*zoom-step*
Defines the amount of percent that is zoomed in or out on each command.
* Value type: Integer
* Default value: 10
SEE ALSO SEE ALSO
======== ========

View file

@ -756,41 +756,41 @@ cb_page_widget_link(ZathuraPage* page, void* data)
void void
cb_page_widget_scaled_button_release(ZathuraPage* page_widget, GdkEventButton* event, cb_page_widget_scaled_button_release(ZathuraPage* page_widget, GdkEventButton* event,
void* data) void* data)
{ {
zathura_t* zathura = data; zathura_t* zathura = data;
zathura_page_t* page = zathura_page_widget_get_page(page_widget); zathura_page_t* page = zathura_page_widget_get_page(page_widget);
if (event->button != GDK_BUTTON_PRIMARY) {
return;
}
/* set page number (but don't scroll there. it was clicked on, so it's visible) */ /* set page number (but don't scroll there. it was clicked on, so it's visible) */
if (event->button == GDK_BUTTON_PRIMARY) { zathura_document_set_current_page_number(zathura->document, zathura_page_get_index(page));
zathura_document_set_current_page_number(zathura->document, zathura_page_get_index(page)); refresh_view(zathura);
refresh_view(zathura);
}
if (event->button != GDK_BUTTON_PRIMARY || !(event->state & GDK_CONTROL_MASK)) { if (event->state & zathura->global.synctex_edit_modmask) {
return; bool synctex = false;
} girara_setting_get(zathura->ui.session, "synctex", &synctex);
if (synctex == false) {
return;
}
bool synctex = false; if (zathura->dbus != NULL) {
girara_setting_get(zathura->ui.session, "synctex", &synctex); zathura_dbus_edit(zathura->dbus, zathura_page_get_index(page), event->x, event->y);
if (synctex == false) { }
return;
}
if (zathura->dbus != NULL) { char* editor = NULL;
zathura_dbus_edit(zathura->dbus, zathura_page_get_index(page), event->x, event->y); girara_setting_get(zathura->ui.session, "synctex-editor-command", &editor);
} if (editor == NULL || *editor == '\0') {
girara_debug("No SyncTeX editor specified.");
g_free(editor);
return;
}
char* editor = NULL; synctex_edit(editor, page, event->x, event->y);
girara_setting_get(zathura->ui.session, "synctex-editor-command", &editor);
if (editor == NULL || *editor == '\0') {
girara_debug("No SyncTeX editor specified.");
g_free(editor); g_free(editor);
return;
} }
synctex_edit(editor, page, event->x, event->y);
g_free(editor);
} }
void void

View file

@ -22,13 +22,12 @@
#define ZATHURA_RC "zathurarc" #define ZATHURA_RC "zathurarc"
static void static void
cb_jumplist_change(girara_session_t* session, const char* name, cb_jumplist_change(girara_session_t* session, const char* UNUSED(name),
girara_setting_type_t UNUSED(type), const void* value, void* UNUSED(data)) girara_setting_type_t UNUSED(type), const void* value, void* UNUSED(data))
{ {
g_return_if_fail(value != NULL); g_return_if_fail(value != NULL);
g_return_if_fail(session != NULL); g_return_if_fail(session != NULL);
g_return_if_fail(session->global.data != NULL); g_return_if_fail(session->global.data != NULL);
g_return_if_fail(name != NULL);
zathura_t* zathura = session->global.data; zathura_t* zathura = session->global.data;
const int* ivalue = value; const int* ivalue = value;
@ -104,6 +103,38 @@ cb_doubleclick_changed(girara_session_t* session, const char* UNUSED(name),
zathura->global.double_click_follow = *(const bool*) value; zathura->global.double_click_follow = *(const bool*) value;
} }
static void
cb_global_modifiers_changed(girara_session_t* session, const char* name,
girara_setting_type_t UNUSED(type), const void* value,
void* UNUSED(data))
{
g_return_if_fail(value != NULL);
g_return_if_fail(session != NULL);
g_return_if_fail(session->global.data != NULL);
zathura_t* zathura = session->global.data;
GdkModifierType* p;
if (g_strcmp0(name, "synctex-edit-modifier") == 0) {
p = &(zathura->global.synctex_edit_modmask);
} else if (g_strcmp0(name, "highlighter-modifier") == 0) {
p = &(zathura->global.highlighter_modmask);
} else {
girara_error("unreachable");
return;
}
const char* modifier = value;
if (g_strcmp0(modifier, "shift") == 0) {
*p = GDK_SHIFT_MASK;
} else if (g_strcmp0(modifier, "ctrl") == 0) {
*p = GDK_CONTROL_MASK;
} else if (g_strcmp0(modifier, "alt") == 0) {
*p = GDK_MOD1_MASK;
} else {
girara_error("Invalid %s option: '%s'", name, modifier);
}
}
static void static void
cb_incsearch_changed(girara_session_t* session, const char* UNUSED(name), cb_incsearch_changed(girara_session_t* session, const char* UNUSED(name),
girara_setting_type_t UNUSED(type), const void* value, void* UNUSED(data)) girara_setting_type_t UNUSED(type), const void* value, void* UNUSED(data))
@ -118,7 +149,7 @@ cb_incsearch_changed(girara_session_t* session, const char* UNUSED(name),
} }
static void static void
cb_sandbox_changed(girara_session_t* session, const char* UNUSED(name), cb_sandbox_changed(girara_session_t* session, const char* name,
girara_setting_type_t UNUSED(type), const void* value, void* UNUSED(data)) girara_setting_type_t UNUSED(type), const void* value, void* UNUSED(data))
{ {
g_return_if_fail(value != NULL); g_return_if_fail(value != NULL);
@ -134,7 +165,7 @@ cb_sandbox_changed(girara_session_t* session, const char* UNUSED(name),
} else if (g_strcmp0(sandbox, "strict") == 0) { } else if (g_strcmp0(sandbox, "strict") == 0) {
zathura->global.sandbox = ZATHURA_SANDBOX_STRICT; zathura->global.sandbox = ZATHURA_SANDBOX_STRICT;
} else { } else {
girara_error("Invalid sandbox option"); girara_error("Invalid %s option: '%s'", name, sandbox);
} }
} }
@ -304,6 +335,8 @@ config_load_default(zathura_t* zathura)
bool_value = true; bool_value = true;
girara_setting_add(gsession, "synctex", &bool_value, BOOLEAN, false, _("Enable synctex support"), NULL, NULL); girara_setting_add(gsession, "synctex", &bool_value, BOOLEAN, false, _("Enable synctex support"), NULL, NULL);
girara_setting_add(gsession, "synctex-editor-command", "", STRING, false, _("Synctex editor command"), NULL, NULL); girara_setting_add(gsession, "synctex-editor-command", "", STRING, false, _("Synctex editor command"), NULL, NULL);
girara_setting_add(gsession, "synctex-edit-modifier", "ctrl", STRING, false, _("Synctex edit modifier"), cb_global_modifiers_changed, NULL);
girara_setting_add(gsession, "highlighter-modifier", "shift", STRING, false, _("Highlighter modifier"), cb_global_modifiers_changed, NULL);
bool_value = true; bool_value = true;
girara_setting_add(gsession, "dbus-service", &bool_value, BOOLEAN, false, _("Enable D-Bus service"), NULL, NULL); girara_setting_add(gsession, "dbus-service", &bool_value, BOOLEAN, false, _("Enable D-Bus service"), NULL, NULL);
girara_setting_add(gsession, "dbus-raise-window", &bool_value, BOOLEAN, false, _("Raise window on certain D-Bus commands"), NULL, NULL); girara_setting_add(gsession, "dbus-raise-window", &bool_value, BOOLEAN, false, _("Raise window on certain D-Bus commands"), NULL, NULL);

View file

@ -1130,7 +1130,7 @@ cb_zathura_page_widget_motion_notify(GtkWidget* widget, GdkEventMotion* event)
const double scale = zathura_document_get_scale(document); const double scale = zathura_document_get_scale(document);
if (event->state & GDK_BUTTON1_MASK) { /* holding left mouse button */ if (event->state & GDK_BUTTON1_MASK) { /* holding left mouse button */
if (event->state & GDK_CONTROL_MASK) { if (event->state & priv->zathura->global.highlighter_modmask) {
double x, y; double x, y;
rotate_point(document, event->x, event->y, &x, &y); rotate_point(document, event->x, event->y, &x, &y);
priv->highlighter.bounds = next_selection_rectangle(priv->mouse.selection.x1, priv->highlighter.bounds = next_selection_rectangle(priv->mouse.selection.x1,

View file

@ -95,6 +95,8 @@ zathura_create(void)
/* global settings */ /* global settings */
zathura->global.search_direction = FORWARD; zathura->global.search_direction = FORWARD;
zathura->global.synctex_edit_modmask = GDK_CONTROL_MASK;
zathura->global.highlighter_modmask = GDK_SHIFT_MASK;
zathura->global.sandbox = ZATHURA_SANDBOX_NORMAL; zathura->global.sandbox = ZATHURA_SANDBOX_NORMAL;
zathura->global.double_click_follow = true; zathura->global.double_click_follow = true;

View file

@ -144,9 +144,11 @@ struct zathura_s
struct struct
{ {
int search_direction; /**< Current search direction (FORWARD or BACKWARD) */
girara_list_t* marks; /**< Marker */ girara_list_t* marks; /**< Marker */
char** arguments; /**> Arguments that were passed at startup */ char** arguments; /**> Arguments that were passed at startup */
int search_direction; /**< Current search direction (FORWARD or BACKWARD) */
GdkModifierType synctex_edit_modmask; /**< Modifier to trigger synctex edit */
GdkModifierType highlighter_modmask; /**< Modifier to draw with a highlighter */
zathura_sandbox_t sandbox; /**< Sandbox mode */ zathura_sandbox_t sandbox; /**< Sandbox mode */
bool double_click_follow; /**< Double/Single click to follow link */ bool double_click_follow; /**< Double/Single click to follow link */
} global; } global;