From cb4da18021a33a2ece255cfbdd147b8f90856f3b Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 29 May 2021 12:39:13 -0700 Subject: [PATCH] key assignment and docs for ShowDebugOverlay refs: https://github.com/wez/wezterm/issues/641 --- config/src/keyassignment.rs | 1 + docs/changelog.md | 1 + docs/config/keys.md | 1 + docs/config/lua/keyassignment/ShowDebugOverlay.md | 15 +++++++++++++++ wezterm-gui/src/overlay/debug.rs | 4 +++- 5 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 docs/config/lua/keyassignment/ShowDebugOverlay.md diff --git a/config/src/keyassignment.rs b/config/src/keyassignment.rs index e0a1c802c..c15feaa27 100644 --- a/config/src/keyassignment.rs +++ b/config/src/keyassignment.rs @@ -301,6 +301,7 @@ impl InputMap { KeyCode::Char('F'), Search(Pattern::CaseSensitiveString("".into())) ], + [Modifiers::CTRL, KeyCode::Char('L'), ShowDebugOverlay], [ctrl_shift, KeyCode::Char(' '), QuickSelect], // Font size manipulation [Modifiers::CTRL, KeyCode::Char('-'), DecreaseFontSize], diff --git a/docs/changelog.md b/docs/changelog.md index c20234361..d1ebedd74 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -34,6 +34,7 @@ As features stabilize some brief notes about them will accumulate here. * Fixed: splitting panes in multiplexer could fail after a network reconnect [#781](https://github.com/wez/wezterm/issues/781) * Fixed: multiplexer now propagates toast notifications and color palette to client [#489](https://github.com/wez/wezterm/issues/489) [#748](https://github.com/wez/wezterm/issues/748) * Fixed: neovim interprets drags as double clicks [#823](https://github.com/wez/wezterm/discussions/823) +* New: `CTRL+SHIFT+L` is assigned to [ShowDebugOverlay](config/lua/keyassignment/ShowDebugOverlay.md) [#641](https://github.com/wez/wezterm/issues/641) ### 20210502-154244-3f7122cb diff --git a/docs/config/keys.md b/docs/config/keys.md index 19aa22d9b..022aca198 100644 --- a/docs/config/keys.md +++ b/docs/config/keys.md @@ -169,6 +169,7 @@ The default key bindings are: | `SUPER` | `h` | `HideApplication` (macOS only) | | `SUPER` | `k` | `ClearScrollback="ScrollbackOnly"` | | `CTRL+SHIFT` | `K` | `ClearScrollback="ScrollbackOnly"` | +| `CTRL+SHIFT` | `L` | `ShowDebugOverlay` (*since: nightly builds only*)| | `SUPER` | `f` | `Search={CaseSensitiveString=""}` | | `CTRL+SHIFT` | `F` | `Search={CaseSensitiveString=""}` | | `CTRL+SHIFT` | `X` | `ActivateCopyMode` | diff --git a/docs/config/lua/keyassignment/ShowDebugOverlay.md b/docs/config/lua/keyassignment/ShowDebugOverlay.md new file mode 100644 index 000000000..5af1c569d --- /dev/null +++ b/docs/config/lua/keyassignment/ShowDebugOverlay.md @@ -0,0 +1,15 @@ +# `ShowDebugOverlay` + +*Since: nightly builds only* + +Overlays the current tab with the debug overlay, which is a combination +of a debug log and a lua [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop). + +The REPL has the following globals available: + +* `wezterm` - the [wezterm](../wezterm/index.md) module is pre-imported +* `window` - the [window](../window/index.md) object for the current window + +The lua context in the REPL is not connected to any global state; you cannot use it +to dynamically assign event handlers for example. It is primarily useful for +prototyping lua snippets before you integrate them fully into your config. diff --git a/wezterm-gui/src/overlay/debug.rs b/wezterm-gui/src/overlay/debug.rs index aa1cee057..f378c7619 100644 --- a/wezterm-gui/src/overlay/debug.rs +++ b/wezterm-gui/src/overlay/debug.rs @@ -131,10 +131,12 @@ pub fn show_debug_overlay(mut term: TermWizTerminal, gui_win: GuiWin) -> anyhow: loop { print_new_log_entries(&mut term, &mut latest_log_entry)?; - let mut editor = LineEditor::new(&mut term); editor.set_prompt("> "); if let Some(line) = editor.read_line(&mut host)? { + if line.is_empty() { + continue; + } host.history().add(&line); let expr = format!("return {}", line);