Commit Graph

47 Commits

Author SHA1 Message Date
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
51e4d97568 interface{} -> any now that Elvish requires Go 1.18. 2022-03-20 16:17:19 +00:00
Qi Xiao
5f1673c6c4 Use go-cmp to report unexpected test results.
cmp.Diff panics when comparing a struct that has unexported fields and no String
or Equal method, so change some structs to either export all their fields or
have an Equal method.

This fixes #1136.
2022-03-11 22:49:32 +00:00
Shengjing Zhu
5724ec4c47 Fix typos and add codespell to CI 2021-08-22 23:07:34 +01:00
Kurtis Rader
85c499f110 Lint cleanups
This change addresses issues reported by the `staticcheck` tool and a
couple reported by the `golint` tool. It also adds missing issue links
to a couple of entries in the release notes. This change deliberately
does not address these warnings since it is unclear whether the project
owner would prefer to suppress or address them:

    pkg/store/cmd.go:8:2: should not use dot imports (ST1001)
    pkg/store/db_store.go:10:2: should not use dot imports (ST1001)
    pkg/store/dir.go:8:2: should not use dot imports (ST1001)
2021-07-07 23:21:02 +01:00
Kurtis Rader
d303c37987 Test more combinations of Text/Segment+num
This fixes the *Segment.Concat and RConcat methods to handle the new
number types. It also adds more tests of concatenation with the "Text"
and "Segment" types with number types.

Related #1340
2021-06-27 16:32:38 +01:00
Qi Xiao
91b6f6dd72 Use the integrated persistent package. 2021-05-03 22:17:46 +01:00
Qi Xiao
c2a232a156 Merge branch 'num'
This fixes #241.
2021-04-08 00:43:19 +01:00
Kurtis Rader
12980c2719 Some golint cleanups 2021-04-05 15:31:53 +01:00
Qi Xiao
da67ba8a4a Use machine word (int) instead of int64 for fixnum. 2021-04-04 13:37:38 +01:00
Qi Xiao
4612b58759 Support exact integer and rational numbers. 2021-04-04 00:58:53 +01:00
Qi Xiao
d3a38e0414 pkg/ui: Add utility for styling multiple regions in a text.
The code is factored from pkg/edit/highlight and is generally useful.
2021-02-27 23:05:42 +00:00
Qi Xiao
196eea21d4 Change module import path to src.elv.sh 2021-01-27 01:30:25 +00:00
Qi Xiao
15d69f98ff pkg/ui: Clarify godoc comments for Concat and RConcat implementations. 2020-12-25 17:43:47 +00:00
Kurtis Rader
d52aa03764 In prompts implicitly coerce float64 to string
Including the float64 data type in the prompt value stream causes an error.
This causes those values to be implicitly converted to a string as happens
everywhere else in Elvish.

I initially intended to modify the code to do the implicit string coercion
for any type not otherwise explicitly handled by the pkg/ui `Concat`
methods. I decided against that approach because doing so doesn't make
sense for some types that might appear in the value stream; e.g., Elvish
exceptions.

Fixes #1186
2020-12-25 17:34:49 +00:00
Qi Xiao
2bf7a5d8d1 Apply feedback for PR #1181. 2020-12-25 01:13:19 +00:00
Kurtis Rader
9c7c9cf7d9 [cleanup] trivial golint suggested changes
As with commit #eb2a792 I acknowledge that `golint` recommendations are
controversial and should not automatically be acted on. Nonetheless,
this change fixes legitimate lint issues such as copy/paste cleanups,
style problems I introduced (`i += 1` versus `i++`) or method/var comments
that are not in the preferred form.
2020-12-25 01:11:33 +00:00
Qi Xiao
11751f87ac Address feedback in PR #1177. 2020-12-25 00:44:26 +00:00
Kurtis Rader
122ce3b7d1 allow binding to a literal control char
It should be possible to bind a key to a literal control character. For
example, it should be possible to write:

    edit:insert:binding["\e"] = $edit:command:start~

as a logically equivalent alternative to the preferred form:

    edit:insert:binding[Ctrl-'['] = $edit:command:start~

