2013-07-18 22:56:05 +00:00
|
|
|
var blessed = require('../')
|
2013-07-28 19:29:07 +00:00
|
|
|
, screen;
|
|
|
|
|
|
|
|
screen = blessed.screen({
|
|
|
|
dump: __dirname + '/logs/form.log'
|
|
|
|
});
|
2013-07-17 05:53:34 +00:00
|
|
|
|
|
|
|
var form = blessed.form({
|
|
|
|
parent: screen,
|
|
|
|
mouse: true,
|
|
|
|
keys: true,
|
|
|
|
vi: true,
|
|
|
|
left: 0,
|
|
|
|
top: 0,
|
|
|
|
width: '100%',
|
2013-07-24 20:39:22 +00:00
|
|
|
//height: 12,
|
2015-04-04 06:43:24 +00:00
|
|
|
style: {
|
|
|
|
bg: 'green',
|
|
|
|
// border: {
|
|
|
|
// inverse: true
|
|
|
|
// },
|
|
|
|
scrollbar: {
|
|
|
|
inverse: true
|
|
|
|
}
|
|
|
|
},
|
2013-07-21 10:31:24 +00:00
|
|
|
content: 'foobar',
|
2013-07-24 20:39:22 +00:00
|
|
|
scrollable: true,
|
2015-04-04 06:43:24 +00:00
|
|
|
// border: {
|
|
|
|
// type: 'ch',
|
|
|
|
// ch: ' '
|
|
|
|
// },
|
2013-07-21 10:31:24 +00:00
|
|
|
scrollbar: {
|
2015-04-04 06:43:24 +00:00
|
|
|
ch: ' '
|
2013-07-21 10:31:24 +00:00
|
|
|
}
|
|
|
|
//alwaysScroll: true
|
2013-07-17 05:53:34 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
form.on('submit', function(data) {
|
|
|
|
output.setContent(JSON.stringify(data, null, 2));
|
|
|
|
screen.render();
|
|
|
|
});
|
|
|
|
|
2013-07-21 10:31:24 +00:00
|
|
|
form.key('d', function() {
|
2013-07-23 12:36:27 +00:00
|
|
|
form.scroll(1, true);
|
2013-07-21 10:31:24 +00:00
|
|
|
screen.render();
|
|
|
|
});
|
|
|
|
|
|
|
|
form.key('u', function() {
|
2013-07-23 12:36:27 +00:00
|
|
|
form.scroll(-1, true);
|
2013-07-21 10:31:24 +00:00
|
|
|
screen.render();
|
|
|
|
});
|
|
|
|
|
2013-07-17 05:53:34 +00:00
|
|
|
var set = blessed.radioset({
|
|
|
|
parent: form,
|
2013-07-21 10:31:24 +00:00
|
|
|
left: 1,
|
|
|
|
top: 1,
|
2013-07-17 08:52:21 +00:00
|
|
|
shrink: true,
|
2013-07-17 10:30:42 +00:00
|
|
|
//padding: 1,
|
|
|
|
//content: 'f',
|
2015-04-04 06:43:24 +00:00
|
|
|
style: {
|
|
|
|
bg: 'magenta'
|
|
|
|
}
|
2013-07-17 05:53:34 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var radio1 = blessed.radiobutton({
|
|
|
|
parent: set,
|
|
|
|
mouse: true,
|
|
|
|
keys: true,
|
|
|
|
shrink: true,
|
2015-04-04 06:43:24 +00:00
|
|
|
style: {
|
|
|
|
bg: 'magenta'
|
|
|
|
},
|
2013-07-17 05:53:34 +00:00
|
|
|
height: 1,
|
|
|
|
left: 0,
|
|
|
|
top: 0,
|
|
|
|
name: 'radio1',
|
|
|
|
content: 'radio1'
|
|
|
|
});
|
|
|
|
|
|
|
|
var radio2 = blessed.radiobutton({
|
|
|
|
parent: set,
|
|
|
|
mouse: true,
|
|
|
|
keys: true,
|
|
|
|
shrink: true,
|
2015-04-04 06:43:24 +00:00
|
|
|
style: {
|
|
|
|
bg: 'magenta'
|
|
|
|
},
|
2013-07-17 05:53:34 +00:00
|
|
|
height: 1,
|
|
|
|
left: 15,
|
|
|
|
top: 0,
|
|
|
|
name: 'radio2',
|
|
|
|
content: 'radio2'
|
|
|
|
});
|
|
|
|
|
|
|
|
var text = blessed.textbox({
|
|
|
|
parent: form,
|
|
|
|
mouse: true,
|
|
|
|
keys: true,
|
2015-04-04 06:43:24 +00:00
|
|
|
style: {
|
|
|
|
bg: 'blue'
|
|
|
|
},
|
2013-07-17 05:53:34 +00:00
|
|
|
height: 1,
|
|
|
|
width: 20,
|
|
|
|
left: 1,
|
2013-07-21 10:31:24 +00:00
|
|
|
top: 3,
|
2013-07-17 05:53:34 +00:00
|
|
|
name: 'text'
|
|
|
|
});
|
|
|
|
|
|
|
|
text.on('focus', function() {
|
|
|
|
text.readInput();
|
|
|
|
});
|
|
|
|
|
|
|
|
var check = blessed.checkbox({
|
|
|
|
parent: form,
|
|
|
|
mouse: true,
|
|
|
|
keys: true,
|
|
|
|
shrink: true,
|
2015-04-04 06:43:24 +00:00
|
|
|
style: {
|
|
|
|
bg: 'magenta'
|
|
|
|
},
|
2013-07-17 05:53:34 +00:00
|
|
|
height: 1,
|
2013-07-17 10:30:42 +00:00
|
|
|
left: 28,
|
2013-07-21 10:31:24 +00:00
|
|
|
top: 1,
|
2013-07-17 05:53:34 +00:00
|
|
|
name: 'check',
|
|
|
|
content: 'check'
|
|
|
|
});
|
|
|
|
|
2013-07-19 14:17:21 +00:00
|
|
|
var check2 = blessed.checkbox({
|
|
|
|
parent: form,
|
|
|
|
mouse: true,
|
|
|
|
keys: true,
|
|
|
|
shrink: true,
|
2015-04-04 06:43:24 +00:00
|
|
|
style: {
|
|
|
|
bg: 'magenta'
|
|
|
|
},
|
2013-07-19 14:17:21 +00:00
|
|
|
height: 1,
|
|
|
|
left: 28,
|
2013-07-21 10:31:24 +00:00
|
|
|
top: 14,
|
2013-07-19 14:17:21 +00:00
|
|
|
name: 'foooooooo2',
|
|
|
|
content: 'foooooooo2'
|
|
|
|
});
|
|
|
|
|
2013-07-17 05:53:34 +00:00
|
|
|
var submit = blessed.button({
|
|
|
|
parent: form,
|
|
|
|
mouse: true,
|
|
|
|
keys: true,
|
2013-07-17 10:30:42 +00:00
|
|
|
shrink: true,
|
2013-07-19 07:28:31 +00:00
|
|
|
padding: {
|
|
|
|
left: 1,
|
|
|
|
right: 1
|
|
|
|
},
|
2013-07-21 10:31:24 +00:00
|
|
|
left: 29,
|
|
|
|
top: 3,
|
2013-07-17 05:53:34 +00:00
|
|
|
shrink: true,
|
|
|
|
name: 'submit',
|
|
|
|
content: 'submit',
|
2013-07-17 06:37:57 +00:00
|
|
|
style: {
|
|
|
|
bg: 'blue',
|
|
|
|
focus: {
|
|
|
|
bg: 'red'
|
|
|
|
}
|
2013-07-17 05:53:34 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
submit.on('press', function() {
|
|
|
|
form.submit();
|
|
|
|
});
|
|
|
|
|
2013-07-23 12:36:27 +00:00
|
|
|
var box1 = blessed.box({
|
|
|
|
parent: form,
|
|
|
|
left: 1,
|
|
|
|
top: 10,
|
|
|
|
height: 10,
|
|
|
|
width: 10,
|
|
|
|
content: 'one',
|
2015-04-04 06:43:24 +00:00
|
|
|
style: {
|
|
|
|
bg: 'cyan'
|
|
|
|
}
|
2013-07-23 12:36:27 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var box2 = blessed.box({
|
|
|
|
parent: box1,
|
|
|
|
left: 1,
|
|
|
|
top: 2,
|
|
|
|
height: 8,
|
|
|
|
width: 9,
|
|
|
|
content: 'two',
|
2015-04-04 06:43:24 +00:00
|
|
|
style: {
|
|
|
|
bg: 'magenta'
|
|
|
|
}
|
2013-07-23 12:36:27 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var box3 = blessed.box({
|
|
|
|
parent: box2,
|
|
|
|
left: 1,
|
|
|
|
top: 2,
|
|
|
|
height: 6,
|
|
|
|
width: 8,
|
|
|
|
content: 'three',
|
2015-04-04 06:43:24 +00:00
|
|
|
style: {
|
|
|
|
bg: 'yellow'
|
|
|
|
}
|
2013-07-23 12:36:27 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var box4 = blessed.box({
|
|
|
|
parent: box3,
|
|
|
|
left: 1,
|
|
|
|
top: 2,
|
|
|
|
height: 4,
|
|
|
|
width: 7,
|
|
|
|
content: 'four',
|
2015-04-04 06:43:24 +00:00
|
|
|
style: {
|
|
|
|
bg: 'blue'
|
|
|
|
}
|
2013-07-23 12:36:27 +00:00
|
|
|
});
|
|
|
|
|
2013-07-17 05:53:34 +00:00
|
|
|
var output = blessed.scrollabletext({
|
2013-07-24 20:39:22 +00:00
|
|
|
parent: form,
|
2013-07-17 05:53:34 +00:00
|
|
|
mouse: true,
|
|
|
|
keys: true,
|
|
|
|
left: 0,
|
2013-07-24 20:39:22 +00:00
|
|
|
top: 20,
|
|
|
|
height: 5,
|
2013-07-24 22:16:55 +00:00
|
|
|
left: 0,
|
|
|
|
right: 0,
|
2015-04-04 06:43:24 +00:00
|
|
|
style: {
|
|
|
|
bg: 'red'
|
|
|
|
},
|
2013-07-17 05:53:34 +00:00
|
|
|
content: 'foobar'
|
|
|
|
});
|
|
|
|
|
2013-07-29 15:22:08 +00:00
|
|
|
var bottom = blessed.line({
|
|
|
|
parent: form,
|
|
|
|
type: 'line',
|
|
|
|
orientation: 'horizontal',
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
|
|
|
top: 50,
|
2015-04-04 06:43:24 +00:00
|
|
|
style: {
|
|
|
|
fg: 'blue'
|
|
|
|
}
|
2013-07-29 15:22:08 +00:00
|
|
|
});
|
|
|
|
|
2013-07-17 05:53:34 +00:00
|
|
|
screen.key('q', function() {
|
|
|
|
return process.exit(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
form.focus();
|
|
|
|
|
|
|
|
form.submit();
|
|
|
|
|
|
|
|
screen.render();
|