Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ l3ine = "l3ine"
4should = "4should"
wr5ap = "wr5ap"
ine = "ine"
worl = "worl"
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ sqlite = ["rusqlite/bundled", "serde_json"]
sqlite-dynlib = ["rusqlite", "serde_json"]
system_clipboard = ["arboard"]
libc = ["crossterm/libc"]
hx = []

[[example]]
name = "helix"
required-features = ["hx"]

[[example]]
name = "cwd_aware_hinter"
Expand Down
9 changes: 9 additions & 0 deletions examples/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ fn main() -> reedline::Result<()> {
];
let completer = Box::new(DefaultCompleter::new_with_wordlen(commands.clone(), 2));

#[cfg(feature = "hx")]
let cursor_config = CursorConfig {
vi_insert: Some(SetCursorStyle::BlinkingBar),
vi_normal: Some(SetCursorStyle::SteadyBlock),
emacs: None,
..CursorConfig::default()
};

#[cfg(not(feature = "hx"))]
let cursor_config = CursorConfig {
vi_insert: Some(SetCursorStyle::BlinkingBar),
vi_normal: Some(SetCursorStyle::SteadyBlock),
Expand Down
30 changes: 30 additions & 0 deletions examples/helix.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Interactive Helix edit mode sandbox.
// cargo run --features=hx --example helix

use reedline::{CursorConfig, DefaultPrompt, Helix, Reedline, Signal};
use std::io;

fn main() -> io::Result<()> {
let mut line_editor = Reedline::create()
.with_edit_mode(Box::new(Helix::default()))
.with_cursor_config(CursorConfig::with_hx_defaults());
let prompt = DefaultPrompt::default();

println!("Helix edit mode demo. Starts in Normal mode.");
println!(" i = Insert, Esc = Normal, v = Select");
println!(" h/l = left/right, w/b/e = word motions");
println!(" Ctrl+C or Ctrl+D to exit\n");

loop {
let sig = line_editor.read_line(&prompt)?;
match sig {
Signal::Success(buffer) => {
println!("We processed: {buffer}");
}
Signal::CtrlD | Signal::CtrlC => {
println!("\nAborted!");
break Ok(());
}
}
}
}
Loading