Skip to content

Commit 6d905fb

Browse files
committed
Allow clicking in focused main view (or pressing enter) to go to staging
Only works if a file is selected.
1 parent b9d67ef commit 6d905fb

17 files changed

+108
-9
lines changed

docs/keybindings/Keybindings_en.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ If you would instead like to start an interactive rebase from the selected commi
209209
| `` mouse wheel up (fn+down) `` | Scroll up | |
210210
| `` <tab> `` | Switch view | Switch to other view (staged/unstaged changes). |
211211
| `` <esc> `` | Exit back to side panel | |
212+
| `` <enter> `` | Enter staging/patch building | |
212213
| `` / `` | Search the current view by text | |
213214

214215
## Main panel (patch building)
@@ -310,6 +311,7 @@ If you would instead like to start an interactive rebase from the selected commi
310311
|-----|--------|-------------|
311312
| `` <tab> `` | Switch view | Switch to other view (staged/unstaged changes). |
312313
| `` <esc> `` | Exit back to side panel | |
314+
| `` <enter> `` | Enter staging/patch building | |
313315
| `` / `` | Search the current view by text | |
314316

315317
## Stash

docs/keybindings/Keybindings_ja.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
5757
|-----|--------|-------------|
5858
| `` <tab> `` | パネルを切り替え | Switch to other view (staged/unstaged changes). |
5959
| `` <esc> `` | Exit back to side panel | |
60+
| `` <enter> `` | Enter staging/patch building | |
6061
| `` / `` | 検索を開始 | |
6162

6263
## Stash
@@ -292,6 +293,7 @@ If you would instead like to start an interactive rebase from the selected commi
292293
| `` mouse wheel up (fn+down) `` | 上にスクロール | |
293294
| `` <tab> `` | パネルを切り替え | Switch to other view (staged/unstaged changes). |
294295
| `` <esc> `` | Exit back to side panel | |
296+
| `` <enter> `` | Enter staging/patch building | |
295297
| `` / `` | 検索を開始 | |
296298

297299
## メインパネル (Patch Building)

docs/keybindings/Keybindings_ko.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
7575
|-----|--------|-------------|
7676
| `` <tab> `` | 패널 전환 | Switch to other view (staged/unstaged changes). |
7777
| `` <esc> `` | Exit back to side panel | |
78+
| `` <enter> `` | Enter staging/patch building | |
7879
| `` / `` | 검색 시작 | |
7980

8081
## Stash
@@ -151,6 +152,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
151152
| `` mouse wheel up (fn+down) `` | 위로 스크롤 | |
152153
| `` <tab> `` | 패널 전환 | Switch to other view (staged/unstaged changes). |
153154
| `` <esc> `` | Exit back to side panel | |
155+
| `` <enter> `` | Enter staging/patch building | |
154156
| `` / `` | 검색 시작 | |
155157

156158
## 메인 패널 (Patch Building)

docs/keybindings/Keybindings_nl.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ If you would instead like to start an interactive rebase from the selected commi
217217
| `` mouse wheel up (fn+down) `` | Scroll omhoog | |
218218
| `` <tab> `` | Ga naar een ander paneel | Switch to other view (staged/unstaged changes). |
219219
| `` <esc> `` | Exit back to side panel | |
220+
| `` <enter> `` | Enter staging/patch building | |
220221
| `` / `` | Start met zoeken | |
221222

222223
## Patch bouwen
@@ -288,6 +289,7 @@ If you would instead like to start an interactive rebase from the selected commi
288289
|-----|--------|-------------|
289290
| `` <tab> `` | Ga naar een ander paneel | Switch to other view (staged/unstaged changes). |
290291
| `` <esc> `` | Exit back to side panel | |
292+
| `` <enter> `` | Enter staging/patch building | |
291293
| `` / `` | Start met zoeken | |
292294

293295
## Staging

docs/keybindings/Keybindings_pl.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ Jeśli chcesz zamiast tego rozpocząć interaktywny rebase od wybranego commita,
9696
|-----|--------|-------------|
9797
| `` <tab> `` | Przełącz widok | Przełącz na inny widok (zatwierdzone/niezatwierdzone zmiany). |
9898
| `` <esc> `` | Exit back to side panel | |
99+
| `` <enter> `` | Enter staging/patch building | |
99100
| `` / `` | Szukaj w bieżącym widoku po tekście | |
100101

101102
## Drzewa pracy
@@ -167,6 +168,7 @@ Jeśli chcesz zamiast tego rozpocząć interaktywny rebase od wybranego commita,
167168
| `` mouse wheel up (fn+down) `` | Przewiń w górę | |
168169
| `` <tab> `` | Przełącz widok | Przełącz na inny widok (zatwierdzone/niezatwierdzone zmiany). |
169170
| `` <esc> `` | Exit back to side panel | |
171+
| `` <enter> `` | Enter staging/patch building | |
170172
| `` / `` | Szukaj w bieżącym widoku po tekście | |
171173

172174
## Panel główny (scalanie)

docs/keybindings/Keybindings_pt.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ If you would instead like to start an interactive rebase from the selected commi
231231
| `` mouse wheel up (fn+down) `` | Scroll up | |
232232
| `` <tab> `` | Mudar de visão | Alternar para outra visão (staged/não processadas alterações). |
233233
| `` <esc> `` | Exit back to side panel | |
234+
| `` <enter> `` | Enter staging/patch building | |
234235
| `` / `` | Search the current view by text | |
235236

