diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-11-10 13:28:06 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-11-10 13:37:17 +0000 |
| commit | 7d4c9c2ccf75f56e449dc28e91f960be144fdafd (patch) | |
| tree | 54f7fd57122c9869b76727025086b1d7047315c5 /src/ncurses.cc | |
| parent | 075e4985d79c81b23842ade9ccc1ac83ec312af3 (diff) | |
Support hinting if an inline info should be above or below the anchor
Used by ctags function info, we always want it *above* the opening
parenthesis so that it does not hide multi line parameter lists.
Diffstat (limited to 'src/ncurses.cc')
| -rw-r--r-- | src/ncurses.cc | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/ncurses.cc b/src/ncurses.cc index 88a4a93b..2931e340 100644 --- a/src/ncurses.cc +++ b/src/ncurses.cc @@ -642,12 +642,23 @@ static CharCoord compute_needed_size(StringView str) } static CharCoord compute_pos(CharCoord anchor, CharCoord size, - WINDOW* opt_window_to_avoid = nullptr) + WINDOW* opt_window_to_avoid = nullptr, + bool prefer_above = false) { CharCoord scrsize = window_size(stdscr); - CharCoord pos = { anchor.line+1, anchor.column }; - if (pos.line + size.line >= scrsize.line) - pos.line = max(0_line, anchor.line - size.line); + CharCoord pos; + if (prefer_above) + { + pos = anchor - CharCoord{size.line}; + if (pos.line < 0) + prefer_above = false; + } + if (not prefer_above) + { + pos = anchor + CharCoord{1_line}; + if (pos.line + size.line >= scrsize.line) + pos.line = max(0_line, anchor.line - size.line); + } if (pos.column + size.column >= scrsize.column) pos.column = max(0_char, anchor.column - size.column+1); @@ -790,7 +801,7 @@ void NCursesUI::info_show(StringView title, StringView content, pos = window_pos(m_menu_win) + CharCoord{0_line, window_size(m_menu_win).column}; else - pos = compute_pos(anchor, size, m_menu_win); + pos = compute_pos(anchor, size, m_menu_win, style == InfoStyle::InlineAbove); m_info_win = (NCursesWin*)newwin((int)size.line, (int)size.column, (int)pos.line, (int)pos.column); |
