2018-08-14 11:05:26 +02:00
|
|
|
package gui
|
|
|
|
|
2018-08-14 14:12:07 +02:00
|
|
|
import (
|
2018-09-05 12:42:11 +02:00
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
|
2018-08-14 14:12:07 +02:00
|
|
|
"github.com/jesseduffield/gocui"
|
2020-10-04 02:00:48 +02:00
|
|
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
2018-08-14 14:12:07 +02:00
|
|
|
)
|
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(
|
2022-01-16 05:46:53 +02:00
|
|
|
gui.c.Tr.CommitMessageConfirm,
|
2020-10-04 02:00:48 +02:00
|
|
|
map[string]string{
|
2022-01-16 05:46:53 +02:00
|
|
|
"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),
|
2018-08-15 09:15:31 +02:00
|
|
|
},
|
|
|
|
)
|
2020-10-04 02:00:48 +02:00
|
|
|
|
2022-01-16 05:46:53 +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
|
|
|
|
2018-09-05 15:02:13 +02:00
|
|
|
func (gui *Gui) RenderCommitLength() {
|
2022-01-16 05:46:53 +02:00
|
|
|
if !gui.c.UserConfig.Gui.CommitLength.Show {
|
2018-09-05 15:02:13 +02:00
|
|
|
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) + " "
|
2018-09-05 15:02:13 +02:00
|
|
|
}
|