Skip to content

Commit

Permalink
Add multiple selection in diff view (#231)
Browse files Browse the repository at this point in the history
* 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`
  • Loading branch information
cruessler authored Aug 19, 2020
1 parent c8ae3b8 commit bc23270
Show file tree
Hide file tree
Showing 12 changed files with 327 additions and 80 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ jobs:
profile: minimal
components: clippy

- name: Install dependencies for clipboard access
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get -qq install libxcb-shape0-dev libxcb-xfixes0-dev
- name: Build Debug
run: |
rustc --version
Expand Down Expand Up @@ -54,6 +59,10 @@ jobs:
profile: minimal
target: x86_64-unknown-linux-musl

- name: Install dependencies for clipboard access
run: |
sudo apt-get -qq install libxcb-shape0-dev libxcb-xfixes0-dev
- name: Setup MUSL
run: |
sudo apt-get -qq install musl-tools
Expand Down
86 changes: 86 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ serde = "1.0"
anyhow = "1.0.32"
unicode-width = "0.1"
textwrap = "0.12"
clipboard = "0.5"

[target.'cfg(not(windows))'.dependencies]
pprof = { version = "0.3", features = ["flamegraph"], optional = true }
Expand Down
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,8 @@ impl App {
self.stashmsg_popup.draw(f, size)?;
self.reset.draw(f, size)?;
self.help.draw(f, size)?;
self.msg.draw(f, size)?;
self.inspect_commit_popup.draw(f, size)?;
self.msg.draw(f, size)?;
self.external_editor_popup.draw(f, size)?;
self.tag_commit_popup.draw(f, size)?;

Expand Down
18 changes: 1 addition & 17 deletions src/components/changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
components::{CommandInfo, Component},
keys,
queue::{Action, InternalEvent, NeedsUpdate, Queue, ResetItem},
strings,
strings, try_or_popup,
ui::style::SharedTheme,
};
use anyhow::Result;
Expand All @@ -17,22 +17,6 @@ use std::path::Path;
use strings::commands;
use tui::{backend::Backend, layout::Rect, Frame};

/// macro to simplify running code that might return Err.
/// It will show a popup in that case
#[macro_export]
macro_rules! try_or_popup {
($self:ident, $msg:literal, $e:expr) => {
if let Err(err) = $e {
$self.queue.borrow_mut().push_back(
InternalEvent::ShowErrorMsg(format!(
"{}\n{}",
$msg, err
)),
);
}
};
}

///
pub struct ChangesComponent {
title: String,
Expand Down
Loading

0 comments on commit bc23270

Please sign in to comment.