Author Topic: BearLibTerminal: a pseudo-terminal window library for roguelike  (Read 19926 times)

Cfyz

  • Bishop
  • ***
  • Posts: 170
    • View Profile
    • Email
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #180 on: January 22, 2017, 11:14:53 PM »
Quote from: KM
and now when I import it, I'm getting strange errors.
This is because wrapper (.py) and binary (.dll) do not match. Specifically, you import the old wrapper since there is no such lines in the new one. There is no PyBearLibTerminal.py anymore either (see this), so you probably just copied the new dll only without updating the wrapper/repacking the app.

When I bundle the script with py2exe, it notices the 'from bearlibterminal' import clause and copies the module files (module installed by pip) into the bundle so there is no need to have an additional PyBearLibTerminal.py in your source. The .dll is another story, no bundler seems to be capable to auto-include binaries, so you have to copy this one manually to the exe directory.

KM

  • Acolyte
  • *
  • Posts: 13
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #181 on: January 28, 2017, 10:24:01 PM »
This is typically what makes me lose interest in Python; I can never get all the dependencies right.  I'm not able to pip anything; what should a folder with this working contain?

EDIT:
Nevermind, thanks Cfyz, I've got it working again. 
« Last Edit: January 28, 2017, 10:33:46 PM by KM »

Saafris

  • Acolyte
  • *
  • Posts: 2
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #182 on: January 31, 2017, 03:19:49 PM »
I've been working on a project using this library (very happy with it!), and I'm planning for the future - specifically, if I want to do more advanced graphics than just what is included in the library.

For example, if I wanted a little orb to be circling around a character, I might use BearLibTerminal for placing all the tiles and sprites, but then do some graphics coding of my own for the orbiting orb.

Don't suppose there's any easy way to getting at the OpenGL so I can implement my own additional graphical effects on top of what's rendered, is there? Or would I have to fork, modify, and compile the library on my own?

Edit:
Project is in C++, by the way.
« Last Edit: January 31, 2017, 03:21:47 PM by Saafris »

Cfyz

  • Bishop
  • ***
  • Posts: 170
    • View Profile
    • Email
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #183 on: January 31, 2017, 05:35:04 PM »
Quote from: Saafris
Don't suppose there's any easy way to getting at the OpenGL so I can implement my own additional graphical effects on top of what's rendered, is there? Or would I have to fork, modify, and compile the library on my own?
Indeed, there is currently no way to do custom rendering. Reliable custom rendering requires support and guarantees from the library, which is far from its focus of abstracting the output.

That said, I do try to make the library capable to perform various tricks without diving into relatively low-level stuff. For example, a circling orb may be implemented via overlayed tile with offset. Take a look at "Extended 1: basics" (lines 42-49) entry in SampleOmni, those circling characters are flying around one spot.

Avagart

  • 7DRL Reviewer
  • High Priest
  • *
  • Posts: 440
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #184 on: February 01, 2017, 11:40:50 AM »
Just figured out that you made BaerLibTerminal bindings for Go. It's awesome, I'll check it in the near future, but - already, thank you very much :)

Elronnd

  • Acolyte
  • *
  • Posts: 6
    • View Profile
    • NetHack and Slash'EM EU server
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #185 on: February 14, 2017, 01:58:49 AM »
Hi, is it possible to make it so that the cursor doesn't blink at all?  I tried setting terminal.set("input.cursor-blink-rate=0");, but that only made the cursor blink as fast as it could.  Can you special-case 0 so that the cursor doesn't blink at all when you set the cursor-blink-rate to 0; or set another boolean value, input.cursor-blink?
Wishes, wishes.  Wish in one hand and do something else in the other, and squeeze them both and see which comes true

 —Roger Zelazny, Nine Princes in Amber

Looks like a fish, moves like a fish, steers like a cow.

 —Douglas Adams, Hitchhiker's Guide to the Galaxy Fit the Fifth

