summaryrefslogtreecommitdiff
Unidiff
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
@@ -1833,1025 +1833,1026 @@ void KateView::redoMultiple(int count) {
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