diff --git a/test/test-ui1.js b/test/test-ui1.js new file mode 100644 index 0000000..0a438ed --- /dev/null +++ b/test/test-ui1.js @@ -0,0 +1,42 @@ +// jamsh +var ui = UI.UI({ + pages : 1, + styles : {}, + terminal: '', + title : 'Test APP' +}); + +function exit2() { + process.exit(); +} + +print(ui) +ui.init(); + + +ui.pages[1]={ + quit : ui.button({left:1,top:1,content:'QUIT', action:exit2}), + label1 : ui.label({right:1,top:2, content:'Input and text field demo. Hit (CTRL) RETURN ..'}), + input1 : ui.input({left:1, top:4, width:ui.screen.width-2, label:'Field 1'}), + input2 : ui.input({left:1, top:8, width:12, height:6, multiline:true, wrap:true, label:'Field 2'}), + text1 : ui.text({left:1, top:14, width:20, scrollable:true, label:'Multiline Text'}), + info1 : ui.info({right:1, top:8, width:40, height:14, multiline:true, wrap:true, scrollable:true, label:'Info'}), +} +_logs=[] +Log = function () { + var line = Array.prototype.slice.call(arguments).map(function (arg) { + return inspect(arg) }).join(' '); + _logs.push(_logs.length+':'+line); + ui.pages[1].info1.setValue(_logs.join('\n')); + ui.pages[1].info1.scrollBottom(); +} + +ui.screen.key(['escape', 'q', 'C-c'], exit2); +ui.pages[1].input1.setValue('Test'); +ui.pages[1].text1.setValue('Test'); +ui.pages[1].text1.on('enter',Log); +ui.pages[1].input2.on('change',Log); +ui.pages[1].input1.on('enter',Log); + + +ui.start();