mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 08:58:21 +00:00
Copy file path (#1516)
* copy file path to click board * update change log * Add copy path info to command bar
This commit is contained in:
parent
0fca8befc8
commit
aefc18d819
5 changed files with 56 additions and 0 deletions
|
|
@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
* add no-verify option on commits to not run hooks [[@dam5h]](https://github.com/dam5h) ([#1374](https://github.com/extrawurst/gitui/issues/1374))
|
||||
* allow `fetch` on status tab [[@alensiljak]](https://github.com/alensiljak) ([#1471](https://github.com/extrawurst/gitui/issues/1471))
|
||||
* allow reset (soft,mixed,hard) from commit log ([#1500](https://github.com/extrawurst/gitui/issues/1500))
|
||||
* allow `copy` file path on revision files and status tree [[@yanganto]](https://github.com/yanganto) ([#1516](https://github.com/extrawurst/gitui/pull/1516))
|
||||
|
||||
### Fixes
|
||||
* commit msg history ordered the wrong way ([#1445](https://github.com/extrawurst/gitui/issues/1445))
|
||||
|
|
|
|||
0
flake.lock
Normal file
0
flake.lock
Normal file
|
|
@ -7,6 +7,7 @@ use crate::{
|
|||
keys::{key_match, SharedKeyConfig},
|
||||
queue::{InternalEvent, Queue, StackablePopupOpen},
|
||||
strings::{self, order, symbol},
|
||||
try_or_popup,
|
||||
ui::{self, common_nav, style::SharedTheme},
|
||||
AsyncAppNotification, AsyncNotification,
|
||||
};
|
||||
|
|
@ -447,6 +448,14 @@ impl Component for RevisionFilesComponent {
|
|||
)
|
||||
.order(order::RARE_ACTION),
|
||||
);
|
||||
out.push(
|
||||
CommandInfo::new(
|
||||
strings::commands::copy_path(&self.key_config),
|
||||
self.tree.selected_file().is_some(),
|
||||
true,
|
||||
)
|
||||
.order(order::RARE_ACTION),
|
||||
);
|
||||
tree_nav_cmds(&self.tree, &self.key_config, out);
|
||||
} else {
|
||||
self.current_file.commands(out, force_all);
|
||||
|
|
@ -515,6 +524,15 @@ impl Component for RevisionFilesComponent {
|
|||
);
|
||||
return Ok(EventState::Consumed);
|
||||
}
|
||||
} else if key_match(key, self.key_config.keys.copy) {
|
||||
if let Some(file) = self.selected_file_path() {
|
||||
try_or_popup!(
|
||||
self,
|
||||
strings::POPUP_FAIL_COPY,
|
||||
crate::clipboard::copy_string(&file)
|
||||
);
|
||||
}
|
||||
return Ok(EventState::Consumed);
|
||||
} else if !is_tree_focused {
|
||||
return self.current_file.event(event);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -302,6 +302,21 @@ impl StatusTreeComponent {
|
|||
selection_offset_visible,
|
||||
)
|
||||
}
|
||||
|
||||
// Copy the real path of selected file to clickboard
|
||||
fn copy_file_path(&self) {
|
||||
if let Some(item) = self.selection() {
|
||||
if crate::clipboard::copy_string(&item.info.full_path)
|
||||
.is_err()
|
||||
{
|
||||
if let Some(queue) = &self.queue {
|
||||
queue.push(InternalEvent::ShowErrorMsg(
|
||||
strings::POPUP_FAIL_COPY.to_string(),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Used for drawing the `FileTreeComponent`
|
||||
|
|
@ -430,6 +445,15 @@ impl Component for StatusTreeComponent {
|
|||
.order(order::RARE_ACTION),
|
||||
);
|
||||
|
||||
out.push(
|
||||
CommandInfo::new(
|
||||
strings::commands::copy_path(&self.key_config),
|
||||
self.selection_file().is_some(),
|
||||
self.focused || force_all,
|
||||
)
|
||||
.order(order::RARE_ACTION),
|
||||
);
|
||||
|
||||
CommandBlocking::PassingOn
|
||||
}
|
||||
|
||||
|
|
@ -481,6 +505,9 @@ impl Component for StatusTreeComponent {
|
|||
}
|
||||
}
|
||||
Ok(EventState::Consumed)
|
||||
} else if key_match(e, self.key_config.keys.copy) {
|
||||
self.copy_file_path();
|
||||
Ok(EventState::Consumed)
|
||||
} else if key_match(e, self.key_config.keys.move_down)
|
||||
{
|
||||
Ok(self
|
||||
|
|
|
|||
|
|
@ -558,6 +558,16 @@ pub mod commands {
|
|||
CMD_GROUP_LOG,
|
||||
)
|
||||
}
|
||||
pub fn copy_path(key_config: &SharedKeyConfig) -> CommandText {
|
||||
CommandText::new(
|
||||
format!(
|
||||
"Copy Path [{}]",
|
||||
key_config.get_hint(key_config.keys.copy),
|
||||
),
|
||||
"copy selected file path to clipboard",
|
||||
CMD_GROUP_LOG,
|
||||
)
|
||||
}
|
||||
pub fn push_tags(key_config: &SharedKeyConfig) -> CommandText {
|
||||
CommandText::new(
|
||||
format!(
|
||||
|
|
|
|||
Loading…
Reference in a new issue