1
0
mirror of https://github.com/fazo96/telecommander.git synced 2025-01-10 11:34:20 +01:00

usability and style update

This commit is contained in:
Enrico Fasoli 2015-08-31 13:32:39 +00:00
parent 411dd8af42
commit 99c302ac35
2 changed files with 38 additions and 16 deletions

View File

@ -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()
})
}

View File

@ -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)