You are not logged in.

#1 2011-07-05 07:19:19

linux-ka
Member
From: ADL
Registered: 2010-05-07
Posts: 232

[C++ Curses] Highlight a single line

Hi,

I am coding a small device manager for my personal use ( fun and exercise ). Right now a panel is used to display devices, whether they are removable or static (hard drive). My idea is to move a curser (up and down) to highlight the selected line. But I don't see any function in curses to achieve this.

Do I need to move an other but highlighted panel, which needs to be filled after every movement with the content of the bottom line or is there a better way?

I hope there are some curses coder out there!

Thanks for every help in advance

L-K

Offline

#2 2011-07-05 07:58:32

ryuslash
Member
Registered: 2010-10-11
Posts: 58
Website

Re: [C++ Curses] Highlight a single line

I always use the mvchgat (or mvwchgat) function to highlight lines.

man curs_attr

might help.

Offline

#3 2011-07-05 14:39:45

linux-ka
Member
From: ADL
Registered: 2010-05-07
Posts: 232

Re: [C++ Curses] Highlight a single line

This sounds promising. I will give it a try. It should be much faster than my unluckily proposed moving panel.

Last edited by linux-ka (2011-07-05 15:46:34)

Offline

#4 2011-07-07 19:01:09

linux-ka
Member
From: ADL
Registered: 2010-05-07
Posts: 232

Re: [C++ Curses] Highlight a single line

Great, this works realy great.

But I have got a serious issue with KEY_UP and KEY_DOWN. It is not recognized when entering those keys. KEY_LEFT and KEY_RIGHT are in the same way ignored when being pressed. Have you ever had the same problem?

Offline

#5 2011-07-08 07:21:21

ryuslash
Member
Registered: 2010-10-11
Posts: 58
Website

Re: [C++ Curses] Highlight a single line

Can't say I have, but which input option functions do you call? cbreak, nocbreak, raw, keypad?

man curs_inopts

might help this time

man ncurses

might be helpful more generally and of course http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/ might help (I know its for C, but since ncurses is a C library anyway, that should be much of a problem, right?)

Offline

#6 2011-07-08 19:05:51

linux-ka
Member
From: ADL
Registered: 2010-05-07
Posts: 232

Re: [C++ Curses] Highlight a single line

I am using

keypad(stdscr,1);
cbreak();

With respect to the man page it should be enough to work with function keys.

EDIT:

I tried to use F1-F9...and it doesn't work as well.


EDIT2:

Got it. My problem was that keys were fetched via getchar instead of getch. Using getch or wgetch everthing is ok.

Last edited by linux-ka (2011-07-08 19:43:21)

Offline

Board footer

Powered by FluxBB