Changeset View
Changeset View
Standalone View
Standalone View
src/view/kateviewinternal.cpp
Show First 20 Lines • Show All 602 Lines • ▼ Show 20 Line(s) | 577 | { | |||
---|---|---|---|---|---|
603 | bool blocked = m_columnScroll->blockSignals(true); | 603 | bool blocked = m_columnScroll->blockSignals(true); | ||
604 | m_columnScroll->setValue(m_startX); | 604 | m_columnScroll->setValue(m_startX); | ||
605 | m_columnScroll->blockSignals(blocked); | 605 | m_columnScroll->blockSignals(blocked); | ||
606 | } | 606 | } | ||
607 | 607 | | |||
608 | // If changed is true, the lines that have been set dirty have been updated. | 608 | // If changed is true, the lines that have been set dirty have been updated. | ||
609 | void KateViewInternal::updateView(bool changed, int viewLinesScrolled) | 609 | void KateViewInternal::updateView(bool changed, int viewLinesScrolled) | ||
610 | { | 610 | { | ||
611 | doUpdateView(changed, viewLinesScrolled); | | |||
612 | | ||||
613 | if (changed) { | | |||
614 | updateDirty(); | | |||
615 | } | | |||
616 | } | | |||
617 | | ||||
618 | void KateViewInternal::doUpdateView(bool changed, int viewLinesScrolled) | | |||
619 | { | | |||
620 | if (!isVisible() && !viewLinesScrolled && !changed) { | 611 | if (!isVisible() && !viewLinesScrolled && !changed) { | ||
621 | return; //When this view is not visible, don't do anything | 612 | return; //When this view is not visible, don't do anything | ||
622 | } | 613 | } | ||
623 | 614 | | |||
624 | bool blocked = m_lineScroll->blockSignals(true); | 615 | bool blocked = m_lineScroll->blockSignals(true); | ||
625 | 616 | | |||
626 | if (width() != cache()->viewWidth()) { | 617 | if (width() != cache()->viewWidth()) { | ||
627 | cache()->setViewWidth(width()); | 618 | cache()->setViewWidth(width()); | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 651 | if (!m_view->dynWordWrap()) { | |||
687 | m_columnScroll->setPageStep(width()); | 678 | m_columnScroll->setPageStep(width()); | ||
688 | 679 | | |||
689 | m_columnScroll->blockSignals(blocked); | 680 | m_columnScroll->blockSignals(blocked); | ||
690 | } else { | 681 | } else { | ||
691 | visible_dummy = false; | 682 | visible_dummy = false; | ||
692 | } | 683 | } | ||
693 | 684 | | |||
694 | m_dummy->setVisible(visible_dummy); | 685 | m_dummy->setVisible(visible_dummy); | ||
686 | | ||||
687 | if (changed) { | ||||
688 | updateDirty(); | ||||
689 | } | ||||
695 | } | 690 | } | ||
696 | 691 | | |||
697 | /** | 692 | /** | ||
698 | * this function ensures a certain location is visible on the screen. | 693 | * this function ensures a certain location is visible on the screen. | ||
699 | * if endCol is -1, ignore making the columns visible. | 694 | * if endCol is -1, ignore making the columns visible. | ||
700 | */ | 695 | */ | ||
701 | void KateViewInternal::makeVisible(const KTextEditor::Cursor &c, int endCol, bool force, bool center, bool calledExternally) | 696 | void KateViewInternal::makeVisible(const KTextEditor::Cursor &c, int endCol, bool force, bool center, bool calledExternally) | ||
702 | { | 697 | { | ||
▲ Show 20 Lines • Show All 169 Lines • ▼ Show 20 Line(s) | 866 | } else { | |||
872 | // should never happen: a range exists, but the cursor position is | 867 | // should never happen: a range exists, but the cursor position is | ||
873 | // neither at the start nor at the end... | 868 | // neither at the start nor at the end... | ||
874 | return KTextEditor::Cursor::invalid(); | 869 | return KTextEditor::Cursor::invalid(); | ||
875 | } | 870 | } | ||
876 | 871 | | |||
877 | return c; | 872 | return c; | ||
878 | } | 873 | } | ||
879 | 874 | | |||
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 | 875 | | |||
951 | class CalculatingCursor | 876 | class CalculatingCursor | ||
952 | { | 877 | { | ||
953 | public: | 878 | public: | ||
954 | // These constructors constrain their arguments to valid positions | 879 | // These constructors constrain their arguments to valid positions | ||
955 | // before only the third one did, but that leads to crashs | 880 | // before only the third one did, but that leads to crashs | ||
956 | // see bug 227449 | 881 | // see bug 227449 | ||
957 | CalculatingCursor(KateViewInternal *vi) | 882 | CalculatingCursor(KateViewInternal *vi) | ||
▲ Show 20 Lines • Show All 1497 Lines • ▼ Show 20 Line(s) | 2336 | { | |||
2455 | 2380 | | |||
2456 | 2381 | | |||
2457 | if (!doc()->isReadWrite()) { | 2382 | if (!doc()->isReadWrite()) { | ||
2458 | e->ignore(); | 2383 | e->ignore(); | ||
2459 | return; | 2384 | return; | ||
2460 | } | 2385 | } | ||
2461 | 2386 | | |||
2462 | if ((key == Qt::Key_Return) || (key == Qt::Key_Enter) || (key == Qt::SHIFT + Qt::Key_Return) || (key == Qt::SHIFT + Qt::Key_Enter)) { | 2387 | if ((key == Qt::Key_Return) || (key == Qt::Key_Enter) || (key == Qt::SHIFT + Qt::Key_Return) || (key == Qt::SHIFT + Qt::Key_Enter)) { | ||
2463 | doReturn(); | 2388 | m_view->keyReturn(); | ||
2464 | e->accept(); | 2389 | e->accept(); | ||
2465 | return; | 2390 | return; | ||
2466 | } | 2391 | } | ||
2467 | 2392 | | |||
2468 | if (key == Qt::Key_Backspace || key == Qt::SHIFT + Qt::Key_Backspace) { | 2393 | if (key == Qt::Key_Backspace || key == Qt::SHIFT + Qt::Key_Backspace) { | ||
2469 | //m_view->backspace(); | 2394 | //m_view->backspace(); | ||
2470 | e->accept(); | 2395 | e->accept(); | ||
2471 | 2396 | | |||
▲ Show 20 Lines • Show All 1476 Lines • Show Last 20 Lines |