diff --git a/go.mod b/go.mod index 4011439bf..598b00ff8 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/imdario/mergo v0.3.11 github.com/integrii/flaggy v1.4.0 github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4 - github.com/jesseduffield/gocui v0.3.1-0.20210402033412-1238f910f001 + github.com/jesseduffield/gocui v0.3.1-0.20210402040718-77a1b9631715 github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe // indirect github.com/jesseduffield/yaml v2.1.0+incompatible github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 diff --git a/go.sum b/go.sum index e9a22851d..ecc1941fa 100644 --- a/go.sum +++ b/go.sum @@ -92,6 +92,8 @@ github.com/jesseduffield/gocui v0.3.1-0.20210329131148-bcc4dcd991ff h1:fTt3EzLtp github.com/jesseduffield/gocui v0.3.1-0.20210329131148-bcc4dcd991ff/go.mod h1:QWq79xplEoyhQO+dgpk3sojjTVRKjQklyTlzm5nC5Kg= github.com/jesseduffield/gocui v0.3.1-0.20210402033412-1238f910f001 h1:1WH+lTSK5YMr8emISHPA+VqYDDcLei6djuSxBCLIaiI= github.com/jesseduffield/gocui v0.3.1-0.20210402033412-1238f910f001/go.mod h1:QWq79xplEoyhQO+dgpk3sojjTVRKjQklyTlzm5nC5Kg= +github.com/jesseduffield/gocui v0.3.1-0.20210402040718-77a1b9631715 h1:nELTdFJiZk3vv7j8nWoHvl7H2IqTr26EHKl6LaorRA8= +github.com/jesseduffield/gocui v0.3.1-0.20210402040718-77a1b9631715/go.mod h1:QWq79xplEoyhQO+dgpk3sojjTVRKjQklyTlzm5nC5Kg= github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe h1:qsVhCf2RFyyKIUe/+gJblbCpXMUki9rZrHuEctg6M/E= github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe/go.mod h1:anMibpZtqNxjDbxrcDEAwSdaJ37vyUeM1f/M4uekib4= github.com/jesseduffield/yaml v2.1.0+incompatible h1:HWQJ1gIv2zHKbDYNp0Jwjlj24K8aqpFHnMCynY1EpmE= diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 73b19cc3b..b9221c01b 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -381,7 +381,7 @@ func GetDefaultConfig() *UserConfig { DiffingMenuAlt: "", CopyToClipboard: "", SubmitEditorText: "", - AppendNewline: "", + AppendNewline: "", }, Status: KeybindingStatusConfig{ CheckForUpdate: "u", diff --git a/pkg/gui/editors.go b/pkg/gui/editors.go index 0cddd1385..7d3054cd0 100644 --- a/pkg/gui/editors.go +++ b/pkg/gui/editors.go @@ -11,7 +11,7 @@ import ( func (gui *Gui) commitMessageEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) bool { newlineKey, ok := gui.getKey(gui.Config.GetUserConfig().Keybinding.Universal.AppendNewline).(gocui.Key) if !ok { - newlineKey = gocui.KeyTab + newlineKey = gocui.KeyAltEnter } matched := true diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 272d63a88..41c61e07f 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -53,8 +53,9 @@ var keyMapReversed = map[gocui.Key]string{ gocui.KeyArrowDown: "▼", gocui.KeyArrowLeft: "◄", gocui.KeyArrowRight: "►", - gocui.KeyTab: "tab", // ctrl+i - gocui.KeyEnter: "enter", // ctrl+m + gocui.KeyTab: "tab", // ctrl+i + gocui.KeyEnter: "enter", // ctrl+m + gocui.KeyAltEnter: "alt+enter", gocui.KeyEsc: "esc", // ctrl+[, ctrl+3 gocui.KeyBackspace: "backspace", // ctrl+h gocui.KeyCtrlSpace: "ctrl+space", // ctrl+~, ctrl+2 @@ -133,6 +134,7 @@ var keymap = map[string]interface{}{ "": gocui.KeyBackspace, "": gocui.KeyTab, "": gocui.KeyEnter, + "": gocui.KeyAltEnter, "": gocui.KeyEsc, "": gocui.KeySpace, "": gocui.KeyF1, diff --git a/vendor/github.com/jesseduffield/gocui/edit.go b/vendor/github.com/jesseduffield/gocui/edit.go index f5844da47..f30d4bf0d 100644 --- a/vendor/github.com/jesseduffield/gocui/edit.go +++ b/vendor/github.com/jesseduffield/gocui/edit.go @@ -5,6 +5,8 @@ package gocui import ( + "unicode" + "github.com/go-errors/errors" "github.com/mattn/go-runewidth" @@ -53,12 +55,8 @@ func simpleEditor(v *View, key Key, ch rune, mod Modifier) bool { v.MoveCursor(-1, 0, false) case key == KeyArrowRight: v.MoveCursor(1, 0, false) - case key == KeyTab: + case key == KeyEnter: v.EditNewLine() - case key == KeySpace: - v.EditWrite(' ') - case key == KeyInsert: - v.Overwrite = !v.Overwrite case key == KeyCtrlU: v.EditDeleteToStartOfLine() case key == KeyCtrlA: @@ -66,12 +64,12 @@ func simpleEditor(v *View, key Key, ch rune, mod Modifier) bool { case key == KeyCtrlE: v.EditGotoToEndOfLine() matched = true + + // TODO: see if we need all three of these conditions: maybe the final one is sufficient + case ch != 0 && mod == 0 && unicode.IsPrint(ch): + v.EditWrite(ch) default: - if ch != 0 && mod == 0 { - v.EditWrite(ch) - } else { - matched = false - } + matched = false } return matched diff --git a/vendor/github.com/jesseduffield/gocui/keybinding.go b/vendor/github.com/jesseduffield/gocui/keybinding.go index 813ebae70..95857656e 100644 --- a/vendor/github.com/jesseduffield/gocui/keybinding.go +++ b/vendor/github.com/jesseduffield/gocui/keybinding.go @@ -297,7 +297,8 @@ const ( // In tcell, these are not keys per se. But in gocui we have them // mapped to the keys so we have to use placeholder keys. - MouseLeft = Key(tcell.KeyF63) // arbitrary assignments + KeyAltEnter = Key(tcell.KeyF64) // arbitrary assignments + MouseLeft = Key(tcell.KeyF63) MouseRight = Key(tcell.KeyF62) MouseMiddle = Key(tcell.KeyF61) MouseRelease = Key(tcell.KeyF60) diff --git a/vendor/github.com/jesseduffield/gocui/tcell_driver.go b/vendor/github.com/jesseduffield/gocui/tcell_driver.go index a7faed903..1bc4c1217 100644 --- a/vendor/github.com/jesseduffield/gocui/tcell_driver.go +++ b/vendor/github.com/jesseduffield/gocui/tcell_driver.go @@ -151,7 +151,14 @@ func pollEvent() GocuiEvent { // - shift - will be translated to the final code of rune // - ctrl - is translated in the key mod = 0 + } else if mod == tcell.ModAlt && k == tcell.KeyEnter { + // for the sake of convenience I'm having a KeyAltEnter key. I will likely + // regret this laziness in the future. We're arbitrarily mapping that to tcell's + // KeyF64. + mod = 0 + k = tcell.KeyF64 } + return GocuiEvent{ Type: eventKey, Key: Key(k), diff --git a/vendor/modules.txt b/vendor/modules.txt index 23dfa0005..6bfcac748 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -149,7 +149,7 @@ github.com/jesseduffield/go-git/v5/utils/merkletrie/filesystem github.com/jesseduffield/go-git/v5/utils/merkletrie/index github.com/jesseduffield/go-git/v5/utils/merkletrie/internal/frame github.com/jesseduffield/go-git/v5/utils/merkletrie/noder -# github.com/jesseduffield/gocui v0.3.1-0.20210402033412-1238f910f001 +# github.com/jesseduffield/gocui v0.3.1-0.20210402040718-77a1b9631715 ## explicit github.com/jesseduffield/gocui # github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe