Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show message when next section is missing #189

Merged
merged 3 commits into from
May 16, 2022
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
69 changes: 41 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -484,32 +484,35 @@ Usage:
ov [flags]

Flags:
-C, --alternate-rows alternately change the line color
-i, --case-sensitive case-sensitive in search
-d, --column-delimiter string column delimiter (default ",")
-c, --column-mode column mode
--completion string generate completion script [bash|zsh|fish|powershell]
--config string config file (default is $HOME/.ov.yaml)
--debug debug mode
--disable-mouse disable mouse support
-e, --exec exec command
-X, --exit-write output the current screen when exiting
-a, --exit-write-after int NUM after the current lines when exiting
-b, --exit-write-before int NUM before the current lines when exiting
-A, --follow-all follow all
-f, --follow-mode follow mode
-H, --header int number of header rows to fix
-h, --help help for ov
--help-key display key bind information
--incsearch incremental search (default true)
-n, --line-number line number mode
-F, --quit-if-one-screen quit if the output fits on one screen
--regexp-search regular expression search
--skip-lines int skip the number of lines
-x, --tab-width int tab stop width (default 8)
-v, --version display version information
-T, --watch int watch mode interval
-w, --wrap wrap mode (default true)
-C, --alternate-rows alternately change the line color
-i, --case-sensitive case-sensitive in search
-d, --column-delimiter string column delimiter (default ",")
-c, --column-mode column mode
--completion string generate completion script [bash|zsh|fish|powershell]
--config string config file (default is $HOME/.ov.yaml)
--debug debug mode
--disable-mouse disable mouse support
-e, --exec exec command
-X, --exit-write output the current screen when exiting
-a, --exit-write-after int NUM after the current lines when exiting
-b, --exit-write-before int NUM before the current lines when exiting
-A, --follow-all follow all
-f, --follow-mode follow mode
--follow-section follow section
-H, --header int number of header rows to fix
-h, --help help for ov
--help-key display key bind information
--incsearch incremental search (default true)
-n, --line-number line number mode
-F, --quit-if-one-screen quit if the output fits on one screen
--regexp-search regular expression search
--section-delimiter string section delimiter
--section-start int section start position
--skip-lines int skip the number of lines
-x, --tab-width int tab stop width (default 8)
-v, --version display version information
-T, --watch int watch mode interval
-w, --wrap wrap mode (default true)
```

It can also be changed after startup.
Expand All @@ -522,8 +525,8 @@ It can also be changed after startup.
[Q] * output screen and quit
[ctrl+q] * set output screen and quit
[ctrl+z] * suspend
[h], [ctrl+f1], [ctrl+alt+c] * display help screen
[ctrl+f2], [ctrl+alt+e] * display log screen
[h], [ctrl+F1], [ctrl+alt+c] * display help screen
[ctrl+F2], [ctrl+alt+e] * display log screen
[ctrl+l] * screen sync
[ctrl+f] * follow mode toggle
[ctrl+a] * follow all mode toggle
Expand Down Expand Up @@ -581,6 +584,15 @@ It can also be changed after startup.
[ctrl+s] * number of skip lines
[t] * TAB width

Section

[alt+d] * section delimiter regular expression
[ctrl+F3], [alt+s] * section start position
[space] * next section
[^] * previous section
[9] * last section
[F2] * follow section mode toggle

Close and reload

[ctrl+F9], [ctrl+alt+s] * close file
Expand Down Expand Up @@ -609,6 +621,7 @@ You can customize the following items.
* StyleSearchHighlight
* StyleColumnHighlight
* StyleMarkLine
* StyleSectionLine

Specifies the color name for the foreground and background [colors](https://pkg.go.dev/github.com/gdamore/tcell/v2#pkg-constants).
Specify bool values for Reverse, Bold, Blink, Dim, Italic, and Underline.
Expand Down
16 changes: 15 additions & 1 deletion ov-less.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ StyleColumnHighlight:
Reverse: true
StyleMarkLine:
Background: "darkgoldenrod"
StyleSectionLine:
Background: "green"

# Keybind
# Special key
Expand Down Expand Up @@ -71,6 +73,8 @@ KeyBind:
- "F"
follow_all:
- "ctrl+a"
follow_section:
- "F2"
help:
- "h"
- "ctrl+alt+c"
Expand Down Expand Up @@ -114,7 +118,6 @@ KeyBind:
page_down:
- "PageDown"
- "ctrl+v"
- "space"
- "alt+space"
- "f"
- "z"
Expand All @@ -124,6 +127,17 @@ KeyBind:
page_half_down:
- "d"
- "ctrl+d"
section_mode:
- "alt+d"
section_start:
- "ctrl+F3"
- "alt+s"
next_section:
- "space"
last_section:
- "9"
previous_section:
- "^"
mark:
- "m"
remove_mark:
Expand Down
15 changes: 14 additions & 1 deletion ov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ StyleColumnHighlight:
StyleMarkLine:
Background: "darkgoldenrod"
StyleSectionLine:
Background: "gray"
Background: "green"

# Keybind
# Special key
Expand Down Expand Up @@ -75,6 +75,8 @@ KeyBind:
- "ctrl+f"
follow_all:
- "ctrl+a"
follow_section:
- "F2"
help:
- "h"
- "ctrl+alt+c"
Expand Down Expand Up @@ -111,6 +113,17 @@ KeyBind:
- "ctrl+u"
page_half_down:
- "ctrl+d"
section_mode:
- "alt+d"
section_start:
- "ctrl+F3"
- "alt+s"
next_section:
- "space"
last_section:
- "9"
previous_section:
- "^"
mark:
- "m"
remove_mark:
Expand Down
2 changes: 1 addition & 1 deletion oviewer/keybind.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const (
actionMoveHfUp = "page_half_up"
actionMoveHfDn = "page_half_down"
actionSection = "section_mode"
actionSectionStart = "section_position_mode"
actionSectionStart = "section_start"
actionNextSection = "next_section"
actionLastSection = "last_section"
actionPrevSection = "previous_section"
Expand Down
7 changes: 4 additions & 3 deletions oviewer/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ func (root *Root) nextSction() {
defer ctx.Done()
n, err := m.SearchLine(ctx, searcher, num)
if err != nil {
// Last section or no section.
root.setMessage("no next section")
root.movePgDn()
return
}
Expand Down Expand Up @@ -328,6 +330,7 @@ func (root *Root) lastSectionPos() int {
root.resetSelect()

m := root.Doc
top := m.topLN + m.firstLine()
// +1 to avoid if the bottom line is a session delimiter.
num := m.BufEndNum() - 2
searcher := NewSearcher(root.Doc.SectionDelimiter, root.Doc.SectionDelimiterReg, true, true)
Expand All @@ -338,14 +341,12 @@ func (root *Root) lastSectionPos() int {
log.Printf("last section:%v", err)
return 0
}
if n == num {
if top > n {
// Does not move if section starts at the bottom line.
// (it is already the last section).
return 0
}

bottom := m.BufEndNum() - m.latestNum
top := m.topLN
root.moveLine((n - root.Doc.firstLine()) + root.Doc.SectionStartPosition)
if top == 0 {
return 0
Expand Down
2 changes: 1 addition & 1 deletion oviewer/oviewer.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func NewConfig() Config {
Background: "darkgoldenrod",
},
StyleSectionLine: OVStyle{
Background: "#ff",
Background: "green",
},
General: general{
TabWidth: 8,
Expand Down