I'm trying to write something inside a curses window, but it seems to write on borders too. How can I fix the code below?
win_self = newwin(LINES / 2, COLS, 0, 0);
box(win_self, 0, 0);
wrefresh(win_self);
wprintw(win_self, "foobar");
If the borders are still not showing when you print, adjust the margins to give more space between the borders and the edge of the page on the document. Go to Layout > Margins, and select Custom Margins. Increase the border that corresponds with the one that's missing when you print.
The most common cause of this problem is that the bottom margin, footer margin, or page border is outside the printable area of the page. All printers have an irreducible unprintable area necessitated by the mechanical requirements of paper handling.
That's usually because the printer driver itself has default borders set for each document, and until they're changed your document will print with a border or your program will tell you that you're trying to print a document that's too large for the page.
I'd say the easiest way is to create a window inside of the window borders and print in that window.
win_self = newwin(LINES / 2, COLS, 0, 0);
box(win_self, 0, 0);
derwin_self = derwin(win_self, LINES / 2 - 2, COLS - 2, 0, 0);
wprintw(derwin_self, "foobar");
In curses, the borders generated by box()
are inside borders. As far as I can tell, there's no way to simply say "don't overwrite my border".
Nevertheless, there are three solutions that I can think of right now:
move()
)refresh()
the screen (you're probably still overwriting something, but at least it's not the border characters)
Just to make it more clear: the box()
function doesn't add the property "this window has visible borders" to the window, it just prints border characters around the window.
You are:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With