all repos — fluxbox @ e85dc01d287fa0a070b59a494419dd416d1c54f1

custom fork of the fluxbox windowmanager

add autocompletion support to fbrun
Thomas Lübking thomas.luebking@gmail.com
commit

e85dc01d287fa0a070b59a494419dd416d1c54f1

parent

d741b6fe6e805b570bb899e777ea7101f6395721

4 files changed, 20 insertions(+), 1 deletions(-)

jump to
M doc/asciidoc/fbrun.txtdoc/asciidoc/fbrun.txt

@@ -69,6 +69,9 @@

*-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
M util/fbrun/FbRun.ccutil/fbrun/FbRun.cc

@@ -244,7 +244,16 @@ // a modifier key by itself doesn't do anything

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:
M util/fbrun/FbRun.hhutil/fbrun/FbRun.hh

@@ -42,6 +42,7 @@ ~FbRun();

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 @@ std::vector<std::string> m_apps;

int m_current_apps_item; ///< holds current position in apps-history size_t m_completion_pos; + bool m_autocomplete; Cursor m_cursor;
M util/fbrun/main.ccutil/fbrun/main.cc

@@ -65,6 +65,7 @@ " -fg [color name] Foreground text color"<<endl<<

" -bg [color name] Background color"<<endl<< " -na Disable antialias"<<endl<< " -hf [history file] History file to load (default ~/.fluxbox/fbrun_history)"<<endl<< + " -autocomplete Complete on typing"<<endl<< " -preselect Select preset text"<<endl<< " -help Show this help"<<endl<<endl<< "Example: fbrun -fg black -bg white -text xterm -title \"run xterm\""<<endl;

@@ -78,6 +79,7 @@ bool set_pos = false; // set position

bool near_mouse = false; // popup near mouse bool print = false; bool preselect = false; + bool autocomplete = getenv("FBRUN_AUTOCOMPLETE"); string fontname; // font name string title("Run program"); // default title string text; // default input text

@@ -119,6 +121,8 @@ } else if (strcmp(argv[i], "-hf") == 0 && i+1 < argc) {

history_file = argv[++i]; } else if (strcmp(argv[i], "-preselect") == 0) { preselect = true; + } else if (strcmp(argv[i], "-autocomplete") == 0) { + autocomplete = true; } else if (arg == "-h" || arg == "-help" || arg == "--help") { showUsage(argv[0]); exit(0);

@@ -136,6 +140,7 @@ FbTk::App application(display_name.c_str());

FbRun fbrun; fbrun.setPrint(print); + fbrun.setAutocomplete(autocomplete); if (fontname.size() != 0) { if (!fbrun.loadFont(fontname.c_str())) {