summaryrefslogtreecommitdiff
authorerik <erik>2007-01-19 01:12:38 (UTC)
committer erik <erik>2007-01-19 01:12:38 (UTC)
commit1ab92f1d2b346de7da8ca5c3aaa6bc75b43981e7 (patch) (unidiff)
treeaf4a12bc46e25853386dc53868b869e1bf05d863
parent2b45dc71e79a3eb7d4e8553273c9bc4f4282d50a (diff)
downloadopie-1ab92f1d2b346de7da8ca5c3aaa6bc75b43981e7.zip
opie-1ab92f1d2b346de7da8ca5c3aaa6bc75b43981e7.tar.gz
opie-1ab92f1d2b346de7da8ca5c3aaa6bc75b43981e7.tar.bz2
Every single file in this commit had a memory leak where a resource is
allocated in the constructor but not de-allocated in the destructor. This commit fixes that.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/TEScreen.cpp32
-rw-r--r--inputmethods/dasher/PPMLanguageModel.cpp3
-rw-r--r--noncore/apps/opie-reader/Bkmks.cpp18
-rw-r--r--noncore/apps/opie-reader/Bkmks.h7
-rw-r--r--noncore/apps/opie-reader/StyleConsts.cpp7
-rw-r--r--noncore/apps/opie-reader/StyleConsts.h8
-rw-r--r--noncore/apps/opie-write/qrichtext.cpp5
-rw-r--r--noncore/apps/tinykate/libkate/document/katehighlight.cpp7
-rw-r--r--noncore/apps/tinykate/libkate/document/katehighlight.h2
9 files changed, 57 insertions, 32 deletions
diff --git a/core/apps/embeddedkonsole/TEScreen.cpp b/core/apps/embeddedkonsole/TEScreen.cpp
index 1db34d2..30ff49d 100644
--- a/core/apps/embeddedkonsole/TEScreen.cpp
+++ b/core/apps/embeddedkonsole/TEScreen.cpp
@@ -1,218 +1,218 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [TEScreen.C] Screen Data Type */ 3/* [TEScreen.C] Screen Data Type */
4/* */ 4/* */
5/* -------------------------------------------------------------------------- */ 5/* -------------------------------------------------------------------------- */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole - an X terminal for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* -------------------------------------------------------------------------- */ 11/* -------------------------------------------------------------------------- */
12/* */ 12/* */
13/* Ported Konsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14/* */ 14/* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16/* */ 16/* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18// enhancements added by L.J. Potter <ljp@llornkcor.com> 18// enhancements added by L.J. Potter <ljp@llornkcor.com>
19 19
20/*! \file 20/*! \file
21*/ 21*/
22 22
23/*! \class TEScreen 23/*! \class TEScreen
24 24
25 \brief The image manipulated by the emulation. 25 \brief The image manipulated by the emulation.
26 26
27 This class implements the operations of the terminal emulation framework. 27 This class implements the operations of the terminal emulation framework.
28 It is a complete passive device, driven by the emulation decoder 28 It is a complete passive device, driven by the emulation decoder
29 (TEmuVT102). By this it forms in fact an ADT, that defines operations 29 (TEmuVT102). By this it forms in fact an ADT, that defines operations
30 on a rectangular image. 30 on a rectangular image.
31 31
32 It does neither know how to display its image nor about escape sequences. 32 It does neither know how to display its image nor about escape sequences.
33 It is further independent of the underlying toolkit. By this, one can even 33 It is further independent of the underlying toolkit. By this, one can even
34 use this module for an ordinary text surface. 34 use this module for an ordinary text surface.
35 35
36 Since the operations are called by a specific emulation decoder, one may 36 Since the operations are called by a specific emulation decoder, one may
37 collect their different operations here. 37 collect their different operations here.
38 38
39 The state manipulated by the operations is mainly kept in `image', though 39 The state manipulated by the operations is mainly kept in `image', though
40 it is a little more complex bejond this. See the header file of the class. 40 it is a little more complex bejond this. See the header file of the class.
41 41
42 \sa TEWidget \sa VT102Emulation 42 \sa TEWidget \sa VT102Emulation
43*/ 43*/
44 44
45#include <stdio.h> 45#include <stdio.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <unistd.h> 47#include <unistd.h>
48// #include <kdebug.h> 48// #include <kdebug.h>
49 49
50#include <assert.h> 50#include <assert.h>
51#include <string.h> 51#include <string.h>
52#include <ctype.h> 52#include <ctype.h>
53 53
54#include <qpe/config.h> 54#include <qpe/config.h>
55#include "TEScreen.h" 55#include "TEScreen.h"
56 56
57#define HERE printf("%s(%d): here\n",__FILE__,__LINE__) 57#define HERE printf("%s(%d): here\n",__FILE__,__LINE__)
58 58
59//FIXME: this is emulation specific. Use FALSE for xterm, TRUE for ANSI. 59//FIXME: this is emulation specific. Use FALSE for xterm, TRUE for ANSI.
60//FIXME: see if we can get this from terminfo. 60//FIXME: see if we can get this from terminfo.
61#define BS_CLEARS FALSE 61#define BS_CLEARS FALSE
62 62
63#define loc(X,Y) ((Y) * columns + (X)) 63#define loc(X,Y) ((Y) * columns + (X))
64 64
65/*! creates a `TEScreen' of `lines' lines and `columns' columns. 65/*! creates a `TEScreen' of `lines' lines and `columns' columns.
66*/ 66*/
67 67
68TEScreen::TEScreen(int lines, int columns) 68TEScreen::TEScreen(int _lines, int _columns) :
69 lines(_lines),
70 columns(_columns),
71 tabstops(0),
72 histCursor(0),
73 horzCursor(0)
69{ 74{
70 this->lines = lines;
71 this->columns = columns;
72// odebug << "Columns " << columns << "" << oendl; 75// odebug << "Columns " << columns << "" << oendl;
73 76
74 image = (ca*) malloc(lines*columns*sizeof(ca)); 77 image = new ca[lines*columns];
75 tabstops = NULL; initTabStops(); 78 initTabStops();
76
77 histCursor = 0;
78 horzCursor = 0;
79 79
80 clearSelection(); 80 clearSelection();
81 reset(); 81 reset();
82} 82}
83 83
84/*! Destructor 84/*! Destructor
85*/ 85*/
86 86
87TEScreen::~TEScreen() 87TEScreen::~TEScreen()
88{ 88{
89 free(image); 89 delete [] image;
90 if (tabstops) free(tabstops); 90 delete [] tabstops;
91} 91}
92 92
93/* ------------------------------------------------------------------------- */ 93/* ------------------------------------------------------------------------- */
94/* */ 94/* */
95/* Normalized Screen Operations */ 95/* Normalized Screen Operations */
96/* */ 96/* */
97/* ------------------------------------------------------------------------- */ 97/* ------------------------------------------------------------------------- */
98 98
99// Cursor Setting -------------------------------------------------------------- 99// Cursor Setting --------------------------------------------------------------
100 100
101/*! \section Cursor 101/*! \section Cursor
102 102
103 The `cursor' is a location within the screen that is implicitely used in 103 The `cursor' is a location within the screen that is implicitely used in
104 many operations. The operations within this section allow to manipulate 104 many operations. The operations within this section allow to manipulate
105 the cursor explicitly and to obtain it's value. 105 the cursor explicitly and to obtain it's value.
106 106
107 The position of the cursor is guarantied to be between (including) 0 and 107 The position of the cursor is guarantied to be between (including) 0 and
108 `columns-1' and `lines-1'. 108 `columns-1' and `lines-1'.
109*/ 109*/
110 110
111/*! 111/*!
112 Move the cursor up. 112 Move the cursor up.
113 113
114 The cursor will not be moved beyond the top margin. 114 The cursor will not be moved beyond the top margin.
115*/ 115*/
116 116
117void TEScreen::cursorUp(int n) 117void TEScreen::cursorUp(int n)
118//=CUU 118//=CUU
119{ 119{
120 if (n == 0) n = 1; // Default 120 if (n == 0) n = 1; // Default
121 int stop = cuY < tmargin ? 0 : tmargin; 121 int stop = cuY < tmargin ? 0 : tmargin;
122 cuX = QMIN(columns-1,cuX); // nowrap! 122 cuX = QMIN(columns-1,cuX); // nowrap!
123 cuY = QMAX(stop,cuY-n); 123 cuY = QMAX(stop,cuY-n);
124} 124}
125 125
126/*! 126/*!
127 Move the cursor down. 127 Move the cursor down.
128 128
129 The cursor will not be moved beyond the bottom margin. 129 The cursor will not be moved beyond the bottom margin.
130*/ 130*/
131 131
132void TEScreen::cursorDown(int n) 132void TEScreen::cursorDown(int n)
133//=CUD 133//=CUD
134{ 134{
135 if (n == 0) n = 1; // Default 135 if (n == 0) n = 1; // Default
136 int stop = cuY > bmargin ? lines-1 : bmargin; 136 int stop = cuY > bmargin ? lines-1 : bmargin;
137 cuX = QMIN(columns-1,cuX); // nowrap! 137 cuX = QMIN(columns-1,cuX); // nowrap!
138 cuY = QMIN(stop,cuY+n); 138 cuY = QMIN(stop,cuY+n);
139} 139}
140 140
141/*! 141/*!
142 Move the cursor left. 142 Move the cursor left.
143 143
144 The cursor will not move beyond the first column. 144 The cursor will not move beyond the first column.
145*/ 145*/
146 146
147void TEScreen::cursorLeft(int n) 147void TEScreen::cursorLeft(int n)
148//=CUB 148//=CUB
149{ 149{
150 if (n == 0) n = 1; // Default 150 if (n == 0) n = 1; // Default
151 cuX = QMIN(columns-1,cuX); // nowrap! 151 cuX = QMIN(columns-1,cuX); // nowrap!
152 cuX = QMAX(0,cuX-n); 152 cuX = QMAX(0,cuX-n);
153} 153}
154 154
155/*! 155/*!
156 Move the cursor left. 156 Move the cursor left.
157 157
158 The cursor will not move beyond the rightmost column. 158 The cursor will not move beyond the rightmost column.
159*/ 159*/
160 160
161void TEScreen::cursorRight(int n) 161void TEScreen::cursorRight(int n)
162//=CUF 162//=CUF
163{ 163{
164 if (n == 0) n = 1; // Default 164 if (n == 0) n = 1; // Default
165 cuX = QMIN(columns-1,cuX+n); 165 cuX = QMIN(columns-1,cuX+n);
166} 166}
167 167
168/*! 168/*!
169 Set top and bottom margin. 169 Set top and bottom margin.
170*/ 170*/
171 171
172void TEScreen::setMargins(int top, int bot) 172void TEScreen::setMargins(int top, int bot)
173//=STBM 173//=STBM
174{ 174{
175 if (top == 0) top = 1; // Default 175 if (top == 0) top = 1; // Default
176 if (bot == 0) bot = lines; // Default 176 if (bot == 0) bot = lines; // Default
177 top = top - 1; // Adjust to internal lineno 177 top = top - 1; // Adjust to internal lineno
178 bot = bot - 1; // Adjust to internal lineno 178 bot = bot - 1; // Adjust to internal lineno
179 if ( !( 0 <= top && top < bot && bot < lines ) ) 179 if ( !( 0 <= top && top < bot && bot < lines ) )
180 { fprintf(stderr,"%s(%d) : setRegion(%d,%d) : bad range.\n", 180 { fprintf(stderr,"%s(%d) : setRegion(%d,%d) : bad range.\n",
181 __FILE__,__LINE__,top,bot); 181 __FILE__,__LINE__,top,bot);
182 return; // Default error action: ignore 182 return; // Default error action: ignore
183 } 183 }
184 tmargin = top; 184 tmargin = top;
185 bmargin = bot; 185 bmargin = bot;
186 cuX = 0; 186 cuX = 0;
187 cuY = getMode(MODE_Origin) ? top : 0; 187 cuY = getMode(MODE_Origin) ? top : 0;
188} 188}
189 189
190/*! 190/*!
191 Move the cursor down one line. 191 Move the cursor down one line.
192 192
193 If cursor is on bottom margin, the region between the 193 If cursor is on bottom margin, the region between the
194 actual top and bottom margin is scrolled up instead. 194 actual top and bottom margin is scrolled up instead.
195*/ 195*/
196 196
197void TEScreen::index() 197void TEScreen::index()
198//=IND 198//=IND
199{ 199{
200 if (cuY == bmargin) 200 if (cuY == bmargin)
201 { 201 {
202 if (tmargin == 0 && bmargin == lines-1) addHistLine(); // hist.history 202 if (tmargin == 0 && bmargin == lines-1) addHistLine(); // hist.history
203 scrollUp(tmargin,1); 203 scrollUp(tmargin,1);
204 } 204 }
205 else if (cuY < lines-1) 205 else if (cuY < lines-1)
206 cuY += 1; 206 cuY += 1;
207} 207}
208 208
209/*! 209/*!
210 Move the cursor up one line. 210 Move the cursor up one line.
211 211
212 If cursor is on the top margin, the region between the 212 If cursor is on the top margin, the region between the
213 actual top and bottom margin is scrolled down instead. 213 actual top and bottom margin is scrolled down instead.
214*/ 214*/
215 215
216void TEScreen::reverseIndex() 216void TEScreen::reverseIndex()
217//=RI 217//=RI
218{ 218{
@@ -271,485 +271,487 @@ void TEScreen::deleteChars(int n)
271*/ 271*/
272 272
273void TEScreen::insertChars(int n) 273void TEScreen::insertChars(int n)
274{ 274{
275 if (n == 0) n = 1; // Default 275 if (n == 0) n = 1; // Default
276 int p = QMAX(0,QMIN(columns-1-n,columns-1)); 276 int p = QMAX(0,QMIN(columns-1-n,columns-1));
277 int q = QMAX(0,QMIN(cuX+n,columns-1)); 277 int q = QMAX(0,QMIN(cuX+n,columns-1));
278 moveImage(loc(q,cuY),loc(cuX,cuY),loc(p,cuY)); 278 moveImage(loc(q,cuY),loc(cuX,cuY),loc(p,cuY));
279 clearImage(loc(cuX,cuY),loc(q-1,cuY),' '); 279 clearImage(loc(cuX,cuY),loc(q-1,cuY),' ');
280} 280}
281 281
282/*! delete `n' lines starting from (including) the cursor position. 282/*! delete `n' lines starting from (including) the cursor position.
283 283
284 The cursor is not moved by the operation. 284 The cursor is not moved by the operation.
285*/ 285*/
286 286
287void TEScreen::deleteLines(int n) 287void TEScreen::deleteLines(int n)
288{ 288{
289 if (n == 0) n = 1; // Default 289 if (n == 0) n = 1; // Default
290 scrollUp(cuY,n); 290 scrollUp(cuY,n);
291} 291}
292 292
293/*! insert `n' lines at the cursor position. 293/*! insert `n' lines at the cursor position.
294 294
295 The cursor is not moved by the operation. 295 The cursor is not moved by the operation.
296*/ 296*/
297 297
298void TEScreen::insertLines(int n) 298void TEScreen::insertLines(int n)
299{ 299{
300 if (n == 0) n = 1; // Default 300 if (n == 0) n = 1; // Default
301 scrollDown(cuY,n); 301 scrollDown(cuY,n);
302} 302}
303 303
304// Mode Operations ----------------------------------------------------------- 304// Mode Operations -----------------------------------------------------------
305 305
306/*! Set a specific mode. */ 306/*! Set a specific mode. */
307 307
308void TEScreen::setMode(int m) 308void TEScreen::setMode(int m)
309{ 309{
310 currParm.mode[m] = TRUE; 310 currParm.mode[m] = TRUE;
311 switch(m) 311 switch(m)
312 { 312 {
313 case MODE_Origin : cuX = 0; cuY = tmargin; break; //FIXME: home 313 case MODE_Origin : cuX = 0; cuY = tmargin; break; //FIXME: home
314 } 314 }
315} 315}
316 316
317/*! Reset a specific mode. */ 317/*! Reset a specific mode. */
318 318
319void TEScreen::resetMode(int m) 319void TEScreen::resetMode(int m)
320{ 320{
321 currParm.mode[m] = FALSE; 321 currParm.mode[m] = FALSE;
322 switch(m) 322 switch(m)
323 { 323 {
324 case MODE_Origin : cuX = 0; cuY = 0; break; //FIXME: home 324 case MODE_Origin : cuX = 0; cuY = 0; break; //FIXME: home
325 } 325 }
326} 326}
327 327
328/*! Save a specific mode. */ 328/*! Save a specific mode. */
329 329
330void TEScreen::saveMode(int m) 330void TEScreen::saveMode(int m)
331{ 331{
332 saveParm.mode[m] = currParm.mode[m]; 332 saveParm.mode[m] = currParm.mode[m];
333} 333}
334 334
335/*! Restore a specific mode. */ 335/*! Restore a specific mode. */
336 336
337void TEScreen::restoreMode(int m) 337void TEScreen::restoreMode(int m)
338{ 338{
339 currParm.mode[m] = saveParm.mode[m]; 339 currParm.mode[m] = saveParm.mode[m];
340} 340}
341 341
342//NOTE: this is a helper function 342//NOTE: this is a helper function
343/*! Return the setting a specific mode. */ 343/*! Return the setting a specific mode. */
344BOOL TEScreen::getMode(int m) 344BOOL TEScreen::getMode(int m)
345{ 345{
346 return currParm.mode[m]; 346 return currParm.mode[m];
347} 347}
348 348
349/*! Save the cursor position and the rendition attribute settings. */ 349/*! Save the cursor position and the rendition attribute settings. */
350 350
351void TEScreen::saveCursor() 351void TEScreen::saveCursor()
352{ 352{
353 sa_cuX = cuX; 353 sa_cuX = cuX;
354 sa_cuY = cuY; 354 sa_cuY = cuY;
355 sa_cu_re = cu_re; 355 sa_cu_re = cu_re;
356 sa_cu_fg = cu_fg; 356 sa_cu_fg = cu_fg;
357 sa_cu_bg = cu_bg; 357 sa_cu_bg = cu_bg;
358} 358}
359 359
360/*! Restore the cursor position and the rendition attribute settings. */ 360/*! Restore the cursor position and the rendition attribute settings. */
361 361
362void TEScreen::restoreCursor() 362void TEScreen::restoreCursor()
363{ 363{
364 cuX = QMIN(sa_cuX,columns-1); 364 cuX = QMIN(sa_cuX,columns-1);
365 cuY = QMIN(sa_cuY,lines-1); 365 cuY = QMIN(sa_cuY,lines-1);
366 cu_re = sa_cu_re; 366 cu_re = sa_cu_re;
367 cu_fg = sa_cu_fg; 367 cu_fg = sa_cu_fg;
368 cu_bg = sa_cu_bg; 368 cu_bg = sa_cu_bg;
369 effectiveRendition(); 369 effectiveRendition();
370} 370}
371 371
372/* ------------------------------------------------------------------------- */ 372/* ------------------------------------------------------------------------- */
373/* */ 373/* */
374/* Screen Operations */ 374/* Screen Operations */
375/* */ 375/* */
376/* ------------------------------------------------------------------------- */ 376/* ------------------------------------------------------------------------- */
377 377
378/*! Assing a new size to the screen. 378/*! Assing a new size to the screen.
379 379
380 The topmost left position is maintained, while lower lines 380 The topmost left position is maintained, while lower lines
381 or right hand side columns might be removed or filled with 381 or right hand side columns might be removed or filled with
382 spaces to fit the new size. 382 spaces to fit the new size.
383 383
384 The region setting is reset to the whole screen and the 384 The region setting is reset to the whole screen and the
385 tab positions reinitialized. 385 tab positions reinitialized.
386*/ 386*/
387 387
388void TEScreen::resizeImage(int new_lines, int new_columns) 388void TEScreen::resizeImage(int new_lines, int new_columns)
389{ 389{
390 if (cuY > new_lines-1) { 390 if (cuY > new_lines-1) {
391// attempt to preserve focus and lines 391// attempt to preserve focus and lines
392 bmargin = lines-1; //FIXME: margin lost 392 bmargin = lines-1; //FIXME: margin lost
393 for (int i = 0; i < cuY-(new_lines-1); i++) { 393 for (int i = 0; i < cuY-(new_lines-1); i++) {
394 addHistLine(); scrollUp(horzCursor,1); 394 addHistLine(); scrollUp(horzCursor,1);
395 } 395 }
396 } 396 }
397 397
398 // make new image 398 // make new image
399 ca* newimg = (ca*)malloc( new_lines * new_columns * sizeof( ca)); 399 ca* newimg = new ca[new_lines * new_columns];
400 400
401 clearSelection(); 401 clearSelection();
402 402
403 // clear new image 403 // clear new image
404 for (int y = 0; y < new_lines; y++) 404 for (int y = 0; y < new_lines; y++)
405 for (int x = 0; x < new_columns; x++) { 405 for (int x = 0; x < new_columns; x++) {
406 newimg[y*new_columns+x].c = ' '; 406 newimg[y*new_columns+x].c = ' ';
407 newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR; 407 newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR;
408 newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR; 408 newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR;
409 newimg[y*new_columns+x].r = DEFAULT_RENDITION; 409 newimg[y*new_columns+x].r = DEFAULT_RENDITION;
410 } 410 }
411 int cpy_lines = QMIN(new_lines, lines); 411 int cpy_lines = QMIN(new_lines, lines);
412 int cpy_columns = QMIN(new_columns,columns); 412 int cpy_columns = QMIN(new_columns,columns);
413 // copy to new image 413 // copy to new image
414 for (int y = 0; y < cpy_lines; y++) 414 for (int y = 0; y < cpy_lines; y++)
415 for (int x = 0; x < cpy_columns; x++) { 415 for (int x = 0; x < cpy_columns; x++) {
416 newimg[y*new_columns+x].c = image[loc(x,y)].c; 416 newimg[y*new_columns+x].c = image[loc(x,y)].c;
417 newimg[y*new_columns+x].f = image[loc(x,y)].f; 417 newimg[y*new_columns+x].f = image[loc(x,y)].f;
418 newimg[y*new_columns+x].b = image[loc(x,y)].b; 418 newimg[y*new_columns+x].b = image[loc(x,y)].b;
419 newimg[y*new_columns+x].r = image[loc(x,y)].r; 419 newimg[y*new_columns+x].r = image[loc(x,y)].r;
420 } 420 }
421 free(image); 421 delete [] image;
422 image = newimg; 422 image = newimg;
423 lines = new_lines; 423 lines = new_lines;
424 columns = new_columns; 424 columns = new_columns;
425 cuX = QMIN(cuX,columns-1); 425 cuX = QMIN(cuX,columns-1);
426 cuY = QMIN(cuY,lines-1); 426 cuY = QMIN(cuY,lines-1);
427 427
428 // FIXME: try to keep values, evtl. 428 // FIXME: try to keep values, evtl.
429 tmargin=0; 429 tmargin=0;
430 bmargin=lines-1; 430 bmargin=lines-1;
431 initTabStops(); 431 initTabStops();
432 clearSelection(); 432 clearSelection();
433} 433}
434 434
435/* 435/*
436 Clarifying rendition here and in TEWidget. 436 Clarifying rendition here and in TEWidget.
437 437
438 currently, TEWidget's color table is 438 currently, TEWidget's color table is
439 0 1 2 .. 9 10 .. 17 439 0 1 2 .. 9 10 .. 17
440 dft_fg, dft_bg, dim 0..7, intensive 0..7 440 dft_fg, dft_bg, dim 0..7, intensive 0..7
441 441
442 cu_fg, cu_bg contain values 0..8; 442 cu_fg, cu_bg contain values 0..8;
443 - 0 = default color 443 - 0 = default color
444 - 1..8 = ansi specified color 444 - 1..8 = ansi specified color
445 445
446 re_fg, re_bg contain values 0..17 446 re_fg, re_bg contain values 0..17
447 due to the TEWidget's color table 447 due to the TEWidget's color table
448 448
449 rendition attributes are 449 rendition attributes are
450 450
451 attr widget screen 451 attr widget screen
452 -------------- ------ ------ 452 -------------- ------ ------
453 RE_UNDERLINE XX XX affects foreground only 453 RE_UNDERLINE XX XX affects foreground only
454 RE_BLINK XX XX affects foreground only 454 RE_BLINK XX XX affects foreground only
455 RE_BOLD XX XX affects foreground only 455 RE_BOLD XX XX affects foreground only
456 RE_REVERSE -- XX 456 RE_REVERSE -- XX
457 RE_TRANSPARENT XX -- affects background only 457 RE_TRANSPARENT XX -- affects background only
458 RE_INTENSIVE XX -- affects foreground only 458 RE_INTENSIVE XX -- affects foreground only
459 459
460 Note that RE_BOLD is used in both widget 460 Note that RE_BOLD is used in both widget
461 and screen rendition. Since xterm/vt102 461 and screen rendition. Since xterm/vt102
462 is to poor to distinguish between bold 462 is to poor to distinguish between bold
463 (which is a font attribute) and intensive 463 (which is a font attribute) and intensive
464 (which is a color attribute), we translate 464 (which is a color attribute), we translate
465 this and RE_BOLD in falls eventually appart 465 this and RE_BOLD in falls eventually appart
466 into RE_BOLD and RE_INTENSIVE. 466 into RE_BOLD and RE_INTENSIVE.
467*/ 467*/
468 468
469void TEScreen::reverseRendition(ca* p) 469void TEScreen::reverseRendition(ca* p)
470{ UINT8 f = p->f; UINT8 b = p->b; 470{ UINT8 f = p->f; UINT8 b = p->b;
471 p->f = b; p->b = f; //p->r &= ~RE_TRANSPARENT; 471 p->f = b; p->b = f; //p->r &= ~RE_TRANSPARENT;
472} 472}
473 473
474void TEScreen::effectiveRendition() 474void TEScreen::effectiveRendition()
475// calculate rendition 475// calculate rendition
476{ 476{
477 ef_re = cu_re & (RE_UNDERLINE | RE_BLINK); 477 ef_re = cu_re & (RE_UNDERLINE | RE_BLINK);
478 if (cu_re & RE_REVERSE) 478 if (cu_re & RE_REVERSE)
479 { 479 {
480 ef_fg = cu_bg; 480 ef_fg = cu_bg;
481 ef_bg = cu_fg; 481 ef_bg = cu_fg;
482 } 482 }
483 else 483 else
484 { 484 {
485 ef_fg = cu_fg; 485 ef_fg = cu_fg;
486 ef_bg = cu_bg; 486 ef_bg = cu_bg;
487 } 487 }
488 if (cu_re & RE_BOLD) 488 if (cu_re & RE_BOLD)
489 { 489 {
490 if (ef_fg < BASE_COLORS) 490 if (ef_fg < BASE_COLORS)
491 ef_fg += BASE_COLORS; 491 ef_fg += BASE_COLORS;
492 else 492 else
493 ef_fg -= BASE_COLORS; 493 ef_fg -= BASE_COLORS;
494 } 494 }
495} 495}
496 496
497/*! 497/*!
498 returns the image. 498 returns the image.
499 499
500 Get the size of the image by \sa getLines and \sa getColumns. 500 Get the size of the image by \sa getLines and \sa getColumns.
501 501
502 NOTE that the image returned by this function must later be 502 NOTE that the image returned by this function must later be
503 freed. 503 freed.
504 504
505*/ 505*/
506 506
507ca* TEScreen::getCookedImage() 507ca* TEScreen::getCookedImage()
508{ 508{
509 int x,y; 509 int x,y;
510 ca* merged = (ca*)malloc(lines*columns*sizeof(ca)); 510 ca* merged = new ca[lines*columns];
511 ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); 511 ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION);
512 512
513 if (histCursor > hist.getLines()) { 513 if (histCursor > hist.getLines()) {
514 histCursor = hist.getLines(); 514 histCursor = hist.getLines();
515 } 515 }
516 516
517 for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++) 517 for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++)
518 { 518 {
519 int len = QMIN(columns,hist.getLineLen(y+histCursor)); 519 int len = QMIN(columns,hist.getLineLen(y+histCursor));
520 int yp = y*columns; 520 int yp = y*columns;
521 int yq = (y+histCursor)*columns; 521 int yq = (y+histCursor)*columns;
522 522
523 hist.getCells(y+histCursor,0,len,merged+yp); 523 hist.getCells(y+histCursor,0,len,merged+yp);
524 for (x = len; x < columns; x++) merged[yp+x] = dft; 524 for (x = len; x < columns; x++) merged[yp+x] = dft;
525 for (x = 0; x < columns; x++) 525 for (x = 0; x < columns; x++)
526 { int p=x + yp; int q=x + yq; 526 { int p=x + yp; int q=x + yq;
527 if ( ( q >= sel_TL ) && ( q <= sel_BR ) ) 527 if ( ( q >= sel_TL ) && ( q <= sel_BR ) )
528 reverseRendition(&merged[p]); // for selection 528 reverseRendition(&merged[p]); // for selection
529 } 529 }
530 } 530 }
531 if (lines >= hist.getLines()-histCursor) 531 if (lines >= hist.getLines()-histCursor)
532 { 532 {
533 for (y = (hist.getLines()-histCursor); y < lines ; y++) 533 for (y = (hist.getLines()-histCursor); y < lines ; y++)
534 { 534 {
535 int yp = y*columns; 535 int yp = y*columns;
536 int yq = (y+histCursor)*columns; 536 int yq = (y+histCursor)*columns;
537 int yr = (y-hist.getLines()+histCursor)*columns; 537 int yr = (y-hist.getLines()+histCursor)*columns;
538 for (x = 0; x < columns; x++) 538 for (x = 0; x < columns; x++)
539 { int p = x + yp; int q = x + yq; int r = x + yr; 539 { int p = x + yp; int q = x + yq; int r = x + yr;
540 merged[p] = image[r]; 540 merged[p] = image[r];
541 if ( q >= sel_TL && q <= sel_BR ) 541 if ( q >= sel_TL && q <= sel_BR )
542 reverseRendition(&merged[p]); // for selection 542 reverseRendition(&merged[p]); // for selection
543 } 543 }
544 544
545 } 545 }
546 } 546 }
547 // evtl. inverse display 547 // evtl. inverse display
548 if (getMode(MODE_Screen)) 548 if (getMode(MODE_Screen))
549 { int i,n = lines*columns; 549 { int i,n = lines*columns;
550 for (i = 0; i < n; i++) 550 for (i = 0; i < n; i++)
551 reverseRendition(&merged[i]); // for reverse display 551 reverseRendition(&merged[i]); // for reverse display
552 } 552 }
553 if (getMode(MODE_Cursor) && (cuY+(hist.getLines()-histCursor) < lines)) // cursor visible 553 if (getMode(MODE_Cursor) && (cuY+(hist.getLines()-histCursor) < lines)) // cursor visible
554 reverseRendition(&merged[loc(cuX,cuY+(hist.getLines()-histCursor))]); 554 reverseRendition(&merged[loc(cuX,cuY+(hist.getLines()-histCursor))]);
555 return merged; 555 return merged;
556 556
557} 557}
558 558
559 559
560/*! 560/*!
561*/ 561*/
562 562
563void TEScreen::reset() 563void TEScreen::reset()
564{ 564{
565 Config cfg( "Konsole" ); 565 Config cfg( "Konsole" );
566 cfg.setGroup("ScrollBar"); 566 cfg.setGroup("ScrollBar");
567 if( !cfg.readBoolEntry("HorzScroll",0) ) 567 if( !cfg.readBoolEntry("HorzScroll",0) )
568 setMode(MODE_Wrap ); saveMode(MODE_Wrap ); // wrap at end of margin 568 setMode(MODE_Wrap ); saveMode(MODE_Wrap ); // wrap at end of margin
569 569
570 570
571 resetMode(MODE_Origin); saveMode(MODE_Origin); // position refere to [1,1] 571 resetMode(MODE_Origin); saveMode(MODE_Origin); // position refere to [1,1]
572 resetMode(MODE_Insert); saveMode(MODE_Insert); // overstroke 572 resetMode(MODE_Insert); saveMode(MODE_Insert); // overstroke
573 setMode(MODE_Cursor); // cursor visible 573 setMode(MODE_Cursor); // cursor visible
574 resetMode(MODE_Screen); // screen not inverse 574 resetMode(MODE_Screen); // screen not inverse
575 resetMode(MODE_NewLine); 575 resetMode(MODE_NewLine);
576 576
577 tmargin=0; 577 tmargin=0;
578 bmargin=lines-1; 578 bmargin=lines-1;
579 579
580 setDefaultRendition(); 580 setDefaultRendition();
581 saveCursor(); 581 saveCursor();
582 582
583 clear(); 583 clear();
584} 584}
585 585
586/*! Clear the entire screen and home the cursor. 586/*! Clear the entire screen and home the cursor.
587*/ 587*/
588 588
589void TEScreen::clear() 589void TEScreen::clear()
590{ 590{
591 clearEntireScreen(); 591 clearEntireScreen();
592 home(); 592 home();
593} 593}
594 594
595/*! Moves the cursor left one column. 595/*! Moves the cursor left one column.
596*/ 596*/
597 597
598void TEScreen::BackSpace() 598void TEScreen::BackSpace()
599{ 599{
600 cuX = QMAX(0,cuX-1); 600 cuX = QMAX(0,cuX-1);
601 if (BS_CLEARS) image[loc(cuX,cuY)].c = ' '; 601 if (BS_CLEARS) image[loc(cuX,cuY)].c = ' ';
602} 602}
603 603
604/*! 604/*!
605*/ 605*/
606 606
607void TEScreen::Tabulate() 607void TEScreen::Tabulate()
608{ 608{
609 // note that TAB is a format effector (does not write ' '); 609 // note that TAB is a format effector (does not write ' ');
610 cursorRight(1); while(cuX < columns-1 && !tabstops[cuX]) cursorRight(1); 610 cursorRight(1); while(cuX < columns-1 && !tabstops[cuX]) cursorRight(1);
611} 611}
612 612
613void TEScreen::clearTabStops() 613void TEScreen::clearTabStops()
614{ 614{
615 for (int i = 0; i < columns; i++) tabstops[i-1] = FALSE; 615 for (int i = 0; i < columns; i++) tabstops[i-1] = FALSE;
616} 616}
617 617
618void TEScreen::changeTabStop(bool set) 618void TEScreen::changeTabStop(bool set)
619{ 619{
620 if (cuX >= columns) return; 620 if (cuX >= columns) return;
621 tabstops[cuX] = set; 621 tabstops[cuX] = set;
622} 622}
623 623
624void TEScreen::initTabStops() 624void TEScreen::initTabStops()
625{ 625{
626 if (tabstops) free(tabstops); 626 if (tabstops)
627 tabstops = (bool*)malloc(columns*sizeof(bool)); 627 delete [] tabstops;
628
629 tabstops = new bool[columns];
628 // Arrg! The 1st tabstop has to be one longer than the other. 630 // Arrg! The 1st tabstop has to be one longer than the other.
629 // i.e. the kids start counting from 0 instead of 1. 631 // i.e. the kids start counting from 0 instead of 1.
630 // Other programs might behave correctly. Be aware. 632 // Other programs might behave correctly. Be aware.
631 for (int i = 0; i < columns; i++) tabstops[i] = (i%8 == 0 && i != 0); 633 for (int i = 0; i < columns; i++) tabstops[i] = (i%8 == 0 && i != 0);
632} 634}
633 635
634/*! 636/*!
635 This behaves either as IND (Screen::Index) or as NEL (Screen::NextLine) 637 This behaves either as IND (Screen::Index) or as NEL (Screen::NextLine)
636 depending on the NewLine Mode (LNM). This mode also 638 depending on the NewLine Mode (LNM). This mode also
637 affects the key sequence returned for newline ([CR]LF). 639 affects the key sequence returned for newline ([CR]LF).
638*/ 640*/
639 641
640void TEScreen::NewLine() 642void TEScreen::NewLine()
641{ 643{
642 if (getMode(MODE_NewLine)) Return(); 644 if (getMode(MODE_NewLine)) Return();
643 index(); 645 index();
644} 646}
645 647
646/*! put `c' literally onto the screen at the current cursor position. 648/*! put `c' literally onto the screen at the current cursor position.
647 649
648 VT100 uses the convention to produce an automatic newline (am) 650 VT100 uses the convention to produce an automatic newline (am)
649 with the *first* character that would fall onto the next line (xenl). 651 with the *first* character that would fall onto the next line (xenl).
650*/ 652*/
651 653
652void TEScreen::checkSelection(int from, int to) 654void TEScreen::checkSelection(int from, int to)
653{ 655{
654 if (sel_begin == -1) return; 656 if (sel_begin == -1) return;
655 int scr_TL = loc(0, hist.getLines()); 657 int scr_TL = loc(0, hist.getLines());
656 //Clear entire selection if it overlaps region [from, to] 658 //Clear entire selection if it overlaps region [from, to]
657 if ( (sel_BR > (from+scr_TL) )&&(sel_TL < (to+scr_TL)) ) 659 if ( (sel_BR > (from+scr_TL) )&&(sel_TL < (to+scr_TL)) )
658 { 660 {
659 clearSelection(); 661 clearSelection();
660 } 662 }
661} 663}
662 664
663void TEScreen::ShowCharacter(unsigned short c) 665void TEScreen::ShowCharacter(unsigned short c)
664{ 666{
665 // Note that VT100 does wrapping BEFORE putting the character. 667 // Note that VT100 does wrapping BEFORE putting the character.
666 // This has impact on the assumption of valid cursor positions. 668 // This has impact on the assumption of valid cursor positions.
667 // We indicate the fact that a newline has to be triggered by 669 // We indicate the fact that a newline has to be triggered by
668 // putting the cursor one right to the last column of the screen. 670 // putting the cursor one right to the last column of the screen.
669 671
670 if (cuX >= columns) 672 if (cuX >= columns)
671 { 673 {
672 if (getMode(MODE_Wrap)) NextLine(); else cuX = columns - 1; 674 if (getMode(MODE_Wrap)) NextLine(); else cuX = columns - 1;
673 // comment out for no wrap 675 // comment out for no wrap
674 } 676 }
675 677
676 if (getMode(MODE_Insert)) insertChars(1); 678 if (getMode(MODE_Insert)) insertChars(1);
677 679
678 int i = loc( cuX, cuY); 680 int i = loc( cuX, cuY);
679 681
680 checkSelection(i, i); // check if selection is still valid. 682 checkSelection(i, i); // check if selection is still valid.
681 683
682 image[i].c = c; 684 image[i].c = c;
683 image[i].f = ef_fg; 685 image[i].f = ef_fg;
684 image[i].b = ef_bg; 686 image[i].b = ef_bg;
685 image[i].r = ef_re; 687 image[i].r = ef_re;
686 688
687 cuX += 1; 689 cuX += 1;
688} 690}
689 691
690// Region commands ------------------------------------------------------------- 692// Region commands -------------------------------------------------------------
691 693
692 694
693/*! scroll up `n' lines within current region. 695/*! scroll up `n' lines within current region.
694 The `n' new lines are cleared. 696 The `n' new lines are cleared.
695 \sa setRegion \sa scrollDown 697 \sa setRegion \sa scrollDown
696*/ 698*/
697 699
698void TEScreen::scrollUp(int from, int n) 700void TEScreen::scrollUp(int from, int n)
699{ 701{
700 if (n <= 0 || from + n > bmargin) return; 702 if (n <= 0 || from + n > bmargin) return;
701 //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. 703 //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds.
702 704
703 moveImage( loc( 0, from), loc( 0, from + n), loc( columns - 1, bmargin)); 705 moveImage( loc( 0, from), loc( 0, from + n), loc( columns - 1, bmargin));
704 clearImage( loc( 0, bmargin - n + 1), loc( columns - 1, bmargin), ' '); 706 clearImage( loc( 0, bmargin - n + 1), loc( columns - 1, bmargin), ' ');
705} 707}
706 708
707/*! scroll down `n' lines within current region. 709/*! scroll down `n' lines within current region.
708 The `n' new lines are cleared. 710 The `n' new lines are cleared.
709 \sa setRegion \sa scrollUp 711 \sa setRegion \sa scrollUp
710*/ 712*/
711 713
712void TEScreen::scrollDown(int from, int n) 714void TEScreen::scrollDown(int from, int n)
713{ 715{
714 716
715//FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. 717//FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds.
716 if (n <= 0) return; 718 if (n <= 0) return;
717 if (from > bmargin) return; 719 if (from > bmargin) return;
718 if (from + n > bmargin) n = bmargin - from; 720 if (from + n > bmargin) n = bmargin - from;
719 721
720 moveImage( loc(0,from+n), loc(0,from), loc(columns-1,bmargin-n)); 722 moveImage( loc(0,from+n), loc(0,from), loc(columns-1,bmargin-n));
721 clearImage(loc(0,from),loc(columns-1,from+n-1),' '); 723 clearImage(loc(0,from),loc(columns-1,from+n-1),' ');
722} 724}
723 725
724 726
725 727
726/*! position the cursor to a specific line and column. */ 728/*! position the cursor to a specific line and column. */
727void TEScreen::setCursorYX(int y, int x) 729void TEScreen::setCursorYX(int y, int x)
728{ 730{
729 setCursorY(y); setCursorX(x); 731 setCursorY(y); setCursorX(x);
730} 732}
731 733
732/*! Set the cursor to x-th line. */ 734/*! Set the cursor to x-th line. */
733 735
734void TEScreen::setCursorX(int x) 736void TEScreen::setCursorX(int x)
735{ 737{
736 if (x == 0) x = 1; // Default 738 if (x == 0) x = 1; // Default
737 x -= 1; // Adjust 739 x -= 1; // Adjust
738 cuX = QMAX(0,QMIN(columns-1, x)); 740 cuX = QMAX(0,QMIN(columns-1, x));
739} 741}
740 742
741/*! Set the cursor to y-th line. */ 743/*! Set the cursor to y-th line. */
742 744
743void TEScreen::setCursorY(int y) 745void TEScreen::setCursorY(int y)
744{ 746{
745 if (y == 0) y = 1; // Default 747 if (y == 0) y = 1; // Default
746 y -= 1; // Adjust 748 y -= 1; // Adjust
747 cuY = QMAX(0,QMIN(lines -1, y + (getMode(MODE_Origin) ? tmargin : 0) )); 749 cuY = QMAX(0,QMIN(lines -1, y + (getMode(MODE_Origin) ? tmargin : 0) ));
748} 750}
749 751
750/*! set cursor to the `left upper' corner of the screen (1,1). 752/*! set cursor to the `left upper' corner of the screen (1,1).
751*/ 753*/
752 754
753void TEScreen::home() 755void TEScreen::home()
754{ 756{
755 cuX = 0; 757 cuX = 0;
diff --git a/inputmethods/dasher/PPMLanguageModel.cpp b/inputmethods/dasher/PPMLanguageModel.cpp
index 137b07f..d767d16 100644
--- a/inputmethods/dasher/PPMLanguageModel.cpp
+++ b/inputmethods/dasher/PPMLanguageModel.cpp
@@ -1,198 +1,199 @@
1// PPMLanguageModel.h 1// PPMLanguageModel.h
2// 2//
3///////////////////////////////////////////////////////////////////////////// 3/////////////////////////////////////////////////////////////////////////////
4// 4//
5// Copyright (c) 1999-2002 David Ward 5// Copyright (c) 1999-2002 David Ward
6// 6//
7///////////////////////////////////////////////////////////////////////////// 7/////////////////////////////////////////////////////////////////////////////
8 8
9#include <math.h> 9#include <math.h>
10#include "PPMLanguageModel.h" 10#include "PPMLanguageModel.h"
11 11
12using namespace Dasher; 12using namespace Dasher;
13using namespace std; 13using namespace std;
14 14
15// static TCHAR debug[256]; 15// static TCHAR debug[256];
16typedef unsigned long ulong; 16typedef unsigned long ulong;
17 17
18//////////////////////////////////////////////////////////////////////// 18////////////////////////////////////////////////////////////////////////
19/// PPMnode definitions 19/// PPMnode definitions
20//////////////////////////////////////////////////////////////////////// 20////////////////////////////////////////////////////////////////////////
21 21
22CPPMLanguageModel::CPPMnode *CPPMLanguageModel::CPPMnode::find_symbol(int sym) 22CPPMLanguageModel::CPPMnode *CPPMLanguageModel::CPPMnode::find_symbol(int sym)
23// see if symbol is a child of node 23// see if symbol is a child of node
24{ 24{
25 // printf("finding symbol %d at node %d\n",sym,node->id); 25 // printf("finding symbol %d at node %d\n",sym,node->id);
26 CPPMnode *found=child; 26 CPPMnode *found=child;
27 while (found) { 27 while (found) {
28 if (found->symbol==sym) 28 if (found->symbol==sym)
29 return found; 29 return found;
30 found=found->next; 30 found=found->next;
31 } 31 }
32 return 0; 32 return 0;
33} 33}
34 34
35 35
36CPPMLanguageModel::CPPMnode * CPPMLanguageModel::CPPMnode::add_symbol_to_node(int sym,int *update) 36CPPMLanguageModel::CPPMnode * CPPMLanguageModel::CPPMnode::add_symbol_to_node(int sym,int *update)
37{ 37{
38 CPPMnode *born,*search; 38 CPPMnode *born,*search;
39 search=find_symbol(sym); 39 search=find_symbol(sym);
40 if (!search) { 40 if (!search) {
41 born = new CPPMnode(sym); 41 born = new CPPMnode(sym);
42 born->next=child; 42 born->next=child;
43 child=born; 43 child=born;
44 // node->count=1; 44 // node->count=1;
45 return born; 45 return born;
46 } else { 46 } else {
47 if (*update) { // perform update exclusions 47 if (*update) { // perform update exclusions
48 search->count++; 48 search->count++;
49 *update=0; 49 *update=0;
50 } 50 }
51 return search; 51 return search;
52 } 52 }
53 53
54} 54}
55 55
56 56
57///////////////////////////////////////////////////////////////////// 57/////////////////////////////////////////////////////////////////////
58// CPPMLanguageModel defs 58// CPPMLanguageModel defs
59///////////////////////////////////////////////////////////////////// 59/////////////////////////////////////////////////////////////////////
60 60
61CPPMLanguageModel::CPPMLanguageModel(CAlphabet *_alphabet,int _normalization) 61CPPMLanguageModel::CPPMLanguageModel(CAlphabet *_alphabet,int _normalization)
62 : CLanguageModel(_alphabet,_normalization) 62 : CLanguageModel(_alphabet,_normalization), root(0), m_rootcontext(0)
63{ 63{
64 root=new CPPMnode(-1); 64 root=new CPPMnode(-1);
65 m_rootcontext=new CPPMContext(root,0); 65 m_rootcontext=new CPPMContext(root,0);
66} 66}
67 67
68 68
69CPPMLanguageModel::~CPPMLanguageModel() 69CPPMLanguageModel::~CPPMLanguageModel()
70{ 70{
71 delete m_rootcontext;
71 delete root; 72 delete root;
72} 73}
73 74
74 75
75bool CPPMLanguageModel::GetProbs(CContext *context,vector<unsigned int> &probs,double ) 76bool CPPMLanguageModel::GetProbs(CContext *context,vector<unsigned int> &probs,double )
76 // get the probability distribution at the context 77 // get the probability distribution at the context
77{ 78{
78 // seems like we have to have this hack for VC++ 79 // seems like we have to have this hack for VC++
79 CPPMContext *ppmcontext=static_cast<CPPMContext *> (context); 80 CPPMContext *ppmcontext=static_cast<CPPMContext *> (context);
80 81
81 82
82 int modelchars=GetNumberModelChars(); 83 int modelchars=GetNumberModelChars();
83 int norm=CLanguageModel::normalization(); 84 int norm=CLanguageModel::normalization();
84 probs.resize(modelchars); 85 probs.resize(modelchars);
85 CPPMnode *temp,*s; 86 CPPMnode *temp,*s;
86 int loop,total; 87 int loop,total;
87 int sym; 88 int sym;
88 // ulong spent=0; 89 // ulong spent=0;
89 ulong size_of_slice; 90 ulong size_of_slice;
90 bool *exclusions=new bool [modelchars]; 91 bool *exclusions=new bool [modelchars];
91 ulong uniform=modelchars; 92 ulong uniform=modelchars;
92 ulong tospend=norm-uniform; 93 ulong tospend=norm-uniform;
93 temp=ppmcontext->head; 94 temp=ppmcontext->head;
94 for (loop=0; loop <modelchars; loop++) { /* set up the exclusions array */ 95 for (loop=0; loop <modelchars; loop++) { /* set up the exclusions array */
95 probs[loop]=0; 96 probs[loop]=0;
96 exclusions[loop]=0; 97 exclusions[loop]=0;
97 } 98 }
98 while (temp!=0) { 99 while (temp!=0) {
99 //Usprintf(debug,TEXT("tospend %u\n"),tospend); 100 //Usprintf(debug,TEXT("tospend %u\n"),tospend);
100 //DebugOutput(TEXT("round\n")); 101 //DebugOutput(TEXT("round\n"));
101 total=0; 102 total=0;
102 s=temp->child; 103 s=temp->child;
103 while (s) { 104 while (s) {
104 sym=s->symbol; 105 sym=s->symbol;
105 if (!exclusions[s->symbol]) 106 if (!exclusions[s->symbol])
106 total=total+s->count; 107 total=total+s->count;
107 s=s->next; 108 s=s->next;
108 } 109 }
109 if (total) { 110 if (total) {
110 //Usprintf(debug,TEXT"escape %u\n"),tospend* 111 //Usprintf(debug,TEXT"escape %u\n"),tospend*
111 size_of_slice=tospend; 112 size_of_slice=tospend;
112 s=temp->child; 113 s=temp->child;
113 while (s) { 114 while (s) {
114 if (!exclusions[s->symbol]) { 115 if (!exclusions[s->symbol]) {
115 exclusions[s->symbol]=1; 116 exclusions[s->symbol]=1;
116 ulong p=size_of_slice*(2*s->count-1)/2/ulong(total); 117 ulong p=size_of_slice*(2*s->count-1)/2/ulong(total);
117 probs[s->symbol]+=p; 118 probs[s->symbol]+=p;
118 tospend-=p; 119 tospend-=p;
119 } 120 }
120 // Usprintf(debug,TEXT("sym %u counts %d p %u tospend %u \n"),sym,s->count,p,tospend); 121 // Usprintf(debug,TEXT("sym %u counts %d p %u tospend %u \n"),sym,s->count,p,tospend);
121 // DebugOutput(debug); 122 // DebugOutput(debug);
122 s=s->next; 123 s=s->next;
123 } 124 }
124 } 125 }
125 temp = temp->vine; 126 temp = temp->vine;
126 } 127 }
127 //Usprintf(debug,TEXT("Norm %u tospend %u\n"),Norm,tospend); 128 //Usprintf(debug,TEXT("Norm %u tospend %u\n"),Norm,tospend);
128 //DebugOutput(debug); 129 //DebugOutput(debug);
129 130
130 size_of_slice=tospend; 131 size_of_slice=tospend;
131 int symbolsleft=0; 132 int symbolsleft=0;
132 for (sym=1;sym<modelchars;sym++) 133 for (sym=1;sym<modelchars;sym++)
133 if (!probs[sym]) 134 if (!probs[sym])
134 symbolsleft++; 135 symbolsleft++;
135 for (sym=1;sym<modelchars;sym++) 136 for (sym=1;sym<modelchars;sym++)
136 if (!probs[sym]) { 137 if (!probs[sym]) {
137 ulong p=size_of_slice/symbolsleft; 138 ulong p=size_of_slice/symbolsleft;
138 probs[sym]+=p; 139 probs[sym]+=p;
139 tospend-=p; 140 tospend-=p;
140 } 141 }
141 142
142 // distribute what's left evenly 143 // distribute what's left evenly
143 tospend+=uniform; 144 tospend+=uniform;
144 for (sym=1;sym<modelchars;sym++) { 145 for (sym=1;sym<modelchars;sym++) {
145 ulong p=tospend/(modelchars-sym); 146 ulong p=tospend/(modelchars-sym);
146 probs[sym]+=p; 147 probs[sym]+=p;
147 tospend-=p; 148 tospend-=p;
148 } 149 }
149 //Usprintf(debug,TEXT("finaltospend %u\n"),tospend); 150 //Usprintf(debug,TEXT("finaltospend %u\n"),tospend);
150 //DebugOutput(debug); 151 //DebugOutput(debug);
151 152
152 // free(exclusions); // !!! 153 // free(exclusions); // !!!
153 // !!! NB by IAM: p577 Stroustrup 3rd Edition: "Allocating an object using new and deleting it using free() is asking for trouble" 154 // !!! NB by IAM: p577 Stroustrup 3rd Edition: "Allocating an object using new and deleting it using free() is asking for trouble"
154 delete[] exclusions; 155 delete[] exclusions;
155 return true; 156 return true;
156} 157}
157 158
158 159
159void CPPMLanguageModel::AddSymbol(CPPMLanguageModel::CPPMContext &context,int symbol) 160void CPPMLanguageModel::AddSymbol(CPPMLanguageModel::CPPMContext &context,int symbol)
160 // add symbol to the context 161 // add symbol to the context
161 // creates new nodes, updates counts 162 // creates new nodes, updates counts
162 // and leaves 'context' at the new context 163 // and leaves 'context' at the new context
163{ 164{
164 // sanity check 165 // sanity check
165 if (symbol==0 || symbol>=GetNumberModelChars()) 166 if (symbol==0 || symbol>=GetNumberModelChars())
166 return; 167 return;
167 168
168 CPPMnode *vineptr,*temp; 169 CPPMnode *vineptr,*temp;
169 int updatecnt=1; 170 int updatecnt=1;
170 171
171 temp=context.head->vine; 172 temp=context.head->vine;
172 context.head=context.head->add_symbol_to_node(symbol,&updatecnt); 173 context.head=context.head->add_symbol_to_node(symbol,&updatecnt);
173 vineptr=context.head; 174 vineptr=context.head;
174 context.order++; 175 context.order++;
175 176
176 while (temp!=0) { 177 while (temp!=0) {
177 vineptr->vine=temp->add_symbol_to_node(symbol,&updatecnt); 178 vineptr->vine=temp->add_symbol_to_node(symbol,&updatecnt);
178 vineptr=vineptr->vine; 179 vineptr=vineptr->vine;
179 temp=temp->vine; 180 temp=temp->vine;
180 } 181 }
181 vineptr->vine=root; 182 vineptr->vine=root;
182 if (context.order>MAX_ORDER){ 183 if (context.order>MAX_ORDER){
183 context.head=context.head->vine; 184 context.head=context.head->vine;
184 context.order--; 185 context.order--;
185 } 186 }
186} 187}
187 188
188 189
189// update context with symbol 'Symbol' 190// update context with symbol 'Symbol'
190void CPPMLanguageModel::EnterSymbol(CContext* Context, modelchar Symbol) 191void CPPMLanguageModel::EnterSymbol(CContext* Context, modelchar Symbol)
191{ 192{
192 CPPMLanguageModel::CPPMContext& context = * static_cast<CPPMContext *> (Context); 193 CPPMLanguageModel::CPPMContext& context = * static_cast<CPPMContext *> (Context);
193 194
194 CPPMnode *find; 195 CPPMnode *find;
195 // CPPMnode *temp=context.head; 196 // CPPMnode *temp=context.head;
196 197
197 while (context.head) { 198 while (context.head) {
198 find =context.head->find_symbol(Symbol); 199 find =context.head->find_symbol(Symbol);
diff --git a/noncore/apps/opie-reader/Bkmks.cpp b/noncore/apps/opie-reader/Bkmks.cpp
index 440d8be..28f6318 100644
--- a/noncore/apps/opie-reader/Bkmks.cpp
+++ b/noncore/apps/opie-reader/Bkmks.cpp
@@ -1,150 +1,166 @@
1#include <qmessagebox.h> 1#include <qmessagebox.h>
2 2
3#include "Bkmks.h" 3#include "Bkmks.h"
4 4
5#include "StyleConsts.h" 5#include "StyleConsts.h"
6#include "Markups.h" 6#include "Markups.h"
7#include "my_list.h" 7#include "my_list.h"
8#include "version.h" 8#include "version.h"
9#include "names.h" 9#include "names.h"
10 10
11const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE); 11const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE);
12 12
13Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p) 13Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p) :
14 m_name(0),
15 m_namelen(0),
16 m_anno(0),
17 m_annolen(0),
18 m_position(0)
14{ 19{
15 init(_nm, _nmlen, _anno, _annolen, _p); 20 init(_nm, _nmlen, _anno, _annolen, _p);
16} 21}
17 22
18Bkmk::Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short annolen, unsigned int _p) : m_position(_p) 23Bkmk::Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short annolen, unsigned int _p) : m_position(_p)
19{ 24{
20 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, annolen, _p); 25 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, annolen, _p);
21} 26}
22 27
28Bkmk::Bkmk(const Bkmk& rhs) :
29 m_name(0),
30 m_namelen(0),
31 m_anno(0),
32 m_annolen(0),
33 m_position(0)
34{
35 init(rhs.name(), sizeof(tchar)*(ustrlen(rhs.name())+1), rhs.anno(),
36 sizeof(tchar)*(ustrlen(rhs.anno())+1), rhs.value());
37}
38
23Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p) 39Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p)
24{ 40{
25 if (_anno == NULL) 41 if (_anno == NULL)
26 { 42 {
27 tchar t = 0; 43 tchar t = 0;
28 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p); 44 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p);
29 } 45 }
30 else 46 else
31 { 47 {
32 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p); 48 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p);
33 } 49 }
34} 50}
35 51
36Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2) : m_position(_p) 52Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2) : m_position(_p)
37{ 53{
38 if (_anno == NULL) 54 if (_anno == NULL)
39 { 55 {
40 tchar t = 0; 56 tchar t = 0;
41 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p); 57 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p);
42 } 58 }
43 else 59 else
44 { 60 {
45 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p); 61 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p);
46 } 62 }
47 m_position2 = _p2; 63 m_position2 = _p2;
48 m_red = m_green = m_blue = 127; 64 m_red = m_green = m_blue = 127;
49} 65}
50 66
51void Bkmk::init(const void* _nm, unsigned short _nmlen, const void* _anno, unsigned short _annolen, unsigned int _p) 67void Bkmk::init(const void* _nm, unsigned short _nmlen, const void* _anno, unsigned short _annolen, unsigned int _p)
52{ 68{
53 m_namelen = _nmlen; 69 m_namelen = _nmlen;
54 if (m_namelen > 0) 70 if (m_namelen > 0)
55 { 71 {
56 m_name = new unsigned char[m_namelen]; 72 m_name = new unsigned char[m_namelen];
57 memcpy(m_name, _nm, m_namelen); 73 memcpy(m_name, _nm, m_namelen);
58 } 74 }
59 else 75 else
60 { 76 {
61 m_name = NULL; 77 m_name = NULL;
62 } 78 }
63 79
64 m_annolen = _annolen; 80 m_annolen = _annolen;
65 if (m_annolen > 0) 81 if (m_annolen > 0)
66 { 82 {
67 m_anno = new unsigned char[m_annolen]; 83 m_anno = new unsigned char[m_annolen];
68 memcpy(m_anno, _anno, m_annolen); 84 memcpy(m_anno, _anno, m_annolen);
69 } 85 }
70 else 86 else
71 { 87 {
72 m_anno = NULL; 88 m_anno = NULL;
73 } 89 }
74 m_position = _p; 90 m_position = _p;
75 m_position2 = _p; 91 m_position2 = _p;
76 m_red = m_green = m_blue = 255; 92 m_red = m_green = m_blue = 255;
77 m_level = 0; 93 m_level = 0;
78} 94}
79 95
80Bkmk::~Bkmk() 96Bkmk::~Bkmk()
81{ 97{
82 if (m_name != NULL) delete [] m_name; 98 if (m_name != NULL) delete [] m_name;
83 m_name = NULL; 99 m_name = NULL;
84 if (m_anno != NULL) delete [] m_anno; 100 if (m_anno != NULL) delete [] m_anno;
85 m_anno = NULL; 101 m_anno = NULL;
86} 102}
87 103
88Bkmk& Bkmk::operator=(const Bkmk& rhs) 104Bkmk& Bkmk::operator=(const Bkmk& rhs)
89{ 105{
90 if (m_name != NULL) 106 if (m_name != NULL)
91 { 107 {
92 delete [] m_name; 108 delete [] m_name;
93 m_name = NULL; 109 m_name = NULL;
94 } 110 }
95 if (m_anno != NULL) 111 if (m_anno != NULL)
96 { 112 {
97 delete [] m_anno; 113 delete [] m_anno;
98 m_anno = NULL; 114 m_anno = NULL;
99 } 115 }
100 if (rhs.m_name != NULL) 116 if (rhs.m_name != NULL)
101 { 117 {
102 m_namelen = rhs.m_namelen; 118 m_namelen = rhs.m_namelen;
103 m_name = new unsigned char[m_namelen]; 119 m_name = new unsigned char[m_namelen];
104 memcpy(m_name, rhs.m_name, m_namelen); 120 memcpy(m_name, rhs.m_name, m_namelen);
105 } 121 }
106 else 122 else
107 m_name = NULL; 123 m_name = NULL;
108 if (rhs.m_anno != NULL) 124 if (rhs.m_anno != NULL)
109 { 125 {
110 m_annolen = rhs.m_annolen; 126 m_annolen = rhs.m_annolen;
111 m_anno = new unsigned char[m_annolen]; 127 m_anno = new unsigned char[m_annolen];
112 memcpy(m_anno, rhs.m_anno, m_annolen); 128 memcpy(m_anno, rhs.m_anno, m_annolen);
113 } 129 }
114 else 130 else
115 m_anno = NULL; 131 m_anno = NULL;
116 m_position = rhs.m_position; 132 m_position = rhs.m_position;
117 m_position2 = rhs.m_position2; 133 m_position2 = rhs.m_position2;
118 m_red = rhs.m_red; 134 m_red = rhs.m_red;
119 m_green = rhs.m_green; 135 m_green = rhs.m_green;
120 m_blue = rhs.m_blue; 136 m_blue = rhs.m_blue;
121 m_level = rhs.m_level; 137 m_level = rhs.m_level;
122 return *this; 138 return *this;
123} 139}
124 140
125bool Bkmk::operator==(const Bkmk& rhs) 141bool Bkmk::operator==(const Bkmk& rhs)
126{ 142{
127 return ((m_position == rhs.m_position) && (m_position2 == rhs.m_position2) && (rhs.m_namelen == m_namelen) && memcmp(m_name,rhs.m_name,m_namelen) == 0); 143 return ((m_position == rhs.m_position) && (m_position2 == rhs.m_position2) && (rhs.m_namelen == m_namelen) && memcmp(m_name,rhs.m_name,m_namelen) == 0);
128} 144}
129 145
130void Bkmk::setAnno(unsigned char* t, unsigned short len) 146void Bkmk::setAnno(unsigned char* t, unsigned short len)
131{ 147{
132 if (m_anno != NULL) 148 if (m_anno != NULL)
133 { 149 {
134 delete [] m_anno; 150 delete [] m_anno;
135 m_anno = NULL; 151 m_anno = NULL;
136 } 152 }
137 if (t != NULL) 153 if (t != NULL)
138 { 154 {
139 m_annolen = len; 155 m_annolen = len;
140 m_anno = new unsigned char[m_annolen]; 156 m_anno = new unsigned char[m_annolen];
141 memcpy(m_anno, t, m_annolen); 157 memcpy(m_anno, t, m_annolen);
142 } 158 }
143 else 159 else
144 { 160 {
145 m_annolen = sizeof(tchar); 161 m_annolen = sizeof(tchar);
146 m_anno = new unsigned char[m_annolen]; 162 m_anno = new unsigned char[m_annolen];
147 *((tchar*)m_anno) = 0; 163 *((tchar*)m_anno) = 0;
148 } 164 }
149} 165}
150 166
diff --git a/noncore/apps/opie-reader/Bkmks.h b/noncore/apps/opie-reader/Bkmks.h
index c2275e2..985e158 100644
--- a/noncore/apps/opie-reader/Bkmks.h
+++ b/noncore/apps/opie-reader/Bkmks.h
@@ -1,84 +1,81 @@
1#ifndef __Bkmks_h 1#ifndef __Bkmks_h
2#define __Bkmks_h 2#define __Bkmks_h
3 3
4#include "config.h" 4#include "config.h"
5#include "Filedata.h" 5#include "Filedata.h"
6#include <stdio.h> 6#include <stdio.h>
7 7
8template<class T> 8template<class T>
9class CList; 9class CList;
10 10
11class Bkmk 11class Bkmk
12{ 12{
13 friend class BkmkFile; 13 friend class BkmkFile;
14 unsigned char* m_name; 14 unsigned char* m_name;
15 unsigned short m_namelen; 15 unsigned short m_namelen;
16 unsigned char* m_anno; 16 unsigned char* m_anno;
17 unsigned short m_annolen; 17 unsigned short m_annolen;
18 unsigned int m_position; 18 unsigned int m_position;
19 unsigned int m_position2; 19 unsigned int m_position2;
20 unsigned char m_red,m_green,m_blue, m_level; 20 unsigned char m_red,m_green,m_blue, m_level;
21 void init(const void*, unsigned short, const void*, unsigned short, unsigned int); 21 void init(const void*, unsigned short, const void*, unsigned short, unsigned int);
22 public: 22 public:
23 Bkmk() : m_name(NULL), m_namelen(0), m_anno(NULL), m_annolen(0), m_position(0) {}; 23 Bkmk() : m_name(0), m_namelen(0), m_anno(0), m_annolen(0), m_position(0) {};
24 Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); 24 Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p);
25 Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); 25 Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short _annolen, unsigned int _p);
26 Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p); 26 Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p);
27 Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2); 27 Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2);
28 Bkmk(const Bkmk& rhs) : m_name(NULL), m_anno(NULL) 28 Bkmk(const Bkmk& rhs);
29 {
30 *this = rhs;
31 }
32 ~Bkmk(); 29 ~Bkmk();
33 unsigned int value() const { return m_position; } 30 unsigned int value() const { return m_position; }
34 void value(unsigned int _v) { m_position = _v; } 31 void value(unsigned int _v) { m_position = _v; }
35 unsigned int value2() const { return m_position2; } 32 unsigned int value2() const { return m_position2; }
36 void value2(unsigned int _v) { m_position2 = _v; } 33 void value2(unsigned int _v) { m_position2 = _v; }
37 unsigned char red() { return m_red; } 34 unsigned char red() { return m_red; }
38 unsigned char green() { return m_green; } 35 unsigned char green() { return m_green; }
39 unsigned char blue() { return m_blue; } 36 unsigned char blue() { return m_blue; }
40 void red(unsigned char _v) { m_red = _v; } 37 void red(unsigned char _v) { m_red = _v; }
41 void green(unsigned char _v) { m_green = _v; } 38 void green(unsigned char _v) { m_green = _v; }
42 void blue(unsigned char _v) { m_blue = _v; } 39 void blue(unsigned char _v) { m_blue = _v; }
43 unsigned char level() { return m_level; } 40 unsigned char level() { return m_level; }
44 void level(unsigned char _v) { m_level = _v; } 41 void level(unsigned char _v) { m_level = _v; }
45 tchar *name() const { return (tchar*)m_name; } 42 tchar *name() const { return (tchar*)m_name; }
46 tchar *anno() const { return (tchar*)m_anno; } 43 tchar *anno() const { return (tchar*)m_anno; }
47 bool operator<(const Bkmk& rhs) { return (m_position < rhs.m_position); } 44 bool operator<(const Bkmk& rhs) { return (m_position < rhs.m_position); }
48 Bkmk& operator=(const Bkmk& rhs); 45 Bkmk& operator=(const Bkmk& rhs);
49 bool operator==(const Bkmk& rhs); 46 bool operator==(const Bkmk& rhs);
50 void setAnno(tchar* t); 47 void setAnno(tchar* t);
51 void setAnno(unsigned char* t, unsigned short len); 48 void setAnno(unsigned char* t, unsigned short len);
52 unsigned char* filedata() 49 unsigned char* filedata()
53 { 50 {
54 CFiledata fd(anno()); 51 CFiledata fd(anno());
55 return m_anno+fd.length(); 52 return m_anno+fd.length();
56 } 53 }
57 unsigned short filedatalen() 54 unsigned short filedatalen()
58 { 55 {
59 CFiledata fd(anno()); 56 CFiledata fd(anno());
60 return m_annolen - fd.length(); 57 return m_annolen - fd.length();
61 } 58 }
62}; 59};
63 60
64class BkmkFile 61class BkmkFile
65{ 62{
66 FILE* f; 63 FILE* f;
67 bool wt; 64 bool wt;
68 bool isUpgraded, m_extras; 65 bool isUpgraded, m_extras;
69 static const unsigned long magic; 66 static const unsigned long magic;
70 private: 67 private:
71 static Bkmk* read07(BkmkFile*, FILE*); 68 static Bkmk* read07(BkmkFile*, FILE*);
72 static Bkmk* read06(BkmkFile*, FILE*); 69 static Bkmk* read06(BkmkFile*, FILE*);
73 static Bkmk* read05(BkmkFile*, FILE*); 70 static Bkmk* read05(BkmkFile*, FILE*);
74 static Bkmk* read03(BkmkFile*, FILE*); 71 static Bkmk* read03(BkmkFile*, FILE*);
75 CList<Bkmk>* readall00(Bkmk*(*fn)(BkmkFile*, FILE*)); 72 CList<Bkmk>* readall00(Bkmk*(*fn)(BkmkFile*, FILE*));
76 void write(const Bkmk& b); 73 void write(const Bkmk& b);
77 public: 74 public:
78 bool upgraded() { return isUpgraded; } 75 bool upgraded() { return isUpgraded; }
79 BkmkFile(const char *fnm, bool w, bool _x); 76 BkmkFile(const char *fnm, bool w, bool _x);
80 ~BkmkFile(); 77 ~BkmkFile();
81 void write(CList<Bkmk>& bl); 78 void write(CList<Bkmk>& bl);
82 CList<Bkmk>* readall(); 79 CList<Bkmk>* readall();
83}; 80};
84#endif 81#endif
diff --git a/noncore/apps/opie-reader/StyleConsts.cpp b/noncore/apps/opie-reader/StyleConsts.cpp
index 77c9d3b..c19fa3d 100644
--- a/noncore/apps/opie-reader/StyleConsts.cpp
+++ b/noncore/apps/opie-reader/StyleConsts.cpp
@@ -1,108 +1,115 @@
1 1
2#include <qimage.h> 2#include <qimage.h>
3#include "StyleConsts.h" 3#include "StyleConsts.h"
4 4
5GraphicLink::~GraphicLink() { delete graphic; } 5GraphicLink::~GraphicLink() { delete graphic; }
6 6
7pmstore::pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) :
8 count(1),
9 m_isScaleable(_canScale)
10{
11 graphic = new GraphicLink(p, isLnk, tgt);
12}
13
7pmstore::~pmstore() 14pmstore::~pmstore()
8{ 15{
9//// qDebug("Deleting image"); 16//// qDebug("Deleting image");
10 delete graphic; 17 delete graphic;
11} 18}
12 19
13CStyle::~CStyle() 20CStyle::~CStyle()
14{ 21{
15 if (graphic != NULL) 22 if (graphic != NULL)
16 { 23 {
17 if (--(graphic->count) == 0) 24 if (--(graphic->count) == 0)
18 { 25 {
19 delete graphic; 26 delete graphic;
20 } 27 }
21 } 28 }
22} 29}
23 30
24CStyle::CStyle(const CStyle& rhs) : graphic(NULL) 31CStyle::CStyle(const CStyle& rhs) : graphic(NULL)
25{ 32{
26 *this = rhs; 33 *this = rhs;
27} 34}
28 35
29CStyle& CStyle::operator=(const CStyle& rhs) 36CStyle& CStyle::operator=(const CStyle& rhs)
30{ 37{
31 if (rhs.graphic != NULL) 38 if (rhs.graphic != NULL)
32 { 39 {
33 (rhs.graphic->count)++; 40 (rhs.graphic->count)++;
34 if (graphic != NULL) 41 if (graphic != NULL)
35 { 42 {
36 if (--(graphic->count) == 0) 43 if (--(graphic->count) == 0)
37 { 44 {
38 delete graphic; 45 delete graphic;
39 } 46 }
40 } 47 }
41 graphic = rhs.graphic; 48 graphic = rhs.graphic;
42 } 49 }
43 else 50 else
44 { 51 {
45 if (graphic != NULL) 52 if (graphic != NULL)
46 { 53 {
47 if (--(graphic->count) == 0) 54 if (--(graphic->count) == 0)
48 { 55 {
49 delete graphic; 56 delete graphic;
50 } 57 }
51 graphic = NULL; 58 graphic = NULL;
52 } 59 }
53 } 60 }
54 sty = rhs.sty; 61 sty = rhs.sty;
55 return *this; 62 return *this;
56} 63}
57 64
58void CStyle::clearPicture() 65void CStyle::clearPicture()
59{ 66{
60 if (graphic != NULL) 67 if (graphic != NULL)
61 { 68 {
62 if (--(graphic->count) == 0) 69 if (--(graphic->count) == 0)
63 { 70 {
64 delete graphic; 71 delete graphic;
65 } 72 }
66 graphic = NULL; 73 graphic = NULL;
67 } 74 }
68} 75}
69 76
70void CStyle::unset() 77void CStyle::unset()
71{ 78{
72 sty.unset(); 79 sty.unset();
73 if (graphic != NULL) 80 if (graphic != NULL)
74 { 81 {
75 if (--(graphic->count) == 0) 82 if (--(graphic->count) == 0)
76 { 83 {
77 delete graphic; 84 delete graphic;
78 } 85 }
79 graphic = NULL; 86 graphic = NULL;
80 } 87 }
81} 88}
82 89
83void CStyle::setPicture(bool canScale, QImage* _g, bool il, unsigned long tgt) 90void CStyle::setPicture(bool canScale, QImage* _g, bool il, unsigned long tgt)
84{ 91{
85 if (graphic != NULL) 92 if (graphic != NULL)
86 { 93 {
87 if (--(graphic->count) == 0) 94 if (--(graphic->count) == 0)
88 { 95 {
89 delete graphic; 96 delete graphic;
90 } 97 }
91 graphic = NULL; 98 graphic = NULL;
92 } 99 }
93 if (_g != NULL) graphic = new pmstore(canScale, _g, il, tgt); 100 if (_g != NULL) graphic = new pmstore(canScale, _g, il, tgt);
94} 101}
95 102
96void CStyle::invert() 103void CStyle::invert()
97{ 104{
98 qDebug("Before:<%02x%02x%02x>", sty.bred, sty.bgreen, sty.bblue); 105 qDebug("Before:<%02x%02x%02x>", sty.bred, sty.bgreen, sty.bblue);
99 qDebug("Before:<%02x%02x%02x>", sty.red, sty.green, sty.blue); 106 qDebug("Before:<%02x%02x%02x>", sty.red, sty.green, sty.blue);
100 sty.bred = 255-sty.bred; 107 sty.bred = 255-sty.bred;
101 sty.bgreen = 255-sty.bgreen; 108 sty.bgreen = 255-sty.bgreen;
102 sty.bblue = 255-sty.bblue; 109 sty.bblue = 255-sty.bblue;
103 sty.red = 255-sty.red; 110 sty.red = 255-sty.red;
104 sty.green = 255-sty.green; 111 sty.green = 255-sty.green;
105 sty.blue = 255-sty.blue; 112 sty.blue = 255-sty.blue;
106 qDebug("After:<%02x%02x%02x>", sty.bred, sty.bgreen, sty.bblue); 113 qDebug("After:<%02x%02x%02x>", sty.bred, sty.bgreen, sty.bblue);
107 qDebug("After:<%02x%02x%02x>", sty.red, sty.green, sty.blue); 114 qDebug("After:<%02x%02x%02x>", sty.red, sty.green, sty.blue);
108} 115}
diff --git a/noncore/apps/opie-reader/StyleConsts.h b/noncore/apps/opie-reader/StyleConsts.h
index 4b7ff4b..5fd9669 100644
--- a/noncore/apps/opie-reader/StyleConsts.h
+++ b/noncore/apps/opie-reader/StyleConsts.h
@@ -1,160 +1,158 @@
1#ifndef __STYLECONSTS_H 1#ifndef __STYLECONSTS_H
2#define __STYLECONSTS_H 2#define __STYLECONSTS_H
3 3
4typedef unsigned short StyleType; 4typedef unsigned short StyleType;
5 5
6#ifdef _WINDOWS 6#ifdef _WINDOWS
7#include <string.h> 7#include <string.h>
8#endif 8#endif
9#include <string.h> 9#include <string.h>
10#include <stdlib.h> 10#include <stdlib.h>
11#include <qglobal.h> 11#include <qglobal.h>
12class QImage; 12class QImage;
13 13
14struct GraphicLink 14struct GraphicLink
15{ 15{
16 QImage* graphic; 16 QImage* graphic;
17 bool isLink; 17 bool isLink;
18 unsigned long link; 18 unsigned long link;
19 GraphicLink(QImage* p, bool isLnk, unsigned long tgt) : 19 GraphicLink(QImage* p, bool isLnk, unsigned long tgt) :
20 graphic(p), isLink(isLnk), link(tgt) {} 20 graphic(p), isLink(isLnk), link(tgt) {}
21 ~GraphicLink(); 21 ~GraphicLink();
22}; 22};
23 23
24struct pmstore 24class pmstore
25{ 25{
26 public:
26 unsigned int count; 27 unsigned int count;
27 bool m_isScaleable; 28 bool m_isScaleable;
28 GraphicLink* graphic; 29 GraphicLink* graphic;
29 pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) : count(1), m_isScaleable(_canScale) 30 pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt);
30 {
31 graphic = new GraphicLink(p, isLnk, tgt);
32 }
33 ~pmstore(); 31 ~pmstore();
34}; 32};
35 33
36enum EalignmentType 34enum EalignmentType
37{ 35{
38 m_AlignLeft, 36 m_AlignLeft,
39 m_AlignRight, 37 m_AlignRight,
40 m_AlignCentre, 38 m_AlignCentre,
41 m_AlignJustify, 39 m_AlignJustify,
42 m_AlignNone 40 m_AlignNone
43}; 41};
44 42
45class CBasicStyle 43class CBasicStyle
46{ 44{
47 friend class CStyle; 45 friend class CStyle;
48 bool m_bold, 46 bool m_bold,
49 m_italic; 47 m_italic;
50 unsigned long m_table; 48 unsigned long m_table;
51 int m_fontsize; 49 int m_fontsize;
52 EalignmentType m_align; 50 EalignmentType m_align;
53 unsigned char red, green, blue; 51 unsigned char red, green, blue;
54 unsigned char bred, bgreen, bblue; 52 unsigned char bred, bgreen, bblue;
55 unsigned char pred, pgreen, pblue; 53 unsigned char pred, pgreen, pblue;
56 unsigned long data; 54 unsigned long data;
57 unsigned long offset; 55 unsigned long offset;
58 bool isLink; 56 bool isLink;
59 // bool isVisited; 57 // bool isVisited;
60 bool m_underline; 58 bool m_underline;
61 bool m_strikethru; 59 bool m_strikethru;
62 bool m_monospaced; 60 bool m_monospaced;
63 unsigned char m_leftmargin, m_rightmargin; 61 unsigned char m_leftmargin, m_rightmargin;
64 signed char m_extraspace; 62 signed char m_extraspace;
65 signed char m_voffset; 63 signed char m_voffset;
66 CBasicStyle() 64 CBasicStyle()
67 { 65 {
68 unset(); 66 unset();
69 m_table = 0xffffffff; 67 m_table = 0xffffffff;
70 } 68 }
71 bool operator!=(const CBasicStyle& rhs) 69 bool operator!=(const CBasicStyle& rhs)
72 { 70 {
73 return (memcmp(this, &rhs, sizeof(CBasicStyle)) != 0); 71 return (memcmp(this, &rhs, sizeof(CBasicStyle)) != 0);
74 } 72 }
75 void unset() 73 void unset()
76 { 74 {
77 m_bold = false; 75 m_bold = false;
78 m_italic = false; 76 m_italic = false;
79 m_fontsize = 0; 77 m_fontsize = 0;
80 m_align = m_AlignLeft; 78 m_align = m_AlignLeft;
81 red = green = blue = 0; 79 red = green = blue = 0;
82 bred = bgreen = bblue = 255; 80 bred = bgreen = bblue = 255;
83 pred = pgreen = pblue = 255; 81 pred = pgreen = pblue = 255;
84 data = 0; 82 data = 0;
85 offset = 0; 83 offset = 0;
86 isLink = false; 84 isLink = false;
87 // isVisited = false; 85 // isVisited = false;
88 m_underline = false; 86 m_underline = false;
89 m_strikethru = false; 87 m_strikethru = false;
90 m_leftmargin = 0; 88 m_leftmargin = 0;
91 m_rightmargin = 0; 89 m_rightmargin = 0;
92 m_monospaced = false; 90 m_monospaced = false;
93 m_extraspace = 0; 91 m_extraspace = 0;
94 m_voffset = 0; 92 m_voffset = 0;
95 } 93 }
96}; 94};
97 95
98class CStyle 96class CStyle
99{ 97{
100 CBasicStyle sty; 98 CBasicStyle sty;
101 pmstore* graphic; 99 pmstore* graphic;
102 public: 100 public:
103 signed char getVOffset() { return sty.m_voffset; } 101 signed char getVOffset() { return sty.m_voffset; }
104 void setVOffset(signed char sp) { sty.m_voffset = sp; } 102 void setVOffset(signed char sp) { sty.m_voffset = sp; }
105 signed char getExtraSpace() { return sty.m_extraspace; } 103 signed char getExtraSpace() { return sty.m_extraspace; }
106 void setExtraSpace(signed char sp) { sty.m_extraspace = sp; } 104 void setExtraSpace(signed char sp) { sty.m_extraspace = sp; }
107 bool getPictureLink() 105 bool getPictureLink()
108 { 106 {
109 return (graphic != NULL && graphic->graphic->isLink); 107 return (graphic != NULL && graphic->graphic->isLink);
110 } 108 }
111 unsigned long getPictureLinkData() 109 unsigned long getPictureLinkData()
112 { 110 {
113 return graphic->graphic->link; 111 return graphic->graphic->link;
114 } 112 }
115 void setLeftMargin(unsigned char m) { sty.m_leftmargin = m; } 113 void setLeftMargin(unsigned char m) { sty.m_leftmargin = m; }
116 unsigned char getLeftMargin() { return sty.m_leftmargin; } 114 unsigned char getLeftMargin() { return sty.m_leftmargin; }
117 void setRightMargin(unsigned char m) { sty.m_rightmargin = m; } 115 void setRightMargin(unsigned char m) { sty.m_rightmargin = m; }
118 unsigned char getRightMargin() { return sty.m_rightmargin; } 116 unsigned char getRightMargin() { return sty.m_rightmargin; }
119 unsigned char Red() { return sty.red; } 117 unsigned char Red() { return sty.red; }
120 unsigned char Green() { return sty.green; } 118 unsigned char Green() { return sty.green; }
121 unsigned char Blue() { return sty.blue; } 119 unsigned char Blue() { return sty.blue; }
122 void setColour(unsigned char r, unsigned char g, unsigned char b) 120 void setColour(unsigned char r, unsigned char g, unsigned char b)
123 { 121 {
124 sty.red = r; 122 sty.red = r;
125 sty.green = g; 123 sty.green = g;
126 sty.blue = b; 124 sty.blue = b;
127 } 125 }
128 unsigned char bRed() { return sty.bred; } 126 unsigned char bRed() { return sty.bred; }
129 unsigned char bGreen() { return sty.bgreen; } 127 unsigned char bGreen() { return sty.bgreen; }
130 unsigned char bBlue() { return sty.bblue; } 128 unsigned char bBlue() { return sty.bblue; }
131 unsigned char pRed() { return sty.pred; } 129 unsigned char pRed() { return sty.pred; }
132 unsigned char pGreen() { return sty.pgreen; } 130 unsigned char pGreen() { return sty.pgreen; }
133 unsigned char pBlue() { return sty.pblue; } 131 unsigned char pBlue() { return sty.pblue; }
134 void setPaper(unsigned char r, unsigned char g, unsigned char b) 132 void setPaper(unsigned char r, unsigned char g, unsigned char b)
135 { 133 {
136 sty.pred = r; 134 sty.pred = r;
137 sty.pgreen = g; 135 sty.pgreen = g;
138 sty.pblue = b; 136 sty.pblue = b;
139 } 137 }
140 void setBackground(unsigned char r, unsigned char g, unsigned char b) 138 void setBackground(unsigned char r, unsigned char g, unsigned char b)
141 { 139 {
142 sty.bred = r; 140 sty.bred = r;
143 sty.bgreen = g; 141 sty.bgreen = g;
144 sty.bblue = b; 142 sty.bblue = b;
145 } 143 }
146 CStyle() : graphic(NULL) {} 144 CStyle() : graphic(NULL) {}
147 ~CStyle(); 145 ~CStyle();
148// CStyle(CStyle&); 146// CStyle(CStyle&);
149 CStyle(const CStyle&); 147 CStyle(const CStyle&);
150 CStyle& operator=(const CStyle&); 148 CStyle& operator=(const CStyle&);
151 void unset(); 149 void unset();
152 bool isTable() const { return (sty.m_table != 0xffffffff); } 150 bool isTable() const { return (sty.m_table != 0xffffffff); }
153 void setTable(unsigned long _b) { sty.m_table = _b; } 151 void setTable(unsigned long _b) { sty.m_table = _b; }
154 unsigned long getTable() { return sty.m_table; } 152 unsigned long getTable() { return sty.m_table; }
155 bool isPicture() const { return (graphic != NULL); } 153 bool isPicture() const { return (graphic != NULL); }
156 bool canScale() const { return graphic->m_isScaleable; } 154 bool canScale() const { return graphic->m_isScaleable; }
157 void clearPicture(); 155 void clearPicture();
158 void setPicture(bool canScale, QImage* _g, bool il=false, unsigned long tgt=0); 156 void setPicture(bool canScale, QImage* _g, bool il=false, unsigned long tgt=0);
159 QImage* getPicture() 157 QImage* getPicture()
160 { 158 {
diff --git a/noncore/apps/opie-write/qrichtext.cpp b/noncore/apps/opie-write/qrichtext.cpp
index c27eb1e..f040f1e 100644
--- a/noncore/apps/opie-write/qrichtext.cpp
+++ b/noncore/apps/opie-write/qrichtext.cpp
@@ -5935,357 +5935,356 @@ QTextFormat QTextFormat::makeTextFormat( const QStyleSheetItem *style, const QMa
5935 // It might be used inside an anchor and it should 5935 // It might be used inside an anchor and it should
5936 // override the link color. 5936 // override the link color.
5937 format.linkColor = FALSE; 5937 format.linkColor = FALSE;
5938 } 5938 }
5939 switch ( style->verticalAlignment() ) { 5939 switch ( style->verticalAlignment() ) {
5940 case QStyleSheetItem::VAlignBaseline: 5940 case QStyleSheetItem::VAlignBaseline:
5941 format.setVAlign( QTextFormat::AlignNormal ); 5941 format.setVAlign( QTextFormat::AlignNormal );
5942 break; 5942 break;
5943 case QStyleSheetItem::VAlignSuper: 5943 case QStyleSheetItem::VAlignSuper:
5944 format.setVAlign( QTextFormat::AlignSuperScript ); 5944 format.setVAlign( QTextFormat::AlignSuperScript );
5945 break; 5945 break;
5946 case QStyleSheetItem::VAlignSub: 5946 case QStyleSheetItem::VAlignSub:
5947 format.setVAlign( QTextFormat::AlignSubScript ); 5947 format.setVAlign( QTextFormat::AlignSubScript );
5948 break; 5948 break;
5949 } 5949 }
5950 5950
5951 if ( style->fontWeight() != QStyleSheetItem::Undefined ) 5951 if ( style->fontWeight() != QStyleSheetItem::Undefined )
5952 format.fn.setWeight( style->fontWeight() ); 5952 format.fn.setWeight( style->fontWeight() );
5953 if ( style->fontSize() != QStyleSheetItem::Undefined ) { 5953 if ( style->fontSize() != QStyleSheetItem::Undefined ) {
5954 format.fn.setPointSize( style->fontSize() ); 5954 format.fn.setPointSize( style->fontSize() );
5955 } else if ( style->logicalFontSize() != QStyleSheetItem::Undefined ) { 5955 } else if ( style->logicalFontSize() != QStyleSheetItem::Undefined ) {
5956 format.logicalFontSize = style->logicalFontSize(); 5956 format.logicalFontSize = style->logicalFontSize();
5957 if ( format.usePixelSizes ) 5957 if ( format.usePixelSizes )
5958 format.fn.setPixelSize( format.stdSize ); 5958 format.fn.setPixelSize( format.stdSize );
5959 else 5959 else
5960 format.fn.setPointSize( format.stdSize ); 5960 format.fn.setPointSize( format.stdSize );
5961 style->styleSheet()->scaleFont( format.fn, format.logicalFontSize ); 5961 style->styleSheet()->scaleFont( format.fn, format.logicalFontSize );
5962 } else if ( style->logicalFontSizeStep() ) { 5962 } else if ( style->logicalFontSizeStep() ) {
5963 format.logicalFontSize += style->logicalFontSizeStep(); 5963 format.logicalFontSize += style->logicalFontSizeStep();
5964 if ( format.usePixelSizes ) 5964 if ( format.usePixelSizes )
5965 format.fn.setPixelSize( format.stdSize ); 5965 format.fn.setPixelSize( format.stdSize );
5966 else 5966 else
5967 format.fn.setPointSize( format.stdSize ); 5967 format.fn.setPointSize( format.stdSize );
5968 style->styleSheet()->scaleFont( format.fn, format.logicalFontSize ); 5968 style->styleSheet()->scaleFont( format.fn, format.logicalFontSize );
5969 } 5969 }
5970 if ( !style->fontFamily().isEmpty() ) 5970 if ( !style->fontFamily().isEmpty() )
5971 format.fn.setFamily( style->fontFamily() ); 5971 format.fn.setFamily( style->fontFamily() );
5972 if ( style->color().isValid() ) 5972 if ( style->color().isValid() )
5973 format.col = style->color(); 5973 format.col = style->color();
5974 if ( style->definesFontItalic() ) 5974 if ( style->definesFontItalic() )
5975 format.fn.setItalic( style->fontItalic() ); 5975 format.fn.setItalic( style->fontItalic() );
5976 if ( style->definesFontUnderline() ) 5976 if ( style->definesFontUnderline() )
5977 format.fn.setUnderline( style->fontUnderline() ); 5977 format.fn.setUnderline( style->fontUnderline() );
5978 if ( style->definesFontStrikeOut() ) 5978 if ( style->definesFontStrikeOut() )
5979 format.fn.setStrikeOut( style->fontStrikeOut() ); 5979 format.fn.setStrikeOut( style->fontStrikeOut() );
5980 5980
5981 5981
5982 if ( style->name() == "font") { 5982 if ( style->name() == "font") {
5983 if ( attr.contains("color") ) { 5983 if ( attr.contains("color") ) {
5984 QString s = attr["color"]; 5984 QString s = attr["color"];
5985 if ( !s.isEmpty() ) { 5985 if ( !s.isEmpty() ) {
5986 format.col.setNamedColor( s ); 5986 format.col.setNamedColor( s );
5987 format.linkColor = FALSE; 5987 format.linkColor = FALSE;
5988 } 5988 }
5989 } 5989 }
5990 if ( attr.contains("face") ) { 5990 if ( attr.contains("face") ) {
5991 QString a = attr["face"]; 5991 QString a = attr["face"];
5992 QString family = QTextDocument::section( a, ",", 0, 0 ); 5992 QString family = QTextDocument::section( a, ",", 0, 0 );
5993 if ( !!family ) 5993 if ( !!family )
5994 format.fn.setFamily( family ); 5994 format.fn.setFamily( family );
5995 } 5995 }
5996 if ( attr.contains("size") ) { 5996 if ( attr.contains("size") ) {
5997 QString a = attr["size"]; 5997 QString a = attr["size"];
5998 int n = a.toInt(); 5998 int n = a.toInt();
5999 if ( a[0] == '+' || a[0] == '-' ) 5999 if ( a[0] == '+' || a[0] == '-' )
6000 n += format.logicalFontSize; 6000 n += format.logicalFontSize;
6001 format.logicalFontSize = n; 6001 format.logicalFontSize = n;
6002 if ( format.usePixelSizes ) 6002 if ( format.usePixelSizes )
6003 format.fn.setPixelSize( format.stdSize ); 6003 format.fn.setPixelSize( format.stdSize );
6004 else 6004 else
6005 format.fn.setPointSize( format.stdSize ); 6005 format.fn.setPointSize( format.stdSize );
6006 style->styleSheet()->scaleFont( format.fn, format.logicalFontSize ); 6006 style->styleSheet()->scaleFont( format.fn, format.logicalFontSize );
6007 } 6007 }
6008 } 6008 }
6009 if ( attr.contains("style" ) ) { 6009 if ( attr.contains("style" ) ) {
6010 QString a = attr["style"]; 6010 QString a = attr["style"];
6011 for ( int s = 0; s < a.contains(';')+1; s++ ) { 6011 for ( int s = 0; s < a.contains(';')+1; s++ ) {
6012 QString style = QTextDocument::section( a, ";", s, s ); 6012 QString style = QTextDocument::section( a, ";", s, s );
6013 if ( style.startsWith("font-size:" ) && QTextDocument::endsWith(style, "pt") ) { 6013 if ( style.startsWith("font-size:" ) && QTextDocument::endsWith(style, "pt") ) {
6014 format.logicalFontSize = 0; 6014 format.logicalFontSize = 0;
6015 format.setPointSize( int( scaleFontsFactor * style.mid( 10, style.length() - 12 ).toInt() ) ); 6015 format.setPointSize( int( scaleFontsFactor * style.mid( 10, style.length() - 12 ).toInt() ) );
6016 } if ( style.startsWith("font-style:" ) ) { 6016 } if ( style.startsWith("font-style:" ) ) {
6017 QString s = style.mid( 11 ).stripWhiteSpace(); 6017 QString s = style.mid( 11 ).stripWhiteSpace();
6018 if ( s == "normal" ) 6018 if ( s == "normal" )
6019 format.fn.setItalic( FALSE ); 6019 format.fn.setItalic( FALSE );
6020 else if ( s == "italic" || s == "oblique" ) 6020 else if ( s == "italic" || s == "oblique" )
6021 format.fn.setItalic( TRUE ); 6021 format.fn.setItalic( TRUE );
6022 } else if ( style.startsWith("font-weight:" ) ) { 6022 } else if ( style.startsWith("font-weight:" ) ) {
6023 QString s = style.mid( 12 ); 6023 QString s = style.mid( 12 );
6024 bool ok = TRUE; 6024 bool ok = TRUE;
6025 int n = s.toInt( &ok ); 6025 int n = s.toInt( &ok );
6026 if ( ok ) 6026 if ( ok )
6027 format.fn.setWeight( n/8 ); 6027 format.fn.setWeight( n/8 );
6028 } else if ( style.startsWith("font-family:" ) ) { 6028 } else if ( style.startsWith("font-family:" ) ) {
6029 format.fn.setFamily( QTextDocument::section(style.mid(12),",",0,0).stripWhiteSpace() ); 6029 format.fn.setFamily( QTextDocument::section(style.mid(12),",",0,0).stripWhiteSpace() );
6030 } else if ( style.startsWith("text-decoration:" ) ) { 6030 } else if ( style.startsWith("text-decoration:" ) ) {
6031 QString s = style.mid( 16 ).stripWhiteSpace(); 6031 QString s = style.mid( 16 ).stripWhiteSpace();
6032 format.fn.setUnderline( s == "underline" ); 6032 format.fn.setUnderline( s == "underline" );
6033 } else if ( style.startsWith("vertical-align:" ) ) { 6033 } else if ( style.startsWith("vertical-align:" ) ) {
6034 QString s = style.mid( 15 ).stripWhiteSpace(); 6034 QString s = style.mid( 15 ).stripWhiteSpace();
6035 if ( s == "sub" ) 6035 if ( s == "sub" )
6036 format.setVAlign( QTextFormat::AlignSubScript ); 6036 format.setVAlign( QTextFormat::AlignSubScript );
6037 else if ( s == "super" ) 6037 else if ( s == "super" )
6038 format.setVAlign( QTextFormat::AlignSuperScript ); 6038 format.setVAlign( QTextFormat::AlignSuperScript );
6039 else 6039 else
6040 format.setVAlign( QTextFormat::AlignNormal ); 6040 format.setVAlign( QTextFormat::AlignNormal );
6041 } else if ( style.startsWith("color:" ) ) { 6041 } else if ( style.startsWith("color:" ) ) {
6042 format.col.setNamedColor( style.mid(6) ); 6042 format.col.setNamedColor( style.mid(6) );
6043 format.linkColor = FALSE; 6043 format.linkColor = FALSE;
6044 } 6044 }
6045 } 6045 }
6046 } 6046 }
6047 6047
6048 format.update(); 6048 format.update();
6049 return format; 6049 return format;
6050} 6050}
6051 6051
6052struct QPixmapInt 6052struct QPixmapInt
6053{ 6053{
6054 QPixmapInt() : ref( 0 ) {} 6054 QPixmapInt() : ref( 0 ) {}
6055 QPixmap pm; 6055 QPixmap pm;
6056 int ref; 6056 int ref;
6057}; 6057};
6058 6058
6059static QMap<QString, QPixmapInt> *pixmap_map = 0; 6059static QMap<QString, QPixmapInt> *pixmap_map = 0;
6060 6060
6061QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context, 6061QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context,
6062 QMimeSourceFactory &factory ) 6062 QMimeSourceFactory &factory )
6063 : QTextCustomItem( p ) 6063 : QTextCustomItem( p ), reg( 0 )
6064{ 6064{
6065 width = height = 0; 6065 width = height = 0;
6066 if ( attr.contains("width") ) 6066 if ( attr.contains("width") )
6067 width = attr["width"].toInt(); 6067 width = attr["width"].toInt();
6068 if ( attr.contains("height") ) 6068 if ( attr.contains("height") )
6069 height = attr["height"].toInt(); 6069 height = attr["height"].toInt();
6070 6070
6071 reg = 0;
6072 QString imageName = attr["src"]; 6071 QString imageName = attr["src"];
6073 6072
6074 if (!imageName) 6073 if (!imageName)
6075 imageName = attr["source"]; 6074 imageName = attr["source"];
6076 6075
6077 if ( !imageName.isEmpty() ) { 6076 if ( !imageName.isEmpty() ) {
6078 imgId = QString( "%1,%2,%3,%4" ).arg( imageName ).arg( width ).arg( height ).arg( (ulong)&factory ); 6077 imgId = QString( "%1,%2,%3,%4" ).arg( imageName ).arg( width ).arg( height ).arg( (ulong)&factory );
6079 if ( !pixmap_map ) 6078 if ( !pixmap_map )
6080 pixmap_map = new QMap<QString, QPixmapInt>; 6079 pixmap_map = new QMap<QString, QPixmapInt>;
6081 if ( pixmap_map->contains( imgId ) ) { 6080 if ( pixmap_map->contains( imgId ) ) {
6082 QPixmapInt& pmi = pixmap_map->operator[](imgId); 6081 QPixmapInt& pmi = pixmap_map->operator[](imgId);
6083 pm = pmi.pm; 6082 pm = pmi.pm;
6084 pmi.ref++; 6083 pmi.ref++;
6085 width = pm.width(); 6084 width = pm.width();
6086 height = pm.height(); 6085 height = pm.height();
6087 } else { 6086 } else {
6088 QImage img; 6087 QImage img;
6089 const QMimeSource* m = 6088 const QMimeSource* m =
6090 factory.data( imageName, context ); 6089 factory.data( imageName, context );
6091 if ( !m ) { 6090 if ( !m ) {
6092 owarn << "QTextImage: no mimesource for " << imageName.latin1() << "" << oendl; 6091 owarn << "QTextImage: no mimesource for " << imageName.latin1() << "" << oendl;
6093 } 6092 }
6094 else { 6093 else {
6095 if ( !QImageDrag::decode( m, img ) ) { 6094 if ( !QImageDrag::decode( m, img ) ) {
6096 owarn << "QTextImage: cannot decode " << imageName.latin1() << "" << oendl; 6095 owarn << "QTextImage: cannot decode " << imageName.latin1() << "" << oendl;
6097 } 6096 }
6098 } 6097 }
6099 6098
6100 if ( !img.isNull() ) { 6099 if ( !img.isNull() ) {
6101 if ( width == 0 ) { 6100 if ( width == 0 ) {
6102 width = img.width(); 6101 width = img.width();
6103 if ( height != 0 ) { 6102 if ( height != 0 ) {
6104 width = img.width() * height / img.height(); 6103 width = img.width() * height / img.height();
6105 } 6104 }
6106 } 6105 }
6107 if ( height == 0 ) { 6106 if ( height == 0 ) {
6108 height = img.height(); 6107 height = img.height();
6109 if ( width != img.width() ) { 6108 if ( width != img.width() ) {
6110 height = img.height() * width / img.width(); 6109 height = img.height() * width / img.width();
6111 } 6110 }
6112 } 6111 }
6113 if ( img.width() != width || img.height() != height ){ 6112 if ( img.width() != width || img.height() != height ){
6114#ifndef QT_NO_IMAGE_SMOOTHSCALE 6113#ifndef QT_NO_IMAGE_SMOOTHSCALE
6115 img = img.smoothScale(width, height); 6114 img = img.smoothScale(width, height);
6116#endif 6115#endif
6117 width = img.width(); 6116 width = img.width();
6118 height = img.height(); 6117 height = img.height();
6119 } 6118 }
6120 pm.convertFromImage( img ); 6119 pm.convertFromImage( img );
6121 } 6120 }
6122 if ( !pm.isNull() ) { 6121 if ( !pm.isNull() ) {
6123 QPixmapInt& pmi = pixmap_map->operator[](imgId); 6122 QPixmapInt& pmi = pixmap_map->operator[](imgId);
6124 pmi.pm = pm; 6123 pmi.pm = pm;
6125 pmi.ref++; 6124 pmi.ref++;
6126 } 6125 }
6127 } 6126 }
6128 if ( pm.mask() ) { 6127 if ( pm.mask() ) {
6129 QRegion mask( *pm.mask() ); 6128 QRegion mask( *pm.mask() );
6130 QRegion all( 0, 0, pm.width(), pm.height() ); 6129 QRegion all( 0, 0, pm.width(), pm.height() );
6131 reg = new QRegion( all.subtract( mask ) ); 6130 reg = new QRegion( all.subtract( mask ) );
6132 } 6131 }
6133 } 6132 }
6134 6133
6135 if ( pm.isNull() && (width*height)==0 ) 6134 if ( pm.isNull() && (width*height)==0 )
6136 width = height = 50; 6135 width = height = 50;
6137 6136
6138 place = PlaceInline; 6137 place = PlaceInline;
6139 if ( attr["align"] == "left" ) 6138 if ( attr["align"] == "left" )
6140 place = PlaceLeft; 6139 place = PlaceLeft;
6141 else if ( attr["align"] == "right" ) 6140 else if ( attr["align"] == "right" )
6142 place = PlaceRight; 6141 place = PlaceRight;
6143 6142
6144 tmpwidth = width; 6143 tmpwidth = width;
6145 tmpheight = height; 6144 tmpheight = height;
6146 6145
6147 attributes = attr; 6146 attributes = attr;
6148} 6147}
6149 6148
6150QTextImage::~QTextImage() 6149QTextImage::~QTextImage()
6151{ 6150{
6151 delete reg;
6152 if ( pixmap_map && pixmap_map->contains( imgId ) ) { 6152 if ( pixmap_map && pixmap_map->contains( imgId ) ) {
6153 QPixmapInt& pmi = pixmap_map->operator[](imgId); 6153 QPixmapInt& pmi = pixmap_map->operator[](imgId);
6154 pmi.ref--; 6154 pmi.ref--;
6155 if ( !pmi.ref ) { 6155 if ( !pmi.ref ) {
6156 pixmap_map->remove( imgId ); 6156 pixmap_map->remove( imgId );
6157 if ( pixmap_map->isEmpty() ) { 6157 if ( pixmap_map->isEmpty() ) {
6158 delete pixmap_map; 6158 delete pixmap_map;
6159 pixmap_map = 0; 6159 pixmap_map = 0;
6160 } 6160 }
6161 } 6161 }
6162 } 6162 }
6163 delete reg;
6164} 6163}
6165 6164
6166QString QTextImage::richText() const 6165QString QTextImage::richText() const
6167{ 6166{
6168 QString s; 6167 QString s;
6169 s += "<img "; 6168 s += "<img ";
6170 QMap<QString, QString>::ConstIterator it = attributes.begin(); 6169 QMap<QString, QString>::ConstIterator it = attributes.begin();
6171 for ( ; it != attributes.end(); ++it ) 6170 for ( ; it != attributes.end(); ++it )
6172 s += it.key() + "=" + *it + " "; 6171 s += it.key() + "=" + *it + " ";
6173 s += ">"; 6172 s += ">";
6174 return s; 6173 return s;
6175} 6174}
6176 6175
6177void QTextImage::adjustToPainter( QPainter* p ) 6176void QTextImage::adjustToPainter( QPainter* p )
6178{ 6177{
6179 width = scale( tmpwidth, p ); 6178 width = scale( tmpwidth, p );
6180 height = scale( tmpheight, p ); 6179 height = scale( tmpheight, p );
6181} 6180}
6182 6181
6183#if !defined(Q_WS_X11) 6182#if !defined(Q_WS_X11)
6184#include <qbitmap.h> 6183#include <qbitmap.h>
6185#include "qcleanuphandler.h" 6184#include "qcleanuphandler.h"
6186static QPixmap *qrt_selection = 0; 6185static QPixmap *qrt_selection = 0;
6187static QSingleCleanupHandler<QPixmap> qrt_cleanup_pixmap; 6186static QSingleCleanupHandler<QPixmap> qrt_cleanup_pixmap;
6188static void qrt_createSelectionPixmap( const QColorGroup &cg ) 6187static void qrt_createSelectionPixmap( const QColorGroup &cg )
6189{ 6188{
6190 qrt_selection = new QPixmap( 2, 2 ); 6189 qrt_selection = new QPixmap( 2, 2 );
6191 qrt_cleanup_pixmap.set( &qrt_selection ); 6190 qrt_cleanup_pixmap.set( &qrt_selection );
6192 qrt_selection->fill( Qt::color0 ); 6191 qrt_selection->fill( Qt::color0 );
6193 QBitmap m( 2, 2 ); 6192 QBitmap m( 2, 2 );
6194 m.fill( Qt::color1 ); 6193 m.fill( Qt::color1 );
6195 QPainter p( &m ); 6194 QPainter p( &m );
6196 p.setPen( Qt::color0 ); 6195 p.setPen( Qt::color0 );
6197 for ( int j = 0; j < 2; ++j ) { 6196 for ( int j = 0; j < 2; ++j ) {
6198 p.drawPoint( j % 2, j ); 6197 p.drawPoint( j % 2, j );
6199 } 6198 }
6200 p.end(); 6199 p.end();
6201 qrt_selection->setMask( m ); 6200 qrt_selection->setMask( m );
6202 qrt_selection->fill( cg.highlight() ); 6201 qrt_selection->fill( cg.highlight() );
6203} 6202}
6204#endif 6203#endif
6205 6204
6206void QTextImage::draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected ) 6205void QTextImage::draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected )
6207{ 6206{
6208 if ( placement() != PlaceInline ) { 6207 if ( placement() != PlaceInline ) {
6209 x = xpos; 6208 x = xpos;
6210 y = ypos; 6209 y = ypos;
6211 } 6210 }
6212 6211
6213 if ( pm.isNull() ) { 6212 if ( pm.isNull() ) {
6214 p->fillRect( x , y, width, height, cg.dark() ); 6213 p->fillRect( x , y, width, height, cg.dark() );
6215 return; 6214 return;
6216 } 6215 }
6217 6216
6218 if ( is_printer( p ) ) { 6217 if ( is_printer( p ) ) {
6219 p->drawPixmap( x, y, pm ); 6218 p->drawPixmap( x, y, pm );
6220 return; 6219 return;
6221 } 6220 }
6222 6221
6223 if ( placement() != PlaceInline && !QRect( xpos, ypos, width, height ).intersects( QRect( cx, cy, cw, ch ) ) ) 6222 if ( placement() != PlaceInline && !QRect( xpos, ypos, width, height ).intersects( QRect( cx, cy, cw, ch ) ) )
6224 return; 6223 return;
6225 6224
6226 if ( placement() == PlaceInline ) 6225 if ( placement() == PlaceInline )
6227 p->drawPixmap( x , y, pm ); 6226 p->drawPixmap( x , y, pm );
6228 else 6227 else
6229 p->drawPixmap( cx , cy, pm, cx - x, cy - y, cw, ch ); 6228 p->drawPixmap( cx , cy, pm, cx - x, cy - y, cw, ch );
6230 6229
6231 if ( selected && placement() == PlaceInline && is_printer( p ) ) { 6230 if ( selected && placement() == PlaceInline && is_printer( p ) ) {
6232#if defined(Q_WS_X11) 6231#if defined(Q_WS_X11)
6233 p->fillRect( QRect( QPoint( x, y ), pm.size() ), QBrush( cg.highlight(), QBrush::Dense4Pattern) ); 6232 p->fillRect( QRect( QPoint( x, y ), pm.size() ), QBrush( cg.highlight(), QBrush::Dense4Pattern) );
6234#else // in WIN32 Dense4Pattern doesn't work correctly (transparency problem), so work around it 6233#else // in WIN32 Dense4Pattern doesn't work correctly (transparency problem), so work around it
6235 if ( !qrt_selection ) 6234 if ( !qrt_selection )
6236 qrt_createSelectionPixmap( cg ); 6235 qrt_createSelectionPixmap( cg );
6237 p->drawTiledPixmap( x, y, pm.width(), pm.height(), *qrt_selection ); 6236 p->drawTiledPixmap( x, y, pm.width(), pm.height(), *qrt_selection );
6238#endif 6237#endif
6239 } 6238 }
6240} 6239}
6241 6240
6242void QTextHorizontalLine::adjustToPainter( QPainter* p ) 6241void QTextHorizontalLine::adjustToPainter( QPainter* p )
6243{ 6242{
6244 height = scale( tmpheight, p ); 6243 height = scale( tmpheight, p );
6245} 6244}
6246 6245
6247 6246
6248QTextHorizontalLine::QTextHorizontalLine( QTextDocument *p, const QMap<QString, QString> &attr, 6247QTextHorizontalLine::QTextHorizontalLine( QTextDocument *p, const QMap<QString, QString> &attr,
6249 const QString &, 6248 const QString &,
6250 QMimeSourceFactory & ) 6249 QMimeSourceFactory & )
6251 : QTextCustomItem( p ) 6250 : QTextCustomItem( p )
6252{ 6251{
6253 height = tmpheight = 8; 6252 height = tmpheight = 8;
6254 if ( attr.find( "color" ) != attr.end() ) 6253 if ( attr.find( "color" ) != attr.end() )
6255 color = QColor( *attr.find( "color" ) ); 6254 color = QColor( *attr.find( "color" ) );
6256} 6255}
6257 6256
6258QTextHorizontalLine::~QTextHorizontalLine() 6257QTextHorizontalLine::~QTextHorizontalLine()
6259{ 6258{
6260} 6259}
6261 6260
6262QString QTextHorizontalLine::richText() const 6261QString QTextHorizontalLine::richText() const
6263{ 6262{
6264 return "<hr>"; 6263 return "<hr>";
6265} 6264}
6266 6265
6267void QTextHorizontalLine::draw( QPainter* p, int x, int y, int , int , int , int , const QColorGroup& cg, bool selected ) 6266void QTextHorizontalLine::draw( QPainter* p, int x, int y, int , int , int , int , const QColorGroup& cg, bool selected )
6268{ 6267{
6269 QRect r( x, y, width, height); 6268 QRect r( x, y, width, height);
6270 if ( is_printer( p ) ) { 6269 if ( is_printer( p ) ) {
6271 QPen oldPen = p->pen(); 6270 QPen oldPen = p->pen();
6272 if ( !color.isValid() ) 6271 if ( !color.isValid() )
6273 p->setPen( QPen( cg.text(), height/8 ) ); 6272 p->setPen( QPen( cg.text(), height/8 ) );
6274 else 6273 else
6275 p->setPen( QPen( color, height/8 ) ); 6274 p->setPen( QPen( color, height/8 ) );
6276 p->drawLine( r.left()-1, y + height / 2, r.right() + 1, y + height / 2 ); 6275 p->drawLine( r.left()-1, y + height / 2, r.right() + 1, y + height / 2 );
6277 p->setPen( oldPen ); 6276 p->setPen( oldPen );
6278 } else { 6277 } else {
6279 QColorGroup g( cg ); 6278 QColorGroup g( cg );
6280 if ( color.isValid() ) 6279 if ( color.isValid() )
6281 g.setColor( QColorGroup::Dark, color ); 6280 g.setColor( QColorGroup::Dark, color );
6282 if ( selected ) 6281 if ( selected )
6283 p->fillRect( r.left(), y, r.right(), y + height, g.highlight() ); 6282 p->fillRect( r.left(), y, r.right(), y + height, g.highlight() );
6284 qDrawShadeLine( p, r.left() - 1, y + height / 2, r.right() + 1, y + height / 2, g, TRUE, height / 8 ); 6283 qDrawShadeLine( p, r.left() - 1, y + height / 2, r.right() + 1, y + height / 2, g, TRUE, height / 8 );
6285 } 6284 }
6286} 6285}
6287 6286
6288 6287
6289/*****************************************************************/ 6288/*****************************************************************/
6290// Small set of utility functions to make the parser a bit simpler 6289// Small set of utility functions to make the parser a bit simpler
6291// 6290//
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.cpp b/noncore/apps/tinykate/libkate/document/katehighlight.cpp
index 539d356..89024f7 100644
--- a/noncore/apps/tinykate/libkate/document/katehighlight.cpp
+++ b/noncore/apps/tinykate/libkate/document/katehighlight.cpp
@@ -264,263 +264,268 @@ const QChar *HlFloat::checkHgl(const QChar *s, int len, bool) {
264 } 264 }
265 return s; 265 return s;
266 } 266 }
267 if ((*s == '-')||(*s =='+')) s++; 267 if ((*s == '-')||(*s =='+')) s++;
268 b = false; 268 b = false;
269 while (s->isDigit()) { 269 while (s->isDigit()) {
270 s++; 270 s++;
271 b = true; 271 b = true;
272 } 272 }
273 if (b) 273 if (b)
274 { 274 {
275 if (subItems) 275 if (subItems)
276 { 276 {
277 for (HlItem *it=subItems->first();it;it=subItems->next()) 277 for (HlItem *it=subItems->first();it;it=subItems->next())
278 { 278 {
279 s1=it->checkHgl(s, len, false); 279 s1=it->checkHgl(s, len, false);
280 if (s1) return s1; 280 if (s1) return s1;
281 } 281 }
282 } 282 }
283 return s; 283 return s;
284 } 284 }
285 else return 0L; 285 else return 0L;
286} 286}
287 287
288 288
289HlCInt::HlCInt(int attribute, int context) 289HlCInt::HlCInt(int attribute, int context)
290 : HlInt(attribute,context) { 290 : HlInt(attribute,context) {
291} 291}
292 292
293const QChar *HlCInt::checkHgl(const QChar *s, int len, bool lineStart) { 293const QChar *HlCInt::checkHgl(const QChar *s, int len, bool lineStart) {
294 294
295// if (*s == '0') s++; else s = HlInt::checkHgl(s); 295// if (*s == '0') s++; else s = HlInt::checkHgl(s);
296 s = HlInt::checkHgl(s, len, lineStart); 296 s = HlInt::checkHgl(s, len, lineStart);
297 if (s != 0L) { 297 if (s != 0L) {
298 int l = 0; 298 int l = 0;
299 int u = 0; 299 int u = 0;
300 const QChar *str; 300 const QChar *str;
301 301
302 do { 302 do {
303 str = s; 303 str = s;
304 if ((*s&0xdf) == 'L' ) { 304 if ((*s&0xdf) == 'L' ) {
305 l++; 305 l++;
306 if (l > 2) return 0L; 306 if (l > 2) return 0L;
307 s++; 307 s++;
308 } 308 }
309 if ((*s&0xdf) == 'U' ){ 309 if ((*s&0xdf) == 'U' ){
310 u++; 310 u++;
311 if (u > 1) return 0L; 311 if (u > 1) return 0L;
312 s++; 312 s++;
313 } 313 }
314 } while (s != str); 314 } while (s != str);
315 } 315 }
316 return s; 316 return s;
317} 317}
318 318
319HlCOct::HlCOct(int attribute, int context) 319HlCOct::HlCOct(int attribute, int context)
320 : HlItem(attribute,context) { 320 : HlItem(attribute,context) {
321} 321}
322 322
323const QChar *HlCOct::checkHgl(const QChar *str, int len, bool) { 323const QChar *HlCOct::checkHgl(const QChar *str, int len, bool) {
324 const QChar *s; 324 const QChar *s;
325 325
326 if (*str == '0') { 326 if (*str == '0') {
327 str++; 327 str++;
328 s = str; 328 s = str;
329 while (*s >= '0' && *s <= '7') s++; 329 while (*s >= '0' && *s <= '7') s++;
330 if (s > str) { 330 if (s > str) {
331 if ((*s&0xdf) == 'L' || (*s&0xdf) == 'U' ) s++; 331 if ((*s&0xdf) == 'L' || (*s&0xdf) == 'U' ) s++;
332 return s; 332 return s;
333 } 333 }
334 } 334 }
335 return 0L; 335 return 0L;
336} 336}
337 337
338HlCHex::HlCHex(int attribute, int context) 338HlCHex::HlCHex(int attribute, int context)
339 : HlItem(attribute,context) { 339 : HlItem(attribute,context) {
340} 340}
341 341
342const QChar *HlCHex::checkHgl(const QChar *str, int len, bool) { 342const QChar *HlCHex::checkHgl(const QChar *str, int len, bool) {
343 const QChar *s=str; 343 const QChar *s=str;
344#if 0 344#if 0
345 int i; 345 int i;
346 for (i=0;(*s)!='\0';s++,i++); 346 for (i=0;(*s)!='\0';s++,i++);
347 QString line(str,i); 347 QString line(str,i);
348 QRegExp3 rx("0[xX][a-fA-F\\d]+[UuLl]?"); // this matches but is also matching parenthesis 348 QRegExp3 rx("0[xX][a-fA-F\\d]+[UuLl]?"); // this matches but is also matching parenthesis
349 int pos=rx.search(line,0); 349 int pos=rx.search(line,0);
350 if(pos > -1) return str+rx.matchedLength(); 350 if(pos > -1) return str+rx.matchedLength();
351 else 351 else
352 return 0L; 352 return 0L;
353 353
354#else 354#else
355 if (str[0] == '0' && ((str[1]&0xdf) == 'X' )) { 355 if (str[0] == '0' && ((str[1]&0xdf) == 'X' )) {
356 str += 2; 356 str += 2;
357 s = str; 357 s = str;
358 while (s->isDigit() || ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') /*|| (*s >= 'a' && *s <= 'f')*/) s++; 358 while (s->isDigit() || ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') /*|| (*s >= 'a' && *s <= 'f')*/) s++;
359 if (s > str) { 359 if (s > str) {
360 if ((*s&0xdf) == 'L' || (*s&0xdf) == 'U' ) s++; 360 if ((*s&0xdf) == 'L' || (*s&0xdf) == 'U' ) s++;
361 return s; 361 return s;
362 } 362 }
363 } 363 }
364 return 0L; 364 return 0L;
365#endif 365#endif
366} 366}
367 367
368HlCFloat::HlCFloat(int attribute, int context) 368HlCFloat::HlCFloat(int attribute, int context)
369 : HlFloat(attribute,context) { 369 : HlFloat(attribute,context) {
370} 370}
371 371
372const QChar *HlCFloat::checkHgl(const QChar *s, int len, bool lineStart) { 372const QChar *HlCFloat::checkHgl(const QChar *s, int len, bool lineStart) {
373 373
374 s = HlFloat::checkHgl(s, len, lineStart); 374 s = HlFloat::checkHgl(s, len, lineStart);
375 if (s && ((*s&0xdf) == 'F' )) s++; 375 if (s && ((*s&0xdf) == 'F' )) s++;
376 return s; 376 return s;
377} 377}
378 378
379HlAnyChar::HlAnyChar(int attribute, int context, const QChar* charList, uint len) 379HlAnyChar::HlAnyChar(int attribute, int context, const QChar* charList, uint len)
380 : HlItem(attribute, context) { 380 : HlItem(attribute, context) {
381 _charList=charList; 381 _charList=charList;
382 _charListLen=len; 382 _charListLen=len;
383} 383}
384 384
385const QChar *HlAnyChar::checkHgl(const QChar *s, int len, bool) 385const QChar *HlAnyChar::checkHgl(const QChar *s, int len, bool)
386{ 386{
387 if (ustrchr(_charList, _charListLen, *s)) return s +1; 387 if (ustrchr(_charList, _charListLen, *s)) return s +1;
388 return 0L; 388 return 0L;
389} 389}
390 390
391HlRegExpr::HlRegExpr(int attribute, int context,QString regexp) 391HlRegExpr::HlRegExpr(int attribute, int context,QString regexp)
392 : HlItem(attribute, context) { 392 : HlItem(attribute, context), Expr(0) {
393 393
394 handlesLinestart=regexp.startsWith("^"); 394 handlesLinestart=regexp.startsWith("^");
395 if(!handlesLinestart) regexp.prepend("^"); 395 if(!handlesLinestart) regexp.prepend("^");
396 Expr=new QRegExp3(regexp); 396 Expr=new QRegExp3(regexp);
397} 397}
398 398
399HlRegExpr::~HlRegExpr()
400{
401 delete Expr;
402}
403
399const QChar *HlRegExpr::checkHgl(const QChar *s, int len, bool lineStart) 404const QChar *HlRegExpr::checkHgl(const QChar *s, int len, bool lineStart)
400{ 405{
401 if ((!lineStart) && handlesLinestart) return 0; 406 if ((!lineStart) && handlesLinestart) return 0;
402 407
403 QString line(s,len); 408 QString line(s,len);
404 int pos = Expr->search( line, 0 ); 409 int pos = Expr->search( line, 0 );
405 if (pos==-1) return 0L; 410 if (pos==-1) return 0L;
406 else 411 else
407 return (s+Expr->matchedLength()); 412 return (s+Expr->matchedLength());
408}; 413};
409 414
410 415
411HlLineContinue::HlLineContinue(int attribute, int context) 416HlLineContinue::HlLineContinue(int attribute, int context)
412 : HlItem(attribute,context) { 417 : HlItem(attribute,context) {
413} 418}
414 419
415const QChar *HlLineContinue::checkHgl(const QChar *s, int len, bool) { 420const QChar *HlLineContinue::checkHgl(const QChar *s, int len, bool) {
416 421
417 if ((s[0].latin1() == '\\') && (len == 1)) 422 if ((s[0].latin1() == '\\') && (len == 1))
418 { 423 {
419 return s + 1; 424 return s + 1;
420 } 425 }
421 return 0L; 426 return 0L;
422} 427}
423 428
424 429
425HlCStringChar::HlCStringChar(int attribute, int context) 430HlCStringChar::HlCStringChar(int attribute, int context)
426 : HlItem(attribute,context) { 431 : HlItem(attribute,context) {
427} 432}
428 433
429//checks for hex and oct (for example \x1b or \033) 434//checks for hex and oct (for example \x1b or \033)
430const QChar *checkCharHexOct(const QChar *str) { 435const QChar *checkCharHexOct(const QChar *str) {
431 const QChar *s; 436 const QChar *s;
432 s=str; 437 s=str;
433 int n; 438 int n;
434 if (*s == 'x') { 439 if (*s == 'x') {
435 n = 0; 440 n = 0;
436 do { 441 do {
437 s++; 442 s++;
438 n *= 16; 443 n *= 16;
439 if (s->isDigit()) n += *s - '0'; 444 if (s->isDigit()) n += *s - '0';
440 else if ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') n += (*s&0xdf) - 'A' + 10; 445 else if ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') n += (*s&0xdf) - 'A' + 10;
441// else if (*s >= 'a' && *s <= 'f') n += *s - 'a' + 10; 446// else if (*s >= 'a' && *s <= 'f') n += *s - 'a' + 10;
442 else break; 447 else break;
443 if (n >= 256) return 0L; 448 if (n >= 256) return 0L;
444 } while (true); 449 } while (true);
445 if (s - str == 1) return 0L; 450 if (s - str == 1) return 0L;
446 } else { 451 } else {
447 if (!(*s >= '0' && *s <= '7')) return 0L; 452 if (!(*s >= '0' && *s <= '7')) return 0L;
448 n = *s - '0'; 453 n = *s - '0';
449 do { 454 do {
450 s++; 455 s++;
451 n *= 8; 456 n *= 8;
452 if (*s >= '0' && *s <= '7') n += *s - '0'; else break; 457 if (*s >= '0' && *s <= '7') n += *s - '0'; else break;
453 if (n >= 256) return s; 458 if (n >= 256) return s;
454 } while (s - str < 3); 459 } while (s - str < 3);
455 } 460 }
456 return s; 461 return s;
457} 462}
458// checks for C escaped chars \n and escaped hex/octal chars 463// checks for C escaped chars \n and escaped hex/octal chars
459const QChar *checkEscapedChar(const QChar *s, int len) { 464const QChar *checkEscapedChar(const QChar *s, int len) {
460 int i; 465 int i;
461 if (s[0] == '\\' && (len > 1) ) { 466 if (s[0] == '\\' && (len > 1) ) {
462 s++; 467 s++;
463 switch(*s){ 468 switch(*s){
464 case 'a': // checks for control chars 469 case 'a': // checks for control chars
465 case 'b': // we want to fall through 470 case 'b': // we want to fall through
466 case 'e': 471 case 'e':
467 case 'f': 472 case 'f':
468 473
469 case 'n': 474 case 'n':
470 case 'r': 475 case 'r':
471 case 't': 476 case 't':
472 case 'v': 477 case 'v':
473 case '\'': 478 case '\'':
474 case '\"': 479 case '\"':
475 case '?' : // added ? ANSI C classifies this as an escaped char 480 case '?' : // added ? ANSI C classifies this as an escaped char
476 case '\\': s++; 481 case '\\': s++;
477 break; 482 break;
478 case 'x': // if it's like \xff 483 case 'x': // if it's like \xff
479 s++; // eat the x 484 s++; // eat the x
480 // these for loops can probably be 485 // these for loops can probably be
481 // replaced with something else but 486 // replaced with something else but
482 // for right now they work 487 // for right now they work
483 // check for hexdigits 488 // check for hexdigits
484 for(i=0;i<2 &&(*s >= '0' && *s <= '9' || (*s&0xdf) >= 'A' && (*s&0xdf) <= 'F');i++,s++); 489 for(i=0;i<2 &&(*s >= '0' && *s <= '9' || (*s&0xdf) >= 'A' && (*s&0xdf) <= 'F');i++,s++);
485 if(i==0) return 0L; // takes care of case '\x' 490 if(i==0) return 0L; // takes care of case '\x'
486 break; 491 break;
487 492
488 case '0': case '1': case '2': case '3' : 493 case '0': case '1': case '2': case '3' :
489 case '4': case '5': case '6': case '7' : 494 case '4': case '5': case '6': case '7' :
490 for(i=0;i < 3 &&(*s >='0'&& *s<='7');i++,s++); 495 for(i=0;i < 3 &&(*s >='0'&& *s<='7');i++,s++);
491 break; 496 break;
492 default: return 0L; 497 default: return 0L;
493 } 498 }
494 return s; 499 return s;
495 } 500 }
496 return 0L; 501 return 0L;
497} 502}
498 503
499const QChar *HlCStringChar::checkHgl(const QChar *str, int len, bool) { 504const QChar *HlCStringChar::checkHgl(const QChar *str, int len, bool) {
500 return checkEscapedChar(str, len); 505 return checkEscapedChar(str, len);
501} 506}
502 507
503 508
504HlCChar::HlCChar(int attribute, int context) 509HlCChar::HlCChar(int attribute, int context)
505 : HlItem(attribute,context) { 510 : HlItem(attribute,context) {
506} 511}
507 512
508const QChar *HlCChar::checkHgl(const QChar *str, int len, bool) { 513const QChar *HlCChar::checkHgl(const QChar *str, int len, bool) {
509 const QChar *s; 514 const QChar *s;
510 515
511 if ((len > 1) && (str[0] == '\'') && (str[1] != '\'')) 516 if ((len > 1) && (str[0] == '\'') && (str[1] != '\''))
512 { 517 {
513 s = checkEscapedChar(&str[1], len); //try to match escaped char 518 s = checkEscapedChar(&str[1], len); //try to match escaped char
514 if (!s) s = &str[2]; //match single non-escaped char 519 if (!s) s = &str[2]; //match single non-escaped char
515 if (*s == '\'') return s + 1; 520 if (*s == '\'') return s + 1;
516 } 521 }
517 return 0L; 522 return 0L;
518} 523}
519 524
520 525
521//-------- 526//--------
522ItemStyle::ItemStyle() : selCol(Qt::white), bold(false), italic(false) { 527ItemStyle::ItemStyle() : selCol(Qt::white), bold(false), italic(false) {
523} 528}
524 529
525ItemStyle::ItemStyle(const QColor &col, const QColor &selCol, 530ItemStyle::ItemStyle(const QColor &col, const QColor &selCol,
526 bool bold, bool italic) 531 bool bold, bool italic)
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.h b/noncore/apps/tinykate/libkate/document/katehighlight.h
index fddf585..f0be27b 100644
--- a/noncore/apps/tinykate/libkate/document/katehighlight.h
+++ b/noncore/apps/tinykate/libkate/document/katehighlight.h
@@ -59,257 +59,257 @@ class HlCharDetect : public HlItem {
59 public: 59 public:
60 HlCharDetect(int attribute, int context, QChar); 60 HlCharDetect(int attribute, int context, QChar);
61 virtual const QChar *checkHgl(const QChar *, int len, bool); 61 virtual const QChar *checkHgl(const QChar *, int len, bool);
62 protected: 62 protected:
63 QChar sChar; 63 QChar sChar;
64}; 64};
65 65
66class Hl2CharDetect : public HlItem { 66class Hl2CharDetect : public HlItem {
67 public: 67 public:
68 Hl2CharDetect(int attribute, int context, QChar ch1, QChar ch2); 68 Hl2CharDetect(int attribute, int context, QChar ch1, QChar ch2);
69 Hl2CharDetect(int attribute, int context, const QChar *ch); 69 Hl2CharDetect(int attribute, int context, const QChar *ch);
70 70
71 virtual const QChar *checkHgl(const QChar *, int len, bool); 71 virtual const QChar *checkHgl(const QChar *, int len, bool);
72 protected: 72 protected:
73 QChar sChar1; 73 QChar sChar1;
74 QChar sChar2; 74 QChar sChar2;
75}; 75};
76 76
77class HlStringDetect : public HlItem { 77class HlStringDetect : public HlItem {
78 public: 78 public:
79 HlStringDetect(int attribute, int context, const QString &, bool inSensitive=false); 79 HlStringDetect(int attribute, int context, const QString &, bool inSensitive=false);
80 virtual ~HlStringDetect(); 80 virtual ~HlStringDetect();
81 virtual const QChar *checkHgl(const QChar *, int len, bool); 81 virtual const QChar *checkHgl(const QChar *, int len, bool);
82 protected: 82 protected:
83 const QString str; 83 const QString str;
84 bool _inSensitive; 84 bool _inSensitive;
85}; 85};
86 86
87class HlRangeDetect : public HlItem { 87class HlRangeDetect : public HlItem {
88 public: 88 public:
89 HlRangeDetect(int attribute, int context, QChar ch1, QChar ch2); 89 HlRangeDetect(int attribute, int context, QChar ch1, QChar ch2);
90 virtual const QChar *checkHgl(const QChar *, int len, bool); 90 virtual const QChar *checkHgl(const QChar *, int len, bool);
91 protected: 91 protected:
92 QChar sChar1; 92 QChar sChar1;
93 QChar sChar2; 93 QChar sChar2;
94}; 94};
95 95
96class HlKeyword : public HlItem 96class HlKeyword : public HlItem
97{ 97{
98 public: 98 public:
99 HlKeyword(int attribute, int context,bool casesensitive, const QChar *deliminator, uint deliLen); 99 HlKeyword(int attribute, int context,bool casesensitive, const QChar *deliminator, uint deliLen);
100 virtual ~HlKeyword(); 100 virtual ~HlKeyword();
101 101
102 virtual void addWord(const QString &); 102 virtual void addWord(const QString &);
103 virtual void addList(const QStringList &); 103 virtual void addList(const QStringList &);
104 virtual const QChar *checkHgl(const QChar *, int len, bool); 104 virtual const QChar *checkHgl(const QChar *, int len, bool);
105 QStringList getList() { return words;}; 105 QStringList getList() { return words;};
106 virtual bool startEnable(QChar c); 106 virtual bool startEnable(QChar c);
107 107
108 protected: 108 protected:
109 QStringList words; 109 QStringList words;
110 QDict<bool> dict; 110 QDict<bool> dict;
111 bool _caseSensitive; 111 bool _caseSensitive;
112 const QChar *deliminatorChars; 112 const QChar *deliminatorChars;
113 uint deliminatorLen; 113 uint deliminatorLen;
114}; 114};
115 115
116class HlPHex : public HlItem { 116class HlPHex : public HlItem {
117 public: 117 public:
118 HlPHex(int attribute,int context); 118 HlPHex(int attribute,int context);
119 virtual const QChar *checkHgl(const QChar *, int len, bool); 119 virtual const QChar *checkHgl(const QChar *, int len, bool);
120}; 120};
121class HlInt : public HlItem { 121class HlInt : public HlItem {
122 public: 122 public:
123 HlInt(int attribute, int context); 123 HlInt(int attribute, int context);
124 virtual const QChar *checkHgl(const QChar *, int len, bool); 124 virtual const QChar *checkHgl(const QChar *, int len, bool);
125}; 125};
126 126
127class HlFloat : public HlItem { 127class HlFloat : public HlItem {
128 public: 128 public:
129 HlFloat(int attribute, int context); 129 HlFloat(int attribute, int context);
130 virtual const QChar *checkHgl(const QChar *, int len, bool); 130 virtual const QChar *checkHgl(const QChar *, int len, bool);
131}; 131};
132 132
133class HlCInt : public HlInt { 133class HlCInt : public HlInt {
134 public: 134 public:
135 HlCInt(int attribute, int context); 135 HlCInt(int attribute, int context);
136 virtual const QChar *checkHgl(const QChar *, int len, bool); 136 virtual const QChar *checkHgl(const QChar *, int len, bool);
137}; 137};
138 138
139class HlCOct : public HlItem { 139class HlCOct : public HlItem {
140 public: 140 public:
141 HlCOct(int attribute, int context); 141 HlCOct(int attribute, int context);
142 virtual const QChar *checkHgl(const QChar *, int len, bool); 142 virtual const QChar *checkHgl(const QChar *, int len, bool);
143}; 143};
144 144
145class HlCHex : public HlItem { 145class HlCHex : public HlItem {
146 public: 146 public:
147 HlCHex(int attribute, int context); 147 HlCHex(int attribute, int context);
148 virtual const QChar *checkHgl(const QChar *, int len, bool); 148 virtual const QChar *checkHgl(const QChar *, int len, bool);
149}; 149};
150 150
151class HlCFloat : public HlFloat { 151class HlCFloat : public HlFloat {
152 public: 152 public:
153 HlCFloat(int attribute, int context); 153 HlCFloat(int attribute, int context);
154 virtual const QChar *checkHgl(const QChar *, int len, bool); 154 virtual const QChar *checkHgl(const QChar *, int len, bool);
155}; 155};
156 156
157class HlLineContinue : public HlItem { 157class HlLineContinue : public HlItem {
158 public: 158 public:
159 HlLineContinue(int attribute, int context); 159 HlLineContinue(int attribute, int context);
160 virtual bool endEnable(QChar c) {return c == '\0';} 160 virtual bool endEnable(QChar c) {return c == '\0';}
161 virtual const QChar *checkHgl(const QChar *, int len, bool); 161 virtual const QChar *checkHgl(const QChar *, int len, bool);
162}; 162};
163 163
164class HlCStringChar : public HlItem { 164class HlCStringChar : public HlItem {
165 public: 165 public:
166 HlCStringChar(int attribute, int context); 166 HlCStringChar(int attribute, int context);
167 virtual const QChar *checkHgl(const QChar *, int len, bool); 167 virtual const QChar *checkHgl(const QChar *, int len, bool);
168}; 168};
169 169
170class HlCChar : public HlItem { 170class HlCChar : public HlItem {
171 public: 171 public:
172 HlCChar(int attribute, int context); 172 HlCChar(int attribute, int context);
173 virtual const QChar *checkHgl(const QChar *, int len, bool); 173 virtual const QChar *checkHgl(const QChar *, int len, bool);
174}; 174};
175 175
176class HlAnyChar : public HlItem { 176class HlAnyChar : public HlItem {
177 public: 177 public:
178 HlAnyChar(int attribute, int context, const QChar* charList, uint len); 178 HlAnyChar(int attribute, int context, const QChar* charList, uint len);
179 virtual const QChar *checkHgl(const QChar *, int len, bool); 179 virtual const QChar *checkHgl(const QChar *, int len, bool);
180 const QChar* _charList; 180 const QChar* _charList;
181 uint _charListLen; 181 uint _charListLen;
182}; 182};
183 183
184class HlRegExpr : public HlItem { 184class HlRegExpr : public HlItem {
185 public: 185 public:
186 HlRegExpr(int attribute, int context,QString expr); 186 HlRegExpr(int attribute, int context,QString expr);
187 ~HlRegExpr(){delete Expr;}; 187 ~HlRegExpr();
188 virtual const QChar *checkHgl(const QChar *, int len, bool); 188 virtual const QChar *checkHgl(const QChar *, int len, bool);
189 QRegExp3 *Expr; 189 QRegExp3 *Expr;
190 bool handlesLinestart; 190 bool handlesLinestart;
191}; 191};
192 192
193//-------- 193//--------
194 194
195 195
196//Item Style: color, selected color, bold, italic 196//Item Style: color, selected color, bold, italic
197class ItemStyle { 197class ItemStyle {
198 public: 198 public:
199 ItemStyle(); 199 ItemStyle();
200// ItemStyle(const ItemStyle &); 200// ItemStyle(const ItemStyle &);
201 ItemStyle(const QColor &, const QColor &, bool bold, bool italic); 201 ItemStyle(const QColor &, const QColor &, bool bold, bool italic);
202 ItemStyle(ItemStyle *its){col=its->col;selCol=its->selCol; bold=its->bold; italic=its->italic;} 202 ItemStyle(ItemStyle *its){col=its->col;selCol=its->selCol; bold=its->bold; italic=its->italic;}
203// void setData(const ItemStyle &); 203// void setData(const ItemStyle &);
204 QColor col; 204 QColor col;
205 QColor selCol; 205 QColor selCol;
206 int bold; //boolean value 206 int bold; //boolean value
207 int italic; //boolean value 207 int italic; //boolean value
208}; 208};
209 209
210typedef QList<ItemStyle> ItemStyleList; 210typedef QList<ItemStyle> ItemStyleList;
211 211
212//Item Properties: name, Item Style, Item Font 212//Item Properties: name, Item Style, Item Font
213class ItemData : public ItemStyle { 213class ItemData : public ItemStyle {
214 public: 214 public:
215 ItemData(const QString name, int defStyleNum); 215 ItemData(const QString name, int defStyleNum);
216 ItemData(const QString name, int defStyleNum, 216 ItemData(const QString name, int defStyleNum,
217 const QColor&, const QColor&, bool bold, bool italic); 217 const QColor&, const QColor&, bool bold, bool italic);
218 ItemData(ItemData 218 ItemData(ItemData
219*itd):ItemStyle((ItemStyle*)itd),name(itd->name),defStyleNum(itd->defStyleNum),defStyle(itd->defStyle){;} 219*itd):ItemStyle((ItemStyle*)itd),name(itd->name),defStyleNum(itd->defStyleNum),defStyle(itd->defStyle){;}
220 const QString name; 220 const QString name;
221 int defStyleNum; 221 int defStyleNum;
222 int defStyle; //boolean value 222 int defStyle; //boolean value
223}; 223};
224 224
225typedef QList<ItemData> ItemDataList; 225typedef QList<ItemData> ItemDataList;
226 226
227class HlData { 227class HlData {
228 public: 228 public:
229 HlData(const QString &wildcards, const QString &mimetypes,const QString &identifier); 229 HlData(const QString &wildcards, const QString &mimetypes,const QString &identifier);
230 ItemDataList itemDataList; 230 ItemDataList itemDataList;
231 QString wildcards; 231 QString wildcards;
232 QString mimetypes; 232 QString mimetypes;
233 QString identifier; 233 QString identifier;
234}; 234};
235 235
236typedef QList<HlData> HlDataList; 236typedef QList<HlData> HlDataList;
237 237
238class HlManager; 238class HlManager;
239class KateConfig; 239class KateConfig;
240 240
241//context 241//context
242class HlContext { 242class HlContext {
243 public: 243 public:
244 HlContext(int attribute, int lineEndContext,int _lineBeginContext); 244 HlContext(int attribute, int lineEndContext,int _lineBeginContext);
245 QList<HlItem> items; 245 QList<HlItem> items;
246 int attr; 246 int attr;
247 int ctx; 247 int ctx;
248 int lineBeginContext; 248 int lineBeginContext;
249}; 249};
250 250
251class Highlight 251class Highlight
252{ 252{
253 friend class HlManager; 253 friend class HlManager;
254 254
255 public: 255 public:
256 Highlight(syntaxModeListItem *def); 256 Highlight(syntaxModeListItem *def);
257 ~Highlight(); 257 ~Highlight();
258 258
259 int doHighlight(int ctxNum, TextLine *); 259 int doHighlight(int ctxNum, TextLine *);
260 260
261 KateConfig *getKateConfig(); 261 KateConfig *getKateConfig();
262 QString getWildcards(); 262 QString getWildcards();
263 QString getMimetypes(); 263 QString getMimetypes();
264 HlData *getData(); 264 HlData *getData();
265 void setData(HlData *); 265 void setData(HlData *);
266 void getItemDataList(ItemDataList &); 266 void getItemDataList(ItemDataList &);
267 void getItemDataList(ItemDataList &, KateConfig *); 267 void getItemDataList(ItemDataList &, KateConfig *);
268 void setItemDataList(ItemDataList &, KateConfig *); 268 void setItemDataList(ItemDataList &, KateConfig *);
269 QString name() {return iName;} 269 QString name() {return iName;}
270 QString section() {return iSection;} 270 QString section() {return iSection;}
271 void use(); 271 void use();
272 void release(); 272 void release();
273 bool isInWord(QChar c); 273 bool isInWord(QChar c);
274 274
275 QString getCommentStart() {return cmlStart;}; 275 QString getCommentStart() {return cmlStart;};
276 QString getCommentEnd() {return cmlEnd;}; 276 QString getCommentEnd() {return cmlEnd;};
277 QString getCommentSingleLineStart() { return cslStart;}; 277 QString getCommentSingleLineStart() { return cslStart;};
278 278
279 protected: 279 protected:
280 void init(); 280 void init();
281 void done(); 281 void done();
282 void makeContextList (); 282 void makeContextList ();
283 void createItemData (ItemDataList &list); 283 void createItemData (ItemDataList &list);
284 void readGlobalKeywordConfig(); 284 void readGlobalKeywordConfig();
285 void readCommentConfig(); 285 void readCommentConfig();
286 HlItem *createHlItem(struct syntaxContextData *data, ItemDataList &iDl); 286 HlItem *createHlItem(struct syntaxContextData *data, ItemDataList &iDl);
287 int lookupAttrName(const QString& name, ItemDataList &iDl); 287 int lookupAttrName(const QString& name, ItemDataList &iDl);
288 ItemDataList internalIDList; 288 ItemDataList internalIDList;
289 static const int nContexts = 32; 289 static const int nContexts = 32;
290 HlContext *contextList[nContexts]; 290 HlContext *contextList[nContexts];
291 291
292 bool noHl; 292 bool noHl;
293 bool casesensitive; 293 bool casesensitive;
294 QString weakDeliminator; 294 QString weakDeliminator;
295 QString deliminator; 295 QString deliminator;
296 const QChar *deliminatorChars; 296 const QChar *deliminatorChars;
297 uint deliminatorLen; 297 uint deliminatorLen;
298 QString cmlStart; 298 QString cmlStart;
299 QString cmlEnd; 299 QString cmlEnd;
300 QString cslStart; 300 QString cslStart;
301 QString iName; 301 QString iName;
302 QString iSection; 302 QString iSection;
303 QString iWildcards; 303 QString iWildcards;
304 QString iMimetypes; 304 QString iMimetypes;
305 QString identifier; 305 QString identifier;
306 int refCount; 306 int refCount;
307}; 307};
308 308
309class HlManager : public QObject { 309class HlManager : public QObject {
310 Q_OBJECT 310 Q_OBJECT
311 public: 311 public:
312 HlManager(); 312 HlManager();
313 ~HlManager(); 313 ~HlManager();
314 314
315 static HlManager *self(); 315 static HlManager *self();