mirror of
https://github.com/git-chglog/git-chglog.git
synced 2026-01-23 10:25:24 +00:00
feat: Supports vim like j/k keybind with item selection of --init
This commit is contained in:
parent
dd838e8675
commit
790a2e6574
6 changed files with 14 additions and 11 deletions
6
Gopkg.lock
generated
6
Gopkg.lock
generated
|
|
@ -74,8 +74,8 @@
|
|||
"core",
|
||||
"terminal"
|
||||
]
|
||||
revision = "0aa8b6a162b391fe2d95648b7677d1d6ac2090a6"
|
||||
version = "v1.4.1"
|
||||
revision = "9f89d9dd66613216993dc300f9f3dbae9c3c9bda"
|
||||
version = "v1.4.2"
|
||||
|
||||
[[projects]]
|
||||
name = "gopkg.in/kyokomi/emoji.v1"
|
||||
|
|
@ -92,6 +92,6 @@
|
|||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "0be1d1c2f1a9b1c1f1d63ad065141425b62687efb378f6657b088ddf993c3882"
|
||||
inputs-digest = "da532fb70b3049dffe6ae9f73b3f0a742452639096a325ac5d2400be6ad0559e"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
[[constraint]]
|
||||
name = "gopkg.in/AlecAivazis/survey.v1"
|
||||
version = "1.4.1"
|
||||
version = "1.4.2"
|
||||
|
||||
[[constraint]]
|
||||
name = "gopkg.in/kyokomi/emoji.v1"
|
||||
|
|
|
|||
4
vendor/gopkg.in/AlecAivazis/survey.v1/multiselect.go
generated
vendored
4
vendor/gopkg.in/AlecAivazis/survey.v1/multiselect.go
generated
vendored
|
|
@ -61,7 +61,7 @@ var MultiSelectQuestionTemplate = `
|
|||
|
||||
// OnChange is called on every keypress.
|
||||
func (m *MultiSelect) OnChange(line []rune, pos int, key rune) (newLine []rune, newPos int, ok bool) {
|
||||
if key == terminal.KeyArrowUp {
|
||||
if key == terminal.KeyArrowUp || key == 'k' {
|
||||
// if we are at the top of the list
|
||||
if m.selectedIndex == 0 {
|
||||
// go to the bottom
|
||||
|
|
@ -70,7 +70,7 @@ func (m *MultiSelect) OnChange(line []rune, pos int, key rune) (newLine []rune,
|
|||
// decrement the selected index
|
||||
m.selectedIndex--
|
||||
}
|
||||
} else if key == terminal.KeyArrowDown {
|
||||
} else if key == terminal.KeyArrowDown || key == 'j' {
|
||||
// if we are at the bottom of the list
|
||||
if m.selectedIndex == len(m.Options)-1 {
|
||||
// start at the top
|
||||
|
|
|
|||
8
vendor/gopkg.in/AlecAivazis/survey.v1/select.go
generated
vendored
8
vendor/gopkg.in/AlecAivazis/survey.v1/select.go
generated
vendored
|
|
@ -61,8 +61,8 @@ func (s *Select) OnChange(line []rune, pos int, key rune) (newLine []rune, newPo
|
|||
// if the user pressed the enter key
|
||||
if key == terminal.KeyEnter {
|
||||
return []rune(s.Options[s.selectedIndex]), 0, true
|
||||
// if the user pressed the up arrow
|
||||
} else if key == terminal.KeyArrowUp {
|
||||
// if the user pressed the up arrow or 'k' to emulate vim
|
||||
} else if key == terminal.KeyArrowUp || key == 'k' {
|
||||
s.useDefault = false
|
||||
|
||||
// if we are at the top of the list
|
||||
|
|
@ -73,8 +73,8 @@ func (s *Select) OnChange(line []rune, pos int, key rune) (newLine []rune, newPo
|
|||
// otherwise we are not at the top of the list so decrement the selected index
|
||||
s.selectedIndex--
|
||||
}
|
||||
// if the user pressed down and there is room to move
|
||||
} else if key == terminal.KeyArrowDown {
|
||||
// if the user pressed down or 'j' to emulate vim
|
||||
} else if key == terminal.KeyArrowDown || key == 'j' {
|
||||
s.useDefault = false
|
||||
// if we are at the bottom of the list
|
||||
if s.selectedIndex == len(s.Options)-1 {
|
||||
|
|
|
|||
0
vendor/gopkg.in/AlecAivazis/survey.v1/terminal/LICENSE.txt
generated
vendored
Normal file
0
vendor/gopkg.in/AlecAivazis/survey.v1/terminal/LICENSE.txt
generated
vendored
Normal file
5
vendor/gopkg.in/AlecAivazis/survey.v1/validate.go
generated
vendored
5
vendor/gopkg.in/AlecAivazis/survey.v1/validate.go
generated
vendored
|
|
@ -8,8 +8,11 @@ import (
|
|||
|
||||
// Required does not allow an empty value
|
||||
func Required(val interface{}) error {
|
||||
// the reflect value of the result
|
||||
value := reflect.ValueOf(val)
|
||||
|
||||
// if the value passed in is the zero value of the appropriate type
|
||||
if isZero(reflect.ValueOf(val)) {
|
||||
if isZero(value) && value.Kind() != reflect.Bool {
|
||||
return errors.New("Value is required")
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue