Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ov-less.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ General:
WrapMode: true
ColumnDelimiter: ","
MarkStyleWidth: 1
# HScrollWidth: 10%
# VScrollLines: 2
Prompt:
Normal:
# ShowFilename: true # Show the filename.
Expand Down
2 changes: 2 additions & 0 deletions ov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ General:
WrapMode: true
ColumnDelimiter: ","
MarkStyleWidth: 1
# HScrollWidth: 10%
# VScrollLines: 2
Prompt:
Normal:
# ShowFilename: true # Show the filename.
Expand Down
6 changes: 6 additions & 0 deletions oviewer/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type General struct {
HScrollWidth *string
// HScrollWidthNum is the horizontal scroll width as an integer (number of columns).
HScrollWidthNum *int
// VScrollLines is the number of lines to scroll with the mouse wheel.
VScrollLines *int
// RulerType is the ruler type (0: none, 1: relative, 2: absolute).
RulerType *RulerType
// AlternateRows alternately style rows.
Expand Down Expand Up @@ -190,6 +192,10 @@ func (g *General) SetHScrollWidthNum(num int) {
g.HScrollWidthNum = &num
}

func (g *General) SetVScrollLines(num int) {
g.VScrollLines = &num
}

// SetRulerType sets the ruler type.
func (g *General) SetRulerType(rtype RulerType) {
g.RulerType = &rtype
Expand Down
10 changes: 5 additions & 5 deletions oviewer/mouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ const (
)

var (
WheelScrollNum = 2 // WheelScrollNum is the number of lines to scroll with the mouse wheel.
ClickInterval = 500 * time.Millisecond // Double/triple click detection time
ClickDistance = 2 // Maximum allowed movement distance (in screen coordinates/cells) for double/triple click detection
ClickInterval = 500 * time.Millisecond // Double/triple click detection time
ClickDistance = 2 // Maximum allowed movement distance (in screen coordinates/cells) for double/triple click detection
)

// ClickState holds the state for click detection.
Expand Down Expand Up @@ -89,13 +88,14 @@ func (root *Root) mouseEvent(ctx context.Context, ev *tcell.EventMouse) {
// wheelUp moves the mouse wheel up.
func (root *Root) wheelUp(context.Context) {
root.setMessage("")
root.moveUp(WheelScrollNum)
root.moveUp(root.Doc.VScrollLines)
}

// wheelDown moves the mouse wheel down.
func (root *Root) wheelDown(context.Context) {
root.setMessage("")
root.moveDown(WheelScrollNum)
log.Println("vScrollLines:", root.Doc.VScrollLines)
root.moveDown(root.Doc.VScrollLines)
}

// wheelRight moves the mouse wheel right.
Expand Down
6 changes: 6 additions & 0 deletions oviewer/oviewer.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ type RunTimeSettings struct {
HScrollWidth string
// HScrollWidthNum is the horizontal scroll width.
HScrollWidthNum int
// VScrollLines is the number of lines to scroll with the mouse wheel.
VScrollLines int
// RulerType is the ruler type (0: none, 1: relative, 2: absolute).
RulerType RulerType
// AlternateRows alternately style rows.
Expand Down Expand Up @@ -480,6 +482,7 @@ func NewRunTimeSettings() RunTimeSettings {
OVPromptConfig: NewOVPromptConfig(),
Style: NewStyle(),
StatusLine: true,
VScrollLines: 2,
}
}

Expand Down Expand Up @@ -1057,6 +1060,9 @@ func updateRunTimeSettings(src RunTimeSettings, dst General) RunTimeSettings {
if dst.HScrollWidthNum != nil {
src.HScrollWidthNum = *dst.HScrollWidthNum
}
if dst.VScrollLines != nil {
src.VScrollLines = *dst.VScrollLines
}
if dst.RulerType != nil {
src.RulerType = *dst.RulerType
}
Expand Down
Loading