summaryrefslogtreecommitdiff
Side-by-side diff
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,186 +1,186 @@
/* -------------------------------------------------------------------------- */
/* */
/* [TEScreen.C] Screen Data Type */
/* */
/* -------------------------------------------------------------------------- */
/* */
/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
/* */
/* This file is part of Konsole - an X terminal for KDE */
/* */
/* -------------------------------------------------------------------------- */
/* */
/* Ported Konsole to Qt/Embedded */
/* */
/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
/* */
/* -------------------------------------------------------------------------- */
// enhancements added by L.J. Potter <ljp@llornkcor.com>
/*! \file
*/
/*! \class TEScreen
\brief The image manipulated by the emulation.
This class implements the operations of the terminal emulation framework.
It is a complete passive device, driven by the emulation decoder
(TEmuVT102). By this it forms in fact an ADT, that defines operations
on a rectangular image.
It does neither know how to display its image nor about escape sequences.
It is further independent of the underlying toolkit. By this, one can even
use this module for an ordinary text surface.
Since the operations are called by a specific emulation decoder, one may
collect their different operations here.
The state manipulated by the operations is mainly kept in `image', though
it is a little more complex bejond this. See the header file of the class.
\sa TEWidget \sa VT102Emulation
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
// #include <kdebug.h>
#include <assert.h>
#include <string.h>
#include <ctype.h>
#include <qpe/config.h>
#include "TEScreen.h"
#define HERE printf("%s(%d): here\n",__FILE__,__LINE__)
//FIXME: this is emulation specific. Use FALSE for xterm, TRUE for ANSI.
//FIXME: see if we can get this from terminfo.
#define BS_CLEARS FALSE
#define loc(X,Y) ((Y) * columns + (X))
/*! creates a `TEScreen' of `lines' lines and `columns' columns.
*/
-TEScreen::TEScreen(int lines, int columns)
+TEScreen::TEScreen(int _lines, int _columns) :
+ lines(_lines),
+ columns(_columns),
+ tabstops(0),
+ histCursor(0),
+ horzCursor(0)
{
- this->lines = lines;
- this->columns = columns;
// odebug << "Columns " << columns << "" << oendl;
- image = (ca*) malloc(lines*columns*sizeof(ca));
- tabstops = NULL; initTabStops();
-
- histCursor = 0;
- horzCursor = 0;
+ image = new ca[lines*columns];
+ initTabStops();
clearSelection();
reset();
}
/*! Destructor
*/
TEScreen::~TEScreen()
{
- free(image);
- if (tabstops) free(tabstops);
+ delete [] image;
+ delete [] tabstops;
}
/* ------------------------------------------------------------------------- */
/* */
/* Normalized Screen Operations */
/* */
/* ------------------------------------------------------------------------- */
// Cursor Setting --------------------------------------------------------------
/*! \section Cursor
The `cursor' is a location within the screen that is implicitely used in
many operations. The operations within this section allow to manipulate
the cursor explicitly and to obtain it's value.
The position of the cursor is guarantied to be between (including) 0 and
`columns-1' and `lines-1'.
*/
/*!
Move the cursor up.
The cursor will not be moved beyond the top margin.
*/
void TEScreen::cursorUp(int n)
//=CUU
{
if (n == 0) n = 1; // Default
int stop = cuY < tmargin ? 0 : tmargin;
cuX = QMIN(columns-1,cuX); // nowrap!
cuY = QMAX(stop,cuY-n);
}
/*!
Move the cursor down.
The cursor will not be moved beyond the bottom margin.
*/
void TEScreen::cursorDown(int n)
//=CUD
{
if (n == 0) n = 1; // Default
int stop = cuY > bmargin ? lines-1 : bmargin;
cuX = QMIN(columns-1,cuX); // nowrap!
cuY = QMIN(stop,cuY+n);
}
/*!
Move the cursor left.
The cursor will not move beyond the first column.
*/
void TEScreen::cursorLeft(int n)
//=CUB
{
if (n == 0) n = 1; // Default
cuX = QMIN(columns-1,cuX); // nowrap!
cuX = QMAX(0,cuX-n);
}
/*!
Move the cursor left.
The cursor will not move beyond the rightmost column.
*/
void TEScreen::cursorRight(int n)
//=CUF
{
if (n == 0) n = 1; // Default
cuX = QMIN(columns-1,cuX+n);
}
/*!
Set top and bottom margin.
*/
void TEScreen::setMargins(int top, int bot)
//=STBM
{
if (top == 0) top = 1; // Default
if (bot == 0) bot = lines; // Default
top = top - 1; // Adjust to internal lineno
bot = bot - 1; // Adjust to internal lineno
if ( !( 0 <= top && top < bot && bot < lines ) )
{ fprintf(stderr,"%s(%d) : setRegion(%d,%d) : bad range.\n",
__FILE__,__LINE__,top,bot);
return; // Default error action: ignore
}
tmargin = top;
bmargin = bot;
cuX = 0;
@@ -303,421 +303,423 @@ void TEScreen::insertLines(int n)
// Mode Operations -----------------------------------------------------------
/*! Set a specific mode. */
void TEScreen::setMode(int m)
{
currParm.mode[m] = TRUE;
switch(m)
{
case MODE_Origin : cuX = 0; cuY = tmargin; break; //FIXME: home
}
}
/*! Reset a specific mode. */
void TEScreen::resetMode(int m)
{
currParm.mode[m] = FALSE;
switch(m)
{
case MODE_Origin : cuX = 0; cuY = 0; break; //FIXME: home
}
}
/*! Save a specific mode. */
void TEScreen::saveMode(int m)
{
saveParm.mode[m] = currParm.mode[m];
}
/*! Restore a specific mode. */
void TEScreen::restoreMode(int m)
{
currParm.mode[m] = saveParm.mode[m];
}
//NOTE: this is a helper function
/*! Return the setting a specific mode. */
BOOL TEScreen::getMode(int m)
{
return currParm.mode[m];
}
/*! Save the cursor position and the rendition attribute settings. */
void TEScreen::saveCursor()
{
sa_cuX = cuX;
sa_cuY = cuY;
sa_cu_re = cu_re;
sa_cu_fg = cu_fg;
sa_cu_bg = cu_bg;
}
/*! Restore the cursor position and the rendition attribute settings. */
void TEScreen::restoreCursor()
{
cuX = QMIN(sa_cuX,columns-1);
cuY = QMIN(sa_cuY,lines-1);
cu_re = sa_cu_re;
cu_fg = sa_cu_fg;
cu_bg = sa_cu_bg;
effectiveRendition();
}
/* ------------------------------------------------------------------------- */
/* */
/* Screen Operations */
/* */
/* ------------------------------------------------------------------------- */
/*! Assing a new size to the screen.
The topmost left position is maintained, while lower lines
or right hand side columns might be removed or filled with
spaces to fit the new size.
The region setting is reset to the whole screen and the
tab positions reinitialized.
*/
void TEScreen::resizeImage(int new_lines, int new_columns)
{
if (cuY > new_lines-1) {
// attempt to preserve focus and lines
bmargin = lines-1; //FIXME: margin lost
for (int i = 0; i < cuY-(new_lines-1); i++) {
addHistLine(); scrollUp(horzCursor,1);
}
}
// make new image
- ca* newimg = (ca*)malloc( new_lines * new_columns * sizeof( ca));
+ ca* newimg = new ca[new_lines * new_columns];
clearSelection();
// clear new image
for (int y = 0; y < new_lines; y++)
for (int x = 0; x < new_columns; x++) {
newimg[y*new_columns+x].c = ' ';
newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR;
newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR;
newimg[y*new_columns+x].r = DEFAULT_RENDITION;
}
int cpy_lines = QMIN(new_lines, lines);
int cpy_columns = QMIN(new_columns,columns);
// copy to new image
for (int y = 0; y < cpy_lines; y++)
for (int x = 0; x < cpy_columns; x++) {
newimg[y*new_columns+x].c = image[loc(x,y)].c;
newimg[y*new_columns+x].f = image[loc(x,y)].f;
newimg[y*new_columns+x].b = image[loc(x,y)].b;
newimg[y*new_columns+x].r = image[loc(x,y)].r;
}
- free(image);
+ delete [] image;
image = newimg;
lines = new_lines;
columns = new_columns;
cuX = QMIN(cuX,columns-1);
cuY = QMIN(cuY,lines-1);
// FIXME: try to keep values, evtl.
tmargin=0;
bmargin=lines-1;
initTabStops();
clearSelection();
}
/*
Clarifying rendition here and in TEWidget.
currently, TEWidget's color table is
0 1 2 .. 9 10 .. 17
dft_fg, dft_bg, dim 0..7, intensive 0..7
cu_fg, cu_bg contain values 0..8;
- 0 = default color
- 1..8 = ansi specified color
re_fg, re_bg contain values 0..17
due to the TEWidget's color table
rendition attributes are
attr widget screen
-------------- ------ ------
RE_UNDERLINE XX XX affects foreground only
RE_BLINK XX XX affects foreground only
RE_BOLD XX XX affects foreground only
RE_REVERSE -- XX
RE_TRANSPARENT XX -- affects background only
RE_INTENSIVE XX -- affects foreground only
Note that RE_BOLD is used in both widget
and screen rendition. Since xterm/vt102
is to poor to distinguish between bold
(which is a font attribute) and intensive
(which is a color attribute), we translate
this and RE_BOLD in falls eventually appart
into RE_BOLD and RE_INTENSIVE.
*/
void TEScreen::reverseRendition(ca* p)
{ UINT8 f = p->f; UINT8 b = p->b;
p->f = b; p->b = f; //p->r &= ~RE_TRANSPARENT;
}
void TEScreen::effectiveRendition()
// calculate rendition
{
ef_re = cu_re & (RE_UNDERLINE | RE_BLINK);
if (cu_re & RE_REVERSE)
{
ef_fg = cu_bg;
ef_bg = cu_fg;
}
else
{
ef_fg = cu_fg;
ef_bg = cu_bg;
}
if (cu_re & RE_BOLD)
{
if (ef_fg < BASE_COLORS)
ef_fg += BASE_COLORS;
else
ef_fg -= BASE_COLORS;
}
}
/*!
returns the image.
Get the size of the image by \sa getLines and \sa getColumns.
NOTE that the image returned by this function must later be
freed.
*/
ca* TEScreen::getCookedImage()
{
int x,y;
- ca* merged = (ca*)malloc(lines*columns*sizeof(ca));
+ ca* merged = new ca[lines*columns];
ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION);
if (histCursor > hist.getLines()) {
histCursor = hist.getLines();
}
for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++)
{
int len = QMIN(columns,hist.getLineLen(y+histCursor));
int yp = y*columns;
int yq = (y+histCursor)*columns;
hist.getCells(y+histCursor,0,len,merged+yp);
for (x = len; x < columns; x++) merged[yp+x] = dft;
for (x = 0; x < columns; x++)
{ int p=x + yp; int q=x + yq;
if ( ( q >= sel_TL ) && ( q <= sel_BR ) )
reverseRendition(&merged[p]); // for selection
}
}
if (lines >= hist.getLines()-histCursor)
{
for (y = (hist.getLines()-histCursor); y < lines ; y++)
{
int yp = y*columns;
int yq = (y+histCursor)*columns;
int yr = (y-hist.getLines()+histCursor)*columns;
for (x = 0; x < columns; x++)
{ int p = x + yp; int q = x + yq; int r = x + yr;
merged[p] = image[r];
if ( q >= sel_TL && q <= sel_BR )
reverseRendition(&merged[p]); // for selection
}
}
}
// evtl. inverse display
if (getMode(MODE_Screen))
{ int i,n = lines*columns;
for (i = 0; i < n; i++)
reverseRendition(&merged[i]); // for reverse display
}
if (getMode(MODE_Cursor) && (cuY+(hist.getLines()-histCursor) < lines)) // cursor visible
reverseRendition(&merged[loc(cuX,cuY+(hist.getLines()-histCursor))]);
return merged;
}
/*!
*/
void TEScreen::reset()
{
Config cfg( "Konsole" );
cfg.setGroup("ScrollBar");
if( !cfg.readBoolEntry("HorzScroll",0) )
setMode(MODE_Wrap ); saveMode(MODE_Wrap ); // wrap at end of margin
resetMode(MODE_Origin); saveMode(MODE_Origin); // position refere to [1,1]
resetMode(MODE_Insert); saveMode(MODE_Insert); // overstroke
setMode(MODE_Cursor); // cursor visible
resetMode(MODE_Screen); // screen not inverse
resetMode(MODE_NewLine);
tmargin=0;
bmargin=lines-1;
setDefaultRendition();
saveCursor();
clear();
}
/*! Clear the entire screen and home the cursor.
*/
void TEScreen::clear()
{
clearEntireScreen();
home();
}
/*! Moves the cursor left one column.
*/
void TEScreen::BackSpace()
{
cuX = QMAX(0,cuX-1);
if (BS_CLEARS) image[loc(cuX,cuY)].c = ' ';
}
/*!
*/
void TEScreen::Tabulate()
{
// note that TAB is a format effector (does not write ' ');
cursorRight(1); while(cuX < columns-1 && !tabstops[cuX]) cursorRight(1);
}
void TEScreen::clearTabStops()
{
for (int i = 0; i < columns; i++) tabstops[i-1] = FALSE;
}
void TEScreen::changeTabStop(bool set)
{
if (cuX >= columns) return;
tabstops[cuX] = set;
}
void TEScreen::initTabStops()
{
- if (tabstops) free(tabstops);
- tabstops = (bool*)malloc(columns*sizeof(bool));
+ if (tabstops)
+ delete [] tabstops;
+
+ tabstops = new bool[columns];
// Arrg! The 1st tabstop has to be one longer than the other.
// i.e. the kids start counting from 0 instead of 1.
// Other programs might behave correctly. Be aware.
for (int i = 0; i < columns; i++) tabstops[i] = (i%8 == 0 && i != 0);
}
/*!
This behaves either as IND (Screen::Index) or as NEL (Screen::NextLine)
depending on the NewLine Mode (LNM). This mode also
affects the key sequence returned for newline ([CR]LF).
*/
void TEScreen::NewLine()
{
if (getMode(MODE_NewLine)) Return();
index();
}
/*! put `c' literally onto the screen at the current cursor position.
VT100 uses the convention to produce an automatic newline (am)
with the *first* character that would fall onto the next line (xenl).
*/
void TEScreen::checkSelection(int from, int to)
{
if (sel_begin == -1) return;
int scr_TL = loc(0, hist.getLines());
//Clear entire selection if it overlaps region [from, to]
if ( (sel_BR > (from+scr_TL) )&&(sel_TL < (to+scr_TL)) )
{
clearSelection();
}
}
void TEScreen::ShowCharacter(unsigned short c)
{
// Note that VT100 does wrapping BEFORE putting the character.
// This has impact on the assumption of valid cursor positions.
// We indicate the fact that a newline has to be triggered by
// putting the cursor one right to the last column of the screen.
if (cuX >= columns)
{
if (getMode(MODE_Wrap)) NextLine(); else cuX = columns - 1;
// comment out for no wrap
}
if (getMode(MODE_Insert)) insertChars(1);
int i = loc( cuX, cuY);
checkSelection(i, i); // check if selection is still valid.
image[i].c = c;
image[i].f = ef_fg;
image[i].b = ef_bg;
image[i].r = ef_re;
cuX += 1;
}
// Region commands -------------------------------------------------------------
/*! scroll up `n' lines within current region.
The `n' new lines are cleared.
\sa setRegion \sa scrollDown
*/
void TEScreen::scrollUp(int from, int n)
{
if (n <= 0 || from + n > bmargin) return;
//FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds.
moveImage( loc( 0, from), loc( 0, from + n), loc( columns - 1, bmargin));
clearImage( loc( 0, bmargin - n + 1), loc( columns - 1, bmargin), ' ');
}
/*! scroll down `n' lines within current region.
The `n' new lines are cleared.
\sa setRegion \sa scrollUp
*/
void TEScreen::scrollDown(int from, int n)
{
//FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds.
if (n <= 0) return;
if (from > bmargin) return;
if (from + n > bmargin) n = bmargin - from;
moveImage( loc(0,from+n), loc(0,from), loc(columns-1,bmargin-n));
clearImage(loc(0,from),loc(columns-1,from+n-1),' ');
}
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,166 +1,167 @@
// PPMLanguageModel.h
//
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 1999-2002 David Ward
//
/////////////////////////////////////////////////////////////////////////////
#include <math.h>
#include "PPMLanguageModel.h"
using namespace Dasher;
using namespace std;
// static TCHAR debug[256];
typedef unsigned long ulong;
////////////////////////////////////////////////////////////////////////
/// PPMnode definitions
////////////////////////////////////////////////////////////////////////
CPPMLanguageModel::CPPMnode *CPPMLanguageModel::CPPMnode::find_symbol(int sym)
// see if symbol is a child of node
{
// printf("finding symbol %d at node %d\n",sym,node->id);
CPPMnode *found=child;
while (found) {
if (found->symbol==sym)
return found;
found=found->next;
}
return 0;
}
CPPMLanguageModel::CPPMnode * CPPMLanguageModel::CPPMnode::add_symbol_to_node(int sym,int *update)
{
CPPMnode *born,*search;
search=find_symbol(sym);
if (!search) {
born = new CPPMnode(sym);
born->next=child;
child=born;
// node->count=1;
return born;
} else {
if (*update) { // perform update exclusions
search->count++;
*update=0;
}
return search;
}
}
/////////////////////////////////////////////////////////////////////
// CPPMLanguageModel defs
/////////////////////////////////////////////////////////////////////
CPPMLanguageModel::CPPMLanguageModel(CAlphabet *_alphabet,int _normalization)
- : CLanguageModel(_alphabet,_normalization)
+ : CLanguageModel(_alphabet,_normalization), root(0), m_rootcontext(0)
{
root=new CPPMnode(-1);
m_rootcontext=new CPPMContext(root,0);
}
CPPMLanguageModel::~CPPMLanguageModel()
{
+ delete m_rootcontext;
delete root;
}
bool CPPMLanguageModel::GetProbs(CContext *context,vector<unsigned int> &probs,double )
// get the probability distribution at the context
{
// seems like we have to have this hack for VC++
CPPMContext *ppmcontext=static_cast<CPPMContext *> (context);
int modelchars=GetNumberModelChars();
int norm=CLanguageModel::normalization();
probs.resize(modelchars);
CPPMnode *temp,*s;
int loop,total;
int sym;
// ulong spent=0;
ulong size_of_slice;
bool *exclusions=new bool [modelchars];
ulong uniform=modelchars;
ulong tospend=norm-uniform;
temp=ppmcontext->head;
for (loop=0; loop <modelchars; loop++) { /* set up the exclusions array */
probs[loop]=0;
exclusions[loop]=0;
}
while (temp!=0) {
// Usprintf(debug,TEXT("tospend %u\n"),tospend);
// DebugOutput(TEXT("round\n"));
total=0;
s=temp->child;
while (s) {
sym=s->symbol;
if (!exclusions[s->symbol])
total=total+s->count;
s=s->next;
}
if (total) {
// Usprintf(debug,TEXT"escape %u\n"),tospend*
size_of_slice=tospend;
s=temp->child;
while (s) {
if (!exclusions[s->symbol]) {
exclusions[s->symbol]=1;
ulong p=size_of_slice*(2*s->count-1)/2/ulong(total);
probs[s->symbol]+=p;
tospend-=p;
}
// Usprintf(debug,TEXT("sym %u counts %d p %u tospend %u \n"),sym,s->count,p,tospend);
// DebugOutput(debug);
s=s->next;
}
}
temp = temp->vine;
}
// Usprintf(debug,TEXT("Norm %u tospend %u\n"),Norm,tospend);
// DebugOutput(debug);
size_of_slice=tospend;
int symbolsleft=0;
for (sym=1;sym<modelchars;sym++)
if (!probs[sym])
symbolsleft++;
for (sym=1;sym<modelchars;sym++)
if (!probs[sym]) {
ulong p=size_of_slice/symbolsleft;
probs[sym]+=p;
tospend-=p;
}
// distribute what's left evenly
tospend+=uniform;
for (sym=1;sym<modelchars;sym++) {
ulong p=tospend/(modelchars-sym);
probs[sym]+=p;
tospend-=p;
}
// Usprintf(debug,TEXT("finaltospend %u\n"),tospend);
// DebugOutput(debug);
// free(exclusions); // !!!
// !!! NB by IAM: p577 Stroustrup 3rd Edition: "Allocating an object using new and deleting it using free() is asking for trouble"
delete[] exclusions;
return true;
}
void CPPMLanguageModel::AddSymbol(CPPMLanguageModel::CPPMContext &context,int symbol)
// add symbol to the context
// creates new nodes, updates counts
// and leaves 'context' at the new context
{
// sanity check
if (symbol==0 || symbol>=GetNumberModelChars())
return;
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,118 +1,134 @@
#include <qmessagebox.h>
#include "Bkmks.h"
#include "StyleConsts.h"
#include "Markups.h"
#include "my_list.h"
#include "version.h"
#include "names.h"
const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE);
-Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p)
+Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p) :
+ m_name(0),
+ m_namelen(0),
+ m_anno(0),
+ m_annolen(0),
+ m_position(0)
{
init(_nm, _nmlen, _anno, _annolen, _p);
}
Bkmk::Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short annolen, unsigned int _p) : m_position(_p)
{
init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, annolen, _p);
}
+Bkmk::Bkmk(const Bkmk& rhs) :
+ m_name(0),
+ m_namelen(0),
+ m_anno(0),
+ m_annolen(0),
+ m_position(0)
+{
+ init(rhs.name(), sizeof(tchar)*(ustrlen(rhs.name())+1), rhs.anno(),
+ sizeof(tchar)*(ustrlen(rhs.anno())+1), rhs.value());
+}
+
Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p)
{
if (_anno == NULL)
{
tchar t = 0;
init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p);
}
else
{
init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p);
}
}
Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2) : m_position(_p)
{
if (_anno == NULL)
{
tchar t = 0;
init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p);
}
else
{
init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p);
}
m_position2 = _p2;
m_red = m_green = m_blue = 127;
}
void Bkmk::init(const void* _nm, unsigned short _nmlen, const void* _anno, unsigned short _annolen, unsigned int _p)
{
m_namelen = _nmlen;
if (m_namelen > 0)
{
m_name = new unsigned char[m_namelen];
memcpy(m_name, _nm, m_namelen);
}
else
{
m_name = NULL;
}
m_annolen = _annolen;
if (m_annolen > 0)
{
m_anno = new unsigned char[m_annolen];
memcpy(m_anno, _anno, m_annolen);
}
else
{
m_anno = NULL;
}
m_position = _p;
m_position2 = _p;
m_red = m_green = m_blue = 255;
m_level = 0;
}
Bkmk::~Bkmk()
{
if (m_name != NULL) delete [] m_name;
m_name = NULL;
if (m_anno != NULL) delete [] m_anno;
m_anno = NULL;
}
Bkmk& Bkmk::operator=(const Bkmk& rhs)
{
if (m_name != NULL)
{
delete [] m_name;
m_name = NULL;
}
if (m_anno != NULL)
{
delete [] m_anno;
m_anno = NULL;
}
if (rhs.m_name != NULL)
{
m_namelen = rhs.m_namelen;
m_name = new unsigned char[m_namelen];
memcpy(m_name, rhs.m_name, m_namelen);
}
else
m_name = NULL;
if (rhs.m_anno != NULL)
{
m_annolen = rhs.m_annolen;
m_anno = new unsigned char[m_annolen];
memcpy(m_anno, rhs.m_anno, m_annolen);
}
else
m_anno = NULL;
m_position = rhs.m_position;
m_position2 = rhs.m_position2;
m_red = rhs.m_red;
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 @@
#ifndef __Bkmks_h
#define __Bkmks_h
#include "config.h"
#include "Filedata.h"
#include <stdio.h>
template<class T>
class CList;
class Bkmk
{
friend class BkmkFile;
unsigned char* m_name;
unsigned short m_namelen;
unsigned char* m_anno;
unsigned short m_annolen;
unsigned int m_position;
unsigned int m_position2;
unsigned char m_red,m_green,m_blue, m_level;
void init(const void*, unsigned short, const void*, unsigned short, unsigned int);
public:
- Bkmk() : m_name(NULL), m_namelen(0), m_anno(NULL), m_annolen(0), m_position(0) {};
+ Bkmk() : m_name(0), m_namelen(0), m_anno(0), m_annolen(0), m_position(0) {};
Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p);
Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short _annolen, unsigned int _p);
Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p);
Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2);
- Bkmk(const Bkmk& rhs) : m_name(NULL), m_anno(NULL)
- {
- *this = rhs;
- }
+ Bkmk(const Bkmk& rhs);
~Bkmk();
unsigned int value() const { return m_position; }
void value(unsigned int _v) { m_position = _v; }
unsigned int value2() const { return m_position2; }
void value2(unsigned int _v) { m_position2 = _v; }
unsigned char red() { return m_red; }
unsigned char green() { return m_green; }
unsigned char blue() { return m_blue; }
void red(unsigned char _v) { m_red = _v; }
void green(unsigned char _v) { m_green = _v; }
void blue(unsigned char _v) { m_blue = _v; }
unsigned char level() { return m_level; }
void level(unsigned char _v) { m_level = _v; }
tchar *name() const { return (tchar*)m_name; }
tchar *anno() const { return (tchar*)m_anno; }
bool operator<(const Bkmk& rhs) { return (m_position < rhs.m_position); }
Bkmk& operator=(const Bkmk& rhs);
bool operator==(const Bkmk& rhs);
void setAnno(tchar* t);
void setAnno(unsigned char* t, unsigned short len);
unsigned char* filedata()
{
CFiledata fd(anno());
return m_anno+fd.length();
}
unsigned short filedatalen()
{
CFiledata fd(anno());
return m_annolen - fd.length();
}
};
class BkmkFile
{
FILE* f;
bool wt;
bool isUpgraded, m_extras;
static const unsigned long magic;
private:
static Bkmk* read07(BkmkFile*, FILE*);
static Bkmk* read06(BkmkFile*, FILE*);
static Bkmk* read05(BkmkFile*, FILE*);
static Bkmk* read03(BkmkFile*, FILE*);
CList<Bkmk>* readall00(Bkmk*(*fn)(BkmkFile*, FILE*));
void write(const Bkmk& b);
public:
bool upgraded() { return isUpgraded; }
BkmkFile(const char *fnm, bool w, bool _x);
~BkmkFile();
void write(CList<Bkmk>& bl);
CList<Bkmk>* readall();
};
#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,102 +1,109 @@
#include <qimage.h>
#include "StyleConsts.h"
GraphicLink::~GraphicLink() { delete graphic; }
+pmstore::pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) :
+ count(1),
+ m_isScaleable(_canScale)
+{
+ graphic = new GraphicLink(p, isLnk, tgt);
+}
+
pmstore::~pmstore()
{
//// qDebug("Deleting image");
delete graphic;
}
CStyle::~CStyle()
{
if (graphic != NULL)
{
if (--(graphic->count) == 0)
{
delete graphic;
}
}
}
CStyle::CStyle(const CStyle& rhs) : graphic(NULL)
{
*this = rhs;
}
CStyle& CStyle::operator=(const CStyle& rhs)
{
if (rhs.graphic != NULL)
{
(rhs.graphic->count)++;
if (graphic != NULL)
{
if (--(graphic->count) == 0)
{
delete graphic;
}
}
graphic = rhs.graphic;
}
else
{
if (graphic != NULL)
{
if (--(graphic->count) == 0)
{
delete graphic;
}
graphic = NULL;
}
}
sty = rhs.sty;
return *this;
}
void CStyle::clearPicture()
{
if (graphic != NULL)
{
if (--(graphic->count) == 0)
{
delete graphic;
}
graphic = NULL;
}
}
void CStyle::unset()
{
sty.unset();
if (graphic != NULL)
{
if (--(graphic->count) == 0)
{
delete graphic;
}
graphic = NULL;
}
}
void CStyle::setPicture(bool canScale, QImage* _g, bool il, unsigned long tgt)
{
if (graphic != NULL)
{
if (--(graphic->count) == 0)
{
delete graphic;
}
graphic = NULL;
}
if (_g != NULL) graphic = new pmstore(canScale, _g, il, tgt);
}
void CStyle::invert()
{
qDebug("Before:<%02x%02x%02x>", sty.bred, sty.bgreen, sty.bblue);
qDebug("Before:<%02x%02x%02x>", sty.red, sty.green, sty.blue);
sty.bred = 255-sty.bred;
sty.bgreen = 255-sty.bgreen;
sty.bblue = 255-sty.bblue;
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,128 +1,126 @@
#ifndef __STYLECONSTS_H
#define __STYLECONSTS_H
typedef unsigned short StyleType;
#ifdef _WINDOWS
#include <string.h>
#endif
#include <string.h>
#include <stdlib.h>
#include <qglobal.h>
class QImage;
struct GraphicLink
{
QImage* graphic;
bool isLink;
unsigned long link;
GraphicLink(QImage* p, bool isLnk, unsigned long tgt) :
graphic(p), isLink(isLnk), link(tgt) {}
~GraphicLink();
};
-struct pmstore
+class pmstore
{
+ public:
unsigned int count;
bool m_isScaleable;
GraphicLink* graphic;
- pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) : count(1), m_isScaleable(_canScale)
- {
- graphic = new GraphicLink(p, isLnk, tgt);
- }
+ pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt);
~pmstore();
};
enum EalignmentType
{
m_AlignLeft,
m_AlignRight,
m_AlignCentre,
m_AlignJustify,
m_AlignNone
};
class CBasicStyle
{
friend class CStyle;
bool m_bold,
m_italic;
unsigned long m_table;
int m_fontsize;
EalignmentType m_align;
unsigned char red, green, blue;
unsigned char bred, bgreen, bblue;
unsigned char pred, pgreen, pblue;
unsigned long data;
unsigned long offset;
bool isLink;
// bool isVisited;
bool m_underline;
bool m_strikethru;
bool m_monospaced;
unsigned char m_leftmargin, m_rightmargin;
signed char m_extraspace;
signed char m_voffset;
CBasicStyle()
{
unset();
m_table = 0xffffffff;
}
bool operator!=(const CBasicStyle& rhs)
{
return (memcmp(this, &rhs, sizeof(CBasicStyle)) != 0);
}
void unset()
{
m_bold = false;
m_italic = false;
m_fontsize = 0;
m_align = m_AlignLeft;
red = green = blue = 0;
bred = bgreen = bblue = 255;
pred = pgreen = pblue = 255;
data = 0;
offset = 0;
isLink = false;
// isVisited = false;
m_underline = false;
m_strikethru = false;
m_leftmargin = 0;
m_rightmargin = 0;
m_monospaced = false;
m_extraspace = 0;
m_voffset = 0;
}
};
class CStyle
{
CBasicStyle sty;
pmstore* graphic;
public:
signed char getVOffset() { return sty.m_voffset; }
void setVOffset(signed char sp) { sty.m_voffset = sp; }
signed char getExtraSpace() { return sty.m_extraspace; }
void setExtraSpace(signed char sp) { sty.m_extraspace = sp; }
bool getPictureLink()
{
return (graphic != NULL && graphic->graphic->isLink);
}
unsigned long getPictureLinkData()
{
return graphic->graphic->link;
}
void setLeftMargin(unsigned char m) { sty.m_leftmargin = m; }
unsigned char getLeftMargin() { return sty.m_leftmargin; }
void setRightMargin(unsigned char m) { sty.m_rightmargin = m; }
unsigned char getRightMargin() { return sty.m_rightmargin; }
unsigned char Red() { return sty.red; }
unsigned char Green() { return sty.green; }
unsigned char Blue() { return sty.blue; }
void setColour(unsigned char r, unsigned char g, unsigned char b)
{
sty.red = r;
sty.green = g;
sty.blue = b;
}
unsigned char bRed() { return sty.bred; }
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
@@ -5967,293 +5967,292 @@ QTextFormat QTextFormat::makeTextFormat( const QStyleSheetItem *style, const QMa
format.fn.setPointSize( format.stdSize );
style->styleSheet()->scaleFont( format.fn, format.logicalFontSize );
}
if ( !style->fontFamily().isEmpty() )
format.fn.setFamily( style->fontFamily() );
if ( style->color().isValid() )
format.col = style->color();
if ( style->definesFontItalic() )
format.fn.setItalic( style->fontItalic() );
if ( style->definesFontUnderline() )
format.fn.setUnderline( style->fontUnderline() );
if ( style->definesFontStrikeOut() )
format.fn.setStrikeOut( style->fontStrikeOut() );
if ( style->name() == "font") {
if ( attr.contains("color") ) {
QString s = attr["color"];
if ( !s.isEmpty() ) {
format.col.setNamedColor( s );
format.linkColor = FALSE;
}
}
if ( attr.contains("face") ) {
QString a = attr["face"];
QString family = QTextDocument::section( a, ",", 0, 0 );
if ( !!family )
format.fn.setFamily( family );
}
if ( attr.contains("size") ) {
QString a = attr["size"];
int n = a.toInt();
if ( a[0] == '+' || a[0] == '-' )
n += format.logicalFontSize;
format.logicalFontSize = n;
if ( format.usePixelSizes )
format.fn.setPixelSize( format.stdSize );
else
format.fn.setPointSize( format.stdSize );
style->styleSheet()->scaleFont( format.fn, format.logicalFontSize );
}
}
if ( attr.contains("style" ) ) {
QString a = attr["style"];
for ( int s = 0; s < a.contains(';')+1; s++ ) {
QString style = QTextDocument::section( a, ";", s, s );
if ( style.startsWith("font-size:" ) && QTextDocument::endsWith(style, "pt") ) {
format.logicalFontSize = 0;
format.setPointSize( int( scaleFontsFactor * style.mid( 10, style.length() - 12 ).toInt() ) );
} if ( style.startsWith("font-style:" ) ) {
QString s = style.mid( 11 ).stripWhiteSpace();
if ( s == "normal" )
format.fn.setItalic( FALSE );
else if ( s == "italic" || s == "oblique" )
format.fn.setItalic( TRUE );
} else if ( style.startsWith("font-weight:" ) ) {
QString s = style.mid( 12 );
bool ok = TRUE;
int n = s.toInt( &ok );
if ( ok )
format.fn.setWeight( n/8 );
} else if ( style.startsWith("font-family:" ) ) {
format.fn.setFamily( QTextDocument::section(style.mid(12),",",0,0).stripWhiteSpace() );
} else if ( style.startsWith("text-decoration:" ) ) {
QString s = style.mid( 16 ).stripWhiteSpace();
format.fn.setUnderline( s == "underline" );
} else if ( style.startsWith("vertical-align:" ) ) {
QString s = style.mid( 15 ).stripWhiteSpace();
if ( s == "sub" )
format.setVAlign( QTextFormat::AlignSubScript );
else if ( s == "super" )
format.setVAlign( QTextFormat::AlignSuperScript );
else
format.setVAlign( QTextFormat::AlignNormal );
} else if ( style.startsWith("color:" ) ) {
format.col.setNamedColor( style.mid(6) );
format.linkColor = FALSE;
}
}
}
format.update();
return format;
}
struct QPixmapInt
{
QPixmapInt() : ref( 0 ) {}
QPixmap pm;
int ref;
};
static QMap<QString, QPixmapInt> *pixmap_map = 0;
QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context,
QMimeSourceFactory &factory )
- : QTextCustomItem( p )
+ : QTextCustomItem( p ), reg( 0 )
{
width = height = 0;
if ( attr.contains("width") )
width = attr["width"].toInt();
if ( attr.contains("height") )
height = attr["height"].toInt();
- reg = 0;
QString imageName = attr["src"];
if (!imageName)
imageName = attr["source"];
if ( !imageName.isEmpty() ) {
imgId = QString( "%1,%2,%3,%4" ).arg( imageName ).arg( width ).arg( height ).arg( (ulong)&factory );
if ( !pixmap_map )
pixmap_map = new QMap<QString, QPixmapInt>;
if ( pixmap_map->contains( imgId ) ) {
QPixmapInt& pmi = pixmap_map->operator[](imgId);
pm = pmi.pm;
pmi.ref++;
width = pm.width();
height = pm.height();
} else {
QImage img;
const QMimeSource* m =
factory.data( imageName, context );
if ( !m ) {
owarn << "QTextImage: no mimesource for " << imageName.latin1() << "" << oendl;
}
else {
if ( !QImageDrag::decode( m, img ) ) {
owarn << "QTextImage: cannot decode " << imageName.latin1() << "" << oendl;
}
}
if ( !img.isNull() ) {
if ( width == 0 ) {
width = img.width();
if ( height != 0 ) {
width = img.width() * height / img.height();
}
}
if ( height == 0 ) {
height = img.height();
if ( width != img.width() ) {
height = img.height() * width / img.width();
}
}
if ( img.width() != width || img.height() != height ){
#ifndef QT_NO_IMAGE_SMOOTHSCALE
img = img.smoothScale(width, height);
#endif
width = img.width();
height = img.height();
}
pm.convertFromImage( img );
}
if ( !pm.isNull() ) {
QPixmapInt& pmi = pixmap_map->operator[](imgId);
pmi.pm = pm;
pmi.ref++;
}
}
if ( pm.mask() ) {
QRegion mask( *pm.mask() );
QRegion all( 0, 0, pm.width(), pm.height() );
reg = new QRegion( all.subtract( mask ) );
}
}
if ( pm.isNull() && (width*height)==0 )
width = height = 50;
place = PlaceInline;
if ( attr["align"] == "left" )
place = PlaceLeft;
else if ( attr["align"] == "right" )
place = PlaceRight;
tmpwidth = width;
tmpheight = height;
attributes = attr;
}
QTextImage::~QTextImage()
{
+ delete reg;
if ( pixmap_map && pixmap_map->contains( imgId ) ) {
QPixmapInt& pmi = pixmap_map->operator[](imgId);
pmi.ref--;
if ( !pmi.ref ) {
pixmap_map->remove( imgId );
if ( pixmap_map->isEmpty() ) {
delete pixmap_map;
pixmap_map = 0;
}
}
}
- delete reg;
}
QString QTextImage::richText() const
{
QString s;
s += "<img ";
QMap<QString, QString>::ConstIterator it = attributes.begin();
for ( ; it != attributes.end(); ++it )
s += it.key() + "=" + *it + " ";
s += ">";
return s;
}
void QTextImage::adjustToPainter( QPainter* p )
{
width = scale( tmpwidth, p );
height = scale( tmpheight, p );
}
#if !defined(Q_WS_X11)
#include <qbitmap.h>
#include "qcleanuphandler.h"
static QPixmap *qrt_selection = 0;
static QSingleCleanupHandler<QPixmap> qrt_cleanup_pixmap;
static void qrt_createSelectionPixmap( const QColorGroup &cg )
{
qrt_selection = new QPixmap( 2, 2 );
qrt_cleanup_pixmap.set( &qrt_selection );
qrt_selection->fill( Qt::color0 );
QBitmap m( 2, 2 );
m.fill( Qt::color1 );
QPainter p( &m );
p.setPen( Qt::color0 );
for ( int j = 0; j < 2; ++j ) {
p.drawPoint( j % 2, j );
}
p.end();
qrt_selection->setMask( m );
qrt_selection->fill( cg.highlight() );
}
#endif
void QTextImage::draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected )
{
if ( placement() != PlaceInline ) {
x = xpos;
y = ypos;
}
if ( pm.isNull() ) {
p->fillRect( x , y, width, height, cg.dark() );
return;
}
if ( is_printer( p ) ) {
p->drawPixmap( x, y, pm );
return;
}
if ( placement() != PlaceInline && !QRect( xpos, ypos, width, height ).intersects( QRect( cx, cy, cw, ch ) ) )
return;
if ( placement() == PlaceInline )
p->drawPixmap( x , y, pm );
else
p->drawPixmap( cx , cy, pm, cx - x, cy - y, cw, ch );
if ( selected && placement() == PlaceInline && is_printer( p ) ) {
#if defined(Q_WS_X11)
p->fillRect( QRect( QPoint( x, y ), pm.size() ), QBrush( cg.highlight(), QBrush::Dense4Pattern) );
#else // in WIN32 Dense4Pattern doesn't work correctly (transparency problem), so work around it
if ( !qrt_selection )
qrt_createSelectionPixmap( cg );
p->drawTiledPixmap( x, y, pm.width(), pm.height(), *qrt_selection );
#endif
}
}
void QTextHorizontalLine::adjustToPainter( QPainter* p )
{
height = scale( tmpheight, p );
}
QTextHorizontalLine::QTextHorizontalLine( QTextDocument *p, const QMap<QString, QString> &attr,
const QString &,
QMimeSourceFactory & )
: QTextCustomItem( p )
{
height = tmpheight = 8;
if ( attr.find( "color" ) != attr.end() )
color = QColor( *attr.find( "color" ) );
}
QTextHorizontalLine::~QTextHorizontalLine()
{
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
@@ -296,199 +296,204 @@ const QChar *HlCInt::checkHgl(const QChar *s, int len, bool lineStart) {
s = HlInt::checkHgl(s, len, lineStart);
if (s != 0L) {
int l = 0;
int u = 0;
const QChar *str;
do {
str = s;
if ((*s&0xdf) == 'L' ) {
l++;
if (l > 2) return 0L;
s++;
}
if ((*s&0xdf) == 'U' ){
u++;
if (u > 1) return 0L;
s++;
}
} while (s != str);
}
return s;
}
HlCOct::HlCOct(int attribute, int context)
: HlItem(attribute,context) {
}
const QChar *HlCOct::checkHgl(const QChar *str, int len, bool) {
const QChar *s;
if (*str == '0') {
str++;
s = str;
while (*s >= '0' && *s <= '7') s++;
if (s > str) {
if ((*s&0xdf) == 'L' || (*s&0xdf) == 'U' ) s++;
return s;
}
}
return 0L;
}
HlCHex::HlCHex(int attribute, int context)
: HlItem(attribute,context) {
}
const QChar *HlCHex::checkHgl(const QChar *str, int len, bool) {
const QChar *s=str;
#if 0
int i;
for (i=0;(*s)!='\0';s++,i++);
QString line(str,i);
QRegExp3 rx("0[xX][a-fA-F\\d]+[UuLl]?"); // this matches but is also matching parenthesis
int pos=rx.search(line,0);
if(pos > -1) return str+rx.matchedLength();
else
return 0L;
#else
if (str[0] == '0' && ((str[1]&0xdf) == 'X' )) {
str += 2;
s = str;
while (s->isDigit() || ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') /*|| (*s >= 'a' && *s <= 'f')*/) s++;
if (s > str) {
if ((*s&0xdf) == 'L' || (*s&0xdf) == 'U' ) s++;
return s;
}
}
return 0L;
#endif
}
HlCFloat::HlCFloat(int attribute, int context)
: HlFloat(attribute,context) {
}
const QChar *HlCFloat::checkHgl(const QChar *s, int len, bool lineStart) {
s = HlFloat::checkHgl(s, len, lineStart);
if (s && ((*s&0xdf) == 'F' )) s++;
return s;
}
HlAnyChar::HlAnyChar(int attribute, int context, const QChar* charList, uint len)
: HlItem(attribute, context) {
_charList=charList;
_charListLen=len;
}
const QChar *HlAnyChar::checkHgl(const QChar *s, int len, bool)
{
if (ustrchr(_charList, _charListLen, *s)) return s +1;
return 0L;
}
HlRegExpr::HlRegExpr(int attribute, int context,QString regexp)
- : HlItem(attribute, context) {
+ : HlItem(attribute, context), Expr(0) {
handlesLinestart=regexp.startsWith("^");
if(!handlesLinestart) regexp.prepend("^");
Expr=new QRegExp3(regexp);
}
+HlRegExpr::~HlRegExpr()
+{
+ delete Expr;
+}
+
const QChar *HlRegExpr::checkHgl(const QChar *s, int len, bool lineStart)
{
if ((!lineStart) && handlesLinestart) return 0;
QString line(s,len);
int pos = Expr->search( line, 0 );
if (pos==-1) return 0L;
else
return (s+Expr->matchedLength());
};
HlLineContinue::HlLineContinue(int attribute, int context)
: HlItem(attribute,context) {
}
const QChar *HlLineContinue::checkHgl(const QChar *s, int len, bool) {
if ((s[0].latin1() == '\\') && (len == 1))
{
return s + 1;
}
return 0L;
}
HlCStringChar::HlCStringChar(int attribute, int context)
: HlItem(attribute,context) {
}
//checks for hex and oct (for example \x1b or \033)
const QChar *checkCharHexOct(const QChar *str) {
const QChar *s;
s=str;
int n;
if (*s == 'x') {
n = 0;
do {
s++;
n *= 16;
if (s->isDigit()) n += *s - '0';
else if ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') n += (*s&0xdf) - 'A' + 10;
// else if (*s >= 'a' && *s <= 'f') n += *s - 'a' + 10;
else break;
if (n >= 256) return 0L;
} while (true);
if (s - str == 1) return 0L;
} else {
if (!(*s >= '0' && *s <= '7')) return 0L;
n = *s - '0';
do {
s++;
n *= 8;
if (*s >= '0' && *s <= '7') n += *s - '0'; else break;
if (n >= 256) return s;
} while (s - str < 3);
}
return s;
}
// checks for C escaped chars \n and escaped hex/octal chars
const QChar *checkEscapedChar(const QChar *s, int len) {
int i;
if (s[0] == '\\' && (len > 1) ) {
s++;
switch(*s){
case 'a': // checks for control chars
case 'b': // we want to fall through
case 'e':
case 'f':
case 'n':
case 'r':
case 't':
case 'v':
case '\'':
case '\"':
case '?' : // added ? ANSI C classifies this as an escaped char
case '\\': s++;
break;
case 'x': // if it's like \xff
s++; // eat the x
// these for loops can probably be
// replaced with something else but
// for right now they work
// check for hexdigits
for(i=0;i<2 &&(*s >= '0' && *s <= '9' || (*s&0xdf) >= 'A' && (*s&0xdf) <= 'F');i++,s++);
if(i==0) return 0L; // takes care of case '\x'
break;
case '0': case '1': case '2': case '3' :
case '4': case '5': case '6': case '7' :
for(i=0;i < 3 &&(*s >='0'&& *s<='7');i++,s++);
break;
default: return 0L;
}
return s;
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
@@ -91,193 +91,193 @@ class HlRangeDetect : public HlItem {
protected:
QChar sChar1;
QChar sChar2;
};
class HlKeyword : public HlItem
{
public:
HlKeyword(int attribute, int context,bool casesensitive, const QChar *deliminator, uint deliLen);
virtual ~HlKeyword();
virtual void addWord(const QString &);
virtual void addList(const QStringList &);
virtual const QChar *checkHgl(const QChar *, int len, bool);
QStringList getList() { return words;};
virtual bool startEnable(QChar c);
protected:
QStringList words;
QDict<bool> dict;
bool _caseSensitive;
const QChar *deliminatorChars;
uint deliminatorLen;
};
class HlPHex : public HlItem {
public:
HlPHex(int attribute,int context);
virtual const QChar *checkHgl(const QChar *, int len, bool);
};
class HlInt : public HlItem {
public:
HlInt(int attribute, int context);
virtual const QChar *checkHgl(const QChar *, int len, bool);
};
class HlFloat : public HlItem {
public:
HlFloat(int attribute, int context);
virtual const QChar *checkHgl(const QChar *, int len, bool);
};
class HlCInt : public HlInt {
public:
HlCInt(int attribute, int context);
virtual const QChar *checkHgl(const QChar *, int len, bool);
};
class HlCOct : public HlItem {
public:
HlCOct(int attribute, int context);
virtual const QChar *checkHgl(const QChar *, int len, bool);
};
class HlCHex : public HlItem {
public:
HlCHex(int attribute, int context);
virtual const QChar *checkHgl(const QChar *, int len, bool);
};
class HlCFloat : public HlFloat {
public:
HlCFloat(int attribute, int context);
virtual const QChar *checkHgl(const QChar *, int len, bool);
};
class HlLineContinue : public HlItem {
public:
HlLineContinue(int attribute, int context);
virtual bool endEnable(QChar c) {return c == '\0';}
virtual const QChar *checkHgl(const QChar *, int len, bool);
};
class HlCStringChar : public HlItem {
public:
HlCStringChar(int attribute, int context);
virtual const QChar *checkHgl(const QChar *, int len, bool);
};
class HlCChar : public HlItem {
public:
HlCChar(int attribute, int context);
virtual const QChar *checkHgl(const QChar *, int len, bool);
};
class HlAnyChar : public HlItem {
public:
HlAnyChar(int attribute, int context, const QChar* charList, uint len);
virtual const QChar *checkHgl(const QChar *, int len, bool);
const QChar* _charList;
uint _charListLen;
};
class HlRegExpr : public HlItem {
public:
HlRegExpr(int attribute, int context,QString expr);
- ~HlRegExpr(){delete Expr;};
+ ~HlRegExpr();
virtual const QChar *checkHgl(const QChar *, int len, bool);
QRegExp3 *Expr;
bool handlesLinestart;
};
//--------
//Item Style: color, selected color, bold, italic
class ItemStyle {
public:
ItemStyle();
// ItemStyle(const ItemStyle &);
ItemStyle(const QColor &, const QColor &, bool bold, bool italic);
ItemStyle(ItemStyle *its){col=its->col;selCol=its->selCol; bold=its->bold; italic=its->italic;}
// void setData(const ItemStyle &);
QColor col;
QColor selCol;
int bold; //boolean value
int italic; //boolean value
};
typedef QList<ItemStyle> ItemStyleList;
//Item Properties: name, Item Style, Item Font
class ItemData : public ItemStyle {
public:
ItemData(const QString name, int defStyleNum);
ItemData(const QString name, int defStyleNum,
const QColor&, const QColor&, bool bold, bool italic);
ItemData(ItemData
*itd):ItemStyle((ItemStyle*)itd),name(itd->name),defStyleNum(itd->defStyleNum),defStyle(itd->defStyle){;}
const QString name;
int defStyleNum;
int defStyle; //boolean value
};
typedef QList<ItemData> ItemDataList;
class HlData {
public:
HlData(const QString &wildcards, const QString &mimetypes,const QString &identifier);
ItemDataList itemDataList;
QString wildcards;
QString mimetypes;
QString identifier;
};
typedef QList<HlData> HlDataList;
class HlManager;
class KateConfig;
//context
class HlContext {
public:
HlContext(int attribute, int lineEndContext,int _lineBeginContext);
QList<HlItem> items;
int attr;
int ctx;
int lineBeginContext;
};
class Highlight
{
friend class HlManager;
public:
Highlight(syntaxModeListItem *def);
~Highlight();
int doHighlight(int ctxNum, TextLine *);
KateConfig *getKateConfig();
QString getWildcards();
QString getMimetypes();
HlData *getData();
void setData(HlData *);
void getItemDataList(ItemDataList &);
void getItemDataList(ItemDataList &, KateConfig *);
void setItemDataList(ItemDataList &, KateConfig *);
QString name() {return iName;}
QString section() {return iSection;}
void use();
void release();
bool isInWord(QChar c);
QString getCommentStart() {return cmlStart;};
QString getCommentEnd() {return cmlEnd;};
QString getCommentSingleLineStart() { return cslStart;};
protected:
void init();
void done();
void makeContextList ();
void createItemData (ItemDataList &list);