From e6570b61f34e9d7822f500706a5a2cd6bc436234 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck 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"<