Commit Graph

44 Commits

Author SHA1 Message Date
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
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
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
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
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
b2591e95a7 Add new edit:clear command.
This fixes #1238.
2021-02-26 00:36:09 +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
196eea21d4 Change module import path to src.elv.sh 2021-01-27 01:30:25 +00:00
Kurtis Rader
7bbf75756c Replace "kr" package dependency with "creack"
I was working on issue #661 and noticed that github.com/kr/pty was dead
when I ran into a problem with that module on macOS (GOARCH == darwin).
Replace that dependency with github.com/creack/pty which is ostensibly
being actively maintained.

I also chose to remove a couple of obsolete module signatures at the
same time.
2020-10-10 22:41:09 +01:00
Qi Xiao
11898f763a pkg/util: Break into fsutil/ and logutil/. 2020-09-03 05:27:18 +01:00
Qi Xiao
6dd122107c pkg: Move multierror.go from util/ to diag/. 2020-09-03 05:12:55 +01:00
Kurtis Rader
eed744044c Eliminate sys.Ioctl
I started by writing tests for sys.Ioctl but after I had 100% coverage
of that function it occurred to me the function could be eliminated.

Related #1062
2020-08-27 15:51:29 +01:00
Qi Xiao
8b2e669a5f Remove unused code. 2020-08-23 16:04:44 +01:00
Kurtis Rader
28798ac053 Convert "XXX" to "TODO" comments
I stumbled across a comment that began with "XXX". It was clearly meant as
a "TODO" comment. This changes all such occurrences. However, a few "XXX"
comments are ambiguous and a better prefix might be "WARNING". The "TODO"
prefix at least ensures someone, eventually, looks into the situation
and either rewords the comment or fixes the problem. This change means
everyone can assume searching for "// TODO" will find all such comments
rather than requiring they also know to search for "// XXX".
2020-08-16 16:29:34 +01:00
Qi Xiao
a90e8eb75d Revert "Eliminate sys.Ioctl"
Results in "failed to put myself in foreground" errors.

This reverts commit bea90271b0.
2020-08-16 14:23:37 +01:00
Kurtis Rader
bea90271b0 Eliminate sys.Ioctl
I started by writing tests for sys.Ioctl but after I had 100% coverage
of that function it occurred to me the function could be eliminated.

Related #1062
2020-08-16 14:14:48 +01:00
Kurtis Rader
4bfb6e2aad Fix how [ctrl-v] works on BSD systems
On BSD systems iexten has to be explicitly disabled. Whereas on Linux
systems it is implicitly ignored if icanon is disabled.

Fixes #917
2020-04-24 21:41:35 +01:00
Qi Xiao
a36a372624 pkg: Fix small issues found by staticcheck. 2020-04-13 13:56:10 +01:00
Qi Xiao
3037f6c8bf pkg/util: Move the wcwidth utilities to a new package, and add more tests.
This addresses #944.
2020-04-06 12:00:01 +01:00
Qi Xiao
b8eee7a29f pkg/cli/term: Add bare-bone unit test for writer.go. 2020-04-04 01:25:01 +01:00
Qi Xiao
770fd8e6c4 Scale all test timeouts with $ELVISH_TEST_TIME_SCALE. 2020-04-03 22:12:20 +01:00
Qi Xiao
31f0eaa7b0 [cleanup] pkg: Remove ineffectual assignments. 2020-04-01 00:17:09 +01:00
Qi Xiao
6cc7063a2a pkg/cli/term: Simplify the Reader interface and implementations.
The Reader interface now consist entirely of synchronous methods. The
asynchronous part is done in cli.aTTY.
2020-01-01 15:32:20 +00:00
Qi Xiao
bd0b2dc96c pkg/cli/term: Implement Reader in terms of readRune.
Also remove runeReader.
2020-01-01 11:04:25 +00:00
Qi Xiao
245b3dc1b2 pkg/cli/term: Add readRune, a much simpler alternative to runeReader. 2019-12-31 22:02:52 +00:00
Qi Xiao
7915c41e69 pkg/cli/term: Support timeout in fileReader. 2019-12-31 21:20:18 +00:00
Qi Xiao
52b5e23d73 pkg/sys: Support timeout in WaitForRead. 2019-12-31 21:14:02 +00:00
Qi Xiao
40cba03887 pkg/cli/term: Introduce a new fileReader helper.
This helper can read from a file one byte at a time and can be stopped. It will
be the basis of a new runeReader.
2019-12-31 16:50:44 +00:00
Qi Xiao
e45fdf7228 Move all libraries to new pkg/. 2019-12-23 20:00:59 +00:00