Compare commits

...

2 Commits

Author SHA1 Message Date
aoife cassidy
8f1eacab87
hackiest fix of the CENTURY omlord 2025-01-19 12:32:59 +02:00
aoife cassidy
92b6d030a6
fix hacky terminal, part 1 2025-01-19 12:15:57 +02:00
3 changed files with 9 additions and 14 deletions

View File

@ -2,6 +2,7 @@ package app
import ( import (
"fmt" "fmt"
"os"
"os/exec" "os/exec"
"os/user" "os/user"
@ -52,11 +53,11 @@ like before, when you're done, type `},
} }
func (view *Editor) Event(state *ui.State, event vaxis.Event) (processed bool) { func (view *Editor) Event(state *ui.State, event vaxis.Event) (processed bool) {
win := state.Window() win := state.Window().New(0, 16, 80, 80)
view.Draw(state) view.Draw(state)
vt := term.New() vt := term.New()
vt.Draw(win.New(0, 16, 80, 80)) vt.TERM = os.Getenv("TERM")
vt.Attach(state.PostEvent()) vt.Attach(state.PostEvent())
vt.Focus() vt.Focus()
err := vt.Start(exec.Command("bash", "-l")) err := vt.Start(exec.Command("bash", "-l"))
@ -76,15 +77,12 @@ func (view *Editor) Event(state *ui.State, event vaxis.Event) (processed bool) {
return return
case vaxis.Redraw: case vaxis.Redraw:
view.Draw(state) view.Draw(state)
vt.Draw(win.New(0, 16, 80, 80)) vt.Draw(win)
state.Render() state.Render()
continue continue
} }
// for some reason vaxis doubles all events for Press/Release so this just ignores releases vt.Update(ev)
if key, ok := ev.(vaxis.Key); ok && key.EventType == vaxis.EventPress {
vt.Update(ev)
}
} }
return return

View File

@ -1,6 +1,7 @@
package app package app
import ( import (
"os"
"os/exec" "os/exec"
"git.sr.ht/~rockorager/vaxis" "git.sr.ht/~rockorager/vaxis"
@ -47,7 +48,7 @@ func (view *Shell) Event(state *ui.State, event vaxis.Event) (processed bool) {
view.Draw(state) view.Draw(state)
vt := term.New() vt := term.New()
vt.Draw(win) vt.TERM = os.Getenv("TERM")
vt.Attach(state.PostEvent()) vt.Attach(state.PostEvent())
vt.Focus() vt.Focus()
err := vt.Start(exec.Command("bash", "-l")) err := vt.Start(exec.Command("bash", "-l"))
@ -72,10 +73,7 @@ func (view *Shell) Event(state *ui.State, event vaxis.Event) (processed bool) {
continue continue
} }
// for some reason vaxis doubles all events for Press/Release so this just ignores releases vt.Update(ev)
if key, ok := ev.(vaxis.Key); ok && key.EventType == vaxis.EventPress {
vt.Update(ev)
}
} }
return return

View File

@ -15,7 +15,7 @@ type View interface {
var Events = make(chan vaxis.Event) var Events = make(chan vaxis.Event)
var Quit = make(chan struct{}) var Quit = make(chan struct{})
var ViewChange = make(chan View, 1) var ViewChange = make(chan View, 10)
type State struct { type State struct {
content View content View
@ -25,7 +25,6 @@ type State struct {
func New(view View) (state State, err error) { func New(view View) (state State, err error) {
vx, err := vaxis.New(vaxis.Options{ vx, err := vaxis.New(vaxis.Options{
DisableMouse: true, DisableMouse: true,
CSIuBitMask: vaxis.CSIuDisambiguate | vaxis.CSIuReportEvents | vaxis.CSIuAlternateKeys | vaxis.CSIuAllKeys | vaxis.CSIuAssociatedText,
}) })
if err != nil { if err != nil {
return return