Commit Graph

131 Commits

Author SHA1 Message Date
Qi Xiao
0f63524c97 pkg/cli/lscolors: Improve coverage of feature.go. 2021-09-10 01:02:31 +01:00
Qi Xiao
5fb6534cfe pkg/cli/lscolors: Fix test on Windows. 2021-09-09 21:57:35 +01:00
Qi Xiao
232a605e93 pkg/cli/lscolors: Improve coverage of feature.go. 2021-09-09 21:53:25 +01:00
Qi Xiao
f011034c06 pkg/cli: Simplify the API for dismissing a widget.
- Rename the method from "Close" to "Dimiss" to avoid any conflict with the
  standard interface{ Close() error }

- Remove the "accept" parameter from the Dismiss method and App.PopAddon - it is
  false in most places, and the few places that pass accept=true has knowledge
  of how to accept the state in the particular widget.

- edit:history:accept has been removed as a consequence - it is never
  documented, and is not currently used by any Elvish code published on GitHub
  (https://github.com/search?q=%22edit%3Ahistory%3Aaccept%22+extension%3Aelv&type=Code)
2021-09-07 23:16:01 +01:00
Qi Xiao
d2936c06a1 Use a more sophisticated algorithm to distribute widget heights.
This is needed since there can now be an arbitrary number of widgets competing
for vertical space.

- Add a new MaxHeight method to the tk.Widget interface to provide hint on how
  to distribute the height.

- Implement the algorithm in distributeHeight in cli/app.go.
2021-09-05 01:17:46 +01:00
Qi Xiao
db0b88f664 Rename pkg/cli/mode -> pkg/cli/modes. 2021-09-03 20:44:04 +01:00
Qi Xiao
55e8850569 pkg/cli: Remove (*app).CodeArea. 2021-09-02 00:09:19 +01:00
Qi Xiao
0a1435f052 pkg/cli/mode: Add test for every mode expecting focused widget to be code area. 2021-09-02 00:01:52 +01:00
Qi Xiao
186bac85e6 pkg/cli: More tests against basic addon behavior. 2021-09-01 23:45:40 +01:00
Qi Xiao
9ca81b9954 Make editor builtins that operate on code area use the focused code area.
This will allow using all such builtins from the minibuf mode.
2021-09-01 22:41:39 +01:00
Qi Xiao
293704ef03 All modes that rely on a code area now use the active code area dynamically.
This will enabling using any of such modes from a minibuf (e.g. completion from
a minibuf).
2021-08-30 23:59:28 +01:00
Qi Xiao
1bfcaeb218 Support a stack of addons in cli.App.
This is motivated by supporting a minibuf from any mode (even in minibuf mode
itself), but could have other applications too.
2021-08-30 00:55:09 +01:00
Qi Xiao
d0be34c227 Run gofmt with Go 1.17.
This has created a lot of //go:build lines.
2021-08-23 00:19:49 +01:00
Shengjing Zhu
5724ec4c47 Fix typos and add codespell to CI 2021-08-22 23:07:34 +01:00
Qi Xiao
e9d328aa16 Make use of (*testing.T).Cleanup for test cleanups.
This allows turning the following pattern in tests:

  value, cleanup := setupSomething()
  defer cleanup()

into the following:

  value := setupSomething(t)
2021-08-06 23:21:23 +01:00
Qi Xiao
6e75f3468c Move API of pkg/store into pkg/storedefs.
This makes the nodaemon entrypoint not depend on boltdb at all, reducing its
size by 100KB (on darwin-arm64).
2021-06-19 01:54:00 +01:00
Qi Xiao
b41b6db5cb Fix coverage fluctuation.
A test in navigation_mode.go verifies that a certain key has no effect. It does
that by verifying that the buffer has not changed, which results in a race
condition: the verification might happen after the key is handled, in which
case the test works. But the verification may also happen before the key is
actually handled, in which case the key handling code has not run and thus has
no coverage.

Fix this by queueing another key that would result in an unrelated buffer
change, thus indirectly verifying that the previous key had no effect.
2021-06-15 15:58:00 +01:00
Qi Xiao
3368744d1b Add comments to pkg/cli/term/reader_windows.go.
Also simplify the logic of AltGr handling. It seems that AltGr and
AltGr+Shift don't actually combine with any other modifiers, so we can
test whether filteredMod is leftCtrl|rightAlt or
leftCtrl|rightAlt|shift, and leave the Mod field unpopulated in the
return value.
2021-06-13 20:41:16 +01:00
kas
903198c96f Remove unnecessary type annotations
Allow AltGr key combinations with modifiers
Remove keyboard layout detection
2021-06-13 16:38:49 +01:00
kas
8be4f8733d Only check for a keyboard layout containing AltGr once 2021-06-13 16:38:49 +01:00
kas
f67ee08b51 Remove unneccessary parentheses 2021-06-13 16:38:49 +01:00
kas
2d8fa34596 Fix wrong syscall arity with GetKeyboardLayout() 2021-06-13 16:38:49 +01:00
kas
3f45103c60 Handle shift-only key combinations the same way as solo keys
This enables uppercase non-ASCII-chars
2021-06-13 16:38:49 +01:00
kas
844a1fedb2 Handle AltGr key combinations on Windows 2021-06-13 16:38:49 +01:00
Kurtis Rader
2b6b11c230 Exercise testutil.MustPipe
I noticed that testutil.MustPipe was not covered by any unit tests. This
converts the handful of places that should use it to do so. This changes
the coverage of pkg/testutil/must.go from 61.5% to 73.1%. There isn't
any way to increase that further without explicitly testing the panic
paths.
2021-06-02 20:29:34 -07:00
Qi Xiao
e142c6b6a0 Suppress SA2001 for genuine use of empty critical section. 2021-05-31 21:37:26 +01:00
Qi Xiao
8a7073a20f pkg/cli/mode: Revise a comment. 2021-04-05 15:33:18 +01:00
Kurtis Rader
12980c2719 Some golint cleanups 2021-04-05 15:31:53 +01:00
Qi Xiao
650161157e pkg/cli/mode: Refactor the handling of default FilterSpec.Maker. 2021-03-29 00:09:32 +01:00
Qi Xiao
cfb05588c7 Merge branch 'master' into query 2021-03-27 02:06:47 +00:00
Qi Xiao
f5aaba0691 pkg/cli/mode: Deflake stub_test.go by adding an app.Redraw call. 2021-03-27 02:06:35 +00:00
Qi Xiao
dea300f9d6 pkg/{cli edit}: Use the query DSL for location, completion and navigation modes. 2021-03-27 01:55:03 +00:00
Qi Xiao
8870defc98 pkg/cli: Refactor how config for custom filters are passed. 2021-03-27 01:21:53 +00:00
Qi Xiao
4ecdb7f278 pkg/cli: Simplify the TTY interface by making it embed term.Writer. 2021-03-19 21:40:32 +00:00
Kurtis Rader
663e04ff75 Fix when cursor is shown by edit:clear
Showing the cursor should only happen after the prompt is redrawn.

Fixes #1238
2021-03-19 21:12:21 +00:00
Qi Xiao
57d3515ec1 Add highlighting for histlist query. 2021-02-27 23:51:49 +00:00
Qi Xiao
b2591e95a7 Add new edit:clear command.
This fixes #1238.
2021-02-26 00:36:09 +00:00
Qi Xiao
9ebb46be0f pkg/cli/tk: Tweak the scrollbar algorithm.
The algorithm now guarantees that the scrollbar size remains the same if the
window size remains the same.
2021-02-21 23:05:41 +00:00
Qi Xiao
5327ba3521 Make tests compatible with "go test -count n" (n > 1).
The "-count" flag causes the test functions to be invoked multiple times. Since
some tests mutate their test data or some global state, they will fail when
invoked with a count larger than 1.

This commit changes *some* of such tests to either avoid mutating the test data,
or resetting the global state. Some such tests still remain and will be fixed later.
2021-02-17 22:46:32 +00:00
Qi Xiao
fcc005a14a Fix pkg/edit test - one file was left out of that commit. 2021-02-17 22:42:06 +00:00
Qi Xiao
ed854fa667 Remove edit:histlist:toggle-case-sensitivity; do smart-case matching. 2021-02-14 15:52:38 +00:00
Qi Xiao
9f13c3cc6e pkg/cli: Support global bindings.
Global bindings are consulted when an event is not handled by the active widget.
2021-02-14 01:38:34 +00:00
Qi Xiao
3545cb5020 pkg/cli/mode: Fix a flaky completion mode test. 2021-02-13 23:23:23 +00:00
Qi Xiao
0976cacf09 Fix style. 2021-02-13 23:21:39 +00:00
Qi Xiao
62f0f4b580 pkg/cli/mode: Expose the navigation mode as a widget. 2021-02-13 23:21:39 +00:00
Qi Xiao
fb134df955 pkg/cli/mode: Expose the custom listing mode as a widget. 2021-02-13 23:21:39 +00:00
Qi Xiao
50808dc3f2 pkg/cli/mode: Expose the lastcmd mode as a widget. 2021-02-13 23:21:39 +00:00
Qi Xiao
9af7297f75 pkg/cli/mode: Expose the instant mode as a widget. 2021-02-13 23:21:39 +00:00
Qi Xiao
0c17a09de6 pkg/cli/mode: Make Completion, Histlist, Location wrap tk.ComboBox.
Also document that they are based on ComboBox.
2021-02-13 23:21:39 +00:00
Qi Xiao
9c5669ecdd pkg/cli/mode: Expose the location mode as a widget. 2021-02-13 01:25:05 +00:00