From a2d40cfbf1df9c6cd7107e9356cca6dbac031f40 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Wed, 5 Sep 2018 23:02:13 +1000 Subject: allow users to configure whether the commit length is shown --- docs/Config.md | 2 ++ pkg/config/app_config.go | 2 ++ pkg/gui/commit_message_panel.go | 10 +++++++++- pkg/gui/files_panel.go | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/Config.md b/docs/Config.md index eb1c65f9a..76cf4bcc0 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -14,6 +14,8 @@ - white optionsTextColor: - blue + commitLength: + show: true update: method: prompt # can be: prompt | background | never days: 14 # how often an update is checked for diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index 3c272e520..ae713a212 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -222,6 +222,8 @@ func GetDefaultConfig() []byte { - white optionsTextColor: - blue + commitLength: + show: true update: method: prompt # can be: prompt | background | never days: 14 # how often a update is checked for diff --git a/pkg/gui/commit_message_panel.go b/pkg/gui/commit_message_panel.go index 7ac566b3f..99d649102 100644 --- a/pkg/gui/commit_message_panel.go +++ b/pkg/gui/commit_message_panel.go @@ -71,9 +71,17 @@ func (gui *Gui) simpleEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.Mo v.EditWrite(ch) } - v.Subtitle = gui.getBufferLength(v) + gui.RenderCommitLength() } func (gui *Gui) getBufferLength(view *gocui.View) string { return " " + strconv.Itoa(strings.Count(view.Buffer(), "")-1) + " " } + +func (gui *Gui) RenderCommitLength() { + if !gui.Config.GetUserConfig().GetBool("gui.commitLength.show") { + return + } + v := gui.getCommitMessageView(gui.g) + v.Subtitle = gui.getBufferLength(v) +} diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index f85ff9d33..1971b3453 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -226,7 +226,7 @@ func (gui *Gui) handleCommitPress(g *gocui.Gui, filesView *gocui.View) error { g.Update(func(g *gocui.Gui) error { g.SetViewOnTop("commitMessage") gui.switchFocus(g, filesView, commitMessageView) - commitMessageView.Subtitle = gui.getBufferLength(commitMessageView) + gui.RenderCommitLength() return nil }) return nil -- cgit v1.2.3