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
|
||||
- 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))
|
||||
|
||||

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