1
0
mirror of https://github.com/mrusme/neonmodem.git synced 2024-06-16 06:25:23 +00:00

Fixed sizing issues

This commit is contained in:
マリウス 2023-01-02 17:43:12 -05:00
parent 6fbc9043d8
commit f878acfe05
No known key found for this signature in database
GPG Key ID: 272ED814BF63261F
3 changed files with 17 additions and 25 deletions

View File

@ -113,7 +113,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
ccmds = m.wm.Open(
msg.Target,
postshow.NewModel(m.ctx),
[4]int{3, 2, 9, 10},
[4]int{3, 1, 4, 4},
&msg,
)
m.ctx.Logger.Debugf("got back ccmds: %v\n", ccmds)

View File

@ -153,8 +153,8 @@ func (wm *WM) Resize(id string, w int, h int) []tea.Cmd {
for i := 0; i < len(wm.stack); i++ {
if wm.stack[i].ID == id {
wm.stack[i].Win, tcmd = wm.stack[i].Win.Update(tea.WindowSizeMsg{
Width: w - wm.stack[i].XYWH[2],
Height: h - wm.stack[i].XYWH[3],
Width: w - wm.stack[i].XYWH[0] - wm.stack[i].XYWH[2],
Height: h - wm.stack[i].XYWH[1] - wm.stack[i].XYWH[3],
})
tcmds = append(tcmds, tcmd)
}
@ -169,8 +169,8 @@ func (wm *WM) ResizeAll(w int, h int) []tea.Cmd {
for i := 0; i < len(wm.stack); i++ {
wm.stack[i].Win, tcmd = wm.stack[i].Win.Update(tea.WindowSizeMsg{
Width: w - wm.stack[i].XYWH[2],
Height: h - wm.stack[i].XYWH[3],
Width: w - wm.stack[i].XYWH[0] - wm.stack[i].XYWH[2],
Height: h - wm.stack[i].XYWH[1] - wm.stack[i].XYWH[3],
})
tcmds = append(tcmds, tcmd)
}
@ -182,9 +182,13 @@ func (wm *WM) View(view string) string {
var v string = view
for i := 0; i < len(wm.stack); i++ {
v = helpers.PlaceOverlay(3, 2,
v = helpers.PlaceOverlay(
wm.stack[i].XYWH[0],
wm.stack[i].XYWH[1]+(wm.ctx.Screen[1]-wm.ctx.Content[1]),
wm.stack[i].Win.View(),
v, true)
v,
true,
)
}
return v

View File

@ -15,7 +15,6 @@ import (
"github.com/mrusme/gobbs/models/reply"
"github.com/mrusme/gobbs/ui/cmd"
"github.com/mrusme/gobbs/ui/ctx"
"github.com/mrusme/gobbs/ui/helpers"
)
var (
@ -94,7 +93,7 @@ func NewModel(c *ctx.Ctx) Model {
m := Model{
ctx: c,
keymap: DefaultKeyMap,
wh: [2]int{0,0},
wh: [2]int{0, 0},
buffer: "",
replyIDs: []string{},
@ -149,8 +148,8 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.wh[0] = msg.Width
m.wh[1] = msg.Height
m.ctx.Logger.Debugf("received WindowSizeMsg: %v\n", m.wh)
viewportWidth := m.wh[0]
viewportHeight := m.wh[1]
viewportWidth := m.wh[0] - 2
viewportHeight := m.wh[1] - 5
viewportStyle.Width(viewportWidth)
viewportStyle.Height(viewportHeight)
@ -238,12 +237,6 @@ func (m Model) View() string {
func (m Model) buildView(cached bool) string {
var view strings.Builder = strings.Builder{}
var l string = ""
view.WriteString(lipgloss.JoinHorizontal(
lipgloss.Top,
l,
))
var style lipgloss.Style
if m.focused {
style = m.ctx.Theme.DialogBox.Titlebar.Focused
@ -267,16 +260,11 @@ func (m Model) buildView(cached bool) string {
var tmp string
if m.focused {
tmp = helpers.PlaceOverlay(3, 2,
m.ctx.Theme.DialogBox.Window.Focused.Render(ui),
view.String(), true)
tmp = m.ctx.Theme.DialogBox.Window.Focused.Render(ui)
} else {
tmp = helpers.PlaceOverlay(3, 2,
m.ctx.Theme.DialogBox.Window.Blurred.Render(ui),
view.String(), true)
tmp = m.ctx.Theme.DialogBox.Window.Blurred.Render(ui)
}
view = strings.Builder{}
view.WriteString(tmp)
return view.String()
@ -354,7 +342,7 @@ func (m *Model) renderReplies(
m.allReplies = append(m.allReplies, &(*replies)[ri])
idx := len(m.replyIDs) - 1
replyIdPadding := (m.viewport.Width-len(author)-len(inReplyTo)-28)
replyIdPadding := (m.viewport.Width - len(author) - len(inReplyTo) - 28)
if replyIdPadding < 0 {
replyIdPadding = 0
}