fix: enable Ctrl+Enter query execution
This commit is contained in:
@@ -22,4 +22,4 @@
|
|||||||
- [x] `line:col` indicator in the bottom-right status bar should never disappear but instead display "N/A" in that case.
|
- [x] `line:col` indicator in the bottom-right status bar should never disappear but instead display "N/A" in that case.
|
||||||
- [x] database type indicator should be moved down just left of the "line:col" indicator like in the attached image
|
- [x] database type indicator should be moved down just left of the "line:col" indicator like in the attached image
|
||||||
- [x] introduce vim navigation inside the query input field (`hjkl`, `w/b/e`, `0/^/$`, `gg/G`; bindings listed in `?`).
|
- [x] introduce vim navigation inside the query input field (`hjkl`, `w/b/e`, `0/^/$`, `gg/G`; bindings listed in `?`).
|
||||||
- [ ] bugfix: ctrl+enter current doesn't work for executing sql, only F5 does.
|
- [x] bugfix: ctrl+enter current doesn't work for executing sql, only F5 does.
|
||||||
@@ -341,6 +341,7 @@ fn draw_help(frame: &mut Frame, screen: Rect, offset: &mut u16) {
|
|||||||
gg / G First / last line\n\
|
gg / G First / last line\n\
|
||||||
Home/End Start / end of line in either mode\n\
|
Home/End Start / end of line in either mode\n\
|
||||||
F5 / Ctrl-Enter Execute query 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\
|
Type / paste Enter SQL in Insert mode\n\
|
||||||
Enter Insert newline in Insert mode\n\
|
Enter Insert newline in Insert mode\n\
|
||||||
Backspace/Delete Remove text 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 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>;
|
type Result<T, E = Box<dyn Error>> = std::result::Result<T, E>;
|
||||||
|
|
||||||
const HELP: &str = r#"dbdash — read-only PostgreSQL and SQLite inspection
|
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.
|
including quoted identifiers, literals, and multiline comments/strings as you type.
|
||||||
F5 / Ctrl-Enter executes one SELECT/CTE on the current connection, showing up
|
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.
|
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
|
Failed queries keep the previous results. Opening a relation restores browsing
|
||||||
without clearing the query text. Query text is not saved across connections.
|
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)
|
q / Ctrl-C Quit outside the query editor (q inserts text only in INSERT)
|
||||||
@@ -137,14 +143,21 @@ fn run() -> Result<()> {
|
|||||||
.transpose()?;
|
.transpose()?;
|
||||||
let result = (|| {
|
let result = (|| {
|
||||||
let mut terminal = ratatui::try_init()?;
|
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)
|
connection::run(&mut terminal, database)
|
||||||
})();
|
})();
|
||||||
let paste_result =
|
let restore_result = crossterm::execute!(
|
||||||
crossterm::execute!(std::io::stdout(), crossterm::event::DisableBracketedPaste);
|
std::io::stdout(),
|
||||||
|
PopKeyboardEnhancementFlags,
|
||||||
|
DisableBracketedPaste
|
||||||
|
);
|
||||||
ratatui::restore();
|
ratatui::restore();
|
||||||
result?;
|
result?;
|
||||||
paste_result?;
|
restore_result?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user