From 4cd2b8bd81db229126156076d26c6051841a802f Mon Sep 17 00:00:00 2001 From: aoife cassidy Date: Sun, 19 Jan 2025 01:17:39 +0200 Subject: [PATCH] add last page --- app/help.go | 40 ++++++++++++++++++++++++++++++++++++++++ app/shell.go | 18 +++++------------- 2 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 app/help.go diff --git a/app/help.go b/app/help.go new file mode 100644 index 0000000..ffcec3c --- /dev/null +++ b/app/help.go @@ -0,0 +1,40 @@ +package app + +import ( + "git.sr.ht/~rockorager/vaxis" + "git.tilde.town/nbsp/welcome/ui" +) + +type Help struct{} + +func (view *Help) Event(state *ui.State, event vaxis.Event) (processed bool) { + if key, ok := event.(vaxis.Key); ok && key.EventType == vaxis.EventPress { + switch key.String() { + case "Ctrl+c", "Ctrl+d", "Enter": + close(ui.Quit) + } + processed = true + } + win := state.Window() + win.Print( + vaxis.Segment{Text: ` ──── links, help, & goodbye ──── + +good job on getting all the way through this tutorial! i knew you could do it. +while there's a lot of things you can do in town, the tools you just received +should help you traverse the land and get further help if you need it. + +• to join our chatroom and ask for help or just say hi, run `}, + vaxis.Segment{Text: "town chat", Style: vaxis.Style{Foreground: vaxis.IndexColor(3)}}, + vaxis.Segment{Text: ` +• run `}, + vaxis.Segment{Text: "town bbj", Style: vaxis.Style{Foreground: vaxis.IndexColor(3)}}, + vaxis.Segment{Text: ` to see what we're talking about on our bulletin board +• oh, and you've got mail! run `}, + vaxis.Segment{Text: "town mail", Style: vaxis.Style{Foreground: vaxis.IndexColor(3)}}, + vaxis.Segment{Text: ` to see who it's from :) + +press ↲ to quit to a shell! +`}, + ) + return +} diff --git a/app/shell.go b/app/shell.go index 4e25898..252d3d8 100644 --- a/app/shell.go +++ b/app/shell.go @@ -43,21 +43,11 @@ you're ready.`}, } func (view *Shell) Event(state *ui.State, event vaxis.Event) (processed bool) { - if key, ok := event.(vaxis.Key); ok && key.EventType == vaxis.EventPress { - switch key.String() { - case "Ctrl+c", "Ctrl+d": - close(ui.Quit) - case "Enter": - ui.ViewChange <- &Settings{} - } - processed = true - } win := state.Window() - view.Draw(state) vt := term.New() - vt.Draw(win.New(0, 15, 80, 80)) + vt.Draw(win.New(0, 16, 80, 80)) vt.Attach(state.PostEvent()) vt.Focus() err := vt.Start(exec.Command("bash", "-i")) @@ -70,12 +60,14 @@ func (view *Shell) Event(state *ui.State, event vaxis.Event) (processed bool) { switch ev.(type) { case term.EventClosed: state.HideCursor() + vt.Detach() + vt.Close() state.Window().Clear() - ui.ViewChange <- &Introduction{} + ui.ViewChange <- &Help{} return case vaxis.Redraw: view.Draw(state) - vt.Draw(win.New(0, 15, 80, 80)) + vt.Draw(win.New(0, 16, 80, 80)) state.Render() continue }