diff --git a/doc/asciidoc/fbrun.txt b/doc/asciidoc/fbrun.txt index 59f24001..ee09d6da 100644 --- a/doc/asciidoc/fbrun.txt +++ b/doc/asciidoc/fbrun.txt @@ -69,6 +69,9 @@ OPTIONS *-preselect*:: Select the preset text given by the *-text* parameter +*-autocomplete*:: + Complete on typing. You can also set the FBRUN_AUTOCOMPLETE environment (to any value) + *-help*:: Show this help diff --git a/util/fbrun/FbRun.cc b/util/fbrun/FbRun.cc index 7fde9365..fdc8b388 100644 --- a/util/fbrun/FbRun.cc +++ b/util/fbrun/FbRun.cc @@ -244,7 +244,16 @@ void FbRun::keyPressEvent(XKeyEvent &ke) { if (IsModifierKey(ks)) return; - if (FbTk::KeyUtil::instance().isolateModifierMask(ke.state)) { // a modifier key is down + if (m_autocomplete && isprint(keychar[0])) { + did_tab_complete = true; + if (m_completion_pos == std::string::npos) { + m_completion_pos = cursorPosition(); + } else { + ++m_completion_pos; + } + tabCompleteApps(); + } else if (FbTk::KeyUtil::instance().isolateModifierMask(ke.state)) { + // a modifier key is down if ((ke.state & ControlMask) == ControlMask) { switch (ks) { case XK_p: diff --git a/util/fbrun/FbRun.hh b/util/fbrun/FbRun.hh index a74d347f..f0915b05 100644 --- a/util/fbrun/FbRun.hh +++ b/util/fbrun/FbRun.hh @@ -42,6 +42,7 @@ public: void setTitle(const std::string &title); void resize(unsigned int width, unsigned int height); void setPrint(bool print) { m_print = print; } + void setAutocomplete(bool complete) { m_autocomplete = complete; } /// load and reconfigure for new font bool loadFont(const std::string &fontname); @@ -102,6 +103,7 @@ private: int m_current_apps_item; ///< holds current position in apps-history size_t m_completion_pos; + bool m_autocomplete; Cursor m_cursor; diff --git a/util/fbrun/main.cc b/util/fbrun/main.cc index c47788a4..0bc02c67 100644 --- a/util/fbrun/main.cc +++ b/util/fbrun/main.cc @@ -65,6 +65,7 @@ void showUsage(const char *progname) { " -bg [color name] Background color"<