summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2020-09-09 18:02:41 +0200
committerCanop <cano.petrole@gmail.com>2020-09-09 18:02:41 +0200
commit5edab5fd73ac38df12ff4ce7db21091f6bd8acbb (patch)
tree4d6fcdfae4f9b8a45a8529cff2e9df184b578a1a
parent752d44bb17b88da634818162113c9a8a0fb08d59 (diff)
ctrl-v now inserts the clipboard content in the input
when the "clipboard" feature is on. This behaviour may be mapped to another key, it's based on the new `:input_paste` verb
-rw-r--r--CHANGELOG.md7
-rwxr-xr-xcompile-all-targets.sh23
-rw-r--r--src/app/app.rs16
-rw-r--r--src/app/state.rs2
-rw-r--r--src/command/mod.rs4
-rw-r--r--src/command/panel_input.rs (renamed from src/command/event.rs)16
-rw-r--r--src/help/help_content.rs2
-rw-r--r--src/verb/builtin.rs5
-rw-r--r--src/verb/internal.rs1
9 files changed, 58 insertions, 18 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5d1603a..7de06df 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,9 @@
### next
-- ignore .gitignore files (including the global one) when not in a git repository - Fix #274
-- the "clipboard" optional feature adds the `:copy_path` verb which copies the selected path to the clipboard (I need return on compilation and usage from users before making this feature a little more standard)
+* ignore .gitignore files (including the global one) when not in a git repository - Fix #274
+* the "clipboard" optional feature adds:
+- the `:copy_path` verb which copies the selected path to the clipboard (mapped to alt-c)
+- the `:input_paste` verb which inserts the clipboard content in the input (mapped to ctrl-v)
+(I need user/dev feedback on compilation and usage before making this feature default)
<a name="v1.0.0"></a>
### v1.0.0 - 2020-09-01
diff --git a/compile-all-targets.sh b/compile-all-targets.sh
index 65a6c5a..9c8eaf2 100755
--- a/compile-all-targets.sh
+++ b/compile-all-targets.sh
@@ -1,21 +1,25 @@
# WARNING: This script is NOT meant for normal installation, it's dedicated
-# to the compilation of all supported targets. This is a long process and
-# it involves specialized toolchains.
+# to the compilation of all supported targets, from a linux machine.
+# This is a long process and it involves specialized toolchains.
# For usual compilation do
# cargo build --release
# or read all possible installation solutions on
# https://dystroy.org/broot/documentation/installation/
+H1="\n\e[30;104;1m\e[2K\n\e[A" # style first header
+H2="\n\e[30;104m\e[1K\n\e[A" # style second header
+EH="\e[00m\n\e[2K" # end header
+
version=$(sed 's/version = "\([0-9.]\{1,\}\(-[a-z]\+\)\?\)"/\1/;t;d' Cargo.toml | head -1)
-echo -e "\e[105m Compilation of all targets for broot $version \e[00m"
+echo -e "${H1}Compilation of all targets for broot $version${EH}"
# clean previous build
-echo "cleaning build"
rm -rf build
mkdir build
+echo " build cleaned"
# build the linux version
-echo -e "\e[30m\e[104mCompiling the linux version \e[00m"
+echo -e "${H2}Compiling the linux version${EH}"
cargo build --release
strip target/release/broot
mkdir build/x86_64-linux/
@@ -23,26 +27,27 @@ cp target/release/broot build/x86_64-linux/
# find and copy the completion scripts
# (they're built as part of the normal compilation so must come after the linux version)
-echo -e "\e[30m\e[104mcopying completion scripts\e[00m"
+echo -e "${H2}copying completion scripts${EH}"
mkdir build/completion
cp "$(broot -c ":gi;release;:focus;broot.bash;:parent;:pp" target)/"* build/completion
+echo " Done"
# build the windows version
# use cargo cross
-echo -e "\e[30m\e[104mCompiling the Windows version \e[00m"
+echo -e "${H2}Compiling the Windows version${EH}"
cross build --target x86_64-pc-windows-gnu --release
mkdir build/x86_64-pc-windows-gnu
cp target/x86_64-pc-windows-gnu/release/broot.exe build/x86_64-pc-windows-gnu/
# build the Raspberry version
# use cargo cross
-echo -e "\e[30m\e[104mCompiling the Raspberry version \e[00m"
+echo -e "${H2}Compiling the Raspberry version${EH}"
cross build --target armv7-unknown-linux-gnueabihf --release
mkdir build/armv7-unknown-linux-gnueabihf
cp target/armv7-unknown-linux-gnueabihf/release/broot build/armv7-unknown-linux-gnueabihf/
# build a musl version
-echo -e "\e[30m\e[104mCompiling the MUSL version \e[00m"
+echo -e "${H2}Compiling the MUSL version${EH}"
cross build --release --target x86_64-unknown-linux-musl
mkdir build/x86_64-unknown-linux-musl
cp target/x86_64-unknown-linux-musl/release/broot build/x86_64-unknown-linux-musl
diff --git a/src/app/app.rs b/src/app/app.rs
index 11f2e17..6edbe5b 100644
--- a/src/app/app.rs
+++ b/src/app/app.rs
@@ -29,13 +29,25 @@ use std::sync::{Arc, Mutex};
/// The GUI
pub struct App {
+ /// the panels of the application, at least one
panels: NonEmptyVec<Panel>,
+
+ /// index of the currently focused panel
active_panel_idx: usize,
+
+ /// whether the app is in the (uncancellable) process of quitting
quitting: bool,
- launch_at_end: Option<Launchable>, // what must be launched after end
+
+ /// what must be done after having closed the TUI
+ launch_at_end: Option<Launchable>,
+
+ /// a count of all panels created
created_panels_count: usize,
- preview: Option<PanelId>, // the panel dedicated to preview, if any
+ /// the panel dedicated to preview, if any
+ preview: Option<PanelId>,
+
+ /// the root of the active panel
#[cfg(feature="client-server")]
root: Arc<Mutex<PathBuf>>,
}
diff --git a/src/app/state.rs b/src/app/state.rs
index c230a9a..e1b30d7 100644
--- a/src/app/state.rs
+++ b/src/app/state.rs
@@ -1,7 +1,7 @@
use {
super::*,
crate::{
- command::{Command, TriggerType},
+ command::*,
display::{Screen, W},
errors::ProgramError,
flag::Flag,
diff --git a/src/command/mod.rs b/src/command/mod.rs
index 7655b92..70e89f5 100644
--- a/src/command/mod.rs
+++ b/src/command/mod.rs
@@ -1,6 +1,6 @@
mod command;
mod completion;
-mod event;
+mod panel_input;
mod parts;
mod sequence;
mod scroll;
@@ -9,7 +9,7 @@ mod trigger_type;
pub use {
command::Command,
completion::Completions,
- event::PanelInput,
+ panel_input::PanelInput,
parts::CommandParts,
sequence::Sequence,
scroll::ScrollCommand,
diff --git a/src/command/event.rs b/src/command/panel_input.rs
index f7b2a54..f8e3af0 100644
--- a/src/command/event.rs
+++ b/src/command/panel_input.rs
@@ -89,6 +89,22 @@ impl PanelInput {
Internal::input_go_word_right => self.input_field.move_word_right(),
Internal::input_go_to_start => self.input_field.move_to_start(),
Internal::input_go_to_end => self.input_field.move_to_end(),
+ #[cfg(feature="clipboard")]
+ Internal::input_paste => {
+ match terminal_clipboard::get_string() {
+ Ok(pasted) => {
+ for c in pasted.chars()
+ .filter(|c| c.is_alphanumeric() || c.is_ascii_punctuation())
+ {
+ self.input_field.put_char(c);
+ }
+ }
+ Err(e) => {
+ warn!("Error in reading clipboard: {:?}", e);
+ }
+ }
+ true
+ }
_ => false,
}
} else {
diff --git a/src/help/help_content.rs b/src/help/help_content.rs
index 9076ecb..da43fc0 100644
--- a/src/help/help_content.rs
+++ b/src/help/help_content.rs
@@ -83,7 +83,7 @@ pub fn build_text(con: &AppContext) -> Text<'_> {
sub.set("description", "");
sub.set("execution", &verb.description.content);
} else {
- sub.set("description", &verb.description.content);
+ sub.set_md("description", &verb.description.content);
sub.set("execution", "");
}
}
diff --git a/src/verb/builtin.rs b/src/verb/builtin.rs
index c43b896..90375ed 100644
--- a/src/verb/builtin.rs
+++ b/src/verb/builtin.rs
@@ -36,7 +36,7 @@ pub fn builtin_verbs() -> Vec<Verb> {
.with_shortcut("cp"),
#[cfg(feature="clipboard")]
Verb::internal(copy_path)
- .with_alt_key( 'c' ),
+ .with_alt_key('c'),
Verb::external(
"copy_to_panel",
"/bin/cp -r {file} {other-panel-directory}",
@@ -49,6 +49,9 @@ pub fn builtin_verbs() -> Vec<Verb> {
Verb::internal(focus)
.with_control_key('f'),
Verb::internal(help).with_key(F1).with_shortcut("?"),
+ #[cfg(feature="clipboard")]
+ Verb::internal(input_paste)
+ .with_control_key('v'),
Verb::internal(line_down).with_key(DOWN),
Verb::internal(line_up).with_key(UP),
Verb::external(
diff --git a/src/verb/internal.rs b/src/verb/internal.rs
index d19240d..952affd 100644
--- a/src/verb/internal.rs
+++ b/src/verb/internal.rs
@@ -69,6 +69,7 @@ Internals! {
input_go_to_start: "move the cursor to the start of input",
input_go_word_left: "move the cursor one word to the left",
input_go_word_right: "move the cursor one word to the right",
+ input_paste: "paste the clipboard content into the input",
line_down: "move one line down",
line_up: "move one line up",
open_stay: "open file or directory according to OS (stay in broot)",