You are not logged in.

#1 2011-04-05 19:29:01

Scionar
Member
Registered: 2010-06-28
Posts: 4

Ncurses - Getting character of wanted cell? [SOLVED]

Hi!

I have been started learning C++ and again trying to do something funny with ncurses. I have now problem which I could solve different ways, but of course if there is this easy way I would use it.

Is there any functions in ncurses which tells which character is in wanted cell? Example if I have character # in cell 6,10 how can I prove that?

If there is something what you didn't understand, just ask. English is not my native language, so there can be some misunderstandings.

Last edited by Scionar (2011-04-10 15:29:39)

Offline

#2 2011-04-06 12:15:11

Chippeur
Member
Registered: 2010-01-25
Posts: 19

Re: Ncurses - Getting character of wanted cell? [SOLVED]

I suggest you:

man 3 inch
man 3 inchstr
man 3 in_wch
man 3 inwstr

Taking your example (assume the target window is stdscr):

char ch = mvinch(10, 6) & A_CHARTEXT;

I didn't test it but it should be something like that.

(not native english too so I'm sorry if I made any mistakes).


Sorry in advance for my poor english...

Offline

#3 2011-04-06 20:04:48

Scionar
Member
Registered: 2010-06-28
Posts: 4

Re: Ncurses - Getting character of wanted cell? [SOLVED]

Yeah! That mvinch-function worked well. Thanks.

I didn't add that "& A_CHARTEXT" to the end, but it worked anyway. I tried to add it anyway to the end, but it didn't make difference.

Let's play that we have # at 6,9:

if (mvinch(6,9) == '#')  {
     implementation
}

This executes the implementation.

Offline

#4 2011-04-06 23:22:11

Chippeur
Member
Registered: 2010-01-25
Posts: 19

Re: Ncurses - Getting character of wanted cell? [SOLVED]

I suggest you to keep "& A_CHARTEXT" in place. If you read the man page it's clear, the function return the *chtype* at the given position, it doesn't return a character. An attribute have 3 elements, the character, the attributes and the color. If you add colors in the future the value of chtype will not be '#' but '#' | YOU_COLOR_VALUE.

Last edited by Chippeur (2011-04-06 23:22:40)


Sorry in advance for my poor english...

Offline

#5 2011-04-07 01:37:53

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,308

Re: Ncurses - Getting character of wanted cell? [SOLVED]

Scionar wrote:

Yeah! That mvinch-function worked well. Thanks.

When you have a chance, be sure to edit your original post and add the tag [SOLVED] to the thread title,
Thanks


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB