Skip to content

Commit

Permalink
Add border select for popup, bump version to 0.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Ja-sonYun committed Mar 15, 2023
1 parent 8a424e1 commit 9fc7d13
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tmux-menu"
version = "0.1.3"
version = "0.1.4"
edition = "2021"
author = ["Ja-sonYun <[email protected]>"]

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# tmux-easy-menu v0.1.3
# tmux-easy-menu v0.1.4

### Easy configurable tmux display-menu

Expand Down Expand Up @@ -43,6 +43,7 @@ To see more actual config files, checkout `./examples` folder.
# command: "command %%KEY%% --cwd %%PWD" # Or run command, %%PWD will replaced with cwd
# background: false
# close_after_command: true
# border: none # Select popup border type, optional
# inputs:
# - KEY # This input will be replaced with '%%KEY%%' on command
# position:
Expand Down
1 change: 1 addition & 0 deletions examples/menu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# command: "command %%KEY%%" # Or run command
# background: false
# close_after_command: true
# border: none # Select popup border type, optional
# inputs:
# - KEY # This input will be replaced with '%%KEY%%' on command
# position:
Expand Down
7 changes: 5 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ fn cli() -> Command {
.arg(arg!(--y <Y> "Y position"))
.arg(arg!(--w <W> "Width"))
.arg(arg!(--h <H> "Height"))
.arg(arg!(--border <BORDER> "Border"))
.arg(arg!(--key <KEY> "Key to show").num_args(..))
.arg(arg!(-E --exit ... "Exit after command"))
.arg(
Expand Down Expand Up @@ -105,7 +106,9 @@ fn main() -> Result<()> {
let (tx, rx) = channel::<()>();
let reader = thread::spawn(move || pipe::read(rx).expect("Failed to read pipe"));

tmux.display_popup(cmd_to_run_input_of_this, &Position::wh(50, 3), true)
let border = sub_matches.get_one::<String>("border").unwrap().clone();

tmux.display_popup(cmd_to_run_input_of_this, &Position::wh(50, 3), &border, true)
.expect("Failed to run command");

// Send the signal to stop reading
Expand Down Expand Up @@ -140,7 +143,7 @@ fn main() -> Result<()> {

pipe::remove()?;

tmux.display_popup(cmd, &Position { x, y, w, h }, e)
tmux.display_popup(cmd, &Position { x, y, w, h }, &border, e)
.expect("Failed to display popup");
}
Some(("input", sub_matches)) => {
Expand Down
11 changes: 11 additions & 0 deletions src/show/construct_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ pub enum MenuType {

#[serde(default = "Position::new_xywh")]
position: Position,

#[serde(default = "default_none")]
border: Option<String>,
},
NoDim {
name: String,
Expand Down Expand Up @@ -96,6 +99,7 @@ impl MenuType {
close_after_command,
background,
position,
border,
inputs,
..
} => {
Expand Down Expand Up @@ -133,6 +137,13 @@ impl MenuType {

wrapped_command.extend(position.as_this_arguments());

wrapped_command.push("--border".to_string());
if let Some(border) = border {
wrapped_command.push(border.to_string());
} else {
wrapped_command.push("simple".to_string());
}

if *close_after_command {
wrapped_command.push("-E".to_string());
}
Expand Down
4 changes: 2 additions & 2 deletions src/tmux/subcommand/display_popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ impl Tmux {
vec!["-b".to_string(), border.to_string()]
}

pub fn display_popup(&self, command: String, position: &Position, exit: bool) -> Result<Child> {
pub fn display_popup(&self, command: String, position: &Position, border: &String, exit: bool) -> Result<Child> {
let mut arguments = vec![DISPLAY_POPUP.to_string()];

arguments.append(&mut Self::construct_border_arguments("double"));
arguments.append(&mut Self::construct_border_arguments(border));
arguments.append(&mut Self::construct_position_arguments(position));
if exit {
arguments.push("-E".to_string());
Expand Down

0 comments on commit 9fc7d13

Please sign in to comment.