MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / Scroll

Method Scroll

src/console_gui.cpp:180–192  ·  view source on GitHub ↗

* Scroll the content of the console. * @param amount Number of lines to scroll back. */

Source from the content-addressed store, hash-verified

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 {

Callers 2

OnKeyPressMethod · 0.95
OnMouseWheelMethod · 0.95

Calls 2

sizeMethod · 0.45
SetDirtyMethod · 0.45

Tested by

no test coverage detected