diff --git a/oviewer/action.go b/oviewer/action.go index c4629e3..eea4f8d 100644 --- a/oviewer/action.go +++ b/oviewer/action.go @@ -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) @@ -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 { @@ -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 { diff --git a/oviewer/keybind.go b/oviewer/keybind.go index 577552c..3cbdff7 100644 --- a/oviewer/keybind.go +++ b/oviewer/keybind.go @@ -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" @@ -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, @@ -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"}, @@ -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)")