ergochat / readline Goto Github PK
View Code? Open in Web Editor NEWA readline implementation in pure Go
License: MIT License
A readline implementation in pure Go
License: MIT License
Suggested by @tpodowd
Hey! hope your doing good! I noticed this patch for the z/OS fq port, merge?
https://github.com/ZOSOpenTools/fqport/blob/main/patches/readline-patch
As discussed here: wader/fq#940 this is a normal readline feature. I checked our v0.0.1 (last upstream release) and it does not work there, so it's not a regression, it was never implemented.
This race is still present:
Ctrl-R writes to the search mode status, wrapWriter reads it on asynchronous writes, and these are not necessarily synchronized.
No repro case yet:
panic: runtime error: slice bounds out of range [2:1]
goroutine 10 [running]:
github.com/ergochat/readline.(*runeBuffer).WriteRunes.func1()
github.com/ergochat/[email protected]/runebuf.go:141 +0x179
github.com/ergochat/readline.(*runeBuffer).refresh(0xc000064360, 0xc00046bc00)
github.com/ergochat/[email protected]/runebuf.go:450 +0x54
github.com/ergochat/readline.(*runeBuffer).WriteRunes(0xc000064360, {0xc0000122ec, 0x1, 0x1})
github.com/ergochat/[email protected]/runebuf.go:140 +0x1f5
github.com/ergochat/readline.(*runeBuffer).WriteRune(...)
github.com/ergochat/[email protected]/runebuf.go:111
github.com/ergochat/readline.(*operation).readline(0xc0000643c0, 0x0)
github.com/ergochat/[email protected]/operation.go:349 +0x143b
github.com/ergochat/readline.(*operation).Runes(0xc0000643c0)
github.com/ergochat/[email protected]/operation.go:447 +0x1a7
github.com/ergochat/readline.(*operation).String(...)
github.com/ergochat/[email protected]/operation.go:409
github.com/ergochat/readline.(*Instance).ReadLine(0x1?)
github.com/ergochat/[email protected]/readline.go:208 +0x17
github.com/ergochat/readline.(*Instance).Readline(0x0?)
github.com/ergochat/[email protected]/readline.go:213 +0x13
main.runClient.func1()
./ircdog.go:331 +0x82
created by main.runClient in goroutine 1
./ircdog.go:328 +0x210
Just noticed this, worth looking into (they work in xterm without tmux)
Investigate https://github.com/charmbracelet/vhs for this: https://www.youtube.com/watch?v=dtVezRX8OEM
This is looking better:
https://pkg.go.dev/github.com/ergochat/[email protected]
but there's still a lot of cruft. For example:
Listener
should probably become a function pointer type rather than an interface, eliminating the need for DumpListener
. See #6 for discussion of the listener APIPrefixCompleter
, PrefixCompleterInterface
, and functions like Do
and Print
is confusedInstance
has too many methodsPainter
should be a function pointer type, not an interface typeTabCompleter
should probably be hiddenSegmentComplete
and SegmentCompleter
?I bisected this to 62ab2cf. There is now a race where the password prompt can be printed an extra time. It's reproducible with example/readline-pass-strength/readline-pass-strength.go
:
$ ./readline-pass-strength
✔ ENT New Password:
✗ ENT New Password: Your password was: sdjflaksdf
I'm considering a more extensive refactor of how config updates are done, but I want to get a firm diagnosis for this first to make sure I'm solving the root cause.
Hey, just happen to noticed this:
$ go run example/readline-demo/readline-demo.go
»
# now press ctrl-r to get the "bck-i-search" promtp, then press enter
» k-i-search:
# ends up with messed up prompt
Think i also managed to get the history search into some other weird states but can't really reproduce it now
Tested on WezTerm, Windows Terminal (both use OpenConsole) and normal Command Prompt. WSL has normal expected Linux behavior.
It's unclear that FillableStdin is actually usable for any purpose that ReadlineWithDefault
can't handle:
Lines 225 to 228 in 86cc349
We've accumulated a lot of cases that are likely to break:
async
command in readline-demo)e.g. (*Instance).ReadlineCtx(ctx context.Context)
chzyer/readline#163 is still present in our fork
Should be straightforward because we already accept Ctrl-A and Ctrl-E?
See #61, it's not clear that this is really useful for anything (although it also doesn't clutter the API very much).
Hi team, I'm looking to support a paged tab completion for an application I'm building using readline.
I noticed that currently the user cannot select or navigate the candidates in pager mode, which makes it less useful. In chyzer#238 I treated paging as a transparent feature. I did not give it an explicit mode, so the user could navigate as usual in CompletSelection
mode with added hotkeys for scrolling through the page.
Below is a demo of what my implementation looks like:
I'd be happy to submit a PR if this change is welcome, or if there are plans to support selecting in pager mode I'd be happy to hack something that aligns with your preferred design, too.
(*Config).Init
: this should not be exposedNewFromConfig
and SetConfig
should copy the config. This prevents data races from clients attempting to modify the config from the outside.Config.opHistory
and Config.opSearch
(these should be members of Operation
only)(*Instance).ReadPasswordWithConfig
has weird implications, for example, it can change the stdio handles back to the defaults. This API needs reevaluation.term*.go are vendored forks, due to chzyer/readline#62 . The underlying issue is still present in x/term 0.6.0. It has something to do with this specifically:
https://github.com/golang/term/blob/0edf009663f942c41572b65d537ee2636e92180c/term_unix.go#L34
Context: golang/go#15625
Things like:
We are trying to migrate from chzyer/readline to this fork since the former seems to be unmaintained.
But I'm facing a few issues.
github.com/chzyer/readline had a ClearScreen method that was quite convenient for us as we want to expose
users a way to clear the screen by typing clear
. This package can still do that when pressing Ctrl+L but doesn't espose that as one easy method.
Could we get a ClearScreen method exposed, please?
This code is extremely bogus:
Lines 60 to 83 in cd7fbcc
Instead, resumption should be detected by handling SIGCONT. (Not sure about the story on Windows.)
Let's do this last, after other invasive refactors are complete, since it will introduce lots of potential merge conflicts.
Add documentation explaining what has changed from upstream and how to migrate.
The expandable ring buffer from #46 can replace container/list
as the data structure for history. Just a nice-to-have.
CharLineStart
, MetaBackward
, etc. can all be lowercased, unexporting them.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.