From 4e06bff706d834303b0061bb5a55f47a1e744a3c Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Wed, 23 Feb 2022 22:42:56 +0100 Subject: [PATCH] Change modi -> modes issues: #1599 --- CONFIG.md | 6 +- README.md | 18 +- config/config.c | 14 +- doc/default_configuration.rasi | 2 +- doc/rofi-keys.5 | 4 +- doc/rofi-keys.5.markdown | 4 +- doc/rofi-script.5 | 4 +- doc/rofi-script.5.markdown | 4 +- doc/rofi.1 | 46 +-- doc/rofi.1.markdown | 46 +-- doc/test_xr.txt | 276 ----------------- include/dialogs/combi.h | 2 +- include/dialogs/script.h | 4 +- include/rofi.h | 8 +- include/settings.h | 8 +- include/view-internal.h | 10 +- include/widgets/widget.h | 2 +- source/dialogs/combi.c | 11 +- source/dialogs/filebrowser.c | 2 +- source/dialogs/ssh.c | 2 +- source/keyb.c | 530 ++++++++++++++++++++++++--------- source/rofi-icon-fetcher.c | 28 ++ source/rofi.c | 222 +++++++------- source/view.c | 29 +- source/xrmoptions.c | 20 +- 25 files changed, 651 insertions(+), 651 deletions(-) delete mode 100644 doc/test_xr.txt diff --git a/CONFIG.md b/CONFIG.md index ba4876b5..8732b12c 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -48,7 +48,7 @@ If a value is the default value, the entry will be commented. For example: ```css configuration { -/* modi: "window,run,ssh,drun";*/ +/* modes: "window,run,ssh,drun";*/ /* font: "mono 12";*/ /* location: 0;*/ /* yoffset: 0;*/ @@ -163,12 +163,12 @@ A list starts with a '[' and ends with a ']'. The entries in the list are comma- The entry in the list single ASCII words. ```css - combi-modi: [window,drun]; + combi-modes: [window,drun]; ``` For older versions you have : ```css - combi-modi: "window,drun"; + combi-modes: "window,drun"; ``` # Get a list of all possible options diff --git a/README.md b/README.md index f3be67af..d8dde3d2 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Rofi is not: # Table of Contents - [Features](#features) -- [Modi](#modi) +- [Modes](#modes) - [Manpages](#manpage) - [Installation](#installation) - [Quickstart](#quickstart) @@ -78,12 +78,12 @@ Its main features are: * Easily extensible using scripts and plugins * Advanced Theming -# Modi +# Modes -**Rofi** has several built-in modi implementing common use cases and can be extended by scripts (either called from +**Rofi** has several built-in modes implementing common use cases and can be extended by scripts (either called from **Rofi** or calling **Rofi**) or plugins. -Below is a list of the different modi: +Below is a list of the different modes: * **run**: launch applications from $PATH, with option to launch in terminal. * **drun**: launch applications based on desktop files. It tries to be compliant to the XDG standard. @@ -92,7 +92,7 @@ Below is a list of the different modi: * **file-browser**: A basic file-browser for opening files. * **keys**: list internal keybindings. * **script**: Write (limited) custom mode using simple scripts. -* **combi**: Combine multiple modi into one. +* **combi**: Combine multiple modes into one. **Rofi** is known to work on Linux and BSD. @@ -135,14 +135,14 @@ Enabled modes can be changed at runtime. Default key is `Ctrl+Tab`. If no modes are specified, all configured modes will be enabled. To only show the `run` and `ssh` launcher: - rofi -modi "run,ssh" -show run + rofi -modes "run,ssh" -show run -The modi to combine in combi mode. -For syntax to `-combi-modi`, see `-modi`. +The modes to combine in combi mode. +For syntax to `-combi-modes `, see `-modes`. To get one merge view, of `window`,`run`, and `ssh`: - rofi -show combi -combi-modi "window,run,ssh" -modi combi + rofi -show combi -combi-modes "window,run,ssh" -modes combi ## Configuration diff --git a/config/config.c b/config/config.c index c1a4946c..4d6b09bd 100644 --- a/config/config.c +++ b/config/config.c @@ -33,12 +33,12 @@ #include Settings config = { -/** List of enabled modi. */ -/** -modi */ +/** List of enabled modes. */ +/** -modes */ #ifdef WINDOW_MODE - .modi = "window,run,ssh", + .modes = "window,run,ssh", #else - .modi = "run,ssh", + .modes = "run,ssh", #endif /** Font */ .menu_font = "mono 12", @@ -93,7 +93,7 @@ Settings config = { .cycle = TRUE, /** Height of an element in #chars */ .element_height = 1, - /** Sidebar mode, show the modi */ + /** Sidebar mode, show the modes */ .sidebar_mode = FALSE, /** auto select */ .auto_select = FALSE, @@ -101,8 +101,8 @@ Settings config = { .parse_hosts = FALSE, /** Parse ~/.ssh/known_hosts file in ssh view. */ .parse_known_hosts = TRUE, - /** Modi to combine into one view. */ - .combi_modi = "window,run", + /** Modes to combine into one view. */ + .combi_modes = "window,run", .tokenize = TRUE, .matching = "normal", .matching_method = MM_NORMAL, diff --git a/doc/default_configuration.rasi b/doc/default_configuration.rasi index bc07d5a9..dc132110 100644 --- a/doc/default_configuration.rasi +++ b/doc/default_configuration.rasi @@ -8,7 +8,7 @@ configuration { action: "kb-cancel"; } - // File browser modi. + // File browser mode. filebrowser { sorting-method: "name"; directories-first: true; diff --git a/doc/rofi-keys.5 b/doc/rofi-keys.5 index c3052336..51e13c9f 100644 --- a/doc/rofi-keys.5 +++ b/doc/rofi-keys.5 @@ -196,14 +196,14 @@ Accept entry .SS \fBkb\-accept\-custom\fP .PP -Use entered text as command (in ssh/run modi) +Use entered text as command (in ssh/run modes) .PP \fBDefault\fP: Control+Return .SS \fBkb\-accept\-custom\-alt\fP .PP -Use entered text as command (in ssh/run modi) +Use entered text as command (in ssh/run modes) .PP \fBDefault\fP: Control+Shift+Return diff --git a/doc/rofi-keys.5.markdown b/doc/rofi-keys.5.markdown index 6ea5c83b..02b1f917 100644 --- a/doc/rofi-keys.5.markdown +++ b/doc/rofi-keys.5.markdown @@ -136,12 +136,12 @@ Accept entry **Default**: Control+j,Control+m,Return,KP_Enter ### **kb-accept-custom** -Use entered text as command (in ssh/run modi) +Use entered text as command (in ssh/run modes) **Default**: Control+Return ### **kb-accept-custom-alt** -Use entered text as command (in ssh/run modi) +Use entered text as command (in ssh/run modes) **Default**: Control+Shift+Return diff --git a/doc/rofi-script.5 b/doc/rofi-script.5 index f414c1a2..42f0ab53 100644 --- a/doc/rofi-script.5 +++ b/doc/rofi-script.5 @@ -2,7 +2,7 @@ .TH ROFI\-SCRIPT 5 rofi\-script .SH NAME .PP -\fBrofi script mode\fP \- Rofi format for scriptable modi. +\fBrofi script mode\fP \- Rofi format for scriptable mode. .SH DESCRIPTION .PP @@ -20,7 +20,7 @@ For example: .RS .nf -rofi \-show fb \-modi "fb:file\_browser.sh" +rofi \-show fb \-modes "fb:file\_browser.sh" .fi .RE diff --git a/doc/rofi-script.5.markdown b/doc/rofi-script.5.markdown index 3e6bd778..5b24d8b9 100644 --- a/doc/rofi-script.5.markdown +++ b/doc/rofi-script.5.markdown @@ -2,7 +2,7 @@ ## NAME -**rofi script mode** - Rofi format for scriptable modi. +**rofi script mode** - Rofi format for scriptable mode. ## DESCRIPTION @@ -18,7 +18,7 @@ To specify a script mode, set a mode with the following syntax: "{name}:{executa For example: ``` -rofi -show fb -modi "fb:file_browser.sh" +rofi -show fb -modes "fb:file_browser.sh" ``` The name should be unique. diff --git a/doc/rofi.1 b/doc/rofi.1 index 8e125c7f..4db14fb9 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -18,7 +18,7 @@ filter, tokenized search and more. .PP \fBrofi\fP\&'s main functionality is to assist in your workflow, allowing you to quickly switch between windows, start applications or log into a remote machine via \fB\fCssh\fR\&. -There are different \fImodi\fP for different types of actions. +There are different \fImodes\fP for different types of actions. \fBrofi\fP is a standalone application and should not be integrated into scripts. For integration into scripts it has a special mode that functions as a (drop\-in) replacement for \fBdmenu(1)\fP\&. See emulating dmenu below. @@ -238,10 +238,10 @@ rofi \-show run .RE .PP -If \fB\fC\-show\fR is the last option passed to rofi, the first enabled modi is shown. +If \fB\fC\-show\fR is the last option passed to rofi, the first enabled modes is shown. .PP -\fB\fC\-modi\fR \fImode1,mode2\fP +\fB\fC\-modes\fR \fImode1,mode2\fP .PP Specify an ordered, comma\-separated list of modes to enable. @@ -253,7 +253,7 @@ To only show the \fB\fCrun\fR and \fB\fCssh\fR launcher: .RS .nf -rofi \-modi "run,ssh" \-show run +rofi \-modes "run,ssh" \-show run .fi .RE @@ -277,7 +277,7 @@ Example: Have a mode called 'Workspaces' using the \fB\fCi3\_switch\_workspaces. .RS .nf -rofi \-modi "window,run,ssh,Workspaces:i3\_switch\_workspaces.sh" \-show Workspaces +rofi \-modes "window,run,ssh,Workspaces:i3\_switch\_workspaces.sh" \-show Workspaces .fi .RE @@ -293,7 +293,7 @@ For that case, \fB\fC#\fR can be used as a separator. .RS .nf -rofi \-modi "My File Browser:fb.sh" \-show "My File Browser" +rofi \-modes "My File Browser:fb.sh" \-show "My File Browser" .fi .RE @@ -595,7 +595,7 @@ Keep a fixed number of visible lines. .PP Open in sidebar\-mode. In this mode, a list of all enabled modes is shown at the bottom. -(See \fB\fC\-modi\fR option) +(See \fB\fC\-modes\fR option) To show sidebar, use: .PP @@ -888,18 +888,18 @@ configuration { .SS Combi settings .PP -\fB\fC\-combi\-modi\fR \fImode1\fP,\fImode2\fP +\fB\fC\-combi\-modes\fR \fImode1\fP,\fImode2\fP .PP -The modi to combine in combi mode. -For syntax to \fB\fC\-combi\-modi\fR, see \fB\fC\-modi\fR\&. +The modes to combine in combi mode. +For syntax to \fB\fC\-combi\-modes\fR, see \fB\fC\-modes\fR\&. To get one merge view, of \fB\fCwindow\fR,\fB\fCrun\fR, and \fB\fCssh\fR: .PP .RS .nf -rofi \-show combi \-combi\-modi "window,run,ssh" \-modi combi +rofi \-show combi \-combi\-modes "window,run,ssh" \-modes combi .fi .RE @@ -1139,7 +1139,7 @@ configuration { .fi .RE -.SH Available Modi +.SH Available Modes .SS window .PP Show a list of all the windows and allow switching between them. @@ -1220,21 +1220,21 @@ Shows a searchable list of key bindings. .SS script .PP -Allows custom scripted Modi to be added, see the \fBrofi\-script(5)\fP manpage for more information. +Allows custom scripted Modes to be added, see the \fBrofi\-script(5)\fP manpage for more information. .SS combi .PP -Combines multiple modi in one list. Specify which modi are included with the \fB\fC\-combi\-modi\fR option. +Combines multiple modes in one list. Specify which modes are included with the \fB\fC\-combi\-modes\fR option. .PP -When using the combi mode, a \fI!bang\fP can be used to filter the results by modi. -All modi that match the bang as a prefix are included. -For example, say you have specified \fB\fC\-combi\-modi run,window,windowcd\fR\&. If your +When using the combi mode, a \fI!bang\fP can be used to filter the results by modes. +All modes that match the bang as a prefix are included. +For example, say you have specified \fB\fC\-combi\-modes run,window,windowcd\fR\&. If your query begins with the bang \fB\fC!w\fR, only results from the \fB\fCwindow\fR and \fB\fCwindowcd\fR -modi are shown, even if the rest of the input text would match results from \fB\fCrun\fR\&. +modes are shown, even if the rest of the input text would match results from \fB\fCrun\fR\&. .PP -If no match, the input is handled by the first combined modi. +If no match, the input is handled by the first combined modes. .SH FAQ .SS The text in the window switcher is not nicely aligned. @@ -1287,7 +1287,7 @@ Show the run dialog: .RS .nf -rofi \-modi run \-show run +rofi \-modes run \-show run .fi .RE @@ -1299,7 +1299,7 @@ Show the run dialog, and allow switching to Desktop File run dialog (\fB\fCdrun\ .RS .nf -rofi \-modi run,drun \-show run +rofi \-modes run,drun \-show run .fi .RE @@ -1311,7 +1311,7 @@ Combine the run and Desktop File run dialog (\fB\fCdrun\fR): .RS .nf -rofi \-modi combi \-show combi \-combi\-modi run,drun +rofi \-modes combi \-show combi \-combi\-modes run,drun .fi .RE @@ -1323,7 +1323,7 @@ Combine the run and Desktop File run dialog (\fB\fCdrun\fR), and allow switching .RS .nf -rofi \-modi combi,window \-show combi \-combi\-modi run,drun +rofi \-modes combi,window \-show combi \-combi\-modes run,drun .fi .RE diff --git a/doc/rofi.1.markdown b/doc/rofi.1.markdown index 477f8ed7..08ebfbf0 100644 --- a/doc/rofi.1.markdown +++ b/doc/rofi.1.markdown @@ -20,7 +20,7 @@ filter, tokenized search and more. **rofi**'s main functionality is to assist in your workflow, allowing you to quickly switch between windows, start applications or log into a remote machine via `ssh`. -There are different *modi* for different types of actions. +There are different *modes* for different types of actions. **rofi** is a standalone application and should not be integrated into scripts. For integration into scripts it has a special mode that functions as a (drop-in) replacement for **dmenu(1)**. See emulating dmenu below. @@ -143,16 +143,16 @@ To show the run-dialog: rofi -show run -If `-show` is the last option passed to rofi, the first enabled modi is shown. +If `-show` is the last option passed to rofi, the first enabled modes is shown. -`-modi` *mode1,mode2* +`-modes` *mode1,mode2* Specify an ordered, comma-separated list of modes to enable. Enabled modes can be changed at runtime. Default key is `Ctrl+Tab`. If no modes are specified, all configured modes will be enabled. To only show the `run` and `ssh` launcher: - rofi -modi "run,ssh" -show run + rofi -modes "run,ssh" -show run Custom modes can be added using the internal `script` mode. Each such mode has two parameters: @@ -160,14 +160,14 @@ Custom modes can be added using the internal `script` mode. Each such mode has t Example: Have a mode called 'Workspaces' using the `i3_switch_workspaces.sh` script: - rofi -modi "window,run,ssh,Workspaces:i3_switch_workspaces.sh" -show Workspaces + rofi -modes "window,run,ssh,Workspaces:i3_switch_workspaces.sh" -show Workspaces Notes: The i3 window manager dislikes commas in the command when specifying an exec command. For that case, `#` can be used as a separator. **TIP**: The name is allowed to contain spaces: - rofi -modi "My File Browser:fb.sh" -show "My File Browser" + rofi -modes "My File Browser:fb.sh" -show "My File Browser" `-case-sensitive` @@ -349,7 +349,7 @@ Keep a fixed number of visible lines. `-sidebar-mode` Open in sidebar-mode. In this mode, a list of all enabled modes is shown at the bottom. -(See `-modi` option) +(See `-modes` option) To show sidebar, use: rofi -show run -sidebar-mode @@ -535,13 +535,13 @@ configuration { ### Combi settings -`-combi-modi` *mode1*,*mode2* +`-combi-modes ` *mode1*,*mode2* -The modi to combine in combi mode. -For syntax to `-combi-modi`, see `-modi`. +The modes to combine in combi mode. +For syntax to `-combi-modes`, see `-modes`. To get one merge view, of `window`,`run`, and `ssh`: - rofi -show combi -combi-modi "window,run,ssh" -modi combi + rofi -show combi -combi-modes "window,run,ssh" -modes combi **NOTE**: The i3 window manager dislikes commas in the command when specifying an exec command. For that case, `#` can be used as a separator. @@ -708,7 +708,7 @@ configuration { } ``` -## Available Modi +## Available Modes ### window @@ -781,19 +781,19 @@ Shows a searchable list of key bindings. ### script -Allows custom scripted Modi to be added, see the **rofi-script(5)** manpage for more information. +Allows custom scripted Modes to be added, see the **rofi-script(5)** manpage for more information. ### combi -Combines multiple modi in one list. Specify which modi are included with the `-combi-modi` option. +Combines multiple modes in one list. Specify which modes are included with the `-combi-modes` option. -When using the combi mode, a *!bang* can be used to filter the results by modi. -All modi that match the bang as a prefix are included. -For example, say you have specified `-combi-modi run,window,windowcd`. If your +When using the combi mode, a *!bang* can be used to filter the results by modes. +All modes that match the bang as a prefix are included. +For example, say you have specified `-combi-modes run,window,windowcd`. If your query begins with the bang `!w`, only results from the `window` and `windowcd` -modi are shown, even if the rest of the input text would match results from `run`. +modes are shown, even if the rest of the input text would match results from `run`. -If no match, the input is handled by the first combined modi. +If no match, the input is handled by the first combined modes. ## FAQ @@ -829,19 +829,19 @@ Some basic usage examples of **rofi**: Show the run dialog: - rofi -modi run -show run + rofi -modes run -show run Show the run dialog, and allow switching to Desktop File run dialog (`drun`): - rofi -modi run,drun -show run + rofi -modes run,drun -show run Combine the run and Desktop File run dialog (`drun`): - rofi -modi combi -show combi -combi-modi run,drun + rofi -modes combi -show combi -combi-modes run,drun Combine the run and Desktop File run dialog (`drun`), and allow switching to window switcher: - rofi -modi combi,window -show combi -combi-modi run,drun + rofi -modes combi,window -show combi -combi-modes run,drun Pop up a text message claiming that this is the end: diff --git a/doc/test_xr.txt b/doc/test_xr.txt deleted file mode 100644 index 7884be84..00000000 --- a/doc/test_xr.txt +++ /dev/null @@ -1,276 +0,0 @@ -! "Enabled modi" Set from: File -rofi.modi: combi,drun -! "Window width" Set from: File -rofi.width: 50 -! "Number of lines" Set from: File -rofi.lines: 8 -! "Number of columns" Set from: File -rofi.columns: 1 -! "Font to use" Set from: File -rofi.font: Source Code Pro Medium 10 -! "Border width" Set from: Default -! rofi.bw: 1 -! "Location on screen" Set from: File -rofi.location: 2 -! "Padding" Set from: Default -! rofi.padding: 5 -! "Y-offset relative to location" Set from: File -rofi.yoffset: -2 -! "X-offset relative to location" Set from: File -rofi.xoffset: 0 -! "Always show number of lines" Set from: File -rofi.fixed-num-lines: true -! "Whether to load and show icons" Set from: Default -! rofi.show-icons: false -! "Terminal to use" Set from: File -rofi.terminal: sakura -! "Ssh client to use" Set from: File -rofi.ssh-client: ssh -! "Ssh command to execute" Set from: File -rofi.ssh-command: {terminal} -e {ssh-client} {host} -! "Run command to execute" Set from: File -rofi.run-command: bash -c "{cmd}" -! "Command to get extra run targets" Set from: Default -! rofi.run-list-command: -! "Run command to execute that runs in shell" Set from: File -rofi.run-shell-command: {terminal} -e {cmd} -! "Command executed on accep-entry-custom for window modus" Set from: File -rofi.window-command: xkill -id {window} -! "Window fields to match in window mode" Set from: Default -! rofi.window-match-fields: all -! "Theme to use to look for icons" Set from: Default -! rofi.icon-theme: -! "Desktop entry fields to match in drun" Set from: Default -! rofi.drun-match-fields: name,generic,exec,categories,keywords -! "Only show Desktop entry from these categories" Set from: Default -! rofi.drun-categories: -! "Desktop entry show actions." Set from: Default -! rofi.drun-show-actions: false -! "DRUN format string. (Supports: generic,name,comment,exec,categories)" Set from: Default -! rofi.drun-display-format: {name} [({generic})] -! "Disable history in run/ssh" Set from: File -rofi.disable-history: false -! "Programs ignored for history" Set from: Default -! rofi.ignored-prefixes: -! "Use sorting" Set from: Default -! rofi.sort: false -! "Choose the strategy used for sorting: normal (levenshtein) or fzf." Set from: Default -! rofi.sorting-method: -! "Set case-sensitivity" Set from: File -rofi.case-sensitive: false -! "Cycle through the results list" Set from: File -rofi.cycle: true -! "Enable sidebar-mode" Set from: File -rofi.sidebar-mode: false -! "Row height (in chars)" Set from: File -rofi.eh: 1 -! "Enable auto select mode" Set from: File -rofi.auto-select: false -! "Parse hosts file for ssh mode" Set from: File -rofi.parse-hosts: false -! "Parse known_hosts file for ssh mode" Set from: File -rofi.parse-known-hosts: true -! "Set the modi to combine in combi mode" Set from: File -rofi.combi-modi: window,drun,run,ssh -! "Set the matching algorithm. (normal, regex, glob, fuzzy, prefix)" Set from: Default -! rofi.matching: normal -! "Tokenize input string" Set from: File -rofi.tokenize: true -! "Monitor id to show on" Set from: File -rofi.m: -1 -! "Margin between rows *DEPRECATED*" Set from: Default -! rofi.line-margin: 2 -! "Padding within rows *DEPRECATED*" Set from: Default -! rofi.line-padding: 1 -! "Pre-set filter" Set from: Default -! rofi.filter: -! "Separator style (none, dash, solid) *DEPRECATED*" Set from: Default -! rofi.separator-style: dash -! "Hide scroll-bar *DEPRECATED*" Set from: Default -! rofi.hide-scrollbar: false -! "Fullscreen" Set from: File -rofi.fullscreen: false -! "Fake transparency *DEPRECATED*" Set from: Default -! rofi.fake-transparency: false -! "DPI" Set from: File -rofi.dpi: 101 -! "Threads to use for string matching" Set from: File -rofi.threads: 8 -! "Scrollbar width *DEPRECATED*" Set from: Default -! rofi.scrollbar-width: 8 -! "Scrolling method. (0: Page, 1: Centered)" Set from: File -rofi.scroll-method: 0 -! "Background to use for fake transparency. (background or screenshot) *DEPRECATED*" Set from: Default -! rofi.fake-background: screenshot -! "Window Format. w (desktop name), t (title), n (name), r (role), c (class)" Set from: Default -! rofi.window-format: {w} {c} {t} -! "Click outside the window to exit" Set from: Default -! rofi.click-to-exit: true -! "New style theme file" Set from: Default -! rofi.theme: -! "Color scheme for normal row" Set from: Default -! rofi.color-normal: -! "Color scheme for urgent row" Set from: Default -! rofi.color-urgent: -! "Color scheme for active row" Set from: Default -! rofi.color-active: -! "Color scheme window" Set from: Default -! rofi.color-window: -! "Max history size (WARNING: can cause slowdowns when set too high)." Set from: Default -! rofi.max-history-size: 25 -! "Hide the prefix mode prefix on the combi view." Set from: Default -! rofi.combi-hide-mode-prefix: false -! "Combi format string. (Supports: mode, text)" Set from: Default -! rofi.combi-display-format: {mode} {text} -! "Set the character used to negate the matching. ('\0' to disable)" Set from: Default -! rofi.matching-negate-char: - -! "Directory where history and temporary files are stored." Set from: Default -! rofi.cache-dir: -! "Show window thumbnail in window switcher if availalbe." Set from: Default -! rofi.window-thumbnail: false -! "Pidfile location" Set from: File -rofi.pid: /tmp/rofi.pid -! "Paste primary selection" Set from: File -rofi.kb-primary-paste: Control+Shift+v,Shift+Insert -! "Paste clipboard" Set from: File -rofi.kb-secondary-paste: Control+v,Insert -! "Clear input line" Set from: File -rofi.kb-clear-line: Control+w -! "Beginning of line" Set from: File -rofi.kb-move-front: Control+a -! "End of line" Set from: File -rofi.kb-move-end: Control+e -! "Move back one word" Set from: File -rofi.kb-move-word-back: Alt+b,Ctrl+Left -! "Move forward one word" Set from: File -rofi.kb-move-word-forward: Alt+f,Ctrl+Right -! "Move back one char" Set from: File -rofi.kb-move-char-back: Left,Control+b -! "Move forward one char" Set from: File -rofi.kb-move-char-forward: Right,Control+f -! "Delete previous word" Set from: File -rofi.kb-remove-word-back: Control+Alt+h,Control+BackSpace -! "Delete next word" Set from: File -rofi.kb-remove-word-forward: Control+Alt+d -! "Delete next char" Set from: File -rofi.kb-remove-char-forward: Delete,Control+d -! "Delete previous char" Set from: File -rofi.kb-remove-char-back: BackSpace,Shift+BackSpace,Control+h -! "Delete till the end of line" Set from: File -rofi.kb-remove-to-eol: Control+k -! "Delete till the start of line" Set from: File -rofi.kb-remove-to-sol: Control+u -! "Accept entry" Set from: File -rofi.kb-accept-entry: Control+j,Control+m,Return,KP_Enter -! "Use entered text as command (in ssh/run modi)" Set from: File -rofi.kb-accept-custom: Control+Return -! "Use alternate accept command." Set from: File -rofi.kb-accept-alt: Shift+Return -! "Delete entry from history" Set from: File -rofi.kb-delete-entry: Shift+Delete -! "Switch to the next mode." Set from: File -rofi.kb-mode-next: Shift+Right,Control+Tab -! "Switch to the previous mode." Set from: File -rofi.kb-mode-previous: Shift+Left,Control+ISO_Left_Tab -! "Go to the previous column" Set from: File -rofi.kb-row-left: Control+Page_Up -! "Go to the next column" Set from: File -rofi.kb-row-right: Control+Page_Down -! "Select previous entry" Set from: File -rofi.kb-row-up: Up,Control+p,ISO_Left_Tab -! "Select next entry" Set from: File -rofi.kb-row-down: Down,Control+n -! "Go to next row, if one left, accept it, if no left next mode." Set from: File -rofi.kb-row-tab: Tab -! "Go to the previous page" Set from: File -rofi.kb-page-prev: Page_Up -! "Go to the next page" Set from: File -rofi.kb-page-next: Page_Down -! "Go to the first entry" Set from: File -rofi.kb-row-first: Home,KP_Home -! "Go to the last entry" Set from: File -rofi.kb-row-last: End,KP_End -! "Set selected item as input text" Set from: File -rofi.kb-row-select: Control+space -! "Take a screenshot of the rofi window" Set from: File -rofi.kb-screenshot: Alt+S -! "Toggle between ellipsize modes for displayed data" Set from: Default -! rofi.kb-ellipsize: Alt+period -! "Toggle case sensitivity" Set from: File -rofi.kb-toggle-case-sensitivity: grave,dead_grave -! "Toggle sort" Set from: File -rofi.kb-toggle-sort: Alt+grave -! "Quit rofi" Set from: File -rofi.kb-cancel: Escape,Control+bracketleft -! "Custom keybinding 1" Set from: File -rofi.kb-custom-1: Alt+1 -! "Custom keybinding 2" Set from: File -rofi.kb-custom-2: Alt+2 -! "Custom keybinding 3" Set from: File -rofi.kb-custom-3: Alt+3 -! "Custom keybinding 4" Set from: File -rofi.kb-custom-4: Alt+4 -! "Custom Keybinding 5" Set from: File -rofi.kb-custom-5: Alt+5 -! "Custom keybinding 6" Set from: File -rofi.kb-custom-6: Alt+6 -! "Custom Keybinding 7" Set from: File -rofi.kb-custom-7: Alt+7 -! "Custom keybinding 8" Set from: File -rofi.kb-custom-8: Alt+8 -! "Custom keybinding 9" Set from: File -rofi.kb-custom-9: Alt+9 -! "Custom keybinding 10" Set from: File -rofi.kb-custom-10: Alt+0 -! "Custom keybinding 11" Set from: File -rofi.kb-custom-11: Alt+Shift+1 -! "Custom keybinding 12" Set from: File -rofi.kb-custom-12: Alt+at -! "Custom keybinding 13" Set from: File -rofi.kb-custom-13: Alt+numbersign -! "Custom keybinding 14" Set from: File -rofi.kb-custom-14: Alt+dollar -! "Custom keybinding 15" Set from: File -rofi.kb-custom-15: Alt+percent -! "Custom keybinding 16" Set from: File -rofi.kb-custom-16: Alt+dead_circumflex -! "Custom keybinding 17" Set from: File -rofi.kb-custom-17: Alt+ampersand -! "Custom keybinding 18" Set from: File -rofi.kb-custom-18: Alt+asterisk -! "Custom Keybinding 19" Set from: File -rofi.kb-custom-19: Alt+parenleft -! "Select row 1" Set from: Default -! rofi.kb-select-1: Super+1 -! "Select row 2" Set from: Default -! rofi.kb-select-2: Super+2 -! "Select row 3" Set from: Default -! rofi.kb-select-3: Super+3 -! "Select row 4" Set from: Default -! rofi.kb-select-4: Super+4 -! "Select row 5" Set from: Default -! rofi.kb-select-5: Super+5 -! "Select row 6" Set from: Default -! rofi.kb-select-6: Super+6 -! "Select row 7" Set from: Default -! rofi.kb-select-7: Super+7 -! "Select row 8" Set from: Default -! rofi.kb-select-8: Super+8 -! "Select row 9" Set from: Default -! rofi.kb-select-9: Super+9 -! "Select row 10" Set from: Default -! rofi.kb-select-10: Super+0 -! "Go to the previous column" Set from: Default -! rofi.ml-row-left: ScrollLeft -! "Go to the next column" Set from: Default -! rofi.ml-row-right: ScrollRight -! "Select previous entry" Set from: Default -! rofi.ml-row-up: ScrollUp -! "Select next entry" Set from: Default -! rofi.ml-row-down: ScrollDown -! "Select hovered row" Set from: Default -! rofi.me-select-entry: MousePrimary -! "Accept hovered row" Set from: Default -! rofi.me-accept-entry: MouseDPrimary -! "Accept hovered row with custom action" Set from: Default -! rofi.me-accept-custom: Control+MouseDPrimary diff --git a/include/dialogs/combi.h b/include/dialogs/combi.h index 2fe39b3b..fbc222d6 100644 --- a/include/dialogs/combi.h +++ b/include/dialogs/combi.h @@ -36,7 +36,7 @@ * Dialog that can combine multiple #Mode into one view. * * This mode uses the following options from the #config object: - * * #Settings::combi_modi + * * #Settings::combi_modes * * It creates the following option: * * Settings::display_combi diff --git a/include/dialogs/script.h b/include/dialogs/script.h index d3ccf41b..47237734 100644 --- a/include/dialogs/script.h +++ b/include/dialogs/script.h @@ -47,9 +47,9 @@ Mode *script_mode_parse_setup(const char *str); /** - * @param token The modi str to check + * @param token The modes str to check * - * Check if token could be a valid script modi. + * Check if token could be a valid script modes. * * @returns true when valid. */ diff --git a/include/rofi.h b/include/rofi.h index 93ee1f60..7558a45b 100644 --- a/include/rofi.h +++ b/include/rofi.h @@ -48,11 +48,11 @@ extern const char *cache_dir; /** - * Get the number of enabled modi. + * Get the number of enabled modes. * - * @returns the number of enabled modi. + * @returns the number of enabled modes. */ -unsigned int rofi_get_num_enabled_modi(void); +unsigned int rofi_get_num_enabled_modes(void); /** * @param index The mode to return. (should be smaller then @@ -90,7 +90,7 @@ void rofi_quit_main_loop(void); * * @return returns Mode * when found, NULL if not. */ -Mode *rofi_collect_modi_search(const char *name); +Mode *rofi_collect_modes_search(const char *name); /** Reset terminal */ #define color_reset "\033[0m" /** Set terminal text bold */ diff --git a/include/settings.h b/include/settings.h index 5b4de835..f77e818a 100644 --- a/include/settings.h +++ b/include/settings.h @@ -53,8 +53,8 @@ typedef enum { SORT_NORMAL = 0, SORT_FZF = 1 } SortingMethod; * @ingroup CONFIGURATION */ typedef struct { - /** List of enabled modi */ - char *modi; + /** List of enabled modes */ + char *modes; /** Font string (pango format) */ char *menu_font; @@ -116,7 +116,7 @@ typedef struct { unsigned int cycle; /** Height of an element in number of rows */ int element_height; - /** Sidebar mode, show the modi */ + /** Sidebar mode, show the modes */ unsigned int sidebar_mode; /** Mouse hover automatically selects */ gboolean hover_select; @@ -129,7 +129,7 @@ typedef struct { /** Knonw_hosts file parsing */ unsigned int parse_known_hosts; /** Combi Modes */ - char *combi_modi; + char *combi_modes; char *matching; MatchingMethod matching_method; unsigned int tokenize; diff --git a/include/view-internal.h b/include/view-internal.h index f6fdbc83..44bf2bcb 100644 --- a/include/view-internal.h +++ b/include/view-internal.h @@ -95,12 +95,12 @@ struct RofiViewState { /** Monitor #workarea the view is displayed on */ workarea mon; - /** #box holding the different modi buttons */ + /** #box holding the different modes buttons */ box *sidebar_bar; - /** number of modi to display */ - unsigned int num_modi; - /** Array of #textbox that act as buttons for switching modi */ - textbox **modi; + /** number of modes to display */ + unsigned int num_modes; + /** Array of #textbox that act as buttons for switching modes */ + textbox **modes; /** Total rows. */ textbox *tb_total_rows; diff --git a/include/widgets/widget.h b/include/widgets/widget.h index 68706cfe..c2897c9b 100644 --- a/include/widgets/widget.h +++ b/include/widgets/widget.h @@ -64,7 +64,7 @@ typedef enum { WIDGET_TYPE_EDITBOX = SCOPE_MOUSE_EDITBOX, /** The listview scrollbar */ WIDGET_TYPE_SCROLLBAR = SCOPE_MOUSE_SCROLLBAR, - /** A widget allowing user to swithc between modi */ + /** A widget allowing user to swithc between modes */ WIDGET_TYPE_MODE_SWITCHER = SCOPE_MOUSE_MODE_SWITCHER, /** Text-only textbox */ WIDGET_TYPE_TEXTBOX_TEXT, diff --git a/source/dialogs/combi.c b/source/dialogs/combi.c index 365a9a37..27fc4a3a 100644 --- a/source/dialogs/combi.c +++ b/source/dialogs/combi.c @@ -63,21 +63,21 @@ static void combi_mode_parse_switchers(Mode *sw) { CombiModePrivateData *pd = mode_get_private_data(sw); char *savept = NULL; // Make a copy, as strtok will modify it. - char *switcher_str = g_strdup(config.combi_modi); + char *switcher_str = g_strdup(config.combi_modes); const char *const sep = ",#"; // Split token on ','. This modifies switcher_str. for (char *token = strtok_r(switcher_str, sep, &savept); token != NULL; token = strtok_r(NULL, sep, &savept)) { /* Check against recursion. */ if (g_strcmp0(token, sw->name) == 0) { - g_warning("You cannot add '%s' to the list of combined modi.", sw->name); + g_warning("You cannot add '%s' to the list of combined modes.", sw->name); continue; } // Resize and add entry. pd->switchers = (CombiMode *)g_realloc( pd->switchers, sizeof(CombiMode) * (pd->num_switchers + 1)); - Mode *mode = rofi_collect_modi_search(token); + Mode *mode = rofi_collect_modes_search(token); if (mode != NULL) { pd->switchers[pd->num_switchers].disable = FALSE; pd->switchers[pd->num_switchers++].mode = mode; @@ -236,10 +236,7 @@ static char *combi_mgrv(const Mode *sw, unsigned int selected_line, int *state, } retv = helper_string_replace_if_exists( - config.combi_display_format, - "{mode}", dname, - "{text}", str, - NULL); + config.combi_display_format, "{mode}", dname, "{text}", str, NULL); g_free(str); if (attr_list != NULL) { diff --git a/source/dialogs/filebrowser.c b/source/dialogs/filebrowser.c index 557d4234..daffcd66 100644 --- a/source/dialogs/filebrowser.c +++ b/source/dialogs/filebrowser.c @@ -402,7 +402,7 @@ static void file_browser_mode_init_current_dir(Mode *sw) { static int file_browser_mode_init(Mode *sw) { /** - * Called on startup when enabled (in modi list) + * Called on startup when enabled (in modes list) */ if (mode_get_private_data(sw) == NULL) { FileBrowserModePrivateData *pd = g_malloc0(sizeof(*pd)); diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c index a41930f3..077d09ce 100644 --- a/source/dialogs/ssh.c +++ b/source/dialogs/ssh.c @@ -31,7 +31,7 @@ */ /** - * Log domain for the ssh modi. + * Log domain for the ssh mode. */ #define G_LOG_DOMAIN "Dialogs.Ssh" diff --git a/source/keyb.c b/source/keyb.c index d1067b1f..5de0481f 100644 --- a/source/keyb.c +++ b/source/keyb.c @@ -25,181 +25,419 @@ * */ -#include "config.h" -#include +#include #include "rofi.h" +#include "config.h" #include "nkutils-bindings.h" #include "xrmoptions.h" +#include -typedef struct -{ - guint id; - guint scope; - char *name; - char *binding; - char *comment; +typedef struct { + guint id; + guint scope; + char *name; + char *binding; + char *comment; } ActionBindingEntry; /** * Data structure holding all the action keybinding. */ -ActionBindingEntry rofi_bindings[] = -{ - { .id = PASTE_PRIMARY, .name = "kb-primary-paste", .binding = "Control+V,Shift+Insert", .comment = "Paste primary selection" }, - { .id = PASTE_SECONDARY, .name = "kb-secondary-paste", .binding = "Control+v,Insert", .comment = "Paste clipboard" }, - { .id = CLEAR_LINE, .name = "kb-clear-line", .binding = "Control+w", .comment = "Clear input line" }, - { .id = MOVE_FRONT, .name = "kb-move-front", .binding = "Control+a", .comment = "Beginning of line" }, - { .id = MOVE_END, .name = "kb-move-end", .binding = "Control+e", .comment = "End of line" }, - { .id = MOVE_WORD_BACK, .name = "kb-move-word-back", .binding = "Alt+b,Control+Left", .comment = "Move back one word" }, - { .id = MOVE_WORD_FORWARD, .name = "kb-move-word-forward", .binding = "Alt+f,Control+Right", .comment = "Move forward one word" }, - { .id = MOVE_CHAR_BACK, .name = "kb-move-char-back", .binding = "Left,Control+b", .comment = "Move back one char" }, - { .id = MOVE_CHAR_FORWARD, .name = "kb-move-char-forward", .binding = "Right,Control+f", .comment = "Move forward one char" }, - { .id = REMOVE_WORD_BACK, .name = "kb-remove-word-back", .binding = "Control+Alt+h,Control+BackSpace", .comment = "Delete previous word" }, - { .id = REMOVE_WORD_FORWARD, .name = "kb-remove-word-forward", .binding = "Control+Alt+d", .comment = "Delete next word" }, - { .id = REMOVE_CHAR_FORWARD, .name = "kb-remove-char-forward", .binding = "Delete,Control+d", .comment = "Delete next char" }, - { .id = REMOVE_CHAR_BACK, .name = "kb-remove-char-back", .binding = "BackSpace,Shift+BackSpace,Control+h", .comment = "Delete previous char" }, - { .id = REMOVE_TO_EOL, .name = "kb-remove-to-eol", .binding = "Control+k", .comment = "Delete till the end of line" }, - { .id = REMOVE_TO_SOL, .name = "kb-remove-to-sol", .binding = "Control+u", .comment = "Delete till the start of line" }, - { .id = ACCEPT_ENTRY, .name = "kb-accept-entry", .binding = "Control+j,Control+m,Return,KP_Enter", .comment = "Accept entry" }, - { .id = ACCEPT_CUSTOM, .name = "kb-accept-custom", .binding = "Control+Return", .comment = "Use entered text as command (in ssh/run modi)" }, - { .id = ACCEPT_CUSTOM_ALT, .name = "kb-accept-custom-alt", .binding = "Control+Shift+Return", .comment = "Use entered text as command (in ssh/run modi)" }, - { .id = ACCEPT_ALT, .name = "kb-accept-alt", .binding = "Shift+Return", .comment = "Use alternate accept command." }, - { .id = DELETE_ENTRY, .name = "kb-delete-entry", .binding = "Shift+Delete", .comment = "Delete entry from history" }, - { .id = MODE_NEXT, .name = "kb-mode-next", .binding = "Shift+Right,Control+Tab", .comment = "Switch to the next mode." }, - { .id = MODE_PREVIOUS, .name = "kb-mode-previous", .binding = "Shift+Left,Control+ISO_Left_Tab", .comment = "Switch to the previous mode." }, - { .id = MODE_COMPLETE, .name = "kb-mode-complete", .binding = "Control+l", .comment = "Start completion for mode." }, - { .id = ROW_LEFT, .name = "kb-row-left", .binding = "Control+Page_Up", .comment = "Go to the previous column" }, - { .id = ROW_RIGHT, .name = "kb-row-right", .binding = "Control+Page_Down", .comment = "Go to the next column" }, - { .id = ROW_UP, .name = "kb-row-up", .binding = "Up,Control+p,ISO_Left_Tab", .comment = "Select previous entry" }, - { .id = ROW_DOWN, .name = "kb-row-down", .binding = "Down,Control+n", .comment = "Select next entry" }, - { .id = ROW_TAB, .name = "kb-row-tab", .binding = "Tab", .comment = "Go to next row, if one left, accept it, if no left next mode." }, - { .id = PAGE_PREV, .name = "kb-page-prev", .binding = "Page_Up", .comment = "Go to the previous page" }, - { .id = PAGE_NEXT, .name = "kb-page-next", .binding = "Page_Down", .comment = "Go to the next page" }, - { .id = ROW_FIRST, .name = "kb-row-first", .binding = "Home,KP_Home", .comment = "Go to the first entry" }, - { .id = ROW_LAST, .name = "kb-row-last", .binding = "End,KP_End", .comment = "Go to the last entry" }, - { .id = ROW_SELECT, .name = "kb-row-select", .binding = "Control+space", .comment = "Set selected item as input text" }, - { .id = SCREENSHOT, .name = "kb-screenshot", .binding = "Alt+S", .comment = "Take a screenshot of the rofi window" }, - { .id = CHANGE_ELLIPSIZE, .name = "kb-ellipsize", .binding = "Alt+period", .comment = "Toggle between ellipsize modes for displayed data" }, - { .id = TOGGLE_CASE_SENSITIVITY, .name = "kb-toggle-case-sensitivity", .binding = "grave,dead_grave", .comment = "Toggle case sensitivity" }, - { .id = TOGGLE_SORT, .name = "kb-toggle-sort", .binding = "Alt+grave", .comment = "Toggle sort" }, - { .id = CANCEL, .name = "kb-cancel", .binding = "Escape,Control+g,Control+bracketleft", .comment = "Quit rofi" }, - { .id = CUSTOM_1, .name = "kb-custom-1", .binding = "Alt+1", .comment = "Custom keybinding 1" }, - { .id = CUSTOM_2, .name = "kb-custom-2", .binding = "Alt+2", .comment = "Custom keybinding 2" }, - { .id = CUSTOM_3, .name = "kb-custom-3", .binding = "Alt+3", .comment = "Custom keybinding 3" }, - { .id = CUSTOM_4, .name = "kb-custom-4", .binding = "Alt+4", .comment = "Custom keybinding 4" }, - { .id = CUSTOM_5, .name = "kb-custom-5", .binding = "Alt+5", .comment = "Custom Keybinding 5" }, - { .id = CUSTOM_6, .name = "kb-custom-6", .binding = "Alt+6", .comment = "Custom keybinding 6" }, - { .id = CUSTOM_7, .name = "kb-custom-7", .binding = "Alt+7", .comment = "Custom Keybinding 7" }, - { .id = CUSTOM_8, .name = "kb-custom-8", .binding = "Alt+8", .comment = "Custom keybinding 8" }, - { .id = CUSTOM_9, .name = "kb-custom-9", .binding = "Alt+9", .comment = "Custom keybinding 9" }, - { .id = CUSTOM_10, .name = "kb-custom-10", .binding = "Alt+0", .comment = "Custom keybinding 10" }, - { .id = CUSTOM_11, .name = "kb-custom-11", .binding = "Alt+exclam", .comment = "Custom keybinding 11" }, - { .id = CUSTOM_12, .name = "kb-custom-12", .binding = "Alt+at", .comment = "Custom keybinding 12" }, - { .id = CUSTOM_13, .name = "kb-custom-13", .binding = "Alt+numbersign", .comment = "Custom keybinding 13" }, - { .id = CUSTOM_14, .name = "kb-custom-14", .binding = "Alt+dollar", .comment = "Custom keybinding 14" }, - { .id = CUSTOM_15, .name = "kb-custom-15", .binding = "Alt+percent", .comment = "Custom keybinding 15" }, - { .id = CUSTOM_16, .name = "kb-custom-16", .binding = "Alt+dead_circumflex", .comment = "Custom keybinding 16" }, - { .id = CUSTOM_17, .name = "kb-custom-17", .binding = "Alt+ampersand", .comment = "Custom keybinding 17" }, - { .id = CUSTOM_18, .name = "kb-custom-18", .binding = "Alt+asterisk", .comment = "Custom keybinding 18" }, - { .id = CUSTOM_19, .name = "kb-custom-19", .binding = "Alt+parenleft", .comment = "Custom Keybinding 19" }, - { .id = SELECT_ELEMENT_1, .name = "kb-select-1", .binding = "Super+1", .comment = "Select row 1" }, - { .id = SELECT_ELEMENT_2, .name = "kb-select-2", .binding = "Super+2", .comment = "Select row 2" }, - { .id = SELECT_ELEMENT_3, .name = "kb-select-3", .binding = "Super+3", .comment = "Select row 3" }, - { .id = SELECT_ELEMENT_4, .name = "kb-select-4", .binding = "Super+4", .comment = "Select row 4" }, - { .id = SELECT_ELEMENT_5, .name = "kb-select-5", .binding = "Super+5", .comment = "Select row 5" }, - { .id = SELECT_ELEMENT_6, .name = "kb-select-6", .binding = "Super+6", .comment = "Select row 6" }, - { .id = SELECT_ELEMENT_7, .name = "kb-select-7", .binding = "Super+7", .comment = "Select row 7" }, - { .id = SELECT_ELEMENT_8, .name = "kb-select-8", .binding = "Super+8", .comment = "Select row 8" }, - { .id = SELECT_ELEMENT_9, .name = "kb-select-9", .binding = "Super+9", .comment = "Select row 9" }, - { .id = SELECT_ELEMENT_10, .name = "kb-select-10", .binding = "Super+0", .comment = "Select row 10" }, +ActionBindingEntry rofi_bindings[] = { + {.id = PASTE_PRIMARY, + .name = "kb-primary-paste", + .binding = "Control+V,Shift+Insert", + .comment = "Paste primary selection"}, + {.id = PASTE_SECONDARY, + .name = "kb-secondary-paste", + .binding = "Control+v,Insert", + .comment = "Paste clipboard"}, + {.id = CLEAR_LINE, + .name = "kb-clear-line", + .binding = "Control+w", + .comment = "Clear input line"}, + {.id = MOVE_FRONT, + .name = "kb-move-front", + .binding = "Control+a", + .comment = "Beginning of line"}, + {.id = MOVE_END, + .name = "kb-move-end", + .binding = "Control+e", + .comment = "End of line"}, + {.id = MOVE_WORD_BACK, + .name = "kb-move-word-back", + .binding = "Alt+b,Control+Left", + .comment = "Move back one word"}, + {.id = MOVE_WORD_FORWARD, + .name = "kb-move-word-forward", + .binding = "Alt+f,Control+Right", + .comment = "Move forward one word"}, + {.id = MOVE_CHAR_BACK, + .name = "kb-move-char-back", + .binding = "Left,Control+b", + .comment = "Move back one char"}, + {.id = MOVE_CHAR_FORWARD, + .name = "kb-move-char-forward", + .binding = "Right,Control+f", + .comment = "Move forward one char"}, + {.id = REMOVE_WORD_BACK, + .name = "kb-remove-word-back", + .binding = "Control+Alt+h,Control+BackSpace", + .comment = "Delete previous word"}, + {.id = REMOVE_WORD_FORWARD, + .name = "kb-remove-word-forward", + .binding = "Control+Alt+d", + .comment = "Delete next word"}, + {.id = REMOVE_CHAR_FORWARD, + .name = "kb-remove-char-forward", + .binding = "Delete,Control+d", + .comment = "Delete next char"}, + {.id = REMOVE_CHAR_BACK, + .name = "kb-remove-char-back", + .binding = "BackSpace,Shift+BackSpace,Control+h", + .comment = "Delete previous char"}, + {.id = REMOVE_TO_EOL, + .name = "kb-remove-to-eol", + .binding = "Control+k", + .comment = "Delete till the end of line"}, + {.id = REMOVE_TO_SOL, + .name = "kb-remove-to-sol", + .binding = "Control+u", + .comment = "Delete till the start of line"}, + {.id = ACCEPT_ENTRY, + .name = "kb-accept-entry", + .binding = "Control+j,Control+m,Return,KP_Enter", + .comment = "Accept entry"}, + {.id = ACCEPT_CUSTOM, + .name = "kb-accept-custom", + .binding = "Control+Return", + .comment = "Use entered text as command (in ssh/run modes)"}, + {.id = ACCEPT_CUSTOM_ALT, + .name = "kb-accept-custom-alt", + .binding = "Control+Shift+Return", + .comment = "Use entered text as command (in ssh/run modes)"}, + {.id = ACCEPT_ALT, + .name = "kb-accept-alt", + .binding = "Shift+Return", + .comment = "Use alternate accept command."}, + {.id = DELETE_ENTRY, + .name = "kb-delete-entry", + .binding = "Shift+Delete", + .comment = "Delete entry from history"}, + {.id = MODE_NEXT, + .name = "kb-mode-next", + .binding = "Shift+Right,Control+Tab", + .comment = "Switch to the next mode."}, + {.id = MODE_PREVIOUS, + .name = "kb-mode-previous", + .binding = "Shift+Left,Control+ISO_Left_Tab", + .comment = "Switch to the previous mode."}, + {.id = MODE_COMPLETE, + .name = "kb-mode-complete", + .binding = "Control+l", + .comment = "Start completion for mode."}, + {.id = ROW_LEFT, + .name = "kb-row-left", + .binding = "Control+Page_Up", + .comment = "Go to the previous column"}, + {.id = ROW_RIGHT, + .name = "kb-row-right", + .binding = "Control+Page_Down", + .comment = "Go to the next column"}, + {.id = ROW_UP, + .name = "kb-row-up", + .binding = "Up,Control+p,ISO_Left_Tab", + .comment = "Select previous entry"}, + {.id = ROW_DOWN, + .name = "kb-row-down", + .binding = "Down,Control+n", + .comment = "Select next entry"}, + {.id = ROW_TAB, + .name = "kb-row-tab", + .binding = "Tab", + .comment = + "Go to next row, if one left, accept it, if no left next mode."}, + {.id = PAGE_PREV, + .name = "kb-page-prev", + .binding = "Page_Up", + .comment = "Go to the previous page"}, + {.id = PAGE_NEXT, + .name = "kb-page-next", + .binding = "Page_Down", + .comment = "Go to the next page"}, + {.id = ROW_FIRST, + .name = "kb-row-first", + .binding = "Home,KP_Home", + .comment = "Go to the first entry"}, + {.id = ROW_LAST, + .name = "kb-row-last", + .binding = "End,KP_End", + .comment = "Go to the last entry"}, + {.id = ROW_SELECT, + .name = "kb-row-select", + .binding = "Control+space", + .comment = "Set selected item as input text"}, + {.id = SCREENSHOT, + .name = "kb-screenshot", + .binding = "Alt+S", + .comment = "Take a screenshot of the rofi window"}, + {.id = CHANGE_ELLIPSIZE, + .name = "kb-ellipsize", + .binding = "Alt+period", + .comment = "Toggle between ellipsize modes for displayed data"}, + {.id = TOGGLE_CASE_SENSITIVITY, + .name = "kb-toggle-case-sensitivity", + .binding = "grave,dead_grave", + .comment = "Toggle case sensitivity"}, + {.id = TOGGLE_SORT, + .name = "kb-toggle-sort", + .binding = "Alt+grave", + .comment = "Toggle sort"}, + {.id = CANCEL, + .name = "kb-cancel", + .binding = "Escape,Control+g,Control+bracketleft", + .comment = "Quit rofi"}, + {.id = CUSTOM_1, + .name = "kb-custom-1", + .binding = "Alt+1", + .comment = "Custom keybinding 1"}, + {.id = CUSTOM_2, + .name = "kb-custom-2", + .binding = "Alt+2", + .comment = "Custom keybinding 2"}, + {.id = CUSTOM_3, + .name = "kb-custom-3", + .binding = "Alt+3", + .comment = "Custom keybinding 3"}, + {.id = CUSTOM_4, + .name = "kb-custom-4", + .binding = "Alt+4", + .comment = "Custom keybinding 4"}, + {.id = CUSTOM_5, + .name = "kb-custom-5", + .binding = "Alt+5", + .comment = "Custom Keybinding 5"}, + {.id = CUSTOM_6, + .name = "kb-custom-6", + .binding = "Alt+6", + .comment = "Custom keybinding 6"}, + {.id = CUSTOM_7, + .name = "kb-custom-7", + .binding = "Alt+7", + .comment = "Custom Keybinding 7"}, + {.id = CUSTOM_8, + .name = "kb-custom-8", + .binding = "Alt+8", + .comment = "Custom keybinding 8"}, + {.id = CUSTOM_9, + .name = "kb-custom-9", + .binding = "Alt+9", + .comment = "Custom keybinding 9"}, + {.id = CUSTOM_10, + .name = "kb-custom-10", + .binding = "Alt+0", + .comment = "Custom keybinding 10"}, + {.id = CUSTOM_11, + .name = "kb-custom-11", + .binding = "Alt+exclam", + .comment = "Custom keybinding 11"}, + {.id = CUSTOM_12, + .name = "kb-custom-12", + .binding = "Alt+at", + .comment = "Custom keybinding 12"}, + {.id = CUSTOM_13, + .name = "kb-custom-13", + .binding = "Alt+numbersign", + .comment = "Custom keybinding 13"}, + {.id = CUSTOM_14, + .name = "kb-custom-14", + .binding = "Alt+dollar", + .comment = "Custom keybinding 14"}, + {.id = CUSTOM_15, + .name = "kb-custom-15", + .binding = "Alt+percent", + .comment = "Custom keybinding 15"}, + {.id = CUSTOM_16, + .name = "kb-custom-16", + .binding = "Alt+dead_circumflex", + .comment = "Custom keybinding 16"}, + {.id = CUSTOM_17, + .name = "kb-custom-17", + .binding = "Alt+ampersand", + .comment = "Custom keybinding 17"}, + {.id = CUSTOM_18, + .name = "kb-custom-18", + .binding = "Alt+asterisk", + .comment = "Custom keybinding 18"}, + {.id = CUSTOM_19, + .name = "kb-custom-19", + .binding = "Alt+parenleft", + .comment = "Custom Keybinding 19"}, + {.id = SELECT_ELEMENT_1, + .name = "kb-select-1", + .binding = "Super+1", + .comment = "Select row 1"}, + {.id = SELECT_ELEMENT_2, + .name = "kb-select-2", + .binding = "Super+2", + .comment = "Select row 2"}, + {.id = SELECT_ELEMENT_3, + .name = "kb-select-3", + .binding = "Super+3", + .comment = "Select row 3"}, + {.id = SELECT_ELEMENT_4, + .name = "kb-select-4", + .binding = "Super+4", + .comment = "Select row 4"}, + {.id = SELECT_ELEMENT_5, + .name = "kb-select-5", + .binding = "Super+5", + .comment = "Select row 5"}, + {.id = SELECT_ELEMENT_6, + .name = "kb-select-6", + .binding = "Super+6", + .comment = "Select row 6"}, + {.id = SELECT_ELEMENT_7, + .name = "kb-select-7", + .binding = "Super+7", + .comment = "Select row 7"}, + {.id = SELECT_ELEMENT_8, + .name = "kb-select-8", + .binding = "Super+8", + .comment = "Select row 8"}, + {.id = SELECT_ELEMENT_9, + .name = "kb-select-9", + .binding = "Super+9", + .comment = "Select row 9"}, + {.id = SELECT_ELEMENT_10, + .name = "kb-select-10", + .binding = "Super+0", + .comment = "Select row 10"}, /* Mouse-aware bindings */ - { .id = SCROLL_LEFT, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-left", .binding = "ScrollLeft", .comment = "Go to the previous column" }, - { .id = SCROLL_RIGHT, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-right", .binding = "ScrollRight", .comment = "Go to the next column" }, - { .id = SCROLL_UP, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-up", .binding = "ScrollUp", .comment = "Select previous entry" }, - { .id = SCROLL_DOWN, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-down", .binding = "ScrollDown", .comment = "Select next entry" }, + {.id = SCROLL_LEFT, + .scope = SCOPE_MOUSE_LISTVIEW, + .name = "ml-row-left", + .binding = "ScrollLeft", + .comment = "Go to the previous column"}, + {.id = SCROLL_RIGHT, + .scope = SCOPE_MOUSE_LISTVIEW, + .name = "ml-row-right", + .binding = "ScrollRight", + .comment = "Go to the next column"}, + {.id = SCROLL_UP, + .scope = SCOPE_MOUSE_LISTVIEW, + .name = "ml-row-up", + .binding = "ScrollUp", + .comment = "Select previous entry"}, + {.id = SCROLL_DOWN, + .scope = SCOPE_MOUSE_LISTVIEW, + .name = "ml-row-down", + .binding = "ScrollDown", + .comment = "Select next entry"}, - { .id = SELECT_HOVERED_ENTRY, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-select-entry", .binding = "MousePrimary", .comment = "Select hovered row" }, - { .id = ACCEPT_HOVERED_ENTRY, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-accept-entry", .binding = "MouseDPrimary", .comment = "Accept hovered row" }, - { .id = ACCEPT_HOVERED_CUSTOM, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-accept-custom", .binding = "Control+MouseDPrimary", .comment = "Accept hovered row with custom action"}, + {.id = SELECT_HOVERED_ENTRY, + .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, + .name = "me-select-entry", + .binding = "MousePrimary", + .comment = "Select hovered row"}, + {.id = ACCEPT_HOVERED_ENTRY, + .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, + .name = "me-accept-entry", + .binding = "MouseDPrimary", + .comment = "Accept hovered row"}, + {.id = ACCEPT_HOVERED_CUSTOM, + .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, + .name = "me-accept-custom", + .binding = "Control+MouseDPrimary", + .comment = "Accept hovered row with custom action"}, }; /** Default binding of mouse button to action. */ static const gchar *mouse_default_bindings[] = { - [MOUSE_CLICK_DOWN] = "MousePrimary", - [MOUSE_CLICK_UP] = "!MousePrimary", + [MOUSE_CLICK_DOWN] = "MousePrimary", + [MOUSE_CLICK_UP] = "!MousePrimary", [MOUSE_DCLICK_DOWN] = "MouseDPrimary", - [MOUSE_DCLICK_UP] = "!MouseDPrimary", + [MOUSE_DCLICK_UP] = "!MouseDPrimary", }; -void setup_abe ( void ) -{ - for ( gsize i = 0; i < G_N_ELEMENTS ( rofi_bindings ); ++i ) { - ActionBindingEntry *b = &rofi_bindings[i]; - b->binding = g_strdup ( b->binding ); - config_parser_add_option ( xrm_String, b->name, (void * *) &( b->binding ), b->comment ); - } -} - -static gboolean binding_check_action ( guint64 scope, G_GNUC_UNUSED gpointer target, gpointer user_data ) -{ - return rofi_view_check_action ( rofi_view_get_active (), scope, GPOINTER_TO_UINT ( user_data ) ) ? NK_BINDINGS_BINDING_TRIGGERED : NK_BINDINGS_BINDING_NOT_TRIGGERED; -} - -static void binding_trigger_action ( guint64 scope, G_GNUC_UNUSED gpointer target, gpointer user_data ) -{ - rofi_view_trigger_action ( rofi_view_get_active (), scope, GPOINTER_TO_UINT ( user_data ) ); -} - -guint key_binding_get_action_from_name ( const char *name ) -{ - for ( gsize i = 0; i < G_N_ELEMENTS ( rofi_bindings ); ++i ) { +void setup_abe(void) { + for (gsize i = 0; i < G_N_ELEMENTS(rofi_bindings); ++i) { ActionBindingEntry *b = &rofi_bindings[i]; - if ( g_strcmp0(b->name, name) == 0 ) { + b->binding = g_strdup(b->binding); + config_parser_add_option(xrm_String, b->name, (void **)&(b->binding), + b->comment); + } +} + +static gboolean binding_check_action(guint64 scope, + G_GNUC_UNUSED gpointer target, + gpointer user_data) { + return rofi_view_check_action(rofi_view_get_active(), scope, + GPOINTER_TO_UINT(user_data)) + ? NK_BINDINGS_BINDING_TRIGGERED + : NK_BINDINGS_BINDING_NOT_TRIGGERED; +} + +static void binding_trigger_action(guint64 scope, G_GNUC_UNUSED gpointer target, + gpointer user_data) { + rofi_view_trigger_action(rofi_view_get_active(), scope, + GPOINTER_TO_UINT(user_data)); +} + +guint key_binding_get_action_from_name(const char *name) { + for (gsize i = 0; i < G_N_ELEMENTS(rofi_bindings); ++i) { + ActionBindingEntry *b = &rofi_bindings[i]; + if (g_strcmp0(b->name, name) == 0) { return b->id; } } return UINT32_MAX; } +gboolean parse_keys_abe(NkBindings *bindings) { + GError *error = NULL; + GString *error_msg = g_string_new(""); + for (gsize i = 0; i < G_N_ELEMENTS(rofi_bindings); ++i) { + ActionBindingEntry *b = &rofi_bindings[i]; + char *keystr = g_strdup(b->binding); + char *sp = NULL; -gboolean parse_keys_abe ( NkBindings *bindings ) -{ - GError *error = NULL; - GString *error_msg = g_string_new ( "" ); - for ( gsize i = 0; i < G_N_ELEMENTS ( rofi_bindings ); ++i ) { - ActionBindingEntry *b = &rofi_bindings[i]; - char *keystr = g_strdup ( b->binding ); - char *sp = NULL; - - // Iter over bindings. - const char *const sep = ","; - for ( char *entry = strtok_r ( keystr, sep, &sp ); entry != NULL; entry = strtok_r ( NULL, sep, &sp ) ) { - if ( !nk_bindings_add_binding ( bindings, b->scope, entry, binding_check_action, binding_trigger_action, GUINT_TO_POINTER ( b->id ), NULL, &error ) ) { - char *str = g_markup_printf_escaped ( "Failed to set binding %s for: %s (%s):\n\t%s\n", - b->binding, b->comment, b->name, error->message ); - g_string_append ( error_msg, str ); - g_free ( str ); - g_clear_error ( &error ); - } - } - - g_free ( keystr ); - } - if ( error_msg->len > 0 ) { - //rofi_view_error_dialog ( error_msg->str, TRUE ); - rofi_add_error_message ( error_msg ); -// g_string_free ( error_msg, TRUE ); - return FALSE; + // Iter over bindings. + const char *const sep = ","; + for (char *entry = strtok_r(keystr, sep, &sp); entry != NULL; + entry = strtok_r(NULL, sep, &sp)) { + if (!nk_bindings_add_binding(bindings, b->scope, entry, + binding_check_action, binding_trigger_action, + GUINT_TO_POINTER(b->id), NULL, &error)) { + char *str = g_markup_printf_escaped( + "Failed to set binding %s for: %s (%s):\n\t%s\n", + b->binding, b->comment, b->name, error->message); + g_string_append(error_msg, str); + g_free(str); + g_clear_error(&error); + } } - for ( gsize i = SCOPE_MIN_FIXED; i <= SCOPE_MAX_FIXED; ++i ) { - for ( gsize j = 1; j < G_N_ELEMENTS ( mouse_default_bindings ); ++j ) { - nk_bindings_add_binding ( bindings, i, mouse_default_bindings[j], binding_check_action, binding_trigger_action, GSIZE_TO_POINTER ( j ), NULL, NULL ); - } - } + g_free(keystr); + } + if (error_msg->len > 0) { + // rofi_view_error_dialog ( error_msg->str, TRUE ); + rofi_add_error_message(error_msg); + // g_string_free ( error_msg, TRUE ); + return FALSE; + } - g_string_free ( error_msg, TRUE ); - return TRUE; + for (gsize i = SCOPE_MIN_FIXED; i <= SCOPE_MAX_FIXED; ++i) { + for (gsize j = 1; j < G_N_ELEMENTS(mouse_default_bindings); ++j) { + nk_bindings_add_binding(bindings, i, mouse_default_bindings[j], + binding_check_action, binding_trigger_action, + GSIZE_TO_POINTER(j), NULL, NULL); + } + } + + g_string_free(error_msg, TRUE); + return TRUE; } diff --git a/source/rofi-icon-fetcher.c b/source/rofi-icon-fetcher.c index 50558c01..03e5ac9c 100644 --- a/source/rofi-icon-fetcher.c +++ b/source/rofi-icon-fetcher.c @@ -36,6 +36,8 @@ #include "rofi-icon-fetcher.h" #include "rofi-types.h" #include "settings.h" +#include +#include #include "keyb.h" #include "view.h" @@ -292,6 +294,32 @@ static void rofi_icon_fetcher_worker(thread_state *sdata, if (g_path_is_absolute(sentry->entry->name)) { icon_path = sentry->entry->name; + } else if (g_str_has_prefix(sentry->entry->name, "font:")) { + cairo_surface_t *surface = cairo_image_surface_create( + CAIRO_FORMAT_ARGB32, sentry->wsize, sentry->hsize); + cairo_t *cr = cairo_create(surface); + PangoLayout *layout = pango_cairo_create_layout(cr); + pango_layout_set_text(layout, &sentry->entry->name[5], -1); + + int width, height; + pango_layout_get_size(layout, &width, &height); + double ws = sentry->wsize / ((double)width / PANGO_SCALE); + double wh = sentry->hsize / ((double)height / PANGO_SCALE); + double scale = MIN(ws, wh); + + cairo_move_to( + cr, (sentry->wsize - ((double)width / PANGO_SCALE) * scale) / 2.0, + (sentry->hsize - ((double)height / PANGO_SCALE) * scale) / 2.0); + cairo_scale(cr, scale, scale); + pango_cairo_update_layout(cr, layout); + pango_layout_get_size(layout, &width, &height); + pango_cairo_show_layout(cr, layout); + g_object_unref(layout); + cairo_destroy(cr); + sentry->surface = surface; + rofi_view_reload(); + return; + } else { icon_path = icon_path_ = nk_xdg_theme_get_icon( rofi_icon_fetcher_data->xdg_context, themes, NULL, sentry->entry->name, diff --git a/source/rofi.c b/source/rofi.c index 300837aa..7f2992d9 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -85,7 +85,7 @@ const char *cache_dir = NULL; /** List of error messages.*/ GList *list_of_error_msgs = NULL; -static void rofi_collect_modi_destroy(void); +static void rofi_collectmodes_destroy(void); void rofi_add_error_message(GString *str) { list_of_error_msgs = g_list_append(list_of_error_msgs, str); } @@ -103,15 +103,15 @@ void rofi_clear_error_messages(void) { /** Path to the configuration file */ G_MODULE_EXPORT char *config_path = NULL; /** Path to the configuration file in the new format */ -/** Array holding all activated modi. */ -Mode **modi = NULL; +/** Array holding all activated modes. */ +Mode **modes = NULL; -/** List of (possibly uninitialized) modi's */ -Mode **available_modi = NULL; -/** Length of #num_available_modi */ -unsigned int num_available_modi = 0; -/** Number of activated modi in #modi array */ -unsigned int num_modi = 0; +/** List of (possibly uninitialized) modes */ +Mode **available_modes = NULL; +/** Length of #num_available_modes */ +unsigned int num_available_modes = 0; +/** Number of activated modes in #modes array */ +unsigned int num_modes = 0; /** Current selected mode */ unsigned int curr_mode = 0; @@ -130,20 +130,20 @@ void process_result(RofiViewState *state); void rofi_set_return_code(int code) { return_code = code; } -unsigned int rofi_get_num_enabled_modi(void) { return num_modi; } +unsigned int rofi_get_num_enabled_modes(void) { return num_modes; } -const Mode *rofi_get_mode(unsigned int index) { return modi[index]; } +const Mode *rofi_get_mode(unsigned int index) { return modes[index]; } /** * @param name Name of the mode to lookup. * * Find the index of the mode with name. * - * @returns index of the mode in modi, -1 if not found. + * @returns index of the mode in modes, -1 if not found. */ static int mode_lookup(const char *name) { - for (unsigned int i = 0; i < num_modi; i++) { - if (strcmp(mode_get_name(modi[i]), name) == 0) { + for (unsigned int i = 0; i < num_modes; i++) { + if (strcmp(mode_get_name(modes[i]), name) == 0) { return i; } } @@ -167,10 +167,10 @@ static void teardown(int pfd) { } static void run_mode_index(ModeMode mode) { // Otherwise check if requested mode is enabled. - for (unsigned int i = 0; i < num_modi; i++) { - if (!mode_init(modi[i])) { + for (unsigned int i = 0; i < num_modes; i++) { + if (!mode_init(modes[i])) { GString *str = g_string_new("Failed to initialize the mode: "); - g_string_append(str, modi[i]->name); + g_string_append(str, modes[i]->name); g_string_append(str, "\n"); rofi_view_error_dialog(str->str, ERROR_MSG_MARKUP); @@ -184,7 +184,7 @@ static void run_mode_index(ModeMode mode) { } curr_mode = mode; RofiViewState *state = - rofi_view_create(modi[mode], config.filter, 0, process_result); + rofi_view_create(modes[mode], config.filter, 0, process_result); // User can pre-select a row. if (find_arg("-selected-row") >= 0) { @@ -223,19 +223,19 @@ void process_result(RofiViewState *state) { ModeMode mode = curr_mode; // Find next enabled if (retv == NEXT_DIALOG) { - mode = (mode + 1) % num_modi; + mode = (mode + 1) % num_modes; } else if (retv == PREVIOUS_DIALOG) { if (mode == 0) { - mode = num_modi - 1; + mode = num_modes - 1; } else { - mode = (mode - 1) % num_modi; + mode = (mode - 1) % num_modes; } } else if (retv == RELOAD_DIALOG) { // do nothing. } else if (retv == RESET_DIALOG) { rofi_view_clear_input(state); } else if (retv < MODE_EXIT) { - mode = (retv) % num_modi; + mode = (retv) % num_modes; } else { mode = retv; } @@ -243,7 +243,7 @@ void process_result(RofiViewState *state) { /** * Load in the new mode. */ - rofi_view_switch_mode(state, modi[mode]); + rofi_view_switch_mode(state, modes[mode]); curr_mode = mode; return; } @@ -260,18 +260,18 @@ void process_result(RofiViewState *state) { /** * Help function. */ -static void print_list_of_modi(int is_term) { - for (unsigned int i = 0; i < num_available_modi; i++) { +static void print_list_of_modes(int is_term) { + for (unsigned int i = 0; i < num_available_modes; i++) { gboolean active = FALSE; - for (unsigned int j = 0; j < num_modi; j++) { - if (modi[j] == available_modi[i]) { + for (unsigned int j = 0; j < num_modes; j++) { + if (modes[j] == available_modes[i]) { active = TRUE; break; } } printf(" • %s%s%s%s\n", active ? "+" : "", is_term ? (active ? color_green : color_red) : "", - available_modi[i]->name, is_term ? color_reset : ""); + available_modes[i]->name, is_term ? color_reset : ""); } } static void print_main_application_options(int is_term) { @@ -323,8 +323,8 @@ static void help(G_GNUC_UNUSED int argc, char **argv) { printf("\n"); display_dump_monitor_layout(); printf("\n"); - printf("Detected modi:\n"); - print_list_of_modi(is_term); + printf("Detected modes:\n"); + print_list_of_modes(is_term); printf("\n"); printf("Compile time options:\n"); #ifdef WINDOW_MODE @@ -390,26 +390,26 @@ static void help_print_disabled_mode(const char *mode) { fprintf(stderr, "Mode %s%s%s is not enabled. I have enabled it for now.\n", color_red, mode, color_reset); fprintf(stderr, - "Please consider adding %s%s%s to the list of enabled modi: " - "%smodi: [%s%s%s,%s]%s.\n", - color_red, mode, color_reset, color_green, config.modi, color_reset, - color_red, mode, color_reset); + "Please consider adding %s%s%s to the list of enabled modes: " + "%smodes: [%s%s%s,%s]%s.\n", + color_red, mode, color_reset, color_green, config.modes, + color_reset, color_red, mode, color_reset); } } static void help_print_mode_not_found(const char *mode) { GString *str = g_string_new(""); - g_string_printf(str, "Mode %s is not found.\nThe following modi are known:\n", - mode); - for (unsigned int i = 0; i < num_available_modi; i++) { + g_string_printf( + str, "Mode %s is not found.\nThe following modes are known:\n", mode); + for (unsigned int i = 0; i < num_available_modes; i++) { gboolean active = FALSE; - for (unsigned int j = 0; j < num_modi; j++) { - if (modi[j] == available_modi[i]) { + for (unsigned int j = 0; j < num_modes; j++) { + if (modes[j] == available_modes[i]) { active = TRUE; break; } } g_string_append_printf(str, " * %s%s\n", active ? "+" : "", - available_modi[i]->name); + available_modes[i]->name); } rofi_add_error_message(str); } @@ -421,27 +421,27 @@ static void help_print_no_arguments(void) { fprintf(stderr, " %srofi%s -show %s{mode}%s\n\n", is_term ? color_bold : "", is_term ? color_reset : "", is_term ? color_green : "", is_term ? color_reset : ""); - fprintf(stderr, "The following modi are enabled:\n"); - for (unsigned int j = 0; j < num_modi; j++) { - fprintf(stderr, " * %s%s%s\n", is_term ? color_green : "", modi[j]->name, + fprintf(stderr, "The following modes are enabled:\n"); + for (unsigned int j = 0; j < num_modes; j++) { + fprintf(stderr, " * %s%s%s\n", is_term ? color_green : "", modes[j]->name, is_term ? color_reset : ""); } fprintf(stderr, "\nThe following can be enabled:\n"); - for (unsigned int i = 0; i < num_available_modi; i++) { + for (unsigned int i = 0; i < num_available_modes; i++) { gboolean active = FALSE; - for (unsigned int j = 0; j < num_modi; j++) { - if (modi[j] == available_modi[i]) { + for (unsigned int j = 0; j < num_modes; j++) { + if (modes[j] == available_modes[i]) { active = TRUE; break; } } if (!active) { fprintf(stderr, " * %s%s%s\n", is_term ? color_red : "", - available_modi[i]->name, is_term ? color_reset : ""); + available_modes[i]->name, is_term ? color_reset : ""); } } fprintf(stderr, - "\nTo activate a mode, add it to the list of modi in the %smodi%s " + "\nTo activate a mode, add it to the list of modes in the %smodes%s " "setting.\n", is_term ? color_green : "", is_term ? color_reset : ""); } @@ -450,8 +450,8 @@ static void help_print_no_arguments(void) { * Cleanup globally allocated memory. */ static void cleanup(void) { - for (unsigned int i = 0; i < num_modi; i++) { - mode_destroy(modi[i]); + for (unsigned int i = 0; i < num_modes; i++) { + mode_destroy(modes[i]); } rofi_view_workers_finalize(); if (main_loop != NULL) { @@ -465,7 +465,7 @@ static void cleanup(void) { // Cleaning up memory allocated by the Xresources file. config_xresource_free(); - g_free(modi); + g_free(modes); g_free(config_path); @@ -476,7 +476,7 @@ static void cleanup(void) { rofi_theme = NULL; } TIMINGS_STOP(); - rofi_collect_modi_destroy(); + rofi_collectmodes_destroy(); rofi_icon_fetcher_destroy(); rofi_theme_free_parsed_files(); @@ -487,13 +487,13 @@ static void cleanup(void) { } /** - * Collected modi + * Collected modes */ -Mode *rofi_collect_modi_search(const char *name) { - for (unsigned int i = 0; i < num_available_modi; i++) { - if (g_strcmp0(name, available_modi[i]->name) == 0) { - return available_modi[i]; +Mode *rofi_collect_modes_search(const char *name) { + for (unsigned int i = 0; i < num_available_modes; i++) { + if (g_strcmp0(name, available_modes[i]->name) == 0) { + return available_modes[i]; } } return NULL; @@ -503,20 +503,20 @@ Mode *rofi_collect_modi_search(const char *name) { * * @returns TRUE when success. */ -static gboolean rofi_collect_modi_add(Mode *mode) { - Mode *m = rofi_collect_modi_search(mode->name); +static gboolean rofi_collectmodes_add(Mode *mode) { + Mode *m = rofi_collect_modes_search(mode->name); if (m == NULL) { - available_modi = - g_realloc(available_modi, sizeof(Mode *) * (num_available_modi + 1)); + available_modes = + g_realloc(available_modes, sizeof(Mode *) * (num_available_modes + 1)); // Set mode. - available_modi[num_available_modi] = mode; - num_available_modi++; + available_modes[num_available_modes] = mode; + num_available_modes++; return TRUE; } return FALSE; } -static void rofi_collect_modi_dir(const char *base_dir) { +static void rofi_collectmodes_dir(const char *base_dir) { g_debug("Looking into: %s for plugins", base_dir); GDir *dir = g_dir_open(base_dir, 0, NULL); if (dir) { @@ -539,7 +539,7 @@ static void rofi_collect_modi_dir(const char *base_dir) { g_module_close(mod); } else { m->module = mod; - if (!rofi_collect_modi_add(m)) { + if (!rofi_collectmodes_add(m)) { g_module_close(mod); } } @@ -558,32 +558,32 @@ static void rofi_collect_modi_dir(const char *base_dir) { } /** - * Find all available modi. + * Find all available modes. */ -static void rofi_collect_modi(void) { +static void rofi_collect_modes(void) { #ifdef WINDOW_MODE - rofi_collect_modi_add(&window_mode); - rofi_collect_modi_add(&window_mode_cd); + rofi_collectmodes_add(&window_mode); + rofi_collectmodes_add(&window_mode_cd); #endif - rofi_collect_modi_add(&run_mode); - rofi_collect_modi_add(&ssh_mode); + rofi_collectmodes_add(&run_mode); + rofi_collectmodes_add(&ssh_mode); #ifdef ENABLE_DRUN - rofi_collect_modi_add(&drun_mode); + rofi_collectmodes_add(&drun_mode); #endif - rofi_collect_modi_add(&combi_mode); - rofi_collect_modi_add(&help_keys_mode); - rofi_collect_modi_add(&file_browser_mode); + rofi_collectmodes_add(&combi_mode); + rofi_collectmodes_add(&help_keys_mode); + rofi_collectmodes_add(&file_browser_mode); if (find_arg("-no-plugins") < 0) { find_arg_str("-plugin-path", &(config.plugin_path)); g_debug("Parse plugin path: %s", config.plugin_path); - rofi_collect_modi_dir(config.plugin_path); + rofi_collectmodes_dir(config.plugin_path); /* ROFI_PLUGIN_PATH */ const char *path = g_getenv("ROFI_PLUGIN_PATH"); if (path != NULL) { gchar **paths = g_strsplit(path, ":", -1); for (unsigned int i = 0; paths[i]; i++) { - rofi_collect_modi_dir(paths[i]); + rofi_collectmodes_dir(paths[i]); } g_strfreev(paths); } @@ -593,61 +593,61 @@ static void rofi_collect_modi(void) { /** * Setup configuration for config. */ -static void rofi_collect_modi_setup(void) { - for (unsigned int i = 0; i < num_available_modi; i++) { - mode_set_config(available_modi[i]); +static void rofi_collectmodes_setup(void) { + for (unsigned int i = 0; i < num_available_modes; i++) { + mode_set_config(available_modes[i]); } } -static void rofi_collect_modi_destroy(void) { - for (unsigned int i = 0; i < num_available_modi; i++) { - if (available_modi[i]->module) { - GModule *mod = available_modi[i]->module; - available_modi[i] = NULL; +static void rofi_collectmodes_destroy(void) { + for (unsigned int i = 0; i < num_available_modes; i++) { + if (available_modes[i]->module) { + GModule *mod = available_modes[i]->module; + available_modes[i] = NULL; g_module_close(mod); } - if (available_modi[i]) { - mode_free(&(available_modi[i])); + if (available_modes[i]) { + mode_free(&(available_modes[i])); } } - g_free(available_modi); - available_modi = NULL; - num_available_modi = 0; + g_free(available_modes); + available_modes = NULL; + num_available_modes = 0; } /** * Parse the mode string, into internal array of type Mode. * * String is split on separator ',' - * First the three build-in modi are checked: window, run, ssh + * First the three build-in modes are checked: window, run, ssh * if that fails, a script-mode is created. */ static int add_mode(const char *token) { - unsigned int index = num_modi; + unsigned int index = num_modes; // Resize and add entry. - modi = (Mode **)g_realloc(modi, sizeof(Mode *) * (num_modi + 1)); + modes = (Mode **)g_realloc(modes, sizeof(Mode *) * (num_modes + 1)); - Mode *mode = rofi_collect_modi_search(token); + Mode *mode = rofi_collect_modes_search(token); if (mode) { - modi[num_modi] = mode; - num_modi++; + modes[num_modes] = mode; + num_modes++; } else if (script_mode_is_valid(token)) { - // If not build in, use custom modi. + // If not build in, use custom mode. Mode *sw = script_mode_parse_setup(token); if (sw != NULL) { // Add to available list, so combi can find it. - rofi_collect_modi_add(sw); + rofi_collectmodes_add(sw); mode_set_config(sw); - modi[num_modi] = sw; - num_modi++; + modes[num_modes] = sw; + num_modes++; } } - return (index == num_modi) ? -1 : (int)index; + return (index == num_modes) ? -1 : (int)index; } -static gboolean setup_modi(void) { +static gboolean setup_modes(void) { const char *const sep = ",#"; char *savept = NULL; // Make a copy, as strtok will modify it. - char *mode_str = g_strdup(config.modi); + char *mode_str = g_strdup(config.modes); // Split token on ','. This modifies mode_str. for (char *token = strtok_r(mode_str, sep, &savept); token != NULL; token = strtok_r(NULL, sep, &savept)) { @@ -750,7 +750,7 @@ static gboolean startup(G_GNUC_UNUSED gpointer data) { show_error_dialog(); return G_SOURCE_REMOVE; } - } else if (find_arg("-show") >= 0 && num_modi > 0) { + } else if (find_arg("-show") >= 0 && num_modes > 0) { run_mode_index(0); } else { help_print_no_arguments(); @@ -885,10 +885,10 @@ int main(int argc, char *argv[]) { } TICK_N("Setup Locale"); - rofi_collect_modi(); - TICK_N("Collect MODI"); - rofi_collect_modi_setup(); - TICK_N("Setup MODI"); + rofi_collect_modes(); + TICK_N("Collect MODES"); + rofi_collectmodes_setup(); + TICK_N("Setup MODES"); main_loop = g_main_loop_new(NULL, FALSE); @@ -978,12 +978,12 @@ int main(int argc, char *argv[]) { /** dirty hack for dmenu compatibility */ char *windowid = NULL; if (!dmenu_mode) { - // setup_modi - if (setup_modi()) { + // setup_modes + if (setup_modes()) { cleanup(); return EXIT_FAILURE; } - TICK_N("Setup Modi"); + TICK_N("Setup Modes"); } else { // Hack for dmenu compatibility. if (find_arg_str("-w", &windowid) == TRUE) { diff --git a/source/view.c b/source/view.c index 140506fb..b15b138d 100644 --- a/source/view.c +++ b/source/view.c @@ -582,8 +582,8 @@ void rofi_view_free(RofiViewState *state) { g_free(state->distance); // Free the switcher boxes. // When state is free'ed we should no longer need these. - g_free(state->modi); - state->num_modi = 0; + g_free(state->modes); + state->num_modes = 0; g_free(state); } @@ -1729,17 +1729,17 @@ static WidgetTriggerActionResult textbox_button_trigger_action( } return WIDGET_TRIGGER_ACTION_RESULT_IGNORED; } -static WidgetTriggerActionResult textbox_sidebar_modi_trigger_action( +static WidgetTriggerActionResult textbox_sidebar_modes_trigger_action( widget *wid, MouseBindingMouseDefaultAction action, G_GNUC_UNUSED gint x, G_GNUC_UNUSED gint y, G_GNUC_UNUSED void *user_data) { RofiViewState *state = (RofiViewState *)user_data; unsigned int i; - for (i = 0; i < state->num_modi; i++) { - if (WIDGET(state->modi[i]) == wid) { + for (i = 0; i < state->num_modes; i++) { + if (WIDGET(state->modes[i]) == wid) { break; } } - if (i == state->num_modi) { + if (i == state->num_modes) { return WIDGET_TRIGGER_ACTION_RESULT_IGNORED; } @@ -1907,17 +1907,17 @@ static void rofi_view_add_widget(RofiViewState *state, widget *parent_widget, state->sidebar_bar = box_create(parent_widget, name, ROFI_ORIENTATION_HORIZONTAL); box_add((box *)parent_widget, WIDGET(state->sidebar_bar), FALSE); - state->num_modi = rofi_get_num_enabled_modi(); - state->modi = g_malloc0(state->num_modi * sizeof(textbox *)); - for (unsigned int j = 0; j < state->num_modi; j++) { + state->num_modes = rofi_get_num_enabled_modes(); + state->modes = g_malloc0(state->num_modes * sizeof(textbox *)); + for (unsigned int j = 0; j < state->num_modes; j++) { const Mode *mode = rofi_get_mode(j); - state->modi[j] = textbox_create( + state->modes[j] = textbox_create( WIDGET(state->sidebar_bar), WIDGET_TYPE_MODE_SWITCHER, "button", TB_AUTOHEIGHT, (mode == state->sw) ? HIGHLIGHT : NORMAL, mode_get_display_name(mode), 0.5, 0.5); - box_add(state->sidebar_bar, WIDGET(state->modi[j]), TRUE); + box_add(state->sidebar_bar, WIDGET(state->modes[j]), TRUE); widget_set_trigger_action_handler( - WIDGET(state->modi[j]), textbox_sidebar_modi_trigger_action, state); + WIDGET(state->modes[j]), textbox_sidebar_modes_trigger_action, state); } } else if (g_ascii_strcasecmp(name, "overlay") == 0) { state->overlay = textbox_create( @@ -2241,9 +2241,10 @@ void rofi_view_switch_mode(RofiViewState *state, Mode *mode) { rofi_view_set_window_title("rofi"); } if (state->sidebar_bar) { - for (unsigned int j = 0; j < state->num_modi; j++) { + for (unsigned int j = 0; j < state->num_modes; j++) { const Mode *tb_mode = rofi_get_mode(j); - textbox_font(state->modi[j], (tb_mode == state->sw) ? HIGHLIGHT : NORMAL); + textbox_font(state->modes[j], + (tb_mode == state->sw) ? HIGHLIGHT : NORMAL); } } rofi_view_restart(state); diff --git a/source/xrmoptions.c b/source/xrmoptions.c index c07df2d8..614dcc83 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -76,12 +76,18 @@ typedef struct { * Currently supports string, boolean and number (signed and unsigned). */ static XrmOption xrmOptions[] = { - {xrm_String, "switchers", {.str = &config.modi}, NULL, "", CONFIG_DEFAULT}, + {xrm_String, "switchers", {.str = &config.modes}, NULL, "", CONFIG_DEFAULT}, + {xrm_String, + "modes", + {.str = &config.modes}, + NULL, + "Enable modes", + CONFIG_DEFAULT}, {xrm_String, "modi", - {.str = &config.modi}, + {.str = &config.modes}, NULL, - "Enabled modi", + "Enabled modes", CONFIG_DEFAULT}, {xrm_String, "font", @@ -282,7 +288,13 @@ static XrmOption xrmOptions[] = { CONFIG_DEFAULT}, {xrm_String, "combi-modi", - {.str = &config.combi_modi}, + {.str = &config.combi_modes}, + NULL, + "Set the modi to combine in combi mode", + CONFIG_DEFAULT}, + {xrm_String, + "combi-modes", + {.str = &config.combi_modes}, NULL, "Set the modi to combine in combi mode", CONFIG_DEFAULT},