blob: 8ea168d4bf464d64a3a7be81a2f5721c2352f871 (
plain)
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
|
// basic playground for testing text editor while developing it
const {
ui: {
Pane,
form: {
FocusElement
}
},
util: {
tuiApp
}
} = require('tui-lib')
const TuiTextEditor = require('./index')
class AppElement extends FocusElement {
constructor() {
super()
this.pane = new Pane()
this.addChild(this.pane)
this.editor = new TuiTextEditor()
this.pane.addChild(this.editor)
}
selected() {
this.root.select(this.editor)
}
fixLayout() {
this.fillParent()
this.pane.fillParent()
this.editor.fillParent()
}
keyPressed(keyBuf) {
if (keyBuf[0] === 0x03) {
this.emit('quitRequested')
}
}
}
tuiApp(({root, quitProgram}) => {
const app = new AppElement()
app.on('quitRequested', quitProgram)
root.addChild(app)
root.select(app)
setTimeout(() => app.scheduleDrawWithoutPropertyChange())
})
|