Skip to content

Commit

Permalink
Reordered functions and other elements
Browse files Browse the repository at this point in the history
  • Loading branch information
noborus committed Jan 24, 2025
1 parent a574682 commit d2d940b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
26 changes: 13 additions & 13 deletions oviewer/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,17 @@ func (root *Root) bottomSectionLN(ctx context.Context) int {
return lN - (root.Doc.topLN + root.Doc.firstLine() - root.Doc.SectionStartPosition)
}

// toggleFixedColumn toggles the fixed column.
func (root *Root) toggleFixedColumn(ctx context.Context) {
cursor := root.Doc.columnCursor + 1
if root.Doc.HeaderColumn == cursor {
cursor = 0
}
root.Doc.HeaderColumn = cursor
root.Doc.VerticalHeader = 0
root.setMessagef("Set Header Column %d", cursor)
}

// ShrinkColumn shrinks the specified column.
func (root *Root) ShrinkColumn(ctx context.Context, cursor int) error {
return root.Doc.shrinkColumn(cursor, true)
Expand All @@ -869,8 +880,8 @@ func (root *Root) ExpandColumn(ctx context.Context, cursor int) error {
return root.Doc.shrinkColumn(cursor, false)
}

// toggleColumnShrink shrinks or expands the current cursor column.
func (root *Root) toggleColumnShrink(ctx context.Context) {
// toggleShrinkColumn shrinks or expands the current cursor column.
func (root *Root) toggleShrinkColumn(ctx context.Context) {
cursor := root.Doc.columnCursor
shrink, err := root.Doc.isColumnShrink(cursor)
if err != nil {
Expand All @@ -881,17 +892,6 @@ func (root *Root) toggleColumnShrink(ctx context.Context) {
}
}

// toggleFixedColumn toggles the fixed column.
func (root *Root) toggleFixedColumn(ctx context.Context) {
cursor := root.Doc.columnCursor + 1
if root.Doc.HeaderColumn == cursor {
cursor = 0
}
root.Doc.HeaderColumn = cursor
root.Doc.VerticalHeader = 0
root.setMessagef("Set Header Column %d", cursor)
}

// isColumnShrink returns whether the specified column is shrink.
func (m *Document) isColumnShrink(cursor int) (bool, error) {
if m.Converter != convAlign {
Expand Down
8 changes: 4 additions & 4 deletions oviewer/keybind.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ const (
actionConvertType = "convert_type"
actionAlignFormat = "align_format"
actionRawFormat = "raw_format"
actionShrinkColumn = "shrink_column"
actionVeritcalHeader = "set_vertical_header"
actionHeaderColumn = "set_header_column"
actionFixedColumn = "fixed_column"
actionShrinkColumn = "shrink_column"

inputCaseSensitive = "input_casesensitive"
inputSmartCaseSensitive = "input_smart_casesensitive"
Expand Down Expand Up @@ -176,10 +176,10 @@ func (root *Root) handlers() map[string]func(context.Context) {
actionConvertType: root.setConvertType,
actionAlignFormat: root.alignFormat,
actionRawFormat: root.rawFormat,
actionShrinkColumn: root.toggleColumnShrink,
actionVeritcalHeader: root.setVerticalHeaderMode,
actionHeaderColumn: root.setHeaderColumnMode,
actionFixedColumn: root.toggleFixedColumn,
actionShrinkColumn: root.toggleShrinkColumn,

inputCaseSensitive: root.inputCaseSensitive,
inputSmartCaseSensitive: root.inputSmartCaseSensitive,
Expand Down Expand Up @@ -271,10 +271,10 @@ func defaultKeyBinds() KeyBind {
actionConvertType: {"alt+t"},
actionAlignFormat: {"alt+F"},
actionRawFormat: {"alt+R"},
actionShrinkColumn: {"s"},
actionVeritcalHeader: {"y"},
actionHeaderColumn: {"Y"},
actionFixedColumn: {"F"},
actionShrinkColumn: {"s"},

inputCaseSensitive: {"alt+c"},
inputSmartCaseSensitive: {"alt+s"},
Expand Down Expand Up @@ -349,8 +349,8 @@ func (k KeyBind) String() string {
k.writeKeyBind(&b, actionColumnMode, "column mode toggle")
k.writeKeyBind(&b, actionColumnWidth, "column width toggle")
k.writeKeyBind(&b, actionRainbow, "column rainbow toggle")
k.writeKeyBind(&b, actionShrinkColumn, "shrink column toggle")
k.writeKeyBind(&b, actionFixedColumn, "header column fixed toggle")
k.writeKeyBind(&b, actionShrinkColumn, "shrink column toggle")
k.writeKeyBind(&b, actionAlternate, "alternate rows of style toggle")
k.writeKeyBind(&b, actionLineNumMode, "line number toggle")
k.writeKeyBind(&b, actionPlain, "original decoration toggle(plain)")
Expand Down

0 comments on commit d2d940b

Please sign in to comment.