Changeset View
Changeset View
Standalone View
Standalone View
src/view/kateviewinternal.cpp
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | 871 | } else { | |||
---|---|---|---|---|---|
872 | // should never happen: a range exists, but the cursor position is | 872 | // should never happen: a range exists, but the cursor position is | ||
873 | // neither at the start nor at the end... | 873 | // neither at the start nor at the end... | ||
874 | return KTextEditor::Cursor::invalid(); | 874 | return KTextEditor::Cursor::invalid(); | ||
875 | } | 875 | } | ||
876 | 876 | | |||
877 | return c; | 877 | return c; | ||
878 | } | 878 | } | ||
879 | 879 | | |||
880 | void KateViewInternal::doReturn() | | |||
881 | { | | |||
882 | doc()->newLine(m_view); | | |||
883 | m_leftBorder->updateForCursorLineChange(); | | |||
884 | updateView(); | | |||
885 | } | | |||
886 | | ||||
887 | void KateViewInternal::doSmartNewline() | | |||
888 | { | | |||
889 | int ln = m_cursor.line(); | | |||
890 | Kate::TextLine line = doc()->kateTextLine(ln); | | |||
891 | int col = qMin(m_cursor.column(), line->firstChar()); | | |||
892 | if (col != -1) { | | |||
893 | while (line->length() > col && | | |||
894 | !(line->at(col).isLetterOrNumber() || line->at(col) == QLatin1Char('_')) && | | |||
895 | col < m_cursor.column()) { | | |||
896 | ++col; | | |||
897 | } | | |||
898 | } else { | | |||
899 | col = line->length(); // stay indented | | |||
900 | } | | |||
901 | doc()->editStart(); | | |||
902 | doc()->editWrapLine(ln, m_cursor.column()); | | |||
903 | doc()->insertText(KTextEditor::Cursor(ln + 1, 0), line->string(0, col)); | | |||
904 | doc()->editEnd(); | | |||
905 | | ||||
906 | updateView(); | | |||
907 | } | | |||
908 | | ||||
909 | void KateViewInternal::doDelete() | | |||
910 | { | | |||
911 | doc()->del(m_view, m_cursor); | | |||
912 | } | | |||
913 | | ||||
914 | void KateViewInternal::doBackspace() | | |||
915 | { | | |||
916 | doc()->backspace(m_view, m_cursor); | | |||
917 | } | | |||
918 | | ||||
919 | void KateViewInternal::doTabulator() | | |||
920 | { | | |||
921 | doc()->insertTab(m_view, m_cursor); | | |||
922 | } | | |||
923 | | ||||
924 | void KateViewInternal::doTranspose() | | |||
925 | { | | |||
926 | doc()->transpose(m_cursor); | | |||
927 | } | | |||
928 | | ||||
929 | void KateViewInternal::doDeletePrevWord() | | |||
930 | { | | |||
931 | doc()->editStart(); | | |||
932 | wordPrev(true); | | |||
933 | KTextEditor::Range selection = m_view->selectionRange(); | | |||
934 | m_view->removeSelectedText(); | | |||
935 | doc()->editEnd(); | | |||
936 | tagRange(selection, true); | | |||
937 | updateDirty(); | | |||
938 | } | | |||
939 | | ||||
940 | void KateViewInternal::doDeleteNextWord() | | |||
941 | { | | |||
942 | doc()->editStart(); | | |||
943 | wordNext(true); | | |||
944 | KTextEditor::Range selection = m_view->selectionRange(); | | |||
945 | m_view->removeSelectedText(); | | |||
946 | doc()->editEnd(); | | |||
947 | tagRange(selection, true); | | |||
948 | updateDirty(); | | |||
949 | } | | |||
950 | 880 | | |||
951 | class CalculatingCursor | 881 | class CalculatingCursor | ||
952 | { | 882 | { | ||
953 | public: | 883 | public: | ||
954 | // These constructors constrain their arguments to valid positions | 884 | // These constructors constrain their arguments to valid positions | ||
955 | // before only the third one did, but that leads to crashs | 885 | // before only the third one did, but that leads to crashs | ||
956 | // see bug 227449 | 886 | // see bug 227449 | ||
957 | CalculatingCursor(KateViewInternal *vi) | 887 | CalculatingCursor(KateViewInternal *vi) | ||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Line(s) | 2341 | { | |||
2455 | 2385 | | |||
2456 | 2386 | | |||
2457 | if (!doc()->isReadWrite()) { | 2387 | if (!doc()->isReadWrite()) { | ||
2458 | e->ignore(); | 2388 | e->ignore(); | ||
2459 | return; | 2389 | return; | ||
2460 | } | 2390 | } | ||
2461 | 2391 | | |||
2462 | if ((key == Qt::Key_Return) || (key == Qt::Key_Enter) || (key == Qt::SHIFT + Qt::Key_Return) || (key == Qt::SHIFT + Qt::Key_Enter)) { | 2392 | if ((key == Qt::Key_Return) || (key == Qt::Key_Enter) || (key == Qt::SHIFT + Qt::Key_Return) || (key == Qt::SHIFT + Qt::Key_Enter)) { | ||
2463 | doReturn(); | 2393 | m_view->keyReturn(); | ||
2464 | e->accept(); | 2394 | e->accept(); | ||
2465 | return; | 2395 | return; | ||
2466 | } | 2396 | } | ||
2467 | 2397 | | |||
2468 | if (key == Qt::Key_Backspace || key == Qt::SHIFT + Qt::Key_Backspace) { | 2398 | if (key == Qt::Key_Backspace || key == Qt::SHIFT + Qt::Key_Backspace) { | ||
2469 | //m_view->backspace(); | 2399 | //m_view->backspace(); | ||
2470 | e->accept(); | 2400 | e->accept(); | ||
2471 | 2401 | | |||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |