简体   繁体   中英

NCurses adds new line when output greater than terminal columns

I have noticed that when I print line in ncurses that takes more than number of terminal columns ncurses adds newline:

#include <ncurses.h>

int main()
{
        initscr();                      /* Start curses mode              */
        printw("Hello World aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!!!");
        refresh();                      /* Print it on to the real screen */
        getch();                        /* Wait for user input */
        endwin();                       /* End curses mode                */

        return 0;
}

Now as the terminal has less columns my output looks like this:

Hello World aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!!!

In my app I wan't to copy terminal output but when I do so I'm getting newline where line breaks but I didn't putted any new line when calling printw. Does ncurses add newlines automatically? How I can disable that? This is simple version of my problem as In my case I'm using mvwaddnwstr to print wide characters but problem stays.

printw , waddstr (or waddwstr ) ultimately call waddch (or wadd_wch ), which wraps at the right margin. You could use (but less convenient) waddchstr or wadd_wchstr , which do not wrap.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM