jam/test/test-ui6.js

54 lines
1.4 KiB
JavaScript

// jamsh
var ui = UI.UI({
pages : 3,
styles : {},
terminal: '',
title : 'Test APP'
});
function exit2() {
process.exit();
}
ui.init();
ui.pages[1]={
quit : ui.button({left:1,top:1,content:'QUIT', action:exit2}),
butnext : ui.button({right:1,top:1,content:'>>', action:'next'}),
chat1 : ui.chat({left:1, top:6, right:1, height:14, prompt:'> ', label:'My Chat',
bot:{color:'red'}, user:{align:'right',color:'blue'}, fg:{color:'black'}}),
}
ui.pages[2]={
butprev : ui.button({left:1,top:1,content:'<<', action:'prev'}),
label : ui.label({ top:2, center:true ,content:'System Logging'}),
log1 : ui.log({left:1, top:6, right:1, height:14, multiline:true, wrap:true, scrollable:true, label:'Log'}),
}
ui.pages[1].next='2';
ui.pages[2].prev='1';
Log = function () {
var line = Array.prototype.slice.call(arguments).map(function (arg) {
return inspect(arg) }).join(' ');
ui.pages[2].log1.add(line);
ui.pages[2].log1.scrollBottom();
}
ui.pages[1].chat1.on('eval',function (user) {
Log(user);
// ui.pages[1].chat1.print(user,{align:'right',color:'red'});
});
ui.pages[1].chat1.on('clicked',function (ev) {
// Log(ev);
});
ui.pages[1].chat1.on('keypress',function (ch,key) {
// Log(key);
});
ui.pages[1].chat1.message('Hello! I am sam.');
ui.screen.key(['escape', 'q', 'C-c'], exit2);
ui.start(1);