summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2012-09-03 19:20:41 +0200
committerMaxime Coste <frrrwww@gmail.com>2012-09-03 19:20:41 +0200
commitc2a4f68899949f69d60df13b2a1ecddf7478e9fc (patch)
tree8d8099f85dbe523ae531fc2a61368959b4ba2f5e /src
parentb08d8719e6a5b6cee67f93a9c62117b747ae4430 (diff)
NCurses: Fix menu display
Diffstat (limited to 'src')
-rw-r--r--src/client.cc10
-rw-r--r--src/ncurses.cc17
2 files changed, 25 insertions, 2 deletions
diff --git a/src/client.cc b/src/client.cc
index dffd3986..296ffa68 100644
--- a/src/client.cc
+++ b/src/client.cc
@@ -53,6 +53,11 @@ public:
client.show_menu(choices);
}
+ ~MenuMode()
+ {
+ m_client.menu_ctrl(MenuCommand::Close);
+ }
+
void on_key(const Key& key, Context& context) override
{
if (key == Key(Key::Modifiers::Control, 'n') or
@@ -107,6 +112,11 @@ public:
m_client.print_status(m_prompt, m_prompt.length());
}
+ ~PromptMode()
+ {
+ m_client.menu_ctrl(MenuCommand::Close);
+ }
+
void on_key(const Key& key, Context& context) override
{
std::vector<String>& history = ms_history[m_prompt];
diff --git a/src/ncurses.cc b/src/ncurses.cc
index 2f420a8d..5554ed8b 100644
--- a/src/ncurses.cc
+++ b/src/ncurses.cc
@@ -92,11 +92,21 @@ void NCursesClient::draw_window(Window& window)
int max_x,max_y;
getmaxyx(stdscr, max_y, max_x);
max_y -= 1;
+ int status_y = max_y;
+
+ if (m_menu)
+ {
+ int rows;
+ int cols;
+ menu_format(m_menu, &rows, &cols);
+ max_y -= rows;
+ }
window.set_dimensions(DisplayCoord(LineCount(max_y), max_x));
window.update_display_buffer();
int line_index = 0;
+ int last_line = INT_MAX;
for (const DisplayLine& line : window.display_buffer().lines())
{
move(line_index, 0);
@@ -137,9 +147,9 @@ void NCursesClient::draw_window(Window& window)
set_color(Color::Cyan, Color::Black);
String status_line = window.status_line();
static int last_status_length = 0;
- move(max_y, max_x - last_status_length);
+ move(status_y, max_x - last_status_length);
clrtoeol();
- move(max_y, max_x - (int)status_line.length());
+ move(status_y, max_x - (int)status_line.length());
addstr(status_line.c_str());
last_status_length = (int)status_line.length();
refresh();
@@ -221,6 +231,7 @@ void NCursesClient::show_menu(const memoryview<String>& choices)
set_menu_sub(m_menu, derwin(stdscr, max_y - pos_y - 1, max_x, pos_y, 0));
set_menu_format(m_menu, lines, columns);
post_menu(m_menu);
+ refresh();
}
void NCursesClient::menu_ctrl(MenuCommand command)
@@ -248,9 +259,11 @@ void NCursesClient::menu_ctrl(MenuCommand command)
m_menu = nullptr;
m_items.clear();
m_counts.clear();
+ m_counts.clear();
break;
}
}
+ refresh();
}
}