diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-05-16 21:44:58 +0200 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-05-16 21:44:58 +0200 |
| commit | b2dffbabb64a045ab01907bbbb9e621787201efe (patch) | |
| tree | abafc195e89652fe8d2cc62ac5d1d3c49b902bc1 /src | |
| parent | 310e0f5bd3e306262f5bed95852b825c8815fee1 (diff) | |
more robust NCursesUI::menu_show
Diffstat (limited to 'src')
| -rw-r--r-- | src/ncurses.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/ncurses.cc b/src/ncurses.cc index f4e44d90..54600c09 100644 --- a/src/ncurses.cc +++ b/src/ncurses.cc @@ -420,12 +420,15 @@ void NCursesUI::menu_show(const memoryview<String>& choices, DisplayCoord maxsize = window_size(stdscr); maxsize.column -= anchor.column; + if (maxsize.column <= 2) + return; m_choices.reserve(choices.size()); CharCount longest = 0; + const CharCount maxlen = std::min((int)maxsize.column-2, 200); for (auto& choice : choices) { - m_choices.push_back(choice.substr(0_char, std::min((int)maxsize.column-2, 200))); + m_choices.push_back(choice.substr(0_char, maxlen)); longest = std::max(longest, m_choices.back().char_length()); } longest += 1; |
