package tui import ( "charm.land/bubbles/v2/list" tea "charm.land/bubbletea/v2" ) func positiveSize(value int) int { if value < 1 { return 1 } return value } func resizeList(model *list.Model, width, height int) { model.SetWidth(width) model.SetHeight(height) } func (m *Model) resizeForTerminal(width, height int) { m.termWidth = width m.termHeight = height viewportWidth := positiveSize(width) viewportHeight := positiveSize(height) contentWidth := positiveSize(width - 10) contentHeight := positiveSize(height - 15) m.viewport.SetWidth(viewportWidth) m.viewport.SetHeight(viewportHeight) m.outputViewport.SetWidth(contentWidth) m.outputViewport.SetHeight(positiveSize(height / 2)) m.logsViewport.SetWidth(contentWidth) m.logsViewport.SetHeight(contentHeight) m.jobDetailViewport.SetWidth(contentWidth) m.jobDetailViewport.SetHeight(contentHeight) lists := []*list.Model{ &m.menuList, &m.installMenuList, &m.updateList, &m.uninstallList, &m.restoreConfigList, &m.majorLangList, &m.regionLangList, &m.selectedLangList, &m.langPreferenceList, &m.configOptionsList, &m.hwaOptionsList, &m.screenshotOptionsList, &m.fileAssociationsList, &m.webUIList, &m.hotkeysList, &m.hotkeysCategoryList, &m.hotkeysPresetList, &m.screenshotValueList, &m.uiSelectList, &m.uiAppList, &m.hotkeysBindingsList, &m.modernzList, &m.uoscList, &m.installPathList, &m.jobHistoryList, } for _, model := range lists { resizeList(model, contentWidth, contentHeight) } } func (m *Model) handleInstallOutputScroll(key rune) bool { switch key { case tea.KeyUp: m.outputViewport.ScrollUp(1) m.autoScroll = false case tea.KeyDown: m.outputViewport.ScrollDown(1) m.autoScroll = m.outputViewport.AtBottom() case tea.KeyPgUp: m.outputViewport.PageUp() m.autoScroll = false case tea.KeyPgDown: m.outputViewport.PageDown() m.autoScroll = m.outputViewport.AtBottom() case tea.KeyHome: m.outputViewport.GotoTop() m.autoScroll = false case tea.KeyEnd: m.outputViewport.GotoBottom() m.autoScroll = true default: return false } return true }