summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2008-10-04 21:01:31 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2008-10-04 21:01:31 (GMT)
commite6570b61f34e9d7822f500706a5a2cd6bc436234 (patch)
tree3f186315662e41fc8908d07a1720de0282113981
parent4b5c00b764417b91388d6e88b10f3cbd2764ff02 (diff)
downloadfluxbox_lack-e6570b61f34e9d7822f500706a5a2cd6bc436234.zip
fluxbox_lack-e6570b61f34e9d7822f500706a5a2cd6bc436234.tar.bz2
add -print option to fbrun to return result to stdout instead of executing it
-rw-r--r--ChangeLog3
-rw-r--r--util/fbrun/FbRun.cc7
-rw-r--r--util/fbrun/FbRun.hh2
-rw-r--r--util/fbrun/main.cc6
4 files changed, 17 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 72c45f3..d62889d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
1 (Format: Year/Month/Day) 1 (Format: Year/Month/Day)
2Changes for 1.1.2 2Changes for 1.1.2
3*08/10/04: 3*08/10/04:
4 * Add -print option to fbrun that sends the result to stdout instead of
5 running it (Mark)
6 util/FbRun/main.cc FbRun.cc/hh
4 * Fix CustomMenu and ClientMenu commands from fluxbox-remote (Mark) 7 * Fix CustomMenu and ClientMenu commands from fluxbox-remote (Mark)
5 Screen.cc 8 Screen.cc
6 * Break emacs-style keychains after one invalid key has been pressed (Mark) 9 * Break emacs-style keychains after one invalid key has been pressed (Mark)
diff --git a/util/fbrun/FbRun.cc b/util/fbrun/FbRun.cc
index c304413..f98a02e 100644
--- a/util/fbrun/FbRun.cc
+++ b/util/fbrun/FbRun.cc
@@ -58,6 +58,7 @@ using std::ios;
58FbRun::FbRun(int x, int y, size_t width): 58FbRun::FbRun(int x, int y, size_t width):
59 FbTk::TextBox(DefaultScreen(FbTk::App::instance()->display()), 59 FbTk::TextBox(DefaultScreen(FbTk::App::instance()->display()),
60 m_font, ""), 60 m_font, ""),
61 m_print(false),
61 m_font("fixed"), 62 m_font("fixed"),
62 m_display(FbTk::App::instance()->display()), 63 m_display(FbTk::App::instance()->display()),
63 m_bevel(4), 64 m_bevel(4),
@@ -115,6 +116,12 @@ void FbRun::run(const std::string &command) {
115 FbTk::App::instance()->end(); // end application 116 FbTk::App::instance()->end(); // end application
116 m_end = true; // mark end of processing 117 m_end = true; // mark end of processing
117 118
119 if (m_print) {
120 std::cout << command;
121 hide();
122 return;
123 }
124
118 // fork and execute program 125 // fork and execute program
119 if (!fork()) { 126 if (!fork()) {
120 127
diff --git a/util/fbrun/FbRun.hh b/util/fbrun/FbRun.hh
index 405ae3f..6ddbad0 100644
--- a/util/fbrun/FbRun.hh
+++ b/util/fbrun/FbRun.hh
@@ -42,6 +42,7 @@ public:
42 void handleEvent(XEvent * const ev); 42 void handleEvent(XEvent * const ev);
43 void setTitle(const std::string &title); 43 void setTitle(const std::string &title);
44 void resize(unsigned int width, unsigned int height); 44 void resize(unsigned int width, unsigned int height);
45 void setPrint(bool print) { m_print = print; }
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);
@@ -83,6 +84,7 @@ private:
83 void tabCompleteHistory(); 84 void tabCompleteHistory();
84 void tabCompleteApps(); 85 void tabCompleteApps();
85 86
87 bool m_print; ///< the input should be printed to stdout rather than run
86 FbTk::Font m_font; ///< font used to draw command text 88 FbTk::Font m_font; ///< font used to draw command text
87 Display *m_display; ///< display connection 89 Display *m_display; ///< display connection
88 int m_bevel; 90 int m_bevel;
diff --git a/util/fbrun/main.cc b/util/fbrun/main.cc
index 6adfbe7..f9875d3 100644
--- a/util/fbrun/main.cc
+++ b/util/fbrun/main.cc
@@ -55,6 +55,7 @@ void showUsage(const char *progname) {
55 " -font [font name] Text font"<<endl<< 55 " -font [font name] Text font"<<endl<<
56 " -title [title name] Set title"<<endl<< 56 " -title [title name] Set title"<<endl<<
57 " -text [text] Text input"<<endl<< 57 " -text [text] Text input"<<endl<<
58 " -print Print result to stdout"<<endl<<
58 " -w [width] Window width in pixels"<<endl<< 59 " -w [width] Window width in pixels"<<endl<<
59 " -h [height] Window height in pixels"<<endl<< 60 " -h [height] Window height in pixels"<<endl<<
60 " -display [display string] Display name"<<endl<< 61 " -display [display string] Display name"<<endl<<
@@ -75,6 +76,7 @@ int main(int argc, char **argv) {
75 bool set_pos = false; // set position 76 bool set_pos = false; // set position
76 bool near_mouse = false; // popup near mouse 77 bool near_mouse = false; // popup near mouse
77 bool antialias = true; // antialias text 78 bool antialias = true; // antialias text
79 bool print = false;
78 string fontname; // font name 80 string fontname; // font name
79 string title("Run program"); // default title 81 string title("Run program"); // default title
80 string text; // default input text 82 string text; // default input text
@@ -86,6 +88,8 @@ int main(int argc, char **argv) {
86 for (int i=1; i<argc; i++) { 88 for (int i=1; i<argc; i++) {
87 if (strcmp(argv[i], "-font") == 0 && i+1 < argc) { 89 if (strcmp(argv[i], "-font") == 0 && i+1 < argc) {
88 fontname = argv[++i]; 90 fontname = argv[++i];
91 } else if (strcmp(argv[i], "-print") == 0) {
92 print = true;
89 } else if (strcmp(argv[i], "-title") == 0 && i+1 < argc) { 93 } else if (strcmp(argv[i], "-title") == 0 && i+1 < argc) {
90 title = argv[++i]; 94 title = argv[++i];
91 } else if (strcmp(argv[i], "-text") == 0 && i+1 < argc) { 95 } else if (strcmp(argv[i], "-text") == 0 && i+1 < argc) {
@@ -129,7 +133,7 @@ int main(int argc, char **argv) {
129 FbTk::App application(display_name.c_str()); 133 FbTk::App application(display_name.c_str());
130 FbRun fbrun; 134 FbRun fbrun;
131 135
132 //fbrun.setAntialias(antialias); 136 fbrun.setPrint(print);
133 137
134 if (fontname.size() != 0) { 138 if (fontname.size() != 0) {
135 if (!fbrun.loadFont(fontname.c_str())) { 139 if (!fbrun.loadFont(fontname.c_str())) {