Resolves #1185
2020-12-25 00:39:43 +00:00
Kurtis Rader
3c29912b3f Improve test coverage
I noticed my prior change did not verify that symbolic key name `Ctrl-?`
was equivalent to `Backspace`.
2020-12-25 00:39:43 +00:00
Kurtis Rader
9edcb78050 Make key binding syntax more consistent
Document the format key of names and modifiers; albeit with a TODO
regarding the `Shift` modifier.

Make function key modifier matching case sensitive (`Alt` not `alt`)
to match key name matching (`Enter` not `enter`).

Implement `Ctrl-?` as the logical counterpart to `"\c?"`.

Resolves #1163
2020-12-25 00:39:43 +00:00
Shengjing Zhu
6c08de0ff3 Fix typos found by codespell 2020-10-10 22:47:50 +01:00
Qi Xiao
735b1cf973 pkg: Move util/feed.go to eval/vals. 2020-09-03 05:22:44 +01:00
Qi Xiao
89d95c17a6 pkg/ui: Do not strip unprintable characters from the prompt.
This will preserve private use characters that are sometimes used by icon fonts.
Control characters are already escaped by cli/term.Writer.
2020-08-28 22:00:40 +01:00
Qi Xiao
5e648ceac7 pkg/ui: Implement ParseSGREscapedText.
Part of a reimplementation of #1038.
2020-08-25 22:47:22 +01:00
Qi Xiao
9169f803ea pkg/ui: Add a Concat function for concatenating multiple Text's. 2020-08-25 22:34:19 +01:00
Qi Xiao
b6adbed317 pkg/ui: Implement StyleFromSGR in terms of a new StylingFromSGR.
Part of a reimplementation of #1038.
2020-08-25 21:17:14 +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
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
2d802874ce pkg/ui: Add bare-bone tests for text_segment.go. 2020-04-04 01:32:13 +01:00
Qi Xiao
8374937a5f pkg/ui: Add more tests.
Also fix some small issues discovered by tests.

This addresses #944.
2020-04-01 22:39:46 +01:00
Qi Xiao
01b761df04 pkg/ui: Make all Styling types comparable. 2020-04-01 22:26:02 +01:00
Qi Xiao
ccbad60ab9 pkg/ui: Test Style.SGR.
This addresses #944.
2020-04-01 00:46:29 +01:00
Qi Xiao
5588cda927 pkg/ui: Style.ImportFromOptions -> .MergeFromOptions. 2020-04-01 00:39:02 +01:00
Qi Xiao
7a324880b0 pkg/ui: Test color.go.
This addresses #944.
2020-04-01 00:37:09 +01:00
Qi Xiao
c0146f1c42 pkg/ui: Export Fg and Bg. 2020-04-01 00:36:46 +01:00
Qi Xiao
3cd90d78cd [cleanup] pkg: Format files with "gofmt -s". 2020-04-01 00:11:16 +01:00
Qi Xiao
a70c2a30a4 pkg/ui: Declare every Styling global variable as Styling type.
This will make them appear under the Styling header in godoc.
2020-04-01 00:09:00 +01:00
Qi Xiao
9b83eaf61b pkg/ui: Improve the doc for styling variables. 2020-04-01 00:07:00 +01:00
Qi Xiao
c36be6e311 pkg/ui: Rearrange files. 2020-03-31 23:11:59 +01:00
Qi Xiao
794c19e19f pkg/ui: Export ParseKey and move ToKey to pkg/edit. 2020-03-31 23:05:41 +01:00
Qi Xiao
5442574394 pkg/ui: Test more of key.go.
Also fix the quoting style and an out-of-range bug in key.go.

This addresses #944.
2020-03-31 22:58:17 +01:00
Qi Xiao
f2ef28f51c pkg/ui: More tests for key.go.
This addresses #944.
2020-03-31 05:55:49 +01:00
Qi Xiao
c68de40a91 pkg/ui: Do not use util.Throw. 2020-01-12 17:45:42 -05:00
Qi Xiao
e9a2a9392d pkg/ui: Parse more SGR sequences in StyleFromSGR. 2019-12-31 11:51:39 +00:00
Qi Xiao
e45fdf7228 Move all libraries to new pkg/. 2019-12-23 20:00:59 +00:00