looking good so far
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"os"
|
||||
|
||||
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) {
|
||||
var (
|
||||
edCmd tea.Cmd
|
||||
taCmd tea.Cmd
|
||||
liCmd tea.Cmd
|
||||
pickerCmd 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, edCmd = m.editor.Update(msg)
|
||||
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 {
|
||||
@@ -207,14 +206,15 @@ func (m mainModel) updateStyles(width, height int) mainModel {
|
||||
m.height = height
|
||||
|
||||
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.SetHeight(editorHeight)
|
||||
m.editor.SetHeight(int(editorHeight))
|
||||
|
||||
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)
|
||||
|
||||
@@ -226,21 +226,30 @@ func (m mainModel) View() string {
|
||||
view, editor string
|
||||
)
|
||||
|
||||
h, _ := defaultStyle.GetFrameSize()
|
||||
topHeight := (m.height * 3 / 4) - h
|
||||
editorHeight := (m.height * 1 / 4) - h
|
||||
switch m.focused {
|
||||
case EDITOR:
|
||||
view = defaultStyle.
|
||||
Height(topHeight).
|
||||
Render(m.table.Render())
|
||||
editor = focusedStyle.
|
||||
Height(editorHeight).
|
||||
Render(m.editor.View())
|
||||
case TABLE:
|
||||
view = focusedStyle.
|
||||
Height(topHeight).
|
||||
Render(m.table.Render())
|
||||
editor = defaultStyle.
|
||||
Height(editorHeight).
|
||||
Render(m.editor.View())
|
||||
case PICKER:
|
||||
view = defaultStyle.
|
||||
Height(topHeight).
|
||||
Render(m.table.Render())
|
||||
editor = defaultStyle.
|
||||
Height(editorHeight).
|
||||
Render(m.editor.View())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user