summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/gdamore/tcell/v2/console_win.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/gdamore/tcell/v2/console_win.go')
-rw-r--r--vendor/github.com/gdamore/tcell/v2/console_win.go35
1 files changed, 29 insertions, 6 deletions
diff --git a/vendor/github.com/gdamore/tcell/v2/console_win.go b/vendor/github.com/gdamore/tcell/v2/console_win.go
index ffa004907..66ab4938f 100644
--- a/vendor/github.com/gdamore/tcell/v2/console_win.go
+++ b/vendor/github.com/gdamore/tcell/v2/console_win.go
@@ -1,7 +1,7 @@
//go:build windows
// +build windows
-// Copyright 2023 The TCell Authors
+// Copyright 2024 The TCell Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use file except in compliance with the License.
@@ -51,6 +51,7 @@ type cScreen struct {
oimode uint32
oomode uint32
cells CellBuffer
+ focusEnable bool
mouseEnabled bool
wg sync.WaitGroup
@@ -280,9 +281,17 @@ func (s *cScreen) EnablePaste() {}
func (s *cScreen) DisablePaste() {}
-func (s *cScreen) EnableFocus() {}
+func (s *cScreen) EnableFocus() {
+ s.Lock()
+ s.focusEnable = true
+ s.Unlock()
+}
-func (s *cScreen) DisableFocus() {}
+func (s *cScreen) DisableFocus() {
+ s.Lock()
+ s.focusEnable = false
+ s.Unlock()
+}
func (s *cScreen) Fini() {
s.finiOnce.Do(func() {
@@ -448,8 +457,8 @@ const (
keyEvent uint16 = 1
mouseEvent uint16 = 2
resizeEvent uint16 = 4
- // menuEvent uint16 = 8 // don't use
- // focusEvent uint16 = 16 // don't use
+ menuEvent uint16 = 8 // don't use
+ focusEvent uint16 = 16
)
type mouseRecord struct {
@@ -460,6 +469,10 @@ type mouseRecord struct {
flags uint32
}
+type focusRecord struct {
+ focused int32 // actually BOOL
+}
+
const (
mouseHWheeled uint32 = 0x8
mouseVWheeled uint32 = 0x4
@@ -754,6 +767,16 @@ func (s *cScreen) getConsoleInput() error {
rrec.y = geti16(rec.data[2:])
s.postEvent(NewEventResize(int(rrec.x), int(rrec.y)))
+ case focusEvent:
+ var focus focusRecord
+ focus.focused = geti32(rec.data[0:])
+ s.Lock()
+ enabled := s.focusEnable
+ s.Unlock()
+ if enabled {
+ s.postEvent(NewEventFocus(focus.focused != 0))
+ }
+
default:
}
default:
@@ -1271,5 +1294,5 @@ func (s *cScreen) EventQ() chan Event {
}
func (s *cScreen) StopQ() <-chan struct{} {
- return s.stopQ
+ return s.quit
}