From e97a6da57804aa14907dec327fbae71bff9b383e Mon Sep 17 00:00:00 2001 From: jowenn Date: Sun, 10 Nov 2002 21:08:01 +0000 Subject: import of tiny kate. (saving not possible yet) --- (limited to 'noncore/apps/tinykate/libkate/document/katecmds.cpp') diff --git a/noncore/apps/tinykate/libkate/document/katecmds.cpp b/noncore/apps/tinykate/libkate/document/katecmds.cpp new file mode 100644 index 0000000..3647853 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/document/katecmds.cpp @@ -0,0 +1,278 @@ +/*************************************************************************** + katecmds.cpp - description + ------------------- + copyright : (C) 2001 by The Kate Team + (C) 2002 by Joseph Wenninger + email : kwrite-devel@kde.org + 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. * + * * + ***************************************************************************/ +#include "katecmds.h" +#include +#include +#include +#include "katedocument.h" +#include + +namespace KateCommands +{ + + +bool InsertTime::execCmd(QString cmd, KateView *view) +{ + if (cmd.left(5) == "time") + { + view->insertText(QTime::currentTime().toString()); + return true; + } + + return false; +} + +static void replace(QString &s, const QString &needle, const QString &with) +{ + int pos=0; + while (1) + { + pos=s.find(needle, pos); + if (pos==-1) break; + s.replace(pos, needle.length(), with); + pos+=with.length(); + } + +} + +// stolen from QString::replace +static void replace(QString &s, QRegExp3 &rx, const QString &with) +{ + if (s.isEmpty()) return; + int index = 0; + int slen = with.length(); + int len; + while (index < (int)s.length()) + { + index = rx.search(s, index); + len = rx.matchedLength(); + if ( index >= 0 ) + { + s.replace(index, len, with); + index += slen; + if (!len) + break; // Avoid infinite loop on 0-length matches, e.g. [a-z]* + } + else + break; + } +} + + + +static int backslashString(const QString &haystack, const QString &needle, int index) +{ + int len=haystack.length(); + int searchlen=needle.length(); + bool evenCount=true; + while (index=0) + { + rep.replace(index, 2, *i); + index+=(*i).length(); + } + } + + refnum++; + } + + textLine.replace(start, length, rep); + if (!repeat) break; + start+=rep.length(); + } + + replace(textLine, "\\\\", "\\"); + replace(textLine, "\\/", "/"); + + return textLine; +} + + +static void setLineText(KateView *view, int line, const QString &text) +{ +// view->doc()->removeLine(line); +// view->doc()->insertLine(text, line); + view->doc()->replaceLine(text,line); +} + +bool SedReplace::execCmd(QString cmd, KateView *view) +{ + kdDebug(13010)<<"SedReplace::execCmd()"<insertText(QString(buf)); + } + else + { // do the unicode thing + QChar c(number); + view->insertText(QString(&c, 1)); + } + + return true; +} + +bool Fifo::execCmd(QString cmd, KateView *view) +{ + +} + +} + +// vim: noet + -- cgit v0.9.0.2