forked from charmbracelet/bubbletea
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.go
More file actions
65 lines (63 loc) · 1.69 KB
/
input.go
File metadata and controls
65 lines (63 loc) · 1.69 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
55
56
57
58
59
60
61
62
63
64
65
package tea
import (
"github.com/charmbracelet/x/input"
)
// translateInputEvent translates an input event into a Bubble Tea Msg.
func (p *Program) translateInputEvent(e input.Event) Msg {
switch e := e.(type) {
case input.ClipboardEvent:
switch e.Selection {
case input.SystemClipboard:
return ClipboardMsg(e.Content)
case input.PrimaryClipboard:
return PrimaryClipboardMsg(e.Content)
}
case input.ForegroundColorEvent:
return ForegroundColorMsg(e)
case input.BackgroundColorEvent:
return BackgroundColorMsg(e)
case input.CursorColorEvent:
return CursorColorMsg(e)
case input.CursorPositionEvent:
return CursorPositionMsg(e)
case input.FocusEvent:
return FocusMsg(e)
case input.BlurEvent:
return BlurMsg(e)
case input.KeyPressEvent:
return KeyPressMsg(e)
case input.KeyReleaseEvent:
return KeyReleaseMsg(e)
case input.MouseClickEvent:
return MouseClickMsg(e)
case input.MouseMotionEvent:
return MouseMotionMsg(e)
case input.MouseReleaseEvent:
return MouseReleaseMsg(e)
case input.MouseWheelEvent:
return MouseWheelMsg(e)
case input.PasteEvent:
return PasteMsg(e)
case input.PasteStartEvent:
return PasteStartMsg(e)
case input.PasteEndEvent:
return PasteEndMsg(e)
case input.WindowSizeEvent:
return WindowSizeMsg(e)
case input.CapabilityEvent:
return CapabilityMsg(e)
case input.TerminalVersionEvent:
return TerminalVersionMsg(e)
case input.KittyEnhancementsEvent:
return KeyboardEnhancementsMsg{
kittyFlags: int(e),
modifyOtherKeys: p.activeEnhancements.modifyOtherKeys,
}
case input.ModifyOtherKeysEvent:
return KeyboardEnhancementsMsg{
modifyOtherKeys: int(e),
kittyFlags: p.activeEnhancements.kittyFlags,
}
}
return e
}