@@ -691,6 +691,23 @@ void RPCConsole::WriteCommandHistory()
691691 settings.endArray ();
692692}
693693
694+ void RPCConsole::ClearCommandHistory ()
695+ {
696+ // Overwrite existing history entries with dummy data before clearing
697+ for (int i = 0 ; i < history.size (); ++i) {
698+ history[i] = QString (history[i].size (), ' x' );
699+ }
700+ WriteCommandHistory ();
701+
702+ // Clear the history list
703+ history.clear ();
704+ historyPtr = 0 ;
705+ cmdBeforeBrowsing.clear ();
706+
707+ // Write empty history to settings
708+ WriteCommandHistory ();
709+ }
710+
694711RPCConsole::~RPCConsole ()
695712{
696713 QSettings settings;
@@ -1182,6 +1199,26 @@ void RPCConsole::on_lineEdit_returnPressed()
11821199 return ;
11831200 }
11841201
1202+ // Special command to clear command history
1203+ if (cmd == QLatin1String (" /clearhistory" )) {
1204+ QMessageBox::StandardButton reply = QMessageBox::question (this ,
1205+ tr (" Clear Command History" ),
1206+ tr (" This will permanently clear your command history and console output.<br><br>"
1207+ " While this action is irreversible, complete removal from memory and disk "
1208+ " cannot be guaranteed due to system limitations.<br><br>"
1209+ " Are you sure you want to proceed?" ),
1210+ QMessageBox::Yes | QMessageBox::No,
1211+ QMessageBox::No);
1212+
1213+ if (reply == QMessageBox::Yes) {
1214+ ClearCommandHistory ();
1215+ clear (false ); // Clear console output too
1216+ message (CMD_REPLY, tr (" Command history and console output cleared." ));
1217+ }
1218+ ui->lineEdit ->clear ();
1219+ return ;
1220+ }
1221+
11851222 if (m_is_executing) {
11861223 return ;
11871224 }
0 commit comments