Originally Posted by
behzad_shabani
thanks
(however I'm losing std::getline instead)
another question, (I know I am pert
) I'm using pdcurses to handle the cursor, but how could I move cursor to previous line?
when i press key up it bring the last line that i wrote.
OK I used curses when I did mine, I asume it was the same/similar.
Anyway I dug out the old code and typed it in (hope there are no typing errors!)
CWIN is a pointer to a window I believe.
I noticed I used a function 'fix' maybe it was to fix the problem you are encountering?
I am guessing really. But none of the other curses routines needed it.
Actually as I used mutliple windows CWIN is actually one of an array
or window pointers, it's probably just a window pointer in yours?
I also had to maintain an array of the data in each window (bd[wn]) wn=window number.
It's also posible you need to set the value in the following functions.
leaveok(stdscr,TRUE);
scrollok(stdscr,FALSE);
However I do not know what your approach to it was so it might be nothing like mine.
Might be easier if you just look at how I used the cursors functions, rather than the code
to maintain my arrays of data.
Dunno if this will be of any help or not.
Code:
struct wid **bd // array of structures of window data, position of window, of cursor row, column etc.... and data in each window
#defne OCOL bd[wn]->offcol // an offset for the column, used when some coulmns have 'scrolled' off the screen.
#defne WROW bd[wn]->rowpos //screen row
#defne WCOL bd[wn]->colpos //screen column
#define CWIN winarray[wn] //current window shorthand
WINDOW **winarray //array of window pointers
cur_up(){
int x,y;
getxy(CWIN,x,y);
if (y<1){ y=1;
OROW--;
scroll_win(NO_SCROLL);
x=1;
else { WROW--1;}
wmove(CWIN,x,y);
fix();
}
fix(){
int x,y;
getxy((CWIN,x,y);
wmove(CWIN,x,y);
wrefresh(CWIN);
WROW=x;
WCOL=y;
}
Note the scroll_win was a function I wrote to take care of scrolling you can ignore it for now, it only
is needed when you reach the top of the window, which is not the case yet I believe.