From 5f2aeeba0fe87f1b0ee53bfc29c7ba15ff90ea46 Mon Sep 17 00:00:00 2001 From: Noboru Saito Date: Sun, 29 Oct 2023 09:04:37 +0900 Subject: [PATCH] Changed scroll to hscroll --- main.go | 4 ++-- oviewer/help.go | 1 + oviewer/mouse.go | 4 ++-- oviewer/move.go | 6 ++---- oviewer/oviewer.go | 16 ++++++++-------- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/main.go b/main.go index 815e1de4..b1003d1c 100644 --- a/main.go +++ b/main.go @@ -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") diff --git a/oviewer/help.go b/oviewer/help.go index 5f8b0077..0c3d974d 100644 --- a/oviewer/help.go +++ b/oviewer/help.go @@ -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 { diff --git a/oviewer/mouse.go b/oviewer/mouse.go index 239dee55..87934e6e 100644 --- a/oviewer/mouse.go +++ b/oviewer/mouse.go @@ -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) } } @@ -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) } } diff --git a/oviewer/move.go b/oviewer/move.go index 6845858e..b58690e1 100644 --- a/oviewer/move.go +++ b/oviewer/move.go @@ -1,7 +1,6 @@ package oviewer import ( - "log" "strconv" ) @@ -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. diff --git a/oviewer/oviewer.go b/oviewer/oviewer.go index 43be8101..44e4617e 100644 --- a/oviewer/oviewer.go +++ b/oviewer/oviewer.go @@ -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. @@ -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 @@ -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 }