Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

T3TerminalModule.swift

77 lines2.3 KB

1import ExpoModulesCore
2​
3public class T3TerminalModule: Module {
4 public func definition() -> ModuleDefinition {
5 Name("T3TerminalSurface")
6​
7 // Bumped when native hardware-keyboard handling changes; surfaced in the JS debug
8 // logs so a stale native binary is distinguishable from a broken key pipeline.
9 Constants([
10 "hardwareKeyRevision": 3,
11 "outputRevision": 1,
12 ])
13​
14 View(T3TerminalView.self) {
15 AsyncFunction("writeOutput") { (view: T3TerminalView, data: String, reset: Bool) in
16 view.writeOutput(data, reset: reset)
17 }
18​
19 Prop("terminalKey") { (view: T3TerminalView, terminalKey: String) in
20 view.terminalKey = terminalKey
21 }
22​
23 Prop("initialBuffer") { (view: T3TerminalView, initialBuffer: String) in
24 view.initialBuffer = initialBuffer
25 }
26​
27 Prop("fontSize") { (view: T3TerminalView, fontSize: Double) in
28 view.fontSize = CGFloat(fontSize)
29 }
30​
31 Prop("focusRequest") { (view: T3TerminalView, focusRequest: Double) in
32 view.focusRequest = focusRequest
33 }
34​
35 Prop("readOnly") { (view: T3TerminalView, readOnly: Bool) in
36 view.readOnly = readOnly
37 }
38​
39 Prop("autoFocus") { (view: T3TerminalView, autoFocus: Bool) in
40 view.autoFocus = autoFocus
41 }
42​
43 Prop("appearanceScheme") { (view: T3TerminalView, appearanceScheme: String) in
44 view.appearanceScheme = appearanceScheme
45 }
46​
47 Prop("themeConfig") { (view: T3TerminalView, themeConfig: String) in
48 view.themeConfig = themeConfig
49 }
50​
51 Prop("backgroundColor") { (view: T3TerminalView, backgroundColor: String) in
52 view.backgroundColorHex = backgroundColor
53 }
54​
55 Prop("foregroundColor") { (view: T3TerminalView, foregroundColor: String) in
56 view.foregroundColorHex = foregroundColor
57 }
58​
59 Prop("mutedForegroundColor") { (view: T3TerminalView, mutedForegroundColor: String) in
60 view.mutedForegroundColorHex = mutedForegroundColor
61 }
62​
63 Prop("captureRequest") { (view: T3TerminalView, request: Double) in
64 view.captureRequest = request
65 }
66​
67 Prop("sharedGrid") { (view: T3TerminalView, sharedGrid: [Int]) in
68 view.sharedGrid = sharedGrid
69 }
70 Events("onInput", "onResize", "onCapture")
71​
72 OnViewDidUpdateProps { (view: T3TerminalView) in
73 view.applyPendingBuffer()
74 }
75 }
76 }