~mariusor/motley

c02c350d2448b89f8503891d0ded401ebde5cf9c — Marius Orcsik 4 months ago fcc05b8
Add an ASCII art model for displaying text on the pager panel when there's no valid object selected
3 files changed, 23 insertions(+), 7 deletions(-)

M go.mod
M item_model.go
M ui.go
M go.mod => go.mod +1 -0
@@ 35,6 35,7 @@ require (
	github.com/atotto/clipboard v0.1.4 // indirect
	github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
	github.com/cespare/xxhash/v2 v2.2.0 // indirect
	github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be // indirect
	github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
	github.com/dgraph-io/badger/v4 v4.2.0 // indirect
	github.com/dgraph-io/ristretto v0.1.1 // indirect

M item_model.go => item_model.go +3 -1
@@ 279,6 279,7 @@ func (i itemModel) updateAsModel(msg tea.Msg) (itemModel, tea.Cmd) {
	case tea.WindowSizeMsg:
		i.logFn("item resize: %+v", msg)
	case nodeUpdateMsg:
		var content tea.Model = M
		if mm.n != nil {
			i.item = mm.n.Item
			if !(vocab.IsIRI(i.item) || vocab.IsItemCollection(i.item)) {


@@ 286,9 287,10 @@ func (i itemModel) updateAsModel(msg tea.Msg) (itemModel, tea.Cmd) {
				if err := vocab.OnObject(i.item, ob.updateObject); err != nil {
					cmds = append(cmds, errCmd(err))
				}
				i.model = ob
				content = ob
			}
		}
		i.model = content
	case tea.KeyMsg:
		switch mm.String() {
		case "home", "g":

M ui.go => ui.go +19 -6
@@ 10,9 10,9 @@ import (
	"github.com/charmbracelet/bubbles/key"
	tea "github.com/charmbracelet/bubbletea"
	"github.com/charmbracelet/lipgloss"
	"github.com/common-nighthawk/go-figure"
	pub "github.com/go-ap/activitypub"
	tree "github.com/mariusor/bubbles-tree"
	"github.com/muesli/reflow/wordwrap"
	"github.com/sirupsen/logrus"
)



@@ 421,11 421,6 @@ func NewColorPair(dark, light string) lipgloss.AdaptiveColor {
	return lipgloss.AdaptiveColor{Dark: dark, Light: light}
}

// Wrap wraps lines at a predefined width via package muesli/reflow.
func Wrap(s string) string {
	return wordwrap.String(s, wrapAt)
}

// Returns a termenv style with foreground and background options.
func newStyle(fg, bg ColorPair, bold bool) func(...string) string {
	s := lipgloss.Style{}.Foreground(fg).Background(bg)


@@ 455,3 450,21 @@ func max(a, b int) int {
func clamp(v, low, high int) int {
	return min(high, max(low, v))
}

type motelyPager struct {
	Title string
}

func (m motelyPager) Init() tea.Cmd {
	return nil
}
func (m motelyPager) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
	return m, nil
}

func (m motelyPager) View() string {
	tit := figure.NewFigure(m.Title, "", true)
	return tit.String()
}

var M = motelyPager{Title: "Motely"}