Replaced all direct curses calls with screen_xx() wrappers. This should

enable us to optionally use termcap directly.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1535 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-06-01 21:49:07 +00:00 committed by cras
parent 6f5c1117de
commit 05777636a7
13 changed files with 238 additions and 132 deletions

View File

@ -31,16 +31,16 @@ static char *prompt;
static void entry_screenpos(void) static void entry_screenpos(void)
{ {
if (pos-scrstart < COLS-2-promptlen && pos-scrstart > 0) { if (pos-scrstart < screen_width-2-promptlen && pos-scrstart > 0) {
scrpos = pos-scrstart; scrpos = pos-scrstart;
return; return;
} }
if (pos < COLS-1-promptlen) { if (pos < screen_width-1-promptlen) {
scrstart = 0; scrstart = 0;
scrpos = pos; scrpos = pos;
} else { } else {
scrpos = (COLS-promptlen)*2/3; scrpos = (screen_width-promptlen)*2/3;
scrstart = pos-scrpos; scrstart = pos-scrpos;
} }
} }
@ -50,26 +50,26 @@ static void entry_update(void)
char *p; char *p;
int n, len; int n, len;
len = entry->len-scrstart > COLS-1-promptlen ? len = entry->len-scrstart > screen_width-1-promptlen ?
COLS-1-promptlen : entry->len-scrstart; screen_width-1-promptlen : entry->len-scrstart;
set_color(stdscr, 0); screen_set_color(screen_root, 0);
move(LINES-1, promptlen); screen_move(screen_root, promptlen, screen_height-1);
for (p = entry->str+scrstart, n = 0; n < len; n++, p++) { for (p = entry->str+scrstart, n = 0; n < len; n++, p++) {
if (prompt_hidden) if (prompt_hidden)
addch(' '); screen_addch(screen_root, ' ');
else if ((unsigned char) *p >= 32) else if ((unsigned char) *p >= 32)
addch((unsigned char) *p); screen_addch(screen_root, (unsigned char) *p);
else { else {
set_color(stdscr, ATTR_REVERSE); screen_set_color(screen_root, ATTR_REVERSE);
addch(*p+'A'-1); screen_addch(screen_root, *p+'A'-1);
set_color(stdscr, 0); screen_set_color(screen_root, 0);
} }
} }
clrtoeol(); screen_clrtoeol(screen_root);
move_cursor(LINES-1, scrpos+promptlen); screen_move_cursor(scrpos+promptlen, screen_height-1);
screen_refresh(NULL); screen_refresh(NULL);
} }
@ -84,7 +84,7 @@ void gui_entry_set_prompt(const char *str)
} }
if (prompt != NULL) if (prompt != NULL)
gui_printtext(0, LINES-1, prompt); gui_printtext(0, screen_height-1, prompt);
entry_screenpos(); entry_screenpos();
entry_update(); entry_update();

View File

@ -165,9 +165,9 @@ static void sig_gui_print_text(WINDOW_REC *window, void *fgcolor,
if (window == NULL) { if (window == NULL) {
g_return_if_fail(next_xpos != -1); g_return_if_fail(next_xpos != -1);
wmove(stdscr, next_ypos, next_xpos); screen_move(screen_root, next_xpos, next_ypos);
set_color(stdscr, fg | (bg << 4)); screen_set_color(screen_root, fg | (bg << 4));
addstr(str); screen_addstr(screen_root, str);
next_xpos += strlen(str); next_xpos += strlen(str);
return; return;
} }
@ -258,7 +258,6 @@ void gui_printtext_init(void)
signal_add("print text finished", (SIGNAL_FUNC) sig_printtext_finished); signal_add("print text finished", (SIGNAL_FUNC) sig_printtext_finished);
signal_add("print format", (SIGNAL_FUNC) sig_print_format); signal_add("print format", (SIGNAL_FUNC) sig_print_format);
signal_add("setup changed", (SIGNAL_FUNC) read_settings); signal_add("setup changed", (SIGNAL_FUNC) read_settings);
signal_add("beep", (SIGNAL_FUNC) beep);
read_settings(); read_settings();
} }
@ -271,5 +270,4 @@ void gui_printtext_deinit(void)
signal_remove("print text finished", (SIGNAL_FUNC) sig_printtext_finished); signal_remove("print text finished", (SIGNAL_FUNC) sig_printtext_finished);
signal_remove("print format", (SIGNAL_FUNC) sig_print_format); signal_remove("print format", (SIGNAL_FUNC) sig_print_format);
signal_remove("setup changed", (SIGNAL_FUNC) read_settings); signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
signal_remove("beep", (SIGNAL_FUNC) beep);
} }

