author | llornkcor <llornkcor> | 2002-12-22 17:43:32 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-12-22 17:43:32 (UTC) |
commit | c82ed38520b4038678ab0ab0c9f0ba147d8791ea (patch) (unidiff) | |
tree | 8c89a248f9471e004c48029edf29b63ece14f7e4 | |
parent | a907eb4d3c6ca142dcab7889d8932ccb452bf07c (diff) | |
download | opie-c82ed38520b4038678ab0ab0c9f0ba147d8791ea.zip opie-c82ed38520b4038678ab0ab0c9f0ba147d8791ea.tar.gz opie-c82ed38520b4038678ab0ab0c9f0ba147d8791ea.tar.bz2 |
show config dialog maximized
-rw-r--r-- | noncore/apps/tinykate/libkate/view/kateview.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/noncore/apps/tinykate/libkate/view/kateview.cpp b/noncore/apps/tinykate/libkate/view/kateview.cpp index 8f3a25e..6453458 100644 --- a/noncore/apps/tinykate/libkate/view/kateview.cpp +++ b/noncore/apps/tinykate/libkate/view/kateview.cpp | |||
@@ -1,104 +1,104 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | kateview.cpp - description | 2 | kateview.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Mon Jan 15 2001 | 4 | begin : Mon Jan 15 2001 |
5 | copyright : (C) 2001 by Christoph "Crossfire" Cullmann | 5 | copyright : (C) 2001 by Christoph "Crossfire" Cullmann |
6 | (C) 2002 by Joseph Wenninger | 6 | (C) 2002 by Joseph Wenninger |
7 | email : crossfire@babylon2k.de | 7 | email : crossfire@babylon2k.de |
8 | jowenn@kde.org | 8 | jowenn@kde.org |
9 | ***************************************************************************/ | 9 | ***************************************************************************/ |
10 | 10 | ||
11 | /*************************************************************************** | 11 | /*************************************************************************** |
12 | * * | 12 | * * |
13 | * This program is free software; you can redistribute it and/or modify * | 13 | * This program is free software; you can redistribute it and/or modify * |
14 | * it under the terms of the GNU General Public License as published by * | 14 | * it under the terms of the GNU General Public License as published by * |
15 | * the Free Software Foundation; either version 2 of the License, or * | 15 | * the Free Software Foundation; either version 2 of the License, or * |
16 | * (at your option) any later version. * | 16 | * (at your option) any later version. * |
17 | * * | 17 | * * |
18 | ***************************************************************************/ | 18 | ***************************************************************************/ |
19 | 19 | ||
20 | /* | 20 | /* |
21 | Copyright (C) 1998, 1999 Jochen Wilhelmy | 21 | Copyright (C) 1998, 1999 Jochen Wilhelmy |
22 | digisnap@cs.tu-berlin.de | 22 | digisnap@cs.tu-berlin.de |
23 | 23 | ||
24 | This library is free software; you can redistribute it and/or | 24 | This library is free software; you can redistribute it and/or |
25 | modify it under the terms of the GNU Library General Public | 25 | modify it under the terms of the GNU Library General Public |
26 | License as published by the Free Software Foundation; either | 26 | License as published by the Free Software Foundation; either |
27 | version 2 of the License, or (at your option) any later version. | 27 | version 2 of the License, or (at your option) any later version. |
28 | 28 | ||
29 | This library is distributed in the hope that it will be useful, | 29 | This library is distributed in the hope that it will be useful, |
30 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 30 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
31 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 31 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
32 | Library General Public License for more details. | 32 | Library General Public License for more details. |
33 | 33 | ||
34 | You should have received a copy of the GNU Library General Public License | 34 | You should have received a copy of the GNU Library General Public License |
35 | along with this library; see the file COPYING.LIB. If not, write to | 35 | along with this library; see the file COPYING.LIB. If not, write to |
36 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 36 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
37 | Boston, MA 02111-1307, USA. | 37 | Boston, MA 02111-1307, USA. |
38 | */ | 38 | */ |
39 | 39 | ||
40 | 40 | ||
41 | 41 | ||
42 | #include "kateview.h" | 42 | #include "kateview.h" |
43 | 43 | ||
44 | #include "../document/katedocument.h" | 44 | #include "../document/katedocument.h" |
45 | #include "../document/katecmd.h" | 45 | #include "../document/katecmd.h" |
46 | #include "../document/katehighlight.h" | 46 | #include "../document/katehighlight.h" |
47 | #include "kateviewdialog.h" | 47 | #include "kateviewdialog.h" |
48 | #include "../document/katedialogs.h" | 48 | #include "../document/katedialogs.h" |
49 | 49 | ||
50 | #include <qfocusdata.h> | 50 | #include <qfocusdata.h> |
51 | #include <kdebug.h> | 51 | #include <kdebug.h> |
52 | #include <kapplication.h> | 52 | #include <kapplication.h> |
53 | #include <qscrollbar.h> | 53 | #include <qscrollbar.h> |
54 | #include <qiodevice.h> | 54 | #include <qiodevice.h> |
55 | #include <qpopupmenu.h> | 55 | #include <qpopupmenu.h> |
56 | #include <kpopupmenu.h> | 56 | #include <kpopupmenu.h> |
57 | #include <qkeycode.h> | 57 | #include <qkeycode.h> |
58 | #include <qintdict.h> | 58 | #include <qintdict.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | #include <qfont.h> | 60 | #include <qfont.h> |
61 | #include <qpainter.h> | 61 | #include <qpainter.h> |
62 | #include <qpixmap.h> | 62 | #include <qpixmap.h> |
63 | #include <qfileinfo.h> | 63 | #include <qfileinfo.h> |
64 | #include <qfile.h> | 64 | #include <qfile.h> |
65 | #include <qevent.h> | 65 | #include <qevent.h> |
66 | #include <qdir.h> | 66 | #include <qdir.h> |
67 | #include <qvbox.h> | 67 | #include <qvbox.h> |
68 | #include <qprintdialog.h> | 68 | #include <qprintdialog.h> |
69 | #include <qpaintdevicemetrics.h> | 69 | #include <qpaintdevicemetrics.h> |
70 | #include <qiodevice.h> | 70 | #include <qiodevice.h> |
71 | #include <qbuffer.h> | 71 | #include <qbuffer.h> |
72 | #include <qfocusdata.h> | 72 | #include <qfocusdata.h> |
73 | #include <klocale.h> | 73 | #include <klocale.h> |
74 | #include <kglobal.h> | 74 | #include <kglobal.h> |
75 | #include <kdebug.h> | 75 | #include <kdebug.h> |
76 | #include <kmessagebox.h> | 76 | #include <kmessagebox.h> |
77 | #include <qregexp.h> | 77 | #include <qregexp.h> |
78 | #include <kdialogbase.h> | 78 | #include <kdialogbase.h> |
79 | #include <klineeditdlg.h> | 79 | #include <klineeditdlg.h> |
80 | #include <qapplication.h> | 80 | #include <qapplication.h> |
81 | #include <kfiledialog.h> | 81 | #include <kfiledialog.h> |
82 | #include <kiconloader.h> | 82 | #include <kiconloader.h> |
83 | #include "../document/katetextline.h" | 83 | #include "../document/katetextline.h" |
84 | #include "kateviewdialog.h" | 84 | #include "kateviewdialog.h" |
85 | #include "kateundohistory.h" | 85 | #include "kateundohistory.h" |
86 | #include <qlayout.h> | 86 | #include <qlayout.h> |
87 | 87 | ||
88 | KateViewInternal::KateViewInternal(KateView *view, KateDocument *doc) : QWidget(view) | 88 | KateViewInternal::KateViewInternal(KateView *view, KateDocument *doc) : QWidget(view) |
89 | { | 89 | { |
90 | waitForPreHighlight=-1; | 90 | waitForPreHighlight=-1; |
91 | myView = view; | 91 | myView = view; |
92 | myDoc = doc; | 92 | myDoc = doc; |
93 | 93 | ||
94 | iconBorderWidth = 16; | 94 | iconBorderWidth = 16; |
95 | iconBorderHeight = 800; | 95 | iconBorderHeight = 800; |
96 | 96 | ||
97 | QWidget::setCursor(ibeamCursor); | 97 | QWidget::setCursor(ibeamCursor); |
98 | setBackgroundMode(NoBackground); | 98 | setBackgroundMode(NoBackground); |
99 | 99 | ||
100 | setFocusPolicy(StrongFocus); | 100 | setFocusPolicy(StrongFocus); |
101 | 101 | ||
102 | xScroll = new QScrollBar(QScrollBar::Horizontal,myView); | 102 | xScroll = new QScrollBar(QScrollBar::Horizontal,myView); |
103 | yScroll = new QScrollBar(QScrollBar::Vertical,myView); | 103 | yScroll = new QScrollBar(QScrollBar::Vertical,myView); |
104 | connect(xScroll,SIGNAL(valueChanged(int)),SLOT(changeXPos(int))); | 104 | connect(xScroll,SIGNAL(valueChanged(int)),SLOT(changeXPos(int))); |
@@ -1680,193 +1680,193 @@ const char * KateView::undoTypeName(int type) { | |||
1680 | QColor* KateView::getColors() | 1680 | QColor* KateView::getColors() |
1681 | { | 1681 | { |
1682 | return myDoc->colors; | 1682 | return myDoc->colors; |
1683 | } | 1683 | } |
1684 | 1684 | ||
1685 | void KateView::applyColors() | 1685 | void KateView::applyColors() |
1686 | { | 1686 | { |
1687 | myDoc->tagAll(); | 1687 | myDoc->tagAll(); |
1688 | myDoc->updateViews(); | 1688 | myDoc->updateViews(); |
1689 | } | 1689 | } |
1690 | 1690 | ||
1691 | bool KateView::isOverwriteMode() const | 1691 | bool KateView::isOverwriteMode() const |
1692 | { | 1692 | { |
1693 | return ( configFlags & KateView::cfOvr ); | 1693 | return ( configFlags & KateView::cfOvr ); |
1694 | } | 1694 | } |
1695 | 1695 | ||
1696 | void KateView::setOverwriteMode( bool b ) | 1696 | void KateView::setOverwriteMode( bool b ) |
1697 | { | 1697 | { |
1698 | if ( isOverwriteMode() && !b ) | 1698 | if ( isOverwriteMode() && !b ) |
1699 | setConfig( configFlags ^ KateView::cfOvr ); | 1699 | setConfig( configFlags ^ KateView::cfOvr ); |
1700 | else | 1700 | else |
1701 | setConfig( configFlags | KateView::cfOvr ); | 1701 | setConfig( configFlags | KateView::cfOvr ); |
1702 | } | 1702 | } |
1703 | 1703 | ||
1704 | void KateView::toggleInsert() { | 1704 | void KateView::toggleInsert() { |
1705 | setConfig(configFlags ^ KateView::cfOvr); | 1705 | setConfig(configFlags ^ KateView::cfOvr); |
1706 | } | 1706 | } |
1707 | 1707 | ||
1708 | void KateView::toggleVertical() | 1708 | void KateView::toggleVertical() |
1709 | { | 1709 | { |
1710 | setConfig(configFlags ^ KateView::cfVerticalSelect); | 1710 | setConfig(configFlags ^ KateView::cfVerticalSelect); |
1711 | } | 1711 | } |
1712 | 1712 | ||
1713 | 1713 | ||
1714 | int KateView::numLines() { | 1714 | int KateView::numLines() { |
1715 | return myDoc->numLines(); | 1715 | return myDoc->numLines(); |
1716 | } | 1716 | } |
1717 | 1717 | ||
1718 | QString KateView::text() { | 1718 | QString KateView::text() { |
1719 | return myDoc->text(); | 1719 | return myDoc->text(); |
1720 | } | 1720 | } |
1721 | 1721 | ||
1722 | QString KateView::currentTextLine() { | 1722 | QString KateView::currentTextLine() { |
1723 | TextLine::Ptr textLine = myDoc->getTextLine(myViewInternal->cursor.y); | 1723 | TextLine::Ptr textLine = myDoc->getTextLine(myViewInternal->cursor.y); |
1724 | return QString(textLine->getText(), textLine->length()); | 1724 | return QString(textLine->getText(), textLine->length()); |
1725 | } | 1725 | } |
1726 | 1726 | ||
1727 | QString KateView::textLine(int num) { | 1727 | QString KateView::textLine(int num) { |
1728 | TextLine::Ptr textLine = myDoc->getTextLine(num); | 1728 | TextLine::Ptr textLine = myDoc->getTextLine(num); |
1729 | return QString(textLine->getText(), textLine->length()); | 1729 | return QString(textLine->getText(), textLine->length()); |
1730 | } | 1730 | } |
1731 | 1731 | ||
1732 | QString KateView::currentWord() { | 1732 | QString KateView::currentWord() { |
1733 | return myDoc->getWord(myViewInternal->cursor); | 1733 | return myDoc->getWord(myViewInternal->cursor); |
1734 | } | 1734 | } |
1735 | 1735 | ||
1736 | QString KateView::word(int x, int y) { | 1736 | QString KateView::word(int x, int y) { |
1737 | PointStruc cursor; | 1737 | PointStruc cursor; |
1738 | cursor.y = (myViewInternal->yPos + y)/myDoc->fontHeight; | 1738 | cursor.y = (myViewInternal->yPos + y)/myDoc->fontHeight; |
1739 | if (cursor.y < 0 || cursor.y > myDoc->lastLine()) return QString(); | 1739 | if (cursor.y < 0 || cursor.y > myDoc->lastLine()) return QString(); |
1740 | cursor.x = myDoc->textPos(myDoc->getTextLine(cursor.y), myViewInternal->xPos-2 + x); | 1740 | cursor.x = myDoc->textPos(myDoc->getTextLine(cursor.y), myViewInternal->xPos-2 + x); |
1741 | return myDoc->getWord(cursor); | 1741 | return myDoc->getWord(cursor); |
1742 | } | 1742 | } |
1743 | 1743 | ||
1744 | void KateView::setText(const QString &s) { | 1744 | void KateView::setText(const QString &s) { |
1745 | myDoc->setText(s); | 1745 | myDoc->setText(s); |
1746 | myDoc->updateViews(); | 1746 | myDoc->updateViews(); |
1747 | } | 1747 | } |
1748 | 1748 | ||
1749 | void KateView::insertText(const QString &s, bool /*mark*/) { | 1749 | void KateView::insertText(const QString &s, bool /*mark*/) { |
1750 | VConfig c; | 1750 | VConfig c; |
1751 | myViewInternal->getVConfig(c); | 1751 | myViewInternal->getVConfig(c); |
1752 | myDoc->insert(c, s); | 1752 | myDoc->insert(c, s); |
1753 | myDoc->updateViews(); | 1753 | myDoc->updateViews(); |
1754 | } | 1754 | } |
1755 | 1755 | ||
1756 | bool KateView::hasMarkedText() { | 1756 | bool KateView::hasMarkedText() { |
1757 | return myDoc->hasMarkedText(); | 1757 | return myDoc->hasMarkedText(); |
1758 | } | 1758 | } |
1759 | 1759 | ||
1760 | QString KateView::markedText() { | 1760 | QString KateView::markedText() { |
1761 | return myDoc->markedText(configFlags); | 1761 | return myDoc->markedText(configFlags); |
1762 | } | 1762 | } |
1763 | 1763 | ||
1764 | bool KateView::canDiscard() { | 1764 | bool KateView::canDiscard() { |
1765 | int query; | 1765 | int query; |
1766 | 1766 | ||
1767 | if (isModified()) { | 1767 | if (isModified()) { |
1768 | query = KMessageBox::warningYesNoCancel(this, | 1768 | query = KMessageBox::warningYesNoCancel(this, |
1769 | i18n("The current Document has been modified.\nWould you like to save it?")); | 1769 | i18n("The current Document has been modified.\nWould you like to save it?")); |
1770 | switch (query) { | 1770 | switch (query) { |
1771 | case KMessageBox::Yes: //yes | 1771 | case KMessageBox::Yes: //yes |
1772 | if (save() == CANCEL) return false; | 1772 | if (save() == CANCEL) return false; |
1773 | if (isModified()) { | 1773 | if (isModified()) { |
1774 | query = KMessageBox::warningContinueCancel(this, | 1774 | query = KMessageBox::warningContinueCancel(this, |
1775 | i18n("Could not save the document.\nDiscard it and continue?"), | 1775 | i18n("Could not save the document.\nDiscard it and continue?"), |
1776 | QString::null, i18n("&Discard")); | 1776 | QString::null, i18n("&Discard")); |
1777 | if (query == KMessageBox::Cancel) return false; | 1777 | if (query == KMessageBox::Cancel) return false; |
1778 | } | 1778 | } |
1779 | break; | 1779 | break; |
1780 | case KMessageBox::Cancel: //cancel | 1780 | case KMessageBox::Cancel: //cancel |
1781 | return false; | 1781 | return false; |
1782 | } | 1782 | } |
1783 | } | 1783 | } |
1784 | return true; | 1784 | return true; |
1785 | } | 1785 | } |
1786 | 1786 | ||
1787 | void KateView::flush() | 1787 | void KateView::flush() |
1788 | { | 1788 | { |
1789 | if (canDiscard()) myDoc->flush(); | 1789 | if (canDiscard()) myDoc->flush(); |
1790 | } | 1790 | } |
1791 | 1791 | ||
1792 | KateView::fileResult KateView::save() { | 1792 | KateView::fileResult KateView::save() { |
1793 | int query = KMessageBox::Yes; | 1793 | int query = KMessageBox::Yes; |
1794 | if (isModified()) { | 1794 | if (isModified()) { |
1795 | return saveAs(); | 1795 | return saveAs(); |
1796 | } | 1796 | } |
1797 | return OK; | 1797 | return OK; |
1798 | } | 1798 | } |
1799 | 1799 | ||
1800 | KateView::fileResult KateView::saveAs() { | 1800 | KateView::fileResult KateView::saveAs() { |
1801 | return OK; | 1801 | return OK; |
1802 | } | 1802 | } |
1803 | 1803 | ||
1804 | void KateView::doCursorCommand(int cmdNum) { | 1804 | void KateView::doCursorCommand(int cmdNum) { |
1805 | VConfig c; | 1805 | VConfig c; |
1806 | myViewInternal->getVConfig(c); | 1806 | myViewInternal->getVConfig(c); |
1807 | if (cmdNum & selectFlag) c.flags |= KateView::cfMark; | 1807 | if (cmdNum & selectFlag) c.flags |= KateView::cfMark; |
1808 | if (cmdNum & multiSelectFlag) c.flags |= KateView::cfMark | KateView::cfKeepSelection; | 1808 | if (cmdNum & multiSelectFlag) c.flags |= KateView::cfMark | KateView::cfKeepSelection; |
1809 | cmdNum &= ~(selectFlag | multiSelectFlag); | 1809 | cmdNum &= ~(selectFlag | multiSelectFlag); |
1810 | myViewInternal->doCursorCommand(c, cmdNum); | 1810 | myViewInternal->doCursorCommand(c, cmdNum); |
1811 | myDoc->updateViews(); | 1811 | myDoc->updateViews(); |
1812 | } | 1812 | } |
1813 | 1813 | ||
1814 | void KateView::doEditCommand(int cmdNum) { | 1814 | void KateView::doEditCommand(int cmdNum) { |
1815 | VConfig c; | 1815 | VConfig c; |
1816 | myViewInternal->getVConfig(c); | 1816 | myViewInternal->getVConfig(c); |
1817 | myViewInternal->doEditCommand(c, cmdNum); | 1817 | myViewInternal->doEditCommand(c, cmdNum); |
1818 | myDoc->updateViews(); | 1818 | myDoc->updateViews(); |
1819 | } | 1819 | } |
1820 | 1820 | ||
1821 | void KateView::undoMultiple(int count) { | 1821 | void KateView::undoMultiple(int count) { |
1822 | if (isReadOnly()) | 1822 | if (isReadOnly()) |
1823 | return; | 1823 | return; |
1824 | 1824 | ||
1825 | VConfig c; | 1825 | VConfig c; |
1826 | myViewInternal->getVConfig(c); | 1826 | myViewInternal->getVConfig(c); |
1827 | myDoc->undo(c, count); | 1827 | myDoc->undo(c, count); |
1828 | myDoc->updateViews(); | 1828 | myDoc->updateViews(); |
1829 | } | 1829 | } |
1830 | 1830 | ||
1831 | void KateView::redoMultiple(int count) { | 1831 | void KateView::redoMultiple(int count) { |
1832 | if (isReadOnly()) | 1832 | if (isReadOnly()) |
1833 | return; | 1833 | return; |
1834 | 1834 | ||
1835 | VConfig c; | 1835 | VConfig c; |
1836 | myViewInternal->getVConfig(c); | 1836 | myViewInternal->getVConfig(c); |
1837 | myDoc->redo(c, count); | 1837 | myDoc->redo(c, count); |
1838 | myDoc->updateViews(); | 1838 | myDoc->updateViews(); |
1839 | } | 1839 | } |
1840 | 1840 | ||
1841 | void KateView::undoHistory() | 1841 | void KateView::undoHistory() |
1842 | { | 1842 | { |
1843 | UndoHistory *undoH; | 1843 | UndoHistory *undoH; |
1844 | 1844 | ||
1845 | undoH = new UndoHistory(this, this, "UndoHistory", true); | 1845 | undoH = new UndoHistory(this, this, "UndoHistory", true); |
1846 | 1846 | ||
1847 | undoH->setCaption(i18n("Undo/Redo History")); | 1847 | undoH->setCaption(i18n("Undo/Redo History")); |
1848 | 1848 | ||
1849 | connect(this,SIGNAL(newUndo()),undoH,SLOT(newUndo())); | 1849 | connect(this,SIGNAL(newUndo()),undoH,SLOT(newUndo())); |
1850 | connect(undoH,SIGNAL(undo(int)),this,SLOT(undoMultiple(int))); | 1850 | connect(undoH,SIGNAL(undo(int)),this,SLOT(undoMultiple(int))); |
1851 | connect(undoH,SIGNAL(redo(int)),this,SLOT(redoMultiple(int))); | 1851 | connect(undoH,SIGNAL(redo(int)),this,SLOT(redoMultiple(int))); |
1852 | 1852 | ||
1853 | undoH->exec(); | 1853 | undoH->exec(); |
1854 | 1854 | ||
1855 | delete undoH; | 1855 | delete undoH; |
1856 | } | 1856 | } |
1857 | 1857 | ||
1858 | static void kwview_addToStrList(QStringList &list, const QString &str) { | 1858 | static void kwview_addToStrList(QStringList &list, const QString &str) { |
1859 | if (list.count() > 0) { | 1859 | if (list.count() > 0) { |
1860 | if (list.first() == str) return; | 1860 | if (list.first() == str) return; |
1861 | QStringList::Iterator it; | 1861 | QStringList::Iterator it; |
1862 | it = list.find(str); | 1862 | it = list.find(str); |
1863 | if (*it != 0L) list.remove(it); | 1863 | if (*it != 0L) list.remove(it); |
1864 | if (list.count() >= 16) list.remove(list.fromLast()); | 1864 | if (list.count() >= 16) list.remove(list.fromLast()); |
1865 | } | 1865 | } |
1866 | list.prepend(str); | 1866 | list.prepend(str); |
1867 | } | 1867 | } |
1868 | 1868 | ||
1869 | void KateView::find() { | 1869 | void KateView::find() { |
1870 | SearchDialog *searchDialog; | 1870 | SearchDialog *searchDialog; |
1871 | 1871 | ||
1872 | if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected; | 1872 | if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected; |
@@ -2104,323 +2104,323 @@ void KateView::doReplaceAction(int result, bool found) { | |||
2104 | found = false; | 2104 | found = false; |
2105 | myDoc->recordStart(this, s.cursor, configFlags, | 2105 | myDoc->recordStart(this, s.cursor, configFlags, |
2106 | KateActionGroup::ugReplace); | 2106 | KateActionGroup::ugReplace); |
2107 | started = true; | 2107 | started = true; |
2108 | } | 2108 | } |
2109 | myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith); | 2109 | myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith); |
2110 | replaces++; | 2110 | replaces++; |
2111 | if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x) | 2111 | if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x) |
2112 | s.startCursor.x += rlen - s.matchedLength; | 2112 | s.startCursor.x += rlen - s.matchedLength; |
2113 | if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen; | 2113 | if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen; |
2114 | } | 2114 | } |
2115 | if (started) myDoc->recordEnd(this, s.cursor, | 2115 | if (started) myDoc->recordEnd(this, s.cursor, |
2116 | configFlags | KateView::cfPersistent); | 2116 | configFlags | KateView::cfPersistent); |
2117 | } while (!askReplaceEnd()); | 2117 | } while (!askReplaceEnd()); |
2118 | return; | 2118 | return; |
2119 | case KateView::srCancel: //cancel | 2119 | case KateView::srCancel: //cancel |
2120 | deleteReplacePrompt(); | 2120 | deleteReplacePrompt(); |
2121 | return; | 2121 | return; |
2122 | default: | 2122 | default: |
2123 | replacePrompt = 0L; | 2123 | replacePrompt = 0L; |
2124 | } | 2124 | } |
2125 | 2125 | ||
2126 | do { | 2126 | do { |
2127 | if (myDoc->doSearch(s,searchFor)) { | 2127 | if (myDoc->doSearch(s,searchFor)) { |
2128 | //text found: highlight it, show replace prompt if needed and exit | 2128 | //text found: highlight it, show replace prompt if needed and exit |
2129 | cursor = s.cursor; | 2129 | cursor = s.cursor; |
2130 | if (!(s.flags & KateView::sfBackward)) cursor.x += s.matchedLength; | 2130 | if (!(s.flags & KateView::sfBackward)) cursor.x += s.matchedLength; |
2131 | myViewInternal->updateCursor(cursor); //does deselectAll() | 2131 | myViewInternal->updateCursor(cursor); //does deselectAll() |
2132 | exposeFound(s.cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,true); | 2132 | exposeFound(s.cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,true); |
2133 | if (replacePrompt == 0L) { | 2133 | if (replacePrompt == 0L) { |
2134 | replacePrompt = new ReplacePrompt(this); | 2134 | replacePrompt = new ReplacePrompt(this); |
2135 | myDoc->setPseudoModal(replacePrompt);//disable(); | 2135 | myDoc->setPseudoModal(replacePrompt);//disable(); |
2136 | connect(replacePrompt,SIGNAL(clicked()),this,SLOT(replaceSlot())); | 2136 | connect(replacePrompt,SIGNAL(clicked()),this,SLOT(replaceSlot())); |
2137 | replacePrompt->show(); //this is not modal | 2137 | replacePrompt->show(); //this is not modal |
2138 | } | 2138 | } |
2139 | return; //exit if text found | 2139 | return; //exit if text found |
2140 | } | 2140 | } |
2141 | //nothing found: repeat until user cancels "repeat from beginning" dialog | 2141 | //nothing found: repeat until user cancels "repeat from beginning" dialog |
2142 | } while (!askReplaceEnd()); | 2142 | } while (!askReplaceEnd()); |
2143 | deleteReplacePrompt(); | 2143 | deleteReplacePrompt(); |
2144 | } | 2144 | } |
2145 | 2145 | ||
2146 | void KateView::exposeFound(PointStruc &cursor, int slen, int flags, bool replace) { | 2146 | void KateView::exposeFound(PointStruc &cursor, int slen, int flags, bool replace) { |
2147 | int x1, x2, y1, y2, xPos, yPos; | 2147 | int x1, x2, y1, y2, xPos, yPos; |
2148 | 2148 | ||
2149 | VConfig c; | 2149 | VConfig c; |
2150 | myViewInternal->getVConfig(c); | 2150 | myViewInternal->getVConfig(c); |
2151 | myDoc->selectLength(cursor,slen,c.flags); | 2151 | myDoc->selectLength(cursor,slen,c.flags); |
2152 | 2152 | ||
2153 | TextLine::Ptr textLine = myDoc->getTextLine(cursor.y); | 2153 | TextLine::Ptr textLine = myDoc->getTextLine(cursor.y); |
2154 | x1 = myDoc->textWidth(textLine,cursor.x) -10; | 2154 | x1 = myDoc->textWidth(textLine,cursor.x) -10; |
2155 | x2 = myDoc->textWidth(textLine,cursor.x + slen) +20; | 2155 | x2 = myDoc->textWidth(textLine,cursor.x + slen) +20; |
2156 | y1 = myDoc->fontHeight*cursor.y -10; | 2156 | y1 = myDoc->fontHeight*cursor.y -10; |
2157 | y2 = y1 + myDoc->fontHeight +30; | 2157 | y2 = y1 + myDoc->fontHeight +30; |
2158 | 2158 | ||
2159 | xPos = myViewInternal->xPos; | 2159 | xPos = myViewInternal->xPos; |
2160 | yPos = myViewInternal->yPos; | 2160 | yPos = myViewInternal->yPos; |
2161 | 2161 | ||
2162 | if (x1 < 0) x1 = 0; | 2162 | if (x1 < 0) x1 = 0; |
2163 | if (replace) y2 += 90; | 2163 | if (replace) y2 += 90; |
2164 | 2164 | ||
2165 | if (x1 < xPos || x2 > xPos + myViewInternal->width()) { | 2165 | if (x1 < xPos || x2 > xPos + myViewInternal->width()) { |
2166 | xPos = x2 - myViewInternal->width(); | 2166 | xPos = x2 - myViewInternal->width(); |
2167 | } | 2167 | } |
2168 | if (y1 < yPos || y2 > yPos + myViewInternal->height()) { | 2168 | if (y1 < yPos || y2 > yPos + myViewInternal->height()) { |
2169 | xPos = x2 - myViewInternal->width(); | 2169 | xPos = x2 - myViewInternal->width(); |
2170 | yPos = myDoc->fontHeight*cursor.y - height()/3; | 2170 | yPos = myDoc->fontHeight*cursor.y - height()/3; |
2171 | } | 2171 | } |
2172 | myViewInternal->setPos(xPos, yPos); | 2172 | myViewInternal->setPos(xPos, yPos); |
2173 | myViewInternal->updateView(flags);// | ufPos,xPos,yPos); | 2173 | myViewInternal->updateView(flags);// | ufPos,xPos,yPos); |
2174 | myDoc->updateViews(this); | 2174 | myDoc->updateViews(this); |
2175 | } | 2175 | } |
2176 | 2176 | ||
2177 | void KateView::deleteReplacePrompt() { | 2177 | void KateView::deleteReplacePrompt() { |
2178 | myDoc->setPseudoModal(0L); | 2178 | myDoc->setPseudoModal(0L); |
2179 | } | 2179 | } |
2180 | 2180 | ||
2181 | bool KateView::askReplaceEnd() { | 2181 | bool KateView::askReplaceEnd() { |
2182 | QString str; | 2182 | QString str; |
2183 | int query; | 2183 | int query; |
2184 | 2184 | ||
2185 | myDoc->updateViews(); | 2185 | myDoc->updateViews(); |
2186 | if (s.flags & KateView::sfFinished) { | 2186 | if (s.flags & KateView::sfFinished) { |
2187 | // replace finished | 2187 | // replace finished |
2188 | str = i18n("%1 replacement(s) made").arg(replaces); | 2188 | str = i18n("%1 replacement(s) made").arg(replaces); |
2189 | KMessageBox::information(this, str, i18n("Replace")); | 2189 | KMessageBox::information(this, str, i18n("Replace")); |
2190 | return true; | 2190 | return true; |
2191 | } | 2191 | } |
2192 | 2192 | ||
2193 | // ask for continue | 2193 | // ask for continue |
2194 | if (!(s.flags & KateView::sfBackward)) { | 2194 | if (!(s.flags & KateView::sfBackward)) { |
2195 | // forward search | 2195 | // forward search |
2196 | str = i18n("%1 replacement(s) made.\n" | 2196 | str = i18n("%1 replacement(s) made.\n" |
2197 | "End of document reached.\n" | 2197 | "End of document reached.\n" |
2198 | "Continue from the beginning?").arg(replaces); | 2198 | "Continue from the beginning?").arg(replaces); |
2199 | query = KMessageBox::questionYesNo(this, str, i18n("Replace"), | 2199 | query = KMessageBox::questionYesNo(this, str, i18n("Replace"), |
2200 | i18n("Continue"), i18n("Stop")); | 2200 | i18n("Continue"), i18n("Stop")); |
2201 | } else { | 2201 | } else { |
2202 | // backward search | 2202 | // backward search |
2203 | str = i18n("%1 replacement(s) made.\n" | 2203 | str = i18n("%1 replacement(s) made.\n" |
2204 | "Beginning of document reached.\n" | 2204 | "Beginning of document reached.\n" |
2205 | "Continue from the end?").arg(replaces); | 2205 | "Continue from the end?").arg(replaces); |
2206 | query = KMessageBox::questionYesNo(this, str, i18n("Replace"), | 2206 | query = KMessageBox::questionYesNo(this, str, i18n("Replace"), |
2207 | i18n("Continue"), i18n("Stop")); | 2207 | i18n("Continue"), i18n("Stop")); |
2208 | } | 2208 | } |
2209 | replaces = 0; | 2209 | replaces = 0; |
2210 | continueSearch(s); | 2210 | continueSearch(s); |
2211 | return (query == KMessageBox::No); | 2211 | return (query == KMessageBox::No); |
2212 | } | 2212 | } |
2213 | 2213 | ||
2214 | void KateView::replaceSlot() { | 2214 | void KateView::replaceSlot() { |
2215 | doReplaceAction(replacePrompt->result(),true); | 2215 | doReplaceAction(replacePrompt->result(),true); |
2216 | } | 2216 | } |
2217 | 2217 | ||
2218 | void KateView::installPopup(QPopupMenu *rmb_Menu) | 2218 | void KateView::installPopup(QPopupMenu *rmb_Menu) |
2219 | { | 2219 | { |
2220 | rmbMenu = rmb_Menu; | 2220 | rmbMenu = rmb_Menu; |
2221 | } | 2221 | } |
2222 | 2222 | ||
2223 | void KateView::readConfig() | 2223 | void KateView::readConfig() |
2224 | { | 2224 | { |
2225 | KConfig *config = KGlobal::config(); | 2225 | KConfig *config = KGlobal::config(); |
2226 | config->setGroup("Kate View"); | 2226 | config->setGroup("Kate View"); |
2227 | 2227 | ||
2228 | searchFlags = config->readNumEntry("SearchFlags", KateView::sfPrompt); | 2228 | searchFlags = config->readNumEntry("SearchFlags", KateView::sfPrompt); |
2229 | configFlags = config->readNumEntry("ConfigFlags", configFlags) & ~KateView::cfMark; | 2229 | configFlags = config->readNumEntry("ConfigFlags", configFlags) & ~KateView::cfMark; |
2230 | 2230 | ||
2231 | config->sync(); | 2231 | config->sync(); |
2232 | } | 2232 | } |
2233 | 2233 | ||
2234 | void KateView::writeConfig() | 2234 | void KateView::writeConfig() |
2235 | { | 2235 | { |
2236 | KConfig *config = KGlobal::config(); | 2236 | KConfig *config = KGlobal::config(); |
2237 | config->setGroup("Kate View"); | 2237 | config->setGroup("Kate View"); |
2238 | 2238 | ||
2239 | config->writeEntry("SearchFlags",searchFlags); | 2239 | config->writeEntry("SearchFlags",searchFlags); |
2240 | config->writeEntry("ConfigFlags",configFlags); | 2240 | config->writeEntry("ConfigFlags",configFlags); |
2241 | 2241 | ||
2242 | config->sync(); | 2242 | config->sync(); |
2243 | } | 2243 | } |
2244 | 2244 | ||
2245 | void KateView::readSessionConfig(KConfig *config) | 2245 | void KateView::readSessionConfig(KConfig *config) |
2246 | { | 2246 | { |
2247 | PointStruc cursor; | 2247 | PointStruc cursor; |
2248 | 2248 | ||
2249 | myViewInternal->xPos = config->readNumEntry("XPos"); | 2249 | myViewInternal->xPos = config->readNumEntry("XPos"); |
2250 | myViewInternal->yPos = config->readNumEntry("YPos"); | 2250 | myViewInternal->yPos = config->readNumEntry("YPos"); |
2251 | cursor.x = config->readNumEntry("CursorX"); | 2251 | cursor.x = config->readNumEntry("CursorX"); |
2252 | cursor.y = config->readNumEntry("CursorY"); | 2252 | cursor.y = config->readNumEntry("CursorY"); |
2253 | myViewInternal->updateCursor(cursor); | 2253 | myViewInternal->updateCursor(cursor); |
2254 | myIconBorder = config->readBoolEntry("IconBorder on"); | 2254 | myIconBorder = config->readBoolEntry("IconBorder on"); |
2255 | setIconBorder(myIconBorder); | 2255 | setIconBorder(myIconBorder); |
2256 | } | 2256 | } |
2257 | 2257 | ||
2258 | void KateView::writeSessionConfig(KConfig *config) | 2258 | void KateView::writeSessionConfig(KConfig *config) |
2259 | { | 2259 | { |
2260 | config->writeEntry("XPos",myViewInternal->xPos); | 2260 | config->writeEntry("XPos",myViewInternal->xPos); |
2261 | config->writeEntry("YPos",myViewInternal->yPos); | 2261 | config->writeEntry("YPos",myViewInternal->yPos); |
2262 | config->writeEntry("CursorX",myViewInternal->cursor.x); | 2262 | config->writeEntry("CursorX",myViewInternal->cursor.x); |
2263 | config->writeEntry("CursorY",myViewInternal->cursor.y); | 2263 | config->writeEntry("CursorY",myViewInternal->cursor.y); |
2264 | config->writeEntry("IconBorder on", myIconBorder); | 2264 | config->writeEntry("IconBorder on", myIconBorder); |
2265 | } | 2265 | } |
2266 | 2266 | ||
2267 | void KateView::configDialog() | 2267 | void KateView::configDialog() |
2268 | { | 2268 | { |
2269 | 2269 | ||
2270 | #warning fixme | 2270 | #warning fixme |
2271 | 2271 | ||
2272 | #if 1 | 2272 | #if 1 |
2273 | KDialogBase *kd = new KDialogBase(KDialogBase::IconList, | 2273 | KDialogBase *kd = new KDialogBase(KDialogBase::IconList, |
2274 | i18n("Configure Editor"), | 2274 | i18n("Configure Editor"), |
2275 | KDialogBase::Ok | KDialogBase::Cancel | | 2275 | KDialogBase::Ok | KDialogBase::Cancel | |
2276 | KDialogBase::Help , | 2276 | KDialogBase::Help , |
2277 | KDialogBase::Ok, this, "tabdialog"); | 2277 | KDialogBase::Ok, this, "tabdialog"); |
2278 | 2278 | ||
2279 | // color options | 2279 | // color options |
2280 | QFrame *page=kd->addPage(i18n("Colors")); | 2280 | QFrame *page=kd->addPage(i18n("Colors")); |
2281 | (new QVBoxLayout(page))->setAutoAdd(true); | 2281 | (new QVBoxLayout(page))->setAutoAdd(true); |
2282 | ColorConfig *colorConfig = new ColorConfig(page); | 2282 | ColorConfig *colorConfig = new ColorConfig(page); |
2283 | QColor* colors = getColors(); | 2283 | QColor* colors = getColors(); |
2284 | colorConfig->setColors(colors); | 2284 | colorConfig->setColors(colors); |
2285 | 2285 | ||
2286 | page = kd->addPage(i18n("Fonts")); | 2286 | page = kd->addPage(i18n("Fonts")); |
2287 | (new QVBoxLayout(page))->setAutoAdd(true); | 2287 | (new QVBoxLayout(page))->setAutoAdd(true); |
2288 | 2288 | ||
2289 | FontConfig *fontConfig = new FontConfig(page); | 2289 | FontConfig *fontConfig = new FontConfig(page); |
2290 | fontConfig->setFont (myDoc->getFont()); | 2290 | fontConfig->setFont (myDoc->getFont()); |
2291 | 2291 | ||
2292 | // indent options | 2292 | // indent options |
2293 | page=kd->addPage(i18n("Indent")); | 2293 | page=kd->addPage(i18n("Indent")); |
2294 | (new QVBoxLayout(page))->setAutoAdd(true); | 2294 | (new QVBoxLayout(page))->setAutoAdd(true); |
2295 | 2295 | ||
2296 | IndentConfigTab *indentConfig = new IndentConfigTab(page, this); | 2296 | IndentConfigTab *indentConfig = new IndentConfigTab(page, this); |
2297 | 2297 | ||
2298 | // select options | 2298 | // select options |
2299 | page=kd->addPage(i18n("Select")); | 2299 | page=kd->addPage(i18n("Select")); |
2300 | (new QVBoxLayout(page))->setAutoAdd(true); | 2300 | (new QVBoxLayout(page))->setAutoAdd(true); |
2301 | 2301 | ||
2302 | SelectConfigTab *selectConfig = new SelectConfigTab(page, this); | 2302 | SelectConfigTab *selectConfig = new SelectConfigTab(page, this); |
2303 | 2303 | ||
2304 | // edit options | 2304 | // edit options |
2305 | page=kd->addPage(i18n("Edit")); | 2305 | page=kd->addPage(i18n("Edit")); |
2306 | (new QVBoxLayout(page))->setAutoAdd(true); | 2306 | (new QVBoxLayout(page))->setAutoAdd(true); |
2307 | 2307 | ||
2308 | EditConfigTab *editConfig = new EditConfigTab(page, this); | 2308 | EditConfigTab *editConfig = new EditConfigTab(page, this); |
2309 | 2309 | ||
2310 | 2310 | ||
2311 | 2311 | ||
2312 | HighlightDialogPage *hlPage; | 2312 | HighlightDialogPage *hlPage; |
2313 | HlManager *hlManager; | 2313 | HlManager *hlManager; |
2314 | HlDataList hlDataList; | 2314 | HlDataList hlDataList; |
2315 | ItemStyleList defaultStyleList; | 2315 | ItemStyleList defaultStyleList; |
2316 | 2316 | ||
2317 | hlManager = HlManager::self(); | 2317 | hlManager = HlManager::self(); |
2318 | 2318 | ||
2319 | defaultStyleList.setAutoDelete(true); | 2319 | defaultStyleList.setAutoDelete(true); |
2320 | hlManager->getDefaults(defaultStyleList); | 2320 | hlManager->getDefaults(defaultStyleList); |
2321 | 2321 | ||
2322 | hlDataList.setAutoDelete(true); | 2322 | hlDataList.setAutoDelete(true); |
2323 | //this gets the data from the KConfig object | 2323 | //this gets the data from the KConfig object |
2324 | hlManager->getHlDataList(hlDataList); | 2324 | hlManager->getHlDataList(hlDataList); |
2325 | 2325 | ||
2326 | page=kd->addPage(i18n("Highlighting")); | 2326 | page=kd->addPage(i18n("Highlighting")); |
2327 | (new QVBoxLayout(page))->setAutoAdd(true); | 2327 | (new QVBoxLayout(page))->setAutoAdd(true); |
2328 | 2328 | ||
2329 | hlPage = new HighlightDialogPage(hlManager, &defaultStyleList, &hlDataList, 0, page); | 2329 | hlPage = new HighlightDialogPage(hlManager, &defaultStyleList, &hlDataList, 0, page); |
2330 | 2330 | kd->showMaximized(); | |
2331 | if (kd->exec()) { | 2331 | if (kd->exec()) { |
2332 | // color options | 2332 | // color options |
2333 | colorConfig->getColors(colors); | 2333 | colorConfig->getColors(colors); |
2334 | myDoc->setFont (fontConfig->getFont()); | 2334 | myDoc->setFont (fontConfig->getFont()); |
2335 | 2335 | ||
2336 | applyColors(); | 2336 | applyColors(); |
2337 | // indent options | 2337 | // indent options |
2338 | indentConfig->getData(this); | 2338 | indentConfig->getData(this); |
2339 | // select options | 2339 | // select options |
2340 | selectConfig->getData(this); | 2340 | selectConfig->getData(this); |
2341 | // edit options | 2341 | // edit options |
2342 | editConfig->getData(this); | 2342 | editConfig->getData(this); |
2343 | // spell checker | 2343 | // spell checker |
2344 | hlManager->setHlDataList(hlDataList); | 2344 | hlManager->setHlDataList(hlDataList); |
2345 | hlManager->setDefaults(defaultStyleList); | 2345 | hlManager->setDefaults(defaultStyleList); |
2346 | hlPage->saveData(); | 2346 | hlPage->saveData(); |
2347 | } | 2347 | } |
2348 | 2348 | ||
2349 | delete kd; | 2349 | delete kd; |
2350 | 2350 | ||
2351 | #endif | 2351 | #endif |
2352 | } | 2352 | } |
2353 | 2353 | ||
2354 | int KateView::getHl() { | 2354 | int KateView::getHl() { |
2355 | return myDoc->highlightNum(); | 2355 | return myDoc->highlightNum(); |
2356 | } | 2356 | } |
2357 | 2357 | ||
2358 | void KateView::setDontChangeHlOnSave() | 2358 | void KateView::setDontChangeHlOnSave() |
2359 | { | 2359 | { |
2360 | myDoc->setDontChangeHlOnSave(); | 2360 | myDoc->setDontChangeHlOnSave(); |
2361 | } | 2361 | } |
2362 | 2362 | ||
2363 | void KateView::setHl(int n) { | 2363 | void KateView::setHl(int n) { |
2364 | myDoc->setHighlight(n); | 2364 | myDoc->setHighlight(n); |
2365 | myDoc->setDontChangeHlOnSave(); | 2365 | myDoc->setDontChangeHlOnSave(); |
2366 | myDoc->updateViews(); | 2366 | myDoc->updateViews(); |
2367 | } | 2367 | } |
2368 | 2368 | ||
2369 | int KateView::getEol() { | 2369 | int KateView::getEol() { |
2370 | return myDoc->eolMode; | 2370 | return myDoc->eolMode; |
2371 | } | 2371 | } |
2372 | 2372 | ||
2373 | void KateView::setEol(int eol) { | 2373 | void KateView::setEol(int eol) { |
2374 | if (isReadOnly()) | 2374 | if (isReadOnly()) |
2375 | return; | 2375 | return; |
2376 | 2376 | ||
2377 | myDoc->eolMode = eol; | 2377 | myDoc->eolMode = eol; |
2378 | myDoc->setModified(true); | 2378 | myDoc->setModified(true); |
2379 | } | 2379 | } |
2380 | 2380 | ||
2381 | 2381 | ||
2382 | 2382 | ||
2383 | void KateView::paintEvent(QPaintEvent *e) { | 2383 | void KateView::paintEvent(QPaintEvent *e) { |
2384 | int x, y; | 2384 | int x, y; |
2385 | 2385 | ||
2386 | QRect updateR = e->rect(); // update rectangle | 2386 | QRect updateR = e->rect(); // update rectangle |
2387 | // debug("Update rect = ( %i, %i, %i, %i )", | 2387 | // debug("Update rect = ( %i, %i, %i, %i )", |
2388 | // updateR.x(),updateR.y(), updateR.width(), updateR.height() ); | 2388 | // updateR.x(),updateR.y(), updateR.width(), updateR.height() ); |
2389 | 2389 | ||
2390 | int ux1 = updateR.x(); | 2390 | int ux1 = updateR.x(); |
2391 | int uy1 = updateR.y(); | 2391 | int uy1 = updateR.y(); |
2392 | int ux2 = ux1 + updateR.width(); | 2392 | int ux2 = ux1 + updateR.width(); |
2393 | int uy2 = uy1 + updateR.height(); | 2393 | int uy2 = uy1 + updateR.height(); |
2394 | 2394 | ||
2395 | QPainter paint; | 2395 | QPainter paint; |
2396 | paint.begin(this); | 2396 | paint.begin(this); |
2397 | 2397 | ||
2398 | QColorGroup g = colorGroup(); | 2398 | QColorGroup g = colorGroup(); |
2399 | x = width(); | 2399 | x = width(); |
2400 | y = height(); | 2400 | y = height(); |
2401 | 2401 | ||
2402 | paint.setPen(g.dark()); | 2402 | paint.setPen(g.dark()); |
2403 | if (uy1 <= 0) paint.drawLine(0,0,x-2,0); | 2403 | if (uy1 <= 0) paint.drawLine(0,0,x-2,0); |
2404 | if (ux1 <= 0) paint.drawLine(0,1,0,y-2); | 2404 | if (ux1 <= 0) paint.drawLine(0,1,0,y-2); |
2405 | 2405 | ||
2406 | paint.setPen(black); | 2406 | paint.setPen(black); |
2407 | if (uy1 <= 1) paint.drawLine(1,1,x-3,1); | 2407 | if (uy1 <= 1) paint.drawLine(1,1,x-3,1); |
2408 | if (ux1 <= 1) paint.drawLine(1,2,1,y-3); | 2408 | if (ux1 <= 1) paint.drawLine(1,2,1,y-3); |
2409 | 2409 | ||
2410 | paint.setPen(g.midlight()); | 2410 | paint.setPen(g.midlight()); |
2411 | if (uy2 >= y-1) paint.drawLine(1,y-2,x-3,y-2); | 2411 | if (uy2 >= y-1) paint.drawLine(1,y-2,x-3,y-2); |
2412 | if (ux2 >= x-1) paint.drawLine(x-2,1,x-2,y-2); | 2412 | if (ux2 >= x-1) paint.drawLine(x-2,1,x-2,y-2); |
2413 | 2413 | ||
2414 | paint.setPen(g.light()); | 2414 | paint.setPen(g.light()); |
2415 | if (uy2 >= y) paint.drawLine(0,y-1,x-2,y-1); | 2415 | if (uy2 >= y) paint.drawLine(0,y-1,x-2,y-1); |
2416 | if (ux2 >= x) paint.drawLine(x-1,0,x-1,y-1); | 2416 | if (ux2 >= x) paint.drawLine(x-1,0,x-1,y-1); |
2417 | 2417 | ||
2418 | x -= 2 + 16; | 2418 | x -= 2 + 16; |
2419 | y -= 2 + 16; | 2419 | y -= 2 + 16; |
2420 | if (ux2 > x && uy2 > y) { | 2420 | if (ux2 > x && uy2 > y) { |
2421 | paint.fillRect(x,y,16,16,g.background()); | 2421 | paint.fillRect(x,y,16,16,g.background()); |
2422 | } | 2422 | } |
2423 | paint.end(); | 2423 | paint.end(); |
2424 | } | 2424 | } |
2425 | 2425 | ||
2426 | void KateView::resizeEvent(QResizeEvent *) { | 2426 | void KateView::resizeEvent(QResizeEvent *) { |
@@ -2744,180 +2744,180 @@ const char*breakpoint_gr_xpm[]={ | |||
2744 | "...#####...", | 2744 | "...#####...", |
2745 | "..#aaaaa#..", | 2745 | "..#aaaaa#..", |
2746 | ".#abbbbbb#.", | 2746 | ".#abbbbbb#.", |
2747 | "#abbbbbbbb#", | 2747 | "#abbbbbbbb#", |
2748 | "#abcacacbd#", | 2748 | "#abcacacbd#", |
2749 | "#abbbbbbbb#", | 2749 | "#abbbbbbbb#", |
2750 | "#abcacacbd#", | 2750 | "#abcacacbd#", |
2751 | "#abbbbbbbb#", | 2751 | "#abbbbbbbb#", |
2752 | ".#bbbbbbb#.", | 2752 | ".#bbbbbbb#.", |
2753 | "..#bdbdb#..", | 2753 | "..#bdbdb#..", |
2754 | "...#####...", | 2754 | "...#####...", |
2755 | "...........", | 2755 | "...........", |
2756 | "...........", | 2756 | "...........", |
2757 | "..........."}; | 2757 | "..........."}; |
2758 | 2758 | ||
2759 | const char*ddd_xpm[]={ | 2759 | const char*ddd_xpm[]={ |
2760 | "11 16 4 1", | 2760 | "11 16 4 1", |
2761 | "a c #00ff00", | 2761 | "a c #00ff00", |
2762 | "b c #000000", | 2762 | "b c #000000", |
2763 | ". c None", | 2763 | ". c None", |
2764 | "# c #00c000", | 2764 | "# c #00c000", |
2765 | "...........", | 2765 | "...........", |
2766 | "...........", | 2766 | "...........", |
2767 | "...........", | 2767 | "...........", |
2768 | "#a.........", | 2768 | "#a.........", |
2769 | "#aaa.......", | 2769 | "#aaa.......", |
2770 | "#aaaaa.....", | 2770 | "#aaaaa.....", |
2771 | "#aaaaaaa...", | 2771 | "#aaaaaaa...", |
2772 | "#aaaaaaaaa.", | 2772 | "#aaaaaaaaa.", |
2773 | "#aaaaaaa#b.", | 2773 | "#aaaaaaa#b.", |
2774 | "#aaaaa#b...", | 2774 | "#aaaaa#b...", |
2775 | "#aaa#b.....", | 2775 | "#aaa#b.....", |
2776 | "#a#b.......", | 2776 | "#a#b.......", |
2777 | "#b.........", | 2777 | "#b.........", |
2778 | "...........", | 2778 | "...........", |
2779 | "...........", | 2779 | "...........", |
2780 | "..........."}; | 2780 | "..........."}; |
2781 | 2781 | ||
2782 | 2782 | ||
2783 | 2783 | ||
2784 | KateIconBorder::KateIconBorder(KateView *view, KateViewInternal *internalView) | 2784 | KateIconBorder::KateIconBorder(KateView *view, KateViewInternal *internalView) |
2785 | : QWidget(view), myView(view), myInternalView(internalView) | 2785 | : QWidget(view), myView(view), myInternalView(internalView) |
2786 | { | 2786 | { |
2787 | lmbSetsBreakpoints = true; | 2787 | lmbSetsBreakpoints = true; |
2788 | } | 2788 | } |
2789 | 2789 | ||
2790 | KateIconBorder::~KateIconBorder() | 2790 | KateIconBorder::~KateIconBorder() |
2791 | { | 2791 | { |
2792 | } | 2792 | } |
2793 | 2793 | ||
2794 | void KateIconBorder::paintLine(int i) | 2794 | void KateIconBorder::paintLine(int i) |
2795 | { | 2795 | { |
2796 | if (!myView->myIconBorder) return; | 2796 | if (!myView->myIconBorder) return; |
2797 | 2797 | ||
2798 | QPainter p(this); | 2798 | QPainter p(this); |
2799 | 2799 | ||
2800 | int fontHeight = myView->doc()->fontHeight; | 2800 | int fontHeight = myView->doc()->fontHeight; |
2801 | int y = i*fontHeight - myInternalView->yPos; | 2801 | int y = i*fontHeight - myInternalView->yPos; |
2802 | p.fillRect(0, y, myInternalView->iconBorderWidth-2, fontHeight, colorGroup().background()); | 2802 | p.fillRect(0, y, myInternalView->iconBorderWidth-2, fontHeight, colorGroup().background()); |
2803 | p.setPen(white); | 2803 | p.setPen(white); |
2804 | p.drawLine(myInternalView->iconBorderWidth-2, y, myInternalView->iconBorderWidth-2, y + fontHeight); | 2804 | p.drawLine(myInternalView->iconBorderWidth-2, y, myInternalView->iconBorderWidth-2, y + fontHeight); |
2805 | p.setPen(QColor(colorGroup().background()).dark()); | 2805 | p.setPen(QColor(colorGroup().background()).dark()); |
2806 | p.drawLine(myInternalView->iconBorderWidth-1, y, myInternalView->iconBorderWidth-1, y + fontHeight); | 2806 | p.drawLine(myInternalView->iconBorderWidth-1, y, myInternalView->iconBorderWidth-1, y + fontHeight); |
2807 | 2807 | ||
2808 | TextLine *line = myView->doc()->getTextLine(i); | 2808 | TextLine *line = myView->doc()->getTextLine(i); |
2809 | if (!line) | 2809 | if (!line) |
2810 | return; | 2810 | return; |
2811 | 2811 | ||
2812 | if (line->mark()&KateDocument::Bookmark) | 2812 | if (line->mark()&KateDocument::Bookmark) |
2813 | p.drawPixmap(2, y, QPixmap(bookmark_xpm)); /* | 2813 | p.drawPixmap(2, y, QPixmap(bookmark_xpm)); /* |
2814 | if (line && (line->breakpointId() != -1)) { | 2814 | if (line && (line->breakpointId() != -1)) { |
2815 | if (!line->breakpointEnabled()) | 2815 | if (!line->breakpointEnabled()) |
2816 | p.drawPixmap(2, y, QPixmap(breakpoint_gr_xpm)); | 2816 | p.drawPixmap(2, y, QPixmap(breakpoint_gr_xpm)); |
2817 | else if (line->breakpointPending()) | 2817 | else if (line->breakpointPending()) |
2818 | p.drawPixmap(2, y, QPixmap(breakpoint_bl_xpm)); | 2818 | p.drawPixmap(2, y, QPixmap(breakpoint_bl_xpm)); |
2819 | else | 2819 | else |
2820 | p.drawPixmap(2, y, QPixmap(breakpoint_xpm)); | 2820 | p.drawPixmap(2, y, QPixmap(breakpoint_xpm)); |
2821 | } | 2821 | } |
2822 | if (line->isExecutionPoint()) | 2822 | if (line->isExecutionPoint()) |
2823 | p.drawPixmap(2, y, QPixmap(ddd_xpm)); */ | 2823 | p.drawPixmap(2, y, QPixmap(ddd_xpm)); */ |
2824 | } | 2824 | } |
2825 | 2825 | ||
2826 | 2826 | ||
2827 | void KateIconBorder::paintEvent(QPaintEvent* e) | 2827 | void KateIconBorder::paintEvent(QPaintEvent* e) |
2828 | { | 2828 | { |
2829 | if (!myView->myIconBorder) return; | 2829 | if (!myView->myIconBorder) return; |
2830 | 2830 | ||
2831 | int lineStart = 0; | 2831 | int lineStart = 0; |
2832 | int lineEnd = 0; | 2832 | int lineEnd = 0; |
2833 | 2833 | ||
2834 | QRect updateR = e->rect(); | 2834 | QRect updateR = e->rect(); |
2835 | 2835 | ||
2836 | KateDocument *doc = myView->doc(); | 2836 | KateDocument *doc = myView->doc(); |
2837 | int h = doc->fontHeight; | 2837 | int h = doc->fontHeight; |
2838 | int yPos = myInternalView->yPos; | 2838 | int yPos = myInternalView->yPos; |
2839 | if (h) { | 2839 | if (h) { |
2840 | lineStart = (yPos + updateR.y()) / h; | 2840 | lineStart = (yPos + updateR.y()) / h; |
2841 | lineEnd = QMAX((yPos + updateR.y() + updateR.height()) / h, (int)doc->numLines()); | 2841 | lineEnd = QMAX((yPos + updateR.y() + updateR.height()) / h, (int)doc->numLines()); |
2842 | } | 2842 | } |
2843 | 2843 | ||
2844 | for(int i = lineStart; i <= lineEnd; ++i) | 2844 | for(int i = lineStart; i <= lineEnd; ++i) |
2845 | paintLine(i); | 2845 | paintLine(i); |
2846 | } | 2846 | } |
2847 | 2847 | ||
2848 | 2848 | ||
2849 | void KateIconBorder::mousePressEvent(QMouseEvent* e) | 2849 | void KateIconBorder::mousePressEvent(QMouseEvent* e) |
2850 | { | 2850 | { |
2851 | myInternalView->placeCursor( 0, e->y(), 0 ); | 2851 | myInternalView->placeCursor( 0, e->y(), 0 ); |
2852 | 2852 | ||
2853 | KateDocument *doc = myView->doc(); | 2853 | KateDocument *doc = myView->doc(); |
2854 | int cursorOnLine = (e->y() + myInternalView->yPos) / doc->fontHeight; | 2854 | int cursorOnLine = (e->y() + myInternalView->yPos) / doc->fontHeight; |
2855 | TextLine *line = doc->getTextLine(cursorOnLine); | 2855 | TextLine *line = doc->getTextLine(cursorOnLine); |
2856 | 2856 | ||
2857 | switch (e->button()) { | 2857 | switch (e->button()) { |
2858 | case LeftButton: | 2858 | case LeftButton: |
2859 | if (!line) | 2859 | if (!line) |
2860 | break; | 2860 | break; |
2861 | else | 2861 | else |
2862 | { | 2862 | { |
2863 | if (line->mark()&KateDocument::Bookmark) | 2863 | if (line->mark()&KateDocument::Bookmark) |
2864 | line->delMark (KateDocument::Bookmark); | 2864 | line->delMark (KateDocument::Bookmark); |
2865 | else | 2865 | else |
2866 | line->addMark (KateDocument::Bookmark); | 2866 | line->addMark (KateDocument::Bookmark); |
2867 | 2867 | ||
2868 | doc->tagLines(cursorOnLine, cursorOnLine); | 2868 | doc->tagLines(cursorOnLine, cursorOnLine); |
2869 | doc->updateViews(); | 2869 | doc->updateViews(); |
2870 | } | 2870 | } |
2871 | break; | 2871 | break; |
2872 | /* case RightButton: | 2872 | /* case RightButton: |
2873 | { | 2873 | { |
2874 | if (!line) | 2874 | if (!line) |
2875 | break; | 2875 | break; |
2876 | KPopupMenu popup; | 2876 | KPopupMenu popup; |
2877 | popup.setCheckable(true); | 2877 | popup.setCheckable(true); |
2878 | popup.insertTitle(i18n("Breakpoints/Bookmarks")); | 2878 | popup.insertTitle(i18n("Breakpoints/Bookmarks")); |
2879 | int idToggleBookmark = popup.insertItem(i18n("Toggle bookmark")); | 2879 | int idToggleBookmark = popup.insertItem(i18n("Toggle bookmark")); |
2880 | popup.insertSeparator(); | 2880 | popup.insertSeparator(); |
2881 | int idToggleBreakpoint = popup.insertItem(i18n("Toggle breakpoint")); | 2881 | int idToggleBreakpoint = popup.insertItem(i18n("Toggle breakpoint")); |
2882 | int idEditBreakpoint = popup.insertItem(i18n("Edit breakpoint")); | 2882 | int idEditBreakpoint = popup.insertItem(i18n("Edit breakpoint")); |
2883 | int idEnableBreakpoint = popup.insertItem(i18n("Disable breakpoint")); | 2883 | int idEnableBreakpoint = popup.insertItem(i18n("Disable breakpoint")); |
2884 | popup.insertSeparator(); | 2884 | popup.insertSeparator(); |
2885 | popup.insertSeparator(); | 2885 | popup.insertSeparator(); |
2886 | int idLmbSetsBreakpoints = popup.insertItem(i18n("LMB sets breakpoints")); | 2886 | int idLmbSetsBreakpoints = popup.insertItem(i18n("LMB sets breakpoints")); |
2887 | int idLmbSetsBookmarks = popup.insertItem(i18n("LMB sets bookmarks")); | 2887 | int idLmbSetsBookmarks = popup.insertItem(i18n("LMB sets bookmarks")); |
2888 | 2888 | ||
2889 | popup.setItemChecked(idLmbSetsBreakpoints, lmbSetsBreakpoints); | 2889 | popup.setItemChecked(idLmbSetsBreakpoints, lmbSetsBreakpoints); |
2890 | popup.setItemChecked(idLmbSetsBookmarks, !lmbSetsBreakpoints); | 2890 | popup.setItemChecked(idLmbSetsBookmarks, !lmbSetsBreakpoints); |
2891 | 2891 | ||
2892 | if (line->breakpointId() == -1) { | 2892 | if (line->breakpointId() == -1) { |
2893 | popup.setItemEnabled(idEditBreakpoint, false); | 2893 | popup.setItemEnabled(idEditBreakpoint, false); |
2894 | popup.setItemEnabled(idEnableBreakpoint, false); | 2894 | popup.setItemEnabled(idEnableBreakpoint, false); |
2895 | popup.changeItem(idEnableBreakpoint, i18n("Enable breakpoint")); | 2895 | popup.changeItem(idEnableBreakpoint, i18n("Enable breakpoint")); |
2896 | } | 2896 | } |
2897 | int res = popup.exec(mapToGlobal(e->pos())); | 2897 | int res = popup.exec(mapToGlobal(e->pos())); |
2898 | if (res == idToggleBookmark) { | 2898 | if (res == idToggleBookmark) { |
2899 | line->toggleBookmark(); | 2899 | line->toggleBookmark(); |
2900 | doc->tagLines(cursorOnLine, cursorOnLine); | 2900 | doc->tagLines(cursorOnLine, cursorOnLine); |
2901 | doc->updateViews(); | 2901 | doc->updateViews(); |
2902 | } else if (res == idToggleBreakpoint) | 2902 | } else if (res == idToggleBreakpoint) |
2903 | emit myView->toggledBreakpoint(cursorOnLine); | 2903 | emit myView->toggledBreakpoint(cursorOnLine); |
2904 | else if (res == idEditBreakpoint) | 2904 | else if (res == idEditBreakpoint) |
2905 | emit myView->editedBreakpoint(cursorOnLine); | 2905 | emit myView->editedBreakpoint(cursorOnLine); |
2906 | else if (res == idEnableBreakpoint) | 2906 | else if (res == idEnableBreakpoint) |
2907 | emit myView->toggledBreakpointEnabled(cursorOnLine+1); | 2907 | emit myView->toggledBreakpointEnabled(cursorOnLine+1); |
2908 | else if (res == idLmbSetsBreakpoints || res == idLmbSetsBookmarks) | 2908 | else if (res == idLmbSetsBreakpoints || res == idLmbSetsBookmarks) |
2909 | lmbSetsBreakpoints = !lmbSetsBreakpoints; | 2909 | lmbSetsBreakpoints = !lmbSetsBreakpoints; |
2910 | break; | 2910 | break; |
2911 | } | 2911 | } |
2912 | case MidButton: | 2912 | case MidButton: |
2913 | line->toggleBookmark(); | 2913 | line->toggleBookmark(); |
2914 | doc->tagLines(cursorOnLine, cursorOnLine); | 2914 | doc->tagLines(cursorOnLine, cursorOnLine); |
2915 | doc->updateViews(); | 2915 | doc->updateViews(); |
2916 | break; */ | 2916 | break; */ |
2917 | default: | 2917 | default: |
2918 | break; | 2918 | break; |
2919 | } | 2919 | } |
2920 | } | 2920 | } |
2921 | 2921 | ||
2922 | 2922 | ||
2923 | 2923 | ||