summaryrefslogtreecommitdiff
authorpaule <paule>2007-01-13 07:23:35 (UTC)
committer paule <paule>2007-01-13 07:23:35 (UTC)
commit80d1934bbbfaea40ee08cf6be738c6517de9477c (patch) (unidiff)
tree58b8f41630b3ad81422c9b47fd0ef1fc0967a8c0
parentbccf96bb5b516d05df54dbcee8b8402ded815ed4 (diff)
downloadopie-80d1934bbbfaea40ee08cf6be738c6517de9477c.zip
opie-80d1934bbbfaea40ee08cf6be738c6517de9477c.tar.gz
opie-80d1934bbbfaea40ee08cf6be738c6517de9477c.tar.bz2
Delete configuration dialog object on closing
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/view/kateview.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/noncore/apps/tinykate/libkate/view/kateview.cpp b/noncore/apps/tinykate/libkate/view/kateview.cpp
index c5673a5..b9ebb1a 100644
--- a/noncore/apps/tinykate/libkate/view/kateview.cpp
+++ b/noncore/apps/tinykate/libkate/view/kateview.cpp
@@ -1,2919 +1,2920 @@
1/*************************************************************************** 1/***************************************************************************
2 kateview.cpp - description 2 kateview.cpp - 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 * This program is free software; you can redistribute it and/or modify * 13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by * 14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or * 15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. * 16 * (at your option) any later version. *
17 * * 17 * *
18 ***************************************************************************/ 18 ***************************************************************************/
19 19
20/* 20/*
21 Copyright (C) 1998, 1999 Jochen Wilhelmy 21 Copyright (C) 1998, 1999 Jochen Wilhelmy
22 digisnap@cs.tu-berlin.de 22 digisnap@cs.tu-berlin.de
23 23
24 This library is free software; you can redistribute it and/or 24 This library is free software; you can redistribute it and/or
25 modify it under the terms of the GNU Library General Public 25 modify it under the terms of the GNU Library General Public
26 License as published by the Free Software Foundation; either 26 License as published by the Free Software Foundation; either
27 version 2 of the License, or (at your option) any later version. 27 version 2 of the License, or (at your option) any later version.
28 28
29 This library is distributed in the hope that it will be useful, 29 This library is distributed in the hope that it will be useful,
30 but WITHOUT ANY WARRANTY; without even the implied warranty of 30 but WITHOUT ANY WARRANTY; without even the implied warranty of
31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32 Library General Public License for more details. 32 Library General Public License for more details.
33 33
34 You should have received a copy of the GNU Library General Public License 34 You should have received a copy of the GNU Library General Public License
35 along with this library; see the file COPYING.LIB. If not, write to 35 along with this library; see the file COPYING.LIB. If not, write to
36 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 36 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
37 Boston, MA 02111-1307, USA. 37 Boston, MA 02111-1307, USA.
38*/ 38*/
39 39
40 40
41 41
42#include "kateview.h" 42#include "kateview.h"
43 43
44#include "../document/katedocument.h" 44#include "../document/katedocument.h"
45#include "../document/katecmd.h" 45#include "../document/katecmd.h"
46#include "../document/katehighlight.h" 46#include "../document/katehighlight.h"
47#include "../document/katedialogs.h" 47#include "../document/katedialogs.h"
48#include "kateviewdialog.h" 48#include "kateviewdialog.h"
49#include <kateconfig.h> 49#include <kateconfig.h>
50 50
51#include <kapplication.h> 51#include <kapplication.h>
52#include <qscrollbar.h> 52#include <qscrollbar.h>
53#include <qpopupmenu.h> 53#include <qpopupmenu.h>
54#include <kpopupmenu.h> 54#include <kpopupmenu.h>
55#include <qkeycode.h> 55#include <qkeycode.h>
56#include <qintdict.h> 56#include <qintdict.h>
57#include <qfont.h> 57#include <qfont.h>
58#include <qpainter.h> 58#include <qpainter.h>
59#include <qpixmap.h> 59#include <qpixmap.h>
60#include <qfileinfo.h> 60#include <qfileinfo.h>
61#include <qfile.h> 61#include <qfile.h>
62#include <qevent.h> 62#include <qevent.h>
63#include <qdir.h> 63#include <qdir.h>
64#include <qvbox.h> 64#include <qvbox.h>
65#include <qprintdialog.h> 65#include <qprintdialog.h>
66#include <qpaintdevicemetrics.h> 66#include <qpaintdevicemetrics.h>
67#include <qbuffer.h> 67#include <qbuffer.h>
68#include <klocale.h> 68#include <klocale.h>
69#include <kglobal.h> 69#include <kglobal.h>
70#include <kmessagebox.h> 70#include <kmessagebox.h>
71#include <qregexp.h> 71#include <qregexp.h>
72#include <kdialogbase.h> 72#include <kdialogbase.h>
73#include <klineeditdlg.h> 73#include <klineeditdlg.h>
74#include <qapplication.h> 74#include <qapplication.h>
75#include <kfiledialog.h> 75#include <kfiledialog.h>
76#include <kiconloader.h> 76#include <kiconloader.h>
77#include "../document/katetextline.h" 77#include "../document/katetextline.h"
78#include "kateundohistory.h" 78#include "kateundohistory.h"
79#include <qlayout.h> 79#include <qlayout.h>
80#include <qpe/qpeapplication.h> 80#include <qpe/qpeapplication.h>
81 81
82KateViewInternal::KateViewInternal(KateView *view, KateDocument *doc) : QWidget(view) 82KateViewInternal::KateViewInternal(KateView *view, KateDocument *doc) : QWidget(view)
83{ 83{
84 waitForPreHighlight=-1; 84 waitForPreHighlight=-1;
85 myView = view; 85 myView = view;
86 myDoc = doc; 86 myDoc = doc;
87 87
88 iconBorderWidth = 16; 88 iconBorderWidth = 16;
89 iconBorderHeight = 800; 89 iconBorderHeight = 800;
90 90
91 QWidget::setCursor(ibeamCursor); 91 QWidget::setCursor(ibeamCursor);
92 setBackgroundMode(NoBackground); 92 setBackgroundMode(NoBackground);
93 93
94 setFocusPolicy(StrongFocus); 94 setFocusPolicy(StrongFocus);
95 95
96 xScroll = new QScrollBar(QScrollBar::Horizontal,myView); 96 xScroll = new QScrollBar(QScrollBar::Horizontal,myView);
97 yScroll = new QScrollBar(QScrollBar::Vertical,myView); 97 yScroll = new QScrollBar(QScrollBar::Vertical,myView);
98 connect(xScroll,SIGNAL(valueChanged(int)),SLOT(changeXPos(int))); 98 connect(xScroll,SIGNAL(valueChanged(int)),SLOT(changeXPos(int)));
99 connect(yScroll,SIGNAL(valueChanged(int)),SLOT(changeYPos(int))); 99 connect(yScroll,SIGNAL(valueChanged(int)),SLOT(changeYPos(int)));
100 connect(yScroll,SIGNAL(valueChanged(int)),myView,SIGNAL(scrollValueChanged(int))); 100 connect(yScroll,SIGNAL(valueChanged(int)),myView,SIGNAL(scrollValueChanged(int)));
101 connect( doc, SIGNAL (preHighlightChanged(long)),this,SLOT(slotPreHighlightUpdate(long))); 101 connect( doc, SIGNAL (preHighlightChanged(long)),this,SLOT(slotPreHighlightUpdate(long)));
102 102
103 xPos = 0; 103 xPos = 0;
104 yPos = 0; 104 yPos = 0;
105 105
106 scrollTimer = 0; 106 scrollTimer = 0;
107 107
108 cursor.x = 0; 108 cursor.x = 0;
109 cursor.y = 0; 109 cursor.y = 0;
110 cursorOn = false; 110 cursorOn = false;
111 cursorTimer = 0; 111 cursorTimer = 0;
112 cXPos = 0; 112 cXPos = 0;
113 cOldXPos = 0; 113 cOldXPos = 0;
114 114
115 startLine = 0; 115 startLine = 0;
116 endLine = -1; 116 endLine = -1;
117 117
118 exposeCursor = false; 118 exposeCursor = false;
119 updateState = 0; 119 updateState = 0;
120 numLines = 0; 120 numLines = 0;
121 lineRanges = 0L; 121 lineRanges = 0L;
122 newXPos = -1; 122 newXPos = -1;
123 newYPos = -1; 123 newYPos = -1;
124 124
125 drawBuffer = new QPixmap (); 125 drawBuffer = new QPixmap ();
126 drawBuffer->setOptimization (QPixmap::BestOptim); 126 drawBuffer->setOptimization (QPixmap::BestOptim);
127 127
128 bm.sXPos = 0; 128 bm.sXPos = 0;
129 bm.eXPos = -1; 129 bm.eXPos = -1;
130 130
131} 131}
132 132
133 133
134KateViewInternal::~KateViewInternal() 134KateViewInternal::~KateViewInternal()
135{ 135{
136 delete [] lineRanges; 136 delete [] lineRanges;
137 delete drawBuffer; 137 delete drawBuffer;
138} 138}
139 139
140 140
141void KateViewInternal::slotPreHighlightUpdate(long line) 141void KateViewInternal::slotPreHighlightUpdate(long line)
142{ 142{
143 //kdDebug()<<QString("slotPreHighlightUpdate - Wait for: %1, line: %2").arg(waitForPreHighlight).arg(line)<<endl; 143 //kdDebug()<<QString("slotPreHighlightUpdate - Wait for: %1, line: %2").arg(waitForPreHighlight).arg(line)<<endl;
144 if (waitForPreHighlight!=-1) 144 if (waitForPreHighlight!=-1)
145 { 145 {
146 if (line>=waitForPreHighlight) 146 if (line>=waitForPreHighlight)
147 { 147 {
148 waitForPreHighlight=-1; 148 waitForPreHighlight=-1;
149 repaint(); 149 repaint();
150 } 150 }
151 } 151 }
152} 152}
153 153
154void KateViewInternal::doCursorCommand(VConfig &c, int cmdNum) { 154void KateViewInternal::doCursorCommand(VConfig &c, int cmdNum) {
155 155
156 switch (cmdNum) { 156 switch (cmdNum) {
157 case KateView::cmLeft: 157 case KateView::cmLeft:
158 cursorLeft(c); 158 cursorLeft(c);
159 break; 159 break;
160 case KateView::cmRight: 160 case KateView::cmRight:
161 cursorRight(c); 161 cursorRight(c);
162 break; 162 break;
163 case KateView::cmWordLeft: 163 case KateView::cmWordLeft:
164 wordLeft(c); 164 wordLeft(c);
165 break; 165 break;
166 case KateView::cmWordRight: 166 case KateView::cmWordRight:
167 wordRight(c); 167 wordRight(c);
168 break; 168 break;
169 case KateView::cmHome: 169 case KateView::cmHome:
170 home(c); 170 home(c);
171 break; 171 break;
172 case KateView::cmEnd: 172 case KateView::cmEnd:
173 end(c); 173 end(c);
174 break; 174 break;
175 case KateView::cmUp: 175 case KateView::cmUp:
176 cursorUp(c); 176 cursorUp(c);
177 break; 177 break;
178 case KateView::cmDown: 178 case KateView::cmDown:
179 cursorDown(c); 179 cursorDown(c);
180 break; 180 break;
181 case KateView::cmScrollUp: 181 case KateView::cmScrollUp:
182 scrollUp(c); 182 scrollUp(c);
183 break; 183 break;
184 case KateView::cmScrollDown: 184 case KateView::cmScrollDown:
185 scrollDown(c); 185 scrollDown(c);
186 break; 186 break;
187 case KateView::cmTopOfView: 187 case KateView::cmTopOfView:
188 topOfView(c); 188 topOfView(c);
189 break; 189 break;
190 case KateView::cmBottomOfView: 190 case KateView::cmBottomOfView:
191 bottomOfView(c); 191 bottomOfView(c);
192 break; 192 break;
193 case KateView::cmPageUp: 193 case KateView::cmPageUp:
194 pageUp(c); 194 pageUp(c);
195 break; 195 break;
196 case KateView::cmPageDown: 196 case KateView::cmPageDown:
197 pageDown(c); 197 pageDown(c);
198 break; 198 break;
199 case KateView::cmTop: 199 case KateView::cmTop:
200 top_home(c); 200 top_home(c);
201 break; 201 break;
202 case KateView::cmBottom: 202 case KateView::cmBottom:
203 bottom_end(c); 203 bottom_end(c);
204 break; 204 break;
205 } 205 }
206} 206}
207 207
208void KateViewInternal::doEditCommand(VConfig &c, int cmdNum) { 208void KateViewInternal::doEditCommand(VConfig &c, int cmdNum) {
209 209
210 switch (cmdNum) { 210 switch (cmdNum) {
211 case KateView::cmCopy: 211 case KateView::cmCopy:
212 myDoc->copy(c.flags); 212 myDoc->copy(c.flags);
213 return; 213 return;
214 case KateView::cmSelectAll: 214 case KateView::cmSelectAll:
215 myDoc->selectAll(); 215 myDoc->selectAll();
216 return; 216 return;
217 case KateView::cmDeselectAll: 217 case KateView::cmDeselectAll:
218 myDoc->deselectAll(); 218 myDoc->deselectAll();
219 return; 219 return;
220 case KateView::cmInvertSelection: 220 case KateView::cmInvertSelection:
221 myDoc->invertSelection(); 221 myDoc->invertSelection();
222 return; 222 return;
223 } 223 }
224 if (myView->isReadOnly()) return; 224 if (myView->isReadOnly()) return;
225 switch (cmdNum) { 225 switch (cmdNum) {
226 case KateView::cmReturn: 226 case KateView::cmReturn:
227 if (c.flags & KateView::cfDelOnInput) myDoc->delMarkedText(c); 227 if (c.flags & KateView::cfDelOnInput) myDoc->delMarkedText(c);
228 myDoc->newLine(c); 228 myDoc->newLine(c);
229 //emit returnPressed(); 229 //emit returnPressed();
230 //e->ignore(); 230 //e->ignore();
231 return; 231 return;
232 case KateView::cmDelete: 232 case KateView::cmDelete:
233 if ((c.flags & KateView::cfDelOnInput) && myDoc->hasMarkedText()) 233 if ((c.flags & KateView::cfDelOnInput) && myDoc->hasMarkedText())
234 myDoc->delMarkedText(c); 234 myDoc->delMarkedText(c);
235 else myDoc->del(c); 235 else myDoc->del(c);
236 return; 236 return;
237 case KateView::cmBackspace: 237 case KateView::cmBackspace:
238 if ((c.flags & KateView::cfDelOnInput) && myDoc->hasMarkedText()) 238 if ((c.flags & KateView::cfDelOnInput) && myDoc->hasMarkedText())
239 myDoc->delMarkedText(c); 239 myDoc->delMarkedText(c);
240 else myDoc->backspace(c); 240 else myDoc->backspace(c);
241 return; 241 return;
242 case KateView::cmKillLine: 242 case KateView::cmKillLine:
243 myDoc->killLine(c); 243 myDoc->killLine(c);
244 return; 244 return;
245 case KateView::cmCut: 245 case KateView::cmCut:
246 myDoc->cut(c); 246 myDoc->cut(c);
247 return; 247 return;
248 case KateView::cmPaste: 248 case KateView::cmPaste:
249 if (c.flags & KateView::cfDelOnInput) myDoc->delMarkedText(c); 249 if (c.flags & KateView::cfDelOnInput) myDoc->delMarkedText(c);
250 myDoc->paste(c); 250 myDoc->paste(c);
251 return; 251 return;
252 case KateView::cmUndo: 252 case KateView::cmUndo:
253 myDoc->undo(c); 253 myDoc->undo(c);
254 return; 254 return;
255 case KateView::cmRedo: 255 case KateView::cmRedo:
256 myDoc->redo(c); 256 myDoc->redo(c);
257 return; 257 return;
258 case KateView::cmIndent: 258 case KateView::cmIndent:
259 myDoc->indent(c); 259 myDoc->indent(c);
260 return; 260 return;
261 case KateView::cmUnindent: 261 case KateView::cmUnindent:
262 myDoc->unIndent(c); 262 myDoc->unIndent(c);
263 return; 263 return;
264 case KateView::cmCleanIndent: 264 case KateView::cmCleanIndent:
265 myDoc->cleanIndent(c); 265 myDoc->cleanIndent(c);
266 return; 266 return;
267 case KateView::cmComment: 267 case KateView::cmComment:
268 myDoc->comment(c); 268 myDoc->comment(c);
269 return; 269 return;
270 case KateView::cmUncomment: 270 case KateView::cmUncomment:
271 myDoc->unComment(c); 271 myDoc->unComment(c);
272 return; 272 return;
273 } 273 }
274} 274}
275 275
276void KateViewInternal::cursorLeft(VConfig &c) { 276void KateViewInternal::cursorLeft(VConfig &c) {
277 277
278 cursor.x--; 278 cursor.x--;
279 if (c.flags & KateView::cfWrapCursor && cursor.x < 0 && cursor.y > 0) { 279 if (c.flags & KateView::cfWrapCursor && cursor.x < 0 && cursor.y > 0) {
280 cursor.y--; 280 cursor.y--;
281 cursor.x = myDoc->textLength(cursor.y); 281 cursor.x = myDoc->textLength(cursor.y);
282 } 282 }
283 cOldXPos = cXPos = myDoc->textWidth(cursor); 283 cOldXPos = cXPos = myDoc->textWidth(cursor);
284 changeState(c); 284 changeState(c);
285} 285}
286 286
287void KateViewInternal::cursorRight(VConfig &c) { 287void KateViewInternal::cursorRight(VConfig &c) {
288 288
289 if (c.flags & KateView::cfWrapCursor) { 289 if (c.flags & KateView::cfWrapCursor) {
290 if (cursor.x >= myDoc->textLength(cursor.y)) { 290 if (cursor.x >= myDoc->textLength(cursor.y)) {
291 if (cursor.y == myDoc->lastLine()) return; 291 if (cursor.y == myDoc->lastLine()) return;
292 cursor.y++; 292 cursor.y++;
293 cursor.x = -1; 293 cursor.x = -1;
294 } 294 }
295 } 295 }
296 cursor.x++; 296 cursor.x++;
297 cOldXPos = cXPos = myDoc->textWidth(cursor); 297 cOldXPos = cXPos = myDoc->textWidth(cursor);
298 changeState(c); 298 changeState(c);
299} 299}
300 300
301void KateViewInternal::wordLeft(VConfig &c) { 301void KateViewInternal::wordLeft(VConfig &c) {
302 Highlight *highlight; 302 Highlight *highlight;
303 303
304 highlight = myDoc->highlight(); 304 highlight = myDoc->highlight();
305 TextLine::Ptr textLine = myDoc->getTextLine(cursor.y); 305 TextLine::Ptr textLine = myDoc->getTextLine(cursor.y);
306 306
307 if (cursor.x > 0) { 307 if (cursor.x > 0) {
308 do { 308 do {
309 cursor.x--; 309 cursor.x--;
310 } while (cursor.x > 0 && !highlight->isInWord(textLine->getChar(cursor.x))); 310 } while (cursor.x > 0 && !highlight->isInWord(textLine->getChar(cursor.x)));
311 while (cursor.x > 0 && highlight->isInWord(textLine->getChar(cursor.x -1))) 311 while (cursor.x > 0 && highlight->isInWord(textLine->getChar(cursor.x -1)))
312 cursor.x--; 312 cursor.x--;
313 } else { 313 } else {
314 if (cursor.y > 0) { 314 if (cursor.y > 0) {
315 cursor.y--; 315 cursor.y--;
316 textLine = myDoc->getTextLine(cursor.y); 316 textLine = myDoc->getTextLine(cursor.y);
317 cursor.x = textLine->length(); 317 cursor.x = textLine->length();
318 } 318 }
319 } 319 }
320 320
321 cOldXPos = cXPos = myDoc->textWidth(cursor); 321 cOldXPos = cXPos = myDoc->textWidth(cursor);
322 changeState(c); 322 changeState(c);
323} 323}
324 324
325void KateViewInternal::wordRight(VConfig &c) { 325void KateViewInternal::wordRight(VConfig &c) {
326 Highlight *highlight; 326 Highlight *highlight;
327 int len; 327 int len;
328 328
329 highlight = myDoc->highlight(); 329 highlight = myDoc->highlight();
330 TextLine::Ptr textLine = myDoc->getTextLine(cursor.y); 330 TextLine::Ptr textLine = myDoc->getTextLine(cursor.y);
331 len = textLine->length(); 331 len = textLine->length();
332 332
333 if (cursor.x < len) { 333 if (cursor.x < len) {
334 do { 334 do {
335 cursor.x++; 335 cursor.x++;
336 } while (cursor.x < len && highlight->isInWord(textLine->getChar(cursor.x))); 336 } while (cursor.x < len && highlight->isInWord(textLine->getChar(cursor.x)));
337 while (cursor.x < len && !highlight->isInWord(textLine->getChar(cursor.x))) 337 while (cursor.x < len && !highlight->isInWord(textLine->getChar(cursor.x)))
338 cursor.x++; 338 cursor.x++;
339 } else { 339 } else {
340 if (cursor.y < myDoc->lastLine()) { 340 if (cursor.y < myDoc->lastLine()) {
341 cursor.y++; 341 cursor.y++;
342 textLine = myDoc->getTextLine(cursor.y); 342 textLine = myDoc->getTextLine(cursor.y);
343 cursor.x = 0; 343 cursor.x = 0;
344 } 344 }
345 } 345 }
346 346
347 cOldXPos = cXPos = myDoc->textWidth(cursor); 347 cOldXPos = cXPos = myDoc->textWidth(cursor);
348 changeState(c); 348 changeState(c);
349} 349}
350 350
351void KateViewInternal::home(VConfig &c) { 351void KateViewInternal::home(VConfig &c) {
352 int lc; 352 int lc;
353 353
354 lc = (c.flags & KateView::cfSmartHome) ? myDoc->getTextLine(cursor.y)->firstChar() : 0; 354 lc = (c.flags & KateView::cfSmartHome) ? myDoc->getTextLine(cursor.y)->firstChar() : 0;
355 if (lc <= 0 || cursor.x == lc) { 355 if (lc <= 0 || cursor.x == lc) {
356 cursor.x = 0; 356 cursor.x = 0;
357 cOldXPos = cXPos = 0; 357 cOldXPos = cXPos = 0;
358 } else { 358 } else {
359 cursor.x = lc; 359 cursor.x = lc;
360 cOldXPos = cXPos = myDoc->textWidth(cursor); 360 cOldXPos = cXPos = myDoc->textWidth(cursor);
361 } 361 }
362 362
363 changeState(c); 363 changeState(c);
364} 364}
365 365
366void KateViewInternal::end(VConfig &c) { 366void KateViewInternal::end(VConfig &c) {
367 cursor.x = myDoc->textLength(cursor.y); 367 cursor.x = myDoc->textLength(cursor.y);
368 cOldXPos = cXPos = myDoc->textWidth(cursor); 368 cOldXPos = cXPos = myDoc->textWidth(cursor);
369 changeState(c); 369 changeState(c);
370} 370}
371 371
372 372
373void KateViewInternal::cursorUp(VConfig &c) { 373void KateViewInternal::cursorUp(VConfig &c) {
374 374
375 cursor.y--; 375 cursor.y--;
376 cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos); 376 cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos);
377 changeState(c); 377 changeState(c);
378} 378}
379 379
380 380
381void KateViewInternal::cursorDown(VConfig &c) { 381void KateViewInternal::cursorDown(VConfig &c) {
382 int x; 382 int x;
383 383
384 if (cursor.y == myDoc->lastLine()) { 384 if (cursor.y == myDoc->lastLine()) {
385 x = myDoc->textLength(cursor.y); 385 x = myDoc->textLength(cursor.y);
386 if (cursor.x >= x) return; 386 if (cursor.x >= x) return;
387 cursor.x = x; 387 cursor.x = x;
388 cXPos = myDoc->textWidth(cursor); 388 cXPos = myDoc->textWidth(cursor);
389 } else { 389 } else {
390 cursor.y++; 390 cursor.y++;
391 cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor, cursor, cOldXPos); 391 cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor, cursor, cOldXPos);
392 } 392 }
393 changeState(c); 393 changeState(c);
394} 394}
395 395
396void KateViewInternal::scrollUp(VConfig &c) { 396void KateViewInternal::scrollUp(VConfig &c) {
397 397
398 if (! yPos) return; 398 if (! yPos) return;
399 399
400 newYPos = yPos - myDoc->fontHeight; 400 newYPos = yPos - myDoc->fontHeight;
401 if (cursor.y == (yPos + height())/myDoc->fontHeight -1) { 401 if (cursor.y == (yPos + height())/myDoc->fontHeight -1) {
402 cursor.y--; 402 cursor.y--;
403 cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos); 403 cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos);
404 404
405 changeState(c); 405 changeState(c);
406 } 406 }
407} 407}
408 408
409void KateViewInternal::scrollDown(VConfig &c) { 409void KateViewInternal::scrollDown(VConfig &c) {
410 410
411 if (endLine >= myDoc->lastLine()) return; 411 if (endLine >= myDoc->lastLine()) return;
412 412
413 newYPos = yPos + myDoc->fontHeight; 413 newYPos = yPos + myDoc->fontHeight;
414 if (cursor.y == (yPos + myDoc->fontHeight -1)/myDoc->fontHeight) { 414 if (cursor.y == (yPos + myDoc->fontHeight -1)/myDoc->fontHeight) {
415 cursor.y++; 415 cursor.y++;
416 cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos); 416 cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos);
417 changeState(c); 417 changeState(c);
418 } 418 }
419} 419}
420 420
421void KateViewInternal::topOfView(VConfig &c) { 421void KateViewInternal::topOfView(VConfig &c) {
422 422
423 cursor.y = (yPos + myDoc->fontHeight -1)/myDoc->fontHeight; 423 cursor.y = (yPos + myDoc->fontHeight -1)/myDoc->fontHeight;
424 cursor.x = 0; 424 cursor.x = 0;
425 cOldXPos = cXPos = 0; 425 cOldXPos = cXPos = 0;
426 changeState(c); 426 changeState(c);
427} 427}
428 428
429void KateViewInternal::bottomOfView(VConfig &c) { 429void KateViewInternal::bottomOfView(VConfig &c) {
430 430
431 cursor.y = (yPos + height())/myDoc->fontHeight -1; 431 cursor.y = (yPos + height())/myDoc->fontHeight -1;
432 if (cursor.y < 0) cursor.y = 0; 432 if (cursor.y < 0) cursor.y = 0;
433 if (cursor.y > myDoc->lastLine()) cursor.y = myDoc->lastLine(); 433 if (cursor.y > myDoc->lastLine()) cursor.y = myDoc->lastLine();
434 cursor.x = 0; 434 cursor.x = 0;
435 cOldXPos = cXPos = 0; 435 cOldXPos = cXPos = 0;
436 changeState(c); 436 changeState(c);
437} 437}
438 438
439void KateViewInternal::pageUp(VConfig &c) { 439void KateViewInternal::pageUp(VConfig &c) {
440 int lines = (endLine - startLine - 1); 440 int lines = (endLine - startLine - 1);
441 441
442 if (lines <= 0) lines = 1; 442 if (lines <= 0) lines = 1;
443 443
444 if (!(c.flags & KateView::cfPageUDMovesCursor) && yPos > 0) { 444 if (!(c.flags & KateView::cfPageUDMovesCursor) && yPos > 0) {
445 newYPos = yPos - lines * myDoc->fontHeight; 445 newYPos = yPos - lines * myDoc->fontHeight;
446 if (newYPos < 0) newYPos = 0; 446 if (newYPos < 0) newYPos = 0;
447 } 447 }
448 cursor.y -= lines; 448 cursor.y -= lines;
449 cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor, cursor, cOldXPos); 449 cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor, cursor, cOldXPos);
450 changeState(c); 450 changeState(c);
451// cursorPageUp(c); 451// cursorPageUp(c);
452} 452}
453 453
454void KateViewInternal::pageDown(VConfig &c) { 454void KateViewInternal::pageDown(VConfig &c) {
455 455
456 int lines = (endLine - startLine - 1); 456 int lines = (endLine - startLine - 1);
457 457
458 if (!(c.flags & KateView::cfPageUDMovesCursor) && endLine < myDoc->lastLine()) { 458 if (!(c.flags & KateView::cfPageUDMovesCursor) && endLine < myDoc->lastLine()) {
459 if (lines < myDoc->lastLine() - endLine) 459 if (lines < myDoc->lastLine() - endLine)
460 newYPos = yPos + lines * myDoc->fontHeight; 460 newYPos = yPos + lines * myDoc->fontHeight;
461 else 461 else
462 newYPos = yPos + (myDoc->lastLine() - endLine) * myDoc->fontHeight; 462 newYPos = yPos + (myDoc->lastLine() - endLine) * myDoc->fontHeight;
463 } 463 }
464 cursor.y += lines; 464 cursor.y += lines;
465 cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos); 465 cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos);
466 changeState(c); 466 changeState(c);
467// cursorPageDown(c); 467// cursorPageDown(c);
468} 468}
469 469
470// go to the top, same X position 470// go to the top, same X position
471void KateViewInternal::top(VConfig &c) { 471void KateViewInternal::top(VConfig &c) {
472 472
473// cursor.x = 0; 473// cursor.x = 0;
474 cursor.y = 0; 474 cursor.y = 0;
475 cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos); 475 cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos);
476// cOldXPos = cXPos = 0; 476// cOldXPos = cXPos = 0;
477 changeState(c); 477 changeState(c);
478} 478}
479 479
480// go to the bottom, same X position 480// go to the bottom, same X position
481void KateViewInternal::bottom(VConfig &c) { 481void KateViewInternal::bottom(VConfig &c) {
482 482
483// cursor.x = 0; 483// cursor.x = 0;
484 cursor.y = myDoc->lastLine(); 484 cursor.y = myDoc->lastLine();
485 cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos); 485 cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos);
486// cOldXPos = cXPos = 0; 486// cOldXPos = cXPos = 0;
487 changeState(c); 487 changeState(c);
488} 488}
489 489
490// go to the top left corner 490// go to the top left corner
491void KateViewInternal::top_home(VConfig &c) 491void KateViewInternal::top_home(VConfig &c)
492{ 492{
493 cursor.y = 0; 493 cursor.y = 0;
494 cursor.x = 0; 494 cursor.x = 0;
495 cOldXPos = cXPos = 0; 495 cOldXPos = cXPos = 0;
496 changeState(c); 496 changeState(c);
497} 497}
498 498
499// go to the bottom right corner 499// go to the bottom right corner
500void KateViewInternal::bottom_end(VConfig &c) { 500void KateViewInternal::bottom_end(VConfig &c) {
501 501
502 cursor.y = myDoc->lastLine(); 502 cursor.y = myDoc->lastLine();
503 cursor.x = myDoc->textLength(cursor.y); 503 cursor.x = myDoc->textLength(cursor.y);
504 cOldXPos = cXPos = myDoc->textWidth(cursor); 504 cOldXPos = cXPos = myDoc->textWidth(cursor);
505 changeState(c); 505 changeState(c);
506} 506}
507 507
508 508
509void KateViewInternal::changeXPos(int p) { 509void KateViewInternal::changeXPos(int p) {
510 int dx; 510 int dx;
511 511
512 dx = xPos - p; 512 dx = xPos - p;
513 xPos = p; 513 xPos = p;
514 if (QABS(dx) < width()) scroll(dx, 0); else update(); 514 if (QABS(dx) < width()) scroll(dx, 0); else update();
515} 515}
516 516
517void KateViewInternal::changeYPos(int p) { 517void KateViewInternal::changeYPos(int p) {
518 int dy; 518 int dy;
519 519
520 dy = yPos - p; 520 dy = yPos - p;
521 yPos = p; 521 yPos = p;
522 clearDirtyCache(height()); 522 clearDirtyCache(height());
523 523
524 if (QABS(dy) < height()) 524 if (QABS(dy) < height())
525 { 525 {
526 scroll(0, dy); 526 scroll(0, dy);
527 leftBorder->scroll(0, dy); 527 leftBorder->scroll(0, dy);
528 } 528 }
529 else 529 else
530 update(); 530 update();
531} 531}
532 532
533 533
534void KateViewInternal::getVConfig(VConfig &c) { 534void KateViewInternal::getVConfig(VConfig &c) {
535 535
536 c.view = myView; 536 c.view = myView;
537 c.cursor = cursor; 537 c.cursor = cursor;
538 c.cXPos = cXPos; 538 c.cXPos = cXPos;
539 c.flags = myView->configFlags; 539 c.flags = myView->configFlags;
540} 540}
541 541
542void KateViewInternal::changeState(VConfig &c) { 542void KateViewInternal::changeState(VConfig &c) {
543 /* 543 /*
544 * we need to be sure to kill the selection on an attempted cursor 544 * we need to be sure to kill the selection on an attempted cursor
545 * movement even if the cursor doesn't physically move, 545 * movement even if the cursor doesn't physically move,
546 * but we need to be careful not to do some other things in this case, 546 * but we need to be careful not to do some other things in this case,
547 * like we don't want to expose the cursor 547 * like we don't want to expose the cursor
548 */ 548 */
549 549
550// if (cursor.x == c.cursor.x && cursor.y == c.cursor.y) return; 550// if (cursor.x == c.cursor.x && cursor.y == c.cursor.y) return;
551 bool nullMove = (cursor.x == c.cursor.x && cursor.y == c.cursor.y); 551 bool nullMove = (cursor.x == c.cursor.x && cursor.y == c.cursor.y);
552 552
553// if (cursor.y != c.cursor.y || c.flags & KateView::cfMark) myDoc->recordReset(); 553// if (cursor.y != c.cursor.y || c.flags & KateView::cfMark) myDoc->recordReset();
554 554
555 if (! nullMove) { 555 if (! nullMove) {
556 556
557 exposeCursor = true; 557 exposeCursor = true;
558 558
559 // mark old position of cursor as dirty 559 // mark old position of cursor as dirty
560 if (cursorOn) { 560 if (cursorOn) {
561 tagLines(c.cursor.y, c.cursor.y, c.cXPos -2, c.cXPos +3); 561 tagLines(c.cursor.y, c.cursor.y, c.cXPos -2, c.cXPos +3);
562 cursorOn = false; 562 cursorOn = false;
563 } 563 }
564 564
565 // mark old bracket mark position as dirty 565 // mark old bracket mark position as dirty
566 if (bm.sXPos < bm.eXPos) { 566 if (bm.sXPos < bm.eXPos) {
567 tagLines(bm.cursor.y, bm.cursor.y, bm.sXPos, bm.eXPos); 567 tagLines(bm.cursor.y, bm.cursor.y, bm.sXPos, bm.eXPos);
568 } 568 }
569 // make new bracket mark 569 // make new bracket mark
570 myDoc->newBracketMark(cursor, bm); 570 myDoc->newBracketMark(cursor, bm);
571 571
572 // remove trailing spaces when leaving a line 572 // remove trailing spaces when leaving a line
573 if (c.flags & KateView::cfRemoveSpaces && cursor.y != c.cursor.y) { 573 if (c.flags & KateView::cfRemoveSpaces && cursor.y != c.cursor.y) {
574 TextLine::Ptr textLine = myDoc->getTextLine(c.cursor.y); 574 TextLine::Ptr textLine = myDoc->getTextLine(c.cursor.y);
575 int newLen = textLine->lastChar(); 575 int newLen = textLine->lastChar();
576 if (newLen != textLine->length()) { 576 if (newLen != textLine->length()) {
577 textLine->truncate(newLen); 577 textLine->truncate(newLen);
578 // if some spaces are removed, tag the line as dirty 578 // if some spaces are removed, tag the line as dirty
579 myDoc->tagLines(c.cursor.y, c.cursor.y); 579 myDoc->tagLines(c.cursor.y, c.cursor.y);
580 } 580 }
581 } 581 }
582 } 582 }
583 583
584 if (c.flags & KateView::cfMark) { 584 if (c.flags & KateView::cfMark) {
585 if (! nullMove) 585 if (! nullMove)
586 myDoc->selectTo(c, cursor, cXPos); 586 myDoc->selectTo(c, cursor, cXPos);
587 } else { 587 } else {
588 if (!(c.flags & KateView::cfPersistent)) 588 if (!(c.flags & KateView::cfPersistent))
589 myDoc->deselectAll(); 589 myDoc->deselectAll();
590 } 590 }
591} 591}
592 592
593void KateViewInternal::insLine(int line) { 593void KateViewInternal::insLine(int line) {
594 594
595 if (line <= cursor.y) { 595 if (line <= cursor.y) {
596 cursor.y++; 596 cursor.y++;
597 } 597 }
598 if (line < startLine) { 598 if (line < startLine) {
599 startLine++; 599 startLine++;
600 endLine++; 600 endLine++;
601 yPos += myDoc->fontHeight; 601 yPos += myDoc->fontHeight;
602 } else if (line <= endLine) { 602 } else if (line <= endLine) {
603 tagAll(); 603 tagAll();
604 } 604 }
605} 605}
606 606
607void KateViewInternal::delLine(int line) { 607void KateViewInternal::delLine(int line) {
608 608
609 if (line <= cursor.y && cursor.y > 0) { 609 if (line <= cursor.y && cursor.y > 0) {
610 cursor.y--; 610 cursor.y--;
611 } 611 }
612 if (line < startLine) { 612 if (line < startLine) {
613 startLine--; 613 startLine--;
614 endLine--; 614 endLine--;
615 yPos -= myDoc->fontHeight; 615 yPos -= myDoc->fontHeight;
616 } else if (line <= endLine) { 616 } else if (line <= endLine) {
617 tagAll(); 617 tagAll();
618 } 618 }
619} 619}
620 620
621void KateViewInternal::updateCursor() { 621void KateViewInternal::updateCursor() {
622 cOldXPos = cXPos = myDoc->textWidth(cursor); 622 cOldXPos = cXPos = myDoc->textWidth(cursor);
623} 623}
624 624
625 625
626void KateViewInternal::updateCursor(PointStruc &newCursor) { 626void KateViewInternal::updateCursor(PointStruc &newCursor) {
627 updateCursor(newCursor, myView->config()); 627 updateCursor(newCursor, myView->config());
628} 628}
629 629
630void KateViewInternal::updateCursor(PointStruc &newCursor, int flags) { 630void KateViewInternal::updateCursor(PointStruc &newCursor, int flags) {
631 631
632 if (!(flags & KateView::cfPersistent)) myDoc->deselectAll(); 632 if (!(flags & KateView::cfPersistent)) myDoc->deselectAll();
633 633
634 exposeCursor = true; 634 exposeCursor = true;
635 if (cursorOn) { 635 if (cursorOn) {
636 tagLines(cursor.y, cursor.y, cXPos -2, cXPos +3); 636 tagLines(cursor.y, cursor.y, cXPos -2, cXPos +3);
637 cursorOn = false; 637 cursorOn = false;
638 } 638 }
639 639
640 if (bm.sXPos < bm.eXPos) { 640 if (bm.sXPos < bm.eXPos) {
641 tagLines(bm.cursor.y, bm.cursor.y, bm.sXPos, bm.eXPos); 641 tagLines(bm.cursor.y, bm.cursor.y, bm.sXPos, bm.eXPos);
642 } 642 }
643 myDoc->newBracketMark(newCursor, bm); 643 myDoc->newBracketMark(newCursor, bm);
644 644
645 cursor = newCursor; 645 cursor = newCursor;
646 cOldXPos = cXPos = myDoc->textWidth(cursor); 646 cOldXPos = cXPos = myDoc->textWidth(cursor);
647} 647}
648 648
649// init the line dirty cache 649// init the line dirty cache
650void KateViewInternal::clearDirtyCache(int height) { 650void KateViewInternal::clearDirtyCache(int height) {
651 int lines, z; 651 int lines, z;
652 652
653 // calc start and end line of visible part 653 // calc start and end line of visible part
654 startLine = yPos/myDoc->fontHeight; 654 startLine = yPos/myDoc->fontHeight;
655 endLine = (yPos + height -1)/myDoc->fontHeight; 655 endLine = (yPos + height -1)/myDoc->fontHeight;
656 656
657 updateState = 0; 657 updateState = 0;
658 658
659 lines = endLine - startLine +1; 659 lines = endLine - startLine +1;
660 if (lines > numLines) { // resize the dirty cache 660 if (lines > numLines) { // resize the dirty cache
661 numLines = lines*2; 661 numLines = lines*2;
662 delete [] lineRanges; 662 delete [] lineRanges;
663 lineRanges = new LineRange[numLines]; 663 lineRanges = new LineRange[numLines];
664 } 664 }
665 665
666 for (z = 0; z < lines; z++) { // clear all lines 666 for (z = 0; z < lines; z++) { // clear all lines
667 lineRanges[z].start = 0xffffff; 667 lineRanges[z].start = 0xffffff;
668 lineRanges[z].end = -2; 668 lineRanges[z].end = -2;
669 } 669 }
670 newXPos = newYPos = -1; 670 newXPos = newYPos = -1;
671} 671}
672 672
673void KateViewInternal::tagLines(int start, int end, int x1, int x2) { 673void KateViewInternal::tagLines(int start, int end, int x1, int x2) {
674 LineRange *r; 674 LineRange *r;
675 int z; 675 int z;
676 676
677 start -= startLine; 677 start -= startLine;
678 if (start < 0) start = 0; 678 if (start < 0) start = 0;
679 end -= startLine; 679 end -= startLine;
680 if (end > endLine - startLine) end = endLine - startLine; 680 if (end > endLine - startLine) end = endLine - startLine;
681 681
682 if (x1 <= 0) x1 = -2; 682 if (x1 <= 0) x1 = -2;
683 if (x1 < xPos-2) x1 = xPos-2; 683 if (x1 < xPos-2) x1 = xPos-2;
684 if (x2 > width() + xPos-2) x2 = width() + xPos-2; 684 if (x2 > width() + xPos-2) x2 = width() + xPos-2;
685 if (x1 >= x2) return; 685 if (x1 >= x2) return;
686 686
687 r = &lineRanges[start]; 687 r = &lineRanges[start];
688 for (z = start; z <= end; z++) { 688 for (z = start; z <= end; z++) {
689 if (x1 < r->start) r->start = x1; 689 if (x1 < r->start) r->start = x1;
690 if (x2 > r->end) r->end = x2; 690 if (x2 > r->end) r->end = x2;
691 r++; 691 r++;
692 updateState |= 1; 692 updateState |= 1;
693 } 693 }
694} 694}
695 695
696void KateViewInternal::tagAll() { 696void KateViewInternal::tagAll() {
697 updateState = 3; 697 updateState = 3;
698} 698}
699 699
700void KateViewInternal::setPos(int x, int y) { 700void KateViewInternal::setPos(int x, int y) {
701 newXPos = x; 701 newXPos = x;
702 newYPos = y; 702 newYPos = y;
703} 703}
704 704
705void KateViewInternal::center() { 705void KateViewInternal::center() {
706 newXPos = 0; 706 newXPos = 0;
707 newYPos = cursor.y*myDoc->fontHeight - height()/2; 707 newYPos = cursor.y*myDoc->fontHeight - height()/2;
708 if (newYPos < 0) newYPos = 0; 708 if (newYPos < 0) newYPos = 0;
709} 709}
710 710
711void KateViewInternal::updateView(int flags) { 711void KateViewInternal::updateView(int flags) {
712 int fontHeight; 712 int fontHeight;
713 int oldXPos, oldYPos; 713 int oldXPos, oldYPos;
714 int w, h; 714 int w, h;
715 int z; 715 int z;
716 bool b; 716 bool b;
717 int xMax, yMax; 717 int xMax, yMax;
718 int cYPos; 718 int cYPos;
719 int cXPosMin, cXPosMax, cYPosMin, cYPosMax; 719 int cXPosMin, cXPosMax, cYPosMin, cYPosMax;
720 int dx, dy; 720 int dx, dy;
721 int pageScroll; 721 int pageScroll;
722 int scrollbarWidth = style().scrollBarExtent().width(); 722 int scrollbarWidth = style().scrollBarExtent().width();
723 723
724//debug("upView %d %d %d %d %d", exposeCursor, updateState, flags, newXPos, newYPos); 724//debug("upView %d %d %d %d %d", exposeCursor, updateState, flags, newXPos, newYPos);
725 if (exposeCursor || flags & KateView::ufDocGeometry) { 725 if (exposeCursor || flags & KateView::ufDocGeometry) {
726 emit myView->newCurPos(); 726 emit myView->newCurPos();
727 } else { 727 } else {
728 if (updateState == 0 && newXPos < 0 && newYPos < 0) return; 728 if (updateState == 0 && newXPos < 0 && newYPos < 0) return;
729 } 729 }
730 730
731 if (cursorTimer) { 731 if (cursorTimer) {
732 killTimer(cursorTimer); 732 killTimer(cursorTimer);
733 cursorTimer = startTimer(KApplication::cursorFlashTime() / 2); 733 cursorTimer = startTimer(KApplication::cursorFlashTime() / 2);
734 cursorOn = true; 734 cursorOn = true;
735 } 735 }
736 736
737 oldXPos = xPos; 737 oldXPos = xPos;
738 oldYPos = yPos; 738 oldYPos = yPos;
739/* if (flags & ufPos) { 739/* if (flags & ufPos) {
740 xPos = newXPos; 740 xPos = newXPos;
741 yPos = newYPos; 741 yPos = newYPos;
742 exposeCursor = true; 742 exposeCursor = true;
743 }*/ 743 }*/
744 if (newXPos >= 0) xPos = newXPos; 744 if (newXPos >= 0) xPos = newXPos;
745 if (newYPos >= 0) yPos = newYPos; 745 if (newYPos >= 0) yPos = newYPos;
746 746
747 fontHeight = myDoc->fontHeight; 747 fontHeight = myDoc->fontHeight;
748 cYPos = cursor.y*fontHeight; 748 cYPos = cursor.y*fontHeight;
749 749
750 z = 0; 750 z = 0;
751 do { 751 do {
752 w = myView->width() - 4; 752 w = myView->width() - 4;
753 h = myView->height() - 4; 753 h = myView->height() - 4;
754 754
755 xMax = myDoc->textWidth() - w; 755 xMax = myDoc->textWidth() - w;
756 b = (xPos > 0 || xMax > 0); 756 b = (xPos > 0 || xMax > 0);
757 if (b) h -= scrollbarWidth; 757 if (b) h -= scrollbarWidth;
758 yMax = myDoc->textHeight() - h; 758 yMax = myDoc->textHeight() - h;
759 if (yPos > 0 || yMax > 0) { 759 if (yPos > 0 || yMax > 0) {
760 w -= scrollbarWidth; 760 w -= scrollbarWidth;
761 xMax += scrollbarWidth; 761 xMax += scrollbarWidth;
762 if (!b && xMax > 0) { 762 if (!b && xMax > 0) {
763 h -= scrollbarWidth; 763 h -= scrollbarWidth;
764 yMax += scrollbarWidth; 764 yMax += scrollbarWidth;
765 } 765 }
766 } 766 }
767 767
768 if (!exposeCursor) break; 768 if (!exposeCursor) break;
769// if (flags & KateView::ufNoScroll) break; 769// if (flags & KateView::ufNoScroll) break;
770/* 770/*
771 if (flags & KateView::ufCenter) { 771 if (flags & KateView::ufCenter) {
772 cXPosMin = xPos + w/3; 772 cXPosMin = xPos + w/3;
773 cXPosMax = xPos + (w*2)/3; 773 cXPosMax = xPos + (w*2)/3;
774 cYPosMin = yPos + h/3; 774 cYPosMin = yPos + h/3;
775 cYPosMax = yPos + ((h - fontHeight)*2)/3; 775 cYPosMax = yPos + ((h - fontHeight)*2)/3;
776 } else {*/ 776 } else {*/
777 cXPosMin = xPos + 4; 777 cXPosMin = xPos + 4;
778 cXPosMax = xPos + w - 8; 778 cXPosMax = xPos + w - 8;
779 cYPosMin = yPos; 779 cYPosMin = yPos;
780 cYPosMax = yPos + (h - fontHeight); 780 cYPosMax = yPos + (h - fontHeight);
781// } 781// }
782 782
783 if (cXPos < cXPosMin) { 783 if (cXPos < cXPosMin) {
784 xPos -= cXPosMin - cXPos; 784 xPos -= cXPosMin - cXPos;
785 } 785 }
786 if (xPos < 0) xPos = 0; 786 if (xPos < 0) xPos = 0;
787 if (cXPos > cXPosMax) { 787 if (cXPos > cXPosMax) {
788 xPos += cXPos - cXPosMax; 788 xPos += cXPos - cXPosMax;
789 } 789 }
790 if (cYPos < cYPosMin) { 790 if (cYPos < cYPosMin) {
791 yPos -= cYPosMin - cYPos; 791 yPos -= cYPosMin - cYPos;
792 } 792 }
793 if (yPos < 0) yPos = 0; 793 if (yPos < 0) yPos = 0;
794 if (cYPos > cYPosMax) { 794 if (cYPos > cYPosMax) {
795 yPos += cYPos - cYPosMax; 795 yPos += cYPos - cYPosMax;
796 } 796 }
797 797
798 z++; 798 z++;
799 } while (z < 2); 799 } while (z < 2);
800 800
801 if (xMax < xPos) xMax = xPos; 801 if (xMax < xPos) xMax = xPos;
802 if (yMax < yPos) yMax = yPos; 802 if (yMax < yPos) yMax = yPos;
803 803
804 if (xMax > 0) { 804 if (xMax > 0) {
805 pageScroll = w - (w % fontHeight) - fontHeight; 805 pageScroll = w - (w % fontHeight) - fontHeight;
806 if (pageScroll <= 0) 806 if (pageScroll <= 0)
807 pageScroll = fontHeight; 807 pageScroll = fontHeight;
808 808
809 xScroll->blockSignals(true); 809 xScroll->blockSignals(true);
810 xScroll->setGeometry(2,h + 2,w,scrollbarWidth); 810 xScroll->setGeometry(2,h + 2,w,scrollbarWidth);
811 xScroll->setRange(0,xMax); 811 xScroll->setRange(0,xMax);
812 xScroll->setValue(xPos); 812 xScroll->setValue(xPos);
813 xScroll->setSteps(fontHeight,pageScroll); 813 xScroll->setSteps(fontHeight,pageScroll);
814 xScroll->blockSignals(false); 814 xScroll->blockSignals(false);
815 xScroll->show(); 815 xScroll->show();
816 } else xScroll->hide(); 816 } else xScroll->hide();
817 817
818 if (yMax > 0) { 818 if (yMax > 0) {
819 pageScroll = h - (h % fontHeight) - fontHeight; 819 pageScroll = h - (h % fontHeight) - fontHeight;
820 if (pageScroll <= 0) 820 if (pageScroll <= 0)
821 pageScroll = fontHeight; 821 pageScroll = fontHeight;
822 822
823 yScroll->blockSignals(true); 823 yScroll->blockSignals(true);
824 yScroll->setGeometry(w + 2,2,scrollbarWidth,h); 824 yScroll->setGeometry(w + 2,2,scrollbarWidth,h);
825 yScroll->setRange(0,yMax); 825 yScroll->setRange(0,yMax);
826 yScroll->setValue(yPos); 826 yScroll->setValue(yPos);
827 yScroll->setSteps(fontHeight,pageScroll); 827 yScroll->setSteps(fontHeight,pageScroll);
828 yScroll->blockSignals(false); 828 yScroll->blockSignals(false);
829 yScroll->show(); 829 yScroll->show();
830 } else yScroll->hide(); 830 } else yScroll->hide();
831 831
832 if (w != width() || h != height()) { 832 if (w != width() || h != height()) {
833 clearDirtyCache(h); 833 clearDirtyCache(h);
834 resize(w,h); 834 resize(w,h);
835 } else { 835 } else {
836 dx = oldXPos - xPos; 836 dx = oldXPos - xPos;
837 dy = oldYPos - yPos; 837 dy = oldYPos - yPos;
838 838
839 b = updateState == 3; 839 b = updateState == 3;
840 if (flags & KateView::ufUpdateOnScroll) { 840 if (flags & KateView::ufUpdateOnScroll) {
841 b |= dx || dy; 841 b |= dx || dy;
842 } else { 842 } else {
843 b |= QABS(dx)*3 > w*2 || QABS(dy)*3 > h*2; 843 b |= QABS(dx)*3 > w*2 || QABS(dy)*3 > h*2;
844 } 844 }
845 845
846 if (b) { 846 if (b) {
847 clearDirtyCache(h); 847 clearDirtyCache(h);
848 update(); 848 update();
849 } else { 849 } else {
850 if (dy) 850 if (dy)
851 leftBorder->scroll(0, dy); 851 leftBorder->scroll(0, dy);
852 if (updateState > 0) paintTextLines(oldXPos, oldYPos); 852 if (updateState > 0) paintTextLines(oldXPos, oldYPos);
853 clearDirtyCache(h); 853 clearDirtyCache(h);
854 854
855 if (dx || dy) { 855 if (dx || dy) {
856 scroll(dx,dy); 856 scroll(dx,dy);
857// kapp->syncX(); 857// kapp->syncX();
858// scroll2(dx - dx/2,dy - dy/2); 858// scroll2(dx - dx/2,dy - dy/2);
859// } else { 859// } else {
860 } 860 }
861 if (cursorOn) paintCursor(); 861 if (cursorOn) paintCursor();
862 if (bm.eXPos > bm.sXPos) paintBracketMark(); 862 if (bm.eXPos > bm.sXPos) paintBracketMark();
863 } 863 }
864 } 864 }
865 exposeCursor = false; 865 exposeCursor = false;
866// updateState = 0; 866// updateState = 0;
867} 867}
868 868
869 869
870void KateViewInternal::paintTextLines(int xPos, int yPos) { 870void KateViewInternal::paintTextLines(int xPos, int yPos) {
871// int xStart, xEnd; 871// int xStart, xEnd;
872 int line;//, z; 872 int line;//, z;
873 int h; 873 int h;
874 LineRange *r; 874 LineRange *r;
875 875
876 if (!drawBuffer) return; 876 if (!drawBuffer) return;
877 if (drawBuffer->isNull()) return; 877 if (drawBuffer->isNull()) return;
878 878
879 QPainter paint; 879 QPainter paint;
880 paint.begin(drawBuffer); 880 paint.begin(drawBuffer);
881 881
882 h = myDoc->fontHeight; 882 h = myDoc->fontHeight;
883 r = lineRanges; 883 r = lineRanges;
884 for (line = startLine; line <= endLine; line++) { 884 for (line = startLine; line <= endLine; line++) {
885 if (r->start < r->end) { 885 if (r->start < r->end) {
886//debug("painttextline %d %d %d", line, r->start, r->end); 886//debug("painttextline %d %d %d", line, r->start, r->end);
887 myDoc->paintTextLine(paint, line, r->start, r->end, myView->configFlags & KateView::cfShowTabs); 887 myDoc->paintTextLine(paint, line, r->start, r->end, myView->configFlags & KateView::cfShowTabs);
888 bitBlt(this, r->start - (xPos-2), line*h - yPos, drawBuffer, 0, 0, 888 bitBlt(this, r->start - (xPos-2), line*h - yPos, drawBuffer, 0, 0,
889 r->end - r->start, h); 889 r->end - r->start, h);
890 leftBorder->paintLine(line); 890 leftBorder->paintLine(line);
891 } 891 }
892 r++; 892 r++;
893 } 893 }
894 894
895 paint.end(); 895 paint.end();
896} 896}
897 897
898void KateViewInternal::paintCursor() { 898void KateViewInternal::paintCursor() {
899 int h, y, x; 899 int h, y, x;
900 static int cx = 0, cy = 0, ch = 0; 900 static int cx = 0, cy = 0, ch = 0;
901 901
902 h = myDoc->fontHeight; 902 h = myDoc->fontHeight;
903 y = h*cursor.y - yPos; 903 y = h*cursor.y - yPos;
904 x = cXPos - (xPos-2); 904 x = cXPos - (xPos-2);
905 905
906 if(myDoc->myFont != font()) setFont(myDoc->myFont); 906 if(myDoc->myFont != font()) setFont(myDoc->myFont);
907 if(cx != x || cy != y || ch != h){ 907 if(cx != x || cy != y || ch != h){
908 cx = x; 908 cx = x;
909 cy = y; 909 cy = y;
910 ch = h; 910 ch = h;
911 setMicroFocusHint(cx, cy, 0, ch - 2); 911 setMicroFocusHint(cx, cy, 0, ch - 2);
912 } 912 }
913 913
914 QPainter paint; 914 QPainter paint;
915 if (cursorOn) { 915 if (cursorOn) {
916 paint.begin(this); 916 paint.begin(this);
917 paint.setClipping(false); 917 paint.setClipping(false);
918 paint.setPen(myDoc->cursorCol(cursor.x,cursor.y)); 918 paint.setPen(myDoc->cursorCol(cursor.x,cursor.y));
919 919
920 h += y - 1; 920 h += y - 1;
921 paint.drawLine(x, y, x, h); 921 paint.drawLine(x, y, x, h);
922 922
923 paint.end(); 923 paint.end();
924 } else { if (drawBuffer && !drawBuffer->isNull()) { 924 } else { if (drawBuffer && !drawBuffer->isNull()) {
925 paint.begin(drawBuffer); 925 paint.begin(drawBuffer);
926 myDoc->paintTextLine(paint, cursor.y, cXPos - 2, cXPos + 3, myView->configFlags & KateView::cfShowTabs); 926 myDoc->paintTextLine(paint, cursor.y, cXPos - 2, cXPos + 3, myView->configFlags & KateView::cfShowTabs);
927 bitBlt(this,x - 2,y, drawBuffer, 0, 0, 5, h); 927 bitBlt(this,x - 2,y, drawBuffer, 0, 0, 5, h);
928 paint.end(); } 928 paint.end(); }
929 } 929 }
930 930
931} 931}
932 932
933void KateViewInternal::paintBracketMark() { 933void KateViewInternal::paintBracketMark() {
934 int y; 934 int y;
935 935
936 y = myDoc->fontHeight*(bm.cursor.y +1) - yPos -1; 936 y = myDoc->fontHeight*(bm.cursor.y +1) - yPos -1;
937 937
938 QPainter paint; 938 QPainter paint;
939 paint.begin(this); 939 paint.begin(this);
940 paint.setPen(myDoc->cursorCol(bm.cursor.x, bm.cursor.y)); 940 paint.setPen(myDoc->cursorCol(bm.cursor.x, bm.cursor.y));
941 941
942 paint.drawLine(bm.sXPos - (xPos-2), y, bm.eXPos - (xPos-2) -1, y); 942 paint.drawLine(bm.sXPos - (xPos-2), y, bm.eXPos - (xPos-2) -1, y);
943 paint.end(); 943 paint.end();
944} 944}
945 945
946void KateViewInternal::placeCursor(int x, int y, int flags) { 946void KateViewInternal::placeCursor(int x, int y, int flags) {
947 VConfig c; 947 VConfig c;
948 948
949 getVConfig(c); 949 getVConfig(c);
950 c.flags |= flags; 950 c.flags |= flags;
951 cursor.y = (yPos + y)/myDoc->fontHeight; 951 cursor.y = (yPos + y)/myDoc->fontHeight;
952 cXPos = cOldXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor, cursor,xPos-2 + x); 952 cXPos = cOldXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor, cursor,xPos-2 + x);
953 changeState(c); 953 changeState(c);
954} 954}
955 955
956// given physical coordinates, report whether the text there is selected 956// given physical coordinates, report whether the text there is selected
957bool KateViewInternal::isTargetSelected(int x, int y) { 957bool KateViewInternal::isTargetSelected(int x, int y) {
958 958
959 y = (yPos + y) / myDoc->fontHeight; 959 y = (yPos + y) / myDoc->fontHeight;
960 960
961 TextLine::Ptr line = myDoc->getTextLine(y); 961 TextLine::Ptr line = myDoc->getTextLine(y);
962 if (!line) 962 if (!line)
963 return false; 963 return false;
964 964
965 x = myDoc->textPos(line, x); 965 x = myDoc->textPos(line, x);
966 966
967 return line->isSelected(x); 967 return line->isSelected(x);
968} 968}
969 969
970void KateViewInternal::focusInEvent(QFocusEvent *) { 970void KateViewInternal::focusInEvent(QFocusEvent *) {
971// debug("got focus %d",cursorTimer); 971// debug("got focus %d",cursorTimer);
972 972
973 if (!cursorTimer) { 973 if (!cursorTimer) {
974 cursorTimer = startTimer(KApplication::cursorFlashTime() / 2); 974 cursorTimer = startTimer(KApplication::cursorFlashTime() / 2);
975 cursorOn = true; 975 cursorOn = true;
976 paintCursor(); 976 paintCursor();
977 } 977 }
978} 978}
979 979
980void KateViewInternal::focusOutEvent(QFocusEvent *) { 980void KateViewInternal::focusOutEvent(QFocusEvent *) {
981// debug("lost focus %d", cursorTimer); 981// debug("lost focus %d", cursorTimer);
982 982
983 if (cursorTimer) { 983 if (cursorTimer) {
984 killTimer(cursorTimer); 984 killTimer(cursorTimer);
985 cursorTimer = 0; 985 cursorTimer = 0;
986 } 986 }
987 987
988 if (cursorOn) { 988 if (cursorOn) {
989 cursorOn = false; 989 cursorOn = false;
990 paintCursor(); 990 paintCursor();
991 } 991 }
992} 992}
993 993
994void KateViewInternal::keyPressEvent(QKeyEvent *e) { 994void KateViewInternal::keyPressEvent(QKeyEvent *e) {
995 VConfig c; 995 VConfig c;
996// int ascii; 996// int ascii;
997 997
998/* if (e->state() & AltButton) { 998/* if (e->state() & AltButton) {
999 e->ignore(); 999 e->ignore();
1000 return; 1000 return;
1001 }*/ 1001 }*/
1002// debug("ascii %i, key %i, state %i",e->ascii(), e->key(), e->state()); 1002// debug("ascii %i, key %i, state %i",e->ascii(), e->key(), e->state());
1003 1003
1004 getVConfig(c); 1004 getVConfig(c);
1005// ascii = e->ascii(); 1005// ascii = e->ascii();
1006 1006
1007 if (!myView->isReadOnly()) { 1007 if (!myView->isReadOnly()) {
1008 if (c.flags & KateView::cfTabIndents && myDoc->hasMarkedText()) { 1008 if (c.flags & KateView::cfTabIndents && myDoc->hasMarkedText()) {
1009 if (e->key() == Qt::Key_Tab) { 1009 if (e->key() == Qt::Key_Tab) {
1010 myDoc->indent(c); 1010 myDoc->indent(c);
1011 myDoc->updateViews(); 1011 myDoc->updateViews();
1012 return; 1012 return;
1013 } 1013 }
1014 if (e->key() == Qt::Key_Backtab) { 1014 if (e->key() == Qt::Key_Backtab) {
1015 myDoc->unIndent(c); 1015 myDoc->unIndent(c);
1016 myDoc->updateViews(); 1016 myDoc->updateViews();
1017 return; 1017 return;
1018 } 1018 }
1019 } 1019 }
1020 if ( !(e->state() & ControlButton ) && myDoc->insertChars(c, e->text())) { 1020 if ( !(e->state() & ControlButton ) && myDoc->insertChars(c, e->text())) {
1021 myDoc->updateViews(); 1021 myDoc->updateViews();
1022 e->accept(); 1022 e->accept();
1023 return; 1023 return;
1024 } 1024 }
1025 } 1025 }
1026 e->ignore(); 1026 e->ignore();
1027} 1027}
1028 1028
1029void KateViewInternal::mousePressEvent(QMouseEvent *e) { 1029void KateViewInternal::mousePressEvent(QMouseEvent *e) {
1030 1030
1031 if (e->button() == LeftButton) { 1031 if (e->button() == LeftButton) {
1032 1032
1033 int flags; 1033 int flags;
1034 1034
1035 flags = 0; 1035 flags = 0;
1036 if (e->state() & ShiftButton) { 1036 if (e->state() & ShiftButton) {
1037 flags |= KateView::cfMark; 1037 flags |= KateView::cfMark;
1038 if (e->state() & ControlButton) flags |= KateView::cfMark | KateView::cfKeepSelection; 1038 if (e->state() & ControlButton) flags |= KateView::cfMark | KateView::cfKeepSelection;
1039 } 1039 }
1040 placeCursor(e->x(), e->y(), flags); 1040 placeCursor(e->x(), e->y(), flags);
1041 scrollX = 0; 1041 scrollX = 0;
1042 scrollY = 0; 1042 scrollY = 0;
1043 if (!scrollTimer) scrollTimer = startTimer(50); 1043 if (!scrollTimer) scrollTimer = startTimer(50);
1044 myDoc->updateViews(); 1044 myDoc->updateViews();
1045 } 1045 }
1046 if (e->button() == MidButton) { 1046 if (e->button() == MidButton) {
1047 placeCursor(e->x(), e->y()); 1047 placeCursor(e->x(), e->y());
1048 if (! myView->isReadOnly()) 1048 if (! myView->isReadOnly())
1049 myView->paste(); 1049 myView->paste();
1050 } 1050 }
1051 if (myView->rmbMenu && e->button() == RightButton) { 1051 if (myView->rmbMenu && e->button() == RightButton) {
1052 myView->rmbMenu->popup(mapToGlobal(e->pos())); 1052 myView->rmbMenu->popup(mapToGlobal(e->pos()));
1053 } 1053 }
1054 myView->mousePressEvent(e); // this doesn't do anything, does it? 1054 myView->mousePressEvent(e); // this doesn't do anything, does it?
1055 // it does :-), we need this for KDevelop, so please don't uncomment it again -Sandy 1055 // it does :-), we need this for KDevelop, so please don't uncomment it again -Sandy
1056} 1056}
1057 1057
1058void KateViewInternal::mouseDoubleClickEvent(QMouseEvent *e) { 1058void KateViewInternal::mouseDoubleClickEvent(QMouseEvent *e) {
1059 1059
1060 if (e->button() == LeftButton) { 1060 if (e->button() == LeftButton) {
1061 VConfig c; 1061 VConfig c;
1062 getVConfig(c); 1062 getVConfig(c);
1063 myDoc->selectWord(c.cursor, c.flags); 1063 myDoc->selectWord(c.cursor, c.flags);
1064 myDoc->updateViews(); 1064 myDoc->updateViews();
1065 } 1065 }
1066} 1066}
1067 1067
1068void KateViewInternal::mouseReleaseEvent(QMouseEvent *e) { 1068void KateViewInternal::mouseReleaseEvent(QMouseEvent *e) {
1069 1069
1070 if (e->button() == LeftButton) { 1070 if (e->button() == LeftButton) {
1071 if (myView->config() & KateView::cfMouseAutoCopy) myView->copy(); 1071 if (myView->config() & KateView::cfMouseAutoCopy) myView->copy();
1072 killTimer(scrollTimer); 1072 killTimer(scrollTimer);
1073 scrollTimer = 0; 1073 scrollTimer = 0;
1074 } 1074 }
1075} 1075}
1076 1076
1077void KateViewInternal::mouseMoveEvent(QMouseEvent *e) { 1077void KateViewInternal::mouseMoveEvent(QMouseEvent *e) {
1078 1078
1079 if (e->state() & LeftButton) { 1079 if (e->state() & LeftButton) {
1080 int flags; 1080 int flags;
1081 int d; 1081 int d;
1082 int x = e->x(), 1082 int x = e->x(),
1083 y = e->y(); 1083 y = e->y();
1084 1084
1085 mouseX = e->x(); 1085 mouseX = e->x();
1086 mouseY = e->y(); 1086 mouseY = e->y();
1087 scrollX = 0; 1087 scrollX = 0;
1088 scrollY = 0; 1088 scrollY = 0;
1089 d = myDoc->fontHeight; 1089 d = myDoc->fontHeight;
1090 if (mouseX < 0) { 1090 if (mouseX < 0) {
1091 mouseX = 0; 1091 mouseX = 0;
1092 scrollX = -d; 1092 scrollX = -d;
1093 } 1093 }
1094 if (mouseX > width()) { 1094 if (mouseX > width()) {
1095 mouseX = width(); 1095 mouseX = width();
1096 scrollX = d; 1096 scrollX = d;
1097 } 1097 }
1098 if (mouseY < 0) { 1098 if (mouseY < 0) {
1099 mouseY = 0; 1099 mouseY = 0;
1100 scrollY = -d; 1100 scrollY = -d;
1101 } 1101 }
1102 if (mouseY > height()) { 1102 if (mouseY > height()) {
1103 mouseY = height(); 1103 mouseY = height();
1104 scrollY = d; 1104 scrollY = d;
1105 } 1105 }
1106//debug("modifiers %d", ((KGuiCmdApp *) kapp)->getModifiers()); 1106//debug("modifiers %d", ((KGuiCmdApp *) kapp)->getModifiers());
1107 flags = KateView::cfMark; 1107 flags = KateView::cfMark;
1108 if (e->state() & ControlButton) flags |= KateView::cfKeepSelection; 1108 if (e->state() & ControlButton) flags |= KateView::cfKeepSelection;
1109 placeCursor(mouseX, mouseY, flags); 1109 placeCursor(mouseX, mouseY, flags);
1110 myDoc->updateViews(/*ufNoScroll*/); 1110 myDoc->updateViews(/*ufNoScroll*/);
1111 } 1111 }
1112} 1112}
1113 1113
1114 1114
1115 1115
1116void KateViewInternal::wheelEvent( QWheelEvent *e ) 1116void KateViewInternal::wheelEvent( QWheelEvent *e )
1117{ 1117{
1118 if( yScroll->isVisible() == true ) 1118 if( yScroll->isVisible() == true )
1119 { 1119 {
1120 QApplication::sendEvent( yScroll, e ); 1120 QApplication::sendEvent( yScroll, e );
1121 } 1121 }
1122} 1122}
1123 1123
1124 1124
1125 1125
1126void KateViewInternal::paintEvent(QPaintEvent *e) { 1126void KateViewInternal::paintEvent(QPaintEvent *e) {
1127 int xStart, xEnd; 1127 int xStart, xEnd;
1128 int h; 1128 int h;
1129 int line, y, yEnd; 1129 int line, y, yEnd;
1130 1130
1131 QRect updateR = e->rect(); 1131 QRect updateR = e->rect();
1132 1132
1133 if (!drawBuffer) return; 1133 if (!drawBuffer) return;
1134 if (drawBuffer->isNull()) return; 1134 if (drawBuffer->isNull()) return;
1135 1135
1136 QPainter paint; 1136 QPainter paint;
1137 paint.begin(drawBuffer); 1137 paint.begin(drawBuffer);
1138 1138
1139 xStart = xPos-2 + updateR.x(); 1139 xStart = xPos-2 + updateR.x();
1140 xEnd = xStart + updateR.width(); 1140 xEnd = xStart + updateR.width();
1141 1141
1142 h = myDoc->fontHeight; 1142 h = myDoc->fontHeight;
1143 line = (yPos + updateR.y()) / h; 1143 line = (yPos + updateR.y()) / h;
1144 y = line*h - yPos; 1144 y = line*h - yPos;
1145 yEnd = updateR.y() + updateR.height(); 1145 yEnd = updateR.y() + updateR.height();
1146 waitForPreHighlight=myDoc->needPreHighlight(waitForPreHighlight=line+((long)(yEnd-y)/h)+5); 1146 waitForPreHighlight=myDoc->needPreHighlight(waitForPreHighlight=line+((long)(yEnd-y)/h)+5);
1147 1147
1148 while (y < yEnd) 1148 while (y < yEnd)
1149 { 1149 {
1150 TextLine *textLine; 1150 TextLine *textLine;
1151 int ctxNum = 0; 1151 int ctxNum = 0;
1152 myDoc->paintTextLine(paint, line, xStart, xEnd, myView->configFlags & KateView::cfShowTabs); 1152 myDoc->paintTextLine(paint, line, xStart, xEnd, myView->configFlags & KateView::cfShowTabs);
1153 bitBlt(this, updateR.x(), y, drawBuffer, 0, 0, updateR.width(), h); 1153 bitBlt(this, updateR.x(), y, drawBuffer, 0, 0, updateR.width(), h);
1154 leftBorder->paintLine(line); 1154 leftBorder->paintLine(line);
1155 line++; 1155 line++;
1156 y += h; 1156 y += h;
1157 } 1157 }
1158 paint.end(); 1158 paint.end();
1159 1159
1160 if (cursorOn) paintCursor(); 1160 if (cursorOn) paintCursor();
1161 if (bm.eXPos > bm.sXPos) paintBracketMark(); 1161 if (bm.eXPos > bm.sXPos) paintBracketMark();
1162} 1162}
1163 1163
1164void KateViewInternal::resizeEvent(QResizeEvent *) 1164void KateViewInternal::resizeEvent(QResizeEvent *)
1165{ 1165{
1166 drawBuffer->resize (width(), myDoc->fontHeight); 1166 drawBuffer->resize (width(), myDoc->fontHeight);
1167 leftBorder->resize(iconBorderWidth, height()); 1167 leftBorder->resize(iconBorderWidth, height());
1168} 1168}
1169 1169
1170void KateViewInternal::timerEvent(QTimerEvent *e) { 1170void KateViewInternal::timerEvent(QTimerEvent *e) {
1171 if (e->timerId() == cursorTimer) { 1171 if (e->timerId() == cursorTimer) {
1172 cursorOn = !cursorOn; 1172 cursorOn = !cursorOn;
1173 paintCursor(); 1173 paintCursor();
1174 } 1174 }
1175 if (e->timerId() == scrollTimer && (scrollX | scrollY)) { 1175 if (e->timerId() == scrollTimer && (scrollX | scrollY)) {
1176 xScroll->setValue(xPos + scrollX); 1176 xScroll->setValue(xPos + scrollX);
1177 yScroll->setValue(yPos + scrollY); 1177 yScroll->setValue(yPos + scrollY);
1178 1178
1179 placeCursor(mouseX, mouseY, KateView::cfMark); 1179 placeCursor(mouseX, mouseY, KateView::cfMark);
1180 myDoc->updateViews(/*ufNoScroll*/); 1180 myDoc->updateViews(/*ufNoScroll*/);
1181 } 1181 }
1182} 1182}
1183 1183
1184uint KateView::uniqueID = 0; 1184uint KateView::uniqueID = 0;
1185 1185
1186KateView::KateView(KateDocument *doc, QWidget *parent, const char * name) : Kate::View (doc, parent, name) 1186KateView::KateView(KateDocument *doc, QWidget *parent, const char * name) : Kate::View (doc, parent, name)
1187{ 1187{
1188 1188
1189 myViewID = uniqueID; 1189 myViewID = uniqueID;
1190 uniqueID++; 1190 uniqueID++;
1191 1191
1192 active = false; 1192 active = false;
1193 myIconBorder = false; 1193 myIconBorder = false;
1194 1194
1195 myDoc = doc; 1195 myDoc = doc;
1196 myViewInternal = new KateViewInternal (this,doc); 1196 myViewInternal = new KateViewInternal (this,doc);
1197 myViewInternal->move(2, 2); 1197 myViewInternal->move(2, 2);
1198 myViewInternal->leftBorder = new KateIconBorder(this, myViewInternal); 1198 myViewInternal->leftBorder = new KateIconBorder(this, myViewInternal);
1199 myViewInternal->leftBorder->setGeometry(2, 2, myViewInternal->iconBorderWidth, myViewInternal->iconBorderHeight); 1199 myViewInternal->leftBorder->setGeometry(2, 2, myViewInternal->iconBorderWidth, myViewInternal->iconBorderHeight);
1200 myViewInternal->leftBorder->hide(); 1200 myViewInternal->leftBorder->hide();
1201 1201
1202 doc->addView( this ); 1202 doc->addView( this );
1203 1203
1204 1204
1205 // some defaults 1205 // some defaults
1206 configFlags = KateView::cfAutoIndent | KateView::cfBackspaceIndents 1206 configFlags = KateView::cfAutoIndent | KateView::cfBackspaceIndents
1207 | KateView::cfTabIndents | KateView::cfKeepIndentProfile 1207 | KateView::cfTabIndents | KateView::cfKeepIndentProfile
1208 | KateView::cfRemoveSpaces 1208 | KateView::cfRemoveSpaces
1209 | KateView::cfDelOnInput | KateView::cfMouseAutoCopy | KateView::cfWrapCursor 1209 | KateView::cfDelOnInput | KateView::cfMouseAutoCopy | KateView::cfWrapCursor
1210 | KateView::cfGroupUndo | KateView::cfShowTabs | KateView::cfSmartHome; 1210 | KateView::cfGroupUndo | KateView::cfShowTabs | KateView::cfSmartHome;
1211 1211
1212 searchFlags = 0; 1212 searchFlags = 0;
1213 replacePrompt = 0L; 1213 replacePrompt = 0L;
1214 rmbMenu = 0L; 1214 rmbMenu = 0L;
1215 1215
1216 1216
1217 setFocusProxy( myViewInternal ); 1217 setFocusProxy( myViewInternal );
1218 myViewInternal->setFocus(); 1218 myViewInternal->setFocus();
1219 resize(parent->width() -4, parent->height() -4); 1219 resize(parent->width() -4, parent->height() -4);
1220 1220
1221 1221
1222 myViewInternal->installEventFilter( this ); 1222 myViewInternal->installEventFilter( this );
1223 1223
1224 //setupActions(); 1224 //setupActions();
1225 1225
1226 connect( this, SIGNAL( newStatus() ), this, SLOT( slotUpdate() ) ); 1226 connect( this, SIGNAL( newStatus() ), this, SLOT( slotUpdate() ) );
1227 connect( this, SIGNAL( newUndo() ), this, SLOT( slotNewUndo() ) ); 1227 connect( this, SIGNAL( newUndo() ), this, SLOT( slotNewUndo() ) );
1228 connect( doc, SIGNAL( fileNameChanged() ), this, SLOT( slotFileStatusChanged() ) ); 1228 connect( doc, SIGNAL( fileNameChanged() ), this, SLOT( slotFileStatusChanged() ) );
1229 connect( doc, SIGNAL( highlightChanged() ), this, SLOT( slotHighlightChanged() ) ); 1229 connect( doc, SIGNAL( highlightChanged() ), this, SLOT( slotHighlightChanged() ) );
1230 1230
1231 readConfig(); 1231 readConfig();
1232// setHighlight->setCurrentItem(getHl()); 1232// setHighlight->setCurrentItem(getHl());
1233 slotUpdate(); 1233 slotUpdate();
1234} 1234}
1235 1235
1236KateView::~KateView() 1236KateView::~KateView()
1237{ 1237{
1238 writeConfig(); 1238 writeConfig();
1239 1239
1240 if (myDoc && !myDoc->m_bSingleViewMode) 1240 if (myDoc && !myDoc->m_bSingleViewMode)
1241 myDoc->removeView( this ); 1241 myDoc->removeView( this );
1242 1242
1243 delete myViewInternal; 1243 delete myViewInternal;
1244} 1244}
1245 1245
1246#if 0 1246#if 0
1247void KateView::setupActions() 1247void KateView::setupActions()
1248{ 1248{
1249#if 0 1249#if 0
1250 KStdAction::close( this, SLOT(flush()), actionCollection(), "file_close" ); 1250 KStdAction::close( this, SLOT(flush()), actionCollection(), "file_close" );
1251 1251
1252 KStdAction::save(this, SLOT(save()), actionCollection()); 1252 KStdAction::save(this, SLOT(save()), actionCollection());
1253 1253
1254 // setup edit menu 1254 // setup edit menu
1255 editUndo = KStdAction::undo(this, SLOT(undo()), actionCollection()); 1255 editUndo = KStdAction::undo(this, SLOT(undo()), actionCollection());
1256 editRedo = KStdAction::redo(this, SLOT(redo()), actionCollection()); 1256 editRedo = KStdAction::redo(this, SLOT(redo()), actionCollection());
1257 editUndoHist = new KAction(i18n("Undo/Redo &History..."), 0, this, SLOT(undoHistory()), 1257 editUndoHist = new KAction(i18n("Undo/Redo &History..."), 0, this, SLOT(undoHistory()),
1258 actionCollection(), "edit_undoHistory"); 1258 actionCollection(), "edit_undoHistory");
1259 KStdAction::cut(this, SLOT(cut()), actionCollection()); 1259 KStdAction::cut(this, SLOT(cut()), actionCollection());
1260 KStdAction::copy(this, SLOT(copy()), actionCollection()); 1260 KStdAction::copy(this, SLOT(copy()), actionCollection());
1261 KStdAction::paste(this, SLOT(paste()), actionCollection()); 1261 KStdAction::paste(this, SLOT(paste()), actionCollection());
1262 1262
1263 if ( myDoc->hasBrowserExtension() ) 1263 if ( myDoc->hasBrowserExtension() )
1264 { 1264 {
1265 KStdAction::saveAs(this, SLOT(saveAs()), myDoc->actionCollection()); 1265 KStdAction::saveAs(this, SLOT(saveAs()), myDoc->actionCollection());
1266 KStdAction::find(this, SLOT(find()), myDoc->actionCollection(), "find"); 1266 KStdAction::find(this, SLOT(find()), myDoc->actionCollection(), "find");
1267 KStdAction::findNext(this, SLOT(findAgain()), myDoc->actionCollection(), "find_again"); 1267 KStdAction::findNext(this, SLOT(findAgain()), myDoc->actionCollection(), "find_again");
1268 KStdAction::findPrev(this, SLOT(findPrev()), myDoc->actionCollection(), "find_prev"); 1268 KStdAction::findPrev(this, SLOT(findPrev()), myDoc->actionCollection(), "find_prev");
1269 KStdAction::gotoLine(this, SLOT(gotoLine()), myDoc->actionCollection(), "goto_line" ); 1269 KStdAction::gotoLine(this, SLOT(gotoLine()), myDoc->actionCollection(), "goto_line" );
1270 new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),myDoc->actionCollection(), "set_confdlg"); 1270 new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),myDoc->actionCollection(), "set_confdlg");
1271 setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, myDoc->actionCollection(), "set_highlight"); 1271 setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, myDoc->actionCollection(), "set_highlight");
1272 KStdAction::selectAll(this, SLOT(selectAll()), myDoc->actionCollection(), "select_all"); 1272 KStdAction::selectAll(this, SLOT(selectAll()), myDoc->actionCollection(), "select_all");
1273 new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()), 1273 new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()),
1274 myDoc->actionCollection(), "unselect_all"); 1274 myDoc->actionCollection(), "unselect_all");
1275 new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()), 1275 new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()),
1276 myDoc->actionCollection(), "invert_select"); 1276 myDoc->actionCollection(), "invert_select");
1277 1277
1278 new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()), 1278 new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()),
1279 myDoc->actionCollection(), "incFontSizes"); 1279 myDoc->actionCollection(), "incFontSizes");
1280 new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()), 1280 new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()),
1281 myDoc->actionCollection(), "decFontSizes"); 1281 myDoc->actionCollection(), "decFontSizes");
1282 } 1282 }
1283 else 1283 else
1284 { 1284 {
1285 KStdAction::saveAs(this, SLOT(saveAs()), actionCollection()); 1285 KStdAction::saveAs(this, SLOT(saveAs()), actionCollection());
1286 KStdAction::find(this, SLOT(find()), actionCollection()); 1286 KStdAction::find(this, SLOT(find()), actionCollection());
1287 KStdAction::findNext(this, SLOT(findAgain()), actionCollection()); 1287 KStdAction::findNext(this, SLOT(findAgain()), actionCollection());
1288 KStdAction::findPrev(this, SLOT(findPrev()), actionCollection(), "edit_find_prev"); 1288 KStdAction::findPrev(this, SLOT(findPrev()), actionCollection(), "edit_find_prev");
1289 KStdAction::gotoLine(this, SLOT(gotoLine()), actionCollection()); 1289 KStdAction::gotoLine(this, SLOT(gotoLine()), actionCollection());
1290 new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),actionCollection(), "set_confdlg"); 1290 new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),actionCollection(), "set_confdlg");
1291 setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, actionCollection(), "set_highlight"); 1291 setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, actionCollection(), "set_highlight");
1292 KStdAction::selectAll(this, SLOT(selectAll()), actionCollection()); 1292 KStdAction::selectAll(this, SLOT(selectAll()), actionCollection());
1293 new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()), 1293 new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()),
1294 actionCollection(), "edit_deselectAll"); 1294 actionCollection(), "edit_deselectAll");
1295 new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()), 1295 new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()),
1296 actionCollection(), "edit_invertSelection"); 1296 actionCollection(), "edit_invertSelection");
1297 1297
1298 new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()), 1298 new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()),
1299 actionCollection(), "incFontSizes"); 1299 actionCollection(), "incFontSizes");
1300 new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()), 1300 new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()),
1301 actionCollection(), "decFontSizes"); 1301 actionCollection(), "decFontSizes");
1302 } 1302 }
1303 1303
1304 new KAction(i18n("Apply Word Wrap"), 0, myDoc, SLOT(applyWordWrap()), actionCollection(), "edit_apply_wordwrap"); 1304 new KAction(i18n("Apply Word Wrap"), 0, myDoc, SLOT(applyWordWrap()), actionCollection(), "edit_apply_wordwrap");
1305 1305
1306 KStdAction::replace(this, SLOT(replace()), actionCollection()); 1306 KStdAction::replace(this, SLOT(replace()), actionCollection());
1307 1307
1308 new KAction(i18n("Editing Co&mmand"), Qt::CTRL+Qt::Key_M, this, SLOT(slotEditCommand()), 1308 new KAction(i18n("Editing Co&mmand"), Qt::CTRL+Qt::Key_M, this, SLOT(slotEditCommand()),
1309 actionCollection(), "edit_cmd"); 1309 actionCollection(), "edit_cmd");
1310 1310
1311 // setup bookmark menu 1311 // setup bookmark menu
1312 bookmarkToggle = new KAction(i18n("Toggle &Bookmark"), Qt::CTRL+Qt::Key_B, this, SLOT(toggleBookmark()), actionCollection(), "edit_bookmarkToggle"); 1312 bookmarkToggle = new KAction(i18n("Toggle &Bookmark"), Qt::CTRL+Qt::Key_B, this, SLOT(toggleBookmark()), actionCollection(), "edit_bookmarkToggle");
1313 bookmarkClear = new KAction(i18n("Clear Bookmarks"), 0, this, SLOT(clearBookmarks()), actionCollection(), "edit_bookmarksClear"); 1313 bookmarkClear = new KAction(i18n("Clear Bookmarks"), 0, this, SLOT(clearBookmarks()), actionCollection(), "edit_bookmarksClear");
1314 1314
1315 // connect settings menu aboutToshow 1315 // connect settings menu aboutToshow
1316 bookmarkMenu = new KActionMenu(i18n("&Bookmarks"), actionCollection(), "bookmarks"); 1316 bookmarkMenu = new KActionMenu(i18n("&Bookmarks"), actionCollection(), "bookmarks");
1317 connect(bookmarkMenu->popupMenu(), SIGNAL(aboutToShow()), this, SLOT(bookmarkMenuAboutToShow())); 1317 connect(bookmarkMenu->popupMenu(), SIGNAL(aboutToShow()), this, SLOT(bookmarkMenuAboutToShow()));
1318 1318
1319 new KToggleAction(i18n("Show &IconBorder"), Key_F6, this, SLOT(toggleIconBorder()), actionCollection(), "view_border"); 1319 new KToggleAction(i18n("Show &IconBorder"), Key_F6, this, SLOT(toggleIconBorder()), actionCollection(), "view_border");
1320 1320
1321 // setup Tools menu 1321 // setup Tools menu
1322 KStdAction::spelling(this, SLOT(spellcheck()), actionCollection()); 1322 KStdAction::spelling(this, SLOT(spellcheck()), actionCollection());
1323 new KAction(i18n("&Indent"), "indent", Qt::CTRL+Qt::Key_I, this, SLOT(indent()), 1323 new KAction(i18n("&Indent"), "indent", Qt::CTRL+Qt::Key_I, this, SLOT(indent()),
1324 actionCollection(), "tools_indent"); 1324 actionCollection(), "tools_indent");
1325 new KAction(i18n("&Unindent"), "unindent", Qt::CTRL+Qt::Key_U, this, SLOT(unIndent()), 1325 new KAction(i18n("&Unindent"), "unindent", Qt::CTRL+Qt::Key_U, this, SLOT(unIndent()),
1326 actionCollection(), "tools_unindent"); 1326 actionCollection(), "tools_unindent");
1327 new KAction(i18n("&Clean Indentation"), 0, this, SLOT(cleanIndent()), 1327 new KAction(i18n("&Clean Indentation"), 0, this, SLOT(cleanIndent()),
1328 actionCollection(), "tools_cleanIndent"); 1328 actionCollection(), "tools_cleanIndent");
1329 new KAction(i18n("C&omment"), CTRL+Qt::Key_NumberSign, this, SLOT(comment()), 1329 new KAction(i18n("C&omment"), CTRL+Qt::Key_NumberSign, this, SLOT(comment()),
1330 actionCollection(), "tools_comment"); 1330 actionCollection(), "tools_comment");
1331 new KAction(i18n("Unco&mment"), CTRL+SHIFT+Qt::Key_NumberSign, this, SLOT(uncomment()), 1331 new KAction(i18n("Unco&mment"), CTRL+SHIFT+Qt::Key_NumberSign, this, SLOT(uncomment()),
1332 actionCollection(), "tools_uncomment"); 1332 actionCollection(), "tools_uncomment");
1333 1333
1334 setVerticalSelection = new KToggleAction(i18n("&Vertical Selection"), Key_F4, this, SLOT(toggleVertical()), 1334 setVerticalSelection = new KToggleAction(i18n("&Vertical Selection"), Key_F4, this, SLOT(toggleVertical()),
1335 actionCollection(), "set_verticalSelect"); 1335 actionCollection(), "set_verticalSelect");
1336 1336
1337 connect(setHighlight, SIGNAL(activated(int)), this, SLOT(setHl(int))); 1337 connect(setHighlight, SIGNAL(activated(int)), this, SLOT(setHl(int)));
1338 QStringList list; 1338 QStringList list;
1339 for (int z = 0; z < HlManager::self()->highlights(); z++) 1339 for (int z = 0; z < HlManager::self()->highlights(); z++)
1340 list.append(HlManager::self()->hlName(z)); 1340 list.append(HlManager::self()->hlName(z));
1341 setHighlight->setItems(list); 1341 setHighlight->setItems(list);
1342 1342
1343 setEndOfLine = new KSelectAction(i18n("&End Of Line"), 0, actionCollection(), "set_eol"); 1343 setEndOfLine = new KSelectAction(i18n("&End Of Line"), 0, actionCollection(), "set_eol");
1344 connect(setEndOfLine, SIGNAL(activated(int)), this, SLOT(setEol(int))); 1344 connect(setEndOfLine, SIGNAL(activated(int)), this, SLOT(setEol(int)));
1345 list.clear(); 1345 list.clear();
1346 list.append("&Unix"); 1346 list.append("&Unix");
1347 list.append("&Windows/Dos"); 1347 list.append("&Windows/Dos");
1348 list.append("&Macintosh"); 1348 list.append("&Macintosh");
1349 setEndOfLine->setItems(list); 1349 setEndOfLine->setItems(list);
1350#endif 1350#endif
1351} 1351}
1352#endif 1352#endif
1353 1353
1354void KateView::slotUpdate() 1354void KateView::slotUpdate()
1355{ 1355{
1356 int cfg = config(); 1356 int cfg = config();
1357 1357
1358#warning fixme setVerticalSelection->setChecked(cfg & KateView::cfVerticalSelect); 1358#warning fixme setVerticalSelection->setChecked(cfg & KateView::cfVerticalSelect);
1359 1359
1360 slotNewUndo(); 1360 slotNewUndo();
1361} 1361}
1362void KateView::slotFileStatusChanged() 1362void KateView::slotFileStatusChanged()
1363{ 1363{
1364 int eol = getEol(); 1364 int eol = getEol();
1365 eol = eol>=1 ? eol : 0; 1365 eol = eol>=1 ? eol : 0;
1366 1366
1367#warning fixme setEndOfLine->setCurrentItem(eol); 1367#warning fixme setEndOfLine->setCurrentItem(eol);
1368} 1368}
1369void KateView::slotNewUndo() 1369void KateView::slotNewUndo()
1370{ 1370{
1371#if 0 1371#if 0
1372 int state = undoState(); 1372 int state = undoState();
1373 1373
1374 editUndoHist->setEnabled(state & 1 || state & 2); 1374 editUndoHist->setEnabled(state & 1 || state & 2);
1375 1375
1376 QString t = i18n("Und&o"); // it would be nicer to fetch the original string 1376 QString t = i18n("Und&o"); // it would be nicer to fetch the original string
1377 if (state & 1) { 1377 if (state & 1) {
1378 editUndo->setEnabled(true); 1378 editUndo->setEnabled(true);
1379 t += ' '; 1379 t += ' ';
1380 t += i18n(undoTypeName(nextUndoType())); 1380 t += i18n(undoTypeName(nextUndoType()));
1381 } else { 1381 } else {
1382 editUndo->setEnabled(false); 1382 editUndo->setEnabled(false);
1383 } 1383 }
1384 editUndo->setText(t); 1384 editUndo->setText(t);
1385 1385
1386 t = i18n("Re&do"); // it would be nicer to fetch the original string 1386 t = i18n("Re&do"); // it would be nicer to fetch the original string
1387 if (state & 2) { 1387 if (state & 2) {
1388 editRedo->setEnabled(true); 1388 editRedo->setEnabled(true);
1389 t += ' '; 1389 t += ' ';
1390 t += i18n(undoTypeName(nextRedoType())); 1390 t += i18n(undoTypeName(nextRedoType()));
1391 } else { 1391 } else {
1392 editRedo->setEnabled(false); 1392 editRedo->setEnabled(false);
1393 } 1393 }
1394 editRedo->setText(t); 1394 editRedo->setText(t);
1395#endif 1395#endif
1396} 1396}
1397 1397
1398void KateView::slotHighlightChanged() 1398void KateView::slotHighlightChanged()
1399{ 1399{
1400// setHighlight->setCurrentItem(getHl()); 1400// setHighlight->setCurrentItem(getHl());
1401} 1401}
1402 1402
1403 1403
1404void KateView::keyPressEvent( QKeyEvent *ev ) 1404void KateView::keyPressEvent( QKeyEvent *ev )
1405{ 1405{
1406 switch ( ev->key() ) 1406 switch ( ev->key() )
1407 { 1407 {
1408 case Key_Left: 1408 case Key_Left:
1409 if ( ev->state() & ShiftButton ) 1409 if ( ev->state() & ShiftButton )
1410 { 1410 {
1411 if ( ev->state() & ControlButton ) 1411 if ( ev->state() & ControlButton )
1412 shiftWordLeft(); 1412 shiftWordLeft();
1413 else 1413 else
1414 shiftCursorLeft(); 1414 shiftCursorLeft();
1415 } 1415 }
1416 else if ( ev->state() & ControlButton ) 1416 else if ( ev->state() & ControlButton )
1417 wordLeft(); 1417 wordLeft();
1418 else 1418 else
1419 cursorLeft(); 1419 cursorLeft();
1420 break; 1420 break;
1421 case Key_Right: 1421 case Key_Right:
1422 if ( ev->state() & ShiftButton ) 1422 if ( ev->state() & ShiftButton )
1423 { 1423 {
1424 if ( ev->state() & ControlButton ) 1424 if ( ev->state() & ControlButton )
1425 shiftWordRight(); 1425 shiftWordRight();
1426 else 1426 else
1427 shiftCursorRight(); 1427 shiftCursorRight();
1428 } 1428 }
1429 else if ( ev->state() & ControlButton ) 1429 else if ( ev->state() & ControlButton )
1430 wordRight(); 1430 wordRight();
1431 else 1431 else
1432 cursorRight(); 1432 cursorRight();
1433 break; 1433 break;
1434 case Key_Home: 1434 case Key_Home:
1435 if ( ev->state() & ShiftButton ) 1435 if ( ev->state() & ShiftButton )
1436 { 1436 {
1437 if ( ev->state() & ControlButton ) 1437 if ( ev->state() & ControlButton )
1438 shiftTop(); 1438 shiftTop();
1439 else 1439 else
1440 shiftHome(); 1440 shiftHome();
1441 } 1441 }
1442 else if ( ev->state() & ControlButton ) 1442 else if ( ev->state() & ControlButton )
1443 top(); 1443 top();
1444 else 1444 else
1445 home(); 1445 home();
1446 break; 1446 break;
1447 case Key_End: 1447 case Key_End:
1448 if ( ev->state() & ShiftButton ) 1448 if ( ev->state() & ShiftButton )
1449 { 1449 {
1450 if ( ev->state() & ControlButton ) 1450 if ( ev->state() & ControlButton )
1451 shiftBottom(); 1451 shiftBottom();
1452 else 1452 else
1453 shiftEnd(); 1453 shiftEnd();
1454 } 1454 }
1455 else if ( ev->state() & ControlButton ) 1455 else if ( ev->state() & ControlButton )
1456 bottom(); 1456 bottom();
1457 else 1457 else
1458 end(); 1458 end();
1459 break; 1459 break;
1460 case Key_Up: 1460 case Key_Up:
1461 if ( ev->state() & ShiftButton ) 1461 if ( ev->state() & ShiftButton )
1462 shiftUp(); 1462 shiftUp();
1463 else if ( ev->state() & ControlButton ) 1463 else if ( ev->state() & ControlButton )
1464 scrollUp(); 1464 scrollUp();
1465 else 1465 else
1466 up(); 1466 up();
1467 break; 1467 break;
1468 case Key_Down: 1468 case Key_Down:
1469 if ( ev->state() & ShiftButton ) 1469 if ( ev->state() & ShiftButton )
1470 shiftDown(); 1470 shiftDown();
1471 else if ( ev->state() & ControlButton ) 1471 else if ( ev->state() & ControlButton )
1472 scrollDown(); 1472 scrollDown();
1473 else 1473 else
1474 down(); 1474 down();
1475 break; 1475 break;
1476 case Key_PageUp: 1476 case Key_PageUp:
1477 if ( ev->state() & ShiftButton ) 1477 if ( ev->state() & ShiftButton )
1478 shiftPageUp(); 1478 shiftPageUp();
1479 else if ( ev->state() & ControlButton ) 1479 else if ( ev->state() & ControlButton )
1480 topOfView(); 1480 topOfView();
1481 else 1481 else
1482 pageUp(); 1482 pageUp();
1483 break; 1483 break;
1484 case Key_PageDown: 1484 case Key_PageDown:
1485 if ( ev->state() & ShiftButton ) 1485 if ( ev->state() & ShiftButton )
1486 shiftPageDown(); 1486 shiftPageDown();
1487 else if ( ev->state() & ControlButton ) 1487 else if ( ev->state() & ControlButton )
1488 bottomOfView(); 1488 bottomOfView();
1489 else 1489 else
1490 pageDown(); 1490 pageDown();
1491 break; 1491 break;
1492 case Key_Return: 1492 case Key_Return:
1493 case Key_Enter: 1493 case Key_Enter:
1494 keyReturn(); 1494 keyReturn();
1495 break; 1495 break;
1496 case Key_Delete: 1496 case Key_Delete:
1497 if ( ev->state() & ControlButton ) 1497 if ( ev->state() & ControlButton )
1498 { 1498 {
1499 VConfig c; 1499 VConfig c;
1500 shiftWordRight(); 1500 shiftWordRight();
1501 myViewInternal->getVConfig(c); 1501 myViewInternal->getVConfig(c);
1502 myDoc->delMarkedText(c); 1502 myDoc->delMarkedText(c);
1503 myViewInternal->update(); 1503 myViewInternal->update();
1504 } 1504 }
1505 else keyDelete(); 1505 else keyDelete();
1506 break; 1506 break;
1507 case Key_Backspace: 1507 case Key_Backspace:
1508 if ( ev->state() & ControlButton ) 1508 if ( ev->state() & ControlButton )
1509 { 1509 {
1510 VConfig c; 1510 VConfig c;
1511 shiftWordLeft(); 1511 shiftWordLeft();
1512 myViewInternal->getVConfig(c); 1512 myViewInternal->getVConfig(c);
1513 myDoc->delMarkedText(c); 1513 myDoc->delMarkedText(c);
1514 myViewInternal->update(); 1514 myViewInternal->update();
1515 } 1515 }
1516 else backspace(); 1516 else backspace();
1517 break; 1517 break;
1518 case Key_Insert: 1518 case Key_Insert:
1519 toggleInsert(); 1519 toggleInsert();
1520 break; 1520 break;
1521 case Key_K: 1521 case Key_K:
1522 if ( ev->state() & ControlButton ) 1522 if ( ev->state() & ControlButton )
1523 { 1523 {
1524 killLine(); 1524 killLine();
1525 break; 1525 break;
1526 } 1526 }
1527 default: 1527 default:
1528 KTextEditor::View::keyPressEvent( ev ); 1528 KTextEditor::View::keyPressEvent( ev );
1529 return; 1529 return;
1530 break; 1530 break;
1531 } 1531 }
1532 ev->accept(); 1532 ev->accept();
1533} 1533}
1534 1534
1535 1535
1536void KateView::setCursorPosition( int line, int col, bool /*mark*/ ) 1536void KateView::setCursorPosition( int line, int col, bool /*mark*/ )
1537{ 1537{
1538 setCursorPositionInternal( line, col ); 1538 setCursorPositionInternal( line, col );
1539} 1539}
1540 1540
1541void KateView::getCursorPosition( int *line, int *col ) 1541void KateView::getCursorPosition( int *line, int *col )
1542{ 1542{
1543 if ( line ) 1543 if ( line )
1544 *line = currentLine(); 1544 *line = currentLine();
1545 1545
1546 if ( col ) 1546 if ( col )
1547 *col = currentColumn(); 1547 *col = currentColumn();
1548} 1548}
1549 1549
1550 1550
1551int KateView::currentLine() { 1551int KateView::currentLine() {
1552 return myViewInternal->cursor.y; 1552 return myViewInternal->cursor.y;
1553} 1553}
1554 1554
1555int KateView::currentColumn() { 1555int KateView::currentColumn() {
1556 return myDoc->currentColumn(myViewInternal->cursor); 1556 return myDoc->currentColumn(myViewInternal->cursor);
1557} 1557}
1558 1558
1559int KateView::currentCharNum() { 1559int KateView::currentCharNum() {
1560 return myViewInternal->cursor.x; 1560 return myViewInternal->cursor.x;
1561} 1561}
1562 1562
1563void KateView::setCursorPositionInternal(int line, int col) { 1563void KateView::setCursorPositionInternal(int line, int col) {
1564 PointStruc cursor; 1564 PointStruc cursor;
1565 1565
1566 cursor.x = col; 1566 cursor.x = col;
1567 cursor.y = line; 1567 cursor.y = line;
1568 myViewInternal->updateCursor(cursor); 1568 myViewInternal->updateCursor(cursor);
1569 myViewInternal->center(); 1569 myViewInternal->center();
1570// myViewInternal->updateView(ufPos, 0, line*myDoc->fontHeight - height()/2); 1570// myViewInternal->updateView(ufPos, 0, line*myDoc->fontHeight - height()/2);
1571// myDoc->updateViews(myViewInternal); //uptade all other views except this one 1571// myDoc->updateViews(myViewInternal); //uptade all other views except this one
1572 myDoc->updateViews(); 1572 myDoc->updateViews();
1573} 1573}
1574 1574
1575int KateView::config() { 1575int KateView::config() {
1576 int flags; 1576 int flags;
1577 1577
1578 flags = configFlags; 1578 flags = configFlags;
1579 if (myDoc->singleSelection()) flags |= KateView::cfSingleSelection; 1579 if (myDoc->singleSelection()) flags |= KateView::cfSingleSelection;
1580 return flags; 1580 return flags;
1581} 1581}
1582 1582
1583void KateView::setConfig(int flags) { 1583void KateView::setConfig(int flags) {
1584 bool updateView; 1584 bool updateView;
1585 1585
1586 // cfSingleSelection is a doc-property 1586 // cfSingleSelection is a doc-property
1587 myDoc->setSingleSelection(flags & KateView::cfSingleSelection); 1587 myDoc->setSingleSelection(flags & KateView::cfSingleSelection);
1588 flags &= ~KateView::cfSingleSelection; 1588 flags &= ~KateView::cfSingleSelection;
1589 1589
1590 if (flags != configFlags) { 1590 if (flags != configFlags) {
1591 // update the view if visibility of tabs has changed 1591 // update the view if visibility of tabs has changed
1592 updateView = (flags ^ configFlags) & KateView::cfShowTabs; 1592 updateView = (flags ^ configFlags) & KateView::cfShowTabs;
1593 configFlags = flags; 1593 configFlags = flags;
1594 emit newStatus(); 1594 emit newStatus();
1595 if (updateView) myViewInternal->update(); 1595 if (updateView) myViewInternal->update();
1596 } 1596 }
1597} 1597}
1598 1598
1599int KateView::tabWidth() { 1599int KateView::tabWidth() {
1600 return myDoc->tabChars; 1600 return myDoc->tabChars;
1601} 1601}
1602 1602
1603void KateView::setTabWidth(int w) { 1603void KateView::setTabWidth(int w) {
1604 myDoc->setTabWidth(w); 1604 myDoc->setTabWidth(w);
1605 myDoc->updateViews(); 1605 myDoc->updateViews();
1606} 1606}
1607 1607
1608void KateView::setEncoding (QString e) { 1608void KateView::setEncoding (QString e) {
1609 myDoc->setEncoding (e); 1609 myDoc->setEncoding (e);
1610 myDoc->updateViews(); 1610 myDoc->updateViews();
1611} 1611}
1612 1612
1613int KateView::undoSteps() { 1613int KateView::undoSteps() {
1614 return myDoc->undoSteps; 1614 return myDoc->undoSteps;
1615} 1615}
1616 1616
1617void KateView::setUndoSteps(int s) { 1617void KateView::setUndoSteps(int s) {
1618 myDoc->setUndoSteps(s); 1618 myDoc->setUndoSteps(s);
1619} 1619}
1620 1620
1621bool KateView::isReadOnly() { 1621bool KateView::isReadOnly() {
1622 return myDoc->readOnly; 1622 return myDoc->readOnly;
1623} 1623}
1624 1624
1625bool KateView::isModified() { 1625bool KateView::isModified() {
1626 return myDoc->modified; 1626 return myDoc->modified;
1627} 1627}
1628 1628
1629void KateView::setReadOnly(bool m) { 1629void KateView::setReadOnly(bool m) {
1630 myDoc->setReadOnly(m); 1630 myDoc->setReadOnly(m);
1631} 1631}
1632 1632
1633void KateView::setModified(bool m) { 1633void KateView::setModified(bool m) {
1634 myDoc->setModified(m); 1634 myDoc->setModified(m);
1635} 1635}
1636 1636
1637bool KateView::isLastView() { 1637bool KateView::isLastView() {
1638 return myDoc->isLastView(1); 1638 return myDoc->isLastView(1);
1639} 1639}
1640 1640
1641KateDocument *KateView::doc() { 1641KateDocument *KateView::doc() {
1642 return myDoc; 1642 return myDoc;
1643} 1643}
1644 1644
1645int KateView::undoState() { 1645int KateView::undoState() {
1646 if (isReadOnly()) 1646 if (isReadOnly())
1647 return 0; 1647 return 0;
1648 else 1648 else
1649 return myDoc->undoState; 1649 return myDoc->undoState;
1650} 1650}
1651 1651
1652int KateView::nextUndoType() { 1652int KateView::nextUndoType() {
1653 return myDoc->nextUndoType(); 1653 return myDoc->nextUndoType();
1654} 1654}
1655 1655
1656int KateView::nextRedoType() { 1656int KateView::nextRedoType() {
1657 return myDoc->nextRedoType(); 1657 return myDoc->nextRedoType();
1658} 1658}
1659 1659
1660void KateView::undoTypeList(QValueList<int> &lst) 1660void KateView::undoTypeList(QValueList<int> &lst)
1661{ 1661{
1662 myDoc->undoTypeList(lst); 1662 myDoc->undoTypeList(lst);
1663} 1663}
1664 1664
1665void KateView::redoTypeList(QValueList<int> &lst) 1665void KateView::redoTypeList(QValueList<int> &lst)
1666{ 1666{
1667 myDoc->redoTypeList(lst); 1667 myDoc->redoTypeList(lst);
1668} 1668}
1669 1669
1670const char * KateView::undoTypeName(int type) { 1670const char * KateView::undoTypeName(int type) {
1671 return KateActionGroup::typeName(type); 1671 return KateActionGroup::typeName(type);
1672} 1672}
1673 1673
1674QColor* KateView::getColors() 1674QColor* KateView::getColors()
1675{ 1675{
1676 return myDoc->colors; 1676 return myDoc->colors;
1677} 1677}
1678 1678
1679void KateView::applyColors() 1679void KateView::applyColors()
1680{ 1680{
1681 myDoc->tagAll(); 1681 myDoc->tagAll();
1682 myDoc->updateViews(); 1682 myDoc->updateViews();
1683} 1683}
1684 1684
1685bool KateView::isOverwriteMode() const 1685bool KateView::isOverwriteMode() const
1686{ 1686{
1687 return ( configFlags & KateView::cfOvr ); 1687 return ( configFlags & KateView::cfOvr );
1688} 1688}
1689 1689
1690void KateView::setOverwriteMode( bool b ) 1690void KateView::setOverwriteMode( bool b )
1691{ 1691{
1692 if ( isOverwriteMode() && !b ) 1692 if ( isOverwriteMode() && !b )
1693 setConfig( configFlags ^ KateView::cfOvr ); 1693 setConfig( configFlags ^ KateView::cfOvr );
1694 else 1694 else
1695 setConfig( configFlags | KateView::cfOvr ); 1695 setConfig( configFlags | KateView::cfOvr );
1696} 1696}
1697 1697
1698void KateView::toggleInsert() { 1698void KateView::toggleInsert() {
1699 setConfig(configFlags ^ KateView::cfOvr); 1699 setConfig(configFlags ^ KateView::cfOvr);
1700} 1700}
1701 1701
1702void KateView::toggleVertical() 1702void KateView::toggleVertical()
1703{ 1703{
1704 setConfig(configFlags ^ KateView::cfVerticalSelect); 1704 setConfig(configFlags ^ KateView::cfVerticalSelect);
1705} 1705}
1706 1706
1707 1707
1708int KateView::numLines() { 1708int KateView::numLines() {
1709 return myDoc->numLines(); 1709 return myDoc->numLines();
1710} 1710}
1711 1711
1712QString KateView::text() { 1712QString KateView::text() {
1713 return myDoc->text(); 1713 return myDoc->text();
1714} 1714}
1715 1715
1716QString KateView::currentTextLine() { 1716QString KateView::currentTextLine() {
1717 TextLine::Ptr textLine = myDoc->getTextLine(myViewInternal->cursor.y); 1717 TextLine::Ptr textLine = myDoc->getTextLine(myViewInternal->cursor.y);
1718 return QString(textLine->getText(), textLine->length()); 1718 return QString(textLine->getText(), textLine->length());
1719} 1719}
1720 1720
1721QString KateView::textLine(int num) { 1721QString KateView::textLine(int num) {
1722 TextLine::Ptr textLine = myDoc->getTextLine(num); 1722 TextLine::Ptr textLine = myDoc->getTextLine(num);
1723 return QString(textLine->getText(), textLine->length()); 1723 return QString(textLine->getText(), textLine->length());
1724} 1724}
1725 1725
1726QString KateView::currentWord() { 1726QString KateView::currentWord() {
1727 return myDoc->getWord(myViewInternal->cursor); 1727 return myDoc->getWord(myViewInternal->cursor);
1728} 1728}
1729 1729
1730QString KateView::word(int x, int y) { 1730QString KateView::word(int x, int y) {
1731 PointStruc cursor; 1731 PointStruc cursor;
1732 cursor.y = (myViewInternal->yPos + y)/myDoc->fontHeight; 1732 cursor.y = (myViewInternal->yPos + y)/myDoc->fontHeight;
1733 if (cursor.y < 0 || cursor.y > myDoc->lastLine()) return QString(); 1733 if (cursor.y < 0 || cursor.y > myDoc->lastLine()) return QString();
1734 cursor.x = myDoc->textPos(myDoc->getTextLine(cursor.y), myViewInternal->xPos-2 + x); 1734 cursor.x = myDoc->textPos(myDoc->getTextLine(cursor.y), myViewInternal->xPos-2 + x);
1735 return myDoc->getWord(cursor); 1735 return myDoc->getWord(cursor);
1736} 1736}
1737 1737
1738void KateView::setText(const QString &s) { 1738void KateView::setText(const QString &s) {
1739 myDoc->setText(s); 1739 myDoc->setText(s);
1740 myDoc->updateViews(); 1740 myDoc->updateViews();
1741} 1741}
1742 1742
1743void KateView::insertText(const QString &s, bool /*mark*/) { 1743void KateView::insertText(const QString &s, bool /*mark*/) {
1744 VConfig c; 1744 VConfig c;
1745 myViewInternal->getVConfig(c); 1745 myViewInternal->getVConfig(c);
1746 myDoc->insert(c, s); 1746 myDoc->insert(c, s);
1747 myDoc->updateViews(); 1747 myDoc->updateViews();
1748} 1748}
1749 1749
1750bool KateView::hasMarkedText() { 1750bool KateView::hasMarkedText() {
1751 return myDoc->hasMarkedText(); 1751 return myDoc->hasMarkedText();
1752} 1752}
1753 1753
1754QString KateView::markedText() { 1754QString KateView::markedText() {
1755 return myDoc->markedText(configFlags); 1755 return myDoc->markedText(configFlags);
1756} 1756}
1757 1757
1758bool KateView::canDiscard() { 1758bool KateView::canDiscard() {
1759 int query; 1759 int query;
1760 1760
1761 if (isModified()) { 1761 if (isModified()) {
1762 query = KMessageBox::warningYesNoCancel(this, 1762 query = KMessageBox::warningYesNoCancel(this,
1763 i18n("The current Document has been modified.\nWould you like to save it?")); 1763 i18n("The current Document has been modified.\nWould you like to save it?"));
1764 switch (query) { 1764 switch (query) {
1765 case KMessageBox::Yes: //yes 1765 case KMessageBox::Yes: //yes
1766 if (save() == CANCEL) return false; 1766 if (save() == CANCEL) return false;
1767 if (isModified()) { 1767 if (isModified()) {
1768 query = KMessageBox::warningContinueCancel(this, 1768 query = KMessageBox::warningContinueCancel(this,
1769 i18n("Could not save the document.\nDiscard it and continue?"), 1769 i18n("Could not save the document.\nDiscard it and continue?"),
1770 QString::null, i18n("&Discard")); 1770 QString::null, i18n("&Discard"));
1771 if (query == KMessageBox::Cancel) return false; 1771 if (query == KMessageBox::Cancel) return false;
1772 } 1772 }
1773 break; 1773 break;
1774 case KMessageBox::Cancel: //cancel 1774 case KMessageBox::Cancel: //cancel
1775 return false; 1775 return false;
1776 } 1776 }
1777 } 1777 }
1778 return true; 1778 return true;
1779} 1779}
1780 1780
1781void KateView::flush() 1781void KateView::flush()
1782{ 1782{
1783 if (canDiscard()) myDoc->flush(); 1783 if (canDiscard()) myDoc->flush();
1784} 1784}
1785 1785
1786KateView::fileResult KateView::save() { 1786KateView::fileResult KateView::save() {
1787 int query = KMessageBox::Yes; 1787 int query = KMessageBox::Yes;
1788 if (isModified()) { 1788 if (isModified()) {
1789 return saveAs(); 1789 return saveAs();
1790 } 1790 }
1791 return OK; 1791 return OK;
1792} 1792}
1793 1793
1794KateView::fileResult KateView::saveAs() { 1794KateView::fileResult KateView::saveAs() {
1795 return OK; 1795 return OK;
1796} 1796}
1797 1797
1798void KateView::doCursorCommand(int cmdNum) { 1798void KateView::doCursorCommand(int cmdNum) {
1799 VConfig c; 1799 VConfig c;
1800 myViewInternal->getVConfig(c); 1800 myViewInternal->getVConfig(c);
1801 if (cmdNum & selectFlag) c.flags |= KateView::cfMark; 1801 if (cmdNum & selectFlag) c.flags |= KateView::cfMark;
1802 if (cmdNum & multiSelectFlag) c.flags |= KateView::cfMark | KateView::cfKeepSelection; 1802 if (cmdNum & multiSelectFlag) c.flags |= KateView::cfMark | KateView::cfKeepSelection;
1803 cmdNum &= ~(selectFlag | multiSelectFlag); 1803 cmdNum &= ~(selectFlag | multiSelectFlag);
1804 myViewInternal->doCursorCommand(c, cmdNum); 1804 myViewInternal->doCursorCommand(c, cmdNum);
1805 myDoc->updateViews(); 1805 myDoc->updateViews();
1806} 1806}
1807 1807
1808void KateView::doEditCommand(int cmdNum) { 1808void KateView::doEditCommand(int cmdNum) {
1809 VConfig c; 1809 VConfig c;
1810 myViewInternal->getVConfig(c); 1810 myViewInternal->getVConfig(c);
1811 myViewInternal->doEditCommand(c, cmdNum); 1811 myViewInternal->doEditCommand(c, cmdNum);
1812 myDoc->updateViews(); 1812 myDoc->updateViews();
1813} 1813}
1814 1814
1815void KateView::undoMultiple(int count) { 1815void KateView::undoMultiple(int count) {
1816 if (isReadOnly()) 1816 if (isReadOnly())
1817 return; 1817 return;
1818 1818
1819 VConfig c; 1819 VConfig c;
1820 myViewInternal->getVConfig(c); 1820 myViewInternal->getVConfig(c);
1821 myDoc->undo(c, count); 1821 myDoc->undo(c, count);
1822 myDoc->updateViews(); 1822 myDoc->updateViews();
1823} 1823}
1824 1824
1825void KateView::redoMultiple(int count) { 1825void KateView::redoMultiple(int count) {
1826 if (isReadOnly()) 1826 if (isReadOnly())
1827 return; 1827 return;
1828 1828
1829 VConfig c; 1829 VConfig c;
1830 myViewInternal->getVConfig(c); 1830 myViewInternal->getVConfig(c);
1831 myDoc->redo(c, count); 1831 myDoc->redo(c, count);
1832 myDoc->updateViews(); 1832 myDoc->updateViews();
1833} 1833}
1834 1834
1835void KateView::undoHistory() 1835void KateView::undoHistory()
1836{ 1836{
1837 UndoHistory *undoH; 1837 UndoHistory *undoH;
1838 1838
1839 undoH = new UndoHistory(this, this, "UndoHistory", true); 1839 undoH = new UndoHistory(this, this, "UndoHistory", true);
1840 1840
1841 undoH->setCaption(i18n("Undo/Redo History")); 1841 undoH->setCaption(i18n("Undo/Redo History"));
1842 1842
1843 connect(this,SIGNAL(newUndo()),undoH,SLOT(newUndo())); 1843 connect(this,SIGNAL(newUndo()),undoH,SLOT(newUndo()));
1844 connect(undoH,SIGNAL(undo(int)),this,SLOT(undoMultiple(int))); 1844 connect(undoH,SIGNAL(undo(int)),this,SLOT(undoMultiple(int)));
1845 connect(undoH,SIGNAL(redo(int)),this,SLOT(redoMultiple(int))); 1845 connect(undoH,SIGNAL(redo(int)),this,SLOT(redoMultiple(int)));
1846 1846
1847 undoH->exec(); 1847 undoH->exec();
1848 1848
1849 delete undoH; 1849 delete undoH;
1850} 1850}
1851 1851
1852static void kwview_addToStrList(QStringList &list, const QString &str) { 1852static void kwview_addToStrList(QStringList &list, const QString &str) {
1853 if (list.count() > 0) { 1853 if (list.count() > 0) {
1854 if (list.first() == str) return; 1854 if (list.first() == str) return;
1855 QStringList::Iterator it; 1855 QStringList::Iterator it;
1856 it = list.find(str); 1856 it = list.find(str);
1857 if (*it != 0L) list.remove(it); 1857 if (*it != 0L) list.remove(it);
1858 if (list.count() >= 16) list.remove(list.fromLast()); 1858 if (list.count() >= 16) list.remove(list.fromLast());
1859 } 1859 }
1860 list.prepend(str); 1860 list.prepend(str);
1861} 1861}
1862 1862
1863void KateView::find() { 1863void KateView::find() {
1864 SearchDialog *searchDialog; 1864 SearchDialog *searchDialog;
1865 1865
1866 if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected; 1866 if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected;
1867 1867
1868 searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList, 1868 searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList,
1869 searchFlags & ~KateView::sfReplace); 1869 searchFlags & ~KateView::sfReplace);
1870 1870
1871 // If the user has marked some text we use that otherwise 1871 // If the user has marked some text we use that otherwise
1872 // use the word under the cursor. 1872 // use the word under the cursor.
1873 QString str; 1873 QString str;
1874 if (myDoc->hasMarkedText()) 1874 if (myDoc->hasMarkedText())
1875 str = markedText(); 1875 str = markedText();
1876 1876
1877 if (str.isEmpty()) 1877 if (str.isEmpty())
1878 str = currentWord(); 1878 str = currentWord();
1879 1879
1880 if (!str.isEmpty()) 1880 if (!str.isEmpty())
1881 { 1881 {
1882 str.replace(QRegExp("^\n"), ""); 1882 str.replace(QRegExp("^\n"), "");
1883 int pos=str.find("\n"); 1883 int pos=str.find("\n");
1884 if (pos>-1) 1884 if (pos>-1)
1885 str=str.left(pos); 1885 str=str.left(pos);
1886 searchDialog->setSearchText( str ); 1886 searchDialog->setSearchText( str );
1887 } 1887 }
1888 1888
1889 myViewInternal->focusOutEvent(0L);// QT bug ? 1889 myViewInternal->focusOutEvent(0L);// QT bug ?
1890 if (searchDialog->exec() == QDialog::Accepted) { 1890 if (searchDialog->exec() == QDialog::Accepted) {
1891 kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor()); 1891 kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor());
1892 searchFlags = searchDialog->getFlags() | (searchFlags & KateView::sfPrompt); 1892 searchFlags = searchDialog->getFlags() | (searchFlags & KateView::sfPrompt);
1893 initSearch(s, searchFlags); 1893 initSearch(s, searchFlags);
1894 findAgain(s); 1894 findAgain(s);
1895 } 1895 }
1896 qApp->processEvents(); 1896 qApp->processEvents();
1897 delete searchDialog; 1897 delete searchDialog;
1898} 1898}
1899 1899
1900void KateView::replace() { 1900void KateView::replace() {
1901 SearchDialog *searchDialog; 1901 SearchDialog *searchDialog;
1902 1902
1903 if (isReadOnly()) return; 1903 if (isReadOnly()) return;
1904 1904
1905 if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected; 1905 if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected;
1906 searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList, 1906 searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList,
1907 searchFlags | KateView::sfReplace); 1907 searchFlags | KateView::sfReplace);
1908 1908
1909 // If the user has marked some text we use that otherwise 1909 // If the user has marked some text we use that otherwise
1910 // use the word under the cursor. 1910 // use the word under the cursor.
1911 QString str; 1911 QString str;
1912 if (myDoc->hasMarkedText()) 1912 if (myDoc->hasMarkedText())
1913 str = markedText(); 1913 str = markedText();
1914 1914
1915 if (str.isEmpty()) 1915 if (str.isEmpty())
1916 str = currentWord(); 1916 str = currentWord();
1917 1917
1918 if (!str.isEmpty()) 1918 if (!str.isEmpty())
1919 { 1919 {
1920 str.replace(QRegExp("^\n"), ""); 1920 str.replace(QRegExp("^\n"), "");
1921 int pos=str.find("\n"); 1921 int pos=str.find("\n");
1922 if (pos>-1) 1922 if (pos>-1)
1923 str=str.left(pos); 1923 str=str.left(pos);
1924 searchDialog->setSearchText( str ); 1924 searchDialog->setSearchText( str );
1925 } 1925 }
1926 1926
1927 myViewInternal->focusOutEvent(0L);// QT bug ? 1927 myViewInternal->focusOutEvent(0L);// QT bug ?
1928 if (searchDialog->exec() == QDialog::Accepted) { 1928 if (searchDialog->exec() == QDialog::Accepted) {
1929// myDoc->recordReset(); 1929// myDoc->recordReset();
1930 kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor()); 1930 kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor());
1931 kwview_addToStrList(myDoc->replaceWithList, searchDialog->getReplaceWith()); 1931 kwview_addToStrList(myDoc->replaceWithList, searchDialog->getReplaceWith());
1932 searchFlags = searchDialog->getFlags(); 1932 searchFlags = searchDialog->getFlags();
1933 initSearch(s, searchFlags); 1933 initSearch(s, searchFlags);
1934 replaceAgain(); 1934 replaceAgain();
1935 } 1935 }
1936 qApp->processEvents(); 1936 qApp->processEvents();
1937 delete searchDialog; 1937 delete searchDialog;
1938} 1938}
1939 1939
1940void KateView::gotoLine() { 1940void KateView::gotoLine() {
1941 GotoLineDialog *dlg; 1941 GotoLineDialog *dlg;
1942 PointStruc cursor; 1942 PointStruc cursor;
1943 1943
1944 dlg = new GotoLineDialog(this, myViewInternal->cursor.y + 1, myDoc->numLines()); 1944 dlg = new GotoLineDialog(this, myViewInternal->cursor.y + 1, myDoc->numLines());
1945// dlg = new GotoLineDialog(myViewInternal->cursor.y + 1, this); 1945// dlg = new GotoLineDialog(myViewInternal->cursor.y + 1, this);
1946 1946
1947 if (dlg->exec() == QDialog::Accepted) { 1947 if (dlg->exec() == QDialog::Accepted) {
1948// myDoc->recordReset(); 1948// myDoc->recordReset();
1949 cursor.x = 0; 1949 cursor.x = 0;
1950 cursor.y = dlg->getLine() - 1; 1950 cursor.y = dlg->getLine() - 1;
1951 myDoc->needPreHighlight(cursor.y); 1951 myDoc->needPreHighlight(cursor.y);
1952 myViewInternal->updateCursor(cursor); 1952 myViewInternal->updateCursor(cursor);
1953 myViewInternal->center(); 1953 myViewInternal->center();
1954 myViewInternal->updateView(KateView::ufUpdateOnScroll); 1954 myViewInternal->updateView(KateView::ufUpdateOnScroll);
1955 myDoc->updateViews(this); //uptade all other views except this one 1955 myDoc->updateViews(this); //uptade all other views except this one
1956 } 1956 }
1957 qApp->processEvents(); 1957 qApp->processEvents();
1958 delete dlg; 1958 delete dlg;
1959} 1959}
1960 1960
1961 1961
1962void KateView::initSearch(SConfig &s, int flags) { 1962void KateView::initSearch(SConfig &s, int flags) {
1963 1963
1964 s.flags = flags; 1964 s.flags = flags;
1965 s.setPattern(myDoc->searchForList.first()); 1965 s.setPattern(myDoc->searchForList.first());
1966 1966
1967 if (!(s.flags & KateView::sfFromBeginning)) { 1967 if (!(s.flags & KateView::sfFromBeginning)) {
1968 // If we are continuing a backward search, make sure we do not get stuck 1968 // If we are continuing a backward search, make sure we do not get stuck
1969 // at an existing match. 1969 // at an existing match.
1970 s.cursor = myViewInternal->cursor; 1970 s.cursor = myViewInternal->cursor;
1971 TextLine::Ptr textLine = myDoc->getTextLine(s.cursor.y); 1971 TextLine::Ptr textLine = myDoc->getTextLine(s.cursor.y);
1972 QString const txt(textLine->getText(),textLine->length()); 1972 QString const txt(textLine->getText(),textLine->length());
1973 const QString searchFor= myDoc->searchForList.first(); 1973 const QString searchFor= myDoc->searchForList.first();
1974 int pos = s.cursor.x-searchFor.length()-1; 1974 int pos = s.cursor.x-searchFor.length()-1;
1975 if ( pos < 0 ) pos = 0; 1975 if ( pos < 0 ) pos = 0;
1976 pos= txt.find(searchFor, pos, s.flags & KateView::sfCaseSensitive); 1976 pos= txt.find(searchFor, pos, s.flags & KateView::sfCaseSensitive);
1977 if ( s.flags & KateView::sfBackward ) 1977 if ( s.flags & KateView::sfBackward )
1978 { 1978 {
1979 if ( pos <= s.cursor.x ) s.cursor.x= pos-1; 1979 if ( pos <= s.cursor.x ) s.cursor.x= pos-1;
1980 } 1980 }
1981 else 1981 else
1982 if ( pos == s.cursor.x ) s.cursor.x++; 1982 if ( pos == s.cursor.x ) s.cursor.x++;
1983 } else { 1983 } else {
1984 if (!(s.flags & KateView::sfBackward)) { 1984 if (!(s.flags & KateView::sfBackward)) {
1985 s.cursor.x = 0; 1985 s.cursor.x = 0;
1986 s.cursor.y = 0; 1986 s.cursor.y = 0;
1987 } else { 1987 } else {
1988 s.cursor.x = -1; 1988 s.cursor.x = -1;
1989 s.cursor.y = myDoc->lastLine(); 1989 s.cursor.y = myDoc->lastLine();
1990 } 1990 }
1991 s.flags |= KateView::sfFinished; 1991 s.flags |= KateView::sfFinished;
1992 } 1992 }
1993 if (!(s.flags & KateView::sfBackward)) { 1993 if (!(s.flags & KateView::sfBackward)) {
1994 if (!(s.cursor.x || s.cursor.y)) 1994 if (!(s.cursor.x || s.cursor.y))
1995 s.flags |= KateView::sfFinished; 1995 s.flags |= KateView::sfFinished;
1996 } 1996 }
1997 s.startCursor = s.cursor; 1997 s.startCursor = s.cursor;
1998} 1998}
1999 1999
2000void KateView::continueSearch(SConfig &s) { 2000void KateView::continueSearch(SConfig &s) {
2001 2001
2002 if (!(s.flags & KateView::sfBackward)) { 2002 if (!(s.flags & KateView::sfBackward)) {
2003 s.cursor.x = 0; 2003 s.cursor.x = 0;
2004 s.cursor.y = 0; 2004 s.cursor.y = 0;
2005 } else { 2005 } else {
2006 s.cursor.x = -1; 2006 s.cursor.x = -1;
2007 s.cursor.y = myDoc->lastLine(); 2007 s.cursor.y = myDoc->lastLine();
2008 } 2008 }
2009 s.flags |= KateView::sfFinished; 2009 s.flags |= KateView::sfFinished;
2010 s.flags &= ~KateView::sfAgain; 2010 s.flags &= ~KateView::sfAgain;
2011} 2011}
2012 2012
2013void KateView::findAgain(SConfig &s) { 2013void KateView::findAgain(SConfig &s) {
2014 int query; 2014 int query;
2015 PointStruc cursor; 2015 PointStruc cursor;
2016 QString str; 2016 QString str;
2017 2017
2018 QString searchFor = myDoc->searchForList.first(); 2018 QString searchFor = myDoc->searchForList.first();
2019 2019
2020 if( searchFor.isEmpty() ) { 2020 if( searchFor.isEmpty() ) {
2021 find(); 2021 find();
2022 return; 2022 return;
2023 } 2023 }
2024 2024
2025 do { 2025 do {
2026 query = KMessageBox::Cancel; 2026 query = KMessageBox::Cancel;
2027 if (myDoc->doSearch(s,searchFor)) { 2027 if (myDoc->doSearch(s,searchFor)) {
2028 cursor = s.cursor; 2028 cursor = s.cursor;
2029 if (!(s.flags & KateView::sfBackward)) 2029 if (!(s.flags & KateView::sfBackward))
2030 s.cursor.x += s.matchedLength; 2030 s.cursor.x += s.matchedLength;
2031 myViewInternal->updateCursor(s.cursor); //does deselectAll() 2031 myViewInternal->updateCursor(s.cursor); //does deselectAll()
2032 exposeFound(cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,false); 2032 exposeFound(cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,false);
2033 } else { 2033 } else {
2034 if (!(s.flags & KateView::sfFinished)) { 2034 if (!(s.flags & KateView::sfFinished)) {
2035 // ask for continue 2035 // ask for continue
2036 if (!(s.flags & KateView::sfBackward)) { 2036 if (!(s.flags & KateView::sfBackward)) {
2037 // forward search 2037 // forward search
2038 str = i18n("End of document reached.\n" 2038 str = i18n("End of document reached.\n"
2039 "Continue from the beginning?"); 2039 "Continue from the beginning?");
2040 query = KMessageBox::warningContinueCancel(this, 2040 query = KMessageBox::warningContinueCancel(this,
2041 str, i18n("Find"), i18n("Continue")); 2041 str, i18n("Find"), i18n("Continue"));
2042 } else { 2042 } else {
2043 // backward search 2043 // backward search
2044 str = i18n("Beginning of document reached.\n" 2044 str = i18n("Beginning of document reached.\n"
2045 "Continue from the end?"); 2045 "Continue from the end?");
2046 query = KMessageBox::warningContinueCancel(this, 2046 query = KMessageBox::warningContinueCancel(this,
2047 str, i18n("Find"), i18n("Continue")); 2047 str, i18n("Find"), i18n("Continue"));
2048 } 2048 }
2049 continueSearch(s); 2049 continueSearch(s);
2050 } else { 2050 } else {
2051 // wrapped 2051 // wrapped
2052 KMessageBox::sorry(this, 2052 KMessageBox::sorry(this,
2053 i18n("Search string '%1' not found!").arg(searchFor), 2053 i18n("Search string '%1' not found!").arg(searchFor),
2054 i18n("Find")); 2054 i18n("Find"));
2055 } 2055 }
2056 } 2056 }
2057 } while (query == KMessageBox::Continue); 2057 } while (query == KMessageBox::Continue);
2058} 2058}
2059 2059
2060void KateView::replaceAgain() { 2060void KateView::replaceAgain() {
2061 if (isReadOnly()) 2061 if (isReadOnly())
2062 return; 2062 return;
2063 2063
2064 replaces = 0; 2064 replaces = 0;
2065 if (s.flags & KateView::sfPrompt) { 2065 if (s.flags & KateView::sfPrompt) {
2066 doReplaceAction(-1); 2066 doReplaceAction(-1);
2067 } else { 2067 } else {
2068 doReplaceAction(KateView::srAll); 2068 doReplaceAction(KateView::srAll);
2069 } 2069 }
2070} 2070}
2071 2071
2072void KateView::doReplaceAction(int result, bool found) { 2072void KateView::doReplaceAction(int result, bool found) {
2073 int rlen; 2073 int rlen;
2074 PointStruc cursor; 2074 PointStruc cursor;
2075 bool started; 2075 bool started;
2076 2076
2077 QString searchFor = myDoc->searchForList.first(); 2077 QString searchFor = myDoc->searchForList.first();
2078 QString replaceWith = myDoc->replaceWithList.first(); 2078 QString replaceWith = myDoc->replaceWithList.first();
2079 rlen = replaceWith.length(); 2079 rlen = replaceWith.length();
2080 2080
2081 switch (result) { 2081 switch (result) {
2082 case KateView::srYes: //yes 2082 case KateView::srYes: //yes
2083 myDoc->recordStart(this, s.cursor, configFlags, 2083 myDoc->recordStart(this, s.cursor, configFlags,
2084 KateActionGroup::ugReplace, true); 2084 KateActionGroup::ugReplace, true);
2085 myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith); 2085 myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith);
2086 replaces++; 2086 replaces++;
2087 if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x) 2087 if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x)
2088 s.startCursor.x += rlen - s.matchedLength; 2088 s.startCursor.x += rlen - s.matchedLength;
2089 if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen; 2089 if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen;
2090 myDoc->recordEnd(this, s.cursor, configFlags | KateView::cfPersistent); 2090 myDoc->recordEnd(this, s.cursor, configFlags | KateView::cfPersistent);
2091 break; 2091 break;
2092 case KateView::srNo: //no 2092 case KateView::srNo: //no
2093 if (!(s.flags & KateView::sfBackward)) s.cursor.x += s.matchedLength; 2093 if (!(s.flags & KateView::sfBackward)) s.cursor.x += s.matchedLength;
2094 break; 2094 break;
2095 case KateView::srAll: //replace all 2095 case KateView::srAll: //replace all
2096 deleteReplacePrompt(); 2096 deleteReplacePrompt();
2097 do { 2097 do {
2098 started = false; 2098 started = false;
2099 while (found || myDoc->doSearch(s,searchFor)) { 2099 while (found || myDoc->doSearch(s,searchFor)) {
2100 if (!started) { 2100 if (!started) {
2101 found = false; 2101 found = false;
2102 myDoc->recordStart(this, s.cursor, configFlags, 2102 myDoc->recordStart(this, s.cursor, configFlags,
2103 KateActionGroup::ugReplace); 2103 KateActionGroup::ugReplace);
2104 started = true; 2104 started = true;
2105 } 2105 }
2106 myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith); 2106 myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith);
2107 replaces++; 2107 replaces++;
2108 if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x) 2108 if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x)
2109 s.startCursor.x += rlen - s.matchedLength; 2109 s.startCursor.x += rlen - s.matchedLength;
2110 if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen; 2110 if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen;
2111 } 2111 }
2112 if (started) myDoc->recordEnd(this, s.cursor, 2112 if (started) myDoc->recordEnd(this, s.cursor,
2113 configFlags | KateView::cfPersistent); 2113 configFlags | KateView::cfPersistent);
2114 } while (!askReplaceEnd()); 2114 } while (!askReplaceEnd());
2115 return; 2115 return;
2116 case KateView::srCancel: //cancel 2116 case KateView::srCancel: //cancel
2117 deleteReplacePrompt(); 2117 deleteReplacePrompt();
2118 return; 2118 return;
2119 default: 2119 default:
2120 replacePrompt = 0L; 2120 replacePrompt = 0L;
2121 } 2121 }
2122 2122
2123 do { 2123 do {
2124 if (myDoc->doSearch(s,searchFor)) { 2124 if (myDoc->doSearch(s,searchFor)) {
2125 //text found: highlight it, show replace prompt if needed and exit 2125 //text found: highlight it, show replace prompt if needed and exit
2126 cursor = s.cursor; 2126 cursor = s.cursor;
2127 if (!(s.flags & KateView::sfBackward)) cursor.x += s.matchedLength; 2127 if (!(s.flags & KateView::sfBackward)) cursor.x += s.matchedLength;
2128 myViewInternal->updateCursor(cursor); //does deselectAll() 2128 myViewInternal->updateCursor(cursor); //does deselectAll()
2129 exposeFound(s.cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,true); 2129 exposeFound(s.cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,true);
2130 if (replacePrompt == 0L) { 2130 if (replacePrompt == 0L) {
2131 replacePrompt = new ReplacePrompt(this); 2131 replacePrompt = new ReplacePrompt(this);
2132 myDoc->setPseudoModal(replacePrompt);//disable(); 2132 myDoc->setPseudoModal(replacePrompt);//disable();
2133 connect(replacePrompt,SIGNAL(clicked()),this,SLOT(replaceSlot())); 2133 connect(replacePrompt,SIGNAL(clicked()),this,SLOT(replaceSlot()));
2134 replacePrompt->show(); //this is not modal 2134 replacePrompt->show(); //this is not modal
2135 } 2135 }
2136 return; //exit if text found 2136 return; //exit if text found
2137 } 2137 }
2138 //nothing found: repeat until user cancels "repeat from beginning" dialog 2138 //nothing found: repeat until user cancels "repeat from beginning" dialog
2139 } while (!askReplaceEnd()); 2139 } while (!askReplaceEnd());
2140 deleteReplacePrompt(); 2140 deleteReplacePrompt();
2141} 2141}
2142 2142
2143void KateView::exposeFound(PointStruc &cursor, int slen, int flags, bool replace) { 2143void KateView::exposeFound(PointStruc &cursor, int slen, int flags, bool replace) {
2144 int x1, x2, y1, y2, xPos, yPos; 2144 int x1, x2, y1, y2, xPos, yPos;
2145 2145
2146 VConfig c; 2146 VConfig c;
2147 myViewInternal->getVConfig(c); 2147 myViewInternal->getVConfig(c);
2148 myDoc->selectLength(cursor,slen,c.flags); 2148 myDoc->selectLength(cursor,slen,c.flags);
2149 2149
2150 TextLine::Ptr textLine = myDoc->getTextLine(cursor.y); 2150 TextLine::Ptr textLine = myDoc->getTextLine(cursor.y);
2151 x1 = myDoc->textWidth(textLine,cursor.x) -10; 2151 x1 = myDoc->textWidth(textLine,cursor.x) -10;
2152 x2 = myDoc->textWidth(textLine,cursor.x + slen) +20; 2152 x2 = myDoc->textWidth(textLine,cursor.x + slen) +20;
2153 y1 = myDoc->fontHeight*cursor.y -10; 2153 y1 = myDoc->fontHeight*cursor.y -10;
2154 y2 = y1 + myDoc->fontHeight +30; 2154 y2 = y1 + myDoc->fontHeight +30;
2155 2155
2156 xPos = myViewInternal->xPos; 2156 xPos = myViewInternal->xPos;
2157 yPos = myViewInternal->yPos; 2157 yPos = myViewInternal->yPos;
2158 2158
2159 if (x1 < 0) x1 = 0; 2159 if (x1 < 0) x1 = 0;
2160 if (replace) y2 += 90; 2160 if (replace) y2 += 90;
2161 2161
2162 if (x1 < xPos || x2 > xPos + myViewInternal->width()) { 2162 if (x1 < xPos || x2 > xPos + myViewInternal->width()) {
2163 xPos = x2 - myViewInternal->width(); 2163 xPos = x2 - myViewInternal->width();
2164 } 2164 }
2165 if (y1 < yPos || y2 > yPos + myViewInternal->height()) { 2165 if (y1 < yPos || y2 > yPos + myViewInternal->height()) {
2166 xPos = x2 - myViewInternal->width(); 2166 xPos = x2 - myViewInternal->width();
2167 yPos = myDoc->fontHeight*cursor.y - height()/3; 2167 yPos = myDoc->fontHeight*cursor.y - height()/3;
2168 } 2168 }
2169 myViewInternal->setPos(xPos, yPos); 2169 myViewInternal->setPos(xPos, yPos);
2170 myViewInternal->updateView(flags);// | ufPos,xPos,yPos); 2170 myViewInternal->updateView(flags);// | ufPos,xPos,yPos);
2171 myDoc->updateViews(this); 2171 myDoc->updateViews(this);
2172} 2172}
2173 2173
2174void KateView::deleteReplacePrompt() { 2174void KateView::deleteReplacePrompt() {
2175 myDoc->setPseudoModal(0L); 2175 myDoc->setPseudoModal(0L);
2176} 2176}
2177 2177
2178bool KateView::askReplaceEnd() { 2178bool KateView::askReplaceEnd() {
2179 QString str; 2179 QString str;
2180 int query; 2180 int query;
2181 2181
2182 myDoc->updateViews(); 2182 myDoc->updateViews();
2183 if (s.flags & KateView::sfFinished) { 2183 if (s.flags & KateView::sfFinished) {
2184 // replace finished 2184 // replace finished
2185 str = i18n("%1 replacement(s) made").arg(replaces); 2185 str = i18n("%1 replacement(s) made").arg(replaces);
2186 KMessageBox::information(this, str, i18n("Replace")); 2186 KMessageBox::information(this, str, i18n("Replace"));
2187 return true; 2187 return true;
2188 } 2188 }
2189 2189
2190 // ask for continue 2190 // ask for continue
2191 if (!(s.flags & KateView::sfBackward)) { 2191 if (!(s.flags & KateView::sfBackward)) {
2192 // forward search 2192 // forward search
2193 str = i18n("%1 replacement(s) made.\n" 2193 str = i18n("%1 replacement(s) made.\n"
2194 "End of document reached.\n" 2194 "End of document reached.\n"
2195 "Continue from the beginning?").arg(replaces); 2195 "Continue from the beginning?").arg(replaces);
2196 query = KMessageBox::questionYesNo(this, str, i18n("Replace"), 2196 query = KMessageBox::questionYesNo(this, str, i18n("Replace"),
2197 i18n("Continue"), i18n("Stop")); 2197 i18n("Continue"), i18n("Stop"));
2198 } else { 2198 } else {
2199 // backward search 2199 // backward search
2200 str = i18n("%1 replacement(s) made.\n" 2200 str = i18n("%1 replacement(s) made.\n"
2201 "Beginning of document reached.\n" 2201 "Beginning of document reached.\n"
2202 "Continue from the end?").arg(replaces); 2202 "Continue from the end?").arg(replaces);
2203 query = KMessageBox::questionYesNo(this, str, i18n("Replace"), 2203 query = KMessageBox::questionYesNo(this, str, i18n("Replace"),
2204 i18n("Continue"), i18n("Stop")); 2204 i18n("Continue"), i18n("Stop"));
2205 } 2205 }
2206 replaces = 0; 2206 replaces = 0;
2207 continueSearch(s); 2207 continueSearch(s);
2208 return (query == KMessageBox::No); 2208 return (query == KMessageBox::No);
2209} 2209}
2210 2210
2211void KateView::replaceSlot() { 2211void KateView::replaceSlot() {
2212 doReplaceAction(replacePrompt->result(),true); 2212 doReplaceAction(replacePrompt->result(),true);
2213} 2213}
2214 2214
2215void KateView::installPopup(QPopupMenu *rmb_Menu) 2215void KateView::installPopup(QPopupMenu *rmb_Menu)
2216{ 2216{
2217 rmbMenu = rmb_Menu; 2217 rmbMenu = rmb_Menu;
2218} 2218}
2219 2219
2220void KateView::readConfig() 2220void KateView::readConfig()
2221{ 2221{
2222 KateConfig *config = KGlobal::config(); 2222 KateConfig *config = KGlobal::config();
2223 config->setGroup("Kate View"); 2223 config->setGroup("Kate View");
2224 2224
2225 searchFlags = config->readNumEntry("SearchFlags", KateView::sfPrompt); 2225 searchFlags = config->readNumEntry("SearchFlags", KateView::sfPrompt);
2226 configFlags = config->readNumEntry("ConfigFlags", configFlags) & ~KateView::cfMark; 2226 configFlags = config->readNumEntry("ConfigFlags", configFlags) & ~KateView::cfMark;
2227 2227
2228// config->sync(); 2228// config->sync();
2229} 2229}
2230 2230
2231void KateView::writeConfig() 2231void KateView::writeConfig()
2232{ 2232{
2233 KateConfig *config = KGlobal::config(); 2233 KateConfig *config = KGlobal::config();
2234 config->setGroup("Kate View"); 2234 config->setGroup("Kate View");
2235 2235
2236 config->writeEntry("SearchFlags",searchFlags); 2236 config->writeEntry("SearchFlags",searchFlags);
2237 config->writeEntry("ConfigFlags",configFlags); 2237 config->writeEntry("ConfigFlags",configFlags);
2238 2238
2239// config->sync(); 2239// config->sync();
2240} 2240}
2241 2241
2242void KateView::readSessionConfig(KateConfig *config) 2242void KateView::readSessionConfig(KateConfig *config)
2243{ 2243{
2244 PointStruc cursor; 2244 PointStruc cursor;
2245 2245
2246 myViewInternal->xPos = config->readNumEntry("XPos"); 2246 myViewInternal->xPos = config->readNumEntry("XPos");
2247 myViewInternal->yPos = config->readNumEntry("YPos"); 2247 myViewInternal->yPos = config->readNumEntry("YPos");
2248 cursor.x = config->readNumEntry("CursorX"); 2248 cursor.x = config->readNumEntry("CursorX");
2249 cursor.y = config->readNumEntry("CursorY"); 2249 cursor.y = config->readNumEntry("CursorY");
2250 myViewInternal->updateCursor(cursor); 2250 myViewInternal->updateCursor(cursor);
2251 myIconBorder = config->readBoolEntry("IconBorder on"); 2251 myIconBorder = config->readBoolEntry("IconBorder on");
2252 setIconBorder(myIconBorder); 2252 setIconBorder(myIconBorder);
2253} 2253}
2254 2254
2255void KateView::writeSessionConfig(KateConfig *config) 2255void KateView::writeSessionConfig(KateConfig *config)
2256{ 2256{
2257 config->writeEntry("XPos",myViewInternal->xPos); 2257 config->writeEntry("XPos",myViewInternal->xPos);
2258 config->writeEntry("YPos",myViewInternal->yPos); 2258 config->writeEntry("YPos",myViewInternal->yPos);
2259 config->writeEntry("CursorX",myViewInternal->cursor.x); 2259 config->writeEntry("CursorX",myViewInternal->cursor.x);
2260 config->writeEntry("CursorY",myViewInternal->cursor.y); 2260 config->writeEntry("CursorY",myViewInternal->cursor.y);
2261 config->writeEntry("IconBorder on", myIconBorder); 2261 config->writeEntry("IconBorder on", myIconBorder);
2262} 2262}
2263 2263
2264void KateView::configDialog() 2264void KateView::configDialog()
2265{ 2265{
2266 2266
2267#warning fixme 2267#warning fixme
2268 2268
2269#if 1 2269#if 1
2270 KDialogBase *kd = new KDialogBase(KDialogBase::IconList, 2270 KDialogBase *kd = new KDialogBase(KDialogBase::IconList,
2271 i18n("Configure Editor"), 2271 i18n("Configure Editor"),
2272 KDialogBase::Ok | KDialogBase::Cancel | 2272 KDialogBase::Ok | KDialogBase::Cancel |
2273 KDialogBase::Help , 2273 KDialogBase::Help ,
2274 KDialogBase::Ok, this, "tabdialog"); 2274 KDialogBase::Ok, this, "tabdialog");
2275 2275
2276 // color options 2276 // color options
2277 QFrame *page=kd->addPage(i18n("Colors")); 2277 QFrame *page=kd->addPage(i18n("Colors"));
2278 (new QVBoxLayout(page))->setAutoAdd(true); 2278 (new QVBoxLayout(page))->setAutoAdd(true);
2279 ColorConfig *colorConfig = new ColorConfig(page); 2279 ColorConfig *colorConfig = new ColorConfig(page);
2280 QColor* colors = getColors(); 2280 QColor* colors = getColors();
2281 colorConfig->setColors(colors); 2281 colorConfig->setColors(colors);
2282 2282
2283 page = kd->addPage(i18n("Fonts")); 2283 page = kd->addPage(i18n("Fonts"));
2284 (new QVBoxLayout(page))->setAutoAdd(true); 2284 (new QVBoxLayout(page))->setAutoAdd(true);
2285 2285
2286 FontConfig *fontConfig = new FontConfig(page); 2286 FontConfig *fontConfig = new FontConfig(page);
2287 fontConfig->setFont (myDoc->getFont()); 2287 fontConfig->setFont (myDoc->getFont());
2288 2288
2289 // indent options 2289 // indent options
2290 page=kd->addPage(i18n("Indent")); 2290 page=kd->addPage(i18n("Indent"));
2291 (new QVBoxLayout(page))->setAutoAdd(true); 2291 (new QVBoxLayout(page))->setAutoAdd(true);
2292 2292
2293 IndentConfigTab *indentConfig = new IndentConfigTab(page, this); 2293 IndentConfigTab *indentConfig = new IndentConfigTab(page, this);
2294 2294
2295 // select options 2295 // select options
2296 page=kd->addPage(i18n("Select")); 2296 page=kd->addPage(i18n("Select"));
2297 (new QVBoxLayout(page))->setAutoAdd(true); 2297 (new QVBoxLayout(page))->setAutoAdd(true);
2298 2298
2299 SelectConfigTab *selectConfig = new SelectConfigTab(page, this); 2299 SelectConfigTab *selectConfig = new SelectConfigTab(page, this);
2300 2300
2301 // edit options 2301 // edit options
2302 page=kd->addPage(i18n("Edit")); 2302 page=kd->addPage(i18n("Edit"));
2303 (new QVBoxLayout(page))->setAutoAdd(true); 2303 (new QVBoxLayout(page))->setAutoAdd(true);
2304 2304
2305 EditConfigTab *editConfig = new EditConfigTab(page, this); 2305 EditConfigTab *editConfig = new EditConfigTab(page, this);
2306 2306
2307 2307
2308 2308
2309 HighlightDialogPage *hlPage; 2309 HighlightDialogPage *hlPage;
2310 HlManager *hlManager; 2310 HlManager *hlManager;
2311 HlDataList hlDataList; 2311 HlDataList hlDataList;
2312 ItemStyleList defaultStyleList; 2312 ItemStyleList defaultStyleList;
2313 2313
2314 hlManager = HlManager::self(); 2314 hlManager = HlManager::self();
2315 2315
2316 defaultStyleList.setAutoDelete(true); 2316 defaultStyleList.setAutoDelete(true);
2317 hlManager->getDefaults(defaultStyleList); 2317 hlManager->getDefaults(defaultStyleList);
2318 2318
2319 hlDataList.setAutoDelete(true); 2319 hlDataList.setAutoDelete(true);
2320 //this gets the data from the KateConfig object 2320 //this gets the data from the KateConfig object
2321 hlManager->getHlDataList(hlDataList); 2321 hlManager->getHlDataList(hlDataList);
2322 2322
2323 page=kd->addPage(i18n("Highlighting")); 2323 page=kd->addPage(i18n("Highlighting"));
2324 (new QVBoxLayout(page))->setAutoAdd(true); 2324 (new QVBoxLayout(page))->setAutoAdd(true);
2325 2325
2326 hlPage = new HighlightDialogPage(hlManager, &defaultStyleList, &hlDataList, 0, page); 2326 hlPage = new HighlightDialogPage(hlManager, &defaultStyleList, &hlDataList, 0, page);
2327 if ( QPEApplication::execDialog( kd )) { 2327 if ( QPEApplication::execDialog( kd )) {
2328 // color options 2328 // color options
2329 colorConfig->getColors(colors); 2329 colorConfig->getColors(colors);
2330 myDoc->setFont (fontConfig->getFont()); 2330 myDoc->setFont (fontConfig->getFont());
2331 2331
2332 applyColors(); 2332 applyColors();
2333 // indent options 2333 // indent options
2334 indentConfig->getData(this); 2334 indentConfig->getData(this);
2335 // select options 2335 // select options
2336 selectConfig->getData(this); 2336 selectConfig->getData(this);
2337 // edit options 2337 // edit options
2338 editConfig->getData(this); 2338 editConfig->getData(this);
2339 // spell checker 2339 // spell checker
2340 hlManager->setHlDataList(hlDataList); 2340 hlManager->setHlDataList(hlDataList);
2341 hlManager->setDefaults(defaultStyleList); 2341 hlManager->setDefaults(defaultStyleList);
2342 hlPage->saveData(); 2342 hlPage->saveData();
2343 } 2343 }
2344 2344
2345// delete kd; 2345 qApp->processEvents();
2346 delete kd;
2346 2347
2347#endif 2348#endif
2348} 2349}
2349 2350
2350int KateView::getHl() { 2351int KateView::getHl() {
2351 return myDoc->highlightNum(); 2352 return myDoc->highlightNum();
2352} 2353}
2353 2354
2354void KateView::setDontChangeHlOnSave() 2355void KateView::setDontChangeHlOnSave()
2355{ 2356{
2356 myDoc->setDontChangeHlOnSave(); 2357 myDoc->setDontChangeHlOnSave();
2357} 2358}
2358 2359
2359void KateView::setHl(int n) { 2360void KateView::setHl(int n) {
2360 myDoc->setHighlight(n); 2361 myDoc->setHighlight(n);
2361 myDoc->setDontChangeHlOnSave(); 2362 myDoc->setDontChangeHlOnSave();
2362 myDoc->updateViews(); 2363 myDoc->updateViews();
2363} 2364}
2364 2365
2365int KateView::getEol() { 2366int KateView::getEol() {
2366 return myDoc->eolMode; 2367 return myDoc->eolMode;
2367} 2368}
2368 2369
2369void KateView::setEol(int eol) { 2370void KateView::setEol(int eol) {
2370 if (isReadOnly()) 2371 if (isReadOnly())
2371 return; 2372 return;
2372 2373
2373 myDoc->eolMode = eol; 2374 myDoc->eolMode = eol;
2374 myDoc->setModified(true); 2375 myDoc->setModified(true);
2375} 2376}
2376 2377
2377 2378
2378 2379
2379void KateView::paintEvent(QPaintEvent *e) { 2380void KateView::paintEvent(QPaintEvent *e) {
2380 int x, y; 2381 int x, y;
2381 2382
2382 QRect updateR = e->rect(); // update rectangle 2383 QRect updateR = e->rect(); // update rectangle
2383// debug("Update rect = ( %i, %i, %i, %i )", 2384// debug("Update rect = ( %i, %i, %i, %i )",
2384// updateR.x(),updateR.y(), updateR.width(), updateR.height() ); 2385// updateR.x(),updateR.y(), updateR.width(), updateR.height() );
2385 2386
2386 int ux1 = updateR.x(); 2387 int ux1 = updateR.x();
2387 int uy1 = updateR.y(); 2388 int uy1 = updateR.y();
2388 int ux2 = ux1 + updateR.width(); 2389 int ux2 = ux1 + updateR.width();
2389 int uy2 = uy1 + updateR.height(); 2390 int uy2 = uy1 + updateR.height();
2390 2391
2391 QPainter paint; 2392 QPainter paint;
2392 paint.begin(this); 2393 paint.begin(this);
2393 2394
2394 QColorGroup g = colorGroup(); 2395 QColorGroup g = colorGroup();
2395 x = width(); 2396 x = width();
2396 y = height(); 2397 y = height();
2397 2398
2398 paint.setPen(g.dark()); 2399 paint.setPen(g.dark());
2399 if (uy1 <= 0) paint.drawLine(0,0,x-2,0); 2400 if (uy1 <= 0) paint.drawLine(0,0,x-2,0);
2400 if (ux1 <= 0) paint.drawLine(0,1,0,y-2); 2401 if (ux1 <= 0) paint.drawLine(0,1,0,y-2);
2401 2402
2402 paint.setPen(black); 2403 paint.setPen(black);
2403 if (uy1 <= 1) paint.drawLine(1,1,x-3,1); 2404 if (uy1 <= 1) paint.drawLine(1,1,x-3,1);
2404 if (ux1 <= 1) paint.drawLine(1,2,1,y-3); 2405 if (ux1 <= 1) paint.drawLine(1,2,1,y-3);
2405 2406
2406 paint.setPen(g.midlight()); 2407 paint.setPen(g.midlight());
2407 if (uy2 >= y-1) paint.drawLine(1,y-2,x-3,y-2); 2408 if (uy2 >= y-1) paint.drawLine(1,y-2,x-3,y-2);
2408 if (ux2 >= x-1) paint.drawLine(x-2,1,x-2,y-2); 2409 if (ux2 >= x-1) paint.drawLine(x-2,1,x-2,y-2);
2409 2410
2410 paint.setPen(g.light()); 2411 paint.setPen(g.light());
2411 if (uy2 >= y) paint.drawLine(0,y-1,x-2,y-1); 2412 if (uy2 >= y) paint.drawLine(0,y-1,x-2,y-1);
2412 if (ux2 >= x) paint.drawLine(x-1,0,x-1,y-1); 2413 if (ux2 >= x) paint.drawLine(x-1,0,x-1,y-1);
2413 2414
2414 x -= 2 + 16; 2415 x -= 2 + 16;
2415 y -= 2 + 16; 2416 y -= 2 + 16;
2416 if (ux2 > x && uy2 > y) { 2417 if (ux2 > x && uy2 > y) {
2417 paint.fillRect(x,y,16,16,g.background()); 2418 paint.fillRect(x,y,16,16,g.background());
2418 } 2419 }
2419 paint.end(); 2420 paint.end();
2420} 2421}
2421 2422
2422void KateView::resizeEvent(QResizeEvent *) { 2423void KateView::resizeEvent(QResizeEvent *) {
2423 2424
2424// debug("Resize %d, %d",e->size().width(),e->size().height()); 2425// debug("Resize %d, %d",e->size().width(),e->size().height());
2425 2426
2426//myViewInternal->resize(width() -20, height() -20); 2427//myViewInternal->resize(width() -20, height() -20);
2427 myViewInternal->tagAll(); 2428 myViewInternal->tagAll();
2428 myViewInternal->updateView(0/*ufNoScroll*/); 2429 myViewInternal->updateView(0/*ufNoScroll*/);
2429} 2430}
2430 2431
2431 2432
2432// Applies a new pattern to the search context. 2433// Applies a new pattern to the search context.
2433void SConfig::setPattern(QString &newPattern) { 2434void SConfig::setPattern(QString &newPattern) {
2434 bool regExp = (flags & KateView::sfRegularExpression); 2435 bool regExp = (flags & KateView::sfRegularExpression);
2435 2436
2436 m_pattern = newPattern; 2437 m_pattern = newPattern;
2437 if (regExp) { 2438 if (regExp) {
2438 m_regExp.setCaseSensitive(flags & KateView::sfCaseSensitive); 2439 m_regExp.setCaseSensitive(flags & KateView::sfCaseSensitive);
2439 m_regExp.setPattern(m_pattern); 2440 m_regExp.setPattern(m_pattern);
2440 } 2441 }
2441} 2442}
2442 2443
2443// Applies the search context to the given string, and returns whether a match was found. If one is, 2444// Applies the search context to the given string, and returns whether a match was found. If one is,
2444// the length of the string matched is also returned. 2445// the length of the string matched is also returned.
2445int SConfig::search(QString &text, int index) { 2446int SConfig::search(QString &text, int index) {
2446 bool regExp = (flags & KateView::sfRegularExpression); 2447 bool regExp = (flags & KateView::sfRegularExpression);
2447 bool caseSensitive = (flags & KateView::sfCaseSensitive); 2448 bool caseSensitive = (flags & KateView::sfCaseSensitive);
2448 2449
2449 if (flags & KateView::sfBackward) { 2450 if (flags & KateView::sfBackward) {
2450 if (regExp) { 2451 if (regExp) {
2451 index = text.findRev(m_regExp, index); 2452 index = text.findRev(m_regExp, index);
2452 } 2453 }
2453 else { 2454 else {
2454 index = text.findRev(m_pattern, index, caseSensitive); 2455 index = text.findRev(m_pattern, index, caseSensitive);
2455 } 2456 }
2456 } 2457 }
2457 else { 2458 else {
2458 if (regExp) { 2459 if (regExp) {
2459 index = text.find(m_regExp, index); 2460 index = text.find(m_regExp, index);
2460 } 2461 }
2461 else { 2462 else {
2462 index = text.find(m_pattern, index, caseSensitive); 2463 index = text.find(m_pattern, index, caseSensitive);
2463 } 2464 }
2464 } 2465 }
2465 2466
2466 // Work out the matched length. 2467 // Work out the matched length.
2467 if (index != -1) 2468 if (index != -1)
2468 { 2469 {
2469 if (regExp) { 2470 if (regExp) {
2470 m_regExp.match(text, index, &matchedLength, false); 2471 m_regExp.match(text, index, &matchedLength, false);
2471 } 2472 }
2472 else { 2473 else {
2473 matchedLength = m_pattern.length(); 2474 matchedLength = m_pattern.length();
2474 } 2475 }
2475 } 2476 }
2476 return index; 2477 return index;
2477} 2478}
2478 2479
2479void KateView::setActive (bool b) 2480void KateView::setActive (bool b)
2480{ 2481{
2481 active = b; 2482 active = b;
2482} 2483}
2483 2484
2484bool KateView::isActive () 2485bool KateView::isActive ()
2485{ 2486{
2486 return active; 2487 return active;
2487} 2488}
2488 2489
2489void KateView::setFocus () 2490void KateView::setFocus ()
2490{ 2491{
2491 QWidget::setFocus (); 2492 QWidget::setFocus ();
2492 2493
2493 emit gotFocus (this); 2494 emit gotFocus (this);
2494} 2495}
2495 2496
2496bool KateView::eventFilter (QObject *object, QEvent *event) 2497bool KateView::eventFilter (QObject *object, QEvent *event)
2497{ 2498{
2498 2499
2499 if ( (event->type() == QEvent::FocusIn) ) 2500 if ( (event->type() == QEvent::FocusIn) )
2500 emit gotFocus (this); 2501 emit gotFocus (this);
2501 2502
2502 if ( (event->type() == QEvent::KeyPress) ) 2503 if ( (event->type() == QEvent::KeyPress) )
2503 { 2504 {
2504 QKeyEvent * ke=(QKeyEvent *)event; 2505 QKeyEvent * ke=(QKeyEvent *)event;
2505 2506
2506 if ((ke->key()==Qt::Key_Tab) || (ke->key()==Qt::Key_BackTab)) 2507 if ((ke->key()==Qt::Key_Tab) || (ke->key()==Qt::Key_BackTab))
2507 { 2508 {
2508 myViewInternal->keyPressEvent(ke); 2509 myViewInternal->keyPressEvent(ke);
2509 return true; 2510 return true;
2510 } 2511 }
2511 } 2512 }
2512 return QWidget::eventFilter (object, event); 2513 return QWidget::eventFilter (object, event);
2513} 2514}
2514 2515
2515void KateView::findAgain (bool back) 2516void KateView::findAgain (bool back)
2516{ 2517{
2517 bool b= (searchFlags & sfBackward) > 0; 2518 bool b= (searchFlags & sfBackward) > 0;
2518 initSearch(s, (searchFlags & ((b==back)?~sfBackward:~0) & ~sfFromBeginning) // clear flag for forward searching 2519 initSearch(s, (searchFlags & ((b==back)?~sfBackward:~0) & ~sfFromBeginning) // clear flag for forward searching
2519 | sfPrompt | sfAgain | ((b!=back)?sfBackward:0) ); 2520 | sfPrompt | sfAgain | ((b!=back)?sfBackward:0) );
2520 if (s.flags & sfReplace) 2521 if (s.flags & sfReplace)
2521 replaceAgain(); 2522 replaceAgain();
2522 else 2523 else
2523 KateView::findAgain(s); 2524 KateView::findAgain(s);
2524} 2525}
2525 2526
2526void KateView::slotEditCommand () 2527void KateView::slotEditCommand ()
2527{ 2528{
2528#warning fixme 2529#warning fixme
2529/* 2530/*
2530 bool ok; 2531 bool ok;
2531 QString cmd = KLineEditDlg::getText("Editing Command", "", &ok, this); 2532 QString cmd = KLineEditDlg::getText("Editing Command", "", &ok, this);
2532 2533
2533 if (ok) 2534 if (ok)
2534 myDoc->cmd()->execCmd (cmd, this);*/ 2535 myDoc->cmd()->execCmd (cmd, this);*/
2535} 2536}
2536 2537
2537void KateView::setIconBorder (bool enable) 2538void KateView::setIconBorder (bool enable)
2538{ 2539{
2539 myIconBorder = enable; 2540 myIconBorder = enable;
2540 2541
2541 if (myIconBorder) 2542 if (myIconBorder)
2542 { 2543 {
2543 myViewInternal->move(myViewInternal->iconBorderWidth+2, 2); 2544 myViewInternal->move(myViewInternal->iconBorderWidth+2, 2);
2544 myViewInternal->leftBorder->show(); 2545 myViewInternal->leftBorder->show();
2545 } 2546 }
2546 else 2547 else
2547 { 2548 {
2548 myViewInternal->leftBorder->hide(); 2549 myViewInternal->leftBorder->hide();
2549 myViewInternal->move(2, 2); 2550 myViewInternal->move(2, 2);
2550 } 2551 }
2551} 2552}
2552 2553
2553void KateView::toggleIconBorder () 2554void KateView::toggleIconBorder ()
2554{ 2555{
2555 setIconBorder (!myIconBorder); 2556 setIconBorder (!myIconBorder);
2556} 2557}
2557 2558
2558void KateView::gotoMark (Kate::Mark *mark) 2559void KateView::gotoMark (Kate::Mark *mark)
2559{ 2560{
2560 PointStruc cursor; 2561 PointStruc cursor;
2561 2562
2562 cursor.x = 0; 2563 cursor.x = 0;
2563 cursor.y = mark->line; 2564 cursor.y = mark->line;
2564 myDoc->needPreHighlight(cursor.y); 2565 myDoc->needPreHighlight(cursor.y);
2565 myViewInternal->updateCursor(cursor); 2566 myViewInternal->updateCursor(cursor);
2566 myViewInternal->center(); 2567 myViewInternal->center();
2567 myViewInternal->updateView(KateView::ufUpdateOnScroll); 2568 myViewInternal->updateView(KateView::ufUpdateOnScroll);
2568 myDoc->updateViews(this); 2569 myDoc->updateViews(this);
2569} 2570}
2570 2571
2571void KateView::toggleBookmark () 2572void KateView::toggleBookmark ()
2572{ 2573{
2573 TextLine::Ptr line = myDoc->getTextLine (currentLine()); 2574 TextLine::Ptr line = myDoc->getTextLine (currentLine());
2574 2575
2575 if (line->mark()&KateDocument::Bookmark) 2576 if (line->mark()&KateDocument::Bookmark)
2576 line->delMark(KateDocument::Bookmark); 2577 line->delMark(KateDocument::Bookmark);
2577 else 2578 else
2578 line->addMark(KateDocument::Bookmark); 2579 line->addMark(KateDocument::Bookmark);
2579 2580
2580 myDoc->tagLines (currentLine(), currentLine()); 2581 myDoc->tagLines (currentLine(), currentLine());
2581 myDoc->updateViews(); 2582 myDoc->updateViews();
2582} 2583}
2583 2584
2584void KateView::clearBookmarks() 2585void KateView::clearBookmarks()
2585{ 2586{
2586 QList<Kate::Mark> list = myDoc->marks(); 2587 QList<Kate::Mark> list = myDoc->marks();
2587 for (int i=0; (uint) i < list.count(); i++) 2588 for (int i=0; (uint) i < list.count(); i++)
2588 { 2589 {
2589 if (list.at(i)->type&KateDocument::Bookmark) 2590 if (list.at(i)->type&KateDocument::Bookmark)
2590 { 2591 {
2591 myDoc->getTextLine(list.at(i)->line)->delMark(KateDocument::Bookmark); 2592 myDoc->getTextLine(list.at(i)->line)->delMark(KateDocument::Bookmark);
2592 myDoc->tagLines(list.at(i)->line, list.at(i)->line); 2593 myDoc->tagLines(list.at(i)->line, list.at(i)->line);
2593 } 2594 }
2594 } 2595 }
2595 2596
2596 myDoc->updateViews(); 2597 myDoc->updateViews();
2597} 2598}
2598 2599
2599void KateView::bookmarkMenuAboutToShow() 2600void KateView::bookmarkMenuAboutToShow()
2600{ 2601{
2601#warning fixme 2602#warning fixme
2602#if 0 2603#if 0
2603 bookmarkMenu->popupMenu()->clear (); 2604 bookmarkMenu->popupMenu()->clear ();
2604 bookmarkToggle->plug (bookmarkMenu->popupMenu()); 2605 bookmarkToggle->plug (bookmarkMenu->popupMenu());
2605 bookmarkClear->plug (bookmarkMenu->popupMenu()); 2606 bookmarkClear->plug (bookmarkMenu->popupMenu());
2606 bookmarkMenu->popupMenu()->insertSeparator (); 2607 bookmarkMenu->popupMenu()->insertSeparator ();
2607 2608
2608 list = myDoc->marks(); 2609 list = myDoc->marks();
2609 for (int i=0; (uint) i < list.count(); i++) 2610 for (int i=0; (uint) i < list.count(); i++)
2610 { 2611 {
2611 if (list.at(i)->type&KateDocument::Bookmark) 2612 if (list.at(i)->type&KateDocument::Bookmark)
2612 { 2613 {
2613 QString bText = textLine(list.at(i)->line); 2614 QString bText = textLine(list.at(i)->line);
2614 bText.truncate(32); 2615 bText.truncate(32);
2615 bText.append ("..."); 2616 bText.append ("...");
2616 bookmarkMenu->popupMenu()->insertItem ( QString("%1 - \"%2\"").arg(list.at(i)->line).arg(bText), this, SLOT (gotoBookmark(int)), 0, i ); 2617 bookmarkMenu->popupMenu()->insertItem ( QString("%1 - \"%2\"").arg(list.at(i)->line).arg(bText), this, SLOT (gotoBookmark(int)), 0, i );
2617 } 2618 }
2618 } 2619 }
2619#endif 2620#endif
2620} 2621}
2621 2622
2622void KateView::gotoBookmark (int n) 2623void KateView::gotoBookmark (int n)
2623{ 2624{
2624 gotoMark (list.at(n)); 2625 gotoMark (list.at(n));
2625} 2626}
2626 2627
2627int KateView::getHlCount () 2628int KateView::getHlCount ()
2628{ 2629{
2629 return HlManager::self()->highlights(); 2630 return HlManager::self()->highlights();
2630} 2631}
2631 2632
2632QString KateView::getHlName (int z) 2633QString KateView::getHlName (int z)
2633{ 2634{
2634 return HlManager::self()->hlName(z); 2635 return HlManager::self()->hlName(z);
2635} 2636}
2636 2637
2637QString KateView::getHlSection (int z) 2638QString KateView::getHlSection (int z)
2638{ 2639{
2639 return HlManager::self()->hlSection (z); 2640 return HlManager::self()->hlSection (z);
2640} 2641}
2641 2642
2642void KateView::slotIncFontSizes () 2643void KateView::slotIncFontSizes ()
2643{ 2644{
2644 QFont font = myDoc->getFont(); 2645 QFont font = myDoc->getFont();
2645 font.setPointSize (font.pointSize()+2); 2646 font.setPointSize (font.pointSize()+2);
2646 myDoc->setFont (font); 2647 myDoc->setFont (font);
2647} 2648}
2648 2649
2649void KateView::slotDecFontSizes () 2650void KateView::slotDecFontSizes ()
2650{ 2651{
2651 QFont font = myDoc->getFont(); 2652 QFont font = myDoc->getFont();
2652 font.setPointSize (font.pointSize()-2); 2653 font.setPointSize (font.pointSize()-2);
2653 myDoc->setFont (font); 2654 myDoc->setFont (font);
2654} 2655}
2655 2656
2656const char*bookmark_xpm[]={ 2657const char*bookmark_xpm[]={
2657"12 16 4 1", 2658"12 16 4 1",
2658"b c #808080", 2659"b c #808080",
2659"a c #000080", 2660"a c #000080",
2660"# c #0000ff", 2661"# c #0000ff",
2661". c None", 2662". c None",
2662"............", 2663"............",
2663"............", 2664"............",
2664"........###.", 2665"........###.",
2665".......#...a", 2666".......#...a",
2666"......#.##.a", 2667"......#.##.a",
2667".....#.#..aa", 2668".....#.#..aa",
2668"....#.#...a.", 2669"....#.#...a.",
2669"...#.#.a.a..", 2670"...#.#.a.a..",
2670"..#.#.a.a...", 2671"..#.#.a.a...",
2671".#.#.a.a....", 2672".#.#.a.a....",
2672"#.#.a.a.....", 2673"#.#.a.a.....",
2673"#.#a.a...bbb", 2674"#.#a.a...bbb",
2674"#...a..bbb..", 2675"#...a..bbb..",
2675".aaa.bbb....", 2676".aaa.bbb....",
2676"............", 2677"............",
2677"............"}; 2678"............"};
2678 2679
2679const char* breakpoint_xpm[]={ 2680const char* breakpoint_xpm[]={
2680"11 16 6 1", 2681"11 16 6 1",
2681"c c #c6c6c6", 2682"c c #c6c6c6",
2682". c None", 2683". c None",
2683"# c #000000", 2684"# c #000000",
2684"d c #840000", 2685"d c #840000",
2685"a c #ffffff", 2686"a c #ffffff",
2686"b c #ff0000", 2687"b c #ff0000",
2687"...........", 2688"...........",
2688"...........", 2689"...........",
2689"...#####...", 2690"...#####...",
2690"..#aaaaa#..", 2691"..#aaaaa#..",
2691".#abbbbbb#.", 2692".#abbbbbb#.",
2692"#abbbbbbbb#", 2693"#abbbbbbbb#",
2693"#abcacacbd#", 2694"#abcacacbd#",
2694"#abbbbbbbb#", 2695"#abbbbbbbb#",
2695"#abcacacbd#", 2696"#abcacacbd#",
2696"#abbbbbbbb#", 2697"#abbbbbbbb#",
2697".#bbbbbbb#.", 2698".#bbbbbbb#.",
2698"..#bdbdb#..", 2699"..#bdbdb#..",
2699"...#####...", 2700"...#####...",
2700"...........", 2701"...........",
2701"...........", 2702"...........",
2702"..........."}; 2703"..........."};
2703 2704
2704const char*breakpoint_bl_xpm[]={ 2705const char*breakpoint_bl_xpm[]={
2705"11 16 7 1", 2706"11 16 7 1",
2706"a c #c0c0ff", 2707"a c #c0c0ff",
2707"# c #000000", 2708"# c #000000",
2708"c c #0000c0", 2709"c c #0000c0",
2709"e c #0000ff", 2710"e c #0000ff",
2710"b c #dcdcdc", 2711"b c #dcdcdc",
2711"d c #ffffff", 2712"d c #ffffff",
2712". c None", 2713". c None",
2713"...........", 2714"...........",
2714"...........", 2715"...........",
2715"...#####...", 2716"...#####...",
2716"..#ababa#..", 2717"..#ababa#..",
2717".#bcccccc#.", 2718".#bcccccc#.",
2718"#acccccccc#", 2719"#acccccccc#",
2719"#bcadadace#", 2720"#bcadadace#",
2720"#acccccccc#", 2721"#acccccccc#",
2721"#bcadadace#", 2722"#bcadadace#",
2722"#acccccccc#", 2723"#acccccccc#",
2723".#ccccccc#.", 2724".#ccccccc#.",
2724"..#cecec#..", 2725"..#cecec#..",
2725"...#####...", 2726"...#####...",
2726"...........", 2727"...........",
2727"...........", 2728"...........",
2728"..........."}; 2729"..........."};
2729 2730
2730const char*breakpoint_gr_xpm[]={ 2731const char*breakpoint_gr_xpm[]={
2731"11 16 6 1", 2732"11 16 6 1",
2732"c c #c6c6c6", 2733"c c #c6c6c6",
2733"d c #2c2c2c", 2734"d c #2c2c2c",
2734"# c #000000", 2735"# c #000000",
2735". c None", 2736". c None",
2736"a c #ffffff", 2737"a c #ffffff",
2737"b c #555555", 2738"b c #555555",
2738"...........", 2739"...........",
2739"...........", 2740"...........",
2740"...#####...", 2741"...#####...",
2741"..#aaaaa#..", 2742"..#aaaaa#..",
2742".#abbbbbb#.", 2743".#abbbbbb#.",
2743"#abbbbbbbb#", 2744"#abbbbbbbb#",
2744"#abcacacbd#", 2745"#abcacacbd#",
2745"#abbbbbbbb#", 2746"#abbbbbbbb#",
2746"#abcacacbd#", 2747"#abcacacbd#",
2747"#abbbbbbbb#", 2748"#abbbbbbbb#",
2748".#bbbbbbb#.", 2749".#bbbbbbb#.",
2749"..#bdbdb#..", 2750"..#bdbdb#..",
2750"...#####...", 2751"...#####...",
2751"...........", 2752"...........",
2752"...........", 2753"...........",
2753"..........."}; 2754"..........."};
2754 2755
2755const char*ddd_xpm[]={ 2756const char*ddd_xpm[]={
2756"11 16 4 1", 2757"11 16 4 1",
2757"a c #00ff00", 2758"a c #00ff00",
2758"b c #000000", 2759"b c #000000",
2759". c None", 2760". c None",
2760"# c #00c000", 2761"# c #00c000",
2761"...........", 2762"...........",
2762"...........", 2763"...........",
2763"...........", 2764"...........",
2764"#a.........", 2765"#a.........",
2765"#aaa.......", 2766"#aaa.......",
2766"#aaaaa.....", 2767"#aaaaa.....",
2767"#aaaaaaa...", 2768"#aaaaaaa...",
2768"#aaaaaaaaa.", 2769"#aaaaaaaaa.",
2769"#aaaaaaa#b.", 2770"#aaaaaaa#b.",
2770"#aaaaa#b...", 2771"#aaaaa#b...",
2771"#aaa#b.....", 2772"#aaa#b.....",
2772"#a#b.......", 2773"#a#b.......",
2773"#b.........", 2774"#b.........",
2774"...........", 2775"...........",
2775"...........", 2776"...........",
2776"..........."}; 2777"..........."};
2777 2778
2778 2779
2779 2780
2780KateIconBorder::KateIconBorder(KateView *view, KateViewInternal *internalView) 2781KateIconBorder::KateIconBorder(KateView *view, KateViewInternal *internalView)
2781 : QWidget(view), myView(view), myInternalView(internalView) 2782 : QWidget(view), myView(view), myInternalView(internalView)
2782{ 2783{
2783 lmbSetsBreakpoints = true; 2784 lmbSetsBreakpoints = true;
2784} 2785}
2785 2786
2786KateIconBorder::~KateIconBorder() 2787KateIconBorder::~KateIconBorder()
2787{ 2788{
2788} 2789}
2789 2790
2790void KateIconBorder::paintLine(int i) 2791void KateIconBorder::paintLine(int i)
2791{ 2792{
2792 if (!myView->myIconBorder) return; 2793 if (!myView->myIconBorder) return;
2793 2794
2794 QPainter p(this); 2795 QPainter p(this);
2795 2796
2796 int fontHeight = myView->doc()->fontHeight; 2797 int fontHeight = myView->doc()->fontHeight;
2797 int y = i*fontHeight - myInternalView->yPos; 2798 int y = i*fontHeight - myInternalView->yPos;
2798 p.fillRect(0, y, myInternalView->iconBorderWidth-2, fontHeight, colorGroup().background()); 2799 p.fillRect(0, y, myInternalView->iconBorderWidth-2, fontHeight, colorGroup().background());
2799 p.setPen(white); 2800 p.setPen(white);
2800 p.drawLine(myInternalView->iconBorderWidth-2, y, myInternalView->iconBorderWidth-2, y + fontHeight); 2801 p.drawLine(myInternalView->iconBorderWidth-2, y, myInternalView->iconBorderWidth-2, y + fontHeight);
2801 p.setPen(QColor(colorGroup().background()).dark()); 2802 p.setPen(QColor(colorGroup().background()).dark());
2802 p.drawLine(myInternalView->iconBorderWidth-1, y, myInternalView->iconBorderWidth-1, y + fontHeight); 2803 p.drawLine(myInternalView->iconBorderWidth-1, y, myInternalView->iconBorderWidth-1, y + fontHeight);
2803 2804
2804 TextLine *line = myView->doc()->getTextLine(i); 2805 TextLine *line = myView->doc()->getTextLine(i);
2805 if (!line) 2806 if (!line)
2806 return; 2807 return;
2807 2808
2808 if (line->mark()&KateDocument::Bookmark) 2809 if (line->mark()&KateDocument::Bookmark)
2809 p.drawPixmap(2, y, QPixmap(bookmark_xpm)); /* 2810 p.drawPixmap(2, y, QPixmap(bookmark_xpm)); /*
2810 if (line && (line->breakpointId() != -1)) { 2811 if (line && (line->breakpointId() != -1)) {
2811 if (!line->breakpointEnabled()) 2812 if (!line->breakpointEnabled())
2812 p.drawPixmap(2, y, QPixmap(breakpoint_gr_xpm)); 2813 p.drawPixmap(2, y, QPixmap(breakpoint_gr_xpm));
2813 else if (line->breakpointPending()) 2814 else if (line->breakpointPending())
2814 p.drawPixmap(2, y, QPixmap(breakpoint_bl_xpm)); 2815 p.drawPixmap(2, y, QPixmap(breakpoint_bl_xpm));
2815 else 2816 else
2816 p.drawPixmap(2, y, QPixmap(breakpoint_xpm)); 2817 p.drawPixmap(2, y, QPixmap(breakpoint_xpm));
2817 } 2818 }
2818 if (line->isExecutionPoint()) 2819 if (line->isExecutionPoint())
2819 p.drawPixmap(2, y, QPixmap(ddd_xpm)); */ 2820 p.drawPixmap(2, y, QPixmap(ddd_xpm)); */
2820} 2821}
2821 2822
2822 2823
2823void KateIconBorder::paintEvent(QPaintEvent* e) 2824void KateIconBorder::paintEvent(QPaintEvent* e)
2824{ 2825{
2825 if (!myView->myIconBorder) return; 2826 if (!myView->myIconBorder) return;
2826 2827
2827 int lineStart = 0; 2828 int lineStart = 0;
2828 int lineEnd = 0; 2829 int lineEnd = 0;
2829 2830
2830 QRect updateR = e->rect(); 2831 QRect updateR = e->rect();
2831 2832
2832 KateDocument *doc = myView->doc(); 2833 KateDocument *doc = myView->doc();
2833 int h = doc->fontHeight; 2834 int h = doc->fontHeight;
2834 int yPos = myInternalView->yPos; 2835 int yPos = myInternalView->yPos;
2835 if (h) { 2836 if (h) {
2836 lineStart = (yPos + updateR.y()) / h; 2837 lineStart = (yPos + updateR.y()) / h;
2837 lineEnd = QMAX((yPos + updateR.y() + updateR.height()) / h, (int)doc->numLines()); 2838 lineEnd = QMAX((yPos + updateR.y() + updateR.height()) / h, (int)doc->numLines());
2838 } 2839 }
2839 2840
2840 for(int i = lineStart; i <= lineEnd; ++i) 2841 for(int i = lineStart; i <= lineEnd; ++i)
2841 paintLine(i); 2842 paintLine(i);
2842} 2843}
2843 2844
2844 2845
2845void KateIconBorder::mousePressEvent(QMouseEvent* e) 2846void KateIconBorder::mousePressEvent(QMouseEvent* e)
2846{ 2847{
2847 myInternalView->placeCursor( 0, e->y(), 0 ); 2848 myInternalView->placeCursor( 0, e->y(), 0 );
2848 2849
2849 KateDocument *doc = myView->doc(); 2850 KateDocument *doc = myView->doc();
2850 int cursorOnLine = (e->y() + myInternalView->yPos) / doc->fontHeight; 2851 int cursorOnLine = (e->y() + myInternalView->yPos) / doc->fontHeight;
2851 TextLine *line = doc->getTextLine(cursorOnLine); 2852 TextLine *line = doc->getTextLine(cursorOnLine);
2852 2853
2853 switch (e->button()) { 2854 switch (e->button()) {
2854 case LeftButton: 2855 case LeftButton:
2855 if (!line) 2856 if (!line)
2856 break; 2857 break;
2857 else 2858 else
2858 { 2859 {
2859 if (line->mark()&KateDocument::Bookmark) 2860 if (line->mark()&KateDocument::Bookmark)
2860 line->delMark (KateDocument::Bookmark); 2861 line->delMark (KateDocument::Bookmark);
2861 else 2862 else
2862 line->addMark (KateDocument::Bookmark); 2863 line->addMark (KateDocument::Bookmark);
2863 2864
2864 doc->tagLines(cursorOnLine, cursorOnLine); 2865 doc->tagLines(cursorOnLine, cursorOnLine);
2865 doc->updateViews(); 2866 doc->updateViews();
2866 } 2867 }
2867 break; 2868 break;
2868 /* case RightButton: 2869 /* case RightButton:
2869 { 2870 {
2870 if (!line) 2871 if (!line)
2871 break; 2872 break;
2872 KPopupMenu popup; 2873 KPopupMenu popup;
2873 popup.setCheckable(true); 2874 popup.setCheckable(true);
2874 popup.insertTitle(i18n("Breakpoints/Bookmarks")); 2875 popup.insertTitle(i18n("Breakpoints/Bookmarks"));
2875 int idToggleBookmark = popup.insertItem(i18n("Toggle bookmark")); 2876 int idToggleBookmark = popup.insertItem(i18n("Toggle bookmark"));
2876 popup.insertSeparator(); 2877 popup.insertSeparator();
2877 int idToggleBreakpoint = popup.insertItem(i18n("Toggle breakpoint")); 2878 int idToggleBreakpoint = popup.insertItem(i18n("Toggle breakpoint"));
2878 int idEditBreakpoint = popup.insertItem(i18n("Edit breakpoint")); 2879 int idEditBreakpoint = popup.insertItem(i18n("Edit breakpoint"));
2879 int idEnableBreakpoint = popup.insertItem(i18n("Disable breakpoint")); 2880 int idEnableBreakpoint = popup.insertItem(i18n("Disable breakpoint"));
2880 popup.insertSeparator(); 2881 popup.insertSeparator();
2881 popup.insertSeparator(); 2882 popup.insertSeparator();
2882 int idLmbSetsBreakpoints = popup.insertItem(i18n("LMB sets breakpoints")); 2883 int idLmbSetsBreakpoints = popup.insertItem(i18n("LMB sets breakpoints"));
2883 int idLmbSetsBookmarks = popup.insertItem(i18n("LMB sets bookmarks")); 2884 int idLmbSetsBookmarks = popup.insertItem(i18n("LMB sets bookmarks"));
2884 2885
2885 popup.setItemChecked(idLmbSetsBreakpoints, lmbSetsBreakpoints); 2886 popup.setItemChecked(idLmbSetsBreakpoints, lmbSetsBreakpoints);
2886 popup.setItemChecked(idLmbSetsBookmarks, !lmbSetsBreakpoints); 2887 popup.setItemChecked(idLmbSetsBookmarks, !lmbSetsBreakpoints);
2887 2888
2888 if (line->breakpointId() == -1) { 2889 if (line->breakpointId() == -1) {
2889 popup.setItemEnabled(idEditBreakpoint, false); 2890 popup.setItemEnabled(idEditBreakpoint, false);
2890 popup.setItemEnabled(idEnableBreakpoint, false); 2891 popup.setItemEnabled(idEnableBreakpoint, false);
2891 popup.changeItem(idEnableBreakpoint, i18n("Enable breakpoint")); 2892 popup.changeItem(idEnableBreakpoint, i18n("Enable breakpoint"));
2892 } 2893 }
2893 int res = popup.exec(mapToGlobal(e->pos())); 2894 int res = popup.exec(mapToGlobal(e->pos()));
2894 if (res == idToggleBookmark) { 2895 if (res == idToggleBookmark) {
2895 line->toggleBookmark(); 2896 line->toggleBookmark();
2896 doc->tagLines(cursorOnLine, cursorOnLine); 2897 doc->tagLines(cursorOnLine, cursorOnLine);
2897 doc->updateViews(); 2898 doc->updateViews();
2898 } else if (res == idToggleBreakpoint) 2899 } else if (res == idToggleBreakpoint)
2899 emit myView->toggledBreakpoint(cursorOnLine); 2900 emit myView->toggledBreakpoint(cursorOnLine);
2900 else if (res == idEditBreakpoint) 2901 else if (res == idEditBreakpoint)
2901 emit myView->editedBreakpoint(cursorOnLine); 2902 emit myView->editedBreakpoint(cursorOnLine);
2902 else if (res == idEnableBreakpoint) 2903 else if (res == idEnableBreakpoint)
2903 emit myView->toggledBreakpointEnabled(cursorOnLine+1); 2904 emit myView->toggledBreakpointEnabled(cursorOnLine+1);
2904 else if (res == idLmbSetsBreakpoints || res == idLmbSetsBookmarks) 2905 else if (res == idLmbSetsBreakpoints || res == idLmbSetsBookmarks)
2905 lmbSetsBreakpoints = !lmbSetsBreakpoints; 2906 lmbSetsBreakpoints = !lmbSetsBreakpoints;
2906 break; 2907 break;
2907 } 2908 }
2908 case MidButton: 2909 case MidButton:
2909 line->toggleBookmark(); 2910 line->toggleBookmark();
2910 doc->tagLines(cursorOnLine, cursorOnLine); 2911 doc->tagLines(cursorOnLine, cursorOnLine);
2911 doc->updateViews(); 2912 doc->updateViews();
2912 break; */ 2913 break; */
2913 default: 2914 default:
2914 break; 2915 break;
2915 } 2916 }
2916} 2917}
2917 2918
2918 2919
2919 2920