Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial integration with fortio.org/terminal #120

Merged
merged 11 commits into from
Aug 10, 2024
Merged

Initial integration with fortio.org/terminal #120

merged 11 commits into from
Aug 10, 2024

Conversation

ldemailly
Copy link
Member

@ldemailly ldemailly commented Aug 8, 2024

Gets arrow keys and history - integration of several days of work to create https://github.com/fortio/terminal and improve the original golang.org/x/term through golang/term#15 (and in a usable fork while waiting: https://github.com/fortio/term)

Only adds 51k 🎉

┌─────────────────────────────────────────────────────────────────────┐
│ Diff between grol and grol_terminal                                 │
├──────────┬──────────────────────────┬──────────┬──────────┬─────────┤
│ PERCENT  │ NAME                     │ OLD SIZE │ NEW SIZE │ DIFF    │
├──────────┼──────────────────────────┼──────────┼──────────┼─────────┤
│ +100%    │ fortio.org/term          │          │ 24 kB    │ +24 kB  │
│ +100%    │ fortio.org/terminal      │          │ 5.9 kB   │ +5.9 kB │
│ +9.57%   │ <autogenerated>          │ 44 kB    │ 49 kB    │ +4.2 kB │
│ +340.55% │ path/filepath            │ 878 B    │ 3.9 kB   │ +3.0 kB │
│ +100%    │ golang.org/x/sys         │          │ 1.8 kB   │ +1.8 kB │
│ +33.03%  │ io                       │ 3.7 kB   │ 4.9 kB   │ +1.2 kB │
│ +7.70%   │ os                       │ 15 kB    │ 16 kB    │ +1.1 kB │
│ +6.59%   │ internal/poll            │ 14 kB    │ 16 kB    │ +958 B  │
│ +0.34%   │ grol.io/grol             │ 202 kB   │ 202 kB   │ +687 B  │
│ +0.09%   │ runtime                  │ 696 kB   │ 697 kB   │ +655 B  │
│ +2.95%   │ strings                  │ 20 kB    │ 21 kB    │ +591 B  │
│ +0.99%   │ fmt                      │ 51 kB    │ 52 kB    │ +511 B  │
│ +5.93%   │ main                     │ 4.6 kB   │ 4.9 kB   │ +272 B  │
├──────────┼──────────────────────────┼──────────┼──────────┼─────────┤
│ +3.04%   │ __rodata __DATA_CONST    │ 185 kB   │ 191 kB   │ +5.6 kB │
│ +1.78%   │ __rodata __TEXT          │ 196 kB   │ 199 kB   │ +3.5 kB │
│ +6.81%   │ __gopclntab __DATA_CONST │ 29 kB    │ 31 kB    │ +2.0 kB │
│ +3.05%   │ __data __DATA            │ 19 kB    │ 20 kB    │ +576 B  │
│ +24.19%  │ __go_buildinfo __DATA    │ 992 B    │ 1.2 kB   │ +240 B  │
│ +0.49%   │ __noptrdata __DATA       │ 32 kB    │ 33 kB    │ +160 B  │
│ +2.70%   │ __typelink __DATA_CONST  │ 2.2 kB   │ 2.3 kB   │ +60 B   │
│ +4.35%   │ __itablink __DATA_CONST  │ 552 B    │ 576 B    │ +24 B   │
├──────────┼──────────────────────────┼──────────┼──────────┼─────────┤
│ +2.50%   │ grol                     │ 2.0 MB   │ 2.1 MB   │ +51 kB  │
│          │ grol_terminal            │          │          │         │
└──────────┴──────────────────────────┴──────────┴──────────┴─────────┘

Fixes #110

@ldemailly ldemailly requested a review from ccoVeille August 9, 2024 19:58
main.go Outdated Show resolved Hide resolved
repl/repl.go Show resolved Hide resolved
repl/repl.go Outdated Show resolved Hide resolved
main.go Outdated
@@ -28,24 +29,34 @@ func Main() int {
compact := flag.Bool("compact", false, "When printing code, use no indentation and most compact form")
showEval := flag.Bool("eval", true, "show eval results")
sharedState := flag.Bool("shared-state", false, "All files share same interpreter state (default is new state for each)")
configDir, err := os.UserConfigDir() // TODO: this is ugly on a mac... allow homedir...
historyFileDefault := filepath.Join(configDir, ".grol_history")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
historyFileDefault := filepath.Join(configDir, ".grol_history")
historyFileDefault := filepath.Join(configDir, "grol", "history")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and now I have to mkdir all etc...? isn't it enough to use the config dir and put files there

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's dirty. I would prefer if you added a .grol_history file at the root of home folder than creating a file at the root of config folder.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok so I switched back to homedir as default but added GROL_HISTORY_FILE env var for people who don't like it so they don't have to set it in the flag either, does that work?

@ldemailly ldemailly merged commit 50d05eb into main Aug 10, 2024
1 check passed
@ldemailly ldemailly deleted the liner branch August 10, 2024 20:41
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.

consider a readline integration
2 participants