简体   繁体   中英

ncurses - printw() doesn't work with long strings (C)

I'm trying to print a long string with printw() but it only print some chars. It's like this function only allow a maximum numbers of chars to print.

Here's a part of my code:

 ...
 move(3,0);
 printw(result_2);
 sleep(1);
 ...

result_2 has a very long string and I know that it has the long string correctly.

The string that I'm trying to print is all the information about a txt file.

I tried with another functions like addstr() but I had the same problem. Is there any way to print long strings with ncurses ?

This is what I have in my string:

user: asdasdasd
user: holaaaa
user: asdsad
user: aw22
user: 2
user: 2
user: 2
user: 2
user: 22
user: 2
user: 2
user: 2
user: asdasd
user: holaaa
user: porfa
user: si
user: suuuuuuuuuuuuuuuuuu
user: no
user: no
user: lel
user: lkajsdkjasdkjasdkjasd

Thanks!

I think you're probably hitting the bottom of the screen. Ncurses will not scroll (or allow the terminal to scroll) unless you've called:

scrollok(stdscr, TRUE);

So probably the output reaches the bottom of the window and stops there.

You might also want to take a look at the curses function idlok .

However, that might not provide what you are really looking for. Ncurses does not maintain a scroll buffer; it only stores what is actually being displayed on the screen. If you want to implement a CLI app which is capable of scrolling long texts, you'll have to implement the scrolling logic yourself, or use one of the widget libraries implemented on top of ncurses (such as CDK ).

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