Rename selected -> selection

pull/3/head
Arijit Basu 3 years ago
parent b70682ecb5
commit 8a6da63936
No known key found for this signature in database
GPG Key ID: 7D7BF809E7378863

2
Cargo.lock generated

@ -1117,7 +1117,7 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "xplr"
version = "0.2.5"
version = "0.2.6"
dependencies = [
"criterion",
"crossterm",

@ -1,6 +1,6 @@
[package]
name = "xplr"
version = "0.2.5" # Update app.rs
version = "0.2.6" # Update app.rs
authors = ["Arijit Basu <sayanarijit@gmail.com>"]
edition = "2018"
description = "An experimental, minimal, configurable TUI file explorer, stealing ideas from nnn and fzf."

@ -11,7 +11,7 @@ use std::collections::VecDeque;
use std::fs;
use std::path::PathBuf;
pub const VERSION: &str = "v0.2.5"; // Update Cargo.toml
pub const VERSION: &str = "v0.2.6"; // Update Cargo.toml
pub const TEMPLATE_TABLE_ROW: &str = "TEMPLATE_TABLE_ROW";
@ -21,7 +21,7 @@ pub const UNSUPPORTED_STR: &str = "???";
pub struct PipesConfig {
pub msg_in: String,
pub focus_out: String,
pub selected_out: String,
pub selection_out: String,
pub mode_out: String,
}
@ -35,19 +35,19 @@ impl PipesConfig {
let focus_out = pipesdir.join("focus_out").to_string_lossy().to_string();
let selected_out = pipesdir.join("selected_out").to_string_lossy().to_string();
let selection_out = pipesdir.join("selection_out").to_string_lossy().to_string();
let mode_out = pipesdir.join("mode_out").to_string_lossy().to_string();
fs::write(&msg_in, "").unwrap();
fs::write(&focus_out, "").unwrap();
fs::write(&selected_out, "").unwrap();
fs::write(&selection_out, "").unwrap();
fs::write(&mode_out, "").unwrap();
Self {
msg_in,
focus_out,
selected_out,
selection_out,
mode_out,
}
}
@ -248,7 +248,7 @@ pub struct App {
pwd: String,
directory_buffers: HashMap<String, DirectoryBuffer>,
tasks: BinaryHeap<Task>,
selected: Vec<Node>,
selection: Vec<Node>,
msg_out: VecDeque<MsgOut>,
mode: Mode,
input_buffer: Option<String>,
@ -284,7 +284,7 @@ impl App {
pwd,
directory_buffers: Default::default(),
tasks: Default::default(),
selected: Default::default(),
selection: Default::default(),
msg_out: Default::default(),
mode,
input_buffer: Default::default(),
@ -582,16 +582,16 @@ impl App {
self.clone()
.focused_node()
.map(|n| {
if self.selected().contains(n) {
self.selected = self
if self.selection().contains(n) {
self.selection = self
.clone()
.selected
.selection
.into_iter()
.filter(|s| s != n)
.collect();
Ok(self.clone())
} else {
self.selected.push(n.to_owned());
self.selection.push(n.to_owned());
Ok(self.clone())
}
})
@ -632,9 +632,9 @@ impl App {
&self.config
}
/// Get a reference to the app's selected.
pub fn selected(&self) -> &Vec<Node> {
&self.selected
/// Get a reference to the app's selection.
pub fn selection(&self) -> &Vec<Node> {
&self.selection
}
pub fn pop_msg_out(&mut self) -> Option<MsgOut> {

@ -138,12 +138,12 @@ fn main() -> Result<(), Error> {
}
app::MsgOut::PrintResultAndQuit => {
let out = if app.selected().is_empty() {
let out = if app.selection().is_empty() {
app.focused_node()
.map(|n| n.absolute_path.clone())
.unwrap_or_default()
} else {
app.selected()
app.selection()
.into_iter()
.map(|n| n.absolute_path.clone())
.collect::<Vec<String>>()
@ -184,14 +184,14 @@ fn main() -> Result<(), Error> {
fs::write(&app.pipes().focus_out, focused).unwrap();
let selected = app
.selected()
let selection = app
.selection()
.iter()
.map(|n| n.absolute_path.clone())
.collect::<Vec<String>>()
.join("\n");
fs::write(&app.pipes().selected_out, selected).unwrap();
fs::write(&app.pipes().selection_out, selection).unwrap();
fs::write(&app.pipes().mode_out, &app.mode().name).unwrap();
}
@ -217,8 +217,8 @@ fn main() -> Result<(), Error> {
.unwrap_or_default()
.to_string();
let selected = app
.selected()
let selection = app
.selection()
.iter()
.map(|n| n.absolute_path.clone())
.collect::<Vec<String>>()
@ -237,7 +237,7 @@ fn main() -> Result<(), Error> {
let pipe_msg_in = app.pipes().msg_in.clone();
let pipe_focus_out = app.pipes().focus_out.clone();
let pipe_selected_out = app.pipes().selected_out.clone();
let pipe_selection_out = app.pipes().selection_out.clone();
let app_yaml = serde_yaml::to_string(&app).unwrap_or_default();
@ -247,10 +247,10 @@ fn main() -> Result<(), Error> {
.env("XPLR_INPUT_BUFFER", input_buffer)
.env("XPLR_FOCUS_PATH", focus_path)
.env("XPLR_FOCUS_INDEX", focus_index)
.env("XPLR_SELECTED", selected)
.env("XPLR_SELECTION", selection)
.env("XPLR_RUNTIME_PATH", app.runtime_path())
.env("XPLR_PIPE_MSG_IN", pipe_msg_in)
.env("XPLR_PIPE_SELECTED_OUT", pipe_selected_out)
.env("XPLR_PIPE_SELECTION_OUT", pipe_selection_out)
.env("XPLR_PIPE_FOCUS_OUT", pipe_focus_out)
.env("XPLR_APP_YAML", app_yaml)
.env("XPLR_DIRECTORY_NODES", directory_nodes)

@ -100,7 +100,7 @@ fn draw_table<B: Backend>(f: &mut Frame<B>, rect: Rect, app: &app::App, hb: &Han
let is_focused = dir.focus == index;
// TODO : Optimize
let is_selected = app.selected().contains(&node);
let is_selected = app.selection().contains(&node);
let ui = if is_focused {
&config.general.focused_ui
@ -250,9 +250,9 @@ fn draw_table<B: Backend>(f: &mut Frame<B>, rect: Rect, app: &app::App, hb: &Han
f.render_stateful_widget(table, rect, &mut table_state);
}
fn draw_selected<B: Backend>(f: &mut Frame<B>, rect: Rect, app: &app::App, _: &Handlebars) {
fn draw_selection<B: Backend>(f: &mut Frame<B>, rect: Rect, app: &app::App, _: &Handlebars) {
let selected: Vec<ListItem> = app
.selected()
.selection()
.iter()
.map(|n| n.absolute_path.clone())
.map(ListItem::new)
@ -384,6 +384,6 @@ pub fn draw<B: Backend>(f: &mut Frame<B>, app: &app::App, hb: &Handlebars) {
draw_table(f, left_chunks[0], app, hb);
draw_input_buffer(f, left_chunks[1], app, hb);
draw_selected(f, right_chunks[0], app, hb);
draw_selection(f, right_chunks[0], app, hb);
draw_help_menu(f, right_chunks[1], app, hb);
}

Loading…
Cancel
Save