Skip to content

Commit a2536be

Browse files
committed
WIP: add index action for git-revise
1 parent 7149726 commit a2536be

File tree

14 files changed

+58
-6
lines changed

14 files changed

+58
-6
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+
| `inputActionIndex` | i | String | Key for setting action to index (git-revise) |
116117
| `inputConfirmNo` | n | String | Key for rejecting a confirmation |
117118
| `inputConfirmYes` | y | String | Key for confirming a confirmation |
118119
| `inputEdit` | E | String | Key for entering edit mode |

src/config/key_bindings.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ pub(crate) struct KeyBindings {
2626
pub(crate) action_edit: Vec<String>,
2727
/// Key bindings for the fixup action.
2828
pub(crate) action_fixup: Vec<String>,
29+
/// Key bindings for the index action.
30+
pub(crate) action_index: Vec<String>,
2931
/// Key bindings for the pick action.
3032
pub(crate) action_pick: Vec<String>,
3133
/// Key bindings for the reword action.
@@ -129,6 +131,7 @@ impl KeyBindings {
129131
action_drop: get_input(git_config, "interactive-rebase-tool.inputActionDrop", "d")?,
130132
action_edit: get_input(git_config, "interactive-rebase-tool.inputActionEdit", "e")?,
131133
action_fixup: get_input(git_config, "interactive-rebase-tool.inputActionFixup", "f")?,
134+
action_index: get_input(git_config, "interactive-rebase-tool.inputActionIndex", "i")?,
132135
action_pick: get_input(git_config, "interactive-rebase-tool.inputActionPick", "p")?,
133136
action_reword: get_input(git_config, "interactive-rebase-tool.inputActionReword", "r")?,
134137
action_squash: get_input(git_config, "interactive-rebase-tool.inputActionSquash", "s")?,
@@ -243,6 +246,7 @@ mod tests {
243246
config_test!(action_drop, "inputActionDrop", "d");
244247
config_test!(action_edit, "inputActionEdit", "e");
245248
config_test!(action_fixup, "inputActionFixup", "f");
249+
config_test!(action_index, "inputActionIndex", "i");
246250
config_test!(action_pick, "inputActionPick", "p");
247251
config_test!(action_reword, "inputActionReword", "r");
248252
config_test!(action_squash, "inputActionSquash", "s");

src/config/theme.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ pub(crate) struct Theme {
3939
pub(crate) color_action_exec: Color,
4040
/// The color for the fixup action.
4141
pub(crate) color_action_fixup: Color,
42+
/// The color for the fixup action.
43+
pub(crate) color_action_index: Color,
4244
/// The color for the pick action.
4345
pub(crate) color_action_pick: Color,
4446
/// The color for the reword action.
@@ -87,6 +89,7 @@ impl Theme {
8789
color_action_edit: get_color(git_config, "interactive-rebase-tool.editColor", Color::LightBlue)?,
8890
color_action_exec: get_color(git_config, "interactive-rebase-tool.execColor", Color::LightWhite)?,
8991
color_action_fixup: get_color(git_config, "interactive-rebase-tool.fixupColor", Color::LightMagenta)?,
92+
color_action_index: get_color(git_config, "interactive-rebase-tool.indexColor", Color::DarkGreen)?,
9093
color_action_pick: get_color(git_config, "interactive-rebase-tool.pickColor", Color::LightGreen)?,
9194
color_action_reword: get_color(git_config, "interactive-rebase-tool.rewordColor", Color::LightYellow)?,
9295
color_action_squash: get_color(git_config, "interactive-rebase-tool.squashColor", Color::LightCyan)?,
@@ -204,6 +207,7 @@ mod tests {
204207
config_test!(color_action_edit, "editColor", Color::LightBlue);
205208
config_test!(color_action_exec, "execColor", Color::LightWhite);
206209
config_test!(color_action_fixup, "fixupColor", Color::LightMagenta);
210+
config_test!(color_action_index, "indexColor", Color::DarkGreen);
207211
config_test!(color_action_pick, "pickColor", Color::LightGreen);
208212
config_test!(color_action_reword, "rewordColor", Color::LightYellow);
209213
config_test!(color_action_squash, "squashColor", Color::LightCyan);

src/display.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub(crate) struct Display<T: Tui> {
3838
action_edit: (Colors, Colors),
3939
action_exec: (Colors, Colors),
4040
action_fixup: (Colors, Colors),
41+
action_index: (Colors, Colors),
4142
action_label: (Colors, Colors),
4243
action_merge: (Colors, Colors),
4344
action_pick: (Colors, Colors),
@@ -101,6 +102,12 @@ impl<T: Tui> Display<T> {
101102
theme.color_background,
102103
theme.color_selected_background,
103104
);
105+
let action_index = register_selectable_color_pairs(
106+
color_mode,
107+
theme.color_action_index,
108+
theme.color_background,
109+
theme.color_selected_background,
110+
);
104111
let action_pick = register_selectable_color_pairs(
105112
color_mode,
106113
theme.color_action_pick,
@@ -180,6 +187,7 @@ impl<T: Tui> Display<T> {
180187
action_edit,
181188
action_exec,
182189
action_fixup,
190+
action_index,
183191
action_label,
184192
action_merge,
185193
action_pick,
@@ -240,6 +248,7 @@ impl<T: Tui> Display<T> {
240248
DisplayColor::ActionEdit => self.action_edit.1,
241249
DisplayColor::ActionExec => self.action_exec.1,
242250
DisplayColor::ActionFixup => self.action_fixup.1,
251+
DisplayColor::ActionIndex => self.action_index.1,
243252
DisplayColor::ActionPick => self.action_pick.1,
244253
DisplayColor::ActionReword => self.action_reword.1,
245254
DisplayColor::ActionSquash => self.action_squash.1,
@@ -263,6 +272,7 @@ impl<T: Tui> Display<T> {
263272
DisplayColor::ActionEdit => self.action_edit.0,
264273
DisplayColor::ActionExec => self.action_exec.0,
265274
DisplayColor::ActionFixup => self.action_fixup.0,
275+
DisplayColor::ActionIndex => self.action_index.0,
266276
DisplayColor::ActionPick => self.action_pick.0,
267277
DisplayColor::ActionReword => self.action_reword.0,
268278
DisplayColor::ActionSquash => self.action_squash.0,
@@ -427,6 +437,13 @@ mod tests {
427437
CrosstermColor::Magenta,
428438
CrosstermColor::AnsiValue(237)
429439
)]
440+
#[case::action_index(DisplayColor::ActionIndex, false, CrosstermColor::DarkGreen, CrosstermColor::Reset)]
441+
#[case::action_index_selected(
442+
DisplayColor::ActionIndex,
443+
true,
444+
CrosstermColor::DarkGreen,
445+
CrosstermColor::AnsiValue(237)
446+
)]
430447
#[case::action_pick(DisplayColor::ActionPick, false, CrosstermColor::Green, CrosstermColor::Reset)]
431448
#[case::action_pick_selected(
432449
DisplayColor::ActionPick,

src/display/display_color.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ pub(crate) enum DisplayColor {
1212
ActionExec,
1313
/// The color for the fixup action.
1414
ActionFixup,
15+
/// The color for the index action.
16+
ActionIndex,
1517
/// The color for the pick action.
1618
ActionPick,
1719
/// The color for the reword action.

src/input/key_bindings.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ pub(crate) struct KeyBindings {
4646
pub(crate) action_edit: Vec<Event>,
4747
/// Key bindings for the fixup action.
4848
pub(crate) action_fixup: Vec<Event>,
49+
/// Key bindings for the index action.
50+
pub(crate) action_index: Vec<Event>,
4951
/// Key bindings for the pick action.
5052
pub(crate) action_pick: Vec<Event>,
5153
/// Key bindings for the reword action.
@@ -124,6 +126,7 @@ impl KeyBindings {
124126
action_drop: map_keybindings(&key_bindings.action_drop),
125127
action_edit: map_keybindings(&key_bindings.action_edit),
126128
action_fixup: map_keybindings(&key_bindings.action_fixup),
129+
action_index: map_keybindings(&key_bindings.action_index),
127130
action_pick: map_keybindings(&key_bindings.action_pick),
128131
action_reword: map_keybindings(&key_bindings.action_reword),
129132
action_squash: map_keybindings(&key_bindings.action_squash),

src/input/standard_event.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ pub(crate) enum StandardEvent {
5555
ActionEdit,
5656
/// The fixup action meta event.
5757
ActionFixup,
58+
/// The index (git-revise) action meta event.
59+
ActionIndex,
5860
/// The pick action meta event.
5961
ActionPick,
6062
/// The reword action meta event.

src/modules/list.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ impl List {
557557
e if key_bindings.action_drop.contains(&e) => Event::from(StandardEvent::ActionDrop),
558558
e if key_bindings.action_edit.contains(&e) => Event::from(StandardEvent::ActionEdit),
559559
e if key_bindings.action_fixup.contains(&e) => Event::from(StandardEvent::ActionFixup),
560+
e if key_bindings.action_index.contains(&e) => Event::from(StandardEvent::ActionIndex),
560561
e if key_bindings.action_pick.contains(&e) => Event::from(StandardEvent::ActionPick),
561562
e if key_bindings.action_reword.contains(&e) => Event::from(StandardEvent::ActionReword),
562563
e if key_bindings.action_squash.contains(&e) => Event::from(StandardEvent::ActionSquash),
@@ -645,6 +646,7 @@ impl List {
645646
StandardEvent::ActionDrop => self.set_selected_line_action(Action::Drop),
646647
StandardEvent::ActionEdit => self.set_selected_line_action(Action::Edit),
647648
StandardEvent::ActionFixup => self.set_selected_line_action(Action::Fixup),
649+
StandardEvent::ActionIndex => self.set_selected_line_action(Action::Index),
648650
StandardEvent::ActionPick => self.set_selected_line_action(Action::Pick),
649651
StandardEvent::ActionReword => self.set_selected_line_action(Action::Reword),
650652
StandardEvent::ActionSquash => self.set_selected_line_action(Action::Squash),

src/modules/list/search.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ impl Searchable for Search {
6262
Action::Drop
6363
| Action::Edit
6464
| Action::Fixup
65+
| Action::Index
6566
| Action::Pick
6667
| Action::Reword
6768
| Action::Squash
@@ -72,6 +73,7 @@ impl Searchable for Search {
7273
Action::Drop
7374
| Action::Edit
7475
| Action::Fixup
76+
| Action::Index
7577
| Action::Pick
7678
| Action::Reword
7779
| Action::Squash

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+
" i |Set selected commits to be staged in the index (git-revise)",
4344
" E |Edit an exec, label, reset or merge action's content",
4445
" I |Insert a new line",
4546
" Delete |Completely remove the selected lines",
@@ -105,6 +106,7 @@ fn visual_mode_help() {
105106
" s |Set selected commits to be squashed",
106107
" f |Set selected commits to be fixed-up",
107108
" d |Set selected commits to be dropped",
109+
" i |Set selected commits to be staged in the index (git-revise)",
108110
" Delete |Completely remove the selected lines",
109111
" Controlz|Undo the last change",
110112
" Controly|Redo the previous undone change",

0 commit comments

Comments
 (0)