Skip to content

Commit

Permalink
Merge pull request #619 from noborus/config-shrink
Browse files Browse the repository at this point in the history
Can change the character of "shrink"
  • Loading branch information
noborus authored Sep 5, 2024
2 parents f235903 + 1af4493 commit 80ab692
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
2 changes: 2 additions & 0 deletions ov-less.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Prompt:
# InvertColor: true # Invert the color of the prompt.
# ProcessOfCount: true # Show the process of count.

# ShrinkChar: '…' # Characters displayed when the column is shrinking.

General:
TabWidth: 4
Header: 0
Expand Down
2 changes: 2 additions & 0 deletions ov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Prompt:
# InvertColor: true # Invert the color of the prompt.
# ProcessOfCount: true # Show the process of count.

# ShrinkChar: '…' # Characters displayed when the column is shrinking.

General:
TabWidth: 8
Header: 0
Expand Down
15 changes: 11 additions & 4 deletions oviewer/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,24 @@ var SpaceContent = content{
style: tcell.StyleDefault,
}

// Shrink is a rune that represents a shrinked column.
var Shrink rune = '…'

// ShrinkContent is a content that represents a shrinked column.
var ShrinkContent = content{
mainc: Shrink,
combc: nil,
width: runewidth.RuneWidth(Shrink),
width: 1,
style: tcell.StyleDefault,
}

// SetShrinkContent sets the shrink character.
func SetShrinkContent(shrink rune) {
ShrinkContent = content{
mainc: shrink,
combc: nil,
width: runewidth.RuneWidth(shrink),
style: tcell.StyleDefault,
}
}

// EOFC is the EOF character.
const EOFC rune = '~'

Expand Down
3 changes: 3 additions & 0 deletions oviewer/convert_align.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ func (a *align) convertWidth(src contents) contents {
func appendShrink(lc contents, delm contents) contents {
lc = append(lc, delm...)
lc = append(lc, ShrinkContent)
if ShrinkContent.width > 1 {
lc = append(lc, SpaceContent)
}
return lc
}

Expand Down
9 changes: 9 additions & 0 deletions oviewer/oviewer.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ type Config struct {
// Incsearch is incremental search if true.
Incsearch bool

// ShrinkChar is the character to display when the column is shrunk.
ShrinkChar string
// DisableColumnCycle is disable column cycle.
DisableColumnCycle bool
// Debug represents whether to enable the debug output.
Expand Down Expand Up @@ -364,6 +366,8 @@ const (
alignConv = "align"
)

var Shrink rune = '…'

var (
// ErrOutOfRange indicates that value is out of range.
ErrOutOfRange = errors.New("out of range")
Expand Down Expand Up @@ -687,6 +691,11 @@ func (root *Root) prepareRun(ctx context.Context) error {
root.Screen.EnableMouse(MouseFlags)
}

if root.Config.ShrinkChar != "" {
Shrink = []rune(root.Config.ShrinkChar)[0]
}
SetShrinkContent(Shrink)

root.setCaption()

root.setViewModeConfig()
Expand Down

0 comments on commit 80ab692

Please sign in to comment.