bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: is there any way to print out unsanitized output?


From: Thomas Dickey
Subject: Re: is there any way to print out unsanitized output?
Date: Sat, 1 Oct 2016 21:56:05 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

On Thu, Sep 29, 2016 at 10:01:59AM -0700, elronnd wrote:
> Not a bug, per se, but a question about how to use ncurses.  I
> understand that ncurses doesn't natively have capabilities to print
> out using 24-bit colour, but I want to use ncurses in my program,
> and I want said program to support 24-bit colour.  There seems to be
> a problem, however, in which ncurses will sanitize its output.
> Consider the following snippet:
> 
> #include <ncurses.h>
> int main() {
>       initscr();
>       printw("\033[33mhello\033[0m\n");
>       refresh();
>       endwin();
>       return 0;
> }
> 
> This simply prints out "^[[33mhello^[[0m", uncoloured.  Is there a
> way to make ncurses not sanitize this output?

sure - but you wouldn't find it useful once you did it.

You can write "anything" to the terminal by

        a) doing a refresh to get the screen up to date
        b) changing the terminal modes back to shell-mode temporarily
        c) write your "anything", and do an fflush afterwards
        d) restore the shell modes
        e) call mvcur to set the cursor to the location where curses
           thought it was (and use -1's for the ordinates of the previous
           location).

Of course, "anything" which you print on the screen that's visible is
likely to be overwritten by ncurses as it updates the screen.

-- 
Thomas E. Dickey <address@hidden>
http://invisible-island.net
ftp://invisible-island.net

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]