Hacker News new | past | comments | ask | show | jobs | submit login
Building Reactive Terminal Interfaces in C++ (hackernoon.com)
30 points by grey_shirts on Aug 22, 2017 | hide | past | favorite | 3 comments



I see that Pixel represents each character on the screen as a "char". This does not seem a simplification made when writing the blog post, as the Rxterm library does the same [1]. Doesn't this limit too much the applicability of the code? There are plenty of interesting Unicode characters to use in a terminal interface (e.g., non-English alphabets, box drawing characters) that cannot be represented using a char.

I imagine that the choice was due to simplicity, as just changing "char" to "char32_t" does not completely solve the situation because of Unicode's combination characters. What one would need here is a "Pixel" structure capable to hold any Unicode grapheme, which unfortunately can be an arbitrary long sequence of bytes in any UTF8/16/32 encoding.

I am writing this because a few months ago I was trying to create some library similar to RxTerm and build a structure very similar to RxTerm's "Pixel", but got struck in inventing a smart way to keep a matrix of graphemes representing the state of the terminal screen. I gave up because the only idea I had was to use "std::string" within Pixel, and this didn't satisfy my taste.

Also, it seems that RxTerm does not use a terminfo database, but it just hardcodes ANSI escape sequences [2]. I understand that the concept of a terminfo database was invented when the number of incompatible terminals out there was far larger than today. How much widespread are today the escape sequences (cursor movements, color, font styles, etc.) used by libraries like RxTerm?

[1] https://github.com/LoopPerfect/rxterm/blob/master/rxterm/inc...

[2] https://github.com/LoopPerfect/rxterm/blob/master/rxterm/inc...


Thanks for sharing! This is awesome because it's so much easier to embed than Python Prompt Toolkit, which IMO is the state of the art for building terminal-based interfaces. RxTerm is exciting though because it isn't constrained performance-wise, is MIT licensed and it compiles to native code and static binaries and overall lends a simpler packaging and distribution experience.

https://github.com/jonathanslenders/python-prompt-toolkit


Looks like a few features are still being developed (most notably text input) but it's a good start.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: