简体   繁体   English

当 output 大于终端列时,NCurses 添加新行

[英]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:我注意到,当我在 ncurses 中打印需要超过终端列数的行时,ncurses 添加了换行符:

#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:现在由于终端的列较少,我的 output 看起来像这样:

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.在我的应用程序中,我不想复制终端 output 但是当我这样做时,我会在换行符处换行,但在调用 printw 时我没有放置任何新行。 Does ncurses add newlines automatically? ncurses 会自动添加换行符吗? 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.这是我的问题的简单版本,因为在我的情况下,我使用 mvwaddnwstr 打印宽字符,但问题仍然存在。

printw , waddstr (or waddwstr ) ultimately call waddch (or wadd_wch ), which wraps at the right margin.printwwaddstr (或waddwstr )最终调用waddch (或wadd_wch ),它在右边距处换行。 You could use (but less convenient) waddchstr or wadd_wchstr , which do not wrap.您可以使用(但不太方便) waddchstrwadd_wchstr ,它们不会换行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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