mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 21:05:48 +02:00
build: $ ./scripts/bump_gocui.sh
This commit is contained in:
parent
c8066c54b5
commit
1c82924307
15 changed files with 231 additions and 40 deletions
6
vendor/github.com/jesseduffield/gocui/edit.go
generated
vendored
6
vendor/github.com/jesseduffield/gocui/edit.go
generated
vendored
|
@ -49,10 +49,16 @@ func SimpleEditor(v *View, key Key, ch rune, mod Modifier) bool {
|
|||
v.TextArea.ToggleOverwrite()
|
||||
case key == KeyCtrlU:
|
||||
v.TextArea.DeleteToStartOfLine()
|
||||
case key == KeyCtrlK:
|
||||
v.TextArea.DeleteToEndOfLine()
|
||||
case key == KeyCtrlA || key == KeyHome:
|
||||
v.TextArea.GoToStartOfLine()
|
||||
case key == KeyCtrlE || key == KeyEnd:
|
||||
v.TextArea.GoToEndOfLine()
|
||||
case key == KeyCtrlW:
|
||||
v.TextArea.BackSpaceWord()
|
||||
case key == KeyCtrlY:
|
||||
v.TextArea.Yank()
|
||||
|
||||
// TODO: see if we need all three of these conditions: maybe the final one is sufficient
|
||||
case ch != 0 && mod == 0 && unicode.IsPrint(ch):
|
||||
|
|
64
vendor/github.com/jesseduffield/gocui/text_area.go
generated
vendored
64
vendor/github.com/jesseduffield/gocui/text_area.go
generated
vendored
|
@ -1,11 +1,21 @@
|
|||
package gocui
|
||||
|
||||
import "github.com/mattn/go-runewidth"
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/mattn/go-runewidth"
|
||||
)
|
||||
|
||||
const (
|
||||
WHITESPACES = " \t"
|
||||
WORD_SEPARATORS = "*?_+-.[]~=/&;!#$%^(){}<>"
|
||||
)
|
||||
|
||||
type TextArea struct {
|
||||
content []rune
|
||||
cursor int
|
||||
overwrite bool
|
||||
clipboard string
|
||||
}
|
||||
|
||||
func (self *TextArea) TypeRune(r rune) {
|
||||
|
@ -92,10 +102,25 @@ func (self *TextArea) DeleteToStartOfLine() {
|
|||
// otherwise, you delete everything up to the start of the current line, without
|
||||
// deleting the newline character
|
||||
newlineIndex := self.closestNewlineOnLeft()
|
||||
self.clipboard = string(self.content[newlineIndex+1 : self.cursor])
|
||||
self.content = append(self.content[:newlineIndex+1], self.content[self.cursor:]...)
|
||||
self.cursor = newlineIndex + 1
|
||||
}
|
||||
|
||||
func (self *TextArea) DeleteToEndOfLine() {
|
||||
if self.atEnd() {
|
||||
return
|
||||
}
|
||||
if self.atLineEnd() {
|
||||
self.content = append(self.content[:self.cursor], self.content[self.cursor+1:]...)
|
||||
return
|
||||
}
|
||||
|
||||
lineEndIndex := self.closestNewlineOnRight()
|
||||
self.clipboard = string(self.content[self.cursor:lineEndIndex])
|
||||
self.content = append(self.content[:self.cursor], self.content[lineEndIndex:]...)
|
||||
}
|
||||
|
||||
func (self *TextArea) GoToStartOfLine() {
|
||||
if self.atLineStart() {
|
||||
return
|
||||
|
@ -142,6 +167,43 @@ func (self *TextArea) atLineStart() bool {
|
|||
(len(self.content) > self.cursor-1 && self.content[self.cursor-1] == '\n')
|
||||
}
|
||||
|
||||
func (self *TextArea) atLineEnd() bool {
|
||||
return self.atEnd() ||
|
||||
(len(self.content) > self.cursor && self.content[self.cursor] == '\n')
|
||||
}
|
||||
|
||||
func (self *TextArea) BackSpaceWord() {
|
||||
if self.cursor == 0 {
|
||||
return
|
||||
}
|
||||
if self.atLineStart() {
|
||||
self.BackSpaceChar()
|
||||
return
|
||||
}
|
||||
|
||||
right := self.cursor
|
||||
for !self.atLineStart() && strings.ContainsRune(WHITESPACES, self.content[self.cursor-1]) {
|
||||
self.cursor--
|
||||
}
|
||||
separators := false
|
||||
for !self.atLineStart() && strings.ContainsRune(WORD_SEPARATORS, self.content[self.cursor-1]) {
|
||||
self.cursor--
|
||||
separators = true
|
||||
}
|
||||
if !separators {
|
||||
for !self.atLineStart() && !strings.ContainsRune(WHITESPACES+WORD_SEPARATORS, self.content[self.cursor-1]) {
|
||||
self.cursor--
|
||||
}
|
||||
}
|
||||
|
||||
self.clipboard = string(self.content[self.cursor:right])
|
||||
self.content = append(self.content[:self.cursor], self.content[right:]...)
|
||||
}
|
||||
|
||||
func (self *TextArea) Yank() {
|
||||
self.TypeString(self.clipboard)
|
||||
}
|
||||
|
||||
func (self *TextArea) GetCursorXY() (int, int) {
|
||||
cursorX := 0
|
||||
cursorY := 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue