summaryrefslogtreecommitdiff
path: root/noncore/apps/tinykate/libkate/document
Side-by-side diff
Diffstat (limited to 'noncore/apps/tinykate/libkate/document') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/document/katebuffer.cpp89
-rw-r--r--noncore/apps/tinykate/libkate/document/katedocument.cpp73
-rw-r--r--noncore/apps/tinykate/libkate/document/katehighlight.cpp126
-rw-r--r--noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp69
4 files changed, 184 insertions, 173 deletions
diff --git a/noncore/apps/tinykate/libkate/document/katebuffer.cpp b/noncore/apps/tinykate/libkate/document/katebuffer.cpp
index 22a4917..4c15fd0 100644
--- a/noncore/apps/tinykate/libkate/document/katebuffer.cpp
+++ b/noncore/apps/tinykate/libkate/document/katebuffer.cpp
@@ -13,42 +13,43 @@
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "katebuffer.h"
+#include "kdebug.h"
-// Includes for reading file
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
+/* OPIE */
+#include <opie2/odebug.h>
+/* QT */
#include <qfile.h>
#include <qtextstream.h>
-
#include <qtimer.h>
#include <qtextcodec.h>
-//
-
+/* STD */
+// Includes for reading file
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
#include <assert.h>
-#include <kdebug.h>
/**
* Create an empty buffer.
*/
KWBuffer::KWBuffer()
{
clear();
}
void
KWBuffer::clear()
{
@@ -56,53 +57,53 @@ KWBuffer::clear()
m_stringListCurrent=0;
m_stringList.clear();
m_lineCount=1;
m_stringListIt = m_stringList.append(new TextLine());
}
/**
* Insert a file at line @p line in the buffer.
*/
void
KWBuffer::insertFile(int line, const QString &file, QTextCodec *codec)
{
- if (line) {
- qDebug("insert File only supports insertion at line 0 == file opening");
- return;
- }
- clear();
- QFile iofile(file);
- iofile.open(IO_ReadOnly);
- QTextStream stream(&iofile);
- stream.setCodec(codec);
- QString qsl;
- int count=0;
- for (count=0;((qsl=stream.readLine())!=QString::null); count++)
- {
- if (count==0)
- {
- (*m_stringListIt)->append(qsl.unicode(),qsl.length());
- }
- else
- {
- TextLine::Ptr tl=new TextLine();
- tl ->append(qsl.unicode(),qsl.length());
- m_stringListIt=m_stringList.append(tl);
- }
- }
- if (count!=0)
- {
- m_stringListCurrent=count-1;
- m_lineCount=count;
- }
+ if (line) {
+ odebug << "insert File only supports insertion at line 0 == file opening" << oendl;
+ return;
+ }
+ clear();
+ QFile iofile(file);
+ iofile.open(IO_ReadOnly);
+ QTextStream stream(&iofile);
+ stream.setCodec(codec);
+ QString qsl;
+ int count=0;
+ for (count=0;((qsl=stream.readLine())!=QString::null); count++)
+ {
+ if (count==0)
+ {
+ (*m_stringListIt)->append(qsl.unicode(),qsl.length());
+ }
+ else
+ {
+ TextLine::Ptr tl=new TextLine();
+ tl ->append(qsl.unicode(),qsl.length());
+ m_stringListIt=m_stringList.append(tl);
+ }
+ }
+ if (count!=0)
+ {
+ m_stringListCurrent=count-1;
+ m_lineCount=count;
+ }
}
void
KWBuffer::loadFilePart()
{
}
void
KWBuffer::insertData(int line, const QByteArray &data, QTextCodec *codec)
{
}
@@ -112,54 +113,54 @@ KWBuffer::slotLoadFile()
{
loadFilePart();
// emit linesChanged(m_totalLines);
emit linesChanged(20);
}
/**
* Return the total number of lines in the buffer.
*/
int
KWBuffer::count()
{
- qDebug("m_stringList.count %d",m_stringList.count());
+ odebug << "m_stringList.count " << m_stringList.count() << "" << oendl;
return m_lineCount;
-// return m_stringList.count();
+// return m_stringList.count();
// return m_totalLines;
}
void KWBuffer::seek(int i)
{
if (m_stringListCurrent == i)
return;
while(m_stringListCurrent < i)
{
++m_stringListCurrent;
++m_stringListIt;
}
while(m_stringListCurrent > i)
{
--m_stringListCurrent;
--m_stringListIt;
}
}
TextLine::Ptr
KWBuffer::line(int i)
{
- if (i>=m_stringList.count()) return 0;
- seek(i);
- return *m_stringListIt;
+ if (i>=m_stringList.count()) return 0;
+ seek(i);
+ return *m_stringListIt;
}
void
KWBuffer::insertLine(int i, TextLine::Ptr line)
{
seek(i);
m_stringListIt = m_stringList.insert(m_stringListIt, line);
m_stringListCurrent = i;
m_lineCount++;
}
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.cpp b/noncore/apps/tinykate/libkate/document/katedocument.cpp
index 0c742d7..6dc4fd2 100644
--- a/noncore/apps/tinykate/libkate/document/katedocument.cpp
+++ b/noncore/apps/tinykate/libkate/document/katedocument.cpp
@@ -1,21 +1,21 @@
/***************************************************************************
katedocument.cpp - description
-------------------
begin : Mon Jan 15 2001
copyright : (C) 2001 by Christoph "Crossfire" Cullmann
(C) 2002 by Joseph Wenninger
email : crossfire@babylon2k.de
jowenn@kde.org
-
+
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/*
@@ -30,62 +30,63 @@
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "katedocument.h"
+#include "kmessagebox.h"
+#include "kglobal.h"
+//#include "kcharsets.h"
+#include "kdebug.h"
+//#include "kinstance.h"
-#include <qfileinfo.h>
-#include <qdatetime.h>
+#include "kglobalsettings.h"
+//#include "kaction.h"
+//#include "kstdaction.h"
-#include <kmessagebox.h>
-#include <qpe/config.h>
-#include <qstring.h>
+#include "../view/kateview.h"
+#include "katebuffer.h"
+#include "katetextline.h"
-#include <sys/time.h>
-#include <unistd.h>
+#include "katecmd.h"
-#include <stdio.h>
+/* OPIE */
+#include <opie2/odebug.h>
+#include <qpe/config.h>
+/* QT */
+#include <qfileinfo.h>
+#include <qdatetime.h>
+#include <qstring.h>
#include <qtimer.h>
#include <qobject.h>
#include <qapplication.h>
#include <qclipboard.h>
#include <qfont.h>
#include <qpainter.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qtextcodec.h>
-#include <kglobal.h>
-//#include <kcharsets.h>
-#include <kdebug.h>
-//#include <kinstance.h>
-
-#include <kglobalsettings.h>
-//#include <kaction.h>
-//#include <kstdaction.h>
-
-#include "../view/kateview.h"
-#include "katebuffer.h"
-#include "katetextline.h"
-
-#include "katecmd.h"
+/* STD */
+#include <sys/time.h>
+#include <unistd.h>
+#include <stdio.h>
KateAction::KateAction(Action a, PointStruc &cursor, int len, const QString &text)
: action(a), cursor(cursor), len(len), text(text) {
}
KateActionGroup::KateActionGroup(PointStruc &aStart, int type)
: start(aStart), action(0L), undoType(type) {
}
KateActionGroup::~KateActionGroup() {
KateAction *current, *next;
@@ -121,47 +122,47 @@ const char * KateActionGroup::typeName(int type)
case ugDelLine : return "Delete Line";
}
return "";
}
const int KateDocument::maxAttribs = 32;
QStringList KateDocument::searchForList = QStringList();
QStringList KateDocument::replaceWithList = QStringList();
uint KateDocument::uniqueID = 0;
-QPtrDict<KateDocument::KateDocPrivate>* KateDocument::d_ptr = 0;
+QPtrDict<KateDocument::KateDocPrivate>* KateDocument::d_ptr = 0;
KateDocument::KateDocument(bool bSingleViewMode, bool bBrowserView,
QWidget *parentWidget, const char *widgetName,
QObject *, const char *)
: Kate::Document (),
myFont(KGlobalSettings::generalFont()), myFontBold(KGlobalSettings::generalFont()), myFontItalic(KGlobalSettings::generalFont()), myFontBI(KGlobalSettings::generalFont()),
myFontMetrics (myFont), myFontMetricsBold (myFontBold), myFontMetricsItalic (myFontItalic), myFontMetricsBI (myFontBI),
hlManager(HlManager::self ())
{
-
- d(this)->hlSetByUser = false;
+
+ d(this)->hlSetByUser = false;
PreHighlightedTill=0;
RequestPreHighlightTill=0;
m_bSingleViewMode=bSingleViewMode;
m_bBrowserView = bBrowserView;
m_url = QString::null;
// NOTE: QFont::CharSet doesn't provide all the charsets KDE supports
- // (esp. it doesn't distinguish between UTF-8 and iso10646-1)
+ // (esp. it doesn't distinguish between UTF-8 and iso10646-1)
myEncoding = QString::fromLatin1(QTextCodec::codecForLocale()->name());
maxLength = -1;
setFont (KGlobalSettings::generalFont());
myDocID = uniqueID;
uniqueID++;
myDocName = QString ("");
fileInfo = new QFileInfo ();
@@ -283,60 +284,60 @@ KateDocument::~KateDocument()
if ( !m_bSingleViewMode )
{
m_views.setAutoDelete( true );
m_views.clear();
m_views.setAutoDelete( false );
}
delete_d(this);
}
void KateDocument::openURL(const QString &filename)
{
- m_file=filename;
+ m_file=filename;
fileInfo->setFile (m_file);
setMTime();
if (!fileInfo->exists() || !fileInfo->isReadable())
{
- qDebug("File doesn't exit or couldn't be read");
+ odebug << "File doesn't exit or couldn't be read" << oendl;
return ;
}
buffer->clear();
#warning fixme
// buffer->insertFile(0, m_file, KGlobal::charsets()->codecForName(myEncoding));
- qDebug("Telling buffer to open file");
+ odebug << "Telling buffer to open file" << oendl;
buffer->insertFile(0, m_file, QTextCodec::codecForLocale());
setMTime();
if (myWordWrap)
wrapText (myWordWrapAt);
int hl = hlManager->wildcardFind( m_file );
setHighlight(hl);
updateLines();
updateViews();
emit fileNameChanged();
-
+
return ;
}
bool KateDocument::saveFile()
{
-
+
QFile f( m_file );
if ( !f.open( IO_WriteOnly ) )
return false; // Error
QTextStream stream(&f);
stream.setEncoding(QTextStream::RawUnicode); // disable Unicode headers
#warning fixme
// stream.setCodec(KGlobal::charsets()->codecForName(myEncoding));
stream.setCodec(QTextCodec::codecForLocale()); // this line sets the mapper to the correct codec
int maxLine = numLines();
@@ -602,25 +603,25 @@ void KateDocument::readConfig()
myWordWrapAt = config->readNumEntry("Word Wrap At", 80);
if (myWordWrap)
wrapText (myWordWrapAt);
setTabWidth(config->readNumEntry("TabWidth", 8));
setUndoSteps(config->readNumEntry("UndoSteps", 50));
m_singleSelection = config->readBoolEntry("SingleSelection", false);
myEncoding = config->readEntry("Encoding", QString::fromLatin1(QTextCodec::codecForLocale()->name()));
setFont (config->readFontEntry("Font", myFont));
colors[0] = config->readColorEntry("Color Background", colors[0]);
colors[1] = config->readColorEntry("Color Selected", colors[1]);
-
+
// config->sync();
}
void KateDocument::writeConfig()
{
KateConfig *config = KGlobal::config();
config->setGroup("Kate Document");
config->writeEntry("Word Wrap On", myWordWrap);
config->writeEntry("Word Wrap At", myWordWrapAt);
config->writeEntry("TabWidth", tabChars);
config->writeEntry("UndoSteps", undoSteps);
config->writeEntry("SingleSelection", m_singleSelection);
@@ -674,25 +675,25 @@ void KateDocument::setHighlight(int n) {
} else {
if (m_highlight != 0L) m_highlight->release();
h->use();
m_highlight = h;
makeAttribs();
}
PreHighlightedTill=0;
RequestPreHighlightTill=0;
emit(highlightChanged());
}
void KateDocument::makeAttribs() {
- qDebug("KateDocument::makeAttribs()");
+ odebug << "KateDocument::makeAttribs()" << oendl;
m_numAttribs = hlManager->makeAttribs(m_highlight, m_attribs, maxAttribs);
updateFontData();
updateLines();
}
void KateDocument::updateFontData() {
int maxAscent, maxDescent;
int tabWidth;
KateView *view;
maxAscent = myFontMetrics.ascent();
maxDescent = myFontMetrics.descent();
@@ -1914,26 +1915,26 @@ void KateDocument::updateLines(int startLine, int endLine, int flags, int cursor
line = startLine;
ctxNum = 0;
if (line > 0) ctxNum = getTextLine(line - 1)->getContext();
do {
// kdDebug(13020)<<QString("**************Working on line: %1").arg(line)<<endl;
textLine = getTextLine(line);
if (textLine==0) kdDebug(13020)<<"****updateLines()>> error textLine==0"<<endl;
if (line <= endLine && line != cursorY) {
if (flags & KateView::cfRemoveSpaces) textLine->removeSpaces();
updateMaxLength(textLine);
}
endCtx = textLine->getContext();
-// qDebug("DOHIGHLIGHT");
-
+// odebug << "DOHIGHLIGHT" << oendl;
+
ctxNum = m_highlight->doHighlight(ctxNum,textLine);
textLine->setContext(ctxNum);
line++;
} while ((buffer->line(line)!=0) && (line <= endLine || endCtx != ctxNum));
// kdDebug(13020)<<"updateLines :: while loop left"<<endl;
tagLines(startLine, line - 1);
}
void KateDocument::updateMaxLength(TextLine::Ptr &textLine) {
int len;
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.cpp b/noncore/apps/tinykate/libkate/document/katehighlight.cpp
index 0d2c283..539d356 100644
--- a/noncore/apps/tinykate/libkate/document/katehighlight.cpp
+++ b/noncore/apps/tinykate/libkate/document/katehighlight.cpp
@@ -1,53 +1,57 @@
/*
Copyright (C) 1998, 1999 Jochen Wilhelmy
digisnap@cs.tu-berlin.de
- (C) 2002, 2001 The Kate Team <kwrite-devel@kde.org>
- (C) 2002 Joseph Wenninger <jowenn@kde.org>
+ (C) 2002, 2001 The Kate Team <kwrite-devel@kde.org>
+ (C) 2002 Joseph Wenninger <jowenn@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-#include <string.h>
-
-#include <qtextstream.h>
-#include <qpe/config.h>
-#include <kglobal.h>
-//#include <kinstance.h>
-//#include <kmimemagic.h>
-#include <klocale.h>
-//#include <kregexp.h>
-#include <kglobalsettings.h>
-#include <kdebug.h>
-#include <kstddirs.h>
-
#include "katehighlight.h"
-
-
#include "katetextline.h"
#include "katedocument.h"
#include "katesyntaxdocument.h"
+#include "kglobal.h"
+//#include "kinstance.h"
+//#include "kmimemagic.h"
+#include "klocale.h"
+//#include "kregexp.h"
+#include "kglobalsettings.h"
+#include "kdebug.h"
+#include "kstddirs.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+#include <qpe/config.h>
+
+/* QT */
+#include <qtextstream.h>
+
+/* STD */
+#include <string.h>
+
HlManager *HlManager::s_pSelf = 0;
enum Item_styles { dsNormal,dsKeyword,dsDataType,dsDecVal,dsBaseN,dsFloat,dsChar,dsString,dsComment,dsOthers};
static bool trueBool = true;
static QString stdDeliminator = QString ("!%&()*+,-./:;<=>?[]^{|}~ \t\\");
int getDefStyleNum(QString name)
{
if (name=="dsNormal") return dsNormal;
if (name=="dsKeyword") return dsKeyword;
@@ -111,26 +115,26 @@ const QChar *Hl2CharDetect::checkHgl(const QChar *str, int len, bool) {
HlStringDetect::HlStringDetect(int attribute, int context, const QString &s, bool inSensitive)
: HlItem(attribute, context), str(inSensitive ? s.upper():s), _inSensitive(inSensitive) {
}
HlStringDetect::~HlStringDetect() {
}
const QChar *HlStringDetect::checkHgl(const QChar *s, int len, bool) {
if (!_inSensitive) {if (memcmp(s, str.unicode(), str.length()*sizeof(QChar)) == 0) return s + str.length();}
else
{
- QString tmp=QString(s,str.length()).upper();
- if (tmp==str) return s+str.length();
+ QString tmp=QString(s,str.length()).upper();
+ if (tmp==str) return s+str.length();
}
return 0L;
}
HlRangeDetect::HlRangeDetect(int attribute, int context, QChar ch1, QChar ch2)
: HlItem(attribute,context) {
sChar1 = ch1;
sChar2 = ch2;
}
const QChar *HlRangeDetect::checkHgl(const QChar *s, int len, bool) {
@@ -204,28 +208,28 @@ HlInt::HlInt(int attribute, int context)
: HlItem(attribute,context) {
}
const QChar *HlInt::checkHgl(const QChar *str, int len, bool) {
const QChar *s,*s1;
s = str;
while (s->isDigit()) s++;
if (s > str)
{
if (subItems)
{
- for (HlItem *it=subItems->first();it;it=subItems->next())
+ for (HlItem *it=subItems->first();it;it=subItems->next())
{
s1=it->checkHgl(s, len, false);
- if (s1) return s1;
+ if (s1) return s1;
}
}
return s;
}
return 0L;
}
HlFloat::HlFloat(int attribute, int context)
: HlItem(attribute,context) {
}
const QChar *HlFloat::checkHgl(const QChar *s, int len, bool) {
@@ -239,32 +243,32 @@ const QChar *HlFloat::checkHgl(const QChar *s, int len, bool) {
}
if (p = (*s == '.')) {
s++;
while (s->isDigit()) {
s++;
b = true;
}
}
if (!b) return 0L;
if ((*s&0xdf) == 'E') s++;
else
if (!p) return 0L;
- else
- {
+ else
+ {
if (subItems)
{
- for (HlItem *it=subItems->first();it;it=subItems->next())
+ for (HlItem *it=subItems->first();it;it=subItems->next())
{
s1=it->checkHgl(s, len, false);
- if (s1) return s1;
+ if (s1) return s1;
}
}
return s;
}
if ((*s == '-')||(*s =='+')) s++;
b = false;
while (s->isDigit()) {
s++;
b = true;
}
if (b)
{
@@ -336,25 +340,25 @@ HlCHex::HlCHex(int attribute, int 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;
+ 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;
@@ -391,38 +395,38 @@ HlRegExpr::HlRegExpr(int attribute, int context,QString regexp)
if(!handlesLinestart) regexp.prepend("^");
Expr=new QRegExp3(regexp);
}
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());
+ 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;
@@ -612,25 +616,25 @@ int Highlight::doHighlight(int ctxNum, TextLine *textLine)
bool found = false;
while (z < len)
{
found = false;
for (item = context->items.first(); item != 0L; item = context->items.next())
{
if (item->startEnable(lastChar))
{
s2 = item->checkHgl(s1, len-z, z==0);
if (s2 > s1)
{
- qDebug("An item has been detected");
+ odebug << "An item has been detected" << oendl;
textLine->setAttribs(item->attr,s1 - str,s2 - str);
ctxNum = item->ctx;
context = contextList[ctxNum];
z = z + s2 - s1 - 1;
s1 = s2 - 1;
found = true;
break;
}
}
}
// nothing found: set attribute of one char
@@ -844,54 +848,54 @@ void Highlight::done()
* input: none
*************
* output: ItemDataList &list :A reference to the internal
list containing the parsed
default config
*************
* return value: none
*******************************************************************************************/
void Highlight::createItemData(ItemDataList &list)
{
- qDebug("Highlight::createItemData");
+ odebug << "Highlight::createItemData" << oendl;
// If no highlighting is selected we need only one default.
if (noHl)
{
list.append(new ItemData(I18N_NOOP("Normal Text"), dsNormal));
return;
}
QString color;
QString selColor;
QString bold;
QString italic;
// If the internal list isn't already available read the config file
if (internalIDList.count()==0)
{
//if all references to the list are destried the contents will also be deleted
internalIDList.setAutoDelete(true);
syntaxContextData *data;
- qDebug("Trying to read itemData section");
+ odebug << "Trying to read itemData section" << oendl;
//Tell the syntax document class which file we want to parse and which data group
HlManager::self()->syntax->setIdentifier(identifier);
data=HlManager::self()->syntax->getGroupInfo("highlighting","itemData");
//begin with the real parsing
while (HlManager::self()->syntax->nextGroup(data))
{
- qDebug("Setting up one itemData element");
+ odebug << "Setting up one itemData element" << oendl;
// read all attributes
color=HlManager::self()->syntax->groupData(data,QString("color"));
selColor=HlManager::self()->syntax->groupData(data,QString("selColor"));
bold=HlManager::self()->syntax->groupData(data,QString("bold"));
italic=HlManager::self()->syntax->groupData(data,QString("italic"));
//check if the user overrides something
if ( (!color.isEmpty()) && (!selColor.isEmpty()) && (!bold.isEmpty()) && (!italic.isEmpty()))
{
//create a user defined style
internalIDList.append(new ItemData(
HlManager::self()->syntax->groupData(data,QString("name")).simplifyWhiteSpace(),
getDefStyleNum(HlManager::self()->syntax->groupData(data,QString("defStyleNum"))),
@@ -924,30 +928,30 @@ void Highlight::createItemData(ItemDataList &list)
* input: QString &name :the attribute name to lookup
* ItemDataList &iDl :the list containing all
* available attributes
*************
* output: none
*************
* return value: int :The index of the attribute
* or 0
*******************************************************************************************/
int Highlight::lookupAttrName(const QString& name, ItemDataList &iDl)
{
- for (int i=0;i<iDl.count();i++)
- {
- if (iDl.at(i)->name==name) return i;
- }
- kdDebug(13010)<<"Couldn't resolve itemDataName"<<endl;
- return 0;
+ for (int i=0;i<iDl.count();i++)
+ {
+ if (iDl.at(i)->name==name) return i;
+ }
+ kdDebug(13010)<<"Couldn't resolve itemDataName"<<endl;
+ return 0;
}
/*******************************************************************************************
Highlight - createHlItem
This function is a helper for makeContextList. It parses the xml file for
information, how single or multi line comments are marked
* input: syntaxContextData *data : Data about the item read from
* the xml file
* ItemDataList &iDl : List of all available itemData
* entries. Needed for attribute
@@ -1068,29 +1072,29 @@ void Highlight::readCommentConfig()
cslStart = "";
HlManager::self()->syntax->setIdentifier(identifier);
syntaxContextData *data=HlManager::self()->syntax->getGroupInfo("general","comment");
if (data)
{
// kdDebug(13010)<<"COMMENT DATA FOUND"<<endl;
while (HlManager::self()->syntax->nextGroup(data))
{
if (HlManager::self()->syntax->groupData(data,"name")=="singleLine")
- cslStart=HlManager::self()->syntax->groupData(data,"start");
- if (HlManager::self()->syntax->groupData(data,"name")=="multiLine")
+ cslStart=HlManager::self()->syntax->groupData(data,"start");
+ if (HlManager::self()->syntax->groupData(data,"name")=="multiLine")
{
- cmlStart=HlManager::self()->syntax->groupData(data,"start");
- cmlEnd=HlManager::self()->syntax->groupData(data,"end");
+ cmlStart=HlManager::self()->syntax->groupData(data,"start");
+ cmlEnd=HlManager::self()->syntax->groupData(data,"end");
}
}
HlManager::self()->syntax->freeGroupInfo(data);
}
}
/*******************************************************************************************
Highlight - readGlobalKeyWordConfig
This function is a helper for makeContextList. It parses the xml file for
information, if keywords should be treated case(in)sensitive and creates the keyword
delimiter list. Which is the default list, without any given weak deliminiators
@@ -1103,46 +1107,46 @@ void Highlight::readCommentConfig()
*******************************************************************************************/
void Highlight::readGlobalKeywordConfig()
{
// Tell the syntax document class which file we want to parse
HlManager::self()->syntax->setIdentifier(identifier);
// Get the keywords config entry
syntaxContextData * data=HlManager::self()->syntax->getConfig("general","keywords");
if (data)
{
- kdDebug(13010)<<"Found global keyword config"<<endl;
+ kdDebug(13010)<<"Found global keyword config"<<endl;
if (HlManager::self()->syntax->groupItemData(data,QString("casesensitive"))!="0")
- casesensitive=true; else {casesensitive=false; kdDebug(13010)<<"Turning on case insensitiveness"<<endl;}
+ casesensitive=true; else {casesensitive=false; kdDebug(13010)<<"Turning on case insensitiveness"<<endl;}
//get the weak deliminators
weakDeliminator=(!HlManager::self()->syntax->groupItemData(data,QString("weakDeliminator")));
// remove any weakDelimitars (if any) from the default list and store this list.
int f;
for (int s=0; s < weakDeliminator.length(); s++)
{
f = 0;
f = deliminator.find (weakDeliminator[s]);
if (f > -1)
deliminator.remove (f, 1);
}
deliminatorChars = deliminator.unicode();
deliminatorLen = deliminator.length();
- HlManager::self()->syntax->freeGroupInfo(data);
+ HlManager::self()->syntax->freeGroupInfo(data);
}
else
{
//Default values
casesensitive=true;
weakDeliminator=QString("");
}
}
/*******************************************************************************************
Highlight - makeContextList
@@ -1195,43 +1199,43 @@ void Highlight::makeContextList()
// END - Translation of the attribute parameter
contextList[i]=new HlContext(
attr,
(HlManager::self()->syntax->groupData(data,QString("lineEndContext"))).toInt(),
(HlManager::self()->syntax->groupData(data,QString("lineBeginContext"))).isEmpty()?-1:
(HlManager::self()->syntax->groupData(data,QString("lineBeginContext"))).toInt());
//Let's create all items for the context
while (HlManager::self()->syntax->nextItem(data))
{
-// kdDebug(13010)<< "In make Contextlist: Item:"<<endl;
- c=createHlItem(data,iDl);
- if (c)
- {
+// kdDebug(13010)<< "In make Contextlist: Item:"<<endl;
+ c=createHlItem(data,iDl);
+ if (c)
+ {
contextList[i]->items.append(c);
// Not supported completely atm and only one level. Subitems.(all have to be matched to at once)
- datasub=HlManager::self()->syntax->getSubItems(data);
- bool tmpbool;
- if (tmpbool=HlManager::self()->syntax->nextItem(datasub))
- {
+ datasub=HlManager::self()->syntax->getSubItems(data);
+ bool tmpbool;
+ if (tmpbool=HlManager::self()->syntax->nextItem(datasub))
+ {
c->subItems=new QList<HlItem>;
- for (;tmpbool;tmpbool=HlManager::self()->syntax->nextItem(datasub))
+ for (;tmpbool;tmpbool=HlManager::self()->syntax->nextItem(datasub))
c->subItems->append(createHlItem(datasub,iDl));
}
- HlManager::self()->syntax->freeGroupInfo(datasub);
+ HlManager::self()->syntax->freeGroupInfo(datasub);
// end of sublevel
- }
-// kdDebug(13010)<<"Last line in loop"<<endl;
+ }
+// kdDebug(13010)<<"Last line in loop"<<endl;
}
i++;
}
}
HlManager::self()->syntax->freeGroupInfo(data);
}
HlManager::HlManager() : QObject(0L)
{
@@ -1303,34 +1307,34 @@ int HlManager::wildcardFind(const QString &fileName) {
}
return -1;
}
int HlManager::makeAttribs(Highlight *highlight, Attribute *a, int maxAttribs) {
ItemStyleList defaultStyleList;
ItemStyle *defaultStyle;
ItemDataList itemDataList;
ItemData *itemData;
int nAttribs, z;
- qDebug("HlManager::makeAttribs");
+ odebug << "HlManager::makeAttribs" << oendl;
defaultStyleList.setAutoDelete(true);
getDefaults(defaultStyleList);
// itemDataList.setAutoDelete(true);
highlight->getItemDataList(itemDataList);
nAttribs = itemDataList.count();
for (z = 0; z < nAttribs; z++) {
- qDebug("HlManager::makeAttribs: createing one attribute definition");
+ odebug << "HlManager::makeAttribs: createing one attribute definition" << oendl;
itemData = itemDataList.at(z);
if (itemData->defStyle) {
// default style
defaultStyle = defaultStyleList.at(itemData->defStyleNum);
a[z].col = defaultStyle->col;
a[z].selCol = defaultStyle->selCol;
a[z].bold = defaultStyle->bold;
a[z].italic = defaultStyle->italic;
} else {
// custom style
a[z].col = itemData->col;
a[z].selCol = itemData->selCol;
@@ -1406,25 +1410,25 @@ void HlManager::getDefaults(ItemStyleList &list) {
i->selCol.setRgb(selCol);
}
}
*/
}
void HlManager::setDefaults(ItemStyleList &list) {
KateConfig *config;
int z;
ItemStyle *i;
char s[64];
#warning fixme
-/*
+/*
config = KateFactory::instance()->config();
config->setGroup("Default Item Styles");
for (z = 0; z < defaultStyles(); z++) {
i = list.at(z);
sprintf(s,"%X,%X,%d,%d",i->col.rgb(),i->selCol.rgb(),i->bold, i->italic);
config->writeEntry(defaultStyleName(z),s);
}
*/
emit changed();
}
diff --git a/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp b/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp
index 6059e9b..9fa4452 100644
--- a/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp
+++ b/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp
@@ -7,48 +7,53 @@
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "katesyntaxdocument.h"
-#include <kateconfig.h>
+#include "kateconfig.h"
+#include "kdebug.h"
+#include "kstddirs.h"
+#include "klocale.h"
+#include "kmessagebox.h"
+#include "kglobal.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+#include <qpe/qpeapplication.h>
+
+/* QT */
#include <qfile.h>
-#include <kdebug.h>
-#include <kstddirs.h>
-#include <klocale.h>
-#include <kmessagebox.h>
#include <qstringlist.h>
-#include <kglobal.h>
-#include <qpe/qpeapplication.h>
#include <qdir.h>
SyntaxDocument::SyntaxDocument()
{
m_root=0;
currentFile="";
setupModeList();
}
void SyntaxDocument::setIdentifier(const QString& identifier)
{
#warning FIXME delete m_root;
m_root=Opie::Core::XMLElement::load(identifier);
if (!m_root) KMessageBox::error( 0L, i18n("Can't open %1").arg(identifier) );
-
+
}
SyntaxDocument::~SyntaxDocument()
{
}
void SyntaxDocument::setupModeList(bool force)
{
if (myModeList.count() > 0) return;
KateConfig *config=KGlobal::config();
@@ -67,39 +72,39 @@ void SyntaxDocument::setupModeList(bool force)
{
config->setGroup(Group);
syntaxModeListItem *mli=new syntaxModeListItem;
mli->name = config->readEntry("name","");
mli->section = config->readEntry("section","");
mli->mimetype = config->readEntry("mimetype","");
mli->extension = config->readEntry("extension","");
mli->identifier = path+*it;
myModeList.append(mli);
}
else
{
- qDebug("Found a description file:"+path+(*it));
+ odebug << "Found a description file:"+path+(*it) << oendl;
setIdentifier(path+(*it));
Opie::Core::XMLElement *e=m_root;
if (e)
{
- e=e->firstChild();
- qDebug(e->tagName());
+ e=e->firstChild();
+ odebug << e->tagName() << oendl;
if (e->tagName()=="language")
{
syntaxModeListItem *mli=new syntaxModeListItem;
mli->name = e->attribute("name");
mli->section = e->attribute("section");
mli->mimetype = e->attribute("mimetype");
mli->extension = e->attribute("extensions");
- qDebug(QString("valid description for: %1/%2").arg(mli->section).arg(mli->name));
+ odebug << QString("valid description for: %1/%2").arg(mli->section).arg(mli->name) << oendl;
if (mli->section.isEmpty())
mli->section=i18n("Other");
mli->identifier = path+(*it);
config->setGroup(Group);
config->writeEntry("name",mli->name);
config->writeEntry("section",mli->section);
config->writeEntry("mimetype",mli->mimetype);
config->writeEntry("extension",mli->extension);
myModeList.append(mli);
}
}
@@ -171,27 +176,27 @@ QString SyntaxDocument::groupData( syntaxContextData* data,QString name)
return QString();
}
void SyntaxDocument::freeGroupInfo( syntaxContextData* data)
{
if (data)
delete data;
}
syntaxContextData* SyntaxDocument::getSubItems(syntaxContextData* data)
{
syntaxContextData *retval=new syntaxContextData;
- retval->parent=0;
- retval->currentGroup=0;
- retval->item=0;
+ retval->parent=0;
+ retval->currentGroup=0;
+ retval->item=0;
if (data != 0)
{
retval->parent=data->currentGroup;
retval->currentGroup=data->item;
retval->item=0;
}
return retval;
}
syntaxContextData* SyntaxDocument::getConfig(const QString& mainGroupName, const QString &Config)
{
@@ -203,26 +208,26 @@ syntaxContextData* SyntaxDocument::getConfig(const QString& mainGroupName, const
if (e->tagName().compare(mainGroupName)==0 )
{
Opie::Core::XMLElement *e1=e->firstChild();
while (e1)
{
kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl;
if (e1->tagName()==Config)
{
syntaxContextData *data=new ( syntaxContextData);
- data->currentGroup=0;
- data->parent=0;
+ data->currentGroup=0;
+ data->parent=0;
data->item=e1;
return data;
}
e1=e1->nextChild();
}
kdDebug(13010) << "WARNING :returning null 3"<< endl;
return 0;
}
e=e->nextChild();
@@ -245,26 +250,26 @@ syntaxContextData* SyntaxDocument::getGroupInfo(const QString& mainGroupName, co
if (e->tagName().compare(mainGroupName)==0 )
{
Opie::Core::XMLElement *e1=e->firstChild();
while (e1)
{
kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl;
if (e1->tagName()==group+"s")
{
syntaxContextData *data=new ( syntaxContextData);
data->parent=e1;
- data->currentGroup=0;
- data->item=0;
+ data->currentGroup=0;
+ data->item=0;
return data;
}
e1=e1->nextChild();
}
kdDebug(13010) << "WARNING : getGroupInfo returning null :1 " << endl;
return 0;
}
e=e->nextChild();
}
@@ -275,32 +280,32 @@ syntaxContextData* SyntaxDocument::getGroupInfo(const QString& mainGroupName, co
QStringList& SyntaxDocument::finddata(const QString& mainGroup,const QString& type,bool clearList)
{
Opie::Core::XMLElement *e = m_root->firstChild();
if (clearList)
m_data.clear();
for(e=e->firstChild(); e; e=e->nextChild())
{
if (e->tagName()==mainGroup)
{
- for (Opie::Core::XMLElement *e1=e->firstChild();e1;e1=e1->nextChild())
- {
- if (e1->tagName()!="list") continue;
-
- if (e1->attribute("name")==type)
- {
- for (Opie::Core::XMLElement *e2=e1->firstChild();e2;e2=e2->nextChild())
- {
- qDebug("FOUND A LIST ENTRY("+e2->tagName()+"):"+e2->firstChild()->value());
- m_data+=e2->firstChild()->value().stripWhiteSpace();
- }
- break;
- }
+ for (Opie::Core::XMLElement *e1=e->firstChild();e1;e1=e1->nextChild())
+ {
+ if (e1->tagName()!="list") continue;
+
+ if (e1->attribute("name")==type)
+ {
+ for (Opie::Core::XMLElement *e2=e1->firstChild();e2;e2=e2->nextChild())
+ {
+ odebug << "FOUND A LIST ENTRY("+e2->tagName()+"):"+e2->firstChild()->value() << oendl;
+ m_data+=e2->firstChild()->value().stripWhiteSpace();
+ }
+ break;
+ }
}
break;
}
}
return m_data;
}