A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol
C arduinobluetoothcan-busdebuggingeepromesp32flipperzerogpiohardware-hackingi2cjtagopenocdprotocolspwmradiorfidspisubghzuartwifi
add tab autocomplete based on history and command words
Geo1524511b3e8f
diff --git a/src/Dispatchers/ActionDispatcher.cpp b/src/Dispatchers/ActionDispatcher.cppindex ec7bf714..2990acb6 100644--- a/src/Dispatchers/ActionDispatcher.cpp+++ b/src/Dispatchers/ActionDispatcher.cpp@@ -1,4 +1,5 @@#include "ActionDispatcher.h"+#include "Data/AutoCompleteWords.h"/*Constructor@@ -236,6 +237,7 @@ std::string ActionDispatcher::getUserAction() {if (handleEnterKey(c, inputLine)) return inputLine;if (handleBackspace(c, inputLine, cursorIndex, mode)) continue;if (handlePrintableChar(c, inputLine, cursorIndex, mode));+ if (handleTabCompletion(c, inputLine, cursorIndex, mode));}}@@ -321,6 +323,42 @@ bool ActionDispatcher::handleEnterKey(char c, const std::string& inputLine) {return true;}+bool ActionDispatcher::handleTabCompletion(char c,+ std::string& inputLine,+ size_t& cursorIndex,+ const std::string& mode) {+ if (c != '\t') return false;++ // prefix up to cursor+ std::string prefix = inputLine.substr(0, cursorIndex);++ // history autocomplete+ std::string suggestion =+ provider.getCommandHistoryManager().autocomplete(prefix);++ // fallback dictionary autocomplete+ if (suggestion.empty()) {+ for (size_t i = 0; autoCompleteWords[i] != nullptr; ++i) {+ std::string w(autoCompleteWords[i]);++ if (w.size() >= prefix.size() &&+ w.compare(0, prefix.size(), prefix) == 0) {+ suggestion = w;+ break;+ }+ }+ }++ // apply suggestion+ if (!suggestion.empty()) {+ inputLine = suggestion;+ cursorIndex = inputLine.length();+ provider.getTerminalView().print("\r" + mode + "> " + inputLine + "\033[K");+ }++ return true;+}+/*User Action: Backspace*/diff --git a/src/Dispatchers/ActionDispatcher.h b/src/Dispatchers/ActionDispatcher.hindex 70604d6a..867d59e7 100644--- a/src/Dispatchers/ActionDispatcher.h+++ b/src/Dispatchers/ActionDispatcher.h@@ -41,6 +41,9 @@ private:// Handle ANSI escape sequences (arrows, etc.)bool handleEscapeSequence(char c, std::string& inputLine, size_t& cursorIndex, const std::string& mode);+ // Handle Tab key for autocompletion+ bool handleTabCompletion(char c, std::string& inputLine, size_t& cursorIndex, const std::string& mode);+// Handle Cardputer arrowsbool handleCardputerEscapeSequence(char c, size_t& cursorIndex, std::string& inputLine, const std::string& mode);