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

Function IConsoleHistoryNavigate

src/console_gui.cpp:476–487  ·  view source on GitHub ↗

* Navigate Up/Down in the history of typed commands * @param direction Go further back in history (+1), go to recently typed commands (-1) */

Source from the content-addressed store, hash-verified

474 * @param direction Go further back in history (+1), go to recently typed commands (-1)
475 */
476static void IConsoleHistoryNavigate(int direction)
477{
478 if (_iconsole_history.empty()) return; // Empty history
479 _iconsole_historypos = Clamp<ptrdiff_t>(_iconsole_historypos + direction, -1, _iconsole_history.size() - 1);
480
481 if (_iconsole_historypos == -1) {
482 _iconsole_cmdline.DeleteAll();
483 } else {
484 _iconsole_cmdline.Assign(_iconsole_history[_iconsole_historypos]);
485 }
486 _iconsole_tab_completion.Reset();
487}
488
489/**
490 * Handle the printing of text entered into the console or redirected there

Callers 1

OnKeyPressMethod · 0.85

Calls 5

DeleteAllMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
AssignMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected