This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Changeset 9939 for ps


Ignore:
Timestamp:
07/31/11 01:06:09 (13 years ago)
Author:
philip
Message:

Replace console prefix-search behaviour with more standard history navigation, based on patch by Ross Bearman.
Fixes #906.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/source/ps/CConsole.cpp

    r9658 r9939  
    407407        // BEGIN: Buffer History Lookup
    408408        case SDLK_UP:
    409             if ( m_deqBufHistory.size() )
    410             {
    411                 int oldHistoryPos = iHistoryPos;
    412                 while( iHistoryPos != (int)m_deqBufHistory.size() - 1)
    413                 {
    414                     iHistoryPos++;
    415                     std::wstring& histString = m_deqBufHistory.at(iHistoryPos);
    416                     if((int)histString.length() >= m_iBufferPos)
    417                     {
    418                         bool bad = false;
    419                         for(int i=0; i<m_iBufferPos; i++)
    420                         {
    421                             if(histString[i] != m_szBuffer[i])
    422                             {
    423                                 bad = true; break;
    424                             }
    425                         }
    426                         if(!bad)
    427                         {
    428                             SetBuffer(m_deqBufHistory.at(iHistoryPos).c_str());
    429                             return;
    430                         }
    431                     }
    432                 }
    433                 // if we got here, failed to find a string with the right prefix;
    434                 // revert to the old position in case the user types more stuff
    435                 iHistoryPos = oldHistoryPos;
     409            if (m_deqBufHistory.size() && iHistoryPos != (int)m_deqBufHistory.size() - 1)
     410            {
     411                iHistoryPos++;
     412                SetBuffer(m_deqBufHistory.at(iHistoryPos).c_str());
     413                m_iBufferPos = m_iBufferLength;
    436414            }
    437415            return;
    438416
    439417        case SDLK_DOWN:
    440             if ( m_deqBufHistory.size() && iHistoryPos > 0 )
    441             {
    442                 int oldHistoryPos = iHistoryPos;
    443                 while( iHistoryPos != 0)
     418            if (m_deqBufHistory.size())
     419            {
     420                if (iHistoryPos > 0)
    444421                {
    445422                    iHistoryPos--;
    446                     std::wstring& histString = m_deqBufHistory.at(iHistoryPos);
    447                     if((int)histString.length() >= m_iBufferPos)
    448                     {
    449                         bool bad = false;
    450                         for(int i=0; i<m_iBufferPos; i++)
    451                         {
    452                             if(histString[i] != m_szBuffer[i])
    453                             {
    454                                 bad = true; break;
    455                             }
    456                         }
    457                         if(!bad)
    458                         {
    459                             SetBuffer(m_deqBufHistory.at(iHistoryPos).c_str());
    460                             return;
    461                         }
    462                     }
     423                    SetBuffer(m_deqBufHistory.at(iHistoryPos).c_str());
     424                    m_iBufferPos = m_iBufferLength;
    463425                }
    464                 // if we got here, failed to find a string with the right prefix;
    465                 // revert to the old position in case the user types more stuff,
    466                 // and also clear any complietion we might've added going up
    467                 iHistoryPos = oldHistoryPos;
    468                 m_szBuffer[m_iBufferPos] = 0;
    469                 m_iBufferLength = m_iBufferPos;
     426                else if (iHistoryPos == 0)
     427                {
     428                    iHistoryPos--;
     429                    FlushBuffer();
     430                }
    470431            }
    471432            return;
Note: See TracChangeset for help on using the changeset viewer.