diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-12-06 10:04:43 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-12-06 10:04:43 +0000 |
commit | 7dc18f68e3dd016d381bef43b943c0c482057e57 (patch) | |
tree | 39e3ad8d1ff8dbebde3188ac8541a53b01a5ddbc /window.c | |
parent | 103748d6adfe1b2d706cb0a1e1a128be5366d655 (diff) |
set/reset mode window functions.
Diffstat (limited to 'window.c')
-rw-r--r-- | window.c | 34 |
1 files changed, 31 insertions, 3 deletions
@@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.33 2007-12-06 09:46:23 nicm Exp $ */ +/* $Id: window.c,v 1.34 2007-12-06 10:04:43 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -244,9 +244,8 @@ window_destroy(struct window *w) input_free(w); + window_reset_mode(w); screen_destroy(&w->base); - if (w->mode != NULL) - w->mode->free(w); buffer_destroy(w->in); buffer_destroy(w->out); @@ -276,6 +275,35 @@ window_resize(struct window *w, u_int sx, u_int sy) return (0); } +int +window_set_mode(struct window *w, const struct window_mode *mode) +{ + struct screen *s; + + if (w->mode != NULL || w->mode == mode) + return (1); + + w->mode = mode; + + if ((s = w->mode->init(w)) != NULL) + w->screen = s; + server_redraw_window(w); + return (0); +} + +void +window_reset_mode(struct window *w) +{ + if (w->mode == NULL) + return; + + w->mode->free(w); + w->mode = NULL; + + w->screen = &w->base; + server_redraw_window(w); +} + void window_parse(struct window *w) { |