View File

@ -313,12 +313,9 @@ void readline(void)
int key; int key;
for (;;) { for (;;) {
key = getch(); key = screen_getch();
if (key == ERR if (key == -1)
#ifdef KEY_RESIZE break;
|| key == KEY_RESIZE
#endif
) break;
handle_key(key); handle_key(key);
} }

View File

@ -254,7 +254,7 @@ static void signal_window_changed(WINDOW_REC *window)
active_mainwin->active = window; active_mainwin->active = window;
textbuffer_view_set_window(WINDOW_GUI(window)->view, textbuffer_view_set_window(WINDOW_GUI(window)->view,
parent->curses_win); parent->screen_win);
window_update_prompt(); window_update_prompt();
} }

View File

@ -89,8 +89,8 @@ static void sig_exit(void)
/* redraw irssi's screen.. */ /* redraw irssi's screen.. */
void irssi_redraw(void) void irssi_redraw(void)
{ {
clear(); screen_clear();
refresh(); screen_refresh(NULL);
/* windows */ /* windows */
mainwindows_redraw(); mainwindows_redraw();

View File

@ -37,7 +37,11 @@ GSList *mainwindows;
MAIN_WINDOW_REC *active_mainwin; MAIN_WINDOW_REC *active_mainwin;
static int reserved_up, reserved_down; static int reserved_up, reserved_down;
static int screen_width, screen_height; static int old_screen_width, old_screen_height;
#define mainwindow_create_screen(window) \
screen_window_create(0, (window)->first_line, \
(window)->width, (window)->height)
static MAIN_WINDOW_REC *find_window_with_room(void) static MAIN_WINDOW_REC *find_window_with_room(void)
{ {
@ -59,15 +63,6 @@ static MAIN_WINDOW_REC *find_window_with_room(void)
return biggest_rec; return biggest_rec;
} }
#ifdef USE_CURSES_WINDOWS
static void create_curses_window(MAIN_WINDOW_REC *window)
{
window->curses_win = newwin(window->height, window->width,
window->first_line, 0);
idlok(window->curses_win, 1);
}
#endif
static void mainwindow_resize(MAIN_WINDOW_REC *window, int xdiff, int ydiff) static void mainwindow_resize(MAIN_WINDOW_REC *window, int xdiff, int ydiff)
{ {
GSList *tmp; GSList *tmp;
@ -77,18 +72,8 @@ static void mainwindow_resize(MAIN_WINDOW_REC *window, int xdiff, int ydiff)
window->width += xdiff; window->width += xdiff;
window->height = window->last_line-window->first_line+1; window->height = window->last_line-window->first_line+1;
#ifdef USE_CURSES_WINDOWS screen_window_move(window->screen_win, 0, window->first_line,
#ifdef HAVE_CURSES_WRESIZE window->width, window->height);
wresize(window->curses_win, window->height, window->width);
mvwin(window->curses_win, window->first_line, 0);
#else
delwin(window->curses_win);
create_curses_window(window);
textbuffer_view_set_window(WINDOW_GUI(window->active)->view,
window->curses_win);
#endif
#endif
for (tmp = windows; tmp != NULL; tmp = tmp->next) { for (tmp = windows; tmp != NULL; tmp = tmp->next) {
WINDOW_REC *rec = tmp->data; WINDOW_REC *rec = tmp->data;
@ -99,7 +84,7 @@ static void mainwindow_resize(MAIN_WINDOW_REC *window, int xdiff, int ydiff)
} }
textbuffer_view_set_window(WINDOW_GUI(window->active)->view, textbuffer_view_set_window(WINDOW_GUI(window->active)->view,
window->curses_win); window->screen_win);
signal_emit("mainwindow resized", 1, window); signal_emit("mainwindow resized", 1, window);
} }
@ -110,11 +95,9 @@ void mainwindows_recreate(void)
for (tmp = mainwindows; tmp != NULL; tmp = tmp->next) { for (tmp = mainwindows; tmp != NULL; tmp = tmp->next) {
MAIN_WINDOW_REC *rec = tmp->data; MAIN_WINDOW_REC *rec = tmp->data;
#ifdef USE_CURSES_WINDOWS rec->screen_win = mainwindow_create_screen(rec);
create_curses_window(rec);
#endif
textbuffer_view_set_window(WINDOW_GUI(rec->active)->view, textbuffer_view_set_window(WINDOW_GUI(rec->active)->view,
rec->curses_win); rec->screen_win);
} }
} }
@ -151,10 +134,8 @@ MAIN_WINDOW_REC *mainwindow_create(void)
mainwindow_resize(parent, 0, -space-1); mainwindow_resize(parent, 0, -space-1);
} }
#ifdef USE_CURSES_WINDOWS rec->screen_win = mainwindow_create_screen(rec);
rec->curses_win = newwin(rec->height, rec->width, rec->first_line, 0); screen_refresh(NULL);
refresh();
#endif
mainwindows = g_slist_append(mainwindows, rec); mainwindows = g_slist_append(mainwindows, rec);
signal_emit("mainwindow created", 1, rec); signal_emit("mainwindow created", 1, rec);
@ -240,9 +221,7 @@ void mainwindow_destroy(MAIN_WINDOW_REC *window)
mainwindows = g_slist_remove(mainwindows, window); mainwindows = g_slist_remove(mainwindows, window);
signal_emit("mainwindow destroyed", 1, window); signal_emit("mainwindow destroyed", 1, window);
#ifdef USE_CURSES_WINDOWS screen_window_destroy(window->screen_win);
delwin(window->curses_win);
#endif
if (!quitting && mainwindows != NULL) { if (!quitting && mainwindows != NULL) {
gui_windows_remove_parent(window); gui_windows_remove_parent(window);
@ -419,10 +398,10 @@ void mainwindows_resize(int width, int height)
{ {
int xdiff, ydiff; int xdiff, ydiff;
xdiff = width-screen_width; xdiff = width-old_screen_width;
ydiff = height-screen_height; ydiff = height-old_screen_height;
screen_width = width; old_screen_width = width;
screen_height = height; old_screen_height = height;
screen_refresh_freeze(); screen_refresh_freeze();
if (ydiff < 0) if (ydiff < 0)
@ -431,9 +410,9 @@ void mainwindows_resize(int width, int height)
mainwindows_resize_bigger(xdiff, ydiff); mainwindows_resize_bigger(xdiff, ydiff);
else if (xdiff != 0) else if (xdiff != 0)
mainwindows_resize_horiz(xdiff); mainwindows_resize_horiz(xdiff);
screen_refresh_thaw();
irssi_redraw(); irssi_redraw();
screen_refresh_thaw();
} }
int mainwindows_reserve_lines(int count, int up) int mainwindows_reserve_lines(int count, int up)
@ -871,8 +850,8 @@ static void cmd_window_stick(const char *data)
void mainwindows_init(void) void mainwindows_init(void)
{ {
screen_width = COLS; old_screen_width = screen_width;
screen_height = LINES; old_screen_height = screen_height;
mainwindows = NULL; mainwindows = NULL;
active_mainwin = NULL; active_mainwin = NULL;

View File

@ -10,11 +10,8 @@ typedef struct {
WINDOW_REC *active; WINDOW_REC *active;
GSList *sticky_windows; /* list of windows allowed to show only in this mainwindow */ GSList *sticky_windows; /* list of windows allowed to show only in this mainwindow */
#ifdef USE_CURSES_WINDOWS SCREEN_WINDOW *screen_win;
WINDOW *curses_win;
#else
#error disable-curses-windows is currently broken /* FIXME */
#endif
int first_line, last_line, width, height; int first_line, last_line, width, height;
int statusbar_lines; int statusbar_lines;
void *statusbar; void *statusbar;

View File

@ -32,12 +32,25 @@
#endif #endif
#include <signal.h> #include <signal.h>
#if defined(USE_NCURSES) && !defined(RENAMED_NCURSES)
# include <ncurses.h>
#else
# include <curses.h>
#endif
#ifndef COLOR_PAIRS #ifndef COLOR_PAIRS
#define COLOR_PAIRS 64 #define COLOR_PAIRS 64
#endif #endif
#define MIN_SCREEN_WIDTH 20 #define MIN_SCREEN_WIDTH 20
struct _SCREEN_WINDOW {
WINDOW *win;
};
SCREEN_WINDOW *screen_root;
int screen_width, screen_height;
static int scrx, scry; static int scrx, scry;
static int use_colors; static int use_colors;
static int freeze_refresh; static int freeze_refresh;
@ -66,6 +79,9 @@ static void sig_winch(int p)
/* Resize curses terminal */ /* Resize curses terminal */
resizeterm(ws.ws_row, ws.ws_col); resizeterm(ws.ws_row, ws.ws_col);
screen_width = COLS;
screen_height = LINES;
#else #else
deinit_screen_int(); deinit_screen_int();
init_screen_int(); init_screen_int();
@ -141,36 +157,103 @@ static int init_curses(void)
static int init_screen_int(void) static int init_screen_int(void)
{ {
int ret;
ret = init_curses();
if (!ret) return 0;
use_colors = settings_get_bool("colors"); use_colors = settings_get_bool("colors");
scrx = scry = 0; scrx = scry = 0;
freeze_refresh = 0; freeze_refresh = 0;
return init_curses(); screen_root = g_new0(SCREEN_WINDOW, 1);
screen_root->win = stdscr;
screen_width = COLS;
screen_height = LINES;
return ret;
} }
static void deinit_screen_int(void) static void deinit_screen_int(void)
{ {
endwin(); endwin();
g_free_and_null(screen_root);
} }
/* Initialize screen, detect screen length */ /* Initialize screen, detect screen length */
int init_screen(void) int init_screen(void)
{ {
settings_add_bool("lookandfeel", "colors", TRUE); settings_add_bool("lookandfeel", "colors", TRUE);
signal_add("beep", (SIGNAL_FUNC) beep);
signal_add("setup changed", (SIGNAL_FUNC) read_settings); signal_add("setup changed", (SIGNAL_FUNC) read_settings);
return init_screen_int(); return init_screen_int();
} }
/* Deinitialize screen */ /* Deinitialize screen */
void deinit_screen(void) void deinit_screen(void)
{ {
deinit_screen_int(); deinit_screen_int();
signal_remove("beep", (SIGNAL_FUNC) beep);
signal_remove("setup changed", (SIGNAL_FUNC) read_settings); signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
} }
void set_color(WINDOW *window, int col) int screen_has_colors(void)
{
return has_colors();
}
void screen_clear(void)
{
clear();
}
SCREEN_WINDOW *screen_window_create(int x, int y, int width, int height)
{
SCREEN_WINDOW *scrwin;
scrwin = g_new0(SCREEN_WINDOW, 1);
scrwin->win = newwin(height, width, y, x);
idlok(scrwin->win, 1);
return scrwin;
}
void screen_window_destroy(SCREEN_WINDOW *window)
{
delwin(window->win);
g_free(window);
}
void screen_window_clear(SCREEN_WINDOW *window)
{
werase(window->win);
}
void screen_window_move(SCREEN_WINDOW *window, int x, int y,
int width, int height)
{
#ifdef HAVE_CURSES_WRESIZE
wresize(window->win, height, width);
mvwin(window->win, y, x);
#else
delwin(window->win);
window->win = newwin(height, width, y, x);
idlok(window->win, 1);
#endif
}
void screen_window_scroll(SCREEN_WINDOW *window, int count)
{
scrollok(window->win, TRUE);
wscrl(window->win, count);
scrollok(window->win, FALSE);
}
void screen_set_color(SCREEN_WINDOW *window, int col)
{ {
int attr; int attr;
@ -189,10 +272,10 @@ void set_color(WINDOW *window, int col)
if (col & ATTR_UNDERLINE) attr |= A_UNDERLINE; if (col & ATTR_UNDERLINE) attr |= A_UNDERLINE;
if (col & ATTR_REVERSE) attr |= A_REVERSE; if (col & ATTR_REVERSE) attr |= A_REVERSE;
wattrset(window, attr); wattrset(window->win, attr);
} }
void set_bg(WINDOW *window, int col) void screen_set_bg(SCREEN_WINDOW *window, int col)
{ {
int attr; int attr;
@ -207,10 +290,30 @@ void set_bg(WINDOW *window, int col)
if (col & 0x08) attr |= A_BOLD; if (col & 0x08) attr |= A_BOLD;
if (col & 0x80) attr |= A_BLINK; if (col & 0x80) attr |= A_BLINK;
wbkgdset(window, ' ' | attr); wbkgdset(window->win, ' ' | attr);
} }
void move_cursor(int y, int x) void screen_move(SCREEN_WINDOW *window, int x, int y)
{
wmove(window->win, y, x);
}
void screen_addch(SCREEN_WINDOW *window, int chr)
{
waddch(window->win, chr);
}
void screen_addstr(SCREEN_WINDOW *window, char *str)
{
waddstr(window->win, str);
}
void screen_clrtoeol(SCREEN_WINDOW *window)
{
wclrtoeol(window->win);
}
void screen_move_cursor(int x, int y)
{ {
scry = y; scry = y;
scrx = x; scrx = x;
@ -229,13 +332,30 @@ void screen_refresh_thaw(void)
} }
} }
void screen_refresh(WINDOW *window) void screen_refresh(SCREEN_WINDOW *window)
{ {
if (window != NULL) if (window != NULL)
wnoutrefresh(window); wnoutrefresh(window->win);
if (freeze_refresh == 0) { if (freeze_refresh == 0) {
move(scry, scrx); move(scry, scrx);
wnoutrefresh(stdscr); wnoutrefresh(stdscr);
doupdate(); doupdate();
} }
} }
int screen_getch(void)
{
int key;
key = getch();
if (key == ERR)
return -1;
#ifdef KEY_RESIZE
if (key == KEY_RESIZE)
return -1;
#endif
return key;
}

View File

@ -1,16 +1,7 @@
#ifndef __SCREEN_H #ifndef __SCREEN_H
#define __SCREEN_H #define __SCREEN_H
#if defined(USE_NCURSES) && !defined(RENAMED_NCURSES) typedef struct _SCREEN_WINDOW SCREEN_WINDOW;
# include <ncurses.h>
#else
# include <curses.h>
#endif
/* Some curseses include term.h, which #defines some things breaking irssi */
#undef lines
#undef key_backspace
#undef tab
#define ATTR_UNDERLINE 0x100 #define ATTR_UNDERLINE 0x100
#define ATTR_COLOR8 0x200 #define ATTR_COLOR8 0x200
@ -25,22 +16,43 @@
*/ */
#ifdef WANT_BIG5 #ifdef WANT_BIG5
/* XXX I didn't check the encoding range of big5+. This is standard big5. */ /* XXX I didn't check the encoding range of big5+. This is standard big5. */
#define is_big5_los(lo) (((char)0x40<=lo)&&(lo<=(char)0x7E)) /* standard */ # define is_big5_los(lo) (((char)0x40<=lo)&&(lo<=(char)0x7E)) /* standard */
#define is_big5_lox(lo) (((char)0x80<=lo)&&(lo<=(char)0xFE)) /* extended */ # define is_big5_lox(lo) (((char)0x80<=lo)&&(lo<=(char)0xFE)) /* extended */
#define is_big5_hi(hi) (((char)0x81<=hi)&&(hi<=(char)0xFE)) # define is_big5_hi(hi) (((char)0x81<=hi)&&(hi<=(char)0xFE))
#define is_big5(hi,lo) is_big5_hi(hi) && (is_big5_los(lo) || is_big5_lox(lo)) # define is_big5(hi,lo) is_big5_hi(hi) && (is_big5_los(lo) || is_big5_lox(lo))
#endif #endif
extern SCREEN_WINDOW *screen_root;
extern int screen_width, screen_height;
int init_screen(void); /* Initialize screen, detect screen length */ int init_screen(void); /* Initialize screen, detect screen length */
void deinit_screen(void); /* Deinitialize screen */ void deinit_screen(void); /* Deinitialize screen */
void set_color(WINDOW *window, int col); int screen_has_colors(void);
void set_bg(WINDOW *window, int col); void screen_clear(void);
void move_cursor(int y, int x); SCREEN_WINDOW *screen_window_create(int x, int y, int width, int height);
void screen_window_destroy(SCREEN_WINDOW *window);
void screen_window_clear(SCREEN_WINDOW *window);
void screen_window_move(SCREEN_WINDOW *window, int x, int y,
int width, int height);
void screen_window_scroll(SCREEN_WINDOW *window, int count);
void screen_set_color(SCREEN_WINDOW *window, int col);
void screen_set_bg(SCREEN_WINDOW *window, int col);
void screen_move(SCREEN_WINDOW *window, int x, int y);
void screen_addch(SCREEN_WINDOW *window, int chr);
void screen_addstr(SCREEN_WINDOW *window, char *str);
void screen_clrtoeol(SCREEN_WINDOW *window);
void screen_move_cursor(int x, int y);
void screen_refresh_freeze(void); void screen_refresh_freeze(void);
void screen_refresh_thaw(void); void screen_refresh_thaw(void);
void screen_refresh(WINDOW *window); void screen_refresh(SCREEN_WINDOW *window);
int screen_getch(void);
#endif #endif

View File

@ -632,7 +632,7 @@ static void sig_main_statusbar_changed(WINDOW_REC *window)
static void read_settings(void) static void read_settings(void)
{ {
use_colors = settings_get_bool("colors") && has_colors(); use_colors = settings_get_bool("colors") && screen_has_colors();
if (settings_get_bool("topicbar")) if (settings_get_bool("topicbar"))
topicbar_create(); topicbar_create();
else else

View File

@ -141,7 +141,7 @@ static void statusbar_redraw_line(STATUSBAR_REC *bar)
if (bar->window != NULL) if (bar->window != NULL)
active_win = bar->window->active; active_win = bar->window->active;
statusbar_get_sizes(bar, COLS-2); statusbar_get_sizes(bar, screen_width-2);
xpos = 1; xpos = 1;
for (tmp = bar->items; tmp != NULL; tmp = tmp->next) { for (tmp = bar->items; tmp != NULL; tmp = tmp->next) {
@ -154,7 +154,7 @@ static void statusbar_redraw_line(STATUSBAR_REC *bar)
} }
} }
rxpos = COLS-1; rxpos = screen_width-1;
for (tmp = bar->items; tmp != NULL; tmp = tmp->next) { for (tmp = bar->items; tmp != NULL; tmp = tmp->next) {
SBAR_ITEM_REC *rec = tmp->data; SBAR_ITEM_REC *rec = tmp->data;
@ -196,9 +196,10 @@ void statusbar_redraw(STATUSBAR_REC *bar)
return; return;
} }
set_bg(stdscr, backs[bar->color] << 4); screen_set_bg(screen_root, backs[bar->color] << 4);
move(bar->ypos, 0); clrtoeol(); screen_move(screen_root, 0, bar->ypos);
set_bg(stdscr, 0); screen_clrtoeol(screen_root);
screen_set_bg(screen_root, 0);
statusbar_redraw_line(bar); statusbar_redraw_line(bar);
@ -247,7 +248,8 @@ STATUSBAR_REC *statusbar_create(int pos, int ypos)
rec->line = pos == STATUSBAR_POS_MIDDLE ? ypos : rec->line = pos == STATUSBAR_POS_MIDDLE ? ypos :
mainwindows_reserve_lines(1, pos == STATUSBAR_POS_UP); mainwindows_reserve_lines(1, pos == STATUSBAR_POS_UP);
rec->ypos = pos == STATUSBAR_POS_MIDDLE ? ypos : rec->ypos = pos == STATUSBAR_POS_MIDDLE ? ypos :
pos == STATUSBAR_POS_UP ? rec->line : LINES-1-rec->line; pos == STATUSBAR_POS_UP ? rec->line :
screen_height-1-rec->line;
/* get background color from sb_background abstract */ /* get background color from sb_background abstract */
str = theme_format_expand(current_theme, "{sb_background}"); str = theme_format_expand(current_theme, "{sb_background}");
@ -268,9 +270,10 @@ STATUSBAR_REC *statusbar_create(int pos, int ypos)
rec->line -= sbar_lowest; rec->line -= sbar_lowest;
} }
set_bg(stdscr, backs[rec->color] << 4); screen_set_bg(screen_root, backs[rec->color] << 4);
move(rec->ypos, 0); clrtoeol(); screen_move(screen_root, 0, rec->ypos);
set_bg(stdscr, 0); screen_clrtoeol(screen_root);
screen_set_bg(screen_root, 0);
return rec; return rec;
} }

