bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do you draw to the bottom-right corner of the screen?


From: Thomas Dickey
Subject: Re: How do you draw to the bottom-right corner of the screen?
Date: Thu, 6 Sep 2007 08:00:13 -0400 (EDT)

On Thu, 6 Sep 2007, Tim Allen wrote:

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.

The move returns OK, but the waddch returns ERR after adding the character because it attempts to scroll the screen, but cannot.

The manpage for addch does not describe in detail the conditions which would produce an error, though this behavior is about ten years old.
(There are several error checks...)


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?


_______________________________________________
Bug-ncurses mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/bug-ncurses

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net




reply via email to

[Prev in Thread] Current Thread [Next in Thread]