Browse Source

Qt/RPCConsole: Save current command entry when browsing history

Shell-like, but doesn't store changed history commands until executing it.
pull/1/head
Jonas Schnelli 8 years ago committed by Luke Dashjr
parent
commit
fc95daa97f
  1. 10
      src/qt/rpcconsole.cpp
  2. 1
      src/qt/rpcconsole.h

10
src/qt/rpcconsole.cpp

@ -751,6 +751,8 @@ void RPCConsole::on_lineEdit_returnPressed() @@ -751,6 +751,8 @@ void RPCConsole::on_lineEdit_returnPressed()
if(!cmd.isEmpty())
{
cmdBeforeBrowsing = QString();
message(CMD_REQUEST, cmd);
Q_EMIT cmdRequest(cmd);
// Remove command, if already in history
@ -769,6 +771,11 @@ void RPCConsole::on_lineEdit_returnPressed() @@ -769,6 +771,11 @@ void RPCConsole::on_lineEdit_returnPressed()
void RPCConsole::browseHistory(int offset)
{
// store current text when start browsing through the history
if (historyPtr == history.size()) {
cmdBeforeBrowsing = ui->lineEdit->text();
}
historyPtr += offset;
if(historyPtr < 0)
historyPtr = 0;
@ -777,6 +784,9 @@ void RPCConsole::browseHistory(int offset) @@ -777,6 +784,9 @@ void RPCConsole::browseHistory(int offset)
QString cmd;
if(historyPtr < history.size())
cmd = history.at(historyPtr);
else if (!cmdBeforeBrowsing.isNull()) {
cmd = cmdBeforeBrowsing;
}
ui->lineEdit->setText(cmd);
}

1
src/qt/rpcconsole.h

@ -140,6 +140,7 @@ private: @@ -140,6 +140,7 @@ private:
ClientModel *clientModel;
QStringList history;
int historyPtr;
QString cmdBeforeBrowsing;
QList<NodeId> cachedNodeids;
const PlatformStyle *platformStyle;
RPCTimerInterface *rpcTimerInterface;

Loading…
Cancel
Save