Closed RichardJohnn closed 6 years ago
Hello @RichardJohnn,
Over a telnet
connection (as well as ssh
connections most of time) the server cannot find out the capabilities of the client terminal.
You got two options: either you continue using the default terminal
instance, but you run your command with COLORTERM=truecolor
(e.g. COLORTERM=truecolor ./dnd
), or you pass the correct option to .createTerminal()
.
BTW the (default) terminal
instance is created using .createTerminal()
with parameters found by .guessTerminal()
. You can pass to the appId
option the codename of your terminal. E.g.:
var term = require( 'terminal-kit' ).createTerminal( {
appId: 'xterm-truecolor' ,
// ...
} ) ;
Correct appId can be found inside the lib/termconfig/
directory (all files basename without extension).
If you manage to build a great game, tell me! I have a similar side-project, a sort of multiplayer version of Dungeon Crawl Stone Soup. But the project is stalled...
hmhm! I did try passing 'gnome-256colors' as the appId and support.trueColor
was true, but things stopped rendering when using ScreenBufferHD. I will keep digging in then, just wanted to make sure it was expected to work out AOK.
Is the code for your game available to take a look at? :)
@RichardJohnn Over telnet and inside the terminal-kit directory, try running COLORTERM=truecolor ./sample/screenbuffer-hd-test.js
, and tell me if it works. It should display three moving boxes with blending effects.
The code of my game is not available yet, I was refactoring it the last time I coded on it. Not sure if I will ever have the time to finish it...
hm not so sure about running a telnet server so i ran an ssh server instead. I tried what you mentioned and that works.
what I have going on might be a little different I think?
const tkit = require('terminal-kit');
require('net').createServer(function(client) {
var buffer, term;
term = tkit.createTerminal({
stdin: client,
stdout: client
});
term.clear();
term.moveTo(1, 1, "ICU");
buffer = tkit.ScreenBufferHD.create({
dst: term
});
buffer.put({
x: 2,
y: 2
}, "Hello");
buffer.draw();
}).listen(2323);
if i telnet localhost 2323
i only see the "ICU", not "Hello". would you expect that to work out?
thank you for your time! i know how it feels having so little of it :|
hmhm drawImage doesn't work out either.
taking a peek in wireshark, nothing is sent over the wire.
i will take a gander at the code later on 👍
good times!
@RichardJohnn Haha, found it... My bad, 15min to remember that a net.socket
is not a TTY stream ^^
Not sure how to achieve that through a socket, many info are lost.
Few things:
term.width
and term.height
createTerminal( {stdin: client, stdout: client, generic: 'xterm-truecolor', appId: 'xterm-truecolor'} )
If you want a full server+telnet approach, you should find a way to open a Node TTY stream (using PTY and SSH?).
But the best approach is to code a true client, and move all terminal-kit stuff there.
Interesting. Looks like I need to read up TTY, PTY and SSH more.
I was thinking I'd make a true client at some point, to support audio or even 3d graphics, but also thought it would be neat to support a simple telnet connection
thank you once again
@RichardJohnn I don't know what I was doing wrong yesterday, since it works perfectly today:
const tkit = require('terminal-kit');
require('net').createServer( client => {
var term = tkit.createTerminal({
stdin: client,
stdout: client,
// Add generic, and appId if it is known (generic *MUST* be xterm-truecolor, appId is the real
// terminal ID)
generic: 'xterm-truecolor',
appId: 'xterm-truecolor'
});
term.clear();
term.moveTo(1, 1, "ICU\n");
// Manually set term width and height
term.width = 80 ;
term.height = 25 ;
var buffer = tkit.ScreenBufferHD.create({
dst: term ,
// define width and height, or it will cover the whole terminal
width: 5 ,
height: 1 ,
x: 2 ,
y: 6
});
buffer.put({
// Don't forget to add colors, or it would write using the default color (which is unknown over telnet)
attr: { r: 86 , g: 48 , b: 12 , bgR: 112 , bgG: 200 , bgB: 50 }
}, "Hello");
buffer.draw();
term.styleReset() ;
term( '\n' ) ;
}).listen(2323);
Like I said earlier, there is no way to guess the terminal width and height over telnet, and it's not possible to detect screen resizing. You have to stick with a common size, or ask the user.
Oh wow! that's great news.. looks like i was missing a lot of info.
I suppose having the user (me;) tweak their environment isn't so bad!
hello, first I'd like to say thanks for the library. I am having fun making a game with clojurescript and this.
I have been using
createTerminal
instead of the plainterminal
because the game is a server for telnet connections, but I can't seem to get the screenbuffers (with lots of fun colors) to work at the same time.does ScreenBufferHD only work with
terminal
?thanks for any tips. i've got kids crawling all over me and i dont get much time to dig into these things