Skip to content

Conversation

hluk
Copy link
Owner

@hluk hluk commented Apr 9, 2025

Overrides some default shortcuts in the Vi/Emacs modes.

Enables Vi/Emacs navigation in menus.

Enables Ctrl+[ in Vi and Ctrl+G in Emacs to work in many other places as Esc key (for example, to hide menus, dialogs).

User can override shortcuts, but not some reserved ones in specific cases (mainly, if the item list or a menu has focus).

This also disables rerunning failed tests cases when run locally (not in a CI).

Fixes #3012

@hluk hluk mentioned this pull request Apr 9, 2025
@hluk hluk force-pushed the test-navigation branch 10 times, most recently from 7150efe to bea1c5a Compare April 9, 2025 16:14
@hluk hluk changed the title Tests: Add tests for Vi/Emacs navigation Fix ESC handling in Vi/Emacs navigation and add tests Apr 9, 2025
@hluk hluk force-pushed the test-navigation branch 2 times, most recently from b759b40 to e0d0a24 Compare April 10, 2025 05:25
@hluk hluk changed the title Fix ESC handling in Vi/Emacs navigation and add tests Ignore default shortcuts for Vi/Emacs Apr 10, 2025
Overrides some default shortcuts in the Vi/Emacs modes.

Enables Vi/Emacs navigation in menus.

Enables `Ctrl+[` in Vi and `Ctrl+G` in Emacs to work in many other
places as Esc key (for example, to hide menus, dialogs).

User can override shortcuts, but not some reserved ones in specific
cases (mainly, if the item list or a menu has focus).

Fixes #3012
@hluk hluk force-pushed the test-navigation branch from e0d0a24 to b8b5392 Compare April 10, 2025 06:15
@hluk
Copy link
Owner Author

hluk commented Apr 10, 2025

@janmejay Hi, Can you help review and test this?

I've enabled Vi mode for my normal use to test it - it seems to work well.

@janmejay
Copy link
Contributor

Tested Emacs keys. Works great. There is a minor confusing element though, the keyboard-shortcuts list displays incorrect binding.
screenshot-20250411@092052
Haven't reviewed the code yet, plan to do it over the weekend.

@janmejay
Copy link
Contributor

@hluk how do you run tests locally? I see scary things like

# Clean up old configuration.
rm -rf ~/.config/copyq.test

in test-linux.sh.

I see Dockerfile, is that the way to go?

@hluk
Copy link
Owner Author

hluk commented Apr 11, 2025

@janmejay Thanks for testing!

Tested Emacs keys. Works great. There is a minor confusing element though, the keyboard-shortcuts list displays incorrect binding.

Yeah, that can be confusing; or the fact that user cannot set some shortcuts. These shortcuts are also shown in menus.

The easiest fix could be to update ShortcutButton::checkAmbiguousShortcuts to also check all navigation styles and add some indication to the shortcut buttons that a shortcut conflicts with a specific style.

@hluk
Copy link
Owner Author

hluk commented Apr 11, 2025

how do you run tests locally?

The full command to build the test version of CopyQ and run specific tests:

cmake -G Ninja -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_INSTALL_PREFIX=$PWD/install \
  -DWITH_TESTS=1 -DWITH_QT6=1 -DPEDANTIC=ON -DCMAKE_CXX_FLAGS="-ggdb" \
  "$COPYQ_SOURCE_CODE_DIR"

ninja install

xnest.sh ./copyq tests navigationDefault navigationVi navigationEmacs

Here is the xnest.sh script. It starts Xephyr with Openbox to spin up a nested X11 environment for testing.

BTW, you don't have to remove the old test configuration ~/.config/copyq.test, that should be handled by the tests.

@hluk hluk merged commit ac05394 into master Apr 23, 2025
12 checks passed
@hluk hluk deleted the test-navigation branch May 4, 2025 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emacs style not working
2 participants