civ

package module
v0.0.0-...-ddbe662 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2019 License: MIT Imports: 6 Imported by: 0

README

civ

A simple CSV interactive viewer.

Demo

civ demo

Build

go get -u github.com/MasahikoSawada/civ

Usage

$ civ [options] [FILE]
Option Description
-d string Use string as a delimiter instead of comma(,)
-H Set dummy header (col_1, col_2 ...)
  • civ reads data from stdin if no file is specified.
  • civ processes the first line as a header line by default. If the first line of the file is not header line please use -H option to set dummy headers.
  • -d option allows a speciial argument \t to parse TSV.

Query Buffer

civ has a buffer for user-input query at top of the window. The first character indicates the current mode as described below.

Modes

civ has 4 modes: view mode, command mode, search mode and filter mode.

You can swtich modes by special character when the query buffer is empty.

  • ':' : View Mode
  • '@' : Command Mode
  • '/' : Search Mode
  • '^' : Filter Mode

Press Ctrl-g always clear all query buffer and switch to view mode.

Press Ctrl-c exits but executing @exit also exits while output the table data to stdout.

Press Enter saves the result of the current command (at most one result for each searching and filtering).

View Mode(:)

Viewing the table data with the following ''less-like'' key binds:

Key Description
e Forward one line
y Backward one line
f, SPACE Forward one window
b Forward one window
d Forward one half-window
u Backward one half-window
g Go to first line in file
G Go to last line in file

Command Mode(@)

Executing the following commands modify the table:

Command Description
@hide column-name [...] Hide the specified column(s)
@show column-name [...] Show the specified hidden column(s)
@show_only column-name [...] Show only the specified column(s)
@reset Reset all configurations(row filtering, column visibility etc)
@exit Output the table data to stdout and exit normally

Pressing Enter key executes the input command.

Note that specifying column name is case-insensive.

Search Mode(/)

civ supports the incremental search hight-lighting the matched words.

Filter Mode(^)

civ supports the incremental filtering rows.

Limitation

Since civ is continually being improved it has some limitations. These limitation might be resolved in the future.

  • Not supports multi-byte characters.

Documentation

Index

Constants

View Source
const (
	MODE_VIEW    = 1
	MODE_COMMAND = 2
	MODE_SEARCH  = 3
	MODE_FILTER  = 4
)

Modes

View Source
const (
	SCROLL_SIZE = 1
)

Variables

This section is empty.

Functions

func GetMaxXY

func GetMaxXY() (maxX int, maxY int)

Types

type Cell

type Cell struct {
	// contains filtered or unexported fields
}

type Civ

type Civ struct {
	// contains filtered or unexported fields
}

func NewCiv

func NewCiv(data [][]string, dummyHeader bool) *Civ

func (*Civ) Draw

func (c *Civ) Draw()

func (*Civ) ExecuteCommand

func (c *Civ) ExecuteCommand()

func (*Civ) Run

func (c *Civ) Run() bool

type QueryLine

type QueryLine struct {
	// contains filtered or unexported fields
}

func NewQueryLine

func NewQueryLine() *QueryLine

func (*QueryLine) BackwardChar

func (q *QueryLine) BackwardChar()

func (*QueryLine) ClearAll

func (q *QueryLine) ClearAll()

func (*QueryLine) ClearQuery

func (q *QueryLine) ClearQuery()

func (*QueryLine) DeleteChar

func (q *QueryLine) DeleteChar()

func (*QueryLine) InputChar

func (q *QueryLine) InputChar(r rune)

func (*QueryLine) MoveBackward

func (q *QueryLine) MoveBackward()

func (*QueryLine) MoveForward

func (q *QueryLine) MoveForward()

func (*QueryLine) MoveToEnd

func (q *QueryLine) MoveToEnd()

func (*QueryLine) MoveToTop

func (q *QueryLine) MoveToTop()

func (*QueryLine) QueryLen

func (q *QueryLine) QueryLen() int

func (*QueryLine) TruncateChars

func (q *QueryLine) TruncateChars()

type Row

type Row struct {
	// contains filtered or unexported fields
}

type Table

type Table struct {
	// contains filtered or unexported fields
}

func NewTable

func NewTable(indata [][]string, dummyHeader bool) *Table

func (*Table) AddDisabledCol

func (t *Table) AddDisabledCol(idx int)

Add the idx'th column to disabled column list. That is, make it invisible

func (*Table) Debugdump

func (t *Table) Debugdump()

func (*Table) FindColName

func (t *Table) FindColName(name string) (int, bool)

Return true and position if the given name is in col names

func (*Table) IsColEnabled

func (t *Table) IsColEnabled(colNum int) bool

func (*Table) MoveDown

func (t *Table) MoveDown(move int)

func (*Table) MoveLeft

func (t *Table) MoveLeft(move int)

func (*Table) MoveRight

func (t *Table) MoveRight(move int)

func (*Table) MoveUp

func (t *Table) MoveUp(move int)

func (*Table) NEnabledCols

func (t *Table) NEnabledCols() int

func (*Table) RemoveDisabledCol

func (t *Table) RemoveDisabledCol(idx int)

Remove the idx'th column from disabled column list. That is, make it visible

func (*Table) ResetDisabledCol

func (t *Table) ResetDisabledCol()

func (*Table) ResetVisibility

func (t *Table) ResetVisibility()

func (*Table) SetMatched

func (t *Table) SetMatched(r int, c int, b int, e int)

func (*Table) SetOffsetRow

func (t *Table) SetOffsetRow(r int)

func (*Table) SetRowVisibility

func (t *Table) SetRowVisibility(rowIdx int, visible bool)

type Terminal

type Terminal struct {
	// contains filtered or unexported fields
}

func NewTerminal

func NewTerminal() *Terminal

func (*Terminal) Draw

func (t *Terminal) Draw(ql *QueryLine, tb *Table) error

Directories

Path Synopsis
cmd
civ

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL