Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
47b2dbf0
Commit
47b2dbf0
authored
Jan 26, 2011
by
lm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added command history
parent
af9f2479
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
31 deletions
+46
-31
DebugConsole.cc
src/ui/DebugConsole.cc
+46
-31
No files found.
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
(
command
Index
==
commandHistory
.
length
()
)
//
Only cycle if there is a history
if
(
command
History
.
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
(
c
ommandHistory
.
at
(
commandIndex
)
);
m_ui
->
sendText
->
setText
(
c
urrCommand
);
}
// 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
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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