add -print option to fbrun to return result to stdout instead of executing it
Mark Tiefenbruck mark@fluxbox.org
4 files changed,
17 insertions(+),
1 deletions(-)
M
ChangeLog
→
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)
M
util/fbrun/FbRun.cc
→
util/fbrun/FbRun.cc
@@ -58,6 +58,7 @@
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),@@ -114,6 +115,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()) {
M
util/fbrun/FbRun.hh
→
util/fbrun/FbRun.hh
@@ -42,6 +42,7 @@ ~FbRun();
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 @@ void lastHistoryItem();
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;
M
util/fbrun/main.cc
→
util/fbrun/main.cc
@@ -55,6 +55,7 @@ "Arguments: "<<endl<<
" -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 @@ bool set_height = false, set_width=false; // use height/width of font by default
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 @@ // parse arguments
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 @@
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())) {