1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-12 11:15:00 +02:00
lazygit/pkg/gui/commit_message_panel.go

37 lines
947 B
Go
Raw Normal View History

2018-08-14 11:05:26 +02:00
package gui
import (
2018-09-05 12:42:11 +02:00
"strconv"
"strings"
"github.com/jesseduffield/gocui"
2020-10-04 02:00:48 +02:00
"github.com/jesseduffield/lazygit/pkg/utils"
)
2018-08-14 11:05:26 +02:00
2020-08-16 05:58:29 +02:00
func (gui *Gui) handleCommitMessageFocused() error {
2020-10-04 02:00:48 +02:00
message := utils.ResolvePlaceholderString(
gui.c.Tr.CommitMessageConfirm,
2020-10-04 02:00:48 +02:00
map[string]string{
"keyBindClose": gui.getKeyDisplay(gui.c.UserConfig.Keybinding.Universal.Return),
"keyBindConfirm": gui.getKeyDisplay(gui.c.UserConfig.Keybinding.Universal.Confirm),
"keyBindNewLine": gui.getKeyDisplay(gui.c.UserConfig.Keybinding.Universal.AppendNewline),
},
)
2020-10-04 02:00:48 +02:00
gui.RenderCommitLength()
2022-01-15 03:04:00 +02:00
return gui.renderString(gui.Views.Options, message)
2018-08-14 11:05:26 +02:00
}
2018-09-05 12:42:11 +02:00
func (gui *Gui) RenderCommitLength() {
if !gui.c.UserConfig.Gui.CommitLength.Show {
return
}
2021-04-04 15:51:59 +02:00
2022-02-22 12:16:00 +02:00
gui.Views.CommitMessage.Subtitle = getBufferLength(gui.Views.CommitMessage)
}
func getBufferLength(view *gocui.View) string {
return " " + strconv.Itoa(strings.Count(view.TextArea.GetContent(), "")-1) + " "
}