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