changeset 13346:381b7413c652

Prevented the command line to lose focus when pressing tab.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Wed, 06 Apr 2011 19:52:12 +0200
parents 01eb3fd5faf5
children fd14634f9c1e
files gui//octaveterminal.h gui//terminalhighlighter.cpp
diffstat 2 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/gui//octaveterminal.h
+++ b/gui//octaveterminal.h
@@ -27,6 +27,7 @@
 #include <QMenu>
 #include <QToolBar>
 #include <QKeyEvent>
+#include <QFocusEvent>
 #include <QQueue>
 
 #include "client.h"
@@ -49,6 +50,10 @@
     void claimCommand(QString command);
 
 protected:
+    void focusOutEvent(QFocusEvent *focusEvent) {
+        setFocus();
+    }
+
     void keyPressEvent(QKeyEvent *keyEvent) {
         QString command;
         switch(keyEvent->key()) {
@@ -61,6 +66,10 @@
                 setText("");
                 break;
 
+            case Qt::Key_Tab:
+                emit claimCommand("\t");
+                break;
+
             case Qt::Key_Up:
                 if(!m_commandHistory.empty())
                 {
--- a/gui//terminalhighlighter.cpp
+++ b/gui//terminalhighlighter.cpp
@@ -28,7 +28,7 @@
     QStringList keywordPatterns;
     keywordPatterns << "\\bOctave\\b" << "\\bGNU\\b";
 
-    foreach (const QString &pattern, keywordPatterns) {
+    foreach(const QString &pattern, keywordPatterns) {
         rule.pattern = QRegExp(pattern);
         rule.format = keywordFormat;
         highlightingRules.append(rule);
@@ -64,10 +64,10 @@
 
 void TerminalHighlighter::highlightBlock(const QString &text)
 {
-    foreach (const HighlightingRule &rule, highlightingRules) {
+    foreach(const HighlightingRule &rule, highlightingRules) {
         QRegExp expression(rule.pattern);
         int index = expression.indexIn(text);
-        while (index >= 0) {
+        while(index >= 0) {
             int length = expression.matchedLength();
             setFormat(index, length, rule.format);
             index = expression.indexIn(text, index + length);