Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
47b2dbf0
Commit
47b2dbf0
authored
Jan 26, 2011
by
lm
Browse files
Added command history
parent
af9f2479
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/ui/DebugConsole.cc
View file @
47b2dbf0
...
...
@@ -58,6 +58,7 @@ DebugConsole::DebugConsole(QWidget *parent) :
lowpassDataRate
(
0.0
f
),
dataRateThreshold
(
500
),
autoHold
(
true
),
commandIndex
(
0
),
m_ui
(
new
Ui
::
DebugConsole
)
{
// Setup basic user interface
...
...
@@ -471,6 +472,12 @@ void DebugConsole::appendSpecialSymbol()
void
DebugConsole
::
sendBytes
()
{
// Store command history
commandHistory
.
append
(
m_ui
->
sendText
->
text
());
// Since text was just sent, we're at position commandHistory.length()
// which is the current text
commandIndex
=
commandHistory
.
length
();
if
(
!
m_ui
->
sentText
->
isVisible
())
{
m_ui
->
sentText
->
setVisible
(
true
);
...
...
@@ -678,18 +685,12 @@ void DebugConsole::keyPressEvent(QKeyEvent * event)
{
if
(
event
->
key
()
==
Qt
::
Key_Up
)
{
qDebug
()
<<
"UP KEY PRESSED"
;
cycleCommandHistory
(
true
);
}
else
if
(
event
->
key
()
==
Qt
::
Key_Down
)
{
qDebug
()
<<
"DOWN KEY PRESSED"
;
cycleCommandHistory
(
false
);
}
else
if
(
event
->
key
()
==
Qt
::
Key_Enter
)
{
this
->
sendBytes
();
}
else
{
QWidget
::
keyPressEvent
(
event
);
...
...
@@ -698,40 +699,54 @@ void DebugConsole::keyPressEvent(QKeyEvent * event)
void
DebugConsole
::
cycleCommandHistory
(
bool
up
)
{
//
Store current command if we're not in
history
yet
if
(
commandIndex
==
commandHistory
.
length
())
//
Only cycle if there is a
history
if
(
commandHistory
.
length
()
>
0
)
{
currCommand
=
m_ui
->
sendText
->
text
();
}
// Store current command if we're not in history yet
if
(
commandIndex
==
commandHistory
.
length
()
&&
up
)
{
currCommand
=
m_ui
->
sendText
->
text
();
}
if
(
up
)
{
// UP
commandIndex
--
;
if
(
commandIndex
>=
0
)
if
(
up
)
{
m_ui
->
sendText
->
setText
(
commandHistory
.
at
(
commandIndex
));
// UP
commandIndex
--
;
if
(
commandIndex
>=
0
)
{
m_ui
->
sendText
->
setText
(
commandHistory
.
at
(
commandIndex
));
}
// If the index
}
else
{
// DOWN
commandIndex
++
;
if
(
commandIndex
<
commandHistory
.
length
())
{
m_ui
->
sendText
->
setText
(
commandHistory
.
at
(
commandIndex
));
}
// If the index is at history length, load the last current command
// If the index
}
else
{
// DOWN
commandIndex
++
;
if
(
commandIndex
<
commandHistory
.
length
())
}
// Restore current command if we went out of history
if
(
commandIndex
==
commandHistory
.
length
())
{
m_ui
->
sendText
->
setText
(
command
History
.
at
(
commandIndex
)
);
m_ui
->
sendText
->
setText
(
c
urrC
ommand
);
}
// If the index is at history length, load the last current command
}
// If we are too far down or too far up, wrap around to current command
if
(
commandIndex
<
0
||
commandIndex
>
commandHistory
.
length
())
{
commandIndex
=
commandHistory
.
length
();
m_ui
->
sendText
->
setText
(
currCommand
);
}
// If we are too far down or too far up, wrap around to current command
if
(
commandIndex
<
0
||
commandIndex
>
commandHistory
.
length
())
{
commandIndex
=
commandHistory
.
length
();
m_ui
->
sendText
->
setText
(
currCommand
);
// Bound the index
if
(
commandIndex
<
0
)
commandIndex
=
0
;
if
(
commandIndex
>
commandHistory
.
length
())
commandIndex
=
commandHistory
.
length
();
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment