Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

showing a ncurses window

37 views
Skip to first unread message

alexo

unread,
Feb 5, 2015, 2:12:05 PM2/5/15
to
Hello all in the group :)

I just started learning the ncurses library but, even if it's not so
obscure as I wrongly thought, I can't get such a simple action as
showing a window on the console screen.
Could you please tel me what I missed in this example?

Thank you.

#include <ncurses.h>
#include <string.h>

void print_win(WINDOW *win, int, int);

int main(void)
{
initscr();
noecho();
cbreak();
curs_set(FALSE);

WINDOW *my_win;

int WIDTH = 15;
int HEIGHT = 8;

int winx = (COLS - WIDTH) / 2;
int winy = (LINES - HEIGHT) / 2;

my_win = newwin(HEIGHT, WIDTH, winy, winx);

if(my_win == NULL)
printw("memory error");

print_win(my_win, HEIGHT, WIDTH);

mvprintw(LINES - 1, (COLS - 11) /2, "press a key");
getch();

delwin(my_win);
endwin();

return 0;
}

void print_win(WINDOW *win, int h, int w)
{
char msg[] = "hello";

/* if I explicitly pass NULL
* I get the error strings,
*
* if I pass stdscr
* I get the correct behaviour
*/

if(box(win, 0, 0) == ERR)
printw("window drawing error\n");

if(mvwprintw(win, h/2, (w - strlen(msg)) /2, msg) == ERR)
printw("writing error\n");

if(wrefresh(win) == ERR)
printw("window rendering error\n");
}

red floyd

unread,
Feb 5, 2015, 2:32:52 PM2/5/15
to
On 2/5/2015 11:11 AM, alexo wrote:
> Hello all in the group :)
>
> I just started learning the ncurses library but, even if it's not so
> obscure as I wrongly thought, I can't get such a simple action as
> showing a window on the console screen.
> Could you please tel me what I missed in this example?
>
[redacted]

You asked in the wrong group?

1. Your code is pure C
2. curses/ncurses is not part of the C++ standard.
3. You should have asked somewhere in the comp.unix hierarcy.

See FAQ 5.9 http://www.parashift.com/c++-faq-lite/which-newsgroup.html





Melzzzzz

unread,
Feb 5, 2015, 2:45:00 PM2/5/15
to
On Thu, 05 Feb 2015 11:32:40 -0800
red floyd <no....@its.invalid> wrote:

> On 2/5/2015 11:11 AM, alexo wrote:
> > Hello all in the group :)
> >
> > I just started learning the ncurses library but, even if it's not so
> > obscure as I wrongly thought, I can't get such a simple action as
> > showing a window on the console screen.
> > Could you please tel me what I missed in this example?
> >
> [redacted]
>
> You asked in the wrong group?
>
> 1. Your code is pure C
[bmaxa@maxa-pc examples]$ g++ -Wall -c curses.cpp -o curses.o
It compiles without warning as C++,,,


alexo

unread,
Feb 5, 2015, 4:11:31 PM2/5/15
to
I know it is not part of the C++; And I know that my code is C code.
I'll post it somewhere else, but I thought this was a good place to
start from.
Does anyone of you ever used this library?

thank you

Melzzzzz

unread,
Feb 5, 2015, 5:02:00 PM2/5/15
to
I used curses in 1992-93 on dumb terminals under AT&T Unix.
Can't remember it ...

>
> thank you


Ian Collins

unread,
Feb 5, 2015, 5:06:10 PM2/5/15
to
Try comp.unix.programmer

> Does anyone of you ever used this library?

Along time ago in a land far away.

--
Ian Collins

Christopher Pisz

unread,
Feb 5, 2015, 5:14:55 PM2/5/15
to
When C++ compilers compile C, it does not make it C++.
Sure as heck doesn't compile on my compiler.

red floyd

unread,
Feb 6, 2015, 1:17:32 AM2/6/15
to
On 2/5/2015 2:05 PM, Ian Collins wrote:
> alexo wrote:
>> Il 05/02/2015 20:32, red floyd ha scritto:
>>> On 2/5/2015 11:11 AM, alexo wrote:

>>> You asked in the wrong group?
>>>
>>> 1. Your code is pure C
>>> 2. curses/ncurses is not part of the C++ standard.
>>> 3. You should have asked somewhere in the comp.unix hierarcy.
>>>
>>> See FAQ 5.9 http://www.parashift.com/c++-faq-lite/which-newsgroup.html
>>
>> I know it is not part of the C++; And I know that my code is C code.
>> I'll post it somewhere else, but I thought this was a good place to
>> start from.
>
> Try comp.unix.programmer
>

As I told him (try somewhere in the comp.unix hierarchy).

Also, my semi standard response applies. I wanted some meat, so I
went to =the butcher, but he wasn't around so I asked the greengrocer
for some, because he eats meat, too.




Richard

unread,
Feb 6, 2015, 12:18:42 PM2/6/15
to
[Please do not mail me a copy of your followup]

alexo <aless...@inwind.it> spake the secret code
<mb0m9e$jf5$1...@speranza.aioe.org> thusly:

>I know it is not part of the C++; And I know that my code is C code.
>I'll post it somewhere else, but I thought this was a good place to
>start from.

Try the ncurses mailing list:
<https://lists.gnu.org/mailman/listinfo/help-ncurses>

Ncurses is well maintained and you shoudl be able to get an answer.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
The Terminals Wiki <http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>

alexo

unread,
Feb 6, 2015, 2:17:03 PM2/6/15
to
Nice example, but he greengrocer could give me the address of a new
butcher's shop.

Anyway your answer was the most colorful one I had in my posting
experience ;)

cheers



0 new messages