terminal_mux: Free ncurses meta data

This commit is contained in:
Norman Feske 2013-03-27 13:39:13 +01:00
parent 0d01fd829f
commit e4c28a1739
3 changed files with 28 additions and 0 deletions

View File

@ -190,6 +190,7 @@ namespace Terminal {
Read_buffer _read_buffer;
Ncurses &_ncurses;
Ncurses::Window &_window;
struct Label
@ -223,6 +224,7 @@ namespace Terminal {
Session_manager &session_manager,
char const *label)
:
_ncurses(ncurses),
_window(*ncurses.create_window(0, 1, ncurses.columns(), ncurses.lines() - 1)),
_label(label),
_session_manager(session_manager),
@ -238,6 +240,7 @@ namespace Terminal {
~Session_component()
{
_session_manager.remove(this);
_ncurses.destroy_window(&_window);
}
@ -406,6 +409,11 @@ class Status_window
_label[0] = 0;
}
~Status_window()
{
_ncurses.destroy_window(&_window);
}
void label(char const *label)
{
Genode::strncpy(_label, label, sizeof(_label));
@ -501,6 +509,11 @@ class Menu : public Registry::Entry
_max_idx(0)
{ }
~Menu()
{
_ncurses.destroy_window(&_window);
}
void reset_selection() { _selected_idx = 0; }
void flush() { }

View File

@ -29,6 +29,12 @@ Ncurses::Window::Window(unsigned x, unsigned y, unsigned w, unsigned h)
{ }
Ncurses::Window::~Window()
{
delwin(_window);
}
void Ncurses::Window::move_cursor(unsigned x, unsigned y)
{
wmove(_window, y, x);
@ -66,6 +72,12 @@ Ncurses::Window *Ncurses::create_window(int x, int y, int w, int h)
}
void Ncurses::destroy_window(Ncurses::Window *window)
{
Genode::destroy(Genode::env()->heap(), window);
}
void Ncurses::clear_ok()
{
clearok(stdscr, true);

View File

@ -32,6 +32,8 @@ class Ncurses
public:
~Window();
void move_cursor(unsigned x, unsigned y);
void print_char(unsigned long const c, bool highlight, bool inverse);
@ -44,6 +46,7 @@ class Ncurses
};
Window *create_window(int x, int y, int w, int h);
void destroy_window(Ncurses::Window *window);
void clear_ok();