From da04fa7ef5bc596176888b58e5f25c831debec31 Mon Sep 17 00:00:00 2001 From: nbsp Date: Sun, 5 Jan 2025 21:07:39 +0200 Subject: [PATCH] add manpage button --- Makefile | 12 +++++++----- app/menu.go | 40 +++++++++++++++++++++++++++++++++++++++- doc/neofeels.1.scd | 23 +++++++++++++++++++++++ go.mod | 4 +++- go.sum | 2 ++ ui/ui.go | 10 +++++++++- 6 files changed, 83 insertions(+), 8 deletions(-) create mode 100644 doc/neofeels.1.scd diff --git a/Makefile b/Makefile index 153fd79..8084c40 100644 --- a/Makefile +++ b/Makefile @@ -7,12 +7,14 @@ all: neofeels doc neofeels: $(GO) build $(GOFLAGS) . -# ifeq (, $(shell which $(SCDOC) 2>/dev/null)) -# $(warning "$(SCDOC) not found, skipping building documentation") +ifeq (, $(shell which $(SCDOC) 2>/dev/null)) +$(warning "$(SCDOC) not found, skipping building documentation") doc: -# else -# doc: doc/neofeels.1 -# $(SCDOC) < doc/neofeels.1.scd > doc/neofeels.1 +else +doc: doc/neofeels.1 +doc/neofeels.1: + $(SCDOC) < doc/neofeels.1.scd > doc/neofeels.1 +endif clean: rm neofeels doc/neofeels.1 diff --git a/app/menu.go b/app/menu.go index ab61bea..f4db832 100644 --- a/app/menu.go +++ b/app/menu.go @@ -1,8 +1,12 @@ package app import ( + "os" + "os/exec" + "git.sr.ht/~rockorager/vaxis" "git.sr.ht/~rockorager/vaxis/widgets/list" + "git.sr.ht/~rockorager/vaxis/widgets/term" "git.tilde.town/nbsp/neofeels/ui" ) @@ -49,7 +53,12 @@ func (menu *MainMenu) Event(state *ui.State, event vaxis.Event) (processed bool) case "Home": menu.list.Home() case "Enter": - ui.ViewChange <- NewCredits() + switch menu.list.Index() { + case 8: + ui.ViewChange <- NewCredits() + case 9: + showManpage(state) + } } processed = true } @@ -66,3 +75,32 @@ func (menu *MainMenu) Event(state *ui.State, event vaxis.Event) (processed bool) win.New(win.Width/2-14, win.Height/2+9, 28, 1).Print(vaxis.Segment{Text: menu.help}) return } + +func showManpage(state *ui.State) { + vt := term.New() + vt.TERM = os.Getenv("TERM") + vt.Attach(state.PostEvent()) + vt.Focus() + err := vt.Start(exec.Command("man", "neofeels")) + if err != nil { + panic(err) + } + defer vt.Close() + + for ev := range state.Events() { + switch ev.(type) { + case term.EventClosed: + state.Window().Clear() + return + case vaxis.Redraw: + vt.Draw(state.Window()) + state.Render() + continue + } + + // for some reason vaxis doubles all events for Press/Release so this just ignores releases + if key, ok := ev.(vaxis.Key); ok && key.EventType == vaxis.EventPress { + vt.Update(ev) + } + } +} diff --git a/doc/neofeels.1.scd b/doc/neofeels.1.scd new file mode 100644 index 0000000..1024cad --- /dev/null +++ b/doc/neofeels.1.scd @@ -0,0 +1,23 @@ +NEOFEELS(1) + +# NAME + +neofeels - a next generation ttbp client + +# DESCRIPTION + +neofeels is a rewrite of feels, the tilde town blogging platform. + +neofeels runs from the command line, providing a hub for writing personal blog +posts and reading posts written by other users of tilde.town. it's a little bit +like livejournal or dreamwidth or tumblr. you can opt to publish your posts to +a public html file hosted on your tilde page, to tilde.town's gopher server, or +keep all your entries private to the tilde.town server. + +todo write the rest + +# AUTHORS + +neofeels was written by ~nbsp. ttbp was originally authored by ~endorphant. +support for neofeels is available by internal mail to nbsp@tilde.town or on the +IRC channel #neofeels. diff --git a/go.mod b/go.mod index f1c7827..8122db5 100644 --- a/go.mod +++ b/go.mod @@ -2,9 +2,11 @@ module git.tilde.town/nbsp/neofeels go 1.23.4 +require git.sr.ht/~rockorager/vaxis v0.11.0 + require ( - git.sr.ht/~rockorager/vaxis v0.11.0 // indirect github.com/containerd/console v1.0.3 // indirect + github.com/creack/pty v1.1.18 // indirect github.com/mattn/go-runewidth v0.0.14 // indirect github.com/mattn/go-sixel v0.0.5 // indirect github.com/rivo/uniseg v0.4.4 // indirect diff --git a/go.sum b/go.sum index 61f99a2..4c399c7 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ git.sr.ht/~rockorager/vaxis v0.11.0 h1:FDEaYCVlC1JVooqrVfMh4Y2GtZBpbkrf/LBAaiLnU git.sr.ht/~rockorager/vaxis v0.11.0/go.mod h1:h94aKek3frIV1hJbdXjqnBqaLkbWXvV+UxAsQHg9bns= github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw= github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= +github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= +github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sixel v0.0.5 h1:55w2FR5ncuhKhXrM5ly1eiqMQfZsnAHIpYNGZX03Cv8= diff --git a/ui/ui.go b/ui/ui.go index a2f48cc..9a42d88 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -64,7 +64,15 @@ func (state *State) Close() { state.vx.Close() } -func (state *State) Redraw() { +func (state *State) PostEvent() func(ev vaxis.Event) { + return state.vx.PostEvent +} + +func (state *State) Events() chan vaxis.Event { + return state.vx.Events() +} + +func (state *State) Render() { state.vx.Render() }