mirror of
https://github.com/TECHNOFAB11/tmux-copyrat.git
synced 2025-12-12 08:00:08 +01:00
refactor: run takes &[&str]
This commit is contained in:
parent
4ec240c2b1
commit
92509fe534
3 changed files with 5 additions and 5 deletions
|
|
@ -12,10 +12,11 @@ fn main() {
|
|||
|
||||
let mut buffer = String::new();
|
||||
handle.read_to_string(&mut buffer).unwrap();
|
||||
let lines = buffer.split('\n').collect::<Vec<_>>();
|
||||
|
||||
// Execute copyrat over the buffer (will take control over stdout).
|
||||
// This returns the selected matche.
|
||||
let selection: Option<Selection> = run(buffer, &opt);
|
||||
let selection: Option<Selection> = run(&lines, &opt);
|
||||
|
||||
// Early exit, signaling no selections were found.
|
||||
if selection.is_none() {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ fn main() -> Result<(), error::ParseError> {
|
|||
.expect("Exactly one tmux pane should be active in the current window.");
|
||||
|
||||
let buffer = tmux::capture_pane(&active_pane, &config.capture_region)?;
|
||||
let lines = buffer.split('\n').collect::<Vec<_>>();
|
||||
|
||||
// We have to dance a little with Panes, because this process' i/o streams
|
||||
// are connected to the pane in the window newly created for us, instead
|
||||
|
|
@ -24,7 +25,7 @@ fn main() -> Result<(), error::ParseError> {
|
|||
let temp_pane_spec = format!("{}.0", config.window_name);
|
||||
tmux::swap_pane_with(&temp_pane_spec)?;
|
||||
|
||||
let selection = copyrat::run(buffer, &config.basic_config);
|
||||
let selection = copyrat::run(&lines, &config.basic_config);
|
||||
|
||||
tmux::swap_pane_with(&temp_pane_spec)?;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,7 @@ pub mod ui;
|
|||
/// # Note
|
||||
///
|
||||
/// Maybe the decision to take ownership of the buffer is a bit bold.
|
||||
pub fn run(buffer: String, opt: &config::basic::Config) -> Option<ui::Selection> {
|
||||
let lines = buffer.split('\n').collect::<Vec<_>>();
|
||||
|
||||
pub fn run(lines: &[&str], opt: &config::basic::Config) -> Option<ui::Selection> {
|
||||
let model = textbuf::Model::new(
|
||||
&lines,
|
||||
&opt.alphabet,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue