add -print option to fbrun to return result to stdout instead of executing it

This commit is contained in:
Mark Tiefenbruck 2008-10-04 14:01:31 -07:00
parent 4b5c00b764
commit e6570b61f3
4 changed files with 17 additions and 1 deletions

View file

@ -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)

View file

@ -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()) {

View file

@ -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;

View file

@ -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())) {