Some work
This commit is contained in:
@@ -24,6 +24,7 @@ package app
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.bullercodeworks.com/brian/expds/data"
|
||||
"git.bullercodeworks.com/brian/expds/data/models"
|
||||
@@ -31,6 +32,7 @@ import (
|
||||
w "git.bullercodeworks.com/brian/tcell-widgets"
|
||||
"github.com/bluesky-social/indigo/atproto/syntax"
|
||||
"github.com/gdamore/tcell"
|
||||
"github.com/skratchdot/open-golang/open"
|
||||
"github.com/spf13/viper"
|
||||
"golang.design/x/clipboard"
|
||||
)
|
||||
@@ -52,6 +54,9 @@ type ScreenHome struct {
|
||||
activePds *models.Pds
|
||||
pdsListing *w.SimpleListWithHelp
|
||||
jsonContent *wd.JsonContent
|
||||
status *wd.StatusBar
|
||||
stDtTmBlock *wd.StatusBlock
|
||||
stPathBlock *wd.StatusBlock
|
||||
|
||||
pdsListingTypes []models.EntryType
|
||||
pdsNSIDs []syntax.NSID
|
||||
@@ -120,11 +125,28 @@ func (s *ScreenHome) Init(a *App) {
|
||||
clipboard.Write(clipboard.FmtText, []byte(s.jsonContent.GetSelectedValue()))
|
||||
return true
|
||||
}),
|
||||
w.NewKey(w.BuildEKr('O'), func(ev *tcell.EventKey) bool {
|
||||
url := fmt.Sprintf("https://%s/xrpc/com.atproto.sync.getBlob?did=did:plc:pqwuemo2ic5tqmpwrajb2phi&cid=%s", s.activePds.AtId.String(), s.jsonContent.GetSelectedValue())
|
||||
open.Run(url)
|
||||
return true
|
||||
}),
|
||||
)
|
||||
s.jsonContent.SetKeyMap(km)
|
||||
s.jsonContent.SetBorder(
|
||||
[]rune{'─', '┐', '│', '┘', '─', '─', ' ', '─', '├', '─', '┤', '┬', '│', '┴', '┼'},
|
||||
)
|
||||
s.status = wd.NewStatusBar("home.statusbar", s.style)
|
||||
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.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)
|
||||
|
||||
s.layout.AddAll(s.columns)
|
||||
@@ -135,7 +157,9 @@ func (s *ScreenHome) Init(a *App) {
|
||||
func (s *ScreenHome) GetName() string { return "home" }
|
||||
func (s *ScreenHome) HandleResize(ev *tcell.EventResize) {
|
||||
s.w, s.h = ev.Size()
|
||||
s.menuLayout.HandleResize(ev)
|
||||
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())
|
||||
}
|
||||
|
||||
func (s *ScreenHome) HandleKey(ev *tcell.EventKey) bool {
|
||||
@@ -164,6 +188,7 @@ 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))
|
||||
}
|
||||
func (s *ScreenHome) Draw() {
|
||||
if s.doOpen {
|
||||
@@ -179,6 +204,7 @@ func (s *ScreenHome) Draw() {
|
||||
if s.isLoading {
|
||||
s.a.DrawWidget(s.loading)
|
||||
}
|
||||
s.a.DrawWidget(s.status)
|
||||
}
|
||||
func (s *ScreenHome) Exit() error { return nil }
|
||||
func (s *ScreenHome) Log(t string, a ...any) {
|
||||
@@ -231,6 +257,7 @@ func (s *ScreenHome) update() {
|
||||
s.menuLayout.SetWidget(s.layout)
|
||||
}
|
||||
s.pdsListing.SetVimMode(viper.GetBool(data.KeyVimMode))
|
||||
s.jsonContent.SetVimMode(viper.GetBool(data.KeyVimMode))
|
||||
vimMI := s.menuLayout.FindItem("settings.vimmode")
|
||||
var vimText = "Enable Vim Mode"
|
||||
if viper.GetBool(data.KeyVimMode) {
|
||||
@@ -353,6 +380,25 @@ func (s *ScreenHome) selectPdsListingEntry(idx int, nm string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *ScreenHome) changePdsList(idx int, nm string) bool {
|
||||
upd := s.updateJsonView(idx, nm)
|
||||
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))
|
||||
return false
|
||||
}
|
||||
switch s.pdsListingTypes[idx] {
|
||||
case models.TypeNSID:
|
||||
s.stPathBlock.SetParts([]string{nm})
|
||||
case models.TypeRecord:
|
||||
nsidNm := s.activePds.GetNSIDForRecordId(nm).String()
|
||||
s.stPathBlock.SetParts([]string{nsidNm, nm})
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (s *ScreenHome) 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))
|
||||
|
||||
Reference in New Issue
Block a user