Commit Graph

159 Commits

Author SHA1 Message Date
Qi Xiao
5bf0290741 pkg/cli/term: Support surrogate pairs on Windows.
This fixes #1502.
2022-06-06 23:12:54 +01:00
Qi Xiao
2c30cf9806 Fix staticcheck errors on Windows. 2022-06-05 22:46:24 +01:00
Qi Xiao
f043bd33fb Fixup for #1549. 2022-06-05 22:37:52 +01:00
Kurtis Rader
fa704d6ac6 Implement edit:command-abbr
It turns out that the "small word" abbreviation mechanism I added isn't
really what I, or most users, want. What users really want, at least
most of the time, is the Fish shell abbreviation behavior of expanding
an abbreviation only in the command head position.

Resolves #1472
2022-06-05 22:15:07 +01:00
Qi Xiao
8b0c7fdb36 Fix some lint warnings found on Windows. 2022-06-05 22:01:16 +01:00
Kurtis Rader
345c5c66dd Don't dot import pkg/ui
Qualified imports of pkg/ui outnumber unqualified (82 to 1). Improve
consistency, and clarity, by changing the dot (unqualified) imports of
that package symbols to qualified.
2022-06-04 23:39:19 +01:00
Kurtis Rader
71cd3835bc Don't dot import pkg/tt
Qualified imports of pkg/tt outnumber unqualified (27 to 24). Improve
consistency, and clarity, by changing the dot (unqualified) imports of
that package symbols to qualified.
2022-06-04 23:39:19 +01:00
Qi Xiao
8519085327 clitest: Make failures in TestBuffer and TestNotesBuffer fatal.
If a buffer (or notes buffer) hasn't appeared, it means that the app is not in
some intended state. Subsequent tests are unlikely to be meaningful, and may run
into race conditions.

A lot of existing code already uses TestBuffer to ensure that a certain state is
reached, and making failures fatal also suits this usage better.

This fixes #1507.
2022-04-09 14:40:52 +01:00
Qi Xiao
51e4d97568 interface{} -> any now that Elvish requires Go 1.18. 2022-03-20 16:17:19 +00:00
Qi Xiao
f7cb556d9b Require Go 1.18.
- Run "go fix" to remove legacy build tags

- Use staticcheck@master until it has a release that supports Go 1.18

- Turn off autocrlf for Windows tasks
2022-03-20 15:28:23 +00:00
Qi Xiao
e2901118a5 Simplify terminal setup functions.
Remove SetupGlobal and Sanitize and replace them with a SetupForEval, which is
similar to Setup, but called before evaluating code and returns a function to
call after evaluating code.
2022-03-18 10:54:01 +00:00
Qi Xiao
e85afa2cbe Fixup for PR #1499.
- Use filepath.Ext instead of path.Ext

- Use cmp.Diff to generate test failure messages

- Misc stylistic changes
2022-03-12 23:22:34 +00:00
Kurtis Rader
603aae077d Improve searching PATH on Windows for completions
This was extracted from https://github.com/elves/elvish/pull/1326. It
augments that change by honoring $E:PATHEXT and some other
minor improvements.  This matches the behavior of the Go stdlib
os/exec.LookPath() function that is used to decide if what has been typed
(in a non-completion context) represents an external command.
2022-03-12 22:49:52 +00:00
moko256
c8f678d2a5 On Windows, implement sanitize in pkg/cli/term/setup_windows to cleanup console modes that external command changed 2022-03-06 23:33:17 +00:00
Qi Xiao
84b72af4ca Support using styled text in &display to edit:complex-candidate.
This fixes #1011.
2022-01-03 20:30:00 +00:00
Qi Xiao
c46fd60270 Properly clear the filter when ascending or descending in nav mode.
Also add regression tests for this behavior.
2021-12-30 12:58:34 +00:00
Qi Xiao
46774d7078 Use (*Evaler).Chdir for changing directory in navigation mode.
This will run the hooks and update $E:PWD correctly.
2021-12-28 17:52:09 +00:00
moko256
c054b0a24d pkg/cli/term: Use ENABLE_WRAP_AT_EOL_OUTPUT on Windows. 2021-12-16 22:20:44 +00:00
Qi Xiao
8cbd39f006 Support calling edit:notify with a styled text.
This fixes #1438.
2021-12-08 00:26:17 +00:00
Qi Xiao
5b490475e7 pkg/testutil: ScaledMs -> Scaled, takes a time.Duration instead. 2021-10-05 01:02:54 +01:00
Qi Xiao
3f418dfd5c pkg/cli/term: Fix test on Windows. 2021-10-03 00:35:32 +01:00
Qi Xiao
00c26410cc pkg/cli/term: Increase coverage of buffer.go and reader.go. 2021-10-03 00:29:55 +01:00
Qi Xiao
0219b99add pkg/cli/term: More tests for convertEvent in reader_windows.go. 2021-10-03 00:03:02 +01:00
Qi Xiao
7961cf2d7a pkg/cli/term: Add very basic tests against reader_windows.go.
We can't test actual console events, but at least we can test the
convertEvent function.
2021-10-02 22:38:02 +01:00
Qi Xiao
7a72b6346a Reorganize pkg/sys into portable and non-portable system utilities.
Non-portable ones are moved into new packages pkg/sys/e{unix windows}. The "e"
prefix is needed to avoid conflict with packages under golang.org/x/sys/ and can
mean "extra".
2021-10-02 13:14:00 +01:00
Qi Xiao
be56f72729 pkg/testutil: Add utility for setting umask during tests. 2021-09-12 14:42:06 +01:00
Qi Xiao
9ade639b38 pkg/cli/term: Improve coverage of reader_unix.go.
Also change error messages to start with lower case letters.
2021-09-10 20:53:02 +01:00
Qi Xiao
c3345eebc7 pkg/cli/lscolors: Fix test on Windows. 2021-09-10 01:10:23 +01:00
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