Skip to content

Commit

Permalink
Newline on Windows is shift-enter
Browse files Browse the repository at this point in the history
I tried ESC, ALT and SHIFT and only SHIFT worked across all the
terminals I tried (cmd.exe, terminal, powershell).
  • Loading branch information
marcbowes committed Apr 28, 2021
1 parent 97a9bf6 commit c742169
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

* Timestamps now render in `--format table`
* Byte arrays <= 32 bytes are rendered in `--format table`
* ALT/ESC + ENTER forces a newline
- on Windows the sequence is 'ESC ENTER'
- otherwise, 'ALT ENTER' (which would maximize the window on Windows)
* ALT/SHIFT + ENTER forces a newline
- on Windows the sequence is SHIFT+ENTER
- otherwise, ALT+ENTER (which would maximize the window on Windows)

## [2.0.0-alpha5] - 2021-04-23

Expand Down
14 changes: 3 additions & 11 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,11 @@ fn force_newline_event_seq() -> KeyEvent {
KeyEvent(KeyCode::Enter, Modifiers::ALT)
}

// On Windows, `ESC ENTER` is the key sequence for forcing a newline. This is
// because `ALT ENTER` typically maximizes the window.
// On Windows, `SHIFT+ENTER` is the key sequence for forcing a newline. This is
// because `ALT+ENTER` typically maximizes the window.
#[cfg(windows)]
fn force_newline_event_seq() -> KeyEvent {
use rustyline::Event;
use smallvec::smallvec;

let seq = smallvec![
KeyEvent(KeyCode::Esc, Modifiers::NONE),
KeyEvent(KeyCode::Enter, Modifiers::NONE)
];
let event = Event::KeySeq(seq);
KeyEvent(event, Modifiers::NONE)
KeyEvent(KeyCode::Enter, Modifiers::SHIFT)
}

impl Ui for ConsoleUi {
Expand Down

0 comments on commit c742169

Please sign in to comment.