Here it is:
Code:
/*
ncurses Column Skipping Test
Arrow keys to move cursor, q to quit
Compile:
gcc editortest.c -lncurses -o editortest
*/
#include <ncurses.h>
void clear_bar(WINDOW* bar) {
wclear(bar);
int i;
for(i=0;i<COLS;i++) waddch(bar, ' ');
wmove(bar, 0, 0);
}
int main(int argc, char** args)
{
WINDOW* titlebar;
WINDOW* statusbar;
WINDOW* textarea;
initscr();
raw();
refresh();
titlebar = newwin(1, COLS, 0, 0);
statusbar = newwin(1, COLS, LINES-1, 0);
textarea = newwin(LINES-2, COLS, 1, 0);
keypad(textarea, TRUE);
wattron(titlebar, A_REVERSE);
wattron(statusbar, A_REVERSE);
clear_bar(titlebar);
clear_bar(statusbar);
wclear(textarea);
wprintw(titlebar, "Titlebar");
wprintw(statusbar, "Statusbar");
wprintw(textarea, "Test");
wmove(textarea, 0, 0);
wrefresh(statusbar); //The cursor will NOT skip a column near the right edge when you comment out this line (???)
wrefresh(titlebar);
wrefresh(textarea);
unsigned long row = 0, col = 0;
while(1) {
int c = wgetch(textarea);
if(c == KEY_UP) row--;
if(c == KEY_DOWN) row++;
if(c == KEY_LEFT) col--;
if(c == KEY_RIGHT) col++;
if(c == 'q') break;
wclear(textarea);
wprintw(textarea, "Test");
wmove(textarea, row, col);
wrefresh(textarea);
}
endwin();
return 0;
}