aboutsummaryrefslogtreecommitdiff
path: root/util/fbrun
diff options
context:
space:
mode:
authormathias <mathias>2006-04-25 06:46:06 (GMT)
committermathias <mathias>2006-04-25 06:46:06 (GMT)
commita15d9af3c7f58d671240b23607bb9488a9165eb1 (patch)
tree6789cd07d3d7f1c1355d1497a0c37b6b879e5d63 /util/fbrun
parente2bc57bc0fef16faba89f996e354445c31aebedd (diff)
downloadfluxbox-a15d9af3c7f58d671240b23607bb9488a9165eb1.zip
fluxbox-a15d9af3c7f58d671240b23607bb9488a9165eb1.tar.bz2
Cleanup unneeded headers (thanks Slava Semushin)
Diffstat (limited to 'util/fbrun')
-rw-r--r--util/fbrun/FbRun.cc62
1 files changed, 30 insertions, 32 deletions
diff --git a/util/fbrun/FbRun.cc b/util/fbrun/FbRun.cc
index 7392083..c175e67 100644
--- a/util/fbrun/FbRun.cc
+++ b/util/fbrun/FbRun.cc
@@ -48,13 +48,9 @@
48#include <iterator> 48#include <iterator>
49#include <fstream> 49#include <fstream>
50#include <algorithm> 50#include <algorithm>
51#ifdef HAVE_CASSERT
52 #include <cassert>
53#else
54 #include <assert.h>
55#endif
56 51
57using namespace std; 52using namespace std;
53
58FbRun::FbRun(int x, int y, size_t width): 54FbRun::FbRun(int x, int y, size_t width):
59 FbTk::TextBox(DefaultScreen(FbTk::App::instance()->display()), 55 FbTk::TextBox(DefaultScreen(FbTk::App::instance()->display()),
60 m_font, ""), 56 m_font, ""),
@@ -67,7 +63,7 @@ FbRun::FbRun(int x, int y, size_t width):
67 m_last_completion_prefix(""), 63 m_last_completion_prefix(""),
68 m_current_apps_item(0), 64 m_current_apps_item(0),
69 m_cursor(XCreateFontCursor(FbTk::App::instance()->display(), XC_xterm)) { 65 m_cursor(XCreateFontCursor(FbTk::App::instance()->display(), XC_xterm)) {
70 66
71 setGC(m_gc.gc()); 67 setGC(m_gc.gc());
72 setCursor(m_cursor); 68 setCursor(m_cursor);
73 // setting nomaximize in local resize 69 // setting nomaximize in local resize
@@ -78,9 +74,9 @@ FbRun::FbRun(int x, int y, size_t width):
78 if (class_hint == 0) 74 if (class_hint == 0)
79 throw string("Out of memory"); 75 throw string("Out of memory");
80 class_hint->res_name = "fbrun"; 76 class_hint->res_name = "fbrun";
81 class_hint->res_class = "FbRun"; 77 class_hint->res_class = "FbRun";
82 XSetClassHint(m_display, window(), class_hint); 78 XSetClassHint(m_display, window(), class_hint);
83 79
84 XFree(class_hint); 80 XFree(class_hint);
85#ifdef HAVE_XPM 81#ifdef HAVE_XPM
86 Pixmap mask = 0; 82 Pixmap mask = 0;
@@ -123,7 +119,7 @@ void FbRun::run(const std::string &command) {
123 } 119 }
124 120
125 hide(); // hide gui 121 hide(); // hide gui
126 122
127 // save command history to file 123 // save command history to file
128 if (text().size() != 0) { // no need to save empty command 124 if (text().size() != 0) { // no need to save empty command
129 125
@@ -134,7 +130,7 @@ void FbRun::run(const std::string &command) {
134 // m_current_history_item is the duplicate 130 // m_current_history_item is the duplicate
135 } else { 131 } else {
136 m_current_history_item = 0; 132 m_current_history_item = 0;
137 for (; m_current_history_item < m_history.size(); 133 for (; m_current_history_item < m_history.size();
138 ++m_current_history_item) { 134 ++m_current_history_item) {
139 if (m_history[m_current_history_item] == text()) 135 if (m_history[m_current_history_item] == text())
140 break; 136 break;
@@ -154,7 +150,7 @@ void FbRun::run(const std::string &command) {
154 // write the history items that come after current 150 // write the history items that come after current
155 for (i++; i < m_history.size(); i++) 151 for (i++; i < m_history.size(); i++)
156 inoutfile<<m_history[i]<<endl; 152 inoutfile<<m_history[i]<<endl;
157 153
158 } else { 154 } else {
159 // set put-pointer at end of file 155 // set put-pointer at end of file
160 inoutfile.seekp(0, ios::end); 156 inoutfile.seekp(0, ios::end);
@@ -215,7 +211,7 @@ void FbRun::setTitle(const string &title) {
215} 211}
216 212
217void FbRun::resize(unsigned int width, unsigned int height) { 213void FbRun::resize(unsigned int width, unsigned int height) {
218 FbTk::TextBox::resize(width, height); 214 FbTk::TextBox::resize(width, height);
219} 215}
220 216
221void FbRun::redrawLabel() { 217void FbRun::redrawLabel() {
@@ -233,7 +229,7 @@ void FbRun::keyPressEvent(XKeyEvent &ke) {
233 char keychar[1]; 229 char keychar[1];
234 XLookupString(&ke, keychar, 1, &ks, 0); 230 XLookupString(&ke, keychar, 1, &ks, 0);
235 // a modifier key by itself doesn't do anything 231 // a modifier key by itself doesn't do anything
236 if (IsModifierKey(ks)) 232 if (IsModifierKey(ks))
237 return; 233 return;
238 234
239 if (FbTk::KeyUtil::instance().isolateModifierMask(ke.state)) { // a modifier key is down 235 if (FbTk::KeyUtil::instance().isolateModifierMask(ke.state)) { // a modifier key is down
@@ -374,7 +370,7 @@ void FbRun::tabCompleteHistory() {
374} 370}
375 371
376void FbRun::tabCompleteApps() { 372void FbRun::tabCompleteApps() {
377 373
378 static bool first_run= true; 374 static bool first_run= true;
379 if (m_last_completion_prefix.empty()) 375 if (m_last_completion_prefix.empty())
380 m_last_completion_prefix = text().substr(0, textStartPos() + cursorPosition()); 376 m_last_completion_prefix = text().substr(0, textStartPos() + cursorPosition());
@@ -387,19 +383,21 @@ void FbRun::tabCompleteApps() {
387 // (re)build m_apps-container 383 // (re)build m_apps-container
388 if (first_run || m_last_completion_prefix != prefix) { 384 if (first_run || m_last_completion_prefix != prefix) {
389 first_run= false; 385 first_run= false;
390 386
391 string path; 387 string path;
392 388
393 if(!prefix.empty() && 389 if(!prefix.empty() &&
394 string("/.~").find_first_of(prefix[0]) != string::npos) { 390 string("/.~").find_first_of(prefix[0]) != string::npos) {
395 size_t rseparator= prefix.find_last_of("/"); 391 size_t rseparator= prefix.find_last_of("/");
396 path= prefix.substr(0, rseparator + 1) + ":"; 392 path= prefix.substr(0, rseparator + 1) + ":";
397 add_dirs= true; 393 add_dirs= true;
398 } else 394 } else {
399 path= getenv("PATH"); 395 char* tmp_path = getenv("PATH");
400 396 if (tmp_path)
397 path = tmp_path;
398 }
401 m_apps.clear(); 399 m_apps.clear();
402 400
403 unsigned int l; 401 unsigned int l;
404 unsigned int r; 402 unsigned int r;
405 403
@@ -412,27 +410,27 @@ void FbRun::tabCompleteApps() {
412 if (n >= 0) { 410 if (n >= 0) {
413 while(n--) { 411 while(n--) {
414 filename= dir.readFilename(); 412 filename= dir.readFilename();
415 fncomplete= dir.name() + 413 fncomplete= dir.name() +
416 (*dir.name().rbegin() != '/' ? "/" : "") + 414 (*dir.name().rbegin() != '/' ? "/" : "") +
417 filename; 415 filename;
418 416
419 // directories in dirmode ? 417 // directories in dirmode ?
420 if (add_dirs && FbTk::FileUtil::isDirectory(fncomplete.c_str()) && 418 if (add_dirs && FbTk::FileUtil::isDirectory(fncomplete.c_str()) &&
421 filename != ".." && filename != ".") { 419 filename != ".." && filename != ".") {
422 m_apps.push_back(fncomplete); 420 m_apps.push_back(fncomplete);
423 // executables in dirmode ? 421 // executables in dirmode ?
424 } else if (add_dirs && FbTk::FileUtil::isRegularFile(fncomplete.c_str()) && 422 } else if (add_dirs && FbTk::FileUtil::isRegularFile(fncomplete.c_str()) &&
425 FbTk::FileUtil::isExecutable(fncomplete.c_str()) && 423 FbTk::FileUtil::isExecutable(fncomplete.c_str()) &&
426 (prefix == "" || 424 (prefix == "" ||
427 fncomplete.substr(0, prefix.size()) == prefix)) { 425 fncomplete.substr(0, prefix.size()) == prefix)) {
428 m_apps.push_back(fncomplete); 426 m_apps.push_back(fncomplete);
429 // executables in $PATH ? 427 // executables in $PATH ?
430 } else if (FbTk::FileUtil::isRegularFile(fncomplete.c_str()) && 428 } else if (FbTk::FileUtil::isRegularFile(fncomplete.c_str()) &&
431 FbTk::FileUtil::isExecutable(fncomplete.c_str()) && 429 FbTk::FileUtil::isExecutable(fncomplete.c_str()) &&
432 (prefix == "" || 430 (prefix == "" ||
433 filename.substr(0, prefix.size()) == prefix)) { 431 filename.substr(0, prefix.size()) == prefix)) {
434 m_apps.push_back(filename); 432 m_apps.push_back(filename);
435 } 433 }
436 } 434 }
437 } 435 }
438 l= r + 1; 436 l= r + 1;
@@ -473,7 +471,7 @@ void FbRun::tabCompleteApps() {
473 } 471 }
474 apps_item++; 472 apps_item++;
475 } 473 }
476 if (!changed_prefix && apps_item == m_current_apps_item) 474 if (!changed_prefix && apps_item == m_current_apps_item)
477 XBell(m_display, 0); 475 XBell(m_display, 0);
478 } 476 }
479} 477}