Skip to content

Advice: using tvision to draw console graphics without using the event loop #135

Answered by magiblot
electroly asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, Brian! Happy new year!

Yes, it is certainly possible to use Turbo Vision without the original event loop (app.run()) and to redraw the screen on demand.

Here is a minimalistic example I came up with; it also reads keyboard input and handles screen resizing properly:

#define Uses_TApplication
#define Uses_TEvent
#define Uses_TScreen
#define Uses_TText
#include <tvision/tv.h>

#include <time.h>

class TConsoleView : public TView
{

public:

    TConsoleView(const TRect &bounds) noexcept :
        TView(bounds)
    {
        growMode = gfGrowHiX | gfGrowHiY;
    }

    void draw() override
    {
        TDrawBuffer b;

        TColorAttr bgColor = '\x10';
        b.moveChar(0, ' ', bgCol…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by magiblot
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #133 on January 16, 2024 09:59.