azat / chdig

Dig into ClickHouse with TUI interface.
MIT License
132 stars 13 forks source link

Close left menu with q/backspace shortcut #50

Closed filimonov closed 7 months ago

filimonov commented 7 months ago

Since you use F1/F2/F8 keys you should also support Esc to close popups.

azat commented 7 months ago

Esc is bad choice for binding to (see referenced commit), but support q/backspace for sidebar menu - make sense.

filimonov commented 7 months ago

And what is the exact problem? Cursive should be able to distinguish Esc and Home (and similar)

use cursive::{Cursive, event::Key};
use cursive::views::{Dialog, OnEventView};
use cursive::CursiveExt;

fn main() {
    let mut siv = Cursive::default();

    let dialog = Dialog::text("Press Esc to quit, or Home for a surprise!")
        .title("Key Event Example")
        .button("OK", |s| s.add_layer(Dialog::info("You pressed OK!")));

    let on_event_view = OnEventView::new(dialog)
        .on_event(Key::Esc, |s| s.quit())
        .on_event(Key::Home, |s| {
            s.add_layer(Dialog::info("Surprise! You pressed Home."));
        });

    siv.add_layer(on_event_view);

    siv.run();
}
azat commented 7 months ago

And what is the exact problem? Cursive should be able to distinguish Esc and Home (and similar)

Either the problem is gone after switching backend or terminal, so OK now - https://github.com/azat/chdig/pull/54

azat commented 7 months ago

Though to me q looks better and more convenient, but OK to bind to both.