Elronnd

  • Acolyte
  • *
  • Posts: 6
    • View Profile
    • NetHack and Slash'EM EU server
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #186 on: February 14, 2017, 03:47:48 AM »
I made a set of D bindings!  Now guaranteed not to segfault: http://code.dlang.org/packages/bearlibterminal
Wishes, wishes.  Wish in one hand and do something else in the other, and squeeze them both and see which comes true

 —Roger Zelazny, Nine Princes in Amber

Looks like a fish, moves like a fish, steers like a cow.

 —Douglas Adams, Hitchhiker's Guide to the Galaxy Fit the Fifth

Cfyz

  • Bishop
  • ***
  • Posts: 170
    • View Profile
    • Email
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #187 on: February 14, 2017, 12:23:42 PM »
Quote from: Elronnd
Can you special-case 0 so that the cursor doesn't blink at all when you set the cursor-blink-rate to 0
Good idea. I was about to suggest using some really large number as a workaround in the meantime, but noticed you've done exactly that =).

Quote from: Elronnd
I made a set of D bindings! Now guaranteed not to segfault
Ah, in the end I was not fast enough =|. Good in any case!

Elronnd

  • Acolyte
  • *
  • Posts: 6
    • View Profile
    • NetHack and Slash'EM EU server
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #188 on: February 14, 2017, 04:36:11 PM »
Quote from: Elronnd
I made a set of D bindings! Now guaranteed not to segfault
Ah, in the end I was not fast enough =|. Good in any case!

Heh.  Yeah, it turned out that I just didn't know how to allocate memory properly.  I was going to write an sfml gui for my game, but then I decided I'd take just *one* more shot at getting bearlibterminal to work...and it did!
Wishes, wishes.  Wish in one hand and do something else in the other, and squeeze them both and see which comes true

 —Roger Zelazny, Nine Princes in Amber

Looks like a fish, moves like a fish, steers like a cow.

 —Douglas Adams, Hitchhiker's Guide to the Galaxy Fit the Fifth

Junkyardfreak

  • Acolyte
  • *
  • Posts: 1
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #189 on: February 16, 2017, 03:56:02 PM »
So, can someone share a code snippet of a simple menu program in python with a title and 2 options; one to print something and the other to exit the window? I was unable to find much info about the Python bindings. Thanks!

Cfyz

  • Bishop
  • ***
  • Posts: 170
    • View Profile
    • Email
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #190 on: February 16, 2017, 10:37:53 PM »
The 'official' python binding follows the library API fairly closely. The simple snippet would probably be something along the lines:
Code: [Select]
from bearlibterminal import terminal
terminal.open()
while True:
terminal.clear()
terminal.puts(2, 1, 'Choose wisely:\n1. Print something\n2. Exit')
terminal.refresh()
key = terminal.read()
if key == terminal.TK_1:
terminal.clear()
terminal.puts(2, 1, 'something')
terminal.refresh()
terminal.read()
elif key in [terminal.TK_2, terminal.TK_CLOSE]:
break
terminal.close()
The clear+puts+refresh+read combination is a generic 'wipe clean, print some text and wait for any keypress' routine.

There are also some more sophisticated samples transcribed to Python available: https://github.com/ibatugow/blt_samples
« Last Edit: February 16, 2017, 10:41:35 PM by Cfyz »

Saafris

  • Acolyte
  • *
  • Posts: 2
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #191 on: February 20, 2017, 07:56:59 PM »
Quote from: Saafris
Don't suppose there's any easy way to getting at the OpenGL so I can implement my own additional graphical effects on top of what's rendered, is there? Or would I have to fork, modify, and compile the library on my own?
Indeed, there is currently no way to do custom rendering. Reliable custom rendering requires support and guarantees from the library, which is far from its focus of abstracting the output.

That said, I do try to make the library capable to perform various tricks without diving into relatively low-level stuff. For example, a circling orb may be implemented via overlayed tile with offset. Take a look at "Extended 1: basics" (lines 42-49) entry in SampleOmni, those circling characters are flying around one spot.

OK, that makes sense. I'm considering grabbing the source code of the library, and trying to modify it just so I can slide some of my own draw calls in before BearLibTerminal refreshes.
Any suggestions on where to start with that (or if it's even feasible)?