Changeset View
Changeset View
Standalone View
Standalone View
src/view/kateview.cpp
Show First 20 Lines • Show All 2784 Lines • ▼ Show 20 Line(s) | 2781 | { | |||
---|---|---|---|---|---|
2785 | removeSelectedText(); | 2785 | removeSelectedText(); | ||
2786 | doc()->editEnd(); | 2786 | doc()->editEnd(); | ||
2787 | m_viewInternal->tagRange(selection, true); | 2787 | m_viewInternal->tagRange(selection, true); | ||
2788 | m_viewInternal->updateDirty(); | 2788 | m_viewInternal->updateDirty(); | ||
2789 | } | 2789 | } | ||
2790 | 2790 | | |||
2791 | void KTextEditor::ViewPrivate::transpose() | 2791 | void KTextEditor::ViewPrivate::transpose() | ||
2792 | { | 2792 | { | ||
2793 | doc()->transpose(cursorPosition()); | 2793 | doc()->transpose(cursorPosition()); | ||
dhaumann: Since we have this line twice, I suggest to move this after line 2791 as follows:
const… | |||||
2794 | } | 2794 | } | ||
2795 | 2795 | | |||
2796 | void KTextEditor::ViewPrivate::cursorLeft() | 2796 | void KTextEditor::ViewPrivate::cursorLeft() | ||
2797 | { | 2797 | { | ||
2798 | if (m_viewInternal->m_view->currentTextLine().isRightToLeft()) { | 2798 | if (selection() && !config()->persistentSelection()) { | ||
2799 | if (currentTextLine().isRightToLeft()) { | ||||
2800 | m_viewInternal->updateCursor(selectionRange().end()); | ||||
2801 | setSelection(KTextEditor::Range::invalid()); | ||||
2802 | } else { | ||||
2803 | m_viewInternal->updateCursor(selectionRange().start()); | ||||
2804 | setSelection(KTextEditor::Range::invalid()); | ||||
2805 | } | ||||
2806 | | ||||
2807 | } else { | ||||
2808 | if (currentTextLine().isRightToLeft()) { | ||||
2799 | m_viewInternal->cursorNextChar(); | 2809 | m_viewInternal->cursorNextChar(); | ||
2800 | } else { | 2810 | } else { | ||
2801 | m_viewInternal->cursorPrevChar(); | 2811 | m_viewInternal->cursorPrevChar(); | ||
2802 | } | 2812 | } | ||
2803 | } | 2813 | } | ||
2814 | } | ||||
2804 | 2815 | | |||
2805 | void KTextEditor::ViewPrivate::shiftCursorLeft() | 2816 | void KTextEditor::ViewPrivate::shiftCursorLeft() | ||
2806 | { | 2817 | { | ||
2807 | if (m_viewInternal->m_view->currentTextLine().isRightToLeft()) { | 2818 | if (currentTextLine().isRightToLeft()) { | ||
2808 | m_viewInternal->cursorNextChar(true); | 2819 | m_viewInternal->cursorNextChar(true); | ||
2809 | } else { | 2820 | } else { | ||
2810 | m_viewInternal->cursorPrevChar(true); | 2821 | m_viewInternal->cursorPrevChar(true); | ||
2811 | } | 2822 | } | ||
2812 | } | 2823 | } | ||
2813 | 2824 | | |||
2814 | void KTextEditor::ViewPrivate::cursorRight() | 2825 | void KTextEditor::ViewPrivate::cursorRight() | ||
2815 | { | 2826 | { | ||
2816 | if (m_viewInternal->m_view->currentTextLine().isRightToLeft()) { | 2827 | if (selection() && !config()->persistentSelection()) { | ||
2828 | if (currentTextLine().isRightToLeft()) { | ||||
2829 | m_viewInternal->updateCursor(selectionRange().start()); | ||||
2830 | setSelection(KTextEditor::Range::invalid()); | ||||
2831 | } else { | ||||
2832 | m_viewInternal->updateCursor(selectionRange().end()); | ||||
2833 | setSelection(KTextEditor::Range::invalid()); | ||||
2834 | } | ||||
2835 | | ||||
2836 | } else { | ||||
2837 | if (currentTextLine().isRightToLeft()) { | ||||
2817 | m_viewInternal->cursorPrevChar(); | 2838 | m_viewInternal->cursorPrevChar(); | ||
2818 | } else { | 2839 | } else { | ||
2819 | m_viewInternal->cursorNextChar(); | 2840 | m_viewInternal->cursorNextChar(); | ||
2820 | } | 2841 | } | ||
2821 | } | 2842 | } | ||
2843 | } | ||||
2822 | 2844 | | |||
2823 | void KTextEditor::ViewPrivate::shiftCursorRight() | 2845 | void KTextEditor::ViewPrivate::shiftCursorRight() | ||
2824 | { | 2846 | { | ||
2825 | if (m_viewInternal->m_view->currentTextLine().isRightToLeft()) { | 2847 | if (currentTextLine().isRightToLeft()) { | ||
2826 | m_viewInternal->cursorPrevChar(true); | 2848 | m_viewInternal->cursorPrevChar(true); | ||
2827 | } else { | 2849 | } else { | ||
2828 | m_viewInternal->cursorNextChar(true); | 2850 | m_viewInternal->cursorNextChar(true); | ||
2829 | } | 2851 | } | ||
2830 | } | 2852 | } | ||
2831 | 2853 | | |||
2832 | void KTextEditor::ViewPrivate::wordLeft() | 2854 | void KTextEditor::ViewPrivate::wordLeft() | ||
2833 | { | 2855 | { | ||
2834 | if (m_viewInternal->m_view->currentTextLine().isRightToLeft()) { | 2856 | if (currentTextLine().isRightToLeft()) { | ||
2835 | m_viewInternal->wordNext(); | 2857 | m_viewInternal->wordNext(); | ||
2836 | } else { | 2858 | } else { | ||
2837 | m_viewInternal->wordPrev(); | 2859 | m_viewInternal->wordPrev(); | ||
2838 | } | 2860 | } | ||
2839 | } | 2861 | } | ||
2840 | 2862 | | |||
2841 | void KTextEditor::ViewPrivate::shiftWordLeft() | 2863 | void KTextEditor::ViewPrivate::shiftWordLeft() | ||
2842 | { | 2864 | { | ||
2843 | if (m_viewInternal->m_view->currentTextLine().isRightToLeft()) { | 2865 | if (currentTextLine().isRightToLeft()) { | ||
2844 | m_viewInternal->wordNext(true); | 2866 | m_viewInternal->wordNext(true); | ||
2845 | } else { | 2867 | } else { | ||
2846 | m_viewInternal->wordPrev(true); | 2868 | m_viewInternal->wordPrev(true); | ||
2847 | } | 2869 | } | ||
2848 | } | 2870 | } | ||
2849 | 2871 | | |||
2850 | void KTextEditor::ViewPrivate::wordRight() | 2872 | void KTextEditor::ViewPrivate::wordRight() | ||
2851 | { | 2873 | { | ||
2852 | if (m_viewInternal->m_view->currentTextLine().isRightToLeft()) { | 2874 | if (currentTextLine().isRightToLeft()) { | ||
2853 | m_viewInternal->wordPrev(); | 2875 | m_viewInternal->wordPrev(); | ||
2854 | } else { | 2876 | } else { | ||
2855 | m_viewInternal->wordNext(); | 2877 | m_viewInternal->wordNext(); | ||
2856 | } | 2878 | } | ||
2857 | } | 2879 | } | ||
2858 | 2880 | | |||
2859 | void KTextEditor::ViewPrivate::shiftWordRight() | 2881 | void KTextEditor::ViewPrivate::shiftWordRight() | ||
2860 | { | 2882 | { | ||
2861 | if (m_viewInternal->m_view->currentTextLine().isRightToLeft()) { | 2883 | if (currentTextLine().isRightToLeft()) { | ||
2862 | m_viewInternal->wordPrev(true); | 2884 | m_viewInternal->wordPrev(true); | ||
2863 | } else { | 2885 | } else { | ||
2864 | m_viewInternal->wordNext(true); | 2886 | m_viewInternal->wordNext(true); | ||
2865 | } | 2887 | } | ||
2866 | } | 2888 | } | ||
2867 | 2889 | | |||
2868 | void KTextEditor::ViewPrivate::home() | 2890 | void KTextEditor::ViewPrivate::home() | ||
2869 | { | 2891 | { | ||
▲ Show 20 Lines • Show All 952 Lines • Show Last 20 Lines |
Since we have this line twice, I suggest to move this after line 2791 as follows:
Then, you can use a simple if (moveToEndOfSelection) {...} which is a bit more readable.