@@ -93,6 +93,8 @@ public Q_SLOTS:
93
93
94
94
Q_SIGNALS:
95
95
void reply (int category, const QString &command);
96
+ void clear (bool clear_history);
97
+ void printHistory ();
96
98
97
99
private:
98
100
interfaces::Node& m_node;
@@ -402,7 +404,21 @@ void RPCExecutor::request(const QString &command, const QString& wallet_name)
402
404
" example: getblock(getblockhash(0) 1)[tx]\n\n "
403
405
404
406
" Results without keys can be queried with an integer in brackets using the parenthesized syntax.\n "
405
- " example: getblock(getblockhash(0),1)[tx][0]\n\n " )));
407
+ " example: getblock(getblockhash(0),1)[tx][0]\n\n "
408
+ " Console commands:\n "
409
+ " clear Clears the screen.\n "
410
+ " history-clear Clears the command history and the screen.\n "
411
+ " history Prints all command history.\n\n "
412
+ )));
413
+ return ;
414
+ } else if (executableCommand == " clear\n " ) {
415
+ Q_EMIT clear (false );
416
+ return ;
417
+ } else if (executableCommand == " history-clear\n " ) {
418
+ Q_EMIT clear (true );
419
+ return ;
420
+ } else if (executableCommand == " history\n " ) {
421
+ Q_EMIT printHistory ();
406
422
return ;
407
423
}
408
424
if (!RPCConsole::RPCExecuteCommandLine (m_node, result, executableCommand, nullptr , wallet_name)) {
@@ -506,6 +522,7 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty
506
522
ui->openDebugLogfileButton ->setIcon (platformStyle->SingleColorIcon (" :/icons/export" ));
507
523
}
508
524
ui->clearButton ->setIcon (platformStyle->SingleColorIcon (" :/icons/remove" ));
525
+ ui->resetButton ->setIcon (platformStyle->SingleColorIcon (" :/icons/transaction_abandoned" )); // Trash icon
509
526
510
527
ui->fontBiggerButton ->setIcon (platformStyle->SingleColorIcon (" :/icons/fontbigger" ));
511
528
// : Main shortcut to increase the RPC console font size.
@@ -528,6 +545,7 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty
528
545
529
546
connect (ui->hidePeersDetailButton , &QAbstractButton::clicked, this , &RPCConsole::clearSelectedNode);
530
547
connect (ui->clearButton , &QAbstractButton::clicked, [this ] { clear (); });
548
+ connect (ui->resetButton , &QAbstractButton::clicked, [this ] { clear (false , true ); });
531
549
connect (ui->fontBiggerButton , &QAbstractButton::clicked, this , &RPCConsole::fontBigger);
532
550
connect (ui->fontSmallerButton , &QAbstractButton::clicked, this , &RPCConsole::fontSmaller);
533
551
connect (ui->btnClearTrafficGraph , &QPushButton::clicked, ui->trafficGraph , &TrafficGraphWidget::clear);
@@ -728,6 +746,9 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
728
746
}
729
747
730
748
wordList << " help-console" ;
749
+ wordList << " clear" ;
750
+ wordList << " history-clear" ;
751
+ wordList << " history" ;
731
752
wordList.sort ();
732
753
autoCompleter = new QCompleter (wordList, this );
733
754
autoCompleter->setModelSorting (QCompleter::CaseSensitivelySortedModel);
@@ -823,8 +844,9 @@ void RPCConsole::setFontSize(int newSize)
823
844
ui->messagesWidget ->verticalScrollBar ()->setValue (oldPosFactor * ui->messagesWidget ->verticalScrollBar ()->maximum ());
824
845
}
825
846
826
- void RPCConsole::clear (bool keep_prompt)
847
+ void RPCConsole::clear (bool keep_prompt, bool clear_history )
827
848
{
849
+ if (clear_history) history.clear ();
828
850
ui->messagesWidget ->clear ();
829
851
if (!keep_prompt) ui->lineEdit ->clear ();
830
852
ui->lineEdit ->setFocus ();
@@ -863,6 +885,7 @@ void RPCConsole::clear(bool keep_prompt)
863
885
they are not space separated from the rest of the text intentionally. */
864
886
tr (" Welcome to the %1 RPC console.\n "
865
887
" Use up and down arrows to navigate history, and %2 to clear screen.\n "
888
+ " Use %9 to clear both the screen and the command history.\n "
866
889
" Use %3 and %4 to increase or decrease the font size.\n "
867
890
" Type %5 for an overview of available commands.\n "
868
891
" For more information on using this console, type %6.\n "
@@ -877,7 +900,9 @@ void RPCConsole::clear(bool keep_prompt)
877
900
" <b>help</b>" ,
878
901
" <b>help-console</b>" ,
879
902
" <span class=\" secwarning\" >" ,
880
- " <span>" );
903
+ " <span>" ,
904
+ " <b>" + ui->resetButton ->shortcut ().toString (QKeySequence::NativeText) + " </b>"
905
+ );
881
906
882
907
message (CMD_REPLY, welcome_message, true );
883
908
}
@@ -1090,6 +1115,22 @@ void RPCConsole::startExecutor()
1090
1115
scrollToEnd ();
1091
1116
m_is_executing = false ;
1092
1117
});
1118
+ connect (m_executor, &RPCExecutor::clear, this , [this ](bool clear_history) {
1119
+ clear (false , clear_history);
1120
+ scrollToEnd ();
1121
+ m_is_executing = false ;
1122
+ });
1123
+ connect (m_executor, &RPCExecutor::printHistory, this , [this ]() {
1124
+ QStringList out;
1125
+ int index = 0 ;
1126
+ for (const QString& entry : history) {
1127
+ out << QString::number (++index) + " : " + entry;
1128
+ }
1129
+ ui->messagesWidget ->undo ();
1130
+ message (CMD_REPLY, out.join (" \n " ));
1131
+ scrollToEnd ();
1132
+ m_is_executing = false ;
1133
+ });
1093
1134
1094
1135
// Make sure executor object is deleted in its own thread
1095
1136
connect (&thread, &QThread::finished, m_executor, &RPCExecutor::deleteLater);
0 commit comments