-rw-r--r-- | core/apps/embeddedkonsole/Makefile.in | 124 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 2 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/commandeditdialog.cpp | 1 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/commandeditdialogbase.cpp | 101 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/commandeditdialogbase.h | 46 |
5 files changed, 260 insertions, 14 deletions
diff --git a/core/apps/embeddedkonsole/Makefile.in b/core/apps/embeddedkonsole/Makefile.in index 1c24ded..44310a6 100644 --- a/core/apps/embeddedkonsole/Makefile.in +++ b/core/apps/embeddedkonsole/Makefile.in | |||
@@ -1,288 +1,388 @@ | |||
1 | ############################################################################# | 1 | ############################################################################# |
2 | 2 | ||
3 | ####### Compiler, tools and options | 3 | ####### Compiler, tools and options |
4 | 4 | ||
5 | CXX =$(SYSCONF_CXX) $(QT_CXX_MT) | 5 | CXX =$(SYSCONF_CXX) $(QT_CXX_MT) |
6 | CXXFLAGS=$(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) | 6 | CXXFLAGS=$(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) |
7 | CC =$(SYSCONF_CC) $(QT_C_MT) | 7 | CC =$(SYSCONF_CC) $(QT_C_MT) |
8 | CFLAGS =$(SYSCONF_CFLAGS) | 8 | CFLAGS =$(SYSCONF_CFLAGS) |
9 | INCPATH =-I$(OPIEDIR)/include | 9 | INCPATH =-I$(OPIEDIR)/include |
10 | LFLAGS =$(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) | 10 | LFLAGS =$(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) |
11 | LIBS =$(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP) | 11 | LIBS =$(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP) |
12 | MOC =$(SYSCONF_MOC) | 12 | MOC =$(SYSCONF_MOC) |
13 | UIC =$(SYSCONF_UIC) | 13 | UIC =$(SYSCONF_UIC) |
14 | 14 | ||
15 | ####### Target | 15 | ####### Target |
16 | 16 | ||
17 | DESTDIR = $(OPIEDIR)/bin/ | 17 | DESTDIR = $(OPIEDIR)/bin/ |
18 | VER_MAJ = 1 | 18 | VER_MAJ = 1 |
19 | VER_MIN = 0 | 19 | VER_MIN = 0 |
20 | VER_PATCH = 0 | 20 | VER_PATCH = 0 |
21 | TARGET= embeddedkonsole | 21 | TARGET= embeddedkonsole |
22 | TARGET1 = lib$(TARGET).so.$(VER_MAJ) | 22 | TARGET1 = lib$(TARGET).so.$(VER_MAJ) |
23 | 23 | ||
24 | ####### Files | 24 | ####### Files |
25 | 25 | ||
26 | HEADERS =TEWidget.h \ | 26 | HEADERS =TEWidget.h \ |
27 | TEScreen.h \ | 27 | TEScreen.h \ |
28 | TECommon.h \ | 28 | TECommon.h \ |
29 | TEHistory.h \ | 29 | TEHistory.h \ |
30 | TEmulation.h \ | 30 | TEmulation.h \ |
31 | TEmuVt102.h \ | 31 | TEmuVt102.h \ |
32 | session.h \ | 32 | session.h \ |
33 | keytrans.h \ | 33 | keytrans.h \ |
34 | konsole.h \ | 34 | konsole.h \ |
35 | commandeditdialog.h \ | ||
36 | commandeditwidget.h \ | ||
37 | playlistselection.h \ | ||
35 | MyPty.h | 38 | MyPty.h |
36 | SOURCES =TEScreen.cpp \ | 39 | SOURCES =TEScreen.cpp \ |
37 | TEWidget.cpp \ | 40 | TEWidget.cpp \ |
38 | TEHistory.cpp \ | 41 | TEHistory.cpp \ |
39 | TEmulation.cpp \ | 42 | TEmulation.cpp \ |
40 | TEmuVt102.cpp \ | 43 | TEmuVt102.cpp \ |
41 | session.cpp \ | 44 | session.cpp \ |
42 | keytrans.cpp \ | 45 | keytrans.cpp \ |
43 | konsole.cpp \ | 46 | konsole.cpp \ |
44 | main.cpp \ | 47 | commandeditdialog.cpp \ |
45 | MyPty.cpp | 48 | commandeditwidget.cpp \ |
49 | playlistselection.cpp \ | ||
50 | MyPty.cpp \ | ||
51 | main.cpp | ||
46 | OBJECTS =TEScreen.o \ | 52 | OBJECTS =TEScreen.o \ |
47 | TEWidget.o \ | 53 | TEWidget.o \ |
48 | TEHistory.o \ | 54 | TEHistory.o \ |
49 | TEmulation.o \ | 55 | TEmulation.o \ |
50 | TEmuVt102.o \ | 56 | TEmuVt102.o \ |
51 | session.o \ | 57 | session.o \ |
52 | keytrans.o \ | 58 | keytrans.o \ |
53 | konsole.o \ | 59 | konsole.o \ |
60 | commandeditdialog.o \ | ||
61 | commandeditwidget.o \ | ||
62 | playlistselection.o \ | ||
63 | MyPty.o \ | ||
54 | main.o \ | 64 | main.o \ |
55 | MyPty.o | 65 | commandeditdialogbase.o \ |
56 | INTERFACES = | 66 | smallcommandeditdialogbase.o |
57 | UICDECLS = | 67 | INTERFACES = commandeditdialogbase.ui \ |
58 | UICIMPLS = | 68 | smallcommandeditdialogbase.ui |
69 | UICDECLS = commandeditdialogbase.h \ | ||
70 | smallcommandeditdialogbase.h | ||
71 | UICIMPLS = commandeditdialogbase.cpp \ | ||
72 | smallcommandeditdialogbase.cpp | ||
59 | SRCMOC =moc_TEWidget.cpp \ | 73 | SRCMOC =moc_TEWidget.cpp \ |
60 | moc_TEmulation.cpp \ | 74 | moc_TEmulation.cpp \ |
61 | moc_TEmuVt102.cpp \ | 75 | moc_TEmuVt102.cpp \ |
62 | moc_session.cpp \ | 76 | moc_session.cpp \ |
63 | moc_konsole.cpp \ | 77 | moc_konsole.cpp \ |
64 | moc_MyPty.cpp | 78 | moc_commandeditdialog.cpp \ |
79 | moc_commandeditwidget.cpp \ | ||
80 | moc_playlistselection.cpp \ | ||
81 | moc_MyPty.cpp \ | ||
82 | moc_commandeditdialogbase.cpp \ | ||
83 | moc_smallcommandeditdialogbase.cpp | ||
65 | OBJMOC =moc_TEWidget.o \ | 84 | OBJMOC =moc_TEWidget.o \ |
66 | moc_TEmulation.o \ | 85 | moc_TEmulation.o \ |
67 | moc_TEmuVt102.o \ | 86 | moc_TEmuVt102.o \ |
68 | moc_session.o \ | 87 | moc_session.o \ |
69 | moc_konsole.o \ | 88 | moc_konsole.o \ |
70 | moc_MyPty.o | 89 | moc_commandeditdialog.o \ |
90 | moc_commandeditwidget.o \ | ||
91 | moc_playlistselection.o \ | ||
92 | moc_MyPty.o \ | ||
93 | moc_commandeditdialogbase.o \ | ||
94 | moc_smallcommandeditdialogbase.o | ||
71 | 95 | ||
72 | 96 | ||
73 | ####### Implicit rules | 97 | ####### Implicit rules |
74 | 98 | ||
75 | .SUFFIXES: .cpp .cxx .cc .C .c | 99 | .SUFFIXES: .cpp .cxx .cc .C .c |
76 | 100 | ||
77 | .cpp.o: | 101 | .cpp.o: |
78 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | 102 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< |
79 | 103 | ||
80 | .cxx.o: | 104 | .cxx.o: |
81 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | 105 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< |
82 | 106 | ||
83 | .cc.o: | 107 | .cc.o: |
84 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | 108 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< |
85 | 109 | ||
86 | .C.o: | 110 | .C.o: |
87 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | 111 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< |
88 | 112 | ||
89 | .c.o: | 113 | .c.o: |
90 | $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< | 114 | $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< |
91 | 115 | ||
92 | ####### Build rules | 116 | ####### Build rules |
93 | 117 | ||
94 | 118 | ||
95 | all: $(DESTDIR)$(TARGET) | 119 | all: $(DESTDIR)$(TARGET) |
96 | 120 | ||
97 | $(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) | 121 | $(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) |
98 | $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) | 122 | $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) |
99 | 123 | ||
100 | moc: $(SRCMOC) | 124 | moc: $(SRCMOC) |
101 | 125 | ||
102 | tmake: | 126 | tmake: |
103 | tmake embeddedkonsole.pro | 127 | tmake embeddedkonsole.pro |
104 | 128 | ||
105 | clean: | 129 | clean: |
106 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) | 130 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) |
107 | -rm -f *~ core | 131 | -rm -f *~ core |
108 | -rm -f allmoc.cpp | 132 | -rm -f allmoc.cpp |
109 | 133 | ||
110 | ####### Extension Modules | 134 | ####### Extension Modules |
111 | 135 | ||
112 | listpromodules: | 136 | listpromodules: |
113 | @echo | 137 | @echo |
114 | 138 | ||
115 | listallmodules: | 139 | listallmodules: |
116 | @echo | 140 | @echo |
117 | 141 | ||
118 | listaddonpromodules: | 142 | listaddonpromodules: |
119 | @echo | 143 | @echo |
120 | 144 | ||
121 | listaddonentmodules: | 145 | listaddonentmodules: |
122 | @echo | 146 | @echo |
123 | 147 | ||
124 | 148 | ||
125 | REQUIRES=embeddedkonsole | 149 | REQUIRES=embeddedkonsole |
126 | 150 | ||
127 | ####### Sub-libraries | 151 | ####### Sub-libraries |
128 | 152 | ||
129 | 153 | ||
130 | ###### Combined headers | 154 | ###### Combined headers |
131 | 155 | ||
132 | 156 | ||
133 | 157 | ||
134 | ####### Compile | 158 | ####### Compile |
135 | 159 | ||
136 | TEScreen.o: TEScreen.cpp \ | 160 | TEScreen.o: TEScreen.cpp \ |
137 | TEScreen.h \ | 161 | TEScreen.h \ |
138 | TECommon.h \ | 162 | TECommon.h \ |
139 | TEHistory.h | 163 | TEHistory.h |
140 | 164 | ||
141 | TEWidget.o: TEWidget.cpp \ | 165 | TEWidget.o: TEWidget.cpp \ |
142 | TEWidget.h \ | 166 | TEWidget.h \ |
143 | TECommon.h \ | 167 | TECommon.h \ |
144 | session.h \ | 168 | session.h \ |
145 | MyPty.h \ | 169 | MyPty.h \ |
146 | TEmuVt102.h \ | 170 | TEmuVt102.h \ |
147 | TEScreen.h \ | 171 | TEScreen.h \ |
148 | TEHistory.h \ | 172 | TEHistory.h \ |
149 | TEmulation.h \ | 173 | TEmulation.h \ |
150 | keytrans.h | 174 | keytrans.h \ |
175 | $(OPIEDIR)/include/qpe/config.h | ||
151 | 176 | ||
152 | TEHistory.o: TEHistory.cpp \ | 177 | TEHistory.o: TEHistory.cpp \ |
153 | TEHistory.h \ | 178 | TEHistory.h \ |
154 | TECommon.h | 179 | TECommon.h |
155 | 180 | ||
156 | TEmulation.o: TEmulation.cpp \ | 181 | TEmulation.o: TEmulation.cpp \ |
157 | TEmulation.h \ | 182 | TEmulation.h \ |
158 | TEWidget.h \ | 183 | TEWidget.h \ |
159 | TECommon.h \ | 184 | TECommon.h \ |
160 | TEScreen.h \ | 185 | TEScreen.h \ |
161 | TEHistory.h \ | 186 | TEHistory.h \ |
162 | keytrans.h | 187 | keytrans.h |
163 | 188 | ||
164 | TEmuVt102.o: TEmuVt102.cpp \ | 189 | TEmuVt102.o: TEmuVt102.cpp \ |
165 | TEmuVt102.h \ | 190 | TEmuVt102.h \ |
166 | TEWidget.h \ | 191 | TEWidget.h \ |
167 | TECommon.h \ | 192 | TECommon.h \ |
168 | TEScreen.h \ | 193 | TEScreen.h \ |
169 | TEHistory.h \ | 194 | TEHistory.h \ |
170 | TEmulation.h \ | 195 | TEmulation.h \ |
171 | keytrans.h | 196 | keytrans.h |
172 | 197 | ||
173 | session.o: session.cpp \ | 198 | session.o: session.cpp \ |
174 | session.h \ | 199 | session.h \ |
175 | MyPty.h \ | 200 | MyPty.h \ |
176 | TEWidget.h \ | 201 | TEWidget.h \ |
177 | TECommon.h \ | 202 | TECommon.h \ |
178 | TEmuVt102.h \ | 203 | TEmuVt102.h \ |
179 | TEScreen.h \ | 204 | TEScreen.h \ |
180 | TEHistory.h \ | 205 | TEHistory.h \ |
181 | TEmulation.h \ | 206 | TEmulation.h \ |
182 | keytrans.h | 207 | keytrans.h |
183 | 208 | ||
184 | keytrans.o: keytrans.cpp \ | 209 | keytrans.o: keytrans.cpp \ |
185 | keytrans.h \ | 210 | keytrans.h \ |
186 | $(OPIEDIR)/include/qpe/qpeapplication.h \ | 211 | $(OPIEDIR)/include/qpe/qpeapplication.h \ |
187 | default.keytab.h | 212 | default.keytab.h |
188 | 213 | ||
189 | konsole.o: konsole.cpp \ | 214 | konsole.o: konsole.cpp \ |
190 | $(OPIEDIR)/include/qpe/resource.h \ | 215 | $(OPIEDIR)/include/qpe/resource.h \ |
191 | $(OPIEDIR)/include/qpe/qpetoolbar.h \ | 216 | $(OPIEDIR)/include/qpe/qpetoolbar.h \ |
192 | $(OPIEDIR)/include/qpe/qpemenubar.h \ | 217 | $(OPIEDIR)/include/qpe/qpemenubar.h \ |
193 | $(OPIEDIR)/include/qpe/config.h \ | 218 | $(OPIEDIR)/include/qpe/config.h \ |
194 | konsole.h \ | 219 | konsole.h \ |
195 | MyPty.h \ | 220 | MyPty.h \ |
196 | TEWidget.h \ | 221 | TEWidget.h \ |
197 | TECommon.h \ | 222 | TECommon.h \ |
198 | TEmuVt102.h \ | 223 | TEmuVt102.h \ |
199 | TEScreen.h \ | 224 | TEScreen.h \ |
200 | TEHistory.h \ | 225 | TEHistory.h \ |
201 | TEmulation.h \ | 226 | TEmulation.h \ |
202 | keytrans.h \ | 227 | keytrans.h \ |
203 | session.h | 228 | session.h \ |
229 | commandeditdialog.h \ | ||
230 | commandeditdialogbase.h | ||
231 | |||
232 | commandeditdialog.o: commandeditdialog.cpp \ | ||
233 | commandeditdialog.h \ | ||
234 | commandeditdialogbase.h \ | ||
235 | playlistselection.h \ | ||
236 | $(OPIEDIR)/include/qpe/applnk.h \ | ||
237 | $(OPIEDIR)/include/qpe/config.h \ | ||
238 | $(OPIEDIR)/include/qpe/qpetoolbar.h \ | ||
239 | $(OPIEDIR)/include/qpe/qpemenubar.h \ | ||
240 | $(OPIEDIR)/include/qpe/resource.h \ | ||
241 | smallcommandeditdialogbase.h | ||
242 | |||
243 | commandeditwidget.o: commandeditwidget.cpp \ | ||
244 | commandeditwidget.h \ | ||
245 | playlistselection.h \ | ||
246 | $(OPIEDIR)/include/qpe/applnk.h | ||
247 | |||
248 | playlistselection.o: playlistselection.cpp \ | ||
249 | $(OPIEDIR)/include/qpe/applnk.h \ | ||
250 | $(OPIEDIR)/include/qpe/resource.h \ | ||
251 | playlistselection.h | ||
252 | |||
253 | MyPty.o: MyPty.cpp \ | ||
254 | MyPty.h | ||
204 | 255 | ||
205 | main.o: main.cpp \ | 256 | main.o: main.cpp \ |
206 | konsole.h \ | 257 | konsole.h \ |
207 | $(OPIEDIR)/include/qpe/qpetoolbar.h \ | 258 | $(OPIEDIR)/include/qpe/qpetoolbar.h \ |
208 | MyPty.h \ | 259 | MyPty.h \ |
209 | TEWidget.h \ | 260 | TEWidget.h \ |
210 | TECommon.h \ | 261 | TECommon.h \ |
211 | TEmuVt102.h \ | 262 | TEmuVt102.h \ |
212 | TEScreen.h \ | 263 | TEScreen.h \ |
213 | TEHistory.h \ | 264 | TEHistory.h \ |
214 | TEmulation.h \ | 265 | TEmulation.h \ |
215 | keytrans.h \ | 266 | keytrans.h \ |
216 | session.h \ | 267 | session.h \ |
217 | $(OPIEDIR)/include/qpe/qpeapplication.h | 268 | $(OPIEDIR)/include/qpe/qpeapplication.h |
218 | 269 | ||
219 | MyPty.o: MyPty.cpp \ | 270 | commandeditdialogbase.h: commandeditdialogbase.ui |
220 | MyPty.h | 271 | $(UIC) commandeditdialogbase.ui -o $(INTERFACE_DECL_PATH)/commandeditdialogbase.h |
272 | |||
273 | commandeditdialogbase.cpp: commandeditdialogbase.ui | ||
274 | $(UIC) commandeditdialogbase.ui -i commandeditdialogbase.h -o commandeditdialogbase.cpp | ||
275 | |||
276 | smallcommandeditdialogbase.h: smallcommandeditdialogbase.ui | ||
277 | $(UIC) smallcommandeditdialogbase.ui -o $(INTERFACE_DECL_PATH)/smallcommandeditdialogbase.h | ||
278 | |||
279 | smallcommandeditdialogbase.cpp: smallcommandeditdialogbase.ui | ||
280 | $(UIC) smallcommandeditdialogbase.ui -i smallcommandeditdialogbase.h -o smallcommandeditdialogbase.cpp | ||
281 | |||
282 | commandeditdialogbase.o: commandeditdialogbase.cpp \ | ||
283 | commandeditdialogbase.h \ | ||
284 | playlistselection.h \ | ||
285 | $(OPIEDIR)/include/qpe/applnk.h | ||
286 | |||
287 | smallcommandeditdialogbase.o: smallcommandeditdialogbase.cpp \ | ||
288 | smallcommandeditdialogbase.h | ||
221 | 289 | ||
222 | moc_TEWidget.o: moc_TEWidget.cpp \ | 290 | moc_TEWidget.o: moc_TEWidget.cpp \ |
223 | TEWidget.h \ | 291 | TEWidget.h \ |
224 | TECommon.h | 292 | TECommon.h |
225 | 293 | ||
226 | moc_TEmulation.o: moc_TEmulation.cpp \ | 294 | moc_TEmulation.o: moc_TEmulation.cpp \ |
227 | TEmulation.h \ | 295 | TEmulation.h \ |
228 | TEWidget.h \ | 296 | TEWidget.h \ |
229 | TECommon.h \ | 297 | TECommon.h \ |
230 | TEScreen.h \ | 298 | TEScreen.h \ |
231 | TEHistory.h \ | 299 | TEHistory.h \ |
232 | keytrans.h | 300 | keytrans.h |
233 | 301 | ||
234 | moc_TEmuVt102.o: moc_TEmuVt102.cpp \ | 302 | moc_TEmuVt102.o: moc_TEmuVt102.cpp \ |
235 | TEmuVt102.h \ | 303 | TEmuVt102.h \ |
236 | TEWidget.h \ | 304 | TEWidget.h \ |
237 | TECommon.h \ | 305 | TECommon.h \ |
238 | TEScreen.h \ | 306 | TEScreen.h \ |
239 | TEHistory.h \ | 307 | TEHistory.h \ |
240 | TEmulation.h \ | 308 | TEmulation.h \ |
241 | keytrans.h | 309 | keytrans.h |
242 | 310 | ||
243 | moc_session.o: moc_session.cpp \ | 311 | moc_session.o: moc_session.cpp \ |
244 | session.h \ | 312 | session.h \ |
245 | MyPty.h \ | 313 | MyPty.h \ |
246 | TEWidget.h \ | 314 | TEWidget.h \ |
247 | TECommon.h \ | 315 | TECommon.h \ |
248 | TEmuVt102.h \ | 316 | TEmuVt102.h \ |
249 | TEScreen.h \ | 317 | TEScreen.h \ |
250 | TEHistory.h \ | 318 | TEHistory.h \ |
251 | TEmulation.h \ | 319 | TEmulation.h \ |
252 | keytrans.h | 320 | keytrans.h |
253 | 321 | ||
254 | moc_konsole.o: moc_konsole.cpp \ | 322 | moc_konsole.o: moc_konsole.cpp \ |
255 | konsole.h \ | 323 | konsole.h \ |
256 | $(OPIEDIR)/include/qpe/qpetoolbar.h \ | 324 | $(OPIEDIR)/include/qpe/qpetoolbar.h \ |
257 | MyPty.h \ | 325 | MyPty.h \ |
258 | TEWidget.h \ | 326 | TEWidget.h \ |
259 | TECommon.h \ | 327 | TECommon.h \ |
260 | TEmuVt102.h \ | 328 | TEmuVt102.h \ |
261 | TEScreen.h \ | 329 | TEScreen.h \ |
262 | TEHistory.h \ | 330 | TEHistory.h \ |
263 | TEmulation.h \ | 331 | TEmulation.h \ |
264 | keytrans.h \ | 332 | keytrans.h \ |
265 | session.h | 333 | session.h |
266 | 334 | ||
335 | moc_commandeditdialog.o: moc_commandeditdialog.cpp \ | ||
336 | commandeditdialog.h \ | ||
337 | commandeditdialogbase.h | ||
338 | |||
339 | moc_commandeditwidget.o: moc_commandeditwidget.cpp \ | ||
340 | commandeditwidget.h | ||
341 | |||
342 | moc_playlistselection.o: moc_playlistselection.cpp \ | ||
343 | playlistselection.h \ | ||
344 | $(OPIEDIR)/include/qpe/applnk.h | ||
345 | |||
267 | moc_MyPty.o: moc_MyPty.cpp \ | 346 | moc_MyPty.o: moc_MyPty.cpp \ |
268 | MyPty.h | 347 | MyPty.h |
269 | 348 | ||
349 | moc_commandeditdialogbase.o: moc_commandeditdialogbase.cpp \ | ||
350 | commandeditdialogbase.h | ||
351 | |||
352 | moc_smallcommandeditdialogbase.o: moc_smallcommandeditdialogbase.cpp \ | ||
353 | smallcommandeditdialogbase.h | ||
354 | |||
270 | moc_TEWidget.cpp: TEWidget.h | 355 | moc_TEWidget.cpp: TEWidget.h |
271 | $(MOC) TEWidget.h -o moc_TEWidget.cpp | 356 | $(MOC) TEWidget.h -o moc_TEWidget.cpp |
272 | 357 | ||
273 | moc_TEmulation.cpp: TEmulation.h | 358 | moc_TEmulation.cpp: TEmulation.h |
274 | $(MOC) TEmulation.h -o moc_TEmulation.cpp | 359 | $(MOC) TEmulation.h -o moc_TEmulation.cpp |
275 | 360 | ||
276 | moc_TEmuVt102.cpp: TEmuVt102.h | 361 | moc_TEmuVt102.cpp: TEmuVt102.h |
277 | $(MOC) TEmuVt102.h -o moc_TEmuVt102.cpp | 362 | $(MOC) TEmuVt102.h -o moc_TEmuVt102.cpp |
278 | 363 | ||
279 | moc_session.cpp: session.h | 364 | moc_session.cpp: session.h |
280 | $(MOC) session.h -o moc_session.cpp | 365 | $(MOC) session.h -o moc_session.cpp |
281 | 366 | ||
282 | moc_konsole.cpp: konsole.h | 367 | moc_konsole.cpp: konsole.h |
283 | $(MOC) konsole.h -o moc_konsole.cpp | 368 | $(MOC) konsole.h -o moc_konsole.cpp |
284 | 369 | ||
370 | moc_commandeditdialog.cpp: commandeditdialog.h | ||
371 | $(MOC) commandeditdialog.h -o moc_commandeditdialog.cpp | ||
372 | |||
373 | moc_commandeditwidget.cpp: commandeditwidget.h | ||
374 | $(MOC) commandeditwidget.h -o moc_commandeditwidget.cpp | ||
375 | |||
376 | moc_playlistselection.cpp: playlistselection.h | ||
377 | $(MOC) playlistselection.h -o moc_playlistselection.cpp | ||
378 | |||
285 | moc_MyPty.cpp: MyPty.h | 379 | moc_MyPty.cpp: MyPty.h |
286 | $(MOC) MyPty.h -o moc_MyPty.cpp | 380 | $(MOC) MyPty.h -o moc_MyPty.cpp |
287 | 381 | ||
382 | moc_commandeditdialogbase.cpp: commandeditdialogbase.h | ||
383 | $(MOC) commandeditdialogbase.h -o moc_commandeditdialogbase.cpp | ||
384 | |||
385 | moc_smallcommandeditdialogbase.cpp: smallcommandeditdialogbase.h | ||
386 | $(MOC) smallcommandeditdialogbase.h -o moc_smallcommandeditdialogbase.cpp | ||
387 | |||
288 | 388 | ||
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index a56dc50..dab0ea3 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp | |||
@@ -1,1261 +1,1261 @@ | |||
1 | /* ------------------------------------------------------------------------ */ | 1 | /* ------------------------------------------------------------------------ */ |
2 | /* */ | 2 | /* */ |
3 | /* [TEWidget.C] Terminal Emulation Widget */ | 3 | /* [TEWidget.C] Terminal Emulation Widget */ |
4 | /* */ | 4 | /* */ |
5 | /* ------------------------------------------------------------------------ */ | 5 | /* ------------------------------------------------------------------------ */ |
6 | /* */ | 6 | /* */ |
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
8 | /* */ | 8 | /* */ |
9 | /* This file is part of Konsole - an X terminal for KDE */ | 9 | /* This file is part of Konsole - an X terminal for KDE */ |
10 | /* */ | 10 | /* */ |
11 | /* ------------------------------------------------------------------------ */ | 11 | /* ------------------------------------------------------------------------ */ |
12 | /* */ | 12 | /* */ |
13 | /* Ported Konsole to Qt/Embedded */ | 13 | /* Ported Konsole to Qt/Embedded */ |
14 | /* */ | 14 | /* */ |
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
16 | /* */ | 16 | /* */ |
17 | /* -------------------------------------------------------------------------- */ | 17 | /* -------------------------------------------------------------------------- */ |
18 | /*! \class TEWidget | 18 | /*! \class TEWidget |
19 | 19 | ||
20 | \brief Visible screen contents | 20 | \brief Visible screen contents |
21 | 21 | ||
22 | This class is responsible to map the `image' of a terminal emulation to the | 22 | This class is responsible to map the `image' of a terminal emulation to the |
23 | display. All the dependency of the emulation to a specific GUI or toolkit is | 23 | display. All the dependency of the emulation to a specific GUI or toolkit is |
24 | localized here. Further, this widget has no knowledge about being part of an | 24 | localized here. Further, this widget has no knowledge about being part of an |
25 | emulation, it simply work within the terminal emulation framework by exposing | 25 | emulation, it simply work within the terminal emulation framework by exposing |
26 | size and key events and by being ordered to show a new image. | 26 | size and key events and by being ordered to show a new image. |
27 | 27 | ||
28 | <ul> | 28 | <ul> |
29 | <li> The internal image has the size of the widget (evtl. rounded up) | 29 | <li> The internal image has the size of the widget (evtl. rounded up) |
30 | <li> The external image used in setImage can have any size. | 30 | <li> The external image used in setImage can have any size. |
31 | <li> (internally) the external image is simply copied to the internal | 31 | <li> (internally) the external image is simply copied to the internal |
32 | when a setImage happens. During a resizeEvent no painting is done | 32 | when a setImage happens. During a resizeEvent no painting is done |
33 | a paintEvent is expected to follow anyway. | 33 | a paintEvent is expected to follow anyway. |
34 | </ul> | 34 | </ul> |
35 | 35 | ||
36 | \sa TEScreen \sa Emulation | 36 | \sa TEScreen \sa Emulation |
37 | */ | 37 | */ |
38 | 38 | ||
39 | /* FIXME: | 39 | /* FIXME: |
40 | - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent | 40 | - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent |
41 | - 'font_a' not used in mouse events | 41 | - 'font_a' not used in mouse events |
42 | - add destructor | 42 | - add destructor |
43 | */ | 43 | */ |
44 | 44 | ||
45 | /* TODO | 45 | /* TODO |
46 | - evtl. be sensitive to `paletteChange' while using default colors. | 46 | - evtl. be sensitive to `paletteChange' while using default colors. |
47 | - set different 'rounding' styles? I.e. have a mode to show clipped chars? | 47 | - set different 'rounding' styles? I.e. have a mode to show clipped chars? |
48 | */ | 48 | */ |
49 | 49 | ||
50 | // #include "config.h" | 50 | // #include "config.h" |
51 | #include "TEWidget.h" | 51 | #include "TEWidget.h" |
52 | #include "session.h" | 52 | #include "session.h" |
53 | #include <qpe/config.h> | 53 | #include <qpe/config.h> |
54 | 54 | ||
55 | #include <qcursor.h> | 55 | #include <qcursor.h> |
56 | #include <qregexp.h> | 56 | #include <qregexp.h> |
57 | #include <qpainter.h> | 57 | #include <qpainter.h> |
58 | #include <qclipboard.h> | 58 | #include <qclipboard.h> |
59 | #include <qstyle.h> | 59 | #include <qstyle.h> |
60 | #include <qfile.h> | 60 | #include <qfile.h> |
61 | #include <qdragobject.h> | 61 | #include <qdragobject.h> |
62 | 62 | ||
63 | #include <stdio.h> | 63 | #include <stdio.h> |
64 | #include <stdlib.h> | 64 | #include <stdlib.h> |
65 | #include <unistd.h> | 65 | #include <unistd.h> |
66 | #include <ctype.h> | 66 | #include <ctype.h> |
67 | #include <sys/stat.h> | 67 | #include <sys/stat.h> |
68 | #include <sys/types.h> | 68 | #include <sys/types.h> |
69 | #include <signal.h> | 69 | #include <signal.h> |
70 | 70 | ||
71 | #include <assert.h> | 71 | #include <assert.h> |
72 | 72 | ||
73 | // #include "TEWidget.moc" | 73 | // #include "TEWidget.moc" |
74 | //#include <kapp.h> | 74 | //#include <kapp.h> |
75 | //#include <kcursor.h> | 75 | //#include <kcursor.h> |
76 | //#include <kurl.h> | 76 | //#include <kurl.h> |
77 | //#include <kdebug.h> | 77 | //#include <kdebug.h> |
78 | //#include <klocale.h> | 78 | //#include <klocale.h> |
79 | 79 | ||
80 | #define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__) | 80 | #define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__) |
81 | #define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } | 81 | #define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } |
82 | 82 | ||
83 | #define loc(X,Y) ((Y)*columns+(X)) | 83 | #define loc(X,Y) ((Y)*columns+(X)) |
84 | 84 | ||
85 | //FIXME: the rim should normally be 1, 0 only when running in full screen mode. | 85 | //FIXME: the rim should normally be 1, 0 only when running in full screen mode. |
86 | #define rimX 0 // left/right rim width | 86 | #define rimX 0 // left/right rim width |
87 | #define rimY 0 // top/bottom rim high | 87 | #define rimY 0 // top/bottom rim high |
88 | 88 | ||
89 | #define SCRWIDTH 16 // width of the scrollbar | 89 | #define SCRWIDTH 16 // width of the scrollbar |
90 | 90 | ||
91 | #define yMouseScroll 1 | 91 | #define yMouseScroll 1 |
92 | // scroll increment used when dragging selection at top/bottom of window. | 92 | // scroll increment used when dragging selection at top/bottom of window. |
93 | 93 | ||
94 | /* ------------------------------------------------------------------------- */ | 94 | /* ------------------------------------------------------------------------- */ |
95 | /* */ | 95 | /* */ |
96 | /* Colors */ | 96 | /* Colors */ |
97 | /* */ | 97 | /* */ |
98 | /* ------------------------------------------------------------------------- */ | 98 | /* ------------------------------------------------------------------------- */ |
99 | 99 | ||
100 | //FIXME: the default color table is in session.C now. | 100 | //FIXME: the default color table is in session.C now. |
101 | // We need a way to get rid of this one, here. | 101 | // We need a way to get rid of this one, here. |
102 | static const ColorEntry base_color_table[TABLE_COLORS] = | 102 | static const ColorEntry base_color_table[TABLE_COLORS] = |
103 | // The following are almost IBM standard color codes, with some slight | 103 | // The following are almost IBM standard color codes, with some slight |
104 | // gamma correction for the dim colors to compensate for bright X screens. | 104 | // gamma correction for the dim colors to compensate for bright X screens. |
105 | // It contains the 8 ansiterm/xterm colors in 2 intensities. | 105 | // It contains the 8 ansiterm/xterm colors in 2 intensities. |
106 | { | 106 | { |
107 | // Fixme: could add faint colors here, also. | 107 | // Fixme: could add faint colors here, also. |
108 | // normal | 108 | // normal |
109 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback | 109 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback |
110 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red | 110 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red |
111 | ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow | 111 | ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow |
112 | ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta | 112 | ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta |
113 | ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White | 113 | ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White |
114 | // intensiv | 114 | // intensiv |
115 | ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), | 115 | ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), |
116 | ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), | 116 | ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), |
117 | ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), | 117 | ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), |
118 | ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), | 118 | ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), |
119 | ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) | 119 | ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) |
120 | }; | 120 | }; |
121 | 121 | ||
122 | /* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) | 122 | /* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) |
123 | 123 | ||
124 | Code 0 1 2 3 4 5 6 7 | 124 | Code 0 1 2 3 4 5 6 7 |
125 | ----------- ------- ------- ------- ------- ------- ------- ------- ------- | 125 | ----------- ------- ------- ------- ------- ------- ------- ------- ------- |
126 | ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White | 126 | ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White |
127 | IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White | 127 | IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White |
128 | */ | 128 | */ |
129 | 129 | ||
130 | QColor TEWidget::getDefaultBackColor() | 130 | QColor TEWidget::getDefaultBackColor() |
131 | { | 131 | { |
132 | return color_table[DEFAULT_BACK_COLOR].color; | 132 | return color_table[DEFAULT_BACK_COLOR].color; |
133 | } | 133 | } |
134 | 134 | ||
135 | const ColorEntry* TEWidget::getColorTable() const | 135 | const ColorEntry* TEWidget::getColorTable() const |
136 | { | 136 | { |
137 | return color_table; | 137 | return color_table; |
138 | } | 138 | } |
139 | 139 | ||
140 | const ColorEntry* TEWidget::getdefaultColorTable() const | 140 | const ColorEntry* TEWidget::getdefaultColorTable() const |
141 | { | 141 | { |
142 | return base_color_table; | 142 | return base_color_table; |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | const QPixmap *TEWidget::backgroundPixmap() | 146 | const QPixmap *TEWidget::backgroundPixmap() |
147 | { | 147 | { |
148 | static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); | 148 | static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); |
149 | const QPixmap *pm = bg; | 149 | const QPixmap *pm = bg; |
150 | return pm; | 150 | return pm; |
151 | } | 151 | } |
152 | 152 | ||
153 | void TEWidget::setColorTable(const ColorEntry table[]) | 153 | void TEWidget::setColorTable(const ColorEntry table[]) |
154 | { | 154 | { |
155 | for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; | 155 | for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; |
156 | 156 | ||
157 | const QPixmap* pm = backgroundPixmap(); | 157 | const QPixmap* pm = backgroundPixmap(); |
158 | if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); | 158 | if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); |
159 | update(); | 159 | update(); |
160 | } | 160 | } |
161 | 161 | ||
162 | //FIXME: add backgroundPixmapChanged. | 162 | //FIXME: add backgroundPixmapChanged. |
163 | 163 | ||
164 | /* ------------------------------------------------------------------------- */ | 164 | /* ------------------------------------------------------------------------- */ |
165 | /* */ | 165 | /* */ |
166 | /* Font */ | 166 | /* Font */ |
167 | /* */ | 167 | /* */ |
168 | /* ------------------------------------------------------------------------- */ | 168 | /* ------------------------------------------------------------------------- */ |
169 | 169 | ||
170 | /* | 170 | /* |
171 | The VT100 has 32 special graphical characters. The usual vt100 extended | 171 | The VT100 has 32 special graphical characters. The usual vt100 extended |
172 | xterm fonts have these at 0x00..0x1f. | 172 | xterm fonts have these at 0x00..0x1f. |
173 | 173 | ||
174 | QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals | 174 | QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals |
175 | come in here as proper unicode characters. | 175 | come in here as proper unicode characters. |
176 | 176 | ||
177 | We treat non-iso10646 fonts as VT100 extended and do the requiered mapping | 177 | We treat non-iso10646 fonts as VT100 extended and do the requiered mapping |
178 | from unicode to 0x00..0x1f. The remaining translation is then left to the | 178 | from unicode to 0x00..0x1f. The remaining translation is then left to the |
179 | QCodec. | 179 | QCodec. |
180 | */ | 180 | */ |
181 | 181 | ||
182 | // assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. | 182 | // assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. |
183 | 183 | ||
184 | unsigned short vt100_graphics[32] = | 184 | unsigned short vt100_graphics[32] = |
185 | { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 | 185 | { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 |
186 | 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, | 186 | 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, |
187 | 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, | 187 | 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, |
188 | 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, | 188 | 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, |
189 | 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 | 189 | 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 |
190 | }; | 190 | }; |
191 | 191 | ||
192 | static QChar vt100extended(QChar c) | 192 | static QChar vt100extended(QChar c) |
193 | { | 193 | { |
194 | switch (c.unicode()) | 194 | switch (c.unicode()) |
195 | { | 195 | { |
196 | case 0x25c6 : return 1; | 196 | case 0x25c6 : return 1; |
197 | case 0x2592 : return 2; | 197 | case 0x2592 : return 2; |
198 | case 0x2409 : return 3; | 198 | case 0x2409 : return 3; |
199 | case 0x240c : return 4; | 199 | case 0x240c : return 4; |
200 | case 0x240d : return 5; | 200 | case 0x240d : return 5; |
201 | case 0x240a : return 6; | 201 | case 0x240a : return 6; |
202 | case 0x00b0 : return 7; | 202 | case 0x00b0 : return 7; |
203 | case 0x00b1 : return 8; | 203 | case 0x00b1 : return 8; |
204 | case 0x2424 : return 9; | 204 | case 0x2424 : return 9; |
205 | case 0x240b : return 10; | 205 | case 0x240b : return 10; |
206 | case 0x2518 : return 11; | 206 | case 0x2518 : return 11; |
207 | case 0x2510 : return 12; | 207 | case 0x2510 : return 12; |
208 | case 0x250c : return 13; | 208 | case 0x250c : return 13; |
209 | case 0x2514 : return 14; | 209 | case 0x2514 : return 14; |
210 | case 0x253c : return 15; | 210 | case 0x253c : return 15; |
211 | case 0xf800 : return 16; | 211 | case 0xf800 : return 16; |
212 | case 0xf801 : return 17; | 212 | case 0xf801 : return 17; |
213 | case 0x2500 : return 18; | 213 | case 0x2500 : return 18; |
214 | case 0xf803 : return 19; | 214 | case 0xf803 : return 19; |
215 | case 0xf804 : return 20; | 215 | case 0xf804 : return 20; |
216 | case 0x251c : return 21; | 216 | case 0x251c : return 21; |
217 | case 0x2524 : return 22; | 217 | case 0x2524 : return 22; |
218 | case 0x2534 : return 23; | 218 | case 0x2534 : return 23; |
219 | case 0x252c : return 24; | 219 | case 0x252c : return 24; |
220 | case 0x2502 : return 25; | 220 | case 0x2502 : return 25; |
221 | case 0x2264 : return 26; | 221 | case 0x2264 : return 26; |
222 | case 0x2265 : return 27; | 222 | case 0x2265 : return 27; |
223 | case 0x03c0 : return 28; | 223 | case 0x03c0 : return 28; |
224 | case 0x2260 : return 29; | 224 | case 0x2260 : return 29; |
225 | case 0x00a3 : return 30; | 225 | case 0x00a3 : return 30; |
226 | case 0x00b7 : return 31; | 226 | case 0x00b7 : return 31; |
227 | } | 227 | } |
228 | return c; | 228 | return c; |
229 | } | 229 | } |
230 | 230 | ||
231 | static QChar identicalMap(QChar c) | 231 | static QChar identicalMap(QChar c) |
232 | { | 232 | { |
233 | return c; | 233 | return c; |
234 | } | 234 | } |
235 | 235 | ||
236 | void TEWidget::fontChange(const QFont &) | 236 | void TEWidget::fontChange(const QFont &) |
237 | { | 237 | { |
238 | QFontMetrics fm(font()); | 238 | QFontMetrics fm(font()); |
239 | font_h = fm.height(); | 239 | font_h = fm.height(); |
240 | font_w = fm.maxWidth(); | 240 | font_w = fm.maxWidth(); |
241 | font_a = fm.ascent(); | 241 | font_a = fm.ascent(); |
242 | //printf("font_h: %d\n",font_h); | 242 | //printf("font_h: %d\n",font_h); |
243 | //printf("font_w: %d\n",font_w); | 243 | //printf("font_w: %d\n",font_w); |
244 | //printf("font_a: %d\n",font_a); | 244 | //printf("font_a: %d\n",font_a); |
245 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); | 245 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); |
246 | //printf("rawname: %s\n",font().rawName().ascii()); | 246 | //printf("rawname: %s\n",font().rawName().ascii()); |
247 | fontMap = | 247 | fontMap = |
248 | #if QT_VERSION < 300 | 248 | #if QT_VERSION < 300 |
249 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") | 249 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") |
250 | ? vt100extended | 250 | ? vt100extended |
251 | : | 251 | : |
252 | #endif | 252 | #endif |
253 | identicalMap; | 253 | identicalMap; |
254 | propagateSize(); | 254 | propagateSize(); |
255 | update(); | 255 | update(); |
256 | } | 256 | } |
257 | 257 | ||
258 | void TEWidget::setVTFont(const QFont& f) | 258 | void TEWidget::setVTFont(const QFont& f) |
259 | { | 259 | { |
260 | QFrame::setFont(f); | 260 | QFrame::setFont(f); |
261 | } | 261 | } |
262 | 262 | ||
263 | QFont TEWidget::getVTFont() { | 263 | QFont TEWidget::getVTFont() { |
264 | return font(); | 264 | return font(); |
265 | } | 265 | } |
266 | 266 | ||
267 | void TEWidget::setFont(const QFont &) | 267 | void TEWidget::setFont(const QFont &) |
268 | { | 268 | { |
269 | // ignore font change request if not coming from konsole itself | 269 | // ignore font change request if not coming from konsole itself |
270 | } | 270 | } |
271 | 271 | ||
272 | /* ------------------------------------------------------------------------- */ | 272 | /* ------------------------------------------------------------------------- */ |
273 | /* */ | 273 | /* */ |
274 | /* Constructor / Destructor */ | 274 | /* Constructor / Destructor */ |
275 | /* */ | 275 | /* */ |
276 | /* ------------------------------------------------------------------------- */ | 276 | /* ------------------------------------------------------------------------- */ |
277 | 277 | ||
278 | TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) | 278 | TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) |
279 | { | 279 | { |
280 | #ifndef QT_NO_CLIPBOARD | 280 | #ifndef QT_NO_CLIPBOARD |
281 | cb = QApplication::clipboard(); | 281 | cb = QApplication::clipboard(); |
282 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 282 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
283 | this, SLOT(onClearSelection()) ); | 283 | this, SLOT(onClearSelection()) ); |
284 | #endif | 284 | #endif |
285 | 285 | ||
286 | scrollbar = new QScrollBar(this); | 286 | scrollbar = new QScrollBar(this); |
287 | scrollbar->setCursor( arrowCursor ); | 287 | scrollbar->setCursor( arrowCursor ); |
288 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 288 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
289 | 289 | ||
290 | Config cfg("Konsole"); | 290 | Config cfg("Konsole"); |
291 | cfg.setGroup("ScrollBar"); | 291 | cfg.setGroup("ScrollBar"); |
292 | switch( cfg.readNumEntry("Position",2)){ | 292 | switch( cfg.readNumEntry("Position",2)){ |
293 | case 0: | 293 | case 0: |
294 | scrollLoc = SCRNONE; | 294 | scrollLoc = SCRNONE; |
295 | break; | 295 | break; |
296 | case 1: | 296 | case 1: |
297 | scrollLoc = SCRLEFT; | 297 | scrollLoc = SCRLEFT; |
298 | break; | 298 | break; |
299 | case 2: | 299 | case 2: |
300 | scrollLoc = SCRRIGHT; | 300 | scrollLoc = SCRRIGHT; |
301 | break; | 301 | break; |
302 | }; | 302 | }; |
303 | 303 | ||
304 | blinkT = new QTimer(this); | 304 | blinkT = new QTimer(this); |
305 | connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); | 305 | connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); |
306 | // blinking = FALSE; | 306 | // blinking = FALSE; |
307 | blinking = TRUE; | 307 | blinking = TRUE; |
308 | 308 | ||
309 | resizing = FALSE; | 309 | resizing = FALSE; |
310 | actSel = 0; | 310 | actSel = 0; |
311 | image = 0; | 311 | image = 0; |
312 | lines = 1; | 312 | lines = 1; |
313 | columns = 1; | 313 | columns = 1; |
314 | font_w = 1; | 314 | font_w = 1; |
315 | font_h = 1; | 315 | font_h = 1; |
316 | font_a = 1; | 316 | font_a = 1; |
317 | word_selection_mode = FALSE; | 317 | word_selection_mode = FALSE; |
318 | 318 | ||
319 | setMouseMarks(TRUE); | 319 | setMouseMarks(TRUE); |
320 | setVTFont( QFont("fixed") ); | 320 | setVTFont( QFont("fixed") ); |
321 | setColorTable(base_color_table); // init color table | 321 | setColorTable(base_color_table); // init color table |
322 | 322 | ||
323 | qApp->installEventFilter( this ); //FIXME: see below | 323 | qApp->installEventFilter( this ); //FIXME: see below |
324 | // KCursor::setAutoHideCursor( this, true ); | 324 | // KCursor::setAutoHideCursor( this, true ); |
325 | 325 | ||
326 | // Init DnD //////////////////////////////////////////////////////////////// | 326 | // Init DnD //////////////////////////////////////////////////////////////// |
327 | currentSession = NULL; | 327 | currentSession = NULL; |
328 | // setAcceptDrops(true); // attempt | 328 | // setAcceptDrops(true); // attempt |
329 | // m_drop = new QPopupMenu(this); | 329 | // m_drop = new QPopupMenu(this); |
330 | // m_drop->insertItem( QString("Paste"), 0); | 330 | // m_drop->insertItem( QString("Paste"), 0); |
331 | // m_drop->insertItem( QString("cd"), 1); | 331 | // m_drop->insertItem( QString("cd"), 1); |
332 | // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); | 332 | // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); |
333 | 333 | ||
334 | // we need focus so that the auto-hide cursor feature works | 334 | // we need focus so that the auto-hide cursor feature works |
335 | setFocus(); | 335 | setFocus(); |
336 | setFocusPolicy( WheelFocus ); | 336 | setFocusPolicy( WheelFocus ); |
337 | } | 337 | } |
338 | 338 | ||
339 | //FIXME: make proper destructor | 339 | //FIXME: make proper destructor |
340 | // Here's a start (David) | 340 | // Here's a start (David) |
341 | TEWidget::~TEWidget() | 341 | TEWidget::~TEWidget() |
342 | { | 342 | { |
343 | qApp->removeEventFilter( this ); | 343 | qApp->removeEventFilter( this ); |
344 | if (image) free(image); | 344 | if (image) free(image); |
345 | } | 345 | } |
346 | 346 | ||
347 | /* ------------------------------------------------------------------------- */ | 347 | /* ------------------------------------------------------------------------- */ |
348 | /* */ | 348 | /* */ |
349 | /* Display Operations */ | 349 | /* Display Operations */ |
350 | /* */ | 350 | /* */ |
351 | /* ------------------------------------------------------------------------- */ | 351 | /* ------------------------------------------------------------------------- */ |
352 | 352 | ||
353 | /*! | 353 | /*! |
354 | attributed string draw primitive | 354 | attributed string draw primitive |
355 | */ | 355 | */ |
356 | 356 | ||
357 | void TEWidget::drawAttrStr(QPainter &paint, QRect rect, | 357 | void TEWidget::drawAttrStr(QPainter &paint, QRect rect, |
358 | QString& str, ca attr, BOOL pm, BOOL clear) | 358 | QString& str, ca attr, BOOL pm, BOOL clear) |
359 | { | 359 | { |
360 | if (pm && color_table[attr.b].transparent) | 360 | if (pm && color_table[attr.b].transparent) |
361 | { | 361 | { |
362 | paint.setBackgroundMode( TransparentMode ); | 362 | paint.setBackgroundMode( TransparentMode ); |
363 | if (clear) erase(rect); | 363 | if (clear) erase(rect); |
364 | } | 364 | } |
365 | else | 365 | else |
366 | { | 366 | { |
367 | if (blinking) | 367 | if (blinking) |
368 | paint.fillRect(rect, color_table[attr.b].color); | 368 | paint.fillRect(rect, color_table[attr.b].color); |
369 | else | 369 | else |
370 | { | 370 | { |
371 | paint.setBackgroundMode( OpaqueMode ); | 371 | paint.setBackgroundMode( OpaqueMode ); |
372 | paint.setBackgroundColor( color_table[attr.b].color ); | 372 | paint.setBackgroundColor( color_table[attr.b].color ); |
373 | } | 373 | } |
374 | } | 374 | } |
375 | 375 | ||
376 | if (color_table[attr.f].bold) | 376 | if (color_table[attr.f].bold) |
377 | paint.setPen(QColor( 0x8F, 0x00, 0x00 )); | 377 | paint.setPen(QColor( 0x8F, 0x00, 0x00 )); |
378 | else | 378 | else |
379 | paint.setPen(color_table[attr.f].color); | 379 | paint.setPen(color_table[attr.f].color); |
380 | 380 | ||
381 | paint.drawText(rect.x(),rect.y()+font_a, str); | 381 | paint.drawText(rect.x(),rect.y()+font_a, str); |
382 | 382 | ||
383 | if (attr.r & RE_UNDERLINE) | 383 | if (attr.r & RE_UNDERLINE) |
384 | paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); | 384 | paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); |
385 | } | 385 | } |
386 | 386 | ||
387 | /*! | 387 | /*! |
388 | The image can only be set completely. | 388 | The image can only be set completely. |
389 | 389 | ||
390 | The size of the new image may or may not match the size of the widget. | 390 | The size of the new image may or may not match the size of the widget. |
391 | */ | 391 | */ |
392 | 392 | ||
393 | void TEWidget::setImage(const ca* const newimg, int lines, int columns) | 393 | void TEWidget::setImage(const ca* const newimg, int lines, int columns) |
394 | { int y,x,len; | 394 | { int y,x,len; |
395 | const QPixmap* pm = backgroundPixmap(); | 395 | const QPixmap* pm = backgroundPixmap(); |
396 | QPainter paint; | 396 | QPainter paint; |
397 | setUpdatesEnabled(FALSE); | 397 | setUpdatesEnabled(FALSE); |
398 | paint.begin( this ); | 398 | paint.begin( this ); |
399 | HCNT("setImage"); | 399 | HCNT("setImage"); |
400 | 400 | ||
401 | QPoint tL = contentsRect().topLeft(); | 401 | QPoint tL = contentsRect().topLeft(); |
402 | int tLx = tL.x(); | 402 | int tLx = tL.x(); |
403 | int tLy = tL.y(); | 403 | int tLy = tL.y(); |
404 | hasBlinker = FALSE; | 404 | hasBlinker = FALSE; |
405 | 405 | ||
406 | int cf = -1; // undefined | 406 | int cf = -1; // undefined |
407 | int cb = -1; // undefined | 407 | int cb = -1; // undefined |
408 | int cr = -1; // undefined | 408 | int cr = -1; // undefined |
409 | 409 | ||
410 | int lins = QMIN(this->lines, QMAX(0,lines )); | 410 | int lins = QMIN(this->lines, QMAX(0,lines )); |
411 | int cols = QMIN(this->columns,QMAX(0,columns)); | 411 | int cols = QMIN(this->columns,QMAX(0,columns)); |
412 | QChar *disstrU = new QChar[cols]; | 412 | QChar *disstrU = new QChar[cols]; |
413 | 413 | ||
414 | //{ static int cnt = 0; printf("setImage %d\n",cnt++); } | 414 | //{ static int cnt = 0; printf("setImage %d\n",cnt++); } |
415 | for (y = 0; y < lins; y++) | 415 | for (y = 0; y < lins; y++) |
416 | { | 416 | { |
417 | const ca* lcl = &image[y*this->columns]; | 417 | const ca* lcl = &image[y*this->columns]; |
418 | const ca* const ext = &newimg[y*columns]; | 418 | const ca* const ext = &newimg[y*columns]; |
419 | if (!resizing) // not while resizing, we're expecting a paintEvent | 419 | if (!resizing) // not while resizing, we're expecting a paintEvent |
420 | for (x = 0; x < cols; x++) | 420 | for (x = 0; x < cols; x++) |
421 | { | 421 | { |
422 | hasBlinker |= (ext[x].r & RE_BLINK); | 422 | hasBlinker |= (ext[x].r & RE_BLINK); |
423 | if (ext[x] != lcl[x]) | 423 | if (ext[x] != lcl[x]) |
424 | { | 424 | { |
425 | cr = ext[x].r; | 425 | cr = ext[x].r; |
426 | cb = ext[x].b; | 426 | cb = ext[x].b; |
427 | if (ext[x].f != cf) cf = ext[x].f; | 427 | if (ext[x].f != cf) cf = ext[x].f; |
428 | int lln = cols - x; | 428 | int lln = cols - x; |
429 | disstrU[0] = fontMap(ext[x+0].c); | 429 | disstrU[0] = fontMap(ext[x+0].c); |
430 | for (len = 1; len < lln; len++) | 430 | for (len = 1; len < lln; len++) |
431 | { | 431 | { |
432 | if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || | 432 | if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || |
433 | ext[x+len] == lcl[x+len] ) | 433 | ext[x+len] == lcl[x+len] ) |
434 | break; | 434 | break; |
435 | disstrU[len] = fontMap(ext[x+len].c); | 435 | disstrU[len] = fontMap(ext[x+len].c); |
436 | } | 436 | } |
437 | QString unistr(disstrU,len); | 437 | QString unistr(disstrU,len); |
438 | drawAttrStr(paint, | 438 | drawAttrStr(paint, |
439 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), | 439 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), |
440 | unistr, ext[x], pm != NULL, true); | 440 | unistr, ext[x], pm != NULL, true); |
441 | x += len - 1; | 441 | x += len - 1; |
442 | } | 442 | } |
443 | } | 443 | } |
444 | // finally, make `image' become `newimg'. | 444 | // finally, make `image' become `newimg'. |
445 | memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca)); | 445 | memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca)); |
446 | } | 446 | } |
447 | drawFrame( &paint ); | 447 | drawFrame( &paint ); |
448 | paint.end(); | 448 | paint.end(); |
449 | setUpdatesEnabled(TRUE); | 449 | setUpdatesEnabled(TRUE); |
450 | if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms | 450 | if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms |
451 | if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } | 451 | if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } |
452 | delete [] disstrU; | 452 | delete [] disstrU; |
453 | } | 453 | } |
454 | 454 | ||
455 | // paint Event //////////////////////////////////////////////////// | 455 | // paint Event //////////////////////////////////////////////////// |
456 | 456 | ||
457 | /*! | 457 | /*! |
458 | The difference of this routine vs. the `setImage' is, | 458 | The difference of this routine vs. the `setImage' is, |
459 | that the drawing does not include a difference analysis | 459 | that the drawing does not include a difference analysis |
460 | between the old and the new image. Instead, the internal | 460 | between the old and the new image. Instead, the internal |
461 | image is used and the painting bound by the PaintEvent box. | 461 | image is used and the painting bound by the PaintEvent box. |
462 | */ | 462 | */ |
463 | 463 | ||
464 | void TEWidget::paintEvent( QPaintEvent* pe ) | 464 | void TEWidget::paintEvent( QPaintEvent* pe ) |
465 | { | 465 | { |
466 | 466 | ||
467 | //{ static int cnt = 0; printf("paint %d\n",cnt++); } | 467 | //{ static int cnt = 0; printf("paint %d\n",cnt++); } |
468 | const QPixmap* pm = backgroundPixmap(); | 468 | const QPixmap* pm = backgroundPixmap(); |
469 | QPainter paint; | 469 | QPainter paint; |
470 | setUpdatesEnabled(FALSE); | 470 | setUpdatesEnabled(FALSE); |
471 | paint.begin( this ); | 471 | paint.begin( this ); |
472 | paint.setBackgroundMode( TransparentMode ); | 472 | paint.setBackgroundMode( TransparentMode ); |
473 | HCNT("paintEvent"); | 473 | HCNT("paintEvent"); |
474 | 474 | ||
475 | // Note that the actual widget size can be slightly larger | 475 | // Note that the actual widget size can be slightly larger |
476 | // that the image (the size is truncated towards the smaller | 476 | // that the image (the size is truncated towards the smaller |
477 | // number of characters in `resizeEvent'. The paint rectangle | 477 | // number of characters in `resizeEvent'. The paint rectangle |
478 | // can thus be larger than the image, but less then the size | 478 | // can thus be larger than the image, but less then the size |
479 | // of one character. | 479 | // of one character. |
480 | 480 | ||
481 | QRect rect = pe->rect().intersect(contentsRect()); | 481 | QRect rect = pe->rect().intersect(contentsRect()); |
482 | 482 | ||
483 | QPoint tL = contentsRect().topLeft(); | 483 | QPoint tL = contentsRect().topLeft(); |
484 | int tLx = tL.x(); | 484 | int tLx = tL.x(); |
485 | int tLy = tL.y(); | 485 | int tLy = tL.y(); |
486 | 486 | ||
487 | int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); | 487 | int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); |
488 | int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); | 488 | int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); |
489 | int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); | 489 | int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); |
490 | int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); | 490 | int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); |
491 | 491 | ||
492 | /* | 492 | /* |
493 | printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, | 493 | printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, |
494 | rect.left(), rect.right(), rect.top(), rect.bottom()); | 494 | rect.left(), rect.right(), rect.top(), rect.bottom()); |
495 | */ | 495 | */ |
496 | 496 | ||
497 | // if (pm != NULL && color_table[image->b].transparent) | 497 | // if (pm != NULL && color_table[image->b].transparent) |
498 | // erase(rect); | 498 | // erase(rect); |
499 | // BL: I have no idea why we need this, and it breaks the refresh. | 499 | // BL: I have no idea why we need this, and it breaks the refresh. |
500 | 500 | ||
501 | QChar *disstrU = new QChar[columns]; | 501 | QChar *disstrU = new QChar[columns]; |
502 | for (int y = luy; y <= rly; y++) | 502 | for (int y = luy; y <= rly; y++) |
503 | for (int x = lux; x <= rlx; x++) | 503 | for (int x = lux; x <= rlx; x++) |
504 | { | 504 | { |
505 | int len = 1; | 505 | int len = 1; |
506 | disstrU[0] = fontMap(image[loc(x,y)].c); | 506 | disstrU[0] = fontMap(image[loc(x,y)].c); |
507 | int cf = image[loc(x,y)].f; | 507 | int cf = image[loc(x,y)].f; |
508 | int cb = image[loc(x,y)].b; | 508 | int cb = image[loc(x,y)].b; |
509 | int cr = image[loc(x,y)].r; | 509 | int cr = image[loc(x,y)].r; |
510 | while (x+len <= rlx && | 510 | while (x+len <= rlx && |
511 | image[loc(x+len,y)].f == cf && | 511 | image[loc(x+len,y)].f == cf && |
512 | image[loc(x+len,y)].b == cb && | 512 | image[loc(x+len,y)].b == cb && |
513 | image[loc(x+len,y)].r == cr ) | 513 | image[loc(x+len,y)].r == cr ) |
514 | { | 514 | { |
515 | disstrU[len] = fontMap(image[loc(x+len,y)].c); | 515 | disstrU[len] = fontMap(image[loc(x+len,y)].c); |
516 | len += 1; | 516 | len += 1; |
517 | } | 517 | } |
518 | QString unistr(disstrU,len); | 518 | QString unistr(disstrU,len); |
519 | drawAttrStr(paint, | 519 | drawAttrStr(paint, |
520 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), | 520 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), |
521 | unistr, image[loc(x,y)], pm != NULL, false); | 521 | unistr, image[loc(x,y)], pm != NULL, false); |
522 | x += len - 1; | 522 | x += len - 1; |
523 | } | 523 | } |
524 | delete [] disstrU; | 524 | delete [] disstrU; |
525 | drawFrame( &paint ); | 525 | drawFrame( &paint ); |
526 | paint.end(); | 526 | paint.end(); |
527 | setUpdatesEnabled(TRUE); | 527 | setUpdatesEnabled(TRUE); |
528 | } | 528 | } |
529 | 529 | ||
530 | void TEWidget::blinkEvent() | 530 | void TEWidget::blinkEvent() |
531 | { | 531 | { |
532 | blinking = !blinking; | 532 | blinking = !blinking; |
533 | repaint(FALSE); | 533 | repaint(FALSE); |
534 | } | 534 | } |
535 | 535 | ||
536 | /* ------------------------------------------------------------------------- */ | 536 | /* ------------------------------------------------------------------------- */ |
537 | /* */ | 537 | /* */ |
538 | /* Resizing */ | 538 | /* Resizing */ |
539 | /* */ | 539 | /* */ |
540 | /* ------------------------------------------------------------------------- */ | 540 | /* ------------------------------------------------------------------------- */ |
541 | 541 | ||
542 | void TEWidget::resizeEvent(QResizeEvent* ev) | 542 | void TEWidget::resizeEvent(QResizeEvent* ev) |
543 | { | 543 | { |
544 | //printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); | 544 | // printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); |
545 | //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h); | 545 | //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h); |
546 | //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h); | 546 | //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h); |
547 | //printf("curren: %d,%d\n",width(),height()); | 547 | //printf("curren: %d,%d\n",width(),height()); |
548 | HCNT("resizeEvent"); | 548 | HCNT("resizeEvent"); |
549 | 549 | ||
550 | // see comment in `paintEvent' concerning the rounding. | 550 | // see comment in `paintEvent' concerning the rounding. |
551 | //FIXME: could make a routine here; check width(),height() | 551 | //FIXME: could make a routine here; check width(),height() |
552 | assert(ev->size().width() == width()); | 552 | assert(ev->size().width() == width()); |
553 | assert(ev->size().height() == height()); | 553 | assert(ev->size().height() == height()); |
554 | 554 | ||
555 | propagateSize(); | 555 | propagateSize(); |
556 | } | 556 | } |
557 | 557 | ||
558 | void TEWidget::propagateSize() | 558 | void TEWidget::propagateSize() |
559 | { | 559 | { |
560 | ca* oldimg = image; | 560 | ca* oldimg = image; |
561 | int oldlin = lines; | 561 | int oldlin = lines; |
562 | int oldcol = columns; | 562 | int oldcol = columns; |
563 | makeImage(); | 563 | makeImage(); |
564 | // we copy the old image to reduce flicker | 564 | // we copy the old image to reduce flicker |
565 | int lins = QMIN(oldlin,lines); | 565 | int lins = QMIN(oldlin,lines); |
566 | int cols = QMIN(oldcol,columns); | 566 | int cols = QMIN(oldcol,columns); |
567 | if (oldimg) | 567 | if (oldimg) |
568 | { | 568 | { |
569 | for (int lin = 0; lin < lins; lin++) | 569 | for (int lin = 0; lin < lins; lin++) |
570 | memcpy((void*)&image[columns*lin], | 570 | memcpy((void*)&image[columns*lin], |
571 | (void*)&oldimg[oldcol*lin],cols*sizeof(ca)); | 571 | (void*)&oldimg[oldcol*lin],cols*sizeof(ca)); |
572 | free(oldimg); //FIXME: try new,delete | 572 | free(oldimg); //FIXME: try new,delete |
573 | } | 573 | } |
574 | else | 574 | else |
575 | clearImage(); | 575 | clearImage(); |
576 | 576 | ||
577 | //NOTE: control flows from the back through the chest right into the eye. | 577 | //NOTE: control flows from the back through the chest right into the eye. |
578 | // `emu' will call back via `setImage'. | 578 | // `emu' will call back via `setImage'. |
579 | 579 | ||
580 | resizing = TRUE; | 580 | resizing = TRUE; |
581 | emit changedImageSizeSignal(lines, columns); // expose resizeEvent | 581 | emit changedImageSizeSignal(lines, columns); // expose resizeEvent |
582 | resizing = FALSE; | 582 | resizing = FALSE; |
583 | } | 583 | } |
584 | 584 | ||
585 | /* ------------------------------------------------------------------------- */ | 585 | /* ------------------------------------------------------------------------- */ |
586 | /* */ | 586 | /* */ |
587 | /* Scrollbar */ | 587 | /* Scrollbar */ |
588 | /* */ | 588 | /* */ |
589 | /* ------------------------------------------------------------------------- */ | 589 | /* ------------------------------------------------------------------------- */ |
590 | 590 | ||
591 | void TEWidget::scrollChanged(int) | 591 | void TEWidget::scrollChanged(int) |
592 | { | 592 | { |
593 | emit changedHistoryCursor(scrollbar->value()); //expose | 593 | emit changedHistoryCursor(scrollbar->value()); //expose |
594 | } | 594 | } |
595 | 595 | ||
596 | void TEWidget::setScroll(int cursor, int slines) | 596 | void TEWidget::setScroll(int cursor, int slines) |
597 | { | 597 | { |
598 | disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 598 | disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
599 | scrollbar->setRange(0,slines); | 599 | scrollbar->setRange(0,slines); |
600 | scrollbar->setSteps(1,lines); | 600 | scrollbar->setSteps(1,lines); |
601 | scrollbar->setValue(cursor); | 601 | scrollbar->setValue(cursor); |
602 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 602 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
603 | } | 603 | } |
604 | 604 | ||
605 | void TEWidget::setScrollbarLocation(int loc) | 605 | void TEWidget::setScrollbarLocation(int loc) |
606 | { | 606 | { |
607 | if (scrollLoc == loc) return; // quickly | 607 | if (scrollLoc == loc) return; // quickly |
608 | scrollLoc = loc; | 608 | scrollLoc = loc; |
609 | propagateSize(); | 609 | propagateSize(); |
610 | update(); | 610 | update(); |
611 | } | 611 | } |
612 | 612 | ||
613 | /* ------------------------------------------------------------------------- */ | 613 | /* ------------------------------------------------------------------------- */ |
614 | /* */ | 614 | /* */ |
615 | /* Mouse */ | 615 | /* Mouse */ |
616 | /* */ | 616 | /* */ |
617 | /* ------------------------------------------------------------------------- */ | 617 | /* ------------------------------------------------------------------------- */ |
618 | 618 | ||
619 | /*! | 619 | /*! |
620 | Three different operations can be performed using the mouse, and the | 620 | Three different operations can be performed using the mouse, and the |
621 | routines in this section serve all of them: | 621 | routines in this section serve all of them: |
622 | 622 | ||
623 | 1) The press/release events are exposed to the application | 623 | 1) The press/release events are exposed to the application |
624 | 2) Marking (press and move left button) and Pasting (press middle button) | 624 | 2) Marking (press and move left button) and Pasting (press middle button) |
625 | 3) The right mouse button is used from the configuration menu | 625 | 3) The right mouse button is used from the configuration menu |
626 | 626 | ||
627 | NOTE: During the marking process we attempt to keep the cursor within | 627 | NOTE: During the marking process we attempt to keep the cursor within |
628 | the bounds of the text as being displayed by setting the mouse position | 628 | the bounds of the text as being displayed by setting the mouse position |
629 | whenever the mouse has left the text area. | 629 | whenever the mouse has left the text area. |
630 | 630 | ||
631 | Two reasons to do so: | 631 | Two reasons to do so: |
632 | 1) QT does not allow the `grabMouse' to confine-to the TEWidget. | 632 | 1) QT does not allow the `grabMouse' to confine-to the TEWidget. |
633 | Thus a `XGrapPointer' would have to be used instead. | 633 | Thus a `XGrapPointer' would have to be used instead. |
634 | 2) Even if so, this would not help too much, since the text area | 634 | 2) Even if so, this would not help too much, since the text area |
635 | of the TEWidget is normally not identical with it's bounds. | 635 | of the TEWidget is normally not identical with it's bounds. |
636 | 636 | ||
637 | The disadvantage of the current handling is, that the mouse can visibly | 637 | The disadvantage of the current handling is, that the mouse can visibly |
638 | leave the bounds of the widget and is then moved back. Because of the | 638 | leave the bounds of the widget and is then moved back. Because of the |
639 | current construction, and the reasons mentioned above, we cannot do better | 639 | current construction, and the reasons mentioned above, we cannot do better |
640 | without changing the overall construction. | 640 | without changing the overall construction. |
641 | */ | 641 | */ |
642 | 642 | ||
643 | /*! | 643 | /*! |
644 | */ | 644 | */ |
645 | 645 | ||
646 | void TEWidget::mousePressEvent(QMouseEvent* ev) | 646 | void TEWidget::mousePressEvent(QMouseEvent* ev) |
647 | { | 647 | { |
648 | //printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | 648 | //printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); |
649 | if ( !contentsRect().contains(ev->pos()) ) return; | 649 | if ( !contentsRect().contains(ev->pos()) ) return; |
650 | QPoint tL = contentsRect().topLeft(); | 650 | QPoint tL = contentsRect().topLeft(); |
651 | int tLx = tL.x(); | 651 | int tLx = tL.x(); |
652 | int tLy = tL.y(); | 652 | int tLy = tL.y(); |
653 | 653 | ||
654 | word_selection_mode = FALSE; | 654 | word_selection_mode = FALSE; |
655 | 655 | ||
656 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); | 656 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); |
657 | if ( ev->button() == LeftButton) | 657 | if ( ev->button() == LeftButton) |
658 | { | 658 | { |
659 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 659 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
660 | 660 | ||
661 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; | 661 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; |
662 | 662 | ||
663 | if (mouse_marks || (ev->state() & ShiftButton)) | 663 | if (mouse_marks || (ev->state() & ShiftButton)) |
664 | { | 664 | { |
665 | emit clearSelectionSignal(); | 665 | emit clearSelectionSignal(); |
666 | iPntSel = pntSel = pos; | 666 | iPntSel = pntSel = pos; |
667 | actSel = 1; // left mouse button pressed but nothing selected yet. | 667 | actSel = 1; // left mouse button pressed but nothing selected yet. |
668 | grabMouse( /*crossCursor*/ ); // handle with care! | 668 | grabMouse( /*crossCursor*/ ); // handle with care! |
669 | } | 669 | } |
670 | else | 670 | else |
671 | { | 671 | { |
672 | emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button | 672 | emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button |
673 | } | 673 | } |
674 | } | 674 | } |
675 | if ( ev->button() == MidButton ) | 675 | if ( ev->button() == MidButton ) |
676 | { | 676 | { |
677 | emitSelection(); | 677 | emitSelection(); |
678 | } | 678 | } |
679 | if ( ev->button() == RightButton ) // Configure | 679 | if ( ev->button() == RightButton ) // Configure |
680 | { | 680 | { |
681 | emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); | 681 | emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); |
682 | } | 682 | } |
683 | } | 683 | } |
684 | 684 | ||
685 | void TEWidget::mouseMoveEvent(QMouseEvent* ev) | 685 | void TEWidget::mouseMoveEvent(QMouseEvent* ev) |
686 | { | 686 | { |
687 | // for auto-hiding the cursor, we need mouseTracking | 687 | // for auto-hiding the cursor, we need mouseTracking |
688 | if (ev->state() == NoButton ) return; | 688 | if (ev->state() == NoButton ) return; |
689 | 689 | ||
690 | if (actSel == 0) return; | 690 | if (actSel == 0) return; |
691 | 691 | ||
692 | // don't extend selection while pasting | 692 | // don't extend selection while pasting |
693 | if (ev->state() & MidButton) return; | 693 | if (ev->state() & MidButton) return; |
694 | 694 | ||
695 | //if ( !contentsRect().contains(ev->pos()) ) return; | 695 | //if ( !contentsRect().contains(ev->pos()) ) return; |
696 | QPoint tL = contentsRect().topLeft(); | 696 | QPoint tL = contentsRect().topLeft(); |
697 | int tLx = tL.x(); | 697 | int tLx = tL.x(); |
698 | int tLy = tL.y(); | 698 | int tLy = tL.y(); |
699 | int scroll = scrollbar->value(); | 699 | int scroll = scrollbar->value(); |
700 | 700 | ||
701 | // we're in the process of moving the mouse with the left button pressed | 701 | // we're in the process of moving the mouse with the left button pressed |
702 | // the mouse cursor will kept catched within the bounds of the text in | 702 | // the mouse cursor will kept catched within the bounds of the text in |
703 | // this widget. | 703 | // this widget. |
704 | 704 | ||
705 | // Adjust position within text area bounds. See FIXME above. | 705 | // Adjust position within text area bounds. See FIXME above. |
706 | QPoint pos = ev->pos(); | 706 | QPoint pos = ev->pos(); |
707 | if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); | 707 | if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); |
708 | if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); | 708 | if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); |
709 | if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); | 709 | if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); |
710 | if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); | 710 | if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); |
711 | // check if we produce a mouse move event by this | 711 | // check if we produce a mouse move event by this |
712 | if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); | 712 | if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); |
713 | 713 | ||
714 | if ( pos.y() == tLy+bY+lines*font_h-1 ) | 714 | if ( pos.y() == tLy+bY+lines*font_h-1 ) |
715 | { | 715 | { |
716 | scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward | 716 | scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward |
717 | } | 717 | } |
718 | if ( pos.y() == tLy+bY ) | 718 | if ( pos.y() == tLy+bY ) |
719 | { | 719 | { |
720 | scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback | 720 | scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback |
721 | } | 721 | } |
722 | 722 | ||
723 | QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); | 723 | QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); |
724 | QPoint ohere; | 724 | QPoint ohere; |
725 | bool swapping = FALSE; | 725 | bool swapping = FALSE; |
726 | 726 | ||
727 | if ( word_selection_mode ) | 727 | if ( word_selection_mode ) |
728 | { | 728 | { |
729 | // Extend to word boundaries | 729 | // Extend to word boundaries |
730 | int i; | 730 | int i; |
731 | int selClass; | 731 | int selClass; |
732 | 732 | ||
733 | bool left_not_right = ( here.y() < iPntSel.y() || | 733 | bool left_not_right = ( here.y() < iPntSel.y() || |
734 | here.y() == iPntSel.y() && here.x() < iPntSel.x() ); | 734 | here.y() == iPntSel.y() && here.x() < iPntSel.x() ); |
735 | bool old_left_not_right = ( pntSel.y() < iPntSel.y() || | 735 | bool old_left_not_right = ( pntSel.y() < iPntSel.y() || |
736 | pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); | 736 | pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); |
737 | swapping = left_not_right != old_left_not_right; | 737 | swapping = left_not_right != old_left_not_right; |
738 | 738 | ||
739 | // Find left (left_not_right ? from here : from start) | 739 | // Find left (left_not_right ? from here : from start) |
740 | QPoint left = left_not_right ? here : iPntSel; | 740 | QPoint left = left_not_right ? here : iPntSel; |
741 | i = loc(left.x(),left.y()); | 741 | i = loc(left.x(),left.y()); |
742 | selClass = charClass(image[i].c); | 742 | selClass = charClass(image[i].c); |
743 | while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) | 743 | while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) |
744 | { i--; left.rx()--; } | 744 | { i--; left.rx()--; } |
745 | 745 | ||
746 | // Find left (left_not_right ? from start : from here) | 746 | // Find left (left_not_right ? from start : from here) |
747 | QPoint right = left_not_right ? iPntSel : here; | 747 | QPoint right = left_not_right ? iPntSel : here; |
748 | i = loc(right.x(),right.y()); | 748 | i = loc(right.x(),right.y()); |
749 | selClass = charClass(image[i].c); | 749 | selClass = charClass(image[i].c); |
750 | while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) | 750 | while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) |
751 | { i++; right.rx()++; } | 751 | { i++; right.rx()++; } |
752 | 752 | ||
753 | // Pick which is start (ohere) and which is extension (here) | 753 | // Pick which is start (ohere) and which is extension (here) |
754 | if ( left_not_right ) | 754 | if ( left_not_right ) |
755 | { | 755 | { |
756 | here = left; ohere = right; | 756 | here = left; ohere = right; |
757 | } | 757 | } |
758 | else | 758 | else |
759 | { | 759 | { |
760 | here = right; ohere = left; | 760 | here = right; ohere = left; |
761 | } | 761 | } |
762 | } | 762 | } |
763 | 763 | ||
764 | if (here == pntSel && scroll == scrollbar->value()) return; // not moved | 764 | if (here == pntSel && scroll == scrollbar->value()) return; // not moved |
765 | 765 | ||
766 | if ( word_selection_mode ) { | 766 | if ( word_selection_mode ) { |
767 | if ( actSel < 2 || swapping ) { | 767 | if ( actSel < 2 || swapping ) { |
768 | emit beginSelectionSignal( ohere.x(), ohere.y() ); | 768 | emit beginSelectionSignal( ohere.x(), ohere.y() ); |
769 | } | 769 | } |
770 | } else if ( actSel < 2 ) { | 770 | } else if ( actSel < 2 ) { |
771 | emit beginSelectionSignal( pntSel.x(), pntSel.y() ); | 771 | emit beginSelectionSignal( pntSel.x(), pntSel.y() ); |
772 | } | 772 | } |
773 | 773 | ||
774 | actSel = 2; // within selection | 774 | actSel = 2; // within selection |
775 | pntSel = here; | 775 | pntSel = here; |
776 | emit extendSelectionSignal( here.x(), here.y() ); | 776 | emit extendSelectionSignal( here.x(), here.y() ); |
777 | } | 777 | } |
778 | 778 | ||
779 | void TEWidget::mouseReleaseEvent(QMouseEvent* ev) | 779 | void TEWidget::mouseReleaseEvent(QMouseEvent* ev) |
780 | { | 780 | { |
781 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | 781 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); |
782 | if ( ev->button() == LeftButton) | 782 | if ( ev->button() == LeftButton) |
783 | { | 783 | { |
784 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); | 784 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); |
785 | preserve_line_breaks = TRUE; | 785 | preserve_line_breaks = TRUE; |
786 | actSel = 0; | 786 | actSel = 0; |
787 | 787 | ||
788 | //FIXME: emits a release event even if the mouse is | 788 | //FIXME: emits a release event even if the mouse is |
789 | // outside the range. The procedure used in `mouseMoveEvent' | 789 | // outside the range. The procedure used in `mouseMoveEvent' |
790 | // applies here, too. | 790 | // applies here, too. |
791 | 791 | ||
792 | QPoint tL = contentsRect().topLeft(); | 792 | QPoint tL = contentsRect().topLeft(); |
793 | int tLx = tL.x(); | 793 | int tLx = tL.x(); |
794 | int tLy = tL.y(); | 794 | int tLy = tL.y(); |
795 | 795 | ||
796 | if (!mouse_marks && !(ev->state() & ShiftButton)) | 796 | if (!mouse_marks && !(ev->state() & ShiftButton)) |
797 | emit mouseSignal( 3, // release | 797 | emit mouseSignal( 3, // release |
798 | (ev->x()-tLx-blX)/font_w + 1, | 798 | (ev->x()-tLx-blX)/font_w + 1, |
799 | (ev->y()-tLy-bY)/font_h + 1 ); | 799 | (ev->y()-tLy-bY)/font_h + 1 ); |
800 | releaseMouse(); | 800 | releaseMouse(); |
801 | } | 801 | } |
802 | } | 802 | } |
803 | 803 | ||
804 | void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) | 804 | void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) |
805 | { | 805 | { |
806 | if ( ev->button() != LeftButton) return; | 806 | if ( ev->button() != LeftButton) return; |
807 | 807 | ||
808 | QPoint tL = contentsRect().topLeft(); | 808 | QPoint tL = contentsRect().topLeft(); |
809 | int tLx = tL.x(); | 809 | int tLx = tL.x(); |
810 | int tLy = tL.y(); | 810 | int tLy = tL.y(); |
811 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 811 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
812 | 812 | ||
813 | // pass on double click as two clicks. | 813 | // pass on double click as two clicks. |
814 | if (!mouse_marks && !(ev->state() & ShiftButton)) | 814 | if (!mouse_marks && !(ev->state() & ShiftButton)) |
815 | { | 815 | { |
816 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button | 816 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button |
817 | emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release | 817 | emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release |
818 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button | 818 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button |
819 | return; | 819 | return; |
820 | } | 820 | } |
821 | 821 | ||
822 | 822 | ||
823 | emit clearSelectionSignal(); | 823 | emit clearSelectionSignal(); |
824 | QPoint bgnSel = pos; | 824 | QPoint bgnSel = pos; |
825 | QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 825 | QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
826 | int i = loc(bgnSel.x(),bgnSel.y()); | 826 | int i = loc(bgnSel.x(),bgnSel.y()); |
827 | iPntSel = bgnSel; | 827 | iPntSel = bgnSel; |
828 | 828 | ||
829 | word_selection_mode = TRUE; | 829 | word_selection_mode = TRUE; |
830 | 830 | ||
831 | // find word boundaries... | 831 | // find word boundaries... |
832 | int selClass = charClass(image[i].c); | 832 | int selClass = charClass(image[i].c); |
833 | { | 833 | { |
834 | // set the start... | 834 | // set the start... |
835 | int x = bgnSel.x(); | 835 | int x = bgnSel.x(); |
836 | while ( x > 0 && charClass(image[i-1].c) == selClass ) | 836 | while ( x > 0 && charClass(image[i-1].c) == selClass ) |
837 | { i--; x--; } | 837 | { i--; x--; } |
838 | bgnSel.setX(x); | 838 | bgnSel.setX(x); |
839 | emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); | 839 | emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); |
840 | 840 | ||
841 | // set the end... | 841 | // set the end... |
842 | i = loc( endSel.x(), endSel.y() ); | 842 | i = loc( endSel.x(), endSel.y() ); |
843 | x = endSel.x(); | 843 | x = endSel.x(); |
844 | while( x < columns-1 && charClass(image[i+1].c) == selClass ) | 844 | while( x < columns-1 && charClass(image[i+1].c) == selClass ) |
845 | { i++; x++ ; } | 845 | { i++; x++ ; } |
846 | endSel.setX(x); | 846 | endSel.setX(x); |
847 | actSel = 2; // within selection | 847 | actSel = 2; // within selection |
848 | emit extendSelectionSignal( endSel.x(), endSel.y() ); | 848 | emit extendSelectionSignal( endSel.x(), endSel.y() ); |
849 | emit endSelectionSignal(preserve_line_breaks); | 849 | emit endSelectionSignal(preserve_line_breaks); |
850 | preserve_line_breaks = TRUE; | 850 | preserve_line_breaks = TRUE; |
851 | } | 851 | } |
852 | } | 852 | } |
853 | 853 | ||
854 | void TEWidget::focusInEvent( QFocusEvent * ) | 854 | void TEWidget::focusInEvent( QFocusEvent * ) |
855 | { | 855 | { |
856 | // do nothing, to prevent repainting | 856 | // do nothing, to prevent repainting |
857 | } | 857 | } |
858 | 858 | ||
859 | 859 | ||
860 | void TEWidget::focusOutEvent( QFocusEvent * ) | 860 | void TEWidget::focusOutEvent( QFocusEvent * ) |
861 | { | 861 | { |
862 | // do nothing, to prevent repainting | 862 | // do nothing, to prevent repainting |
863 | } | 863 | } |
864 | 864 | ||
865 | bool TEWidget::focusNextPrevChild( bool next ) | 865 | bool TEWidget::focusNextPrevChild( bool next ) |
866 | { | 866 | { |
867 | if (next) | 867 | if (next) |
868 | return false; // This disables changing the active part in konqueror | 868 | return false; // This disables changing the active part in konqueror |
869 | // when pressing Tab | 869 | // when pressing Tab |
870 | return QFrame::focusNextPrevChild( next ); | 870 | return QFrame::focusNextPrevChild( next ); |
871 | } | 871 | } |
872 | 872 | ||
873 | 873 | ||
874 | int TEWidget::charClass(char ch) const | 874 | int TEWidget::charClass(char ch) const |
875 | { | 875 | { |
876 | // This might seem like overkill, but imagine if ch was a Unicode | 876 | // This might seem like overkill, but imagine if ch was a Unicode |
877 | // character (Qt 2.0 QChar) - it might then be sensible to separate | 877 | // character (Qt 2.0 QChar) - it might then be sensible to separate |
878 | // the different language ranges, etc. | 878 | // the different language ranges, etc. |
879 | 879 | ||
880 | if ( isspace(ch) ) return ' '; | 880 | if ( isspace(ch) ) return ' '; |
881 | 881 | ||
882 | static const char *word_characters = ":@-./_~"; | 882 | static const char *word_characters = ":@-./_~"; |
883 | if ( isalnum(ch) || strchr(word_characters, ch) ) | 883 | if ( isalnum(ch) || strchr(word_characters, ch) ) |
884 | return 'a'; | 884 | return 'a'; |
885 | 885 | ||
886 | // Everything else is weird | 886 | // Everything else is weird |
887 | return 1; | 887 | return 1; |
888 | } | 888 | } |
889 | 889 | ||
890 | void TEWidget::setMouseMarks(bool on) | 890 | void TEWidget::setMouseMarks(bool on) |
891 | { | 891 | { |
892 | mouse_marks = on; | 892 | mouse_marks = on; |
893 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); | 893 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); |
894 | } | 894 | } |
895 | 895 | ||
896 | /* ------------------------------------------------------------------------- */ | 896 | /* ------------------------------------------------------------------------- */ |
897 | /* */ | 897 | /* */ |
898 | /* Clipboard */ | 898 | /* Clipboard */ |
899 | /* */ | 899 | /* */ |
900 | /* ------------------------------------------------------------------------- */ | 900 | /* ------------------------------------------------------------------------- */ |
901 | 901 | ||
902 | #undef KeyPress | 902 | #undef KeyPress |
903 | 903 | ||
904 | void TEWidget::emitSelection() | 904 | void TEWidget::emitSelection() |
905 | // Paste Clipboard by simulating keypress events | 905 | // Paste Clipboard by simulating keypress events |
906 | { | 906 | { |
907 | #ifndef QT_NO_CLIPBOARD | 907 | #ifndef QT_NO_CLIPBOARD |
908 | QString text = QApplication::clipboard()->text(); | 908 | QString text = QApplication::clipboard()->text(); |
909 | if ( ! text.isNull() ) | 909 | if ( ! text.isNull() ) |
910 | { | 910 | { |
911 | text.replace(QRegExp("\n"), "\r"); | 911 | text.replace(QRegExp("\n"), "\r"); |
912 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | 912 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); |
913 | emit keyPressedSignal(&e); // expose as a big fat keypress event | 913 | emit keyPressedSignal(&e); // expose as a big fat keypress event |
914 | emit clearSelectionSignal(); | 914 | emit clearSelectionSignal(); |
915 | } | 915 | } |
916 | #endif | 916 | #endif |
917 | } | 917 | } |
918 | 918 | ||
919 | void TEWidget::emitText(QString text) | 919 | void TEWidget::emitText(QString text) |
920 | { | 920 | { |
921 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | 921 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); |
922 | emit keyPressedSignal(&e); // expose as a big fat keypress event | 922 | emit keyPressedSignal(&e); // expose as a big fat keypress event |
923 | } | 923 | } |
924 | 924 | ||
925 | void TEWidget::pasteClipboard( ) | 925 | void TEWidget::pasteClipboard( ) |
926 | { | 926 | { |
927 | emitSelection(); | 927 | emitSelection(); |
928 | } | 928 | } |
929 | 929 | ||
930 | void TEWidget::setSelection(const QString& t) | 930 | void TEWidget::setSelection(const QString& t) |
931 | { | 931 | { |
932 | #ifndef QT_NO_CLIPBOARD | 932 | #ifndef QT_NO_CLIPBOARD |
933 | // Disconnect signal while WE set the clipboard | 933 | // Disconnect signal while WE set the clipboard |
934 | QObject *cb = QApplication::clipboard(); | 934 | QObject *cb = QApplication::clipboard(); |
935 | QObject::disconnect( cb, SIGNAL(dataChanged()), | 935 | QObject::disconnect( cb, SIGNAL(dataChanged()), |
936 | this, SLOT(onClearSelection()) ); | 936 | this, SLOT(onClearSelection()) ); |
937 | 937 | ||
938 | QApplication::clipboard()->setText(t); | 938 | QApplication::clipboard()->setText(t); |
939 | 939 | ||
940 | QObject::connect( cb, SIGNAL(dataChanged()), | 940 | QObject::connect( cb, SIGNAL(dataChanged()), |
941 | this, SLOT(onClearSelection()) ); | 941 | this, SLOT(onClearSelection()) ); |
942 | #endif | 942 | #endif |
943 | } | 943 | } |
944 | 944 | ||
945 | void TEWidget::onClearSelection() | 945 | void TEWidget::onClearSelection() |
946 | { | 946 | { |
947 | emit clearSelectionSignal(); | 947 | emit clearSelectionSignal(); |
948 | } | 948 | } |
949 | 949 | ||
950 | /* ------------------------------------------------------------------------- */ | 950 | /* ------------------------------------------------------------------------- */ |
951 | /* */ | 951 | /* */ |
952 | /* Keyboard */ | 952 | /* Keyboard */ |
953 | /* */ | 953 | /* */ |
954 | /* ------------------------------------------------------------------------- */ | 954 | /* ------------------------------------------------------------------------- */ |
955 | 955 | ||
956 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' | 956 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' |
957 | // due to a bug in `QT' or the ignorance of the author to prevent | 957 | // due to a bug in `QT' or the ignorance of the author to prevent |
958 | // repaint events being emitted to the screen whenever one leaves | 958 | // repaint events being emitted to the screen whenever one leaves |
959 | // or reenters the screen to/from another application. | 959 | // or reenters the screen to/from another application. |
960 | // | 960 | // |
961 | // Troll says one needs to change focusInEvent() and focusOutEvent(), | 961 | // Troll says one needs to change focusInEvent() and focusOutEvent(), |
962 | // which would also let you have an in-focus cursor and an out-focus | 962 | // which would also let you have an in-focus cursor and an out-focus |
963 | // cursor like xterm does. | 963 | // cursor like xterm does. |
964 | 964 | ||
965 | // for the auto-hide cursor feature, I added empty focusInEvent() and | 965 | // for the auto-hide cursor feature, I added empty focusInEvent() and |
966 | // focusOutEvent() so that update() isn't called. | 966 | // focusOutEvent() so that update() isn't called. |
967 | // For auto-hide, we need to get keypress-events, but we only get them when | 967 | // For auto-hide, we need to get keypress-events, but we only get them when |
968 | // we have focus. | 968 | // we have focus. |
969 | 969 | ||
970 | void TEWidget::doScroll(int lines) | 970 | void TEWidget::doScroll(int lines) |
971 | { | 971 | { |
972 | scrollbar->setValue(scrollbar->value()+lines); | 972 | scrollbar->setValue(scrollbar->value()+lines); |
973 | } | 973 | } |
974 | 974 | ||
975 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | 975 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) |
976 | { | 976 | { |
977 | if ( (e->type() == QEvent::Accel || | 977 | if ( (e->type() == QEvent::Accel || |
978 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) | 978 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) |
979 | { | 979 | { |
980 | static_cast<QKeyEvent *>( e )->ignore(); | 980 | static_cast<QKeyEvent *>( e )->ignore(); |
981 | return true; | 981 | return true; |
982 | } | 982 | } |
983 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) | 983 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) |
984 | return FALSE; // not us | 984 | return FALSE; // not us |
985 | if ( e->type() == QEvent::Wheel) | 985 | if ( e->type() == QEvent::Wheel) |
986 | { | 986 | { |
987 | QApplication::sendEvent(scrollbar, e); | 987 | QApplication::sendEvent(scrollbar, e); |
988 | } | 988 | } |
989 | 989 | ||
990 | #ifdef FAKE_CTRL_AND_ALT | 990 | #ifdef FAKE_CTRL_AND_ALT |
991 | static bool control = FALSE; | 991 | static bool control = FALSE; |
992 | static bool alt = FALSE; | 992 | static bool alt = FALSE; |
993 | // Has a keyboard with no CTRL and ALT keys, but we fake it: | 993 | // Has a keyboard with no CTRL and ALT keys, but we fake it: |
994 | bool dele=FALSE; | 994 | bool dele=FALSE; |
995 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 995 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
996 | QKeyEvent* ke = (QKeyEvent*)e; | 996 | QKeyEvent* ke = (QKeyEvent*)e; |
997 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | 997 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); |
998 | switch (ke->key()) { | 998 | switch (ke->key()) { |
999 | case Key_F9: // let this be "Control" | 999 | case Key_F9: // let this be "Control" |
1000 | control = keydown; | 1000 | control = keydown; |
1001 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | 1001 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); |
1002 | dele=TRUE; | 1002 | dele=TRUE; |
1003 | break; | 1003 | break; |
1004 | case Key_F13: // let this be "Alt" | 1004 | case Key_F13: // let this be "Alt" |
1005 | alt = keydown; | 1005 | alt = keydown; |
1006 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); | 1006 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); |
1007 | dele=TRUE; | 1007 | dele=TRUE; |
1008 | break; | 1008 | break; |
1009 | default: | 1009 | default: |
1010 | if ( control ) { | 1010 | if ( control ) { |
1011 | int a = toupper(ke->ascii())-64; | 1011 | int a = toupper(ke->ascii())-64; |
1012 | if ( a >= 0 && a < ' ' ) { | 1012 | if ( a >= 0 && a < ' ' ) { |
1013 | e = new QKeyEvent(e->type(), ke->key(), | 1013 | e = new QKeyEvent(e->type(), ke->key(), |
1014 | a, ke->state()|ControlButton, QChar(a,0)); | 1014 | a, ke->state()|ControlButton, QChar(a,0)); |
1015 | dele=TRUE; | 1015 | dele=TRUE; |
1016 | } | 1016 | } |
1017 | } | 1017 | } |
1018 | if ( alt ) { | 1018 | if ( alt ) { |
1019 | e = new QKeyEvent(e->type(), ke->key(), | 1019 | e = new QKeyEvent(e->type(), ke->key(), |
1020 | ke->ascii(), ke->state()|AltButton, ke->text()); | 1020 | ke->ascii(), ke->state()|AltButton, ke->text()); |
1021 | dele=TRUE; | 1021 | dele=TRUE; |
1022 | } | 1022 | } |
1023 | } | 1023 | } |
1024 | } | 1024 | } |
1025 | #endif | 1025 | #endif |
1026 | 1026 | ||
1027 | if ( e->type() == QEvent::KeyPress ) | 1027 | if ( e->type() == QEvent::KeyPress ) |
1028 | { | 1028 | { |
1029 | QKeyEvent* ke = (QKeyEvent*)e; | 1029 | QKeyEvent* ke = (QKeyEvent*)e; |
1030 | 1030 | ||
1031 | actSel=0; // Key stroke implies a screen update, so TEWidget won't | 1031 | actSel=0; // Key stroke implies a screen update, so TEWidget won't |
1032 | // know where the current selection is. | 1032 | // know where the current selection is. |
1033 | 1033 | ||
1034 | emit keyPressedSignal(ke); // expose | 1034 | emit keyPressedSignal(ke); // expose |
1035 | ke->accept(); | 1035 | ke->accept(); |
1036 | #ifdef FAKE_CTRL_AND_ALT | 1036 | #ifdef FAKE_CTRL_AND_ALT |
1037 | if ( dele ) delete e; | 1037 | if ( dele ) delete e; |
1038 | #endif | 1038 | #endif |
1039 | return true; // stop the event | 1039 | return true; // stop the event |
1040 | } | 1040 | } |
1041 | if ( e->type() == QEvent::Enter ) | 1041 | if ( e->type() == QEvent::Enter ) |
1042 | { | 1042 | { |
1043 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), | 1043 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), |
1044 | this, SLOT(onClearSelection()) ); | 1044 | this, SLOT(onClearSelection()) ); |
1045 | } | 1045 | } |
1046 | if ( e->type() == QEvent::Leave ) | 1046 | if ( e->type() == QEvent::Leave ) |
1047 | { | 1047 | { |
1048 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 1048 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
1049 | this, SLOT(onClearSelection()) ); | 1049 | this, SLOT(onClearSelection()) ); |
1050 | } | 1050 | } |
1051 | return QFrame::eventFilter( obj, e ); | 1051 | return QFrame::eventFilter( obj, e ); |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | /* ------------------------------------------------------------------------- */ | 1054 | /* ------------------------------------------------------------------------- */ |
1055 | /* */ | 1055 | /* */ |
1056 | /* Frame */ | 1056 | /* Frame */ |
1057 | /* */ | 1057 | /* */ |
1058 | /* ------------------------------------------------------------------------- */ | 1058 | /* ------------------------------------------------------------------------- */ |
1059 | 1059 | ||
1060 | void TEWidget::frameChanged() | 1060 | void TEWidget::frameChanged() |
1061 | { | 1061 | { |
1062 | propagateSize(); | 1062 | propagateSize(); |
1063 | update(); | 1063 | update(); |
1064 | } | 1064 | } |
1065 | 1065 | ||
1066 | /* ------------------------------------------------------------------------- */ | 1066 | /* ------------------------------------------------------------------------- */ |
1067 | /* */ | 1067 | /* */ |
1068 | /* Sound */ | 1068 | /* Sound */ |
1069 | /* */ | 1069 | /* */ |
1070 | /* ------------------------------------------------------------------------- */ | 1070 | /* ------------------------------------------------------------------------- */ |
1071 | 1071 | ||
1072 | void TEWidget::Bell() | 1072 | void TEWidget::Bell() |
1073 | { | 1073 | { |
1074 | QApplication::beep(); | 1074 | QApplication::beep(); |
1075 | } | 1075 | } |
1076 | 1076 | ||
1077 | /* ------------------------------------------------------------------------- */ | 1077 | /* ------------------------------------------------------------------------- */ |
1078 | /* */ | 1078 | /* */ |
1079 | /* Auxiluary */ | 1079 | /* Auxiluary */ |
1080 | /* */ | 1080 | /* */ |
1081 | /* ------------------------------------------------------------------------- */ | 1081 | /* ------------------------------------------------------------------------- */ |
1082 | 1082 | ||
1083 | void TEWidget::clearImage() | 1083 | void TEWidget::clearImage() |
1084 | // initialize the image | 1084 | // initialize the image |
1085 | // for internal use only | 1085 | // for internal use only |
1086 | { | 1086 | { |
1087 | for (int y = 0; y < lines; y++) | 1087 | for (int y = 0; y < lines; y++) |
1088 | for (int x = 0; x < columns; x++) | 1088 | for (int x = 0; x < columns; x++) |
1089 | { | 1089 | { |
1090 | image[loc(x,y)].c = 0xff; //' '; | 1090 | image[loc(x,y)].c = 0xff; //' '; |
1091 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; | 1091 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; |
1092 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; | 1092 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; |
1093 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; | 1093 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; |
1094 | } | 1094 | } |
1095 | } | 1095 | } |
1096 | 1096 | ||
1097 | // Create Image /////////////////////////////////////////////////////// | 1097 | // Create Image /////////////////////////////////////////////////////// |
1098 | 1098 | ||
1099 | void TEWidget::calcGeometry() | 1099 | void TEWidget::calcGeometry() |
1100 | { | 1100 | { |
1101 | //FIXME: set rimX == rimY == 0 when running in full screen mode. | 1101 | //FIXME: set rimX == rimY == 0 when running in full screen mode. |
1102 | 1102 | ||
1103 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), | 1103 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), |
1104 | contentsRect().height()); | 1104 | contentsRect().height()); |
1105 | switch(scrollLoc) | 1105 | switch(scrollLoc) |
1106 | { | 1106 | { |
1107 | case SCRNONE : | 1107 | case SCRNONE : |
1108 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; | 1108 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; |
1109 | blX = (contentsRect().width() - (columns*font_w) ) / 2; | 1109 | blX = (contentsRect().width() - (columns*font_w) ) / 2; |
1110 | brX = blX; | 1110 | brX = blX; |
1111 | scrollbar->hide(); | 1111 | scrollbar->hide(); |
1112 | break; | 1112 | break; |
1113 | case SCRLEFT : | 1113 | case SCRLEFT : |
1114 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1114 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1115 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1115 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1116 | blX = brX + scrollbar->width(); | 1116 | blX = brX + scrollbar->width(); |
1117 | scrollbar->move(contentsRect().topLeft()); | 1117 | scrollbar->move(contentsRect().topLeft()); |
1118 | scrollbar->show(); | 1118 | scrollbar->show(); |
1119 | break; | 1119 | break; |
1120 | case SCRRIGHT: | 1120 | case SCRRIGHT: |
1121 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1121 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1122 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1122 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1123 | brX = blX; | 1123 | brX = blX; |
1124 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); | 1124 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); |
1125 | scrollbar->show(); | 1125 | scrollbar->show(); |
1126 | break; | 1126 | break; |
1127 | } | 1127 | } |
1128 | //FIXME: support 'rounding' styles | 1128 | //FIXME: support 'rounding' styles |
1129 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; | 1129 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; |
1130 | bY = (contentsRect().height() - (lines *font_h)) / 2; | 1130 | bY = (contentsRect().height() - (lines *font_h)) / 2; |
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | void TEWidget::makeImage() | 1133 | void TEWidget::makeImage() |
1134 | //FIXME: rename 'calcGeometry? | 1134 | //FIXME: rename 'calcGeometry? |
1135 | { | 1135 | { |
1136 | calcGeometry(); | 1136 | calcGeometry(); |
1137 | image = (ca*) malloc(lines*columns*sizeof(ca)); | 1137 | image = (ca*) malloc(lines*columns*sizeof(ca)); |
1138 | clearImage(); | 1138 | clearImage(); |
1139 | } | 1139 | } |
1140 | 1140 | ||
1141 | // calculate the needed size | 1141 | // calculate the needed size |
1142 | QSize TEWidget::calcSize(int cols, int lins) const | 1142 | QSize TEWidget::calcSize(int cols, int lins) const |
1143 | { | 1143 | { |
1144 | int frw = width() - contentsRect().width(); | 1144 | int frw = width() - contentsRect().width(); |
1145 | int frh = height() - contentsRect().height(); | 1145 | int frh = height() - contentsRect().height(); |
1146 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); | 1146 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); |
1147 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); | 1147 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); |
1148 | } | 1148 | } |
1149 | 1149 | ||
1150 | QSize TEWidget::sizeHint() const | 1150 | QSize TEWidget::sizeHint() const |
1151 | { | 1151 | { |
1152 | return size(); | 1152 | return size(); |
1153 | } | 1153 | } |
1154 | 1154 | ||
1155 | void TEWidget::styleChange(QStyle &) | 1155 | void TEWidget::styleChange(QStyle &) |
1156 | { | 1156 | { |
1157 | propagateSize(); | 1157 | propagateSize(); |
1158 | } | 1158 | } |
1159 | 1159 | ||
1160 | #ifndef QT_NO_DRAGANDDROP | 1160 | #ifndef QT_NO_DRAGANDDROP |
1161 | 1161 | ||
1162 | /* --------------------------------------------------------------------- */ | 1162 | /* --------------------------------------------------------------------- */ |
1163 | /* */ | 1163 | /* */ |
1164 | /* Drag & Drop */ | 1164 | /* Drag & Drop */ |
1165 | /* */ | 1165 | /* */ |
1166 | /* --------------------------------------------------------------------- */ | 1166 | /* --------------------------------------------------------------------- */ |
1167 | 1167 | ||
1168 | 1168 | ||
1169 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) | 1169 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) |
1170 | { | 1170 | { |
1171 | e->accept(QTextDrag::canDecode(e) || | 1171 | e->accept(QTextDrag::canDecode(e) || |
1172 | QUriDrag::canDecode(e)); | 1172 | QUriDrag::canDecode(e)); |
1173 | } | 1173 | } |
1174 | 1174 | ||
1175 | void TEWidget::dropEvent(QDropEvent* event) | 1175 | void TEWidget::dropEvent(QDropEvent* event) |
1176 | { | 1176 | { |
1177 | // The current behaviour when url(s) are dropped is | 1177 | // The current behaviour when url(s) are dropped is |
1178 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd | 1178 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd |
1179 | // * in all other cases, just paste | 1179 | // * in all other cases, just paste |
1180 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) | 1180 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) |
1181 | QStrList strlist; | 1181 | QStrList strlist; |
1182 | int file_count = 0; | 1182 | int file_count = 0; |
1183 | dropText = ""; | 1183 | dropText = ""; |
1184 | bool bPopup = true; | 1184 | bool bPopup = true; |
1185 | 1185 | ||
1186 | if(QUriDrag::decode(event, strlist)) { | 1186 | if(QUriDrag::decode(event, strlist)) { |
1187 | if (strlist.count()) { | 1187 | if (strlist.count()) { |
1188 | for(const char* p = strlist.first(); p; p = strlist.next()) { | 1188 | for(const char* p = strlist.first(); p; p = strlist.next()) { |
1189 | if(file_count++ > 0) { | 1189 | if(file_count++ > 0) { |
1190 | dropText += " "; | 1190 | dropText += " "; |
1191 | bPopup = false; // more than one file, don't popup | 1191 | bPopup = false; // more than one file, don't popup |
1192 | } | 1192 | } |
1193 | 1193 | ||
1194 | /* | 1194 | /* |
1195 | KURL url(p); | 1195 | KURL url(p); |
1196 | if (url.isLocalFile()) { | 1196 | if (url.isLocalFile()) { |
1197 | dropText += url.path(); // local URL : remove protocol | 1197 | dropText += url.path(); // local URL : remove protocol |
1198 | } | 1198 | } |
1199 | else { | 1199 | else { |
1200 | dropText += url.prettyURL(); | 1200 | dropText += url.prettyURL(); |
1201 | bPopup = false; // a non-local file, don't popup | 1201 | bPopup = false; // a non-local file, don't popup |
1202 | } | 1202 | } |
1203 | */ | 1203 | */ |
1204 | 1204 | ||
1205 | } | 1205 | } |
1206 | 1206 | ||
1207 | if (bPopup) | 1207 | if (bPopup) |
1208 | // m_drop->popup(pos() + event->pos()); | 1208 | // m_drop->popup(pos() + event->pos()); |
1209 | m_drop->popup(mapToGlobal(event->pos())); | 1209 | m_drop->popup(mapToGlobal(event->pos())); |
1210 | else | 1210 | else |
1211 | { | 1211 | { |
1212 | if (currentSession) { | 1212 | if (currentSession) { |
1213 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1213 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1214 | } | 1214 | } |
1215 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1215 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1216 | } | 1216 | } |
1217 | } | 1217 | } |
1218 | } | 1218 | } |
1219 | else if(QTextDrag::decode(event, dropText)) { | 1219 | else if(QTextDrag::decode(event, dropText)) { |
1220 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1220 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1221 | if (currentSession) { | 1221 | if (currentSession) { |
1222 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1222 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1223 | } | 1223 | } |
1224 | // Paste it | 1224 | // Paste it |
1225 | } | 1225 | } |
1226 | } | 1226 | } |
1227 | #endif | 1227 | #endif |
1228 | 1228 | ||
1229 | 1229 | ||
1230 | void TEWidget::drop_menu_activated(int item) | 1230 | void TEWidget::drop_menu_activated(int item) |
1231 | { | 1231 | { |
1232 | #ifndef QT_NO_DRAGANDDROP | 1232 | #ifndef QT_NO_DRAGANDDROP |
1233 | switch (item) | 1233 | switch (item) |
1234 | { | 1234 | { |
1235 | case 0: // paste | 1235 | case 0: // paste |
1236 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1236 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1237 | // KWM::activate((Window)this->winId()); | 1237 | // KWM::activate((Window)this->winId()); |
1238 | break; | 1238 | break; |
1239 | case 1: // cd ... | 1239 | case 1: // cd ... |
1240 | currentSession->getEmulation()->sendString("cd "); | 1240 | currentSession->getEmulation()->sendString("cd "); |
1241 | struct stat statbuf; | 1241 | struct stat statbuf; |
1242 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) | 1242 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) |
1243 | { | 1243 | { |
1244 | if ( !S_ISDIR(statbuf.st_mode) ) | 1244 | if ( !S_ISDIR(statbuf.st_mode) ) |
1245 | { | 1245 | { |
1246 | /* | 1246 | /* |
1247 | KURL url; | 1247 | KURL url; |
1248 | url.setPath( dropText ); | 1248 | url.setPath( dropText ); |
1249 | dropText = url.directory( true, false ); // remove filename | 1249 | dropText = url.directory( true, false ); // remove filename |
1250 | */ | 1250 | */ |
1251 | } | 1251 | } |
1252 | } | 1252 | } |
1253 | dropText.replace(QRegExp(" "), "\\ "); // escape spaces | 1253 | dropText.replace(QRegExp(" "), "\\ "); // escape spaces |
1254 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1254 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1255 | currentSession->getEmulation()->sendString("\n"); | 1255 | currentSession->getEmulation()->sendString("\n"); |
1256 | // KWM::activate((Window)this->winId()); | 1256 | // KWM::activate((Window)this->winId()); |
1257 | break; | 1257 | break; |
1258 | } | 1258 | } |
1259 | #endif | 1259 | #endif |
1260 | } | 1260 | } |
1261 | 1261 | ||
diff --git a/core/apps/embeddedkonsole/commandeditdialog.cpp b/core/apps/embeddedkonsole/commandeditdialog.cpp index e8ef858..ce21c47 100644 --- a/core/apps/embeddedkonsole/commandeditdialog.cpp +++ b/core/apps/embeddedkonsole/commandeditdialog.cpp | |||
@@ -1,224 +1,223 @@ | |||
1 | //comandeditdialog.cpp | 1 | //comandeditdialog.cpp |
2 | 2 | ||
3 | #include "commandeditdialog.h" | 3 | #include "commandeditdialog.h" |
4 | #include "playlistselection.h" | 4 | #include "playlistselection.h" |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | #include <qpe/config.h> | 6 | #include <qpe/config.h> |
7 | #include <qpe/qpetoolbar.h> | 7 | #include <qpe/qpetoolbar.h> |
8 | #include <qwidget.h> | 8 | #include <qwidget.h> |
9 | #include <qpe/qpemenubar.h> | 9 | #include <qpe/qpemenubar.h> |
10 | #include <qpe/resource.h> | 10 | #include <qpe/resource.h> |
11 | #include <qlist.h> | 11 | #include <qlist.h> |
12 | #include <qtoolbutton.h> | 12 | #include <qtoolbutton.h> |
13 | #include <qvbox.h> | 13 | #include <qvbox.h> |
14 | #include <qlistview.h> | 14 | #include <qlistview.h> |
15 | #include <qlineedit.h> | 15 | #include <qlineedit.h> |
16 | #include <qheader.h> | 16 | #include <qheader.h> |
17 | #include <qlabel.h> | 17 | #include <qlabel.h> |
18 | #include <qmessagebox.h> | 18 | #include <qmessagebox.h> |
19 | #include "smallcommandeditdialogbase.h" | 19 | #include "smallcommandeditdialogbase.h" |
20 | 20 | ||
21 | CommandEditDialog::CommandEditDialog(QWidget *parent, const char* name, WFlags fl ) | 21 | CommandEditDialog::CommandEditDialog(QWidget *parent, const char* name, WFlags fl ) |
22 | : CommandEditDialogBase(parent, name, TRUE, fl) | 22 | : CommandEditDialogBase(parent, name, TRUE, fl) |
23 | 23 | ||
24 | { | 24 | { |
25 | m_SuggestedCommandList->addColumn( tr("Command Selection") ); | 25 | m_SuggestedCommandList->addColumn( tr("Command Selection") ); |
26 | m_SuggestedCommandList->header()->hide(); | 26 | m_SuggestedCommandList->header()->hide(); |
27 | m_SuggestedCommandList->setSorting(-1,FALSE); | 27 | m_SuggestedCommandList->setSorting(-1,FALSE); |
28 | m_SuggestedCommandList->clearSelection(); | 28 | m_SuggestedCommandList->clearSelection(); |
29 | m_SuggestedCommandList->setSorting(0,TRUE); | 29 | m_SuggestedCommandList->setSorting(0,TRUE); |
30 | 30 | ||
31 | QListViewItem *item; | 31 | QListViewItem *item; |
32 | 32 | ||
33 | 33 | ||
34 | item = new QListViewItem( m_SuggestedCommandList,"ls "); | 34 | item = new QListViewItem( m_SuggestedCommandList,"ls "); |
35 | 35 | ||
36 | item = new QListViewItem( m_SuggestedCommandList,"cat "); | 36 | item = new QListViewItem( m_SuggestedCommandList,"cat "); |
37 | item = new QListViewItem( m_SuggestedCommandList,"cd "); | 37 | item = new QListViewItem( m_SuggestedCommandList,"cd "); |
38 | item = new QListViewItem( m_SuggestedCommandList,"chmod "); | 38 | item = new QListViewItem( m_SuggestedCommandList,"chmod "); |
39 | item = new QListViewItem( m_SuggestedCommandList,"cp "); | 39 | item = new QListViewItem( m_SuggestedCommandList,"cp "); |
40 | item = new QListViewItem( m_SuggestedCommandList,"dc "); | 40 | item = new QListViewItem( m_SuggestedCommandList,"dc "); |
41 | item = new QListViewItem( m_SuggestedCommandList,"df "); | 41 | item = new QListViewItem( m_SuggestedCommandList,"df "); |
42 | item = new QListViewItem( m_SuggestedCommandList,"dmesg "); | 42 | item = new QListViewItem( m_SuggestedCommandList,"dmesg "); |
43 | item = new QListViewItem( m_SuggestedCommandList,"echo "); | 43 | item = new QListViewItem( m_SuggestedCommandList,"echo "); |
44 | item = new QListViewItem( m_SuggestedCommandList,"export "); | 44 | item = new QListViewItem( m_SuggestedCommandList,"export "); |
45 | item = new QListViewItem( m_SuggestedCommandList,"env "); | 45 | item = new QListViewItem( m_SuggestedCommandList,"env "); |
46 | item = new QListViewItem( m_SuggestedCommandList,"find "); | 46 | item = new QListViewItem( m_SuggestedCommandList,"find "); |
47 | item = new QListViewItem( m_SuggestedCommandList,"free "); | 47 | item = new QListViewItem( m_SuggestedCommandList,"free "); |
48 | item = new QListViewItem( m_SuggestedCommandList,"ifconfig "); | 48 | item = new QListViewItem( m_SuggestedCommandList,"ifconfig "); |
49 | item = new QListViewItem( m_SuggestedCommandList,"ipkg "); | 49 | item = new QListViewItem( m_SuggestedCommandList,"ipkg "); |
50 | item = new QListViewItem( m_SuggestedCommandList,"mkdir "); | 50 | item = new QListViewItem( m_SuggestedCommandList,"mkdir "); |
51 | item = new QListViewItem( m_SuggestedCommandList,"mv "); | 51 | item = new QListViewItem( m_SuggestedCommandList,"mv "); |
52 | item = new QListViewItem( m_SuggestedCommandList,"nc localhost 7776 "); | 52 | item = new QListViewItem( m_SuggestedCommandList,"nc localhost 7776 "); |
53 | item = new QListViewItem( m_SuggestedCommandList,"nc localhost 7777 "); | 53 | item = new QListViewItem( m_SuggestedCommandList,"nc localhost 7777 "); |
54 | item = new QListViewItem( m_SuggestedCommandList,"nslookup "); | 54 | item = new QListViewItem( m_SuggestedCommandList,"nslookup "); |
55 | item = new QListViewItem( m_SuggestedCommandList,"ping "); | 55 | item = new QListViewItem( m_SuggestedCommandList,"ping "); |
56 | item = new QListViewItem( m_SuggestedCommandList,"ps aux"); | 56 | item = new QListViewItem( m_SuggestedCommandList,"ps aux"); |
57 | item = new QListViewItem( m_SuggestedCommandList,"pwd "); | 57 | item = new QListViewItem( m_SuggestedCommandList,"pwd "); |
58 | item = new QListViewItem( m_SuggestedCommandList,"rm "); | 58 | item = new QListViewItem( m_SuggestedCommandList,"rm "); |
59 | item = new QListViewItem( m_SuggestedCommandList,"rmdir "); | 59 | item = new QListViewItem( m_SuggestedCommandList,"rmdir "); |
60 | item = new QListViewItem( m_SuggestedCommandList,"route "); | 60 | item = new QListViewItem( m_SuggestedCommandList,"route "); |
61 | item = new QListViewItem( m_SuggestedCommandList,"gzip "); | 61 | item = new QListViewItem( m_SuggestedCommandList,"gzip "); |
62 | item = new QListViewItem( m_SuggestedCommandList,"gunzip "); | 62 | item = new QListViewItem( m_SuggestedCommandList,"gunzip "); |
63 | item = new QListViewItem( m_SuggestedCommandList,"chgrp "); | 63 | item = new QListViewItem( m_SuggestedCommandList,"chgrp "); |
64 | item = new QListViewItem( m_SuggestedCommandList,"chown "); | 64 | item = new QListViewItem( m_SuggestedCommandList,"chown "); |
65 | item = new QListViewItem( m_SuggestedCommandList,"date "); | 65 | item = new QListViewItem( m_SuggestedCommandList,"date "); |
66 | item = new QListViewItem( m_SuggestedCommandList,"dd "); | 66 | item = new QListViewItem( m_SuggestedCommandList,"dd "); |
67 | item = new QListViewItem( m_SuggestedCommandList,"df "); | 67 | item = new QListViewItem( m_SuggestedCommandList,"df "); |
68 | item = new QListViewItem( m_SuggestedCommandList,"dmesg "); | 68 | item = new QListViewItem( m_SuggestedCommandList,"dmesg "); |
69 | item = new QListViewItem( m_SuggestedCommandList,"fuser "); | 69 | item = new QListViewItem( m_SuggestedCommandList,"fuser "); |
70 | item = new QListViewItem( m_SuggestedCommandList,"hostname "); | 70 | item = new QListViewItem( m_SuggestedCommandList,"hostname "); |
71 | item = new QListViewItem( m_SuggestedCommandList,"kill "); | 71 | item = new QListViewItem( m_SuggestedCommandList,"kill "); |
72 | item = new QListViewItem( m_SuggestedCommandList,"killall "); | 72 | item = new QListViewItem( m_SuggestedCommandList,"killall "); |
73 | item = new QListViewItem( m_SuggestedCommandList,"ln "); | 73 | item = new QListViewItem( m_SuggestedCommandList,"ln "); |
74 | item = new QListViewItem( m_SuggestedCommandList,"ln -s "); | 74 | item = new QListViewItem( m_SuggestedCommandList,"ln -s "); |
75 | item = new QListViewItem( m_SuggestedCommandList,"mount "); | 75 | item = new QListViewItem( m_SuggestedCommandList,"mount "); |
76 | item = new QListViewItem( m_SuggestedCommandList,"more "); | 76 | item = new QListViewItem( m_SuggestedCommandList,"more "); |
77 | item = new QListViewItem( m_SuggestedCommandList,"sort "); | 77 | item = new QListViewItem( m_SuggestedCommandList,"sort "); |
78 | item = new QListViewItem( m_SuggestedCommandList,"touch "); | 78 | item = new QListViewItem( m_SuggestedCommandList,"touch "); |
79 | item = new QListViewItem( m_SuggestedCommandList,"umount "); | 79 | item = new QListViewItem( m_SuggestedCommandList,"umount "); |
80 | item = new QListViewItem( m_SuggestedCommandList,"mknod "); | 80 | item = new QListViewItem( m_SuggestedCommandList,"mknod "); |
81 | item = new QListViewItem( m_SuggestedCommandList,"netstat "); | 81 | item = new QListViewItem( m_SuggestedCommandList,"netstat "); |
82 | item = new QListViewItem( m_SuggestedCommandList,"cardctl eject "); | 82 | item = new QListViewItem( m_SuggestedCommandList,"cardctl eject "); |
83 | m_SuggestedCommandList->setSelected(m_SuggestedCommandList->firstChild(),TRUE); | 83 | m_SuggestedCommandList->setSelected(m_SuggestedCommandList->firstChild(),TRUE); |
84 | m_SuggestedCommandList->sort(); | 84 | m_SuggestedCommandList->sort(); |
85 | 85 | ||
86 | connect( m_SuggestedCommandList, SIGNAL( clicked( QListViewItem * ) ), m_PlayListSelection, SLOT( addToSelection( QListViewItem *) ) ); | 86 | connect( m_SuggestedCommandList, SIGNAL( clicked( QListViewItem * ) ), m_PlayListSelection, SLOT( addToSelection( QListViewItem *) ) ); |
87 | 87 | ||
88 | 88 | ||
89 | 89 | ||
90 | ToolButton1->setTextLabel("new"); | 90 | ToolButton1->setTextLabel("new"); |
91 | ToolButton1->setPixmap(Resource::loadPixmap("new")); | 91 | ToolButton1->setPixmap(Resource::loadPixmap("new")); |
92 | ToolButton1->setAutoRaise(TRUE); | 92 | ToolButton1->setAutoRaise(TRUE); |
93 | ToolButton1->setFocusPolicy(QWidget::NoFocus); | 93 | ToolButton1->setFocusPolicy(QWidget::NoFocus); |
94 | connect(ToolButton1,SIGNAL(clicked()),this,SLOT(showAddDialog())); | 94 | connect(ToolButton1,SIGNAL(clicked()),this,SLOT(showAddDialog())); |
95 | 95 | ||
96 | ToolButton2->setTextLabel("edit"); | 96 | ToolButton2->setTextLabel("edit"); |
97 | ToolButton2->setPixmap(Resource::loadPixmap("edit")); | 97 | ToolButton2->setPixmap(Resource::loadPixmap("edit")); |
98 | ToolButton2->setAutoRaise(TRUE); | 98 | ToolButton2->setAutoRaise(TRUE); |
99 | ToolButton2->setFocusPolicy(QWidget::NoFocus); | 99 | ToolButton2->setFocusPolicy(QWidget::NoFocus); |
100 | connect(ToolButton2,SIGNAL(clicked()),this,SLOT(showEditDialog())); | 100 | connect(ToolButton2,SIGNAL(clicked()),this,SLOT(showEditDialog())); |
101 | 101 | ||
102 | ToolButton3->setTextLabel("delete"); | 102 | ToolButton3->setTextLabel("delete"); |
103 | ToolButton3->setPixmap(Resource::loadPixmap("editdelete")); | 103 | ToolButton3->setPixmap(Resource::loadPixmap("editdelete")); |
104 | ToolButton3->setAutoRaise(TRUE); | 104 | ToolButton3->setAutoRaise(TRUE); |
105 | ToolButton3->setFocusPolicy(QWidget::NoFocus); | 105 | ToolButton3->setFocusPolicy(QWidget::NoFocus); |
106 | connect(ToolButton3,SIGNAL(clicked()),m_PlayListSelection,SLOT(removeSelected())); | 106 | connect(ToolButton3,SIGNAL(clicked()),m_PlayListSelection,SLOT(removeSelected())); |
107 | 107 | ||
108 | ToolButton4->setTextLabel("up"); | 108 | ToolButton4->setTextLabel("up"); |
109 | ToolButton4->setPixmap(Resource::loadPixmap("up")); | 109 | ToolButton4->setPixmap(Resource::loadPixmap("up")); |
110 | ToolButton4->setAutoRaise(TRUE); | 110 | ToolButton4->setAutoRaise(TRUE); |
111 | ToolButton4->setFocusPolicy(QWidget::NoFocus); | 111 | ToolButton4->setFocusPolicy(QWidget::NoFocus); |
112 | connect(ToolButton4,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedUp())); | 112 | connect(ToolButton4,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedUp())); |
113 | 113 | ||
114 | ToolButton5->setTextLabel("down"); | 114 | ToolButton5->setTextLabel("down"); |
115 | ToolButton5->setPixmap(Resource::loadPixmap("down")); | 115 | ToolButton5->setPixmap(Resource::loadPixmap("down")); |
116 | ToolButton5->setAutoRaise(TRUE); | 116 | ToolButton5->setAutoRaise(TRUE); |
117 | ToolButton5->setFocusPolicy(QWidget::NoFocus); | 117 | ToolButton5->setFocusPolicy(QWidget::NoFocus); |
118 | 118 | ||
119 | connect(ToolButton5,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedDown())); | 119 | connect(ToolButton5,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedDown())); |
120 | 120 | ||
121 | 121 | ||
122 | 122 | ||
123 | 123 | ||
124 | QListViewItem *current = m_SuggestedCommandList->selectedItem(); | 124 | QListViewItem *current = m_SuggestedCommandList->selectedItem(); |
125 | if ( current ) | 125 | if ( current ) |
126 | item->moveItem( current ); | 126 | item->moveItem( current ); |
127 | m_SuggestedCommandList->setSelected( item, TRUE ); | 127 | m_SuggestedCommandList->setSelected( item, TRUE ); |
128 | m_SuggestedCommandList->ensureItemVisible( m_SuggestedCommandList->selectedItem() ); | 128 | m_SuggestedCommandList->ensureItemVisible( m_SuggestedCommandList->selectedItem() ); |
129 | Config cfg("Konsole"); | 129 | Config cfg("Konsole"); |
130 | cfg.setGroup("Commands"); | 130 | cfg.setGroup("Commands"); |
131 | if (cfg.readEntry("Commands Set","FALSE") == "TRUE") { | 131 | if (cfg.readEntry("Commands Set","FALSE") == "TRUE") { |
132 | for (int i = 0; i < 100; i++) { | 132 | for (int i = 0; i < 100; i++) { |
133 | QString tmp; | 133 | QString tmp; |
134 | tmp = cfg.readEntry( QString::number(i),""); | 134 | tmp = cfg.readEntry( QString::number(i),""); |
135 | if (!tmp.isEmpty()) | 135 | if (!tmp.isEmpty()) |
136 | m_PlayListSelection->addStringToSelection(tmp); | 136 | m_PlayListSelection->addStringToSelection(tmp); |
137 | } | 137 | } |
138 | } else { | 138 | } else { |
139 | 139 | ||
140 | m_PlayListSelection->addStringToSelection("ls "); | 140 | m_PlayListSelection->addStringToSelection("ls "); |
141 | m_PlayListSelection->addStringToSelection("cardctl eject"); | 141 | m_PlayListSelection->addStringToSelection("cardctl eject"); |
142 | m_PlayListSelection->addStringToSelection("cat "); | 142 | m_PlayListSelection->addStringToSelection("cat "); |
143 | m_PlayListSelection->addStringToSelection("cd "); | 143 | m_PlayListSelection->addStringToSelection("cd "); |
144 | m_PlayListSelection->addStringToSelection("chmod "); | 144 | m_PlayListSelection->addStringToSelection("chmod "); |
145 | m_PlayListSelection->addStringToSelection("cp "); | 145 | m_PlayListSelection->addStringToSelection("cp "); |
146 | m_PlayListSelection->addStringToSelection("dc "); | 146 | m_PlayListSelection->addStringToSelection("dc "); |
147 | m_PlayListSelection->addStringToSelection("df "); | 147 | m_PlayListSelection->addStringToSelection("df "); |
148 | m_PlayListSelection->addStringToSelection("dmesg"); | 148 | m_PlayListSelection->addStringToSelection("dmesg"); |
149 | m_PlayListSelection->addStringToSelection("echo "); | 149 | m_PlayListSelection->addStringToSelection("echo "); |
150 | m_PlayListSelection->addStringToSelection("env"); | 150 | m_PlayListSelection->addStringToSelection("env"); |
151 | m_PlayListSelection->addStringToSelection("find "); | 151 | m_PlayListSelection->addStringToSelection("find "); |
152 | m_PlayListSelection->addStringToSelection("free"); | 152 | m_PlayListSelection->addStringToSelection("free"); |
153 | m_PlayListSelection->addStringToSelection("grep "); | 153 | m_PlayListSelection->addStringToSelection("grep "); |
154 | m_PlayListSelection->addStringToSelection("ifconfig "); | 154 | m_PlayListSelection->addStringToSelection("ifconfig "); |
155 | m_PlayListSelection->addStringToSelection("ipkg "); | 155 | m_PlayListSelection->addStringToSelection("ipkg "); |
156 | m_PlayListSelection->addStringToSelection("mkdir "); | 156 | m_PlayListSelection->addStringToSelection("mkdir "); |
157 | m_PlayListSelection->addStringToSelection("mv "); | 157 | m_PlayListSelection->addStringToSelection("mv "); |
158 | m_PlayListSelection->addStringToSelection("nc localhost 7776"); | 158 | m_PlayListSelection->addStringToSelection("nc localhost 7776"); |
159 | m_PlayListSelection->addStringToSelection("nc localhost 7777"); | 159 | m_PlayListSelection->addStringToSelection("nc localhost 7777"); |
160 | m_PlayListSelection->addStringToSelection("nslookup "); | 160 | m_PlayListSelection->addStringToSelection("nslookup "); |
161 | m_PlayListSelection->addStringToSelection("ping "); | 161 | m_PlayListSelection->addStringToSelection("ping "); |
162 | m_PlayListSelection->addStringToSelection("ps aux"); | 162 | m_PlayListSelection->addStringToSelection("ps aux"); |
163 | m_PlayListSelection->addStringToSelection("pwd "); | 163 | m_PlayListSelection->addStringToSelection("pwd "); |
164 | m_PlayListSelection->addStringToSelection("rm "); | 164 | m_PlayListSelection->addStringToSelection("rm "); |
165 | m_PlayListSelection->addStringToSelection("rmdir "); | 165 | m_PlayListSelection->addStringToSelection("rmdir "); |
166 | m_PlayListSelection->addStringToSelection("route "); | 166 | m_PlayListSelection->addStringToSelection("route "); |
167 | m_PlayListSelection->addStringToSelection("set "); | 167 | m_PlayListSelection->addStringToSelection("set "); |
168 | m_PlayListSelection->addStringToSelection("traceroute"); | 168 | m_PlayListSelection->addStringToSelection("traceroute"); |
169 | 169 | ||
170 | } | 170 | } |
171 | } | 171 | } |
172 | CommandEditDialog::~CommandEditDialog() | 172 | CommandEditDialog::~CommandEditDialog() |
173 | { | 173 | { |
174 | } | 174 | } |
175 | 175 | ||
176 | void CommandEditDialog::accept() | 176 | void CommandEditDialog::accept() |
177 | { | 177 | { |
178 | int i = 0; | 178 | int i = 0; |
179 | Config *cfg = new Config("Konsole"); | 179 | Config *cfg = new Config("Konsole"); |
180 | cfg->setGroup("Commands"); | 180 | cfg->setGroup("Commands"); |
181 | cfg->clearGroup(); | 181 | cfg->clearGroup(); |
182 | 182 | ||
183 | QListViewItemIterator it( m_PlayListSelection ); | 183 | QListViewItemIterator it( m_PlayListSelection ); |
184 | 184 | ||
185 | for ( ; it.current(); ++it ) { | 185 | for ( ; it.current(); ++it ) { |
186 | // qDebug(it.current()->text(0)); | 186 | // qDebug(it.current()->text(0)); |
187 | cfg->writeEntry(QString::number(i),it.current()->text(0)); | 187 | cfg->writeEntry(QString::number(i),it.current()->text(0)); |
188 | i++; | 188 | i++; |
189 | 189 | ||
190 | } | 190 | } |
191 | cfg->writeEntry("Commands Set","TRUE"); | 191 | cfg->writeEntry("Commands Set","TRUE"); |
192 | // qDebug("CommandEditDialog::accept() - written"); | 192 | // qDebug("CommandEditDialog::accept() - written"); |
193 | delete cfg; | 193 | delete cfg; |
194 | emit commandsEdited(); | 194 | emit commandsEdited(); |
195 | close(); | 195 | close(); |
196 | 196 | ||
197 | 197 | ||
198 | 198 | ||
199 | 199 | ||
200 | 200 | ||
201 | } | 201 | } |
202 | 202 | ||
203 | void CommandEditDialog::showEditDialog() | 203 | void CommandEditDialog::showEditDialog() |
204 | { | 204 | { |
205 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); | 205 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); |
206 | d->setCaption("Edit command"); | 206 | d->setCaption("Edit command"); |
207 | d->TextLabel->setText("Edit command:"); | 207 | d->TextLabel->setText("Edit command:"); |
208 | d->commandEdit->setText(m_PlayListSelection->currentItem()->text(0)); | 208 | d->commandEdit->setText(m_PlayListSelection->currentItem()->text(0)); |
209 | int i = d->exec(); | 209 | int i = d->exec(); |
210 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) | 210 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) |
211 | m_PlayListSelection->currentItem()->setText(0,(d->commandEdit->text())); | 211 | m_PlayListSelection->currentItem()->setText(0,(d->commandEdit->text())); |
212 | } | 212 | } |
213 | 213 | ||
214 | void CommandEditDialog::showAddDialog() | 214 | void CommandEditDialog::showAddDialog() |
215 | { | 215 | { |
216 | 216 | ||
217 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); | 217 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); |
218 | int i = d->exec(); | 218 | int i = d->exec(); |
219 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) | 219 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) |
220 | m_PlayListSelection->addStringToSelection(d->commandEdit->text()); | 220 | m_PlayListSelection->addStringToSelection(d->commandEdit->text()); |
221 | 221 | ||
222 | } | 222 | } |
223 | 223 | ||
224 | |||
diff --git a/core/apps/embeddedkonsole/commandeditdialogbase.cpp b/core/apps/embeddedkonsole/commandeditdialogbase.cpp new file mode 100644 index 0000000..f25edb4 --- a/dev/null +++ b/core/apps/embeddedkonsole/commandeditdialogbase.cpp | |||
@@ -0,0 +1,101 @@ | |||
1 | /**************************************************************************** | ||
2 | ** Form implementation generated from reading ui file 'commandeditdialogbase.ui' | ||
3 | ** | ||
4 | ** Created: Sun Feb 3 15:23:58 2002 | ||
5 | ** by: The User Interface Compiler (uic) | ||
6 | ** | ||
7 | ** WARNING! All changes made in this file will be lost! | ||
8 | ****************************************************************************/ | ||
9 | #include "commandeditdialogbase.h" | ||
10 | |||
11 | #include <qheader.h> | ||
12 | #include <qlabel.h> | ||
13 | #include <qlistview.h> | ||
14 | #include <qpushbutton.h> | ||
15 | #include <qtoolbutton.h> | ||
16 | #include "playlistselection.h" | ||
17 | #include <qlayout.h> | ||
18 | #include <qvariant.h> | ||
19 | #include <qtooltip.h> | ||
20 | #include <qwhatsthis.h> | ||
21 | |||
22 | /* | ||
23 | * Constructs a CommandEditDialogBase which is a child of 'parent', with the | ||
24 | * name 'name' and widget flags set to 'f' | ||
25 | * | ||
26 | * The dialog will by default be modeless, unless you set 'modal' to | ||
27 | * TRUE to construct a modal dialog. | ||
28 | */ | ||
29 | CommandEditDialogBase::CommandEditDialogBase( QWidget* parent, const char* name, bool modal, WFlags fl ) | ||
30 | : QDialog( parent, name, modal, fl ) | ||
31 | { | ||
32 | if ( !name ) | ||
33 | setName( "CommandEditDialogBase" ); | ||
34 | resize( 196, 414 ); | ||
35 | setCaption( tr( "Commands" ) ); | ||
36 | CommandEditDialogBaseLayout = new QGridLayout( this ); | ||
37 | CommandEditDialogBaseLayout->setSpacing( 6 ); | ||
38 | CommandEditDialogBaseLayout->setMargin( 11 ); | ||
39 | |||
40 | TextLabel1 = new QLabel( this, "TextLabel1" ); | ||
41 | TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); | ||
42 | TextLabel1->setText( tr( "<B>Commands</B>:" ) ); | ||
43 | |||
44 | CommandEditDialogBaseLayout->addWidget( TextLabel1, 0, 0 ); | ||
45 | |||
46 | Layout2 = new QVBoxLayout; | ||
47 | Layout2->setSpacing( 6 ); | ||
48 | Layout2->setMargin( 0 ); | ||
49 | |||
50 | ToolButton1 = new QToolButton( this, "ToolButton1" ); | ||
51 | ToolButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, ToolButton1->sizePolicy().hasHeightForWidth() ) ); | ||
52 | Layout2->addWidget( ToolButton1 ); | ||
53 | |||
54 | ToolButton2 = new QToolButton( this, "ToolButton2" ); | ||
55 | ToolButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, ToolButton2->sizePolicy().hasHeightForWidth() ) ); | ||
56 | Layout2->addWidget( ToolButton2 ); | ||
57 | |||
58 | ToolButton3 = new QToolButton( this, "ToolButton3" ); | ||
59 | ToolButton3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, ToolButton3->sizePolicy().hasHeightForWidth() ) ); | ||
60 | Layout2->addWidget( ToolButton3 ); | ||
61 | |||
62 | ToolButton4 = new QToolButton( this, "ToolButton4" ); | ||
63 | ToolButton4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, ToolButton4->sizePolicy().hasHeightForWidth() ) ); | ||
64 | Layout2->addWidget( ToolButton4 ); | ||
65 | |||
66 | ToolButton5 = new QToolButton( this, "ToolButton5" ); | ||
67 | ToolButton5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, ToolButton5->sizePolicy().hasHeightForWidth() ) ); | ||
68 | Layout2->addWidget( ToolButton5 ); | ||
69 | |||
70 | CommandEditDialogBaseLayout->addLayout( Layout2, 1, 2 ); | ||
71 | QSpacerItem* spacer = new QSpacerItem( 21, 20, QSizePolicy::Fixed, QSizePolicy::Minimum ); | ||
72 | CommandEditDialogBaseLayout->addItem( spacer, 0, 2 ); | ||
73 | |||
74 | TextLabel1_2 = new QLabel( this, "TextLabel1_2" ); | ||
75 | TextLabel1_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, TextLabel1_2->sizePolicy().hasHeightForWidth() ) ); | ||
76 | TextLabel1_2->setText( tr( "<B>Suggested Commands</B>:" ) ); | ||
77 | |||
78 | CommandEditDialogBaseLayout->addWidget( TextLabel1_2, 2, 0 ); | ||
79 | |||
80 | m_PlayListSelection = new PlayListSelection( this, "m_PlayListSelection" ); | ||
81 | m_PlayListSelection->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, m_PlayListSelection->sizePolicy().hasHeightForWidth() ) ); | ||
82 | |||
83 | CommandEditDialogBaseLayout->addMultiCellWidget( m_PlayListSelection, 1, 1, 0, 1 ); | ||
84 | QSpacerItem* spacer_2 = new QSpacerItem( 20, 30, QSizePolicy::Minimum, QSizePolicy::Fixed ); | ||
85 | CommandEditDialogBaseLayout->addItem( spacer_2, 2, 1 ); | ||
86 | QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Fixed ); | ||
87 | CommandEditDialogBaseLayout->addItem( spacer_3, 2, 2 ); | ||
88 | |||
89 | m_SuggestedCommandList = new QListView( this, "m_SuggestedCommandList" ); | ||
90 | |||
91 | CommandEditDialogBaseLayout->addMultiCellWidget( m_SuggestedCommandList, 3, 3, 0, 1 ); | ||
92 | } | ||
93 | |||
94 | /* | ||
95 | * Destroys the object and frees any allocated resources | ||
96 | */ | ||
97 | CommandEditDialogBase::~CommandEditDialogBase() | ||
98 | { | ||
99 | // no need to delete child widgets, Qt does it all for us | ||
100 | } | ||
101 | |||
diff --git a/core/apps/embeddedkonsole/commandeditdialogbase.h b/core/apps/embeddedkonsole/commandeditdialogbase.h new file mode 100644 index 0000000..6a37ec9 --- a/dev/null +++ b/core/apps/embeddedkonsole/commandeditdialogbase.h | |||
@@ -0,0 +1,46 @@ | |||
1 | /**************************************************************************** | ||
2 | ** Form interface generated from reading ui file 'commandeditdialogbase.ui' | ||
3 | ** | ||
4 | ** Created: Sun Feb 3 15:23:28 2002 | ||
5 | ** by: The User Interface Compiler (uic) | ||
6 | ** | ||
7 | ** WARNING! All changes made in this file will be lost! | ||
8 | ****************************************************************************/ | ||
9 | #ifndef COMMANDEDITDIALOGBASE_H | ||
10 | #define COMMANDEDITDIALOGBASE_H | ||
11 | |||
12 | #include <qvariant.h> | ||
13 | #include <qdialog.h> | ||
14 | class QVBoxLayout; | ||
15 | class QHBoxLayout; | ||
16 | class QGridLayout; | ||
17 | class PlayListSelection; | ||
18 | class QLabel; | ||
19 | class QListView; | ||
20 | class QListViewItem; | ||
21 | class QToolButton; | ||
22 | |||
23 | class CommandEditDialogBase : public QDialog | ||
24 | { | ||
25 | Q_OBJECT | ||
26 | |||
27 | public: | ||
28 | CommandEditDialogBase( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); | ||
29 | ~CommandEditDialogBase(); | ||
30 | |||
31 | QLabel* TextLabel1; | ||
32 | QToolButton* ToolButton1; | ||
33 | QToolButton* ToolButton2; | ||
34 | QToolButton* ToolButton3; | ||
35 | QToolButton* ToolButton4; | ||
36 | QToolButton* ToolButton5; | ||
37 | QLabel* TextLabel1_2; | ||
38 | PlayListSelection* m_PlayListSelection; | ||
39 | QListView* m_SuggestedCommandList; | ||
40 | |||
41 | protected: | ||
42 | QGridLayout* CommandEditDialogBaseLayout; | ||
43 | QVBoxLayout* Layout2; | ||
44 | }; | ||
45 | |||
46 | #endif // COMMANDEDITDIALOGBASE_H | ||