summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/fbrun/main.cc45
1 files changed, 28 insertions, 17 deletions
diff --git a/util/fbrun/main.cc b/util/fbrun/main.cc
index d04b4a0..2237340 100644
--- a/util/fbrun/main.cc
+++ b/util/fbrun/main.cc
@@ -19,16 +19,31 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: main.cc,v 1.1 2002/08/20 02:04:34 fluxgen Exp $ 22// $Id: main.cc,v 1.2 2002/11/12 16:46:17 fluxgen Exp $
23 23
24#include "FbRun.hh" 24#include "FbRun.hh"
25#include "BaseDisplay.hh"
25 26
26#include <string> 27#include <string>
27#include <iostream> 28#include <iostream>
29
28using namespace std; 30using namespace std;
29 31
32class App:public BaseDisplay {
33public:
34 App(const char *displaystr):BaseDisplay("FbRun", displaystr) { }
35 FbRun &fbrun() { return m_fbrun; }
36 void handleEvent(XEvent * const ev) {
37 m_fbrun.handleEvent(ev);
38 if (m_fbrun.end())
39 shutdown();
40 }
41private:
42 FbRun m_fbrun;
43};
44
30void showUsage(const char *progname) { 45void showUsage(const char *progname) {
31 cerr<<"fbrun 1.1.0 : (c) 2002 Henrik Kinnunen"<<endl; 46 cerr<<"fbrun 1.1.1 : (c) 2002 Henrik Kinnunen"<<endl;
32 cerr<<"Usage: "<< 47 cerr<<"Usage: "<<
33 progname<<" [arguments]"<<endl<< 48 progname<<" [arguments]"<<endl<<
34 "Arguments: "<<endl<< 49 "Arguments: "<<endl<<
@@ -41,6 +56,7 @@ void showUsage(const char *progname) {
41 " -pos [x] [y] Window position in pixels"<<endl<< 56 " -pos [x] [y] Window position in pixels"<<endl<<
42 " -fg [color name] Foreground text color"<<endl<< 57 " -fg [color name] Foreground text color"<<endl<<
43 " -bg [color name] Background color"<<endl<< 58 " -bg [color name] Background color"<<endl<<
59 " -a Antialias"<<endl<<
44 " -help Show this help"<<endl<<endl<< 60 " -help Show this help"<<endl<<endl<<
45 "Example: fbrun -fg black -bg white -text xterm -title \"run xterm\""<<endl; 61 "Example: fbrun -fg black -bg white -text xterm -title \"run xterm\""<<endl;
46} 62}
@@ -50,6 +66,7 @@ int main(int argc, char **argv) {
50 size_t width = 200, height = 32; // default size of window 66 size_t width = 200, height = 32; // default size of window
51 bool set_height = false; // use height of font by default 67 bool set_height = false; // use height of font by default
52 bool set_pos = false; // set position 68 bool set_pos = false; // set position
69 bool antialias = false; // antialias text
53 string fontname; // font name 70 string fontname; // font name
54 string title("Run program"); // default title 71 string title("Run program"); // default title
55 string text; // default input text 72 string text; // default input text
@@ -90,6 +107,8 @@ int main(int argc, char **argv) {
90 } else if (strcmp(argv[i], "-bg") == 0 && i+1 < argc) { 107 } else if (strcmp(argv[i], "-bg") == 0 && i+1 < argc) {
91 ++i; 108 ++i;
92 background = argv[i]; 109 background = argv[i];
110 } else if (strcmp(argv[i], "-a") == 0) {
111 antialias = true;
93 } else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-help") == 0) { 112 } else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-help") == 0) {
94 showUsage(argv[0]); 113 showUsage(argv[0]);
95 exit(0); 114 exit(0);
@@ -102,15 +121,11 @@ int main(int argc, char **argv) {
102 } 121 }
103 122
104 try { 123 try {
105
106 Display *disp = 0;
107
108 // establish display connection
109 disp = XOpenDisplay(display_name.c_str());
110 if (disp == 0)
111 throw string("Can't open display: " + display_name);
112 124
113 FbRun fbrun(disp); 125 App application(display_name.c_str());
126 Display *disp = application.getXDisplay();
127
128 FbRun &fbrun = application.fbrun();
114 if (fontname.size() != 0) { 129 if (fontname.size() != 0) {
115 if (!fbrun.loadFont(fontname.c_str())) { 130 if (!fbrun.loadFont(fontname.c_str())) {
116 cerr<<"Failed to load font: "<<fontname<<endl; 131 cerr<<"Failed to load font: "<<fontname<<endl;
@@ -142,7 +157,8 @@ int main(int argc, char **argv) {
142 157
143 if (set_height) 158 if (set_height)
144 fbrun.resize(width, height); 159 fbrun.resize(width, height);
145 160 if (antialias)
161 fbrun.setAntialias(antialias);
146 fbrun.setTitle(title); 162 fbrun.setTitle(title);
147 fbrun.setText(text); 163 fbrun.setText(text);
148 fbrun.show(); 164 fbrun.show();
@@ -150,12 +166,7 @@ int main(int argc, char **argv) {
150 if (set_pos) 166 if (set_pos)
151 fbrun.move(x, y); 167 fbrun.move(x, y);
152 168
153 XEvent event; 169 application.eventLoop();
154 // main loop
155 while (!fbrun.end()) {
156 XNextEvent(disp, &event);
157 fbrun.handleEvent(&event);
158 }
159 170
160 } catch (string errstr) { 171 } catch (string errstr) {
161 cerr<<"Error: "<<errstr<<endl; 172 cerr<<"Error: "<<errstr<<endl;