aboutsummaryrefslogtreecommitdiff
path: root/util/fbrun
diff options
context:
space:
mode:
authorThomas Lübking <thomas.luebking@gmail.com>2016-07-23 06:18:26 (GMT)
committerThomas Lübking <thomas.luebking@gmail.com>2016-07-23 14:58:04 (GMT)
commite85dc01d287fa0a070b59a494419dd416d1c54f1 (patch)
tree58981ff5ab773a031f5683755789818a4cb95b14 /util/fbrun
parentd741b6fe6e805b570bb899e777ea7101f6395721 (diff)
downloadfluxbox-e85dc01d287fa0a070b59a494419dd416d1c54f1.zip
fluxbox-e85dc01d287fa0a070b59a494419dd416d1c54f1.tar.bz2
add autocompletion support to fbrun
Diffstat (limited to 'util/fbrun')
-rw-r--r--util/fbrun/FbRun.cc11
-rw-r--r--util/fbrun/FbRun.hh2
-rw-r--r--util/fbrun/main.cc5
3 files changed, 17 insertions, 1 deletions
diff --git a/util/fbrun/FbRun.cc b/util/fbrun/FbRun.cc
index 7fde936..fdc8b38 100644
--- a/util/fbrun/FbRun.cc
+++ b/util/fbrun/FbRun.cc
@@ -244,7 +244,16 @@ void FbRun::keyPressEvent(XKeyEvent &ke) {
244 if (IsModifierKey(ks)) 244 if (IsModifierKey(ks))
245 return; 245 return;
246 246
247 if (FbTk::KeyUtil::instance().isolateModifierMask(ke.state)) { // a modifier key is down 247 if (m_autocomplete && isprint(keychar[0])) {
248 did_tab_complete = true;
249 if (m_completion_pos == std::string::npos) {
250 m_completion_pos = cursorPosition();
251 } else {
252 ++m_completion_pos;
253 }
254 tabCompleteApps();
255 } else if (FbTk::KeyUtil::instance().isolateModifierMask(ke.state)) {
256 // a modifier key is down
248 if ((ke.state & ControlMask) == ControlMask) { 257 if ((ke.state & ControlMask) == ControlMask) {
249 switch (ks) { 258 switch (ks) {
250 case XK_p: 259 case XK_p:
diff --git a/util/fbrun/FbRun.hh b/util/fbrun/FbRun.hh
index a74d347..f0915b0 100644
--- a/util/fbrun/FbRun.hh
+++ b/util/fbrun/FbRun.hh
@@ -42,6 +42,7 @@ public:
42 void setTitle(const std::string &title); 42 void setTitle(const std::string &title);
43 void resize(unsigned int width, unsigned int height); 43 void resize(unsigned int width, unsigned int height);
44 void setPrint(bool print) { m_print = print; } 44 void setPrint(bool print) { m_print = print; }
45 void setAutocomplete(bool complete) { m_autocomplete = complete; }
45 46
46 /// load and reconfigure for new font 47 /// load and reconfigure for new font
47 bool loadFont(const std::string &fontname); 48 bool loadFont(const std::string &fontname);
@@ -102,6 +103,7 @@ private:
102 int m_current_apps_item; ///< holds current position in apps-history 103 int m_current_apps_item; ///< holds current position in apps-history
103 104
104 size_t m_completion_pos; 105 size_t m_completion_pos;
106 bool m_autocomplete;
105 107
106 Cursor m_cursor; 108 Cursor m_cursor;
107 109
diff --git a/util/fbrun/main.cc b/util/fbrun/main.cc
index c47788a..0bc02c6 100644
--- a/util/fbrun/main.cc
+++ b/util/fbrun/main.cc
@@ -65,6 +65,7 @@ void showUsage(const char *progname) {
65 " -bg [color name] Background color"<<endl<< 65 " -bg [color name] Background color"<<endl<<
66 " -na Disable antialias"<<endl<< 66 " -na Disable antialias"<<endl<<
67 " -hf [history file] History file to load (default ~/.fluxbox/fbrun_history)"<<endl<< 67 " -hf [history file] History file to load (default ~/.fluxbox/fbrun_history)"<<endl<<
68 " -autocomplete Complete on typing"<<endl<<
68 " -preselect Select preset text"<<endl<< 69 " -preselect Select preset text"<<endl<<
69 " -help Show this help"<<endl<<endl<< 70 " -help Show this help"<<endl<<endl<<
70 "Example: fbrun -fg black -bg white -text xterm -title \"run xterm\""<<endl; 71 "Example: fbrun -fg black -bg white -text xterm -title \"run xterm\""<<endl;
@@ -78,6 +79,7 @@ int main(int argc, char **argv) {
78 bool near_mouse = false; // popup near mouse 79 bool near_mouse = false; // popup near mouse
79 bool print = false; 80 bool print = false;
80 bool preselect = false; 81 bool preselect = false;
82 bool autocomplete = getenv("FBRUN_AUTOCOMPLETE");
81 string fontname; // font name 83 string fontname; // font name
82 string title("Run program"); // default title 84 string title("Run program"); // default title
83 string text; // default input text 85 string text; // default input text
@@ -119,6 +121,8 @@ int main(int argc, char **argv) {
119 history_file = argv[++i]; 121 history_file = argv[++i];
120 } else if (strcmp(argv[i], "-preselect") == 0) { 122 } else if (strcmp(argv[i], "-preselect") == 0) {
121 preselect = true; 123 preselect = true;
124 } else if (strcmp(argv[i], "-autocomplete") == 0) {
125 autocomplete = true;
122 } else if (arg == "-h" || arg == "-help" || arg == "--help") { 126 } else if (arg == "-h" || arg == "-help" || arg == "--help") {
123 showUsage(argv[0]); 127 showUsage(argv[0]);
124 exit(0); 128 exit(0);
@@ -136,6 +140,7 @@ int main(int argc, char **argv) {
136 FbRun fbrun; 140 FbRun fbrun;
137 141
138 fbrun.setPrint(print); 142 fbrun.setPrint(print);
143 fbrun.setAutocomplete(autocomplete);
139 144
140 if (fontname.size() != 0) { 145 if (fontname.size() != 0) {
141 if (!fbrun.loadFont(fontname.c_str())) { 146 if (!fbrun.loadFont(fontname.c_str())) {