Working on the status bar

This commit is contained in:
2026-01-29 11:19:31 -06:00
parent c84fe6b807
commit abf21d8e1b
4 changed files with 144 additions and 81 deletions

View File

@@ -24,7 +24,6 @@ package app
import (
"fmt"
"strings"
"time"
"git.bullercodeworks.com/brian/expds/data"
"git.bullercodeworks.com/brian/expds/data/models"
@@ -55,7 +54,7 @@ type ScreenHome struct {
pdsListing *w.SimpleListWithHelp
jsonContent *wd.JsonContent
status *wd.StatusBar
stDtTmBlock *wd.StatusBlock
stTmBlock *wd.StatusBlock
stPathBlock *wd.StatusBlock
pdsListingTypes []models.EntryType
@@ -109,7 +108,7 @@ func (s *ScreenHome) Init(a *App) {
)
s.pdsListing.SetTitle(strings.Repeat(" ", 30))
s.pdsListing.SetOnSelect(s.selectPdsListingEntry)
s.pdsListing.SetOnChange(s.updateJsonView)
s.pdsListing.SetOnChange(s.changePdsList)
s.pdsListing.SetVimMode(viper.GetBool(data.KeyVimMode))
s.jsonContent = wd.NewJsonContent("jsoncontent", s.style)
@@ -135,17 +134,14 @@ func (s *ScreenHome) Init(a *App) {
s.jsonContent.SetBorder(
[]rune{'─', '┐', '│', '┘', '─', '─', ' ', '─', '├', '─', '┤', '┬', '│', '┴', '┼'},
)
s.status = wd.NewStatusBar("home.statusbar", s.style)
statusStyle := s.style.Background(tcell.ColorDarkSlateGray)
s.status = wd.NewStatusBar("home.statusbar", statusStyle)
s.status.SetPos(w.Coord{X: 0, Y: s.a.GetH() - 1})
s.status.SetLogger(s.Log)
s.stPathBlock = wd.NewStatusBlock("home.statusbar.block", s.style.Background(tcell.ColorOrange).Foreground(tcell.ColorBlack))
s.stPathBlock = wd.NewStatusBlock("home.statusbar.block", statusStyle.Foreground(tcell.ColorDarkSlateGray).Background(tcell.ColorOrange))
s.stPathBlock.SetType(wd.SBTypePath)
s.status.Add(s.stPathBlock)
s.stPathBlock.SetParts([]string{"dir1", "dir2", "dir3"})
s.stDtTmBlock = wd.NewStatusBlock("home.statusbar.dttm", s.style.Background(tcell.ColorOrange).Foreground(tcell.ColorBlack))
s.stDtTmBlock.SetType(wd.SBTypeText)
s.status.Add(s.stDtTmBlock)
s.status.SetFlag(s.stDtTmBlock, w.LFAlignHRight)
s.columns.AddAll(s.pdsListing, s.jsonContent)
@@ -158,6 +154,7 @@ func (s *ScreenHome) GetName() string { return "home" }
func (s *ScreenHome) HandleResize(ev *tcell.EventResize) {
s.w, s.h = ev.Size()
s.menuLayout.HandleResize(w.Coord{X: s.w, Y: s.h - 1}.ResizeEvent())
s.status.SetPos(w.Coord{X: 0, Y: s.h - 1})
s.status.HandleResize(w.Coord{X: s.w, Y: 1}.ResizeEvent())
}
@@ -188,7 +185,8 @@ func (s *ScreenHome) HandleKey(ev *tcell.EventKey) bool {
func (s *ScreenHome) HandleTime(ev *tcell.EventTime) {
s.menuLayout.HandleTime(ev)
s.loading.HandleTime(ev)
s.stDtTmBlock.SetText(time.Now().Format(time.Kitchen))
s.status.HandleTime(ev)
//s.stTmBlock.SetText(time.Now().Format(time.TimeOnly))
}
func (s *ScreenHome) Draw() {
if s.doOpen {
@@ -325,7 +323,7 @@ func (s *ScreenHome) cliGetPds(args ...string) bool {
s.activePds = pds
s.expandedEntries = make(map[string]interface{})
s.updatePdsListing()
s.updateJsonView(s.pdsListing.SelectedIndex(), s.pdsListing.GetSelectedItem())
s.changePdsList(s.pdsListing.SelectedIndex(), s.pdsListing.GetSelectedItem())
s.isLoading = false
}()
return true
@@ -385,6 +383,7 @@ func (s *ScreenHome) changePdsList(idx int, nm string) bool {
upd = s.updateStatusPathBlock(idx, nm)
return upd
}
func (s *ScreenHome) updateStatusPathBlock(idx int, nm string) bool {
if len(s.pdsListingTypes) < idx {
s.Log("error finding pds listing type (idx: %d >= list length: %d", idx, len(s.pdsListingTypes))
@@ -392,10 +391,10 @@ func (s *ScreenHome) updateStatusPathBlock(idx int, nm string) bool {
}
switch s.pdsListingTypes[idx] {
case models.TypeNSID:
s.stPathBlock.SetParts([]string{nm})
s.stPathBlock.SetParts([]string{s.activePds.AtId.String(), nm})
case models.TypeRecord:
nsidNm := s.activePds.GetNSIDForRecordId(nm).String()
s.stPathBlock.SetParts([]string{nsidNm, nm})
s.stPathBlock.SetParts([]string{s.activePds.AtId.String(), nsidNm, nm})
}
return true
}