-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinput-form.js
More file actions
107 lines (90 loc) · 1.6 KB
/
Copy pathinput-form.js
File metadata and controls
107 lines (90 loc) · 1.6 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
'use strict'; //jshint ignore:line
var blessed = require('blessed'),
screen = blessed.screen();
var form = blessed.form({
parent: screen,
keys: true,
left: 'center',
top: 'center',
width: 30,
height: 8,
bg: 'green',
autoNext: true,
content: 'Add Alert'
});
var greaterThanEdit = blessed.Textbox({
parent: form,
top: 3,
height: 1,
left: 2,
right: 2,
bg: 'black',
keys: true,
inputOnFocus: true,
content: 'test',
});
var submit = blessed.button({
parent: form,
mouse: true,
keys: true,
shrink: true,
padding: {
left: 1,
right: 1
},
left: 10,
bottom: 2,
name: 'submit',
content: 'submit',
style: {
bg: 'blue',
focus: {
bg: 'red'
},
hover: {
bg: 'red'
}
}
});
var cancel = blessed.button({
parent: form,
mouse: true,
keys: true,
shrink: true,
padding: {
left: 1,
right: 1
},
left: 20,
bottom: 2,
name: 'cancel',
content: 'cancel',
style: {
bg: 'blue',
focus: {
bg: 'red'
},
hover: {
bg: 'red'
}
}
});
submit.on('press', function() {
form.submit();
});
cancel.on('press', function() {
form.reset();
});
form.on('submit', function(data) {
form.setContent('Submitted.');
screen.render();
});
form.on('reset', function(data) {
form.setContent('Canceled.');
screen.render();
});
screen.key('q', function() {
process.exit(0);
});
greaterThanEdit.focus();
screen.render();