[prev in list] [next in list] [prev in thread] [next in thread]
List: kwrite-devel
Subject: [kate] part: Feature: Jump to next/previous change
From: Dominik Haumann <dhaumann () kde ! org>
Date: 2014-02-19 21:31:51
Message-ID: E1WGEkB-0005Yv-Ni () scm ! kde ! org
[Download RAW message or body]
Git commit 8c2f4bb0eb33ac3b1b05b3148b9f8f722612c904 by Dominik Haumann.
Committed on 19/02/2014 at 21:29.
Pushed by dhaumann into branch 'master'.
Feature: Jump to next/previous change
Currently, these two actions are now directly in the Edit menu:
- Move to Previous Modified Line
- Move to Next Modified Line
- Go To...
Is that ok for 4.x, or do you want it all in a "Go To" submenu?
CCMAIL: kwrite-devel@kde.org
By default, no shortcuts are assigned.
FIXED-IN: 4.13
BUG: 310738
M +3 -1 part/data/katepartui.rc
M +15 -0 part/document/katedocument.cpp
M +3 -0 part/document/katedocument.h
M +32 -0 part/view/kateview.cpp
M +2 -0 part/view/kateview.h
http://commits.kde.org/kate/8c2f4bb0eb33ac3b1b05b3148b9f8f722612c904
diff --git a/part/data/katepartui.rc b/part/data/katepartui.rc
index 7e55a52..af1e23f 100644
--- a/part/data/katepartui.rc
+++ b/part/data/katepartui.rc
@@ -1,5 +1,5 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<kpartgui name="KatePartView" version="66">
+<kpartgui name="KatePartView" version="67">
<MenuBar>
<Menu name="file" noMerge="1"><text>&File</text>
<Action name="file_save" group="save_merge" />
@@ -34,6 +34,8 @@
</Menu>
<Action name="edit_replace" group="edit_find_merge" />
<Separator group="edit_find_merge" />
+ <Action name="modified_line_up" group="edit_find_merge"/>
+ <Action name="modified_line_down" group="edit_find_merge"/>
<Action name="go_goto_line" group="edit_find_merge"/>
</Menu>
diff --git a/part/document/katedocument.cpp b/part/document/katedocument.cpp
index 22d5db7..fdfbf03 100644
--- a/part/document/katedocument.cpp
+++ b/part/document/katedocument.cpp
@@ -5509,6 +5509,21 @@ bool KateDocument::isComment(int line, int column)
return defaultStyle == KTextEditor::HighlightInterface::dsComment;
}
+int KateDocument::findModifiedLine(int startLine, bool down)
+{
+ const int offset = down ? 1 : -1;
+ const int lineCount = lines();
+ while (startLine >= 0 && startLine < lineCount) {
+ Kate::TextLine tl = m_buffer->plainLine(startLine);
+ if (tl && (tl->markedAsModified() || tl->markedAsSavedOnDisk())) {
+ return startLine;
+ }
+ startLine += offset;
+ }
+
+ return -1;
+}
+
//BEGIN KTextEditor::MessageInterface
bool KateDocument::postMessage(KTextEditor::Message* message)
{
diff --git a/part/document/katedocument.h b/part/document/katedocument.h
index 76e9c55..f96769d 100644
--- a/part/document/katedocument.h
+++ b/part/document/katedocument.h
@@ -1166,6 +1166,9 @@ Q_SIGNALS:
int defStyleNum(int line, int column);
bool isComment(int line, int column);
+public:
+ int findModifiedLine(int startLine, bool down);
+
private Q_SLOTS:
/**
* watch for all started io jobs to remember if file is perhaps loading atm
diff --git a/part/view/kateview.cpp b/part/view/kateview.cpp
index 5bf6657..f5c8d6f 100644
--- a/part/view/kateview.cpp
+++ b/part/view/kateview.cpp
@@ -483,6 +483,16 @@ void KateView::setupActions()
a = ac->addAction( KStandardAction::GotoLine, this, SLOT(gotoLine()) );
a->setWhatsThis(i18n("This command opens a dialog and lets you choose a line that \
you want the cursor to move to."));
+ a = ac->addAction(QLatin1String("modified_line_up"));
+ a->setText(i18n("Move to Previous Modified Line"));
+ a->setWhatsThis(i18n("Move upwards to the previous modified line."));
+ connect(a, SIGNAL(triggered(bool)), SLOT(toPrevModifiedLine()));
+
+ a = ac->addAction(QLatin1String("modified_line_down"));
+ a->setText(i18n("Move to Next Modified Line"));
+ a->setWhatsThis(i18n("Move downwards to the next modified line."));
+ connect(a, SIGNAL(triggered(bool)), SLOT(toNextModifiedLine()));
+
a = ac->addAction("set_confdlg");
a->setText(i18n("&Configure Editor..."));
a->setWhatsThis(i18n("Configure various aspects of this editor."));
@@ -2753,6 +2763,28 @@ void KateView::shiftToMatchingBracket( )
m_viewInternal->cursorToMatchingBracket(true);
}
+void KateView::toPrevModifiedLine()
+{
+ const int startLine = m_viewInternal->m_cursor.line() - 1;
+ const int line = m_doc->findModifiedLine(startLine, false);
+ if (line >= 0) {
+ KTextEditor::Cursor c(line, 0);
+ m_viewInternal->updateSelection(c, false);
+ m_viewInternal->updateCursor(c);
+ }
+}
+
+void KateView::toNextModifiedLine()
+{
+ const int startLine = m_viewInternal->m_cursor.line() + 1;
+ const int line = m_doc->findModifiedLine(startLine, true);
+ if (line >= 0) {
+ KTextEditor::Cursor c(line, 0);
+ m_viewInternal->updateSelection(c, false);
+ m_viewInternal->updateCursor(c);
+ }
+}
+
const KTextEditor::Range & KateView::selectionRange( ) const
{
// update the cache
diff --git a/part/view/kateview.h b/part/view/kateview.h
index c707298..fc15b94 100644
--- a/part/view/kateview.h
+++ b/part/view/kateview.h
@@ -483,6 +483,8 @@ class KATEPART_TESTS_EXPORT KateView : public KTextEditor::View,
void shiftBottom();
void toMatchingBracket();
void shiftToMatchingBracket();
+ void toPrevModifiedLine();
+ void toNextModifiedLine();
void insertTab();
void gotoLine();
_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic