MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / prev

Method prev

src/Gui/PythonConsole.cpp:1636–1653  ·  view source on GitHub ↗

* prev switches the history pointer to the previous item. * The optional parameter prefix allows one to search the history selectively for commands that * start with a certain character sequence. * @param prefix - prefix string for searching backwards in history, empty string by default * @return true if the pointer was switched to an earlier item, false otherwise. */

Source from the content-addressed store, hash-verified

1634 * @return true if the pointer was switched to an earlier item, false otherwise.
1635 */
1636bool ConsoleHistory::prev(const QString& prefix)
1637{
1638 bool wentPrev = false;
1639
1640 // store prefix if it's the first history access
1641 if (_it == _history.cend()) {
1642 _prefix = prefix;
1643 }
1644
1645 // while we didn't go back or reach history's begin ...
1646 while (!wentPrev && _it != _history.cbegin()) {
1647 // go back in history and check if item matches prefix
1648 // Skip empty items
1649 --_it;
1650 wentPrev = (!_it->isEmpty() && _it->startsWith(_prefix));
1651 }
1652 return wentPrev;
1653}
1654
1655bool ConsoleHistory::isEmpty() const
1656{

Callers 5

dumpEdgeFunction · 0.80
isSameBranchMethod · 0.80
makeMAFunction · 0.80
keyPressEventMethod · 0.80
getPrevMethod · 0.80

Calls 4

cendMethod · 0.80
cbeginMethod · 0.80
startsWithMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected