add manpage button

trunk
nbsp 2025-01-05 21:07:39 +02:00
parent d3a492d1be
commit da04fa7ef5
No known key found for this signature in database
GPG Key ID: 7184AC1C9835CE48
6 changed files with 83 additions and 8 deletions

View File

@ -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

View File

@ -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)
}
}
}

23
doc/neofeels.1.scd 100644
View File

@ -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.

4
go.mod
View File

@ -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

2
go.sum
View File

@ -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=

View File

@ -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()
}