[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How do you draw to the bottom-right corner of the screen?
From: |
Tim Allen |
Subject: |
How do you draw to the bottom-right corner of the screen? |
Date: |
Thu, 6 Sep 2007 01:23:47 +1000 |
According to the ncurses announcement page, "Unlike SVr3 curses,
ncurses can write to the rightmost-bottommost corner of the screen if
your terminal has an insert-character capability." However, if you
actually try this, mvaddch() returns ERR. Is there some special
function call you have to make in order to get ncurses to accept
bottom-right screen writes? The mvaddch manpage and numerous Google
searches don't seem to mention such a thing.
Here is the code I used to test:
----------------------------------------------------
#include <curses.h>
int main(int argc, char *argv[])
{
int c, ret;
/* Curses init */
initscr();
cbreak();
noecho();
ret = mvaddch(LINES-1,COLS-1, ACS_CKBOARD);
if (ret == ERR) {
mvaddstr(0,0, "mvaddch had an error!");
}
/* refresh, accept single keystroke of input */
c = getch();
endwin();
return 0;
}
----------------------------------------------------
...compiled with "gcc -lncurses curses-demo.c" on Mac OS X 10.4,
which is ncurses 5.0 by default, but I also tried linking with a copy
of 5.4 I found lying around, and version "5.6+20070812-1" on Debian
Testing, all with the same behaviour.
What I expected:
- chequerboard character appears at bottom-right corner of screen
- everything else is blank
What I got:
- chequerboard character appears at bottom-right corner of screen
- error message at top-left corner of screen
It looks like the best way to draw on the bottom-right corner of the
screen is to write my own wrapper function for mvaddch() that
silently ignores errors if the coordinates are (LINES-1,COLS-1)...
but I hate the thought of any solution involving the phrase "silently
ignore errors". Is there a better way?
- How do you draw to the bottom-right corner of the screen?,
Tim Allen <=