looking good so far
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
db.*
|
db.*
|
||||||
main
|
main
|
||||||
|
debug.log
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
engine "git.pablu.de/pablu/sqv-engine"
|
engine "git.pablu.de/pablu/sqv-engine"
|
||||||
@@ -133,8 +134,6 @@ type tableMsg struct {
|
|||||||
func (m mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
func (m mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
var (
|
var (
|
||||||
edCmd tea.Cmd
|
edCmd tea.Cmd
|
||||||
taCmd tea.Cmd
|
|
||||||
liCmd tea.Cmd
|
|
||||||
pickerCmd tea.Cmd
|
pickerCmd tea.Cmd
|
||||||
cmds tea.Cmd
|
cmds tea.Cmd
|
||||||
)
|
)
|
||||||
@@ -196,10 +195,10 @@ func (m mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
m.editor.Focus()
|
m.editor.Focus()
|
||||||
m.editor, edCmd = m.editor.Update(msg)
|
m.editor, edCmd = m.editor.Update(msg)
|
||||||
case PICKER:
|
case PICKER:
|
||||||
m.picker, liCmd = m.picker.Update(msg)
|
m.picker, pickerCmd = m.picker.Update(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
return m, tea.Batch(edCmd, taCmd, liCmd, cmds, pickerCmd)
|
return m, tea.Batch(edCmd, cmds, pickerCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m mainModel) updateStyles(width, height int) mainModel {
|
func (m mainModel) updateStyles(width, height int) mainModel {
|
||||||
@@ -207,14 +206,15 @@ func (m mainModel) updateStyles(width, height int) mainModel {
|
|||||||
m.height = height
|
m.height = height
|
||||||
|
|
||||||
h, v := defaultStyle.GetFrameSize()
|
h, v := defaultStyle.GetFrameSize()
|
||||||
topHeight := (m.height * 3 / 4) - h
|
|
||||||
editorHeight := (m.height * 1 / 4) - h
|
topHeight := math.Ceil(float64(m.height)*3/4 - float64(h))
|
||||||
|
editorHeight := math.Ceil(float64(m.height)*1/4 - float64(h))
|
||||||
|
|
||||||
m.editor.SetWidth(m.width - v)
|
m.editor.SetWidth(m.width - v)
|
||||||
m.editor.SetHeight(editorHeight)
|
m.editor.SetHeight(int(editorHeight))
|
||||||
|
|
||||||
m.table.Width(m.width - v)
|
m.table.Width(m.width - v)
|
||||||
m.table.Height(topHeight - h)
|
m.table.Height(int(topHeight) - h*2)
|
||||||
|
|
||||||
m.picker.SetSize(m.width*7/10, m.height*7/10)
|
m.picker.SetSize(m.width*7/10, m.height*7/10)
|
||||||
|
|
||||||
@@ -226,21 +226,30 @@ func (m mainModel) View() string {
|
|||||||
view, editor string
|
view, editor string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
h, _ := defaultStyle.GetFrameSize()
|
||||||
|
topHeight := (m.height * 3 / 4) - h
|
||||||
|
editorHeight := (m.height * 1 / 4) - h
|
||||||
switch m.focused {
|
switch m.focused {
|
||||||
case EDITOR:
|
case EDITOR:
|
||||||
view = defaultStyle.
|
view = defaultStyle.
|
||||||
|
Height(topHeight).
|
||||||
Render(m.table.Render())
|
Render(m.table.Render())
|
||||||
editor = focusedStyle.
|
editor = focusedStyle.
|
||||||
|
Height(editorHeight).
|
||||||
Render(m.editor.View())
|
Render(m.editor.View())
|
||||||
case TABLE:
|
case TABLE:
|
||||||
view = focusedStyle.
|
view = focusedStyle.
|
||||||
|
Height(topHeight).
|
||||||
Render(m.table.Render())
|
Render(m.table.Render())
|
||||||
editor = defaultStyle.
|
editor = defaultStyle.
|
||||||
|
Height(editorHeight).
|
||||||
Render(m.editor.View())
|
Render(m.editor.View())
|
||||||
case PICKER:
|
case PICKER:
|
||||||
view = defaultStyle.
|
view = defaultStyle.
|
||||||
|
Height(topHeight).
|
||||||
Render(m.table.Render())
|
Render(m.table.Render())
|
||||||
editor = defaultStyle.
|
editor = defaultStyle.
|
||||||
|
Height(editorHeight).
|
||||||
Render(m.editor.View())
|
Render(m.editor.View())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user