-rw-r--r-- | noncore/apps/tinykate/libkate/document/katedocument.cpp | 10 | ||||
-rw-r--r-- | noncore/apps/tinykate/libkate/document/katedocument.h | 11 |
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 | |||
@@ -283,96 +283,97 @@ KateDocument::~KateDocument() | |||
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 | ||
293 | void KateDocument::openURL(const QString &filename) | 293 | void 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 | ||
329 | bool KateDocument::saveFile() | 329 | bool 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 | ||
370 | KTextEditor::View *KateDocument::createView( QWidget *parent, const char *name ) | 371 | KTextEditor::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 | ||
375 | QString KateDocument::textLine( int line ) const | 376 | QString 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 ) |
@@ -1880,97 +1881,98 @@ void KateDocument::delMarkedText(VConfig &c/*, bool undo*/) { | |||
1880 | } | 1881 | } |
1881 | 1882 | ||
1882 | void KateDocument::tagLineRange(int line, int x1, int x2) { | 1883 | void 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 | ||
1890 | void KateDocument::tagLines(int start, int end) { | 1891 | void 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 | ||
1898 | void KateDocument::tagAll() { | 1899 | void 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 | ||
1906 | void KateDocument::updateLines(int startLine, int endLine, int flags, int cursorY) { | 1907 | void 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 | ||
1938 | void KateDocument::updateMaxLength(TextLine::Ptr &textLine) { | 1940 | void 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 | ||
1963 | void KateDocument::slotBufferChanged() { | 1965 | void KateDocument::slotBufferChanged() { |
1964 | newDocGeometry = true; | 1966 | newDocGeometry = true; |
1965 | //updateLines();//JW | 1967 | //updateLines();//JW |
1966 | updateViews(); | 1968 | updateViews(); |
1967 | } | 1969 | } |
1968 | 1970 | ||
1969 | void KateDocument::slotBufferHighlight(long start,long stop) { | 1971 | void 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 | ||
1975 | void KateDocument::updateViews(KateView *exclude) { | 1977 | void KateDocument::updateViews(KateView *exclude) { |
1976 | KateView *view; | 1978 | KateView *view; |
@@ -2985,96 +2987,102 @@ void KateDocument::newBracketMark(PointStruc &cursor, BracketMark &bm) | |||
2985 | } | 2987 | } |
2986 | } | 2988 | } |
2987 | return; | 2989 | return; |
2988 | 2990 | ||
2989 | found: | 2991 | found: |
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 | ||
3007 | void KateDocument::clipboardChanged() { //slot | 3009 | void 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 |
3019 | void KateDocument::guiActivateEvent( KParts::GUIActivateEvent *ev ) | 3021 | void 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 | ||
3027 | void KateDocument::setDocName (QString docName) | 3029 | void KateDocument::setDocName (QString docName) |
3028 | { | 3030 | { |
3029 | myDocName = docName; | 3031 | myDocName = docName; |
3030 | emit nameChanged (this); | 3032 | emit nameChanged (this); |
3031 | } | 3033 | } |
3032 | 3034 | ||
3035 | void KateDocument::setDocFile (QString docFile) | ||
3036 | { | ||
3037 | m_file = docFile; | ||
3038 | emit fileNameChanged (); | ||
3039 | } | ||
3040 | |||
3033 | void KateDocument::setMTime() | 3041 | void 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 | ||
3041 | void KateDocument::isModOnHD(bool forceReload) | 3049 | void 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 | ||
3059 | void KateDocument::reloadFile() | 3067 | void 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 | ||
3070 | void KateDocument::slotModChanged() | 3078 | void KateDocument::slotModChanged() |
3071 | { | 3079 | { |
3072 | emit modStateChanged (this); | 3080 | emit modStateChanged (this); |
3073 | } | 3081 | } |
3074 | 3082 | ||
3075 | QList<Kate::Mark> KateDocument::marks () | 3083 | QList<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++) |
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 | |||
@@ -409,161 +409,162 @@ class KateDocument: public Kate::Document | |||
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 |
539 | static QPtrDict<KateDocPrivate>* d_ptr; | 540 | static QPtrDict<KateDocPrivate>* d_ptr; |
540 | static void cleanup_d_ptr() | 541 | static void cleanup_d_ptr() |
541 | { | 542 | { |
542 | delete d_ptr; | 543 | delete d_ptr; |
543 | } | 544 | } |
544 | 545 | ||
545 | KateDocPrivate* d( const KateDocument* foo ) | 546 | KateDocPrivate* 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 | ||
559 | void delete_d( const KateDocument* foo ) | 560 | void 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 | ||