Trying to get keys to the treebrowser

This commit is contained in:
2026-01-30 16:59:26 -06:00
parent 330a2e3ddf
commit 3474f20ce1
2 changed files with 38 additions and 46 deletions

View File

@@ -50,12 +50,10 @@ type ScreenHome struct {
layout *w.LinearLayout
columns *w.LinearLayout
activePds *models.Pds
//pdsListing *w.SimpleListWithHelp
activePds *models.Pds
pdsListing *wd.TreeBrowser
jsonContent *wd.JsonContent
status *wd.StatusBar
stTmBlock *wd.StatusBlock
stPathBlock *wd.StatusBlock
pdsListingTypes []models.EntryType
@@ -105,13 +103,13 @@ func (s *ScreenHome) Init(a *App) {
//s.pdsListing = w.NewSimpleListWithHelp("pdslisting", s.style)
s.pdsListing = wd.NewTreeBrowser("pdslisting", s.style)
s.pdsListing.SetBorder(
[]rune{'─', '┬', '│', '┴', '─', '└', '│', '┌', '├', '─', '┤', '┬', '│', '┴', '┼'},
)
s.pdsListing.SetBorder([]rune{'─', '┬', '│', '┴', '─', '└', '│', '┌', '├', '─', '┤', '┬', '│', '┴', '┼'})
s.pdsListing.SetTitle(strings.Repeat(" ", 30))
s.pdsListing.SetOnSelect(s.selectPdsListingEntry)
s.pdsListing.SetOnChange(s.changePdsList)
s.pdsListing.SetVimMode(viper.GetBool(data.KeyVimMode))
s.pdsListing.SetLogger(s.Log)
s.jsonContent = wd.NewJsonContent("jsoncontent", s.style)
km := s.jsonContent.GetKeyMap()
@@ -148,8 +146,12 @@ func (s *ScreenHome) Init(a *App) {
s.columns.AddAll(s.pdsListing, s.jsonContent)
s.layout.AddAll(s.columns)
s.layout.SetWeight(s.columns, 4)
//s.layout.AddAll(s.columns)
//s.layout.SetLogger(s.Log)
//s.layout.SetWeight(s.columns, 4)
s.layout.Add(s.pdsListing)
s.layout.SetLogger(s.Log)
s.layout.SetWeight(s.pdsListing, 4)
s.menuLayout.SetWidget(s.layout)
}
@@ -182,14 +184,12 @@ func (s *ScreenHome) HandleKey(ev *tcell.EventKey) bool {
}
return s.openPdsEntry.HandleKey(ev)
}
return s.menuLayout.HandleKey(ev)
}
func (s *ScreenHome) HandleTime(ev *tcell.EventTime) {
s.menuLayout.HandleTime(ev)
s.loading.HandleTime(ev)
s.status.HandleTime(ev)
//s.stTmBlock.SetText(time.Now().Format(time.TimeOnly))
}
func (s *ScreenHome) Draw() {
if s.doOpen {
@@ -348,23 +348,11 @@ func (s *ScreenHome) updatePdsListing() {
t.AddChild(c)
}
s.pdsListing.Add(t)
/*
wrk = append(wrk, t)
wrk = append(wrk, v)
s.pdsListingTypes = append(s.pdsListingTypes, models.TypeNSID)
if _, ok := s.expandedEntries[v]; ok {
nsid := s.activePds.NSIDs[i]
rIds := s.activePds.GetRecordIdsFor(nsid)
for j := range rIds {
wrk = append(wrk, fmt.Sprintf("• %s", rIds[j]))
s.pdsListingTypes = append(s.pdsListingTypes, models.TypeRecord)
s.recordIdsToNSIDs[rIds[j]] = nsid
}
}
*/
}
//s.pdsListing.AddChild(wrk)
s.layout.ActivateWidget(s.columns)
s.columns.ActivateWidget(s.pdsListing)
s.pdsListing.SetActive(true)
s.pdsListing.SetFocusable(true)
s.hideCli()
}
@@ -381,7 +369,7 @@ func (s *ScreenHome) changePdsList(tn *wd.TreeNode) bool {
return upd
}
func (s *ScreenHome) updateStatusPathBlock(tn *wd.TreeNode) bool {
// TODO: UpdateStatusPathBlock
s.stPathBlock.SetParts(tn.GetLabelPath())
return true
}
@@ -390,6 +378,7 @@ func (s *ScreenHome) updateJsonView(tn *wd.TreeNode) bool {
return true
}
/*
func (s *ScreenHome) o_selectPdsListingEntry(idx int, nm string) bool {
if !s.o_updateJsonView(idx, nm) {
return false
@@ -414,25 +403,6 @@ func (s *ScreenHome) o_selectPdsListingEntry(idx int, nm string) bool {
return false
}
func (s *ScreenHome) o_changePdsList(idx int, nm string) bool {
upd := s.o_updateJsonView(idx, nm)
upd = s.o_updateStatusPathBlock(idx, nm)
return upd
}
func (s *ScreenHome) o_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))
return false
}
switch s.pdsListingTypes[idx] {
case models.TypeNSID:
s.stPathBlock.SetParts([]string{s.activePds.AtId.String(), nm})
case models.TypeRecord:
nsidNm := s.activePds.GetNSIDForRecordId(nm).String()
s.stPathBlock.SetParts([]string{s.activePds.AtId.String(), nsidNm, nm})
}
return true
}
func (s *ScreenHome) o_updateJsonView(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))
@@ -464,3 +434,4 @@ func (s *ScreenHome) o_updateJsonView(idx int, nm string) bool {
return false
}
*/