summaryrefslogtreecommitdiffstats
path: root/src/repl.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-03-05 10:42:35 +0800
committerGitHub <noreply@github.com>2023-03-05 10:42:35 +0800
commitd876818df17ad7b25ebb38a678aa23c79b826e38 (patch)
tree8fc47e937867f4ccded5fed6b0190f5782e06725 /src/repl.rs
parent181fbe8163139cbd43425734eda6207553470a3b (diff)
downloadaichat-d876818df17ad7b25ebb38a678aa23c79b826e38.tar.gz
refactor: optimize clear screen (#16)
Diffstat (limited to 'src/repl.rs')
-rw-r--r--src/repl.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/repl.rs b/src/repl.rs
index 2ca1ea0..cd9e990 100644
--- a/src/repl.rs
+++ b/src/repl.rs
@@ -1,7 +1,7 @@
use crate::client::ChatGptClient;
use crate::config::{Config, Role};
-use crate::editor;
use crate::render::{self, MarkdownRender};
+use crate::term;
use crate::utils::{copy, dump};
use anyhow::{anyhow, Result};
use crossbeam::channel::{unbounded, Sender};
@@ -115,7 +115,7 @@ impl Repl {
dump_repl_help();
}
".clear" => match args {
- Some("screen") => self.editor.clear_scrollback()?,
+ Some("screen") => term::clear_screen(0)?,
Some("history") => {
let history = Box::new(self.editor.history_mut());
history
@@ -139,7 +139,7 @@ impl Repl {
"// Entering editor mode (Ctrl+D to finish, Ctrl+C to cancel)",
1,
);
- let content = editor::edit()?;
+ let content = term::edit()?;
dump("", 1);
handler.handle(ReplCmd::Submit(content))?;
}
@@ -189,6 +189,11 @@ impl Repl {
ReedlineEvent::MenuNext,
]),
);
+ keybindings.add_binding(
+ KeyModifiers::CONTROL,
+ KeyCode::Char('l'),
+ ReedlineEvent::ExecuteHostCommand(".clear screen".into()),
+ );
keybindings
}