Skip to content

Commit

Permalink
Qt/RPCConsole: Save current command entry when browsing history
Browse files Browse the repository at this point in the history
Shell-like, but doesn't store changed history commands until executing it.
  • Loading branch information
jonasschnelli authored and luke-jr committed Dec 29, 2016
1 parent dce853e commit fc95daa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions src/qt/rpcconsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public Q_SLOTS:
ClientModel *clientModel;
QStringList history;
int historyPtr;
QString cmdBeforeBrowsing;
QList<NodeId> cachedNodeids;
const PlatformStyle *platformStyle;
RPCTimerInterface *rpcTimerInterface;
Expand Down

0 comments on commit fc95daa

Please sign in to comment.