Skip to content

Commit 8731df9

Browse files
committed
WIP: add cut action for git-revise
1 parent a2536be commit 8731df9

File tree

14 files changed

+50
-8
lines changed

14 files changed

+50
-8
lines changed

readme/customization.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ Most keys can be changed to any printable character or supported special charact
113113
| `inputActionPick` | p | String | Key for setting action to pick |
114114
| `inputActionReword` | r | String | Key for setting action to reword |
115115
| `inputActionSquash` | s | String | Key for setting action to squash |
116+
| `inputActionCut` | x | String | Key for setting action to cut (git-revise) |
116117
| `inputActionIndex` | i | String | Key for setting action to index (git-revise) |
117118
| `inputConfirmNo` | n | String | Key for rejecting a confirmation |
118119
| `inputConfirmYes` | y | String | Key for confirming a confirmation |

src/config/key_bindings.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ pub(crate) struct KeyBindings {
2020
pub(crate) abort: Vec<String>,
2121
/// Key bindings for the break action.
2222
pub(crate) action_break: Vec<String>,
23+
/// Key bindings for the cut action.
24+
pub(crate) action_cut: Vec<String>,
2325
/// Key bindings for the drop action.
2426
pub(crate) action_drop: Vec<String>,
2527
/// Key bindings for the edit action.
@@ -128,6 +130,7 @@ impl KeyBindings {
128130
Ok(Self {
129131
abort: get_input(git_config, "interactive-rebase-tool.inputAbort", "q")?,
130132
action_break: get_input(git_config, "interactive-rebase-tool.inputActionBreak", "b")?,
133+
action_cut: get_input(git_config, "interactive-rebase-tool.inputActionCut", "x")?,
131134
action_drop: get_input(git_config, "interactive-rebase-tool.inputActionDrop", "d")?,
132135
action_edit: get_input(git_config, "interactive-rebase-tool.inputActionEdit", "e")?,
133136
action_fixup: get_input(git_config, "interactive-rebase-tool.inputActionFixup", "f")?,

src/config/theme.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ pub(crate) struct Theme {
3131
pub(crate) character_vertical_spacing: String,
3232
/// The color for the break action.
3333
pub(crate) color_action_break: Color,
34+
/// The color for the cut action.
35+
pub(crate) color_action_cut: Color,
3436
/// The color for the drop action.
3537
pub(crate) color_action_drop: Color,
3638
/// The color for the edit action.
@@ -85,6 +87,7 @@ impl Theme {
8587
"~",
8688
)?,
8789
color_action_break: get_color(git_config, "interactive-rebase-tool.breakColor", Color::LightWhite)?,
90+
color_action_cut: get_color(git_config, "interactive-rebase-tool.cutColor", Color::DarkRed)?,
8891
color_action_drop: get_color(git_config, "interactive-rebase-tool.dropColor", Color::LightRed)?,
8992
color_action_edit: get_color(git_config, "interactive-rebase-tool.editColor", Color::LightBlue)?,
9093
color_action_exec: get_color(git_config, "interactive-rebase-tool.execColor", Color::LightWhite)?,

src/display.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use crate::config::Theme;
3434
#[derive(Debug)]
3535
pub(crate) struct Display<T: Tui> {
3636
action_break: (Colors, Colors),
37+
action_cut: (Colors, Colors),
3738
action_drop: (Colors, Colors),
3839
action_edit: (Colors, Colors),
3940
action_exec: (Colors, Colors),
@@ -78,6 +79,12 @@ impl<T: Tui> Display<T> {
7879
theme.color_background,
7980
theme.color_selected_background,
8081
);
82+
let action_cut = register_selectable_color_pairs(
83+
color_mode,
84+
theme.color_action_cut,
85+
theme.color_background,
86+
theme.color_selected_background,
87+
);
8188
let action_drop = register_selectable_color_pairs(
8289
color_mode,
8390
theme.color_action_drop,
@@ -183,6 +190,7 @@ impl<T: Tui> Display<T> {
183190

184191
Self {
185192
action_break,
193+
action_cut,
186194
action_drop,
187195
action_edit,
188196
action_exec,
@@ -244,6 +252,7 @@ impl<T: Tui> Display<T> {
244252
if selected {
245253
match color {
246254
DisplayColor::ActionBreak => self.action_break.1,
255+
DisplayColor::ActionCut => self.action_cut.1,
247256
DisplayColor::ActionDrop => self.action_drop.1,
248257
DisplayColor::ActionEdit => self.action_edit.1,
249258
DisplayColor::ActionExec => self.action_exec.1,
@@ -268,6 +277,7 @@ impl<T: Tui> Display<T> {
268277
else {
269278
match color {
270279
DisplayColor::ActionBreak => self.action_break.0,
280+
DisplayColor::ActionCut => self.action_cut.0,
271281
DisplayColor::ActionDrop => self.action_drop.0,
272282
DisplayColor::ActionEdit => self.action_edit.0,
273283
DisplayColor::ActionExec => self.action_exec.0,

src/display/display_color.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
pub(crate) enum DisplayColor {
55
/// The color for the break action.
66
ActionBreak,
7+
/// The color for the cut action.
8+
ActionCut,
79
/// The color for the drop action.
810
ActionDrop,
911
/// The color for the edit action.

src/input/key_bindings.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ pub(crate) struct KeyBindings {
4040
pub(crate) abort: Vec<Event>,
4141
/// Key bindings for the break action.
4242
pub(crate) action_break: Vec<Event>,
43+
/// Key bindings for the cut action.
44+
pub(crate) action_cut: Vec<Event>,
4345
/// Key bindings for the drop action.
4446
pub(crate) action_drop: Vec<Event>,
4547
/// Key bindings for the edit action.
@@ -123,6 +125,7 @@ impl KeyBindings {
123125
search_previous: map_keybindings(&key_bindings.search_previous),
124126
abort: map_keybindings(&key_bindings.abort),
125127
action_break: map_keybindings(&key_bindings.action_break),
128+
action_cut: map_keybindings(&key_bindings.action_cut),
126129
action_drop: map_keybindings(&key_bindings.action_drop),
127130
action_edit: map_keybindings(&key_bindings.action_edit),
128131
action_fixup: map_keybindings(&key_bindings.action_fixup),

src/input/standard_event.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ pub(crate) enum StandardEvent {
4949
ForceRebase,
5050
/// The break action meta event.
5151
ActionBreak,
52+
/// The cut (git-revise) action meta event.
53+
ActionCut,
5254
/// The drop action meta event.
5355
ActionDrop,
5456
/// The edit action meta event.

src/modules/list.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ impl List {
554554
match event {
555555
e if key_bindings.abort.contains(&e) => Event::from(StandardEvent::Abort),
556556
e if key_bindings.action_break.contains(&e) => Event::from(StandardEvent::ActionBreak),
557+
e if key_bindings.action_cut.contains(&e) => Event::from(StandardEvent::ActionCut),
557558
e if key_bindings.action_drop.contains(&e) => Event::from(StandardEvent::ActionDrop),
558559
e if key_bindings.action_edit.contains(&e) => Event::from(StandardEvent::ActionEdit),
559560
e if key_bindings.action_fixup.contains(&e) => Event::from(StandardEvent::ActionFixup),
@@ -643,6 +644,7 @@ impl List {
643644
Event::Standard(standard_event) => {
644645
match standard_event {
645646
StandardEvent::Abort => self.abort(&mut results),
647+
StandardEvent::ActionCut => self.set_selected_line_action(Action::Cut),
646648
StandardEvent::ActionDrop => self.set_selected_line_action(Action::Drop),
647649
StandardEvent::ActionEdit => self.set_selected_line_action(Action::Edit),
648650
StandardEvent::ActionFixup => self.set_selected_line_action(Action::Fixup),

src/modules/list/search.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ impl Searchable for Search {
5959

6060
let has_hash_match = match action {
6161
Action::Break | Action::Noop | Action::Label | Action::Reset | Action::Merge | Action::Exec => false,
62-
Action::Drop
62+
Action::Cut
63+
| Action::Drop
6364
| Action::Edit
6465
| Action::Fixup
6566
| Action::Index
@@ -70,7 +71,8 @@ impl Searchable for Search {
7071
};
7172
let has_content_match = match action {
7273
Action::Break | Action::Noop => false,
73-
Action::Drop
74+
Action::Cut
75+
| Action::Drop
7476
| Action::Edit
7577
| Action::Fixup
7678
| Action::Index

src/modules/list/tests/help.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ fn normal_mode_help() {
4040
" s |Set selected commits to be squashed",
4141
" f |Set selected commits to be fixed-up",
4242
" d |Set selected commits to be dropped",
43+
" x |Set selected commits to be cut / split (git-revise)",
4344
" i |Set selected commits to be staged in the index (git-revise)",
4445
" E |Edit an exec, label, reset or merge action's content",
4546
" I |Insert a new line",
@@ -106,6 +107,7 @@ fn visual_mode_help() {
106107
" s |Set selected commits to be squashed",
107108
" f |Set selected commits to be fixed-up",
108109
" d |Set selected commits to be dropped",
110+
" x |Set selected commits to be cut / split (git-revise)",
109111
" i |Set selected commits to be staged in the index (git-revise)",
110112
" Delete |Completely remove the selected lines",
111113
" Controlz|Undo the last change",

0 commit comments

Comments
 (0)