Skip to content

Commit

Permalink
Changed scroll to hscroll
Browse files Browse the repository at this point in the history
  • Loading branch information
noborus committed Oct 29, 2023
1 parent 8dbce7b commit 5f2aeeb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ func init() {
rootCmd.PersistentFlags().StringP("jump-target", "j", "", "jump target `[int|int%|.int|'section']`")
_ = viper.BindPFlag("general.JumpTarget", rootCmd.PersistentFlags().Lookup("jump-target"))

rootCmd.PersistentFlags().StringP("scroll-width", "", ".1", "width to scroll horizontally `[int|int%|.int]`")
_ = viper.BindPFlag("general.ScrollWidth", rootCmd.PersistentFlags().Lookup("scroll-width"))
rootCmd.PersistentFlags().StringP("hscroll-width", "", "10%", "width to scroll horizontally `[int|int%|.int]`")
_ = viper.BindPFlag("general.HScrollWidth", rootCmd.PersistentFlags().Lookup("hscroll-width"))

// Config
rootCmd.PersistentFlags().BoolP("disable-mouse", "", false, "disable mouse support")
Expand Down
1 change: 1 addition & 0 deletions oviewer/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func NewHelp(k KeyBind) (*Document, error) {
m.store.eof = 1
m.preventReload = true
m.seekable = false
m.SectionHeader = true
m.setSectionDelimiter("\t")
atomic.StoreInt32(&m.closed, 1)
if err := m.ControlReader(helpStr, nil); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions oviewer/mouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (root *Root) wheelRight() {
if root.Doc.ColumnMode {
root.moveRightOne()
} else {
root.moveRight(root.Doc.ScrollWidthNum)
root.moveRight(root.Doc.HScrollWidthNum)
}
}

Expand All @@ -83,7 +83,7 @@ func (root *Root) wheelLeft() {
if root.Doc.ColumnMode {
root.moveLeftOne()
} else {
root.moveLeft(root.Doc.ScrollWidthNum)
root.moveLeft(root.Doc.HScrollWidthNum)
}
}

Expand Down
6 changes: 2 additions & 4 deletions oviewer/move.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package oviewer

import (
"log"
"strconv"
)

Expand Down Expand Up @@ -161,14 +160,13 @@ func (root *Root) moveRightOne() {
// Move to the width of the screen to the left.
// Called from a EventKey.
func (root *Root) moveWidthLeft() {
root.moveLeft(root.Doc.ScrollWidthNum)
root.moveLeft(root.Doc.HScrollWidthNum)
}

// Move to the width of the screen to the right.
// Called from a EventKey.
func (root *Root) moveWidthRight() {
log.Println("ScrollWidth", root.Doc.ScrollWidth)
root.moveRight(root.Doc.ScrollWidthNum)
root.moveRight(root.Doc.HScrollWidthNum)
}

// Move left by n amount.
Expand Down
16 changes: 8 additions & 8 deletions oviewer/oviewer.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ type general struct {
MarkStyleWidth int
// SectionStartPosition is a section start position.
SectionStartPosition int
// ScrollWidth is the horizontal scroll width.
ScrollWidth string
// ScrollWidthNum is the horizontal scroll width.
ScrollWidthNum int
// HScrollWidth is the horizontal scroll width.
HScrollWidth string
// HScrollWidthNum is the horizontal scroll width.
HScrollWidthNum int
// AlternateRows alternately style rows.
AlternateRows bool
// ColumnMode is column mode.
Expand Down Expand Up @@ -871,8 +871,8 @@ func mergeGeneral(src general, dst general) general {
if dst.JumpTarget != "" {
src.JumpTarget = dst.JumpTarget
}
if dst.ScrollWidth != "" {
src.ScrollWidth = dst.ScrollWidth
if dst.HScrollWidth != "" {
src.HScrollWidth = dst.HScrollWidth
}
if len(dst.MultiColorWords) > 0 {
src.MultiColorWords = dst.MultiColorWords
Expand All @@ -888,8 +888,8 @@ func (root *Root) prepareView() {
// Do not allow size 0.
root.scr.vWidth = max(root.scr.vWidth, 1)
root.scr.vHeight = max(root.scr.vHeight, 1)
num := int(math.Round(calculatePosition(root.scr.vWidth, root.Doc.ScrollWidth)))
root.Doc.ScrollWidthNum = max(num, 1)
num := int(math.Round(calculatePosition(root.scr.vWidth, root.Doc.HScrollWidth)))
root.Doc.HScrollWidthNum = max(num, 1)
root.scr.numbers = make([]LineNumber, root.scr.vHeight+1)
root.Doc.statusPos = root.scr.vHeight - statusLine
}
Expand Down

0 comments on commit 5f2aeeb

Please sign in to comment.