Mercurial > fife-parpg
diff engine/core/gui/console/commandline.cpp @ 378:64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
author | vtchill@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 11 Jan 2010 23:34:52 +0000 |
parents | 756b895e1dab |
children |
line wrap: on
line diff
--- a/engine/core/gui/console/commandline.cpp Wed Dec 09 17:01:52 2009 +0000 +++ b/engine/core/gui/console/commandline.cpp Mon Jan 11 23:34:52 2010 +0000 @@ -38,8 +38,7 @@ using namespace gcn; - CommandLine::CommandLine() : gcn::UTF8TextField() { - m_history_position = 0; + CommandLine::CommandLine() : gcn::UTF8TextField(), m_history_position(0) { m_blinkTimer.setInterval(500); m_blinkTimer.setCallback(boost::bind(&CommandLine::toggleCaretVisible,this)); @@ -70,27 +69,28 @@ void CommandLine::keyPressed(gcn::KeyEvent &keyEvent) { gcn::Key key = keyEvent.getKey(); - - if (key.getValue() == Key::LEFT && mCaretPosition > 0) + int keyType = key.getValue(); + + if (keyType == Key::LEFT && mCaretPosition > 0) { UTF8TextField::keyPressed(keyEvent); } - else if (key.getValue() == Key::RIGHT && mCaretPosition < mText.size()) + else if (keyType == Key::RIGHT && mCaretPosition < mText.size()) { UTF8TextField::keyPressed(keyEvent); } - else if (key.getValue() == Key::DOWN && !m_history.empty()) + else if (keyType == Key::DOWN && !m_history.empty()) { if( m_history_position < m_history.size() ) { - ++m_history_position; - if( m_history_position == m_history.size() ) { + + if( ++m_history_position == m_history.size() ) { setText( m_cmdline ); } else { setText( m_history[m_history_position] ); } }; } - else if (key.getValue() == Key::UP && !m_history.empty()) + else if (keyType == Key::UP && !m_history.empty()) { if( m_history_position > 0 ) { if( m_history_position == m_history.size() ) { @@ -100,15 +100,15 @@ setText( m_history[m_history_position] ); }; } - else if (key.getValue() == Key::DELETE && mCaretPosition < mText.size()) + else if (keyType == Key::DELETE && mCaretPosition < mText.size()) { UTF8TextField::keyPressed(keyEvent); } - else if (key.getValue() == Key::BACKSPACE && mCaretPosition > 0) + else if (keyType == Key::BACKSPACE && mCaretPosition > 0) { UTF8TextField::keyPressed(keyEvent); } - else if (key.getValue() == Key::ENTER) + else if (keyType == Key::ENTER) { if( mText != "" ) { if(m_callback) { @@ -119,11 +119,11 @@ setText(""); } } - else if (key.getValue() == Key::HOME) + else if (keyType == Key::HOME) { mCaretPosition = 0; } - else if (key.getValue() == Key::END) + else if (keyType == Key::END) { mCaretPosition = mText.size(); }