set/reset mode window functions.

This commit is contained in:
Nicholas Marriott
2007-12-06 10:04:43 +00:00
parent 103748d6ad
commit 7dc18f68e3
9 changed files with 67 additions and 58 deletions

View File

@ -1,4 +1,4 @@
/* $Id: window-scroll.c,v 1.15 2007-12-06 09:46:23 nicm Exp $ */
/* $Id: window-scroll.c,v 1.16 2007-12-06 10:04:43 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -22,7 +22,7 @@
#include "tmux.h"
void window_scroll_init(struct window *);
struct screen *window_scroll_init(struct window *);
void window_scroll_free(struct window *);
void window_scroll_resize(struct window *, u_int, u_int);
void window_scroll_key(struct window *, int);
@ -52,7 +52,7 @@ struct window_scroll_mode_data {
u_int oy;
};
void
struct screen *
window_scroll_init(struct window *w)
{
struct window_scroll_mode_data *data;
@ -67,12 +67,13 @@ window_scroll_init(struct window *w)
s = &data->screen;
screen_create(s, screen_size_x(&w->base), screen_size_y(&w->base));
s->mode = 0;
w->screen = s;
screen_write_start(&ctx, s, NULL, NULL);
for (i = 0; i < screen_size_y(s); i++)
window_scroll_write_line(w, &ctx, i);
screen_write_stop(&ctx);
return (s);
}
void
@ -80,11 +81,8 @@ window_scroll_free(struct window *w)
{
struct window_scroll_mode_data *data = w->modedata;
w->screen = &w->base;
screen_destroy(&data->screen);
w->mode = NULL;
xfree(w->modedata);
xfree(data);
}
void
@ -107,8 +105,7 @@ window_scroll_key(struct window *w, int key)
switch (key) {
case 'Q':
case 'q':
window_scroll_free(w);
server_redraw_window(w);
window_reset_mode(w);
break;
case 'h':
case KEYC_LEFT: