diff --git a/docs/keybindings/Keybindings_en.md b/docs/keybindings/Keybindings_en.md index 843c1c898..396459478 100644 --- a/docs/keybindings/Keybindings_en.md +++ b/docs/keybindings/Keybindings_en.md @@ -210,6 +210,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` mouse wheel up (fn+down) `` | Scroll up | | | `` `` | Switch view | Switch to other view (staged/unstaged changes). | | `` `` | Exit back to side panel | | +| `` / `` | Search the current view by text | | ## Main panel (patch building) @@ -311,6 +312,7 @@ If you would instead like to start an interactive rebase from the selected commi |-----|--------|-------------| | `` `` | Switch view | Switch to other view (staged/unstaged changes). | | `` `` | Exit back to side panel | | +| `` / `` | Search the current view by text | | ## Stash diff --git a/docs/keybindings/Keybindings_ja.md b/docs/keybindings/Keybindings_ja.md index f02d933d3..eff44cbb2 100644 --- a/docs/keybindings/Keybindings_ja.md +++ b/docs/keybindings/Keybindings_ja.md @@ -57,6 +57,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ |-----|--------|-------------| | `` `` | パネルを切り替え | Switch to other view (staged/unstaged changes). | | `` `` | Exit back to side panel | | +| `` / `` | 検索を開始 | | ## Stash @@ -293,6 +294,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` mouse wheel up (fn+down) `` | 上にスクロール | | | `` `` | パネルを切り替え | Switch to other view (staged/unstaged changes). | | `` `` | Exit back to side panel | | +| `` / `` | 検索を開始 | | ## メインパネル (Patch Building) diff --git a/docs/keybindings/Keybindings_ko.md b/docs/keybindings/Keybindings_ko.md index 8223e0bc5..c1561441b 100644 --- a/docs/keybindings/Keybindings_ko.md +++ b/docs/keybindings/Keybindings_ko.md @@ -76,6 +76,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ |-----|--------|-------------| | `` `` | 패널 전환 | Switch to other view (staged/unstaged changes). | | `` `` | Exit back to side panel | | +| `` / `` | 검색 시작 | | ## Stash @@ -152,6 +153,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` mouse wheel up (fn+down) `` | 위로 스크롤 | | | `` `` | 패널 전환 | Switch to other view (staged/unstaged changes). | | `` `` | Exit back to side panel | | +| `` / `` | 검색 시작 | | ## 메인 패널 (Patch Building) diff --git a/docs/keybindings/Keybindings_nl.md b/docs/keybindings/Keybindings_nl.md index c1fa45887..1752329e7 100644 --- a/docs/keybindings/Keybindings_nl.md +++ b/docs/keybindings/Keybindings_nl.md @@ -218,6 +218,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` mouse wheel up (fn+down) `` | Scroll omhoog | | | `` `` | Ga naar een ander paneel | Switch to other view (staged/unstaged changes). | | `` `` | Exit back to side panel | | +| `` / `` | Start met zoeken | | ## Patch bouwen @@ -289,6 +290,7 @@ If you would instead like to start an interactive rebase from the selected commi |-----|--------|-------------| | `` `` | Ga naar een ander paneel | Switch to other view (staged/unstaged changes). | | `` `` | Exit back to side panel | | +| `` / `` | Start met zoeken | | ## Staging diff --git a/docs/keybindings/Keybindings_pl.md b/docs/keybindings/Keybindings_pl.md index 7c6b26921..67a4ba277 100644 --- a/docs/keybindings/Keybindings_pl.md +++ b/docs/keybindings/Keybindings_pl.md @@ -97,6 +97,7 @@ Jeśli chcesz zamiast tego rozpocząć interaktywny rebase od wybranego commita, |-----|--------|-------------| | `` `` | Przełącz widok | Przełącz na inny widok (zatwierdzone/niezatwierdzone zmiany). | | `` `` | Exit back to side panel | | +| `` / `` | Szukaj w bieżącym widoku po tekście | | ## Drzewa pracy @@ -167,6 +168,7 @@ Jeśli chcesz zamiast tego rozpocząć interaktywny rebase od wybranego commita, | `` mouse wheel up (fn+down) `` | Przewiń w górę | | | `` `` | Przełącz widok | Przełącz na inny widok (zatwierdzone/niezatwierdzone zmiany). | | `` `` | Exit back to side panel | | +| `` / `` | Szukaj w bieżącym widoku po tekście | | ## Panel główny (scalanie) diff --git a/docs/keybindings/Keybindings_pt.md b/docs/keybindings/Keybindings_pt.md index 8cb2d3319..ccf5524b0 100644 --- a/docs/keybindings/Keybindings_pt.md +++ b/docs/keybindings/Keybindings_pt.md @@ -232,6 +232,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` mouse wheel up (fn+down) `` | Rolar para cima | | | `` `` | Mudar de visão | Alternar para outra visão (staged/não processadas alterações). | | `` `` | Exit back to side panel | | +| `` / `` | Search the current view by text | | ## Painel Principal (preparação) @@ -324,6 +325,7 @@ Veja a documentação: |-----|--------|-------------| | `` `` | Mudar de visão | Alternar para outra visão (staged/não processadas alterações). | | `` `` | Exit back to side panel | | +| `` / `` | Search the current view by text | | ## Stash diff --git a/docs/keybindings/Keybindings_ru.md b/docs/keybindings/Keybindings_ru.md index 6febfe80b..b75fc0d80 100644 --- a/docs/keybindings/Keybindings_ru.md +++ b/docs/keybindings/Keybindings_ru.md @@ -67,6 +67,7 @@ _Связки клавиш_ |-----|--------|-------------| | `` `` | Переключиться на другую панель (проиндексированные/непроиндексированные изменения) | Switch to other view (staged/unstaged changes). | | `` `` | Exit back to side panel | | +| `` / `` | Найти | | ## Главная панель (Индексирование) @@ -98,6 +99,7 @@ _Связки клавиш_ | `` mouse wheel up (fn+down) `` | Прокрутить вверх | | | `` `` | Переключиться на другую панель (проиндексированные/непроиндексированные изменения) | Switch to other view (staged/unstaged changes). | | `` `` | Exit back to side panel | | +| `` / `` | Найти | | ## Главная панель (Слияние) diff --git a/docs/keybindings/Keybindings_zh-CN.md b/docs/keybindings/Keybindings_zh-CN.md index def6f1632..4cdda3dd0 100644 --- a/docs/keybindings/Keybindings_zh-CN.md +++ b/docs/keybindings/Keybindings_zh-CN.md @@ -278,6 +278,7 @@ _图例:`` 意味着ctrl+b, `意味着Alt+b, `B` 意味着shift+b_ |-----|--------|-------------| | `` `` | 切换到其他面板 | 切换到其他视图(已暂存/未暂存的变更) | | `` `` | Exit back to side panel | | +| `` / `` | 开始搜索 | | ## 正在合并 @@ -325,6 +326,7 @@ _图例:`` 意味着ctrl+b, `意味着Alt+b, `B` 意味着shift+b_ | `` mouse wheel up (fn+down) `` | 向上滚动 | | | `` `` | 切换到其他面板 | 切换到其他视图(已暂存/未暂存的变更) | | `` `` | Exit back to side panel | | +| `` / `` | 开始搜索 | | ## 状态 diff --git a/docs/keybindings/Keybindings_zh-TW.md b/docs/keybindings/Keybindings_zh-TW.md index b056c92b9..8312ca98b 100644 --- a/docs/keybindings/Keybindings_zh-TW.md +++ b/docs/keybindings/Keybindings_zh-TW.md @@ -74,6 +74,7 @@ _說明:`` 表示 Ctrl+B、`` 表示 Alt+B,`B`表示 Shift+B | `` mouse wheel up (fn+down) `` | 向上捲動 | | | `` `` | 切換至另一個面板 (已預存/未預存更改) | Switch to other view (staged/unstaged changes). | | `` `` | Exit back to side panel | | +| `` / `` | 搜尋 | | ## 主面板(合併) @@ -347,6 +348,7 @@ If you would instead like to start an interactive rebase from the selected commi |-----|--------|-------------| | `` `` | 切換至另一個面板 (已預存/未預存更改) | Switch to other view (staged/unstaged changes). | | `` `` | Exit back to side panel | | +| `` / `` | 搜尋 | | ## 狀態 diff --git a/pkg/gui/context/main_context.go b/pkg/gui/context/main_context.go index 7ca6ffdd1..66babac03 100644 --- a/pkg/gui/context/main_context.go +++ b/pkg/gui/context/main_context.go @@ -7,12 +7,16 @@ import ( type MainContext struct { *SimpleContext + *SearchTrait } +var _ types.ISearchableContext = (*MainContext)(nil) + func NewMainContext( view *gocui.View, windowName string, key types.ContextKey, + c *ContextCommon, ) *MainContext { ctx := &MainContext{ SimpleContext: NewSimpleContext( @@ -24,7 +28,14 @@ func NewMainContext( Focusable: true, HighlightOnFocus: false, })), + SearchTrait: NewSearchTrait(c), } + ctx.GetView().SetOnSelectItem(ctx.SearchTrait.onSelectItemWrapper(func(int) error { return nil })) + return ctx } + +func (self *MainContext) ModelSearchResults(searchStr string, caseSensitive bool) []gocui.SearchPosition { + return nil +} diff --git a/pkg/gui/context/setup.go b/pkg/gui/context/setup.go index 33e67fda5..3a87c100a 100644 --- a/pkg/gui/context/setup.go +++ b/pkg/gui/context/setup.go @@ -39,8 +39,8 @@ func NewContextTree(c *ContextCommon) *ContextTree { Tags: NewTagsContext(c), Stash: NewStashContext(c), Suggestions: NewSuggestionsContext(c), - Normal: NewMainContext(c.Views().Main, "main", NORMAL_MAIN_CONTEXT_KEY), - NormalSecondary: NewMainContext(c.Views().Secondary, "secondary", NORMAL_SECONDARY_CONTEXT_KEY), + Normal: NewMainContext(c.Views().Main, "main", NORMAL_MAIN_CONTEXT_KEY, c), + NormalSecondary: NewMainContext(c.Views().Secondary, "secondary", NORMAL_SECONDARY_CONTEXT_KEY, c), Staging: NewPatchExplorerContext( c.Views().Staging, "main", diff --git a/pkg/gui/controllers/switch_to_focused_main_view_controller.go b/pkg/gui/controllers/switch_to_focused_main_view_controller.go index f2d48448f..85da121be 100644 --- a/pkg/gui/controllers/switch_to_focused_main_view_controller.go +++ b/pkg/gui/controllers/switch_to_focused_main_view_controller.go @@ -44,6 +44,9 @@ func (self *SwitchToFocusedMainViewController) Context() types.Context { func (self *SwitchToFocusedMainViewController) handleFocusMainView() error { mainViewContext := self.c.Helpers().Window.GetContextForWindow("main") mainViewContext.SetParentContext(self.context) + if context, ok := mainViewContext.(types.ISearchableContext); ok { + context.ClearSearchString() + } self.c.Context().Push(mainViewContext, types.OnFocusOpts{}) return nil }