-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignals_windows.go
More file actions
54 lines (44 loc) · 1.19 KB
/
Copy pathsignals_windows.go
File metadata and controls
54 lines (44 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//go:build windows
package main
import (
"time"
"github.com/slzatz/vimango/rawmode"
)
// setupSignalHandling sets up platform-specific signal handling
// On Windows, we use polling to detect terminal resize since SIGWINCH doesn't exist
func setupSignalHandling(app *App) {
// Start background goroutine to poll for terminal size changes
go func() {
// Get initial terminal size
ws, err := rawmode.GetWindowSize()
if err != nil {
return // If we can't get initial size, skip resize detection
}
prevRows := ws.Row
prevCols := ws.Col
ticker := time.NewTicker(100 * time.Millisecond) // Poll every 100ms
defer ticker.Stop()
for {
select {
case <-ticker.C:
// Check if application is still running
if !app.Run {
return
}
// Get current terminal size
currentWs, err := rawmode.GetWindowSize()
if err != nil {
continue // Skip this iteration if we can't get size
}
// Check if size has changed
if currentWs.Row != prevRows || currentWs.Col != prevCols {
// Size changed, call the signal handler
app.signalHandler()
// Update previous size
prevRows = currentWs.Row
prevCols = currentWs.Col
}
}
}
}()
}