236237
## Painel Principal (preparação)
@@ -323,6 +324,7 @@ Veja a documentação:
323324
|-----|--------|-------------|
324325
| `` <tab> `` | Mudar de visão | Alternar para outra visão (staged/não processadas alterações). |
325326
| `` <esc> `` | Exit back to side panel | |
327+
| `` <enter> `` | Enter staging/patch building | |
326328
| `` / `` | Search the current view by text | |
327329

328330
## Stash

docs/keybindings/Keybindings_ru.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ _Связки клавиш_
6767
|-----|--------|-------------|
6868
| `` <tab> `` | Переключиться на другую панель (проиндексированные/непроиндексированные изменения) | Switch to other view (staged/unstaged changes). |
6969
| `` <esc> `` | Exit back to side panel | |
70+
| `` <enter> `` | Enter staging/patch building | |
7071
| `` / `` | Найти | |
7172

7273
## Главная панель (Индексирование)
@@ -99,6 +100,7 @@ _Связки клавиш_
99100
| `` mouse wheel up (fn+down) `` | Прокрутить вверх | |
100101
| `` <tab> `` | Переключиться на другую панель (проиндексированные/непроиндексированные изменения) | Switch to other view (staged/unstaged changes). |
101102
| `` <esc> `` | Exit back to side panel | |
103+
| `` <enter> `` | Enter staging/patch building | |
102104
| `` / `` | Найти | |
103105

104106
## Главная панель (Слияние)

docs/keybindings/Keybindings_zh-CN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ _图例:`<c-b>` 意味着ctrl+b, `<a-b>意味着Alt+b, `B` 意味着shift+b_
275275
|-----|--------|-------------|
276276
| `` <tab> `` | 切换到其他面板 | 切换到其他视图(已暂存/未暂存的变更) |
277277
| `` <esc> `` | Exit back to side panel | |
278+
| `` <enter> `` | Enter staging/patch building | |
278279
| `` / `` | 开始搜索 | |
279280

280281
## 正在合并
@@ -323,6 +324,7 @@ _图例:`<c-b>` 意味着ctrl+b, `<a-b>意味着Alt+b, `B` 意味着shift+b_
323324
| `` mouse wheel up (fn+down) `` | 向上滚动 | |
324325
| `` <tab> `` | 切换到其他面板 | 切换到其他视图(已暂存/未暂存的变更) |
325326
| `` <esc> `` | Exit back to side panel | |
327+
| `` <enter> `` | Enter staging/patch building | |
326328
| `` / `` | 开始搜索 | |
327329

328330
## 状态

docs/keybindings/Keybindings_zh-TW.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ _說明:`<c-b>` 表示 Ctrl+B、`<a-b>` 表示 Alt+B,`B`表示 Shift+B
7474
| `` mouse wheel up (fn+down) `` | 向上捲動 | |
7575
| `` <tab> `` | 切換至另一個面板 (已預存/未預存更改) | Switch to other view (staged/unstaged changes). |
7676
| `` <esc> `` | Exit back to side panel | |
77+
| `` <enter> `` | Enter staging/patch building | |
7778
| `` / `` | 搜尋 | |
7879

7980
## 主面板(合併)
@@ -345,6 +346,7 @@ If you would instead like to start an interactive rebase from the selected commi
345346
|-----|--------|-------------|
346347
| `` <tab> `` | 切換至另一個面板 (已預存/未預存更改) | Switch to other view (staged/unstaged changes). |
347348
| `` <esc> `` | Exit back to side panel | |
349+
| `` <enter> `` | Enter staging/patch building | |
348350
| `` / `` | 搜尋 | |
349351

350352
## 狀態

pkg/gui/context/base_context.go

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ type BaseContext struct {
1313
windowName string
1414
onGetOptionsMap func() map[string]string
1515

16-
keybindingsFns []types.KeybindingsFn
17-
mouseKeybindingsFns []types.MouseKeybindingsFn
18-
onClickFn func() error
19-
onRenderToMainFn func()
20-
onFocusFn onFocusFn
21-
onFocusLostFn onFocusLostFn
16+
keybindingsFns []types.KeybindingsFn
17+
mouseKeybindingsFns []types.MouseKeybindingsFn
18+
onClickFn func() error
19+
onClickFocusedMainViewFn onClickFocusedMainViewFn
20+
onRenderToMainFn func()
21+
onFocusFn onFocusFn
22+
onFocusLostFn onFocusLostFn
2223

2324
focusable bool
2425
transient bool
@@ -31,8 +32,9 @@ type BaseContext struct {
3132
}
3233

3334
type (
34-
onFocusFn = func(types.OnFocusOpts)
35-
onFocusLostFn = func(types.OnFocusLostOpts)
35+
onFocusFn = func(types.OnFocusOpts)
36+
onFocusLostFn = func(types.OnFocusLostOpts)
37+
onClickFocusedMainViewFn = func(mainViewName string, clickedLineIdx int) error
3638
)
3739

3840
var _ types.IBaseContext = &BaseContext{}
@@ -144,10 +146,20 @@ func (self *BaseContext) AddOnClickFn(fn func() error) {
144146
}
145147
}
146148

149+
func (self *BaseContext) AddOnClickFocusedMainViewFn(fn onClickFocusedMainViewFn) {
150+
if fn != nil {
151+
self.onClickFocusedMainViewFn = fn
152+
}
153+
}
154+
147155
func (self *BaseContext) GetOnClick() func() error {
148156
return self.onClickFn
149157
}
150158

159+
func (self *BaseContext) GetOnClickFocusedMainView() onClickFocusedMainViewFn {
160+
return self.onClickFocusedMainViewFn
161+
}
162+
151163
func (self *BaseContext) AddOnRenderToMainFn(fn func()) {
152164
if fn != nil {
153165
self.onRenderToMainFn = fn

0 commit comments

Comments
 (0)