From 99c302ac3510cae043fad19ba1f11eb065c0d7de Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Mon, 31 Aug 2015 13:32:39 +0000 Subject: [PATCH] usability and style update --- lib/ui.js | 48 +++++++++++++++++++++++++++++++++++------------- telecommander.js | 6 +++--- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/lib/ui.js b/lib/ui.js index 2d9da7a..dba353f 100644 --- a/lib/ui.js +++ b/lib/ui.js @@ -40,11 +40,24 @@ module.exports = function(data){ }) data.screen.title = "Telecommander" - data.defaultStyle = { - fg: 'white', - border: { fg: 'grey' }, - scrollbar: { - ch: '*' + data.getDefaultStyle = function(){ + return { + fg: 'white', + border: { fg: 'grey' }, + focus: { + border: { fg: 'white' } + }, + selected: { bold: true }, + scrollbar: { + style: { + ch: '#', + fg: 'white' + }, + track : { + ch: '|', + fg: 'grey' + } + } } } @@ -59,9 +72,8 @@ module.exports = function(data){ border: { type: 'line' }, mouse: true, invertSelected: true, - style: data.defaultStyle, + style: data.getDefaultStyle(), }) - data.chats.style.selected = { bold: true } // Function to create a log box data.mkBox = function(label){ @@ -75,21 +87,21 @@ module.exports = function(data){ border: { type: 'line' }, scrollable: true, //draggable: true, - style: data.defaultStyle + style: data.getDefaultStyle() }) } // Command line prompt data.cmdline = blessed.textbox({ - keys: true, + keys: false, + mouse: true, label: 'Command for Telecommander', - inputOnFocus: true, bottom: 0, left: 'center', width: '100%', height: 3, border: { type: 'line' }, - style: data.defaultStyle + style: data.getDefaultStyle() }) // mgsBox holds the chat boxes for every list entry @@ -187,15 +199,24 @@ module.exports = function(data){ data.chats.on('select',function(selected){ //data.log('SELECT:',selected.content) data.switchToBox(selected.content) - data.screen.focusPush(data.cmdline) + data.cmdline.focus() data.screen.render() }) - +/* + data.cmdline.on('click',function(){ + data.cmdline.focus() + data.screen.render() + }) +*/ // Catch ctrl-c or escape event and close program data.screen.key(['escape','C-c'], function(ch,key){ data.quit() }); + data.cmdline.on('focus',function(){ + data.cmdline.readInput() + }) + // What happens when the user submits a command in the prompt data.cmdline.on('submit',function(value){ data.getMsgBox(data.statusWindow).add('< '+value) @@ -211,6 +232,7 @@ module.exports = function(data){ } data.cmdline.clearValue() data.cmdline.focus() + }) } diff --git a/telecommander.js b/telecommander.js index 1ada7b3..0a5333d 100755 --- a/telecommander.js +++ b/telecommander.js @@ -245,10 +245,10 @@ data.appendToUserBox = function(msg,context){ } } if(goesto === undefined){ - if(context.users.list[0].user_id == user.id){ - goesto = data.getMsgBox(getName(context.users.list[1].id,'user')) + if(context.users.list[0].user_id == data.user.id){ + goesto = data.getMsgBox(data.getName(context.users.list[1].id,'user')) } else{ - goesto = data.getMsgBox(getName(context.users.list[0].id,'user')) + goesto = data.getMsgBox(data.getName(context.users.list[0].id,'user')) } } data.appendMsg(msg,goesto,true)