Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,8 @@ keybinding:
select: <space>
goInto: <enter>
confirm: <enter>
confirmMenu: <enter>
confirmSuggestion: <enter>
confirmInEditor: <a-enter>
confirmInEditor-alt: <c-s>
remove: d
Expand Down
7 changes: 7 additions & 0 deletions docs/keybindings/Keybindings_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
| `` 0 `` | Focus main view | |
| `` / `` | Search the current view by text | |

## Input prompt

| Key | Action | Info |
|-----|--------|-------------|
| `` <enter> `` | Confirm | |
| `` <esc> `` | Close/Cancel | |

## Local branches

| Key | Action | Info |
Expand Down
7 changes: 7 additions & 0 deletions docs/keybindings/Keybindings_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ _凡例:`<c-b>` はctrl+b、`<a-b>` はalt+b、`B` はshift+bを意味
| `` ] `` | 次のタブ | |
| `` [ `` | 前のタブ | |

## Input prompt

| Key | Action | Info |
|-----|--------|-------------|
| `` <enter> `` | 確認 | |
| `` <esc> `` | 閉じる/キャンセル | |

## コミット

| Key | Action | Info |
Expand Down
7 changes: 7 additions & 0 deletions docs/keybindings/Keybindings_ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
| `` ] `` | 이전 탭 | |
| `` [ `` | 다음 탭 | |

## Input prompt

| Key | Action | Info |
|-----|--------|-------------|
| `` <enter> `` | 확인 | |
| `` <esc> `` | 닫기/취소 | |

## Reflog

| Key | Action | Info |
Expand Down
7 changes: 7 additions & 0 deletions docs/keybindings/Keybindings_nl.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
| `` w `` | View worktree options | |
| `` / `` | Start met zoeken | |

## Input prompt

| Key | Action | Info |
|-----|--------|-------------|
| `` <enter> `` | Bevestig | |
| `` <esc> `` | Sluiten | |

## Menu

| Key | Action | Info |
Expand Down
7 changes: 7 additions & 0 deletions docs/keybindings/Keybindings_pl.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ _Legenda: `<c-b>` oznacza ctrl+b, `<a-b>` oznacza alt+b, `B` oznacza shift+b_
| `` <esc> `` | Wyjdź z budowniczego niestandardowej łatki | |
| `` / `` | Szukaj w bieżącym widoku po tekście | |

## Input prompt

| Key | Action | Info |
|-----|--------|-------------|
| `` <enter> `` | Potwierdź | |
| `` <esc> `` | Zamknij/Anuluj | |

## Lokalne gałęzie

| Key | Action | Info |
Expand Down
7 changes: 7 additions & 0 deletions docs/keybindings/Keybindings_pt.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,13 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
| `` w `` | View worktree options | |
| `` / `` | Filter the current view by text | |

## Input prompt

| Key | Action | Info |
|-----|--------|-------------|
| `` <enter> `` | Confirmar | |
| `` <esc> `` | Fechar/Cancelar | |

## Menu

| Key | Action | Info |
Expand Down
7 changes: 7 additions & 0 deletions docs/keybindings/Keybindings_ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ _Связки клавиш_
| `` ] `` | Следующая вкладка | |
| `` [ `` | Предыдущая вкладка | |

## Input prompt

| Key | Action | Info |
|-----|--------|-------------|
| `` <enter> `` | Подтвердить | |
| `` <esc> `` | Закрыть/отменить | |

## Worktrees

| Key | Action | Info |
Expand Down
7 changes: 7 additions & 0 deletions docs/keybindings/Keybindings_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ _图例:`<c-b>` 意味着ctrl+b, `<a-b>意味着Alt+b, `B` 意味着shift+b_
| `` ] `` | 下一个标签 | |
| `` [ `` | 上一个标签 | |

## Input prompt

| Key | Action | Info |
|-----|--------|-------------|
| `` <enter> `` | 确认 | |
| `` <esc> `` | 关闭 | |

## Reflog

| Key | Action | Info |
Expand Down
7 changes: 7 additions & 0 deletions docs/keybindings/Keybindings_zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ _說明:`<c-b>` 表示 Ctrl+B、`<a-b>` 表示 Alt+B,`B`表示 Shift+B
| `` ] `` | 下一個索引標籤 | |
| `` [ `` | 上一個索引標籤 | |

## Input prompt

| Key | Action | Info |
|-----|--------|-------------|
| `` <enter> `` | 確認 | |
| `` <esc> `` | 關閉/取消 | |

## 主面板 (補丁生成)

| Key | Action | Info |
Expand Down
1 change: 1 addition & 0 deletions pkg/cheatsheet/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func localisedTitle(tr *i18n.TranslationSet, str string) string {
"commitDescription": tr.CommitDescriptionTitle,
"commits": tr.CommitsTitle,
"confirmation": tr.ConfirmationTitle,
"prompt": tr.PromptTitle,
"information": tr.InformationTitle,
"main": tr.NormalTitle,
"patchBuilding": tr.PatchBuildingTitle,
Expand Down
4 changes: 4 additions & 0 deletions pkg/config/user_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ type KeybindingUniversalConfig struct {
Select string `yaml:"select"`
GoInto string `yaml:"goInto"`
Confirm string `yaml:"confirm"`
ConfirmMenu string `yaml:"confirmMenu"`
ConfirmSuggestion string `yaml:"confirmSuggestion"`
ConfirmInEditor string `yaml:"confirmInEditor"`
ConfirmInEditorAlt string `yaml:"confirmInEditor-alt"`
Remove string `yaml:"remove"`
Expand Down Expand Up @@ -889,6 +891,8 @@ func GetDefaultConfig() *UserConfig {
Select: "<space>",
GoInto: "<enter>",
Confirm: "<enter>",
ConfirmMenu: "<enter>",
ConfirmSuggestion: "<enter>",
ConfirmInEditor: "<a-enter>",
ConfirmInEditorAlt: "<c-s>",
Remove: "d",
Expand Down
4 changes: 4 additions & 0 deletions pkg/gui/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const (

MENU_CONTEXT_KEY types.ContextKey = "menu"
CONFIRMATION_CONTEXT_KEY types.ContextKey = "confirmation"
PROMPT_CONTEXT_KEY types.ContextKey = "prompt"
SEARCH_CONTEXT_KEY types.ContextKey = "search"
COMMIT_MESSAGE_CONTEXT_KEY types.ContextKey = "commitMessage"
COMMIT_DESCRIPTION_CONTEXT_KEY types.ContextKey = "commitDescription"
Expand Down Expand Up @@ -73,6 +74,7 @@ var AllContextKeys = []types.ContextKey{

MENU_CONTEXT_KEY,
CONFIRMATION_CONTEXT_KEY,
PROMPT_CONTEXT_KEY,
SEARCH_CONTEXT_KEY,
COMMIT_MESSAGE_CONTEXT_KEY,
SUBMODULES_CONTEXT_KEY,
Expand Down Expand Up @@ -106,6 +108,7 @@ type ContextTree struct {
CustomPatchBuilderSecondary types.Context
MergeConflicts *MergeConflictsContext
Confirmation *ConfirmationContext
Prompt *PromptContext
CommitMessage *CommitMessageContext
CommitDescription types.Context
CommandLog types.Context
Expand Down Expand Up @@ -141,6 +144,7 @@ func (self *ContextTree) Flatten() []types.Context {
self.Stash,
self.Menu,
self.Confirmation,
self.Prompt,
self.CommitMessage,
self.CommitDescription,

Expand Down
30 changes: 30 additions & 0 deletions pkg/gui/context/prompt_context.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package context

import (
"github.com/jesseduffield/lazygit/pkg/gui/types"
)

type PromptContext struct {
*SimpleContext
c *ContextCommon

State ConfirmationContextState
}

var _ types.Context = (*PromptContext)(nil)

func NewPromptContext(
c *ContextCommon,
) *PromptContext {
return &PromptContext{
c: c,
SimpleContext: NewSimpleContext(NewBaseContext(NewBaseContextOpts{
View: c.Views().Prompt,
WindowName: "prompt",
Key: PROMPT_CONTEXT_KEY,
Kind: types.TEMPORARY_POPUP,
Focusable: true,
HasUncontrolledBounds: true,
})),
}
}
1 change: 1 addition & 0 deletions pkg/gui/context/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func NewContextTree(c *ContextCommon) *ContextTree {
c,
),
Confirmation: NewConfirmationContext(c),
Prompt: NewPromptContext(c),
CommitMessage: NewCommitMessageContext(c),
CommitDescription: NewSimpleContext(
NewBaseContext(NewBaseContextOpts{
Expand Down
5 changes: 5 additions & 0 deletions pkg/gui/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ func (gui *Gui) resetHelpersAndControllers() {
statusController := controllers.NewStatusController(common)
commandLogController := controllers.NewCommandLogController(common)
confirmationController := controllers.NewConfirmationController(common)
promptController := controllers.NewPromptController(common)
suggestionsController := controllers.NewSuggestionsController(common)
jumpToSideWindowController := controllers.NewJumpToSideWindowController(common, gui.handleNextTab)

Expand Down Expand Up @@ -399,6 +400,10 @@ func (gui *Gui) resetHelpersAndControllers() {
confirmationController,
)

controllers.AttachControllers(gui.State.Contexts.Prompt,
promptController,
)

controllers.AttachControllers(gui.State.Contexts.Suggestions,
suggestionsController,
)
Expand Down
60 changes: 5 additions & 55 deletions pkg/gui/controllers/confirmation_controller.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package controllers

import (
"fmt"

"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
Expand Down Expand Up @@ -39,45 +36,19 @@ func (self *ConfirmationController) GetKeybindings(opts types.KeybindingsOpts) [
DisplayOnScreen: true,
},
{
Key: opts.GetKey(opts.Config.Universal.TogglePanel),
Handler: func() error {
if len(self.c.Contexts().Suggestions.State.Suggestions) > 0 {
self.switchToSuggestions()
}
return nil
},
},
{
Key: opts.GetKey(opts.Config.Universal.CopyToClipboard),
Handler: self.handleCopyToClipboard,
Description: self.c.Tr.CopyToClipboardMenu,
DisplayOnScreen: true,
GetDisabledReason: self.copyToClipboardEnabled,
Key: opts.GetKey(opts.Config.Universal.CopyToClipboard),
Handler: self.handleCopyToClipboard,
Description: self.c.Tr.CopyToClipboardMenu,
DisplayOnScreen: true,
},
}

return bindings
}

func (self *ConfirmationController) GetMouseKeybindings(opts types.KeybindingsOpts) []*gocui.ViewMouseBinding {
return []*gocui.ViewMouseBinding{
{
ViewName: self.c.Contexts().Suggestions.GetViewName(),
FocusedView: self.c.Contexts().Confirmation.GetViewName(),
Key: gocui.MouseLeft,
Handler: func(gocui.ViewMouseBindingOpts) error {
self.switchToSuggestions()
// Let it fall through to the ListController's click handler so that
// the clicked line gets selected:
return gocui.ErrKeybindingNotHandled
},
},
}
}

func (self *ConfirmationController) GetOnFocusLost() func(types.OnFocusLostOpts) {
return func(types.OnFocusLostOpts) {
self.c.Helpers().Confirmation.DeactivateConfirmationPrompt()
self.c.Helpers().Confirmation.DeactivateConfirmation()
}
}

Expand All @@ -89,18 +60,6 @@ func (self *ConfirmationController) context() *context.ConfirmationContext {
return self.c.Contexts().Confirmation
}

func (self *ConfirmationController) switchToSuggestions() {
subtitle := ""
if self.c.State().GetRepoState().GetCurrentPopupOpts().HandleDeleteSuggestion != nil {
// We assume that whenever things are deletable, they
// are also editable, so we show both keybindings
subtitle = fmt.Sprintf(self.c.Tr.SuggestionsSubtitle,
self.c.UserConfig().Keybinding.Universal.Remove, self.c.UserConfig().Keybinding.Universal.Edit)
}
self.c.Views().Suggestions.Subtitle = subtitle
self.c.Context().Replace(self.c.Contexts().Suggestions)
}

func (self *ConfirmationController) handleCopyToClipboard() error {
confirmationView := self.c.Views().Confirmation
text := confirmationView.Buffer()
Expand All @@ -111,12 +70,3 @@ func (self *ConfirmationController) handleCopyToClipboard() error {
self.c.Toast(self.c.Tr.MessageCopiedToClipboard)
return nil
}

func (self *ConfirmationController) copyToClipboardEnabled() *types.DisabledReason {
if self.c.Views().Confirmation.Editable {
// The empty text is intentional. We don't want to get a toast when invoking this, we only
// want to prevent it from showing up in the options bar.
return &types.DisabledReason{Text: ""}
}
return nil
}
Loading
Loading