Coder Social home page Coder Social logo

readline's People

Contributors

abiosoft avatar antekresic avatar bbrowning avatar bdarnell avatar buaazp avatar chessman avatar chzyer avatar derickr avatar dvrkps avatar edwardbetts avatar fxaguessy avatar gfrey avatar helflym avatar jamesnetherton avatar jcramb avatar jelmersnoeck avatar jordanlewis avatar kenshaw avatar mehrdadrad avatar michalpristas avatar mrsinham avatar nvanbenschoten avatar paultag avatar rreuvekamp avatar sahib avatar setnicka avatar slingamn avatar tpodowd avatar wader avatar xdamman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

sohomdatta1

readline's Issues

unexport constants

CharLineStart, MetaBackward, etc. can all be lowercased, unexporting them.

racey redundant prompt in ReadPassword methods

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.

History search done redraw issue

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

add migration doc

Add documentation explaining what has changed from upstream and how to migrate.

refactor suspend/resume

This code is extremely bogus:

readline/utils.go

Lines 60 to 83 in cd7fbcc

// WaitForResume need to call before current process got suspend.
// It will run a ticker until a long duration is occurs,
// which means this process is resumed.
func WaitForResume() chan struct{} {
ch := make(chan struct{})
var wg sync.WaitGroup
wg.Add(1)
go func() {
ticker := time.NewTicker(10 * time.Millisecond)
t := time.Now()
wg.Done()
for {
now := <-ticker.C
if now.Sub(t) > 100*time.Millisecond {
break
}
t = now
}
ticker.Stop()
ch <- struct{}{}
}()
wg.Wait()
return ch
}

Instead, resumption should be detected by handling SIGCONT. (Not sure about the story on Windows.)

enforce gofmt

Let's do this last, after other invasive refactors are complete, since it will introduce lots of potential merge conflicts.

Where is the ClearScreen method?

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?

refactor config handling

  1. Hide (*Config).Init: this should not be exposed
  2. NewFromConfig and SetConfig should copy the config. This prevents data races from clients attempting to modify the config from the outside.
  3. Multiple copies of the config are stored in different structures. All config access should be consolidated into one canonical location that can be updated atomically
  4. It will still be necessary to propagate some changes into subsystems when the config is updated; this should be made data-race-free
  5. Remove Config.opHistory and Config.opSearch (these should be members of Operation only)
  6. (*Instance).ReadPasswordWithConfig has weird implications, for example, it can change the stdio handles back to the defaults. This API needs reevaluation.

consider removing FillableStdin

It's unclear that FillableStdin is actually usable for any purpose that ReadlineWithDefault can't handle:

readline/readline.go

Lines 225 to 228 in 86cc349

func (i *Instance) ReadlineWithDefault(what string) (string, error) {
i.operation.SetBuffer(what)
return i.operation.String()
}

second pass at shrinking the API

This is looking better:

https://pkg.go.dev/github.com/ergochat/[email protected]

but there's still a lot of cruft. For example:

  1. Listener should probably become a function pointer type rather than an interface, eliminating the need for DumpListener. See #6 for discussion of the listener API
  2. The relationship between PrefixCompleter, PrefixCompleterInterface, and functions like Do and Print is confused
  3. Instance has too many methods
  4. Painter should be a function pointer type, not an interface type
  5. TabCompleter should probably be hidden
  6. What are SegmentComplete and SegmentCompleter?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.