mirror of
https://github.com/gitui-org/gitui
synced 2026-05-24 09:28:21 +00:00
cleanup clipboard and add to changelog (#325)
This commit is contained in:
parent
62573b9d7a
commit
0b97c545ed
2 changed files with 10 additions and 11 deletions
|
|
@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- do not highlight selection in diff view when not focused ([#270](https://github.com/extrawurst/gitui/issues/270))
|
- do not highlight selection in diff view when not focused ([#270](https://github.com/extrawurst/gitui/issues/270))
|
||||||
|
- copy to clipboard using `xclip`(linux), `pbcopy`(mac) or `clip`(win) [[@cruessler](https://github.com/cruessler)] ([#262](https://github.com/extrawurst/gitui/issues/262))
|
||||||
- compact treeview [[@WizardOhio24](https://github.com/WizardOhio24)] ([#192](https://github.com/extrawurst/gitui/issues/192))
|
- compact treeview [[@WizardOhio24](https://github.com/WizardOhio24)] ([#192](https://github.com/extrawurst/gitui/issues/192))
|
||||||
|
|
||||||

|

|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,11 @@ use anyhow::Result;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
|
|
||||||
fn execute_copy_command(
|
fn execute_copy_command(command: Command, text: &str) -> Result<()> {
|
||||||
command: &mut Command,
|
|
||||||
string: &str,
|
|
||||||
) -> Result<()> {
|
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
|
|
||||||
|
let mut command = command;
|
||||||
|
|
||||||
let mut process = command
|
let mut process = command
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stdout(Stdio::null())
|
.stdout(Stdio::null())
|
||||||
|
|
@ -18,7 +17,7 @@ fn execute_copy_command(
|
||||||
.stdin
|
.stdin
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.ok_or_else(|| anyhow!("`{:?}`", command))?
|
.ok_or_else(|| anyhow!("`{:?}`", command))?
|
||||||
.write_all(string.as_bytes())
|
.write_all(text.as_bytes())
|
||||||
.map_err(|e| anyhow!("`{:?}`: {}", command, e))?;
|
.map_err(|e| anyhow!("`{:?}`: {}", command, e))?;
|
||||||
|
|
||||||
process
|
process
|
||||||
|
|
@ -30,18 +29,17 @@ fn execute_copy_command(
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub fn copy_string(string: &str) -> Result<()> {
|
pub fn copy_string(string: &str) -> Result<()> {
|
||||||
execute_copy_command(
|
let mut cmd = Command::new("xclip");
|
||||||
Command::new("xclip").arg("-selection").arg("clipboard"),
|
cmd.arg("-selection").arg("clipboard");
|
||||||
string,
|
execute_copy_command(cmd, string)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
pub fn copy_string(string: &str) -> Result<()> {
|
pub fn copy_string(string: &str) -> Result<()> {
|
||||||
execute_copy_command(&mut Command::new("pbcopy"), string)
|
execute_copy_command(Command::new("pbcopy"), string)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pub fn copy_string(string: &str) -> Result<()> {
|
pub fn copy_string(string: &str) -> Result<()> {
|
||||||
execute_copy_command(&mut Command::new("clip"), string)
|
execute_copy_command(Command::new("clip"), string)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue