summaryrefslogtreecommitdiff
path: root/noncore/apps/tinykate/libkate/document/katedocument.h
Unidiff
Diffstat (limited to 'noncore/apps/tinykate/libkate/document/katedocument.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/document/katedocument.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.h b/noncore/apps/tinykate/libkate/document/katedocument.h
index 9d8ec6a..969be87 100644
--- a/noncore/apps/tinykate/libkate/document/katedocument.h
+++ b/noncore/apps/tinykate/libkate/document/katedocument.h
@@ -1,33 +1,33 @@
1/*************************************************************************** 1/***************************************************************************
2 katedocument.h - description 2 katedocument.h - description
3 ------------------- 3 -------------------
4 begin : Mon Jan 15 2001 4 begin : Mon Jan 15 2001
5 copyright : (C) 2001 by Christoph "Crossfire" Cullmann 5 copyright : (C) 2001 by Christoph "Crossfire" Cullmann
6 (C) 2002 by Joseph Wenninger 6 (C) 2002 by Joseph Wenninger
7 email : crossfire@babylon2k.de 7 email : crossfire@babylon2k.de
8 jowenn@kde.org 8 jowenn@kde.org
9 9
10***************************************************************************/ 10***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * * 13 * *
14 * This program is free software; you can redistribute it and/or modify * 14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by * 15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; either version 2 of the License, or * 16 * the Free Software Foundation; either version 2 of the License, or *
17 * (at your option) any later version. * 17 * (at your option) any later version. *
18 * * 18 * *
19 ***************************************************************************/ 19 ***************************************************************************/
20 20
21/* 21/*
22 Copyright (C) 1998, 1999 Jochen Wilhelmy 22 Copyright (C) 1998, 1999 Jochen Wilhelmy
23 digisnap@cs.tu-berlin.de 23 digisnap@cs.tu-berlin.de
24 24
25 This library is free software; you can redistribute it and/or 25 This library is free software; you can redistribute it and/or
26 modify it under the terms of the GNU Library General Public 26 modify it under the terms of the GNU Library General Public
27 License as published by the Free Software Foundation; either 27 License as published by the Free Software Foundation; either
28 version 2 of the License, or (at your option) any later version. 28 version 2 of the License, or (at your option) any later version.
29 29
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.
@@ -55,49 +55,49 @@
55#include "katebuffer.h" 55#include "katebuffer.h"
56#include "katetextline.h" 56#include "katetextline.h"
57 57
58 58
59#include <qptrdict.h> 59#include <qptrdict.h>
60 60
61class KateCmd; 61class KateCmd;
62 62
63class CachedFontMetrics : public QFontMetrics { 63class CachedFontMetrics : public QFontMetrics {
64private: 64private:
65 short *warray[256]; 65 short *warray[256];
66public: 66public:
67 CachedFontMetrics(const QFont& f) : QFontMetrics(f) { 67 CachedFontMetrics(const QFont& f) : QFontMetrics(f) {
68 for (int i=0; i<256; i++) warray[i]=0; 68 for (int i=0; i<256; i++) warray[i]=0;
69 } 69 }
70 ~CachedFontMetrics() { 70 ~CachedFontMetrics() {
71 for (int i=0; i<256; i++) 71 for (int i=0; i<256; i++)
72 if (warray[i]) delete[] warray[i]; 72 if (warray[i]) delete[] warray[i];
73 } 73 }
74 int width(QChar c) { 74 int width(QChar c) {
75 uchar cell=c.cell(); 75 uchar cell=c.cell();
76 uchar row=c.row(); 76 uchar row=c.row();
77 short *wa=warray[row]; 77 short *wa=warray[row];
78 if (!wa) { 78 if (!wa) {
79 // qDebug("create row: %d",row); 79 // odebug << "create row: " << row << oendl;
80 wa=warray[row]=new short[256]; 80 wa=warray[row]=new short[256];
81 for (int i=0; i<256; i++) wa[i]=-1; 81 for (int i=0; i<256; i++) wa[i]=-1;
82 } 82 }
83 if (wa[cell]<0) wa[cell]=(short) QFontMetrics::width(c); 83 if (wa[cell]<0) wa[cell]=(short) QFontMetrics::width(c);
84 return (int)wa[cell]; 84 return (int)wa[cell];
85 } 85 }
86 int width(QString s) { return QFontMetrics::width(s); } 86 int width(QString s) { return QFontMetrics::width(s); }
87}; 87};
88 88
89class Attribute { 89class Attribute {
90 public: 90 public:
91 Attribute() { ; }; 91 Attribute() { ; };
92 92
93 QColor col; 93 QColor col;
94 QColor selCol; 94 QColor selCol;
95 bool bold; 95 bool bold;
96 bool italic; 96 bool italic;
97}; 97};
98 98
99class KateAction { 99class KateAction {
100 public: 100 public:
101 enum Action {replace, wordWrap, wordUnWrap, newLine, delLine, 101 enum Action {replace, wordWrap, wordUnWrap, newLine, delLine,
102 insLine, killLine};//, doubleLine, removeLine}; 102 insLine, killLine};//, doubleLine, removeLine};
103 103
@@ -158,49 +158,49 @@ class KateDocument: public Kate::Document
158 friend class KateIconBorder; 158 friend class KateIconBorder;
159 159
160 public: 160 public:
161 KateDocument(bool bSingleViewMode=false, bool bBrowserView=false, QWidget *parentWidget = 0, const char *widgetName = 0, QObject * = 0, const char * = 0); 161 KateDocument(bool bSingleViewMode=false, bool bBrowserView=false, QWidget *parentWidget = 0, const char *widgetName = 0, QObject * = 0, const char * = 0);
162 ~KateDocument(); 162 ~KateDocument();
163 163
164 protected: 164 protected:
165 QFont myFont, myFontBold, myFontItalic, myFontBI; 165 QFont myFont, myFontBold, myFontItalic, myFontBI;
166 CachedFontMetrics myFontMetrics, myFontMetricsBold, myFontMetricsItalic, myFontMetricsBI; 166 CachedFontMetrics myFontMetrics, myFontMetricsBold, myFontMetricsItalic, myFontMetricsBI;
167 167
168 public: 168 public:
169 void setFont (QFont font); 169 void setFont (QFont font);
170 QFont getFont () { return myFont; }; 170 QFont getFont () { return myFont; };
171 CachedFontMetrics getFontMetrics () { return myFontMetrics; }; 171 CachedFontMetrics getFontMetrics () { return myFontMetrics; };
172 172
173 virtual bool saveFile(); 173 virtual bool saveFile();
174 174
175 virtual KTextEditor::View *createView( QWidget *parent, const char *name ); 175 virtual KTextEditor::View *createView( QWidget *parent, const char *name );
176 virtual QString textLine( int line ) const; 176 virtual QString textLine( int line ) const;
177 177
178 virtual void insertLine( const QString &s, int line = -1 ); 178 virtual void insertLine( const QString &s, int line = -1 );
179 179
180 void insert_Line(const QString& s,int line=-1, bool update=true); 180 void insert_Line(const QString& s,int line=-1, bool update=true);
181 void remove_Line(int line,bool update=true); 181 void remove_Line(int line,bool update=true);
182 void replaceLine(const QString& s,int line=-1); 182 void replaceLine(const QString& s,int line=-1);
183 virtual void insertAt( const QString &s, int line, int col, bool mark = FALSE ); 183 virtual void insertAt( const QString &s, int line, int col, bool mark = FALSE );
184 virtual void removeLine( int line ); 184 virtual void removeLine( int line );
185 virtual int length() const; 185 virtual int length() const;
186 186
187 virtual void setSelection( int row_from, int col_from, int row_to, int col_t ); 187 virtual void setSelection( int row_from, int col_from, int row_to, int col_t );
188 virtual bool hasSelection() const; 188 virtual bool hasSelection() const;
189 virtual QString selection() const; 189 virtual QString selection() const;
190 190
191 // only to make part work, don't change it ! 191 // only to make part work, don't change it !
192 bool m_bSingleViewMode; 192 bool m_bSingleViewMode;
193 193
194// public interface 194// public interface
195 /** 195 /**
196 * gets the number of lines 196 * gets the number of lines
197 */ 197 */
198 virtual int numLines() const; 198 virtual int numLines() const;
199 199
200 /** 200 /**
201 * gets the last line number (numLines() -1) 201 * gets the last line number (numLines() -1)
202 */ 202 */
203 int lastLine() const {return numLines()-1;} 203 int lastLine() const {return numLines()-1;}
204 204
205 /** 205 /**
206 gets the given line 206 gets the given line
@@ -513,58 +513,58 @@ class KateDocument: public Kate::Document
513 void fileNameChanged (); 513 void fileNameChanged ();
514 514
515 public: 515 public:
516 //end of line settings 516 //end of line settings
517 enum Eol_settings {eolUnix=0,eolDos=1,eolMacintosh=2}; 517 enum Eol_settings {eolUnix=0,eolDos=1,eolMacintosh=2};
518 518
519 // for the DCOP interface 519 // for the DCOP interface
520 public: 520 public:
521 void open (const QString &name=0); 521 void open (const QString &name=0);
522 522
523 public: 523 public:
524 // wrap the text of the document at the column col 524 // wrap the text of the document at the column col
525 void wrapText (uint col); 525 void wrapText (uint col);
526 526
527 public slots: 527 public slots:
528 void applyWordWrap (); 528 void applyWordWrap ();
529 529
530 private: 530 private:
531 531
532 class KateDocPrivate 532 class KateDocPrivate
533 { 533 {
534 public: 534 public:
535 bool hlSetByUser; 535 bool hlSetByUser;
536 }; 536 };
537 537
538 538
539// BCI: Add a real d-pointer in the next BIC release 539// BCI: Add a real d-pointer in the next BIC release
540static QPtrDict<KateDocPrivate>* d_ptr; 540static QPtrDict<KateDocPrivate>* d_ptr;
541static void cleanup_d_ptr() 541static void cleanup_d_ptr()
542 { 542 {
543 delete d_ptr; 543 delete d_ptr;
544 } 544 }
545 545
546KateDocPrivate* d( const KateDocument* foo ) 546KateDocPrivate* d( const KateDocument* foo )
547 { 547 {
548 if ( !d_ptr ) { 548 if ( !d_ptr ) {
549 d_ptr = new QPtrDict<KateDocPrivate>; 549 d_ptr = new QPtrDict<KateDocPrivate>;
550 //qAddPostRoutine( cleanup_d_ptr ); 550 //qAddPostRoutine( cleanup_d_ptr );
551 } 551 }
552 KateDocPrivate* ret = d_ptr->find( (void*) foo ); 552 KateDocPrivate* ret = d_ptr->find( (void*) foo );
553 if ( ! ret ) { 553 if ( ! ret ) {
554 ret = new KateDocPrivate; 554 ret = new KateDocPrivate;
555 d_ptr->replace( (void*) foo, ret ); 555 d_ptr->replace( (void*) foo, ret );
556 } 556 }
557 return ret; 557 return ret;
558 } 558 }
559 559
560void delete_d( const KateDocument* foo ) 560void delete_d( const KateDocument* foo )
561 { 561 {
562 if ( d_ptr ) 562 if ( d_ptr )
563 d_ptr->remove( (void*) foo ); 563 d_ptr->remove( (void*) foo );
564 } 564 }
565 565
566}; 566};
567 567
568#endif 568#endif
569 569
570 570