mirror of
https://github.com/lbonn/rofi
synced 2024-11-10 06:14:14 +00:00
Merge tag '1.7.4' into wayland
This commit is contained in:
commit
4e833a4ec4
62 changed files with 2165 additions and 1716 deletions
|
@ -21,6 +21,7 @@ packages:
|
|||
- flex
|
||||
- bison
|
||||
- libglib2.0-dev-bin
|
||||
- doxygen
|
||||
sources:
|
||||
- https://sr.ht/~qball/rofi/
|
||||
tasks:
|
||||
|
@ -31,6 +32,9 @@ tasks:
|
|||
ninja -C rofi/builddir
|
||||
- test: |
|
||||
ninja -C rofi/builddir test
|
||||
- doxygen: |
|
||||
ninja -C rofi/builddir/ doc/html > doxygen.log 2>&1
|
||||
if [ $(grep -c warnings doxygen.log) -gt 0 ]; then exit 1; fi
|
||||
- dist: |
|
||||
ninja -C rofi/builddir dist
|
||||
artifacts:
|
||||
|
|
2
.github/actions/doxycheck/action.yml
vendored
2
.github/actions/doxycheck/action.yml
vendored
|
@ -11,7 +11,7 @@ runs:
|
|||
steps:
|
||||
- id: check
|
||||
run: |
|
||||
if [[ "$(grep -c warning ${{ inputs.logfile }})" != 0 ]]; then
|
||||
if [[ "$(grep -c warning: ${{ inputs.logfile }})" != 0 ]]; then
|
||||
echo
|
||||
echo Doxygen warnings found:
|
||||
grep warning ${{ inputs.logfile }}
|
||||
|
|
7
.github/actions/meson/action.yml
vendored
7
.github/actions/meson/action.yml
vendored
|
@ -32,3 +32,10 @@ runs:
|
|||
- id: test
|
||||
run: ninja -C builddir test
|
||||
shell: bash
|
||||
- id: doxy
|
||||
run: ninja -C builddir doc/html > doxygen.log 2>&1
|
||||
shell: bash
|
||||
- id: doxycheck
|
||||
uses: ./.github/actions/doxycheck
|
||||
with:
|
||||
logfile: doxygen.log
|
||||
|
|
|
@ -10,6 +10,7 @@ then
|
|||
# Override the previously set prompt.
|
||||
echo -en "\0theme\x1felement-text { background-color: "$@";}\n"
|
||||
echo -en "\0keep-selection\x1ftrue\n"
|
||||
# echo -en "\0new-selection\x1f2\n"
|
||||
echo "red"
|
||||
echo "lightgreen"
|
||||
echo "lightblue"
|
||||
|
|
|
@ -24,7 +24,7 @@ You can also use [Meson](https://mesonbuild.com/) as an alternative.
|
|||
|
||||
### External libraries
|
||||
|
||||
* libpango
|
||||
* libpango >= 1.50
|
||||
* libpangocairo
|
||||
* libcairo
|
||||
* libcairo-xcb
|
||||
|
|
|
@ -161,4 +161,7 @@ Settings config = {
|
|||
/** fallback icon */
|
||||
.application_fallback_icon = NULL,
|
||||
/** refilter limit */
|
||||
.refilter_timeout_limit = 8192};
|
||||
.refilter_timeout_limit = 8192,
|
||||
/** workaround for broken xserver (#300 on xserver, #611) */
|
||||
.xserver_i300_workaround = FALSE,
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
AC_INIT([rofi], [1.7.3-dev], [https://github.com/davatorium/rofi/],[],[https://reddit.com/r/qtools/])
|
||||
AC_INIT([rofi], [1.7.4], [https://github.com/davatorium/rofi/],[],[https://reddit.com/r/qtools/])
|
||||
|
||||
AC_CONFIG_SRCDIR([source/rofi.c])
|
||||
AC_CONFIG_HEADER([config.h])
|
||||
|
|
|
@ -280,6 +280,24 @@ The column separator. This is a regex.
|
|||
.PP
|
||||
\fIdefault\fP: '\\t'
|
||||
|
||||
.PP
|
||||
\fB\fC-ballot-selected-str\fR \fIstring\fP
|
||||
|
||||
.PP
|
||||
When multi-select is enabled, prefix this string when element is selected.
|
||||
|
||||
.PP
|
||||
\fIdefault\fP: "☑ "
|
||||
|
||||
.PP
|
||||
\fB\fC-ballot-unselected-str\fR \fIstring\fP
|
||||
|
||||
.PP
|
||||
When multi-select is enabled, prefix this string when element is not selected.
|
||||
|
||||
.PP
|
||||
\fIdefault\fP: "☐ "
|
||||
|
||||
.SH RETURN VALUE
|
||||
.RS
|
||||
.IP \(bu 2
|
||||
|
|
|
@ -180,6 +180,17 @@ The column separator. This is a regex.
|
|||
|
||||
*default*: '\t'
|
||||
|
||||
`-ballot-selected-str` *string*
|
||||
|
||||
When multi-select is enabled, prefix this string when element is selected.
|
||||
|
||||
*default*: "☑ "
|
||||
|
||||
`-ballot-unselected-str` *string*
|
||||
|
||||
When multi-select is enabled, prefix this string when element is not selected.
|
||||
|
||||
*default*: "☐ "
|
||||
|
||||
## RETURN VALUE
|
||||
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
\fBrofi\fP supports modes that use simple scripts in the background to generate a list and process the result from user
|
||||
actions. This provide a simple interface to make simple extensions to rofi.
|
||||
\fBrofi\fP supports modes that use simple scripts in the background to generate a
|
||||
list and process the result from user actions. This provide a simple interface
|
||||
to make simple extensions to rofi.
|
||||
|
||||
.SH USAGE
|
||||
.PP
|
||||
|
@ -30,10 +31,11 @@ The name should be unique.
|
|||
|
||||
.SH API
|
||||
.PP
|
||||
Rofi calls the executable without arguments on startup. This should generate a list of options, separated by a newline
|
||||
(\fB\fC\\n\fR) (This can be changed by the script).
|
||||
If the user selects an option, rofi calls the executable with the text of that option as the first argument.
|
||||
If the script returns no entries, rofi quits.
|
||||
Rofi calls the executable without arguments on startup. This should generate a
|
||||
list of options, separated by a newline (\fB\fC\\n\fR) (This can be changed by the
|
||||
script). If the user selects an option, rofi calls the executable with the text
|
||||
of that option as the first argument. If the script returns no entries, rofi
|
||||
quits.
|
||||
|
||||
.PP
|
||||
A simple script would be:
|
||||
|
@ -124,7 +126,9 @@ The following extra options exists:
|
|||
.IP \(bu 2
|
||||
\fBuse-hot-keys\fP: If set to true, it enabled the Custom keybindings for script. Warning this breaks the normal rofi flow.
|
||||
.IP \(bu 2
|
||||
\fBkeep-selection\fP: If set, the selection is not moved to the first entry, but the current position is maintained.
|
||||
\fBkeep-selection\fP: If set, the selection is not moved to the first entry, but the current position is maintained. The filter is cleared.
|
||||
.IP \(bu 2
|
||||
\fBnew-selection\fP: If \fB\fCkeep-selection\fR is set, this allows you to override the selected entry (absolute position).
|
||||
.IP \(bu 2
|
||||
\fBdata\fP: Passed data to the next execution of the script via \fBROFI_DATA\fP\&.
|
||||
.IP \(bu 2
|
||||
|
|
|
@ -7,8 +7,9 @@
|
|||
|
||||
## DESCRIPTION
|
||||
|
||||
**rofi** supports modes that use simple scripts in the background to generate a list and process the result from user
|
||||
actions. This provide a simple interface to make simple extensions to rofi.
|
||||
**rofi** supports modes that use simple scripts in the background to generate a
|
||||
list and process the result from user actions. This provide a simple interface
|
||||
to make simple extensions to rofi.
|
||||
|
||||
|
||||
## USAGE
|
||||
|
@ -25,10 +26,11 @@ The name should be unique.
|
|||
|
||||
## API
|
||||
|
||||
Rofi calls the executable without arguments on startup. This should generate a list of options, separated by a newline
|
||||
(`\n`) (This can be changed by the script).
|
||||
If the user selects an option, rofi calls the executable with the text of that option as the first argument.
|
||||
If the script returns no entries, rofi quits.
|
||||
Rofi calls the executable without arguments on startup. This should generate a
|
||||
list of options, separated by a newline (`\n`) (This can be changed by the
|
||||
script). If the user selects an option, rofi calls the executable with the text
|
||||
of that option as the first argument. If the script returns no entries, rofi
|
||||
quits.
|
||||
|
||||
A simple script would be:
|
||||
|
||||
|
@ -88,7 +90,8 @@ The following extra options exists:
|
|||
* **delim**: Set the delimiter for for next rows. Default is '\n' and this option should finish with this. Only call this on first call of script, it is remembered for consecutive calls.
|
||||
* **no-custom**: If set to 'true'; only accept listed entries, ignore custom input.
|
||||
* **use-hot-keys**: If set to true, it enabled the Custom keybindings for script. Warning this breaks the normal rofi flow.
|
||||
* **keep-selection**: If set, the selection is not moved to the first entry, but the current position is maintained.
|
||||
* **keep-selection**: If set, the selection is not moved to the first entry, but the current position is maintained. The filter is cleared.
|
||||
* **new-selection**: If `keep-selection` is set, this allows you to override the selected entry (absolute position).
|
||||
* **data**: Passed data to the next execution of the script via **ROFI_DATA**.
|
||||
* **theme**: Small theme snippet to f.e. change the background color of a widget.
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ If you want to center the text relative to the icon, we can set this:
|
|||
.RS
|
||||
|
||||
.nf
|
||||
element-icon {
|
||||
element-text {
|
||||
vertical-align: 0.5;
|
||||
}
|
||||
|
||||
|
@ -773,9 +773,30 @@ should be applied.
|
|||
.IP \(bu 2
|
||||
\fB\fCitalic\fR: put the highlighted text in script type (slanted).
|
||||
.IP \(bu 2
|
||||
\fB\fCunderline\fR: put a line under the highlighted text.
|
||||
\fB\fCunderline\fR: put a line under the text.
|
||||
.IP \(bu 2
|
||||
\fB\fCstrikethrough\fR: put a line through the highlighted text.
|
||||
\fB\fCstrikethrough\fR: put a line through the text.
|
||||
|
||||
.RE
|
||||
|
||||
.PP
|
||||
The following options are available on pango 1.50.0 and up:
|
||||
|
||||
.RS
|
||||
.IP \(bu 2
|
||||
\fB\fCuppercase\fR: Uppercase the text.
|
||||
.IP \(bu 2
|
||||
\fB\fClowercase\fR: Lowercase the text.
|
||||
|
||||
.RE
|
||||
|
||||
.PP
|
||||
The following option is disabled as pango crashes on this if there is eel
|
||||
upsizing or wrapping. This will be re-enabled once fixed:
|
||||
|
||||
.RS
|
||||
.IP \(bu 2
|
||||
\fB\fCcapitalize\fR: Capitalize the text.
|
||||
|
||||
.RE
|
||||
|
||||
|
@ -1468,6 +1489,8 @@ The offset of the window to the anchor point, allowing you to push the window le
|
|||
.IP \(bu 2
|
||||
\fBtext-color\fP: the text color to use.
|
||||
.IP \(bu 2
|
||||
\fBtext-transform\fP: text style {color} for the whole text.
|
||||
.IP \(bu 2
|
||||
\fBhighlight\fP: text style {color}.
|
||||
color is optional, multiple highlight styles can be added like: bold underline italic #000000;
|
||||
This option is only available on the \fB\fCelement-text\fR widget.
|
||||
|
@ -1529,6 +1552,9 @@ The order the elements are layed out. Vertical is the original 'column' view.
|
|||
.IP \(bu 2
|
||||
\fBfixed-columns\fP: boolean
|
||||
Do not reduce the number of columns shown when number of visible elements is not enough to fill them all.
|
||||
.IP \(bu 2
|
||||
\fBrequire-input\fP: boolean
|
||||
Listview requires user input to show up.
|
||||
|
||||
.RE
|
||||
|
||||
|
@ -2099,6 +2125,54 @@ FontAwesome 22
|
|||
.fi
|
||||
.RE
|
||||
|
||||
.SH Icon Handling
|
||||
.PP
|
||||
Rofi supports 3 ways of specifying an icon:
|
||||
|
||||
.RS
|
||||
.IP \(bu 2
|
||||
Filename
|
||||
.IP \(bu 2
|
||||
icon-name, this is looked up via the icon-theme.
|
||||
.IP \(bu 2
|
||||
Markup String. It renders a string as an icon.
|
||||
|
||||
.RE
|
||||
|
||||
.PP
|
||||
For the first two options, GdkPixbuf is used to open and render the icons.
|
||||
This in general gives support for most required image formats.
|
||||
For the string option it uses Pango to render the string. The string needs to
|
||||
start with a \fB\fC<span\fR tag, that allows you to set color and font.
|
||||
|
||||
.PP
|
||||
Markup string:
|
||||
|
||||
.PP
|
||||
.RS
|
||||
|
||||
.nf
|
||||
echo -en "testing\\0icon\\x1f<span color='red'>⏻</span>" | ./rofi -dmenu
|
||||
|
||||
.fi
|
||||
.RE
|
||||
|
||||
.PP
|
||||
Getting supported icon formats:
|
||||
|
||||
.PP
|
||||
.RS
|
||||
|
||||
.nf
|
||||
G_MESSAGES_DEBUG=Helpers.IconFetcher rofi
|
||||
|
||||
.fi
|
||||
.RE
|
||||
|
||||
.PP
|
||||
This uses the debug framework and prints out a list of supported image file
|
||||
extensions.
|
||||
|
||||
.SH Multiple file handling
|
||||
.PP
|
||||
The rasi file format offers two methods of including other files.
|
||||
|
|
|
@ -116,7 +116,7 @@ list of widget names.
|
|||
If you want to center the text relative to the icon, we can set this:
|
||||
|
||||
```css
|
||||
element-icon {
|
||||
element-text {
|
||||
vertical-align: 0.5;
|
||||
}
|
||||
```
|
||||
|
@ -498,8 +498,18 @@ should be applied.
|
|||
|
||||
* `bold`: make the text thicker then the surrounding text.
|
||||
* `italic`: put the highlighted text in script type (slanted).
|
||||
* `underline`: put a line under the highlighted text.
|
||||
* `strikethrough`: put a line through the highlighted text.
|
||||
* `underline`: put a line under the text.
|
||||
* `strikethrough`: put a line through the text.
|
||||
|
||||
The following options are available on pango 1.50.0 and up:
|
||||
|
||||
* `uppercase`: Uppercase the text.
|
||||
* `lowercase`: Lowercase the text.
|
||||
|
||||
The following option is disabled as pango crashes on this if there is eel
|
||||
upsizing or wrapping. This will be re-enabled once fixed:
|
||||
|
||||
* `capitalize`: Capitalize the text.
|
||||
|
||||
## Line style
|
||||
|
||||
|
@ -912,6 +922,7 @@ The following properties are currently supported:
|
|||
* **vertical-align**: Vertical alignment of the text. A number between 0 (top) and 1 (bottom).
|
||||
* **horizontal-align**: Horizontal alignment of the text. A number between 0 (left) and 1 (right).
|
||||
* **text-color**: the text color to use.
|
||||
* **text-transform**: text style {color} for the whole text.
|
||||
* **highlight**: text style {color}.
|
||||
color is optional, multiple highlight styles can be added like: bold underline italic #000000;
|
||||
This option is only available on the `element-text` widget.
|
||||
|
@ -951,6 +962,8 @@ The following properties are currently supported:
|
|||
The order the elements are layed out. Vertical is the original 'column' view.
|
||||
* **fixed-columns**: boolean
|
||||
Do not reduce the number of columns shown when number of visible elements is not enough to fill them all.
|
||||
* **require-input**: boolean
|
||||
Listview requires user input to show up.
|
||||
|
||||
Each element is a `box` called `element`. Each `element` can contain an `element-icon` and `element-text`.
|
||||
|
||||
|
@ -1342,6 +1355,34 @@ Or
|
|||
FontAwesome 22
|
||||
```
|
||||
|
||||
## Icon Handling
|
||||
|
||||
Rofi supports 3 ways of specifying an icon:
|
||||
|
||||
* Filename
|
||||
* icon-name, this is looked up via the icon-theme.
|
||||
* Markup String. It renders a string as an icon.
|
||||
|
||||
|
||||
For the first two options, GdkPixbuf is used to open and render the icons.
|
||||
This in general gives support for most required image formats.
|
||||
For the string option it uses Pango to render the string. The string needs to
|
||||
start with a `<span` tag, that allows you to set color and font.
|
||||
|
||||
Markup string:
|
||||
|
||||
```bash
|
||||
echo -en "testing\0icon\x1f<span color='red'>⏻</span>" | ./rofi -dmenu
|
||||
```
|
||||
|
||||
Getting supported icon formats:
|
||||
|
||||
```bash
|
||||
G_MESSAGES_DEBUG=Helpers.IconFetcher rofi
|
||||
```
|
||||
This uses the debug framework and prints out a list of supported image file
|
||||
extensions.
|
||||
|
||||
## Multiple file handling
|
||||
|
||||
The rasi file format offers two methods of including other files.
|
||||
|
|
67
doc/rofi.1
67
doc/rofi.1
|
@ -10,9 +10,9 @@
|
|||
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
\fBrofi\fP is an X11 pop-up window switcher, run dialog, dmenu replacement, and more. It focuses on
|
||||
being fast to use and have minimal distraction. It supports keyboard and mouse navigation, type to
|
||||
filter, tokenized search and more.
|
||||
\fBrofi\fP is an X11 pop-up window switcher, run dialog, dmenu replacement, and
|
||||
more. It focuses on being fast to use and have minimal distraction. It supports
|
||||
keyboard and mouse navigation, type to filter, tokenized search and more.
|
||||
|
||||
.SH USAGE
|
||||
.PP
|
||||
|
@ -57,7 +57,8 @@ running firefox, or launch it when it is not running.
|
|||
|
||||
.SS Emulating dmenu
|
||||
.PP
|
||||
\fBrofi\fP can emulate \fBdmenu(1)\fP (a dynamic menu for X11) when launched with the \fB\fC-dmenu\fR flag.
|
||||
\fBrofi\fP can emulate \fBdmenu(1)\fP (a dynamic menu for X11) when launched with
|
||||
the \fB\fC-dmenu\fR flag.
|
||||
|
||||
.PP
|
||||
For more information see \fBrofi-dmenu(5)\fP\&.
|
||||
|
@ -191,8 +192,8 @@ Below is a list of the most important options:
|
|||
\fB\fC-help\fR
|
||||
|
||||
.PP
|
||||
The help option shows the full list of command-line options and the current set values.
|
||||
These include dynamic (run-time generated) options.
|
||||
The help option shows the full list of command-line options and the current set
|
||||
values. These include dynamic (run-time generated) options.
|
||||
|
||||
.PP
|
||||
\fB\fC-version\fR
|
||||
|
@ -277,9 +278,10 @@ See the \fBrofi-dmenu(5)\fP manpage for more information.
|
|||
\fB\fC-show\fR \fImode\fP
|
||||
|
||||
.PP
|
||||
Open \fBrofi\fP in a certain mode. Available modes are \fB\fCwindow\fR, \fB\fCrun\fR, \fB\fCdrun\fR, \fB\fCssh\fR, \fB\fCcombi\fR\&.
|
||||
The special argument \fB\fCkeys\fR can be used to open a searchable list of supported key bindings
|
||||
(see \fIKEY BINDINGS\fP)
|
||||
Open \fBrofi\fP in a certain mode. Available modes are \fB\fCwindow\fR, \fB\fCrun\fR, \fB\fCdrun\fR,
|
||||
\fB\fCssh\fR, \fB\fCcombi\fR\&. The special argument \fB\fCkeys\fR can be used to open a searchable
|
||||
list of supported key bindings
|
||||
(see the \fBrofi-keys(5)\fP manpage)
|
||||
|
||||
.PP
|
||||
To show the run-dialog:
|
||||
|
@ -315,7 +317,8 @@ rofi -modes "run,ssh" -show run
|
|||
.RE
|
||||
|
||||
.PP
|
||||
Custom modes can be added using the internal \fB\fCscript\fR mode. Each such mode has two parameters:
|
||||
Custom modes can be added using the internal \fB\fCscript\fR mode. Each such mode has
|
||||
two parameters:
|
||||
|
||||
.PP
|
||||
.RS
|
||||
|
@ -339,8 +342,8 @@ rofi -modes "window,run,ssh,Workspaces:i3_switch_workspaces.sh" -show Workspaces
|
|||
.RE
|
||||
|
||||
.PP
|
||||
Notes: The i3 window manager dislikes commas in the command when specifying an exec command.
|
||||
For that case, \fB\fC#\fR can be used as a separator.
|
||||
Notes: The i3 window manager dislikes commas in the command when specifying an
|
||||
exec command. For that case, \fB\fC#\fR can be used as a separator.
|
||||
|
||||
.PP
|
||||
\fBTIP\fP: The name is allowed to contain spaces:
|
||||
|
@ -977,6 +980,25 @@ configuration {
|
|||
.fi
|
||||
.RE
|
||||
|
||||
.PP
|
||||
You can hide the currently active window with the 'hide-active-window' setting:
|
||||
|
||||
.PP
|
||||
.RS
|
||||
|
||||
.nf
|
||||
configuration {
|
||||
window {
|
||||
hide-active-window: true;
|
||||
}
|
||||
}
|
||||
|
||||
.fi
|
||||
.RE
|
||||
|
||||
.PP
|
||||
or pass \fB\fC-window-hide-active-window true\fR on command line.
|
||||
|
||||
.SS Combi settings
|
||||
.PP
|
||||
\fB\fC-combi-modes\fR \fImode1\fP,\fImode2\fP
|
||||
|
@ -1163,6 +1185,15 @@ Click the mouse outside the \fBrofi\fP window to exit.
|
|||
.PP
|
||||
Default: \fIenabled\fP
|
||||
|
||||
.PP
|
||||
\fB\fC-xserver-i300-workaround\fR
|
||||
|
||||
.PP
|
||||
Workaround for bug in Xserver. See issue #611 and #1642 on the rofi issue tracker.
|
||||
|
||||
.PP
|
||||
Default: \fIdisabled\fP
|
||||
|
||||
.SH PATTERN
|
||||
.PP
|
||||
To launch commands (for example, when using the ssh launcher), the user can enter the used command-line. The following keys can be used that will be replaced at runtime:
|
||||
|
@ -1330,7 +1361,7 @@ 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.
|
||||
.PP
|
||||
Try using a mono-space font.
|
||||
Try using a mono-space font or tabs + the tab-stops setting..
|
||||
|
||||
.SS The window is completely black.
|
||||
.PP
|
||||
|
@ -1499,7 +1530,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
.SH WEBSITE
|
||||
.PP
|
||||
\fBrofi\fP website can be found here
|
||||
\[la]https://davedavenport.github.io/rofi/\[ra]
|
||||
\[la]https://github.com/davatorium/rofi/\[ra]
|
||||
|
||||
.SH SUPPORT
|
||||
.PP
|
||||
|
@ -1518,11 +1549,11 @@ For more information see \fBrofi-debugging(5)\fP manpage.
|
|||
.SH ISSUE TRACKER
|
||||
.PP
|
||||
The \fBrofi\fP issue tracker can be found here
|
||||
\[la]https://github.com/DaveDavenport/rofi/issues\[ra]
|
||||
|
||||
.PP
|
||||
\[la]https://github.com/davatorium/rofi/issues\[ra]
|
||||
Before creating an issue, consider posting a question on the discussion forum
|
||||
\[la]https://github.com/davatorium/rofi/discussions\[ra] first.
|
||||
When creating an issue, please read this
|
||||
\[la]https://github.com/DaveDavenport/rofi/blob/master/.github/CONTRIBUTING.md\[ra]
|
||||
\[la]https://github.com/davatorium/rofi/blob/master/.github/CONTRIBUTING.md\[ra]
|
||||
first.
|
||||
|
||||
.SH SEE ALSO
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
## DESCRIPTION
|
||||
|
||||
**rofi** is an X11 pop-up window switcher, run dialog, dmenu replacement, and more. It focuses on
|
||||
being fast to use and have minimal distraction. It supports keyboard and mouse navigation, type to
|
||||
filter, tokenized search and more.
|
||||
**rofi** is an X11 pop-up window switcher, run dialog, dmenu replacement, and
|
||||
more. It focuses on being fast to use and have minimal distraction. It supports
|
||||
keyboard and mouse navigation, type to filter, tokenized search and more.
|
||||
|
||||
|
||||
## USAGE
|
||||
|
@ -48,7 +48,8 @@ running firefox, or launch it when it is not running.
|
|||
|
||||
### Emulating dmenu
|
||||
|
||||
**rofi** can emulate **dmenu(1)** (a dynamic menu for X11) when launched with the `-dmenu` flag.
|
||||
**rofi** can emulate **dmenu(1)** (a dynamic menu for X11) when launched with
|
||||
the `-dmenu` flag.
|
||||
|
||||
For more information see **rofi-dmenu(5)**.
|
||||
|
||||
|
@ -122,8 +123,8 @@ Below is a list of the most important options:
|
|||
|
||||
`-help`
|
||||
|
||||
The help option shows the full list of command-line options and the current set values.
|
||||
These include dynamic (run-time generated) options.
|
||||
The help option shows the full list of command-line options and the current set
|
||||
values. These include dynamic (run-time generated) options.
|
||||
|
||||
`-version`
|
||||
|
||||
|
@ -172,9 +173,10 @@ See the **rofi-dmenu(5)** manpage for more information.
|
|||
|
||||
`-show` *mode*
|
||||
|
||||
Open **rofi** in a certain mode. Available modes are `window`, `run`, `drun`, `ssh`, `combi`.
|
||||
The special argument `keys` can be used to open a searchable list of supported key bindings
|
||||
(see *KEY BINDINGS*)
|
||||
Open **rofi** in a certain mode. Available modes are `window`, `run`, `drun`,
|
||||
`ssh`, `combi`. The special argument `keys` can be used to open a searchable
|
||||
list of supported key bindings
|
||||
(see the **rofi-keys(5)** manpage)
|
||||
|
||||
To show the run-dialog:
|
||||
|
||||
|
@ -191,7 +193,8 @@ To only show the `run` and `ssh` launcher:
|
|||
|
||||
rofi -modes "run,ssh" -show run
|
||||
|
||||
Custom modes can be added using the internal `script` mode. Each such mode has two parameters:
|
||||
Custom modes can be added using the internal `script` mode. Each such mode has
|
||||
two parameters:
|
||||
|
||||
<name>:<script>
|
||||
|
||||
|
@ -199,8 +202,8 @@ Example: Have a mode called 'Workspaces' using the `i3_switch_workspaces.sh` scr
|
|||
|
||||
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.
|
||||
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:
|
||||
|
||||
|
@ -592,6 +595,18 @@ configuration {
|
|||
}
|
||||
}
|
||||
```
|
||||
You can hide the currently active window with the 'hide-active-window' setting:
|
||||
|
||||
```css
|
||||
configuration {
|
||||
window {
|
||||
hide-active-window: true;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
or pass `-window-hide-active-window true` on command line.
|
||||
|
||||
|
||||
### Combi settings
|
||||
|
||||
|
@ -719,6 +734,12 @@ Click the mouse outside the **rofi** window to exit.
|
|||
|
||||
Default: *enabled*
|
||||
|
||||
`-xserver-i300-workaround`
|
||||
|
||||
Workaround for bug in Xserver. See issue #611 and #1642 on the rofi issue tracker.
|
||||
|
||||
Default: *disabled*
|
||||
|
||||
## PATTERN
|
||||
|
||||
To launch commands (for example, when using the ssh launcher), the user can enter the used command-line. The following keys can be used that will be replaced at runtime:
|
||||
|
@ -859,7 +880,7 @@ If no match, the input is handled by the first combined modes.
|
|||
|
||||
### The text in the window switcher is not nicely aligned.
|
||||
|
||||
Try using a mono-space font.
|
||||
Try using a mono-space font or tabs + the tab-stops setting..
|
||||
|
||||
### The window is completely black.
|
||||
|
||||
|
@ -949,7 +970,7 @@ been released.
|
|||
|
||||
## WEBSITE
|
||||
|
||||
**rofi** website can be found [here](https://davedavenport.github.io/rofi/)
|
||||
**rofi** website can be found [here](https://github.com/davatorium/rofi/)
|
||||
|
||||
## SUPPORT
|
||||
|
||||
|
@ -964,9 +985,9 @@ For more information see **rofi-debugging(5)** manpage.
|
|||
|
||||
## ISSUE TRACKER
|
||||
|
||||
The **rofi** issue tracker can be found [here](https://github.com/DaveDavenport/rofi/issues)
|
||||
|
||||
When creating an issue, please read [this](https://github.com/DaveDavenport/rofi/blob/master/.github/CONTRIBUTING.md)
|
||||
The **rofi** issue tracker can be found [here](https://github.com/davatorium/rofi/issues)
|
||||
Before creating an issue, consider posting a question on the [discussion forum](https://github.com/davatorium/rofi/discussions) first.
|
||||
When creating an issue, please read [this](https://github.com/davatorium/rofi/blob/master/.github/CONTRIBUTING.md)
|
||||
first.
|
||||
|
||||
## SEE ALSO
|
||||
|
|
|
@ -236,7 +236,7 @@ ALIASES =
|
|||
# A mapping has the form "name=value". For example adding "class=itcl::class"
|
||||
# will allow you to use the command class in the itcl::class meaning.
|
||||
|
||||
TCL_SUBST =
|
||||
# TCL_SUBST =
|
||||
|
||||
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
|
||||
# only. Doxygen will then generate output that is more tailored for C. For
|
||||
|
@ -995,7 +995,7 @@ ALPHABETICAL_INDEX = NO
|
|||
# Minimum value: 1, maximum value: 20, default value: 5.
|
||||
# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
|
||||
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
#COLS_IN_ALPHA_INDEX = 5
|
||||
|
||||
# In case all classes in a project start with a common prefix, all classes will
|
||||
# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
|
||||
|
@ -1599,7 +1599,7 @@ COMPACT_LATEX = NO
|
|||
# The default value is: a4.
|
||||
# This tag requires that the tag GENERATE_LATEX is set to YES.
|
||||
|
||||
PAPER_TYPE = a4wide
|
||||
#PAPER_TYPE = a4wide
|
||||
|
||||
# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names
|
||||
# that should be included in the LaTeX output. To get the times font for
|
||||
|
|
|
@ -49,6 +49,19 @@ PangoAttrList *helper_token_match_get_pango_attr(RofiHighlightColorStyle th,
|
|||
const char *input,
|
||||
PangoAttrList *retv);
|
||||
|
||||
/**
|
||||
* @param retv The Attribute list to update with matches
|
||||
* @param start The start to highlighting.
|
||||
* @param end The end point for the highlight
|
||||
* @param th The RofiHighlightColorStyle
|
||||
*
|
||||
* Creates a set of pango attributes highlighting the matches found in the input
|
||||
* style.
|
||||
*
|
||||
*/
|
||||
void helper_token_match_set_pango_attr_on_style(PangoAttrList *retv, int start,
|
||||
int end,
|
||||
RofiHighlightColorStyle th);
|
||||
/**
|
||||
* @param pfd Pango font description to validate.
|
||||
* @param font The name of the font to check.
|
||||
|
|
|
@ -60,6 +60,7 @@ typedef char *(*_mode_get_display_value)(const Mode *sw,
|
|||
/**
|
||||
* @param sw The #Mode pointer
|
||||
* @param selected_line The selected line
|
||||
* @param height The height of the icon
|
||||
*
|
||||
* Obtains the icon if available
|
||||
*
|
||||
|
@ -67,7 +68,7 @@ typedef char *(*_mode_get_display_value)(const Mode *sw,
|
|||
*/
|
||||
typedef cairo_surface_t *(*_mode_get_icon)(const Mode *sw,
|
||||
unsigned int selected_line,
|
||||
int height);
|
||||
unsigned int height);
|
||||
|
||||
/**
|
||||
* @param sw The #Mode pointer
|
||||
|
@ -81,11 +82,9 @@ typedef char *(*_mode_get_completion)(const Mode *sw,
|
|||
unsigned int selected_line);
|
||||
|
||||
/**
|
||||
* @param data The #Mode pointer
|
||||
* @param tokens List of (input) tokens to match.
|
||||
* @param input The entry to match against.
|
||||
* @param case_sensitive Whether case is significant.
|
||||
* @param index The current selected index.
|
||||
* @param data User data.
|
||||
*
|
||||
* Function prototype for the matching algorithm.
|
||||
*
|
||||
|
|
|
@ -139,7 +139,7 @@ char *mode_get_display_value(const Mode *mode, unsigned int selected_line,
|
|||
* @returns allocated new cairo_surface_t if applicable
|
||||
*/
|
||||
cairo_surface_t *mode_get_icon(Mode *mode, unsigned int selected_line,
|
||||
int height);
|
||||
unsigned int height);
|
||||
|
||||
/**
|
||||
* @param mode The mode to query
|
||||
|
|
|
@ -58,12 +58,16 @@ typedef enum {
|
|||
ROFI_HL_UNDERLINE = 2,
|
||||
/** strikethrough */
|
||||
ROFI_HL_STRIKETHROUGH = 16,
|
||||
/** small caps */
|
||||
ROFI_HL_SMALL_CAPS = 32,
|
||||
/** italic */
|
||||
ROFI_HL_ITALIC = 4,
|
||||
/** color */
|
||||
ROFI_HL_COLOR = 8
|
||||
ROFI_HL_COLOR = 8,
|
||||
/** uppercase */
|
||||
ROFI_HL_UPPERCASE = 32,
|
||||
/** lowercase */
|
||||
ROFI_HL_LOWERCASE = 64,
|
||||
/** capitalize */
|
||||
ROFI_HL_CAPITALIZE = 128
|
||||
} RofiHighlightStyle;
|
||||
|
||||
/** Style of line */
|
||||
|
|
|
@ -75,6 +75,18 @@ void rofi_add_error_message(GString *str);
|
|||
* Clear the list of stored error messages.
|
||||
*/
|
||||
void rofi_clear_error_messages(void);
|
||||
|
||||
/**
|
||||
* @param str A GString with an warning message to display.
|
||||
*
|
||||
* Queue an warning.
|
||||
*/
|
||||
void rofi_add_warning_message(GString *str);
|
||||
|
||||
/**
|
||||
* Clear the list of stored warning messages.
|
||||
*/
|
||||
void rofi_clear_warning_messages(void);
|
||||
/**
|
||||
* @param code the code to return
|
||||
*
|
||||
|
|
|
@ -189,6 +189,9 @@ typedef struct {
|
|||
/** refilter timeout limit, when more then these entries,go into timeout mode.
|
||||
*/
|
||||
unsigned int refilter_timeout_limit;
|
||||
|
||||
/** workaround for broken xserver (#300 on xserver, #611) */
|
||||
gboolean xserver_i300_workaround;
|
||||
} Settings;
|
||||
|
||||
/** Default number of lines in the list view */
|
||||
|
|
|
@ -144,7 +144,7 @@ void rofi_theme_property_free(Property *p);
|
|||
*
|
||||
* @returns a copy of p
|
||||
*/
|
||||
Property *rofi_theme_property_copy(const Property *p);
|
||||
Property *rofi_theme_property_copy(const Property *p, void *);
|
||||
/**
|
||||
* @param widget
|
||||
*
|
||||
|
|
|
@ -54,8 +54,6 @@ typedef enum {
|
|||
MENU_NORMAL_WINDOW = 2,
|
||||
/** ERROR dialog */
|
||||
MENU_ERROR_DIALOG = 4,
|
||||
/** INDICATOR */
|
||||
MENU_INDICATOR = 8,
|
||||
} MenuFlags;
|
||||
|
||||
/**
|
||||
|
|
|
@ -55,6 +55,7 @@ typedef enum {
|
|||
|
||||
/**
|
||||
* @param tb The textbox to set
|
||||
* @param ico The icon to set
|
||||
* @param entry The position of the textbox
|
||||
* @param udata User data
|
||||
* @param type The textbox font style to apply to this entry (normal, selected,
|
||||
|
@ -230,13 +231,6 @@ void listview_set_scroll_type(listview *lv, ScrollType type);
|
|||
void listview_set_mouse_activated_cb(listview *lv,
|
||||
listview_mouse_activated_cb cb,
|
||||
void *udata);
|
||||
/**
|
||||
* @param lv Handler to the listview object
|
||||
* @param enable boolean to enable/disable multi-select
|
||||
*
|
||||
* Enable,disable multi-select.
|
||||
*/
|
||||
void listview_set_multi_select(listview *lv, gboolean enable);
|
||||
/**
|
||||
* @param lv Handler to the listview object.
|
||||
* @param num_lines the maximum number of lines to display.
|
||||
|
|
|
@ -92,7 +92,6 @@ typedef enum {
|
|||
TB_MARKUP = 1 << 20,
|
||||
TB_WRAP = 1 << 21,
|
||||
TB_PASSWORD = 1 << 22,
|
||||
TB_INDICATOR = 1 << 23,
|
||||
} TextboxFlags;
|
||||
/**
|
||||
* Flags indicating current state of the textbox.
|
||||
|
|
|
@ -85,8 +85,8 @@ typedef enum {
|
|||
/**
|
||||
* @param widget The container widget itself
|
||||
* @param type The widget type searched for
|
||||
* @param x The X coordination of the mouse event relative to @param widget
|
||||
* @param y The Y coordination of the mouse event relative to @param widget
|
||||
* @param x The X coordination of the mouse event relative to #widget
|
||||
* @param y The Y coordination of the mouse event relative to #widget
|
||||
*
|
||||
* This callback must only iterate over the children of a Widget, and return
|
||||
* NULL if none of them is relevant.
|
||||
|
@ -99,8 +99,8 @@ typedef widget *(*widget_find_mouse_target_cb)(widget *widget, WidgetType type,
|
|||
/**
|
||||
* @param widget The target widget
|
||||
* @param action The action value (which enum it is depends on the widget type)
|
||||
* @param x The X coordination of the mouse event relative to @param widget
|
||||
* @param y The Y coordination of the mouse event relative to @param widget
|
||||
* @param x The X coordination of the mouse event relative to #widget
|
||||
* @param y The Y coordination of the mouse event relative to #widget
|
||||
* @param user_data The data passed to widget_set_trigger_action_handler()
|
||||
*
|
||||
* This callback should handle the action if relevant, and returns whether it
|
||||
|
|
|
@ -219,7 +219,9 @@ BOLD (?i:bold)
|
|||
UNDERLINE (?i:underline)
|
||||
ITALIC (?i:italic)
|
||||
STRIKETHROUGH (?i:strikethrough)
|
||||
SMALLCAPS (?i:small\ caps)
|
||||
UPPERCASE (?i:uppercase)
|
||||
LOWERCASE (?i:lowercase)
|
||||
CAPITALIZE (?i:capitalize)
|
||||
|
||||
/* ANGLES */
|
||||
|
||||
|
@ -729,7 +731,9 @@ if ( queue == NULL ) {
|
|||
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{ITALIC} { return T_ITALIC; }
|
||||
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{UNDERLINE} { return T_UNDERLINE; }
|
||||
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{STRIKETHROUGH} { return T_STRIKETHROUGH; }
|
||||
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{SMALLCAPS} { return T_SMALLCAPS; }
|
||||
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{UPPERCASE} { return T_UPPERCASE; }
|
||||
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{LOWERCASE} { return T_LOWERCASE; }
|
||||
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{CAPITALIZE} { return T_CAPITALIZE; }
|
||||
|
||||
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{ANGLE_DEG} { return T_ANGLE_DEG; }
|
||||
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{ANGLE_RAD} { return T_ANGLE_RAD; }
|
||||
|
|
|
@ -185,9 +185,11 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b )
|
|||
%token T_ITALIC "Italic"
|
||||
%token T_UNDERLINE "Underline"
|
||||
%token T_STRIKETHROUGH "Strikethrough"
|
||||
%token T_SMALLCAPS "Small CAPS"
|
||||
%token T_DASH "Dash"
|
||||
%token T_SOLID "Solid"
|
||||
%token T_UPPERCASE "Uppercase"
|
||||
%token T_CAPITALIZE "Capitalize"
|
||||
%token T_LOWERCASE "Lowercase"
|
||||
|
||||
%token T_UNIT_PX "pixels"
|
||||
%token T_UNIT_MM "mm"
|
||||
|
@ -762,7 +764,9 @@ t_property_highlight_style
|
|||
| T_UNDERLINE { $$ = ROFI_HL_UNDERLINE; }
|
||||
| T_STRIKETHROUGH { $$ = ROFI_HL_STRIKETHROUGH; }
|
||||
| T_ITALIC { $$ = ROFI_HL_ITALIC; }
|
||||
| T_SMALLCAPS { $$ = ROFI_HL_SMALL_CAPS; }
|
||||
| T_UPPERCASE { $$ = ROFI_HL_UPPERCASE; }
|
||||
| T_LOWERCASE { $$ = ROFI_HL_LOWERCASE; }
|
||||
| T_CAPITALIZE { $$ = ROFI_HL_CAPITALIZE; }
|
||||
;
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
project('rofi', 'c',
|
||||
version: '1.7.3+wayland1-dev',
|
||||
version: '1.7.4+wayland1',
|
||||
meson_version: '>=0.47.0',
|
||||
license: [ 'MIT' ],
|
||||
default_options: [
|
||||
|
@ -22,6 +22,7 @@ flags = [
|
|||
'-Wunreachable-code',
|
||||
'-Werror=missing-prototypes',
|
||||
'-Wno-inline', # A bit too noisy with Bison…
|
||||
'-Wextra'
|
||||
]
|
||||
foreach f : flags
|
||||
if c_compiler.has_argument(f)
|
||||
|
|
BIN
releasenotes/1.7.4/horizontal.png
Normal file
BIN
releasenotes/1.7.4/horizontal.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
|
@ -1,41 +1,108 @@
|
|||
# 1.7.4:
|
||||
# 1.7.4: Preshellected Optimizations
|
||||
|
||||
Another maintenance and small features expansion release. A lot of small
|
||||
annoyances have been fixed and ignored errors are now more visually flagged to
|
||||
the user. In the past typos in the theme could result into broken themes
|
||||
without any warning to the user, if an unknown link is found it will now throw
|
||||
an error. Also to help the user, manpages are further split up into sub-pages
|
||||
and are expanded
|
||||
without any warning to the user (except in debug mode), if an unknown link is
|
||||
found it will now throw an error. To help the user find the right
|
||||
documentation, the manpages are further split up into sub-pages and are
|
||||
expanded
|
||||
|
||||
A massif speedup has been implemented in the async input reading of dmenu.
|
||||
It turned out glib's GInputStream async functions where very slow, so a custom
|
||||
implementation has been made. Background loading is now close to the same speed
|
||||
as loading at start before displaying. A million item list is now near instant.
|
||||
On very large lists, the instant filtering automatically changes to be
|
||||
postponed until the user stops typing. This severely reduces system load.
|
||||
We now have:
|
||||
|
||||
On the new feature front, you can now change the flow in the listview from
|
||||
vertical first to horizontal first. Making it mimic tables.
|
||||
* rofi(1)
|
||||
* rofi-theme-selector(1)
|
||||
* rofi-keys(5)
|
||||
* rofi-theme(5)
|
||||
* rofi-debugging(5)
|
||||
* rofi-dmenu(5)
|
||||
* rofi-script(5)
|
||||
|
||||
{screenshot vertical } { screenshot horizontal }
|
||||
Another improvement made that can have huge impact on the user-experience is a
|
||||
significant speedup in the async input reading of dmenu. It turned out glib's
|
||||
GInputStream async methods are very slow. On large input sets where it was
|
||||
supposed to improve the user experience, it made it unusable. To resolve this a
|
||||
custom implementation has been made. Background loading is now close to the
|
||||
same speed as loading at start before displaying. A million item list is now
|
||||
near instant. On very large lists, the instant filtering automatically changes
|
||||
to be postponed until the user stops typing. This severely reduces system load
|
||||
and interface blocking.
|
||||
|
||||
You can now set a fallback icon individual for each mode.
|
||||
A few long standing feature requests and bug reports have been implemented or fixed:
|
||||
|
||||
You can now add a separate icon or textbox widget to the UI that displays the
|
||||
current selected item.
|
||||
* Listview flow. You can now change the flow in the listview from vertical first
|
||||
to horizontal first. Making it mimic tables.
|
||||
|
||||
In dmenu mode (and script) you can now make (some) changes to the theme, for
|
||||
example modifying the background color of the entry box.
|
||||
```bash
|
||||
for i in {1..90}; do echo $i; done | rofi -dmenu -no-config -theme-str 'listview { columns: 3; flow: vertical; }'
|
||||
```
|
||||
![Vertical](./vertical.png)
|
||||
|
||||
You can now put users scripts (for script mode) into
|
||||
`$XDG_CONFIG_HOME/rofi/scripts` directory and those are automatically available
|
||||
in rofi.
|
||||
```bash
|
||||
for i in {1..90}; do echo $i; done | rofi -dmenu -no-config -theme-str 'listview { columns: 3; flow: horizontal; }'
|
||||
```
|
||||
![Horizontal](./horizontal.png)
|
||||
|
||||
* You can set a custom fallback icon for each mode.
|
||||
|
||||
```css
|
||||
configuration {
|
||||
run,drun {
|
||||
fallback-icon: "application-x-addon";
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* In dmenu mode (and script) you can now make (some) changes to the theme, for
|
||||
example modifying the background color of the entry box.
|
||||
|
||||
```bash
|
||||
echo -en "\0theme\x1felement-text { background-color: red;}\n"
|
||||
```
|
||||
|
||||
* User scripts (for script mode) into `$XDG_CONFIG_HOME/rofi/scripts` directory
|
||||
are automatically available in rofi.
|
||||
|
||||
```bash
|
||||
rofi -h
|
||||
<snip>
|
||||
Detected user scripts:
|
||||
• hc (/home/qball/.config/rofi/scripts/hc.sh)
|
||||
</snip>
|
||||
```
|
||||
|
||||
This script can now by shows by running `rofi -show hc`.
|
||||
|
||||
* You can now render text as icons, this allows you to use glyphs icon fonts as
|
||||
icons.
|
||||
|
||||
```bash
|
||||
echo -en "testing\0icon\x1f<span color='green'>Test</span>" | rofi -dmenu
|
||||
```
|
||||
|
||||
* Hide listview when unfiltered. (#1079)
|
||||
|
||||
```css
|
||||
listview {
|
||||
require-input: true;
|
||||
}
|
||||
```
|
||||
|
||||
* You can now add a separate icon or textbox widget to the UI that displays the
|
||||
current selected item. As an example see the included `sidebar-v2`.
|
||||
|
||||
* A bug was fixed that caused problems with newer xkeyboard-config versions and
|
||||
different keyboard layouts.
|
||||
|
||||
Below is a more complete list of changes:
|
||||
|
||||
# Changelog
|
||||
|
||||
* [Doc] Add `-config` to `-help` output. (#1665)
|
||||
* [Dmenu] Fix multi-select, use text as indicator.
|
||||
* [filebrowser] Fix building on Mac. (#1662,#1663)
|
||||
* [textbox] Implement text-transform option. (#1010)
|
||||
* [script] Add `new-selection` (#1064).
|
||||
* [Script] Add keep-selection flag that keeps the current selection. (#1064)
|
||||
* [Debug] Add '-log' flag to redirect debug output to a file.
|
||||
* [XCB] Try to deduce rotated monitors.
|
||||
|
@ -67,6 +134,9 @@ Below is a more complete list of changes:
|
|||
* Change modi to modes to avoid confusion.
|
||||
* [Theme] When links are unresolvable throw an error to the user.
|
||||
* [DMenu] Document the `display-columns` and `display-column-separator` option.
|
||||
* [Theme] Media now supports `enabled` that supports an environment variable.
|
||||
* [IconFetcher] Support rendering fonts as icon.
|
||||
* [xcb] Remove work-around to fix use with new xkeyboard-config (#1642)
|
||||
|
||||
# Thanks
|
||||
|
||||
|
|
BIN
releasenotes/1.7.4/vertical.png
Normal file
BIN
releasenotes/1.7.4/vertical.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
117
source/helper.c
117
source/helper.c
|
@ -414,6 +414,75 @@ int find_arg_char(const char *const key, char *val) {
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void helper_token_match_set_pango_attr_on_style(PangoAttrList *retv, int start,
|
||||
int end,
|
||||
RofiHighlightColorStyle th) {
|
||||
if (th.style & ROFI_HL_BOLD) {
|
||||
PangoAttribute *pa = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
|
||||
pa->start_index = start;
|
||||
pa->end_index = end;
|
||||
pango_attr_list_insert(retv, pa);
|
||||
}
|
||||
#if PANGO_VERSION_CHECK(1, 50, 0)
|
||||
if (th.style & ROFI_HL_UPPERCASE) {
|
||||
PangoAttribute *pa =
|
||||
pango_attr_text_transform_new(PANGO_TEXT_TRANSFORM_UPPERCASE);
|
||||
pa->start_index = start;
|
||||
pa->end_index = end;
|
||||
pango_attr_list_insert(retv, pa);
|
||||
}
|
||||
if (th.style & ROFI_HL_LOWERCASE) {
|
||||
PangoAttribute *pa =
|
||||
pango_attr_text_transform_new(PANGO_TEXT_TRANSFORM_LOWERCASE);
|
||||
pa->start_index = start;
|
||||
pa->end_index = end;
|
||||
pango_attr_list_insert(retv, pa);
|
||||
}
|
||||
if (th.style & ROFI_HL_CAPITALIZE) {
|
||||
#if 0
|
||||
PangoAttribute *pa =
|
||||
pango_attr_text_transform_new(PANGO_TEXT_TRANSFORM_CAPITALIZE);
|
||||
pa->start_index = start;
|
||||
pa->end_index = end;
|
||||
pango_attr_list_insert(retv, pa);
|
||||
#endif
|
||||
// Disabled because of bug in pango
|
||||
}
|
||||
#endif
|
||||
if (th.style & ROFI_HL_UNDERLINE) {
|
||||
PangoAttribute *pa = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
|
||||
pa->start_index = start;
|
||||
pa->end_index = end;
|
||||
pango_attr_list_insert(retv, pa);
|
||||
}
|
||||
if (th.style & ROFI_HL_STRIKETHROUGH) {
|
||||
PangoAttribute *pa = pango_attr_strikethrough_new(TRUE);
|
||||
pa->start_index = start;
|
||||
pa->end_index = end;
|
||||
pango_attr_list_insert(retv, pa);
|
||||
}
|
||||
if (th.style & ROFI_HL_ITALIC) {
|
||||
PangoAttribute *pa = pango_attr_style_new(PANGO_STYLE_ITALIC);
|
||||
pa->start_index = start;
|
||||
pa->end_index = end;
|
||||
pango_attr_list_insert(retv, pa);
|
||||
}
|
||||
if (th.style & ROFI_HL_COLOR) {
|
||||
PangoAttribute *pa = pango_attr_foreground_new(
|
||||
th.color.red * 65535, th.color.green * 65535, th.color.blue * 65535);
|
||||
pa->start_index = start;
|
||||
pa->end_index = end;
|
||||
pango_attr_list_insert(retv, pa);
|
||||
|
||||
if (th.color.alpha < 1.0) {
|
||||
pa = pango_attr_foreground_alpha_new(th.color.alpha * 65535);
|
||||
pa->start_index = start;
|
||||
pa->end_index = end;
|
||||
pango_attr_list_insert(retv, pa);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PangoAttrList *helper_token_match_get_pango_attr(RofiHighlightColorStyle th,
|
||||
rofi_int_matcher **tokens,
|
||||
const char *input,
|
||||
|
@ -435,53 +504,7 @@ PangoAttrList *helper_token_match_get_pango_attr(RofiHighlightColorStyle th,
|
|||
for (int index = (count > 1) ? 1 : 0; index < count; index++) {
|
||||
int start, end;
|
||||
g_match_info_fetch_pos(gmi, index, &start, &end);
|
||||
if (th.style & ROFI_HL_BOLD) {
|
||||
PangoAttribute *pa = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
|
||||
pa->start_index = start;
|
||||
pa->end_index = end;
|
||||
pango_attr_list_insert(retv, pa);
|
||||
}
|
||||
if (th.style & ROFI_HL_UNDERLINE) {
|
||||
PangoAttribute *pa =
|
||||
pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
|
||||
pa->start_index = start;
|
||||
pa->end_index = end;
|
||||
pango_attr_list_insert(retv, pa);
|
||||
}
|
||||
if (th.style & ROFI_HL_STRIKETHROUGH) {
|
||||
PangoAttribute *pa = pango_attr_strikethrough_new(TRUE);
|
||||
pa->start_index = start;
|
||||
pa->end_index = end;
|
||||
pango_attr_list_insert(retv, pa);
|
||||
}
|
||||
if (th.style & ROFI_HL_SMALL_CAPS) {
|
||||
PangoAttribute *pa =
|
||||
pango_attr_variant_new(PANGO_VARIANT_SMALL_CAPS);
|
||||
pa->start_index = start;
|
||||
pa->end_index = end;
|
||||
pango_attr_list_insert(retv, pa);
|
||||
}
|
||||
if (th.style & ROFI_HL_ITALIC) {
|
||||
PangoAttribute *pa = pango_attr_style_new(PANGO_STYLE_ITALIC);
|
||||
pa->start_index = start;
|
||||
pa->end_index = end;
|
||||
pango_attr_list_insert(retv, pa);
|
||||
}
|
||||
if (th.style & ROFI_HL_COLOR) {
|
||||
PangoAttribute *pa = pango_attr_foreground_new(
|
||||
th.color.red * 65535, th.color.green * 65535,
|
||||
th.color.blue * 65535);
|
||||
pa->start_index = start;
|
||||
pa->end_index = end;
|
||||
pango_attr_list_insert(retv, pa);
|
||||
|
||||
if (th.color.alpha < 1.0) {
|
||||
pa = pango_attr_foreground_alpha_new(th.color.alpha * 65535);
|
||||
pa->start_index = start;
|
||||
pa->end_index = end;
|
||||
pango_attr_list_insert(retv, pa);
|
||||
}
|
||||
}
|
||||
helper_token_match_set_pango_attr_on_style(retv, start, end, th);
|
||||
}
|
||||
g_match_info_next(gmi, NULL);
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ char *mode_get_display_value(const Mode *mode, unsigned int selected_line,
|
|||
}
|
||||
|
||||
cairo_surface_t *mode_get_icon(Mode *mode, unsigned int selected_line,
|
||||
int height) {
|
||||
unsigned int height) {
|
||||
g_assert(mode != NULL);
|
||||
|
||||
if (mode->_get_icon != NULL) {
|
||||
|
|
|
@ -277,7 +277,7 @@ static char *combi_get_completion(const Mode *sw, unsigned int index) {
|
|||
}
|
||||
|
||||
static cairo_surface_t *combi_get_icon(const Mode *sw, unsigned int index,
|
||||
int height) {
|
||||
unsigned int height) {
|
||||
CombiModePrivateData *pd = mode_get_private_data(sw);
|
||||
for (unsigned i = 0; i < pd->num_switchers; i++) {
|
||||
if (index >= pd->starts[i] && index < (pd->starts[i] + pd->lengths[i])) {
|
||||
|
|
|
@ -56,8 +56,8 @@
|
|||
static int dmenu_mode_init(Mode *sw);
|
||||
static int dmenu_token_match(const Mode *sw, rofi_int_matcher **tokens,
|
||||
unsigned int index);
|
||||
static cairo_surface_t *dmenu_get_icon(const Mode *sw,
|
||||
unsigned int selected_line, int height);
|
||||
static cairo_surface_t *
|
||||
dmenu_get_icon(const Mode *sw, unsigned int selected_line, unsigned int height);
|
||||
static char *dmenu_get_message(const Mode *sw);
|
||||
|
||||
static inline unsigned int bitget(uint32_t const *const array,
|
||||
|
@ -108,6 +108,9 @@ typedef struct {
|
|||
int pipefd2[2];
|
||||
guint wake_source;
|
||||
gboolean loading;
|
||||
|
||||
char *ballot_selected;
|
||||
char *ballot_unselected;
|
||||
} DmenuModePrivateData;
|
||||
|
||||
#define BLOCK_LINES_SIZE 2048
|
||||
|
@ -192,9 +195,13 @@ static gboolean dmenu_async_read_proc(gint fd, GIOCondition condition,
|
|||
gpointer user_data) {
|
||||
DmenuModePrivateData *pd = (DmenuModePrivateData *)user_data;
|
||||
char command;
|
||||
// Only interrested in read events.
|
||||
if ((condition & G_IO_IN) != G_IO_IN) {
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
// Read the entry from the pipe that was used to signal this action.
|
||||
if (read(fd, &command, 1) == 1) {
|
||||
if ( command == 'r' ){
|
||||
if (command == 'r') {
|
||||
Block *block = NULL;
|
||||
gboolean changed = FALSE;
|
||||
// Empty out the AsyncQueue (that is thread safe) from all blocks pushed
|
||||
|
@ -204,10 +211,10 @@ static gboolean dmenu_async_read_proc(gint fd, GIOCondition condition,
|
|||
if (pd->cmd_list_real_length < (pd->cmd_list_length + block->length)) {
|
||||
pd->cmd_list_real_length = MAX(pd->cmd_list_real_length * 2, 4096);
|
||||
pd->cmd_list = g_realloc(pd->cmd_list, sizeof(DmenuScriptEntry) *
|
||||
pd->cmd_list_real_length);
|
||||
pd->cmd_list_real_length);
|
||||
}
|
||||
memcpy(&(pd->cmd_list[pd->cmd_list_length]), &(block->values[0]),
|
||||
sizeof(DmenuScriptEntry) * block->length);
|
||||
sizeof(DmenuScriptEntry) * block->length);
|
||||
pd->cmd_list_length += block->length;
|
||||
g_free(block);
|
||||
changed = TRUE;
|
||||
|
@ -215,8 +222,8 @@ static gboolean dmenu_async_read_proc(gint fd, GIOCondition condition,
|
|||
if (changed) {
|
||||
rofi_view_reload();
|
||||
}
|
||||
} else if ( command == 'q' ){
|
||||
if ( pd->loading ) {
|
||||
} else if (command == 'q') {
|
||||
if (pd->loading) {
|
||||
rofi_view_set_overlay(rofi_view_get_active(), NULL);
|
||||
}
|
||||
}
|
||||
|
@ -239,7 +246,7 @@ static void read_input_sync(DmenuModePrivateData *pd, unsigned int pre_read) {
|
|||
static gpointer read_input_thread(gpointer userdata) {
|
||||
DmenuModePrivateData *pd = (DmenuModePrivateData *)userdata;
|
||||
ssize_t nread = 0;
|
||||
size_t len = 0;
|
||||
ssize_t len = 0;
|
||||
char *line = NULL;
|
||||
// Create the message passing queue to the UI thread.
|
||||
pd->async_queue = g_async_queue_new();
|
||||
|
@ -276,7 +283,7 @@ static gpointer read_input_thread(gpointer userdata) {
|
|||
if (readbytes > 0) {
|
||||
nread += readbytes;
|
||||
line[nread] = '\0';
|
||||
size_t i = 0;
|
||||
ssize_t i = 0;
|
||||
while (i < nread) {
|
||||
if (line[i] == pd->separator) {
|
||||
line[i] = '\0';
|
||||
|
@ -334,8 +341,17 @@ static unsigned int dmenu_mode_get_num_entries(const Mode *sw) {
|
|||
}
|
||||
|
||||
static gchar *dmenu_format_output_string(const DmenuModePrivateData *pd,
|
||||
const char *input) {
|
||||
const char *input,
|
||||
const unsigned int index,
|
||||
gboolean multi_select) {
|
||||
if (pd->columns == NULL) {
|
||||
if (multi_select) {
|
||||
if (pd->selected_list && bitget(pd->selected_list, index) == TRUE) {
|
||||
return g_strdup_printf("%s%s", pd->ballot_selected, input);
|
||||
} else {
|
||||
return g_strdup_printf("%s%s", pd->ballot_unselected, input);
|
||||
}
|
||||
}
|
||||
return g_strdup(input);
|
||||
}
|
||||
char *retv = NULL;
|
||||
|
@ -346,6 +362,14 @@ static gchar *dmenu_format_output_string(const DmenuModePrivateData *pd,
|
|||
;
|
||||
}
|
||||
GString *str_retv = g_string_new("");
|
||||
|
||||
if (multi_select) {
|
||||
if (pd->selected_list && bitget(pd->selected_list, index) == TRUE) {
|
||||
g_string_append(str_retv, pd->ballot_selected);
|
||||
} else {
|
||||
g_string_append(str_retv, pd->ballot_unselected);
|
||||
}
|
||||
}
|
||||
for (uint32_t i = 0; pd->columns && pd->columns[i]; i++) {
|
||||
unsigned int index =
|
||||
(unsigned int)g_ascii_strtoull(pd->columns[i], NULL, 10);
|
||||
|
@ -375,6 +399,13 @@ static inline unsigned int get_index(unsigned int length, int index) {
|
|||
return UINT_MAX;
|
||||
}
|
||||
|
||||
static char *dmenu_get_completion_data(const Mode *data, unsigned int index) {
|
||||
Mode *sw = (Mode *)data;
|
||||
DmenuModePrivateData *pd = (DmenuModePrivateData *)mode_get_private_data(sw);
|
||||
DmenuScriptEntry *retv = (DmenuScriptEntry *)pd->cmd_list;
|
||||
return dmenu_format_output_string(pd, retv[index].entry, index, FALSE);
|
||||
}
|
||||
|
||||
static char *get_display_data(const Mode *data, unsigned int index, int *state,
|
||||
G_GNUC_UNUSED GList **list, int get_entry) {
|
||||
Mode *sw = (Mode *)data;
|
||||
|
@ -403,7 +434,9 @@ static char *get_display_data(const Mode *data, unsigned int index, int *state,
|
|||
*state |= MARKUP;
|
||||
}
|
||||
char *my_retv =
|
||||
(get_entry ? dmenu_format_output_string(pd, retv[index].entry) : NULL);
|
||||
(get_entry ? dmenu_format_output_string(pd, retv[index].entry, index,
|
||||
pd->multi_select)
|
||||
: NULL);
|
||||
return my_retv;
|
||||
}
|
||||
|
||||
|
@ -443,7 +476,7 @@ Mode dmenu_mode = {.name = "dmenu",
|
|||
._token_match = dmenu_token_match,
|
||||
._get_display_value = get_display_data,
|
||||
._get_icon = dmenu_get_icon,
|
||||
._get_completion = NULL,
|
||||
._get_completion = dmenu_get_completion_data,
|
||||
._preprocess_input = NULL,
|
||||
._get_message = dmenu_get_message,
|
||||
.private_data = NULL,
|
||||
|
@ -632,7 +665,8 @@ static char *dmenu_get_message(const Mode *sw) {
|
|||
return NULL;
|
||||
}
|
||||
static cairo_surface_t *dmenu_get_icon(const Mode *sw,
|
||||
unsigned int selected_line, int height) {
|
||||
unsigned int selected_line,
|
||||
unsigned int height) {
|
||||
DmenuModePrivateData *pd = (DmenuModePrivateData *)mode_get_private_data(sw);
|
||||
|
||||
g_return_val_if_fail(pd->cmd_list != NULL, NULL);
|
||||
|
@ -650,7 +684,8 @@ static cairo_surface_t *dmenu_get_icon(const Mode *sw,
|
|||
return rofi_icon_fetcher_get(uid);
|
||||
}
|
||||
|
||||
static void dmenu_finish(DmenuModePrivateData *pd, RofiViewState *state, int retv) {
|
||||
static void dmenu_finish(DmenuModePrivateData *pd, RofiViewState *state,
|
||||
int retv) {
|
||||
|
||||
if (pd->reading_thread) {
|
||||
// Stop listinig to new messages from reading thread.
|
||||
|
@ -779,7 +814,7 @@ static void dmenu_finalize(RofiViewState *state) {
|
|||
rofi_view_restart(state);
|
||||
rofi_view_set_selected_line(state, pd->selected_line);
|
||||
if (!restart) {
|
||||
dmenu_finish(pd,state, retv);
|
||||
dmenu_finish(pd, state, retv);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -835,7 +870,7 @@ static void dmenu_finalize(RofiViewState *state) {
|
|||
rofi_view_restart(state);
|
||||
rofi_view_set_selected_line(state, pd->selected_line);
|
||||
} else {
|
||||
dmenu_finish(pd,state, retv);
|
||||
dmenu_finish(pd, state, retv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -850,8 +885,11 @@ int dmenu_mode_dialog(void) {
|
|||
|
||||
pd->only_selected = FALSE;
|
||||
pd->multi_select = FALSE;
|
||||
pd->ballot_selected = "☑ ";
|
||||
pd->ballot_unselected = "☐ ";
|
||||
find_arg_str("-ballot-selected-str", &(pd->ballot_selected));
|
||||
find_arg_str("-ballot-unselected-str", &(pd->ballot_unselected));
|
||||
if (find_arg("-multi-select") >= 0) {
|
||||
menu_flags = MENU_INDICATOR;
|
||||
pd->multi_select = TRUE;
|
||||
}
|
||||
if (find_arg("-markup-rows") >= 0) {
|
||||
|
@ -958,8 +996,16 @@ void print_dmenu_options(void) {
|
|||
print_help_msg("-w", "windowid", "Position over window with X11 windowid.",
|
||||
NULL, is_term);
|
||||
print_help_msg("-keep-right", "", "Set ellipsize to end.", NULL, is_term);
|
||||
print_help_msg("--display-columns", "", "Only show the selected columns",
|
||||
NULL, is_term);
|
||||
print_help_msg("--display-column-separator", "\t",
|
||||
print_help_msg("-display-columns", "", "Only show the selected columns", NULL,
|
||||
is_term);
|
||||
print_help_msg("-display-column-separator", "\t",
|
||||
"Separator to use to split columns (regex)", NULL, is_term);
|
||||
print_help_msg("-ballot-selected-str", "\t",
|
||||
"When multi-select is enabled prefix this string when element "
|
||||
"is selected.",
|
||||
NULL, is_term);
|
||||
print_help_msg("-ballot-unselected-str", "\t",
|
||||
"When multi-select is enabled prefix this string when element "
|
||||
"is not selected.",
|
||||
NULL, is_term);
|
||||
}
|
||||
|
|
|
@ -1329,7 +1329,7 @@ static char *_get_display_value(const Mode *sw, unsigned int selected_line,
|
|||
}
|
||||
|
||||
static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line,
|
||||
int height) {
|
||||
unsigned int height) {
|
||||
DRunModePrivateData *pd = (DRunModePrivateData *)mode_get_private_data(sw);
|
||||
if (pd->file_complete) {
|
||||
return pd->completer->_get_icon(pd->completer, selected_line, height);
|
||||
|
|
|
@ -50,6 +50,12 @@
|
|||
|
||||
#define FILEBROWSER_CACHE_FILE "rofi3.filebrowsercache"
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#define st_atim st_atimespec
|
||||
#define st_ctim st_ctimespec
|
||||
#define st_mtim st_mtimespec
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The internal data structure holding the private data of the TEST Mode.
|
||||
*/
|
||||
|
@ -561,7 +567,7 @@ static int file_browser_token_match(const Mode *sw, rofi_int_matcher **tokens,
|
|||
}
|
||||
|
||||
static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line,
|
||||
int height) {
|
||||
unsigned int height) {
|
||||
FileBrowserModePrivateData *pd =
|
||||
(FileBrowserModePrivateData *)mode_get_private_data(sw);
|
||||
g_return_val_if_fail(pd->array != NULL, NULL);
|
||||
|
|
|
@ -534,7 +534,7 @@ static char *run_get_message(const Mode *sw) {
|
|||
return NULL;
|
||||
}
|
||||
static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line,
|
||||
int height) {
|
||||
unsigned int height) {
|
||||
RunModePrivateData *pd = (RunModePrivateData *)mode_get_private_data(sw);
|
||||
if (pd->file_complete) {
|
||||
return pd->completer->_get_icon(pd->completer, selected_line, height);
|
||||
|
|
|
@ -68,6 +68,7 @@ typedef struct {
|
|||
char *data;
|
||||
gboolean do_markup;
|
||||
gboolean keep_selection;
|
||||
int64_t new_selection;
|
||||
char delim;
|
||||
/** no custom */
|
||||
gboolean no_custom;
|
||||
|
@ -138,6 +139,8 @@ static void parse_header_entry(Mode *sw, char *line, ssize_t length) {
|
|||
pd->use_hot_keys = (strcasecmp(value, "true") == 0);
|
||||
} else if (strcasecmp(line, "keep-selection") == 0) {
|
||||
pd->keep_selection = (strcasecmp(value, "true") == 0);
|
||||
} else if (strcasecmp(line, "new-selection") == 0) {
|
||||
pd->new_selection = (int64_t)g_ascii_strtoll(value, NULL, 0);
|
||||
} else if (strcasecmp(line, "data") == 0) {
|
||||
g_free(pd->data);
|
||||
pd->data = g_strdup(value);
|
||||
|
@ -160,7 +163,9 @@ static DmenuScriptEntry *execute_executor(Mode *sw, char *arg,
|
|||
char **argv = NULL;
|
||||
int argc = 0;
|
||||
*length = 0;
|
||||
|
||||
// Reset these between runs.
|
||||
pd->new_selection = -1;
|
||||
pd->keep_selection = -1;
|
||||
// Environment
|
||||
char **env = g_get_environ();
|
||||
|
||||
|
@ -343,6 +348,15 @@ static ModeMode script_mode_result(Mode *sw, int mretv, char **input,
|
|||
rmpd->cmd_list = new_list;
|
||||
rmpd->cmd_list_length = new_length;
|
||||
if (rmpd->keep_selection) {
|
||||
if (rmpd->new_selection >= 0 &&
|
||||
rmpd->new_selection < rmpd->cmd_list_length) {
|
||||
rofi_view_set_selected_line(rofi_view_get_active(),
|
||||
rmpd->new_selection);
|
||||
} else {
|
||||
rofi_view_set_selected_line(rofi_view_get_active(), selected_line);
|
||||
}
|
||||
g_free(*input);
|
||||
*input = NULL;
|
||||
retv = RELOAD_DIALOG;
|
||||
} else {
|
||||
retv = RESET_DIALOG;
|
||||
|
@ -429,8 +443,9 @@ static char *script_get_message(const Mode *sw) {
|
|||
ScriptModePrivateData *pd = sw->private_data;
|
||||
return g_strdup(pd->message);
|
||||
}
|
||||
static cairo_surface_t *
|
||||
script_get_icon(const Mode *sw, unsigned int selected_line, int height) {
|
||||
static cairo_surface_t *script_get_icon(const Mode *sw,
|
||||
unsigned int selected_line,
|
||||
unsigned int height) {
|
||||
ScriptModePrivateData *pd =
|
||||
(ScriptModePrivateData *)mode_get_private_data(sw);
|
||||
g_return_val_if_fail(pd->cmd_list != NULL, NULL);
|
||||
|
@ -454,7 +469,7 @@ typedef struct ScriptUser {
|
|||
} ScriptUser;
|
||||
|
||||
ScriptUser *user_scripts = NULL;
|
||||
int num_scripts = 0;
|
||||
size_t num_scripts = 0;
|
||||
|
||||
void script_mode_cleanup(void) {
|
||||
for (size_t i = 0; i < num_scripts; i++) {
|
||||
|
@ -493,7 +508,7 @@ void script_mode_gather_user_scripts(void) {
|
|||
|
||||
static int script_mode_has_user_script(char const *const user) {
|
||||
|
||||
for (int i = 0; i < num_scripts; i++) {
|
||||
for (size_t i = 0; i < num_scripts; i++) {
|
||||
if (g_strcmp0(user_scripts[i].name, user) == 0) {
|
||||
return i;
|
||||
}
|
||||
|
|
|
@ -148,6 +148,8 @@ typedef struct {
|
|||
unsigned int title_len;
|
||||
unsigned int role_len;
|
||||
GRegex *window_regex;
|
||||
// Hide current active window
|
||||
gboolean hide_active_window;
|
||||
} WindowModePrivateData;
|
||||
|
||||
winlist *cache_client = NULL;
|
||||
|
@ -399,7 +401,8 @@ static gboolean window_client_reload(G_GNUC_UNUSED void *data) {
|
|||
}
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
void window_client_handle_signal(xcb_window_t win, gboolean create) {
|
||||
void window_client_handle_signal(G_GNUC_UNUSED xcb_window_t win,
|
||||
G_GNUC_UNUSED gboolean create) {
|
||||
// g_idle_add_full(G_PRIORITY_HIGH_IDLE, window_client_reload, NULL, NULL);
|
||||
if (window_reload_timeout > 0) {
|
||||
g_source_remove(window_reload_timeout);
|
||||
|
@ -663,7 +666,9 @@ static void _window_mode_load_data(Mode *sw, unsigned int cd) {
|
|||
if (cd && winclient->wmdesktop != current_desktop) {
|
||||
continue;
|
||||
}
|
||||
winlist_append(pd->ids, winclient->window, NULL);
|
||||
if (!pd->hide_active_window || winclient->window != curr_win_id) {
|
||||
winlist_append(pd->ids, winclient->window, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -675,7 +680,14 @@ static void _window_mode_load_data(Mode *sw, unsigned int cd) {
|
|||
}
|
||||
static int window_mode_init(Mode *sw) {
|
||||
if (mode_get_private_data(sw) == NULL) {
|
||||
|
||||
WindowModePrivateData *pd = g_malloc0(sizeof(*pd));
|
||||
ThemeWidget *wid = rofi_config_find_widget(sw->name, NULL, TRUE);
|
||||
Property *p =
|
||||
rofi_theme_find_property(wid, P_BOOLEAN, "hide-active-window", FALSE);
|
||||
if (p && p->type == P_BOOLEAN && p->value.b == TRUE) {
|
||||
pd->hide_active_window = TRUE;
|
||||
}
|
||||
pd->window_regex = g_regex_new("{[-\\w]+(:-?[0-9]+)?}", 0, 0, NULL);
|
||||
mode_set_private_data(sw, (void *)pd);
|
||||
_window_mode_load_data(sw, FALSE);
|
||||
|
@ -688,6 +700,13 @@ static int window_mode_init(Mode *sw) {
|
|||
static int window_mode_init_cd(Mode *sw) {
|
||||
if (mode_get_private_data(sw) == NULL) {
|
||||
WindowModePrivateData *pd = g_malloc0(sizeof(*pd));
|
||||
|
||||
ThemeWidget *wid = rofi_config_find_widget(sw->name, NULL, TRUE);
|
||||
Property *p =
|
||||
rofi_theme_find_property(wid, P_BOOLEAN, "hide-active-window", FALSE);
|
||||
if (p && p->type == P_BOOLEAN && p->value.b == TRUE) {
|
||||
pd->hide_active_window = TRUE;
|
||||
}
|
||||
pd->window_regex = g_regex_new("{[-\\w]+(:-?[0-9]+)?}", 0, 0, NULL);
|
||||
mode_set_private_data(sw, (void *)pd);
|
||||
_window_mode_load_data(sw, TRUE);
|
||||
|
@ -930,7 +949,8 @@ static cairo_user_data_key_t data_key;
|
|||
/** Create a surface object from this image data.
|
||||
* \param width The width of the image.
|
||||
* \param height The height of the image
|
||||
* \param data The image's data in ARGB format, will be copied by this function.
|
||||
* \param data The image's data in ARGB format, will be copied by this
|
||||
* function.
|
||||
*/
|
||||
static cairo_surface_t *draw_surface_from_data(int width, int height,
|
||||
uint32_t const *const data) {
|
||||
|
@ -984,7 +1004,8 @@ static cairo_surface_t *ewmh_window_icon_from_reply(xcb_get_property_reply_t *r,
|
|||
break;
|
||||
}
|
||||
|
||||
/* use the greater of the two dimensions to match against the preferred size
|
||||
/* use the greater of the two dimensions to match against the preferred
|
||||
* size
|
||||
*/
|
||||
uint32_t size = MAX(data[0], data[1]);
|
||||
|
||||
|
@ -1023,7 +1044,7 @@ static cairo_surface_t *get_net_wm_icon(xcb_window_t xid,
|
|||
return surface;
|
||||
}
|
||||
static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line,
|
||||
int size) {
|
||||
unsigned int size) {
|
||||
WindowModePrivateData *rmpd = mode_get_private_data(sw);
|
||||
client *c = window_client(rmpd, rmpd->ids->array[selected_line]);
|
||||
if (c == NULL) {
|
||||
|
|
|
@ -292,12 +292,12 @@ 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:")) {
|
||||
} else if (g_str_has_prefix(sentry->entry->name, "<span")) {
|
||||
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);
|
||||
pango_layout_set_markup(layout, sentry->entry->name, -1);
|
||||
|
||||
int width, height;
|
||||
pango_layout_get_size(layout, &width, &height);
|
||||
|
|
|
@ -81,6 +81,7 @@ const char *cache_dir = NULL;
|
|||
|
||||
/** List of error messages.*/
|
||||
GList *list_of_error_msgs = NULL;
|
||||
GList *list_of_warning_msgs = NULL;
|
||||
|
||||
static void rofi_collectmodes_destroy(void);
|
||||
void rofi_add_error_message(GString *str) {
|
||||
|
@ -96,6 +97,19 @@ void rofi_clear_error_messages(void) {
|
|||
list_of_error_msgs = NULL;
|
||||
}
|
||||
}
|
||||
void rofi_add_warning_message(GString *str) {
|
||||
list_of_warning_msgs = g_list_append(list_of_warning_msgs, str);
|
||||
}
|
||||
void rofi_clear_warning_messages(void) {
|
||||
if (list_of_warning_msgs) {
|
||||
for (GList *iter = g_list_first(list_of_warning_msgs); iter != NULL;
|
||||
iter = g_list_next(iter)) {
|
||||
g_string_free((GString *)iter->data, TRUE);
|
||||
}
|
||||
g_list_free(list_of_warning_msgs);
|
||||
list_of_warning_msgs = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/** Path to the configuration file */
|
||||
G_MODULE_EXPORT char *config_path = NULL;
|
||||
|
@ -273,6 +287,8 @@ static void print_list_of_modes(int is_term) {
|
|||
}
|
||||
}
|
||||
static void print_main_application_options(int is_term) {
|
||||
print_help_msg("-config", "[file]", "Load an alternative configuration.",
|
||||
NULL, is_term);
|
||||
print_help_msg("-no-config", "",
|
||||
"Do not load configuration, use default values.", NULL,
|
||||
is_term);
|
||||
|
@ -328,6 +344,7 @@ static void help(G_GNUC_UNUSED int argc, char **argv) {
|
|||
script_user_list(is_term);
|
||||
printf("\n");
|
||||
printf("Compile time options:\n");
|
||||
printf("\t• Pango version %s\n", pango_version_string());
|
||||
#ifdef WINDOW_MODE
|
||||
printf("\t• window %senabled%s\n", is_term ? color_green : "",
|
||||
is_term ? color_reset : "");
|
||||
|
@ -471,6 +488,7 @@ static void cleanup(void) {
|
|||
g_free(config_path);
|
||||
|
||||
rofi_clear_error_messages();
|
||||
rofi_clear_warning_messages();
|
||||
|
||||
if (rofi_theme) {
|
||||
rofi_theme_free(rofi_theme);
|
||||
|
@ -719,6 +737,13 @@ static gboolean startup(G_GNUC_UNUSED gpointer data) {
|
|||
show_error_dialog();
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
if (list_of_warning_msgs != NULL) {
|
||||
for (GList *iter = g_list_first(list_of_warning_msgs); iter != NULL;
|
||||
iter = g_list_next(iter)) {
|
||||
fputs(((GString *)iter->data)->str, stderr);
|
||||
fputs("\n", stderr);
|
||||
}
|
||||
}
|
||||
// Dmenu mode.
|
||||
if (dmenu_mode == TRUE) {
|
||||
// force off sidebar mode:
|
||||
|
@ -771,7 +796,7 @@ static gboolean record(G_GNUC_UNUSED void *data) {
|
|||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
static void rofi_custom_log_function(const char *log_domain,
|
||||
GLogLevelFlags log_level,
|
||||
G_GNUC_UNUSED GLogLevelFlags log_level,
|
||||
const gchar *message, gpointer user_data) {
|
||||
int fp = GPOINTER_TO_INT(user_data);
|
||||
dprintf(fp, "[%s]: %s\n", log_domain == NULL ? "default" : log_domain,
|
||||
|
@ -1145,7 +1170,7 @@ extern GList *list_of_error_msgs;
|
|||
int rofi_theme_rasi_validate(const char *filename) {
|
||||
rofi_theme_parse_file(filename);
|
||||
rofi_theme_parse_process_links();
|
||||
if (list_of_error_msgs == NULL) {
|
||||
if (list_of_error_msgs == NULL && list_of_warning_msgs == NULL) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1154,6 +1179,11 @@ int rofi_theme_rasi_validate(const char *filename) {
|
|||
fputs(((GString *)iter->data)->str, stderr);
|
||||
fputs("\n", stderr);
|
||||
}
|
||||
for (GList *iter = g_list_first(list_of_warning_msgs); iter != NULL;
|
||||
iter = g_list_next(iter)) {
|
||||
fputs(((GString *)iter->data)->str, stderr);
|
||||
fputs("\n", stderr);
|
||||
}
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
@ -121,7 +121,8 @@ RofiDistance rofi_theme_property_copy_distance(RofiDistance const distance) {
|
|||
return retv;
|
||||
}
|
||||
|
||||
Property *rofi_theme_property_copy(const Property *p) {
|
||||
Property *rofi_theme_property_copy(const Property *p,
|
||||
G_GNUC_UNUSED void *data) {
|
||||
Property *retv = rofi_theme_property_create(p->type);
|
||||
retv->name = g_strdup(p->name);
|
||||
|
||||
|
@ -138,7 +139,7 @@ Property *rofi_theme_property_copy(const Property *p) {
|
|||
retv->value.link.ref = NULL;
|
||||
if (p->value.link.def_value) {
|
||||
retv->value.link.def_value =
|
||||
rofi_theme_property_copy(p->value.link.def_value);
|
||||
rofi_theme_property_copy(p->value.link.def_value, NULL);
|
||||
}
|
||||
break;
|
||||
case P_PADDING: {
|
||||
|
@ -386,6 +387,15 @@ static void int_rofi_theme_print_property(Property *p) {
|
|||
if (p->value.highlight.style & ROFI_HL_ITALIC) {
|
||||
printf("italic ");
|
||||
}
|
||||
if (p->value.highlight.style & ROFI_HL_UPPERCASE) {
|
||||
printf("uppercase ");
|
||||
}
|
||||
if (p->value.highlight.style & ROFI_HL_LOWERCASE) {
|
||||
printf("lowercase ");
|
||||
}
|
||||
if (p->value.highlight.style & ROFI_HL_CAPITALIZE) {
|
||||
printf("capitalize ");
|
||||
}
|
||||
if (p->value.highlight.style & ROFI_HL_COLOR) {
|
||||
rofi_theme_print_color(p->value.highlight.color);
|
||||
}
|
||||
|
@ -636,7 +646,7 @@ void yyerror(YYLTYPE *yylloc, const char *what, const char *s) {
|
|||
static void rofi_theme_copy_property_int(G_GNUC_UNUSED gpointer key,
|
||||
gpointer value, gpointer user_data) {
|
||||
GHashTable *table = (GHashTable *)user_data;
|
||||
Property *p = rofi_theme_property_copy((Property *)value);
|
||||
Property *p = rofi_theme_property_copy((Property *)value, NULL);
|
||||
g_hash_table_replace(table, p->name, p);
|
||||
}
|
||||
void rofi_theme_widget_add_properties(ThemeWidget *widget, GHashTable *table) {
|
||||
|
@ -1594,7 +1604,7 @@ static void rofi_theme_parse_process_links_int(ThemeWidget *wid) {
|
|||
pv->value.link.name, n, pv->name,
|
||||
pv->value.link.name);
|
||||
|
||||
rofi_add_error_message(str);
|
||||
rofi_add_warning_message(str);
|
||||
g_free(n);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,14 +114,39 @@ static void rofi_view_update_prompt(RofiViewState *state) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
extern GList *list_of_warning_msgs;
|
||||
static void rofi_view_reload_message_bar(RofiViewState *state) {
|
||||
if (state->mesg_box == NULL) {
|
||||
return;
|
||||
}
|
||||
char *msg = mode_get_message(state->sw);
|
||||
if (msg) {
|
||||
textbox_text(state->mesg_tb, msg);
|
||||
if (msg || list_of_warning_msgs) {
|
||||
/** we want to popin warning here. */
|
||||
|
||||
GString *emesg = g_string_new(msg);
|
||||
if (list_of_warning_msgs) {
|
||||
if (msg) {
|
||||
g_string_append_c(emesg, '\n');
|
||||
}
|
||||
g_string_append(
|
||||
emesg, "The following warnings were detected when starting rofi:\n");
|
||||
GList *iter = g_list_first(list_of_warning_msgs);
|
||||
int index = 0;
|
||||
for (; iter != NULL && index < 2; iter = g_list_next(iter)) {
|
||||
GString *msg = (GString *)(iter->data);
|
||||
g_string_append(emesg, "\n\n");
|
||||
g_string_append(emesg, msg->str);
|
||||
index++;
|
||||
}
|
||||
if (g_list_length(iter) > 1) {
|
||||
g_string_append_printf(emesg, "\nThere are <b>%u</b> more errors.",
|
||||
g_list_length(iter) - 1);
|
||||
}
|
||||
}
|
||||
textbox_text(state->mesg_tb, emesg->str);
|
||||
widget_enable(WIDGET(state->mesg_box));
|
||||
g_string_free(emesg, TRUE);
|
||||
g_free(msg);
|
||||
} else {
|
||||
widget_disable(WIDGET(state->mesg_box));
|
||||
|
@ -429,8 +454,8 @@ inline static void rofi_view_nav_last(RofiViewState *state) {
|
|||
// state->selected = state->filtered_lines - 1;
|
||||
listview_set_selected(state->list_view, -1);
|
||||
}
|
||||
static void selection_changed_callback(listview *lv, unsigned int index,
|
||||
void *udata) {
|
||||
static void selection_changed_callback(G_GNUC_UNUSED listview *lv,
|
||||
unsigned int index, void *udata) {
|
||||
RofiViewState *state = (RofiViewState *)udata;
|
||||
if (state->tb_current_entry) {
|
||||
if (index < state->filtered_lines) {
|
||||
|
@ -1282,10 +1307,6 @@ static void rofi_view_add_widget(RofiViewState *state, widget *parent_widget,
|
|||
listview_set_selection_changed_callback(
|
||||
state->list_view, selection_changed_callback, (void *)state);
|
||||
box_add((box *)parent_widget, WIDGET(state->list_view), TRUE);
|
||||
// Set configuration
|
||||
listview_set_multi_select(state->list_view,
|
||||
(state->menu_flags & MENU_INDICATOR) ==
|
||||
MENU_INDICATOR);
|
||||
listview_set_scroll_type(state->list_view, config.scroll_method);
|
||||
listview_set_mouse_activated_cb(
|
||||
state->list_view, rofi_view_listview_mouse_activated_cb, state);
|
||||
|
|
|
@ -102,7 +102,6 @@ struct _listview {
|
|||
gboolean filtered;
|
||||
|
||||
gboolean cycle;
|
||||
gboolean multi_select;
|
||||
|
||||
ScrollType scroll_type;
|
||||
|
||||
|
@ -168,7 +167,7 @@ static void listview_set_state(_listview_row r, TextBoxFontType tbft) {
|
|||
}
|
||||
static void listview_add_widget(listview *lv, _listview_row *row, widget *wid,
|
||||
const char *label) {
|
||||
TextboxFlags flags = (lv->multi_select) ? TB_INDICATOR : 0;
|
||||
TextboxFlags flags = 0;
|
||||
if (strcasecmp(label, "element-icon") == 0) {
|
||||
row->icon = icon_create(WIDGET(wid), "element-icon");
|
||||
box_add((box *)wid, WIDGET(row->icon), FALSE);
|
||||
|
@ -737,6 +736,7 @@ listview *listview_create(widget *parent, const char *name,
|
|||
buff[i * 2] = 'a';
|
||||
buff[i * 2 + 1] = '\n';
|
||||
};
|
||||
textbox_moveresize(row.textbox, 0, 0, 100000000, -1);
|
||||
textbox_text(row.textbox, buff);
|
||||
}
|
||||
// Make textbox very wide.
|
||||
|
@ -1052,11 +1052,6 @@ void listview_set_mouse_activated_cb(listview *lv,
|
|||
lv->mouse_activated_data = udata;
|
||||
}
|
||||
}
|
||||
void listview_set_multi_select(listview *lv, gboolean enable) {
|
||||
if (lv) {
|
||||
lv->multi_select = enable;
|
||||
}
|
||||
}
|
||||
void listview_set_num_lines(listview *lv, unsigned int num_lines) {
|
||||
if (lv) {
|
||||
lv->menu_lines = num_lines;
|
||||
|
|
|
@ -39,9 +39,6 @@
|
|||
|
||||
#include "theme.h"
|
||||
|
||||
/** The space reserved for the DOT when enabling multi-select. */
|
||||
#define DOT_OFFSET 15
|
||||
|
||||
static void textbox_draw(widget *, cairo_t *);
|
||||
static void textbox_free(widget *);
|
||||
static int textbox_get_width(widget *);
|
||||
|
@ -77,7 +74,6 @@ static void textbox_resize(widget *wid, short w, short h) {
|
|||
}
|
||||
static int textbox_get_desired_height(widget *wid, const int width) {
|
||||
textbox *tb = (textbox *)wid;
|
||||
unsigned int offset = ((tb->flags & TB_INDICATOR) ? DOT_OFFSET : 0);
|
||||
if ((tb->flags & TB_AUTOHEIGHT) == 0) {
|
||||
return tb->widget.h;
|
||||
}
|
||||
|
@ -87,8 +83,7 @@ static int textbox_get_desired_height(widget *wid, const int width) {
|
|||
int old_width = pango_layout_get_width(tb->layout);
|
||||
pango_layout_set_width(
|
||||
tb->layout,
|
||||
PANGO_SCALE *
|
||||
(width - widget_padding_get_padding_width(WIDGET(tb)) - offset));
|
||||
PANGO_SCALE * (width - widget_padding_get_padding_width(WIDGET(tb))));
|
||||
|
||||
int height =
|
||||
textbox_get_estimated_height(tb, pango_layout_get_line_count(tb->layout));
|
||||
|
@ -236,10 +231,6 @@ textbox *textbox_create(widget *parent, WidgetType type, const char *name,
|
|||
textbox_text(tb, txt ? txt : "");
|
||||
textbox_cursor_end(tb);
|
||||
|
||||
// auto height/width modes get handled here
|
||||
textbox_moveresize(tb, tb->widget.x, tb->widget.y, tb->widget.w,
|
||||
tb->widget.h);
|
||||
|
||||
tb->blink_timeout = 0;
|
||||
tb->blink = 1;
|
||||
if ((tb->flags & TB_EDITABLE) == TB_EDITABLE) {
|
||||
|
@ -261,6 +252,11 @@ textbox *textbox_create(widget *parent, WidgetType type, const char *name,
|
|||
} else {
|
||||
pango_layout_set_alignment(tb->layout, PANGO_ALIGN_RIGHT);
|
||||
}
|
||||
// auto height/width modes get handled here
|
||||
// UPDATE: don't autoheight here, as there is no width set.
|
||||
// so no height can be determined and might result into crash.
|
||||
// textbox_moveresize(tb, tb->widget.x, tb->widget.y, tb->widget.w,
|
||||
// tb->widget.h);
|
||||
|
||||
return tb;
|
||||
}
|
||||
|
@ -328,6 +324,15 @@ static void __textbox_update_pango_text(textbox *tb) {
|
|||
} else {
|
||||
pango_layout_set_text(tb->layout, tb->text, -1);
|
||||
}
|
||||
if (tb->text) {
|
||||
RofiHighlightColorStyle th = {0, {0.0, 0.0, 0.0, 0.0}};
|
||||
th = rofi_theme_get_highlight(WIDGET(tb), "text-transform", th);
|
||||
if (th.style != 0) {
|
||||
PangoAttrList *list = pango_attr_list_new();
|
||||
helper_token_match_set_pango_attr_on_style(list, 0, G_MAXUINT, th);
|
||||
pango_layout_set_attributes(tb->layout, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
const char *textbox_get_visible_text(const textbox *tb) {
|
||||
if (tb == NULL) {
|
||||
|
@ -385,11 +390,10 @@ void textbox_text(textbox *tb, const char *text) {
|
|||
|
||||
// within the parent handled auto width/height modes
|
||||
void textbox_moveresize(textbox *tb, int x, int y, int w, int h) {
|
||||
unsigned int offset = ((tb->flags & TB_INDICATOR) ? DOT_OFFSET : 0);
|
||||
if (tb->flags & TB_AUTOWIDTH) {
|
||||
pango_layout_set_width(tb->layout, -1);
|
||||
w = textbox_get_font_width(tb) +
|
||||
widget_padding_get_padding_width(WIDGET(tb)) + offset;
|
||||
widget_padding_get_padding_width(WIDGET(tb));
|
||||
} else {
|
||||
// set ellipsize
|
||||
if ((tb->flags & TB_EDITABLE) == TB_EDITABLE) {
|
||||
|
@ -403,11 +407,9 @@ void textbox_moveresize(textbox *tb, int x, int y, int w, int h) {
|
|||
|
||||
if (tb->flags & TB_AUTOHEIGHT) {
|
||||
// Width determines height!
|
||||
int tw = MAX(1, w);
|
||||
pango_layout_set_width(
|
||||
tb->layout,
|
||||
PANGO_SCALE *
|
||||
(tw - widget_padding_get_padding_width(WIDGET(tb)) - offset));
|
||||
int padding = widget_padding_get_padding_width(WIDGET(tb));
|
||||
int tw = MAX(1 + padding, w);
|
||||
pango_layout_set_width(tb->layout, PANGO_SCALE * (tw - padding));
|
||||
int hd = textbox_get_height(tb);
|
||||
h = MAX(hd, h);
|
||||
}
|
||||
|
@ -422,9 +424,8 @@ void textbox_moveresize(textbox *tb, int x, int y, int w, int h) {
|
|||
|
||||
// We always want to update this
|
||||
pango_layout_set_width(
|
||||
tb->layout,
|
||||
PANGO_SCALE * (tb->widget.w -
|
||||
widget_padding_get_padding_width(WIDGET(tb)) - offset));
|
||||
tb->layout, PANGO_SCALE * (tb->widget.w -
|
||||
widget_padding_get_padding_width(WIDGET(tb))));
|
||||
widget_queue_redraw(WIDGET(tb));
|
||||
}
|
||||
|
||||
|
@ -452,14 +453,14 @@ static void textbox_draw(widget *wid, cairo_t *draw) {
|
|||
return;
|
||||
}
|
||||
textbox *tb = (textbox *)wid;
|
||||
unsigned int dot_offset = ((tb->flags & TB_INDICATOR) ? DOT_OFFSET : 0);
|
||||
int dot_offset = 0;
|
||||
|
||||
if (tb->changed) {
|
||||
__textbox_update_pango_text(tb);
|
||||
}
|
||||
|
||||
// Skip the side MARGIN on the X axis.
|
||||
int x = widget_padding_get_left(WIDGET(tb));
|
||||
int x;
|
||||
int top = widget_padding_get_top(WIDGET(tb));
|
||||
int y = (pango_font_metrics_get_ascent(tb->tbfc->metrics) -
|
||||
pango_layout_get_baseline(tb->layout)) /
|
||||
|
@ -474,10 +475,6 @@ static void textbox_draw(widget *wid, cairo_t *draw) {
|
|||
}
|
||||
y += top;
|
||||
|
||||
x += dot_offset;
|
||||
|
||||
if (tb->xalign > 0.001) {
|
||||
}
|
||||
// TODO check if this is still needed after flatning.
|
||||
cairo_set_operator(draw, CAIRO_OPERATOR_OVER);
|
||||
cairo_set_source_rgb(draw, 0.0, 0.0, 0.0);
|
||||
|
@ -492,7 +489,7 @@ static void textbox_draw(widget *wid, cairo_t *draw) {
|
|||
case PANGO_ALIGN_CENTER: {
|
||||
int rem =
|
||||
MAX(0, tb->widget.w - widget_padding_get_padding_width(WIDGET(tb)) -
|
||||
line_width);
|
||||
line_width - dot_offset);
|
||||
x = (tb->xalign - 0.5) * rem + widget_padding_get_left(WIDGET(tb));
|
||||
cairo_move_to(draw, x, top);
|
||||
break;
|
||||
|
@ -500,7 +497,7 @@ static void textbox_draw(widget *wid, cairo_t *draw) {
|
|||
case PANGO_ALIGN_RIGHT: {
|
||||
int rem =
|
||||
MAX(0, tb->widget.w - widget_padding_get_padding_width(WIDGET(tb)) -
|
||||
line_width);
|
||||
line_width - dot_offset);
|
||||
x = -(1.0 - tb->xalign) * rem + widget_padding_get_left(WIDGET(tb));
|
||||
cairo_move_to(draw, x, top);
|
||||
break;
|
||||
|
@ -508,8 +505,9 @@ static void textbox_draw(widget *wid, cairo_t *draw) {
|
|||
default: {
|
||||
int rem =
|
||||
MAX(0, tb->widget.w - widget_padding_get_padding_width(WIDGET(tb)) -
|
||||
line_width);
|
||||
line_width - dot_offset);
|
||||
x = tb->xalign * rem + widget_padding_get_left(WIDGET(tb));
|
||||
x += dot_offset;
|
||||
cairo_move_to(draw, x, top);
|
||||
break;
|
||||
}
|
||||
|
@ -538,11 +536,6 @@ static void textbox_draw(widget *wid, cairo_t *draw) {
|
|||
cursor_height);
|
||||
cairo_fill(draw);
|
||||
}
|
||||
|
||||
if ((tb->flags & TB_INDICATOR) == TB_INDICATOR && (tb->tbft & (SELECTED))) {
|
||||
cairo_arc(draw, DOT_OFFSET / 2.0, tb->widget.h / 2.0, 2.0, 0, 2.0 * M_PI);
|
||||
cairo_fill(draw);
|
||||
}
|
||||
}
|
||||
|
||||
// cursor handling for edit mode
|
||||
|
@ -904,9 +897,7 @@ void textbox_cleanup(void) {
|
|||
int textbox_get_width(widget *wid) {
|
||||
textbox *tb = (textbox *)wid;
|
||||
if (tb->flags & TB_AUTOWIDTH) {
|
||||
unsigned int offset = (tb->flags & TB_INDICATOR) ? DOT_OFFSET : 0;
|
||||
return textbox_get_font_width(tb) + widget_padding_get_padding_width(wid) +
|
||||
offset;
|
||||
return textbox_get_font_width(tb) + widget_padding_get_padding_width(wid);
|
||||
}
|
||||
return tb->widget.w;
|
||||
}
|
||||
|
@ -968,10 +959,8 @@ int textbox_get_desired_width(widget *wid, G_GNUC_UNUSED const int height) {
|
|||
return 0;
|
||||
}
|
||||
textbox *tb = (textbox *)wid;
|
||||
unsigned int offset = ((tb->flags & TB_INDICATOR) ? DOT_OFFSET : 0);
|
||||
if (wid->expand && tb->flags & TB_AUTOWIDTH) {
|
||||
return textbox_get_font_width(tb) + widget_padding_get_padding_width(wid) +
|
||||
offset;
|
||||
return textbox_get_font_width(tb) + widget_padding_get_padding_width(wid);
|
||||
}
|
||||
RofiDistance w = rofi_theme_get_distance(WIDGET(tb), "width", 0);
|
||||
int wi = distance_get_pixel(w, ROFI_ORIENTATION_HORIZONTAL);
|
||||
|
@ -985,7 +974,7 @@ int textbox_get_desired_width(widget *wid, G_GNUC_UNUSED const int height) {
|
|||
int width = textbox_get_font_width(tb);
|
||||
// Restore.
|
||||
pango_layout_set_width(tb->layout, old_width);
|
||||
return width + padding + offset;
|
||||
return width + padding;
|
||||
}
|
||||
|
||||
void textbox_set_ellipsize(textbox *tb, PangoEllipsizeMode mode) {
|
||||
|
|
|
@ -526,8 +526,10 @@ widget *widget_find_mouse_target(widget *wid, WidgetType type, gint x, gint y) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
WidgetTriggerActionResult widget_check_action(widget *wid, guint action, gint x,
|
||||
gint y) {
|
||||
WidgetTriggerActionResult widget_check_action(widget *wid,
|
||||
G_GNUC_UNUSED guint action,
|
||||
G_GNUC_UNUSED gint x,
|
||||
G_GNUC_UNUSED gint y) {
|
||||
if (wid == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
|
16
source/xcb.c
16
source/xcb.c
|
@ -1257,9 +1257,15 @@ static void main_loop_x11_event_handler_view(xcb_generic_event_t *event) {
|
|||
gchar *text;
|
||||
|
||||
xcb->last_timestamp = xkpe->time;
|
||||
text = nk_bindings_seat_handle_key_with_modmask(
|
||||
xcb->bindings_seat, NULL, xkpe->state, xkpe->detail,
|
||||
NK_BINDINGS_KEY_STATE_PRESS);
|
||||
if ( config.xserver_i300_workaround ) {
|
||||
text = nk_bindings_seat_handle_key_with_modmask(
|
||||
xcb->bindings_seat, NULL, xkpe->state, xkpe->detail,
|
||||
NK_BINDINGS_KEY_STATE_PRESS);
|
||||
} else {
|
||||
text = nk_bindings_seat_handle_key(
|
||||
xcb->bindings_seat, NULL, xkpe->detail,
|
||||
NK_BINDINGS_KEY_STATE_PRESS);
|
||||
}
|
||||
if (text != NULL) {
|
||||
rofi_view_handle_text(state, text);
|
||||
g_free(text);
|
||||
|
@ -1288,7 +1294,9 @@ static gboolean main_loop_x11_event_handler(xcb_generic_event_t *ev,
|
|||
g_main_loop_quit(xcb->main_loop);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
g_warning("main_loop_x11_event_handler: ev == NULL, status == %d", status);
|
||||
// DD: it seems this handler often gets dispatched while the queue in GWater is empty.
|
||||
// resulting in a NULL for ev. This seems not an error.
|
||||
//g_warning("main_loop_x11_event_handler: ev == NULL, status == %d", status);
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
uint8_t type = ev->response_type & ~0x80;
|
||||
|
|
|
@ -429,6 +429,12 @@ static XrmOption xrmOptions[] = {
|
|||
"When there are more entries then this limit, only refilter after a "
|
||||
"timeout.",
|
||||
CONFIG_DEFAULT},
|
||||
{xrm_Boolean,
|
||||
"xserver-i300-workaround",
|
||||
{.snum = &(config.xserver_i300_workaround)},
|
||||
NULL,
|
||||
"Workaround for XServer issue #300 (issue #611 for rofi.)",
|
||||
CONFIG_DEFAULT},
|
||||
};
|
||||
|
||||
/** Dynamic array of extra options */
|
||||
|
@ -734,13 +740,13 @@ gboolean config_parse_set_property(const Property *p, char **error) {
|
|||
iter = g_list_next(iter)) {
|
||||
if (g_strcmp0(((Property *)(iter->data))->name, p->name) == 0) {
|
||||
rofi_theme_property_free((Property *)(iter->data));
|
||||
iter->data = (void *)rofi_theme_property_copy(p);
|
||||
iter->data = (void *)rofi_theme_property_copy(p, NULL);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
g_debug("Adding option: %s to backup list.", p->name);
|
||||
extra_parsed_options =
|
||||
g_list_append(extra_parsed_options, rofi_theme_property_copy(p));
|
||||
g_list_append(extra_parsed_options, rofi_theme_property_copy(p, NULL));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
482
test/box-test.c
482
test/box-test.c
|
@ -25,269 +25,257 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
#include <theme.h>
|
||||
#include <widgets/box.h>
|
||||
#include <widgets/widget.h>
|
||||
#include <widgets/widget-internal.h>
|
||||
#include "rofi.h"
|
||||
#include "xrmoptions.h"
|
||||
#include "helper.h"
|
||||
#include "display.h"
|
||||
#include "rofi-icon-fetcher.h"
|
||||
unsigned int test =0;
|
||||
#define TASSERT( a ) { \
|
||||
assert ( a ); \
|
||||
printf ( "Test %3u passed (%s)\n", ++test, # a ); \
|
||||
}
|
||||
#include "rofi.h"
|
||||
#include "xrmoptions.h"
|
||||
#include <assert.h>
|
||||
#include <glib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <theme.h>
|
||||
#include <unistd.h>
|
||||
#include <widgets/box.h>
|
||||
#include <widgets/widget-internal.h>
|
||||
#include <widgets/widget.h>
|
||||
unsigned int test = 0;
|
||||
#define TASSERT(a) \
|
||||
{ \
|
||||
assert(a); \
|
||||
printf("Test %3u passed (%s)\n", ++test, #a); \
|
||||
}
|
||||
|
||||
#define TASSERTE( a, b ) { \
|
||||
if ( ( a ) == ( b ) ) { \
|
||||
printf ( "Test %u passed (%s == %s) (%d == %d)\n", ++test, # a, # b, a, b ); \
|
||||
} else { \
|
||||
printf ( "Test %u failed (%s == %s) (%d != %d)\n", ++test, # a, # b, a, b ); \
|
||||
abort ( ); \
|
||||
} \
|
||||
}
|
||||
#define TASSERTE(a, b) \
|
||||
{ \
|
||||
if ((a) == (b)) { \
|
||||
printf("Test %u passed (%s == %s) (%d == %d)\n", ++test, #a, #b, a, b); \
|
||||
} else { \
|
||||
printf("Test %u failed (%s == %s) (%d != %d)\n", ++test, #a, #b, a, b); \
|
||||
abort(); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define TASSERTW( a, b ) { \
|
||||
if ( ( a ) == ( b ) ) { \
|
||||
printf ( "Test %u passed (%s == %s) (%p == %p)\n", ++test, # a, # b, (void *)a, (void *)b ); \
|
||||
} else { \
|
||||
printf ( "Test %u failed (%s == %s) (%p != %p)\n", ++test, # a, # b, (void *)a, (void *)b ); \
|
||||
abort ( ); \
|
||||
} \
|
||||
}
|
||||
#define TASSERTW(a, b) \
|
||||
{ \
|
||||
if ((a) == (b)) { \
|
||||
printf("Test %u passed (%s == %s) (%p == %p)\n", ++test, #a, #b, \
|
||||
(void *)a, (void *)b); \
|
||||
} else { \
|
||||
printf("Test %u failed (%s == %s) (%p != %p)\n", ++test, #a, #b, \
|
||||
(void *)a, (void *)b); \
|
||||
abort(); \
|
||||
} \
|
||||
}
|
||||
ThemeWidget *rofi_configuration = NULL;
|
||||
|
||||
uint32_t rofi_icon_fetcher_query ( const char *name, const int size )
|
||||
{
|
||||
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int size) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t rofi_icon_fetcher_query_advanced ( const char *name, const int wsize, const int hsize )
|
||||
{
|
||||
uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int wsize,
|
||||
G_GNUC_UNUSED const int hsize) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid )
|
||||
{
|
||||
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int monitor_active ( G_GNUC_UNUSED workarea *mon )
|
||||
{
|
||||
return 0;
|
||||
int monitor_active(G_GNUC_UNUSED workarea *mon) { return 0; }
|
||||
|
||||
gboolean config_parse_set_property(G_GNUC_UNUSED const Property *p,
|
||||
G_GNUC_UNUSED char **error) {
|
||||
return FALSE;
|
||||
}
|
||||
char *rofi_expand_path(G_GNUC_UNUSED const char *path) { return NULL; }
|
||||
|
||||
gboolean config_parse_set_property ( G_GNUC_UNUSED const Property *p, G_GNUC_UNUSED char **error )
|
||||
{
|
||||
return FALSE;
|
||||
char *helper_get_theme_path(const char *file, G_GNUC_UNUSED const char *ext) {
|
||||
return g_strdup(file);
|
||||
}
|
||||
char * rofi_expand_path ( G_GNUC_UNUSED const char *path )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char * helper_get_theme_path ( const char *file, const char *ext)
|
||||
{
|
||||
return g_strdup ( file );
|
||||
}
|
||||
void rofi_add_error_message ( G_GNUC_UNUSED GString *msg )
|
||||
{
|
||||
}
|
||||
int textbox_get_estimated_char_height ( void );
|
||||
int textbox_get_estimated_char_height ( void )
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
double textbox_get_estimated_ch ( void );
|
||||
double textbox_get_estimated_ch ( void )
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
void rofi_view_get_current_monitor ( G_GNUC_UNUSED int *width, G_GNUC_UNUSED int *height )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||
{
|
||||
{
|
||||
box *b = box_create ( NULL, "box", ROFI_ORIENTATION_HORIZONTAL );
|
||||
//box_set_padding ( b, 5 );
|
||||
widget_resize ( WIDGET (b), 100, 20);
|
||||
|
||||
widget *wid1 = g_malloc0(sizeof(widget));
|
||||
wid1->parent = WIDGET(b);
|
||||
box_add ( b , WIDGET( wid1 ), TRUE );
|
||||
// Widget not enabled. no width allocated.
|
||||
TASSERTE ( wid1->h, 0 );
|
||||
TASSERTE ( wid1->w, 0 );
|
||||
widget_enable ( WIDGET ( wid1 ) );
|
||||
widget_update ( WIDGET ( b ) ) ;
|
||||
// Widget enabled. so width allocated.
|
||||
TASSERTE ( wid1->h, 20 );
|
||||
TASSERTE ( wid1->w, 100 );
|
||||
widget *wid2 = g_malloc0(sizeof(widget));
|
||||
wid2->parent = WIDGET (b) ;
|
||||
widget_enable ( WIDGET ( wid2 ) );
|
||||
box_add ( b , WIDGET( wid2 ), TRUE );
|
||||
TASSERTE ( wid1->h, 20);
|
||||
TASSERTE ( wid1->w, 49);
|
||||
TASSERTE ( wid2->h, 20);
|
||||
TASSERTE ( wid2->w, 49);
|
||||
|
||||
widget *wid3 = g_malloc0(sizeof(widget));
|
||||
wid3->parent = WIDGET (b);
|
||||
widget_enable ( WIDGET ( wid3 ) );
|
||||
box_add ( b , WIDGET( wid3 ), FALSE );
|
||||
TASSERTE ( wid1->h, 20);
|
||||
TASSERTE ( wid1->w, 48);
|
||||
TASSERTE ( wid2->h, 20);
|
||||
TASSERTE ( wid2->w, 48);
|
||||
|
||||
widget_resize ( WIDGET (wid3) , 20, 10 );
|
||||
// TODO should this happen automagically?
|
||||
widget_update ( WIDGET ( b ) ) ;
|
||||
TASSERTE ( wid1->h, 20);
|
||||
TASSERTE ( wid1->w, 38);
|
||||
TASSERTE ( wid2->h, 20);
|
||||
TASSERTE ( wid2->w, 38);
|
||||
TASSERTE ( wid3->h, 20);
|
||||
TASSERTE ( wid3->w, 20);
|
||||
|
||||
widget_resize ( WIDGET (b ), 200, 20 );
|
||||
TASSERTE ( wid1->h, 20);
|
||||
TASSERTE ( wid1->w, 88);
|
||||
TASSERTE ( wid2->h, 20);
|
||||
TASSERTE ( wid2->w, 88);
|
||||
TASSERTE ( wid3->h, 20);
|
||||
TASSERTE ( wid3->w, 20);
|
||||
// TASSERTE ( box_get_fixed_pixels ( b ) , 24 );
|
||||
|
||||
widget *wid4 = g_malloc0(sizeof(widget));
|
||||
wid4->parent = WIDGET ( b );
|
||||
widget_enable ( WIDGET ( wid4 ) );
|
||||
widget_resize ( WIDGET ( wid4 ), 20, 20 );
|
||||
box_add ( b , WIDGET( wid4 ), FALSE );
|
||||
TASSERTE ( wid4->x, 200-20);
|
||||
widget *wid5 = g_malloc0(sizeof(widget));
|
||||
wid5->parent = WIDGET ( b );
|
||||
widget_enable ( WIDGET ( wid5 ) );
|
||||
widget_resize ( WIDGET ( wid5 ), 20, 20 );
|
||||
box_add ( b , WIDGET( wid5 ), TRUE );
|
||||
TASSERTE ( wid5->x, 149);
|
||||
widget_free ( WIDGET ( b ) );
|
||||
}
|
||||
{
|
||||
box *b = box_create ( NULL, "box", ROFI_ORIENTATION_VERTICAL );
|
||||
widget_resize ( WIDGET (b), 20, 100);
|
||||
//box_set_padding ( b, 5 );
|
||||
|
||||
widget *wid1 = g_malloc0(sizeof(widget));
|
||||
wid1->parent = WIDGET ( b );
|
||||
box_add ( b , WIDGET( wid1 ), TRUE );
|
||||
// Widget not enabled. no width allocated.
|
||||
TASSERTE ( wid1->h, 0);
|
||||
TASSERTE ( wid1->w, 0 );
|
||||
widget_enable ( WIDGET ( wid1 ) );
|
||||
widget_update ( WIDGET ( b ) ) ;
|
||||
// Widget enabled. so width allocated.
|
||||
TASSERTE ( wid1->h, 100);
|
||||
TASSERTE ( wid1->w, 20 );
|
||||
widget *wid2 = g_malloc0(sizeof(widget));
|
||||
wid2->parent = WIDGET ( b );
|
||||
widget_enable ( WIDGET ( wid2 ) );
|
||||
box_add ( b , WIDGET( wid2 ), TRUE );
|
||||
TASSERTE ( wid1->w, 20);
|
||||
TASSERTE ( wid1->h, 49);
|
||||
TASSERTE ( wid2->w, 20);
|
||||
TASSERTE ( wid2->h, 49);
|
||||
|
||||
widget *wid3 = g_malloc0(sizeof(widget));
|
||||
wid3->parent = WIDGET ( b );
|
||||
widget_enable ( WIDGET ( wid3 ) );
|
||||
box_add ( b , WIDGET( wid3 ), FALSE );
|
||||
TASSERTE ( wid1->w, 20);
|
||||
TASSERTE ( wid1->h, 48);
|
||||
TASSERTE ( wid2->w, 20);
|
||||
TASSERTE ( wid2->h, 48);
|
||||
|
||||
widget_resize ( WIDGET (wid3) , 10, 20 );
|
||||
// TODO should this happen automagically?
|
||||
widget_update ( WIDGET ( b ) ) ;
|
||||
TASSERTE ( wid1->w, 20);
|
||||
TASSERTE ( wid1->h, 38);
|
||||
TASSERTE ( wid2->w, 20);
|
||||
TASSERTE ( wid2->h, 38);
|
||||
TASSERTE ( wid3->w, 20);
|
||||
TASSERTE ( wid3->h, 20);
|
||||
|
||||
widget_resize ( WIDGET (b ), 20, 200 );
|
||||
TASSERTE ( wid1->w, 20);
|
||||
TASSERTE ( wid1->h, 88);
|
||||
TASSERTE ( wid2->w, 20);
|
||||
TASSERTE ( wid2->h, 88);
|
||||
TASSERTE ( wid3->w, 20);
|
||||
TASSERTE ( wid3->h, 20);
|
||||
// TASSERTE ( box_get_fixed_pixels ( b ) , 4 );
|
||||
widget *wid4 = g_malloc0(sizeof(widget));
|
||||
wid4->parent = WIDGET ( b );
|
||||
widget_enable ( WIDGET ( wid4 ) );
|
||||
widget_resize ( WIDGET ( wid4 ), 20, 20 );
|
||||
box_add ( b , WIDGET( wid4 ), FALSE );
|
||||
TASSERTE ( wid4->y, 180);
|
||||
widget *wid5 = g_malloc0(sizeof(widget));
|
||||
wid5->parent = WIDGET ( b );
|
||||
widget_enable ( WIDGET ( wid5 ) );
|
||||
widget_resize ( WIDGET ( wid5 ), 20, 20 );
|
||||
box_add ( b , WIDGET( wid5 ), TRUE );
|
||||
TASSERTE ( wid5->y, 149);
|
||||
widget_free ( WIDGET ( b ) );
|
||||
}
|
||||
{
|
||||
box *b = box_create ( NULL, "box", ROFI_ORIENTATION_VERTICAL );
|
||||
widget_resize ( WIDGET (b), 20, 90);
|
||||
//box_set_padding ( b, 5 );
|
||||
widget *wid1 = g_malloc0(sizeof(widget));
|
||||
wid1->parent = WIDGET ( b );
|
||||
wid1->type = 1;
|
||||
widget_enable(wid1);
|
||||
box_add ( b , WIDGET( wid1 ), TRUE );
|
||||
widget *wid2 = g_malloc0(sizeof(widget));
|
||||
wid2->parent = WIDGET ( b );
|
||||
wid2->type = 1;
|
||||
widget_enable(wid2);
|
||||
box_add ( b , WIDGET( wid2 ), TRUE );
|
||||
widget *wid3 = g_malloc0(sizeof(widget));
|
||||
wid3->parent = WIDGET ( b );
|
||||
wid3->type = 2;
|
||||
widget_enable(wid3);
|
||||
box_add ( b , WIDGET( wid3 ), TRUE );
|
||||
|
||||
gint x = 10;
|
||||
gint y = 50;
|
||||
TASSERTW ( widget_find_mouse_target ( WIDGET(b), 1, x, y ), WIDGET(wid2) );
|
||||
|
||||
y = 30;
|
||||
TASSERTW ( widget_find_mouse_target ( WIDGET(b), 1, x, y ), WIDGET(wid2) );
|
||||
y = 27;
|
||||
TASSERTW ( widget_find_mouse_target ( WIDGET(b), 1, x, y ), WIDGET(wid1) );
|
||||
widget_disable ( wid2 );
|
||||
y = 40;
|
||||
TASSERTW ( widget_find_mouse_target ( WIDGET(b), 1, x, y ), WIDGET(wid1) );
|
||||
widget_disable ( wid1 );
|
||||
widget_enable ( wid2 );
|
||||
TASSERTW ( widget_find_mouse_target ( WIDGET(b), 1, x, y ), WIDGET(wid2) );
|
||||
TASSERTW ( widget_find_mouse_target ( WIDGET(b), 2, x, y ), NULL );
|
||||
y = 55;
|
||||
TASSERTW ( widget_find_mouse_target ( WIDGET(b), 2, x, y ), WIDGET(wid3) );
|
||||
widget_free ( WIDGET ( b ) );
|
||||
}
|
||||
void rofi_add_error_message(G_GNUC_UNUSED GString *msg) {}
|
||||
void rofi_add_warning_message(G_GNUC_UNUSED GString *msg) {}
|
||||
int textbox_get_estimated_char_height(void);
|
||||
int textbox_get_estimated_char_height(void) { return 16; }
|
||||
double textbox_get_estimated_ch(void);
|
||||
double textbox_get_estimated_ch(void) { return 8; }
|
||||
void rofi_view_get_current_monitor(G_GNUC_UNUSED int *width,
|
||||
G_GNUC_UNUSED int *height) {}
|
||||
|
||||
int main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) {
|
||||
{
|
||||
box *b = box_create(NULL, "box", ROFI_ORIENTATION_HORIZONTAL);
|
||||
// box_set_padding ( b, 5 );
|
||||
widget_resize(WIDGET(b), 100, 20);
|
||||
|
||||
widget *wid1 = g_malloc0(sizeof(widget));
|
||||
wid1->parent = WIDGET(b);
|
||||
box_add(b, WIDGET(wid1), TRUE);
|
||||
// Widget not enabled. no width allocated.
|
||||
TASSERTE(wid1->h, 0);
|
||||
TASSERTE(wid1->w, 0);
|
||||
widget_enable(WIDGET(wid1));
|
||||
widget_update(WIDGET(b));
|
||||
// Widget enabled. so width allocated.
|
||||
TASSERTE(wid1->h, 20);
|
||||
TASSERTE(wid1->w, 100);
|
||||
widget *wid2 = g_malloc0(sizeof(widget));
|
||||
wid2->parent = WIDGET(b);
|
||||
widget_enable(WIDGET(wid2));
|
||||
box_add(b, WIDGET(wid2), TRUE);
|
||||
TASSERTE(wid1->h, 20);
|
||||
TASSERTE(wid1->w, 49);
|
||||
TASSERTE(wid2->h, 20);
|
||||
TASSERTE(wid2->w, 49);
|
||||
|
||||
widget *wid3 = g_malloc0(sizeof(widget));
|
||||
wid3->parent = WIDGET(b);
|
||||
widget_enable(WIDGET(wid3));
|
||||
box_add(b, WIDGET(wid3), FALSE);
|
||||
TASSERTE(wid1->h, 20);
|
||||
TASSERTE(wid1->w, 48);
|
||||
TASSERTE(wid2->h, 20);
|
||||
TASSERTE(wid2->w, 48);
|
||||
|
||||
widget_resize(WIDGET(wid3), 20, 10);
|
||||
// TODO should this happen automagically?
|
||||
widget_update(WIDGET(b));
|
||||
TASSERTE(wid1->h, 20);
|
||||
TASSERTE(wid1->w, 38);
|
||||
TASSERTE(wid2->h, 20);
|
||||
TASSERTE(wid2->w, 38);
|
||||
TASSERTE(wid3->h, 20);
|
||||
TASSERTE(wid3->w, 20);
|
||||
|
||||
widget_resize(WIDGET(b), 200, 20);
|
||||
TASSERTE(wid1->h, 20);
|
||||
TASSERTE(wid1->w, 88);
|
||||
TASSERTE(wid2->h, 20);
|
||||
TASSERTE(wid2->w, 88);
|
||||
TASSERTE(wid3->h, 20);
|
||||
TASSERTE(wid3->w, 20);
|
||||
// TASSERTE ( box_get_fixed_pixels ( b ) , 24 );
|
||||
|
||||
widget *wid4 = g_malloc0(sizeof(widget));
|
||||
wid4->parent = WIDGET(b);
|
||||
widget_enable(WIDGET(wid4));
|
||||
widget_resize(WIDGET(wid4), 20, 20);
|
||||
box_add(b, WIDGET(wid4), FALSE);
|
||||
TASSERTE(wid4->x, 200 - 20);
|
||||
widget *wid5 = g_malloc0(sizeof(widget));
|
||||
wid5->parent = WIDGET(b);
|
||||
widget_enable(WIDGET(wid5));
|
||||
widget_resize(WIDGET(wid5), 20, 20);
|
||||
box_add(b, WIDGET(wid5), TRUE);
|
||||
TASSERTE(wid5->x, 149);
|
||||
widget_free(WIDGET(b));
|
||||
}
|
||||
{
|
||||
box *b = box_create(NULL, "box", ROFI_ORIENTATION_VERTICAL);
|
||||
widget_resize(WIDGET(b), 20, 100);
|
||||
// box_set_padding ( b, 5 );
|
||||
|
||||
widget *wid1 = g_malloc0(sizeof(widget));
|
||||
wid1->parent = WIDGET(b);
|
||||
box_add(b, WIDGET(wid1), TRUE);
|
||||
// Widget not enabled. no width allocated.
|
||||
TASSERTE(wid1->h, 0);
|
||||
TASSERTE(wid1->w, 0);
|
||||
widget_enable(WIDGET(wid1));
|
||||
widget_update(WIDGET(b));
|
||||
// Widget enabled. so width allocated.
|
||||
TASSERTE(wid1->h, 100);
|
||||
TASSERTE(wid1->w, 20);
|
||||
widget *wid2 = g_malloc0(sizeof(widget));
|
||||
wid2->parent = WIDGET(b);
|
||||
widget_enable(WIDGET(wid2));
|
||||
box_add(b, WIDGET(wid2), TRUE);
|
||||
TASSERTE(wid1->w, 20);
|
||||
TASSERTE(wid1->h, 49);
|
||||
TASSERTE(wid2->w, 20);
|
||||
TASSERTE(wid2->h, 49);
|
||||
|
||||
widget *wid3 = g_malloc0(sizeof(widget));
|
||||
wid3->parent = WIDGET(b);
|
||||
widget_enable(WIDGET(wid3));
|
||||
box_add(b, WIDGET(wid3), FALSE);
|
||||
TASSERTE(wid1->w, 20);
|
||||
TASSERTE(wid1->h, 48);
|
||||
TASSERTE(wid2->w, 20);
|
||||
TASSERTE(wid2->h, 48);
|
||||
|
||||
widget_resize(WIDGET(wid3), 10, 20);
|
||||
// TODO should this happen automagically?
|
||||
widget_update(WIDGET(b));
|
||||
TASSERTE(wid1->w, 20);
|
||||
TASSERTE(wid1->h, 38);
|
||||
TASSERTE(wid2->w, 20);
|
||||
TASSERTE(wid2->h, 38);
|
||||
TASSERTE(wid3->w, 20);
|
||||
TASSERTE(wid3->h, 20);
|
||||
|
||||
widget_resize(WIDGET(b), 20, 200);
|
||||
TASSERTE(wid1->w, 20);
|
||||
TASSERTE(wid1->h, 88);
|
||||
TASSERTE(wid2->w, 20);
|
||||
TASSERTE(wid2->h, 88);
|
||||
TASSERTE(wid3->w, 20);
|
||||
TASSERTE(wid3->h, 20);
|
||||
// TASSERTE ( box_get_fixed_pixels ( b ) , 4 );
|
||||
widget *wid4 = g_malloc0(sizeof(widget));
|
||||
wid4->parent = WIDGET(b);
|
||||
widget_enable(WIDGET(wid4));
|
||||
widget_resize(WIDGET(wid4), 20, 20);
|
||||
box_add(b, WIDGET(wid4), FALSE);
|
||||
TASSERTE(wid4->y, 180);
|
||||
widget *wid5 = g_malloc0(sizeof(widget));
|
||||
wid5->parent = WIDGET(b);
|
||||
widget_enable(WIDGET(wid5));
|
||||
widget_resize(WIDGET(wid5), 20, 20);
|
||||
box_add(b, WIDGET(wid5), TRUE);
|
||||
TASSERTE(wid5->y, 149);
|
||||
widget_free(WIDGET(b));
|
||||
}
|
||||
{
|
||||
box *b = box_create(NULL, "box", ROFI_ORIENTATION_VERTICAL);
|
||||
widget_resize(WIDGET(b), 20, 90);
|
||||
// box_set_padding ( b, 5 );
|
||||
widget *wid1 = g_malloc0(sizeof(widget));
|
||||
wid1->parent = WIDGET(b);
|
||||
wid1->type = 1;
|
||||
widget_enable(wid1);
|
||||
box_add(b, WIDGET(wid1), TRUE);
|
||||
widget *wid2 = g_malloc0(sizeof(widget));
|
||||
wid2->parent = WIDGET(b);
|
||||
wid2->type = 1;
|
||||
widget_enable(wid2);
|
||||
box_add(b, WIDGET(wid2), TRUE);
|
||||
widget *wid3 = g_malloc0(sizeof(widget));
|
||||
wid3->parent = WIDGET(b);
|
||||
wid3->type = 2;
|
||||
widget_enable(wid3);
|
||||
box_add(b, WIDGET(wid3), TRUE);
|
||||
|
||||
gint x = 10;
|
||||
gint y = 50;
|
||||
TASSERTW(widget_find_mouse_target(WIDGET(b), 1, x, y), WIDGET(wid2));
|
||||
|
||||
y = 30;
|
||||
TASSERTW(widget_find_mouse_target(WIDGET(b), 1, x, y), WIDGET(wid2));
|
||||
y = 27;
|
||||
TASSERTW(widget_find_mouse_target(WIDGET(b), 1, x, y), WIDGET(wid1));
|
||||
widget_disable(wid2);
|
||||
y = 40;
|
||||
TASSERTW(widget_find_mouse_target(WIDGET(b), 1, x, y), WIDGET(wid1));
|
||||
widget_disable(wid1);
|
||||
widget_enable(wid2);
|
||||
TASSERTW(widget_find_mouse_target(WIDGET(b), 1, x, y), WIDGET(wid2));
|
||||
TASSERTW(widget_find_mouse_target(WIDGET(b), 2, x, y), NULL);
|
||||
y = 55;
|
||||
TASSERTW(widget_find_mouse_target(WIDGET(b), 2, x, y), WIDGET(wid3));
|
||||
widget_free(WIDGET(b));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,136 +25,127 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <locale.h>
|
||||
#include <glib.h>
|
||||
#include <stdio.h>
|
||||
#include <helper.h>
|
||||
#include <string.h>
|
||||
#include "display.h"
|
||||
#include "xcb.h"
|
||||
#include "xcb-internal.h"
|
||||
#include "rofi-icon-fetcher.h"
|
||||
#include "rofi.h"
|
||||
#include "settings.h"
|
||||
#include "widgets/textbox.h"
|
||||
#include "rofi-icon-fetcher.h"
|
||||
#include "xcb-internal.h"
|
||||
#include "xcb.h"
|
||||
#include <assert.h>
|
||||
#include <glib.h>
|
||||
#include <helper.h>
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static int test = 0;
|
||||
static int test = 0;
|
||||
|
||||
#define TASSERT( a ) { \
|
||||
assert ( a ); \
|
||||
printf ( "Test %i passed (%s)\n", ++test, # a ); \
|
||||
}
|
||||
#define TASSERTE( a, b ) { \
|
||||
if ( ( a ) == ( b ) ) { \
|
||||
printf ( "Test %i passed (%s == %s) (%u == %u)\n", ++test, # a, # b, a, b ); \
|
||||
} else { \
|
||||
printf ( "Test %i failed (%s == %s) (%u != %u)\n", ++test, # a, # b, a, b ); \
|
||||
abort ( ); \
|
||||
} \
|
||||
}
|
||||
#define TASSERT(a) \
|
||||
{ \
|
||||
assert(a); \
|
||||
printf("Test %i passed (%s)\n", ++test, #a); \
|
||||
}
|
||||
#define TASSERTE(a, b) \
|
||||
{ \
|
||||
if ((a) == (b)) { \
|
||||
printf("Test %i passed (%s == %s) (%u == %u)\n", ++test, #a, #b, a, b); \
|
||||
} else { \
|
||||
printf("Test %i failed (%s == %s) (%u != %u)\n", ++test, #a, #b, a, b); \
|
||||
abort(); \
|
||||
} \
|
||||
}
|
||||
#include "theme.h"
|
||||
ThemeWidget *rofi_theme = NULL;
|
||||
uint32_t rofi_icon_fetcher_query ( const char *name, const int size )
|
||||
{
|
||||
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int size) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t rofi_icon_fetcher_query_advanced ( const char *name, const int wsize, const int hsize )
|
||||
{
|
||||
uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int wsize,
|
||||
G_GNUC_UNUSED const int hsize) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid )
|
||||
{
|
||||
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
|
||||
return NULL;
|
||||
}
|
||||
void rofi_clear_error_messages (void )
|
||||
{
|
||||
}
|
||||
void rofi_clear_error_messages(void) {}
|
||||
void rofi_clear_warning_messages(void) {}
|
||||
|
||||
gboolean rofi_theme_parse_string ( const char *string )
|
||||
{
|
||||
gboolean rofi_theme_parse_string(G_GNUC_UNUSED const char *string) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
double textbox_get_estimated_char_height ( void )
|
||||
{
|
||||
return 12.0;
|
||||
double textbox_get_estimated_char_height(void) { return 12.0; }
|
||||
void rofi_view_get_current_monitor(int *width, int *height) {
|
||||
*width = 1920;
|
||||
*height = 1080;
|
||||
}
|
||||
void rofi_view_get_current_monitor ( int *width, int *height )
|
||||
{
|
||||
*width = 1920;
|
||||
*height = 1080;
|
||||
}
|
||||
double textbox_get_estimated_ch ( void )
|
||||
{
|
||||
return 9.0;
|
||||
}
|
||||
void rofi_add_error_message ( G_GNUC_UNUSED GString *msg )
|
||||
{
|
||||
}
|
||||
int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
|
||||
{
|
||||
fputs ( msg, stderr );
|
||||
return TRUE;
|
||||
double textbox_get_estimated_ch(void) { return 9.0; }
|
||||
void rofi_add_error_message(G_GNUC_UNUSED GString *msg) {}
|
||||
void rofi_add_warning_message(G_GNUC_UNUSED GString *msg) {}
|
||||
int rofi_view_error_dialog(const char *msg, G_GNUC_UNUSED int markup) {
|
||||
fputs(msg, stderr);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int monitor_active ( G_GNUC_UNUSED workarea *mon )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void display_startup_notification ( G_GNUC_UNUSED RofiHelperExecuteContext *context, G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup, G_GNUC_UNUSED gpointer *user_data )
|
||||
{
|
||||
}
|
||||
|
||||
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||
{
|
||||
|
||||
if ( setlocale ( LC_ALL, "" ) == NULL ) {
|
||||
fprintf ( stderr, "Failed to set locale.\n" );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
char **list = NULL;
|
||||
int llength = 0;
|
||||
char * test_str =
|
||||
"{host} {terminal} -e bash -c \"{ssh-client} {host}; echo '{terminal} {host}'\" -i -3 -u 4";
|
||||
helper_parse_setup ( test_str, &list, &llength, "{host}", "chuck",
|
||||
"{terminal}", "x-terminal-emulator", NULL );
|
||||
|
||||
TASSERT ( llength == 10);
|
||||
TASSERT ( strcmp ( list[0], "chuck" ) == 0 );
|
||||
TASSERT ( strcmp ( list[1], "x-terminal-emulator" ) == 0 );
|
||||
TASSERT ( strcmp ( list[2], "-e" ) == 0 );
|
||||
TASSERT ( strcmp ( list[3], "bash" ) == 0 );
|
||||
TASSERT ( strcmp ( list[4], "-c" ) == 0 );
|
||||
TASSERT ( strcmp ( list[5], "ssh chuck; echo 'x-terminal-emulator chuck'" ) == 0 );
|
||||
TASSERT ( strcmp ( list[6], "-i" ) == 0 );
|
||||
TASSERT ( strcmp ( list[7], "-3" ) == 0 );
|
||||
TASSERT ( strcmp ( list[8], "-u" ) == 0 );
|
||||
TASSERT ( strcmp ( list[9], "4" ) == 0 );
|
||||
|
||||
cmd_set_arguments ( llength, list);
|
||||
TASSERT ( find_arg ( "-e") == 2 );
|
||||
TASSERT ( find_arg ( "-x") == -1 );
|
||||
char *str;
|
||||
TASSERT ( find_arg_str ( "-e", &str) == TRUE );
|
||||
TASSERT ( str == list[3] );
|
||||
TASSERT ( find_arg_str ( "-x", &str) == FALSE );
|
||||
// Should be unmodified.
|
||||
TASSERT ( str == list[3] );
|
||||
|
||||
unsigned int u = 1234;
|
||||
int d = -1234;
|
||||
TASSERT ( find_arg_uint ( "-x", &u ) == FALSE );
|
||||
TASSERT ( u == 1234 );
|
||||
TASSERT ( find_arg_int ( "-x", &d ) == FALSE );
|
||||
TASSERT ( d == -1234 );
|
||||
TASSERT ( find_arg_uint ( "-u", &u ) == TRUE );
|
||||
TASSERT ( u == 4 );
|
||||
TASSERT ( find_arg_uint ( "-i", &u ) == TRUE );
|
||||
TASSERT ( u == 4294967293 );
|
||||
TASSERT ( find_arg_int ( "-i", &d ) == TRUE );
|
||||
TASSERT ( d == -3 );
|
||||
|
||||
g_strfreev ( list );
|
||||
|
||||
int monitor_active(G_GNUC_UNUSED workarea *mon) { return 0; }
|
||||
|
||||
void display_startup_notification(
|
||||
G_GNUC_UNUSED RofiHelperExecuteContext *context,
|
||||
G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup,
|
||||
G_GNUC_UNUSED gpointer *user_data) {}
|
||||
|
||||
int main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) {
|
||||
|
||||
if (setlocale(LC_ALL, "") == NULL) {
|
||||
fprintf(stderr, "Failed to set locale.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
char **list = NULL;
|
||||
int llength = 0;
|
||||
char *test_str = "{host} {terminal} -e bash -c \"{ssh-client} {host}; echo "
|
||||
"'{terminal} {host}'\" -i -3 -u 4";
|
||||
helper_parse_setup(test_str, &list, &llength, "{host}", "chuck", "{terminal}",
|
||||
"x-terminal-emulator", NULL);
|
||||
|
||||
TASSERT(llength == 10);
|
||||
TASSERT(strcmp(list[0], "chuck") == 0);
|
||||
TASSERT(strcmp(list[1], "x-terminal-emulator") == 0);
|
||||
TASSERT(strcmp(list[2], "-e") == 0);
|
||||
TASSERT(strcmp(list[3], "bash") == 0);
|
||||
TASSERT(strcmp(list[4], "-c") == 0);
|
||||
TASSERT(strcmp(list[5], "ssh chuck; echo 'x-terminal-emulator chuck'") == 0);
|
||||
TASSERT(strcmp(list[6], "-i") == 0);
|
||||
TASSERT(strcmp(list[7], "-3") == 0);
|
||||
TASSERT(strcmp(list[8], "-u") == 0);
|
||||
TASSERT(strcmp(list[9], "4") == 0);
|
||||
|
||||
cmd_set_arguments(llength, list);
|
||||
TASSERT(find_arg("-e") == 2);
|
||||
TASSERT(find_arg("-x") == -1);
|
||||
char *str;
|
||||
TASSERT(find_arg_str("-e", &str) == TRUE);
|
||||
TASSERT(str == list[3]);
|
||||
TASSERT(find_arg_str("-x", &str) == FALSE);
|
||||
// Should be unmodified.
|
||||
TASSERT(str == list[3]);
|
||||
|
||||
unsigned int u = 1234;
|
||||
int d = -1234;
|
||||
TASSERT(find_arg_uint("-x", &u) == FALSE);
|
||||
TASSERT(u == 1234);
|
||||
TASSERT(find_arg_int("-x", &d) == FALSE);
|
||||
TASSERT(d == -1234);
|
||||
TASSERT(find_arg_uint("-u", &u) == TRUE);
|
||||
TASSERT(u == 4);
|
||||
TASSERT(find_arg_uint("-i", &u) == TRUE);
|
||||
TASSERT(u == 4294967293);
|
||||
TASSERT(find_arg_int("-i", &d) == TRUE);
|
||||
TASSERT(d == -3);
|
||||
|
||||
g_strfreev(list);
|
||||
}
|
||||
|
|
|
@ -25,116 +25,107 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <locale.h>
|
||||
#include <glib.h>
|
||||
#include <stdio.h>
|
||||
#include <helper.h>
|
||||
#include <string.h>
|
||||
#include "theme.h"
|
||||
#include "display.h"
|
||||
#include "rofi-icon-fetcher.h"
|
||||
#include "rofi.h"
|
||||
#include "settings.h"
|
||||
#include "theme.h"
|
||||
#include "widgets/textbox.h"
|
||||
#include "rofi-icon-fetcher.h"
|
||||
#include "xcb-internal.h"
|
||||
#include "xcb.h"
|
||||
#include <assert.h>
|
||||
#include <glib.h>
|
||||
#include <helper.h>
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static int test = 0;
|
||||
static int test = 0;
|
||||
|
||||
#define TASSERT( a ) { \
|
||||
assert ( a ); \
|
||||
printf ( "Test %i passed (%s)\n", ++test, # a ); \
|
||||
}
|
||||
#define TASSERTE( a, b ) { \
|
||||
if ( ( a ) == ( b ) ) { \
|
||||
printf ( "Test %i passed (%s == %s) (%u == %u)\n", ++test, # a, # b, a, b ); \
|
||||
} else { \
|
||||
printf ( "Test %i failed (%s == %s) (%u != %u)\n", ++test, # a, # b, a, b ); \
|
||||
abort ( ); \
|
||||
} \
|
||||
}
|
||||
#define TASSERT(a) \
|
||||
{ \
|
||||
assert(a); \
|
||||
printf("Test %i passed (%s)\n", ++test, #a); \
|
||||
}
|
||||
#define TASSERTE(a, b) \
|
||||
{ \
|
||||
if ((a) == (b)) { \
|
||||
printf("Test %i passed (%s == %s) (%u == %u)\n", ++test, #a, #b, a, b); \
|
||||
} else { \
|
||||
printf("Test %i failed (%s == %s) (%u != %u)\n", ++test, #a, #b, a, b); \
|
||||
abort(); \
|
||||
} \
|
||||
}
|
||||
ThemeWidget *rofi_theme = NULL;
|
||||
void rofi_clear_error_messages ( void ) {}
|
||||
uint32_t rofi_icon_fetcher_query ( const char *name, const int size )
|
||||
{
|
||||
void rofi_clear_error_messages(void) {}
|
||||
void rofi_clear_warning_messages(void) {}
|
||||
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int size) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t rofi_icon_fetcher_query_advanced ( const char *name, const int wsize, const int hsize )
|
||||
{
|
||||
uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int wsize,
|
||||
G_GNUC_UNUSED const int hsize) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid )
|
||||
{
|
||||
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
double textbox_get_estimated_char_height ( void )
|
||||
{
|
||||
return 12.0;
|
||||
double textbox_get_estimated_char_height(void) { return 12.0; }
|
||||
void rofi_view_get_current_monitor(int *width, int *height) {
|
||||
*width = 1920;
|
||||
*height = 1080;
|
||||
}
|
||||
void rofi_view_get_current_monitor ( int *width, int *height )
|
||||
{
|
||||
*width = 1920;
|
||||
*height = 1080;
|
||||
}
|
||||
double textbox_get_estimated_ch ( void )
|
||||
{
|
||||
return 9.0;
|
||||
}
|
||||
gboolean rofi_theme_parse_string ( const char *string )
|
||||
{
|
||||
return 0;
|
||||
double textbox_get_estimated_ch(void) { return 9.0; }
|
||||
gboolean rofi_theme_parse_string(G_GNUC_UNUSED const char *string) { return 0; }
|
||||
|
||||
void rofi_add_error_message(G_GNUC_UNUSED GString *msg) {}
|
||||
void rofi_add_warning_message(G_GNUC_UNUSED GString *msg) {}
|
||||
|
||||
int rofi_view_error_dialog(const char *msg, G_GNUC_UNUSED int markup) {
|
||||
fputs(msg, stderr);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void rofi_add_error_message ( G_GNUC_UNUSED GString *msg )
|
||||
{
|
||||
}
|
||||
|
||||
int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
|
||||
{
|
||||
fputs ( msg, stderr );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int monitor_active ( G_GNUC_UNUSED workarea *mon )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void display_startup_notification ( G_GNUC_UNUSED RofiHelperExecuteContext *context, G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup, G_GNUC_UNUSED gpointer *user_data )
|
||||
{
|
||||
}
|
||||
|
||||
int main ( int argc, char **argv )
|
||||
{
|
||||
cmd_set_arguments ( argc, argv );
|
||||
|
||||
if ( setlocale ( LC_ALL, "" ) == NULL ) {
|
||||
fprintf ( stderr, "Failed to set locale.\n" );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test some path functions. Not easy as not sure what is right output on travis.
|
||||
*/
|
||||
// Test if root is preserved.
|
||||
char *str = rofi_expand_path ( "/" );
|
||||
TASSERT ( strcmp ( str, "/" ) == 0 );
|
||||
g_free ( str );
|
||||
// Test is relative path is preserved.
|
||||
str = rofi_expand_path ( "../AUTHORS" );
|
||||
TASSERT ( strcmp ( str, "../AUTHORS" ) == 0 );
|
||||
g_free ( str );
|
||||
// Test another one.
|
||||
str = rofi_expand_path ( "/bin/false" );
|
||||
TASSERT ( strcmp ( str, "/bin/false" ) == 0 );
|
||||
g_free ( str );
|
||||
// See if user paths get expanded in full path.
|
||||
str = rofi_expand_path ( "~/" );
|
||||
const char *hd = g_get_home_dir ();
|
||||
TASSERT ( strcmp ( str, hd ) == 0 );
|
||||
g_free ( str );
|
||||
str = rofi_expand_path ( "~root/" );
|
||||
TASSERT ( str[0] == '/' );
|
||||
g_free ( str );
|
||||
int monitor_active(G_GNUC_UNUSED workarea *mon) { return 0; }
|
||||
|
||||
void display_startup_notification(
|
||||
G_GNUC_UNUSED RofiHelperExecuteContext *context,
|
||||
G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup,
|
||||
G_GNUC_UNUSED gpointer *user_data) {}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
cmd_set_arguments(argc, argv);
|
||||
|
||||
if (setlocale(LC_ALL, "") == NULL) {
|
||||
fprintf(stderr, "Failed to set locale.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test some path functions. Not easy as not sure what is right output on
|
||||
* travis.
|
||||
*/
|
||||
// Test if root is preserved.
|
||||
char *str = rofi_expand_path("/");
|
||||
TASSERT(strcmp(str, "/") == 0);
|
||||
g_free(str);
|
||||
// Test is relative path is preserved.
|
||||
str = rofi_expand_path("../AUTHORS");
|
||||
TASSERT(strcmp(str, "../AUTHORS") == 0);
|
||||
g_free(str);
|
||||
// Test another one.
|
||||
str = rofi_expand_path("/bin/false");
|
||||
TASSERT(strcmp(str, "/bin/false") == 0);
|
||||
g_free(str);
|
||||
// See if user paths get expanded in full path.
|
||||
str = rofi_expand_path("~/");
|
||||
const char *hd = g_get_home_dir();
|
||||
TASSERT(strcmp(str, hd) == 0);
|
||||
g_free(str);
|
||||
str = rofi_expand_path("~root/");
|
||||
TASSERT(str[0] == '/');
|
||||
g_free(str);
|
||||
}
|
||||
|
|
|
@ -47,17 +47,26 @@ static int test = 0;
|
|||
#include "theme.h"
|
||||
ThemeWidget *rofi_theme = NULL;
|
||||
|
||||
uint32_t rofi_icon_fetcher_query(const char *name, const int size) { return 0; }
|
||||
uint32_t rofi_icon_fetcher_query_advanced(const char *name, const int wsize,
|
||||
const int hsize) {
|
||||
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int size) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int wsize,
|
||||
G_GNUC_UNUSED const int hsize) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
cairo_surface_t *rofi_icon_fetcher_get(const uint32_t uid) { return NULL; }
|
||||
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void rofi_clear_error_messages(void) {}
|
||||
void rofi_clear_warning_messages(void) {}
|
||||
|
||||
gboolean rofi_theme_parse_string(const char *string) { return FALSE; }
|
||||
gboolean rofi_theme_parse_string(G_GNUC_UNUSED const char *string) {
|
||||
return FALSE;
|
||||
}
|
||||
double textbox_get_estimated_char_height(void) { return 12.0; }
|
||||
void rofi_view_get_current_monitor(int *width, int *height) {
|
||||
*width = 1920;
|
||||
|
@ -65,6 +74,7 @@ void rofi_view_get_current_monitor(int *width, int *height) {
|
|||
}
|
||||
double textbox_get_estimated_ch(void) { return 9.0; }
|
||||
void rofi_add_error_message(G_GNUC_UNUSED GString *msg) {}
|
||||
void rofi_add_warning_message(G_GNUC_UNUSED GString *msg) {}
|
||||
int rofi_view_error_dialog(const char *msg, G_GNUC_UNUSED int markup) {
|
||||
fputs(msg, stderr);
|
||||
return TRUE;
|
||||
|
|
|
@ -25,202 +25,222 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <locale.h>
|
||||
#include <glib.h>
|
||||
#include <stdio.h>
|
||||
#include <helper.h>
|
||||
#include <string.h>
|
||||
#include "theme.h"
|
||||
#include "display.h"
|
||||
#include "rofi-icon-fetcher.h"
|
||||
#include "rofi.h"
|
||||
#include "settings.h"
|
||||
#include "rofi-icon-fetcher.h"
|
||||
#include "theme.h"
|
||||
#include "xcb-internal.h"
|
||||
#include "xcb.h"
|
||||
#include <assert.h>
|
||||
#include <glib.h>
|
||||
#include <helper.h>
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static int test = 0;
|
||||
static int test = 0;
|
||||
|
||||
#define TASSERT( a ) { \
|
||||
assert ( a ); \
|
||||
printf ( "Test %i passed (%s)\n", ++test, # a ); \
|
||||
}
|
||||
#define TASSERTE( a, b ) { \
|
||||
if ( ( a ) == ( b ) ) { \
|
||||
printf ( "Test %i passed (%s == %s) (%u == %u)\n", ++test, # a, # b, a, b ); \
|
||||
} else { \
|
||||
printf ( "Test %i failed (%s == %s) (%u != %u)\n", ++test, # a, # b, a, b ); \
|
||||
abort ( ); \
|
||||
} \
|
||||
}
|
||||
#define TASSERTL( a, b ) { \
|
||||
if ( ( a ) == ( b ) ) { \
|
||||
printf ( "Test %i passed (%s == %s) (%d == %d)\n", ++test, # a, # b, a, b ); \
|
||||
} else { \
|
||||
printf ( "Test %i failed (%s == %s) (%d != %d)\n", ++test, # a, # b, a, b ); \
|
||||
abort ( ); \
|
||||
} \
|
||||
}
|
||||
#define TASSERT(a) \
|
||||
{ \
|
||||
assert(a); \
|
||||
printf("Test %i passed (%s)\n", ++test, #a); \
|
||||
}
|
||||
#define TASSERTE(a, b) \
|
||||
{ \
|
||||
if ((a) == (b)) { \
|
||||
printf("Test %i passed (%s == %s) (%u == %u)\n", ++test, #a, #b, a, b); \
|
||||
} else { \
|
||||
printf("Test %i failed (%s == %s) (%u != %u)\n", ++test, #a, #b, a, b); \
|
||||
abort(); \
|
||||
} \
|
||||
}
|
||||
#define TASSERTL(a, b) \
|
||||
{ \
|
||||
if ((a) == (b)) { \
|
||||
printf("Test %i passed (%s == %s) (%d == %d)\n", ++test, #a, #b, a, b); \
|
||||
} else { \
|
||||
printf("Test %i failed (%s == %s) (%d != %d)\n", ++test, #a, #b, a, b); \
|
||||
abort(); \
|
||||
} \
|
||||
}
|
||||
|
||||
#include "widgets/textbox.h"
|
||||
|
||||
ThemeWidget *rofi_theme = NULL;
|
||||
|
||||
gboolean rofi_theme_parse_string ( const char *string )
|
||||
{
|
||||
gboolean rofi_theme_parse_string(G_GNUC_UNUSED const char *string) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
uint32_t rofi_icon_fetcher_query ( const char *name, const int size )
|
||||
{
|
||||
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int size) {
|
||||
return 0;
|
||||
}
|
||||
void rofi_clear_error_messages ( void ) {}
|
||||
uint32_t rofi_icon_fetcher_query_advanced ( const char *name, const int wsize, const int hsize )
|
||||
{
|
||||
void rofi_clear_error_messages(void) {}
|
||||
void rofi_clear_warning_messages(void) {}
|
||||
uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int wsize,
|
||||
G_GNUC_UNUSED const int hsize) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid )
|
||||
{
|
||||
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
double textbox_get_estimated_char_height ( void )
|
||||
{
|
||||
return 12.0;
|
||||
double textbox_get_estimated_char_height(void) { return 12.0; }
|
||||
void rofi_view_get_current_monitor(int *width, int *height) {
|
||||
*width = 1920;
|
||||
*height = 1080;
|
||||
}
|
||||
void rofi_view_get_current_monitor ( int *width, int *height )
|
||||
{
|
||||
*width = 1920;
|
||||
*height = 1080;
|
||||
}
|
||||
double textbox_get_estimated_ch ( void )
|
||||
{
|
||||
return 9.0;
|
||||
}
|
||||
void rofi_add_error_message ( G_GNUC_UNUSED GString *msg )
|
||||
{
|
||||
double textbox_get_estimated_ch(void) { return 9.0; }
|
||||
void rofi_add_error_message(G_GNUC_UNUSED GString *msg) {}
|
||||
void rofi_add_warning_message(G_GNUC_UNUSED GString *msg) {}
|
||||
|
||||
int rofi_view_error_dialog(const char *msg, G_GNUC_UNUSED int markup) {
|
||||
fputs(msg, stderr);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
|
||||
{
|
||||
fputs ( msg, stderr );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int monitor_active ( G_GNUC_UNUSED workarea *mon )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void display_startup_notification ( G_GNUC_UNUSED RofiHelperExecuteContext *context, G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup, G_GNUC_UNUSED gpointer *user_data )
|
||||
{
|
||||
}
|
||||
|
||||
int main ( int argc, char **argv )
|
||||
{
|
||||
cmd_set_arguments ( argc, argv );
|
||||
|
||||
if ( setlocale ( LC_ALL, "" ) == NULL ) {
|
||||
fprintf ( stderr, "Failed to set locale.\n" );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Char function
|
||||
*/
|
||||
|
||||
TASSERT ( helper_parse_char ( "\\n" ) == '\n' );
|
||||
TASSERT ( helper_parse_char ( "\\a" ) == '\a' );
|
||||
TASSERT ( helper_parse_char ( "\\b" ) == '\b' );
|
||||
TASSERT ( helper_parse_char ( "\\t" ) == '\t' );
|
||||
TASSERT ( helper_parse_char ( "\\v" ) == '\v' );
|
||||
TASSERT ( helper_parse_char ( "\\f" ) == '\f' );
|
||||
TASSERT ( helper_parse_char ( "\\r" ) == '\r' );
|
||||
TASSERT ( helper_parse_char ( "\\\\" ) == '\\' );
|
||||
TASSERT ( helper_parse_char ( "\\0" ) == 0 );
|
||||
TASSERT ( helper_parse_char ( "\\x77" ) == 'w' );
|
||||
TASSERT ( helper_parse_char ( "\\x0A" ) == '\n' );
|
||||
|
||||
/**
|
||||
* tokenize
|
||||
*/
|
||||
|
||||
TASSERT ( levenshtein ( "aap", g_utf8_strlen ( "aap", -1), "aap", g_utf8_strlen ( "aap", -1) ) == 0 );
|
||||
TASSERT ( levenshtein ( "aap", g_utf8_strlen ( "aap", -1), "aap ", g_utf8_strlen ( "aap ", -1) ) == 1 );
|
||||
TASSERT ( levenshtein ( "aap ", g_utf8_strlen ( "aap ", -1), "aap", g_utf8_strlen ( "aap", -1) ) == 1 );
|
||||
TASSERTE ( levenshtein ( "aap", g_utf8_strlen ( "aap", -1), "aap noot", g_utf8_strlen ( "aap noot", -1) ), 5u );
|
||||
TASSERTE ( levenshtein ( "aap", g_utf8_strlen ( "aap", -1), "noot aap", g_utf8_strlen ( "noot aap", -1) ), 5u );
|
||||
TASSERTE ( levenshtein ( "aap", g_utf8_strlen ( "aap", -1), "noot aap mies", g_utf8_strlen ( "noot aap mies", -1) ), 10u );
|
||||
TASSERTE ( levenshtein ( "noot aap mies", g_utf8_strlen ( "noot aap mies", -1), "aap", g_utf8_strlen ( "aap", -1) ), 10u );
|
||||
TASSERTE ( levenshtein ( "otp", g_utf8_strlen ( "otp", -1), "noot aap", g_utf8_strlen ( "noot aap", -1) ), 5u );
|
||||
/**
|
||||
* Quick converision check.
|
||||
*/
|
||||
{
|
||||
char *str = rofi_latin_to_utf8_strdup ( "\xA1\xB5", 2 );
|
||||
TASSERT ( g_utf8_collate ( str, "¡µ" ) == 0 );
|
||||
g_free ( str );
|
||||
}
|
||||
|
||||
{
|
||||
char *str = rofi_force_utf8 ( "Valid utf8", 10 );
|
||||
TASSERT ( g_utf8_collate ( str, "Valid utf8" ) == 0 );
|
||||
g_free ( str );
|
||||
char in[] = "Valid utf8 until \xc3\x28 we continue here";
|
||||
TASSERT ( g_utf8_validate ( in, -1, NULL ) == FALSE );
|
||||
str = rofi_force_utf8 ( in, strlen ( in ) );
|
||||
TASSERT ( g_utf8_validate ( str, -1, NULL ) == TRUE );
|
||||
TASSERT ( g_utf8_collate ( str, "Valid utf8 until <20>( we continue here" ) == 0 );
|
||||
g_free ( str );
|
||||
}
|
||||
{
|
||||
TASSERT ( utf8_strncmp ( "aapno", "aap€",3) == 0 );
|
||||
TASSERT ( utf8_strncmp ( "aapno", "aap€",4) != 0 );
|
||||
TASSERT ( utf8_strncmp ( "aapno", "a",4) != 0 );
|
||||
TASSERT ( utf8_strncmp ( "a", "aap€",4) != 0 );
|
||||
// char in[] = "Valid utf8 until \xc3\x28 we continue here";
|
||||
// TASSERT ( utf8_strncmp ( in, "Valid", 3 ) == 0);
|
||||
}
|
||||
{
|
||||
TASSERTL ( rofi_scorer_fuzzy_evaluate ("aap noot mies", 12 , "aap noot mies", 12), -605);
|
||||
TASSERTL ( rofi_scorer_fuzzy_evaluate ("anm", 3, "aap noot mies", 12), -155);
|
||||
TASSERTL ( rofi_scorer_fuzzy_evaluate ("blu", 3, "aap noot mies", 12), 1073741824);
|
||||
config.case_sensitive = TRUE;
|
||||
TASSERTL ( rofi_scorer_fuzzy_evaluate ("Anm", 3, "aap noot mies", 12), 1073741754);
|
||||
config.case_sensitive = FALSE;
|
||||
TASSERTL ( rofi_scorer_fuzzy_evaluate ("Anm", 3, "aap noot mies", 12), -155);
|
||||
TASSERTL ( rofi_scorer_fuzzy_evaluate ("aap noot mies", 12,"Anm", 3 ), 1073741824);
|
||||
|
||||
}
|
||||
|
||||
|
||||
char *a;
|
||||
a = helper_string_replace_if_exists ( "{terminal} [-t {title} blub ]-e {cmd}", "{cmd}", "aap", "{title}", "some title", "{terminal}", "rofi-sensible-terminal", NULL);
|
||||
printf("%s\n",a);
|
||||
TASSERT ( g_utf8_collate ( a, "rofi-sensible-terminal -t some title blub -e aap") == 0);
|
||||
g_free(a);
|
||||
a = helper_string_replace_if_exists ( "{terminal} [-t {title} blub ]-e {cmd}", "{cmd}", "aap", "{terminal}", "rofi-sensible-terminal", NULL);
|
||||
printf("%s\n",a);
|
||||
TASSERT ( g_utf8_collate ( a, "rofi-sensible-terminal -e aap") == 0);
|
||||
g_free(a);
|
||||
a = helper_string_replace_if_exists ( "{name} [<span weight='light' size='small'><i>({category})</i></span>]", "{name}", "Librecad", "{category}", "Desktop app", "{terminal}", "rofi-sensible-terminal", NULL );
|
||||
printf("%s\n",a);
|
||||
TASSERT ( g_utf8_collate ( a, "Librecad <span weight='light' size='small'><i>(Desktop app)</i></span>") == 0);
|
||||
g_free(a);
|
||||
a = helper_string_replace_if_exists ( "{name}[ <span weight='light' size='small'><i>({category})</i></span>]", "{name}", "Librecad", "{terminal}", "rofi-sensible-terminal", NULL );
|
||||
TASSERT ( g_utf8_collate ( a, "Librecad") == 0);
|
||||
g_free(a);
|
||||
a = helper_string_replace_if_exists ( "{terminal} [{title} blub ]-e {cmd}", "{cmd}", "aap", "{title}", "some title", "{terminal}", "rofi-sensible-terminal", NULL);
|
||||
printf("%s\n",a);
|
||||
TASSERT ( g_utf8_collate ( a, "rofi-sensible-terminal some title blub -e aap") == 0);
|
||||
g_free(a);
|
||||
a = helper_string_replace_if_exists ( "{terminal} [{title} blub ]-e {cmd}",
|
||||
"{cmd}", "aap",
|
||||
"{title}", NULL,
|
||||
"{terminal}", "rofi-sensible-terminal",
|
||||
NULL);
|
||||
printf("%s\n",a);
|
||||
TASSERT ( g_utf8_collate ( a, "rofi-sensible-terminal -e aap") == 0);
|
||||
g_free(a);
|
||||
int monitor_active(G_GNUC_UNUSED workarea *mon) { return 0; }
|
||||
|
||||
void display_startup_notification(
|
||||
G_GNUC_UNUSED RofiHelperExecuteContext *context,
|
||||
G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup,
|
||||
G_GNUC_UNUSED gpointer *user_data) {}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
cmd_set_arguments(argc, argv);
|
||||
|
||||
if (setlocale(LC_ALL, "") == NULL) {
|
||||
fprintf(stderr, "Failed to set locale.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Char function
|
||||
*/
|
||||
|
||||
TASSERT(helper_parse_char("\\n") == '\n');
|
||||
TASSERT(helper_parse_char("\\a") == '\a');
|
||||
TASSERT(helper_parse_char("\\b") == '\b');
|
||||
TASSERT(helper_parse_char("\\t") == '\t');
|
||||
TASSERT(helper_parse_char("\\v") == '\v');
|
||||
TASSERT(helper_parse_char("\\f") == '\f');
|
||||
TASSERT(helper_parse_char("\\r") == '\r');
|
||||
TASSERT(helper_parse_char("\\\\") == '\\');
|
||||
TASSERT(helper_parse_char("\\0") == 0);
|
||||
TASSERT(helper_parse_char("\\x77") == 'w');
|
||||
TASSERT(helper_parse_char("\\x0A") == '\n');
|
||||
|
||||
/**
|
||||
* tokenize
|
||||
*/
|
||||
|
||||
TASSERT(levenshtein("aap", g_utf8_strlen("aap", -1), "aap",
|
||||
g_utf8_strlen("aap", -1)) == 0);
|
||||
TASSERT(levenshtein("aap", g_utf8_strlen("aap", -1), "aap ",
|
||||
g_utf8_strlen("aap ", -1)) == 1);
|
||||
TASSERT(levenshtein("aap ", g_utf8_strlen("aap ", -1), "aap",
|
||||
g_utf8_strlen("aap", -1)) == 1);
|
||||
TASSERTE(levenshtein("aap", g_utf8_strlen("aap", -1), "aap noot",
|
||||
g_utf8_strlen("aap noot", -1)),
|
||||
5u);
|
||||
TASSERTE(levenshtein("aap", g_utf8_strlen("aap", -1), "noot aap",
|
||||
g_utf8_strlen("noot aap", -1)),
|
||||
5u);
|
||||
TASSERTE(levenshtein("aap", g_utf8_strlen("aap", -1), "noot aap mies",
|
||||
g_utf8_strlen("noot aap mies", -1)),
|
||||
10u);
|
||||
TASSERTE(levenshtein("noot aap mies", g_utf8_strlen("noot aap mies", -1),
|
||||
"aap", g_utf8_strlen("aap", -1)),
|
||||
10u);
|
||||
TASSERTE(levenshtein("otp", g_utf8_strlen("otp", -1), "noot aap",
|
||||
g_utf8_strlen("noot aap", -1)),
|
||||
5u);
|
||||
/**
|
||||
* Quick converision check.
|
||||
*/
|
||||
{
|
||||
char *str = rofi_latin_to_utf8_strdup("\xA1\xB5", 2);
|
||||
TASSERT(g_utf8_collate(str, "¡µ") == 0);
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
{
|
||||
char *str = rofi_force_utf8("Valid utf8", 10);
|
||||
TASSERT(g_utf8_collate(str, "Valid utf8") == 0);
|
||||
g_free(str);
|
||||
char in[] = "Valid utf8 until \xc3\x28 we continue here";
|
||||
TASSERT(g_utf8_validate(in, -1, NULL) == FALSE);
|
||||
str = rofi_force_utf8(in, strlen(in));
|
||||
TASSERT(g_utf8_validate(str, -1, NULL) == TRUE);
|
||||
TASSERT(g_utf8_collate(str, "Valid utf8 until <20>( we continue here") == 0);
|
||||
g_free(str);
|
||||
}
|
||||
{
|
||||
TASSERT(utf8_strncmp("aapno", "aap€", 3) == 0);
|
||||
TASSERT(utf8_strncmp("aapno", "aap€", 4) != 0);
|
||||
TASSERT(utf8_strncmp("aapno", "a", 4) != 0);
|
||||
TASSERT(utf8_strncmp("a", "aap€", 4) != 0);
|
||||
// char in[] = "Valid utf8 until \xc3\x28 we continue here";
|
||||
// TASSERT ( utf8_strncmp ( in, "Valid", 3 ) == 0);
|
||||
}
|
||||
{
|
||||
TASSERTL(
|
||||
rofi_scorer_fuzzy_evaluate("aap noot mies", 12, "aap noot mies", 12),
|
||||
-605);
|
||||
TASSERTL(rofi_scorer_fuzzy_evaluate("anm", 3, "aap noot mies", 12), -155);
|
||||
TASSERTL(rofi_scorer_fuzzy_evaluate("blu", 3, "aap noot mies", 12),
|
||||
1073741824);
|
||||
config.case_sensitive = TRUE;
|
||||
TASSERTL(rofi_scorer_fuzzy_evaluate("Anm", 3, "aap noot mies", 12),
|
||||
1073741754);
|
||||
config.case_sensitive = FALSE;
|
||||
TASSERTL(rofi_scorer_fuzzy_evaluate("Anm", 3, "aap noot mies", 12), -155);
|
||||
TASSERTL(rofi_scorer_fuzzy_evaluate("aap noot mies", 12, "Anm", 3),
|
||||
1073741824);
|
||||
}
|
||||
|
||||
char *a;
|
||||
a = helper_string_replace_if_exists(
|
||||
"{terminal} [-t {title} blub ]-e {cmd}", "{cmd}", "aap", "{title}",
|
||||
"some title", "{terminal}", "rofi-sensible-terminal", NULL);
|
||||
printf("%s\n", a);
|
||||
TASSERT(g_utf8_collate(
|
||||
a, "rofi-sensible-terminal -t some title blub -e aap") == 0);
|
||||
g_free(a);
|
||||
a = helper_string_replace_if_exists("{terminal} [-t {title} blub ]-e {cmd}",
|
||||
"{cmd}", "aap", "{terminal}",
|
||||
"rofi-sensible-terminal", NULL);
|
||||
printf("%s\n", a);
|
||||
TASSERT(g_utf8_collate(a, "rofi-sensible-terminal -e aap") == 0);
|
||||
g_free(a);
|
||||
a = helper_string_replace_if_exists(
|
||||
"{name} [<span weight='light' size='small'><i>({category})</i></span>]",
|
||||
"{name}", "Librecad", "{category}", "Desktop app", "{terminal}",
|
||||
"rofi-sensible-terminal", NULL);
|
||||
printf("%s\n", a);
|
||||
TASSERT(g_utf8_collate(a, "Librecad <span weight='light' "
|
||||
"size='small'><i>(Desktop app)</i></span>") == 0);
|
||||
g_free(a);
|
||||
a = helper_string_replace_if_exists(
|
||||
"{name}[ <span weight='light' size='small'><i>({category})</i></span>]",
|
||||
"{name}", "Librecad", "{terminal}", "rofi-sensible-terminal", NULL);
|
||||
TASSERT(g_utf8_collate(a, "Librecad") == 0);
|
||||
g_free(a);
|
||||
a = helper_string_replace_if_exists(
|
||||
"{terminal} [{title} blub ]-e {cmd}", "{cmd}", "aap", "{title}",
|
||||
"some title", "{terminal}", "rofi-sensible-terminal", NULL);
|
||||
printf("%s\n", a);
|
||||
TASSERT(g_utf8_collate(a, "rofi-sensible-terminal some title blub -e aap") ==
|
||||
0);
|
||||
g_free(a);
|
||||
a = helper_string_replace_if_exists(
|
||||
"{terminal} [{title} blub ]-e {cmd}", "{cmd}", "aap", "{title}", NULL,
|
||||
"{terminal}", "rofi-sensible-terminal", NULL);
|
||||
printf("%s\n", a);
|
||||
TASSERT(g_utf8_collate(a, "rofi-sensible-terminal -e aap") == 0);
|
||||
g_free(a);
|
||||
}
|
||||
|
|
|
@ -25,480 +25,440 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <locale.h>
|
||||
#include <glib.h>
|
||||
#include <stdio.h>
|
||||
#include <helper.h>
|
||||
#include <string.h>
|
||||
#include "display.h"
|
||||
#include "theme.h"
|
||||
#include "rofi-icon-fetcher.h"
|
||||
#include "rofi-types.h"
|
||||
#include "rofi.h"
|
||||
#include "settings.h"
|
||||
#include "rofi-types.h"
|
||||
#include "theme.h"
|
||||
#include "widgets/textbox.h"
|
||||
#include "rofi-icon-fetcher.h"
|
||||
#include "xcb-internal.h"
|
||||
#include "xcb.h"
|
||||
#include <assert.h>
|
||||
#include <glib.h>
|
||||
#include <helper.h>
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <check.h>
|
||||
|
||||
ThemeWidget *rofi_theme = NULL;
|
||||
|
||||
uint32_t rofi_icon_fetcher_query ( const char *name, const int size )
|
||||
{
|
||||
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int size) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t rofi_icon_fetcher_query_advanced ( const char *name, const int wsize, const int hsize )
|
||||
{
|
||||
uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int wsize,
|
||||
G_GNUC_UNUSED const int hsize) {
|
||||
return 0;
|
||||
}
|
||||
void rofi_clear_error_messages ( void ) {}
|
||||
void rofi_clear_error_messages(void) {}
|
||||
void rofi_clear_warning_messages(void) {}
|
||||
|
||||
cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid )
|
||||
{
|
||||
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean rofi_theme_parse_string ( G_GNUC_UNUSED const char *string )
|
||||
{
|
||||
gboolean rofi_theme_parse_string(G_GNUC_UNUSED const char *string) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
double textbox_get_estimated_char_height ( void )
|
||||
{
|
||||
return 12.0;
|
||||
double textbox_get_estimated_char_height(void) { return 12.0; }
|
||||
void rofi_view_get_current_monitor(int *width, int *height) {
|
||||
*width = 1920;
|
||||
*height = 1080;
|
||||
}
|
||||
void rofi_view_get_current_monitor ( int *width, int *height )
|
||||
{
|
||||
*width = 1920;
|
||||
*height = 1080;
|
||||
}
|
||||
double textbox_get_estimated_ch ( void )
|
||||
{
|
||||
return 9.0;
|
||||
}
|
||||
void rofi_add_error_message ( G_GNUC_UNUSED GString *msg )
|
||||
{
|
||||
}
|
||||
int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
|
||||
{
|
||||
fputs ( msg, stderr );
|
||||
return TRUE;
|
||||
}
|
||||
int monitor_active ( G_GNUC_UNUSED workarea *mon )
|
||||
{
|
||||
return 0;
|
||||
double textbox_get_estimated_ch(void) { return 9.0; }
|
||||
void rofi_add_error_message(G_GNUC_UNUSED GString *msg) {}
|
||||
void rofi_add_warning_message(G_GNUC_UNUSED GString *msg) {}
|
||||
int rofi_view_error_dialog(const char *msg, G_GNUC_UNUSED int markup) {
|
||||
fputs(msg, stderr);
|
||||
return TRUE;
|
||||
}
|
||||
int monitor_active(G_GNUC_UNUSED workarea *mon) { return 0; }
|
||||
|
||||
void display_startup_notification ( G_GNUC_UNUSED RofiHelperExecuteContext *context, G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup, G_GNUC_UNUSED gpointer *user_data )
|
||||
{
|
||||
}
|
||||
START_TEST(test_tokenizer_free )
|
||||
{
|
||||
helper_tokenize_free ( NULL );
|
||||
}
|
||||
void display_startup_notification(
|
||||
G_GNUC_UNUSED RofiHelperExecuteContext *context,
|
||||
G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup,
|
||||
G_GNUC_UNUSED gpointer *user_data) {}
|
||||
START_TEST(test_tokenizer_free) { helper_tokenize_free(NULL); }
|
||||
END_TEST
|
||||
START_TEST ( test_tokenizer_match_normal_single_ci )
|
||||
{
|
||||
config.matching_method = MM_NORMAL;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "noot", FALSE );
|
||||
START_TEST(test_tokenizer_match_normal_single_ci) {
|
||||
config.matching_method = MM_NORMAL;
|
||||
rofi_int_matcher **tokens = helper_tokenize("noot", FALSE);
|
||||
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap Noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "Nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noOTap mies") , TRUE );
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap Noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "Nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noOTap mies"), TRUE);
|
||||
|
||||
helper_tokenize_free ( tokens );
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST ( test_tokenizer_match_normal_single_cs )
|
||||
{
|
||||
config.matching_method = MM_NORMAL;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "noot", TRUE );
|
||||
START_TEST(test_tokenizer_match_normal_single_cs) {
|
||||
config.matching_method = MM_NORMAL;
|
||||
rofi_int_matcher **tokens = helper_tokenize("noot", TRUE);
|
||||
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap Noot mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "Nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noOTap mies") , FALSE );
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap Noot mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "Nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noOTap mies"), FALSE);
|
||||
|
||||
helper_tokenize_free ( tokens );
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST ( test_tokenizer_match_normal_multiple_ci )
|
||||
{
|
||||
config.matching_method = MM_NORMAL;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "no ot", FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE );
|
||||
helper_tokenize_free ( tokens );
|
||||
|
||||
START_TEST(test_tokenizer_match_normal_multiple_ci) {
|
||||
config.matching_method = MM_NORMAL;
|
||||
rofi_int_matcher **tokens = helper_tokenize("no ot", FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), TRUE);
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST ( test_tokenizer_match_normal_single_ci_negate )
|
||||
{
|
||||
config.matching_method = MM_NORMAL;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "-noot", FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE );
|
||||
helper_tokenize_free ( tokens );
|
||||
START_TEST(test_tokenizer_match_normal_single_ci_negate) {
|
||||
config.matching_method = MM_NORMAL;
|
||||
rofi_int_matcher **tokens = helper_tokenize("-noot", FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), TRUE);
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST ( test_tokenizer_match_normal_multiple_ci_negate )
|
||||
{
|
||||
config.matching_method = MM_NORMAL;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "-noot aap", FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , FALSE );
|
||||
helper_tokenize_free ( tokens );
|
||||
|
||||
START_TEST(test_tokenizer_match_normal_multiple_ci_negate) {
|
||||
config.matching_method = MM_NORMAL;
|
||||
rofi_int_matcher **tokens = helper_tokenize("-noot aap", FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), FALSE);
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST ( test_tokenizer_match_glob_single_ci )
|
||||
{
|
||||
config.matching_method = MM_GLOB;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "noot", FALSE );
|
||||
START_TEST(test_tokenizer_match_glob_single_ci) {
|
||||
config.matching_method = MM_GLOB;
|
||||
rofi_int_matcher **tokens = helper_tokenize("noot", FALSE);
|
||||
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap Noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "Nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noOTap mies") , TRUE );
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap Noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "Nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noOTap mies"), TRUE);
|
||||
|
||||
helper_tokenize_free ( tokens );
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST ( test_tokenizer_match_glob_single_cs )
|
||||
{
|
||||
config.matching_method = MM_GLOB;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "noot", TRUE );
|
||||
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap Noot mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "Nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noOTap mies") , FALSE );
|
||||
helper_tokenize_free ( tokens );
|
||||
START_TEST(test_tokenizer_match_glob_single_cs) {
|
||||
config.matching_method = MM_GLOB;
|
||||
rofi_int_matcher **tokens = helper_tokenize("noot", TRUE);
|
||||
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap Noot mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "Nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noOTap mies"), FALSE);
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST ( test_tokenizer_match_glob_multiple_ci )
|
||||
{
|
||||
config.matching_method = MM_GLOB;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "no ot", FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE );
|
||||
helper_tokenize_free ( tokens );
|
||||
START_TEST(test_tokenizer_match_glob_multiple_ci) {
|
||||
config.matching_method = MM_GLOB;
|
||||
rofi_int_matcher **tokens = helper_tokenize("no ot", FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), TRUE);
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST ( test_tokenizer_match_glob_single_ci_question )
|
||||
{
|
||||
config.matching_method = MM_GLOB;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "n?ot", FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , FALSE);
|
||||
helper_tokenize_free ( tokens );
|
||||
START_TEST(test_tokenizer_match_glob_single_ci_question) {
|
||||
config.matching_method = MM_GLOB;
|
||||
rofi_int_matcher **tokens = helper_tokenize("n?ot", FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), FALSE);
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST ( test_tokenizer_match_glob_single_ci_star )
|
||||
{
|
||||
config.matching_method = MM_GLOB;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "n*ot", FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE);
|
||||
helper_tokenize_free ( tokens );
|
||||
START_TEST(test_tokenizer_match_glob_single_ci_star) {
|
||||
config.matching_method = MM_GLOB;
|
||||
rofi_int_matcher **tokens = helper_tokenize("n*ot", FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), TRUE);
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST ( test_tokenizer_match_glob_multiple_ci_star )
|
||||
{
|
||||
config.matching_method = MM_GLOB;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "n* ot", FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE);
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "ot nap mies") , TRUE);
|
||||
helper_tokenize_free ( tokens );
|
||||
START_TEST(test_tokenizer_match_glob_multiple_ci_star) {
|
||||
config.matching_method = MM_GLOB;
|
||||
rofi_int_matcher **tokens = helper_tokenize("n* ot", FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "ot nap mies"), TRUE);
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST ( test_tokenizer_match_fuzzy_single_ci )
|
||||
{
|
||||
config.matching_method = MM_FUZZY;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "noot", FALSE );
|
||||
START_TEST(test_tokenizer_match_fuzzy_single_ci) {
|
||||
config.matching_method = MM_FUZZY;
|
||||
rofi_int_matcher **tokens = helper_tokenize("noot", FALSE);
|
||||
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap Noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "Nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noOTap mies") , TRUE );
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap Noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "Nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noOTap mies"), TRUE);
|
||||
|
||||
helper_tokenize_free ( tokens );
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST ( test_tokenizer_match_fuzzy_single_cs )
|
||||
{
|
||||
config.matching_method = MM_FUZZY;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "noot", TRUE );
|
||||
START_TEST(test_tokenizer_match_fuzzy_single_cs) {
|
||||
config.matching_method = MM_FUZZY;
|
||||
rofi_int_matcher **tokens = helper_tokenize("noot", TRUE);
|
||||
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap Noot mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "Nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noOTap mies") , FALSE );
|
||||
helper_tokenize_free ( tokens );
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap Noot mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "Nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noOTap mies"), FALSE);
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST ( test_tokenizer_match_fuzzy_multiple_ci )
|
||||
{
|
||||
config.matching_method = MM_FUZZY;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "no ot", FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE );
|
||||
helper_tokenize_free ( tokens );
|
||||
START_TEST(test_tokenizer_match_fuzzy_multiple_ci) {
|
||||
config.matching_method = MM_FUZZY;
|
||||
rofi_int_matcher **tokens = helper_tokenize("no ot", FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), TRUE);
|
||||
helper_tokenize_free(tokens);
|
||||
|
||||
tokens = helper_tokenize ( "n ot", FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE);
|
||||
helper_tokenize_free ( tokens );
|
||||
tokens = helper_tokenize("n ot", FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), TRUE);
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST ( test_tokenizer_match_fuzzy_single_ci_split )
|
||||
{
|
||||
config.matching_method = MM_FUZZY;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "ont", FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , FALSE);
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap nmiest") , TRUE );
|
||||
helper_tokenize_free ( tokens );
|
||||
START_TEST(test_tokenizer_match_fuzzy_single_ci_split) {
|
||||
config.matching_method = MM_FUZZY;
|
||||
rofi_int_matcher **tokens = helper_tokenize("ont", FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap nmiest"), TRUE);
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST ( test_tokenizer_match_fuzzy_multiple_ci_split )
|
||||
{
|
||||
config.matching_method = MM_FUZZY;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "o n t", FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE);
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "ot nap mies") , TRUE);
|
||||
helper_tokenize_free ( tokens );
|
||||
START_TEST(test_tokenizer_match_fuzzy_multiple_ci_split) {
|
||||
config.matching_method = MM_FUZZY;
|
||||
rofi_int_matcher **tokens = helper_tokenize("o n t", FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "ot nap mies"), TRUE);
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST ( test_tokenizer_match_regex_single_ci )
|
||||
{
|
||||
config.matching_method = MM_REGEX;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "noot", FALSE );
|
||||
START_TEST(test_tokenizer_match_regex_single_ci) {
|
||||
config.matching_method = MM_REGEX;
|
||||
rofi_int_matcher **tokens = helper_tokenize("noot", FALSE);
|
||||
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap Noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "Nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noOTap mies") , TRUE );
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap Noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "Nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noOTap mies"), TRUE);
|
||||
|
||||
helper_tokenize_free ( tokens );
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST ( test_tokenizer_match_regex_single_cs )
|
||||
{
|
||||
config.matching_method = MM_REGEX;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "noot", TRUE );
|
||||
START_TEST(test_tokenizer_match_regex_single_cs) {
|
||||
config.matching_method = MM_REGEX;
|
||||
rofi_int_matcher **tokens = helper_tokenize("noot", TRUE);
|
||||
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap Noot mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "Nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noOTap mies") , FALSE );
|
||||
helper_tokenize_free ( tokens );
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap Noot mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "Nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noOTap mies"), FALSE);
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST ( test_tokenizer_match_regex_multiple_ci )
|
||||
{
|
||||
config.matching_method = MM_REGEX;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "no ot", FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE );
|
||||
helper_tokenize_free ( tokens );
|
||||
START_TEST(test_tokenizer_match_regex_multiple_ci) {
|
||||
config.matching_method = MM_REGEX;
|
||||
rofi_int_matcher **tokens = helper_tokenize("no ot", FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), TRUE);
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST ( test_tokenizer_match_regex_single_ci_dq )
|
||||
{
|
||||
config.matching_method = MM_REGEX;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "n.?ot", FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , FALSE);
|
||||
helper_tokenize_free ( tokens );
|
||||
START_TEST(test_tokenizer_match_regex_single_ci_dq) {
|
||||
config.matching_method = MM_REGEX;
|
||||
rofi_int_matcher **tokens = helper_tokenize("n.?ot", FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), FALSE);
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST ( test_tokenizer_match_regex_single_two_char )
|
||||
{
|
||||
config.matching_method = MM_REGEX;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "n[oa]{2}t", FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noat miesot") , TRUE);
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noaat miesot") , FALSE);
|
||||
helper_tokenize_free ( tokens );
|
||||
START_TEST(test_tokenizer_match_regex_single_two_char) {
|
||||
config.matching_method = MM_REGEX;
|
||||
rofi_int_matcher **tokens = helper_tokenize("n[oa]{2}t", FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noat miesot"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noaat miesot"), FALSE);
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST ( test_tokenizer_match_regex_single_two_word_till_end )
|
||||
{
|
||||
config.matching_method = MM_REGEX;
|
||||
rofi_int_matcher **tokens = helper_tokenize ( "^(aap|noap)\\sMie.*", FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , TRUE);
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , FALSE );
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE);
|
||||
ck_assert_int_eq ( helper_token_match ( tokens, "ot nap mies") , FALSE );
|
||||
helper_tokenize_free ( tokens );
|
||||
START_TEST(test_tokenizer_match_regex_single_two_word_till_end) {
|
||||
config.matching_method = MM_REGEX;
|
||||
rofi_int_matcher **tokens = helper_tokenize("^(aap|noap)\\sMie.*", FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), FALSE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), TRUE);
|
||||
ck_assert_int_eq(helper_token_match(tokens, "ot nap mies"), FALSE);
|
||||
helper_tokenize_free(tokens);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static Suite * helper_tokenizer_suite (void)
|
||||
{
|
||||
Suite *s;
|
||||
static Suite *helper_tokenizer_suite(void) {
|
||||
Suite *s;
|
||||
|
||||
s = suite_create("Tokenizer");
|
||||
s = suite_create("Tokenizer");
|
||||
|
||||
/* Core test case */
|
||||
{
|
||||
TCase *tc_core;
|
||||
tc_core = tcase_create("Core");
|
||||
tcase_add_test(tc_core, test_tokenizer_free);
|
||||
suite_add_tcase(s, tc_core);
|
||||
}
|
||||
{
|
||||
TCase *tc_normal = tcase_create ("Normal");
|
||||
tcase_add_test(tc_normal, test_tokenizer_match_normal_single_ci );
|
||||
tcase_add_test(tc_normal, test_tokenizer_match_normal_single_cs );
|
||||
tcase_add_test(tc_normal, test_tokenizer_match_normal_multiple_ci );
|
||||
tcase_add_test(tc_normal, test_tokenizer_match_normal_single_ci_negate );
|
||||
tcase_add_test(tc_normal, test_tokenizer_match_normal_multiple_ci_negate);
|
||||
suite_add_tcase(s, tc_normal);
|
||||
}
|
||||
{
|
||||
TCase *tc_glob = tcase_create ("Glob");
|
||||
tcase_add_test(tc_glob, test_tokenizer_match_glob_single_ci);
|
||||
tcase_add_test(tc_glob, test_tokenizer_match_glob_single_cs);
|
||||
tcase_add_test(tc_glob, test_tokenizer_match_glob_multiple_ci);
|
||||
tcase_add_test(tc_glob, test_tokenizer_match_glob_single_ci_question);
|
||||
tcase_add_test(tc_glob, test_tokenizer_match_glob_single_ci_star);
|
||||
tcase_add_test(tc_glob, test_tokenizer_match_glob_multiple_ci_star);
|
||||
suite_add_tcase(s, tc_glob);
|
||||
}
|
||||
{
|
||||
TCase *tc_fuzzy = tcase_create ("Fuzzy");
|
||||
tcase_add_test(tc_fuzzy, test_tokenizer_match_fuzzy_single_ci);
|
||||
tcase_add_test(tc_fuzzy, test_tokenizer_match_fuzzy_single_cs);
|
||||
tcase_add_test(tc_fuzzy, test_tokenizer_match_fuzzy_single_ci_split);
|
||||
tcase_add_test(tc_fuzzy, test_tokenizer_match_fuzzy_multiple_ci);
|
||||
tcase_add_test(tc_fuzzy, test_tokenizer_match_fuzzy_multiple_ci_split);
|
||||
suite_add_tcase(s, tc_fuzzy);
|
||||
}
|
||||
{
|
||||
TCase *tc_regex = tcase_create ("Regex");
|
||||
tcase_add_test(tc_regex, test_tokenizer_match_regex_single_ci);
|
||||
tcase_add_test(tc_regex, test_tokenizer_match_regex_single_cs);
|
||||
tcase_add_test(tc_regex, test_tokenizer_match_regex_single_ci_dq);
|
||||
tcase_add_test(tc_regex, test_tokenizer_match_regex_single_two_char);
|
||||
tcase_add_test(tc_regex, test_tokenizer_match_regex_single_two_word_till_end);
|
||||
tcase_add_test(tc_regex, test_tokenizer_match_regex_multiple_ci);
|
||||
suite_add_tcase(s, tc_regex);
|
||||
}
|
||||
/* Core test case */
|
||||
{
|
||||
TCase *tc_core;
|
||||
tc_core = tcase_create("Core");
|
||||
tcase_add_test(tc_core, test_tokenizer_free);
|
||||
suite_add_tcase(s, tc_core);
|
||||
}
|
||||
{
|
||||
TCase *tc_normal = tcase_create("Normal");
|
||||
tcase_add_test(tc_normal, test_tokenizer_match_normal_single_ci);
|
||||
tcase_add_test(tc_normal, test_tokenizer_match_normal_single_cs);
|
||||
tcase_add_test(tc_normal, test_tokenizer_match_normal_multiple_ci);
|
||||
tcase_add_test(tc_normal, test_tokenizer_match_normal_single_ci_negate);
|
||||
tcase_add_test(tc_normal, test_tokenizer_match_normal_multiple_ci_negate);
|
||||
suite_add_tcase(s, tc_normal);
|
||||
}
|
||||
{
|
||||
TCase *tc_glob = tcase_create("Glob");
|
||||
tcase_add_test(tc_glob, test_tokenizer_match_glob_single_ci);
|
||||
tcase_add_test(tc_glob, test_tokenizer_match_glob_single_cs);
|
||||
tcase_add_test(tc_glob, test_tokenizer_match_glob_multiple_ci);
|
||||
tcase_add_test(tc_glob, test_tokenizer_match_glob_single_ci_question);
|
||||
tcase_add_test(tc_glob, test_tokenizer_match_glob_single_ci_star);
|
||||
tcase_add_test(tc_glob, test_tokenizer_match_glob_multiple_ci_star);
|
||||
suite_add_tcase(s, tc_glob);
|
||||
}
|
||||
{
|
||||
TCase *tc_fuzzy = tcase_create("Fuzzy");
|
||||
tcase_add_test(tc_fuzzy, test_tokenizer_match_fuzzy_single_ci);
|
||||
tcase_add_test(tc_fuzzy, test_tokenizer_match_fuzzy_single_cs);
|
||||
tcase_add_test(tc_fuzzy, test_tokenizer_match_fuzzy_single_ci_split);
|
||||
tcase_add_test(tc_fuzzy, test_tokenizer_match_fuzzy_multiple_ci);
|
||||
tcase_add_test(tc_fuzzy, test_tokenizer_match_fuzzy_multiple_ci_split);
|
||||
suite_add_tcase(s, tc_fuzzy);
|
||||
}
|
||||
{
|
||||
TCase *tc_regex = tcase_create("Regex");
|
||||
tcase_add_test(tc_regex, test_tokenizer_match_regex_single_ci);
|
||||
tcase_add_test(tc_regex, test_tokenizer_match_regex_single_cs);
|
||||
tcase_add_test(tc_regex, test_tokenizer_match_regex_single_ci_dq);
|
||||
tcase_add_test(tc_regex, test_tokenizer_match_regex_single_two_char);
|
||||
tcase_add_test(tc_regex,
|
||||
test_tokenizer_match_regex_single_two_word_till_end);
|
||||
tcase_add_test(tc_regex, test_tokenizer_match_regex_multiple_ci);
|
||||
suite_add_tcase(s, tc_regex);
|
||||
}
|
||||
|
||||
|
||||
return s;
|
||||
return s;
|
||||
}
|
||||
|
||||
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||
{
|
||||
if ( setlocale ( LC_ALL, "" ) == NULL ) {
|
||||
fprintf ( stderr, "Failed to set locale.\n" );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
int main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) {
|
||||
if (setlocale(LC_ALL, "") == NULL) {
|
||||
fprintf(stderr, "Failed to set locale.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
int number_failed = 0;
|
||||
Suite *s;
|
||||
SRunner *sr;
|
||||
int number_failed = 0;
|
||||
Suite *s;
|
||||
SRunner *sr;
|
||||
|
||||
s = helper_tokenizer_suite();
|
||||
sr = srunner_create(s);
|
||||
|
||||
srunner_run_all(sr, CK_NORMAL);
|
||||
number_failed = srunner_ntests_failed(sr);
|
||||
srunner_free(sr);
|
||||
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
s = helper_tokenizer_suite();
|
||||
sr = srunner_create(s);
|
||||
|
||||
srunner_run_all(sr, CK_NORMAL);
|
||||
number_failed = srunner_ntests_failed(sr);
|
||||
srunner_free(sr);
|
||||
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
@ -49,19 +49,29 @@
|
|||
|
||||
ThemeWidget *rofi_theme = NULL;
|
||||
|
||||
uint32_t rofi_icon_fetcher_query(const char *name, const int size) { return 0; }
|
||||
uint32_t rofi_icon_fetcher_query_advanced(const char *name, const int wsize,
|
||||
const int hsize) {
|
||||
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int size) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int wsize,
|
||||
G_GNUC_UNUSED const int hsize) {
|
||||
return 0;
|
||||
}
|
||||
void rofi_clear_error_messages(void) {}
|
||||
cairo_surface_t *rofi_icon_fetcher_get(const uint32_t uid) { return NULL; }
|
||||
void rofi_clear_warning_messages(void) {}
|
||||
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean rofi_theme_parse_string(const char *string) { return FALSE; }
|
||||
gboolean rofi_theme_parse_string(G_GNUC_UNUSED const char *string) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
double textbox_get_estimated_char_height(void) { return 16.0; }
|
||||
double textbox_get_estimated_ch(void) { return 9.0; }
|
||||
void rofi_add_error_message(G_GNUC_UNUSED GString *msg) {}
|
||||
void rofi_add_warning_message(G_GNUC_UNUSED GString *msg) {}
|
||||
int monitor_active(G_GNUC_UNUSED workarea *d) { return 0; }
|
||||
int rofi_view_error_dialog(const char *msg, G_GNUC_UNUSED int markup) {
|
||||
fputs(msg, stderr);
|
||||
|
|
|
@ -25,135 +25,118 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
#include <widgets/scrollbar.h>
|
||||
#include <widgets/textbox.h>
|
||||
#include <widgets/icon.h>
|
||||
#include <widgets/listview.h>
|
||||
#include <widgets/widget.h>
|
||||
#include <widgets/widget-internal.h>
|
||||
#include "rofi.h"
|
||||
#include "xrmoptions.h"
|
||||
#include "helper.h"
|
||||
#include "display.h"
|
||||
#include "rofi-icon-fetcher.h"
|
||||
unsigned int test =0;
|
||||
#define TASSERT( a ) { \
|
||||
assert ( a ); \
|
||||
printf ( "Test %3u passed (%s)\n", ++test, # a ); \
|
||||
}
|
||||
#include "rofi.h"
|
||||
#include "xrmoptions.h"
|
||||
#include <assert.h>
|
||||
#include <glib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <widgets/icon.h>
|
||||
#include <widgets/listview.h>
|
||||
#include <widgets/scrollbar.h>
|
||||
#include <widgets/textbox.h>
|
||||
#include <widgets/widget-internal.h>
|
||||
#include <widgets/widget.h>
|
||||
unsigned int test = 0;
|
||||
#define TASSERT(a) \
|
||||
{ \
|
||||
assert(a); \
|
||||
printf("Test %3u passed (%s)\n", ++test, #a); \
|
||||
}
|
||||
|
||||
#define TASSERTE( a, b ) { \
|
||||
if ( ( a ) == ( b ) ) { \
|
||||
printf ( "Test %u passed (%s == %s) (%u == %u)\n", ++test, # a, # b, a, b ); \
|
||||
} else { \
|
||||
printf ( "Test %u failed (%s == %s) (%u != %u)\n", ++test, # a, # b, a, b ); \
|
||||
abort ( ); \
|
||||
} \
|
||||
}
|
||||
#define TASSERTE(a, b) \
|
||||
{ \
|
||||
if ((a) == (b)) { \
|
||||
printf("Test %u passed (%s == %s) (%u == %u)\n", ++test, #a, #b, a, b); \
|
||||
} else { \
|
||||
printf("Test %u failed (%s == %s) (%u != %u)\n", ++test, #a, #b, a, b); \
|
||||
abort(); \
|
||||
} \
|
||||
}
|
||||
|
||||
ThemeWidget *rofi_configuration = NULL;
|
||||
|
||||
uint32_t rofi_icon_fetcher_query ( const char *name, const int size )
|
||||
{
|
||||
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int size) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t rofi_icon_fetcher_query_advanced ( const char *name, const int wsize, const int hsize )
|
||||
{
|
||||
uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int wsize,
|
||||
G_GNUC_UNUSED const int hsize) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid )
|
||||
{
|
||||
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int monitor_active ( G_GNUC_UNUSED workarea *mon )
|
||||
{
|
||||
return 0;
|
||||
int monitor_active(G_GNUC_UNUSED workarea *mon) { return 0; }
|
||||
|
||||
char *helper_get_theme_path(const char *file, G_GNUC_UNUSED const char *ext) {
|
||||
return g_strdup(file);
|
||||
}
|
||||
|
||||
char * helper_get_theme_path ( const char *file, const char *ext )
|
||||
{
|
||||
return g_strdup ( file );
|
||||
gboolean config_parse_set_property(G_GNUC_UNUSED const Property *p,
|
||||
G_GNUC_UNUSED char **error) {
|
||||
return FALSE;
|
||||
}
|
||||
gboolean config_parse_set_property ( G_GNUC_UNUSED const Property *p, G_GNUC_UNUSED char **error )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
void rofi_add_error_message ( G_GNUC_UNUSED GString *msg )
|
||||
{}
|
||||
|
||||
char * rofi_expand_path ( G_GNUC_UNUSED const char *path )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
double textbox_get_estimated_char_height ( void )
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
double textbox_get_estimated_ch ( void )
|
||||
{
|
||||
return 8.0;
|
||||
}
|
||||
|
||||
void listview_set_selected ( G_GNUC_UNUSED listview *lv, G_GNUC_UNUSED unsigned int selected )
|
||||
{
|
||||
|
||||
}
|
||||
void rofi_view_get_current_monitor ( G_GNUC_UNUSED int *width, G_GNUC_UNUSED int *height )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||
{
|
||||
scrollbar * sb = scrollbar_create ( NULL, "scrollbar" );
|
||||
widget_resize ( WIDGET (sb), 10, 100);
|
||||
|
||||
scrollbar_set_handle ( NULL, 10213);
|
||||
scrollbar_set_max_value ( NULL, 10 );
|
||||
scrollbar_set_handle_length ( NULL , 1000);
|
||||
|
||||
scrollbar_set_max_value ( sb, 10000);
|
||||
TASSERTE ( sb->length, 10000u );
|
||||
scrollbar_set_handle_length ( sb, 10);
|
||||
TASSERTE ( sb->pos_length, 10u );
|
||||
scrollbar_set_handle ( sb , 5000 );
|
||||
TASSERTE ( sb->pos, 5000u );
|
||||
scrollbar_set_handle ( sb , 15000 );
|
||||
TASSERTE ( sb->pos, 10000u );
|
||||
scrollbar_set_handle ( sb , UINT32_MAX );
|
||||
TASSERTE ( sb->pos, 10000u );
|
||||
scrollbar_set_handle_length ( sb, 15000);
|
||||
TASSERTE ( sb->pos_length, 10000u );
|
||||
scrollbar_set_handle_length ( sb, 0);
|
||||
TASSERTE ( sb->pos_length, 1u );
|
||||
|
||||
|
||||
guint cl = scrollbar_scroll_get_line ( sb, 10 );
|
||||
TASSERTE ( cl, 1010u);
|
||||
cl = scrollbar_scroll_get_line ( sb, 20 );
|
||||
TASSERTE ( cl, 2020u);
|
||||
cl = scrollbar_scroll_get_line ( sb, 0 );
|
||||
TASSERTE ( cl, 0u);
|
||||
cl = scrollbar_scroll_get_line ( sb, 99 );
|
||||
TASSERTE ( cl, 9999u);
|
||||
scrollbar_set_handle_length ( sb, 1000);
|
||||
cl = scrollbar_scroll_get_line ( sb, 10 );
|
||||
TASSERTE ( cl, 555u);
|
||||
cl = scrollbar_scroll_get_line ( sb, 20 );
|
||||
TASSERTE ( cl, 1666u);
|
||||
cl = scrollbar_scroll_get_line ( sb, 0 );
|
||||
TASSERTE ( cl, 0u);
|
||||
cl = scrollbar_scroll_get_line ( sb, 99 );
|
||||
TASSERTE ( cl, 9999u);
|
||||
|
||||
widget_free( WIDGET (sb ) );
|
||||
void rofi_add_error_message(G_GNUC_UNUSED GString *msg) {}
|
||||
void rofi_add_warning_message(G_GNUC_UNUSED GString *msg) {}
|
||||
|
||||
char *rofi_expand_path(G_GNUC_UNUSED const char *path) { return NULL; }
|
||||
double textbox_get_estimated_char_height(void) { return 16; }
|
||||
double textbox_get_estimated_ch(void) { return 8.0; }
|
||||
|
||||
void listview_set_selected(G_GNUC_UNUSED listview *lv,
|
||||
G_GNUC_UNUSED unsigned int selected) {}
|
||||
void rofi_view_get_current_monitor(G_GNUC_UNUSED int *width,
|
||||
G_GNUC_UNUSED int *height) {}
|
||||
|
||||
int main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) {
|
||||
scrollbar *sb = scrollbar_create(NULL, "scrollbar");
|
||||
widget_resize(WIDGET(sb), 10, 100);
|
||||
|
||||
scrollbar_set_handle(NULL, 10213);
|
||||
scrollbar_set_max_value(NULL, 10);
|
||||
scrollbar_set_handle_length(NULL, 1000);
|
||||
|
||||
scrollbar_set_max_value(sb, 10000);
|
||||
TASSERTE(sb->length, 10000u);
|
||||
scrollbar_set_handle_length(sb, 10);
|
||||
TASSERTE(sb->pos_length, 10u);
|
||||
scrollbar_set_handle(sb, 5000);
|
||||
TASSERTE(sb->pos, 5000u);
|
||||
scrollbar_set_handle(sb, 15000);
|
||||
TASSERTE(sb->pos, 10000u);
|
||||
scrollbar_set_handle(sb, UINT32_MAX);
|
||||
TASSERTE(sb->pos, 10000u);
|
||||
scrollbar_set_handle_length(sb, 15000);
|
||||
TASSERTE(sb->pos_length, 10000u);
|
||||
scrollbar_set_handle_length(sb, 0);
|
||||
TASSERTE(sb->pos_length, 1u);
|
||||
|
||||
guint cl = scrollbar_scroll_get_line(sb, 10);
|
||||
TASSERTE(cl, 1010u);
|
||||
cl = scrollbar_scroll_get_line(sb, 20);
|
||||
TASSERTE(cl, 2020u);
|
||||
cl = scrollbar_scroll_get_line(sb, 0);
|
||||
TASSERTE(cl, 0u);
|
||||
cl = scrollbar_scroll_get_line(sb, 99);
|
||||
TASSERTE(cl, 9999u);
|
||||
scrollbar_set_handle_length(sb, 1000);
|
||||
cl = scrollbar_scroll_get_line(sb, 10);
|
||||
TASSERTE(cl, 555u);
|
||||
cl = scrollbar_scroll_get_line(sb, 20);
|
||||
TASSERTE(cl, 1666u);
|
||||
cl = scrollbar_scroll_get_line(sb, 0);
|
||||
TASSERTE(cl, 0u);
|
||||
cl = scrollbar_scroll_get_line(sb, 99);
|
||||
TASSERTE(cl, 9999u);
|
||||
|
||||
widget_free(WIDGET(sb));
|
||||
}
|
||||
|
|
|
@ -25,190 +25,188 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include "display.h"
|
||||
#include "settings.h"
|
||||
#include "xcb.h"
|
||||
#include "xrmoptions.h"
|
||||
#include <assert.h>
|
||||
#include <cairo-xlib.h>
|
||||
#include <glib.h>
|
||||
#include <history.h>
|
||||
#include <string.h>
|
||||
#include <widgets/textbox.h>
|
||||
#include <rofi.h>
|
||||
#include <cairo.h>
|
||||
#include "display.h"
|
||||
#include "settings.h"
|
||||
#include "xrmoptions.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <widgets/textbox.h>
|
||||
|
||||
#include "rofi-icon-fetcher.h"
|
||||
static int test = 0;
|
||||
static int test = 0;
|
||||
unsigned int normal_window_mode = 0;
|
||||
|
||||
#define TASSERT( a ) { \
|
||||
assert ( a ); \
|
||||
printf ( "Test %3i passed (%s)\n", ++test, # a ); \
|
||||
}
|
||||
#define TASSERT(a) \
|
||||
{ \
|
||||
assert(a); \
|
||||
printf("Test %3i passed (%s)\n", ++test, #a); \
|
||||
}
|
||||
|
||||
#include "view.h"
|
||||
|
||||
ThemeWidget *rofi_configuration = NULL;
|
||||
|
||||
uint32_t rofi_icon_fetcher_query ( const char *name, const int size )
|
||||
{
|
||||
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int size) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t rofi_icon_fetcher_query_advanced ( const char *name, const int wsize, const int hsize )
|
||||
{
|
||||
uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int wsize,
|
||||
G_GNUC_UNUSED const int hsize) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid )
|
||||
{
|
||||
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean config_parse_set_property ( G_GNUC_UNUSED const Property *p, G_GNUC_UNUSED char **error )
|
||||
{
|
||||
return FALSE;
|
||||
gboolean config_parse_set_property(G_GNUC_UNUSED const Property *p,
|
||||
G_GNUC_UNUSED char **error) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void rofi_add_error_message ( G_GNUC_UNUSED GString *msg )
|
||||
{
|
||||
}
|
||||
void rofi_view_queue_redraw ()
|
||||
{
|
||||
}
|
||||
void rofi_view_get_current_monitor ( G_GNUC_UNUSED int *width, G_GNUC_UNUSED int *height )
|
||||
{
|
||||
|
||||
}
|
||||
int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
|
||||
{
|
||||
fputs ( msg, stderr );
|
||||
return FALSE;
|
||||
void rofi_add_error_message(G_GNUC_UNUSED GString *msg) {}
|
||||
void rofi_add_warning_message(G_GNUC_UNUSED GString *msg) {}
|
||||
void rofi_view_queue_redraw() {}
|
||||
void rofi_view_get_current_monitor(G_GNUC_UNUSED int *width,
|
||||
G_GNUC_UNUSED int *height) {}
|
||||
int rofi_view_error_dialog(const char *msg, G_GNUC_UNUSED int markup) {
|
||||
fputs(msg, stderr);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int monitor_active ( G_GNUC_UNUSED workarea *mon )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void display_startup_notification ( G_GNUC_UNUSED RofiHelperExecuteContext *context, G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup, G_GNUC_UNUSED gpointer *user_data )
|
||||
{
|
||||
}
|
||||
|
||||
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||
{
|
||||
cairo_surface_t *surf = cairo_image_surface_create ( CAIRO_FORMAT_ARGB32, 100, 100 );
|
||||
cairo_t *draw = cairo_create ( surf );
|
||||
PangoContext *p = pango_cairo_create_context ( draw );
|
||||
|
||||
|
||||
textbox_setup();
|
||||
textbox_set_pango_context ( "default", p );
|
||||
|
||||
|
||||
textbox *box = textbox_create ( NULL, WIDGET_TYPE_TEXTBOX_TEXT, "textbox", TB_EDITABLE | TB_AUTOWIDTH | TB_AUTOHEIGHT, NORMAL, "test",0,0 );
|
||||
TASSERT ( box != NULL );
|
||||
|
||||
textbox_keybinding ( box, MOVE_END );
|
||||
TASSERT ( box->cursor == 4 );
|
||||
textbox_cursor ( box, -1 );
|
||||
TASSERT ( box->cursor == 0 );
|
||||
textbox_cursor ( box, 8 );
|
||||
TASSERT ( box->cursor == 4 );
|
||||
textbox_cursor ( box, 2 );
|
||||
TASSERT ( box->cursor == 2 );
|
||||
textbox_insert ( box, 3, "bo", 2 );
|
||||
TASSERT ( strcmp ( box->text, "tesbot" ) == 0 );
|
||||
textbox_keybinding ( box, MOVE_END );
|
||||
TASSERT ( box->cursor == 6 );
|
||||
|
||||
TASSERT ( widget_get_width ( WIDGET ( box ) ) > 0 );
|
||||
TASSERT ( textbox_get_height ( box ) > 0 );
|
||||
|
||||
TASSERT ( widget_get_width ( WIDGET ( box ) ) >= textbox_get_font_width ( box ) );
|
||||
TASSERT ( textbox_get_height ( box ) >= textbox_get_font_height ( box ) );
|
||||
|
||||
TASSERT ( textbox_get_estimated_char_width ( ) > 0 );
|
||||
|
||||
textbox_keybinding ( box, REMOVE_CHAR_BACK );
|
||||
TASSERT ( strcmp ( box->text, "tesbo" ) == 0 );
|
||||
TASSERT ( box->cursor == 5 );
|
||||
|
||||
textbox_keybinding ( box, MOVE_CHAR_BACK );
|
||||
TASSERT ( box->cursor == 4 );
|
||||
textbox_keybinding ( box, REMOVE_CHAR_FORWARD );
|
||||
TASSERT ( strcmp ( box->text, "tesb" ) == 0 );
|
||||
textbox_keybinding ( box, MOVE_CHAR_BACK );
|
||||
TASSERT ( box->cursor == 3 );
|
||||
textbox_keybinding ( box, MOVE_CHAR_FORWARD );
|
||||
TASSERT ( box->cursor == 4 );
|
||||
textbox_keybinding ( box, MOVE_CHAR_FORWARD );
|
||||
TASSERT ( box->cursor == 4 );
|
||||
// Cursor after delete section.
|
||||
textbox_delete ( box, 0, 1 );
|
||||
TASSERT ( strcmp ( box->text, "esb" ) == 0 );
|
||||
TASSERT ( box->cursor == 3 );
|
||||
// Cursor before delete.
|
||||
textbox_text ( box, "aap noot mies" );
|
||||
TASSERT ( strcmp ( box->text, "aap noot mies" ) == 0 );
|
||||
textbox_cursor ( box, 3 );
|
||||
TASSERT ( box->cursor == 3 );
|
||||
textbox_delete ( box, 3, 6 );
|
||||
TASSERT ( strcmp ( box->text, "aapmies" ) == 0 );
|
||||
TASSERT ( box->cursor == 3 );
|
||||
|
||||
// Cursor within delete
|
||||
textbox_text ( box, "aap noot mies" );
|
||||
TASSERT ( strcmp ( box->text, "aap noot mies" ) == 0 );
|
||||
textbox_cursor ( box, 5 );
|
||||
TASSERT ( box->cursor == 5 );
|
||||
textbox_delete ( box, 3, 6 );
|
||||
TASSERT ( strcmp ( box->text, "aapmies" ) == 0 );
|
||||
TASSERT ( box->cursor == 3 );
|
||||
// Cursor after delete.
|
||||
textbox_text ( box, "aap noot mies" );
|
||||
TASSERT ( strcmp ( box->text, "aap noot mies" ) == 0 );
|
||||
textbox_cursor ( box, 11 );
|
||||
TASSERT ( box->cursor == 11 );
|
||||
textbox_delete ( box, 3, 6 );
|
||||
TASSERT ( strcmp ( box->text, "aapmies" ) == 0 );
|
||||
TASSERT ( box->cursor == 5 );
|
||||
|
||||
textbox_text ( box, "aap noot mies" );
|
||||
textbox_cursor ( box, 8 );
|
||||
textbox_keybinding ( box, REMOVE_WORD_BACK );
|
||||
TASSERT ( box->cursor == 4 );
|
||||
TASSERT ( strcmp ( box->text, "aap mies" ) == 0 );
|
||||
textbox_keybinding ( box, REMOVE_TO_EOL );
|
||||
TASSERT ( box->cursor == 4 );
|
||||
TASSERT ( strcmp ( box->text, "aap " ) == 0 );
|
||||
textbox_text ( box, "aap noot mies" );
|
||||
textbox_cursor ( box, 8 );
|
||||
textbox_keybinding ( box, REMOVE_WORD_FORWARD );
|
||||
TASSERT ( strcmp ( box->text, "aap noot" ) == 0 );
|
||||
textbox_keybinding ( box, MOVE_FRONT );
|
||||
TASSERT ( box->cursor == 0 );
|
||||
textbox_keybinding ( box, CLEAR_LINE );
|
||||
TASSERT ( strcmp ( box->text, "" ) == 0 );
|
||||
textbox_text ( box, "aap noot mies" );
|
||||
textbox_keybinding ( box, MOVE_END );
|
||||
textbox_keybinding ( box, MOVE_WORD_BACK );
|
||||
TASSERT ( box->cursor == 9 );
|
||||
textbox_keybinding ( box, MOVE_WORD_BACK );
|
||||
TASSERT ( box->cursor == 4 );
|
||||
textbox_keybinding ( box, REMOVE_TO_SOL );
|
||||
TASSERT ( strcmp ( box->text, "noot mies" ) == 0 );
|
||||
TASSERT ( box->cursor == 0 );
|
||||
|
||||
textbox_font ( box, HIGHLIGHT );
|
||||
//textbox_draw ( box, draw );
|
||||
|
||||
widget_move ( WIDGET ( box ), 12, 13 );
|
||||
TASSERT ( box->widget.x == 12 );
|
||||
TASSERT ( box->widget.y == 13 );
|
||||
|
||||
widget_free ( WIDGET ( box ) );
|
||||
textbox_cleanup ( );
|
||||
int monitor_active(G_GNUC_UNUSED workarea *mon) { return 0; }
|
||||
|
||||
void display_startup_notification(
|
||||
G_GNUC_UNUSED RofiHelperExecuteContext *context,
|
||||
G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup,
|
||||
G_GNUC_UNUSED gpointer *user_data) {}
|
||||
|
||||
int main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) {
|
||||
cairo_surface_t *surf =
|
||||
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 100, 100);
|
||||
cairo_t *draw = cairo_create(surf);
|
||||
PangoContext *p = pango_cairo_create_context(draw);
|
||||
|
||||
textbox_setup();
|
||||
textbox_set_pango_context("default", p);
|
||||
|
||||
textbox *box = textbox_create(NULL, WIDGET_TYPE_TEXTBOX_TEXT, "textbox",
|
||||
TB_EDITABLE | TB_AUTOWIDTH | TB_AUTOHEIGHT,
|
||||
NORMAL, "test", 0, 0);
|
||||
TASSERT(box != NULL);
|
||||
|
||||
textbox_keybinding(box, MOVE_END);
|
||||
TASSERT(box->cursor == 4);
|
||||
textbox_cursor(box, -1);
|
||||
TASSERT(box->cursor == 0);
|
||||
textbox_cursor(box, 8);
|
||||
TASSERT(box->cursor == 4);
|
||||
textbox_cursor(box, 2);
|
||||
TASSERT(box->cursor == 2);
|
||||
textbox_insert(box, 3, "bo", 2);
|
||||
TASSERT(strcmp(box->text, "tesbot") == 0);
|
||||
textbox_keybinding(box, MOVE_END);
|
||||
TASSERT(box->cursor == 6);
|
||||
|
||||
TASSERT(widget_get_width(WIDGET(box)) > 0);
|
||||
TASSERT(textbox_get_height(box) > 0);
|
||||
|
||||
TASSERT(widget_get_width(WIDGET(box)) >= textbox_get_font_width(box));
|
||||
TASSERT(textbox_get_height(box) >= textbox_get_font_height(box));
|
||||
|
||||
TASSERT(textbox_get_estimated_char_width() > 0);
|
||||
|
||||
textbox_keybinding(box, REMOVE_CHAR_BACK);
|
||||
TASSERT(strcmp(box->text, "tesbo") == 0);
|
||||
TASSERT(box->cursor == 5);
|
||||
|
||||
textbox_keybinding(box, MOVE_CHAR_BACK);
|
||||
TASSERT(box->cursor == 4);
|
||||
textbox_keybinding(box, REMOVE_CHAR_FORWARD);
|
||||
TASSERT(strcmp(box->text, "tesb") == 0);
|
||||
textbox_keybinding(box, MOVE_CHAR_BACK);
|
||||
TASSERT(box->cursor == 3);
|
||||
textbox_keybinding(box, MOVE_CHAR_FORWARD);
|
||||
TASSERT(box->cursor == 4);
|
||||
textbox_keybinding(box, MOVE_CHAR_FORWARD);
|
||||
TASSERT(box->cursor == 4);
|
||||
// Cursor after delete section.
|
||||
textbox_delete(box, 0, 1);
|
||||
TASSERT(strcmp(box->text, "esb") == 0);
|
||||
TASSERT(box->cursor == 3);
|
||||
// Cursor before delete.
|
||||
textbox_text(box, "aap noot mies");
|
||||
TASSERT(strcmp(box->text, "aap noot mies") == 0);
|
||||
textbox_cursor(box, 3);
|
||||
TASSERT(box->cursor == 3);
|
||||
textbox_delete(box, 3, 6);
|
||||
TASSERT(strcmp(box->text, "aapmies") == 0);
|
||||
TASSERT(box->cursor == 3);
|
||||
|
||||
// Cursor within delete
|
||||
textbox_text(box, "aap noot mies");
|
||||
TASSERT(strcmp(box->text, "aap noot mies") == 0);
|
||||
textbox_cursor(box, 5);
|
||||
TASSERT(box->cursor == 5);
|
||||
textbox_delete(box, 3, 6);
|
||||
TASSERT(strcmp(box->text, "aapmies") == 0);
|
||||
TASSERT(box->cursor == 3);
|
||||
// Cursor after delete.
|
||||
textbox_text(box, "aap noot mies");
|
||||
TASSERT(strcmp(box->text, "aap noot mies") == 0);
|
||||
textbox_cursor(box, 11);
|
||||
TASSERT(box->cursor == 11);
|
||||
textbox_delete(box, 3, 6);
|
||||
TASSERT(strcmp(box->text, "aapmies") == 0);
|
||||
TASSERT(box->cursor == 5);
|
||||
|
||||
textbox_text(box, "aap noot mies");
|
||||
textbox_cursor(box, 8);
|
||||
textbox_keybinding(box, REMOVE_WORD_BACK);
|
||||
TASSERT(box->cursor == 4);
|
||||
TASSERT(strcmp(box->text, "aap mies") == 0);
|
||||
textbox_keybinding(box, REMOVE_TO_EOL);
|
||||
TASSERT(box->cursor == 4);
|
||||
TASSERT(strcmp(box->text, "aap ") == 0);
|
||||
textbox_text(box, "aap noot mies");
|
||||
textbox_cursor(box, 8);
|
||||
textbox_keybinding(box, REMOVE_WORD_FORWARD);
|
||||
TASSERT(strcmp(box->text, "aap noot") == 0);
|
||||
textbox_keybinding(box, MOVE_FRONT);
|
||||
TASSERT(box->cursor == 0);
|
||||
textbox_keybinding(box, CLEAR_LINE);
|
||||
TASSERT(strcmp(box->text, "") == 0);
|
||||
textbox_text(box, "aap noot mies");
|
||||
textbox_keybinding(box, MOVE_END);
|
||||
textbox_keybinding(box, MOVE_WORD_BACK);
|
||||
TASSERT(box->cursor == 9);
|
||||
textbox_keybinding(box, MOVE_WORD_BACK);
|
||||
TASSERT(box->cursor == 4);
|
||||
textbox_keybinding(box, REMOVE_TO_SOL);
|
||||
TASSERT(strcmp(box->text, "noot mies") == 0);
|
||||
TASSERT(box->cursor == 0);
|
||||
|
||||
textbox_font(box, HIGHLIGHT);
|
||||
// textbox_draw ( box, draw );
|
||||
|
||||
widget_move(WIDGET(box), 12, 13);
|
||||
TASSERT(box->widget.x == 12);
|
||||
TASSERT(box->widget.y == 13);
|
||||
|
||||
widget_free(WIDGET(box));
|
||||
textbox_cleanup();
|
||||
}
|
||||
|
|
|
@ -44,14 +44,22 @@
|
|||
|
||||
#define REAL_COMPARE_DELTA 0.001
|
||||
|
||||
uint32_t rofi_icon_fetcher_query(const char *name, const int size) { return 0; }
|
||||
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int size) {
|
||||
return 0;
|
||||
}
|
||||
void rofi_clear_error_messages(void) {}
|
||||
uint32_t rofi_icon_fetcher_query_advanced(const char *name, const int wsize,
|
||||
const int hsize) {
|
||||
void rofi_clear_warning_messages(void) {}
|
||||
uint32_t
|
||||
rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED G_GNUC_UNUSED const int wsize,
|
||||
G_GNUC_UNUSED const int hsize) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
cairo_surface_t *rofi_icon_fetcher_get(const uint32_t uid) { return NULL; }
|
||||
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int rofi_view_error_dialog(const char *msg, G_GNUC_UNUSED int markup) {
|
||||
fputs(msg, stderr);
|
||||
|
@ -94,11 +102,18 @@ void display_startup_notification(
|
|||
|
||||
gboolean error = FALSE;
|
||||
GString *error_msg = NULL;
|
||||
gboolean warning = FALSE;
|
||||
GString *warning_msg = NULL;
|
||||
void rofi_add_error_message(GString *msg) {
|
||||
ck_assert_ptr_null(error_msg);
|
||||
error_msg = msg;
|
||||
error = TRUE;
|
||||
}
|
||||
void rofi_add_warning_message(GString *msg) {
|
||||
ck_assert_ptr_null(warning_msg);
|
||||
warning_msg = msg;
|
||||
warning = TRUE;
|
||||
}
|
||||
|
||||
static void theme_parser_setup(void) { error = 0; }
|
||||
static void theme_parser_teardown(void) {
|
||||
|
|
|
@ -25,199 +25,191 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include "display.h"
|
||||
#include "rofi-icon-fetcher.h"
|
||||
#include "rofi.h"
|
||||
#include "xcb.h"
|
||||
#include "xrmoptions.h"
|
||||
#include <assert.h>
|
||||
#include <glib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <widgets/widget.h>
|
||||
#include <unistd.h>
|
||||
#include <widgets/widget-internal.h>
|
||||
#include "rofi.h"
|
||||
#include "display.h"
|
||||
#include "xrmoptions.h"
|
||||
#include "rofi-icon-fetcher.h"
|
||||
unsigned int test =0;
|
||||
#define TASSERT( a ) { \
|
||||
assert ( a ); \
|
||||
printf ( "Test %3u passed (%s)\n", ++test, # a ); \
|
||||
}
|
||||
#include <widgets/widget.h>
|
||||
unsigned int test = 0;
|
||||
#define TASSERT(a) \
|
||||
{ \
|
||||
assert(a); \
|
||||
printf("Test %3u passed (%s)\n", ++test, #a); \
|
||||
}
|
||||
|
||||
ThemeWidget *rofi_configuration = NULL;
|
||||
|
||||
uint32_t rofi_icon_fetcher_query ( const char *name, const int size )
|
||||
{
|
||||
return 0;
|
||||
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int size) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t rofi_icon_fetcher_query_advanced ( const char *name, const int wsize, const int hsize )
|
||||
{
|
||||
return 0;
|
||||
uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int wsize,
|
||||
G_GNUC_UNUSED const int hsize) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid )
|
||||
{
|
||||
return NULL;
|
||||
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean config_parse_set_property ( G_GNUC_UNUSED const Property *p, G_GNUC_UNUSED char **error )
|
||||
{
|
||||
return FALSE;
|
||||
gboolean config_parse_set_property(G_GNUC_UNUSED const Property *p,
|
||||
G_GNUC_UNUSED char **error) {
|
||||
return FALSE;
|
||||
}
|
||||
void rofi_add_error_message ( G_GNUC_UNUSED GString *msg )
|
||||
{
|
||||
}
|
||||
void rofi_view_queue_redraw ( void )
|
||||
{
|
||||
|
||||
}
|
||||
int monitor_active ( G_GNUC_UNUSED workarea *mon )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
void rofi_view_get_current_monitor ( G_GNUC_UNUSED int *width, G_GNUC_UNUSED int *height )
|
||||
{
|
||||
|
||||
}
|
||||
int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
|
||||
{
|
||||
fputs ( msg, stderr );
|
||||
return FALSE;
|
||||
void rofi_add_error_message(G_GNUC_UNUSED GString *msg) {}
|
||||
void rofi_add_warning_message(G_GNUC_UNUSED GString *msg) {}
|
||||
void rofi_view_queue_redraw(void) {}
|
||||
int monitor_active(G_GNUC_UNUSED workarea *mon) { return 0; }
|
||||
void rofi_view_get_current_monitor(G_GNUC_UNUSED int *width,
|
||||
G_GNUC_UNUSED int *height) {}
|
||||
int rofi_view_error_dialog(const char *msg, G_GNUC_UNUSED int markup) {
|
||||
fputs(msg, stderr);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void display_startup_notification ( G_GNUC_UNUSED RofiHelperExecuteContext *context, G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup, G_GNUC_UNUSED gpointer *user_data )
|
||||
{
|
||||
}
|
||||
|
||||
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||
{
|
||||
// box 20 by 40
|
||||
widget *wid= (widget*)g_malloc0(sizeof(widget));
|
||||
widget_resize ( wid, 20, 40);
|
||||
widget_move ( wid, 10, 10);
|
||||
// Getter, setter x pos
|
||||
//
|
||||
TASSERT ( widget_get_x_pos ( wid ) == 10 );
|
||||
TASSERT ( widget_get_y_pos ( wid ) == 10 );
|
||||
|
||||
// Left of box
|
||||
TASSERT ( widget_intersect ( wid, 0, 0) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 0, 10) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 0, 25) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 0, 40) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 0, 50) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 9, 0) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 9, 10) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 9, 25) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 9, 40) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 9, 50) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 10, 0) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 10, 10) == 1 );
|
||||
TASSERT ( widget_intersect ( wid, 10, 25) == 1 );
|
||||
TASSERT ( widget_intersect ( wid, 10, 40) == 1 );
|
||||
TASSERT ( widget_intersect ( wid, 10, 50) == 0 );
|
||||
|
||||
// Middle
|
||||
|
||||
TASSERT ( widget_intersect ( wid, 25, 0) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 25, 10) == 1 );
|
||||
TASSERT ( widget_intersect ( wid, 25, 25) == 1 );
|
||||
TASSERT ( widget_intersect ( wid, 25, 40) == 1 );
|
||||
TASSERT ( widget_intersect ( wid, 25, 50) == 0 );
|
||||
|
||||
// Right
|
||||
TASSERT ( widget_intersect ( wid, 29, 0) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 29, 10) == 1 );
|
||||
TASSERT ( widget_intersect ( wid, 29, 25) == 1 );
|
||||
TASSERT ( widget_intersect ( wid, 29, 40) == 1 );
|
||||
TASSERT ( widget_intersect ( wid, 29, 50) == 0 );
|
||||
|
||||
TASSERT ( widget_intersect ( wid, 30, 0) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 30, 10) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 30, 25) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 30, 40) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 30, 50) == 0 );
|
||||
|
||||
widget_move ( wid, 30, 30);
|
||||
// Left of box
|
||||
TASSERT ( widget_intersect ( wid, 10, 20) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 10, 30) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 10, 45) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 10, 60) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 10, 70) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 19, 20) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 19, 30) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 19, 45) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 19, 60) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 19, 70) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 30, 20) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 30, 30) == 1 );
|
||||
TASSERT ( widget_intersect ( wid, 30, 45) == 1 );
|
||||
TASSERT ( widget_intersect ( wid, 30, 60) == 1 );
|
||||
TASSERT ( widget_intersect ( wid, 30, 70) == 0 );
|
||||
|
||||
// Middle
|
||||
|
||||
TASSERT ( widget_intersect ( wid, 20+25,20+ 0) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 20+25,20+ 10) == 1 );
|
||||
TASSERT ( widget_intersect ( wid, 20+25,20+ 25) == 1 );
|
||||
TASSERT ( widget_intersect ( wid, 20+25,20+ 40) == 1 );
|
||||
TASSERT ( widget_intersect ( wid, 20+25,20+ 50) == 0 );
|
||||
|
||||
TASSERT ( widget_intersect ( wid, 20+29, 20+0) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 20+29, 20+10) == 1 );
|
||||
TASSERT ( widget_intersect ( wid, 20+29, 20+25) == 1 );
|
||||
TASSERT ( widget_intersect ( wid, 20+29, 20+40) == 1 );
|
||||
TASSERT ( widget_intersect ( wid, 20+29, 20+50) == 0 );
|
||||
|
||||
TASSERT ( widget_intersect ( wid, 20+30, 20+0) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 20+30, 20+10) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 20+30, 20+25) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 20+30, 20+40) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 20+30, 20+50) == 0 );
|
||||
|
||||
// Right
|
||||
TASSERT ( widget_intersect ( wid, 20+29, 20+0) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 20+29, 20+10) == 1 );
|
||||
TASSERT ( widget_intersect ( wid, 20+29, 20+25) == 1 );
|
||||
TASSERT ( widget_intersect ( wid, 20+29, 20+40) == 1 );
|
||||
TASSERT ( widget_intersect ( wid, 20+29, 20+50) == 0 );
|
||||
|
||||
TASSERT ( widget_intersect ( wid, 20+30, 20+0) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 20+30, 20+10) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 20+30, 20+25) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 20+30, 20+40) == 0 );
|
||||
TASSERT ( widget_intersect ( wid, 20+30, 20+50) == 0 );
|
||||
|
||||
TASSERT ( widget_intersect ( wid, -100, -100) == 0);
|
||||
TASSERT ( widget_intersect ( wid, INT_MIN, INT_MIN) == 0);
|
||||
TASSERT ( widget_intersect ( wid, INT_MAX, INT_MAX) == 0);
|
||||
|
||||
// Other wrappers.
|
||||
TASSERT ( widget_get_height ( wid ) == wid->h);
|
||||
TASSERT ( widget_get_width ( wid ) == wid->w);
|
||||
|
||||
TASSERT ( widget_enabled ( wid ) == FALSE );
|
||||
widget_enable ( wid );
|
||||
TASSERT ( widget_enabled ( wid ) == TRUE );
|
||||
widget_disable ( wid );
|
||||
TASSERT ( widget_enabled ( wid ) == FALSE );
|
||||
// Null pointer tests.
|
||||
TASSERT ( widget_intersect ( NULL, 0, 0) == 0 );
|
||||
widget_move ( NULL, 0, 0 );
|
||||
TASSERT ( widget_get_height ( NULL ) == 0);
|
||||
TASSERT ( widget_get_width ( NULL ) == 0);
|
||||
TASSERT ( widget_enabled ( NULL ) == 0);
|
||||
widget_disable ( NULL );
|
||||
widget_enable ( NULL );
|
||||
widget_draw ( NULL, NULL );
|
||||
widget_free ( NULL );
|
||||
widget_resize ( NULL, 0, 0);
|
||||
widget_update ( NULL );
|
||||
widget_queue_redraw ( NULL );
|
||||
TASSERT (widget_need_redraw ( NULL ) == FALSE);
|
||||
widget_trigger_action ( NULL, 0, 0, 0 );
|
||||
widget_set_trigger_action_handler ( NULL, NULL, NULL );
|
||||
|
||||
g_free(wid);
|
||||
void display_startup_notification(
|
||||
G_GNUC_UNUSED RofiHelperExecuteContext *context,
|
||||
G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup,
|
||||
G_GNUC_UNUSED gpointer *user_data) {}
|
||||
|
||||
int main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) {
|
||||
// box 20 by 40
|
||||
widget *wid = (widget *)g_malloc0(sizeof(widget));
|
||||
widget_resize(wid, 20, 40);
|
||||
widget_move(wid, 10, 10);
|
||||
// Getter, setter x pos
|
||||
//
|
||||
TASSERT(widget_get_x_pos(wid) == 10);
|
||||
TASSERT(widget_get_y_pos(wid) == 10);
|
||||
|
||||
// Left of box
|
||||
TASSERT(widget_intersect(wid, 0, 0) == 0);
|
||||
TASSERT(widget_intersect(wid, 0, 10) == 0);
|
||||
TASSERT(widget_intersect(wid, 0, 25) == 0);
|
||||
TASSERT(widget_intersect(wid, 0, 40) == 0);
|
||||
TASSERT(widget_intersect(wid, 0, 50) == 0);
|
||||
TASSERT(widget_intersect(wid, 9, 0) == 0);
|
||||
TASSERT(widget_intersect(wid, 9, 10) == 0);
|
||||
TASSERT(widget_intersect(wid, 9, 25) == 0);
|
||||
TASSERT(widget_intersect(wid, 9, 40) == 0);
|
||||
TASSERT(widget_intersect(wid, 9, 50) == 0);
|
||||
TASSERT(widget_intersect(wid, 10, 0) == 0);
|
||||
TASSERT(widget_intersect(wid, 10, 10) == 1);
|
||||
TASSERT(widget_intersect(wid, 10, 25) == 1);
|
||||
TASSERT(widget_intersect(wid, 10, 40) == 1);
|
||||
TASSERT(widget_intersect(wid, 10, 50) == 0);
|
||||
|
||||
// Middle
|
||||
|
||||
TASSERT(widget_intersect(wid, 25, 0) == 0);
|
||||
TASSERT(widget_intersect(wid, 25, 10) == 1);
|
||||
TASSERT(widget_intersect(wid, 25, 25) == 1);
|
||||
TASSERT(widget_intersect(wid, 25, 40) == 1);
|
||||
TASSERT(widget_intersect(wid, 25, 50) == 0);
|
||||
|
||||
// Right
|
||||
TASSERT(widget_intersect(wid, 29, 0) == 0);
|
||||
TASSERT(widget_intersect(wid, 29, 10) == 1);
|
||||
TASSERT(widget_intersect(wid, 29, 25) == 1);
|
||||
TASSERT(widget_intersect(wid, 29, 40) == 1);
|
||||
TASSERT(widget_intersect(wid, 29, 50) == 0);
|
||||
|
||||
TASSERT(widget_intersect(wid, 30, 0) == 0);
|
||||
TASSERT(widget_intersect(wid, 30, 10) == 0);
|
||||
TASSERT(widget_intersect(wid, 30, 25) == 0);
|
||||
TASSERT(widget_intersect(wid, 30, 40) == 0);
|
||||
TASSERT(widget_intersect(wid, 30, 50) == 0);
|
||||
|
||||
widget_move(wid, 30, 30);
|
||||
// Left of box
|
||||
TASSERT(widget_intersect(wid, 10, 20) == 0);
|
||||
TASSERT(widget_intersect(wid, 10, 30) == 0);
|
||||
TASSERT(widget_intersect(wid, 10, 45) == 0);
|
||||
TASSERT(widget_intersect(wid, 10, 60) == 0);
|
||||
TASSERT(widget_intersect(wid, 10, 70) == 0);
|
||||
TASSERT(widget_intersect(wid, 19, 20) == 0);
|
||||
TASSERT(widget_intersect(wid, 19, 30) == 0);
|
||||
TASSERT(widget_intersect(wid, 19, 45) == 0);
|
||||
TASSERT(widget_intersect(wid, 19, 60) == 0);
|
||||
TASSERT(widget_intersect(wid, 19, 70) == 0);
|
||||
TASSERT(widget_intersect(wid, 30, 20) == 0);
|
||||
TASSERT(widget_intersect(wid, 30, 30) == 1);
|
||||
TASSERT(widget_intersect(wid, 30, 45) == 1);
|
||||
TASSERT(widget_intersect(wid, 30, 60) == 1);
|
||||
TASSERT(widget_intersect(wid, 30, 70) == 0);
|
||||
|
||||
// Middle
|
||||
|
||||
TASSERT(widget_intersect(wid, 20 + 25, 20 + 0) == 0);
|
||||
TASSERT(widget_intersect(wid, 20 + 25, 20 + 10) == 1);
|
||||
TASSERT(widget_intersect(wid, 20 + 25, 20 + 25) == 1);
|
||||
TASSERT(widget_intersect(wid, 20 + 25, 20 + 40) == 1);
|
||||
TASSERT(widget_intersect(wid, 20 + 25, 20 + 50) == 0);
|
||||
|
||||
TASSERT(widget_intersect(wid, 20 + 29, 20 + 0) == 0);
|
||||
TASSERT(widget_intersect(wid, 20 + 29, 20 + 10) == 1);
|
||||
TASSERT(widget_intersect(wid, 20 + 29, 20 + 25) == 1);
|
||||
TASSERT(widget_intersect(wid, 20 + 29, 20 + 40) == 1);
|
||||
TASSERT(widget_intersect(wid, 20 + 29, 20 + 50) == 0);
|
||||
|
||||
TASSERT(widget_intersect(wid, 20 + 30, 20 + 0) == 0);
|
||||
TASSERT(widget_intersect(wid, 20 + 30, 20 + 10) == 0);
|
||||
TASSERT(widget_intersect(wid, 20 + 30, 20 + 25) == 0);
|
||||
TASSERT(widget_intersect(wid, 20 + 30, 20 + 40) == 0);
|
||||
TASSERT(widget_intersect(wid, 20 + 30, 20 + 50) == 0);
|
||||
|
||||
// Right
|
||||
TASSERT(widget_intersect(wid, 20 + 29, 20 + 0) == 0);
|
||||
TASSERT(widget_intersect(wid, 20 + 29, 20 + 10) == 1);
|
||||
TASSERT(widget_intersect(wid, 20 + 29, 20 + 25) == 1);
|
||||
TASSERT(widget_intersect(wid, 20 + 29, 20 + 40) == 1);
|
||||
TASSERT(widget_intersect(wid, 20 + 29, 20 + 50) == 0);
|
||||
|
||||
TASSERT(widget_intersect(wid, 20 + 30, 20 + 0) == 0);
|
||||
TASSERT(widget_intersect(wid, 20 + 30, 20 + 10) == 0);
|
||||
TASSERT(widget_intersect(wid, 20 + 30, 20 + 25) == 0);
|
||||
TASSERT(widget_intersect(wid, 20 + 30, 20 + 40) == 0);
|
||||
TASSERT(widget_intersect(wid, 20 + 30, 20 + 50) == 0);
|
||||
|
||||
TASSERT(widget_intersect(wid, -100, -100) == 0);
|
||||
TASSERT(widget_intersect(wid, INT_MIN, INT_MIN) == 0);
|
||||
TASSERT(widget_intersect(wid, INT_MAX, INT_MAX) == 0);
|
||||
|
||||
// Other wrappers.
|
||||
TASSERT(widget_get_height(wid) == wid->h);
|
||||
TASSERT(widget_get_width(wid) == wid->w);
|
||||
|
||||
TASSERT(widget_enabled(wid) == FALSE);
|
||||
widget_enable(wid);
|
||||
TASSERT(widget_enabled(wid) == TRUE);
|
||||
widget_disable(wid);
|
||||
TASSERT(widget_enabled(wid) == FALSE);
|
||||
// Null pointer tests.
|
||||
TASSERT(widget_intersect(NULL, 0, 0) == 0);
|
||||
widget_move(NULL, 0, 0);
|
||||
TASSERT(widget_get_height(NULL) == 0);
|
||||
TASSERT(widget_get_width(NULL) == 0);
|
||||
TASSERT(widget_enabled(NULL) == 0);
|
||||
widget_disable(NULL);
|
||||
widget_enable(NULL);
|
||||
widget_draw(NULL, NULL);
|
||||
widget_free(NULL);
|
||||
widget_resize(NULL, 0, 0);
|
||||
widget_update(NULL);
|
||||
widget_queue_redraw(NULL);
|
||||
TASSERT(widget_need_redraw(NULL) == FALSE);
|
||||
widget_trigger_action(NULL, 0, 0, 0);
|
||||
widget_set_trigger_action_handler(NULL, NULL, NULL);
|
||||
|
||||
g_free(wid);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue