feat: add dedicated Profile management page
This commit is contained in:
@@ -53,26 +53,29 @@ func defaultModelOptions() modelOptions {
|
||||
}
|
||||
|
||||
type presentationState struct {
|
||||
snapshot app.Snapshot
|
||||
page page
|
||||
width int
|
||||
height int
|
||||
selected int
|
||||
selectedTargetID string
|
||||
dashboardFocus dashboardPane
|
||||
showUnavailable bool
|
||||
detailsOffset int
|
||||
form formState
|
||||
confirm bool
|
||||
confirmation *app.Confirmation
|
||||
status string
|
||||
operationStatus app.OperationStatus
|
||||
currentError *operationError
|
||||
errorExpanded bool
|
||||
errorOffset int
|
||||
exitDeferred bool
|
||||
operationActive bool
|
||||
operationProgress map[string]app.TargetProgressPhase
|
||||
snapshot app.Snapshot
|
||||
page page
|
||||
width int
|
||||
height int
|
||||
selected int
|
||||
profileOffset int
|
||||
profileDetails int
|
||||
profileDelete *profileDeleteConfirmation
|
||||
selectedTargetID string
|
||||
dashboardFocus dashboardPane
|
||||
showUnavailable bool
|
||||
detailsOffset int
|
||||
form formState
|
||||
confirmation *app.Confirmation
|
||||
confirmationDialog *confirmationDialog
|
||||
status string
|
||||
operationStatus app.OperationStatus
|
||||
currentError *operationError
|
||||
errorExpanded bool
|
||||
errorOffset int
|
||||
exitDeferred bool
|
||||
operationActive bool
|
||||
operationProgress map[string]app.TargetProgressPhase
|
||||
}
|
||||
|
||||
// terminalPresentation is the terminal-presentation Module. Application
|
||||
@@ -92,6 +95,8 @@ type terminalPage struct {
|
||||
statusExpanded bool
|
||||
statusOffset int
|
||||
focusLine int
|
||||
primaryOffset int
|
||||
contextOffset int
|
||||
dashboard *dashboardRenderState
|
||||
}
|
||||
|
||||
@@ -208,7 +213,7 @@ func (p terminalPresentation) renderShell(page terminalPage, width, height int)
|
||||
|
||||
func renderPageBody(page terminalPage, width, height int) string {
|
||||
if page.context == "" || height < 5 {
|
||||
return viewportContent(page.primary, width, height, page.focusLine)
|
||||
return viewportContentAt(page.primary, width, height, page.primaryOffset, page.focusLine)
|
||||
}
|
||||
|
||||
contextHeight := min(lineCount(page.context), max(3, height/2))
|
||||
@@ -217,20 +222,30 @@ func renderPageBody(page terminalPage, width, height int) string {
|
||||
primaryHeight = 1
|
||||
contextHeight = max(1, height-primaryHeight-1)
|
||||
}
|
||||
primary := viewportContent(page.primary, width, primaryHeight, page.focusLine)
|
||||
context := viewportContent(page.context, width, contextHeight, 0)
|
||||
primary := viewportContentAt(page.primary, width, primaryHeight, page.primaryOffset, page.focusLine)
|
||||
context := viewportContentAt(page.context, width, contextHeight, page.contextOffset, -1)
|
||||
return primary + "\n\n" + context
|
||||
}
|
||||
|
||||
func viewportContent(content string, width, height, focusLine int) string {
|
||||
return viewportContentAt(content, width, height, 0, focusLine)
|
||||
}
|
||||
|
||||
func viewportContentAt(content string, width, height, offset, focusLine int) string {
|
||||
if content == "" || width <= 0 || height <= 0 {
|
||||
return ""
|
||||
}
|
||||
view := viewport.New(width, height)
|
||||
view.SetContent(strings.TrimRight(content, "\n"))
|
||||
if focusLine >= height {
|
||||
view.SetYOffset(focusLine - height + 1)
|
||||
top := max(0, offset)
|
||||
if focusLine >= 0 {
|
||||
if focusLine < top {
|
||||
top = focusLine
|
||||
} else if focusLine >= top+height {
|
||||
top = focusLine - height + 1
|
||||
}
|
||||
}
|
||||
view.SetYOffset(top)
|
||||
return view.View()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user