diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2018-09-05 20:42:11 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2018-09-05 20:43:45 +1000 |
commit | 986774e5c7ddf5c1de1e1adb831baac84a2dae66 (patch) | |
tree | 63c0af0ec32cfd39615d8212bdc3a707e5e30d5b /pkg/gui/commit_message_panel.go | |
parent | 98763e98cb4c0af033b5276423e451f1f8cd11ee (diff) |
add commit count via gocui subtitle
Diffstat (limited to 'pkg/gui/commit_message_panel.go')
-rw-r--r-- | pkg/gui/commit_message_panel.go | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/pkg/gui/commit_message_panel.go b/pkg/gui/commit_message_panel.go index 88a011c76..7ac566b3f 100644 --- a/pkg/gui/commit_message_panel.go +++ b/pkg/gui/commit_message_panel.go @@ -1,6 +1,9 @@ package gui import ( + "strconv" + "strings" + "github.com/jesseduffield/gocui" ) @@ -30,7 +33,6 @@ func (gui *Gui) handleCommitConfirm(g *gocui.Gui, v *gocui.View) error { func (gui *Gui) handleCommitClose(g *gocui.Gui, v *gocui.View) error { g.SetViewOnBottom("commitMessage") - g.SetViewOnBottom("commitMessageCount") return gui.switchFocus(g, v, gui.getFilesView(g)) } @@ -44,3 +46,34 @@ func (gui *Gui) handleCommitFocused(g *gocui.Gui, v *gocui.View) error { ) return gui.renderString(g, "options", message) } + +func (gui *Gui) simpleEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) { + switch { + case key == gocui.KeyBackspace || key == gocui.KeyBackspace2: + v.EditDelete(true) + case key == gocui.KeyDelete: + v.EditDelete(false) + case key == gocui.KeyArrowDown: + v.MoveCursor(0, 1, false) + case key == gocui.KeyArrowUp: + v.MoveCursor(0, -1, false) + case key == gocui.KeyArrowLeft: + v.MoveCursor(-1, 0, false) + case key == gocui.KeyArrowRight: + v.MoveCursor(1, 0, false) + case key == gocui.KeyTab: + v.EditNewLine() + case key == gocui.KeySpace: + v.EditWrite(' ') + case key == gocui.KeyInsert: + v.Overwrite = !v.Overwrite + default: + v.EditWrite(ch) + } + + v.Subtitle = gui.getBufferLength(v) +} + +func (gui *Gui) getBufferLength(view *gocui.View) string { + return " " + strconv.Itoa(strings.Count(view.Buffer(), "")-1) + " " +} |