Skip to content

Commit bc23270

Browse files
authored
Add multiple selection in diff view (#231)
* Add multiple selection in diff view * Copy selection to clipboard in diff view * Show error message if copy to clipboard fails - Draw `msg` after `inspect_commit_popup` to make sure the error message is visible - Move `try_or_popup!` to `utils`
1 parent c8ae3b8 commit bc23270

File tree

12 files changed

+327
-80
lines changed

12 files changed

+327
-80
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ jobs:
2727
profile: minimal
2828
components: clippy
2929

30+
- name: Install dependencies for clipboard access
31+
if: matrix.os == 'ubuntu-latest'
32+
run: |
33+
sudo apt-get -qq install libxcb-shape0-dev libxcb-xfixes0-dev
34+
3035
- name: Build Debug
3136
run: |
3237
rustc --version
@@ -54,6 +59,10 @@ jobs:
5459
profile: minimal
5560
target: x86_64-unknown-linux-musl
5661

62+
- name: Install dependencies for clipboard access
63+
run: |
64+
sudo apt-get -qq install libxcb-shape0-dev libxcb-xfixes0-dev
65+
5766
- name: Setup MUSL
5867
run: |
5968
sudo apt-get -qq install musl-tools

Cargo.lock

Lines changed: 86 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ serde = "1.0"
4040
anyhow = "1.0.32"
4141
unicode-width = "0.1"
4242
textwrap = "0.12"
43+
clipboard = "0.5"
4344

4445
[target.'cfg(not(windows))'.dependencies]
4546
pprof = { version = "0.3", features = ["flamegraph"], optional = true }

src/app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,8 @@ impl App {
515515
self.stashmsg_popup.draw(f, size)?;
516516
self.reset.draw(f, size)?;
517517
self.help.draw(f, size)?;
518-
self.msg.draw(f, size)?;
519518
self.inspect_commit_popup.draw(f, size)?;
519+
self.msg.draw(f, size)?;
520520
self.external_editor_popup.draw(f, size)?;
521521
self.tag_commit_popup.draw(f, size)?;
522522

src/components/changes.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{
77
components::{CommandInfo, Component},
88
keys,
99
queue::{Action, InternalEvent, NeedsUpdate, Queue, ResetItem},
10-
strings,
10+
strings, try_or_popup,
1111
ui::style::SharedTheme,
1212
};
1313
use anyhow::Result;
@@ -17,22 +17,6 @@ use std::path::Path;
1717
use strings::commands;
1818
use tui::{backend::Backend, layout::Rect, Frame};
1919

20-
/// macro to simplify running code that might return Err.
21-
/// It will show a popup in that case
22-
#[macro_export]
23-
macro_rules! try_or_popup {
24-
($self:ident, $msg:literal, $e:expr) => {
25-
if let Err(err) = $e {
26-
$self.queue.borrow_mut().push_back(
27-
InternalEvent::ShowErrorMsg(format!(
28-
"{}\n{}",
29-
$msg, err
30-
)),
31-
);
32-
}
33-
};
34-
}
35-
3620
///
3721
pub struct ChangesComponent {
3822
title: String,

0 commit comments

Comments
 (0)