/*************************************************************************** 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