Code Monkey home page Code Monkey logo

Comments (9)

cronvel avatar cronvel commented on July 20, 2024

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...

from terminal-kit.

RichardJohnn avatar RichardJohnn commented on July 20, 2024

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? :)

from terminal-kit.

cronvel avatar cronvel commented on July 20, 2024

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

from terminal-kit.

RichardJohnn avatar RichardJohnn commented on July 20, 2024

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 :|

from terminal-kit.

RichardJohnn avatar RichardJohnn commented on July 20, 2024

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!

from terminal-kit.

cronvel avatar cronvel commented on July 20, 2024

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

  • manually set term.width and term.height
  • createTerminal( {stdin: client, stdout: client, generic: 'xterm-truecolor', appId: 'xterm-truecolor'} )
  • terminal resizing will not be detected
  • during my test, it appears that ScreenBufferHD are not working through socket, I don't know why. There is probably a bug somewhere I should investigate... So use standard ScreenBuffer

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.

from terminal-kit.

RichardJohnn avatar RichardJohnn commented on July 20, 2024

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

from terminal-kit.

cronvel avatar cronvel commented on July 20, 2024

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

from terminal-kit.

RichardJohnn avatar RichardJohnn commented on July 20, 2024

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!

from terminal-kit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.