mirror of
				https://github.com/jesseduffield/lazygit.git
				synced 2025-10-30 23:57:43 +02:00 
			
		
		
		
	bump gocui to get contexts on keybindings
This commit is contained in:
		
							
								
								
									
										2
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.mod
									
									
									
									
									
								
							| @@ -11,7 +11,7 @@ require ( | ||||
| 	github.com/golang/protobuf v1.3.2 // indirect | ||||
| 	github.com/google/go-cmp v0.3.1 // indirect | ||||
| 	github.com/integrii/flaggy v1.3.0 | ||||
| 	github.com/jesseduffield/gocui v0.3.1-0.20191110053728-01cdcccd0508 | ||||
| 	github.com/jesseduffield/gocui v0.3.1-0.20191116013947-b13bda319532 | ||||
| 	github.com/jesseduffield/pty v1.2.1 | ||||
| 	github.com/jesseduffield/rollrus v0.0.0-20190701125922-dd028cb0bfd7 | ||||
| 	github.com/jesseduffield/termbox-go v0.0.0-20190630083001-9dd53af7214e // indirect | ||||
|   | ||||
							
								
								
									
										4
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								go.sum
									
									
									
									
									
								
							| @@ -75,8 +75,8 @@ github.com/integrii/flaggy v1.3.0 h1:8I5Qqz22C6+EwUqJuaN5ITh77obI8VSg6RwYLe2VB7o | ||||
| github.com/integrii/flaggy v1.3.0/go.mod h1:tnTxHeTJbah0gQ6/K0RW0J7fMUBk9MCF5blhm43LNpI= | ||||
| github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= | ||||
| github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= | ||||
| github.com/jesseduffield/gocui v0.3.1-0.20191110053728-01cdcccd0508 h1:8CPQLUe+0QXxnbnUfaMxh1UGxg3rYCqCvbxecC9rrIY= | ||||
| github.com/jesseduffield/gocui v0.3.1-0.20191110053728-01cdcccd0508/go.mod h1:2RtZznzYKt8RLRwvFiSkXjU0Ei8WwHdubgnlaYH47dw= | ||||
| github.com/jesseduffield/gocui v0.3.1-0.20191116013947-b13bda319532 h1:V1Lk2rm5/p27NjnlF2ezzkxDaisHNcveMNueSD7RYgs= | ||||
| github.com/jesseduffield/gocui v0.3.1-0.20191116013947-b13bda319532/go.mod h1:2RtZznzYKt8RLRwvFiSkXjU0Ei8WwHdubgnlaYH47dw= | ||||
| github.com/jesseduffield/pty v1.2.1 h1:7xYBiwNH0PpWqC8JmvrPq1a/ksNqyCavzWu9pbBGYWI= | ||||
| github.com/jesseduffield/pty v1.2.1/go.mod h1:7jlS40+UhOqkZJDIG1B/H21xnuET/+fvbbnHCa8wSIo= | ||||
| github.com/jesseduffield/roll v0.0.0-20190629104057-695be2e62b00 h1:+JaOkfBNYQYlGD7dgru8mCwYNEc5tRRI8mThlVANhSM= | ||||
|   | ||||
							
								
								
									
										4
									
								
								vendor/github.com/jesseduffield/gocui/gui.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/jesseduffield/gocui/gui.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -295,14 +295,14 @@ func (g *Gui) CurrentView() *View { | ||||
| // SetKeybinding creates a new keybinding. If viewname equals to "" | ||||
| // (empty string) then the keybinding will apply to all views. key must | ||||
| // be a rune or a Key. | ||||
| func (g *Gui) SetKeybinding(viewname string, key interface{}, mod Modifier, handler func(*Gui, *View) error) error { | ||||
| func (g *Gui) SetKeybinding(viewname string, contexts []string, key interface{}, mod Modifier, handler func(*Gui, *View) error) error { | ||||
| 	var kb *keybinding | ||||
|  | ||||
| 	k, ch, err := getKey(key) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	kb = newKeybinding(viewname, k, ch, mod, handler) | ||||
| 	kb = newKeybinding(viewname, contexts, k, ch, mod, handler) | ||||
| 	g.keybindings = append(g.keybindings, kb) | ||||
| 	return nil | ||||
| } | ||||
|   | ||||
							
								
								
									
										20
									
								
								vendor/github.com/jesseduffield/gocui/keybinding.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										20
									
								
								vendor/github.com/jesseduffield/gocui/keybinding.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -9,6 +9,7 @@ import "github.com/jesseduffield/termbox-go" | ||||
| // Keybidings are used to link a given key-press event with a handler. | ||||
| type keybinding struct { | ||||
| 	viewName string | ||||
| 	contexts []string | ||||
| 	key      Key | ||||
| 	ch       rune | ||||
| 	mod      Modifier | ||||
| @@ -16,9 +17,10 @@ type keybinding struct { | ||||
| } | ||||
|  | ||||
| // newKeybinding returns a new Keybinding object. | ||||
| func newKeybinding(viewname string, key Key, ch rune, mod Modifier, handler func(*Gui, *View) error) (kb *keybinding) { | ||||
| func newKeybinding(viewname string, contexts []string, key Key, ch rune, mod Modifier, handler func(*Gui, *View) error) (kb *keybinding) { | ||||
| 	kb = &keybinding{ | ||||
| 		viewName: viewname, | ||||
| 		contexts: contexts, | ||||
| 		key:      key, | ||||
| 		ch:       ch, | ||||
| 		mod:      mod, | ||||
| @@ -32,7 +34,7 @@ func (kb *keybinding) matchKeypress(key Key, ch rune, mod Modifier) bool { | ||||
| 	return kb.key == key && kb.ch == ch && kb.mod == mod | ||||
| } | ||||
|  | ||||
| // matchView returns if the keybinding matches the current view. | ||||
| // matchView returns if the keybinding matches the current view (and the view's context) | ||||
| func (kb *keybinding) matchView(v *View) bool { | ||||
| 	// if the user is typing in a field, ignore char keys | ||||
| 	if v == nil { | ||||
| @@ -41,7 +43,19 @@ func (kb *keybinding) matchView(v *View) bool { | ||||
| 	if v.Editable == true && kb.ch != 0 { | ||||
| 		return false | ||||
| 	} | ||||
| 	return kb.viewName == v.name | ||||
| 	if kb.viewName != v.name { | ||||
| 		return false | ||||
| 	} | ||||
| 	// if the keybinding doesn't specify contexts, it applies for all contexts | ||||
| 	if len(kb.contexts) == 0 { | ||||
| 		return true | ||||
| 	} | ||||
| 	for _, context := range kb.contexts { | ||||
| 		if context == v.Context { | ||||
| 			return true | ||||
| 		} | ||||
| 	} | ||||
| 	return false | ||||
| } | ||||
|  | ||||
| // Key represents special keys or keys combinations. | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/jesseduffield/gocui/view.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/jesseduffield/gocui/view.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -103,6 +103,8 @@ type View struct { | ||||
|  | ||||
| 	// ParentView is the view which catches events bubbled up from the given view if there's no matching handler | ||||
| 	ParentView *View | ||||
|  | ||||
| 	Context string // this is for assigning keybindings to a view only in certain contexts | ||||
| } | ||||
|  | ||||
| type viewLine struct { | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/modules.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/modules.txt
									
									
									
									
										vendored
									
									
								
							| @@ -32,7 +32,7 @@ github.com/hashicorp/hcl/json/token | ||||
| github.com/integrii/flaggy | ||||
| # github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 | ||||
| github.com/jbenet/go-context/io | ||||
| # github.com/jesseduffield/gocui v0.3.1-0.20191110053728-01cdcccd0508 | ||||
| # github.com/jesseduffield/gocui v0.3.1-0.20191116013947-b13bda319532 | ||||
| github.com/jesseduffield/gocui | ||||
| # github.com/jesseduffield/pty v1.2.1 | ||||
| github.com/jesseduffield/pty | ||||
|   | ||||
		Reference in New Issue
	
	Block a user