summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/document/katedocument.cpp10
-rw-r--r--noncore/apps/tinykate/libkate/document/katedocument.h11
2 files changed, 15 insertions, 6 deletions
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.cpp b/noncore/apps/tinykate/libkate/document/katedocument.cpp
index 10bc976..df1de8d 100644
--- a/noncore/apps/tinykate/libkate/document/katedocument.cpp
+++ b/noncore/apps/tinykate/libkate/document/katedocument.cpp
@@ -203,256 +203,257 @@ KateDocument::KateDocument(bool bSingleViewMode, bool bBrowserView,
203 setHighlight(0); //calls updateFontData() 203 setHighlight(0); //calls updateFontData()
204 // if the user changes the highlight with the dialog, notify the doc 204 // if the user changes the highlight with the dialog, notify the doc
205 connect(hlManager,SIGNAL(changed()),SLOT(hlChanged())); 205 connect(hlManager,SIGNAL(changed()),SLOT(hlChanged()));
206 206
207 newDocGeometry = false; 207 newDocGeometry = false;
208 208
209 readConfig(); 209 readConfig();
210 210
211 setReadOnly(false); 211 setReadOnly(false);
212} 212}
213 213
214void KateDocument::setDontChangeHlOnSave() 214void KateDocument::setDontChangeHlOnSave()
215{ 215{
216 d(this)->hlSetByUser = true; 216 d(this)->hlSetByUser = true;
217} 217}
218 218
219void KateDocument::setFont (QFont font) 219void KateDocument::setFont (QFont font)
220{ 220{
221 kdDebug()<<"Kate:: setFont"<<endl; 221 kdDebug()<<"Kate:: setFont"<<endl;
222 int oldwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 222 int oldwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0
223 myFont = font; 223 myFont = font;
224 myFontBold = QFont (font); 224 myFontBold = QFont (font);
225 myFontBold.setBold (true); 225 myFontBold.setBold (true);
226 226
227 myFontItalic = QFont (font); 227 myFontItalic = QFont (font);
228 myFontItalic.setItalic (true); 228 myFontItalic.setItalic (true);
229 229
230 myFontBI = QFont (font); 230 myFontBI = QFont (font);
231 myFontBI.setBold (true); 231 myFontBI.setBold (true);
232 myFontBI.setItalic (true); 232 myFontBI.setItalic (true);
233 233
234 myFontMetrics = CachedFontMetrics (myFont); 234 myFontMetrics = CachedFontMetrics (myFont);
235 myFontMetricsBold = CachedFontMetrics (myFontBold); 235 myFontMetricsBold = CachedFontMetrics (myFontBold);
236 myFontMetricsItalic = CachedFontMetrics (myFontItalic); 236 myFontMetricsItalic = CachedFontMetrics (myFontItalic);
237 myFontMetricsBI = CachedFontMetrics (myFontBI); 237 myFontMetricsBI = CachedFontMetrics (myFontBI);
238 int newwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 238 int newwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0
239 maxLength=maxLength*(float)newwidth/(float)oldwidth; //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 239 maxLength=maxLength*(float)newwidth/(float)oldwidth; //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0
240 240
241 updateFontData(); 241 updateFontData();
242 updateViews(); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 242 updateViews(); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0
243 243
244} 244}
245 245
246long KateDocument::needPreHighlight(long till) 246long KateDocument::needPreHighlight(long till)
247{ 247{
248 int max=numLines()-1; 248 int max=numLines()-1;
249 if (till>max) 249 if (till>max)
250 { 250 {
251 till=max; 251 till=max;
252 } 252 }
253 if (PreHighlightedTill>=till) return -1; 253 if (PreHighlightedTill>=till) return -1;
254 254
255 long tmp=RequestPreHighlightTill; 255 long tmp=RequestPreHighlightTill;
256 if (RequestPreHighlightTill<till) 256 if (RequestPreHighlightTill<till)
257 { 257 {
258 RequestPreHighlightTill=till; 258 RequestPreHighlightTill=till;
259 if (tmp<=PreHighlightedTill) QTimer::singleShot(10,this,SLOT(doPreHighlight())); 259 if (tmp<=PreHighlightedTill) QTimer::singleShot(10,this,SLOT(doPreHighlight()));
260 } 260 }
261 return RequestPreHighlightTill; 261 return RequestPreHighlightTill;
262} 262}
263 263
264void KateDocument::doPreHighlight() 264void KateDocument::doPreHighlight()
265{ 265{
266 int from = PreHighlightedTill; 266 int from = PreHighlightedTill;
267 int till = PreHighlightedTill+200; 267 int till = PreHighlightedTill+200;
268 int max = numLines()-1; 268 int max = numLines()-1;
269 if (till > max) 269 if (till > max)
270 { 270 {
271 till = max; 271 till = max;
272 } 272 }
273 PreHighlightedTill = till; 273 PreHighlightedTill = till;
274 updateLines(from,till); 274 updateLines(from,till);
275 emit preHighlightChanged(PreHighlightedTill); 275 emit preHighlightChanged(PreHighlightedTill);
276 if (PreHighlightedTill<RequestPreHighlightTill) 276 if (PreHighlightedTill<RequestPreHighlightTill)
277 QTimer::singleShot(10,this,SLOT(doPreHighlight())); 277 QTimer::singleShot(10,this,SLOT(doPreHighlight()));
278} 278}
279 279
280KateDocument::~KateDocument() 280KateDocument::~KateDocument()
281{ 281{
282 m_highlight->release(); 282 m_highlight->release();
283 283
284 if ( !m_bSingleViewMode ) 284 if ( !m_bSingleViewMode )
285 { 285 {
286 m_views.setAutoDelete( true ); 286 m_views.setAutoDelete( true );
287 m_views.clear(); 287 m_views.clear();
288 m_views.setAutoDelete( false ); 288 m_views.setAutoDelete( false );
289 } 289 }
290 delete_d(this); 290 delete_d(this);
291} 291}
292 292
293void KateDocument::openURL(const QString &filename) 293void KateDocument::openURL(const QString &filename)
294{ 294{
295 295
296 m_file=filename; 296 m_file=filename;
297 fileInfo->setFile (m_file); 297 fileInfo->setFile (m_file);
298 setMTime(); 298 setMTime();
299 299
300 if (!fileInfo->exists() || !fileInfo->isReadable()) 300 if (!fileInfo->exists() || !fileInfo->isReadable())
301 { 301 {
302 qDebug("File doesn't exit or couldn't be read"); 302 qDebug("File doesn't exit or couldn't be read");
303 return ; 303 return ;
304 } 304 }
305 305
306 buffer->clear(); 306 buffer->clear();
307#warning fixme 307#warning fixme
308// buffer->insertFile(0, m_file, KGlobal::charsets()->codecForName(myEncoding)); 308// buffer->insertFile(0, m_file, KGlobal::charsets()->codecForName(myEncoding));
309 qDebug("Telling buffer to open file"); 309 qDebug("Telling buffer to open file");
310 buffer->insertFile(0, m_file, QTextCodec::codecForLocale()); 310 buffer->insertFile(0, m_file, QTextCodec::codecForLocale());
311 311
312 setMTime(); 312 setMTime();
313 313
314 if (myWordWrap) 314 if (myWordWrap)
315 wrapText (myWordWrapAt); 315 wrapText (myWordWrapAt);
316 316
317 int hl = hlManager->wildcardFind( m_file ); 317 int hl = hlManager->wildcardFind( m_file );
318 318
319 setHighlight(hl); 319 setHighlight(hl);
320 320
321 updateLines(); 321 updateLines();
322 updateViews(); 322 updateViews();
323 323
324 emit fileNameChanged(); 324 emit fileNameChanged();
325 325
326 return ; 326 return ;
327} 327}
328 328
329bool KateDocument::saveFile() 329bool KateDocument::saveFile()
330{ 330{
331
331 QFile f( m_file ); 332 QFile f( m_file );
332 if ( !f.open( IO_WriteOnly ) ) 333 if ( !f.open( IO_WriteOnly ) )
333 return false; // Error 334 return false; // Error
334 335
335 QTextStream stream(&f); 336 QTextStream stream(&f);
336 337
337 stream.setEncoding(QTextStream::RawUnicode); // disable Unicode headers 338 stream.setEncoding(QTextStream::RawUnicode); // disable Unicode headers
338#warning fixme 339#warning fixme
339// stream.setCodec(KGlobal::charsets()->codecForName(myEncoding)); 340// stream.setCodec(KGlobal::charsets()->codecForName(myEncoding));
340 stream.setCodec(QTextCodec::codecForLocale()); // this line sets the mapper to the correct codec 341 stream.setCodec(QTextCodec::codecForLocale()); // this line sets the mapper to the correct codec
341 342
342 int maxLine = numLines(); 343 int maxLine = numLines();
343 int line = 0; 344 int line = 0;
344 while(true) 345 while(true)
345 { 346 {
346 stream << getTextLine(line)->getString(); 347 stream << getTextLine(line)->getString();
347 line++; 348 line++;
348 if (line >= maxLine) break; 349 if (line >= maxLine) break;
349 350
350 if (eolMode == KateDocument::eolUnix) stream << "\n"; 351 if (eolMode == KateDocument::eolUnix) stream << "\n";
351 else if (eolMode == KateDocument::eolDos) stream << "\r\n"; 352 else if (eolMode == KateDocument::eolDos) stream << "\r\n";
352 else if (eolMode == KateDocument::eolMacintosh) stream << '\r'; 353 else if (eolMode == KateDocument::eolMacintosh) stream << '\r';
353 }; 354 };
354 f.close(); 355 f.close();
355 356
356 fileInfo->setFile (m_file); 357 fileInfo->setFile (m_file);
357 setMTime(); 358 setMTime();
358 359
359 if (!(d(this)->hlSetByUser)) 360 if (!(d(this)->hlSetByUser))
360 { 361 {
361 int hl = hlManager->wildcardFind( m_file ); 362 int hl = hlManager->wildcardFind( m_file );
362 363
363 setHighlight(hl); 364 setHighlight(hl);
364 } 365 }
365 emit fileNameChanged (); 366 emit fileNameChanged ();
366 367
367 return (f.status() == IO_Ok); 368 return (f.status() == IO_Ok);
368} 369}
369 370
370KTextEditor::View *KateDocument::createView( QWidget *parent, const char *name ) 371KTextEditor::View *KateDocument::createView( QWidget *parent, const char *name )
371{ 372{
372 return new KateView( this, parent, name); 373 return new KateView( this, parent, name);
373} 374}
374 375
375QString KateDocument::textLine( int line ) const 376QString KateDocument::textLine( int line ) const
376{ 377{
377 TextLine::Ptr l = getTextLine( line ); 378 TextLine::Ptr l = getTextLine( line );
378 if ( !l ) 379 if ( !l )
379 return QString(); 380 return QString();
380 381
381 return l->getString(); 382 return l->getString();
382} 383}
383 384
384void KateDocument::replaceLine(const QString& s,int line) 385void KateDocument::replaceLine(const QString& s,int line)
385{ 386{
386 remove_Line(line,false); 387 remove_Line(line,false);
387 insert_Line(s,line,true); 388 insert_Line(s,line,true);
388} 389}
389 390
390void KateDocument::insertLine( const QString &str, int l ) { 391void KateDocument::insertLine( const QString &str, int l ) {
391 insert_Line(str,l,true); 392 insert_Line(str,l,true);
392} 393}
393 394
394void KateDocument::insert_Line(const QString& s,int line, bool update) 395void KateDocument::insert_Line(const QString& s,int line, bool update)
395{ 396{
396 kdDebug(13020)<<"KateDocument::insertLine "<<s<<QString(" %1").arg(line)<<endl; 397 kdDebug(13020)<<"KateDocument::insertLine "<<s<<QString(" %1").arg(line)<<endl;
397 TextLine::Ptr TL=new TextLine(); 398 TextLine::Ptr TL=new TextLine();
398 TL->append(s.unicode(),s.length()); 399 TL->append(s.unicode(),s.length());
399 buffer->insertLine(line,TL); 400 buffer->insertLine(line,TL);
400 if (update) 401 if (update)
401 { 402 {
402 newDocGeometry=true; 403 newDocGeometry=true;
403 updateLines(line); 404 updateLines(line);
404 updateViews(); 405 updateViews();
405 } 406 }
406} 407}
407 408
408void KateDocument::insertAt( const QString &s, int line, int col, bool ) 409void KateDocument::insertAt( const QString &s, int line, int col, bool )
409{ 410{
410 VConfig c; 411 VConfig c;
411 c.view = 0; // ### FIXME 412 c.view = 0; // ### FIXME
412 c.cursor.x = col; 413 c.cursor.x = col;
413 c.cursor.y = line; 414 c.cursor.y = line;
414 c.cXPos = 0; // ### FIXME 415 c.cXPos = 0; // ### FIXME
415 c.flags = 0; // ### FIXME 416 c.flags = 0; // ### FIXME
416 insert( c, s ); 417 insert( c, s );
417} 418}
418 419
419void KateDocument::removeLine( int line ) { 420void KateDocument::removeLine( int line ) {
420 remove_Line(line,true); 421 remove_Line(line,true);
421} 422}
422 423
423void KateDocument::remove_Line(int line,bool update) 424void KateDocument::remove_Line(int line,bool update)
424{ 425{
425 kdDebug(13020)<<"KateDocument::removeLine "<<QString("%1").arg(line)<<endl; 426 kdDebug(13020)<<"KateDocument::removeLine "<<QString("%1").arg(line)<<endl;
426 buffer->removeLine(line); 427 buffer->removeLine(line);
427// newDocGeometry=true; 428// newDocGeometry=true;
428// if line==0) 429// if line==0)
429 if (update) 430 if (update)
430 { 431 {
431 updateLines(line); 432 updateLines(line);
432 updateViews(); 433 updateViews();
433 } 434 }
434} 435}
435 436
436int KateDocument::length() const 437int KateDocument::length() const
437{ 438{
438 return text().length(); 439 return text().length();
439} 440}
440 441
441void KateDocument::setSelection( int , int , int , int ) 442void KateDocument::setSelection( int , int , int , int )
442{ 443{
443} 444}
444 445
445bool KateDocument::hasSelection() const 446bool KateDocument::hasSelection() const
446{ 447{
447 return (selectEnd >= selectStart); 448 return (selectEnd >= selectStart);
448} 449}
449 450
450QString KateDocument::selection() const 451QString KateDocument::selection() const
451{ 452{
452 uint flags = 0; 453 uint flags = 0;
453 TextLine::Ptr textLine; 454 TextLine::Ptr textLine;
454 int len, z, start, end, i; 455 int len, z, start, end, i;
455 456
456 len = 1; 457 len = 1;
457 if (!(flags & KateView::cfVerticalSelect)) { 458 if (!(flags & KateView::cfVerticalSelect)) {
458 for (z = selectStart; z <= selectEnd; z++) { 459 for (z = selectStart; z <= selectEnd; z++) {
@@ -1800,257 +1801,258 @@ QString KateDocument::markedText(int flags) {
1800 } 1801 }
1801 QString s; 1802 QString s;
1802 len = 0; 1803 len = 0;
1803 for (z = selectStart; z <= selectEnd; z++) { 1804 for (z = selectStart; z <= selectEnd; z++) {
1804 textLine = getTextLine(z); 1805 textLine = getTextLine(z);
1805 end = 0; 1806 end = 0;
1806 do { 1807 do {
1807 start = textLine->findUnselected(end); 1808 start = textLine->findUnselected(end);
1808 end = textLine->findSelected(start); 1809 end = textLine->findSelected(start);
1809 for (i = start; i < end; i++) { 1810 for (i = start; i < end; i++) {
1810 s[len] = textLine->getChar(i); 1811 s[len] = textLine->getChar(i);
1811 len++; 1812 len++;
1812 } 1813 }
1813 } while (start < end); 1814 } while (start < end);
1814 if (textLine->isSelected()) { 1815 if (textLine->isSelected()) {
1815 s[len] = '\n'; 1816 s[len] = '\n';
1816 len++; 1817 len++;
1817 } 1818 }
1818 } 1819 }
1819// s[len] = '\0'; 1820// s[len] = '\0';
1820 return s; 1821 return s;
1821 } else { 1822 } else {
1822 for (z = selectStart; z <= selectEnd; z++) { 1823 for (z = selectStart; z <= selectEnd; z++) {
1823 textLine = getTextLine(z); 1824 textLine = getTextLine(z);
1824 len += textLine->numSelected() + 1; 1825 len += textLine->numSelected() + 1;
1825 } 1826 }
1826 QString s; 1827 QString s;
1827 len = 0; 1828 len = 0;
1828 for (z = selectStart; z <= selectEnd; z++) { 1829 for (z = selectStart; z <= selectEnd; z++) {
1829 textLine = getTextLine(z); 1830 textLine = getTextLine(z);
1830 end = 0; 1831 end = 0;
1831 do { 1832 do {
1832 start = textLine->findUnselected(end); 1833 start = textLine->findUnselected(end);
1833 end = textLine->findSelected(start); 1834 end = textLine->findSelected(start);
1834 for (i = start; i < end; i++) { 1835 for (i = start; i < end; i++) {
1835 s[len] = textLine->getChar(i); 1836 s[len] = textLine->getChar(i);
1836 len++; 1837 len++;
1837 } 1838 }
1838 } while (start < end); 1839 } while (start < end);
1839 s[len] = '\n'; 1840 s[len] = '\n';
1840 len++; 1841 len++;
1841 } 1842 }
1842// s[len] = '\0'; // the final \0 is not counted in length() 1843// s[len] = '\0'; // the final \0 is not counted in length()
1843 return s; 1844 return s;
1844 } 1845 }
1845} 1846}
1846 1847
1847void KateDocument::delMarkedText(VConfig &c/*, bool undo*/) { 1848void KateDocument::delMarkedText(VConfig &c/*, bool undo*/) {
1848 int end = 0; 1849 int end = 0;
1849 1850
1850 if (selectEnd < selectStart) return; 1851 if (selectEnd < selectStart) return;
1851 1852
1852 // the caller may have already started an undo record for the current action 1853 // the caller may have already started an undo record for the current action
1853// if (undo) 1854// if (undo)
1854 1855
1855 //auto deletion of the marked text occurs not very often and can therefore 1856 //auto deletion of the marked text occurs not very often and can therefore
1856 // be recorded separately 1857 // be recorded separately
1857 recordStart(c, KateActionGroup::ugDelBlock); 1858 recordStart(c, KateActionGroup::ugDelBlock);
1858 1859
1859 for (c.cursor.y = selectEnd; c.cursor.y >= selectStart; c.cursor.y--) { 1860 for (c.cursor.y = selectEnd; c.cursor.y >= selectStart; c.cursor.y--) {
1860 TextLine::Ptr textLine = getTextLine(c.cursor.y); 1861 TextLine::Ptr textLine = getTextLine(c.cursor.y);
1861 1862
1862 c.cursor.x = textLine->length(); 1863 c.cursor.x = textLine->length();
1863 do { 1864 do {
1864 end = textLine->findRevUnselected(c.cursor.x); 1865 end = textLine->findRevUnselected(c.cursor.x);
1865 if (end == 0) break; 1866 if (end == 0) break;
1866 c.cursor.x = textLine->findRevSelected(end); 1867 c.cursor.x = textLine->findRevSelected(end);
1867 recordDelete(c.cursor, end - c.cursor.x); 1868 recordDelete(c.cursor, end - c.cursor.x);
1868 } while (true); 1869 } while (true);
1869 end = c.cursor.x; 1870 end = c.cursor.x;
1870 c.cursor.x = textLine->length(); 1871 c.cursor.x = textLine->length();
1871 if (textLine->isSelected()) recordAction(KateAction::delLine,c.cursor); 1872 if (textLine->isSelected()) recordAction(KateAction::delLine,c.cursor);
1872 } 1873 }
1873 c.cursor.y++; 1874 c.cursor.y++;
1874 /*if (end < c.cursor.x)*/ c.cursor.x = end; 1875 /*if (end < c.cursor.x)*/ c.cursor.x = end;
1875 1876
1876 selectEnd = -1; 1877 selectEnd = -1;
1877 select.x = -1; 1878 select.x = -1;
1878 1879
1879 /*if (undo)*/ recordEnd(c); 1880 /*if (undo)*/ recordEnd(c);
1880} 1881}
1881 1882
1882void KateDocument::tagLineRange(int line, int x1, int x2) { 1883void KateDocument::tagLineRange(int line, int x1, int x2) {
1883 int z; 1884 int z;
1884 1885
1885 for (z = 0; z < (int) views.count(); z++) { 1886 for (z = 0; z < (int) views.count(); z++) {
1886 views.at(z)->tagLines(line, line, x1, x2); 1887 views.at(z)->tagLines(line, line, x1, x2);
1887 } 1888 }
1888} 1889}
1889 1890
1890void KateDocument::tagLines(int start, int end) { 1891void KateDocument::tagLines(int start, int end) {
1891 int z; 1892 int z;
1892 1893
1893 for (z = 0; z < (int) views.count(); z++) { 1894 for (z = 0; z < (int) views.count(); z++) {
1894 views.at(z)->tagLines(start, end, 0, 0xffffff); 1895 views.at(z)->tagLines(start, end, 0, 0xffffff);
1895 } 1896 }
1896} 1897}
1897 1898
1898void KateDocument::tagAll() { 1899void KateDocument::tagAll() {
1899 int z; 1900 int z;
1900 1901
1901 for (z = 0; z < (int) views.count(); z++) { 1902 for (z = 0; z < (int) views.count(); z++) {
1902 views.at(z)->tagAll(); 1903 views.at(z)->tagAll();
1903 } 1904 }
1904} 1905}
1905 1906
1906void KateDocument::updateLines(int startLine, int endLine, int flags, int cursorY) { 1907void KateDocument::updateLines(int startLine, int endLine, int flags, int cursorY) {
1907 TextLine::Ptr textLine; 1908 TextLine::Ptr textLine;
1908 int line, last_line; 1909 int line, last_line;
1909 int ctxNum, endCtx; 1910 int ctxNum, endCtx;
1910// kdDebug(13020)<<"******************KateDocument::updateLines Checkpoint 1"<<endl; 1911// kdDebug(13020)<<"******************KateDocument::updateLines Checkpoint 1"<<endl;
1911 if (buffer->line(startLine)==0) {kdDebug(13020)<<"********************No buffer for line " << startLine << " found**************"<<endl; return;}; 1912 if (buffer->line(startLine)==0) {kdDebug(13020)<<"********************No buffer for line " << startLine << " found**************"<<endl; return;};
1912// kdDebug(13020)<<"KateDocument::updateLines Checkpoint 2"<<endl; 1913// kdDebug(13020)<<"KateDocument::updateLines Checkpoint 2"<<endl;
1913 last_line = lastLine(); 1914 last_line = lastLine();
1914// if (endLine >= last_line) endLine = last_line; 1915// if (endLine >= last_line) endLine = last_line;
1915 1916
1916 line = startLine; 1917 line = startLine;
1917 ctxNum = 0; 1918 ctxNum = 0;
1918 if (line > 0) ctxNum = getTextLine(line - 1)->getContext(); 1919 if (line > 0) ctxNum = getTextLine(line - 1)->getContext();
1919 do { 1920 do {
1920// kdDebug(13020)<<QString("**************Working on line: %1").arg(line)<<endl; 1921// kdDebug(13020)<<QString("**************Working on line: %1").arg(line)<<endl;
1921 textLine = getTextLine(line); 1922 textLine = getTextLine(line);
1922 if (textLine==0) kdDebug(13020)<<"****updateLines()>> error textLine==0"<<endl; 1923 if (textLine==0) kdDebug(13020)<<"****updateLines()>> error textLine==0"<<endl;
1923 if (line <= endLine && line != cursorY) { 1924 if (line <= endLine && line != cursorY) {
1924 if (flags & KateView::cfRemoveSpaces) textLine->removeSpaces(); 1925 if (flags & KateView::cfRemoveSpaces) textLine->removeSpaces();
1925 updateMaxLength(textLine); 1926 updateMaxLength(textLine);
1926 } 1927 }
1927 endCtx = textLine->getContext(); 1928 endCtx = textLine->getContext();
1928 qDebug("DOHIGHLIGHT"); 1929// qDebug("DOHIGHLIGHT");
1930
1929 ctxNum = m_highlight->doHighlight(ctxNum,textLine); 1931 ctxNum = m_highlight->doHighlight(ctxNum,textLine);
1930 textLine->setContext(ctxNum); 1932 textLine->setContext(ctxNum);
1931 line++; 1933 line++;
1932 } while ((buffer->line(line)!=0) && (line <= endLine || endCtx != ctxNum)); 1934 } while ((buffer->line(line)!=0) && (line <= endLine || endCtx != ctxNum));
1933// kdDebug(13020)<<"updateLines :: while loop left"<<endl; 1935// kdDebug(13020)<<"updateLines :: while loop left"<<endl;
1934 tagLines(startLine, line - 1); 1936 tagLines(startLine, line - 1);
1935} 1937}
1936 1938
1937 1939
1938void KateDocument::updateMaxLength(TextLine::Ptr &textLine) { 1940void KateDocument::updateMaxLength(TextLine::Ptr &textLine) {
1939 int len; 1941 int len;
1940 1942
1941 len = textWidth(textLine,textLine->length()); 1943 len = textWidth(textLine,textLine->length());
1942 1944
1943 if (len > maxLength) { 1945 if (len > maxLength) {
1944 longestLine = textLine; 1946 longestLine = textLine;
1945 maxLength = len; 1947 maxLength = len;
1946 newDocGeometry = true; 1948 newDocGeometry = true;
1947 } else { 1949 } else {
1948 if (!longestLine || (textLine == longestLine && len <= maxLength*3/4)) { 1950 if (!longestLine || (textLine == longestLine && len <= maxLength*3/4)) {
1949 maxLength = -1; 1951 maxLength = -1;
1950 for (int i = 0; i < numLines();i++) { 1952 for (int i = 0; i < numLines();i++) {
1951 textLine = getTextLine(i); 1953 textLine = getTextLine(i);
1952 len = textWidth(textLine,textLine->length()); 1954 len = textWidth(textLine,textLine->length());
1953 if (len > maxLength) { 1955 if (len > maxLength) {
1954 maxLength = len; 1956 maxLength = len;
1955 longestLine = textLine; 1957 longestLine = textLine;
1956 } 1958 }
1957 } 1959 }
1958 newDocGeometry = true; 1960 newDocGeometry = true;
1959 } 1961 }
1960 } 1962 }
1961} 1963}
1962 1964
1963void KateDocument::slotBufferChanged() { 1965void KateDocument::slotBufferChanged() {
1964 newDocGeometry = true; 1966 newDocGeometry = true;
1965 //updateLines();//JW 1967 //updateLines();//JW
1966 updateViews(); 1968 updateViews();
1967} 1969}
1968 1970
1969void KateDocument::slotBufferHighlight(long start,long stop) { 1971void KateDocument::slotBufferHighlight(long start,long stop) {
1970 kdDebug(13020)<<"KateDocument::slotBufferHighlight"<<QString("%1-%2").arg(start).arg(stop)<<endl; 1972 kdDebug(13020)<<"KateDocument::slotBufferHighlight"<<QString("%1-%2").arg(start).arg(stop)<<endl;
1971 updateLines(start,stop); 1973 updateLines(start,stop);
1972// buffer->startLoadTimer(); 1974// buffer->startLoadTimer();
1973} 1975}
1974 1976
1975void KateDocument::updateViews(KateView *exclude) { 1977void KateDocument::updateViews(KateView *exclude) {
1976 KateView *view; 1978 KateView *view;
1977 int flags; 1979 int flags;
1978 bool markState = hasMarkedText(); 1980 bool markState = hasMarkedText();
1979 1981
1980 flags = (newDocGeometry) ? KateView::ufDocGeometry : 0; 1982 flags = (newDocGeometry) ? KateView::ufDocGeometry : 0;
1981 for (view = views.first(); view != 0L; view = views.next() ) { 1983 for (view = views.first(); view != 0L; view = views.next() ) {
1982 if (view != exclude) view->updateView(flags); 1984 if (view != exclude) view->updateView(flags);
1983 1985
1984 // notify every view about the changed mark state.... 1986 // notify every view about the changed mark state....
1985 if (oldMarkState != markState) emit view->newMarkStatus(); 1987 if (oldMarkState != markState) emit view->newMarkStatus();
1986 } 1988 }
1987 oldMarkState = markState; 1989 oldMarkState = markState;
1988 newDocGeometry = false; 1990 newDocGeometry = false;
1989} 1991}
1990 1992
1991QColor &KateDocument::cursorCol(int x, int y) { 1993QColor &KateDocument::cursorCol(int x, int y) {
1992 int attr; 1994 int attr;
1993 Attribute *a; 1995 Attribute *a;
1994 1996
1995 TextLine::Ptr textLine = getTextLine(y); 1997 TextLine::Ptr textLine = getTextLine(y);
1996 attr = textLine->getRawAttr(x); 1998 attr = textLine->getRawAttr(x);
1997 a = &m_attribs[attr & taAttrMask]; 1999 a = &m_attribs[attr & taAttrMask];
1998 if (attr & taSelected) return a->selCol; else return a->col; 2000 if (attr & taSelected) return a->selCol; else return a->col;
1999} 2001}
2000 2002
2001void KateDocument::paintTextLine(QPainter &paint, int line, int xStart, int xEnd, bool showTabs) 2003void KateDocument::paintTextLine(QPainter &paint, int line, int xStart, int xEnd, bool showTabs)
2002{ 2004{
2003 paintTextLine (paint, line, 0, xStart, xEnd, showTabs); 2005 paintTextLine (paint, line, 0, xStart, xEnd, showTabs);
2004} 2006}
2005 2007
2006void KateDocument::paintTextLine(QPainter &paint, int line, int y, int xStart, int xEnd, bool showTabs) 2008void KateDocument::paintTextLine(QPainter &paint, int line, int y, int xStart, int xEnd, bool showTabs)
2007{ 2009{
2008 TextLine::Ptr textLine; 2010 TextLine::Ptr textLine;
2009 int len; 2011 int len;
2010 const QChar *s; 2012 const QChar *s;
2011 int z, x; 2013 int z, x;
2012 QChar ch; 2014 QChar ch;
2013 Attribute *a = 0L; 2015 Attribute *a = 0L;
2014 int attr, nextAttr; 2016 int attr, nextAttr;
2015 int xs; 2017 int xs;
2016 int xc, zc; 2018 int xc, zc;
2017 2019
2018 if (line > lastLine()) { 2020 if (line > lastLine()) {
2019 paint.fillRect(0, y, xEnd - xStart,fontHeight, colors[0]); 2021 paint.fillRect(0, y, xEnd - xStart,fontHeight, colors[0]);
2020 return; 2022 return;
2021 } 2023 }
2022 2024
2023 textLine = getTextLine(line); 2025 textLine = getTextLine(line);
2024 len = textLine->length(); 2026 len = textLine->length();
2025 s = textLine->getText(); 2027 s = textLine->getText();
2026 2028
2027 // skip to first visible character 2029 // skip to first visible character
2028 x = 0; 2030 x = 0;
2029 z = 0; 2031 z = 0;
2030 do { 2032 do {
2031 xc = x; 2033 xc = x;
2032 zc = z; 2034 zc = z;
2033 if (z == len) break; 2035 if (z == len) break;
2034 ch = s[z];//textLine->getChar(z); 2036 ch = s[z];//textLine->getChar(z);
2035 if (ch == '\t') { 2037 if (ch == '\t') {
2036 x += m_tabWidth - (x % m_tabWidth); 2038 x += m_tabWidth - (x % m_tabWidth);
2037 } else { 2039 } else {
2038 a = &m_attribs[textLine->getAttr(z)]; 2040 a = &m_attribs[textLine->getAttr(z)];
2039 2041
2040 if (a->bold && a->italic) 2042 if (a->bold && a->italic)
2041 x += myFontMetricsBI.width(ch); 2043 x += myFontMetricsBI.width(ch);
2042 else if (a->bold) 2044 else if (a->bold)
2043 x += myFontMetricsBold.width(ch); 2045 x += myFontMetricsBold.width(ch);
2044 else if (a->italic) 2046 else if (a->italic)
2045 x += myFontMetricsItalic.width(ch); 2047 x += myFontMetricsItalic.width(ch);
2046 else 2048 else
2047 x += myFontMetrics.width(ch); 2049 x += myFontMetrics.width(ch);
2048 } 2050 }
2049 z++; 2051 z++;
2050 } while (x <= xStart); 2052 } while (x <= xStart);
2051 2053
2052 // draw background 2054 // draw background
2053 xs = xStart; 2055 xs = xStart;
2054 attr = textLine->getRawAttr(zc); 2056 attr = textLine->getRawAttr(zc);
2055 while (x < xEnd) 2057 while (x < xEnd)
2056 { 2058 {
@@ -2905,256 +2907,262 @@ void KateDocument::setPseudoModal(QWidget *w) {
2905 if (pseudoModal && pseudoModal != (QWidget*)1L) 2907 if (pseudoModal && pseudoModal != (QWidget*)1L)
2906 delete pseudoModal; 2908 delete pseudoModal;
2907 2909
2908// pseudoModal = 0L; 2910// pseudoModal = 0L;
2909// if (old || w) recordReset(); 2911// if (old || w) recordReset();
2910 2912
2911 pseudoModal = w; 2913 pseudoModal = w;
2912} 2914}
2913 2915
2914 2916
2915void KateDocument::newBracketMark(PointStruc &cursor, BracketMark &bm) 2917void KateDocument::newBracketMark(PointStruc &cursor, BracketMark &bm)
2916{ 2918{
2917 TextLine::Ptr textLine; 2919 TextLine::Ptr textLine;
2918 int x, line, count, attr; 2920 int x, line, count, attr;
2919 QChar bracket, opposite, ch; 2921 QChar bracket, opposite, ch;
2920 Attribute *a; 2922 Attribute *a;
2921 2923
2922 bm.eXPos = -1; //mark bracked mark as invalid 2924 bm.eXPos = -1; //mark bracked mark as invalid
2923 x = cursor.x -1; // -1 to look at left side of cursor 2925 x = cursor.x -1; // -1 to look at left side of cursor
2924 if (x < 0) return; 2926 if (x < 0) return;
2925 line = cursor.y; //current line 2927 line = cursor.y; //current line
2926 count = 0; //bracket counter for nested brackets 2928 count = 0; //bracket counter for nested brackets
2927 2929
2928 textLine = getTextLine(line); 2930 textLine = getTextLine(line);
2929 if (!textLine) return; 2931 if (!textLine) return;
2930 2932
2931 bracket = textLine->getChar(x); 2933 bracket = textLine->getChar(x);
2932 attr = textLine->getAttr(x); 2934 attr = textLine->getAttr(x);
2933 2935
2934 if (bracket == '(' || bracket == '[' || bracket == '{') 2936 if (bracket == '(' || bracket == '[' || bracket == '{')
2935 { 2937 {
2936 //get opposite bracket 2938 //get opposite bracket
2937 opposite = ')'; 2939 opposite = ')';
2938 if (bracket == '[') opposite = ']'; 2940 if (bracket == '[') opposite = ']';
2939 if (bracket == '{') opposite = '}'; 2941 if (bracket == '{') opposite = '}';
2940 //get attribute of bracket (opposite bracket must have the same attribute) 2942 //get attribute of bracket (opposite bracket must have the same attribute)
2941 x++; 2943 x++;
2942 while (line - cursor.y < 40) { 2944 while (line - cursor.y < 40) {
2943 //go to next line on end of line 2945 //go to next line on end of line
2944 while (x >= (int) textLine->length()) { 2946 while (x >= (int) textLine->length()) {
2945 line++; 2947 line++;
2946 if (line > lastLine()) return; 2948 if (line > lastLine()) return;
2947 textLine = getTextLine(line); 2949 textLine = getTextLine(line);
2948 x = 0; 2950 x = 0;
2949 } 2951 }
2950 if (textLine->getAttr(x) == attr) { 2952 if (textLine->getAttr(x) == attr) {
2951 //try to find opposite bracked 2953 //try to find opposite bracked
2952 ch = textLine->getChar(x); 2954 ch = textLine->getChar(x);
2953 if (ch == bracket) count++; //same bracket : increase counter 2955 if (ch == bracket) count++; //same bracket : increase counter
2954 if (ch == opposite) { 2956 if (ch == opposite) {
2955 count--; 2957 count--;
2956 if (count < 0) goto found; 2958 if (count < 0) goto found;
2957 } 2959 }
2958 } 2960 }
2959 x++; 2961 x++;
2960 } 2962 }
2961 } 2963 }
2962 else if (bracket == ')' || bracket == ']' || bracket == '}') 2964 else if (bracket == ')' || bracket == ']' || bracket == '}')
2963 { 2965 {
2964 opposite = '('; 2966 opposite = '(';
2965 if (bracket == ']') opposite = '['; 2967 if (bracket == ']') opposite = '[';
2966 if (bracket == '}') opposite = '{'; 2968 if (bracket == '}') opposite = '{';
2967 x--; 2969 x--;
2968 while (cursor.y - line < 20) { 2970 while (cursor.y - line < 20) {
2969 2971
2970 while (x < 0) { 2972 while (x < 0) {
2971 line--; 2973 line--;
2972 if (line < 0) return; 2974 if (line < 0) return;
2973 textLine = getTextLine(line); 2975 textLine = getTextLine(line);
2974 x = textLine->length() -1; 2976 x = textLine->length() -1;
2975 } 2977 }
2976 if (textLine->getAttr(x) == attr) { 2978 if (textLine->getAttr(x) == attr) {
2977 ch = textLine->getChar(x); 2979 ch = textLine->getChar(x);
2978 if (ch == bracket) count++; 2980 if (ch == bracket) count++;
2979 if (ch == opposite) { 2981 if (ch == opposite) {
2980 count--; 2982 count--;
2981 if (count < 0) goto found; 2983 if (count < 0) goto found;
2982 } 2984 }
2983 } 2985 }
2984 x--; 2986 x--;
2985 } 2987 }
2986 } 2988 }
2987 return; 2989 return;
2988 2990
2989found: 2991found:
2990 //cursor position of opposite bracket 2992 //cursor position of opposite bracket
2991 bm.cursor.x = x; 2993 bm.cursor.x = x;
2992 bm.cursor.y = line; 2994 bm.cursor.y = line;
2993 //x position (start and end) of related bracket 2995 //x position (start and end) of related bracket
2994 bm.sXPos = textWidth(textLine, x); 2996 bm.sXPos = textWidth(textLine, x);
2995 a = &m_attribs[attr]; 2997 a = &m_attribs[attr];
2996 2998
2997 if (a->bold && a->italic) 2999 if (a->bold && a->italic)
2998 bm.eXPos = bm.sXPos + myFontMetricsBI.width(bracket); 3000 bm.eXPos = bm.sXPos + myFontMetricsBI.width(bracket);
2999 else if (a->bold) 3001 else if (a->bold)
3000 bm.eXPos = bm.sXPos + myFontMetricsBold.width(bracket); 3002 bm.eXPos = bm.sXPos + myFontMetricsBold.width(bracket);
3001 else if (a->italic) 3003 else if (a->italic)
3002 bm.eXPos = bm.sXPos + myFontMetricsItalic.width(bracket); 3004 bm.eXPos = bm.sXPos + myFontMetricsItalic.width(bracket);
3003 else 3005 else
3004 bm.eXPos = bm.sXPos + myFontMetrics.width(bracket); 3006 bm.eXPos = bm.sXPos + myFontMetrics.width(bracket);
3005} 3007}
3006 3008
3007void KateDocument::clipboardChanged() { //slot 3009void KateDocument::clipboardChanged() { //slot
3008//#if defined(_WS_X11_) 3010//#if defined(_WS_X11_)
3009 if (m_singleSelection) { 3011 if (m_singleSelection) {
3010 disconnect(QApplication::clipboard(), SIGNAL(dataChanged()), 3012 disconnect(QApplication::clipboard(), SIGNAL(dataChanged()),
3011 this, SLOT(clipboardChanged())); 3013 this, SLOT(clipboardChanged()));
3012 deselectAll(); 3014 deselectAll();
3013 updateViews(); 3015 updateViews();
3014 } 3016 }
3015//#endif 3017//#endif
3016} 3018}
3017 3019
3018#if 0 3020#if 0
3019void KateDocument::guiActivateEvent( KParts::GUIActivateEvent *ev ) 3021void KateDocument::guiActivateEvent( KParts::GUIActivateEvent *ev )
3020{ 3022{
3021 KParts::ReadWritePart::guiActivateEvent( ev ); 3023 KParts::ReadWritePart::guiActivateEvent( ev );
3022 if ( ev->activated() ) 3024 if ( ev->activated() )
3023 emit selectionChanged(); 3025 emit selectionChanged();
3024} 3026}
3025#endif 3027#endif
3026 3028
3027void KateDocument::setDocName (QString docName) 3029void KateDocument::setDocName (QString docName)
3028{ 3030{
3029 myDocName = docName; 3031 myDocName = docName;
3030 emit nameChanged (this); 3032 emit nameChanged (this);
3031} 3033}
3032 3034
3035void KateDocument::setDocFile (QString docFile)
3036{
3037 m_file = docFile;
3038 emit fileNameChanged ();
3039}
3040
3033void KateDocument::setMTime() 3041void KateDocument::setMTime()
3034{ 3042{
3035 if (fileInfo && !fileInfo->fileName().isEmpty()) { 3043 if (fileInfo && !fileInfo->fileName().isEmpty()) {
3036 fileInfo->refresh(); 3044 fileInfo->refresh();
3037 mTime = fileInfo->lastModified(); 3045 mTime = fileInfo->lastModified();
3038 } 3046 }
3039} 3047}
3040 3048
3041void KateDocument::isModOnHD(bool forceReload) 3049void KateDocument::isModOnHD(bool forceReload)
3042{ 3050{
3043 if (fileInfo && !fileInfo->fileName().isEmpty()) { 3051 if (fileInfo && !fileInfo->fileName().isEmpty()) {
3044 fileInfo->refresh(); 3052 fileInfo->refresh();
3045 if (fileInfo->lastModified() > mTime) { 3053 if (fileInfo->lastModified() > mTime) {
3046 if ( forceReload || 3054 if ( forceReload ||
3047 (KMessageBox::warningContinueCancel(0, 3055 (KMessageBox::warningContinueCancel(0,
3048 (i18n("The file %1 has changed on disk.\nDo you want to reload it?\n\nIf you cancel you will lose these changes next time you save this file")).arg(m_url), 3056 (i18n("The file %1 has changed on disk.\nDo you want to reload it?\n\nIf you cancel you will lose these changes next time you save this file")).arg(m_url),
3049 i18n("File has changed on Disk"), 3057 i18n("File has changed on Disk"),
3050 i18n("Yes") ) == KMessageBox::Continue) 3058 i18n("Yes") ) == KMessageBox::Continue)
3051 ) 3059 )
3052 reloadFile(); 3060 reloadFile();
3053 else 3061 else
3054 setMTime(); 3062 setMTime();
3055 } 3063 }
3056 } 3064 }
3057} 3065}
3058 3066
3059void KateDocument::reloadFile() 3067void KateDocument::reloadFile()
3060{ 3068{
3061#warning fixme 3069#warning fixme
3062#if 0 3070#if 0
3063 if (fileInfo && !fileInfo->fileName().isEmpty()) { 3071 if (fileInfo && !fileInfo->fileName().isEmpty()) {
3064 KateDocument::openFile(); 3072 KateDocument::openFile();
3065 setMTime(); 3073 setMTime();
3066 } 3074 }
3067#endif 3075#endif
3068} 3076}
3069 3077
3070void KateDocument::slotModChanged() 3078void KateDocument::slotModChanged()
3071{ 3079{
3072 emit modStateChanged (this); 3080 emit modStateChanged (this);
3073} 3081}
3074 3082
3075QList<Kate::Mark> KateDocument::marks () 3083QList<Kate::Mark> KateDocument::marks ()
3076{ 3084{
3077 QList<Kate::Mark> list; 3085 QList<Kate::Mark> list;
3078 TextLine::Ptr line; 3086 TextLine::Ptr line;
3079 3087
3080 for (int i=0; i < numLines(); i++) 3088 for (int i=0; i < numLines(); i++)
3081 { 3089 {
3082 line = getTextLine(i); 3090 line = getTextLine(i);
3083 if (line->mark() != 0) 3091 if (line->mark() != 0)
3084 { 3092 {
3085 Kate::Mark *mark=new Kate::Mark; 3093 Kate::Mark *mark=new Kate::Mark;
3086 mark->line = i; 3094 mark->line = i;
3087 mark->type = line->mark(); 3095 mark->type = line->mark();
3088 list.append (mark); 3096 list.append (mark);
3089 } 3097 }
3090 } 3098 }
3091 3099
3092 return list; 3100 return list;
3093} 3101}
3094 3102
3095void KateDocument::flush () 3103void KateDocument::flush ()
3096{ 3104{
3097 if (isReadOnly()) 3105 if (isReadOnly())
3098 return; 3106 return;
3099 3107
3100 m_url = QString::null; 3108 m_url = QString::null;
3101 fileInfo->setFile (QString()); 3109 fileInfo->setFile (QString());
3102 setMTime(); 3110 setMTime();
3103 3111
3104 clear(); 3112 clear();
3105 updateViews(); 3113 updateViews();
3106 3114
3107 emit fileNameChanged (); 3115 emit fileNameChanged ();
3108} 3116}
3109 3117
3110void KateDocument::open (const QString &name) 3118void KateDocument::open (const QString &name)
3111{ 3119{
3112 openURL (name); 3120 openURL (name);
3113} 3121}
3114 3122
3115void KateDocument::wrapText (uint col) 3123void KateDocument::wrapText (uint col)
3116{ 3124{
3117 int line = 0; 3125 int line = 0;
3118 int z = 0; 3126 int z = 0;
3119 3127
3120 while(true) 3128 while(true)
3121 { 3129 {
3122 TextLine::Ptr l = getTextLine(line); 3130 TextLine::Ptr l = getTextLine(line);
3123 3131
3124 if (l->length() > col) 3132 if (l->length() > col)
3125 { 3133 {
3126 TextLine::Ptr tl = new TextLine(); 3134 TextLine::Ptr tl = new TextLine();
3127 buffer->insertLine(line+1,tl); 3135 buffer->insertLine(line+1,tl);
3128 const QChar *text = l->getText(); 3136 const QChar *text = l->getText();
3129 3137
3130 for (z=col; z>0; z--) 3138 for (z=col; z>0; z--)
3131 { 3139 {
3132 if (z < 1) break; 3140 if (z < 1) break;
3133 if (text[z].isSpace()) break; 3141 if (text[z].isSpace()) break;
3134 } 3142 }
3135 3143
3136 if (z < 1) z=col; 3144 if (z < 1) z=col;
3137 3145
3138 l->wrap (tl, z); 3146 l->wrap (tl, z);
3139 } 3147 }
3140 3148
3141 line++; 3149 line++;
3142 if (line >= numLines()) break; 3150 if (line >= numLines()) break;
3143 }; 3151 };
3144 3152
3145 newDocGeometry=true; 3153 newDocGeometry=true;
3146 updateLines(); 3154 updateLines();
3147 updateViews(); 3155 updateViews();
3148} 3156}
3149 3157
3150void KateDocument::setWordWrap (bool on) 3158void KateDocument::setWordWrap (bool on)
3151{ 3159{
3152 if (on != myWordWrap && on) 3160 if (on != myWordWrap && on)
3153 wrapText (myWordWrapAt); 3161 wrapText (myWordWrapAt);
3154 3162
3155 myWordWrap = on; 3163 myWordWrap = on;
3156} 3164}
3157 3165
3158void KateDocument::setWordWrapAt (uint col) 3166void KateDocument::setWordWrapAt (uint col)
3159{ 3167{
3160 if (myWordWrapAt != col && myWordWrap) 3168 if (myWordWrapAt != col && myWordWrap)
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.h b/noncore/apps/tinykate/libkate/document/katedocument.h
index 220d188..356541f 100644
--- a/noncore/apps/tinykate/libkate/document/katedocument.h
+++ b/noncore/apps/tinykate/libkate/document/katedocument.h
@@ -329,241 +329,242 @@ class KateDocument: public Kate::Document
329 QString markedText(int flags); 329 QString markedText(int flags);
330 void delMarkedText(VConfig &/*, bool undo = true*/); 330 void delMarkedText(VConfig &/*, bool undo = true*/);
331 331
332 void tagLineRange(int line, int x1, int x2); 332 void tagLineRange(int line, int x1, int x2);
333 void tagLines(int start, int end); 333 void tagLines(int start, int end);
334 void tagAll(); 334 void tagAll();
335 void updateLines(int startLine = 0, int endLine = 0xffffff, int flags = 0, int cursorY = -1); 335 void updateLines(int startLine = 0, int endLine = 0xffffff, int flags = 0, int cursorY = -1);
336 void updateMaxLength(TextLine::Ptr &); 336 void updateMaxLength(TextLine::Ptr &);
337 void updateViews(KateView *exclude = 0L); 337 void updateViews(KateView *exclude = 0L);
338 338
339 QColor &cursorCol(int x, int y); 339 QColor &cursorCol(int x, int y);
340 void paintTextLine(QPainter &, int line, int xStart, int xEnd, bool showTabs); 340 void paintTextLine(QPainter &, int line, int xStart, int xEnd, bool showTabs);
341 void paintTextLine(QPainter &, int line, int y, int xStart, int xEnd, bool showTabs); 341 void paintTextLine(QPainter &, int line, int y, int xStart, int xEnd, bool showTabs);
342 342
343 bool doSearch(SConfig &s, const QString &searchFor); 343 bool doSearch(SConfig &s, const QString &searchFor);
344 344
345// internal 345// internal
346 void tagLine(int line); 346 void tagLine(int line);
347 void insLine(int line); 347 void insLine(int line);
348 void delLine(int line); 348 void delLine(int line);
349 void optimizeSelection(); 349 void optimizeSelection();
350 350
351 void doAction(KateAction *); 351 void doAction(KateAction *);
352 void doReplace(KateAction *); 352 void doReplace(KateAction *);
353 void doWordWrap(KateAction *); 353 void doWordWrap(KateAction *);
354 void doWordUnWrap(KateAction *); 354 void doWordUnWrap(KateAction *);
355 void doNewLine(KateAction *); 355 void doNewLine(KateAction *);
356 void doDelLine(KateAction *); 356 void doDelLine(KateAction *);
357 void doInsLine(KateAction *); 357 void doInsLine(KateAction *);
358 void doKillLine(KateAction *); 358 void doKillLine(KateAction *);
359 void newUndo(); 359 void newUndo();
360 360
361 void recordStart(VConfig &, int newUndoType); 361 void recordStart(VConfig &, int newUndoType);
362 void recordStart(KateView *, PointStruc &, int flags, int newUndoType, bool keepModal = false, bool mergeUndo = false); 362 void recordStart(KateView *, PointStruc &, int flags, int newUndoType, bool keepModal = false, bool mergeUndo = false);
363 void recordAction(KateAction::Action, PointStruc &); 363 void recordAction(KateAction::Action, PointStruc &);
364 void recordInsert(VConfig &, const QString &text); 364 void recordInsert(VConfig &, const QString &text);
365 void recordReplace(VConfig &, int len, const QString &text); 365 void recordReplace(VConfig &, int len, const QString &text);
366 void recordInsert(PointStruc &, const QString &text); 366 void recordInsert(PointStruc &, const QString &text);
367 void recordDelete(PointStruc &, int len); 367 void recordDelete(PointStruc &, int len);
368 void recordReplace(PointStruc &, int len, const QString &text); 368 void recordReplace(PointStruc &, int len, const QString &text);
369 void recordEnd(VConfig &); 369 void recordEnd(VConfig &);
370 void recordEnd(KateView *, PointStruc &, int flags); 370 void recordEnd(KateView *, PointStruc &, int flags);
371 void doActionGroup(KateActionGroup *, int flags, bool undo = false); 371 void doActionGroup(KateActionGroup *, int flags, bool undo = false);
372 372
373 int nextUndoType(); 373 int nextUndoType();
374 int nextRedoType(); 374 int nextRedoType();
375 void undoTypeList(QValueList<int> &lst); 375 void undoTypeList(QValueList<int> &lst);
376 void redoTypeList(QValueList<int> &lst); 376 void redoTypeList(QValueList<int> &lst);
377 void undo(VConfig &, int count = 1); 377 void undo(VConfig &, int count = 1);
378 void redo(VConfig &, int count = 1); 378 void redo(VConfig &, int count = 1);
379 void clearRedo(); 379 void clearRedo();
380 void setUndoSteps(int steps); 380 void setUndoSteps(int steps);
381 381
382 void setPseudoModal(QWidget *); 382 void setPseudoModal(QWidget *);
383 383
384 void newBracketMark(PointStruc &, BracketMark &); 384 void newBracketMark(PointStruc &, BracketMark &);
385 385
386 386
387 protected slots: 387 protected slots:
388 void clipboardChanged(); 388 void clipboardChanged();
389 void slotBufferChanged(); 389 void slotBufferChanged();
390 void slotBufferHighlight(long,long); 390 void slotBufferHighlight(long,long);
391 void doPreHighlight(); 391 void doPreHighlight();
392 392
393 private slots: 393 private slots:
394 void slotViewDestroyed(); 394 void slotViewDestroyed();
395 395
396// member variables 396// member variables
397 protected: 397 protected:
398 long PreHighlightedTill; 398 long PreHighlightedTill;
399 long RequestPreHighlightTill; 399 long RequestPreHighlightTill;
400 KWBuffer *buffer; 400 KWBuffer *buffer;
401 QColor colors[2]; 401 QColor colors[2];
402 HlManager *hlManager; 402 HlManager *hlManager;
403 Highlight *m_highlight; 403 Highlight *m_highlight;
404 int m_numAttribs; 404 int m_numAttribs;
405 static const int maxAttribs; 405 static const int maxAttribs;
406 Attribute *m_attribs; 406 Attribute *m_attribs;
407 407
408 int eolMode; 408 int eolMode;
409 409
410 int tabChars; 410 int tabChars;
411 int m_tabWidth; 411 int m_tabWidth;
412 int fontHeight; 412 int fontHeight;
413 int fontAscent; 413 int fontAscent;
414 414
415 QList<KateView> views; 415 QList<KateView> views;
416 bool newDocGeometry; 416 bool newDocGeometry;
417 417
418 TextLine::Ptr longestLine; 418 TextLine::Ptr longestLine;
419 float maxLength; 419 float maxLength;
420 420
421 PointStruc select; 421 PointStruc select;
422 PointStruc anchor; 422 PointStruc anchor;
423 int aXPos; 423 int aXPos;
424 int selectStart; 424 int selectStart;
425 int selectEnd; 425 int selectEnd;
426 bool oldMarkState; 426 bool oldMarkState;
427 bool m_singleSelection; // false: windows-like, true: X11-like 427 bool m_singleSelection; // false: windows-like, true: X11-like
428 428
429 bool readOnly; 429 bool readOnly;
430 bool newDoc; // True if the file is a new document (used to determine whether 430 bool newDoc; // True if the file is a new document (used to determine whether
431 // to check for overwriting files on save) 431 // to check for overwriting files on save)
432 bool modified; 432 bool modified;
433 433
434 bool myWordWrap; 434 bool myWordWrap;
435 uint myWordWrapAt; 435 uint myWordWrapAt;
436 436
437 QList<KateActionGroup> undoList; 437 QList<KateActionGroup> undoList;
438 int currentUndo; 438 int currentUndo;
439 int undoState; 439 int undoState;
440 int undoSteps; 440 int undoSteps;
441 int tagStart; 441 int tagStart;
442 int tagEnd; 442 int tagEnd;
443 int undoCount; //counts merged undo steps 443 int undoCount; //counts merged undo steps
444 444
445 QWidget *pseudoModal; //the replace prompt is pseudo modal 445 QWidget *pseudoModal; //the replace prompt is pseudo modal
446 446
447 public: 447 public:
448 /** Tjecks if the file on disk is newer than document contents. 448 /** Tjecks if the file on disk is newer than document contents.
449 If forceReload is true, the document is reloaded without asking the user, 449 If forceReload is true, the document is reloaded without asking the user,
450 otherwise [default] the user is asked what to do. */ 450 otherwise [default] the user is asked what to do. */
451 void isModOnHD(bool forceReload=false); 451 void isModOnHD(bool forceReload=false);
452 452
453 uint docID () {return myDocID;}; 453 uint docID () {return myDocID;};
454 QString docName () {return myDocName;}; 454 QString docName () {return myDocName;};
455 455
456 void setDocName (QString docName); 456 void setDocName (QString docName);
457 void setDocFile (QString docFile);
457 458
458 public slots: 459 public slots:
459 /** Reloads the current document from disk if possible */ 460 /** Reloads the current document from disk if possible */
460 void reloadFile(); 461 void reloadFile();
461 462
462 private slots: 463 private slots:
463 void slotModChanged (); 464 void slotModChanged ();
464 465
465 private: 466 private:
466 /** updates mTime to reflect file on fs. 467 /** updates mTime to reflect file on fs.
467 called from constructor and from saveFile. */ 468 called from constructor and from saveFile. */
468 void setMTime(); 469 void setMTime();
469 uint myDocID; 470 uint myDocID;
470 QFileInfo* fileInfo; 471 QFileInfo* fileInfo;
471 QDateTime mTime; 472 QDateTime mTime;
472 QString myDocName; 473 QString myDocName;
473 474
474 QString m_url; 475 QString m_url;
475 QString m_file; 476 QString m_file;
476 void openURL(const QString &filename); 477 void openURL(const QString &filename);
477 private: 478 private:
478 KateCmd *myCmd; 479 KateCmd *myCmd;
479 480
480 public: 481 public:
481 KateCmd *cmd () { return myCmd; }; 482 KateCmd *cmd () { return myCmd; };
482 483
483 private: 484 private:
484 QString myEncoding; 485 QString myEncoding;
485 486
486 public: 487 public:
487 void setEncoding (QString e) { myEncoding = e; }; 488 void setEncoding (QString e) { myEncoding = e; };
488 QString encoding() { return myEncoding; }; 489 QString encoding() { return myEncoding; };
489 490
490 void setWordWrap (bool on); 491 void setWordWrap (bool on);
491 bool wordWrap () { return myWordWrap; }; 492 bool wordWrap () { return myWordWrap; };
492 493
493 void setWordWrapAt (uint col); 494 void setWordWrapAt (uint col);
494 uint wordWrapAt () { return myWordWrapAt; }; 495 uint wordWrapAt () { return myWordWrapAt; };
495 496
496 signals: 497 signals:
497 void modStateChanged (KateDocument *doc); 498 void modStateChanged (KateDocument *doc);
498 void nameChanged (KateDocument *doc); 499 void nameChanged (KateDocument *doc);
499 500
500 public: 501 public:
501 QList<Kate::Mark> marks (); 502 QList<Kate::Mark> marks ();
502 503
503 public slots: 504 public slots:
504 // clear buffer/filename - update the views 505 // clear buffer/filename - update the views
505 void flush (); 506 void flush ();
506 507
507 signals: 508 signals:
508 /** 509 /**
509 The file has been saved (perhaps the name has changed). The main window 510 The file has been saved (perhaps the name has changed). The main window
510 can use this to change its caption 511 can use this to change its caption
511 */ 512 */
512 void fileNameChanged (); 513 void fileNameChanged ();
513 514
514 public: 515 public:
515 //end of line settings 516 //end of line settings
516 enum Eol_settings {eolUnix=0,eolDos=1,eolMacintosh=2}; 517 enum Eol_settings {eolUnix=0,eolDos=1,eolMacintosh=2};
517 518
518 // for the DCOP interface 519 // for the DCOP interface
519 public: 520 public:
520 void open (const QString &name=0); 521 void open (const QString &name=0);
521 522
522 public: 523 public:
523 // wrap the text of the document at the column col 524 // wrap the text of the document at the column col
524 void wrapText (uint col); 525 void wrapText (uint col);
525 526
526 public slots: 527 public slots:
527 void applyWordWrap (); 528 void applyWordWrap ();
528 529
529 private: 530 private:
530 531
531 class KateDocPrivate 532 class KateDocPrivate
532 { 533 {
533 public: 534 public:
534 bool hlSetByUser; 535 bool hlSetByUser;
535 }; 536 };
536 537
537 538
538// BCI: Add a real d-pointer in the next BIC release 539// BCI: Add a real d-pointer in the next BIC release
539static QPtrDict<KateDocPrivate>* d_ptr; 540static QPtrDict<KateDocPrivate>* d_ptr;
540static void cleanup_d_ptr() 541static void cleanup_d_ptr()
541 { 542 {
542 delete d_ptr; 543 delete d_ptr;
543 } 544 }
544 545
545KateDocPrivate* d( const KateDocument* foo ) 546KateDocPrivate* d( const KateDocument* foo )
546 { 547 {
547 if ( !d_ptr ) { 548 if ( !d_ptr ) {
548 d_ptr = new QPtrDict<KateDocPrivate>; 549 d_ptr = new QPtrDict<KateDocPrivate>;
549 //qAddPostRoutine( cleanup_d_ptr ); 550 //qAddPostRoutine( cleanup_d_ptr );
550 } 551 }
551 KateDocPrivate* ret = d_ptr->find( (void*) foo ); 552 KateDocPrivate* ret = d_ptr->find( (void*) foo );
552 if ( ! ret ) { 553 if ( ! ret ) {
553 ret = new KateDocPrivate; 554 ret = new KateDocPrivate;
554 d_ptr->replace( (void*) foo, ret ); 555 d_ptr->replace( (void*) foo, ret );
555 } 556 }
556 return ret; 557 return ret;
557 } 558 }
558 559
559void delete_d( const KateDocument* foo ) 560void delete_d( const KateDocument* foo )
560 { 561 {
561 if ( d_ptr ) 562 if ( d_ptr )
562 d_ptr->remove( (void*) foo ); 563 d_ptr->remove( (void*) foo );
563 } 564 }
564 565
565}; 566};
566 567
567#endif 568#endif
568 569
569 570