Skip to content

Commit

Permalink
Adjust demo to sane bracketed paste API
Browse files Browse the repository at this point in the history
  • Loading branch information
sholderbach committed Nov 7, 2023
1 parent ac88209 commit 01261c8
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions examples/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use std::process::Command;
use {
crossterm::{
cursor::SetCursorStyle,
event::{DisableBracketedPaste, KeyCode, KeyModifiers},
execute,
event::{KeyCode, KeyModifiers},
},
nu_ansi_term::{Color, Style},
reedline::{
Expand All @@ -13,7 +12,6 @@ use {
EditCommand, EditMode, Emacs, ExampleHighlighter, Keybindings, ListMenu, Reedline,
ReedlineEvent, ReedlineMenu, Signal, Vi,
},
std::io::stdout,
};

use reedline::CursorConfig;
Expand Down Expand Up @@ -95,11 +93,7 @@ fn main() -> std::io::Result<()> {
))
.with_validator(Box::new(DefaultValidator))
.with_ansi_colors(true);
let res = line_editor.enable_bracketed_paste();
let bracketed_paste_enabled = res.is_ok();
if !bracketed_paste_enabled {
println!("Warn: failed to enable bracketed paste mode: {res:?}");
}
let _ = line_editor.enable_bracketed_paste();

// Adding default menus for the compiled reedline
line_editor = line_editor
Expand Down Expand Up @@ -226,9 +220,6 @@ fn main() -> std::io::Result<()> {
}
}

if bracketed_paste_enabled {
let _ = execute!(stdout(), DisableBracketedPaste);
}
println!();
Ok(())
}
Expand Down

0 comments on commit 01261c8

Please sign in to comment.