summaryrefslogtreecommitdiffstats
path: root/src/shell
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2022-02-28 23:02:46 -0500
committerJesse Luehrs <doy@tozt.net>2022-02-28 23:02:46 -0500
commitb792d9a83d0ed5e71ba4c0ae62730db8fee00216 (patch)
tree45fe04a1e536e5b7df6e9a67bd86efa420667b01 /src/shell
parentb9d919152cfa12bf74d4ffc5d0b1528e3b64857a (diff)
downloadnbsh-b792d9a83d0ed5e71ba4c0ae62730db8fee00216.tar.gz
nbsh-b792d9a83d0ed5e71ba4c0ae62730db8fee00216.zip
push some copies up the stack
Diffstat (limited to 'src/shell')
-rw-r--r--src/shell/history/mod.rs10
-rw-r--r--src/shell/mod.rs11
-rw-r--r--src/shell/readline.rs4
3 files changed, 15 insertions, 10 deletions
diff --git a/src/shell/history/mod.rs b/src/shell/history/mod.rs
index 5bcc820..8b67ed2 100644
--- a/src/shell/history/mod.rs
+++ b/src/shell/history/mod.rs
@@ -90,24 +90,24 @@ impl History {
pub fn run(
&mut self,
- cmdline: &str,
- env: &Env,
+ cmdline: String,
+ env: Env,
event_w: crate::shell::event::Writer,
) -> usize {
let (input_w, input_r) = tokio::sync::mpsc::unbounded_channel();
let (resize_w, resize_r) = tokio::sync::mpsc::unbounded_channel();
let entry = std::sync::Arc::new(std::sync::Mutex::new(Entry::new(
- cmdline.to_string(),
+ cmdline.clone(),
env.clone(),
self.size,
input_w,
resize_w,
)));
run_commands(
- cmdline.to_string(),
+ cmdline,
std::sync::Arc::clone(&entry),
- env.clone(),
+ env,
input_r,
resize_r,
event_w,
diff --git a/src/shell/mod.rs b/src/shell/mod.rs
index ab01161..a494752 100644
--- a/src/shell/mod.rs
+++ b/src/shell/mod.rs
@@ -417,7 +417,8 @@ impl Shell {
entry.should_fullscreen(),
)
});
- let idx = self.history.run(&input, &self.env, event_w);
+ let idx =
+ self.history.run(input, self.env.clone(), event_w);
self.set_focus(Focus::History(idx), fullscreen);
self.hide_readline = true;
self.env.set_idx(idx + 1);
@@ -469,7 +470,7 @@ impl Shell {
let input = self
.history
.with_entry(idx, |entry| entry.cmd().to_string());
- self.readline.set_input(&input);
+ self.readline.set_input(input);
self.set_focus(Focus::Readline, false);
}
}
@@ -532,7 +533,11 @@ impl Shell {
textmode::Key::Ctrl(b'm') => {
let input = self.readline.input();
if !input.is_empty() {
- let idx = self.history.run(input, &self.env, event_w);
+ let idx = self.history.run(
+ input.to_string(),
+ self.env.clone(),
+ event_w,
+ );
self.set_focus(
Focus::History(idx),
self.history.should_fullscreen(idx),
diff --git a/src/shell/readline.rs b/src/shell/readline.rs
index 49a3ab6..5de9901 100644
--- a/src/shell/readline.rs
+++ b/src/shell/readline.rs
@@ -102,9 +102,9 @@ impl Readline {
self.inc_pos(s.chars().count());
}
- pub fn set_input(&mut self, s: &str) {
- self.input_line = s.to_string();
+ pub fn set_input(&mut self, s: String) {
self.set_pos(s.chars().count());
+ self.input_line = s;
}
pub fn backspace(&mut self) {