* Scroll the content of the console. * @param amount Number of lines to scroll back. */
| 178 | * @param amount Number of lines to scroll back. |
| 179 | */ |
| 180 | void Scroll(int amount) |
| 181 | { |
| 182 | if (amount < 0) { |
| 183 | size_t namount = static_cast<size_t>(-amount); |
| 184 | IConsoleWindow::scroll = (namount > IConsoleWindow::scroll) ? 0 : IConsoleWindow::scroll - namount; |
| 185 | } else { |
| 186 | assert(this->height >= 0 && this->line_height > 0); |
| 187 | size_t visible_lines = static_cast<size_t>(this->height / this->line_height); |
| 188 | size_t max_scroll = (visible_lines > _iconsole_buffer.size()) ? 0 : _iconsole_buffer.size() + 1 - visible_lines; |
| 189 | IConsoleWindow::scroll = std::min<size_t>(IConsoleWindow::scroll + amount, max_scroll); |
| 190 | } |
| 191 | this->SetDirty(); |
| 192 | } |
| 193 | |
| 194 | void OnPaint() override |
| 195 | { |
no test coverage detected