Giter VIP home page Giter VIP logo

Comments (5)

gbitten avatar gbitten commented on May 12, 2024 1

The PR #56 makes the KeyESC binding work correctly.

from gocui.

jroimartin avatar jroimartin commented on May 12, 2024

Hi @phf,

On one hand, I hardcoded it to avoid adding "tricky" options to the gocui's API, making it simple for the users.

On the other hand, I chose inputMode := termbox.InputAlt because I think it's more "compatible". From the termbox-go documentation:

    1. Esc input mode. When ESC sequence is in the buffer and it doesn't
    match any known sequence. ESC means KeyEsc. This is the default input
    mode.

    2. Alt input mode. When ESC sequence is in the buffer and it doesn't
    match any known sequence. ESC enables ModAlt modifier for the next
    keyboard event.

I always remember having troubles, depending on the terminal emulator, to make the ALT/META key works. So, you ended up using 'ESC+' or mapping ALT/META to 'ESC+'. The same happens in OSX and, for instance, iTerm2 recommends:

image

So, for example, when you press "ALT+2", it will send ESC+2. To bind this combination in gocui, you can use:

if err := g.SetKeybinding("someView", '2', gocui.ModAlt, someFunc); err != nil {
                return err
}

Because it uses termbox.InputAlt by default. And, this is the rationale to take this decision.

from gocui.

micronix avatar micronix commented on May 12, 2024

I'm trying to create an editor interface similar to vim with a normal mode and an insert mode. It feels like it should be easy to do this, but when I bind j in ModAlt mode I have to press Esc every time. What am I missing?

    if err := g.SetKeybinding("main", 'j', gocui.ModAlt, cursorDown); err != nil {
        return err
    }

from gocui.

jroimartin avatar jroimartin commented on May 12, 2024

@micronix please take a look at my previous comment. There you have the explanation and solution to that.

from gocui.

jroimartin avatar jroimartin commented on May 12, 2024

Closed due to inactivity.

from gocui.

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.