1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

more things

This commit is contained in:
Jesse Duffield
2022-03-20 10:19:14 +11:00
parent e392b9f86a
commit cb26c7a1f2
7 changed files with 176 additions and 41 deletions

View File

@ -3,15 +3,14 @@ package gui
import (
"fmt"
"github.com/jesseduffield/generics/slices"
"github.com/jesseduffield/lazygit/pkg/constants"
"github.com/jesseduffield/lazygit/pkg/gui/style"
)
func (gui *Gui) informationStr() string {
for _, mode := range gui.modeStatuses() {
if mode.isActive() {
return mode.description()
}
if activeMode, ok := gui.getActiveMode(); ok {
return activeMode.description()
}
if gui.g.Mouse {
@ -23,6 +22,12 @@ func (gui *Gui) informationStr() string {
}
}
func (gui *Gui) getActiveMode() (modeStatus, bool) {
return slices.Find(gui.modeStatuses(), func(mode modeStatus) bool {
return mode.isActive()
})
}
func (gui *Gui) handleInfoClick() error {
if !gui.g.Mouse {
return nil
@ -33,13 +38,11 @@ func (gui *Gui) handleInfoClick() error {
cx, _ := view.Cursor()
width, _ := view.Size()
for _, mode := range gui.modeStatuses() {
if mode.isActive() {
if width-cx > len(gui.c.Tr.ResetInParentheses) {
return nil
}
return mode.reset()
if activeMode, ok := gui.getActiveMode(); ok {
if width-cx > len(gui.c.Tr.ResetInParentheses) {
return nil
}
return activeMode.reset()
}
// if we're not in an active mode we show the donate button