Merge lp:~larryprice/ubuntu-terminal-app/update-qmltermwidget into lp:~ubuntu-terminal-dev/ubuntu-terminal-app/reboot
- update-qmltermwidget
- Merge into reboot
Proposed by
Larry Price
Status: | Superseded |
---|---|
Proposed branch: | lp:~larryprice/ubuntu-terminal-app/update-qmltermwidget |
Merge into: | lp:~ubuntu-terminal-dev/ubuntu-terminal-app/reboot |
Prerequisite: | lp:~larryprice/ubuntu-terminal-app/fix-cmake-xenial |
Diff against target: |
27374 lines (+2019/-24346) 109 files modified
src/app/qml/TerminalComponent.qml (+0/-4) src/plugin/konsole/BlockArray.cpp (+0/-377) src/plugin/konsole/BlockArray.h (+0/-126) src/plugin/konsole/CMakeLists.txt (+0/-93) src/plugin/konsole/Character.h (+0/-221) src/plugin/konsole/CharacterColor.h (+0/-294) src/plugin/konsole/ColorScheme.cpp (+0/-774) src/plugin/konsole/ColorScheme.h (+0/-342) src/plugin/konsole/ColorTables.h (+0/-55) src/plugin/konsole/DefaultTranslatorText.h (+0/-2) src/plugin/konsole/Emulation.cpp (+0/-458) src/plugin/konsole/Emulation.h (+0/-467) src/plugin/konsole/ExtendedDefaultTranslator.h (+0/-74) src/plugin/konsole/Filter.cpp (+0/-542) src/plugin/konsole/Filter.h (+0/-380) src/plugin/konsole/History.cpp (+0/-986) src/plugin/konsole/History.h (+0/-490) src/plugin/konsole/KeyboardTranslator.cpp (+0/-892) src/plugin/konsole/KeyboardTranslator.h (+0/-584) src/plugin/konsole/LineFont.h (+0/-21) src/plugin/konsole/LineFont.src (+0/-786) src/plugin/konsole/Pty.cpp (+0/-310) src/plugin/konsole/Pty.h (+0/-206) src/plugin/konsole/Screen.cpp (+0/-1360) src/plugin/konsole/Screen.h (+0/-672) src/plugin/konsole/ScreenWindow.cpp (+0/-292) src/plugin/konsole/ScreenWindow.h (+0/-257) src/plugin/konsole/Session.cpp (+0/-1064) src/plugin/konsole/Session.h (+0/-626) src/plugin/konsole/ShellCommand.cpp (+0/-167) src/plugin/konsole/ShellCommand.h (+0/-90) src/plugin/konsole/TerminalCharacterDecoder.cpp (+0/-251) src/plugin/konsole/TerminalCharacterDecoder.h (+0/-148) src/plugin/konsole/TerminalDisplay.cpp (+0/-2171) src/plugin/konsole/TerminalDisplay.h (+0/-715) src/plugin/konsole/Vt102Emulation.cpp (+0/-1221) src/plugin/konsole/Vt102Emulation.h (+0/-188) src/plugin/konsole/assets/color-schemes/BlackOnLightYellow.schema (+0/-42) src/plugin/konsole/assets/color-schemes/BlackOnRandomLight.colorscheme (+0/-104) src/plugin/konsole/assets/color-schemes/BlackOnWhite.schema (+0/-42) src/plugin/konsole/assets/color-schemes/DarkPastels.colorscheme (+0/-103) src/plugin/konsole/assets/color-schemes/GreenOnBlack.colorscheme (+0/-104) src/plugin/konsole/assets/color-schemes/Linux.colorscheme (+0/-100) src/plugin/konsole/assets/color-schemes/WhiteOnBlack.schema (+0/-42) src/plugin/konsole/assets/color-schemes/historic/BlackOnLightColor.schema (+0/-42) src/plugin/konsole/assets/color-schemes/historic/DarkPicture.schema (+0/-44) src/plugin/konsole/assets/color-schemes/historic/Example.Schema (+0/-47) src/plugin/konsole/assets/color-schemes/historic/GreenOnBlack.schema (+0/-42) src/plugin/konsole/assets/color-schemes/historic/GreenTint.schema (+0/-49) src/plugin/konsole/assets/color-schemes/historic/GreenTint_MC.schema (+0/-49) src/plugin/konsole/assets/color-schemes/historic/LightPicture.schema (+0/-44) src/plugin/konsole/assets/color-schemes/historic/Linux.schema (+0/-47) src/plugin/konsole/assets/color-schemes/historic/README.Schema (+0/-132) src/plugin/konsole/assets/color-schemes/historic/README.default.Schema (+0/-44) src/plugin/konsole/assets/color-schemes/historic/Transparent.schema (+0/-49) src/plugin/konsole/assets/color-schemes/historic/Transparent_MC.schema (+0/-51) src/plugin/konsole/assets/color-schemes/historic/Transparent_darkbg.schema (+0/-42) src/plugin/konsole/assets/color-schemes/historic/Transparent_lightbg.schema (+0/-51) src/plugin/konsole/assets/color-schemes/historic/XTerm.schema (+0/-46) src/plugin/konsole/assets/color-schemes/historic/syscolor.schema (+0/-44) src/plugin/konsole/assets/color-schemes/historic/vim.schema (+0/-40) src/plugin/konsole/assets/kb-layouts/README (+0/-72) src/plugin/konsole/assets/kb-layouts/default.keytab (+0/-169) src/plugin/konsole/assets/kb-layouts/historic/vt100.keytab (+0/-133) src/plugin/konsole/assets/kb-layouts/historic/x11r5.keytab (+0/-71) src/plugin/konsole/assets/kb-layouts/linux.keytab (+0/-164) src/plugin/konsole/assets/kb-layouts/macbook.keytab (+0/-175) src/plugin/konsole/assets/kb-layouts/solaris.keytab (+0/-108) src/plugin/konsole/assets/kb-layouts/vt420pc.keytab (+0/-168) src/plugin/konsole/default.keytab (+0/-128) src/plugin/konsole/konsole_wcwidth.cpp (+0/-224) src/plugin/konsole/konsole_wcwidth.h (+0/-24) src/plugin/konsole/kprocess.cpp (+0/-412) src/plugin/konsole/kprocess.h (+0/-372) src/plugin/konsole/kpty.cpp (+0/-701) src/plugin/konsole/kpty.h (+0/-191) src/plugin/konsole/kpty_p.h (+0/-50) src/plugin/konsole/kptydevice.cpp (+0/-422) src/plugin/konsole/kptydevice.h (+0/-360) src/plugin/konsole/kptyprocess.cpp (+0/-129) src/plugin/konsole/kptyprocess.h (+0/-178) src/plugin/konsole/ksession.cpp (+0/-242) src/plugin/konsole/ksession.h (+0/-132) src/plugin/konsole/plugin.cpp (+0/-63) src/plugin/konsole/plugin.h (+0/-46) src/plugin/konsole/plugins.qmltypes (+0/-169) src/plugin/konsole/qmldir (+0/-3) src/plugin/konsole/tools.cpp (+0/-80) src/plugin/konsole/tools.h (+0/-10) src/plugin/qmltermwidget/.gitignore (+0/-1) src/plugin/qmltermwidget/AUTHORS (+1/-0) src/plugin/qmltermwidget/lib.pri (+2/-1) src/plugin/qmltermwidget/lib/Emulation.cpp (+5/-0) src/plugin/qmltermwidget/lib/Emulation.h (+11/-1) src/plugin/qmltermwidget/lib/KeyboardTranslator.cpp (+1/-1) src/plugin/qmltermwidget/lib/ProcessInfo.cpp (+1174/-0) src/plugin/qmltermwidget/lib/ProcessInfo.h (+460/-0) src/plugin/qmltermwidget/lib/Session.cpp (+41/-4) src/plugin/qmltermwidget/lib/Session.h (+10/-1) src/plugin/qmltermwidget/lib/TerminalDisplay.cpp (+64/-51) src/plugin/qmltermwidget/lib/TerminalDisplay.h (+29/-25) src/plugin/qmltermwidget/lib/Vt102Emulation.cpp (+6/-3) src/plugin/qmltermwidget/lib/color-schemes/Ubuntu.colorscheme (+0/-138) src/plugin/qmltermwidget/lib/kpty.cpp (+6/-1) src/plugin/qmltermwidget/packaging/rpm/qmltermwidget.spec (+59/-0) src/plugin/qmltermwidget/qmltermwidget.pro (+20/-0) src/plugin/qmltermwidget/src/ksession.cpp (+70/-9) src/plugin/qmltermwidget/src/ksession.h (+37/-6) src/plugin/qmltermwidget/test-app/test-app.qml (+23/-2) |
To merge this branch: | bzr merge lp:~larryprice/ubuntu-terminal-app/update-qmltermwidget |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Terminal Developers | Pending | ||
Review via email: mp+297471@code.launchpad.net |
This proposal has been superseded by a proposal from 2016-09-19.
Commit message
Update QMLTermWidget to latest version and remove duplicate konsole application code.
Description of the change
Update QMLTermWidget to latest version and remove duplicate konsole application code.
To post a comment you must log in.
- 203. By Larry Price
-
Update QMLTermWidget and remove unnecessary parts
- 204. By Larry Price
-
Merge
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/app/qml/TerminalComponent.qml' |
2 | --- src/app/qml/TerminalComponent.qml 2016-09-19 00:05:02 +0000 |
3 | +++ src/app/qml/TerminalComponent.qml 2016-09-19 14:23:50 +0000 |
4 | @@ -31,10 +31,6 @@ |
5 | font.family: settings.fontStyle |
6 | font.pixelSize: FontUtils.sizeToPixels("medium") * settings.fontSize / 10 |
7 | |
8 | - // WORKAROUND: Mir/QtMir does not support drag&drop yet, therefore we need |
9 | - // to disable this functionality (see lp:1488588). |
10 | - dragMode: QMLTermWidget.NoDrag |
11 | - |
12 | signal sessionFinished(var session); |
13 | |
14 | session: QMLTermSession { |
15 | |
16 | === removed directory 'src/plugin/konsole' |
17 | === removed file 'src/plugin/konsole/BlockArray.cpp' |
18 | --- src/plugin/konsole/BlockArray.cpp 2014-11-12 00:10:12 +0000 |
19 | +++ src/plugin/konsole/BlockArray.cpp 1970-01-01 00:00:00 +0000 |
20 | @@ -1,377 +0,0 @@ |
21 | -/* |
22 | - This file is part of Konsole, an X terminal. |
23 | - Copyright (C) 2000 by Stephan Kulow <coolo@kde.org> |
24 | - |
25 | - Rewritten for QT4 by e_k <e_k at users.sourceforge.net>, Copyright (C)2008 |
26 | - |
27 | - This program is free software; you can redistribute it and/or modify |
28 | - it under the terms of the GNU General Public License as published by |
29 | - the Free Software Foundation; either version 2 of the License, or |
30 | - (at your option) any later version. |
31 | - |
32 | - This program is distributed in the hope that it will be useful, |
33 | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
34 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
35 | - GNU General Public License for more details. |
36 | - |
37 | - You should have received a copy of the GNU General Public License |
38 | - along with this program; if not, write to the Free Software |
39 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
40 | - 02110-1301 USA. |
41 | - |
42 | -*/ |
43 | - |
44 | -// Own |
45 | -#include "BlockArray.h" |
46 | - |
47 | -#include <QtCore> |
48 | - |
49 | -// System |
50 | -#include <assert.h> |
51 | -#include <sys/mman.h> |
52 | -#include <sys/param.h> |
53 | -#include <unistd.h> |
54 | -#include <stdio.h> |
55 | - |
56 | - |
57 | -static int blocksize = 0; |
58 | - |
59 | -BlockArray::BlockArray() |
60 | - : size(0), |
61 | - current(size_t(-1)), |
62 | - index(size_t(-1)), |
63 | - lastmap(0), |
64 | - lastmap_index(size_t(-1)), |
65 | - lastblock(0), ion(-1), |
66 | - length(0) |
67 | -{ |
68 | - // lastmap_index = index = current = size_t(-1); |
69 | - if (blocksize == 0) { |
70 | - blocksize = ((sizeof(Block) / getpagesize()) + 1) * getpagesize(); |
71 | - } |
72 | - |
73 | -} |
74 | - |
75 | -BlockArray::~BlockArray() |
76 | -{ |
77 | - setHistorySize(0); |
78 | - assert(!lastblock); |
79 | -} |
80 | - |
81 | -size_t BlockArray::append(Block * block) |
82 | -{ |
83 | - if (!size) { |
84 | - return size_t(-1); |
85 | - } |
86 | - |
87 | - ++current; |
88 | - if (current >= size) { |
89 | - current = 0; |
90 | - } |
91 | - |
92 | - int rc; |
93 | - rc = lseek(ion, current * blocksize, SEEK_SET); |
94 | - if (rc < 0) { |
95 | - perror("HistoryBuffer::add.seek"); |
96 | - setHistorySize(0); |
97 | - return size_t(-1); |
98 | - } |
99 | - rc = write(ion, block, blocksize); |
100 | - if (rc < 0) { |
101 | - perror("HistoryBuffer::add.write"); |
102 | - setHistorySize(0); |
103 | - return size_t(-1); |
104 | - } |
105 | - |
106 | - length++; |
107 | - if (length > size) { |
108 | - length = size; |
109 | - } |
110 | - |
111 | - ++index; |
112 | - |
113 | - delete block; |
114 | - return current; |
115 | -} |
116 | - |
117 | -size_t BlockArray::newBlock() |
118 | -{ |
119 | - if (!size) { |
120 | - return size_t(-1); |
121 | - } |
122 | - append(lastblock); |
123 | - |
124 | - lastblock = new Block(); |
125 | - return index + 1; |
126 | -} |
127 | - |
128 | -Block * BlockArray::lastBlock() const |
129 | -{ |
130 | - return lastblock; |
131 | -} |
132 | - |
133 | -bool BlockArray::has(size_t i) const |
134 | -{ |
135 | - if (i == index + 1) { |
136 | - return true; |
137 | - } |
138 | - |
139 | - if (i > index) { |
140 | - return false; |
141 | - } |
142 | - if (index - i >= length) { |
143 | - return false; |
144 | - } |
145 | - return true; |
146 | -} |
147 | - |
148 | -const Block * BlockArray::at(size_t i) |
149 | -{ |
150 | - if (i == index + 1) { |
151 | - return lastblock; |
152 | - } |
153 | - |
154 | - if (i == lastmap_index) { |
155 | - return lastmap; |
156 | - } |
157 | - |
158 | - if (i > index) { |
159 | - qDebug() << "BlockArray::at() i > index\n"; |
160 | - return 0; |
161 | - } |
162 | - |
163 | -// if (index - i >= length) { |
164 | -// kDebug(1211) << "BlockArray::at() index - i >= length\n"; |
165 | -// return 0; |
166 | -// } |
167 | - |
168 | - size_t j = i; // (current - (index - i) + (index/size+1)*size) % size ; |
169 | - |
170 | - assert(j < size); |
171 | - unmap(); |
172 | - |
173 | - Block * block = (Block *)mmap(0, blocksize, PROT_READ, MAP_PRIVATE, ion, j * blocksize); |
174 | - |
175 | - if (block == (Block *)-1) { |
176 | - perror("mmap"); |
177 | - return 0; |
178 | - } |
179 | - |
180 | - lastmap = block; |
181 | - lastmap_index = i; |
182 | - |
183 | - return block; |
184 | -} |
185 | - |
186 | -void BlockArray::unmap() |
187 | -{ |
188 | - if (lastmap) { |
189 | - int res = munmap((char *)lastmap, blocksize); |
190 | - if (res < 0) { |
191 | - perror("munmap"); |
192 | - } |
193 | - } |
194 | - lastmap = 0; |
195 | - lastmap_index = size_t(-1); |
196 | -} |
197 | - |
198 | -bool BlockArray::setSize(size_t newsize) |
199 | -{ |
200 | - return setHistorySize(newsize * 1024 / blocksize); |
201 | -} |
202 | - |
203 | -bool BlockArray::setHistorySize(size_t newsize) |
204 | -{ |
205 | -// kDebug(1211) << "setHistorySize " << size << " " << newsize; |
206 | - |
207 | - if (size == newsize) { |
208 | - return false; |
209 | - } |
210 | - |
211 | - unmap(); |
212 | - |
213 | - if (!newsize) { |
214 | - delete lastblock; |
215 | - lastblock = 0; |
216 | - if (ion >= 0) { |
217 | - close(ion); |
218 | - } |
219 | - ion = -1; |
220 | - current = size_t(-1); |
221 | - return true; |
222 | - } |
223 | - |
224 | - if (!size) { |
225 | - FILE * tmp = tmpfile(); |
226 | - if (!tmp) { |
227 | - perror("konsole: cannot open temp file.\n"); |
228 | - } else { |
229 | - ion = dup(fileno(tmp)); |
230 | - if (ion<0) { |
231 | - perror("konsole: cannot dup temp file.\n"); |
232 | - fclose(tmp); |
233 | - } |
234 | - } |
235 | - if (ion < 0) { |
236 | - return false; |
237 | - } |
238 | - |
239 | - assert(!lastblock); |
240 | - |
241 | - lastblock = new Block(); |
242 | - size = newsize; |
243 | - return false; |
244 | - } |
245 | - |
246 | - if (newsize > size) { |
247 | - increaseBuffer(); |
248 | - size = newsize; |
249 | - return false; |
250 | - } else { |
251 | - decreaseBuffer(newsize); |
252 | - ftruncate(ion, length*blocksize); |
253 | - size = newsize; |
254 | - |
255 | - return true; |
256 | - } |
257 | -} |
258 | - |
259 | -void moveBlock(FILE * fion, int cursor, int newpos, char * buffer2) |
260 | -{ |
261 | - int res = fseek(fion, cursor * blocksize, SEEK_SET); |
262 | - if (res) { |
263 | - perror("fseek"); |
264 | - } |
265 | - res = fread(buffer2, blocksize, 1, fion); |
266 | - if (res != 1) { |
267 | - perror("fread"); |
268 | - } |
269 | - |
270 | - res = fseek(fion, newpos * blocksize, SEEK_SET); |
271 | - if (res) { |
272 | - perror("fseek"); |
273 | - } |
274 | - res = fwrite(buffer2, blocksize, 1, fion); |
275 | - if (res != 1) { |
276 | - perror("fwrite"); |
277 | - } |
278 | - // printf("moving block %d to %d\n", cursor, newpos); |
279 | -} |
280 | - |
281 | -void BlockArray::decreaseBuffer(size_t newsize) |
282 | -{ |
283 | - if (index < newsize) { // still fits in whole |
284 | - return; |
285 | - } |
286 | - |
287 | - int offset = (current - (newsize - 1) + size) % size; |
288 | - |
289 | - if (!offset) { |
290 | - return; |
291 | - } |
292 | - |
293 | - // The Block constructor could do somthing in future... |
294 | - char * buffer1 = new char[blocksize]; |
295 | - |
296 | - FILE * fion = fdopen(dup(ion), "w+b"); |
297 | - if (!fion) { |
298 | - delete [] buffer1; |
299 | - perror("fdopen/dup"); |
300 | - return; |
301 | - } |
302 | - |
303 | - int firstblock; |
304 | - if (current <= newsize) { |
305 | - firstblock = current + 1; |
306 | - } else { |
307 | - firstblock = 0; |
308 | - } |
309 | - |
310 | - size_t oldpos; |
311 | - for (size_t i = 0, cursor=firstblock; i < newsize; i++) { |
312 | - oldpos = (size + cursor + offset) % size; |
313 | - moveBlock(fion, oldpos, cursor, buffer1); |
314 | - if (oldpos < newsize) { |
315 | - cursor = oldpos; |
316 | - } else { |
317 | - cursor++; |
318 | - } |
319 | - } |
320 | - |
321 | - current = newsize - 1; |
322 | - length = newsize; |
323 | - |
324 | - delete [] buffer1; |
325 | - |
326 | - fclose(fion); |
327 | - |
328 | -} |
329 | - |
330 | -void BlockArray::increaseBuffer() |
331 | -{ |
332 | - if (index < size) { // not even wrapped once |
333 | - return; |
334 | - } |
335 | - |
336 | - int offset = (current + size + 1) % size; |
337 | - if (!offset) { // no moving needed |
338 | - return; |
339 | - } |
340 | - |
341 | - // The Block constructor could do somthing in future... |
342 | - char * buffer1 = new char[blocksize]; |
343 | - char * buffer2 = new char[blocksize]; |
344 | - |
345 | - int runs = 1; |
346 | - int bpr = size; // blocks per run |
347 | - |
348 | - if (size % offset == 0) { |
349 | - bpr = size / offset; |
350 | - runs = offset; |
351 | - } |
352 | - |
353 | - FILE * fion = fdopen(dup(ion), "w+b"); |
354 | - if (!fion) { |
355 | - perror("fdopen/dup"); |
356 | - delete [] buffer1; |
357 | - delete [] buffer2; |
358 | - return; |
359 | - } |
360 | - |
361 | - int res; |
362 | - for (int i = 0; i < runs; i++) { |
363 | - // free one block in chain |
364 | - int firstblock = (offset + i) % size; |
365 | - res = fseek(fion, firstblock * blocksize, SEEK_SET); |
366 | - if (res) { |
367 | - perror("fseek"); |
368 | - } |
369 | - res = fread(buffer1, blocksize, 1, fion); |
370 | - if (res != 1) { |
371 | - perror("fread"); |
372 | - } |
373 | - int newpos = 0; |
374 | - for (int j = 1, cursor=firstblock; j < bpr; j++) { |
375 | - cursor = (cursor + offset) % size; |
376 | - newpos = (cursor - offset + size) % size; |
377 | - moveBlock(fion, cursor, newpos, buffer2); |
378 | - } |
379 | - res = fseek(fion, i * blocksize, SEEK_SET); |
380 | - if (res) { |
381 | - perror("fseek"); |
382 | - } |
383 | - res = fwrite(buffer1, blocksize, 1, fion); |
384 | - if (res != 1) { |
385 | - perror("fwrite"); |
386 | - } |
387 | - } |
388 | - current = size - 1; |
389 | - length = size; |
390 | - |
391 | - delete [] buffer1; |
392 | - delete [] buffer2; |
393 | - |
394 | - fclose(fion); |
395 | - |
396 | -} |
397 | - |
398 | |
399 | === removed file 'src/plugin/konsole/BlockArray.h' |
400 | --- src/plugin/konsole/BlockArray.h 2014-11-12 00:10:12 +0000 |
401 | +++ src/plugin/konsole/BlockArray.h 1970-01-01 00:00:00 +0000 |
402 | @@ -1,126 +0,0 @@ |
403 | -/* |
404 | - This file is part of Konsole, an X terminal. |
405 | - Copyright (C) 2000 by Stephan Kulow <coolo@kde.org> |
406 | - |
407 | - Rewritten for QT4 by e_k <e_k at users.sourceforge.net>, Copyright (C)2008 |
408 | - |
409 | - This program is free software; you can redistribute it and/or modify |
410 | - it under the terms of the GNU General Public License as published by |
411 | - the Free Software Foundation; either version 2 of the License, or |
412 | - (at your option) any later version. |
413 | - |
414 | - This program is distributed in the hope that it will be useful, |
415 | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
416 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
417 | - GNU General Public License for more details. |
418 | - |
419 | - You should have received a copy of the GNU General Public License |
420 | - along with this program; if not, write to the Free Software |
421 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
422 | - 02110-1301 USA. |
423 | -*/ |
424 | - |
425 | -#ifndef BLOCKARRAY_H |
426 | -#define BLOCKARRAY_H |
427 | - |
428 | -#include <unistd.h> |
429 | - |
430 | -//#error Do not use in KDE 2.1 |
431 | - |
432 | -#define BlockSize (1 << 12) |
433 | -#define ENTRIES ((BlockSize - sizeof(size_t) ) / sizeof(unsigned char)) |
434 | - |
435 | -struct Block { |
436 | - Block() { |
437 | - size = 0; |
438 | - } |
439 | - unsigned char data[ENTRIES]; |
440 | - size_t size; |
441 | -}; |
442 | - |
443 | -// /////////////////////////////////////////////////////// |
444 | - |
445 | -class BlockArray { |
446 | -public: |
447 | - /** |
448 | - * Creates a history file for holding |
449 | - * maximal size blocks. If more blocks |
450 | - * are requested, then it drops earlier |
451 | - * added ones. |
452 | - */ |
453 | - BlockArray(); |
454 | - |
455 | - /// destructor |
456 | - ~BlockArray(); |
457 | - |
458 | - /** |
459 | - * adds the Block at the end of history. |
460 | - * This may drop other blocks. |
461 | - * |
462 | - * The ownership on the block is transfered. |
463 | - * An unique index number is returned for accessing |
464 | - * it later (if not yet dropped then) |
465 | - * |
466 | - * Note, that the block may be dropped completely |
467 | - * if history is turned off. |
468 | - */ |
469 | - size_t append(Block * block); |
470 | - |
471 | - /** |
472 | - * gets the block at the index. Function may return |
473 | - * 0 if the block isn't available any more. |
474 | - * |
475 | - * The returned block is strictly readonly as only |
476 | - * maped in memory - and will be invalid on the next |
477 | - * operation on this class. |
478 | - */ |
479 | - const Block * at(size_t index); |
480 | - |
481 | - /** |
482 | - * reorders blocks as needed. If newsize is null, |
483 | - * the history is emptied completely. The indices |
484 | - * returned on append won't change their semantic, |
485 | - * but they may not be valid after this call. |
486 | - */ |
487 | - bool setHistorySize(size_t newsize); |
488 | - |
489 | - size_t newBlock(); |
490 | - |
491 | - Block * lastBlock() const; |
492 | - |
493 | - /** |
494 | - * Convenient function to set the size in KBytes |
495 | - * instead of blocks |
496 | - */ |
497 | - bool setSize(size_t newsize); |
498 | - |
499 | - size_t len() const { |
500 | - return length; |
501 | - } |
502 | - |
503 | - bool has(size_t index) const; |
504 | - |
505 | - size_t getCurrent() const { |
506 | - return current; |
507 | - } |
508 | - |
509 | -private: |
510 | - void unmap(); |
511 | - void increaseBuffer(); |
512 | - void decreaseBuffer(size_t newsize); |
513 | - |
514 | - size_t size; |
515 | - // current always shows to the last inserted block |
516 | - size_t current; |
517 | - size_t index; |
518 | - |
519 | - Block * lastmap; |
520 | - size_t lastmap_index; |
521 | - Block * lastblock; |
522 | - |
523 | - int ion; |
524 | - size_t length; |
525 | - |
526 | -}; |
527 | - |
528 | -#endif |
529 | |
530 | === removed file 'src/plugin/konsole/CMakeLists.txt' |
531 | --- src/plugin/konsole/CMakeLists.txt 2014-11-12 00:10:12 +0000 |
532 | +++ src/plugin/konsole/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
533 | @@ -1,93 +0,0 @@ |
534 | -include_directories( |
535 | - ${CMAKE_CURRENT_SOURCE_DIR} |
536 | -) |
537 | - |
538 | -set(PLUGIN_DIR org/kde/konsole) |
539 | -add_definitions(-DHAVE_POSIX_OPENPT -DHAVE_SYS_TIME_H -DHAVE_UPDWTMPX) |
540 | -add_definitions(-DQ_WS_UBUNTU) |
541 | - |
542 | -set(konsole_SRCS |
543 | - BlockArray.cpp |
544 | - BlockArray.h |
545 | - CharacterColor.h |
546 | - Character.h |
547 | - ColorScheme.cpp |
548 | - ColorScheme.h |
549 | - ColorTables.h |
550 | - DefaultTranslatorText.h |
551 | - Emulation.cpp |
552 | - Emulation.h |
553 | - ExtendedDefaultTranslator.h |
554 | - Filter.cpp |
555 | - Filter.h |
556 | - History.cpp |
557 | - History.h |
558 | - KeyboardTranslator.cpp |
559 | - KeyboardTranslator.h |
560 | - konsole_wcwidth.cpp |
561 | - konsole_wcwidth.h |
562 | - kprocess.cpp |
563 | - kprocess.h |
564 | - kpty.cpp |
565 | - kptydevice.cpp |
566 | - kptydevice.h |
567 | - kpty.h |
568 | - kpty_p.h |
569 | - kptyprocess.cpp |
570 | - kptyprocess.h |
571 | - ksession.cpp |
572 | - ksession.h |
573 | - LineFont.h |
574 | - plugin.cpp |
575 | - plugin.h |
576 | - Pty.cpp |
577 | - Pty.h |
578 | - Screen.cpp |
579 | - Screen.h |
580 | - ScreenWindow.cpp |
581 | - ScreenWindow.h |
582 | - Session.cpp |
583 | - Session.h |
584 | - ShellCommand.cpp |
585 | - ShellCommand.h |
586 | - TerminalCharacterDecoder.cpp |
587 | - TerminalCharacterDecoder.h |
588 | - TerminalDisplay.cpp |
589 | - TerminalDisplay.h |
590 | - tools.cpp |
591 | - tools.h |
592 | - Vt102Emulation.cpp |
593 | - Vt102Emulation.h |
594 | -) |
595 | - |
596 | -add_library(kdekonsole MODULE |
597 | - ${konsole_SRCS} |
598 | -) |
599 | - |
600 | -qt5_use_modules(kdekonsole Gui Qml Quick Widgets) |
601 | - |
602 | -# Copy the plugin, the qmldir file and other assets to the build dir for running in QtCreator |
603 | -if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") |
604 | - add_custom_target(konsole-qmldir ALL |
605 | - COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/qmldir ${CMAKE_CURRENT_BINARY_DIR}/../${PLUGIN_DIR} |
606 | - DEPENDS ${QMLFILES} |
607 | - ) |
608 | - add_custom_target(konsole-layouts-schemes ALL |
609 | - COMMAND cp -a ${CMAKE_CURRENT_SOURCE_DIR}/assets/color-schemes ${CMAKE_CURRENT_BINARY_DIR}/../${PLUGIN_DIR} |
610 | - COMMAND cp -a ${CMAKE_CURRENT_SOURCE_DIR}/assets/kb-layouts ${CMAKE_CURRENT_BINARY_DIR}/../${PLUGIN_DIR} |
611 | - DEPENDS ${QMLFILES} |
612 | - ) |
613 | - add_custom_command(TARGET kdekonsole POST_BUILD |
614 | - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/../${PLUGIN_DIR} |
615 | - COMMENT "Creating plugin directory layout in the build dir" |
616 | - COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:kdekonsole> ${CMAKE_CURRENT_BINARY_DIR}/../${PLUGIN_DIR} |
617 | - COMMENT "Copying to output directory" |
618 | - ) |
619 | -endif(NOT "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") |
620 | - |
621 | - |
622 | -install(TARGETS kdekonsole DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN_DIR}) |
623 | -install(FILES qmldir DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN_DIR}) |
624 | -install(DIRECTORY assets/color-schemes DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN_DIR}) |
625 | -install(DIRECTORY assets/kb-layouts DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN_DIR}) |
626 | - |
627 | |
628 | === removed file 'src/plugin/konsole/Character.h' |
629 | --- src/plugin/konsole/Character.h 2014-11-12 00:10:12 +0000 |
630 | +++ src/plugin/konsole/Character.h 1970-01-01 00:00:00 +0000 |
631 | @@ -1,221 +0,0 @@ |
632 | -/* |
633 | - This file is part of Konsole, KDE's terminal. |
634 | - |
635 | - Copyright 2007-2008 by Robert Knight <robertknight@gmail.com> |
636 | - Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de> |
637 | - |
638 | - This program is free software; you can redistribute it and/or modify |
639 | - it under the terms of the GNU General Public License as published by |
640 | - the Free Software Foundation; either version 2 of the License, or |
641 | - (at your option) any later version. |
642 | - |
643 | - This program is distributed in the hope that it will be useful, |
644 | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
645 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
646 | - GNU General Public License for more details. |
647 | - |
648 | - You should have received a copy of the GNU General Public License |
649 | - along with this program; if not, write to the Free Software |
650 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
651 | - 02110-1301 USA. |
652 | -*/ |
653 | - |
654 | -#ifndef CHARACTER_H |
655 | -#define CHARACTER_H |
656 | - |
657 | -// Qt |
658 | -#include <QtCore/QHash> |
659 | - |
660 | -// Local |
661 | -#include "CharacterColor.h" |
662 | - |
663 | -typedef unsigned char LineProperty; |
664 | - |
665 | -static const int LINE_DEFAULT = 0; |
666 | -static const int LINE_WRAPPED = (1 << 0); |
667 | -static const int LINE_DOUBLEWIDTH = (1 << 1); |
668 | -static const int LINE_DOUBLEHEIGHT = (1 << 2); |
669 | - |
670 | -#define DEFAULT_RENDITION 0 |
671 | -#define RE_BOLD (1 << 0) |
672 | -#define RE_BLINK (1 << 1) |
673 | -#define RE_UNDERLINE (1 << 2) |
674 | -#define RE_REVERSE (1 << 3) // Screen only |
675 | -#define RE_INTENSIVE (1 << 3) // Widget only |
676 | -#define RE_CURSOR (1 << 4) |
677 | -#define RE_EXTENDED_CHAR (1 << 5) |
678 | - |
679 | -/** |
680 | - * A single character in the terminal which consists of a unicode character |
681 | - * value, foreground and background colors and a set of rendition attributes |
682 | - * which specify how it should be drawn. |
683 | - */ |
684 | -class Character |
685 | -{ |
686 | -public: |
687 | - /** |
688 | - * Constructs a new character. |
689 | - * |
690 | - * @param _c The unicode character value of this character. |
691 | - * @param _f The foreground color used to draw the character. |
692 | - * @param _b The color used to draw the character's background. |
693 | - * @param _r A set of rendition flags which specify how this character is to be drawn. |
694 | - */ |
695 | - inline Character(quint16 _c = ' ', |
696 | - CharacterColor _f = CharacterColor(COLOR_SPACE_DEFAULT,DEFAULT_FORE_COLOR), |
697 | - CharacterColor _b = CharacterColor(COLOR_SPACE_DEFAULT,DEFAULT_BACK_COLOR), |
698 | - quint8 _r = DEFAULT_RENDITION) |
699 | - : character(_c), rendition(_r), foregroundColor(_f), backgroundColor(_b) {} |
700 | - |
701 | - union |
702 | - { |
703 | - /** The unicode character value for this character. */ |
704 | - quint16 character; |
705 | - /** |
706 | - * Experimental addition which allows a single Character instance to contain more than |
707 | - * one unicode character. |
708 | - * |
709 | - * charSequence is a hash code which can be used to look up the unicode |
710 | - * character sequence in the ExtendedCharTable used to create the sequence. |
711 | - */ |
712 | - quint16 charSequence; |
713 | - }; |
714 | - |
715 | - /** A combination of RENDITION flags which specify options for drawing the character. */ |
716 | - quint8 rendition; |
717 | - |
718 | - /** The foreground color used to draw this character. */ |
719 | - CharacterColor foregroundColor; |
720 | - /** The color used to draw this character's background. */ |
721 | - CharacterColor backgroundColor; |
722 | - |
723 | - /** |
724 | - * Returns true if this character has a transparent background when |
725 | - * it is drawn with the specified @p palette. |
726 | - */ |
727 | - bool isTransparent(const ColorEntry* palette) const; |
728 | - /** |
729 | - * Returns true if this character should always be drawn in bold when |
730 | - * it is drawn with the specified @p palette, independent of whether |
731 | - * or not the character has the RE_BOLD rendition flag. |
732 | - */ |
733 | - ColorEntry::FontWeight fontWeight(const ColorEntry* base) const; |
734 | - |
735 | - /** |
736 | - * returns true if the format (color, rendition flag) of the compared characters is equal |
737 | - */ |
738 | - bool equalsFormat(const Character &other) const; |
739 | - |
740 | - /** |
741 | - * Compares two characters and returns true if they have the same unicode character value, |
742 | - * rendition and colors. |
743 | - */ |
744 | - friend bool operator == (const Character& a, const Character& b); |
745 | - /** |
746 | - * Compares two characters and returns true if they have different unicode character values, |
747 | - * renditions or colors. |
748 | - */ |
749 | - friend bool operator != (const Character& a, const Character& b); |
750 | -}; |
751 | - |
752 | -inline bool operator == (const Character& a, const Character& b) |
753 | -{ |
754 | - return a.character == b.character && |
755 | - a.rendition == b.rendition && |
756 | - a.foregroundColor == b.foregroundColor && |
757 | - a.backgroundColor == b.backgroundColor; |
758 | -} |
759 | - |
760 | -inline bool operator != (const Character& a, const Character& b) |
761 | -{ |
762 | - return a.character != b.character || |
763 | - a.rendition != b.rendition || |
764 | - a.foregroundColor != b.foregroundColor || |
765 | - a.backgroundColor != b.backgroundColor; |
766 | -} |
767 | - |
768 | -inline bool Character::isTransparent(const ColorEntry* base) const |
769 | -{ |
770 | - return ((backgroundColor._colorSpace == COLOR_SPACE_DEFAULT) && |
771 | - base[backgroundColor._u+0+(backgroundColor._v?BASE_COLORS:0)].transparent) |
772 | - || ((backgroundColor._colorSpace == COLOR_SPACE_SYSTEM) && |
773 | - base[backgroundColor._u+2+(backgroundColor._v?BASE_COLORS:0)].transparent); |
774 | -} |
775 | - |
776 | -inline bool Character::equalsFormat(const Character& other) const |
777 | -{ |
778 | - return |
779 | - backgroundColor==other.backgroundColor && |
780 | - foregroundColor==other.foregroundColor && |
781 | - rendition==other.rendition; |
782 | -} |
783 | - |
784 | -inline ColorEntry::FontWeight Character::fontWeight(const ColorEntry* base) const |
785 | -{ |
786 | - if (backgroundColor._colorSpace == COLOR_SPACE_DEFAULT) |
787 | - return base[backgroundColor._u+0+(backgroundColor._v?BASE_COLORS:0)].fontWeight; |
788 | - else if (backgroundColor._colorSpace == COLOR_SPACE_SYSTEM) |
789 | - return base[backgroundColor._u+2+(backgroundColor._v?BASE_COLORS:0)].fontWeight; |
790 | - else |
791 | - return ColorEntry::UseCurrentFormat; |
792 | -} |
793 | - |
794 | -extern unsigned short vt100_graphics[32]; |
795 | - |
796 | - |
797 | -/** |
798 | - * A table which stores sequences of unicode characters, referenced |
799 | - * by hash keys. The hash key itself is the same size as a unicode |
800 | - * character ( ushort ) so that it can occupy the same space in |
801 | - * a structure. |
802 | - */ |
803 | -class ExtendedCharTable |
804 | -{ |
805 | -public: |
806 | - /** Constructs a new character table. */ |
807 | - ExtendedCharTable(); |
808 | - ~ExtendedCharTable(); |
809 | - |
810 | - /** |
811 | - * Adds a sequences of unicode characters to the table and returns |
812 | - * a hash code which can be used later to look up the sequence |
813 | - * using lookupExtendedChar() |
814 | - * |
815 | - * If the same sequence already exists in the table, the hash |
816 | - * of the existing sequence will be returned. |
817 | - * |
818 | - * @param unicodePoints An array of unicode character points |
819 | - * @param length Length of @p unicodePoints |
820 | - */ |
821 | - ushort createExtendedChar(ushort* unicodePoints , ushort length); |
822 | - /** |
823 | - * Looks up and returns a pointer to a sequence of unicode characters |
824 | - * which was added to the table using createExtendedChar(). |
825 | - * |
826 | - * @param hash The hash key returned by createExtendedChar() |
827 | - * @param length This variable is set to the length of the |
828 | - * character sequence. |
829 | - * |
830 | - * @return A unicode character sequence of size @p length. |
831 | - */ |
832 | - ushort* lookupExtendedChar(ushort hash , ushort& length) const; |
833 | - |
834 | - /** The global ExtendedCharTable instance. */ |
835 | - static ExtendedCharTable instance; |
836 | -private: |
837 | - // calculates the hash key of a sequence of unicode points of size 'length' |
838 | - ushort extendedCharHash(ushort* unicodePoints , ushort length) const; |
839 | - // tests whether the entry in the table specified by 'hash' matches the |
840 | - // character sequence 'unicodePoints' of size 'length' |
841 | - bool extendedCharMatch(ushort hash , ushort* unicodePoints , ushort length) const; |
842 | - // internal, maps hash keys to character sequence buffers. The first ushort |
843 | - // in each value is the length of the buffer, followed by the ushorts in the buffer |
844 | - // themselves. |
845 | - QHash<ushort,ushort*> extendedCharTable; |
846 | -}; |
847 | - |
848 | - |
849 | -Q_DECLARE_TYPEINFO(Character, Q_MOVABLE_TYPE); |
850 | - |
851 | -#endif // CHARACTER_H |
852 | - |
853 | |
854 | === removed file 'src/plugin/konsole/CharacterColor.h' |
855 | --- src/plugin/konsole/CharacterColor.h 2014-11-12 00:10:12 +0000 |
856 | +++ src/plugin/konsole/CharacterColor.h 1970-01-01 00:00:00 +0000 |
857 | @@ -1,294 +0,0 @@ |
858 | -/* |
859 | - This file is part of Konsole, KDE's terminal. |
860 | - |
861 | - Copyright 2007-2008 by Robert Knight <robertknight@gmail.com> |
862 | - Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de> |
863 | - |
864 | - This program is free software; you can redistribute it and/or modify |
865 | - it under the terms of the GNU General Public License as published by |
866 | - the Free Software Foundation; either version 2 of the License, or |
867 | - (at your option) any later version. |
868 | - |
869 | - This program is distributed in the hope that it will be useful, |
870 | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
871 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
872 | - GNU General Public License for more details. |
873 | - |
874 | - You should have received a copy of the GNU General Public License |
875 | - along with this program; if not, write to the Free Software |
876 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
877 | - 02110-1301 USA. |
878 | -*/ |
879 | - |
880 | -#ifndef CHARACTERCOLOR_H |
881 | -#define CHARACTERCOLOR_H |
882 | - |
883 | -// Qt |
884 | -#include <QtGui/QColor> |
885 | - |
886 | -//#include <kdemacros.h> |
887 | -#define KDE_NO_EXPORT |
888 | - |
889 | -/** |
890 | - * An entry in a terminal display's color palette. |
891 | - * |
892 | - * A color palette is an array of 16 ColorEntry instances which map |
893 | - * system color indexes (from 0 to 15) into actual colors. |
894 | - * |
895 | - * Each entry can be set as bold, in which case any text |
896 | - * drawn using the color should be drawn in bold. |
897 | - * |
898 | - * Each entry can also be transparent, in which case the terminal |
899 | - * display should avoid drawing the background for any characters |
900 | - * using the entry as a background. |
901 | - */ |
902 | -class ColorEntry |
903 | -{ |
904 | -public: |
905 | - /** Specifies the weight to use when drawing text with this color. */ |
906 | - enum FontWeight |
907 | - { |
908 | - /** Always draw text in this color with a bold weight. */ |
909 | - Bold, |
910 | - /** Always draw text in this color with a normal weight. */ |
911 | - Normal, |
912 | - /** |
913 | - * Use the current font weight set by the terminal application. |
914 | - * This is the default behavior. |
915 | - */ |
916 | - UseCurrentFormat |
917 | - }; |
918 | - |
919 | - /** |
920 | - * Constructs a new color palette entry. |
921 | - * |
922 | - * @param c The color value for this entry. |
923 | - * @param tr Specifies that the color should be transparent when used as a background color. |
924 | - * @param weight Specifies the font weight to use when drawing text with this color. |
925 | - */ |
926 | - ColorEntry(QColor c, bool tr, FontWeight weight = UseCurrentFormat) |
927 | - : color(c), transparent(tr), fontWeight(weight) {} |
928 | - |
929 | - /** |
930 | - * Constructs a new color palette entry with an undefined color, and |
931 | - * with the transparent and bold flags set to false. |
932 | - */ |
933 | - ColorEntry() : transparent(false), fontWeight(UseCurrentFormat) {} |
934 | - |
935 | - /** |
936 | - * Sets the color, transparency and boldness of this color to those of @p rhs. |
937 | - */ |
938 | - void operator=(const ColorEntry& rhs) |
939 | - { |
940 | - color = rhs.color; |
941 | - transparent = rhs.transparent; |
942 | - fontWeight = rhs.fontWeight; |
943 | - } |
944 | - |
945 | - /** The color value of this entry for display. */ |
946 | - QColor color; |
947 | - |
948 | - /** |
949 | - * If true character backgrounds using this color should be transparent. |
950 | - * This is not applicable when the color is used to render text. |
951 | - */ |
952 | - bool transparent; |
953 | - /** |
954 | - * Specifies the font weight to use when drawing text with this color. |
955 | - * This is not applicable when the color is used to draw a character's background. |
956 | - */ |
957 | - FontWeight fontWeight; |
958 | -}; |
959 | - |
960 | - |
961 | -// Attributed Character Representations /////////////////////////////// |
962 | - |
963 | -// Colors |
964 | - |
965 | -#define BASE_COLORS (2+8) |
966 | -#define INTENSITIES 2 |
967 | -#define TABLE_COLORS (INTENSITIES*BASE_COLORS) |
968 | - |
969 | -#define DEFAULT_FORE_COLOR 0 |
970 | -#define DEFAULT_BACK_COLOR 1 |
971 | - |
972 | -//a standard set of colors using black text on a white background. |
973 | -//defined in TerminalDisplay.cpp |
974 | - |
975 | -extern const ColorEntry base_color_table[TABLE_COLORS] KDE_NO_EXPORT; |
976 | - |
977 | -/* CharacterColor is a union of the various color spaces. |
978 | - |
979 | - Assignment is as follows: |
980 | - |
981 | - Type - Space - Values |
982 | - |
983 | - 0 - Undefined - u: 0, v:0 w:0 |
984 | - 1 - Default - u: 0..1 v:intense w:0 |
985 | - 2 - System - u: 0..7 v:intense w:0 |
986 | - 3 - Index(256) - u: 16..255 v:0 w:0 |
987 | - 4 - RGB - u: 0..255 v:0..256 w:0..256 |
988 | - |
989 | - Default colour space has two separate colours, namely |
990 | - default foreground and default background colour. |
991 | -*/ |
992 | - |
993 | -#define COLOR_SPACE_UNDEFINED 0 |
994 | -#define COLOR_SPACE_DEFAULT 1 |
995 | -#define COLOR_SPACE_SYSTEM 2 |
996 | -#define COLOR_SPACE_256 3 |
997 | -#define COLOR_SPACE_RGB 4 |
998 | - |
999 | -/** |
1000 | - * Describes the color of a single character in the terminal. |
1001 | - */ |
1002 | -class CharacterColor |
1003 | -{ |
1004 | - friend class Character; |
1005 | - |
1006 | -public: |
1007 | - /** Constructs a new CharacterColor whoose color and color space are undefined. */ |
1008 | - CharacterColor() |
1009 | - : _colorSpace(COLOR_SPACE_UNDEFINED), |
1010 | - _u(0), |
1011 | - _v(0), |
1012 | - _w(0) |
1013 | - {} |
1014 | - |
1015 | - /** |
1016 | - * Constructs a new CharacterColor using the specified @p colorSpace and with |
1017 | - * color value @p co |
1018 | - * |
1019 | - * The meaning of @p co depends on the @p colorSpace used. |
1020 | - * |
1021 | - * TODO : Document how @p co relates to @p colorSpace |
1022 | - * |
1023 | - * TODO : Add documentation about available color spaces. |
1024 | - */ |
1025 | - CharacterColor(quint8 colorSpace, int co) |
1026 | - : _colorSpace(colorSpace), |
1027 | - _u(0), |
1028 | - _v(0), |
1029 | - _w(0) |
1030 | - { |
1031 | - switch (colorSpace) |
1032 | - { |
1033 | - case COLOR_SPACE_DEFAULT: |
1034 | - _u = co & 1; |
1035 | - break; |
1036 | - case COLOR_SPACE_SYSTEM: |
1037 | - _u = co & 7; |
1038 | - _v = (co >> 3) & 1; |
1039 | - break; |
1040 | - case COLOR_SPACE_256: |
1041 | - _u = co & 255; |
1042 | - break; |
1043 | - case COLOR_SPACE_RGB: |
1044 | - _u = co >> 16; |
1045 | - _v = co >> 8; |
1046 | - _w = co; |
1047 | - break; |
1048 | - default: |
1049 | - _colorSpace = COLOR_SPACE_UNDEFINED; |
1050 | - } |
1051 | - } |
1052 | - |
1053 | - /** |
1054 | - * Returns true if this character color entry is valid. |
1055 | - */ |
1056 | - bool isValid() |
1057 | - { |
1058 | - return _colorSpace != COLOR_SPACE_UNDEFINED; |
1059 | - } |
1060 | - |
1061 | - /** |
1062 | - * Toggles the value of this color between a normal system color and the corresponding intensive |
1063 | - * system color. |
1064 | - * |
1065 | - * This is only applicable if the color is using the COLOR_SPACE_DEFAULT or COLOR_SPACE_SYSTEM |
1066 | - * color spaces. |
1067 | - */ |
1068 | - void toggleIntensive(); |
1069 | - |
1070 | - /** |
1071 | - * Returns the color within the specified color @p palette |
1072 | - * |
1073 | - * The @p palette is only used if this color is one of the 16 system colors, otherwise |
1074 | - * it is ignored. |
1075 | - */ |
1076 | - QColor color(const ColorEntry* palette) const; |
1077 | - |
1078 | - /** |
1079 | - * Compares two colors and returns true if they represent the same color value and |
1080 | - * use the same color space. |
1081 | - */ |
1082 | - friend bool operator == (const CharacterColor& a, const CharacterColor& b); |
1083 | - /** |
1084 | - * Compares two colors and returns true if they represent different color values |
1085 | - * or use different color spaces. |
1086 | - */ |
1087 | - friend bool operator != (const CharacterColor& a, const CharacterColor& b); |
1088 | - |
1089 | -private: |
1090 | - quint8 _colorSpace; |
1091 | - |
1092 | - // bytes storing the character color |
1093 | - quint8 _u; |
1094 | - quint8 _v; |
1095 | - quint8 _w; |
1096 | -}; |
1097 | - |
1098 | -inline bool operator == (const CharacterColor& a, const CharacterColor& b) |
1099 | -{ |
1100 | - return a._colorSpace == b._colorSpace && |
1101 | - a._u == b._u && |
1102 | - a._v == b._v && |
1103 | - a._w == b._w; |
1104 | -} |
1105 | -inline bool operator != (const CharacterColor& a, const CharacterColor& b) |
1106 | -{ |
1107 | - return !operator==(a,b); |
1108 | -} |
1109 | - |
1110 | -inline const QColor color256(quint8 u, const ColorEntry* base) |
1111 | -{ |
1112 | - // 0.. 16: system colors |
1113 | - if (u < 8) return base[u+2 ].color; u -= 8; |
1114 | - if (u < 8) return base[u+2+BASE_COLORS].color; u -= 8; |
1115 | - |
1116 | - // 16..231: 6x6x6 rgb color cube |
1117 | - if (u < 216) return QColor(((u/36)%6) ? (40*((u/36)%6)+55) : 0, |
1118 | - ((u/ 6)%6) ? (40*((u/ 6)%6)+55) : 0, |
1119 | - ((u/ 1)%6) ? (40*((u/ 1)%6)+55) : 0); u -= 216; |
1120 | - |
1121 | - // 232..255: gray, leaving out black and white |
1122 | - int gray = u*10+8; return QColor(gray,gray,gray); |
1123 | -} |
1124 | - |
1125 | -inline QColor CharacterColor::color(const ColorEntry* base) const |
1126 | -{ |
1127 | - switch (_colorSpace) |
1128 | - { |
1129 | - case COLOR_SPACE_DEFAULT: return base[_u+0+(_v?BASE_COLORS:0)].color; |
1130 | - case COLOR_SPACE_SYSTEM: return base[_u+2+(_v?BASE_COLORS:0)].color; |
1131 | - case COLOR_SPACE_256: return color256(_u,base); |
1132 | - case COLOR_SPACE_RGB: return QColor(_u,_v,_w); |
1133 | - case COLOR_SPACE_UNDEFINED: return QColor(); |
1134 | - } |
1135 | - |
1136 | - Q_ASSERT(false); // invalid color space |
1137 | - |
1138 | - return QColor(); |
1139 | -} |
1140 | - |
1141 | -inline void CharacterColor::toggleIntensive() |
1142 | -{ |
1143 | - if (_colorSpace == COLOR_SPACE_SYSTEM || _colorSpace == COLOR_SPACE_DEFAULT) |
1144 | - { |
1145 | - _v = !_v; |
1146 | - } |
1147 | -} |
1148 | - |
1149 | - |
1150 | -#endif // CHARACTERCOLOR_H |
1151 | - |
1152 | |
1153 | === removed file 'src/plugin/konsole/ColorScheme.cpp' |
1154 | --- src/plugin/konsole/ColorScheme.cpp 2014-11-12 00:10:12 +0000 |
1155 | +++ src/plugin/konsole/ColorScheme.cpp 1970-01-01 00:00:00 +0000 |
1156 | @@ -1,774 +0,0 @@ |
1157 | -/* |
1158 | - This source file is part of Konsole, a terminal emulator. |
1159 | - |
1160 | - Copyright 2007-2008 by Robert Knight <robertknight@gmail.com> |
1161 | - |
1162 | - This program is free software; you can redistribute it and/or modify |
1163 | - it under the terms of the GNU General Public License as published by |
1164 | - the Free Software Foundation; either version 2 of the License, or |
1165 | - (at your option) any later version. |
1166 | - |
1167 | - This program is distributed in the hope that it will be useful, |
1168 | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
1169 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1170 | - GNU General Public License for more details. |
1171 | - |
1172 | - You should have received a copy of the GNU General Public License |
1173 | - along with this program; if not, write to the Free Software |
1174 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
1175 | - 02110-1301 USA. |
1176 | -*/ |
1177 | - |
1178 | -// Own |
1179 | -#include "ColorScheme.h" |
1180 | -#include "tools.h" |
1181 | - |
1182 | -// Qt |
1183 | -#include <QtGui/QBrush> |
1184 | -#include <QtCore/QFile> |
1185 | -#include <QtCore/QFileInfo> |
1186 | -#include <QtDebug> |
1187 | -#include <QSettings> |
1188 | -#include <QDir> |
1189 | - |
1190 | - |
1191 | -// KDE |
1192 | -//#include <KColorScheme> |
1193 | -//#include <KConfig> |
1194 | -//#include <KLocale> |
1195 | -//#include <KDebug> |
1196 | -//#include <KConfigGroup> |
1197 | -//#include <KStandardDirs> |
1198 | - |
1199 | - |
1200 | -const ColorEntry ColorScheme::defaultTable[TABLE_COLORS] = |
1201 | - // The following are almost IBM standard color codes, with some slight |
1202 | - // gamma correction for the dim colors to compensate for bright X screens. |
1203 | - // It contains the 8 ansiterm/xterm colors in 2 intensities. |
1204 | -{ |
1205 | - ColorEntry( QColor(0x00,0x00,0x00), 0), ColorEntry( |
1206 | -QColor(0xFF,0xFF,0xFF), 1), // Dfore, Dback |
1207 | - ColorEntry( QColor(0x00,0x00,0x00), 0), ColorEntry( |
1208 | -QColor(0xB2,0x18,0x18), 0), // Black, Red |
1209 | - ColorEntry( QColor(0x18,0xB2,0x18), 0), ColorEntry( |
1210 | -QColor(0xB2,0x68,0x18), 0), // Green, Yellow |
1211 | - ColorEntry( QColor(0x18,0x18,0xB2), 0), ColorEntry( |
1212 | -QColor(0xB2,0x18,0xB2), 0), // Blue, Magenta |
1213 | - ColorEntry( QColor(0x18,0xB2,0xB2), 0), ColorEntry( |
1214 | -QColor(0xB2,0xB2,0xB2), 0), // Cyan, White |
1215 | - // intensive |
1216 | - ColorEntry( QColor(0x00,0x00,0x00), 0), ColorEntry( |
1217 | -QColor(0xFF,0xFF,0xFF), 1), |
1218 | - ColorEntry( QColor(0x68,0x68,0x68), 0), ColorEntry( |
1219 | -QColor(0xFF,0x54,0x54), 0), |
1220 | - ColorEntry( QColor(0x54,0xFF,0x54), 0), ColorEntry( |
1221 | -QColor(0xFF,0xFF,0x54), 0), |
1222 | - ColorEntry( QColor(0x54,0x54,0xFF), 0), ColorEntry( |
1223 | -QColor(0xFF,0x54,0xFF), 0), |
1224 | - ColorEntry( QColor(0x54,0xFF,0xFF), 0), ColorEntry( |
1225 | -QColor(0xFF,0xFF,0xFF), 0) |
1226 | -}; |
1227 | - |
1228 | -const char* const ColorScheme::colorNames[TABLE_COLORS] = |
1229 | -{ |
1230 | - "Foreground", |
1231 | - "Background", |
1232 | - "Color0", |
1233 | - "Color1", |
1234 | - "Color2", |
1235 | - "Color3", |
1236 | - "Color4", |
1237 | - "Color5", |
1238 | - "Color6", |
1239 | - "Color7", |
1240 | - "ForegroundIntense", |
1241 | - "BackgroundIntense", |
1242 | - "Color0Intense", |
1243 | - "Color1Intense", |
1244 | - "Color2Intense", |
1245 | - "Color3Intense", |
1246 | - "Color4Intense", |
1247 | - "Color5Intense", |
1248 | - "Color6Intense", |
1249 | - "Color7Intense" |
1250 | -}; |
1251 | -// dummy silently comment out the tr_NOOP |
1252 | -#define tr_NOOP |
1253 | -const char* const ColorScheme::translatedColorNames[TABLE_COLORS] = |
1254 | -{ |
1255 | - tr_NOOP("Foreground"), |
1256 | - tr_NOOP("Background"), |
1257 | - tr_NOOP("Color 1"), |
1258 | - tr_NOOP("Color 2"), |
1259 | - tr_NOOP("Color 3"), |
1260 | - tr_NOOP("Color 4"), |
1261 | - tr_NOOP("Color 5"), |
1262 | - tr_NOOP("Color 6"), |
1263 | - tr_NOOP("Color 7"), |
1264 | - tr_NOOP("Color 8"), |
1265 | - tr_NOOP("Foreground (Intense)"), |
1266 | - tr_NOOP("Background (Intense)"), |
1267 | - tr_NOOP("Color 1 (Intense)"), |
1268 | - tr_NOOP("Color 2 (Intense)"), |
1269 | - tr_NOOP("Color 3 (Intense)"), |
1270 | - tr_NOOP("Color 4 (Intense)"), |
1271 | - tr_NOOP("Color 5 (Intense)"), |
1272 | - tr_NOOP("Color 6 (Intense)"), |
1273 | - tr_NOOP("Color 7 (Intense)"), |
1274 | - tr_NOOP("Color 8 (Intense)") |
1275 | -}; |
1276 | - |
1277 | -ColorScheme::ColorScheme() |
1278 | -{ |
1279 | - _table = 0; |
1280 | - _randomTable = 0; |
1281 | - _opacity = 1.0; |
1282 | -} |
1283 | -ColorScheme::ColorScheme(const ColorScheme& other) |
1284 | - : _opacity(other._opacity) |
1285 | - ,_table(0) |
1286 | - ,_randomTable(0) |
1287 | -{ |
1288 | - setName(other.name()); |
1289 | - setDescription(other.description()); |
1290 | - |
1291 | - if ( other._table != 0 ) |
1292 | - { |
1293 | - for ( int i = 0 ; i < TABLE_COLORS ; i++ ) |
1294 | - setColorTableEntry(i,other._table[i]); |
1295 | - } |
1296 | - |
1297 | - if ( other._randomTable != 0 ) |
1298 | - { |
1299 | - for ( int i = 0 ; i < TABLE_COLORS ; i++ ) |
1300 | - { |
1301 | - const RandomizationRange& range = other._randomTable[i]; |
1302 | - setRandomizationRange(i,range.hue,range.saturation,range.value); |
1303 | - } |
1304 | - } |
1305 | -} |
1306 | -ColorScheme::~ColorScheme() |
1307 | -{ |
1308 | - delete[] _table; |
1309 | - delete[] _randomTable; |
1310 | -} |
1311 | - |
1312 | -void ColorScheme::setDescription(const QString& description) { _description = description; } |
1313 | -QString ColorScheme::description() const { return _description; } |
1314 | - |
1315 | -void ColorScheme::setName(const QString& name) { _name = name; } |
1316 | -QString ColorScheme::name() const { return _name; } |
1317 | - |
1318 | -void ColorScheme::setColorTableEntry(int index , const ColorEntry& entry) |
1319 | -{ |
1320 | - Q_ASSERT( index >= 0 && index < TABLE_COLORS ); |
1321 | - |
1322 | - if ( !_table ) |
1323 | - { |
1324 | - _table = new ColorEntry[TABLE_COLORS]; |
1325 | - |
1326 | - for (int i=0;i<TABLE_COLORS;i++) |
1327 | - _table[i] = defaultTable[i]; |
1328 | - } |
1329 | - |
1330 | - _table[index] = entry; |
1331 | -} |
1332 | -ColorEntry ColorScheme::colorEntry(int index , uint randomSeed) const |
1333 | -{ |
1334 | - Q_ASSERT( index >= 0 && index < TABLE_COLORS ); |
1335 | - |
1336 | - if ( randomSeed != 0 ) |
1337 | - qsrand(randomSeed); |
1338 | - |
1339 | - ColorEntry entry = colorTable()[index]; |
1340 | - |
1341 | - if ( randomSeed != 0 && |
1342 | - _randomTable != 0 && |
1343 | - !_randomTable[index].isNull() ) |
1344 | - { |
1345 | - const RandomizationRange& range = _randomTable[index]; |
1346 | - |
1347 | - |
1348 | - int hueDifference = range.hue ? (qrand() % range.hue) - range.hue/2 : 0; |
1349 | - int saturationDifference = range.saturation ? (qrand() % range.saturation) - range.saturation/2 : 0; |
1350 | - int valueDifference = range.value ? (qrand() % range.value) - range.value/2 : 0; |
1351 | - |
1352 | - QColor& color = entry.color; |
1353 | - |
1354 | - int newHue = qAbs( (color.hue() + hueDifference) % MAX_HUE ); |
1355 | - int newValue = qMin( qAbs(color.value() + valueDifference) , 255 ); |
1356 | - int newSaturation = qMin( qAbs(color.saturation() + saturationDifference) , 255 ); |
1357 | - |
1358 | - color.setHsv(newHue,newSaturation,newValue); |
1359 | - } |
1360 | - |
1361 | - return entry; |
1362 | -} |
1363 | -void ColorScheme::getColorTable(ColorEntry* table , uint randomSeed) const |
1364 | -{ |
1365 | - for ( int i = 0 ; i < TABLE_COLORS ; i++ ) |
1366 | - table[i] = colorEntry(i,randomSeed); |
1367 | -} |
1368 | -bool ColorScheme::randomizedBackgroundColor() const |
1369 | -{ |
1370 | - return _randomTable == 0 ? false : !_randomTable[1].isNull(); |
1371 | -} |
1372 | -void ColorScheme::setRandomizedBackgroundColor(bool randomize) |
1373 | -{ |
1374 | - // the hue of the background colour is allowed to be randomly |
1375 | - // adjusted as much as possible. |
1376 | - // |
1377 | - // the value and saturation are left alone to maintain read-ability |
1378 | - if ( randomize ) |
1379 | - { |
1380 | - setRandomizationRange( 1 /* background color index */ , MAX_HUE , 255 , 0 ); |
1381 | - } |
1382 | - else |
1383 | - { |
1384 | - if ( _randomTable ) |
1385 | - setRandomizationRange( 1 /* background color index */ , 0 , 0 , 0 ); |
1386 | - } |
1387 | -} |
1388 | - |
1389 | -void ColorScheme::setRandomizationRange( int index , quint16 hue , quint8 saturation , |
1390 | - quint8 value ) |
1391 | -{ |
1392 | - Q_ASSERT( hue <= MAX_HUE ); |
1393 | - Q_ASSERT( index >= 0 && index < TABLE_COLORS ); |
1394 | - |
1395 | - if ( _randomTable == 0 ) |
1396 | - _randomTable = new RandomizationRange[TABLE_COLORS]; |
1397 | - |
1398 | - _randomTable[index].hue = hue; |
1399 | - _randomTable[index].value = value; |
1400 | - _randomTable[index].saturation = saturation; |
1401 | -} |
1402 | - |
1403 | -const ColorEntry* ColorScheme::colorTable() const |
1404 | -{ |
1405 | - if ( _table ) |
1406 | - return _table; |
1407 | - else |
1408 | - return defaultTable; |
1409 | -} |
1410 | -QColor ColorScheme::foregroundColor() const |
1411 | -{ |
1412 | - return colorTable()[0].color; |
1413 | -} |
1414 | -QColor ColorScheme::backgroundColor() const |
1415 | -{ |
1416 | - return colorTable()[1].color; |
1417 | -} |
1418 | -bool ColorScheme::hasDarkBackground() const |
1419 | -{ |
1420 | - // value can range from 0 - 255, with larger values indicating higher brightness. |
1421 | - // so 127 is in the middle, anything less is deemed 'dark' |
1422 | - return backgroundColor().value() < 127; |
1423 | -} |
1424 | -void ColorScheme::setOpacity(qreal opacity) { _opacity = opacity; } |
1425 | -qreal ColorScheme::opacity() const { return _opacity; } |
1426 | - |
1427 | -void ColorScheme::read(const QString & fileName) |
1428 | -{ |
1429 | - QSettings s(fileName, QSettings::IniFormat); |
1430 | - s.beginGroup("General"); |
1431 | - |
1432 | - _description = s.value("Description", QObject::tr("Un-named Color Scheme")).toString(); |
1433 | - _opacity = s.value("Opacity",qreal(1.0)).toDouble(); |
1434 | - s.endGroup(); |
1435 | - |
1436 | - for (int i=0 ; i < TABLE_COLORS ; i++) |
1437 | - { |
1438 | - readColorEntry(&s, i); |
1439 | - } |
1440 | -} |
1441 | -#if 0 |
1442 | -// implemented upstream - user apps |
1443 | -void ColorScheme::read(KConfig& config) |
1444 | -{ |
1445 | - KConfigGroup configGroup = config.group("General"); |
1446 | - |
1447 | - QString description = configGroup.readEntry("Description", QObject::tr("Un-named Color Scheme")); |
1448 | - |
1449 | - _description = tr(description.toUtf8()); |
1450 | - _opacity = configGroup.readEntry("Opacity",qreal(1.0)); |
1451 | - |
1452 | - for (int i=0 ; i < TABLE_COLORS ; i++) |
1453 | - { |
1454 | - readColorEntry(config,i); |
1455 | - } |
1456 | -} |
1457 | -void ColorScheme::write(KConfig& config) const |
1458 | -{ |
1459 | - KConfigGroup configGroup = config.group("General"); |
1460 | - |
1461 | - configGroup.writeEntry("Description",_description); |
1462 | - configGroup.writeEntry("Opacity",_opacity); |
1463 | - |
1464 | - for (int i=0 ; i < TABLE_COLORS ; i++) |
1465 | - { |
1466 | - RandomizationRange random = _randomTable != 0 ? _randomTable[i] : RandomizationRange(); |
1467 | - writeColorEntry(config,colorNameForIndex(i),colorTable()[i],random); |
1468 | - } |
1469 | -} |
1470 | -#endif |
1471 | - |
1472 | -QString ColorScheme::colorNameForIndex(int index) |
1473 | -{ |
1474 | - Q_ASSERT( index >= 0 && index < TABLE_COLORS ); |
1475 | - |
1476 | - return QString(colorNames[index]); |
1477 | -} |
1478 | -QString ColorScheme::translatedColorNameForIndex(int index) |
1479 | -{ |
1480 | - Q_ASSERT( index >= 0 && index < TABLE_COLORS ); |
1481 | - |
1482 | - return translatedColorNames[index]; |
1483 | -} |
1484 | - |
1485 | -void ColorScheme::readColorEntry(QSettings * s , int index) |
1486 | -{ |
1487 | - s->beginGroup(colorNameForIndex(index)); |
1488 | - |
1489 | - ColorEntry entry; |
1490 | - |
1491 | - QStringList rgbList = s->value("Color", QStringList()).toStringList(); |
1492 | - if (rgbList.count() != 3) |
1493 | - { |
1494 | - Q_ASSERT(0); |
1495 | - } |
1496 | - int r, g, b; |
1497 | - r = rgbList[0].toInt(); |
1498 | - g = rgbList[1].toInt(); |
1499 | - b = rgbList[2].toInt(); |
1500 | - entry.color = QColor(r, g, b); |
1501 | - |
1502 | - entry.transparent = s->value("Transparent",false).toBool(); |
1503 | - |
1504 | - // Deprecated key from KDE 4.0 which set 'Bold' to true to force |
1505 | - // a color to be bold or false to use the current format |
1506 | - // |
1507 | - // TODO - Add a new tri-state key which allows for bold, normal or |
1508 | - // current format |
1509 | - if (s->contains("Bold")) |
1510 | - entry.fontWeight = s->value("Bold",false).toBool() ? ColorEntry::Bold : |
1511 | - ColorEntry::UseCurrentFormat; |
1512 | - |
1513 | - quint16 hue = s->value("MaxRandomHue",0).toInt(); |
1514 | - quint8 value = s->value("MaxRandomValue",0).toInt(); |
1515 | - quint8 saturation = s->value("MaxRandomSaturation",0).toInt(); |
1516 | - |
1517 | - setColorTableEntry( index , entry ); |
1518 | - |
1519 | - if ( hue != 0 || value != 0 || saturation != 0 ) |
1520 | - setRandomizationRange( index , hue , saturation , value ); |
1521 | - |
1522 | - s->endGroup(); |
1523 | -} |
1524 | -#if 0 |
1525 | -// implemented upstream - user apps |
1526 | -void ColorScheme::writeColorEntry(KConfig& config , const QString& colorName, const ColorEntry& entry , const RandomizationRange& random) const |
1527 | -{ |
1528 | - KConfigGroup configGroup(&config,colorName); |
1529 | - |
1530 | - configGroup.writeEntry("Color",entry.color); |
1531 | - configGroup.writeEntry("Transparency",(bool)entry.transparent); |
1532 | - if (entry.fontWeight != ColorEntry::UseCurrentFormat) |
1533 | - { |
1534 | - configGroup.writeEntry("Bold",entry.fontWeight == ColorEntry::Bold); |
1535 | - } |
1536 | - |
1537 | - // record randomization if this color has randomization or |
1538 | - // if one of the keys already exists |
1539 | - if ( !random.isNull() || configGroup.hasKey("MaxRandomHue") ) |
1540 | - { |
1541 | - configGroup.writeEntry("MaxRandomHue",(int)random.hue); |
1542 | - configGroup.writeEntry("MaxRandomValue",(int)random.value); |
1543 | - configGroup.writeEntry("MaxRandomSaturation",(int)random.saturation); |
1544 | - } |
1545 | -} |
1546 | -#endif |
1547 | - |
1548 | -// |
1549 | -// Work In Progress - A color scheme for use on KDE setups for users |
1550 | -// with visual disabilities which means that they may have trouble |
1551 | -// reading text with the supplied color schemes. |
1552 | -// |
1553 | -// This color scheme uses only the 'safe' colors defined by the |
1554 | -// KColorScheme class. |
1555 | -// |
1556 | -// A complication this introduces is that each color provided by |
1557 | -// KColorScheme is defined as a 'background' or 'foreground' color. |
1558 | -// Only foreground colors are allowed to be used to render text and |
1559 | -// only background colors are allowed to be used for backgrounds. |
1560 | -// |
1561 | -// The ColorEntry and TerminalDisplay classes do not currently |
1562 | -// support this restriction. |
1563 | -// |
1564 | -// Requirements: |
1565 | -// - A color scheme which uses only colors from the KColorScheme class |
1566 | -// - Ability to restrict which colors the TerminalDisplay widget |
1567 | -// uses as foreground and background color |
1568 | -// - Make use of KGlobalSettings::allowDefaultBackgroundImages() as |
1569 | -// a hint to determine whether this accessible color scheme should |
1570 | -// be used by default. |
1571 | -// |
1572 | -// |
1573 | -// -- Robert Knight <robertknight@gmail.com> 21/07/2007 |
1574 | -// |
1575 | -AccessibleColorScheme::AccessibleColorScheme() |
1576 | - : ColorScheme() |
1577 | -{ |
1578 | -#if 0 |
1579 | -// It's not finished in konsole and it breaks Qt4 compilation as well |
1580 | - // basic attributes |
1581 | - setName("accessible"); |
1582 | - setDescription(QObject::tr("Accessible Color Scheme")); |
1583 | - |
1584 | - // setup colors |
1585 | - const int ColorRoleCount = 8; |
1586 | - |
1587 | - const KColorScheme colorScheme(QPalette::Active); |
1588 | - |
1589 | - QBrush colors[ColorRoleCount] = |
1590 | - { |
1591 | - colorScheme.foreground( colorScheme.NormalText ), |
1592 | - colorScheme.background( colorScheme.NormalBackground ), |
1593 | - |
1594 | - colorScheme.foreground( colorScheme.InactiveText ), |
1595 | - colorScheme.foreground( colorScheme.ActiveText ), |
1596 | - colorScheme.foreground( colorScheme.LinkText ), |
1597 | - colorScheme.foreground( colorScheme.VisitedText ), |
1598 | - colorScheme.foreground( colorScheme.NegativeText ), |
1599 | - colorScheme.foreground( colorScheme.NeutralText ) |
1600 | - }; |
1601 | - |
1602 | - for ( int i = 0 ; i < TABLE_COLORS ; i++ ) |
1603 | - { |
1604 | - ColorEntry entry; |
1605 | - entry.color = colors[ i % ColorRoleCount ].color(); |
1606 | - |
1607 | - setColorTableEntry( i , entry ); |
1608 | - } |
1609 | -#endif |
1610 | -} |
1611 | - |
1612 | -KDE3ColorSchemeReader::KDE3ColorSchemeReader( QIODevice* device ) : |
1613 | - _device(device) |
1614 | -{ |
1615 | -} |
1616 | -ColorScheme* KDE3ColorSchemeReader::read() |
1617 | -{ |
1618 | - Q_ASSERT( _device->openMode() == QIODevice::ReadOnly || |
1619 | - _device->openMode() == QIODevice::ReadWrite ); |
1620 | - |
1621 | - ColorScheme* scheme = new ColorScheme(); |
1622 | - |
1623 | - QRegExp comment("#.*$"); |
1624 | - while ( !_device->atEnd() ) |
1625 | - { |
1626 | - QString line(_device->readLine()); |
1627 | - line.remove(comment); |
1628 | - line = line.simplified(); |
1629 | - |
1630 | - if ( line.isEmpty() ) |
1631 | - continue; |
1632 | - |
1633 | - if ( line.startsWith(QLatin1String("color")) ) |
1634 | - { |
1635 | - if (!readColorLine(line,scheme)) |
1636 | - qDebug() << "Failed to read KDE 3 color scheme line" << line; |
1637 | - } |
1638 | - else if ( line.startsWith(QLatin1String("title")) ) |
1639 | - { |
1640 | - if (!readTitleLine(line,scheme)) |
1641 | - qDebug() << "Failed to read KDE 3 color scheme title line" << line; |
1642 | - } |
1643 | - else |
1644 | - { |
1645 | - qDebug() << "KDE 3 color scheme contains an unsupported feature, '" << |
1646 | - line << "'"; |
1647 | - } |
1648 | - } |
1649 | - |
1650 | - return scheme; |
1651 | -} |
1652 | -bool KDE3ColorSchemeReader::readColorLine(const QString& line,ColorScheme* scheme) |
1653 | -{ |
1654 | - QStringList list = line.split(QChar(' ')); |
1655 | - |
1656 | - if (list.count() != 7) |
1657 | - return false; |
1658 | - if (list.first() != "color") |
1659 | - return false; |
1660 | - |
1661 | - int index = list[1].toInt(); |
1662 | - int red = list[2].toInt(); |
1663 | - int green = list[3].toInt(); |
1664 | - int blue = list[4].toInt(); |
1665 | - int transparent = list[5].toInt(); |
1666 | - int bold = list[6].toInt(); |
1667 | - |
1668 | - const int MAX_COLOR_VALUE = 255; |
1669 | - |
1670 | - if( (index < 0 || index >= TABLE_COLORS ) |
1671 | - || (red < 0 || red > MAX_COLOR_VALUE ) |
1672 | - || (blue < 0 || blue > MAX_COLOR_VALUE ) |
1673 | - || (green < 0 || green > MAX_COLOR_VALUE ) |
1674 | - || (transparent != 0 && transparent != 1 ) |
1675 | - || (bold != 0 && bold != 1) ) |
1676 | - return false; |
1677 | - |
1678 | - ColorEntry entry; |
1679 | - entry.color = QColor(red,green,blue); |
1680 | - entry.transparent = ( transparent != 0 ); |
1681 | - entry.fontWeight = ( bold != 0 ) ? ColorEntry::Bold : ColorEntry::UseCurrentFormat; |
1682 | - |
1683 | - scheme->setColorTableEntry(index,entry); |
1684 | - return true; |
1685 | -} |
1686 | -bool KDE3ColorSchemeReader::readTitleLine(const QString& line,ColorScheme* scheme) |
1687 | -{ |
1688 | - if( !line.startsWith(QLatin1String("title")) ) |
1689 | - return false; |
1690 | - |
1691 | - int spacePos = line.indexOf(' '); |
1692 | - if( spacePos == -1 ) |
1693 | - return false; |
1694 | - |
1695 | - QString description = line.mid(spacePos+1); |
1696 | - |
1697 | - scheme->setDescription(description.toUtf8()); |
1698 | - return true; |
1699 | -} |
1700 | -ColorSchemeManager::ColorSchemeManager() |
1701 | - : _haveLoadedAll(false) |
1702 | -{ |
1703 | -} |
1704 | -ColorSchemeManager::~ColorSchemeManager() |
1705 | -{ |
1706 | - QHashIterator<QString,const ColorScheme*> iter(_colorSchemes); |
1707 | - while (iter.hasNext()) |
1708 | - { |
1709 | - iter.next(); |
1710 | - delete iter.value(); |
1711 | - } |
1712 | -} |
1713 | -void ColorSchemeManager::loadAllColorSchemes() |
1714 | -{ |
1715 | - qDebug() << "loadAllColorSchemes"; |
1716 | - int success = 0; |
1717 | - int failed = 0; |
1718 | - |
1719 | - QList<QString> nativeColorSchemes = listColorSchemes(); |
1720 | - |
1721 | - QListIterator<QString> nativeIter(nativeColorSchemes); |
1722 | - while ( nativeIter.hasNext() ) |
1723 | - { |
1724 | - if ( loadColorScheme( nativeIter.next() ) ) |
1725 | - success++; |
1726 | - else |
1727 | - failed++; |
1728 | - } |
1729 | - |
1730 | - QList<QString> kde3ColorSchemes = listKDE3ColorSchemes(); |
1731 | - QListIterator<QString> kde3Iter(kde3ColorSchemes); |
1732 | - while ( kde3Iter.hasNext() ) |
1733 | - { |
1734 | - if ( loadKDE3ColorScheme( kde3Iter.next() ) ) |
1735 | - success++; |
1736 | - else |
1737 | - failed++; |
1738 | - } |
1739 | - |
1740 | - if ( failed > 0 ) |
1741 | - qDebug() << "failed to load " << failed << " color schemes."; |
1742 | - |
1743 | - _haveLoadedAll = true; |
1744 | -} |
1745 | -QList<const ColorScheme*> ColorSchemeManager::allColorSchemes() |
1746 | -{ |
1747 | - if ( !_haveLoadedAll ) |
1748 | - { |
1749 | - loadAllColorSchemes(); |
1750 | - } |
1751 | - |
1752 | - return _colorSchemes.values(); |
1753 | -} |
1754 | -bool ColorSchemeManager::loadKDE3ColorScheme(const QString& filePath) |
1755 | -{ |
1756 | - QFile file(filePath); |
1757 | - if (!filePath.endsWith(QLatin1String(".schema")) || !file.open(QIODevice::ReadOnly)) |
1758 | - return false; |
1759 | - |
1760 | - KDE3ColorSchemeReader reader(&file); |
1761 | - ColorScheme* scheme = reader.read(); |
1762 | - scheme->setName(QFileInfo(file).baseName()); |
1763 | - file.close(); |
1764 | - |
1765 | - if (scheme->name().isEmpty()) |
1766 | - { |
1767 | - qDebug() << "color scheme name is not valid."; |
1768 | - delete scheme; |
1769 | - return false; |
1770 | - } |
1771 | - |
1772 | - QFileInfo info(filePath); |
1773 | - |
1774 | - if ( !_colorSchemes.contains(info.baseName()) ) |
1775 | - _colorSchemes.insert(scheme->name(),scheme); |
1776 | - else |
1777 | - { |
1778 | - qDebug() << "color scheme with name" << scheme->name() << "has already been" << |
1779 | - "found, ignoring."; |
1780 | - delete scheme; |
1781 | - } |
1782 | - |
1783 | - return true; |
1784 | -} |
1785 | -#if 0 |
1786 | -void ColorSchemeManager::addColorScheme(ColorScheme* scheme) |
1787 | -{ |
1788 | - _colorSchemes.insert(scheme->name(),scheme); |
1789 | - |
1790 | - // save changes to disk |
1791 | - QString path = KGlobal::dirs()->saveLocation("data","konsole/") + scheme->name() + ".colorscheme"; |
1792 | - KConfig config(path , KConfig::NoGlobals); |
1793 | - |
1794 | - scheme->write(config); |
1795 | -} |
1796 | -#endif |
1797 | -bool ColorSchemeManager::loadColorScheme(const QString& filePath) |
1798 | -{ |
1799 | - if ( !filePath.endsWith(QLatin1String(".colorscheme")) || !QFile::exists(filePath) ) |
1800 | - return false; |
1801 | - |
1802 | - QFileInfo info(filePath); |
1803 | - |
1804 | - ColorScheme* scheme = new ColorScheme(); |
1805 | - scheme->setName(info.baseName()); |
1806 | - scheme->read(filePath); |
1807 | - |
1808 | - if (scheme->name().isEmpty()) |
1809 | - { |
1810 | - qDebug() << "Color scheme in" << filePath << "does not have a valid name and was not loaded."; |
1811 | - delete scheme; |
1812 | - return false; |
1813 | - } |
1814 | - |
1815 | - if ( !_colorSchemes.contains(info.baseName()) ) |
1816 | - { |
1817 | - _colorSchemes.insert(scheme->name(),scheme); |
1818 | - } |
1819 | - else |
1820 | - { |
1821 | - qDebug() << "color scheme with name" << scheme->name() << "has already been" << |
1822 | - "found, ignoring."; |
1823 | - |
1824 | - delete scheme; |
1825 | - } |
1826 | - |
1827 | - return true; |
1828 | -} |
1829 | -QList<QString> ColorSchemeManager::listKDE3ColorSchemes() |
1830 | -{ |
1831 | - QString dname(get_color_schemes_dir()); |
1832 | - QDir dir(dname); |
1833 | - QStringList filters; |
1834 | - filters << "*.schema"; |
1835 | - dir.setNameFilters(filters); |
1836 | - QStringList list = dir.entryList(filters); |
1837 | - QStringList ret; |
1838 | - foreach(QString i, list) |
1839 | - ret << dname + "/" + i; |
1840 | - return ret; |
1841 | - //return KGlobal::dirs()->findAllResources("data", |
1842 | - // "konsole/*.schema", |
1843 | - // KStandardDirs::NoDuplicates); |
1844 | - // |
1845 | -} |
1846 | -QList<QString> ColorSchemeManager::listColorSchemes() |
1847 | -{ |
1848 | - QString dname(get_color_schemes_dir()); |
1849 | - QDir dir(dname); |
1850 | - QStringList filters; |
1851 | - filters << "*.colorscheme"; |
1852 | - dir.setNameFilters(filters); |
1853 | - QStringList list = dir.entryList(filters); |
1854 | - QStringList ret; |
1855 | - foreach(QString i, list) |
1856 | - ret << dname + "/" + i; |
1857 | - return ret; |
1858 | -// return KGlobal::dirs()->findAllResources("data", |
1859 | -// "konsole/*.colorscheme", |
1860 | -// KStandardDirs::NoDuplicates); |
1861 | -} |
1862 | -const ColorScheme ColorSchemeManager::_defaultColorScheme; |
1863 | -const ColorScheme* ColorSchemeManager::defaultColorScheme() const |
1864 | -{ |
1865 | - return &_defaultColorScheme; |
1866 | -} |
1867 | -bool ColorSchemeManager::deleteColorScheme(const QString& name) |
1868 | -{ |
1869 | - Q_ASSERT( _colorSchemes.contains(name) ); |
1870 | - |
1871 | - // lookup the path and delete |
1872 | - QString path = findColorSchemePath(name); |
1873 | - if ( QFile::remove(path) ) |
1874 | - { |
1875 | - _colorSchemes.remove(name); |
1876 | - return true; |
1877 | - } |
1878 | - else |
1879 | - { |
1880 | - qDebug() << "Failed to remove color scheme -" << path; |
1881 | - return false; |
1882 | - } |
1883 | -} |
1884 | -QString ColorSchemeManager::findColorSchemePath(const QString& name) const |
1885 | -{ |
1886 | -// QString path = KStandardDirs::locate("data","konsole/"+name+".colorscheme"); |
1887 | - QString path(get_color_schemes_dir() + "/"+ name + ".colorscheme"); |
1888 | - if ( !path.isEmpty() ) |
1889 | - return path; |
1890 | - |
1891 | - //path = KStandardDirs::locate("data","konsole/"+name+".schema"); |
1892 | - path = get_color_schemes_dir() + "/"+ name + ".schema"; |
1893 | - |
1894 | - return path; |
1895 | -} |
1896 | -const ColorScheme* ColorSchemeManager::findColorScheme(const QString& name) |
1897 | -{ |
1898 | - if ( name.isEmpty() ) |
1899 | - return defaultColorScheme(); |
1900 | - |
1901 | - if ( _colorSchemes.contains(name) ) |
1902 | - return _colorSchemes[name]; |
1903 | - else |
1904 | - { |
1905 | - // look for this color scheme |
1906 | - QString path = findColorSchemePath(name); |
1907 | - if ( !path.isEmpty() && loadColorScheme(path) ) |
1908 | - { |
1909 | - return findColorScheme(name); |
1910 | - } |
1911 | - else |
1912 | - { |
1913 | - if (!path.isEmpty() && loadKDE3ColorScheme(path)) |
1914 | - return findColorScheme(name); |
1915 | - } |
1916 | - |
1917 | - qDebug() << "Could not find color scheme - " << name; |
1918 | - |
1919 | - return 0; |
1920 | - } |
1921 | -} |
1922 | - |
1923 | -ColorSchemeManager* ColorSchemeManager::theColorSchemeManager = 0; |
1924 | -//K_GLOBAL_STATIC( ColorSchemeManager , theColorSchemeManager ) |
1925 | -ColorSchemeManager* ColorSchemeManager::instance() |
1926 | -{ |
1927 | - if (! theColorSchemeManager) |
1928 | - theColorSchemeManager = new ColorSchemeManager(); |
1929 | - return theColorSchemeManager; |
1930 | -} |
1931 | |
1932 | === removed file 'src/plugin/konsole/ColorScheme.h' |
1933 | --- src/plugin/konsole/ColorScheme.h 2014-11-12 00:10:12 +0000 |
1934 | +++ src/plugin/konsole/ColorScheme.h 1970-01-01 00:00:00 +0000 |
1935 | @@ -1,342 +0,0 @@ |
1936 | -/* |
1937 | - This source file is part of Konsole, a terminal emulator. |
1938 | - |
1939 | - Copyright 2007-2008 by Robert Knight <robertknight@gmail.com> |
1940 | - |
1941 | - This program is free software; you can redistribute it and/or modify |
1942 | - it under the terms of the GNU General Public License as published by |
1943 | - the Free Software Foundation; either version 2 of the License, or |
1944 | - (at your option) any later version. |
1945 | - |
1946 | - This program is distributed in the hope that it will be useful, |
1947 | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
1948 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1949 | - GNU General Public License for more details. |
1950 | - |
1951 | - You should have received a copy of the GNU General Public License |
1952 | - along with this program; if not, write to the Free Software |
1953 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
1954 | - 02110-1301 USA. |
1955 | -*/ |
1956 | - |
1957 | -#ifndef COLORSCHEME_H |
1958 | -#define COLORSCHEME_H |
1959 | - |
1960 | -// Qt |
1961 | -#include <QtCore/QHash> |
1962 | -#include <QtCore/QList> |
1963 | -#include <QtCore/QMetaType> |
1964 | -#include <QtCore/QIODevice> |
1965 | -#include <QtCore/QSet> |
1966 | -#include <QSettings> |
1967 | - |
1968 | -// Konsole |
1969 | -#include "CharacterColor.h" |
1970 | - |
1971 | -class QIODevice; |
1972 | -//class KConfig; |
1973 | - |
1974 | - |
1975 | -/** |
1976 | - * Represents a color scheme for a terminal display. |
1977 | - * |
1978 | - * The color scheme includes the palette of colors used to draw the text and character backgrounds |
1979 | - * in the display and the opacity level of the display background. |
1980 | - */ |
1981 | -class ColorScheme |
1982 | -{ |
1983 | -public: |
1984 | - /** |
1985 | - * Constructs a new color scheme which is initialised to the default color set |
1986 | - * for Konsole. |
1987 | - */ |
1988 | - ColorScheme(); |
1989 | - ColorScheme(const ColorScheme& other); |
1990 | - ~ColorScheme(); |
1991 | - |
1992 | - /** Sets the descriptive name of the color scheme. */ |
1993 | - void setDescription(const QString& description); |
1994 | - /** Returns the descriptive name of the color scheme. */ |
1995 | - QString description() const; |
1996 | - |
1997 | - /** Sets the name of the color scheme */ |
1998 | - void setName(const QString& name); |
1999 | - /** Returns the name of the color scheme */ |
2000 | - QString name() const; |
2001 | - |
2002 | -#if 0 |
2003 | -// Implemented upstream - in user apps |
2004 | - /** Reads the color scheme from the specified configuration source */ |
2005 | - void read(KConfig& config); |
2006 | - /** Writes the color scheme to the specified configuration source */ |
2007 | - void write(KConfig& config) const; |
2008 | -#endif |
2009 | - void read(const QString & filename); |
2010 | - |
2011 | - /** Sets a single entry within the color palette. */ |
2012 | - void setColorTableEntry(int index , const ColorEntry& entry); |
2013 | - |
2014 | - /** |
2015 | - * Copies the color entries which form the palette for this color scheme |
2016 | - * into @p table. @p table should be an array with TABLE_COLORS entries. |
2017 | - * |
2018 | - * @param table Array into which the color entries for this color scheme |
2019 | - * are copied. |
2020 | - * @param randomSeed Color schemes may allow certain colors in their |
2021 | - * palette to be randomized. The seed is used to pick the random color. |
2022 | - */ |
2023 | - void getColorTable(ColorEntry* table, uint randomSeed = 0) const; |
2024 | - |
2025 | - /** |
2026 | - * Retrieves a single color entry from the table. |
2027 | - * |
2028 | - * See getColorTable() |
2029 | - */ |
2030 | - ColorEntry colorEntry(int index , uint randomSeed = 0) const; |
2031 | - |
2032 | - /** |
2033 | - * Convenience method. Returns the |
2034 | - * foreground color for this scheme, |
2035 | - * this is the primary color used to draw the |
2036 | - * text in this scheme. |
2037 | - */ |
2038 | - QColor foregroundColor() const; |
2039 | - /** |
2040 | - * Convenience method. Returns the background color for |
2041 | - * this scheme, this is the primary color used to |
2042 | - * draw the terminal background in this scheme. |
2043 | - */ |
2044 | - QColor backgroundColor() const; |
2045 | - |
2046 | - /** |
2047 | - * Returns true if this color scheme has a dark background. |
2048 | - * The background color is said to be dark if it has a value of less than 127 |
2049 | - * in the HSV color space. |
2050 | - */ |
2051 | - bool hasDarkBackground() const; |
2052 | - |
2053 | - /** |
2054 | - * Sets the opacity level of the display background. @p opacity ranges |
2055 | - * between 0 (completely transparent background) and 1 (completely |
2056 | - * opaque background). |
2057 | - * |
2058 | - * Defaults to 1. |
2059 | - * |
2060 | - * TODO: More documentation |
2061 | - */ |
2062 | - void setOpacity(qreal opacity); |
2063 | - /** |
2064 | - * Returns the opacity level for this color scheme, see setOpacity() |
2065 | - * TODO: More documentation |
2066 | - */ |
2067 | - qreal opacity() const; |
2068 | - |
2069 | - /** |
2070 | - * Enables randomization of the background color. This will cause |
2071 | - * the palette returned by getColorTable() and colorEntry() to |
2072 | - * be adjusted depending on the value of the random seed argument |
2073 | - * to them. |
2074 | - */ |
2075 | - void setRandomizedBackgroundColor(bool randomize); |
2076 | - |
2077 | - /** Returns true if the background color is randomized. */ |
2078 | - bool randomizedBackgroundColor() const; |
2079 | - |
2080 | - static QString colorNameForIndex(int index); |
2081 | - static QString translatedColorNameForIndex(int index); |
2082 | - |
2083 | -private: |
2084 | - // specifies how much a particular color can be randomized by |
2085 | - class RandomizationRange |
2086 | - { |
2087 | - public: |
2088 | - RandomizationRange() : hue(0) , saturation(0) , value(0) {} |
2089 | - |
2090 | - bool isNull() const |
2091 | - { |
2092 | - return ( hue == 0 && saturation == 0 && value == 0 ); |
2093 | - } |
2094 | - |
2095 | - quint16 hue; |
2096 | - quint8 saturation; |
2097 | - quint8 value; |
2098 | - }; |
2099 | - |
2100 | - // returns the active color table. if none has been set specifically, |
2101 | - // this is the default color table. |
2102 | - const ColorEntry* colorTable() const; |
2103 | - |
2104 | -#if 0 |
2105 | -// implemented upstream - user apps |
2106 | - // reads a single colour entry from a KConfig source |
2107 | - // and sets the palette entry at 'index' to the entry read. |
2108 | - void readColorEntry(KConfig& config , int index); |
2109 | - // writes a single colour entry to a KConfig source |
2110 | - void writeColorEntry(KConfig& config , const QString& colorName, const ColorEntry& entry,const RandomizationRange& range) const; |
2111 | -#endif |
2112 | - void readColorEntry(QSettings *s, int index); |
2113 | - |
2114 | - // sets the amount of randomization allowed for a particular color |
2115 | - // in the palette. creates the randomization table if |
2116 | - // it does not already exist |
2117 | - void setRandomizationRange( int index , quint16 hue , quint8 saturation , quint8 value ); |
2118 | - |
2119 | - QString _description; |
2120 | - QString _name; |
2121 | - qreal _opacity; |
2122 | - ColorEntry* _table; // pointer to custom color table or 0 if the default |
2123 | - // color scheme is being used |
2124 | - |
2125 | - |
2126 | - static const quint16 MAX_HUE = 340; |
2127 | - |
2128 | - RandomizationRange* _randomTable; // pointer to randomization table or 0 |
2129 | - // if no colors in the color scheme support |
2130 | - // randomization |
2131 | - |
2132 | - static const char* const colorNames[TABLE_COLORS]; |
2133 | - static const char* const translatedColorNames[TABLE_COLORS]; |
2134 | - |
2135 | - static const ColorEntry defaultTable[]; // table of default color entries |
2136 | -}; |
2137 | - |
2138 | -/** |
2139 | - * A color scheme which uses colors from the standard KDE color palette. |
2140 | - * |
2141 | - * This is designed primarily for the benefit of users who are using specially |
2142 | - * designed colors. |
2143 | - * |
2144 | - * TODO Implement and make it the default on systems with specialized KDE |
2145 | - * color schemes. |
2146 | - */ |
2147 | -class AccessibleColorScheme : public ColorScheme |
2148 | -{ |
2149 | -public: |
2150 | - AccessibleColorScheme(); |
2151 | -}; |
2152 | - |
2153 | -/** |
2154 | - * Reads a color scheme stored in the .schema format used in the KDE 3 incarnation |
2155 | - * of Konsole |
2156 | - * |
2157 | - * Only the basic essentials ( title and color palette entries ) are currently |
2158 | - * supported. Additional options such as background image and background |
2159 | - * blend colors are ignored. |
2160 | - */ |
2161 | -class KDE3ColorSchemeReader |
2162 | -{ |
2163 | -public: |
2164 | - /** |
2165 | - * Constructs a new reader which reads from the specified device. |
2166 | - * The device should be open in read-only mode. |
2167 | - */ |
2168 | - KDE3ColorSchemeReader( QIODevice* device ); |
2169 | - |
2170 | - /** |
2171 | - * Reads and parses the contents of the .schema file from the input |
2172 | - * device and returns the ColorScheme defined within it. |
2173 | - * |
2174 | - * Returns a null pointer if an error occurs whilst parsing |
2175 | - * the contents of the file. |
2176 | - */ |
2177 | - ColorScheme* read(); |
2178 | - |
2179 | -private: |
2180 | - // reads a line from the file specifying a colour palette entry |
2181 | - // format is: color [index] [red] [green] [blue] [transparent] [bold] |
2182 | - bool readColorLine(const QString& line , ColorScheme* scheme); |
2183 | - bool readTitleLine(const QString& line , ColorScheme* scheme); |
2184 | - |
2185 | - QIODevice* _device; |
2186 | -}; |
2187 | - |
2188 | -/** |
2189 | - * Manages the color schemes available for use by terminal displays. |
2190 | - * See ColorScheme |
2191 | - */ |
2192 | -class ColorSchemeManager |
2193 | -{ |
2194 | -public: |
2195 | - |
2196 | - /** |
2197 | - * Constructs a new ColorSchemeManager and loads the list |
2198 | - * of available color schemes. |
2199 | - * |
2200 | - * The color schemes themselves are not loaded until they are first |
2201 | - * requested via a call to findColorScheme() |
2202 | - */ |
2203 | - ColorSchemeManager(); |
2204 | - /** |
2205 | - * Destroys the ColorSchemeManager and saves any modified color schemes to disk. |
2206 | - */ |
2207 | - ~ColorSchemeManager(); |
2208 | - |
2209 | - /** |
2210 | - * Returns the default color scheme for Konsole |
2211 | - */ |
2212 | - const ColorScheme* defaultColorScheme() const; |
2213 | - |
2214 | - /** |
2215 | - * Returns the color scheme with the given name or 0 if no |
2216 | - * scheme with that name exists. If @p name is empty, the |
2217 | - * default color scheme is returned. |
2218 | - * |
2219 | - * The first time that a color scheme with a particular name is |
2220 | - * requested, the configuration information is loaded from disk. |
2221 | - */ |
2222 | - const ColorScheme* findColorScheme(const QString& name); |
2223 | - |
2224 | -#if 0 |
2225 | - /** |
2226 | - * Adds a new color scheme to the manager. If @p scheme has the same name as |
2227 | - * an existing color scheme, it replaces the existing scheme. |
2228 | - * |
2229 | - * TODO - Ensure the old color scheme gets deleted |
2230 | - */ |
2231 | - void addColorScheme(ColorScheme* scheme); |
2232 | -#endif |
2233 | - /** |
2234 | - * Deletes a color scheme. Returns true on successful deletion or false otherwise. |
2235 | - */ |
2236 | - bool deleteColorScheme(const QString& name); |
2237 | - |
2238 | - /** |
2239 | - * Returns a list of the all the available color schemes. |
2240 | - * This may be slow when first called because all of the color |
2241 | - * scheme resources on disk must be located, read and parsed. |
2242 | - * |
2243 | - * Subsequent calls will be inexpensive. |
2244 | - */ |
2245 | - QList<const ColorScheme*> allColorSchemes(); |
2246 | - |
2247 | - /** Returns the global color scheme manager instance. */ |
2248 | - static ColorSchemeManager* instance(); |
2249 | - |
2250 | -private: |
2251 | - // loads a color scheme from a KDE 4+ .colorscheme file |
2252 | - bool loadColorScheme(const QString& path); |
2253 | - // loads a color scheme from a KDE 3 .schema file |
2254 | - bool loadKDE3ColorScheme(const QString& path); |
2255 | - // returns a list of paths of color schemes in the KDE 4+ .colorscheme file format |
2256 | - QList<QString> listColorSchemes(); |
2257 | - // returns a list of paths of color schemes in the .schema file format |
2258 | - // used in KDE 3 |
2259 | - QList<QString> listKDE3ColorSchemes(); |
2260 | - // loads all of the color schemes |
2261 | - void loadAllColorSchemes(); |
2262 | - // finds the path of a color scheme |
2263 | - QString findColorSchemePath(const QString& name) const; |
2264 | - |
2265 | - QHash<QString,const ColorScheme*> _colorSchemes; |
2266 | - QSet<ColorScheme*> _modifiedSchemes; |
2267 | - |
2268 | - bool _haveLoadedAll; |
2269 | - |
2270 | - static const ColorScheme _defaultColorScheme; |
2271 | - |
2272 | - static ColorSchemeManager * theColorSchemeManager; |
2273 | -}; |
2274 | - |
2275 | -Q_DECLARE_METATYPE(const ColorScheme*) |
2276 | - |
2277 | -#endif //COLORSCHEME_H |
2278 | |
2279 | === removed file 'src/plugin/konsole/ColorTables.h' |
2280 | --- src/plugin/konsole/ColorTables.h 2014-11-12 00:10:12 +0000 |
2281 | +++ src/plugin/konsole/ColorTables.h 1970-01-01 00:00:00 +0000 |
2282 | @@ -1,55 +0,0 @@ |
2283 | -#ifndef _COLOR_TABLE_H |
2284 | -#define _COLOR_TABLE_H |
2285 | - |
2286 | -#include "CharacterColor.h" |
2287 | - |
2288 | -//using namespace Konsole; |
2289 | -#if 0 |
2290 | -static const ColorEntry whiteonblack_color_table[TABLE_COLORS] = { |
2291 | - // normal |
2292 | - ColorEntry(QColor(0xFF,0xFF,0xFF), false ), ColorEntry( QColor(0x00,0x00,0x00), true ), // Dfore, Dback |
2293 | - ColorEntry(QColor(0x00,0x00,0x00), false ), ColorEntry( QColor(0xB2,0x18,0x18), false ), // Black, Red |
2294 | - ColorEntry(QColor(0x18,0xB2,0x18), false ), ColorEntry( QColor(0xB2,0x68,0x18), false ), // Green, Yellow |
2295 | - ColorEntry(QColor(0x18,0x18,0xB2), false ), ColorEntry( QColor(0xB2,0x18,0xB2), false ), // Blue, Magenta |
2296 | - ColorEntry(QColor(0x18,0xB2,0xB2), false ), ColorEntry( QColor(0xB2,0xB2,0xB2), false ), // Cyan, White |
2297 | - // intensiv |
2298 | - ColorEntry(QColor(0x00,0x00,0x00), false ), ColorEntry( QColor(0xFF,0xFF,0xFF), true ), |
2299 | - ColorEntry(QColor(0x68,0x68,0x68), false ), ColorEntry( QColor(0xFF,0x54,0x54), false ), |
2300 | - ColorEntry(QColor(0x54,0xFF,0x54), false ), ColorEntry( QColor(0xFF,0xFF,0x54), false ), |
2301 | - ColorEntry(QColor(0x54,0x54,0xFF), false ), ColorEntry( QColor(0xFF,0x54,0xFF), false ), |
2302 | - ColorEntry(QColor(0x54,0xFF,0xFF), false ), ColorEntry( QColor(0xFF,0xFF,0xFF), false ) |
2303 | -}; |
2304 | - |
2305 | -static const ColorEntry greenonblack_color_table[TABLE_COLORS] = { |
2306 | - ColorEntry(QColor( 24, 240, 24), false), ColorEntry(QColor( 0, 0, 0), true), |
2307 | - ColorEntry(QColor( 0, 0, 0), false), ColorEntry(QColor( 178, 24, 24), false), |
2308 | - ColorEntry(QColor( 24, 178, 24), false), ColorEntry(QColor( 178, 104, 24), false), |
2309 | - ColorEntry(QColor( 24, 24, 178), false), ColorEntry(QColor( 178, 24, 178), false), |
2310 | - ColorEntry(QColor( 24, 178, 178), false), ColorEntry(QColor( 178, 178, 178), false), |
2311 | - // intensive colors |
2312 | - ColorEntry(QColor( 24, 240, 24), false ), ColorEntry(QColor( 0, 0, 0), true ), |
2313 | - ColorEntry(QColor( 104, 104, 104), false ), ColorEntry(QColor( 255, 84, 84), false ), |
2314 | - ColorEntry(QColor( 84, 255, 84), false ), ColorEntry(QColor( 255, 255, 84), false ), |
2315 | - ColorEntry(QColor( 84, 84, 255), false ), ColorEntry(QColor( 255, 84, 255), false ), |
2316 | - ColorEntry(QColor( 84, 255, 255), false ), ColorEntry(QColor( 255, 255, 255), false ) |
2317 | -}; |
2318 | - |
2319 | -static const ColorEntry blackonlightyellow_color_table[TABLE_COLORS] = { |
2320 | - ColorEntry(QColor( 0, 0, 0), false), ColorEntry(QColor( 255, 255, 221), true), |
2321 | - ColorEntry(QColor( 0, 0, 0), false), ColorEntry(QColor( 178, 24, 24), false), |
2322 | - ColorEntry(QColor( 24, 178, 24), false), ColorEntry(QColor( 178, 104, 24), false), |
2323 | - ColorEntry(QColor( 24, 24, 178), false), ColorEntry(QColor( 178, 24, 178), false), |
2324 | - ColorEntry(QColor( 24, 178, 178), false), ColorEntry(QColor( 178, 178, 178), false), |
2325 | - ColorEntry(QColor( 0, 0, 0), false), ColorEntry(QColor( 255, 255, 221), true), |
2326 | - ColorEntry(QColor(104, 104, 104), false), ColorEntry(QColor( 255, 84, 84), false), |
2327 | - ColorEntry(QColor( 84, 255, 84), false), ColorEntry(QColor( 255, 255, 84), false), |
2328 | - ColorEntry(QColor( 84, 84, 255), false), ColorEntry(QColor( 255, 84, 255), false), |
2329 | - ColorEntry(QColor( 84, 255, 255), false), ColorEntry(QColor( 255, 255, 255), false) |
2330 | -}; |
2331 | - |
2332 | - |
2333 | -#endif |
2334 | - |
2335 | - |
2336 | -#endif |
2337 | - |
2338 | |
2339 | === removed file 'src/plugin/konsole/DefaultTranslatorText.h' |
2340 | --- src/plugin/konsole/DefaultTranslatorText.h 2014-11-12 00:10:12 +0000 |
2341 | +++ src/plugin/konsole/DefaultTranslatorText.h 1970-01-01 00:00:00 +0000 |
2342 | @@ -1,2 +0,0 @@ |
2343 | -"keyboard \"Fallback Key Translator\"\n" |
2344 | -"key Tab : \"\\t\" \0" |
2345 | |
2346 | === removed file 'src/plugin/konsole/Emulation.cpp' |
2347 | --- src/plugin/konsole/Emulation.cpp 2014-11-12 00:10:12 +0000 |
2348 | +++ src/plugin/konsole/Emulation.cpp 1970-01-01 00:00:00 +0000 |
2349 | @@ -1,458 +0,0 @@ |
2350 | -/* |
2351 | - Copyright 2007-2008 Robert Knight <robertknight@gmail.com> |
2352 | - Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de> |
2353 | - Copyright 1996 by Matthias Ettrich <ettrich@kde.org> |
2354 | - |
2355 | - This program is free software; you can redistribute it and/or modify |
2356 | - it under the terms of the GNU General Public License as published by |
2357 | - the Free Software Foundation; either version 2 of the License, or |
2358 | - (at your option) any later version. |
2359 | - |
2360 | - This program is distributed in the hope that it will be useful, |
2361 | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
2362 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2363 | - GNU General Public License for more details. |
2364 | - |
2365 | - You should have received a copy of the GNU General Public License |
2366 | - along with this program; if not, write to the Free Software |
2367 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
2368 | - 02110-1301 USA. |
2369 | -*/ |
2370 | - |
2371 | -// Own |
2372 | -#include "Emulation.h" |
2373 | - |
2374 | -// System |
2375 | -#include <assert.h> |
2376 | -#include <stdio.h> |
2377 | -#include <stdlib.h> |
2378 | -#include <unistd.h> |
2379 | - |
2380 | -// Qt |
2381 | -#include <QGuiApplication> |
2382 | -#include <QtGui/QClipboard> |
2383 | -#include <QtCore/QHash> |
2384 | -#include <QtGui/QKeyEvent> |
2385 | -#include <QtCore/QRegExp> |
2386 | -#include <QtCore/QTextStream> |
2387 | -#include <QtCore/QThread> |
2388 | - |
2389 | -#include <QtCore/QTime> |
2390 | - |
2391 | -// KDE |
2392 | -//#include <kdebug.h> |
2393 | - |
2394 | -// Konsole |
2395 | -#include "KeyboardTranslator.h" |
2396 | -#include "Screen.h" |
2397 | -#include "TerminalCharacterDecoder.h" |
2398 | -#include "ScreenWindow.h" |
2399 | - |
2400 | -Emulation::Emulation() : |
2401 | - _currentScreen(0), |
2402 | - _codec(0), |
2403 | - _decoder(0), |
2404 | - _keyTranslator(0), |
2405 | - _usesMouse(false) |
2406 | -{ |
2407 | - // create screens with a default size |
2408 | - _screen[0] = new Screen(40,80); |
2409 | - _screen[1] = new Screen(40,80); |
2410 | - _currentScreen = _screen[0]; |
2411 | - |
2412 | - QObject::connect(&_bulkTimer1, SIGNAL(timeout()), this, SLOT(showBulk()) ); |
2413 | - QObject::connect(&_bulkTimer2, SIGNAL(timeout()), this, SLOT(showBulk()) ); |
2414 | - |
2415 | - // listen for mouse status changes |
2416 | - connect( this , SIGNAL(programUsesMouseChanged(bool)) , |
2417 | - SLOT(usesMouseChanged(bool)) ); |
2418 | -} |
2419 | - |
2420 | -bool Emulation::programUsesMouse() const |
2421 | -{ |
2422 | - return _usesMouse; |
2423 | -} |
2424 | - |
2425 | -void Emulation::usesMouseChanged(bool usesMouse) |
2426 | -{ |
2427 | - _usesMouse = usesMouse; |
2428 | -} |
2429 | - |
2430 | -ScreenWindow* Emulation::createWindow() |
2431 | -{ |
2432 | - ScreenWindow* window = new ScreenWindow(); |
2433 | - window->setScreen(_currentScreen); |
2434 | - _windows << window; |
2435 | - |
2436 | - connect(window , SIGNAL(selectionChanged()), |
2437 | - this , SLOT(bufferedUpdate())); |
2438 | - |
2439 | - connect(this , SIGNAL(outputChanged()), |
2440 | - window , SLOT(notifyOutputChanged()) ); |
2441 | - return window; |
2442 | -} |
2443 | - |
2444 | -Emulation::~Emulation() |
2445 | -{ |
2446 | - QListIterator<ScreenWindow*> windowIter(_windows); |
2447 | - |
2448 | - while (windowIter.hasNext()) |
2449 | - { |
2450 | - delete windowIter.next(); |
2451 | - } |
2452 | - |
2453 | - delete _screen[0]; |
2454 | - delete _screen[1]; |
2455 | - delete _decoder; |
2456 | -} |
2457 | - |
2458 | -void Emulation::setScreen(int n) |
2459 | -{ |
2460 | - Screen *old = _currentScreen; |
2461 | - _currentScreen = _screen[n & 1]; |
2462 | - if (_currentScreen != old) |
2463 | - { |
2464 | - // tell all windows onto this emulation to switch to the newly active screen |
2465 | - foreach(ScreenWindow* window,_windows) |
2466 | - window->setScreen(_currentScreen); |
2467 | - } |
2468 | -} |
2469 | - |
2470 | -void Emulation::clearHistory() |
2471 | -{ |
2472 | - _screen[0]->setScroll( _screen[0]->getScroll() , false ); |
2473 | -} |
2474 | -void Emulation::setHistory(const HistoryType& t) |
2475 | -{ |
2476 | - _screen[0]->setScroll(t); |
2477 | - |
2478 | - showBulk(); |
2479 | -} |
2480 | - |
2481 | -const HistoryType& Emulation::history() const |
2482 | -{ |
2483 | - return _screen[0]->getScroll(); |
2484 | -} |
2485 | - |
2486 | -void Emulation::setCodec(const QTextCodec * qtc) |
2487 | -{ |
2488 | - if (qtc) |
2489 | - _codec = qtc; |
2490 | - else |
2491 | - setCodec(LocaleCodec); |
2492 | - |
2493 | - delete _decoder; |
2494 | - _decoder = _codec->makeDecoder(); |
2495 | - |
2496 | - emit useUtf8Request(utf8()); |
2497 | -} |
2498 | - |
2499 | -void Emulation::setCodec(EmulationCodec codec) |
2500 | -{ |
2501 | - if ( codec == Utf8Codec ) |
2502 | - setCodec( QTextCodec::codecForName("utf8") ); |
2503 | - else if ( codec == LocaleCodec ) |
2504 | - setCodec( QTextCodec::codecForLocale() ); |
2505 | -} |
2506 | - |
2507 | -void Emulation::setKeyBindings(const QString& name) |
2508 | -{ |
2509 | - _keyTranslator = KeyboardTranslatorManager::instance()->findTranslator(name); |
2510 | - if (!_keyTranslator) |
2511 | - { |
2512 | - _keyTranslator = KeyboardTranslatorManager::instance()->defaultTranslator(); |
2513 | - } |
2514 | -} |
2515 | - |
2516 | -QString Emulation::keyBindings() const |
2517 | -{ |
2518 | - return _keyTranslator->name(); |
2519 | -} |
2520 | - |
2521 | -void Emulation::receiveChar(int c) |
2522 | -// process application unicode input to terminal |
2523 | -// this is a trivial scanner |
2524 | -{ |
2525 | - c &= 0xff; |
2526 | - switch (c) |
2527 | - { |
2528 | - case '\b' : _currentScreen->backspace(); break; |
2529 | - case '\t' : _currentScreen->tab(); break; |
2530 | - case '\n' : _currentScreen->newLine(); break; |
2531 | - case '\r' : _currentScreen->toStartOfLine(); break; |
2532 | - case 0x07 : emit stateSet(NOTIFYBELL); |
2533 | - break; |
2534 | - default : _currentScreen->displayCharacter(c); break; |
2535 | - }; |
2536 | -} |
2537 | - |
2538 | -void Emulation::sendKeyEvent( QKeyEvent* ev ) |
2539 | -{ |
2540 | - emit stateSet(NOTIFYNORMAL); |
2541 | - |
2542 | - if (!ev->text().isEmpty()) |
2543 | - { // A block of text |
2544 | - // Note that the text is proper unicode. |
2545 | - // We should do a conversion here |
2546 | - emit sendData(ev->text().toUtf8(),ev->text().length()); |
2547 | - } |
2548 | -} |
2549 | - |
2550 | -void Emulation::sendString(const char*,int) |
2551 | -{ |
2552 | - // default implementation does nothing |
2553 | -} |
2554 | - |
2555 | -void Emulation::sendMouseEvent(int /*buttons*/, int /*column*/, int /*row*/, int /*eventType*/) |
2556 | -{ |
2557 | - // default implementation does nothing |
2558 | -} |
2559 | - |
2560 | -/* |
2561 | - We are doing code conversion from locale to unicode first. |
2562 | -TODO: Character composition from the old code. See #96536 |
2563 | -*/ |
2564 | - |
2565 | -void Emulation::receiveData(const char* text, int length) |
2566 | -{ |
2567 | - emit stateSet(NOTIFYACTIVITY); |
2568 | - |
2569 | - bufferedUpdate(); |
2570 | - |
2571 | - QString unicodeText = _decoder->toUnicode(text,length); |
2572 | - |
2573 | - //send characters to terminal emulator |
2574 | - for (int i=0;i<unicodeText.length();i++) |
2575 | - receiveChar(unicodeText[i].unicode()); |
2576 | - |
2577 | - //look for z-modem indicator |
2578 | - //-- someone who understands more about z-modems that I do may be able to move |
2579 | - //this check into the above for loop? |
2580 | - for (int i=0;i<length;i++) |
2581 | - { |
2582 | - if (text[i] == '\030') |
2583 | - { |
2584 | - if ((length-i-1 > 3) && (strncmp(text+i+1, "B00", 3) == 0)) |
2585 | - emit zmodemDetected(); |
2586 | - } |
2587 | - } |
2588 | -} |
2589 | - |
2590 | -//OLDER VERSION |
2591 | -//This version of onRcvBlock was commented out because |
2592 | -// a) It decoded incoming characters one-by-one, which is slow in the current version of Qt (4.2 tech preview) |
2593 | -// b) It messed up decoding of non-ASCII characters, with the result that (for example) chinese characters |
2594 | -// were not printed properly. |
2595 | -// |
2596 | -//There is something about stopping the _decoder if "we get a control code halfway a multi-byte sequence" (see below) |
2597 | -//which hasn't been ported into the newer function (above). Hopefully someone who understands this better |
2598 | -//can find an alternative way of handling the check. |
2599 | - |
2600 | - |
2601 | -/*void Emulation::onRcvBlock(const char *s, int len) |
2602 | -{ |
2603 | - emit notifySessionState(NOTIFYACTIVITY); |
2604 | - |
2605 | - bufferedUpdate(); |
2606 | - for (int i = 0; i < len; i++) |
2607 | - { |
2608 | - |
2609 | - QString result = _decoder->toUnicode(&s[i],1); |
2610 | - int reslen = result.length(); |
2611 | - |
2612 | - // If we get a control code halfway a multi-byte sequence |
2613 | - // we flush the _decoder and continue with the control code. |
2614 | - if ((s[i] < 32) && (s[i] > 0)) |
2615 | - { |
2616 | - // Flush _decoder |
2617 | - while(!result.length()) |
2618 | - result = _decoder->toUnicode(&s[i],1); |
2619 | - reslen = 1; |
2620 | - result.resize(reslen); |
2621 | - result[0] = QChar(s[i]); |
2622 | - } |
2623 | - |
2624 | - for (int j = 0; j < reslen; j++) |
2625 | - { |
2626 | - if (result[j].characterategory() == QChar::Mark_NonSpacing) |
2627 | - _currentScreen->compose(result.mid(j,1)); |
2628 | - else |
2629 | - onRcvChar(result[j].unicode()); |
2630 | - } |
2631 | - if (s[i] == '\030') |
2632 | - { |
2633 | - if ((len-i-1 > 3) && (strncmp(s+i+1, "B00", 3) == 0)) |
2634 | - emit zmodemDetected(); |
2635 | - } |
2636 | - } |
2637 | -}*/ |
2638 | - |
2639 | -void Emulation::writeToStream( TerminalCharacterDecoder* _decoder , |
2640 | - int startLine , |
2641 | - int endLine) |
2642 | -{ |
2643 | - _currentScreen->writeLinesToStream(_decoder,startLine,endLine); |
2644 | -} |
2645 | - |
2646 | -int Emulation::lineCount() const |
2647 | -{ |
2648 | - // sum number of lines currently on _screen plus number of lines in history |
2649 | - return _currentScreen->getLines() + _currentScreen->getHistLines(); |
2650 | -} |
2651 | - |
2652 | -#define BULK_TIMEOUT1 10 |
2653 | -#define BULK_TIMEOUT2 40 |
2654 | - |
2655 | -void Emulation::showBulk() |
2656 | -{ |
2657 | - _bulkTimer1.stop(); |
2658 | - _bulkTimer2.stop(); |
2659 | - |
2660 | - emit outputChanged(); |
2661 | - |
2662 | - _currentScreen->resetScrolledLines(); |
2663 | - _currentScreen->resetDroppedLines(); |
2664 | -} |
2665 | - |
2666 | -void Emulation::bufferedUpdate() |
2667 | -{ |
2668 | - _bulkTimer1.setSingleShot(true); |
2669 | - _bulkTimer1.start(BULK_TIMEOUT1); |
2670 | - if (!_bulkTimer2.isActive()) |
2671 | - { |
2672 | - _bulkTimer2.setSingleShot(true); |
2673 | - _bulkTimer2.start(BULK_TIMEOUT2); |
2674 | - } |
2675 | -} |
2676 | - |
2677 | -char Emulation::eraseChar() const |
2678 | -{ |
2679 | - return '\b'; |
2680 | -} |
2681 | - |
2682 | -void Emulation::setImageSize(int lines, int columns) |
2683 | -{ |
2684 | - if ((lines < 1) || (columns < 1)) |
2685 | - return; |
2686 | - |
2687 | - QSize screenSize[2] = { QSize(_screen[0]->getColumns(), |
2688 | - _screen[0]->getLines()), |
2689 | - QSize(_screen[1]->getColumns(), |
2690 | - _screen[1]->getLines()) }; |
2691 | - QSize newSize(columns,lines); |
2692 | - |
2693 | - if (newSize == screenSize[0] && newSize == screenSize[1]) |
2694 | - return; |
2695 | - |
2696 | - _screen[0]->resizeImage(lines,columns); |
2697 | - _screen[1]->resizeImage(lines,columns); |
2698 | - |
2699 | - emit imageSizeChanged(lines,columns); |
2700 | - |
2701 | - bufferedUpdate(); |
2702 | -} |
2703 | - |
2704 | -QSize Emulation::imageSize() const |
2705 | -{ |
2706 | - return QSize(_currentScreen->getColumns(), _currentScreen->getLines()); |
2707 | -} |
2708 | - |
2709 | -ushort ExtendedCharTable::extendedCharHash(ushort* unicodePoints , ushort length) const |
2710 | -{ |
2711 | - ushort hash = 0; |
2712 | - for ( ushort i = 0 ; i < length ; i++ ) |
2713 | - { |
2714 | - hash = 31*hash + unicodePoints[i]; |
2715 | - } |
2716 | - return hash; |
2717 | -} |
2718 | -bool ExtendedCharTable::extendedCharMatch(ushort hash , ushort* unicodePoints , ushort length) const |
2719 | -{ |
2720 | - ushort* entry = extendedCharTable[hash]; |
2721 | - |
2722 | - // compare given length with stored sequence length ( given as the first ushort in the |
2723 | - // stored buffer ) |
2724 | - if ( entry == 0 || entry[0] != length ) |
2725 | - return false; |
2726 | - // if the lengths match, each character must be checked. the stored buffer starts at |
2727 | - // entry[1] |
2728 | - for ( int i = 0 ; i < length ; i++ ) |
2729 | - { |
2730 | - if ( entry[i+1] != unicodePoints[i] ) |
2731 | - return false; |
2732 | - } |
2733 | - return true; |
2734 | -} |
2735 | -ushort ExtendedCharTable::createExtendedChar(ushort* unicodePoints , ushort length) |
2736 | -{ |
2737 | - // look for this sequence of points in the table |
2738 | - ushort hash = extendedCharHash(unicodePoints,length); |
2739 | - |
2740 | - // check existing entry for match |
2741 | - while ( extendedCharTable.contains(hash) ) |
2742 | - { |
2743 | - if ( extendedCharMatch(hash,unicodePoints,length) ) |
2744 | - { |
2745 | - // this sequence already has an entry in the table, |
2746 | - // return its hash |
2747 | - return hash; |
2748 | - } |
2749 | - else |
2750 | - { |
2751 | - // if hash is already used by another, different sequence of unicode character |
2752 | - // points then try next hash |
2753 | - hash++; |
2754 | - } |
2755 | - } |
2756 | - |
2757 | - |
2758 | - // add the new sequence to the table and |
2759 | - // return that index |
2760 | - ushort* buffer = new ushort[length+1]; |
2761 | - buffer[0] = length; |
2762 | - for ( int i = 0 ; i < length ; i++ ) |
2763 | - buffer[i+1] = unicodePoints[i]; |
2764 | - |
2765 | - extendedCharTable.insert(hash,buffer); |
2766 | - |
2767 | - return hash; |
2768 | -} |
2769 | - |
2770 | -ushort* ExtendedCharTable::lookupExtendedChar(ushort hash , ushort& length) const |
2771 | -{ |
2772 | - // lookup index in table and if found, set the length |
2773 | - // argument and return a pointer to the character sequence |
2774 | - |
2775 | - ushort* buffer = extendedCharTable[hash]; |
2776 | - if ( buffer ) |
2777 | - { |
2778 | - length = buffer[0]; |
2779 | - return buffer+1; |
2780 | - } |
2781 | - else |
2782 | - { |
2783 | - length = 0; |
2784 | - return 0; |
2785 | - } |
2786 | -} |
2787 | - |
2788 | -ExtendedCharTable::ExtendedCharTable() |
2789 | -{ |
2790 | -} |
2791 | -ExtendedCharTable::~ExtendedCharTable() |
2792 | -{ |
2793 | - // free all allocated character buffers |
2794 | - QHashIterator<ushort,ushort*> iter(extendedCharTable); |
2795 | - while ( iter.hasNext() ) |
2796 | - { |
2797 | - iter.next(); |
2798 | - delete[] iter.value(); |
2799 | - } |
2800 | -} |
2801 | - |
2802 | -// global instance |
2803 | -ExtendedCharTable ExtendedCharTable::instance; |
2804 | - |
2805 | - |
2806 | -//#include "Emulation.moc" |
2807 | - |
2808 | |
2809 | === removed file 'src/plugin/konsole/Emulation.h' |
2810 | --- src/plugin/konsole/Emulation.h 2014-11-12 00:10:12 +0000 |
2811 | +++ src/plugin/konsole/Emulation.h 1970-01-01 00:00:00 +0000 |
2812 | @@ -1,467 +0,0 @@ |
2813 | -/* |
2814 | - This file is part of Konsole, an X terminal. |
2815 | - |
2816 | - Copyright 2007-2008 by Robert Knight <robertknight@gmail.com> |
2817 | - Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de> |
2818 | - |
2819 | - This program is free software; you can redistribute it and/or modify |
2820 | - it under the terms of the GNU General Public License as published by |
2821 | - the Free Software Foundation; either version 2 of the License, or |
2822 | - (at your option) any later version. |
2823 | - |
2824 | - This program is distributed in the hope that it will be useful, |
2825 | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
2826 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2827 | - GNU General Public License for more details. |
2828 | - |
2829 | - You should have received a copy of the GNU General Public License |
2830 | - along with this program; if not, write to the Free Software |
2831 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
2832 | - 02110-1301 USA. |
2833 | -*/ |
2834 | - |
2835 | -#ifndef EMULATION_H |
2836 | -#define EMULATION_H |
2837 | - |
2838 | -// System |
2839 | -#include <stdio.h> |
2840 | - |
2841 | -// Qt |
2842 | -#include <QtGui/QKeyEvent> |
2843 | -//#include <QPointer> |
2844 | -#include <QtCore/QTextCodec> |
2845 | -#include <QtCore/QTextStream> |
2846 | -#include <QtCore/QTimer> |
2847 | - |
2848 | -// Konsole |
2849 | -//#include "konsole_export.h" |
2850 | -#define KONSOLEPRIVATE_EXPORT |
2851 | - |
2852 | -class KeyboardTranslator; |
2853 | -class HistoryType; |
2854 | -class Screen; |
2855 | -class ScreenWindow; |
2856 | -class TerminalCharacterDecoder; |
2857 | - |
2858 | -/** |
2859 | - * This enum describes the available states which |
2860 | - * the terminal emulation may be set to. |
2861 | - * |
2862 | - * These are the values used by Emulation::stateChanged() |
2863 | - */ |
2864 | -enum |
2865 | -{ |
2866 | - /** The emulation is currently receiving user input. */ |
2867 | - NOTIFYNORMAL=0, |
2868 | - /** |
2869 | - * The terminal program has triggered a bell event |
2870 | - * to get the user's attention. |
2871 | - */ |
2872 | - NOTIFYBELL=1, |
2873 | - /** |
2874 | - * The emulation is currently receiving data from its |
2875 | - * terminal input. |
2876 | - */ |
2877 | - NOTIFYACTIVITY=2, |
2878 | - |
2879 | - // unused here? |
2880 | - NOTIFYSILENCE=3 |
2881 | -}; |
2882 | - |
2883 | -/** |
2884 | - * Base class for terminal emulation back-ends. |
2885 | - * |
2886 | - * The back-end is responsible for decoding an incoming character stream and |
2887 | - * producing an output image of characters. |
2888 | - * |
2889 | - * When input from the terminal is received, the receiveData() slot should be called with |
2890 | - * the data which has arrived. The emulation will process the data and update the |
2891 | - * screen image accordingly. The codec used to decode the incoming character stream |
2892 | - * into the unicode characters used internally can be specified using setCodec() |
2893 | - * |
2894 | - * The size of the screen image can be specified by calling setImageSize() with the |
2895 | - * desired number of lines and columns. When new lines are added, old content |
2896 | - * is moved into a history store, which can be set by calling setHistory(). |
2897 | - * |
2898 | - * The screen image can be accessed by creating a ScreenWindow onto this emulation |
2899 | - * by calling createWindow(). Screen windows provide access to a section of the |
2900 | - * output. Each screen window covers the same number of lines and columns as the |
2901 | - * image size returned by imageSize(). The screen window can be moved up and down |
2902 | - * and provides transparent access to both the current on-screen image and the |
2903 | - * previous output. The screen windows emit an outputChanged signal |
2904 | - * when the section of the image they are looking at changes. |
2905 | - * Graphical views can then render the contents of a screen window, listening for notifications |
2906 | - * of output changes from the screen window which they are associated with and updating |
2907 | - * accordingly. |
2908 | - * |
2909 | - * The emulation also is also responsible for converting input from the connected views such |
2910 | - * as keypresses and mouse activity into a character string which can be sent |
2911 | - * to the terminal program. Key presses can be processed by calling the sendKeyEvent() slot, |
2912 | - * while mouse events can be processed using the sendMouseEvent() slot. When the character |
2913 | - * stream has been produced, the emulation will emit a sendData() signal with a pointer |
2914 | - * to the character buffer. This data should be fed to the standard input of the terminal |
2915 | - * process. The translation of key presses into an output character stream is performed |
2916 | - * using a lookup in a set of key bindings which map key sequences to output |
2917 | - * character sequences. The name of the key bindings set used can be specified using |
2918 | - * setKeyBindings() |
2919 | - * |
2920 | - * The emulation maintains certain state information which changes depending on the |
2921 | - * input received. The emulation can be reset back to its starting state by calling |
2922 | - * reset(). |
2923 | - * |
2924 | - * The emulation also maintains an activity state, which specifies whether |
2925 | - * terminal is currently active ( when data is received ), normal |
2926 | - * ( when the terminal is idle or receiving user input ) or trying |
2927 | - * to alert the user ( also known as a "Bell" event ). The stateSet() signal |
2928 | - * is emitted whenever the activity state is set. This can be used to determine |
2929 | - * how long the emulation has been active/idle for and also respond to |
2930 | - * a 'bell' event in different ways. |
2931 | - */ |
2932 | -class KONSOLEPRIVATE_EXPORT Emulation : public QObject |
2933 | -{ |
2934 | -Q_OBJECT |
2935 | - |
2936 | -public: |
2937 | - |
2938 | - /** Constructs a new terminal emulation */ |
2939 | - Emulation(); |
2940 | - ~Emulation(); |
2941 | - |
2942 | - /** |
2943 | - * Creates a new window onto the output from this emulation. The contents |
2944 | - * of the window are then rendered by views which are set to use this window using the |
2945 | - * TerminalDisplay::setScreenWindow() method. |
2946 | - */ |
2947 | - ScreenWindow* createWindow(); |
2948 | - |
2949 | - /** Returns the size of the screen image which the emulation produces */ |
2950 | - QSize imageSize() const; |
2951 | - |
2952 | - /** |
2953 | - * Returns the total number of lines, including those stored in the history. |
2954 | - */ |
2955 | - int lineCount() const; |
2956 | - |
2957 | - /** |
2958 | - * Sets the history store used by this emulation. When new lines |
2959 | - * are added to the output, older lines at the top of the screen are transferred to a history |
2960 | - * store. |
2961 | - * |
2962 | - * The number of lines which are kept and the storage location depend on the |
2963 | - * type of store. |
2964 | - */ |
2965 | - void setHistory(const HistoryType&); |
2966 | - /** Returns the history store used by this emulation. See setHistory() */ |
2967 | - const HistoryType& history() const; |
2968 | - /** Clears the history scroll. */ |
2969 | - void clearHistory(); |
2970 | - |
2971 | - /** |
2972 | - * Copies the output history from @p startLine to @p endLine |
2973 | - * into @p stream, using @p decoder to convert the terminal |
2974 | - * characters into text. |
2975 | - * |
2976 | - * @param decoder A decoder which converts lines of terminal characters with |
2977 | - * appearance attributes into output text. PlainTextDecoder is the most commonly |
2978 | - * used decoder. |
2979 | - * @param startLine Index of first line to copy |
2980 | - * @param endLine Index of last line to copy |
2981 | - */ |
2982 | - virtual void writeToStream(TerminalCharacterDecoder* decoder,int startLine,int endLine); |
2983 | - |
2984 | - /** Returns the codec used to decode incoming characters. See setCodec() */ |
2985 | - const QTextCodec* codec() const { return _codec; } |
2986 | - /** Sets the codec used to decode incoming characters. */ |
2987 | - void setCodec(const QTextCodec*); |
2988 | - |
2989 | - /** |
2990 | - * Convenience method. |
2991 | - * Returns true if the current codec used to decode incoming |
2992 | - * characters is UTF-8 |
2993 | - */ |
2994 | - bool utf8() const |
2995 | - { Q_ASSERT(_codec); return _codec->mibEnum() == 106; } |
2996 | - |
2997 | - |
2998 | - /** TODO Document me */ |
2999 | - virtual char eraseChar() const; |
3000 | - |
3001 | - /** |
3002 | - * Sets the key bindings used to key events |
3003 | - * ( received through sendKeyEvent() ) into character |
3004 | - * streams to send to the terminal. |
3005 | - */ |
3006 | - void setKeyBindings(const QString& name); |
3007 | - /** |
3008 | - * Returns the name of the emulation's current key bindings. |
3009 | - * See setKeyBindings() |
3010 | - */ |
3011 | - QString keyBindings() const; |
3012 | - |
3013 | - /** |
3014 | - * Copies the current image into the history and clears the screen. |
3015 | - */ |
3016 | - virtual void clearEntireScreen() =0; |
3017 | - |
3018 | - /** Resets the state of the terminal. */ |
3019 | - virtual void reset() =0; |
3020 | - |
3021 | - /** |
3022 | - * Returns true if the active terminal program wants |
3023 | - * mouse input events. |
3024 | - * |
3025 | - * The programUsesMouseChanged() signal is emitted when this |
3026 | - * changes. |
3027 | - */ |
3028 | - bool programUsesMouse() const; |
3029 | - |
3030 | -public slots: |
3031 | - |
3032 | - /** Change the size of the emulation's image */ |
3033 | - virtual void setImageSize(int lines, int columns); |
3034 | - |
3035 | - /** |
3036 | - * Interprets a sequence of characters and sends the result to the terminal. |
3037 | - * This is equivalent to calling sendKeyEvent() for each character in @p text in succession. |
3038 | - */ |
3039 | - virtual void sendText(const QString& text) = 0; |
3040 | - |
3041 | - /** |
3042 | - * Interprets a key press event and emits the sendData() signal with |
3043 | - * the resulting character stream. |
3044 | - */ |
3045 | - virtual void sendKeyEvent(QKeyEvent*); |
3046 | - |
3047 | - /** |
3048 | - * Converts information about a mouse event into an xterm-compatible escape |
3049 | - * sequence and emits the character sequence via sendData() |
3050 | - */ |
3051 | - virtual void sendMouseEvent(int buttons, int column, int line, int eventType); |
3052 | - |
3053 | - /** |
3054 | - * Sends a string of characters to the foreground terminal process. |
3055 | - * |
3056 | - * @param string The characters to send. |
3057 | - * @param length Length of @p string or if set to a negative value, @p string will |
3058 | - * be treated as a null-terminated string and its length will be determined automatically. |
3059 | - */ |
3060 | - virtual void sendString(const char* string, int length = -1) = 0; |
3061 | - |
3062 | - /** |
3063 | - * Processes an incoming stream of characters. receiveData() decodes the incoming |
3064 | - * character buffer using the current codec(), and then calls receiveChar() for |
3065 | - * each unicode character in the resulting buffer. |
3066 | - * |
3067 | - * receiveData() also starts a timer which causes the outputChanged() signal |
3068 | - * to be emitted when it expires. The timer allows multiple updates in quick |
3069 | - * succession to be buffered into a single outputChanged() signal emission. |
3070 | - * |
3071 | - * @param buffer A string of characters received from the terminal program. |
3072 | - * @param len The length of @p buffer |
3073 | - */ |
3074 | - void receiveData(const char* buffer,int len); |
3075 | - |
3076 | -signals: |
3077 | - |
3078 | - /** |
3079 | - * Emitted when a buffer of data is ready to send to the |
3080 | - * standard input of the terminal. |
3081 | - * |
3082 | - * @param data The buffer of data ready to be sent |
3083 | - * @param len The length of @p data in bytes |
3084 | - */ |
3085 | - void sendData(const char* data,int len); |
3086 | - |
3087 | - /** |
3088 | - * Requests that sending of input to the emulation |
3089 | - * from the terminal process be suspended or resumed. |
3090 | - * |
3091 | - * @param suspend If true, requests that sending of |
3092 | - * input from the terminal process' stdout be |
3093 | - * suspended. Otherwise requests that sending of |
3094 | - * input be resumed. |
3095 | - */ |
3096 | - void lockPtyRequest(bool suspend); |
3097 | - |
3098 | - /** |
3099 | - * Requests that the pty used by the terminal process |
3100 | - * be set to UTF 8 mode. |
3101 | - * |
3102 | - * TODO: More documentation |
3103 | - */ |
3104 | - void useUtf8Request(bool); |
3105 | - |
3106 | - /** |
3107 | - * Emitted when the activity state of the emulation is set. |
3108 | - * |
3109 | - * @param state The new activity state, one of NOTIFYNORMAL, NOTIFYACTIVITY |
3110 | - * or NOTIFYBELL |
3111 | - */ |
3112 | - void stateSet(int state); |
3113 | - |
3114 | - /** TODO Document me */ |
3115 | - void zmodemDetected(); |
3116 | - |
3117 | - |
3118 | - /** |
3119 | - * Requests that the color of the text used |
3120 | - * to represent the tabs associated with this |
3121 | - * emulation be changed. This is a Konsole-specific |
3122 | - * extension from pre-KDE 4 times. |
3123 | - * |
3124 | - * TODO: Document how the parameter works. |
3125 | - */ |
3126 | - void changeTabTextColorRequest(int color); |
3127 | - |
3128 | - /** |
3129 | - * This is emitted when the program running in the shell indicates whether or |
3130 | - * not it is interested in mouse events. |
3131 | - * |
3132 | - * @param usesMouse This will be true if the program wants to be informed about |
3133 | - * mouse events or false otherwise. |
3134 | - */ |
3135 | - void programUsesMouseChanged(bool usesMouse); |
3136 | - |
3137 | - /** |
3138 | - * Emitted when the contents of the screen image change. |
3139 | - * The emulation buffers the updates from successive image changes, |
3140 | - * and only emits outputChanged() at sensible intervals when |
3141 | - * there is a lot of terminal activity. |
3142 | - * |
3143 | - * Normally there is no need for objects other than the screen windows |
3144 | - * created with createWindow() to listen for this signal. |
3145 | - * |
3146 | - * ScreenWindow objects created using createWindow() will emit their |
3147 | - * own outputChanged() signal in response to this signal. |
3148 | - */ |
3149 | - void outputChanged(); |
3150 | - |
3151 | - /** |
3152 | - * Emitted when the program running in the terminal wishes to update the |
3153 | - * session's title. This also allows terminal programs to customize other |
3154 | - * aspects of the terminal emulation display. |
3155 | - * |
3156 | - * This signal is emitted when the escape sequence "\033]ARG;VALUE\007" |
3157 | - * is received in the input string, where ARG is a number specifying what |
3158 | - * should change and VALUE is a string specifying the new value. |
3159 | - * |
3160 | - * TODO: The name of this method is not very accurate since this method |
3161 | - * is used to perform a whole range of tasks besides just setting |
3162 | - * the user-title of the session. |
3163 | - * |
3164 | - * @param title Specifies what to change. |
3165 | - * <ul> |
3166 | - * <li>0 - Set window icon text and session title to @p newTitle</li> |
3167 | - * <li>1 - Set window icon text to @p newTitle</li> |
3168 | - * <li>2 - Set session title to @p newTitle</li> |
3169 | - * <li>11 - Set the session's default background color to @p newTitle, |
3170 | - * where @p newTitle can be an HTML-style string ("#RRGGBB") or a named |
3171 | - * color (eg 'red', 'blue'). |
3172 | - * See http://doc.trolltech.com/4.2/qcolor.html#setNamedColor for more |
3173 | - * details. |
3174 | - * </li> |
3175 | - * <li>31 - Supposedly treats @p newTitle as a URL and opens it (NOT IMPLEMENTED)</li> |
3176 | - * <li>32 - Sets the icon associated with the session. @p newTitle is the name |
3177 | - * of the icon to use, which can be the name of any icon in the current KDE icon |
3178 | - * theme (eg: 'konsole', 'kate', 'folder_home')</li> |
3179 | - * </ul> |
3180 | - * @param newTitle Specifies the new title |
3181 | - */ |
3182 | - |
3183 | - void titleChanged(int title,const QString& newTitle); |
3184 | - |
3185 | - /** |
3186 | - * Emitted when the program running in the terminal changes the |
3187 | - * screen size. |
3188 | - */ |
3189 | - void imageSizeChanged(int lineCount , int columnCount); |
3190 | - |
3191 | - /** |
3192 | - * Emitted when the terminal program requests to change various properties |
3193 | - * of the terminal display. |
3194 | - * |
3195 | - * A profile change command occurs when a special escape sequence, followed |
3196 | - * by a string containing a series of name and value pairs is received. |
3197 | - * This string can be parsed using a ProfileCommandParser instance. |
3198 | - * |
3199 | - * @param text A string expected to contain a series of key and value pairs in |
3200 | - * the form: name=value;name2=value2 ... |
3201 | - */ |
3202 | - void profileChangeCommandReceived(const QString& text); |
3203 | - |
3204 | - /** |
3205 | - * Emitted when a flow control key combination ( Ctrl+S or Ctrl+Q ) is pressed. |
3206 | - * @param suspendKeyPressed True if Ctrl+S was pressed to suspend output or Ctrl+Q to |
3207 | - * resume output. |
3208 | - */ |
3209 | - void flowControlKeyPressed(bool suspendKeyPressed); |
3210 | - |
3211 | -protected: |
3212 | - virtual void setMode(int mode) = 0; |
3213 | - virtual void resetMode(int mode) = 0; |
3214 | - |
3215 | - /** |
3216 | - * Processes an incoming character. See receiveData() |
3217 | - * @p ch A unicode character code. |
3218 | - */ |
3219 | - virtual void receiveChar(int ch); |
3220 | - |
3221 | - /** |
3222 | - * Sets the active screen. The terminal has two screens, primary and alternate. |
3223 | - * The primary screen is used by default. When certain interactive programs such |
3224 | - * as Vim are run, they trigger a switch to the alternate screen. |
3225 | - * |
3226 | - * @param index 0 to switch to the primary screen, or 1 to switch to the alternate screen |
3227 | - */ |
3228 | - void setScreen(int index); |
3229 | - |
3230 | - enum EmulationCodec |
3231 | - { |
3232 | - LocaleCodec = 0, |
3233 | - Utf8Codec = 1 |
3234 | - }; |
3235 | - void setCodec(EmulationCodec codec); // codec number, 0 = locale, 1=utf8 |
3236 | - |
3237 | - |
3238 | - QList<ScreenWindow*> _windows; |
3239 | - |
3240 | - Screen* _currentScreen; // pointer to the screen which is currently active, |
3241 | - // this is one of the elements in the screen[] array |
3242 | - |
3243 | - Screen* _screen[2]; // 0 = primary screen ( used by most programs, including the shell |
3244 | - // scrollbars are enabled in this mode ) |
3245 | - // 1 = alternate ( used by vi , emacs etc. |
3246 | - // scrollbars are not enabled in this mode ) |
3247 | - |
3248 | - |
3249 | - //decodes an incoming C-style character stream into a unicode QString using |
3250 | - //the current text codec. (this allows for rendering of non-ASCII characters in text files etc.) |
3251 | - const QTextCodec* _codec; |
3252 | - QTextDecoder* _decoder; |
3253 | - const KeyboardTranslator* _keyTranslator; // the keyboard layout |
3254 | - |
3255 | -protected slots: |
3256 | - /** |
3257 | - * Schedules an update of attached views. |
3258 | - * Repeated calls to bufferedUpdate() in close succession will result in only a single update, |
3259 | - * much like the Qt buffered update of widgets. |
3260 | - */ |
3261 | - void bufferedUpdate(); |
3262 | - |
3263 | -private slots: |
3264 | - |
3265 | - // triggered by timer, causes the emulation to send an updated screen image to each |
3266 | - // view |
3267 | - void showBulk(); |
3268 | - |
3269 | - void usesMouseChanged(bool usesMouse); |
3270 | - |
3271 | -private: |
3272 | - bool _usesMouse; |
3273 | - QTimer _bulkTimer1; |
3274 | - QTimer _bulkTimer2; |
3275 | - |
3276 | -}; |
3277 | - |
3278 | - |
3279 | -#endif // ifndef EMULATION_H |
3280 | |
3281 | === removed file 'src/plugin/konsole/ExtendedDefaultTranslator.h' |
3282 | --- src/plugin/konsole/ExtendedDefaultTranslator.h 2014-11-12 00:10:12 +0000 |
3283 | +++ src/plugin/konsole/ExtendedDefaultTranslator.h 1970-01-01 00:00:00 +0000 |
3284 | @@ -1,74 +0,0 @@ |
3285 | -"keyboard \"Default (XFree 4)\"" |
3286 | -"key Escape : \"\\E\"" |
3287 | -"key Tab -Shift : \"\\t\"\n" |
3288 | -"key Tab +Shift+Ansi : \"\\E[Z\"\n" |
3289 | -"key Tab +Shift-Ansi : \"\\t\"\n" |
3290 | -"key Backtab +Ansi : \"\\E[Z\"\n" |
3291 | -"key Backtab -Ansi : \"\\t\"\n" |
3292 | -"key Return-Shift-NewLine : \"\\r\"\n" |
3293 | -"key Return-Shift+NewLine : \"\\r\\n\"\n" |
3294 | -"key Return+Shift : \"\\EOM\"\n" |
3295 | -"key Backspace : \"\\x7f\"\n" |
3296 | -"key Up -Shift-Ansi : \"\\EA\"\n" |
3297 | -"key Down -Shift-Ansi : \"\\EB\"\n" |
3298 | -"key Right-Shift-Ansi : \"\\EC\"\n" |
3299 | -"key Left -Shift-Ansi : \"\\ED\"\n" |
3300 | -"key Up -Shift-AnyMod+Ansi+AppCuKeys : \"\\EOA\"\n" |
3301 | -"key Down -Shift-AnyMod+Ansi+AppCuKeys : \"\\EOB\"\n" |
3302 | -"key Right -Shift-AnyMod+Ansi+AppCuKeys : \"\\EOC\"\n" |
3303 | -"key Left -Shift-AnyMod+Ansi+AppCuKeys : \"\\EOD\"\n" |
3304 | -"key Up -Shift-AnyMod+Ansi-AppCuKeys : \"\\E[A\"\n" |
3305 | -"key Down -Shift-AnyMod+Ansi-AppCuKeys : \"\\E[B\"\n" |
3306 | -"key Right -Shift-AnyMod+Ansi-AppCuKeys : \"\\E[C\"\n" |
3307 | -"key Left -Shift-AnyMod+Ansi-AppCuKeys : \"\\E[D\"\n" |
3308 | -"key Up -Shift+AnyMod+Ansi : \"\\E[1;*A\"\n" |
3309 | -"key Down -Shift+AnyMod+Ansi : \"\\E[1;*B\"\n" |
3310 | -"key Right -Shift+AnyMod+Ansi : \"\\E[1;*C\"\n" |
3311 | -"key Left -Shift+AnyMod+Ansi : \"\\E[1;*D\"\n" |
3312 | -"key Enter+NewLine : \"\\r\\n\"\n" |
3313 | -"key Enter-NewLine : \"\\r\"\n" |
3314 | -"key Home -AnyMod -AppCuKeys : \"\\E[H\" \n" |
3315 | -"key End -AnyMod -AppCuKeys : \"\\E[F\" \n" |
3316 | -"key Home -AnyMod +AppCuKeys : \"\\EOH\" \n" |
3317 | -"key End -AnyMod +AppCuKeys : \"\\EOF\" \n" |
3318 | -"key Home +AnyMod : \"\\E[1;*H\"\n" |
3319 | -"key End +AnyMod : \"\\E[1;*F\"\n" |
3320 | -"key Insert -AnyMod : \"\\E[2~\"\n" |
3321 | -"key Delete -AnyMod : \"\\E[3~\"\n" |
3322 | -"key Insert +AnyMod : \"\\E[2;*~\"\n" |
3323 | -"key Delete +AnyMod : \"\\E[3;*~\"\n" |
3324 | -"key Prior -Shift-AnyMod : \"\\E[5~\"\n" |
3325 | -"key Next -Shift-AnyMod : \"\\E[6~\"\n" |
3326 | -"key Prior -Shift+AnyMod : \"\\E[5;*~\"\n" |
3327 | -"key Next -Shift+AnyMod : \"\\E[6;*~\"\n" |
3328 | -"key F1 -AnyMod : \"\\EOP\"\n" |
3329 | -"key F2 -AnyMod : \"\\EOQ\"\n" |
3330 | -"key F3 -AnyMod : \"\\EOR\"\n" |
3331 | -"key F4 -AnyMod : \"\\EOS\"\n" |
3332 | -"key F5 -AnyMod : \"\\E[15~\"\n" |
3333 | -"key F6 -AnyMod : \"\\E[17~\"\n" |
3334 | -"key F7 -AnyMod : \"\\E[18~\"\n" |
3335 | -"key F8 -AnyMod : \"\\E[19~\"\n" |
3336 | -"key F9 -AnyMod : \"\\E[20~\"\n" |
3337 | -"key F10 -AnyMod : \"\\E[21~\"\n" |
3338 | -"key F11 -AnyMod : \"\\E[23~\"\n" |
3339 | -"key F12 -AnyMod : \"\\E[24~\"\n" |
3340 | -"key F1 +AnyMod : \"\\EO*P\"\n" |
3341 | -"key F2 +AnyMod : \"\\EO*Q\"\n" |
3342 | -"key F3 +AnyMod : \"\\EO*R\"\n" |
3343 | -"key F4 +AnyMod : \"\\EO*S\"\n" |
3344 | -"key F5 +AnyMod : \"\\E[15;*~\"\n" |
3345 | -"key F6 +AnyMod : \"\\E[17;*~\"\n" |
3346 | -"key F7 +AnyMod : \"\\E[18;*~\"\n" |
3347 | -"key F8 +AnyMod : \"\\E[19;*~\"\n" |
3348 | -"key F9 +AnyMod : \"\\E[20;*~\"\n" |
3349 | -"key F10 +AnyMod : \"\\E[21;*~\"\n" |
3350 | -"key F11 +AnyMod : \"\\E[23;*~\"\n" |
3351 | -"key F12 +AnyMod : \"\\E[24;*~\"\n" |
3352 | -"key Space +Control : \"\\x00\"\n" |
3353 | -"key Up +Shift-AppScreen : scrollLineUp\n" |
3354 | -"key Prior +Shift-AppScreen : scrollPageUp\n" |
3355 | -"key Down +Shift-AppScreen : scrollLineDown\n" |
3356 | -"key Next +Shift-AppScreen : scrollPageDown\n" |
3357 | -"key ScrollLock : scrollLock\n" |
3358 | -"\0" |
3359 | |
3360 | === removed file 'src/plugin/konsole/Filter.cpp' |
3361 | --- src/plugin/konsole/Filter.cpp 2014-11-12 00:10:12 +0000 |
3362 | +++ src/plugin/konsole/Filter.cpp 1970-01-01 00:00:00 +0000 |
3363 | @@ -1,542 +0,0 @@ |
3364 | -/* |
3365 | - Copyright 2007-2008 by Robert Knight <robertknight@gmail.com> |
3366 | - |
3367 | - This program is free software; you can redistribute it and/or modify |
3368 | - it under the terms of the GNU General Public License as published by |
3369 | - the Free Software Foundation; either version 2 of the License, or |
3370 | - (at your option) any later version. |
3371 | - |
3372 | - This program is distributed in the hope that it will be useful, |
3373 | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
3374 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3375 | - GNU General Public License for more details. |
3376 | - |
3377 | - You should have received a copy of the GNU General Public License |
3378 | - along with this program; if not, write to the Free Software |
3379 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
3380 | - 02110-1301 USA. |
3381 | -*/ |
3382 | - |
3383 | -// Own |
3384 | -#include "Filter.h" |
3385 | - |
3386 | -// System |
3387 | -#include <iostream> |
3388 | - |
3389 | -// Qt |
3390 | -#include <QtWidgets/QAction> |
3391 | -#include <QtWidgets/QApplication> |
3392 | -#include <QtGui/QClipboard> |
3393 | -#include <QtCore/QString> |
3394 | -#include <QtCore/QTextStream> |
3395 | -#include <QtCore/QSharedData> |
3396 | -#include <QtCore/QFile> |
3397 | -#include <QDesktopServices> |
3398 | -#include <QUrl> |
3399 | - |
3400 | -// KDE |
3401 | -//#include <KLocale> |
3402 | -//#include <KRun> |
3403 | - |
3404 | -// Konsole |
3405 | -#include "TerminalCharacterDecoder.h" |
3406 | -#include "konsole_wcwidth.h" |
3407 | - |
3408 | - |
3409 | -FilterChain::~FilterChain() |
3410 | -{ |
3411 | - QMutableListIterator<Filter*> iter(*this); |
3412 | - |
3413 | - while ( iter.hasNext() ) |
3414 | - { |
3415 | - Filter* filter = iter.next(); |
3416 | - iter.remove(); |
3417 | - delete filter; |
3418 | - } |
3419 | -} |
3420 | - |
3421 | -void FilterChain::addFilter(Filter* filter) |
3422 | -{ |
3423 | - append(filter); |
3424 | -} |
3425 | -void FilterChain::removeFilter(Filter* filter) |
3426 | -{ |
3427 | - removeAll(filter); |
3428 | -} |
3429 | -bool FilterChain::containsFilter(Filter* filter) |
3430 | -{ |
3431 | - return contains(filter); |
3432 | -} |
3433 | -void FilterChain::reset() |
3434 | -{ |
3435 | - QListIterator<Filter*> iter(*this); |
3436 | - while (iter.hasNext()) |
3437 | - iter.next()->reset(); |
3438 | -} |
3439 | -void FilterChain::setBuffer(const QString* buffer , const QList<int>* linePositions) |
3440 | -{ |
3441 | - QListIterator<Filter*> iter(*this); |
3442 | - while (iter.hasNext()) |
3443 | - iter.next()->setBuffer(buffer,linePositions); |
3444 | -} |
3445 | -void FilterChain::process() |
3446 | -{ |
3447 | - QListIterator<Filter*> iter(*this); |
3448 | - while (iter.hasNext()) |
3449 | - iter.next()->process(); |
3450 | -} |
3451 | -void FilterChain::clear() |
3452 | -{ |
3453 | - QList<Filter*>::clear(); |
3454 | -} |
3455 | -Filter::HotSpot* FilterChain::hotSpotAt(int line , int column) const |
3456 | -{ |
3457 | - QListIterator<Filter*> iter(*this); |
3458 | - while (iter.hasNext()) |
3459 | - { |
3460 | - Filter* filter = iter.next(); |
3461 | - Filter::HotSpot* spot = filter->hotSpotAt(line,column); |
3462 | - if ( spot != 0 ) |
3463 | - { |
3464 | - return spot; |
3465 | - } |
3466 | - } |
3467 | - |
3468 | - return 0; |
3469 | -} |
3470 | - |
3471 | -QList<Filter::HotSpot*> FilterChain::hotSpots() const |
3472 | -{ |
3473 | - QList<Filter::HotSpot*> list; |
3474 | - QListIterator<Filter*> iter(*this); |
3475 | - while (iter.hasNext()) |
3476 | - { |
3477 | - Filter* filter = iter.next(); |
3478 | - list << filter->hotSpots(); |
3479 | - } |
3480 | - return list; |
3481 | -} |
3482 | -//QList<Filter::HotSpot*> FilterChain::hotSpotsAtLine(int line) const; |
3483 | - |
3484 | -TerminalImageFilterChain::TerminalImageFilterChain() |
3485 | -: _buffer(0) |
3486 | -, _linePositions(0) |
3487 | -{ |
3488 | -} |
3489 | - |
3490 | -TerminalImageFilterChain::~TerminalImageFilterChain() |
3491 | -{ |
3492 | - delete _buffer; |
3493 | - delete _linePositions; |
3494 | -} |
3495 | - |
3496 | -void TerminalImageFilterChain::setImage(const Character* const image , int lines , int columns, const QVector<LineProperty>& lineProperties) |
3497 | -{ |
3498 | - if (empty()) |
3499 | - return; |
3500 | - |
3501 | - // reset all filters and hotspots |
3502 | - reset(); |
3503 | - |
3504 | - PlainTextDecoder decoder; |
3505 | - decoder.setTrailingWhitespace(false); |
3506 | - |
3507 | - // setup new shared buffers for the filters to process on |
3508 | - QString* newBuffer = new QString(); |
3509 | - QList<int>* newLinePositions = new QList<int>(); |
3510 | - setBuffer( newBuffer , newLinePositions ); |
3511 | - |
3512 | - // free the old buffers |
3513 | - delete _buffer; |
3514 | - delete _linePositions; |
3515 | - |
3516 | - _buffer = newBuffer; |
3517 | - _linePositions = newLinePositions; |
3518 | - |
3519 | - QTextStream lineStream(_buffer); |
3520 | - decoder.begin(&lineStream); |
3521 | - |
3522 | - for (int i=0 ; i < lines ; i++) |
3523 | - { |
3524 | - _linePositions->append(_buffer->length()); |
3525 | - decoder.decodeLine(image + i*columns,columns,LINE_DEFAULT); |
3526 | - |
3527 | - // pretend that each line ends with a newline character. |
3528 | - // this prevents a link that occurs at the end of one line |
3529 | - // being treated as part of a link that occurs at the start of the next line |
3530 | - // |
3531 | - // the downside is that links which are spread over more than one line are not |
3532 | - // highlighted. |
3533 | - // |
3534 | - // TODO - Use the "line wrapped" attribute associated with lines in a |
3535 | - // terminal image to avoid adding this imaginary character for wrapped |
3536 | - // lines |
3537 | - if ( !(lineProperties.value(i,LINE_DEFAULT) & LINE_WRAPPED) ) |
3538 | - lineStream << QChar('\n'); |
3539 | - } |
3540 | - decoder.end(); |
3541 | -} |
3542 | - |
3543 | -Filter::Filter() : |
3544 | -_linePositions(0), |
3545 | -_buffer(0) |
3546 | -{ |
3547 | -} |
3548 | - |
3549 | -Filter::~Filter() |
3550 | -{ |
3551 | - QListIterator<HotSpot*> iter(_hotspotList); |
3552 | - while (iter.hasNext()) |
3553 | - { |
3554 | - delete iter.next(); |
3555 | - } |
3556 | -} |
3557 | -void Filter::reset() |
3558 | -{ |
3559 | - _hotspots.clear(); |
3560 | - _hotspotList.clear(); |
3561 | -} |
3562 | - |
3563 | -void Filter::setBuffer(const QString* buffer , const QList<int>* linePositions) |
3564 | -{ |
3565 | - _buffer = buffer; |
3566 | - _linePositions = linePositions; |
3567 | -} |
3568 | - |
3569 | -void Filter::getLineColumn(int position , int& startLine , int& startColumn) |
3570 | -{ |
3571 | - Q_ASSERT( _linePositions ); |
3572 | - Q_ASSERT( _buffer ); |
3573 | - |
3574 | - |
3575 | - for (int i = 0 ; i < _linePositions->count() ; i++) |
3576 | - { |
3577 | - int nextLine = 0; |
3578 | - |
3579 | - if ( i == _linePositions->count()-1 ) |
3580 | - nextLine = _buffer->length() + 1; |
3581 | - else |
3582 | - nextLine = _linePositions->value(i+1); |
3583 | - |
3584 | - if ( _linePositions->value(i) <= position && position < nextLine ) |
3585 | - { |
3586 | - startLine = i; |
3587 | - startColumn = string_width(buffer()->mid(_linePositions->value(i),position - _linePositions->value(i))); |
3588 | - return; |
3589 | - } |
3590 | - } |
3591 | -} |
3592 | - |
3593 | - |
3594 | -/*void Filter::addLine(const QString& text) |
3595 | -{ |
3596 | - _linePositions << _buffer.length(); |
3597 | - _buffer.append(text); |
3598 | -}*/ |
3599 | - |
3600 | -const QString* Filter::buffer() |
3601 | -{ |
3602 | - return _buffer; |
3603 | -} |
3604 | -Filter::HotSpot::~HotSpot() |
3605 | -{ |
3606 | -} |
3607 | -void Filter::addHotSpot(HotSpot* spot) |
3608 | -{ |
3609 | - _hotspotList << spot; |
3610 | - |
3611 | - for (int line = spot->startLine() ; line <= spot->endLine() ; line++) |
3612 | - { |
3613 | - _hotspots.insert(line,spot); |
3614 | - } |
3615 | -} |
3616 | -QList<Filter::HotSpot*> Filter::hotSpots() const |
3617 | -{ |
3618 | - return _hotspotList; |
3619 | -} |
3620 | -QList<Filter::HotSpot*> Filter::hotSpotsAtLine(int line) const |
3621 | -{ |
3622 | - return _hotspots.values(line); |
3623 | -} |
3624 | - |
3625 | -Filter::HotSpot* Filter::hotSpotAt(int line , int column) const |
3626 | -{ |
3627 | - QListIterator<HotSpot*> spotIter(_hotspots.values(line)); |
3628 | - |
3629 | - while (spotIter.hasNext()) |
3630 | - { |
3631 | - HotSpot* spot = spotIter.next(); |
3632 | - |
3633 | - if ( spot->startLine() == line && spot->startColumn() > column ) |
3634 | - continue; |
3635 | - if ( spot->endLine() == line && spot->endColumn() < column ) |
3636 | - continue; |
3637 | - |
3638 | - return spot; |
3639 | - } |
3640 | - |
3641 | - return 0; |
3642 | -} |
3643 | - |
3644 | -Filter::HotSpot::HotSpot(int startLine , int startColumn , int endLine , int endColumn) |
3645 | - : _startLine(startLine) |
3646 | - , _startColumn(startColumn) |
3647 | - , _endLine(endLine) |
3648 | - , _endColumn(endColumn) |
3649 | - , _type(NotSpecified) |
3650 | -{ |
3651 | -} |
3652 | -QString Filter::HotSpot::tooltip() const |
3653 | -{ |
3654 | - return QString(); |
3655 | -} |
3656 | -QList<QAction*> Filter::HotSpot::actions() |
3657 | -{ |
3658 | - return QList<QAction*>(); |
3659 | -} |
3660 | -int Filter::HotSpot::startLine() const |
3661 | -{ |
3662 | - return _startLine; |
3663 | -} |
3664 | -int Filter::HotSpot::endLine() const |
3665 | -{ |
3666 | - return _endLine; |
3667 | -} |
3668 | -int Filter::HotSpot::startColumn() const |
3669 | -{ |
3670 | - return _startColumn; |
3671 | -} |
3672 | -int Filter::HotSpot::endColumn() const |
3673 | -{ |
3674 | - return _endColumn; |
3675 | -} |
3676 | -Filter::HotSpot::Type Filter::HotSpot::type() const |
3677 | -{ |
3678 | - return _type; |
3679 | -} |
3680 | -void Filter::HotSpot::setType(Type type) |
3681 | -{ |
3682 | - _type = type; |
3683 | -} |
3684 | - |
3685 | -RegExpFilter::RegExpFilter() |
3686 | -{ |
3687 | -} |
3688 | - |
3689 | -RegExpFilter::HotSpot::HotSpot(int startLine,int startColumn,int endLine,int endColumn) |
3690 | - : Filter::HotSpot(startLine,startColumn,endLine,endColumn) |
3691 | -{ |
3692 | - setType(Marker); |
3693 | -} |
3694 | - |
3695 | -void RegExpFilter::HotSpot::activate(QObject*) |
3696 | -{ |
3697 | -} |
3698 | - |
3699 | -void RegExpFilter::HotSpot::setCapturedTexts(const QStringList& texts) |
3700 | -{ |
3701 | - _capturedTexts = texts; |
3702 | -} |
3703 | -QStringList RegExpFilter::HotSpot::capturedTexts() const |
3704 | -{ |
3705 | - return _capturedTexts; |
3706 | -} |
3707 | - |
3708 | -void RegExpFilter::setRegExp(const QRegExp& regExp) |
3709 | -{ |
3710 | - _searchText = regExp; |
3711 | -} |
3712 | -QRegExp RegExpFilter::regExp() const |
3713 | -{ |
3714 | - return _searchText; |
3715 | -} |
3716 | -/*void RegExpFilter::reset(int) |
3717 | -{ |
3718 | - _buffer = QString(); |
3719 | -}*/ |
3720 | -void RegExpFilter::process() |
3721 | -{ |
3722 | - int pos = 0; |
3723 | - const QString* text = buffer(); |
3724 | - |
3725 | - Q_ASSERT( text ); |
3726 | - |
3727 | - // ignore any regular expressions which match an empty string. |
3728 | - // otherwise the while loop below will run indefinitely |
3729 | - static const QString emptyString(""); |
3730 | - if ( _searchText.exactMatch(emptyString) ) |
3731 | - return; |
3732 | - |
3733 | - while(pos >= 0) |
3734 | - { |
3735 | - pos = _searchText.indexIn(*text,pos); |
3736 | - |
3737 | - if ( pos >= 0 ) |
3738 | - { |
3739 | - int startLine = 0; |
3740 | - int endLine = 0; |
3741 | - int startColumn = 0; |
3742 | - int endColumn = 0; |
3743 | - |
3744 | - getLineColumn(pos,startLine,startColumn); |
3745 | - getLineColumn(pos + _searchText.matchedLength(),endLine,endColumn); |
3746 | - |
3747 | - RegExpFilter::HotSpot* spot = newHotSpot(startLine,startColumn, |
3748 | - endLine,endColumn); |
3749 | - spot->setCapturedTexts(_searchText.capturedTexts()); |
3750 | - |
3751 | - addHotSpot( spot ); |
3752 | - pos += _searchText.matchedLength(); |
3753 | - |
3754 | - // if matchedLength == 0, the program will get stuck in an infinite loop |
3755 | - if ( _searchText.matchedLength() == 0 ) |
3756 | - pos = -1; |
3757 | - } |
3758 | - } |
3759 | -} |
3760 | - |
3761 | -RegExpFilter::HotSpot* RegExpFilter::newHotSpot(int startLine,int startColumn, |
3762 | - int endLine,int endColumn) |
3763 | -{ |
3764 | - return new RegExpFilter::HotSpot(startLine,startColumn, |
3765 | - endLine,endColumn); |
3766 | -} |
3767 | -RegExpFilter::HotSpot* UrlFilter::newHotSpot(int startLine,int startColumn,int endLine, |
3768 | - int endColumn) |
3769 | -{ |
3770 | - return new UrlFilter::HotSpot(startLine,startColumn, |
3771 | - endLine,endColumn); |
3772 | -} |
3773 | -UrlFilter::HotSpot::HotSpot(int startLine,int startColumn,int endLine,int endColumn) |
3774 | -: RegExpFilter::HotSpot(startLine,startColumn,endLine,endColumn) |
3775 | -, _urlObject(new FilterObject(this)) |
3776 | -{ |
3777 | - setType(Link); |
3778 | -} |
3779 | -QString UrlFilter::HotSpot::tooltip() const |
3780 | -{ |
3781 | - QString url = capturedTexts().first(); |
3782 | - |
3783 | - const UrlType kind = urlType(); |
3784 | - |
3785 | - if ( kind == StandardUrl ) |
3786 | - return QString(); |
3787 | - else if ( kind == Email ) |
3788 | - return QString(); |
3789 | - else |
3790 | - return QString(); |
3791 | -} |
3792 | -UrlFilter::HotSpot::UrlType UrlFilter::HotSpot::urlType() const |
3793 | -{ |
3794 | - QString url = capturedTexts().first(); |
3795 | - |
3796 | - if ( FullUrlRegExp.exactMatch(url) ) |
3797 | - return StandardUrl; |
3798 | - else if ( EmailAddressRegExp.exactMatch(url) ) |
3799 | - return Email; |
3800 | - else |
3801 | - return Unknown; |
3802 | -} |
3803 | - |
3804 | -void UrlFilter::HotSpot::activate(QObject* object) |
3805 | -{ |
3806 | - QString url = capturedTexts().first(); |
3807 | - |
3808 | - const UrlType kind = urlType(); |
3809 | - |
3810 | - const QString& actionName = object ? object->objectName() : QString(); |
3811 | - |
3812 | - if ( actionName == "copy-action" ) |
3813 | - { |
3814 | - QApplication::clipboard()->setText(url); |
3815 | - return; |
3816 | - } |
3817 | - |
3818 | - if ( !object || actionName == "open-action" ) |
3819 | - { |
3820 | - if ( kind == StandardUrl ) |
3821 | - { |
3822 | - // if the URL path does not include the protocol ( eg. "www.kde.org" ) then |
3823 | - // prepend http:// ( eg. "www.kde.org" --> "http://www.kde.org" ) |
3824 | - if (!url.contains("://")) |
3825 | - { |
3826 | - url.prepend("http://"); |
3827 | - } |
3828 | - } |
3829 | - else if ( kind == Email ) |
3830 | - { |
3831 | - url.prepend("mailto:"); |
3832 | - } |
3833 | - |
3834 | - QDesktopServices::openUrl(QUrl(url)); |
3835 | - //new KRun(url,QApplication::activeWindow()); |
3836 | - } |
3837 | -} |
3838 | - |
3839 | -// Note: Altering these regular expressions can have a major effect on the performance of the filters |
3840 | -// used for finding URLs in the text, especially if they are very general and could match very long |
3841 | -// pieces of text. |
3842 | -// Please be careful when altering them. |
3843 | - |
3844 | -//regexp matches: |
3845 | -// full url: |
3846 | -// protocolname:// or www. followed by anything other than whitespaces, <, >, ' or ", and ends before whitespaces, <, >, ', ", ], !, comma and dot |
3847 | -const QRegExp UrlFilter::FullUrlRegExp("(www\\.(?!\\.)|[a-z][a-z0-9+.-]*://)[^\\s<>'\"]+[^!,\\.\\s<>'\"\\]]"); |
3848 | -// email address: |
3849 | -// [word chars, dots or dashes]@[word chars, dots or dashes].[word chars] |
3850 | -const QRegExp UrlFilter::EmailAddressRegExp("\\b(\\w|\\.|-)+@(\\w|\\.|-)+\\.\\w+\\b"); |
3851 | - |
3852 | -// matches full url or email address |
3853 | -const QRegExp UrlFilter::CompleteUrlRegExp('('+FullUrlRegExp.pattern()+'|'+ |
3854 | - EmailAddressRegExp.pattern()+')'); |
3855 | - |
3856 | -UrlFilter::UrlFilter() |
3857 | -{ |
3858 | - setRegExp( CompleteUrlRegExp ); |
3859 | -} |
3860 | -UrlFilter::HotSpot::~HotSpot() |
3861 | -{ |
3862 | - delete _urlObject; |
3863 | -} |
3864 | -void FilterObject::activated() |
3865 | -{ |
3866 | - _filter->activate(sender()); |
3867 | -} |
3868 | -QList<QAction*> UrlFilter::HotSpot::actions() |
3869 | -{ |
3870 | - QList<QAction*> list; |
3871 | - |
3872 | - const UrlType kind = urlType(); |
3873 | - |
3874 | - QAction* openAction = new QAction(_urlObject); |
3875 | - QAction* copyAction = new QAction(_urlObject);; |
3876 | - |
3877 | - Q_ASSERT( kind == StandardUrl || kind == Email ); |
3878 | - |
3879 | - if ( kind == StandardUrl ) |
3880 | - { |
3881 | - openAction->setText(QObject::tr("Open Link")); |
3882 | - copyAction->setText(QObject::tr("Copy Link Address")); |
3883 | - } |
3884 | - else if ( kind == Email ) |
3885 | - { |
3886 | - openAction->setText(QObject::tr("Send Email To...")); |
3887 | - copyAction->setText(QObject::tr("Copy Email Address")); |
3888 | - } |
3889 | - |
3890 | - // object names are set here so that the hotspot performs the |
3891 | - // correct action when activated() is called with the triggered |
3892 | - // action passed as a parameter. |
3893 | - openAction->setObjectName( QLatin1String("open-action" )); |
3894 | - copyAction->setObjectName( QLatin1String("copy-action" )); |
3895 | - |
3896 | - QObject::connect( openAction , SIGNAL(triggered()) , _urlObject , SLOT(activated()) ); |
3897 | - QObject::connect( copyAction , SIGNAL(triggered()) , _urlObject , SLOT(activated()) ); |
3898 | - |
3899 | - list << openAction; |
3900 | - list << copyAction; |
3901 | - |
3902 | - return list; |
3903 | -} |
3904 | - |
3905 | -//#include "Filter.moc" |
3906 | |
3907 | === removed file 'src/plugin/konsole/Filter.h' |
3908 | --- src/plugin/konsole/Filter.h 2014-11-12 00:10:12 +0000 |
3909 | +++ src/plugin/konsole/Filter.h 1970-01-01 00:00:00 +0000 |
3910 | @@ -1,380 +0,0 @@ |
3911 | -/* |
3912 | - Copyright 2007-2008 by Robert Knight <robertknight@gmail.com> |
3913 | - |
3914 | - This program is free software; you can redistribute it and/or modify |
3915 | - it under the terms of the GNU General Public License as published by |
3916 | - the Free Software Foundation; either version 2 of the License, or |
3917 | - (at your option) any later version. |
3918 | - |
3919 | - This program is distributed in the hope that it will be useful, |
3920 | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
3921 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3922 | - GNU General Public License for more details. |
3923 | - |
3924 | - You should have received a copy of the GNU General Public License |
3925 | - along with this program; if not, write to the Free Software |
3926 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
3927 | - 02110-1301 USA. |
3928 | -*/ |
3929 | - |
3930 | -#ifndef FILTER_H |
3931 | -#define FILTER_H |
3932 | - |
3933 | -// Qt |
3934 | -#include <QtWidgets/QAction> |
3935 | -#include <QtCore/QList> |
3936 | -#include <QtCore/QObject> |
3937 | -#include <QtCore/QStringList> |
3938 | -#include <QtCore/QHash> |
3939 | -#include <QtCore/QRegExp> |
3940 | - |
3941 | -// Local |
3942 | -#include "Character.h" |
3943 | - |
3944 | - |
3945 | -/** |
3946 | - * A filter processes blocks of text looking for certain patterns (such as URLs or keywords from a list) |
3947 | - * and marks the areas which match the filter's patterns as 'hotspots'. |
3948 | - * |
3949 | - * Each hotspot has a type identifier associated with it ( such as a link or a highlighted section ), |
3950 | - * and an action. When the user performs some activity such as a mouse-click in a hotspot area ( the exact |
3951 | - * action will depend on what is displaying the block of text which the filter is processing ), the hotspot's |
3952 | - * activate() method should be called. Depending on the type of hotspot this will trigger a suitable response. |
3953 | - * |
3954 | - * For example, if a hotspot represents a URL then a suitable action would be opening that URL in a web browser. |
3955 | - * Hotspots may have more than one action, in which case the list of actions can be obtained using the |
3956 | - * actions() method. |
3957 | - * |
3958 | - * Different subclasses of filter will return different types of hotspot. |
3959 | - * Subclasses must reimplement the process() method to examine a block of text and identify sections of interest. |
3960 | - * When processing the text they should create instances of Filter::HotSpot subclasses for sections of interest |
3961 | - * and add them to the filter's list of hotspots using addHotSpot() |
3962 | - */ |
3963 | -class Filter |
3964 | -{ |
3965 | -public: |
3966 | - /** |
3967 | - * Represents an area of text which matched the pattern a particular filter has been looking for. |
3968 | - * |
3969 | - * Each hotspot has a type identifier associated with it ( such as a link or a highlighted section ), |
3970 | - * and an action. When the user performs some activity such as a mouse-click in a hotspot area ( the exact |
3971 | - * action will depend on what is displaying the block of text which the filter is processing ), the hotspot's |
3972 | - * activate() method should be called. Depending on the type of hotspot this will trigger a suitable response. |
3973 | - * |
3974 | - * For example, if a hotspot represents a URL then a suitable action would be opening that URL in a web browser. |
3975 | - * Hotspots may have more than one action, in which case the list of actions can be obtained using the |
3976 | - * actions() method. These actions may then be displayed in a popup menu or toolbar for example. |
3977 | - */ |
3978 | - class HotSpot |
3979 | - { |
3980 | - public: |
3981 | - /** |
3982 | - * Constructs a new hotspot which covers the area from (@p startLine,@p startColumn) to (@p endLine,@p endColumn) |
3983 | - * in a block of text. |
3984 | - */ |
3985 | - HotSpot(int startLine , int startColumn , int endLine , int endColumn); |
3986 | - virtual ~HotSpot(); |
3987 | - |
3988 | - enum Type |
3989 | - { |
3990 | - // the type of the hotspot is not specified |
3991 | - NotSpecified, |
3992 | - // this hotspot represents a clickable link |
3993 | - Link, |
3994 | - // this hotspot represents a marker |
3995 | - Marker |
3996 | - }; |
3997 | - |
3998 | - /** Returns the line when the hotspot area starts */ |
3999 | - int startLine() const; |
4000 | - /** Returns the line where the hotspot area ends */ |
4001 | - int endLine() const; |
4002 | - /** Returns the column on startLine() where the hotspot area starts */ |
4003 | - int startColumn() const; |
4004 | - /** Returns the column on endLine() where the hotspot area ends */ |
4005 | - int endColumn() const; |
4006 | - /** |
4007 | - * Returns the type of the hotspot. This is usually used as a hint for views on how to represent |
4008 | - * the hotspot graphically. eg. Link hotspots are typically underlined when the user mouses over them |
4009 | - */ |
4010 | - Type type() const; |
4011 | - /** |
4012 | - * Causes the an action associated with a hotspot to be triggered. |
4013 | - * |
4014 | - * @param object The object which caused the hotspot to be triggered. This is |
4015 | - * typically null ( in which case the default action should be performed ) or |
4016 | - * one of the objects from the actions() list. In which case the associated |
4017 | - * action should be performed. |
4018 | - */ |
4019 | - virtual void activate(QObject* object = 0) = 0; |
4020 | - /** |
4021 | - * Returns a list of actions associated with the hotspot which can be used in a |
4022 | - * menu or toolbar |
4023 | - */ |
4024 | - virtual QList<QAction*> actions(); |
4025 | - |
4026 | - /** |
4027 | - * Returns the text of a tooltip to be shown when the mouse moves over the hotspot, or |
4028 | - * an empty string if there is no tooltip associated with this hotspot. |
4029 | - * |
4030 | - * The default implementation returns an empty string. |
4031 | - */ |
4032 | - virtual QString tooltip() const; |
4033 | - |
4034 | - protected: |
4035 | - /** Sets the type of a hotspot. This should only be set once */ |
4036 | - void setType(Type type); |
4037 | - |
4038 | - private: |
4039 | - int _startLine; |
4040 | - int _startColumn; |
4041 | - int _endLine; |
4042 | - int _endColumn; |
4043 | - Type _type; |
4044 | - |
4045 | - }; |
4046 | - |
4047 | - /** Constructs a new filter. */ |
4048 | - Filter(); |
4049 | - virtual ~Filter(); |
4050 | - |
4051 | - /** Causes the filter to process the block of text currently in its internal buffer */ |
4052 | - virtual void process() = 0; |
4053 | - |
4054 | - /** |
4055 | - * Empties the filters internal buffer and resets the line count back to 0. |
4056 | - * All hotspots are deleted. |
4057 | - */ |
4058 | - void reset(); |
4059 | - |
4060 | - /** Adds a new line of text to the filter and increments the line count */ |
4061 | - //void addLine(const QString& string); |
4062 | - |
4063 | - /** Returns the hotspot which covers the given @p line and @p column, or 0 if no hotspot covers that area */ |
4064 | - HotSpot* hotSpotAt(int line , int column) const; |
4065 | - |
4066 | - /** Returns the list of hotspots identified by the filter */ |
4067 | - QList<HotSpot*> hotSpots() const; |
4068 | - |
4069 | - /** Returns the list of hotspots identified by the filter which occur on a given line */ |
4070 | - QList<HotSpot*> hotSpotsAtLine(int line) const; |
4071 | - |
4072 | - /** |
4073 | - * TODO: Document me |
4074 | - */ |
4075 | - void setBuffer(const QString* buffer , const QList<int>* linePositions); |
4076 | - |
4077 | -protected: |
4078 | - /** Adds a new hotspot to the list */ |
4079 | - void addHotSpot(HotSpot*); |
4080 | - /** Returns the internal buffer */ |
4081 | - const QString* buffer(); |
4082 | - /** Converts a character position within buffer() to a line and column */ |
4083 | - void getLineColumn(int position , int& startLine , int& startColumn); |
4084 | - |
4085 | -private: |
4086 | - QMultiHash<int,HotSpot*> _hotspots; |
4087 | - QList<HotSpot*> _hotspotList; |
4088 | - |
4089 | - const QList<int>* _linePositions; |
4090 | - const QString* _buffer; |
4091 | -}; |
4092 | - |
4093 | -/** |
4094 | - * A filter which searches for sections of text matching a regular expression and creates a new RegExpFilter::HotSpot |
4095 | - * instance for them. |
4096 | - * |
4097 | - * Subclasses can reimplement newHotSpot() to return custom hotspot types when matches for the regular expression |
4098 | - * are found. |
4099 | - */ |
4100 | -class RegExpFilter : public Filter |
4101 | -{ |
4102 | -public: |
4103 | - /** |
4104 | - * Type of hotspot created by RegExpFilter. The capturedTexts() method can be used to find the text |
4105 | - * matched by the filter's regular expression. |
4106 | - */ |
4107 | - class HotSpot : public Filter::HotSpot |
4108 | - { |
4109 | - public: |
4110 | - HotSpot(int startLine, int startColumn, int endLine , int endColumn); |
4111 | - virtual void activate(QObject* object = 0); |
4112 | - |
4113 | - /** Sets the captured texts associated with this hotspot */ |
4114 | - void setCapturedTexts(const QStringList& texts); |
4115 | - /** Returns the texts found by the filter when matching the filter's regular expression */ |
4116 | - QStringList capturedTexts() const; |
4117 | - private: |
4118 | - QStringList _capturedTexts; |
4119 | - }; |
4120 | - |
4121 | - /** Constructs a new regular expression filter */ |
4122 | - RegExpFilter(); |
4123 | - |
4124 | - /** |
4125 | - * Sets the regular expression which the filter searches for in blocks of text. |
4126 | - * |
4127 | - * Regular expressions which match the empty string are treated as not matching |
4128 | - * anything. |
4129 | - */ |
4130 | - void setRegExp(const QRegExp& text); |
4131 | - /** Returns the regular expression which the filter searches for in blocks of text */ |
4132 | - QRegExp regExp() const; |
4133 | - |
4134 | - /** |
4135 | - * Reimplemented to search the filter's text buffer for text matching regExp() |
4136 | - * |
4137 | - * If regexp matches the empty string, then process() will return immediately |
4138 | - * without finding results. |
4139 | - */ |
4140 | - virtual void process(); |
4141 | - |
4142 | -protected: |
4143 | - /** |
4144 | - * Called when a match for the regular expression is encountered. Subclasses should reimplement this |
4145 | - * to return custom hotspot types |
4146 | - */ |
4147 | - virtual RegExpFilter::HotSpot* newHotSpot(int startLine,int startColumn, |
4148 | - int endLine,int endColumn); |
4149 | - |
4150 | -private: |
4151 | - QRegExp _searchText; |
4152 | -}; |
4153 | - |
4154 | -class FilterObject; |
4155 | - |
4156 | -/** A filter which matches URLs in blocks of text */ |
4157 | -class UrlFilter : public RegExpFilter |
4158 | -{ |
4159 | -public: |
4160 | - /** |
4161 | - * Hotspot type created by UrlFilter instances. The activate() method opens a web browser |
4162 | - * at the given URL when called. |
4163 | - */ |
4164 | - class HotSpot : public RegExpFilter::HotSpot |
4165 | - { |
4166 | - public: |
4167 | - HotSpot(int startLine,int startColumn,int endLine,int endColumn); |
4168 | - virtual ~HotSpot(); |
4169 | - |
4170 | - virtual QList<QAction*> actions(); |
4171 | - |
4172 | - /** |
4173 | - * Open a web browser at the current URL. The url itself can be determined using |
4174 | - * the capturedTexts() method. |
4175 | - */ |
4176 | - virtual void activate(QObject* object = 0); |
4177 | - |
4178 | - virtual QString tooltip() const; |
4179 | - private: |
4180 | - enum UrlType |
4181 | - { |
4182 | - StandardUrl, |
4183 | - Email, |
4184 | - Unknown |
4185 | - }; |
4186 | - UrlType urlType() const; |
4187 | - |
4188 | - FilterObject* _urlObject; |
4189 | - }; |
4190 | - |
4191 | - UrlFilter(); |
4192 | - |
4193 | -protected: |
4194 | - virtual RegExpFilter::HotSpot* newHotSpot(int,int,int,int); |
4195 | - |
4196 | -private: |
4197 | - |
4198 | - static const QRegExp FullUrlRegExp; |
4199 | - static const QRegExp EmailAddressRegExp; |
4200 | - |
4201 | - // combined OR of FullUrlRegExp and EmailAddressRegExp |
4202 | - static const QRegExp CompleteUrlRegExp; |
4203 | -}; |
4204 | - |
4205 | -class FilterObject : public QObject |
4206 | -{ |
4207 | -Q_OBJECT |
4208 | -public: |
4209 | - FilterObject(Filter::HotSpot* filter) : _filter(filter) {} |
4210 | -private slots: |
4211 | - void activated(); |
4212 | -private: |
4213 | - Filter::HotSpot* _filter; |
4214 | -}; |
4215 | - |
4216 | -/** |
4217 | - * A chain which allows a group of filters to be processed as one. |
4218 | - * The chain owns the filters added to it and deletes them when the chain itself is destroyed. |
4219 | - * |
4220 | - * Use addFilter() to add a new filter to the chain. |
4221 | - * When new text to be filtered arrives, use addLine() to add each additional |
4222 | - * line of text which needs to be processed and then after adding the last line, use |
4223 | - * process() to cause each filter in the chain to process the text. |
4224 | - * |
4225 | - * After processing a block of text, the reset() method can be used to set the filter chain's |
4226 | - * internal cursor back to the first line. |
4227 | - * |
4228 | - * The hotSpotAt() method will return the first hotspot which covers a given position. |
4229 | - * |
4230 | - * The hotSpots() and hotSpotsAtLine() method return all of the hotspots in the text and on |
4231 | - * a given line respectively. |
4232 | - */ |
4233 | -class FilterChain : protected QList<Filter*> |
4234 | -{ |
4235 | -public: |
4236 | - virtual ~FilterChain(); |
4237 | - |
4238 | - /** Adds a new filter to the chain. The chain will delete this filter when it is destroyed */ |
4239 | - void addFilter(Filter* filter); |
4240 | - /** Removes a filter from the chain. The chain will no longer delete the filter when destroyed */ |
4241 | - void removeFilter(Filter* filter); |
4242 | - /** Returns true if the chain contains @p filter */ |
4243 | - bool containsFilter(Filter* filter); |
4244 | - /** Removes all filters from the chain */ |
4245 | - void clear(); |
4246 | - |
4247 | - /** Resets each filter in the chain */ |
4248 | - void reset(); |
4249 | - /** |
4250 | - * Processes each filter in the chain |
4251 | - */ |
4252 | - void process(); |
4253 | - |
4254 | - /** Sets the buffer for each filter in the chain to process. */ |
4255 | - void setBuffer(const QString* buffer , const QList<int>* linePositions); |
4256 | - |
4257 | - /** Returns the first hotspot which occurs at @p line, @p column or 0 if no hotspot was found */ |
4258 | - Filter::HotSpot* hotSpotAt(int line , int column) const; |
4259 | - /** Returns a list of all the hotspots in all the chain's filters */ |
4260 | - QList<Filter::HotSpot*> hotSpots() const; |
4261 | - /** Returns a list of all hotspots at the given line in all the chain's filters */ |
4262 | - QList<Filter::HotSpot> hotSpotsAtLine(int line) const; |
4263 | - |
4264 | -}; |
4265 | - |
4266 | -/** A filter chain which processes character images from terminal displays */ |
4267 | -class TerminalImageFilterChain : public FilterChain |
4268 | -{ |
4269 | -public: |
4270 | - TerminalImageFilterChain(); |
4271 | - virtual ~TerminalImageFilterChain(); |
4272 | - |
4273 | - /** |
4274 | - * Set the current terminal image to @p image. |
4275 | - * |
4276 | - * @param image The terminal image |
4277 | - * @param lines The number of lines in the terminal image |
4278 | - * @param columns The number of columns in the terminal image |
4279 | - * @param lineProperties The line properties to set for image |
4280 | - */ |
4281 | - void setImage(const Character* const image , int lines , int columns, |
4282 | - const QVector<LineProperty>& lineProperties); |
4283 | - |
4284 | -private: |
4285 | - QString* _buffer; |
4286 | - QList<int>* _linePositions; |
4287 | -}; |
4288 | - |
4289 | - |
4290 | -#endif //FILTER_H |
4291 | |
4292 | === removed file 'src/plugin/konsole/History.cpp' |
4293 | --- src/plugin/konsole/History.cpp 2014-11-12 00:10:12 +0000 |
4294 | +++ src/plugin/konsole/History.cpp 1970-01-01 00:00:00 +0000 |
4295 | @@ -1,986 +0,0 @@ |
4296 | -/* |
4297 | - This file is part of Konsole, an X terminal. |
4298 | - Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de> |
4299 | - |
4300 | - This program is free software; you can redistribute it and/or modify |
4301 | - it under the terms of the GNU General Public License as published by |
4302 | - the Free Software Foundation; either version 2 of the License, or |
4303 | - (at your option) any later version. |
4304 | - |
4305 | - This program is distributed in the hope that it will be useful, |
4306 | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
4307 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4308 | - GNU General Public License for more details. |
4309 | - |
4310 | - You should have received a copy of the GNU General Public License |
4311 | - along with this program; if not, write to the Free Software |
4312 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
4313 | - 02110-1301 USA. |
4314 | -*/ |
4315 | - |
4316 | -// Own |
4317 | -#include "History.h" |
4318 | - |
4319 | -// System |
4320 | -#include <iostream> |
4321 | -#include <stdlib.h> |
4322 | -#include <assert.h> |
4323 | -#include <stdio.h> |
4324 | -#include <sys/types.h> |
4325 | -#include <sys/mman.h> |
4326 | -#include <unistd.h> |
4327 | -#include <errno.h> |
4328 | - |
4329 | -#include <QtDebug> |
4330 | - |
4331 | -// KDE |
4332 | -//#include <kde_file.h> |
4333 | -//#include <kdebug.h> |
4334 | - |
4335 | -// Reasonable line size |
4336 | -#define LINE_SIZE 1024 |
4337 | -#define KDE_lseek lseek |
4338 | - |
4339 | - |
4340 | -/* |
4341 | - An arbitrary long scroll. |
4342 | - |
4343 | - One can modify the scroll only by adding either cells |
4344 | - or newlines, but access it randomly. |
4345 | - |
4346 | - The model is that of an arbitrary wide typewriter scroll |
4347 | - in that the scroll is a serie of lines and each line is |
4348 | - a serie of cells with no overwriting permitted. |
4349 | - |
4350 | - The implementation provides arbitrary length and numbers |
4351 | - of cells and line/column indexed read access to the scroll |
4352 | - at constant costs. |
4353 | - |
4354 | -KDE4: Can we use QTemporaryFile here, instead of KTempFile? |
4355 | - |
4356 | -FIXME: some complain about the history buffer comsuming the |
4357 | - memory of their machines. This problem is critical |
4358 | - since the history does not behave gracefully in cases |
4359 | - where the memory is used up completely. |
4360 | - |
4361 | - I put in a workaround that should handle it problem |
4362 | - now gracefully. I'm not satisfied with the solution. |
4363 | - |
4364 | -FIXME: Terminating the history is not properly indicated |
4365 | - in the menu. We should throw a signal. |
4366 | - |
4367 | -FIXME: There is noticeable decrease in speed, also. Perhaps, |
4368 | - there whole feature needs to be revisited therefore. |
4369 | - Disadvantage of a more elaborated, say block-oriented |
4370 | - scheme with wrap around would be it's complexity. |
4371 | -*/ |
4372 | - |
4373 | -//FIXME: tempory replacement for tmpfile |
4374 | -// this is here one for debugging purpose. |
4375 | - |
4376 | -//#define tmpfile xTmpFile |
4377 | - |
4378 | -// History File /////////////////////////////////////////// |
4379 | - |
4380 | -/* |
4381 | - A Row(X) data type which allows adding elements to the end. |
4382 | -*/ |
4383 | - |
4384 | -HistoryFile::HistoryFile() |
4385 | - : ion(-1), |
4386 | - length(0), |
4387 | - fileMap(0) |
4388 | -{ |
4389 | - if (tmpFile.open()) |
4390 | - { |
4391 | - tmpFile.setAutoRemove(true); |
4392 | - ion = tmpFile.handle(); |
4393 | - } |
4394 | -} |
4395 | - |
4396 | -HistoryFile::~HistoryFile() |
4397 | -{ |
4398 | - if (fileMap) |
4399 | - unmap(); |
4400 | -} |
4401 | - |
4402 | -//TODO: Mapping the entire file in will cause problems if the history file becomes exceedingly large, |
4403 | -//(ie. larger than available memory). HistoryFile::map() should only map in sections of the file at a time, |
4404 | -//to avoid this. |
4405 | -void HistoryFile::map() |
4406 | -{ |
4407 | - assert( fileMap == 0 ); |
4408 | - |
4409 | - fileMap = (char*)mmap( 0 , length , PROT_READ , MAP_PRIVATE , ion , 0 ); |
4410 | - |
4411 | - //if mmap'ing fails, fall back to the read-lseek combination |
4412 | - if ( fileMap == MAP_FAILED ) |
4413 | - { |
4414 | - readWriteBalance = 0; |
4415 | - fileMap = 0; |
4416 | - qDebug() << __FILE__ << __LINE__ << ": mmap'ing history failed. errno = " << errno; |
4417 | - } |
4418 | -} |
4419 | - |
4420 | -void HistoryFile::unmap() |
4421 | -{ |
4422 | - int result = munmap( fileMap , length ); |
4423 | - assert( result == 0 ); Q_UNUSED( result ); |
4424 | - |
4425 | - fileMap = 0; |
4426 | -} |
4427 | - |
4428 | -bool HistoryFile::isMapped() |
4429 | -{ |
4430 | - return (fileMap != 0); |
4431 | -} |
4432 | - |
4433 | -void HistoryFile::add(const unsigned char* bytes, int len) |
4434 | -{ |
4435 | - if ( fileMap ) |
4436 | - unmap(); |
4437 | - |
4438 | - readWriteBalance++; |
4439 | - |
4440 | - int rc = 0; |
4441 | - |
4442 | - rc = KDE_lseek(ion,length,SEEK_SET); if (rc < 0) { perror("HistoryFile::add.seek"); return; } |
4443 | - rc = write(ion,bytes,len); if (rc < 0) { perror("HistoryFile::add.write"); return; } |
4444 | - length += rc; |
4445 | -} |
4446 | - |
4447 | -void HistoryFile::get(unsigned char* bytes, int len, int loc) |
4448 | -{ |
4449 | - //count number of get() calls vs. number of add() calls. |
4450 | - //If there are many more get() calls compared with add() |
4451 | - //calls (decided by using MAP_THRESHOLD) then mmap the log |
4452 | - //file to improve performance. |
4453 | - readWriteBalance--; |
4454 | - if ( !fileMap && readWriteBalance < MAP_THRESHOLD ) |
4455 | - map(); |
4456 | - |
4457 | - if ( fileMap ) |
4458 | - { |
4459 | - for (int i=0;i<len;i++) |
4460 | - bytes[i]=fileMap[loc+i]; |
4461 | - } |
4462 | - else |
4463 | - { |
4464 | - int rc = 0; |
4465 | - |
4466 | - if (loc < 0 || len < 0 || loc + len > length) |
4467 | - fprintf(stderr,"getHist(...,%d,%d): invalid args.\n",len,loc); |
4468 | - rc = KDE_lseek(ion,loc,SEEK_SET); if (rc < 0) { perror("HistoryFile::get.seek"); return; } |
4469 | - rc = read(ion,bytes,len); if (rc < 0) { perror("HistoryFile::get.read"); return; } |
4470 | - } |
4471 | -} |
4472 | - |
4473 | -int HistoryFile::len() |
4474 | -{ |
4475 | - return length; |
4476 | -} |
4477 | - |
4478 | - |
4479 | -// History Scroll abstract base class ////////////////////////////////////// |
4480 | - |
4481 | - |
4482 | -HistoryScroll::HistoryScroll(HistoryType* t) |
4483 | - : m_histType(t) |
4484 | -{ |
4485 | -} |
4486 | - |
4487 | -HistoryScroll::~HistoryScroll() |
4488 | -{ |
4489 | - delete m_histType; |
4490 | -} |
4491 | - |
4492 | -bool HistoryScroll::hasScroll() |
4493 | -{ |
4494 | - return true; |
4495 | -} |
4496 | - |
4497 | -// History Scroll File ////////////////////////////////////// |
4498 | - |
4499 | -/* |
4500 | - The history scroll makes a Row(Row(Cell)) from |
4501 | - two history buffers. The index buffer contains |
4502 | - start of line positions which refere to the cells |
4503 | - buffer. |
4504 | - |
4505 | - Note that index[0] addresses the second line |
4506 | - (line #1), while the first line (line #0) starts |
4507 | - at 0 in cells. |
4508 | -*/ |
4509 | - |
4510 | -HistoryScrollFile::HistoryScrollFile(const QString &logFileName) |
4511 | - : HistoryScroll(new HistoryTypeFile(logFileName)), |
4512 | - m_logFileName(logFileName) |
4513 | -{ |
4514 | -} |
4515 | - |
4516 | -HistoryScrollFile::~HistoryScrollFile() |
4517 | -{ |
4518 | -} |
4519 | - |
4520 | -int HistoryScrollFile::getLines() |
4521 | -{ |
4522 | - return index.len() / sizeof(int); |
4523 | -} |
4524 | - |
4525 | -int HistoryScrollFile::getLineLen(int lineno) |
4526 | -{ |
4527 | - return (startOfLine(lineno+1) - startOfLine(lineno)) / sizeof(Character); |
4528 | -} |
4529 | - |
4530 | -bool HistoryScrollFile::isWrappedLine(int lineno) |
4531 | -{ |
4532 | - if (lineno>=0 && lineno <= getLines()) { |
4533 | - unsigned char flag; |
4534 | - lineflags.get((unsigned char*)&flag,sizeof(unsigned char),(lineno)*sizeof(unsigned char)); |
4535 | - return flag; |
4536 | - } |
4537 | - return false; |
4538 | -} |
4539 | - |
4540 | -int HistoryScrollFile::startOfLine(int lineno) |
4541 | -{ |
4542 | - if (lineno <= 0) return 0; |
4543 | - if (lineno <= getLines()) |
4544 | - { |
4545 | - |
4546 | - if (!index.isMapped()) |
4547 | - index.map(); |
4548 | - |
4549 | - int res; |
4550 | - index.get((unsigned char*)&res,sizeof(int),(lineno-1)*sizeof(int)); |
4551 | - return res; |
4552 | - } |
4553 | - return cells.len(); |
4554 | -} |
4555 | - |
4556 | -void HistoryScrollFile::getCells(int lineno, int colno, int count, Character res[]) |
4557 | -{ |
4558 | - cells.get((unsigned char*)res,count*sizeof(Character),startOfLine(lineno)+colno*sizeof(Character)); |
4559 | -} |
4560 | - |
4561 | -void HistoryScrollFile::addCells(const Character text[], int count) |
4562 | -{ |
4563 | - cells.add((unsigned char*)text,count*sizeof(Character)); |
4564 | -} |
4565 | - |
4566 | -void HistoryScrollFile::addLine(bool previousWrapped) |
4567 | -{ |
4568 | - if (index.isMapped()) |
4569 | - index.unmap(); |
4570 | - |
4571 | - int locn = cells.len(); |
4572 | - index.add((unsigned char*)&locn,sizeof(int)); |
4573 | - unsigned char flags = previousWrapped ? 0x01 : 0x00; |
4574 | - lineflags.add((unsigned char*)&flags,sizeof(unsigned char)); |
4575 | -} |
4576 | - |
4577 | - |
4578 | -// History Scroll Buffer ////////////////////////////////////// |
4579 | -HistoryScrollBuffer::HistoryScrollBuffer(unsigned int maxLineCount) |
4580 | - : HistoryScroll(new HistoryTypeBuffer(maxLineCount)) |
4581 | - ,_historyBuffer() |
4582 | - ,_maxLineCount(0) |
4583 | - ,_usedLines(0) |
4584 | - ,_head(0) |
4585 | -{ |
4586 | - setMaxNbLines(maxLineCount); |
4587 | -} |
4588 | - |
4589 | -HistoryScrollBuffer::~HistoryScrollBuffer() |
4590 | -{ |
4591 | - delete[] _historyBuffer; |
4592 | -} |
4593 | - |
4594 | -void HistoryScrollBuffer::addCellsVector(const QVector<Character>& cells) |
4595 | -{ |
4596 | - _head++; |
4597 | - if ( _usedLines < _maxLineCount ) |
4598 | - _usedLines++; |
4599 | - |
4600 | - if ( _head >= _maxLineCount ) |
4601 | - { |
4602 | - _head = 0; |
4603 | - } |
4604 | - |
4605 | - _historyBuffer[bufferIndex(_usedLines-1)] = cells; |
4606 | - _wrappedLine[bufferIndex(_usedLines-1)] = false; |
4607 | -} |
4608 | -void HistoryScrollBuffer::addCells(const Character a[], int count) |
4609 | -{ |
4610 | - HistoryLine newLine(count); |
4611 | - qCopy(a,a+count,newLine.begin()); |
4612 | - |
4613 | - addCellsVector(newLine); |
4614 | -} |
4615 | - |
4616 | -void HistoryScrollBuffer::addLine(bool previousWrapped) |
4617 | -{ |
4618 | - _wrappedLine[bufferIndex(_usedLines-1)] = previousWrapped; |
4619 | -} |
4620 | - |
4621 | -int HistoryScrollBuffer::getLines() |
4622 | -{ |
4623 | - return _usedLines; |
4624 | -} |
4625 | - |
4626 | -int HistoryScrollBuffer::getLineLen(int lineNumber) |
4627 | -{ |
4628 | - Q_ASSERT( lineNumber >= 0 && lineNumber < _maxLineCount ); |
4629 | - |
4630 | - if ( lineNumber < _usedLines ) |
4631 | - { |
4632 | - return _historyBuffer[bufferIndex(lineNumber)].size(); |
4633 | - } |
4634 | - else |
4635 | - { |
4636 | - return 0; |
4637 | - } |
4638 | -} |
4639 | - |
4640 | -bool HistoryScrollBuffer::isWrappedLine(int lineNumber) |
4641 | -{ |
4642 | - Q_ASSERT( lineNumber >= 0 && lineNumber < _maxLineCount ); |
4643 | - |
4644 | - if (lineNumber < _usedLines) |
4645 | - { |
4646 | - //kDebug() << "Line" << lineNumber << "wrapped is" << _wrappedLine[bufferIndex(lineNumber)]; |
4647 | - return _wrappedLine[bufferIndex(lineNumber)]; |
4648 | - } |
4649 | - else |
4650 | - return false; |
4651 | -} |
4652 | - |
4653 | -void HistoryScrollBuffer::getCells(int lineNumber, int startColumn, int count, Character buffer[]) |
4654 | -{ |
4655 | - if ( count == 0 ) return; |
4656 | - |
4657 | - Q_ASSERT( lineNumber < _maxLineCount ); |
4658 | - |
4659 | - if (lineNumber >= _usedLines) |
4660 | - { |
4661 | - memset(buffer, 0, count * sizeof(Character)); |
4662 | - return; |
4663 | - } |
4664 | - |
4665 | - const HistoryLine& line = _historyBuffer[bufferIndex(lineNumber)]; |
4666 | - |
4667 | - //kDebug() << "startCol " << startColumn; |
4668 | - //kDebug() << "line.size() " << line.size(); |
4669 | - //kDebug() << "count " << count; |
4670 | - |
4671 | - Q_ASSERT( startColumn <= line.size() - count ); |
4672 | - |
4673 | - memcpy(buffer, line.constData() + startColumn , count * sizeof(Character)); |
4674 | -} |
4675 | - |
4676 | -void HistoryScrollBuffer::setMaxNbLines(unsigned int lineCount) |
4677 | -{ |
4678 | - HistoryLine* oldBuffer = _historyBuffer; |
4679 | - HistoryLine* newBuffer = new HistoryLine[lineCount]; |
4680 | - |
4681 | - for ( int i = 0 ; i < qMin(_usedLines,(int)lineCount) ; i++ ) |
4682 | - { |
4683 | - newBuffer[i] = oldBuffer[bufferIndex(i)]; |
4684 | - } |
4685 | - |
4686 | - _usedLines = qMin(_usedLines,(int)lineCount); |
4687 | - _maxLineCount = lineCount; |
4688 | - _head = ( _usedLines == _maxLineCount ) ? 0 : _usedLines-1; |
4689 | - |
4690 | - _historyBuffer = newBuffer; |
4691 | - delete[] oldBuffer; |
4692 | - |
4693 | - _wrappedLine.resize(lineCount); |
4694 | - dynamic_cast<HistoryTypeBuffer*>(m_histType)->m_nbLines = lineCount; |
4695 | -} |
4696 | - |
4697 | -int HistoryScrollBuffer::bufferIndex(int lineNumber) |
4698 | -{ |
4699 | - Q_ASSERT( lineNumber >= 0 ); |
4700 | - Q_ASSERT( lineNumber < _maxLineCount ); |
4701 | - Q_ASSERT( (_usedLines == _maxLineCount) || lineNumber <= _head ); |
4702 | - |
4703 | - if ( _usedLines == _maxLineCount ) |
4704 | - { |
4705 | - return (_head+lineNumber+1) % _maxLineCount; |
4706 | - } |
4707 | - else |
4708 | - { |
4709 | - return lineNumber; |
4710 | - } |
4711 | -} |
4712 | - |
4713 | - |
4714 | -// History Scroll None ////////////////////////////////////// |
4715 | - |
4716 | -HistoryScrollNone::HistoryScrollNone() |
4717 | - : HistoryScroll(new HistoryTypeNone()) |
4718 | -{ |
4719 | -} |
4720 | - |
4721 | -HistoryScrollNone::~HistoryScrollNone() |
4722 | -{ |
4723 | -} |
4724 | - |
4725 | -bool HistoryScrollNone::hasScroll() |
4726 | -{ |
4727 | - return false; |
4728 | -} |
4729 | - |
4730 | -int HistoryScrollNone::getLines() |
4731 | -{ |
4732 | - return 0; |
4733 | -} |
4734 | - |
4735 | -int HistoryScrollNone::getLineLen(int) |
4736 | -{ |
4737 | - return 0; |
4738 | -} |
4739 | - |
4740 | -bool HistoryScrollNone::isWrappedLine(int /*lineno*/) |
4741 | -{ |
4742 | - return false; |
4743 | -} |
4744 | - |
4745 | -void HistoryScrollNone::getCells(int, int, int, Character []) |
4746 | -{ |
4747 | -} |
4748 | - |
4749 | -void HistoryScrollNone::addCells(const Character [], int) |
4750 | -{ |
4751 | -} |
4752 | - |
4753 | -void HistoryScrollNone::addLine(bool) |
4754 | -{ |
4755 | -} |
4756 | - |
4757 | -// History Scroll BlockArray ////////////////////////////////////// |
4758 | - |
4759 | -HistoryScrollBlockArray::HistoryScrollBlockArray(size_t size) |
4760 | - : HistoryScroll(new HistoryTypeBlockArray(size)) |
4761 | -{ |
4762 | - m_blockArray.setHistorySize(size); // nb. of lines. |
4763 | -} |
4764 | - |
4765 | -HistoryScrollBlockArray::~HistoryScrollBlockArray() |
4766 | -{ |
4767 | -} |
4768 | - |
4769 | -int HistoryScrollBlockArray::getLines() |
4770 | -{ |
4771 | - return m_lineLengths.count(); |
4772 | -} |
4773 | - |
4774 | -int HistoryScrollBlockArray::getLineLen(int lineno) |
4775 | -{ |
4776 | - if ( m_lineLengths.contains(lineno) ) |
4777 | - return m_lineLengths[lineno]; |
4778 | - else |
4779 | - return 0; |
4780 | -} |
4781 | - |
4782 | -bool HistoryScrollBlockArray::isWrappedLine(int /*lineno*/) |
4783 | -{ |
4784 | - return false; |
4785 | -} |
4786 | - |
4787 | -void HistoryScrollBlockArray::getCells(int lineno, int colno, |
4788 | - int count, Character res[]) |
4789 | -{ |
4790 | - if (!count) return; |
4791 | - |
4792 | - const Block *b = m_blockArray.at(lineno); |
4793 | - |
4794 | - if (!b) { |
4795 | - memset(res, 0, count * sizeof(Character)); // still better than random data |
4796 | - return; |
4797 | - } |
4798 | - |
4799 | - assert(((colno + count) * sizeof(Character)) < ENTRIES); |
4800 | - memcpy(res, b->data + (colno * sizeof(Character)), count * sizeof(Character)); |
4801 | -} |
4802 | - |
4803 | -void HistoryScrollBlockArray::addCells(const Character a[], int count) |
4804 | -{ |
4805 | - Block *b = m_blockArray.lastBlock(); |
4806 | - |
4807 | - if (!b) return; |
4808 | - |
4809 | - // put cells in block's data |
4810 | - assert((count * sizeof(Character)) < ENTRIES); |
4811 | - |
4812 | - memset(b->data, 0, ENTRIES); |
4813 | - |
4814 | - memcpy(b->data, a, count * sizeof(Character)); |
4815 | - b->size = count * sizeof(Character); |
4816 | - |
4817 | - size_t res = m_blockArray.newBlock(); |
4818 | - assert (res > 0); |
4819 | - Q_UNUSED( res ); |
4820 | - |
4821 | - m_lineLengths.insert(m_blockArray.getCurrent(), count); |
4822 | -} |
4823 | - |
4824 | -void HistoryScrollBlockArray::addLine(bool) |
4825 | -{ |
4826 | -} |
4827 | - |
4828 | -//////////////////////////////////////////////////////////////// |
4829 | -// Compact History Scroll ////////////////////////////////////// |
4830 | -//////////////////////////////////////////////////////////////// |
4831 | -void* CompactHistoryBlock::allocate ( size_t length ) |
4832 | -{ |
4833 | - Q_ASSERT ( length > 0 ); |
4834 | - if ( tail-blockStart+length > blockLength ) |
4835 | - return NULL; |
4836 | - |
4837 | - void* block = tail; |
4838 | - tail += length; |
4839 | - //kDebug() << "allocated " << length << " bytes at address " << block; |
4840 | - allocCount++; |
4841 | - return block; |
4842 | -} |
4843 | - |
4844 | -void CompactHistoryBlock::deallocate ( ) |
4845 | -{ |
4846 | - allocCount--; |
4847 | - Q_ASSERT ( allocCount >= 0 ); |
4848 | -} |
4849 | - |
4850 | -void* CompactHistoryBlockList::allocate(size_t size) |
4851 | -{ |
4852 | - CompactHistoryBlock* block; |
4853 | - if ( list.isEmpty() || list.last()->remaining() < size) |
4854 | - { |
4855 | - block = new CompactHistoryBlock(); |
4856 | - list.append ( block ); |
4857 | - //kDebug() << "new block created, remaining " << block->remaining() << "number of blocks=" << list.size(); |
4858 | - } |
4859 | - else |
4860 | - { |
4861 | - block = list.last(); |
4862 | - //kDebug() << "old block used, remaining " << block->remaining(); |
4863 | - } |
4864 | - return block->allocate(size); |
4865 | -} |
4866 | - |
4867 | -void CompactHistoryBlockList::deallocate(void* ptr) |
4868 | -{ |
4869 | - Q_ASSERT( !list.isEmpty()); |
4870 | - |
4871 | - int i=0; |
4872 | - CompactHistoryBlock *block = list.at(i); |
4873 | - while ( i<list.size() && !block->contains(ptr) ) |
4874 | - { |
4875 | - i++; |
4876 | - block=list.at(i); |
4877 | - } |
4878 | - |
4879 | - Q_ASSERT( i<list.size() ); |
4880 | - |
4881 | - block->deallocate(); |
4882 | - |
4883 | - if (!block->isInUse()) |
4884 | - { |
4885 | - list.removeAt(i); |
4886 | - delete block; |
4887 | - //kDebug() << "block deleted, new size = " << list.size(); |
4888 | - } |
4889 | -} |
4890 | - |
4891 | -CompactHistoryBlockList::~CompactHistoryBlockList() |
4892 | -{ |
4893 | - qDeleteAll ( list.begin(), list.end() ); |
4894 | - list.clear(); |
4895 | -} |
4896 | - |
4897 | -void* CompactHistoryLine::operator new (size_t size, CompactHistoryBlockList& blockList) |
4898 | -{ |
4899 | - return blockList.allocate(size); |
4900 | -} |
4901 | - |
4902 | -CompactHistoryLine::CompactHistoryLine ( const TextLine& line, CompactHistoryBlockList& bList ) |
4903 | - : blockList(bList), |
4904 | - formatLength(0) |
4905 | -{ |
4906 | - length=line.size(); |
4907 | - |
4908 | - if (line.size() > 0) { |
4909 | - formatLength=1; |
4910 | - int k=1; |
4911 | - |
4912 | - // count number of different formats in this text line |
4913 | - Character c = line[0]; |
4914 | - while ( k<length ) |
4915 | - { |
4916 | - if ( !(line[k].equalsFormat(c))) |
4917 | - { |
4918 | - formatLength++; // format change detected |
4919 | - c=line[k]; |
4920 | - } |
4921 | - k++; |
4922 | - } |
4923 | - |
4924 | - //kDebug() << "number of different formats in string: " << formatLength; |
4925 | - formatArray = (CharacterFormat*) blockList.allocate(sizeof(CharacterFormat)*formatLength); |
4926 | - Q_ASSERT (formatArray!=NULL); |
4927 | - text = (quint16*) blockList.allocate(sizeof(quint16)*line.size()); |
4928 | - Q_ASSERT (text!=NULL); |
4929 | - |
4930 | - length=line.size(); |
4931 | - formatLength=formatLength; |
4932 | - wrapped=false; |
4933 | - |
4934 | - // record formats and their positions in the format array |
4935 | - c=line[0]; |
4936 | - formatArray[0].setFormat ( c ); |
4937 | - formatArray[0].startPos=0; // there's always at least 1 format (for the entire line, unless a change happens) |
4938 | - |
4939 | - k=1; // look for possible format changes |
4940 | - int j=1; |
4941 | - while ( k<length && j<formatLength ) |
4942 | - { |
4943 | - if (!(line[k].equalsFormat(c))) |
4944 | - { |
4945 | - c=line[k]; |
4946 | - formatArray[j].setFormat(c); |
4947 | - formatArray[j].startPos=k; |
4948 | - //kDebug() << "format entry " << j << " at pos " << formatArray[j].startPos << " " << &(formatArray[j].startPos) ; |
4949 | - j++; |
4950 | - } |
4951 | - k++; |
4952 | - } |
4953 | - |
4954 | - // copy character values |
4955 | - for ( int i=0; i<line.size(); i++ ) |
4956 | - { |
4957 | - text[i]=line[i].character; |
4958 | - //kDebug() << "char " << i << " at mem " << &(text[i]); |
4959 | - } |
4960 | - } |
4961 | - //kDebug() << "line created, length " << length << " at " << &(length); |
4962 | -} |
4963 | - |
4964 | -CompactHistoryLine::~CompactHistoryLine() |
4965 | -{ |
4966 | - //kDebug() << "~CHL"; |
4967 | - if (length>0) { |
4968 | - blockList.deallocate(text); |
4969 | - blockList.deallocate(formatArray); |
4970 | - } |
4971 | - blockList.deallocate(this); |
4972 | -} |
4973 | - |
4974 | -void CompactHistoryLine::getCharacter ( int index, Character &r ) |
4975 | -{ |
4976 | - Q_ASSERT ( index < length ); |
4977 | - int formatPos=0; |
4978 | - while ( ( formatPos+1 ) < formatLength && index >= formatArray[formatPos+1].startPos ) |
4979 | - formatPos++; |
4980 | - |
4981 | - r.character=text[index]; |
4982 | - r.rendition = formatArray[formatPos].rendition; |
4983 | - r.foregroundColor = formatArray[formatPos].fgColor; |
4984 | - r.backgroundColor = formatArray[formatPos].bgColor; |
4985 | -} |
4986 | - |
4987 | -void CompactHistoryLine::getCharacters ( Character* array, int length, int startColumn ) |
4988 | -{ |
4989 | - Q_ASSERT ( startColumn >= 0 && length >= 0 ); |
4990 | - Q_ASSERT ( startColumn+length <= ( int ) getLength() ); |
4991 | - |
4992 | - for ( int i=startColumn; i<length+startColumn; i++ ) |
4993 | - { |
4994 | - getCharacter ( i, array[i-startColumn] ); |
4995 | - } |
4996 | -} |
4997 | - |
4998 | -CompactHistoryScroll::CompactHistoryScroll ( unsigned int maxLineCount ) |
4999 | - : HistoryScroll ( new CompactHistoryType ( maxLineCount ) ) |
5000 | - ,lines() |
The diff has been truncated for viewing.