Giter Club home page Giter Club logo

Comments (5)

gwenn avatar gwenn commented on August 29, 2024 1

An equally good solution, that is conceptually cleaner would be a way to register a custom handler for the Enter KeyEvent, which would then decide whether to forward on a Cmd::Newline or a Cmd::AcceptOrInsertLine / Cmd::AcceptLine. Is this possible somehow?

You mean like https://docs.rs/rustyline/latest/rustyline/trait.ConditionalEventHandler.html ?

from rustyline.

gwenn avatar gwenn commented on August 29, 2024

Similar projects don't seem to expose those details either:
https://docs.rs/reedline/latest/reedline/trait.Validator.html
https://python-prompt-toolkit.readthedocs.io/en/master/pages/asking_for_input.html?highlight=valid#input-validation
https://python-prompt-toolkit.readthedocs.io/en/master/pages/reference.html#prompt_toolkit.validation.Validator

from rustyline.

luketpeterson avatar luketpeterson commented on August 29, 2024

Similar projects don't seem to expose those details either:

That's a good point. Exposing editor details in the Validator isn't very conceptually pure if the role of a Validator is just to validate a line.

My problem is that Validator does double duty first determining if a given Enter event should be a newline or not, and then whether the line should be accepted / rejected.

An equally good solution, that is conceptually cleaner would be a way to register a custom handler for the Enter KeyEvent, which would then decide whether to forward on a Cmd::Newline or a Cmd::AcceptOrInsertLine / Cmd::AcceptLine. Is this possible somehow?

from rustyline.

luketpeterson avatar luketpeterson commented on August 29, 2024

You mean like https://docs.rs/rustyline/latest/rustyline/trait.ConditionalEventHandler.html ?

Exactly like that! I don't know how I missed that. 🤦 Thank you for the reply.

from rustyline.

gwenn avatar gwenn commented on August 29, 2024

I don't know how I missed that.

Mainly because rustyline documentation is not great like the one for python-prompt-toolkit.

from rustyline.

Related Issues (20)

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.