View File

@ -254,12 +254,12 @@ static int view_line_draw(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line,
color = cache->lines[subline-1].color; color = cache->lines[subline-1].color;
} }
set_color(view->window, 0); screen_set_color(view->window, 0);
wmove(view->window, ypos, 0); screen_move(view->window, 0, ypos);
wclrtoeol(view->window); screen_clrtoeol(view->window);
wmove(view->window, ypos, xpos); screen_move(view->window, xpos, ypos);
set_color(view->window, color); screen_set_color(view->window, color);
/* get the beginning of the next subline */ /* get the beginning of the next subline */
text_newline = subline == cache->count-1 ? NULL : text_newline = subline == cache->count-1 ? NULL :
@ -298,18 +298,18 @@ static int view_line_draw(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line,
color |= 0x80; color |= 0x80;
break; break;
} }
set_color(view->window, color); screen_set_color(view->window, color);
text++; text++;
continue; continue;
} }
if ((*text & 127) >= 32) if ((*text & 127) >= 32)
waddch(view->window, *text); screen_addch(view->window, *text);
else { else {
/* low-ascii */ /* low-ascii */
set_color(view->window, ATTR_REVERSE); screen_set_color(view->window, ATTR_REVERSE);
waddch(view->window, (*text & 127)+'A'-1); screen_addch(view->window, (*text & 127)+'A'-1);
set_color(view->window, color); screen_set_color(view->window, color);
} }
text++; text++;
} }
@ -475,8 +475,8 @@ static void view_draw(TEXT_BUFFER_VIEW_REC *view, GList *line,
/* clear the rest of the view */ /* clear the rest of the view */
while (lines > 0) { while (lines > 0) {
wmove(view->window, ypos, 0); screen_move(view->window, ypos, 0);
wclrtoeol(view->window); screen_clrtoeol(view->window);
ypos++; lines--; ypos++; lines--;
} }
} }
@ -562,9 +562,7 @@ static int view_scroll(TEXT_BUFFER_VIEW_REC *view, GList **lines, int *subline,
whole view */ whole view */
textbuffer_view_redraw(view); textbuffer_view_redraw(view);
} else { } else {
scrollok(view->window, TRUE); screen_window_scroll(view->window, realcount);
wscrl(view->window, realcount);
scrollok(view->window, FALSE);
if (draw_nonclean) { if (draw_nonclean) {
if (realcount < 0) if (realcount < 0)
@ -1054,7 +1052,8 @@ LINE_REC *textbuffer_view_get_bookmark(TEXT_BUFFER_VIEW_REC *view,
/* Specify window where the changes in view should be drawn, /* Specify window where the changes in view should be drawn,
NULL disables it. */ NULL disables it. */
void textbuffer_view_set_window(TEXT_BUFFER_VIEW_REC *view, WINDOW *window) void textbuffer_view_set_window(TEXT_BUFFER_VIEW_REC *view,
SCREEN_WINDOW *window)
{ {
g_return_if_fail(view != NULL); g_return_if_fail(view != NULL);
@ -1071,7 +1070,7 @@ void textbuffer_view_redraw(TEXT_BUFFER_VIEW_REC *view)
g_return_if_fail(view != NULL); g_return_if_fail(view != NULL);
if (view->window != NULL) { if (view->window != NULL) {
werase(view->window); screen_window_clear(view->window);
view_draw_top(view, view->height); view_draw_top(view, view->height);
screen_refresh(view->window); screen_refresh(view->window);
} }

View File

@ -41,7 +41,7 @@ typedef struct {
TEXT_BUFFER_REC *buffer; TEXT_BUFFER_REC *buffer;
GSList *siblings; /* other views that use the same buffer */ GSList *siblings; /* other views that use the same buffer */
WINDOW *window; SCREEN_WINDOW *window;
int width, height; int width, height;
int default_indent; int default_indent;
@ -121,7 +121,8 @@ LINE_REC *textbuffer_view_get_bookmark(TEXT_BUFFER_VIEW_REC *view,
/* Specify window where the changes in view should be drawn, /* Specify window where the changes in view should be drawn,
NULL disables it. */ NULL disables it. */
void textbuffer_view_set_window(TEXT_BUFFER_VIEW_REC *view, WINDOW *window); void textbuffer_view_set_window(TEXT_BUFFER_VIEW_REC *view,
SCREEN_WINDOW *window);
/* Redraw the view */ /* Redraw the view */
void textbuffer_view_redraw(TEXT_BUFFER_VIEW_REC *view); void textbuffer_view_redraw(TEXT_BUFFER_VIEW_REC *view);