1
0
mirror of https://github.com/mrusme/neonmodem.git synced 2024-12-04 14:46:37 -05:00

Fixed textarea positioning

This commit is contained in:
マリウス 2023-01-02 19:45:49 -05:00
parent 6775d6df17
commit 0e987d1e4f
No known key found for this signature in database
GPG Key ID: 272ED814BF63261F
3 changed files with 10 additions and 5 deletions

View File

@ -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{} { func (cmd *Command) GetArg(name string) interface{} {
if iface, ok := cmd.Args[name]; ok { if iface, ok := cmd.Args[name]; ok {
return iface return iface

View File

@ -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) wm.stack = append(wm.stack, *item)
command.AddArg("xywh", item.XYWH)
tcmds = append(tcmds, wm.Update(id, *command)) tcmds = append(tcmds, wm.Update(id, *command))
wm.ctx.Logger.Debugf("content: %v\n", wm.ctx.Content) wm.ctx.Logger.Debugf("content: %v\n", wm.ctx.Content)
tcmds = append(tcmds, wm.Resize(id, wm.ctx.Content[0], wm.ctx.Content[1])...) tcmds = append(tcmds, wm.Resize(id, wm.ctx.Content[0], wm.ctx.Content[1])...)

View File

@ -42,6 +42,7 @@ type Model struct {
keymap KeyMap keymap KeyMap
wh [2]int wh [2]int
focused bool focused bool
xywh [4]int
textarea textarea.Model textarea textarea.Model
a *aggregator.Aggregator a *aggregator.Aggregator
@ -71,6 +72,7 @@ func NewModel(c *ctx.Ctx) Model {
ctx: c, ctx: c,
keymap: DefaultKeyMap, keymap: DefaultKeyMap,
focused: false, focused: false,
xywh: [4]int{0, 0, 0, 0},
replyToIdx: 0, replyToIdx: 0,
@ -141,6 +143,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg.Call { switch msg.Call {
case cmd.WinOpen: case cmd.WinOpen:
if msg.Target == WIN_ID { if msg.Target == WIN_ID {
m.xywh = msg.GetArg("xywh").([4]int)
return m, m.textarea.Focus() return m, m.textarea.Focus()
} }
case cmd.WinClose: case cmd.WinClose:
@ -237,13 +240,10 @@ func (m Model) buildView(cached bool) string {
bottombar, bottombar,
) )
replyWindowX := 5
replyWindowY := m.ctx.Screen[1] - 21
tmp := m.ctx.Theme.DialogBox.Window.Focused.Render(replyWindow) tmp := m.ctx.Theme.DialogBox.Window.Focused.Render(replyWindow)
m.viewcacheTextareaXY[0] = replyWindowX + 1 m.viewcacheTextareaXY[0] = 1
m.viewcacheTextareaXY[1] = replyWindowY + 2 m.viewcacheTextareaXY[1] = 2
m.viewcacheTextareaXY[2] = textareaWidth m.viewcacheTextareaXY[2] = textareaWidth
m.viewcacheTextareaXY[3] = textareaHeight m.viewcacheTextareaXY[3] = textareaHeight