summaryrefslogtreecommitdiff
path: root/noncore/apps/tinykate/libkate/document/katedocument.cpp
Unidiff
Diffstat (limited to 'noncore/apps/tinykate/libkate/document/katedocument.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/document/katedocument.cpp53
1 files changed, 27 insertions, 26 deletions
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
@@ -30,62 +30,63 @@
30 This library is distributed in the hope that it will be useful, 30 This library is distributed in the hope that it will be useful,
31 but WITHOUT ANY WARRANTY; without even the implied warranty of 31 but WITHOUT ANY WARRANTY; without even the implied warranty of
32 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 32 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33 Library General Public License for more details. 33 Library General Public License for more details.
34 34
35 You should have received a copy of the GNU Library General Public License 35 You should have received a copy of the GNU Library General Public License
36 along with this library; see the file COPYING.LIB. If not, write to 36 along with this library; see the file COPYING.LIB. If not, write to
37 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 37 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
38 Boston, MA 02111-1307, USA. 38 Boston, MA 02111-1307, USA.
39*/ 39*/
40 40
41#include "katedocument.h" 41#include "katedocument.h"
42#include "kmessagebox.h"
43#include "kglobal.h"
42 44
45//#include "kcharsets.h"
46#include "kdebug.h"
47//#include "kinstance.h"
43 48
44#include <qfileinfo.h> 49#include "kglobalsettings.h"
45#include <qdatetime.h> 50//#include "kaction.h"
51//#include "kstdaction.h"
46 52
47#include <kmessagebox.h> 53#include "../view/kateview.h"
48#include <qpe/config.h> 54#include "katebuffer.h"
49#include <qstring.h> 55#include "katetextline.h"
50 56
51#include <sys/time.h> 57#include "katecmd.h"
52#include <unistd.h>
53 58
54#include <stdio.h> 59/* OPIE */
60#include <opie2/odebug.h>
61#include <qpe/config.h>
55 62
63/* QT */
64#include <qfileinfo.h>
65#include <qdatetime.h>
66#include <qstring.h>
56#include <qtimer.h> 67#include <qtimer.h>
57#include <qobject.h> 68#include <qobject.h>
58#include <qapplication.h> 69#include <qapplication.h>
59#include <qclipboard.h> 70#include <qclipboard.h>
60#include <qfont.h> 71#include <qfont.h>
61#include <qpainter.h> 72#include <qpainter.h>
62#include <qfile.h> 73#include <qfile.h>
63#include <qtextstream.h> 74#include <qtextstream.h>
64#include <qtextcodec.h> 75#include <qtextcodec.h>
65#include <kglobal.h>
66
67//#include <kcharsets.h>
68#include <kdebug.h>
69//#include <kinstance.h>
70
71#include <kglobalsettings.h>
72//#include <kaction.h>
73//#include <kstdaction.h>
74
75#include "../view/kateview.h"
76#include "katebuffer.h"
77#include "katetextline.h"
78 76
79#include "katecmd.h" 77/* STD */
78#include <sys/time.h>
79#include <unistd.h>
80#include <stdio.h>
80 81
81KateAction::KateAction(Action a, PointStruc &cursor, int len, const QString &text) 82KateAction::KateAction(Action a, PointStruc &cursor, int len, const QString &text)
82 : action(a), cursor(cursor), len(len), text(text) { 83 : action(a), cursor(cursor), len(len), text(text) {
83} 84}
84 85
85KateActionGroup::KateActionGroup(PointStruc &aStart, int type) 86KateActionGroup::KateActionGroup(PointStruc &aStart, int type)
86 : start(aStart), action(0L), undoType(type) { 87 : start(aStart), action(0L), undoType(type) {
87} 88}
88 89
89KateActionGroup::~KateActionGroup() { 90KateActionGroup::~KateActionGroup() {
90 KateAction *current, *next; 91 KateAction *current, *next;
91 92
@@ -289,32 +290,32 @@ KateDocument::~KateDocument()
289 delete_d(this); 290 delete_d(this);
290} 291}
291 292
292void KateDocument::openURL(const QString &filename) 293void KateDocument::openURL(const QString &filename)
293{ 294{
294 295
295 m_file=filename; 296 m_file=filename;
296 fileInfo->setFile (m_file); 297 fileInfo->setFile (m_file);
297 setMTime(); 298 setMTime();
298 299
299 if (!fileInfo->exists() || !fileInfo->isReadable()) 300 if (!fileInfo->exists() || !fileInfo->isReadable())
300 { 301 {
301 qDebug("File doesn't exit or couldn't be read"); 302 odebug << "File doesn't exit or couldn't be read" << oendl;
302 return ; 303 return ;
303 } 304 }
304 305
305 buffer->clear(); 306 buffer->clear();
306#warning fixme 307#warning fixme
307// buffer->insertFile(0, m_file, KGlobal::charsets()->codecForName(myEncoding)); 308// buffer->insertFile(0, m_file, KGlobal::charsets()->codecForName(myEncoding));
308 qDebug("Telling buffer to open file"); 309 odebug << "Telling buffer to open file" << oendl;
309 buffer->insertFile(0, m_file, QTextCodec::codecForLocale()); 310 buffer->insertFile(0, m_file, QTextCodec::codecForLocale());
310 311
311 setMTime(); 312 setMTime();
312 313
313 if (myWordWrap) 314 if (myWordWrap)
314 wrapText (myWordWrapAt); 315 wrapText (myWordWrapAt);
315 316
316 int hl = hlManager->wildcardFind( m_file ); 317 int hl = hlManager->wildcardFind( m_file );
317 318
318 setHighlight(hl); 319 setHighlight(hl);
319 320
320 updateLines(); 321 updateLines();
@@ -674,25 +675,25 @@ void KateDocument::setHighlight(int n) {
674 } else { 675 } else {
675 if (m_highlight != 0L) m_highlight->release(); 676 if (m_highlight != 0L) m_highlight->release();
676 h->use(); 677 h->use();
677 m_highlight = h; 678 m_highlight = h;
678 makeAttribs(); 679 makeAttribs();
679 } 680 }
680 PreHighlightedTill=0; 681 PreHighlightedTill=0;
681 RequestPreHighlightTill=0; 682 RequestPreHighlightTill=0;
682 emit(highlightChanged()); 683 emit(highlightChanged());
683} 684}
684 685
685void KateDocument::makeAttribs() { 686void KateDocument::makeAttribs() {
686 qDebug("KateDocument::makeAttribs()"); 687 odebug << "KateDocument::makeAttribs()" << oendl;
687 m_numAttribs = hlManager->makeAttribs(m_highlight, m_attribs, maxAttribs); 688 m_numAttribs = hlManager->makeAttribs(m_highlight, m_attribs, maxAttribs);
688 updateFontData(); 689 updateFontData();
689 updateLines(); 690 updateLines();
690} 691}
691 692
692void KateDocument::updateFontData() { 693void KateDocument::updateFontData() {
693 int maxAscent, maxDescent; 694 int maxAscent, maxDescent;
694 int tabWidth; 695 int tabWidth;
695 KateView *view; 696 KateView *view;
696 697
697 maxAscent = myFontMetrics.ascent(); 698 maxAscent = myFontMetrics.ascent();
698 maxDescent = myFontMetrics.descent(); 699 maxDescent = myFontMetrics.descent();
@@ -1914,25 +1915,25 @@ void KateDocument::updateLines(int startLine, int endLine, int flags, int cursor
1914 line = startLine; 1915 line = startLine;
1915 ctxNum = 0; 1916 ctxNum = 0;
1916 if (line > 0) ctxNum = getTextLine(line - 1)->getContext(); 1917 if (line > 0) ctxNum = getTextLine(line - 1)->getContext();
1917 do { 1918 do {
1918// kdDebug(13020)<<QString("**************Working on line: %1").arg(line)<<endl; 1919// kdDebug(13020)<<QString("**************Working on line: %1").arg(line)<<endl;
1919 textLine = getTextLine(line); 1920 textLine = getTextLine(line);
1920 if (textLine==0) kdDebug(13020)<<"****updateLines()>> error textLine==0"<<endl; 1921 if (textLine==0) kdDebug(13020)<<"****updateLines()>> error textLine==0"<<endl;
1921 if (line <= endLine && line != cursorY) { 1922 if (line <= endLine && line != cursorY) {
1922 if (flags & KateView::cfRemoveSpaces) textLine->removeSpaces(); 1923 if (flags & KateView::cfRemoveSpaces) textLine->removeSpaces();
1923 updateMaxLength(textLine); 1924 updateMaxLength(textLine);
1924 } 1925 }
1925 endCtx = textLine->getContext(); 1926 endCtx = textLine->getContext();
1926// qDebug("DOHIGHLIGHT"); 1927// odebug << "DOHIGHLIGHT" << oendl;
1927 1928
1928 ctxNum = m_highlight->doHighlight(ctxNum,textLine); 1929 ctxNum = m_highlight->doHighlight(ctxNum,textLine);
1929 textLine->setContext(ctxNum); 1930 textLine->setContext(ctxNum);
1930 line++; 1931 line++;
1931 } while ((buffer->line(line)!=0) && (line <= endLine || endCtx != ctxNum)); 1932 } while ((buffer->line(line)!=0) && (line <= endLine || endCtx != ctxNum));
1932// kdDebug(13020)<<"updateLines :: while loop left"<<endl; 1933// kdDebug(13020)<<"updateLines :: while loop left"<<endl;
1933 tagLines(startLine, line - 1); 1934 tagLines(startLine, line - 1);
1934} 1935}
1935 1936
1936 1937
1937void KateDocument::updateMaxLength(TextLine::Ptr &textLine) { 1938void KateDocument::updateMaxLength(TextLine::Ptr &textLine) {
1938 int len; 1939 int len;