diff --git a/modules/gui/src/python_shell/shell_history.cc b/modules/gui/src/python_shell/shell_history.cc index a761cd86f787dd3e9ade0fa997b2abbd492c1a12..14ce28eaf96eebc4e8a61659daebc0c5b7e1d93b 100644 --- a/modules/gui/src/python_shell/shell_history.cc +++ b/modules/gui/src/python_shell/shell_history.cc @@ -19,7 +19,6 @@ /* Author: Andreas Schenk */ - #include "shell_history.hh" namespace ost { namespace gui { @@ -77,29 +76,33 @@ bool ShellHistory::AtEnd() return index_>=history_list_.size(); } -void ShellHistory::operator--() +void ShellHistory::MoveToPreviousMatch() { - if(index_>0){ - --index_; + int newindex=index_-1; + while(newindex>=0){ + if(history_list_[newindex].first.indexOf(current_)==0 || current_.size()==0){ + index_=newindex; + break; + } + --newindex; } } -void ShellHistory::operator--(int) -{ - operator--(); -} - -void ShellHistory::operator++() +void ShellHistory::MoveToNextMatch() { - if(index_<history_list_.size()){ - ++index_; + int newindex=index_+1; + while(newindex<history_list_.size()){ + if(history_list_[newindex].first.indexOf(current_)==0 || current_.size()==0){ + index_=newindex; + break; + } + ++newindex; + } + if(newindex!=index_){ + index_=history_list_.size(); } } -void ShellHistory::operator++(int) -{ - operator++(); -} }}//ns diff --git a/modules/gui/src/python_shell/shell_history.hh b/modules/gui/src/python_shell/shell_history.hh index 653650fb2181c4935669e1dabce41a72434cf861..a04bd8469e50deb6113c208cce104465cdaccbc8 100644 --- a/modules/gui/src/python_shell/shell_history.hh +++ b/modules/gui/src/python_shell/shell_history.hh @@ -38,10 +38,8 @@ public: QString GetCommand(); BlockEditMode GetCommandMode(); bool AtEnd(); - void operator--(); - void operator--(int); - void operator++(); - void operator++(int); + void MoveToPreviousMatch(); + void MoveToNextMatch(); protected: std::vector<std::pair<QString,BlockEditMode> > history_list_; QString current_;