Documentation ¶
Index ¶
- Constants
- func Abs(a int) int
- func CopyFile(src string) (string, int64, error)
- func Exists(path string) (bool, error)
- func FileExists(name string) (bool, error)
- func GetDatabaseForFile(database string) *sql.DB
- func GetHelpText() (help string)
- func GetInterfaceFromString(str string, original *interface{}) interface{}
- func GetStringRepresentationOfInterface(val interface{}) string
- func Hash(s string) uint32
- func IsUrl(fp string) bool
- func Max(a, b int) int
- func Min(a, b int) int
- func SplitLines(s string) []string
- func Sync(m ViewportModel) tea.Cmd
- func TruncateIfApplicable(m *TuiModel, conv string) (s string)
- func ViewDown(m ViewportModel, lines []string) tea.Cmd
- func ViewUp(m ViewportModel, lines []string) tea.Cmd
- func WriteTextFile(m *TuiModel, text string) (string, error)
- type Database
- type Query
- type SQLite
- type TableState
- type TuiModel
- func (m *TuiModel) CellWidth() int
- func (m *TuiModel) CopyMap() (to map[string]interface{})
- func (m *TuiModel) DisplayMessage(msg string)
- func (m *TuiModel) GetBaseStyle() lipgloss.Style
- func (m *TuiModel) GetColumn() int
- func (m *TuiModel) GetColumnData() []interface{}
- func (m *TuiModel) GetHeaders() []string
- func (m *TuiModel) GetRow() int
- func (m *TuiModel) GetRowData() map[string]interface{}
- func (m *TuiModel) GetSchemaData() map[string][]interface{}
- func (m *TuiModel) GetSchemaName() string
- func (m *TuiModel) GetSelectedColumnName() string
- func (m *TuiModel) GetSelectedOption() (*interface{}, int, []interface{})
- func (m TuiModel) Init() tea.Cmd
- func (m *TuiModel) NumHeaders() int
- func (m *TuiModel) ProcessSqlQueryForDatabaseType(q Query)
- func (m *TuiModel) Serialize() string
- func (m *TuiModel) SerializeOverwrite()
- func (m *TuiModel) SetModel(c *sql.Rows, db *sql.DB)
- func (m *TuiModel) SetViewSlices()
- func (m TuiModel) Update(message tea.Msg) (tea.Model, tea.Cmd)
- func (m TuiModel) View() string
- type Update
- type ViewportModel
- func (m ViewportModel) AtBottom() bool
- func (m ViewportModel) AtTop() bool
- func (m *ViewportModel) GotoBottom() (lines []string)
- func (m *ViewportModel) GotoTop() (lines []string)
- func (m *ViewportModel) HalfViewDown() (lines []string)
- func (m *ViewportModel) HalfViewUp() (lines []string)
- func (m *ViewportModel) LineDown(n int) (lines []string)
- func (m *ViewportModel) LineUp(n int) (lines []string)
- func (m ViewportModel) PastBottom() bool
- func (m ViewportModel) ScrollPercent() float64
- func (m *ViewportModel) SetContent(s string)
- func (m ViewportModel) Update(msg tea.Msg) (ViewportModel, tea.Cmd)
- func (m ViewportModel) View() string
- func (m *ViewportModel) ViewDown() []string
- func (m *ViewportModel) ViewUp() []string
Constants ¶
const (
HiddenTmpDirectoryName = ".termdbms"
)
Variables ¶
This section is empty.
Functions ¶
func FileExists ¶
func GetDatabaseForFile ¶
GetDatabaseForFile does what you think it does
func GetHelpText ¶
func GetHelpText() (help string)
func GetInterfaceFromString ¶
func GetInterfaceFromString(str string, original *interface{}) interface{}
func GetStringRepresentationOfInterface ¶
func GetStringRepresentationOfInterface(val interface{}) string
func SplitLines ¶
func Sync ¶
func Sync(m ViewportModel) tea.Cmd
Sync tells the renderer where the viewport will be located and requests a render of the current state of the viewport. It should be called for the first render and after a window resize.
For high performance rendering only.
func TruncateIfApplicable ¶
func ViewDown ¶
func ViewDown(m ViewportModel, lines []string) tea.Cmd
ViewDown is a high performance command that moves the viewport up by a given numer of lines. Use ViewportModel.ViewDown to get the lines that should be rendered. For example:
lines := model.ViewDown(1) cmd := ViewDown(m, lines)
Types ¶
type SQLite ¶
type SQLite struct { FileName string // contains filtered or unexported fields }
func (*SQLite) CloseDatabaseReference ¶
func (s *SQLite) CloseDatabaseReference()
func (*SQLite) GetDatabaseReference ¶
func (*SQLite) GetFileName ¶
func (*SQLite) SetDatabaseReference ¶
type TableState ¶
type TuiModel ¶
type TuiModel struct { Table TableState // all non destructive changes are TableStates getting passed around TableHeaders map[string][]string // keeps track of which schema has which headers TableHeadersSlice []string DataSlices map[string][]interface{} TableIndexMap map[int]string // keeps the schemas in order TableSelection int InitialFileName string // used if saving destructively UndoStack []TableState RedoStack []TableState // contains filtered or unexported fields }
TuiModel holds all the necessary state for this app to work the way I designed it to
func GetNewModel ¶
GetNewModel returns a TuiModel struct with some fields set
func (*TuiModel) DisplayMessage ¶
func (*TuiModel) GetBaseStyle ¶
GetBaseStyle returns a new style that is used everywhere
func (*TuiModel) GetColumnData ¶
func (m *TuiModel) GetColumnData() []interface{}
func (*TuiModel) GetHeaders ¶
GetHeaders does just that for the current schema
func (*TuiModel) GetRowData ¶
func (*TuiModel) GetSchemaData ¶
GetSchemaData is a helper function to get the data of the current schema
func (*TuiModel) GetSchemaName ¶
GetSchemaName gets the current schema name
func (*TuiModel) GetSelectedColumnName ¶
func (*TuiModel) GetSelectedOption ¶
func (*TuiModel) NumHeaders ¶
NumHeaders gets the number of columns for the current schema
func (*TuiModel) ProcessSqlQueryForDatabaseType ¶
func (*TuiModel) SerializeOverwrite ¶
func (m *TuiModel) SerializeOverwrite()
func (*TuiModel) SetModel ¶
SetModel creates a model to be used by bubbletea using some golang wizardry
func (*TuiModel) SetViewSlices ¶
func (m *TuiModel) SetViewSlices()
type Update ¶
type ViewportModel ¶
type ViewportModel struct { Width int Height int // YOffset is the vertical scroll position. YOffset int // YPosition is the position of the viewport in relation to the terminal // window. It's used in high performance rendering. YPosition int // HighPerformanceRendering bypasses the normal Bubble Tea renderer to // provide higher performance rendering. Most of the time the normal Bubble // Tea rendering methods will suffice, but if you're passing content with // a lot of ANSI escape codes you may see improved rendering in certain // terminals with this enabled. // // This should only be used in program occupying the entire terminal, // which is usually via the alternate screen buffer. HighPerformanceRendering bool // contains filtered or unexported fields }
ViewportModel is the Bubble Tea model for this viewport element.
func (ViewportModel) AtBottom ¶
func (m ViewportModel) AtBottom() bool
AtBottom returns whether or not the viewport is at or past the very bottom position.
func (ViewportModel) AtTop ¶
func (m ViewportModel) AtTop() bool
AtTop returns whether or not the viewport is in the very top position.
func (*ViewportModel) GotoBottom ¶
func (m *ViewportModel) GotoBottom() (lines []string)
GotoBottom sets the viewport to the bottom position.
func (*ViewportModel) GotoTop ¶
func (m *ViewportModel) GotoTop() (lines []string)
GotoTop sets the viewport to the top position.
func (*ViewportModel) HalfViewDown ¶
func (m *ViewportModel) HalfViewDown() (lines []string)
HalfViewDown moves the view down by half the height of the viewport.
func (*ViewportModel) HalfViewUp ¶
func (m *ViewportModel) HalfViewUp() (lines []string)
HalfViewUp moves the view up by half the height of the viewport.
func (*ViewportModel) LineDown ¶
func (m *ViewportModel) LineDown(n int) (lines []string)
LineDown moves the view down by the given number of lines.
func (*ViewportModel) LineUp ¶
func (m *ViewportModel) LineUp(n int) (lines []string)
LineUp moves the view down by the given number of lines. Returns the new lines to show.
func (ViewportModel) PastBottom ¶
func (m ViewportModel) PastBottom() bool
PastBottom returns whether or not the viewport is scrolled beyond the last line. This can happen when adjusting the viewport height.
func (ViewportModel) ScrollPercent ¶
func (m ViewportModel) ScrollPercent() float64
ScrollPercent returns the amount scrolled as a float between 0 and 1.
func (*ViewportModel) SetContent ¶
func (m *ViewportModel) SetContent(s string)
SetContent set the pager's text content. For high performance rendering the Sync command should also be called.
func (ViewportModel) Update ¶
func (m ViewportModel) Update(msg tea.Msg) (ViewportModel, tea.Cmd)
Update runs the update loop with default keybindings similar to popular pagers. To define your own keybindings use the methods on ViewportModel (i.e. ViewportModel.LineDown()) and define your own update function.
func (ViewportModel) View ¶
func (m ViewportModel) View() string
View renders the viewport into a string.
func (*ViewportModel) ViewDown ¶
func (m *ViewportModel) ViewDown() []string
ViewDown moves the view down by the number of lines in the viewport. Basically, "page down".
func (*ViewportModel) ViewUp ¶
func (m *ViewportModel) ViewUp() []string
ViewUp moves the view up by one height of the viewport. Basically, "page up".