Documentation ¶
Index ¶
- Constants
- Variables
- func Abs(a int) int
- func AssembleTable(m *TuiModel) string
- func CopyFile(src string) (string, int64, error)
- func CreateEmptyBuffer(m *TuiModel, original *interface{})
- func CreatePopulatedBuffer(m *TuiModel, original *interface{}, str string)
- func DisplayFormatText(m *TuiModel) string
- func DisplaySelection(m *TuiModel) string
- func DisplayTable(m *TuiModel) string
- func EditEnter(m *TuiModel)
- func Exists(path string) (bool, error)
- func ExitToDefaultView(m *TuiModel)
- func FileExists(name string) (bool, error)
- func FormatJson(str string) (string, error)
- func GetFormattedTextBuffer(m *TuiModel) []string
- func GetHelpText() (help string)
- func GetInterfaceFromString(str string, original *interface{}) interface{}
- func GetOffsetForLineNumber(a int) int
- func GetScrollDownMaximumForSelection(m *TuiModel) int
- func GetStringRepresentationOfInterface(val interface{}) string
- func HandleClipboardEvents(m *TuiModel, str string, command *tea.Cmd, msg tea.Msg)
- func HandleEditInput(m *TuiModel, str, val string) (ret bool)
- func HandleEditMode(m *TuiModel, str string)
- func HandleEditMovement(m *TuiModel, str, val string) (ret bool)
- func HandleFormatInput(m *TuiModel, str string) bool
- func HandleFormatMode(m *TuiModel, str string)
- func HandleFormatMovement(m *TuiModel, str string) (ret bool)
- func HandleKeyboardEvents(m *TuiModel, msg *tea.KeyMsg) tea.Cmd
- func HandleMouseEvents(m *TuiModel, msg *tea.MouseMsg)
- func HandleWindowSizeEvents(m *TuiModel, msg *tea.WindowSizeMsg) tea.Cmd
- func Hash(s string) uint32
- func InsertCharacter(m *TuiModel, newlineOrTab string)
- func IsUrl(fp string) bool
- func Max(a, b int) int
- func Min(a, b int) int
- func MoveCursorWithinBounds(m *TuiModel)
- func PrepareFormatMode(m *TuiModel)
- func ScrollDown(m *TuiModel)
- func ScrollUp(m *TuiModel)
- func SelectOption(m *TuiModel)
- func Serialize(m *TuiModel) (string, error)
- func SerializeOverwrite(m *TuiModel) error
- func SerializeOverwriteSQLiteDB(db *database.SQLite, m *TuiModel)
- func SerializeSQLiteDB(db *database.SQLite, m *TuiModel) string
- func SetStyles()
- func ShowClipboard(m *TuiModel) string
- func SplitLines(s string) []string
- func ToggleColumn(m *TuiModel)
- func TruncateIfApplicable(m *TuiModel, conv string) (s string)
- func WriteCSV(m *TuiModel)
- func WriteTextFile(m *TuiModel, text string) (string, error)
- type Command
- type EnterFunction
- type FormatState
- type LineEdit
- type SQLSnippet
- type ScrollData
- type TableAssembly
- type TableState
- type TuiModel
- func (m *TuiModel) CellWidth() int
- func (m *TuiModel) CopyMap() (to map[string]interface{})
- func (m *TuiModel) Data() *UIData
- 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) GetSelectedLineEdit() *LineEdit
- func (m *TuiModel) GetSelectedOption() (*interface{}, int, []interface{})
- func (m TuiModel) Init() tea.Cmd
- func (m *TuiModel) NumHeaders() int
- func (m *TuiModel) PopulateDataForResult(c *sql.Rows, indexMap *int, schemaName string)
- func (m *TuiModel) SetModel(c *sql.Rows, db *sql.DB) error
- func (m *TuiModel) SetViewSlices()
- func (m *TuiModel) SwapTableValues(f, t *TableState)
- func (m *TuiModel) Table() *TableState
- func (m TuiModel) Update(message tea.Msg) (tea.Model, tea.Cmd)
- func (m TuiModel) View() string
- func (m *TuiModel) WriteMessage(s string)
- type UIData
- type UIState
Constants ¶
const ( HiddenTmpDirectoryName = ".termdbms" SQLSnippetsFile = "snippets.termdbms" )
const (
QueryResultsTableName = "results"
)
Variables ¶
var ( HeaderAssembly TableAssembly Message string MIP bool )
var ( HeaderHeight = 2 MaxInputLength int HeaderStyle lipgloss.Style HeaderDividerStyle lipgloss.Style InitialModel *TuiModel )
var (
GlobalCommands = make(map[string]Command)
)
var (
InputBlacklist = []string{
"alt+",
"ctrl+",
"up",
"down",
"tab",
"left",
"enter",
"right",
"pgdown",
"pgup",
}
)
Functions ¶
func AssembleTable ¶
AssembleTable shows either the selection text or the table
func CreateEmptyBuffer ¶
func CreateEmptyBuffer(m *TuiModel, original *interface{})
func CreatePopulatedBuffer ¶
func DisplayFormatText ¶
func DisplaySelection ¶
DisplaySelection does that or writes it to a file if the selection is over a limit
func DisplayTable ¶
DisplayTable does some fancy stuff to get a table rendered in text
func ExitToDefaultView ¶
func ExitToDefaultView(m *TuiModel)
func FileExists ¶
func FormatJson ¶
FormatJson is some more code I stole off stackoverflow
func GetFormattedTextBuffer ¶
func GetHelpText ¶
func GetHelpText() (help string)
func GetInterfaceFromString ¶
func GetInterfaceFromString(str string, original *interface{}) interface{}
func GetOffsetForLineNumber ¶
func GetStringRepresentationOfInterface ¶
func GetStringRepresentationOfInterface(val interface{}) string
func HandleClipboardEvents ¶
func HandleEditInput ¶
func HandleEditMode ¶
HandleEditMode implementation is kind of jank, but we can clean it up later
func HandleEditMovement ¶
func HandleFormatInput ¶
func HandleFormatMode ¶
func HandleFormatMovement ¶
func HandleKeyboardEvents ¶
HandleKeyboardEvents does that
func HandleMouseEvents ¶
HandleMouseEvents does that
func HandleWindowSizeEvents ¶
func HandleWindowSizeEvents(m *TuiModel, msg *tea.WindowSizeMsg) tea.Cmd
HandleWindowSizeEvents does that
func InsertCharacter ¶
func MoveCursorWithinBounds ¶
func MoveCursorWithinBounds(m *TuiModel)
func PrepareFormatMode ¶
func PrepareFormatMode(m *TuiModel)
func ScrollDown ¶
func ScrollDown(m *TuiModel)
ScrollDown is a simple function to move the Viewport down
func SelectOption ¶
func SelectOption(m *TuiModel)
func SerializeOverwrite ¶
func ShowClipboard ¶
func SplitLines ¶
func ToggleColumn ¶
func ToggleColumn(m *TuiModel)
func TruncateIfApplicable ¶
Types ¶
type EnterFunction ¶
type EnterFunction func(m *TuiModel, selectedInput *tuiutil.TextInputModel, input string)
type FormatState ¶
type LineEdit ¶
type LineEdit struct { Model tuiutil.TextInputModel Original *interface{} }
type SQLSnippet ¶
func (SQLSnippet) Description ¶
func (s SQLSnippet) Description() string
func (SQLSnippet) FilterValue ¶
func (s SQLSnippet) FilterValue() string
func (SQLSnippet) Title ¶
func (s SQLSnippet) Title() string
type ScrollData ¶
type TableAssembly ¶
type TableState ¶
TableState holds everything needed to save/serialize state
type TuiModel ¶
type TuiModel struct { DefaultTable TableState // all non-destructive changes are TableStates getting passed around DefaultData UIData QueryResult *TableState QueryData *UIData Format FormatState UI UIState Scroll ScrollData Ready bool InitialFileName string // used if saving destructively Viewport viewport.Model ClipboardList list.Model Clipboard []list.Item TableStyle lipgloss.Style MouseData tea.MouseEvent TextInput LineEdit FormatInput LineEdit UndoStack []TableState RedoStack []TableState }
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) GetSelectedLineEdit ¶
func (*TuiModel) GetSelectedOption ¶
func (*TuiModel) NumHeaders ¶
NumHeaders gets the number of columns for the current schema
func (*TuiModel) PopulateDataForResult ¶
func (*TuiModel) SetModel ¶
SetModel creates a model to be used by bubbletea using some golang wizardry
func (*TuiModel) SetViewSlices ¶
func (m *TuiModel) SetViewSlices()
func (*TuiModel) SwapTableValues ¶
func (m *TuiModel) SwapTableValues(f, t *TableState)
func (*TuiModel) Table ¶
func (m *TuiModel) Table() *TableState