mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-15 01:34:26 +02:00
fix editor
This commit is contained in:
committed by
github-actions[bot]
parent
7564e506b5
commit
345c90ac05
44
vendor/github.com/jesseduffield/gocui/view.go
generated
vendored
44
vendor/github.com/jesseduffield/gocui/view.go
generated
vendored
@ -6,6 +6,7 @@ package gocui
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
"sync"
|
||||
@ -158,6 +159,8 @@ type View struct {
|
||||
// KeybindOnEdit should be set to true when you want to execute keybindings even when the view is editable
|
||||
// (this is usually not the case)
|
||||
KeybindOnEdit bool
|
||||
|
||||
TextArea *TextArea
|
||||
}
|
||||
|
||||
// call this in the event of a view resize, or if you want to render new content
|
||||
@ -340,6 +343,7 @@ func newView(name string, x0, y0, x1, y1 int, mode OutputMode) *View {
|
||||
outMode: mode,
|
||||
ei: newEscapeInterpreter(mode),
|
||||
searcher: &searcher{},
|
||||
TextArea: &TextArea{},
|
||||
}
|
||||
|
||||
v.FgColor, v.BgColor = ColorDefault, ColorDefault
|
||||
@ -1119,3 +1123,43 @@ func (v *View) SelectedPoint() (int, int) {
|
||||
ox, oy := v.Origin()
|
||||
return cx + ox, cy + oy
|
||||
}
|
||||
|
||||
func (v *View) RenderTextArea() {
|
||||
v.Clear()
|
||||
fmt.Fprint(v, v.TextArea.GetContent())
|
||||
cursorX, cursorY := v.TextArea.GetCursorXY()
|
||||
prevOriginX, prevOriginY := v.Origin()
|
||||
width, height := v.Size()
|
||||
|
||||
frameAdjustment := 0
|
||||
if v.Frame {
|
||||
frameAdjustment = -1
|
||||
}
|
||||
newViewCursorX, newOriginX := updatedCursorAndOrigin(prevOriginX, width+frameAdjustment, cursorX)
|
||||
newViewCursorY, newOriginY := updatedCursorAndOrigin(prevOriginY, height+frameAdjustment, cursorY)
|
||||
|
||||
_ = v.SetCursor(newViewCursorX, newViewCursorY)
|
||||
_ = v.SetOrigin(newOriginX, newOriginY)
|
||||
}
|
||||
|
||||
func updatedCursorAndOrigin(prevOrigin int, size int, cursor int) (int, int) {
|
||||
var newViewCursor int
|
||||
newOrigin := prevOrigin
|
||||
|
||||
if cursor > prevOrigin+size {
|
||||
newOrigin = cursor - size
|
||||
newViewCursor = size
|
||||
} else if cursor < prevOrigin {
|
||||
newOrigin = cursor
|
||||
newViewCursor = 0
|
||||
} else {
|
||||
newViewCursor = cursor - prevOrigin
|
||||
}
|
||||
|
||||
return newViewCursor, newOrigin
|
||||
}
|
||||
|
||||
func (v *View) ClearTextArea() {
|
||||
v.TextArea.Clear()
|
||||
v.Clear()
|
||||
}
|
||||
|
Reference in New Issue
Block a user