[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    Re: [ktexteditor] src: Feature: Jump to next/previous change
From:       Michal Humpula <michal.humpula () seznam ! cz>
Date:       2014-02-19 20:54:27
Message-ID: 5727779.4xsa9cWxCK () amonsul
[Download RAW message or body]

nice:)

On Wednesday 19 of February 2014 20:53:00 Dominik Haumann wrote:
> Git commit 6d3b2f62d409b990ecf45733f0710d78c21a4a36 by Dominik Haumann.
> Committed on 19/02/2014 at 20:49.
> Pushed by dhaumann into branch 'master'.
> 
> Feature: Jump to next/previous change
> 
> Currently, no shortcut is assigned. Any suggestions?
> 
> CCBUG: 310738
> REVIEW: 115633
> 
> M  +9    -5    src/data/katepartui.rc
> M  +15   -0    src/document/katedocument.cpp
> M  +3    -0    src/document/katedocument.h
> M  +32   -0    src/view/kateview.cpp
> M  +2    -0    src/view/kateview.h
> 
> http://commits.kde.org/ktexteditor/6d3b2f62d409b990ecf45733f0710d78c21a4a36
> 
> diff --git a/src/data/katepartui.rc b/src/data/katepartui.rc
> index dbb6a94..303cd2f 100644
> --- a/src/data/katepartui.rc
> +++ b/src/data/katepartui.rc
> @@ -1,5 +1,5 @@
> <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
> -<kpartgui name="KatePartView" version="68">
> +<kpartgui name="KatePartView" version="69">
> <MenuBar>
> <Menu name="file" noMerge="1"><text>&amp;File</text>
> <Action name="file_save" group="save_merge" />
> @@ -40,11 +40,15 @@
> </Menu>
> <Action name="edit_replace" group="edit_find_merge" />
> <Separator group="edit_find_merge" />
> -    <Menu name="edit_matching_bracket" group="edit_find_merge"><text>Matching \
>                 Bracket</text>
> -        <Action name="to_matching_bracket" group="edit_matching_bracket" />
> -        <Action name="select_matching_bracket" group="edit_matching_bracket" />
> +    <Menu name="edit_goto" group="edit_goto"><text>Go To</text>
> +      <Action name="to_matching_bracket" group="edit_goto" />
> +      <Action name="select_matching_bracket" group="edit_goto" />
> +      <Separator group="edit_goto" />
> +      <Action name="modified_line_up" group="edit_goto"/>
> +      <Action name="modified_line_down" group="edit_goto"/>
> +      <Separator group="edit_goto" />
> +      <Action name="go_goto_line" group="edit_goto"/>
> </Menu>
> -    <Action name="go_goto_line" group="edit_find_merge"/>
> </Menu>
> 
> <Menu name="view" noMerge="1"><text>&amp;View</text>
> diff --git a/src/document/katedocument.cpp b/src/document/katedocument.cpp
> index 1392bc9..66c2d5a 100644
> --- a/src/document/katedocument.cpp
> +++ b/src/document/katedocument.cpp
> @@ -5627,6 +5627,21 @@ bool KTextEditor::DocumentPrivate::isComment(int line, int \
> column) return defaultStyle == KTextEditor::HighlightInterface::dsComment;
> }
> 
> +int KTextEditor::DocumentPrivate::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 KTextEditor::DocumentPrivate::postMessage(KTextEditor::Message *message)
> {
> diff --git a/src/document/katedocument.h b/src/document/katedocument.h
> index d31b7f8..1840584 100644
> --- a/src/document/katedocument.h
> +++ b/src/document/katedocument.h
> @@ -1205,6 +1205,9 @@ public:
> 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/src/view/kateview.cpp b/src/view/kateview.cpp
> index 6040eac..c2e3e99 100644
> --- a/src/view/kateview.cpp
> +++ b/src/view/kateview.cpp
> @@ -458,6 +458,16 @@ void KTextEditor::ViewPrivate::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(QLatin1String("set_confdlg"));
> a->setText(i18n("&Configure Editor..."));
> a->setWhatsThis(i18n("Configure various aspects of this editor."));
> @@ -2813,6 +2823,28 @@ void KTextEditor::ViewPrivate::shiftToMatchingBracket()
> m_viewInternal->cursorToMatchingBracket(true);
> }
> 
> +void KTextEditor::ViewPrivate::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 KTextEditor::ViewPrivate::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);
> +    }
> +}
> +
> KTextEditor::Range KTextEditor::ViewPrivate::selectionRange() const
> {
> return m_selection;
> diff --git a/src/view/kateview.h b/src/view/kateview.h
> index dc888c1..7646932 100644
> --- a/src/view/kateview.h
> +++ b/src/view/kateview.h
> @@ -501,6 +501,8 @@ public Q_SLOTS:
> void shiftBottom();
> void toMatchingBracket();
> void shiftToMatchingBracket();
> +    void toPrevModifiedLine();
> +    void toNextModifiedLine();
> void insertTab();
> 
> void gotoLine();
> 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic