Code Monkey home page Code Monkey logo

Comments (10)

cronvel avatar cronvel commented on July 20, 2024

BTW you should not edit the screen directly because it would do it behind the back of the inputField.

If I understand correctly, this is trivial to implement, I will look into it tomorrow.

from terminal-kit.

jwarkentin avatar jwarkentin commented on July 20, 2024

Another thing I'm thinking about where this would be useful is in implementing the standard terminal ability to hold CTRL and press the left and right arrow keys to move the cursor by words and logical segments. If there were just a way to get and set the cursor offset (single number, not coordinates) in the input relative to the beginning of the text then all of this would be easy to implement. The trick is just making sure that the offset takes into account multi-line inputs.

from terminal-kit.

cronvel avatar cronvel commented on July 20, 2024

@jwarkentin Ctrl-left, Ctrl-right, Ctrl-U and Ctrl-K are now implemented as of v1.2.0.

from terminal-kit.

samizdatco avatar samizdatco commented on July 20, 2024

As far as I can tell, the current implementation of the Ctrl-U and Ctrl-K behavior updates the cursor position and the inputField's value, but it doesn't actually erase any characters from the terminal. Is this a bug or is the screen-updating supposed to happen outside of the inputField's redraw() routine?

from terminal-kit.

cronvel avatar cronvel commented on July 20, 2024

@samizdatco It works on all terminal that I tested. What is your terminal/OS?

from terminal-kit.

samizdatco avatar samizdatco commented on July 20, 2024

I'm using Terminal.app on Mac OS 10.11 (though note that the same behavior is seen in iTerm2 as well).

Here's my test script:

var term = require( 'terminal-kit' ).terminal
term('>')
term.inputField(function(err, input){
    term.processExit(0)
})

And here's what I see after entering some text and then typing Ctrl-U:

termkit-crtl-u

from terminal-kit.

cronvel avatar cronvel commented on July 20, 2024

Thanks for reporting, indeed there was redraw issue depending on some options (or absence of options). It should be fixed now! ;)

from terminal-kit.

samizdatco avatar samizdatco commented on July 20, 2024

Yes! It's working great now. Thanks so much!

from terminal-kit.

samizdatco avatar samizdatco commented on July 20, 2024

I also added a couple of other deletion keybindings that are common to most readline-powered command line tools here:
Ctrl-W: delete previous word
Alt-D: delete next word

Do these seem more or less correct to you?

from terminal-kit.

cronvel avatar cronvel commented on July 20, 2024

This is cherry-picked, and it landed on v1.9.0, thanks! ;)

from terminal-kit.

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.