[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Column Skipping
From: |
MTK358 |
Subject: |
Column Skipping |
Date: |
Thu, 10 Sep 2009 08:31:11 -0700 (PDT) |
I am trying to make an ncurses command line text editor, but the problem is
that for some reason the cursor skips a column near the right edge of the
terminal. This for some reason only happens when I refresh the statusbar
WINDOW in the beginning.
[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;
}
[/code]
--
View this message in context:
http://www.nabble.com/Column-Skipping-tp25385333p25385333.html
Sent from the Gnu - Ncurses mailing list archive at Nabble.com.
- Column Skipping,
MTK358 <=