summaryrefslogtreecommitdiff
path: root/tui
diff options
context:
space:
mode:
authorraven <citrons@mondecitronne.com>2026-02-20 13:44:41 -0600
committerraven <citrons@mondecitronne.com>2026-02-20 13:47:05 -0600
commit9b7d0bc49ef17e0382751d79b43e230bd3a6ac0b (patch)
tree2a601ac0417966312c5337d66e42f56ce2091728 /tui
parent5b6196ebe67cf954bae8212c1a33b869da723e11 (diff)
preliminary windows concessionsHEADmaster
Diffstat (limited to 'tui')
-rw-r--r--tui/draw.go2
-rw-r--r--tui/event.go11
-rw-r--r--tui/posix.go16
-rw-r--r--tui/windows.go16
4 files changed, 34 insertions, 11 deletions
diff --git a/tui/draw.go b/tui/draw.go
index f70c98e..c4224ca 100644
--- a/tui/draw.go
+++ b/tui/draw.go
@@ -98,7 +98,7 @@ func Start() error {
return err
}
}
- saved, err = term.MakeRaw(0)
+ saved, err = term.MakeRaw(int(os.Stdin.Fd()))
if err != nil {
return err
}
diff --git a/tui/event.go b/tui/event.go
index d24bd2b..345e61a 100644
--- a/tui/event.go
+++ b/tui/event.go
@@ -2,13 +2,11 @@ package tui
import (
"os"
- "os/signal"
"citrons.xyz/talk/tui/termfo"
"citrons.xyz/talk/tui/termfo/keys"
"strings"
"strconv"
"bufio"
- "syscall"
"sync"
)
@@ -38,14 +36,7 @@ func Events() <-chan Event {
once.Do(func() {
ch := terminfo.FindKeys(bufio.NewReader(os.Stdin))
go readKeys(ch, evChan)
-
- sigs := make(chan os.Signal, 1)
- signal.Notify(sigs, syscall.SIGWINCH)
- go func() {
- for _ = range sigs {
- sendEvent(Event {Resize: true})
- }
- }()
+ go detectSizeChange()
})
return evChan
}
diff --git a/tui/posix.go b/tui/posix.go
new file mode 100644
index 0000000..6a3b859
--- /dev/null
+++ b/tui/posix.go
@@ -0,0 +1,16 @@
+//go:build !windows
+package tui
+
+import (
+ "os"
+ "os/signal"
+ "syscall"
+)
+
+func detectSizeChange() {
+ sigs := make(chan os.Signal, 1)
+ signal.Notify(sigs, syscall.SIGWINCH)
+ for _ = range sigs {
+ sendEvent(Event {Resize: true})
+ }
+}
diff --git a/tui/windows.go b/tui/windows.go
new file mode 100644
index 0000000..61184d3
--- /dev/null
+++ b/tui/windows.go
@@ -0,0 +1,16 @@
+//go:build windows
+package tui
+
+import "time"
+
+func detectSizeChange() {
+ tick := time.Tick(time.Second / 60)
+ size := Size()
+ for _ = range tick {
+ new := Size()
+ if size != new {
+ size = new
+ sendEvent(Event {Resize: true})
+ }
+ }
+}