[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ncurses mvaddch() cursor movement a possible bug?
From: |
Tim van der Molen |
Subject: |
Re: ncurses mvaddch() cursor movement a possible bug? |
Date: |
Mon, 30 Mar 2015 20:02:24 +0200 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
Avinash Sonawane (2015-03-30 12:41 +0200):
> Hello there! I have a query regarding mvaddch cursor movement. Please
> go through the following code snippet. I am using xterm BTW.
>
> Code:
>
> #include <ncurses.h>
>
> int main(int argc, char **argv)
> {
> initscr();
> noecho();
> cbreak();
>
> mvprintw(0, 0, curses_version());
> mvprintw(1, 0, "Hello World");
> mvaddch(2, 0, mvinch(1, 4)); // Why doesn't this work?
>
> getch();
> endwin();
>
> return 0;
> }
>
> Output:
>
> ncurses 5.9.20130608
> Hello World
>
> with pointer blinking (waiting for getch ) just after o of Hello.
>
> Question:
> As in C, arguments passed to a function are evaluated first before
> calling that function, mvinch() will be called first and when it'll
> return the character o the call to mvaddch() will be made.
> But then why character o is not printed on line 2 (just below Hello
> World)? Instead mvaddch prints o at current cursor position (thanks to
> winch which is 1,4). Here mvaddch() behaves just like addch paying no
> respect to the mv prefix and the explicit movement coordinates given
> to it. Why?
>
> Is this a possible bug in mvaddch() or am I missing something?
mvaddch() and mvinch() are not functions, but macros. If you run your
code through cpp, you'll see that mvaddch(2, 0, mvinch(1, 4)) expands
to:
(wmove(stdscr,2,0) == (-1) ? (-1) :
waddch(stdscr,(wmove(stdscr,1,4) == (-1) ? (chtype)((-1)) :
winch(stdscr))));