Diffstat (limited to 'noncore/apps/tinykate/libkate/document/katedocument.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/tinykate/libkate/document/katedocument.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.cpp b/noncore/apps/tinykate/libkate/document/katedocument.cpp index f05e21a..0c742d7 100644 --- a/noncore/apps/tinykate/libkate/document/katedocument.cpp +++ b/noncore/apps/tinykate/libkate/document/katedocument.cpp | |||
@@ -75,193 +75,193 @@ | |||
75 | #include "../view/kateview.h" | 75 | #include "../view/kateview.h" |
76 | #include "katebuffer.h" | 76 | #include "katebuffer.h" |
77 | #include "katetextline.h" | 77 | #include "katetextline.h" |
78 | 78 | ||
79 | #include "katecmd.h" | 79 | #include "katecmd.h" |
80 | 80 | ||
81 | KateAction::KateAction(Action a, PointStruc &cursor, int len, const QString &text) | 81 | KateAction::KateAction(Action a, PointStruc &cursor, int len, const QString &text) |
82 | : action(a), cursor(cursor), len(len), text(text) { | 82 | : action(a), cursor(cursor), len(len), text(text) { |
83 | } | 83 | } |
84 | 84 | ||
85 | KateActionGroup::KateActionGroup(PointStruc &aStart, int type) | 85 | KateActionGroup::KateActionGroup(PointStruc &aStart, int type) |
86 | : start(aStart), action(0L), undoType(type) { | 86 | : start(aStart), action(0L), undoType(type) { |
87 | } | 87 | } |
88 | 88 | ||
89 | KateActionGroup::~KateActionGroup() { | 89 | KateActionGroup::~KateActionGroup() { |
90 | KateAction *current, *next; | 90 | KateAction *current, *next; |
91 | 91 | ||
92 | current = action; | 92 | current = action; |
93 | while (current) { | 93 | while (current) { |
94 | next = current->next; | 94 | next = current->next; |
95 | delete current; | 95 | delete current; |
96 | current = next; | 96 | current = next; |
97 | } | 97 | } |
98 | } | 98 | } |
99 | 99 | ||
100 | void KateActionGroup::insertAction(KateAction *a) { | 100 | void KateActionGroup::insertAction(KateAction *a) { |
101 | a->next = action; | 101 | a->next = action; |
102 | action = a; | 102 | action = a; |
103 | } | 103 | } |
104 | 104 | ||
105 | const char * KateActionGroup::typeName(int type) | 105 | const char * KateActionGroup::typeName(int type) |
106 | { | 106 | { |
107 | // return a short text description of the given undo group type suitable for a menu | 107 | // return a short text description of the given undo group type suitable for a menu |
108 | // not the lack of i18n's, the caller is expected to handle translation | 108 | // not the lack of i18n's, the caller is expected to handle translation |
109 | switch (type) { | 109 | switch (type) { |
110 | case ugPaste : return "Paste Text"; | 110 | case ugPaste : return "Paste Text"; |
111 | case ugDelBlock : return "Selection Overwrite"; | 111 | case ugDelBlock : return "Selection Overwrite"; |
112 | case ugIndent : return "Indent"; | 112 | case ugIndent : return "Indent"; |
113 | case ugUnindent : return "Unindent"; | 113 | case ugUnindent : return "Unindent"; |
114 | case ugComment : return "Comment"; | 114 | case ugComment : return "Comment"; |
115 | case ugUncomment : return "Uncomment"; | 115 | case ugUncomment : return "Uncomment"; |
116 | case ugReplace : return "Text Replace"; | 116 | case ugReplace : return "Text Replace"; |
117 | case ugSpell : return "Spell Check"; | 117 | case ugSpell : return "Spell Check"; |
118 | case ugInsChar : return "Typing"; | 118 | case ugInsChar : return "Typing"; |
119 | case ugDelChar : return "Delete Text"; | 119 | case ugDelChar : return "Delete Text"; |
120 | case ugInsLine : return "New Line"; | 120 | case ugInsLine : return "New Line"; |
121 | case ugDelLine : return "Delete Line"; | 121 | case ugDelLine : return "Delete Line"; |
122 | } | 122 | } |
123 | return ""; | 123 | return ""; |
124 | } | 124 | } |
125 | 125 | ||
126 | const int KateDocument::maxAttribs = 32; | 126 | const int KateDocument::maxAttribs = 32; |
127 | 127 | ||
128 | QStringList KateDocument::searchForList = QStringList(); | 128 | QStringList KateDocument::searchForList = QStringList(); |
129 | QStringList KateDocument::replaceWithList = QStringList(); | 129 | QStringList KateDocument::replaceWithList = QStringList(); |
130 | 130 | ||
131 | uint KateDocument::uniqueID = 0; | 131 | uint KateDocument::uniqueID = 0; |
132 | 132 | ||
133 | QPtrDict<KateDocument::KateDocPrivate>* KateDocument::d_ptr = 0; | 133 | QPtrDict<KateDocument::KateDocPrivate>* KateDocument::d_ptr = 0; |
134 | 134 | ||
135 | 135 | ||
136 | KateDocument::KateDocument(bool bSingleViewMode, bool bBrowserView, | 136 | KateDocument::KateDocument(bool bSingleViewMode, bool bBrowserView, |
137 | QWidget *parentWidget, const char *widgetName, | 137 | QWidget *parentWidget, const char *widgetName, |
138 | QObject *, const char *) | 138 | QObject *, const char *) |
139 | : Kate::Document (), | 139 | : Kate::Document (), |
140 | myFont(KGlobalSettings::generalFont()), myFontBold(KGlobalSettings::generalFont()), myFontItalic(KGlobalSettings::generalFont()), myFontBI(KGlobalSettings::generalFont()), | 140 | myFont(KGlobalSettings::generalFont()), myFontBold(KGlobalSettings::generalFont()), myFontItalic(KGlobalSettings::generalFont()), myFontBI(KGlobalSettings::generalFont()), |
141 | myFontMetrics (myFont), myFontMetricsBold (myFontBold), myFontMetricsItalic (myFontItalic), myFontMetricsBI (myFontBI), | 141 | myFontMetrics (myFont), myFontMetricsBold (myFontBold), myFontMetricsItalic (myFontItalic), myFontMetricsBI (myFontBI), |
142 | hlManager(HlManager::self ()) | 142 | hlManager(HlManager::self ()) |
143 | { | 143 | { |
144 | 144 | ||
145 | d(this)->hlSetByUser = false; | 145 | d(this)->hlSetByUser = false; |
146 | PreHighlightedTill=0; | 146 | PreHighlightedTill=0; |
147 | RequestPreHighlightTill=0; | 147 | RequestPreHighlightTill=0; |
148 | 148 | ||
149 | m_bSingleViewMode=bSingleViewMode; | 149 | m_bSingleViewMode=bSingleViewMode; |
150 | m_bBrowserView = bBrowserView; | 150 | m_bBrowserView = bBrowserView; |
151 | 151 | ||
152 | m_url = QString::null; | 152 | m_url = QString::null; |
153 | 153 | ||
154 | // NOTE: QFont::CharSet doesn't provide all the charsets KDE supports | 154 | // NOTE: QFont::CharSet doesn't provide all the charsets KDE supports |
155 | // (esp. it doesn't distinguish between UTF-8 and iso10646-1) | 155 | // (esp. it doesn't distinguish between UTF-8 and iso10646-1) |
156 | 156 | ||
157 | myEncoding = QString::fromLatin1(QTextCodec::codecForLocale()->name()); | 157 | myEncoding = QString::fromLatin1(QTextCodec::codecForLocale()->name()); |
158 | 158 | ||
159 | maxLength = -1; | 159 | maxLength = -1; |
160 | 160 | ||
161 | setFont (KGlobalSettings::generalFont()); | 161 | setFont (KGlobalSettings::generalFont()); |
162 | 162 | ||
163 | myDocID = uniqueID; | 163 | myDocID = uniqueID; |
164 | uniqueID++; | 164 | uniqueID++; |
165 | 165 | ||
166 | myDocName = QString (""); | 166 | myDocName = QString (""); |
167 | fileInfo = new QFileInfo (); | 167 | fileInfo = new QFileInfo (); |
168 | 168 | ||
169 | myCmd = new KateCmd (this); | 169 | myCmd = new KateCmd (this); |
170 | 170 | ||
171 | connect(this,SIGNAL(modifiedChanged ()),this,SLOT(slotModChanged ())); | 171 | connect(this,SIGNAL(modifiedChanged()),this,SLOT(slotModChanged())); |
172 | 172 | ||
173 | buffer = new KWBuffer; | 173 | buffer = new KWBuffer; |
174 | connect(buffer, SIGNAL(linesChanged(int)), this, SLOT(slotBufferChanged())); | 174 | connect(buffer, SIGNAL(linesChanged(int)), this, SLOT(slotBufferChanged())); |
175 | // connect(buffer, SIGNAL(textChanged()), this, SIGNAL(textChanged())); | 175 | // connect(buffer, SIGNAL(textChanged()), this, SIGNAL(textChanged())); |
176 | connect(buffer, SIGNAL(needHighlight(long,long)),this,SLOT(slotBufferHighlight(long,long))); | 176 | connect(buffer, SIGNAL(needHighlight(long,long)),this,SLOT(slotBufferHighlight(long,long))); |
177 | 177 | ||
178 | colors[0] = KGlobalSettings::baseColor(); | 178 | colors[0] = KGlobalSettings::baseColor(); |
179 | colors[1] = KGlobalSettings::highlightColor(); | 179 | colors[1] = KGlobalSettings::highlightColor(); |
180 | 180 | ||
181 | m_attribs = new Attribute[maxAttribs]; | 181 | m_attribs = new Attribute[maxAttribs]; |
182 | 182 | ||
183 | m_highlight = 0L; | 183 | m_highlight = 0L; |
184 | tabChars = 8; | 184 | tabChars = 8; |
185 | 185 | ||
186 | m_singleSelection = false; | 186 | m_singleSelection = false; |
187 | 187 | ||
188 | newDocGeometry = false; | 188 | newDocGeometry = false; |
189 | readOnly = false; | 189 | readOnly = false; |
190 | newDoc = false; | 190 | newDoc = false; |
191 | 191 | ||
192 | modified = false; | 192 | modified = false; |
193 | 193 | ||
194 | undoList.setAutoDelete(true); | 194 | undoList.setAutoDelete(true); |
195 | undoState = 0; | 195 | undoState = 0; |
196 | undoSteps = 50; | 196 | undoSteps = 50; |
197 | 197 | ||
198 | pseudoModal = 0L; | 198 | pseudoModal = 0L; |
199 | clear(); | 199 | clear(); |
200 | 200 | ||
201 | setHighlight(0); //calls updateFontData() | 201 | setHighlight(0); //calls updateFontData() |
202 | // if the user changes the highlight with the dialog, notify the doc | 202 | // if the user changes the highlight with the dialog, notify the doc |
203 | connect(hlManager,SIGNAL(changed()),SLOT(hlChanged())); | 203 | connect(hlManager,SIGNAL(changed()),SLOT(hlChanged())); |
204 | 204 | ||
205 | newDocGeometry = false; | 205 | newDocGeometry = false; |
206 | 206 | ||
207 | readConfig(); | 207 | readConfig(); |
208 | 208 | ||
209 | setReadOnly(false); | 209 | setReadOnly(false); |
210 | } | 210 | } |
211 | 211 | ||
212 | void KateDocument::setDontChangeHlOnSave() | 212 | void KateDocument::setDontChangeHlOnSave() |
213 | { | 213 | { |
214 | d(this)->hlSetByUser = true; | 214 | d(this)->hlSetByUser = true; |
215 | } | 215 | } |
216 | 216 | ||
217 | void KateDocument::setFont (QFont font) | 217 | void KateDocument::setFont (QFont font) |
218 | { | 218 | { |
219 | kdDebug()<<"Kate:: setFont"<<endl; | 219 | kdDebug()<<"Kate:: setFont"<<endl; |
220 | int oldwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 | 220 | int oldwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 |
221 | myFont = font; | 221 | myFont = font; |
222 | myFontBold = QFont (font); | 222 | myFontBold = QFont (font); |
223 | myFontBold.setBold (true); | 223 | myFontBold.setBold (true); |
224 | 224 | ||
225 | myFontItalic = QFont (font); | 225 | myFontItalic = QFont (font); |
226 | myFontItalic.setItalic (true); | 226 | myFontItalic.setItalic (true); |
227 | 227 | ||
228 | myFontBI = QFont (font); | 228 | myFontBI = QFont (font); |
229 | myFontBI.setBold (true); | 229 | myFontBI.setBold (true); |
230 | myFontBI.setItalic (true); | 230 | myFontBI.setItalic (true); |
231 | 231 | ||
232 | myFontMetrics = CachedFontMetrics (myFont); | 232 | myFontMetrics = CachedFontMetrics (myFont); |
233 | myFontMetricsBold = CachedFontMetrics (myFontBold); | 233 | myFontMetricsBold = CachedFontMetrics (myFontBold); |
234 | myFontMetricsItalic = CachedFontMetrics (myFontItalic); | 234 | myFontMetricsItalic = CachedFontMetrics (myFontItalic); |
235 | myFontMetricsBI = CachedFontMetrics (myFontBI); | 235 | myFontMetricsBI = CachedFontMetrics (myFontBI); |
236 | int newwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 | 236 | int newwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 |
237 | maxLength=maxLength*(float)newwidth/(float)oldwidth; //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 | 237 | maxLength=maxLength*(float)newwidth/(float)oldwidth; //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 |
238 | 238 | ||
239 | updateFontData(); | 239 | updateFontData(); |
240 | updateViews(); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 | 240 | updateViews(); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 |
241 | 241 | ||
242 | } | 242 | } |
243 | 243 | ||
244 | long KateDocument::needPreHighlight(long till) | 244 | long KateDocument::needPreHighlight(long till) |
245 | { | 245 | { |
246 | int max=numLines()-1; | 246 | int max=numLines()-1; |
247 | if (till>max) | 247 | if (till>max) |
248 | { | 248 | { |
249 | till=max; | 249 | till=max; |
250 | } | 250 | } |
251 | if (PreHighlightedTill>=till) return -1; | 251 | if (PreHighlightedTill>=till) return -1; |
252 | 252 | ||
253 | long tmp=RequestPreHighlightTill; | 253 | long tmp=RequestPreHighlightTill; |
254 | if (RequestPreHighlightTill<till) | 254 | if (RequestPreHighlightTill<till) |
255 | { | 255 | { |
256 | RequestPreHighlightTill=till; | 256 | RequestPreHighlightTill=till; |
257 | if (tmp<=PreHighlightedTill) QTimer::singleShot(10,this,SLOT(doPreHighlight())); | 257 | if (tmp<=PreHighlightedTill) QTimer::singleShot(10,this,SLOT(doPreHighlight())); |
258 | } | 258 | } |
259 | return RequestPreHighlightTill; | 259 | return RequestPreHighlightTill; |
260 | } | 260 | } |
261 | 261 | ||
262 | void KateDocument::doPreHighlight() | 262 | void KateDocument::doPreHighlight() |
263 | { | 263 | { |
264 | int from = PreHighlightedTill; | 264 | int from = PreHighlightedTill; |
265 | int till = PreHighlightedTill+200; | 265 | int till = PreHighlightedTill+200; |
266 | int max = numLines()-1; | 266 | int max = numLines()-1; |
267 | if (till > max) | 267 | if (till > max) |