WIP BAK
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"math"
|
||||
"os"
|
||||
@@ -33,8 +34,10 @@ type mainModel struct {
|
||||
table *table.Table
|
||||
editor textarea.Model
|
||||
picker list.Model
|
||||
}
|
||||
|
||||
debugMsgs []string
|
||||
type tableModel struct {
|
||||
Table *table.Table
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -59,7 +62,13 @@ func newMainModerl(manager *engine.Manager) mainModel {
|
||||
|
||||
ed.ShowLineNumbers = false
|
||||
|
||||
ta := table.New().Border(lipgloss.NormalBorder())
|
||||
ta := table.New().
|
||||
Border(lipgloss.NormalBorder()).
|
||||
BorderBottom(false).
|
||||
BorderTop(false).
|
||||
BorderLeft(false).
|
||||
BorderRight(false).
|
||||
Wrap(false)
|
||||
|
||||
li := list.New(nil, list.NewDefaultDelegate(), 0, 0)
|
||||
li.Title = "Table Picker"
|
||||
@@ -77,7 +86,6 @@ func (m mainModel) Init() tea.Cmd {
|
||||
}
|
||||
|
||||
func (m mainModel) GetTableDefinitions() tea.Msg {
|
||||
|
||||
tables := m.manager.GetTables()
|
||||
tableNames := make([]list.Item, len(tables))
|
||||
|
||||
@@ -150,8 +158,6 @@ func (m mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
} else {
|
||||
m.focused = EDITOR
|
||||
}
|
||||
case "j":
|
||||
m.table.Offset(50)
|
||||
case "ctrl+e":
|
||||
if m.focused == PICKER {
|
||||
m.focused = m.lastFocused
|
||||
@@ -191,6 +197,8 @@ func (m mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
}
|
||||
|
||||
switch m.focused {
|
||||
case TABLE:
|
||||
|
||||
case EDITOR:
|
||||
m.editor.Focus()
|
||||
m.editor, edCmd = m.editor.Update(msg)
|
||||
@@ -213,7 +221,7 @@ func (m mainModel) updateStyles(width, height int) mainModel {
|
||||
m.editor.SetWidth(m.width - v)
|
||||
m.editor.SetHeight(int(editorHeight))
|
||||
|
||||
m.table.Width(m.width - v)
|
||||
m.table.Width(m.width)
|
||||
m.table.Height(int(topHeight) - h*2)
|
||||
|
||||
m.picker.SetSize(m.width*7/10, m.height*7/10)
|
||||
@@ -226,30 +234,30 @@ func (m mainModel) View() string {
|
||||
view, editor string
|
||||
)
|
||||
|
||||
h, _ := defaultStyle.GetFrameSize()
|
||||
h, v := defaultStyle.GetFrameSize()
|
||||
topHeight := (m.height * 3 / 4) - h
|
||||
editorHeight := (m.height * 1 / 4) - h
|
||||
width := m.width - v
|
||||
switch m.focused {
|
||||
case EDITOR:
|
||||
view = defaultStyle.
|
||||
Height(topHeight).
|
||||
Width(width).
|
||||
Render(m.table.Render())
|
||||
editor = focusedStyle.
|
||||
Height(editorHeight).
|
||||
Render(m.editor.View())
|
||||
case TABLE:
|
||||
view = focusedStyle.
|
||||
Height(topHeight).
|
||||
Width(width).
|
||||
Render(m.table.Render())
|
||||
editor = defaultStyle.
|
||||
Height(editorHeight).
|
||||
Render(m.editor.View())
|
||||
case PICKER:
|
||||
view = defaultStyle.
|
||||
Height(topHeight).
|
||||
Width(width).
|
||||
Render(m.table.Render())
|
||||
editor = defaultStyle.
|
||||
Height(editorHeight).
|
||||
Render(m.editor.View())
|
||||
}
|
||||
|
||||
@@ -265,7 +273,13 @@ func (m mainModel) View() string {
|
||||
return main
|
||||
}
|
||||
|
||||
var (
|
||||
path = flag.String("path", "db.sqlite", "Path to sqlite db")
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
f, err := tea.LogToFile("debug.log", "debug")
|
||||
if err != nil {
|
||||
fmt.Println("fatal:", err)
|
||||
@@ -276,7 +290,7 @@ func main() {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
log.SetOutput(f)
|
||||
|
||||
m, err := engine.NewManager("../vdcmp/db.sqlite")
|
||||
m, err := engine.NewManager(*path)
|
||||
if err != nil {
|
||||
fmt.Println("fatal:", err)
|
||||
os.Exit(1)
|
||||
|
||||
Reference in New Issue
Block a user