fix: enable Ctrl+Enter query execution
This commit is contained in:
@@ -341,6 +341,7 @@ fn draw_help(frame: &mut Frame, screen: Rect, offset: &mut u16) {
|
||||
gg / G First / last line\n\
|
||||
Home/End Start / end of line in either mode\n\
|
||||
F5 / Ctrl-Enter Execute query in either mode\n\
|
||||
Ctrl-Enter needs enhanced keyboard reporting; use F5 otherwise.\n\
|
||||
Type / paste Enter SQL in Insert mode\n\
|
||||
Enter Insert newline in Insert mode\n\
|
||||
Backspace/Delete Remove text in Insert mode\n\
|
||||
|
||||
+17
-4
@@ -5,6 +5,11 @@ mod sql;
|
||||
|
||||
use std::{error::Error, io::IsTerminal, path::Path, process::ExitCode};
|
||||
|
||||
use crossterm::event::{
|
||||
DisableBracketedPaste, EnableBracketedPaste, KeyboardEnhancementFlags,
|
||||
PopKeyboardEnhancementFlags, PushKeyboardEnhancementFlags,
|
||||
};
|
||||
|
||||
type Result<T, E = Box<dyn Error>> = std::result::Result<T, E>;
|
||||
|
||||
const HELP: &str = r#"dbdash — read-only PostgreSQL and SQLite inspection
|
||||
@@ -65,6 +70,7 @@ Navigation:
|
||||
including quoted identifiers, literals, and multiline comments/strings as you type.
|
||||
F5 / Ctrl-Enter executes one SELECT/CTE on the current connection, showing up
|
||||
to 100 rows below. Results report truncation; use SQL LIMIT/OFFSET for more.
|
||||
Ctrl-Enter needs terminal support for enhanced keyboard reporting; use F5 otherwise.
|
||||
Failed queries keep the previous results. Opening a relation restores browsing
|
||||
without clearing the query text. Query text is not saved across connections.
|
||||
q / Ctrl-C Quit outside the query editor (q inserts text only in INSERT)
|
||||
@@ -137,14 +143,21 @@ fn run() -> Result<()> {
|
||||
.transpose()?;
|
||||
let result = (|| {
|
||||
let mut terminal = ratatui::try_init()?;
|
||||
crossterm::execute!(std::io::stdout(), crossterm::event::EnableBracketedPaste)?;
|
||||
crossterm::execute!(
|
||||
std::io::stdout(),
|
||||
EnableBracketedPaste,
|
||||
PushKeyboardEnhancementFlags(KeyboardEnhancementFlags::DISAMBIGUATE_ESCAPE_CODES)
|
||||
)?;
|
||||
connection::run(&mut terminal, database)
|
||||
})();
|
||||
let paste_result =
|
||||
crossterm::execute!(std::io::stdout(), crossterm::event::DisableBracketedPaste);
|
||||
let restore_result = crossterm::execute!(
|
||||
std::io::stdout(),
|
||||
PopKeyboardEnhancementFlags,
|
||||
DisableBracketedPaste
|
||||
);
|
||||
ratatui::restore();
|
||||
result?;
|
||||
paste_result?;
|
||||
restore_result?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user