mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Reset the color before clearing screen. Set the cursor invisible when moving
around in screen and set it visible again when it's in wanted position. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1964 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
67a9ad0598
commit
25b04419d4
@ -37,10 +37,11 @@ struct _TERM_WINDOW {
|
|||||||
TERM_WINDOW *root_window;
|
TERM_WINDOW *root_window;
|
||||||
int term_width, term_height;
|
int term_width, term_height;
|
||||||
|
|
||||||
static int vcx, vcy;
|
static int vcx, vcy, curs_visible;
|
||||||
static int curs_x, curs_y;
|
static int curs_x, curs_y;
|
||||||
static int last_fg, last_bg, last_attrs;
|
static int last_fg, last_bg, last_attrs;
|
||||||
static int redraw_needed, redraw_tag;
|
static int redraw_needed, redraw_tag;
|
||||||
|
static int freeze_counter;
|
||||||
|
|
||||||
/* SIGCONT handler */
|
/* SIGCONT handler */
|
||||||
static void sig_cont(int p)
|
static void sig_cont(int p)
|
||||||
@ -65,7 +66,8 @@ int term_init(void)
|
|||||||
|
|
||||||
last_fg = last_bg = -1;
|
last_fg = last_bg = -1;
|
||||||
last_attrs = 0;
|
last_attrs = 0;
|
||||||
vcx = vcy = -1;
|
vcx = vcy = -1;
|
||||||
|
curs_visible = TRUE;
|
||||||
|
|
||||||
current_term = terminfo_core_init(stdin, stdout);
|
current_term = terminfo_core_init(stdin, stdout);
|
||||||
if (current_term == NULL)
|
if (current_term == NULL)
|
||||||
@ -134,6 +136,7 @@ void term_force_colors(int set)
|
|||||||
void term_clear(void)
|
void term_clear(void)
|
||||||
{
|
{
|
||||||
vcx = vcy = -1;
|
vcx = vcy = -1;
|
||||||
|
term_set_color(root_window, 0);
|
||||||
terminfo_clear();
|
terminfo_clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,6 +267,11 @@ void term_move(TERM_WINDOW *window, int x, int y)
|
|||||||
{
|
{
|
||||||
int newx, newy;
|
int newx, newy;
|
||||||
|
|
||||||
|
if (curs_visible) {
|
||||||
|
terminfo_set_cursor_visible(FALSE);
|
||||||
|
curs_visible = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
newx = x+window->x;
|
newx = x+window->x;
|
||||||
newy = y+window->y;
|
newy = y+window->y;
|
||||||
if (vcx != newx || vcy != newy) {
|
if (vcx != newx || vcy != newy) {
|
||||||
@ -305,17 +313,31 @@ void term_move_cursor(int x, int y)
|
|||||||
|
|
||||||
void term_refresh(TERM_WINDOW *window)
|
void term_refresh(TERM_WINDOW *window)
|
||||||
{
|
{
|
||||||
|
if (freeze_counter > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (vcx != curs_x || vcy != curs_y)
|
if (vcx != curs_x || vcy != curs_y)
|
||||||
term_move(root_window, curs_x, curs_y);
|
term_move(root_window, curs_x, curs_y);
|
||||||
|
if (!curs_visible) {
|
||||||
|
terminfo_set_cursor_visible(TRUE);
|
||||||
|
curs_visible = TRUE;
|
||||||
|
}
|
||||||
fflush(window != NULL ? window->term->out : current_term->out);
|
fflush(window != NULL ? window->term->out : current_term->out);
|
||||||
}
|
}
|
||||||
|
|
||||||
void term_refresh_freeze(void)
|
void term_refresh_freeze(void)
|
||||||
{
|
{
|
||||||
|
freeze_counter++;
|
||||||
|
if (curs_visible) {
|
||||||
|
terminfo_set_cursor_visible(FALSE);
|
||||||
|
curs_visible = FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void term_refresh_thaw(void)
|
void term_refresh_thaw(void)
|
||||||
{
|
{
|
||||||
|
if (--freeze_counter == 0)
|
||||||
|
term_refresh(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void term_stop(void)
|
void term_stop(void)
|
||||||
|
@ -59,10 +59,12 @@ static TERMINFO_REC tcaps[] = {
|
|||||||
{ "smcup", "ti", CAP_TYPE_STR, &temp_term.TI_smcup },
|
{ "smcup", "ti", CAP_TYPE_STR, &temp_term.TI_smcup },
|
||||||
{ "rmcup", "te", CAP_TYPE_STR, &temp_term.TI_rmcup },
|
{ "rmcup", "te", CAP_TYPE_STR, &temp_term.TI_rmcup },
|
||||||
{ "cup", "cm", CAP_TYPE_STR, &temp_term.TI_cup },
|
{ "cup", "cm", CAP_TYPE_STR, &temp_term.TI_cup },
|
||||||
{ "hpa", "ch", CAP_TYPE_STR, &temp_term.TI_hpa },
|
{ "hpa", "ch", CAP_TYPE_STR, &temp_term.TI_hpa },
|
||||||
{ "vpa", "vh", CAP_TYPE_STR, &temp_term.TI_vpa },
|
{ "vpa", "vh", CAP_TYPE_STR, &temp_term.TI_vpa },
|
||||||
{ "cub1", "le", CAP_TYPE_STR, &temp_term.TI_cub1 },
|
{ "cub1", "le", CAP_TYPE_STR, &temp_term.TI_cub1 },
|
||||||
{ "cuf1", "nd", CAP_TYPE_STR, &temp_term.TI_cuf1 },
|
{ "cuf1", "nd", CAP_TYPE_STR, &temp_term.TI_cuf1 },
|
||||||
|
{ "civis", "vi", CAP_TYPE_STR, &temp_term.TI_civis },
|
||||||
|
{ "cnorm", "ve", CAP_TYPE_STR, &temp_term.TI_cnorm },
|
||||||
|
|
||||||
/* Scrolling */
|
/* Scrolling */
|
||||||
{ "csr", "cs", CAP_TYPE_STR, &temp_term.TI_csr },
|
{ "csr", "cs", CAP_TYPE_STR, &temp_term.TI_csr },
|
||||||
@ -150,6 +152,12 @@ static void _move_relative(TERM_REC *term, int oldx, int oldy, int x, int y)
|
|||||||
tput(tparm(term->TI_hpa, x));
|
tput(tparm(term->TI_hpa, x));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set cursor visible/invisible */
|
||||||
|
static void _set_cursor_visible(TERM_REC *term, int set)
|
||||||
|
{
|
||||||
|
tput(tparm(set ? term->TI_cnorm : term->TI_civis));
|
||||||
|
}
|
||||||
|
|
||||||
#define scroll_region_setup(term, y1, y2) \
|
#define scroll_region_setup(term, y1, y2) \
|
||||||
if ((term)->TI_csr != NULL) \
|
if ((term)->TI_csr != NULL) \
|
||||||
tput(tparm((term)->TI_csr, y1, y2)); \
|
tput(tparm((term)->TI_csr, y1, y2)); \
|
||||||
@ -530,8 +538,9 @@ static int term_setup(TERM_REC *term)
|
|||||||
fprintf(term->out, "Terminal doesn't support cursor movement\n");
|
fprintf(term->out, "Terminal doesn't support cursor movement\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
term->move_relative = _move_relative;
|
term->move_relative = _move_relative;
|
||||||
|
term->set_cursor_visible = term->TI_civis && term->TI_cnorm ?
|
||||||
|
_set_cursor_visible : _ignore_parm;
|
||||||
|
|
||||||
/* Scrolling */
|
/* Scrolling */
|
||||||
if ((term->TI_csr || term->TI_wind) && term->TI_rin && term->TI_indn)
|
if ((term->TI_csr || term->TI_wind) && term->TI_rin && term->TI_indn)
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#define terminfo_move(x, y) current_term->move(current_term, x, y)
|
#define terminfo_move(x, y) current_term->move(current_term, x, y)
|
||||||
#define terminfo_move_relative(oldx, oldy, x, y) current_term->move_relative(current_term, oldx, oldy, x, y)
|
#define terminfo_move_relative(oldx, oldy, x, y) current_term->move_relative(current_term, oldx, oldy, x, y)
|
||||||
|
#define terminfo_set_cursor_visible(set) current_term->set_cursor_visible(current_term, set)
|
||||||
#define terminfo_scroll(y1, y2, count) current_term->scroll(current_term, y1, y2, count)
|
#define terminfo_scroll(y1, y2, count) current_term->scroll(current_term, y1, y2, count)
|
||||||
#define terminfo_clear() current_term->clear(current_term)
|
#define terminfo_clear() current_term->clear(current_term)
|
||||||
#define terminfo_clrtoeol() current_term->clrtoeol(current_term)
|
#define terminfo_clrtoeol() current_term->clrtoeol(current_term)
|
||||||
@ -24,6 +25,7 @@ struct _TERM_REC {
|
|||||||
/* Functions */
|
/* Functions */
|
||||||
void (*move)(TERM_REC *term, int x, int y);
|
void (*move)(TERM_REC *term, int x, int y);
|
||||||
void (*move_relative)(TERM_REC *term, int oldx, int oldy, int x, int y);
|
void (*move_relative)(TERM_REC *term, int oldx, int oldy, int x, int y);
|
||||||
|
void (*set_cursor_visible)(TERM_REC *term, int set);
|
||||||
void (*scroll)(TERM_REC *term, int y1, int y2, int count);
|
void (*scroll)(TERM_REC *term, int y1, int y2, int count);
|
||||||
|
|
||||||
void (*clear)(TERM_REC *term);
|
void (*clear)(TERM_REC *term);
|
||||||
@ -51,6 +53,7 @@ struct _TERM_REC {
|
|||||||
/* Cursor movement */
|
/* Cursor movement */
|
||||||
const char *TI_smcup, *TI_rmcup, *TI_cup;
|
const char *TI_smcup, *TI_rmcup, *TI_cup;
|
||||||
const char *TI_hpa, *TI_vpa, *TI_cub1, *TI_cuf1;
|
const char *TI_hpa, *TI_vpa, *TI_cub1, *TI_cuf1;
|
||||||
|
const char *TI_civis, *TI_cnorm;
|
||||||
|
|
||||||
/* Scrolling */
|
/* Scrolling */
|
||||||
const char *TI_csr, *TI_wind;
|
const char *TI_csr, *TI_wind;
|
||||||
|
Loading…
Reference in New Issue
Block a user