void do_scroll_vertical (int num_to_scroll) override;
void do_scroll_horizontal (int num_to_scroll) override;
+ void refresh_window () override
+ {
+ tui_win_info::refresh_window ();
+ if (m_inner_window != nullptr)
+ {
+ touchwin (m_inner_window.get ());
+ tui_wrefresh (m_inner_window.get ());
+ }
+ }
+
/* Erase and re-box the window. */
void erase ()
{
- if (is_visible ())
+ if (is_visible () && m_inner_window != nullptr)
{
- werase (handle.get ());
+ werase (m_inner_window.get ());
check_and_display_highlight_if_needed ();
- cursor_x = 0;
- cursor_y = 0;
}
}
private:
- /* Location of the cursor. */
- int cursor_x = 0;
- int cursor_y = 0;
-
/* The name of this window. */
std::string m_name;
+ /* We make our own inner window, so that it is easy to print without
+ overwriting the border. */
+ std::unique_ptr<WINDOW, curses_deleter> m_inner_window;
+
/* The underlying Python window object. */
gdbpy_ref<> m_window;
void
tui_py_window::rerender ()
{
+ tui_win_info::rerender ();
+
gdbpy_enter enter_py (get_current_arch (), current_language);
+ int h = viewport_height ();
+ int w = viewport_width ();
+ if (h == 0 || w == 0)
+ {
+ /* The window would be too small, so just remove the
+ contents. */
+ m_inner_window.reset (nullptr);
+ return;
+ }
+ m_inner_window.reset (newwin (h, w, y + 1, x + 1));
+
if (PyObject_HasAttrString (m_window.get (), "render"))
{
gdbpy_ref<> result (PyObject_CallMethod (m_window.get (), "render",
void
tui_py_window::output (const char *text)
{
- int vwidth = viewport_width ();
-
- while (cursor_y < viewport_height () && *text != '\0')
+ if (m_inner_window != nullptr)
{
- wmove (handle.get (), cursor_y + 1, cursor_x + 1);
-
- std::string line = tui_copy_source_line (&text, 0, 0,
- vwidth - cursor_x, 0);
- tui_puts (line.c_str (), handle.get ());
-
- if (*text == '\n')
- {
- ++text;
- ++cursor_y;
- cursor_x = 0;
- }
- else
- cursor_x = getcurx (handle.get ()) - 1;
+ tui_puts (text, m_inner_window.get ());
+ tui_wrefresh (m_inner_window.get ());
}
-
- wrefresh (handle.get ());
}
\f