From 0e987d1e4ff9d2c42644481d3467dc40b34a2371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=9E=E3=83=AA=E3=82=A6=E3=82=B9?= Date: Mon, 2 Jan 2023 19:45:49 -0500 Subject: [PATCH] Fixed textarea positioning --- ui/cmd/cmd.go | 4 ++++ ui/windowmanager/windowmanager.go | 1 + ui/windows/postcreate/postcreate.go | 10 +++++----- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ui/cmd/cmd.go b/ui/cmd/cmd.go index 6ba3e17..ee1db5f 100644 --- a/ui/cmd/cmd.go +++ b/ui/cmd/cmd.go @@ -54,6 +54,10 @@ func (cmd *Command) Tea() tea.Cmd { } } +func (cmd *Command) AddArg(name string, value interface{}) { + cmd.Args[name] = value +} + func (cmd *Command) GetArg(name string) interface{} { if iface, ok := cmd.Args[name]; ok { return iface diff --git a/ui/windowmanager/windowmanager.go b/ui/windowmanager/windowmanager.go index 03b1455..382c70d 100644 --- a/ui/windowmanager/windowmanager.go +++ b/ui/windowmanager/windowmanager.go @@ -43,6 +43,7 @@ func (wm *WM) Open(id string, win windows.Window, xywh [4]int, command *cmd.Comm wm.stack = append(wm.stack, *item) + command.AddArg("xywh", item.XYWH) tcmds = append(tcmds, wm.Update(id, *command)) wm.ctx.Logger.Debugf("content: %v\n", wm.ctx.Content) tcmds = append(tcmds, wm.Resize(id, wm.ctx.Content[0], wm.ctx.Content[1])...) diff --git a/ui/windows/postcreate/postcreate.go b/ui/windows/postcreate/postcreate.go index 5675d22..2c89f6a 100644 --- a/ui/windows/postcreate/postcreate.go +++ b/ui/windows/postcreate/postcreate.go @@ -42,6 +42,7 @@ type Model struct { keymap KeyMap wh [2]int focused bool + xywh [4]int textarea textarea.Model a *aggregator.Aggregator @@ -71,6 +72,7 @@ func NewModel(c *ctx.Ctx) Model { ctx: c, keymap: DefaultKeyMap, focused: false, + xywh: [4]int{0, 0, 0, 0}, replyToIdx: 0, @@ -141,6 +143,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg.Call { case cmd.WinOpen: if msg.Target == WIN_ID { + m.xywh = msg.GetArg("xywh").([4]int) return m, m.textarea.Focus() } case cmd.WinClose: @@ -237,13 +240,10 @@ func (m Model) buildView(cached bool) string { bottombar, ) - replyWindowX := 5 - replyWindowY := m.ctx.Screen[1] - 21 - tmp := m.ctx.Theme.DialogBox.Window.Focused.Render(replyWindow) - m.viewcacheTextareaXY[0] = replyWindowX + 1 - m.viewcacheTextareaXY[1] = replyWindowY + 2 + m.viewcacheTextareaXY[0] = 1 + m.viewcacheTextareaXY[1] = 2 m.viewcacheTextareaXY[2] = textareaWidth m.viewcacheTextareaXY[3] = textareaHeight