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
6 changes: 6 additions & 0 deletions oviewer/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -972,10 +972,16 @@ func (m *Document) isValidColumn(cursor int) error {

// setPauseFollow sets pauseFollow to true if sticky follow is not disabled.
func (root *Root) setPauseFollow() {
// If sticky follow is disabled, do nothing.
if root.Config.DisableStickyFollow {
return
}
// If already paused, do nothing.
if root.Doc.pauseFollow {
return
}
if root.FollowAll || root.Doc.FollowMode || root.Doc.FollowSection {
root.Doc.pauseFollow = true
root.Doc.pauseLastNum = max(root.Doc.BufEndNum()-1, 0)
}
}
2 changes: 2 additions & 0 deletions oviewer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ type StyleConfig struct {
SelectActive *OVStyle
// SelectCopied is the style that applies to the text that has been copied to clipboard.
SelectCopied *OVStyle
// PauseLine is the style that applies to the line where follow mode is paused.
PauseLine *OVStyle
}

// deprecatedStyleConfig is the old style setting.
Expand Down
2 changes: 2 additions & 0 deletions oviewer/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ type Document struct {
nonMatch bool
// pauseFollow indicates if follow mode is paused.
pauseFollow bool
// pauseFollowNum is the line number where follow mode was paused.
pauseLastNum int
// General is the General settings.
General General
}
Expand Down
3 changes: 3 additions & 0 deletions oviewer/draw.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ func (root *Root) coordinatesStyle(lN int, y int) {
if root.Doc.jumpTargetHeight != 0 && root.Doc.headerHeight+root.Doc.jumpTargetHeight == y {
root.applyStyleToLine(y, root.Doc.Style.JumpTargetLine)
}
if root.Doc.pauseFollow && lN == root.Doc.pauseLastNum {
root.applyStyleToLine(y, root.Doc.Style.PauseLine)
}
}

// applyStyleToAlternate applies from beginning to end of line.
Expand Down
8 changes: 8 additions & 0 deletions oviewer/oviewer.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ type Style struct {
SelectActive OVStyle
// SelectCopied is the style that applies to the text that has been copied to clipboard.
SelectCopied OVStyle
// PauseLine is the style that applies to the line where follow mode is paused.
PauseLine OVStyle
}

var (
Expand Down Expand Up @@ -541,6 +543,9 @@ func NewStyle() Style {
SelectCopied: OVStyle{
Background: "slategrey",
},
PauseLine: OVStyle{
Background: "#663333",
},
}
}

Expand Down Expand Up @@ -1208,6 +1213,9 @@ func updateRuntimeStyle(src Style, dst StyleConfig) Style {
if dst.SelectCopied != nil {
src.SelectCopied = *dst.SelectCopied
}
if dst.PauseLine != nil {
src.PauseLine = *dst.PauseLine
}
return src
}

Expand Down
2 changes: 2 additions & 0 deletions oviewer/oviewer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,7 @@ func Test_updateRuntimeStyle(t *testing.T) {
VerticalHeaderBorder: &boldStyle,
SelectActive: &blueStyle,
SelectCopied: &blueStyle,
PauseLine: &blueStyle,
},
},
want: Style{
Expand All @@ -1352,6 +1353,7 @@ func Test_updateRuntimeStyle(t *testing.T) {
VerticalHeaderBorder: boldStyle,
SelectActive: blueStyle,
SelectCopied: blueStyle,
PauseLine: blueStyle,
},
},
}
Expand Down
Loading