From e6570b61f34e9d7822f500706a5a2cd6bc436234 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck <mark@fluxbox.org> Date: Sat, 4 Oct 2008 14:01:31 -0700 Subject: add -print option to fbrun to return result to stdout instead of executing it --- ChangeLog | 3 +++ util/fbrun/FbRun.cc | 7 +++++++ util/fbrun/FbRun.hh | 2 ++ util/fbrun/main.cc | 6 +++++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 72c45f3..d62889d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ (Format: Year/Month/Day) Changes for 1.1.2 *08/10/04: + * Add -print option to fbrun that sends the result to stdout instead of + running it (Mark) + util/FbRun/main.cc FbRun.cc/hh * Fix CustomMenu and ClientMenu commands from fluxbox-remote (Mark) Screen.cc * 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; FbRun::FbRun(int x, int y, size_t width): FbTk::TextBox(DefaultScreen(FbTk::App::instance()->display()), m_font, ""), + m_print(false), m_font("fixed"), m_display(FbTk::App::instance()->display()), m_bevel(4), @@ -115,6 +116,12 @@ void FbRun::run(const std::string &command) { FbTk::App::instance()->end(); // end application m_end = true; // mark end of processing + if (m_print) { + std::cout << command; + hide(); + return; + } + // fork and execute program if (!fork()) { 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: void handleEvent(XEvent * const ev); void setTitle(const std::string &title); void resize(unsigned int width, unsigned int height); + void setPrint(bool print) { m_print = print; } /// load and reconfigure for new font bool loadFont(const std::string &fontname); @@ -83,6 +84,7 @@ private: void tabCompleteHistory(); void tabCompleteApps(); + bool m_print; ///< the input should be printed to stdout rather than run FbTk::Font m_font; ///< font used to draw command text Display *m_display; ///< display connection 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) { " -font [font name] Text font"<<endl<< " -title [title name] Set title"<<endl<< " -text [text] Text input"<<endl<< + " -print Print result to stdout"<<endl<< " -w [width] Window width in pixels"<<endl<< " -h [height] Window height in pixels"<<endl<< " -display [display string] Display name"<<endl<< @@ -75,6 +76,7 @@ int main(int argc, char **argv) { bool set_pos = false; // set position bool near_mouse = false; // popup near mouse bool antialias = true; // antialias text + bool print = false; string fontname; // font name string title("Run program"); // default title string text; // default input text @@ -86,6 +88,8 @@ int main(int argc, char **argv) { for (int i=1; i<argc; i++) { if (strcmp(argv[i], "-font") == 0 && i+1 < argc) { fontname = argv[++i]; + } else if (strcmp(argv[i], "-print") == 0) { + print = true; } else if (strcmp(argv[i], "-title") == 0 && i+1 < argc) { title = argv[++i]; } else if (strcmp(argv[i], "-text") == 0 && i+1 < argc) { @@ -129,7 +133,7 @@ int main(int argc, char **argv) { FbTk::App application(display_name.c_str()); FbRun fbrun; - //fbrun.setAntialias(antialias); + fbrun.setPrint(print); if (fontname.size() != 0) { if (!fbrun.loadFont(fontname.c_str())) { -- cgit v0.11.2