Author Topic: Sodna: A lightweight virtual terminal library  (Read 5246 times)

rsaarelm

  • Newcomer
  • Posts: 33
  • Karma: +0/-0
    • View Profile
    • Email
Sodna: A lightweight virtual terminal library
« on: October 06, 2013, 09:22:10 AM »
I wanted a library for bringing up a graphical terminal window, drawing characters on it, reading user input, and doing nothing else. Here's the one I made: https://github.com/rsaarelm/sodna/

The header is all there is to the interface. The screen buffer is an array to 32-bit cells, which contain the 8-bit character and 12-bit background and foreground colors. You draw on the screen by getting the pointer from the interface and modifying the array. The demo program provides a more detailed usage example.

My use case for this is calling the library through a foreign function interface from a non-C language, so I want to keep the library free of any kind of application logic that could just as well be implemented on the host language. Sodna's role is to stick to the window management, graphical display and input handling which has to access external systems.

It's MIT licensed, feel free to pick it up if it looks like something you could use.

george

  • Rogueliker
  • ***
  • Posts: 201
  • Karma: +1/-1
    • View Profile
    • Email
Re: Sodna: A lightweight virtual terminal library
« Reply #1 on: October 06, 2013, 05:26:57 PM »
Cool rsaarelm, can you say a few words about how this compares to something like libtcod?

rsaarelm

  • Newcomer
  • Posts: 33
  • Karma: +0/-0
    • View Profile
    • Email
Re: Sodna: A lightweight virtual terminal library
« Reply #2 on: October 06, 2013, 06:03:48 PM »
Sodna is meant to be a replacement for the terminal display part of libtcod, while leaving out all of libtcod's software logic level bits like the map generator and pathfinding modules.

It's current improvements to libtcod are support of in-memory font bitmap data instead of requiring the font to be loaded from a filesystem bitmap, and automatically zooming the display as the window is resized. You can even use Sodna without any font bitmap data, since the library has the standard 8x8 CGA font baked in, and will use it until the user specifies a different font image.

Sodna currently doesn't support mouse input (I'm still thinking about the best way to represent incoming mouse events). I'd also like for the zoom feature to be pixel perfect instead of scaling exactly to the edges of whatever the current window is, but that looks like it would be some amount of work for a minor bit of visual niceness.