mirror of
https://github.com/fazo96/telecommander.git
synced 2025-01-10 11:34:20 +01:00
rewrote chatbox to support manual scrolling and custom behavior
This commit is contained in:
parent
99c302ac35
commit
94337fa3ef
47
lib/ui.js
47
lib/ui.js
@ -1,4 +1,5 @@
|
||||
var blessed = require('blessed')
|
||||
var ChatBox = require('./ui-widgets/chatbox.js')
|
||||
|
||||
module.exports = function(data){
|
||||
data.statusWindow = "Status"
|
||||
@ -45,18 +46,16 @@ module.exports = function(data){
|
||||
fg: 'white',
|
||||
border: { fg: 'grey' },
|
||||
focus: {
|
||||
border: { fg: 'white' }
|
||||
border: { fg: 'white' },
|
||||
scrollbar: {
|
||||
fg: 'white',
|
||||
bg: 'white'
|
||||
}
|
||||
},
|
||||
selected: { bold: true },
|
||||
scrollbar: {
|
||||
style: {
|
||||
ch: '#',
|
||||
fg: 'white'
|
||||
},
|
||||
track : {
|
||||
ch: '|',
|
||||
fg: 'grey'
|
||||
}
|
||||
fg: 'white', bg: 'white',
|
||||
track: { fg: 'grey', bg: 'grey' }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -71,14 +70,24 @@ module.exports = function(data){
|
||||
width: '20%',
|
||||
border: { type: 'line' },
|
||||
mouse: true,
|
||||
invertSelected: true,
|
||||
/*
|
||||
scrollbar: {
|
||||
ch: ' ',
|
||||
track : {
|
||||
ch: ' '
|
||||
}
|
||||
},
|
||||
*/
|
||||
scrollbar: false, // disabled cause can't change track style when focused
|
||||
invertSelected: false,
|
||||
style: data.getDefaultStyle(),
|
||||
})
|
||||
|
||||
// Function to create a log box
|
||||
data.mkBox = function(label){
|
||||
return blessed.log({
|
||||
var b = ChatBox({
|
||||
keys: true,
|
||||
mouse: true,
|
||||
right: 0,
|
||||
label: label,
|
||||
width: '80%',
|
||||
@ -86,9 +95,20 @@ module.exports = function(data){
|
||||
height: data.screen.height - data.cmdline.height,
|
||||
border: { type: 'line' },
|
||||
scrollable: true,
|
||||
//draggable: true,
|
||||
autoscroll: true,
|
||||
scrollbar: {
|
||||
ch: ' ',
|
||||
fg: 'white',
|
||||
track: {
|
||||
ch: ' ', fg: 'grey', bg: 'grey'
|
||||
}
|
||||
},
|
||||
style: data.getDefaultStyle()
|
||||
})
|
||||
b.key('enter',function(){
|
||||
data.cmdline.focus()
|
||||
})
|
||||
return b
|
||||
}
|
||||
|
||||
// Command line prompt
|
||||
@ -219,7 +239,7 @@ module.exports = function(data){
|
||||
|
||||
// What happens when the user submits a command in the prompt
|
||||
data.cmdline.on('submit',function(value){
|
||||
data.getMsgBox(data.statusWindow).add('< '+value)
|
||||
data.getMsgBox(data.statusWindow).pushLine('< '+value)
|
||||
if(data.selectedWindow === data.statusWindow || data.nameToObj(data.selectedWindow) === undefined){
|
||||
//log('Window:',selectedWindow,'Eval cmd:',value)
|
||||
data.command(value)
|
||||
@ -232,7 +252,6 @@ module.exports = function(data){
|
||||
}
|
||||
data.cmdline.clearValue()
|
||||
data.cmdline.focus()
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
@ -155,6 +155,7 @@ data.whenReady = function(){
|
||||
data.log('Connected')
|
||||
data.connected = true
|
||||
data.downloadData()
|
||||
data.chats.focus()
|
||||
}
|
||||
|
||||
// Downloads stuff
|
||||
@ -216,7 +217,7 @@ data.getMessages = function(name,box){
|
||||
var peer = data.idToPeer(obj.id,type)
|
||||
box.add('Downloading message history for '+name)
|
||||
if(!peer) return log('Could not find peer:',name)
|
||||
data.client.messages.getHistory(peer,0,-1,20,function(res){
|
||||
data.client.messages.getHistory(peer,0,-1,100,function(res){
|
||||
//log(res.toPrintable())
|
||||
//log('Got history for: '+getName(peer.user_id||peer.chat_id,peer.chat_id?'group':'user'))
|
||||
if(!res.messages){
|
||||
|
Loading…
Reference in New Issue
Block a user