Skip to content

Commit

Permalink
feat: Show a little status indicator for edit status
Browse files Browse the repository at this point in the history
  • Loading branch information
ja-he committed Jul 1, 2024
1 parent 79ce7aa commit ed95dfc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
17 changes: 9 additions & 8 deletions internal/ui/panes/composite_editor_ui_pane.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,20 @@ func (p *CompositeEditorPane) Draw() {
// draw background
style := p.Stylesheet.Editor
status := p.e.GetStatus()
c := '?'
switch status {
case edit.EditorSelected, edit.EditorFocussed:
style = p.Stylesheet.CategoryFallback
case edit.EditorChildActive:
style = p.Stylesheet.CategoryFallback.DarkenedBG(30)
c = '.'
case edit.EditorFocussed:
c = '*'
case edit.EditorInactive:
c = ' '
case edit.EditorSelected:
c = '>'
}
p.Renderer.DrawBox(x, y, w, h, style)
p.Renderer.DrawText(x+1, y, w-2, 1, style, util.TruncateAt(p.e.GetName(), w-2))
if status == edit.EditorFocussed {
p.Renderer.DrawText(x, y, 1, 1, style.Bolded(), ">")
}

// p.Renderer.DrawText(x, y, w, 1, style.Italicized(), string(status))
p.Renderer.DrawText(x, y, 1, 1, style.Bolded(), string(c))

// draw all subpanes
for _, subpane := range p.subpanes {
Expand Down
18 changes: 11 additions & 7 deletions internal/ui/panes/string_editor_ui_pane.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,16 @@ func (p *StringEditorPane) Draw() {
fieldStyle := baseStyle
labelStyle := baseStyle
status := p.e.GetStatus()
if status == edit.EditorSelected {
boxStyle = p.Stylesheet.CategoryFallback
} else if status == edit.EditorFocussed {
fieldStyle = p.Stylesheet.CategoryFallback.DarkenedBG(30)
c := '?'
switch status {
case edit.EditorChildActive:
c = '.'
case edit.EditorFocussed:
c = '*'
case edit.EditorInactive:
c = ' '
case edit.EditorSelected:
c = '>'
}

nameWidth := 8
Expand All @@ -46,9 +52,7 @@ func (p *StringEditorPane) Draw() {

p.Renderer.DrawBox(x, y, w, h, boxStyle)
p.Renderer.DrawText(x+padding, y, nameWidth, h, labelStyle, p.e.GetName())
if status == edit.EditorSelected {
p.Renderer.DrawText(x, y, 1, 1, boxStyle.Bolded(), ">")
}
p.Renderer.DrawText(x, y, 1, 1, boxStyle.Bolded(), string(c))

if status == edit.EditorFocussed {
switch p.e.GetMode() {
Expand Down

0 comments on commit ed95dfc

Please sign in to comment.