From b0f7d74adc77d01a9ef76f11160afe378c4375c6 Mon Sep 17 00:00:00 2001 From: Pablu Date: Tue, 20 Jan 2026 00:39:20 +0100 Subject: [PATCH] looking good so far --- .gitignore | 1 + cmd/sqv-tea/main.go | 25 +++++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 7ad819c..a7e89cd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ db.* main +debug.log diff --git a/cmd/sqv-tea/main.go b/cmd/sqv-tea/main.go index 5c63088..6577dd4 100644 --- a/cmd/sqv-tea/main.go +++ b/cmd/sqv-tea/main.go @@ -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()) }