From 84bf14ad11cce63c8db62b78ccac0f77420b3b49 Mon Sep 17 00:00:00 2001 From: sbosse Date: Tue, 27 Aug 2024 00:16:07 +0200 Subject: [PATCH] Tue 27 Aug 00:14:56 CEST 2024 --- test/test-ui6.js | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 test/test-ui6.js diff --git a/test/test-ui6.js b/test/test-ui6.js new file mode 100644 index 0000000..03200ad --- /dev/null +++ b/test/test-ui6.js @@ -0,0 +1,53 @@ +// 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);