17#include "clipboardhistorydialog.h"
18#include "export/exporter.h"
19#include "inlinenotedata.h"
20#include "kateabstractinputmode.h"
21#include "kateautoindent.h"
22#include "katebookmarks.h"
23#include "katebuffer.h"
24#include "katecompletionwidget.h"
25#include "kateconfig.h"
26#include "katedialogs.h"
27#include "katedocument.h"
28#include "kateglobal.h"
29#include "katehighlight.h"
30#include "katehighlightmenu.h"
31#include "katekeywordcompletion.h"
32#include "katelayoutcache.h"
33#include "katemessagewidget.h"
34#include "katemodemenu.h"
35#include "katepartdebug.h"
36#include "katerenderer.h"
37#include "katestatusbar.h"
38#include "katetemplatehandler.h"
39#include "katetextline.h"
40#include "kateundomanager.h"
41#include "kateviewhelpers.h"
42#include "kateviewinternal.h"
43#include "katewordcompletion.h"
44#include "printing/kateprinter.h"
45#include "screenshotdialog.h"
46#include "script/katescriptaction.h"
47#include "script/katescriptmanager.h"
48#include "spellcheck/spellcheck.h"
49#include "spellcheck/spellcheckdialog.h"
50#include "spellcheck/spellingmenu.h"
52#include <KTextEditor/Message>
53#include <ktexteditor/annotationinterface.h>
54#include <ktexteditor/inlinenoteprovider.h>
55#include <ktexteditor/texthintinterface.h>
57#include <KActionCollection>
59#include <KConfigGroup>
62#include <KSelectAction>
63#include <KStandardAction>
64#include <KStandardShortcut>
65#include <KToggleAction>
66#include <KXMLGUIFactory>
68#include <QActionGroup>
69#include <QApplication>
74#include <QInputDialog>
79#include <QRegularExpression>
80#include <QTextToSpeech>
89bool hasCommentInFirstLine(KTextEditor::DocumentPrivate *doc)
92 return doc->isComment(0, line.
firstChar());
108 , m_completionWidget(nullptr)
109 , m_annotationModel(nullptr)
110 , m_markedSelection(false)
113 , m_textFolding(doc->
buffer())
114 , m_config(new KateViewConfig(this))
115 , m_renderer(new
KateRenderer(doc, m_textFolding, this))
116 , m_viewInternal(new KateViewInternal(this))
117 , m_spell(new KateSpellCheckDialog(this))
118 , m_bookmarks(new KateBookmarks(this))
124 , m_updatingDocumentConfig(false)
125 , m_selection(m_doc->
buffer(),
KTextEditor::
Range::invalid(), Kate::TextRange::ExpandLeft, Kate::TextRange::AllowEmpty)
127 , m_bottomViewBar(nullptr)
129 , m_dictionaryBar(nullptr)
130 , m_spellingMenu(new KateSpellingMenu(this))
131 , m_userContextMenuSet(false)
132 , m_lineToUpdateRange(
KTextEditor::LineRange::invalid())
133 , m_mainWindow(mainWindow ? mainWindow :
KTextEditor::EditorPrivate::self()->dummyMainWindow())
134 , m_statusBar(nullptr)
135 , m_temporaryAutomaticInvocationDisabled(false)
136 , m_autoFoldedFirstLine(false)
139 connect(
this, &KTextEditor::ViewPrivate::delayedUpdateOfView,
this, &KTextEditor::ViewPrivate::slotDelayedUpdateOfView,
Qt::QueuedConnection);
141 m_delayedUpdateTimer.setSingleShot(
true);
142 m_delayedUpdateTimer.setInterval(0);
149 m_selection.setView(
this);
152 m_selection.setZDepth(-100000.0);
157 QWidget *bottomBarParent = m_mainWindow->createViewBar(
this);
159 m_bottomViewBar =
new KateViewBar(bottomBarParent !=
nullptr, bottomBarParent ? bottomBarParent : this, this);
167 m_bottomViewBar->installEventFilter(m_viewInternal);
180 if (bottomBarParent) {
181 m_mainWindow->addWidgetToViewBar(
this, m_bottomViewBar);
186 m_notificationLayout->setContentsMargins(20, 20, 20, 20);
187 m_viewInternal->setLayout(m_notificationLayout);
190 m_viewInternal->updateView();
194 setFocusProxy(m_viewInternal);
197 setXMLFile(QStringLiteral(
"katepart5ui.rc"));
203 new KateWordCompletionView(
this, actionCollection());
212 m_startingUp =
false;
218 for (
auto messageWidget : m_messageWidgets) {
229 connect(m_doc, &KTextEditor::DocumentPrivate::aboutToReload,
this, &KTextEditor::ViewPrivate::saveFoldingState);
230 connect(m_doc, &KTextEditor::DocumentPrivate::reloaded,
this, &KTextEditor::ViewPrivate::applyFoldingState);
232 connect(m_doc, &KTextEditor::DocumentPrivate::reloaded,
this, &KTextEditor::ViewPrivate::slotDocumentReloaded);
233 connect(m_doc, &KTextEditor::DocumentPrivate::aboutToReload,
this, &KTextEditor::ViewPrivate::slotDocumentAboutToReload);
236 connect(
this, &KTextEditor::ViewPrivate::displayRangeChanged,
this, &KTextEditor::ViewPrivate::createHighlights);
239 connect(m_doc, &KTextEditor::DocumentPrivate::aboutToReload,
this, &KTextEditor::ViewPrivate::clearHighlights);
245KTextEditor::ViewPrivate::~ViewPrivate()
252 doc()->removeView(
this);
255 delete m_completionWidget;
263 delete m_viewInternal;
266 m_mainWindow->deleteViewBar(
this);
267 m_bottomViewBar =
nullptr;
274void KTextEditor::ViewPrivate::toggleStatusBar()
278 bottomViewBar()->removePermanentBarWidget(m_statusBar);
280 m_statusBar =
nullptr;
281 Q_EMIT statusBarEnabledChanged(
this,
false);
286 m_statusBar =
new KateStatusBar(
this);
287 bottomViewBar()->addPermanentBarWidget(m_statusBar);
288 Q_EMIT statusBarEnabledChanged(
this,
true);
291void KTextEditor::ViewPrivate::setupLayout()
322 if (frameAroundContents) {
327 layout->
addItem(m_topSpacer, 1, 0, 1, 4);
330 layout->
addItem(m_leftSpacer, 2, 0, 1, 1);
333 layout->
addWidget(m_viewInternal->m_leftBorder, 2, 1, 1, 1);
336 layout->
addWidget(m_viewInternal, 2, 2, 1, 1);
339 layout->
addItem(m_rightSpacer, 2, 3, 1, 1);
342 layout->
addItem(m_bottomSpacer, 3, 0, 1, 4);
345 layout->
addWidget(m_viewInternal->m_lineScroll, 1, 4, 3, 1);
348 layout->
addWidget(m_viewInternal->m_columnScroll, 4, 0, 1, 4);
351 layout->
addWidget(m_viewInternal->m_dummy, 4, 4, 1, 1);
357 if (m_bottomViewBar->parentWidget() ==
this) {
358 layout->
addWidget(m_bottomViewBar, 6, 0, 1, 5);
367 m_viewInternal->m_lineScroll->setAutoFillBackground(
false);
370 m_viewInternal->m_columnScroll->setAutoFillBackground(
false);
377 layout->
addItem(m_topSpacer, 1, 0, 1, 5);
380 layout->
addItem(m_leftSpacer, 2, 0, 1, 1);
383 layout->
addWidget(m_viewInternal->m_leftBorder, 2, 1, 1, 1);
386 layout->
addWidget(m_viewInternal, 2, 2, 1, 1);
389 layout->
addWidget(m_viewInternal->m_lineScroll, 2, 3, 1, 1);
392 layout->
addItem(m_rightSpacer, 2, 4, 1, 1);
395 layout->
addWidget(m_viewInternal->m_columnScroll, 3, 1, 1, 2);
398 layout->
addWidget(m_viewInternal->m_dummy, 3, 3, 1, 1);
401 layout->
addItem(m_bottomSpacer, 4, 0, 1, 5);
407 if (m_bottomViewBar->parentWidget() ==
this) {
408 layout->
addWidget(m_bottomViewBar, 6, 0, 1, 5);
417 m_viewInternal->m_lineScroll->setAutoFillBackground(
true);
419 m_viewInternal->m_columnScroll->setBackgroundRole(
QPalette::Base);
420 m_viewInternal->m_columnScroll->setAutoFillBackground(
true);
424void KTextEditor::ViewPrivate::setupConnections()
426 connect(m_doc, &KTextEditor::DocumentPrivate::undoChanged,
this, &KTextEditor::ViewPrivate::slotUpdateUndo);
427 connect(m_doc, &KTextEditor::DocumentPrivate::highlightingModeChanged,
this, &KTextEditor::ViewPrivate::slotHlChanged);
428 connect(m_doc, &KTextEditor::DocumentPrivate::canceled,
this, &KTextEditor::ViewPrivate::slotSaveCanceled);
429 connect(m_viewInternal, &KateViewInternal::dropEventPass,
this, &KTextEditor::ViewPrivate::dropEventPass);
431 connect(m_doc, &KTextEditor::DocumentPrivate::annotationModelChanged, m_viewInternal->m_leftBorder, &KateIconBorder::annotationModelChanged);
434void KTextEditor::ViewPrivate::goToPreviousEditingPosition()
436 auto c = doc()->lastEditingPosition(KTextEditor::DocumentPrivate::Previous, cursorPosition());
438 setCursorPosition(c);
442void KTextEditor::ViewPrivate::goToNextEditingPosition()
444 auto c = doc()->lastEditingPosition(KTextEditor::DocumentPrivate::Next, cursorPosition());
446 setCursorPosition(c);
449void KTextEditor::ViewPrivate::setupActions()
454 m_toggleWriteLock =
nullptr;
457 a->
setWhatsThis(
i18n(
"Cut the selected text and move it to the clipboard"));
463 a->
setWhatsThis(
i18n(
"Use this command to copy the currently selected text to the system clipboard."));
465 m_clipboardHistory = a = ac->
addAction(QStringLiteral(
"clipboard_history_paste"),
this, [
this] {
466 ClipboardHistoryDialog chd(mainWindow()->
window(),
this);
479 m_swapWithClipboard = a = ac->
addAction(QStringLiteral(
"edit_swap_with_clipboard"),
this, SLOT(swapWithClipboard()));
481 a->
setWhatsThis(
i18n(
"Swap the selected text with the clipboard contents"));
483 m_screenshotSelection = a = ac->
addAction(QStringLiteral(
"text_screenshot_selection"),
this, &KTextEditor::ViewPrivate::screenshot);
486 if (!doc()->readOnly()) {
499 ac->
addAction(QStringLiteral(
"tools_scripts"), m_scriptActionMenu.get());
501 a = ac->
addAction(QStringLiteral(
"tools_apply_wordwrap"));
504 i18n(
"Use this to wrap the current line, or to reformat the selected lines as paragraph, "
505 "to fit the 'Wrap words at' setting in the configuration dialog.<br /><br />"
506 "This is a static word wrap, meaning the document is changed."));
509 a = ac->
addAction(QStringLiteral(
"tools_cleanIndent"));
512 i18n(
"Use this to clean the indentation of a selected block of text (only tabs/only spaces).<br /><br />"
513 "You can configure whether tabs should be honored and used or replaced with spaces, in the configuration dialog."));
516 a = ac->
addAction(QStringLiteral(
"tools_formatIndent"));
518 a->
setWhatsThis(
i18n(
"Use this to auto indent the current line or block of text to its proper indent level."));
521 a = ac->
addAction(QStringLiteral(
"tools_alignOn"));
524 i18n(
"This command aligns lines in the selected block or whole document on the column given by a regular expression "
525 "that you will be prompted for.<br /><br />"
526 "If you give an empty pattern it will align on the first non-blank character by default.<br />"
527 "If the pattern has a capture it will indent on the captured match.<br /><br />"
528 "<i>Examples</i>:<br />"
529 "With '-' it will insert spaces before the first '-' of each lines to align them all on the same column.<br />"
530 "With ':\\s+(.)' it will insert spaces before the first non-blank character that occurs after a colon to align "
531 "them all on the same column."));
534 a = ac->
addAction(QStringLiteral(
"tools_comment"));
538 i18n(
"This command comments out the current line or a selected block of text.<br /><br />"
539 "The characters for single/multiple line comments are defined within the language's highlighting."));
542 a = ac->
addAction(QStringLiteral(
"Previous Editing Line"));
543 a->
setText(
i18n(
"Go to Previous Editing Location"));
548 a = ac->
addAction(QStringLiteral(
"Next Editing Line"));
554 a = ac->
addAction(QStringLiteral(
"tools_uncomment"));
558 i18n(
"This command removes comments from the current line or a selected block of text.<br /><br />"
559 "The characters for single/multiple line comments are defined within the language's highlighting."));
562 a = ac->
addAction(QStringLiteral(
"tools_toggle_comment"));
571 ac->
addAction(QStringLiteral(
"tools_toggle_write_lock"), a);
576 m_forceRTL = checked;
580 ac->
addAction(QStringLiteral(
"force_rtl_direction"), a);
582 a = ac->
addAction(QStringLiteral(
"tools_uppercase"));
587 i18n(
"Convert the selection to uppercase, or the character to the "
588 "right of the cursor if no text is selected."));
591 a = ac->
addAction(QStringLiteral(
"tools_lowercase"));
596 i18n(
"Convert the selection to lowercase, or the character to the "
597 "right of the cursor if no text is selected."));
600 a = ac->
addAction(QStringLiteral(
"tools_capitalize"));
605 i18n(
"Capitalize the selection, or the word under the "
606 "cursor if no text is selected."));
609 a = ac->
addAction(QStringLiteral(
"tools_join_lines"));
614 a = ac->
addAction(QStringLiteral(
"tools_invoke_code_completion"));
616 a->
setWhatsThis(
i18n(
"Manually invoke command completion, usually by using a shortcut bound to this action."));
620 a = ac->
addAction(QStringLiteral(
"remove_trailing_spaces"));
623 doc()->removeAllTrailingSpaces();
626 for (
auto *action : {m_cut, m_paste, m_clipboardHistory, m_swapWithClipboard}) {
627 action->setEnabled(
false);
630 if (m_pasteSelection) {
631 m_pasteSelection->setEnabled(
false);
634 m_editUndo =
nullptr;
635 m_editRedo =
nullptr;
644 a = ac->
addAction(QStringLiteral(
"file_reload"));
652 a->
setWhatsThis(
i18n(
"Save the current document to disk, with a name of your choice."));
654 a =
new KateViewEncodingAction(m_doc,
this,
i18n(
"Save As with Encoding..."),
this,
true );
656 ac->
addAction(QStringLiteral(
"file_save_as_with_encoding"), a);
658 a = ac->
addAction(QStringLiteral(
"file_save_copy_as"));
665 a->
setWhatsThis(
i18n(
"This command opens a dialog and lets you choose a line that you want the cursor to move to."));
667 a = ac->
addAction(QStringLiteral(
"modified_line_up"));
673 a = ac->
addAction(QStringLiteral(
"modified_line_down"));
679 a = ac->
addAction(QStringLiteral(
"set_confdlg"));
685 m_modeAction =
new KateModeMenu(
i18n(
"&Mode"),
this);
686 ac->
addAction(QStringLiteral(
"tools_mode"), m_modeAction);
688 "Here you can choose which mode should be used for the current document. This will influence the highlighting and folding being used, for example."));
689 m_modeAction->updateMenu(m_doc);
691 KateHighlightingMenu *menu =
new KateHighlightingMenu(
i18n(
"&Highlighting"),
this);
692 ac->
addAction(QStringLiteral(
"tools_highlighting"), menu);
693 menu->
setWhatsThis(
i18n(
"Here you can choose how the current document should be highlighted."));
694 menu->updateMenu(m_doc);
696 KateViewSchemaAction *schemaMenu =
new KateViewSchemaAction(
i18n(
"&Editor Color Theme"),
this);
698 ac->
addAction(QStringLiteral(
"view_schemas"), schemaMenu);
699 schemaMenu->updateMenu(
this);
703 ac->
addAction(QStringLiteral(
"tools_indentation"), indentMenu);
713 a->
setWhatsThis(
i18n(
"If you have selected something within the current document, this will no longer be selected."));
715 a = ac->
addAction(QStringLiteral(
"view_inc_font_sizes"));
721 m_viewInternal->slotIncFontSizes();
724 a = ac->
addAction(QStringLiteral(
"view_dec_font_sizes"));
726 a->setText(
i18n(
"Shrink Font"));
728 a->setWhatsThis(
i18n(
"This decreases the display font size."));
730 m_viewInternal->slotDecFontSizes();
733 a = ac->
addAction(QStringLiteral(
"view_reset_font_sizes"));
735 a->setText(
i18n(
"Reset Font Size"));
737 a->setWhatsThis(
i18n(
"This resets the display font size."));
740 a = m_toggleBlockSelection =
new KToggleAction(
i18n(
"Bl&ock Selection Mode"),
this);
741 ac->
addAction(QStringLiteral(
"set_verticalSelect"), a);
743 a->setWhatsThis(
i18n(
"This command allows switching between the normal (line based) selection mode and the block selection mode."));
746 a = ac->
addAction(QStringLiteral(
"switch_next_input_mode"));
749 a->setWhatsThis(
i18n(
"Switch to the next input mode."));
753 ac->
addAction(QStringLiteral(
"set_insert"), a);
755 a->setWhatsThis(
i18n(
"Choose whether you want the text you type to be inserted or to overwrite existing text."));
759 a = m_toggleDynWrap = toggleAction =
new KToggleAction(
i18n(
"&Dynamic Word Wrap"),
this);
761 ac->
addAction(QStringLiteral(
"view_dynamic_word_wrap"), a);
763 i18n(
"If this option is checked, the text lines will be wrapped at the view border on the screen.<br /><br />"
764 "This is only a view option, meaning the document will not changed."));
767 a = m_setDynWrapIndicators =
new KSelectAction(
i18n(
"Dynamic Word Wrap Indicators"),
this);
768 ac->
addAction(QStringLiteral(
"dynamic_word_wrap_indicators"), a);
769 a->
setWhatsThis(
i18n(
"Choose when the Dynamic Word Wrap Indicators should be displayed"));
772 m_setDynWrapIndicators->setItems(list2);
773 m_setDynWrapIndicators->setEnabled(m_toggleDynWrap->isChecked());
776 ac->
addAction(QStringLiteral(
"view_static_word_wrap"), a);
777 a->
setWhatsThis(
i18n(
"If this option is checked, the text lines will be wrapped at the column defined in the editing properties."));
780 m_doc->setWordWrap(!m_doc->wordWrap());
784 a = toggleAction = m_toggleWWMarker =
new KToggleAction(
i18n(
"Show Static &Word Wrap Marker"),
this);
785 ac->
addAction(QStringLiteral(
"view_word_wrap_marker"), a);
787 i18n(
"Show/hide the Word Wrap Marker, a vertical line drawn at the word "
788 "wrap column as defined in the editing properties"));
791 a = toggleAction = m_toggleFoldingMarkers =
new KToggleAction(
i18n(
"Show Folding &Markers"),
this);
792 ac->
addAction(QStringLiteral(
"view_folding_markers"), a);
793 a->
setWhatsThis(
i18n(
"You can choose if the codefolding marks should be shown, if codefolding is possible."));
796 a = m_toggleIconBar = toggleAction =
new KToggleAction(
i18n(
"Show &Icon Border"),
this);
797 ac->
addAction(QStringLiteral(
"view_border"), a);
798 a->
setWhatsThis(
i18n(
"Show/hide the icon border.<br /><br />The icon border shows bookmark symbols, for instance."));
801 a = toggleAction = m_toggleLineNumbers =
new KToggleAction(
i18n(
"Show &Line Numbers"),
this);
802 ac->
addAction(QStringLiteral(
"view_line_numbers"), a);
803 a->
setWhatsThis(
i18n(
"Show/hide the line numbers on the left hand side of the view."));
806 a = m_toggleScrollBarMarks = toggleAction =
new KToggleAction(
i18n(
"Show Scroll&bar Marks"),
this);
807 ac->
addAction(QStringLiteral(
"view_scrollbar_marks"), a);
808 a->
setWhatsThis(
i18n(
"Show/hide the marks on the vertical scrollbar.<br /><br />The marks show bookmarks, for instance."));
811 a = m_toggleScrollBarMiniMap = toggleAction =
new KToggleAction(
i18n(
"Show Scrollbar Mini-Map"),
this);
812 ac->
addAction(QStringLiteral(
"view_scrollbar_minimap"), a);
813 a->
setWhatsThis(
i18n(
"Show/hide the mini-map on the vertical scrollbar.<br /><br />The mini-map shows an overview of the whole document."));
816 a = m_doc->autoReloadToggleAction();
817 ac->
addAction(QStringLiteral(
"view_auto_reload"), a);
825 a = m_toggleNPSpaces =
new KToggleAction(
i18n(
"Show Non-Printable Spaces"),
this);
826 ac->
addAction(QStringLiteral(
"view_non_printable_spaces"), a);
827 a->
setWhatsThis(
i18n(
"Show/hide bounding box around non-printable spaces"));
830 a = m_switchCmdLine = ac->
addAction(QStringLiteral(
"switch_to_cmd_line"));
833 a->setWhatsThis(
i18n(
"Show/hide the command line on the bottom of the view."));
838 ac->
addAction(QStringLiteral(
"view_input_modes"), am);
839 auto switchInputModeAction = ac->
action(QStringLiteral(
"switch_next_input_mode"));
842 for (
const auto &mode : m_viewInternal->m_inputModes) {
843 a =
new QAction(
mode->viewInputModeHuman(), m_inputModeActions);
845 a->setWhatsThis(
i18n(
"Activate/deactivate %1",
mode->viewInputModeHuman()));
846 const InputMode im =
mode->viewInputMode();
847 a->setData(
static_cast<int>(im));
848 a->setCheckable(
true);
849 if (im == m_config->inputMode()) {
856 ac->
addAction(QStringLiteral(
"set_eol"), a);
857 a->
setWhatsThis(
i18n(
"Choose which line endings should be used, when you save the document"));
859 i18nc(
"@item:inmenu End of Line",
"&Windows/DOS"),
860 i18nc(
"@item:inmenu End of Line",
"&Macintosh")};
861 m_setEndOfLine->setItems(list);
862 m_setEndOfLine->setCurrentItem(doc()->
config()->eol());
866 m_addBom->setChecked(doc()->
config()->
bom());
867 ac->
addAction(QStringLiteral(
"add_bom"), a);
868 a->
setWhatsThis(
i18n(
"Enable/disable adding of byte order marks for UTF-8/UTF-16 encoded files while saving"));
872 m_encodingAction =
new KateViewEncodingAction(m_doc,
this,
i18n(
"E&ncoding"),
this);
873 ac->
addAction(QStringLiteral(
"set_encoding"), m_encodingAction);
876 a->
setWhatsThis(
i18n(
"Look up the first occurrence of a piece of text or regular expression."));
879 a = ac->
addAction(QStringLiteral(
"edit_find_selected"));
882 a->setWhatsThis(
i18n(
"Finds next occurrence of selected text."));
885 a = ac->
addAction(QStringLiteral(
"edit_find_selected_backwards"));
888 a->setWhatsThis(
i18n(
"Finds previous occurrence of selected text."));
891 a = ac->
addAction(QStringLiteral(
"edit_find_multicursor_next_occurrence"));
892 a->
setText(
i18n(
"Find and Select Next Occurrence"));
894 a->setWhatsThis(
i18n(
"Finds next occurrence of the word under cursor and add it to selection."));
897 a = ac->
addAction(QStringLiteral(
"edit_skip_multicursor_current_occurrence"));
898 a->
setText(
i18n(
"Mark Currently Selected Occurrence as Skipped"));
900 a->setWhatsThis(
i18n(
"Marks the currently selected word as skipped."));
903 a = ac->
addAction(QStringLiteral(
"edit_find_multicursor_all_occurrences"));
904 a->
setText(
i18n(
"Find and Select All Occurrences"));
906 a->setWhatsThis(
i18n(
"Finds all occurrences of the word under cursor and selects them."));
914 a->
setWhatsThis(
i18n(
"Look up the previous occurrence of the search phrase."));
918 a->
setWhatsThis(
i18n(
"Look up a piece of text or regular expression and replace the result with some given text."));
920 a = ac->
addAction(QStringLiteral(
"edit_create_multi_cursor_from_sel"));
923 a->setWhatsThis(
i18n(
"Creates a cursor at the end of every line in selection."));
926 a = ac->
addAction(QStringLiteral(
"edit_create_multi_cursor_down"));
929 a->setWhatsThis(
i18n(
"Adds a caret in the line below the current caret."));
932 a = ac->
addAction(QStringLiteral(
"edit_create_multi_cursor_up"));
935 a->setWhatsThis(
i18n(
"Adds a caret in the line above the current caret."));
938 a = ac->
addAction(QStringLiteral(
"edit_toggle_camel_case_cursor"));
939 a->
setText(
i18n(
"Toggle Camel Case Cursor Movement"));
940 a->setWhatsThis(
i18n(
"Toggle between normal word movement and camel case cursor movement."));
943 a = ac->
addAction(QStringLiteral(
"edit_remove_cursors_from_empty_lines"));
944 a->
setText(
i18n(
"Remove Cursors from Empty Lines"));
945 a->setWhatsThis(
i18n(
"Remove cursors from empty lines"));
948 m_spell->createActions(ac);
949 m_toggleOnTheFlySpellCheck =
new KToggleAction(
i18n(
"Automatic Spell Checking"),
this);
950 m_toggleOnTheFlySpellCheck->setWhatsThis(
i18n(
"Enable/disable automatic spell checking"));
952 ac->
addAction(QStringLiteral(
"tools_toggle_automatic_spell_checking"), m_toggleOnTheFlySpellCheck);
955 a = ac->
addAction(QStringLiteral(
"tools_change_dictionary"));
957 a->setWhatsThis(
i18n(
"Change the dictionary that is used for spell checking."));
960 a = ac->
addAction(QStringLiteral(
"tools_clear_dictionary_ranges"));
962 a->setEnabled(
false);
963 a->setWhatsThis(
i18n(
"Remove all the separate dictionary ranges that were set for spell checking."));
967 m_copyHtmlAction = ac->
addAction(QStringLiteral(
"edit_copy_html"),
this, SLOT(exportHtmlToClipboard()));
969 m_copyHtmlAction->setText(
i18n(
"Copy as &HTML"));
970 m_copyHtmlAction->setWhatsThis(
i18n(
"Use this command to copy the currently selected text as HTML to the system clipboard."));
972 a = ac->
addAction(QStringLiteral(
"file_export_html"),
this, SLOT(exportHtmlToFile()));
974 a->setText(
i18n(
"E&xport as HTML..."));
976 i18n(
"This command allows you to export the current document"
977 " with all highlighting information into a HTML document."));
979 m_spellingMenu->createActions(ac);
981 m_bookmarks->createActions(ac);
983 slotSelectionChanged();
989 setupSpeechActions();
993 const auto actions = ac->
actions();
994 for (
QAction *action : actions) {
1001void KTextEditor::ViewPrivate::slotConfigDialog()
1007void KTextEditor::ViewPrivate::setupEditActions()
1018 m_editActions.push_back(a);
1020 a = ac->
addAction(QStringLiteral(
"select_char_left"));
1024 m_editActions.push_back(a);
1026 a = ac->
addAction(QStringLiteral(
"select_word_left"));
1030 m_editActions.push_back(a);
1032 a = ac->
addAction(QStringLiteral(
"word_right"));
1036 m_editActions.push_back(a);
1038 a = ac->
addAction(QStringLiteral(
"select_char_right"));
1042 m_editActions.push_back(a);
1044 a = ac->
addAction(QStringLiteral(
"select_word_right"));
1048 m_editActions.push_back(a);
1050 a = ac->
addAction(QStringLiteral(
"mark_selection"));
1052 a->
setWhatsThis(
i18n(
"Emulate the Emacs-like selection mode, where the beginning is marked and then the selection is continuously updated."));
1054 m_editActions.push_back(a);
1056 a = ac->
addAction(QStringLiteral(
"beginning_of_line"));
1060 m_editActions.push_back(a);
1062 a = ac->
addAction(QStringLiteral(
"beginning_of_document"));
1063 a->
setText(
i18n(
"Move to Beginning of Document"));
1066 m_editActions.push_back(a);
1068 a = ac->
addAction(QStringLiteral(
"select_beginning_of_line"));
1072 m_editActions.push_back(a);
1074 a = ac->
addAction(QStringLiteral(
"select_beginning_of_document"));
1075 a->
setText(
i18n(
"Select to Beginning of Document"));
1078 m_editActions.push_back(a);
1080 a = ac->
addAction(QStringLiteral(
"end_of_line"));
1084 m_editActions.push_back(a);
1086 a = ac->
addAction(QStringLiteral(
"end_of_document"));
1090 m_editActions.push_back(a);
1092 a = ac->
addAction(QStringLiteral(
"select_end_of_line"));
1096 m_editActions.push_back(a);
1098 a = ac->
addAction(QStringLiteral(
"select_end_of_document"));
1102 m_editActions.push_back(a);
1104 a = ac->
addAction(QStringLiteral(
"select_line_up"));
1108 m_editActions.push_back(a);
1110 a = ac->
addAction(QStringLiteral(
"scroll_line_up"));
1114 m_editActions.push_back(a);
1116 a = ac->
addAction(QStringLiteral(
"move_line_down"));
1120 m_editActions.push_back(a);
1122 a = ac->
addAction(QStringLiteral(
"move_line_up"));
1126 m_editActions.push_back(a);
1128 a = ac->
addAction(QStringLiteral(
"move_cursor_right"));
1132 m_editActions.push_back(a);
1134 a = ac->
addAction(QStringLiteral(
"move_cursor_left"));
1138 m_editActions.push_back(a);
1140 a = ac->
addAction(QStringLiteral(
"select_line_down"));
1144 m_editActions.push_back(a);
1146 a = ac->
addAction(QStringLiteral(
"scroll_line_down"));
1150 m_editActions.push_back(a);
1152 a = ac->
addAction(QStringLiteral(
"scroll_page_up"));
1156 m_editActions.push_back(a);
1158 a = ac->
addAction(QStringLiteral(
"select_page_up"));
1162 m_editActions.push_back(a);
1164 a = ac->
addAction(QStringLiteral(
"move_top_of_view"));
1168 m_editActions.push_back(a);
1170 a = ac->
addAction(QStringLiteral(
"select_top_of_view"));
1174 m_editActions.push_back(a);
1176 a = ac->
addAction(QStringLiteral(
"scroll_page_down"));
1180 m_editActions.push_back(a);
1182 a = ac->
addAction(QStringLiteral(
"select_page_down"));
1186 m_editActions.push_back(a);
1188 a = ac->
addAction(QStringLiteral(
"move_bottom_of_view"));
1192 m_editActions.push_back(a);
1194 a = ac->
addAction(QStringLiteral(
"select_bottom_of_view"));
1198 m_editActions.push_back(a);
1200 a = ac->
addAction(QStringLiteral(
"to_matching_bracket"));
1206 a = ac->
addAction(QStringLiteral(
"select_matching_bracket"));
1213 if (!doc()->readOnly()) {
1214 a = ac->
addAction(QStringLiteral(
"transpose_char"));
1217 m_editActions.push_back(a);
1219 a = ac->
addAction(QStringLiteral(
"transpose_word"));
1222 m_editActions.push_back(a);
1224 a = ac->
addAction(QStringLiteral(
"delete_line"));
1228 m_editActions.push_back(a);
1230 a = ac->
addAction(QStringLiteral(
"delete_word_left"));
1234 m_editActions.push_back(a);
1236 a = ac->
addAction(QStringLiteral(
"delete_word_right"));
1240 m_editActions.push_back(a);
1242 a = ac->
addAction(QStringLiteral(
"delete_next_character"));
1246 m_editActions.push_back(a);
1248 a = ac->
addAction(QStringLiteral(
"backspace"));
1254 m_editActions.push_back(a);
1256 a = ac->
addAction(QStringLiteral(
"insert_tabulator"));
1259 m_editActions.push_back(a);
1261 a = ac->
addAction(QStringLiteral(
"smart_newline"));
1263 a->
setWhatsThis(
i18n(
"Insert newline including leading characters of the current line which are not letters or numbers."));
1268 m_editActions.push_back(a);
1270 a = ac->
addAction(QStringLiteral(
"no_indent_newline"));
1271 a->
setText(
i18n(
"Insert a Non-Indented Newline"));
1272 a->
setWhatsThis(
i18n(
"Insert a new line without indentation, regardless of indentation settings."));
1277 m_editActions.push_back(a);
1279 a = ac->
addAction(QStringLiteral(
"newline_above"));
1280 a->
setText(
i18n(
"Insert a Newline Above Current Line"));
1281 a->
setWhatsThis(
i18n(
"Insert a new line above current line without modifying the current line."));
1286 m_editActions.push_back(a);
1288 a = ac->
addAction(QStringLiteral(
"newline_below"));
1289 a->
setText(
i18n(
"Insert a Newline Below Current Line"));
1290 a->
setWhatsThis(
i18n(
"Insert a new line below current line without modifying the current line."));
1295 m_editActions.push_back(a);
1297 a = ac->
addAction(QStringLiteral(
"tools_indent"));
1301 i18n(
"Use this to indent a selected block of text.<br /><br />"
1302 "You can configure whether tabs should be honored and used or replaced with spaces, in the configuration dialog."));
1306 a = ac->
addAction(QStringLiteral(
"tools_unindent"));
1321void KTextEditor::ViewPrivate::setupCodeFolding()
1326 a = ac->
addAction(QStringLiteral(
"folding_toplevel"));
1330 a = ac->
addAction(QStringLiteral(
"folding_expandtoplevel"));
1334 a = ac->
addAction(QStringLiteral(
"folding_toggle_current"));
1338 a = ac->
addAction(QStringLiteral(
"folding_toggle_in_current"));
1343void KTextEditor::ViewPrivate::setupSpeechActions()
1348 a->
setText(
i18n(
"Say current selection or document"));
1357 a = ac->
addAction(QStringLiteral(
"tools_speech_stop"));
1363 a = ac->
addAction(QStringLiteral(
"tools_speech_pause"));
1369 a = ac->
addAction(QStringLiteral(
"tools_speech_resume"));
1376void KTextEditor::ViewPrivate::slotFoldToplevelNodes()
1378 for (
int line = 0; line < doc()->lines(); ++line) {
1379 if (textFolding().isLineVisible(line)) {
1385void KTextEditor::ViewPrivate::slotExpandToplevelNodes()
1387 const auto topLevelRanges(textFolding().foldingRangesForParentRange());
1388 for (
const auto &range : topLevelRanges) {
1389 textFolding().unfoldRange(range.first);
1393void KTextEditor::ViewPrivate::slotToggleFolding()
1395 int line = cursorPosition().line();
1396 bool actionDone =
false;
1397 while (!actionDone && (line > -1)) {
1398 actionDone = unfoldLine(line);
1400 actionDone = foldLine(line--).isValid();
1405void KTextEditor::ViewPrivate::slotToggleFoldingsInRange()
1407 int line = cursorPosition().line();
1408 while (!toggleFoldingsInRange(line) && (line > -1)) {
1415 KTextEditor::Range foldingRange = doc()->buffer().computeFoldingRangeForStartLine(line);
1416 if (!foldingRange.
isValid()) {
1417 return foldingRange;
1422 if (!m_doc->buffer().isFoldingStartingOnLine(line).second && !foldingRange.
onSingleLine()) {
1423 const int adjustedLine = foldingRange.
end().
line() - 1;
1431 auto folds = textFolding().foldingRangesStartingOnLine(line);
1432 for (
int i = 0; i < folds.size(); ++i) {
1434 if (fold == foldingRange) {
1435 return foldingRange;
1445 return foldingRange;
1448bool KTextEditor::ViewPrivate::unfoldLine(
int line)
1450 bool actionDone =
false;
1455 auto startingRanges = textFolding().foldingRangesStartingOnLine(line);
1456 for (
int i = 0; i < startingRanges.size() && !actionDone; ++i) {
1458 setCursorPosition(textFolding().foldingRange(startingRanges[i].first).
start());
1460 actionDone |= textFolding().unfoldRange(startingRanges[i].first);
1465 setCursorPosition(currentCursor);
1471bool KTextEditor::ViewPrivate::toggleFoldingOfLine(
int line)
1473 bool actionDone = unfoldLine(line);
1475 actionDone = foldLine(line).isValid();
1481bool KTextEditor::ViewPrivate::toggleFoldingsInRange(
int line)
1483 KTextEditor::Range foldingRange = doc()->buffer().computeFoldingRangeForStartLine(line);
1484 if (!foldingRange.
isValid()) {
1489 bool actionDone =
false;
1494 actionDone |= unfoldLine(line);
1498 for (
int ln = foldingRange.
start().
line() + 1; ln < foldingRange.
end().
line(); ++ln) {
1499 actionDone |= unfoldLine(ln);
1504 setCursorPosition(currentCursor);
1510 for (
int ln = foldingRange.
start().
line() + 1; ln < foldingRange.
end().
line(); ++ln) {
1514 ln = qMax(ln, fr.
end().
line() - 1);
1523 actionDone |= foldLine(line).isValid();
1532 return currentInputMode()->viewMode();
1535QString KTextEditor::ViewPrivate::viewModeHuman()
const
1537 QString currentMode = currentInputMode()->viewModeHuman();
1540 if (!doc()->isReadWrite()) {
1541 currentMode =
i18n(
"(R/O) %1", currentMode);
1550 return currentInputMode()->viewInputMode();
1553QString KTextEditor::ViewPrivate::viewInputModeHuman()
const
1555 return currentInputMode()->viewInputModeHuman();
1560 if (currentInputMode()->viewInputMode() == mode) {
1566 clearSecondaryCursors();
1569 m_viewInternal->m_currentInputMode->deactivate();
1570 m_viewInternal->m_currentInputMode = m_viewInternal->m_inputModes[mode].get();
1571 m_viewInternal->m_currentInputMode->activate();
1574 if (rememberInConfig) {
1579 const auto inputModeActions = m_inputModeActions->actions();
1580 for (
QAction *action : inputModeActions) {
1581 if (
static_cast<InputMode
>(action->data().toInt()) == mode) {
1582 action->setChecked(
true);
1588 Q_EMIT viewInputModeChanged(
this, mode);
1589 Q_EMIT viewModeChanged(
this, viewMode());
1592void KTextEditor::ViewPrivate::slotDocumentAboutToReload()
1594 if (doc()->isAutoReload()) {
1595 const int lastVisibleLine = m_viewInternal->endLine();
1596 const int currentLine = cursorPosition().line();
1597 m_gotoBottomAfterReload = (lastVisibleLine == currentLine) && (currentLine == doc()->lastLine());
1598 if (!m_gotoBottomAfterReload) {
1600 const int firstVisibleLine = 1 + lastVisibleLine - m_viewInternal->linesDisplayed();
1601 const int newLine = qBound(firstVisibleLine, currentLine, lastVisibleLine);
1605 m_gotoBottomAfterReload =
false;
1609void KTextEditor::ViewPrivate::slotDocumentReloaded()
1611 if (m_gotoBottomAfterReload) {
1616void KTextEditor::ViewPrivate::slotGotFocus()
1619 currentInputMode()->gotFocus();
1625 if (m_viewInternal->m_lineScroll->isVisible()) {
1626 m_viewInternal->m_lineScroll->update();
1629 if (m_viewInternal->m_columnScroll->isVisible()) {
1630 m_viewInternal->m_columnScroll->update();
1636void KTextEditor::ViewPrivate::slotLostFocus()
1639 currentInputMode()->lostFocus();
1645 if (m_viewInternal->m_lineScroll->isVisible()) {
1646 m_viewInternal->m_lineScroll->update();
1649 if (m_viewInternal->m_columnScroll->isVisible()) {
1650 m_viewInternal->m_columnScroll->update();
1653 if (doc()->
config()->autoSave() && doc()->
config()->autoSaveOnFocusOut() && doc()->isModified() && doc()->url().isLocalFile()) {
1654 doc()->documentSave();
1660void KTextEditor::ViewPrivate::setDynWrapIndicators(
int mode)
1665bool KTextEditor::ViewPrivate::isOverwriteMode()
const
1667 return doc()->config()->ovr();
1670void KTextEditor::ViewPrivate::reloadFile()
1673 doc()->documentReload();
1676void KTextEditor::ViewPrivate::slotReadWriteChanged()
1678 if (m_toggleWriteLock) {
1679 m_toggleWriteLock->setChecked(!doc()->isReadWrite());
1682 m_cut->setEnabled(doc()->isReadWrite() && (selection() || m_config->smartCopyCut()));
1683 m_paste->setEnabled(doc()->isReadWrite());
1684 if (m_pasteSelection) {
1685 m_pasteSelection->setEnabled(doc()->isReadWrite());
1687 m_swapWithClipboard->setEnabled(doc()->isReadWrite());
1688 m_setEndOfLine->setEnabled(doc()->isReadWrite());
1690 static const auto l = {QStringLiteral(
"edit_replace"),
1691 QStringLiteral(
"tools_spelling"),
1692 QStringLiteral(
"tools_indent"),
1693 QStringLiteral(
"tools_unindent"),
1694 QStringLiteral(
"tools_cleanIndent"),
1695 QStringLiteral(
"tools_formatIndet"),
1696 QStringLiteral(
"tools_alignOn"),
1697 QStringLiteral(
"tools_comment"),
1698 QStringLiteral(
"tools_uncomment"),
1699 QStringLiteral(
"tools_toggle_comment"),
1700 QStringLiteral(
"tools_uppercase"),
1701 QStringLiteral(
"tools_lowercase"),
1702 QStringLiteral(
"tools_capitalize"),
1703 QStringLiteral(
"tools_join_lines"),
1704 QStringLiteral(
"tools_apply_wordwrap"),
1705 QStringLiteral(
"tools_spelling_from_cursor"),
1706 QStringLiteral(
"tools_spelling_selection")};
1708 for (
const auto &action : l) {
1709 QAction *a = actionCollection()->action(action);
1716 currentInputMode()->readWriteChanged(doc()->isReadWrite());
1719 Q_EMIT viewModeChanged(
this, viewMode());
1720 Q_EMIT viewInputModeChanged(
this, viewInputMode());
1723void KTextEditor::ViewPrivate::toggleCamelCaseCursor()
1725 const auto enabled = doc()->config()->camelCursor();
1726 doc()->config()->setCamelCursor(!enabled);
1736 doc()->postMessage(m);
1739void KTextEditor::ViewPrivate::slotUpdateUndo()
1741 if (doc()->readOnly()) {
1745 m_editUndo->setEnabled(doc()->isReadWrite() && doc()->undoCount() > 0);
1746 m_editRedo->setEnabled(doc()->isReadWrite() && doc()->redoCount() > 0);
1749bool KTextEditor::ViewPrivate::setCursorPositionInternal(
const KTextEditor::Cursor position, uint tabwidth,
bool calledExternally)
1751 if (position.
line() < 0 || position.
line() >= doc()->lines()) {
1760 for (; z < line_str.
length() && z < position.
column(); z++) {
1762 x += tabwidth - (x % tabwidth);
1768 if (blockSelection()) {
1769 if (z < position.
column()) {
1770 x += position.
column() - z;
1782void KTextEditor::ViewPrivate::toggleInsert()
1784 doc()->config()->setOvr(!doc()->
config()->ovr());
1785 m_toggleInsert->setChecked(isOverwriteMode());
1788 if (isOverwriteMode()) {
1789 clearSecondaryCursors();
1792 Q_EMIT viewModeChanged(
this, viewMode());
1793 Q_EMIT viewInputModeChanged(
this, viewInputMode());
1796void KTextEditor::ViewPrivate::slotSaveCanceled(
const QString &error)
1798 if (!
error.isEmpty()) {
1803void KTextEditor::ViewPrivate::gotoLine()
1805 gotoBar()->updateData();
1806 bottomViewBar()->showBarWidget(gotoBar());
1809void KTextEditor::ViewPrivate::changeDictionary()
1811 dictionaryBar()->updateData();
1812 bottomViewBar()->showBarWidget(dictionaryBar());
1815void KTextEditor::ViewPrivate::joinLines()
1817 int first = selectionRange().start().line();
1818 int last = selectionRange().end().line();
1820 if (first == last) {
1821 first = cursorPosition().line();
1824 doc()->joinLines(first, last);
1833 setCursorPositionInternal(savedPosition);
1836 const int scroll = config.
readEntry(
"ScrollLine", -1);
1837 if (scroll >= 0 && scroll < doc()->lines() && savedPosition.line() < doc()->lines()) {
1841 m_config->setDynWordWrap(config.
readEntry(
"Dynamic Word Wrap",
false));
1845 applyFoldingState();
1847 m_forceRTL = config.
readEntry(
"Force RTL Direction",
false);
1848 m_forceRTLDirection->setChecked(m_forceRTL);
1850 for (
const auto &mode : m_viewInternal->m_inputModes) {
1851 mode->readSessionConfig(config);
1861 const auto cursor = cursorPosition();
1863 config.
writeEntry(
"CursorLine", cursor.line());
1864 config.
writeEntry(
"CursorColumn", cursor.column());
1868 const int scrollLine = firstDisplayedLineInternal(LineType::RealLine);
1869 if (scrollLine > 0 && scrollLine != cursor.line()) {
1874 if (m_config->isSet(KateViewConfig::DynamicWordWrap)) {
1875 config.
writeEntry(
"Dynamic Word Wrap", m_config->dynWordWrap());
1880 if (!m_savedFoldingState.object().value(
QLatin1String(
"ranges")).toArray().isEmpty()) {
1886 config.
writeEntry(
"Force RTL Direction", m_forceRTL);
1889 for (
const auto &mode : m_viewInternal->m_inputModes) {
1890 mode->writeSessionConfig(config);
1894int KTextEditor::ViewPrivate::getEol()
const
1896 return doc()->config()->eol();
1899QMenu *KTextEditor::ViewPrivate::getEolMenu()
1901 return m_setEndOfLine->menu();
1904void KTextEditor::ViewPrivate::setEol(
int eol)
1906 if (!doc()->isReadWrite()) {
1910 if (m_updatingDocumentConfig) {
1914 if (eol != doc()->config()->eol()) {
1915 doc()->setModified(
true);
1916 doc()->config()->setEol(eol);
1920void KTextEditor::ViewPrivate::setAddBom(
bool enabled)
1922 if (!doc()->isReadWrite()) {
1926 if (m_updatingDocumentConfig) {
1930 doc()->config()->setBom(enabled);
1931 doc()->bomSetByUser();
1934void KTextEditor::ViewPrivate::setIconBorder(
bool enable)
1936 config()->setValue(KateViewConfig::ShowIconBar, enable);
1939void KTextEditor::ViewPrivate::toggleIconBorder()
1941 config()->setValue(KateViewConfig::ShowIconBar, !config()->iconBar());
1944void KTextEditor::ViewPrivate::setLineNumbersOn(
bool enable)
1946 config()->setValue(KateViewConfig::ShowLineNumbers, enable);
1949void KTextEditor::ViewPrivate::toggleLineNumbersOn()
1951 config()->setValue(KateViewConfig::ShowLineNumbers, !config()->lineNumbers());
1954void KTextEditor::ViewPrivate::setScrollBarMarks(
bool enable)
1956 config()->setValue(KateViewConfig::ShowScrollBarMarks, enable);
1959void KTextEditor::ViewPrivate::toggleScrollBarMarks()
1961 config()->setValue(KateViewConfig::ShowScrollBarMarks, !config()->scrollBarMarks());
1964void KTextEditor::ViewPrivate::setScrollBarMiniMap(
bool enable)
1966 config()->setValue(KateViewConfig::ShowScrollBarMiniMap, enable);
1969void KTextEditor::ViewPrivate::toggleScrollBarMiniMap()
1971 config()->setValue(KateViewConfig::ShowScrollBarMiniMap, !config()->scrollBarMiniMap());
1974void KTextEditor::ViewPrivate::setScrollBarMiniMapAll(
bool enable)
1976 config()->setValue(KateViewConfig::ShowScrollBarMiniMapAll, enable);
1979void KTextEditor::ViewPrivate::toggleScrollBarMiniMapAll()
1981 config()->setValue(KateViewConfig::ShowScrollBarMiniMapAll, !config()->scrollBarMiniMapAll());
1984void KTextEditor::ViewPrivate::setScrollBarMiniMapWidth(
int width)
1986 config()->setValue(KateViewConfig::ScrollBarMiniMapWidth, width);
1989void KTextEditor::ViewPrivate::toggleDynWordWrap()
1991 config()->setDynWordWrap(!config()->dynWordWrap());
1994void KTextEditor::ViewPrivate::toggleWWMarker()
1996 m_renderer->config()->setWordWrapMarker(!m_renderer->config()->wordWrapMarker());
1999void KTextEditor::ViewPrivate::toggleNPSpaces()
2001 m_renderer->setShowNonPrintableSpaces(!m_renderer->showNonPrintableSpaces());
2002 m_viewInternal->update();
2005void KTextEditor::ViewPrivate::toggleWordCount(
bool on)
2007 config()->setShowWordCount(on);
2010void KTextEditor::ViewPrivate::setFoldingMarkersOn(
bool enable)
2012 config()->setValue(KateViewConfig::ShowFoldingBar, enable);
2015void KTextEditor::ViewPrivate::toggleFoldingMarkers()
2017 config()->setValue(KateViewConfig::ShowFoldingBar, !config()->foldingBar());
2020bool KTextEditor::ViewPrivate::iconBorder()
2022 return m_viewInternal->m_leftBorder->iconBorderOn();
2025bool KTextEditor::ViewPrivate::lineNumbersOn()
2027 return m_viewInternal->m_leftBorder->lineNumbersOn();
2030bool KTextEditor::ViewPrivate::scrollBarMarks()
2032 return m_viewInternal->m_lineScroll->showMarks();
2035bool KTextEditor::ViewPrivate::scrollBarMiniMap()
2037 return m_viewInternal->m_lineScroll->showMiniMap();
2040int KTextEditor::ViewPrivate::dynWrapIndicators()
2042 return m_viewInternal->m_leftBorder->dynWrapIndicators();
2045bool KTextEditor::ViewPrivate::foldingMarkersOn()
2047 return m_viewInternal->m_leftBorder->foldingMarkersOn();
2050bool KTextEditor::ViewPrivate::forceRTLDirection()
const
2055void KTextEditor::ViewPrivate::toggleWriteLock()
2057 doc()->setReadWrite(!doc()->isReadWrite());
2062 m_viewInternal->registerTextHintProvider(provider);
2067 m_viewInternal->unregisterTextHintProvider(provider);
2070void KTextEditor::ViewPrivate::setTextHintDelay(
int delay)
2072 m_viewInternal->setTextHintDelay(delay);
2075int KTextEditor::ViewPrivate::textHintDelay()
const
2077 return m_viewInternal->textHintDelay();
2081void KTextEditor::ViewPrivate::find()
2083 currentInputMode()->find();
2087void KTextEditor::ViewPrivate::findSelectedForwards()
2089 currentInputMode()->findSelectedForwards();
2093void KTextEditor::ViewPrivate::findSelectedBackwards()
2095 currentInputMode()->findSelectedBackwards();
2098void KTextEditor::ViewPrivate::skipCurrentOccurunceSelection()
2100 if (isMulticursorNotAllowed()) {
2103 m_skipCurrentSelection =
true;
2106void KTextEditor::ViewPrivate::findNextOccurunceAndSelect()
2108 if (isMulticursorNotAllowed()) {
2112 const auto text = selection() ? doc()->text(selectionRange()) :
QString();
2114 const auto selection = doc()->wordRangeAt(cursorPosition());
2116 setSelection(selection);
2117 setCursorPosition(selection.end());
2120 for (
auto &c : m_secondaryCursors) {
2121 const auto range = doc()->wordRangeAt(c.cursor());
2122 if (!c.range && !c.anchor.isValid()) {
2123 c.anchor = range.
start();
2124 c.range.reset(newSecondarySelectionRange(range));
2130 }
else if (!m_rangesForHighlights.empty()) {
2135 const auto lastSelectionRange = selectionRange();
2140 searchRange.setRange(doc()->documentRange().
start(), lastSelectionRange.end());
2141 matches = doc()->searchText(searchRange, text, KTextEditor::Default);
2149 auto it = std::find_if(m_secondaryCursors.begin(), m_secondaryCursors.end(), [&](
const SecondaryCursor &c) {
2150 return c.range && c.range->toRange() == matches.constFirst();
2153 if (it != m_secondaryCursors.end()) {
2154 m_secondaryCursors.erase(it);
2160 setCursorPosition(matches.
constFirst().end());
2164 if (!m_skipCurrentSelection) {
2165 PlainSecondaryCursor c;
2166 c.pos = lastSelectionRange.end();
2167 c.range = lastSelectionRange;
2169 addSecondaryCursorsWithSelection({c});
2172 m_skipCurrentSelection =
false;
2175void KTextEditor::ViewPrivate::findAllOccuruncesAndSelect()
2177 if (isMulticursorNotAllowed()) {
2181 QString text = selection() ? doc()->text(selectionRange()) :
QString();
2183 const auto selection = doc()->wordRangeAt(cursorPosition());
2184 setSelection(selection);
2185 setCursorPosition(selection.end());
2187 text = doc()->text(selection);
2189 for (
auto &c : m_secondaryCursors) {
2190 const auto range = doc()->wordRangeAt(c.cursor());
2191 if (!c.range && !c.anchor.isValid()) {
2192 c.anchor = range.
start();
2193 c.range.reset(newSecondarySelectionRange(range));
2204 matches = doc()->searchText(searchRange, text, KTextEditor::Default);
2208 if (matches.
constFirst() != selectionRange()) {
2209 PlainSecondaryCursor c;
2214 searchRange.setStart(matches.
constFirst().end());
2216 }
while (matches.
first().isValid());
2219 if (!resultRanges.
empty()) {
2223 clearSecondaryCursors();
2224 addSecondaryCursorsWithSelection(resultRanges);
2228void KTextEditor::ViewPrivate::replace()
2230 currentInputMode()->findReplace();
2234void KTextEditor::ViewPrivate::findNext()
2236 currentInputMode()->findNext();
2240void KTextEditor::ViewPrivate::findPrevious()
2242 currentInputMode()->findPrevious();
2245void KTextEditor::ViewPrivate::showSearchWrappedHint(
bool isReverseSearch)
2248 const QIcon icon = isReverseSearch ?
QIcon::fromTheme(QStringLiteral(
"go-up-search")) :
QIcon::fromTheme(QStringLiteral(
"go-down-search"));
2250 if (!m_wrappedMessage || m_isLastSearchReversed != isReverseSearch) {
2251 m_isLastSearchReversed = isReverseSearch;
2253 m_wrappedMessage->setIcon(icon);
2255 m_wrappedMessage->setAutoHide(2000);
2257 m_wrappedMessage->setView(
this);
2258 this->doc()->postMessage(m_wrappedMessage);
2262void KTextEditor::ViewPrivate::createMultiCursorsFromSelection()
2264 if (!selection() || selectionRange().isEmpty()) {
2269 clearSecondaryCursors();
2271 const auto range = selectionRange();
2274 const auto end = range.
end().
line() > doc()->lines() ? doc()->lines() : range.
end().
line();
2275 const auto currentLine = cursorPosition().line();
2276 setCursorPosition({currentLine, doc()->lineLength(currentLine)});
2277 for (
int line =
start; line <=
end; ++line) {
2278 if (line != currentLine) {
2279 cursorsToAdd.
push_back({line, doc()->lineLength(line)});
2284 setSecondaryCursors(cursorsToAdd);
2287void KTextEditor::ViewPrivate::removeCursorsFromEmptyLines()
2289 if (!m_secondaryCursors.empty()) {
2290 std::vector<KTextEditor::Cursor> cursorsToRemove;
2291 for (
const auto &c : m_secondaryCursors) {
2292 auto cursor = c.cursor();
2293 if (doc()->lineLength(cursor.line()) == 0) {
2294 cursorsToRemove.push_back(cursor);
2297 removeSecondaryCursors(cursorsToRemove);
2301void KTextEditor::ViewPrivate::slotSelectionChanged()
2303 m_copy->setEnabled(selection() || m_config->smartCopyCut());
2304 m_deSelect->setEnabled(selection());
2305 m_copyHtmlAction->setEnabled(selection());
2308 selectionChangedForHighlights();
2310 if (doc()->readOnly()) {
2314 m_cut->setEnabled(selection() || m_config->smartCopyCut());
2315 m_screenshotSelection->setVisible(selection());
2316 m_screenshotSelection->setEnabled(selection());
2320void KTextEditor::ViewPrivate::switchToCmdLine()
2322 currentInputMode()->activateCommandLine();
2330KateRendererConfig *KTextEditor::ViewPrivate::rendererConfig()
2332 return m_renderer->config();
2335void KTextEditor::ViewPrivate::updateConfig()
2342 if (m_hasWrap != config()->dynWordWrap()) {
2343 m_hasWrap = config()->dynWordWrap();
2345 m_viewInternal->dynWrapChanged();
2347 m_setDynWrapIndicators->setEnabled(config()->dynWordWrap());
2348 m_toggleDynWrap->setChecked(config()->dynWordWrap());
2351 m_viewInternal->m_leftBorder->setDynWrapIndicators(config()->dynWordWrapIndicators());
2352 m_setDynWrapIndicators->setCurrentItem(config()->dynWordWrapIndicators());
2355 m_viewInternal->m_leftBorder->setLineNumbersOn(config()->lineNumbers());
2356 m_toggleLineNumbers->setChecked(config()->lineNumbers());
2359 m_viewInternal->m_leftBorder->setIconBorderOn(config()->iconBar());
2360 m_toggleIconBar->setChecked(config()->iconBar());
2363 m_viewInternal->m_lineScroll->setShowMarks(config()->scrollBarMarks());
2364 m_toggleScrollBarMarks->setChecked(config()->scrollBarMarks());
2367 m_viewInternal->m_lineScroll->setShowMiniMap(config()->scrollBarMiniMap());
2368 m_toggleScrollBarMiniMap->setChecked(config()->scrollBarMiniMap());
2371 m_viewInternal->m_lineScroll->setMiniMapAll(config()->scrollBarMiniMapAll());
2375 m_viewInternal->m_lineScroll->setMiniMapWidth(config()->scrollBarMiniMapWidth());
2378 m_toggleBlockSelection->setChecked(blockSelection());
2379 m_toggleInsert->setChecked(isOverwriteMode());
2381 updateFoldingConfig();
2384 m_bookmarks->setSorting((KateBookmarks::Sorting)config()->bookmarkSort());
2386 m_viewInternal->setAutoCenterLines(config()->autoCenterLines());
2388 for (
const auto &input : m_viewInternal->m_inputModes) {
2389 input->updateConfig();
2392 setInputMode(config()->inputMode(),
false );
2394 reflectOnTheFlySpellCheckStatus(doc()->isOnTheFlySpellCheckingEnabled());
2397 bool wc = config()->wordCompletion();
2406 bool kc = config()->keywordCompletion();
2415 m_cut->setEnabled(doc()->isReadWrite() && (selection() || m_config->smartCopyCut()));
2416 m_copy->setEnabled(selection() || m_config->smartCopyCut());
2418 m_accessibilityEnabled = m_config->value(KateViewConfig::EnableAccessibility).toBool();
2422 m_statusBar->updateStatus();
2426 m_viewInternal->cache()->clear();
2430 Q_EMIT configChanged(
this);
2433void KTextEditor::ViewPrivate::updateDocumentConfig()
2439 m_updatingDocumentConfig =
true;
2441 m_setEndOfLine->setCurrentItem(doc()->config()->eol());
2443 m_addBom->setChecked(doc()->config()->
bom());
2445 m_updatingDocumentConfig =
false;
2448 ensureCursorColumnValid();
2451 m_renderer->setTabWidth(doc()->config()->tabWidth());
2452 m_renderer->setIndentWidth(doc()->config()->indentationWidth());
2455 m_viewInternal->cache()->clear();
2460void KTextEditor::ViewPrivate::updateRendererConfig()
2466 m_toggleWWMarker->setChecked(m_renderer->config()->wordWrapMarker());
2468 m_viewInternal->updateBracketMarkAttributes();
2469 m_viewInternal->updateBracketMarks();
2472 m_viewInternal->cache()->clear();
2474 m_viewInternal->updateView(
true);
2477 m_viewInternal->m_leftBorder->updateFont();
2478 m_viewInternal->m_leftBorder->repaint();
2480 m_viewInternal->m_lineScroll->queuePixmapUpdate();
2482 currentInputMode()->updateRendererConfig();
2486 Q_EMIT configChanged(
this);
2489void KTextEditor::ViewPrivate::updateFoldingConfig()
2492 m_viewInternal->m_leftBorder->setFoldingMarkersOn(config()->foldingBar());
2493 m_toggleFoldingMarkers->setChecked(config()->foldingBar());
2495 if (hasCommentInFirstLine(m_doc)) {
2496 if (config()->foldFirstLine() && !m_autoFoldedFirstLine) {
2498 m_autoFoldedFirstLine =
true;
2499 }
else if (!config()->foldFirstLine() && m_autoFoldedFirstLine) {
2501 m_autoFoldedFirstLine =
false;
2504 m_autoFoldedFirstLine =
false;
2510 QStringLiteral(
"folding_toplevel")
2511 , QStringLiteral(
"folding_expandtoplevel")
2512 , QStringLiteral(
"folding_toggle_current")
2513 , QStringLiteral(
"folding_toggle_in_current")
2517 for (
int z = 0; z < l.
size(); z++)
2518 if ((a = actionCollection()->action(l[z].toAscii().constData()))) {
2519 a->
setEnabled(doc()->highlight() && doc()->highlight()->allowsFolding());
2524void KTextEditor::ViewPrivate::ensureCursorColumnValid()
2531 if (!blockSelection() && wrapCursor() && (!c.
isValid() || c.
column() > doc()->lineLength(c.
line()))) {
2532 c.
setColumn(doc()->lineLength(cursorPosition().line()));
2533 setCursorPosition(c);
2538void KTextEditor::ViewPrivate::editStart()
2540 m_viewInternal->editStart();
2543void KTextEditor::ViewPrivate::editEnd(
int editTagLineStart,
int editTagLineEnd,
bool tagFrom)
2545 m_viewInternal->editEnd(editTagLineStart, editTagLineEnd, tagFrom);
2546 textFolding().editEnd(editTagLineStart, editTagLineEnd, [
this](
int line) {
2547 return m_doc->buffer().isFoldingStartingOnLine(line).first;
2553 m_viewInternal->editSetCursor(cursor);
2560 return m_viewInternal->tagLine(virtualCursor);
2565 return m_viewInternal->tagRange(range, realLines);
2570 return m_viewInternal->tagLines(lineRange.
start(), lineRange.
end(), realLines);
2575 return m_viewInternal->tagLines(
start, end, realCursors);
2578void KTextEditor::ViewPrivate::tagAll()
2580 m_viewInternal->tagAll();
2583void KTextEditor::ViewPrivate::clear()
2585 m_viewInternal->clear();
2588void KTextEditor::ViewPrivate::repaintText(
bool paintOnlyDirty)
2590 if (paintOnlyDirty) {
2591 m_viewInternal->updateDirty();
2593 m_viewInternal->update();
2597void KTextEditor::ViewPrivate::updateView(
bool changed)
2600 m_viewInternal->updateView(changed);
2601 m_viewInternal->m_leftBorder->update();
2606void KTextEditor::ViewPrivate::slotHlChanged()
2608 KateHighlighting *hl = doc()->highlight();
2609 bool ok(!hl->getCommentStart(0).
isEmpty() || !hl->getCommentSingleLineStart(0).
isEmpty());
2611 if (actionCollection()->action(QStringLiteral(
"tools_comment"))) {
2612 actionCollection()->action(QStringLiteral(
"tools_comment"))->setEnabled(ok);
2615 if (actionCollection()->action(QStringLiteral(
"tools_uncomment"))) {
2616 actionCollection()->action(QStringLiteral(
"tools_uncomment"))->setEnabled(ok);
2619 if (actionCollection()->action(QStringLiteral(
"tools_toggle_comment"))) {
2620 actionCollection()->action(QStringLiteral(
"tools_toggle_comment"))->setEnabled(ok);
2624 updateFoldingConfig();
2627int KTextEditor::ViewPrivate::virtualCursorColumn()
const
2629 return doc()->toVirtualColumn(m_viewInternal->cursorPosition());
2632void KTextEditor::ViewPrivate::notifyMousePositionChanged(
const KTextEditor::Cursor newPosition)
2634 Q_EMIT mousePositionChanged(
this, newPosition);
2642 if (selection == m_selection) {
2653 tagSelection(oldSelection);
2657 Q_EMIT selectionChanged(
this);
2663bool KTextEditor::ViewPrivate::clearSelection()
2665 return clearSelection(
true);
2668bool KTextEditor::ViewPrivate::clearSelection(
bool redraw,
bool finishedChangingSelection)
2682 tagSelection(oldSelection);
2688 if (finishedChangingSelection) {
2689 Q_EMIT selectionChanged(
this);
2692 m_viewInternal->m_selChangedByUser =
false;
2697bool KTextEditor::ViewPrivate::selection()
const
2699 if (!wrapCursor()) {
2702 return m_selection.toRange().isValid();
2706QString KTextEditor::ViewPrivate::selectionText()
const
2709 return doc()->text(m_selection, blockSelect);
2713 for (
const auto &c : m_secondaryCursors) {
2718 ranges.
push_back(m_selection.toRange());
2719 std::sort(ranges.
begin(), ranges.
end());
2722 text.
reserve(ranges.
size() * m_selection.toRange().columnWidth());
2723 for (
int i = 0; i < ranges.
size() - 1; ++i) {
2724 text += doc()->text(ranges[i]) + QStringLiteral(
"\n");
2726 text += doc()->text(ranges.
last());
2731bool KTextEditor::ViewPrivate::removeSelectedText()
2733 if (!hasSelections()) {
2739 bool removed =
false;
2742 completionWidget()->setIgnoreBufferSignals(
true);
2743 for (
auto &c : m_secondaryCursors) {
2746 doc()->removeText(c.range->toRange());
2750 completionWidget()->setIgnoreBufferSignals(
false);
2758 doc()->removeText(selection, blockSelect);
2763 int selectionColumn = qMin(doc()->toVirtualColumn(selection.
start()), doc()->toVirtualColumn(selection.
end()));
2767 setSelection(newSelection);
2768 setCursorPositionInternal(newSelection.
start());
2770 clearSecondarySelections();
2771 clearSelection(
false);
2777bool KTextEditor::ViewPrivate::selectAll()
2779 clearSecondaryCursors();
2780 setBlockSelection(
false);
2787 setSelection(doc()->documentRange());
2788 m_viewInternal->moveCursorToSelectionEdge(
false);
2789 m_viewInternal->updateMicroFocus();
2796 if ((!blockSelect) && (ret.
column() < 0)) {
2801 return cursor.
line() >= m_selection.start().line() && ret.
line() <= m_selection.end().line() && ret.
column() >= m_selection.start().column()
2802 && ret.
column() <= m_selection.end().column();
2804 return m_selection.toRange().contains(cursor) || m_selection.end() == cursor;
2808bool KTextEditor::ViewPrivate::lineSelected(
int line)
2810 return !blockSelect && m_selection.toRange().containsLine(line);
2815 return (!blockSelect)
2816 && (lineEndPos.
line() > m_selection.start().line()
2817 || (lineEndPos.
line() == m_selection.start().line() && (m_selection.start().column() < lineEndPos.
column() || lineEndPos.
column() == -1)))
2818 && (lineEndPos.
line() < m_selection.end().line()
2819 || (lineEndPos.
line() == m_selection.end().line() && (lineEndPos.
column() <= m_selection.end().column() && lineEndPos.
column() != -1)));
2822bool KTextEditor::ViewPrivate::lineHasSelected(
int line)
2824 return selection() && m_selection.toRange().
containsLine(line);
2827bool KTextEditor::ViewPrivate::lineIsSelection(
int line)
2829 return (line == m_selection.start().line() && line == m_selection.end().line());
2835 if (oldSelection.
start().
line() == -1) {
2839 tagLines(m_selection,
true);
2841 }
else if (blockSelection()
2842 && (oldSelection.
start().
column() != m_selection.start().column() || oldSelection.
end().
column() != m_selection.end().column())) {
2844 tagLines(m_selection,
true);
2845 tagLines(oldSelection,
true);
2848 if (oldSelection.
start() != m_selection.
start()) {
2852 if (oldSelection.
end() != m_selection.end()) {
2859 tagLines(oldSelection,
true);
2865 setSelection(doc()->wordRangeAt(cursor));
2870 int line = cursor.
line();
2871 if (line + 1 >= doc()->lines()) {
2878void KTextEditor::ViewPrivate::cut()
2880 if (!selection() && !m_config->smartCopyCut()) {
2886 m_markedSelection =
false;
2890 selectLine(cursorPosition());
2892 removeSelectedText();
2895void KTextEditor::ViewPrivate::copy()
2901 if (!m_config->smartCopyCut()) {
2904 text = doc()->line(cursorPosition().line()) +
QLatin1Char(
'\n');
2905 m_viewInternal->moveEdge(KateViewInternal::left,
false);
2907 text = selectionText();
2910 if (!m_secondaryCursors.empty()) {
2912 for (
const auto &c : m_secondaryCursors) {
2917 ranges.
push_back(m_selection.toRange());
2918 std::sort(ranges.
begin(), ranges.
end());
2920 for (
auto range : ranges) {
2921 texts.
append(doc()->text(range));
2926 if (m_markedSelection) {
2928 m_markedSelection =
false;
2936void KTextEditor::ViewPrivate::screenshot()
2942 ScreenshotDialog d(selectionRange(),
this);
2943 d.renderScreenshot(m_renderer);
2947void KTextEditor::ViewPrivate::pasteSelection()
2949 m_temporaryAutomaticInvocationDisabled =
true;
2951 m_temporaryAutomaticInvocationDisabled =
false;
2954void KTextEditor::ViewPrivate::swapWithClipboard()
2956 m_temporaryAutomaticInvocationDisabled =
true;
2965 doc()->paste(
this, text);
2967 m_temporaryAutomaticInvocationDisabled =
false;
2970void KTextEditor::ViewPrivate::applyWordWrap()
2972 int first = selectionRange().start().line();
2973 int last = selectionRange().end().line();
2975 if (first == last) {
2977 first = cursorPosition().line();
2981 doc()->wrapParagraph(first, last);
2988bool KTextEditor::ViewPrivate::blockSelection()
const
2993bool KTextEditor::ViewPrivate::setBlockSelection(
bool on)
2995 if (on != blockSelect) {
3000 const bool hadSelection = clearSelection(
false,
false);
3002 setSelection(oldSelection);
3004 m_toggleBlockSelection->setChecked(blockSelection());
3008 ensureCursorColumnValid();
3010 if (!hadSelection) {
3015 Q_EMIT selectionChanged(
this);
3022bool KTextEditor::ViewPrivate::toggleBlockSelection()
3025 clearSecondaryCursors();
3027 m_toggleBlockSelection->setChecked(!blockSelect);
3028 return setBlockSelection(!blockSelect);
3031bool KTextEditor::ViewPrivate::wrapCursor()
const
3033 return !blockSelection();
3040 Q_EMIT textInserted(view, position, text);
3046 if (templateString.
isEmpty()) {
3051 if (!doc()->isReadWrite()) {
3057 doc()->setActiveTemplateHandler(
nullptr);
3058 doc()->setActiveTemplateHandler(
new KateTemplateHandler(
this, c, templateString, script, doc()->undoManager()));
3064 return tagLines(range.
start(), range.
end(), realRange);
3067void KTextEditor::ViewPrivate::deactivateEditActions()
3069 for (
QAction *action :
std::as_const(m_editActions)) {
3070 action->setEnabled(
false);
3074void KTextEditor::ViewPrivate::activateEditActions()
3076 for (
QAction *action :
std::as_const(m_editActions)) {
3077 action->setEnabled(
true);
3081bool KTextEditor::ViewPrivate::mouseTrackingEnabled()
const
3087bool KTextEditor::ViewPrivate::setMouseTrackingEnabled(
bool)
3093bool KTextEditor::ViewPrivate::isMulticursorNotAllowed()
const
3100 auto primaryCursor = cursorPosition();
3101 const bool overlapsOrOnPrimary = pos == primaryCursor || (selection() && selectionRange().
contains(pos));
3102 if (overlapsOrOnPrimary && m_secondaryCursors.empty()) {
3106 }
else if (overlapsOrOnPrimary) {
3110 auto &last = m_secondaryCursors.back();
3111 setCursorPosition(last.cursor());
3113 setSelection(last.range->toRange());
3114 Q_ASSERT(last.anchor.isValid());
3115 m_viewInternal->m_selectAnchor = last.anchor;
3117 m_secondaryCursors.pop_back();
3124 if (removeSecondaryCursors({pos},
true)) {
3132 setCursorPosition(pos);
3133 KTextEditor::ViewPrivate::PlainSecondaryCursor p;
3134 p.pos = primaryCursor;
3137 addSecondaryCursorsWithSelection({p});
3142 clearSecondaryCursors();
3144 if (positions.
isEmpty() || isMulticursorNotAllowed()) {
3148 const auto totalLines = doc()->lines();
3149 for (
auto p : positions) {
3150 if (p != cursorPosition() && p.line() < totalLines) {
3153 m_secondaryCursors.push_back(std::move(c));
3161void KTextEditor::ViewPrivate::clearSecondarySelections()
3163 for (
auto &c : m_secondaryCursors) {
3169void KTextEditor::ViewPrivate::clearSecondaryCursors()
3171 if (m_secondaryCursors.empty()) {
3174 for (
const auto &c : m_secondaryCursors) {
3175 tagLine(c.cursor());
3177 m_secondaryCursors.clear();
3178 m_viewInternal->updateDirty();
3181const std::vector<KTextEditor::ViewPrivate::SecondaryCursor> &KTextEditor::ViewPrivate::secondaryCursors()
const
3183 return m_secondaryCursors;
3189 cursors.
reserve(m_secondaryCursors.size());
3190 std::transform(m_secondaryCursors.begin(), m_secondaryCursors.end(), std::back_inserter(cursors), [](
const SecondaryCursor &c) {
3192 return PlainSecondaryCursor{c.cursor(), c.range->toRange()};
3194 return PlainSecondaryCursor{c.cursor(), KTextEditor::Range::invalid()};
3199bool KTextEditor::ViewPrivate::removeSecondaryCursors(
const std::vector<KTextEditor::Cursor> &cursorsToRemove,
bool removeIfOverlapsSelection)
3201 Q_ASSERT(std::is_sorted(cursorsToRemove.begin(), cursorsToRemove.end()));
3205 if (removeIfOverlapsSelection) {
3206 m_secondaryCursors.
erase(std::remove_if(m_secondaryCursors.begin(),
3207 m_secondaryCursors.end(),
3208 [&](
const SecondaryCursor &c) {
3209 auto it = std::find_if(cursorsToRemove.begin(), cursorsToRemove.end(), [&c](KTextEditor::Cursor pos) {
3210 return c.cursor() == pos || (c.range && c.range->contains(pos));
3212 const bool match = it != cursorsToRemove.end();
3218 m_secondaryCursors.end());
3220 m_secondaryCursors.erase(std::remove_if(m_secondaryCursors.begin(),
3221 m_secondaryCursors.end(),
3222 [&](
const SecondaryCursor &c) {
3223 auto it = std::find_if(cursorsToRemove.begin(), cursorsToRemove.end(), [&c](
KTextEditor::Cursor pos) {
3224 return c.cursor() == pos;
3226 const bool match = it != cursorsToRemove.end();
3232 m_secondaryCursors.end());
3235 for (
const auto &c : linesToTag) {
3236 tagLine(m_viewInternal->toVirtualCursor(c));
3238 return !linesToTag.
empty();
3240 for (
auto cur : cursorsToRemove) {
3241 auto &sec = m_secondaryCursors;
3242 auto it = std::find_if(sec.begin(), sec.end(), [cur](
const SecondaryCursor &c) {
3243 return c.cursor() == cur;
3245 if (it != sec.end()) {
3247 m_secondaryCursors.erase(it);
3248 tagLine(m_viewInternal->toVirtualCursor(cur));
3253 m_viewInternal->updateDirty();
3255 m_viewInternal->paintCursor();
3257 return !linesToTag.
empty();
3262void KTextEditor::ViewPrivate::ensureUniqueCursors(
bool matchLine)
3264 if (m_secondaryCursors.empty()) {
3268 std::vector<SecondaryCursor>::iterator it;
3270 auto matchLine = [](
const SecondaryCursor &l,
const SecondaryCursor &r) {
3271 return l.cursor().line() == r.cursor().line();
3273 it = std::unique(m_secondaryCursors.begin(), m_secondaryCursors.end(), matchLine);
3275 it = std::unique(m_secondaryCursors.begin(), m_secondaryCursors.end());
3277 if (it != m_secondaryCursors.end()) {
3278 m_secondaryCursors.erase(it, m_secondaryCursors.end());
3282 const int ln = cursorPosition().line();
3283 m_secondaryCursors.erase(std::remove_if(m_secondaryCursors.begin(),
3284 m_secondaryCursors.end(),
3285 [ln](
const SecondaryCursor &c) {
3286 return c.cursor().line() == ln;
3288 m_secondaryCursors.end());
3290 const auto cp = cursorPosition();
3291 m_secondaryCursors.erase(std::remove_if(m_secondaryCursors.begin(),
3292 m_secondaryCursors.end(),
3293 [cp](
const SecondaryCursor &c) {
3294 return c.cursor() == cp;
3296 m_secondaryCursors.end());
3302 if (isMulticursorNotAllowed() || cursorsWithSelection.
isEmpty()) {
3306 for (
const auto &c : cursorsWithSelection) {
3308 if (c.pos == cursorPosition()) {
3313 if (c.range.isValid()) {
3314 n.range.reset(newSecondarySelectionRange(c.range));
3315 n.anchor = c.range.start() == c.pos ? c.range.end() : c.range.start();
3317 m_secondaryCursors.push_back(std::move(n));
3331 selAttr->setBackground(color);
3333 range->setZDepth(-999999.);
3334 range->setAttribute(selAttr);
3338bool KTextEditor::ViewPrivate::hasSelections()
const
3342 return std::any_of(m_secondaryCursors.cbegin(), m_secondaryCursors.cend(), [](
const SecondaryCursor &c) {
3343 return c.range && !c.range->isEmpty();
3347void KTextEditor::ViewPrivate::addSecondaryCursorDown()
3350 const auto &secondary = secondaryCursors();
3351 if (!secondary.empty()) {
3352 last = secondary.back().cursor();
3353 last = std::max(cursorPosition(), last);
3359 auto nextRange = m_viewInternal->nextLayout(last);
3360 if (!nextRange.isValid()) {
3363 auto primaryCursorLineLayout = m_viewInternal->currentLayout(cursorPosition());
3364 if (!primaryCursorLineLayout.isValid()) {
3368 int x = renderer()->cursorToX(primaryCursorLineLayout, cursorPosition().column(), !wrapCursor());
3369 auto next = renderer()->xToCursor(nextRange, x, !wrapCursor());
3370 addSecondaryCursor(next);
3373void KTextEditor::ViewPrivate::addSecondaryCursorUp()
3376 const auto &secondary = secondaryCursors();
3377 if (!secondary.empty()) {
3378 last = secondary.front().cursor();
3379 last = std::min(cursorPosition(), last);
3381 if (last.
line() == 0) {
3384 auto nextRange = m_viewInternal->previousLayout(last);
3385 if (!nextRange.isValid()) {
3389 auto primaryCursorLineLayout = m_viewInternal->currentLayout(cursorPosition());
3390 if (!primaryCursorLineLayout.isValid()) {
3394 int x = renderer()->cursorToX(primaryCursorLineLayout, cursorPosition().column(), !wrapCursor());
3395 auto next = renderer()->xToCursor(nextRange, x, !wrapCursor());
3396 addSecondaryCursor(next);
3402 ret.
reserve(m_secondaryCursors.size() + 1);
3403 ret << cursorPosition();
3404 std::transform(m_secondaryCursors.begin(), m_secondaryCursors.end(), std::back_inserter(ret), [](
const SecondaryCursor &c) {
3417 ret.
reserve(m_secondaryCursors.size() + 1);
3418 ret << selectionRange();
3419 std::transform(m_secondaryCursors.begin(), m_secondaryCursors.end(), std::back_inserter(ret), [](
const SecondaryCursor &c) {
3421 qWarning() <<
"selectionRanges(): Unexpected null selection range, please fix";
3422 return KTextEditor::Range::invalid();
3424 return c.range->toRange();
3431 if (isMulticursorNotAllowed()) {
3432 qWarning() <<
"setCursors failed: Multicursors not allowed because one of the following is true"
3433 <<
", blockSelection: " << blockSelection() <<
", overwriteMode: " << isOverwriteMode()
3438 clearSecondaryCursors();
3439 if (cursorPositions.
empty()) {
3443 const auto primary = cursorPositions.
front();
3447 setCursorPosition(primary);
3449 setSecondaryCursors(cursorPositions);
3454 if (isMulticursorNotAllowed()) {
3455 qWarning() <<
"setSelections failed: Multicursors not allowed because one of the following is true"
3456 <<
", blockSelection: " << blockSelection() <<
", overwriteMode: " << isOverwriteMode()
3461 clearSecondaryCursors();
3463 if (selectionRanges.
isEmpty()) {
3467 auto first = selectionRanges.
front();
3468 setCursorPosition(first.end());
3469 setSelection(first);
3471 if (selectionRanges.
size() == 1) {
3475 const auto docRange = doc()->documentRange();
3476 for (
auto it = selectionRanges.
begin() + 1; it != selectionRanges.
end(); ++it) {
3479 if (c == cursorPosition() || !r.
isValid() || r.
isEmpty() || !docRange.contains(r)) {
3485 n.range.reset(newSecondarySelectionRange(r));
3486 n.anchor = r.
start();
3487 m_secondaryCursors.push_back(std::move(n));
3489 m_viewInternal->mergeSelections();
3495void KTextEditor::ViewPrivate::sortCursors()
3497 std::sort(m_secondaryCursors.begin(), m_secondaryCursors.end());
3498 ensureUniqueCursors();
3501void KTextEditor::ViewPrivate::paintCursors()
3503 if (m_viewInternal->m_cursorTimer.isActive()) {
3507 renderer()->setDrawCaret(
true);
3509 m_viewInternal->paintCursor();
3512bool KTextEditor::ViewPrivate::isCompletionActive()
const
3514 return completionWidget()->isCompletionActive();
3519 if (!m_completionWidget) {
3523 return m_completionWidget;
3528 completionWidget()->startCompletion(word, model);
3531void KTextEditor::ViewPrivate::startCompletion(
const Range &word,
3533 KTextEditor::CodeCompletionModel::InvocationType invocationType)
3535 completionWidget()->startCompletion(word, models, invocationType);
3538void KTextEditor::ViewPrivate::abortCompletion()
3540 completionWidget()->abortCompletion();
3543void KTextEditor::ViewPrivate::forceCompletion()
3545 completionWidget()->execute();
3550 completionWidget()->registerCompletionModel(model);
3555 completionWidget()->unregisterCompletionModel(model);
3560 return completionWidget()->isCompletionModelRegistered(model);
3565 return completionWidget()->codeCompletionModels();
3568bool KTextEditor::ViewPrivate::isAutomaticInvocationEnabled()
const
3570 return !m_temporaryAutomaticInvocationDisabled && m_config->automaticCompletionInvocation();
3573void KTextEditor::ViewPrivate::setAutomaticInvocationEnabled(
bool enabled)
3575 config()->setValue(KateViewConfig::AutomaticCompletionInvocation, enabled);
3580 Q_EMIT completionExecuted(
this, position, model, index);
3583void KTextEditor::ViewPrivate::sendCompletionAborted()
3585 Q_EMIT completionAborted(
this);
3588void KTextEditor::ViewPrivate::paste(
const QString *textToPaste)
3590 const int cursorCount = m_secondaryCursors.size() + 1;
3592 if (cursorCount == multicursorClipboard.size() && !textToPaste) {
3593 if (doc()->multiPaste(
this, multicursorClipboard)) {
3596 }
else if (!textToPaste && cursorCount > 1) {
3602 for (
int i = 0; i < cursorCount; ++i) {
3607 if (doc()->multiPaste(
this, texts)) {
3612 m_temporaryAutomaticInvocationDisabled =
true;
3614 m_temporaryAutomaticInvocationDisabled =
false;
3619 return setCursorPositionInternal(position, 1,
true);
3624 return m_viewInternal->cursorPosition();
3629 return KTextEditor::Cursor(m_viewInternal->cursorPosition().line(), virtualCursorColumn());
3635 const QPoint pt = m_viewInternal->cursorToCoordinate(cursor,
true,
false);
3636 return pt ==
QPoint(-1, -1) ? pt : m_viewInternal->mapToParent(pt);
3642 return m_viewInternal->coordinatesToCursor(m_viewInternal->mapFromParent(coords),
false);
3645QPoint KTextEditor::ViewPrivate::cursorPositionCoordinates()
const
3648 const QPoint pt = m_viewInternal->cursorCoordinates(
false);
3649 return pt ==
QPoint(-1, -1) ? pt : m_viewInternal->mapToParent(pt);
3654 m_viewInternal->scrollPos(cursor,
false,
true,
false);
3657void KTextEditor::ViewPrivate::setHorizontalScrollPositionInternal(
int x)
3659 m_viewInternal->scrollColumns(x);
3664 return m_viewInternal->maxStartPos(
true);
3667int KTextEditor::ViewPrivate::firstDisplayedLineInternal(LineType lineType)
const
3669 if (lineType == RealLine) {
3670 return m_textFolding.visibleLineToLine(m_viewInternal->startLine());
3672 return m_viewInternal->startLine();
3676int KTextEditor::ViewPrivate::lastDisplayedLineInternal(LineType lineType)
const
3678 if (lineType == RealLine) {
3679 return m_textFolding.visibleLineToLine(m_viewInternal->endLine());
3681 return m_viewInternal->endLine();
3685QRect KTextEditor::ViewPrivate::textAreaRectInternal()
const
3687 const auto sourceRect = m_viewInternal->rect();
3688 const auto topLeft = m_viewInternal->mapTo(
this, sourceRect.topLeft());
3689 const auto bottomRight = m_viewInternal->mapTo(
this, sourceRect.bottomRight());
3690 return {topLeft, bottomRight};
3695 return setCursorPositionInternal(position, doc()->config()->tabWidth(),
true);
3698QScrollBar *KTextEditor::ViewPrivate::verticalScrollBar()
const
3700 return m_viewInternal->m_lineScroll;
3703QScrollBar *KTextEditor::ViewPrivate::horizontalScrollBar()
const
3705 return m_viewInternal->m_columnScroll;
3708bool KTextEditor::ViewPrivate::isLineRTL(
int line)
const
3710 const QString s = doc()->line(line);
3712 int line = cursorPosition().line();
3714 const int count = doc()->lines();
3715 for (
int i = 1; i < count; ++i) {
3716 const QString ln = doc()->line(i);
3723 int line = cursorPosition().line();
3724 for (; line >= 0; --line) {
3725 const QString s = doc()->line(line);
3740 KateLineLayout *thisLine = m_viewInternal->cache()->line(pos.
line());
3741 return thisLine && thisLine->isValid() ? thisLine->layout() :
nullptr;
3744void KTextEditor::ViewPrivate::indent()
3748 doc()->indent(r, 1);
3751void KTextEditor::ViewPrivate::unIndent()
3755 doc()->indent(r, -1);
3758void KTextEditor::ViewPrivate::cleanIndent()
3762 doc()->indent(r, 0);
3765void KTextEditor::ViewPrivate::formatIndent()
3768 const int line = cursorPosition().line();
3771 formatRange = selectionRange();
3774 doc()->align(
this, formatRange);
3778void KTextEditor::ViewPrivate::align()
3783void KTextEditor::ViewPrivate::alignOn()
3788 range = doc()->documentRange();
3790 range = selectionRange();
3797 doc()->alignOn(range, pattern, this->blockSelection());
3800void KTextEditor::ViewPrivate::comment()
3803 doc()->comment(
this, cursorPosition().line(), cursorPosition().column(), DocumentPrivate::Comment);
3807void KTextEditor::ViewPrivate::uncomment()
3809 doc()->comment(
this, cursorPosition().line(), cursorPosition().column(), DocumentPrivate::UnComment);
3812void KTextEditor::ViewPrivate::toggleComment()
3815 doc()->comment(
this, cursorPosition().line(), cursorPosition().column(), DocumentPrivate::ToggleComment);
3819void KTextEditor::ViewPrivate::uppercase()
3821 doc()->transform(
this, cursorPosition(), KTextEditor::DocumentPrivate::Uppercase);
3824void KTextEditor::ViewPrivate::killLine()
3826 std::vector<int> linesToRemove;
3827 if (m_selection.isEmpty()) {
3829 linesToRemove.reserve(m_secondaryCursors.size() + 1);
3830 for (
const auto &c : m_secondaryCursors) {
3831 linesToRemove.push_back(c.pos->
line());
3834 linesToRemove.push_back(cursorPosition().line());
3836 linesToRemove.reserve(m_secondaryCursors.size() + 1);
3837 for (
const auto &c : m_secondaryCursors) {
3838 const auto &range = c.range;
3842 for (
int line = range->
end().
line(); line >= range->
start().
line(); line--) {
3843 linesToRemove.push_back(line);
3848 for (
int line = m_selection.end().line(), endLine = m_selection.start().line(); line >= endLine; line--) {
3849 linesToRemove.push_back(line);
3853 std::sort(linesToRemove.begin(), linesToRemove.end(), std::greater{});
3854 linesToRemove.erase(std::unique(linesToRemove.begin(), linesToRemove.end()), linesToRemove.end());
3857 std::for_each(linesToRemove.begin(), linesToRemove.end(), [
this](
int line) {
3858 doc()->removeLine(line);
3862 ensureUniqueCursors();
3865void KTextEditor::ViewPrivate::lowercase()
3867 doc()->transform(
this, cursorPosition(), KTextEditor::DocumentPrivate::Lowercase);
3870void KTextEditor::ViewPrivate::capitalize()
3873 doc()->transform(
this, cursorPosition(), KTextEditor::DocumentPrivate::Lowercase);
3874 doc()->transform(
this, cursorPosition(), KTextEditor::DocumentPrivate::Capitalize);
3878void KTextEditor::ViewPrivate::keyReturn()
3880 doc()->newLine(
this);
3881 m_viewInternal->iconBorder()->updateForCursorLineChange();
3882 m_viewInternal->updateView();
3885void KTextEditor::ViewPrivate::smartNewline()
3888 const int ln = cursor.
line();
3899 doc()->editWrapLine(ln, cursor.
column());
3903 m_viewInternal->updateView();
3906void KTextEditor::ViewPrivate::noIndentNewline()
3908 doc()->newLine(
this, KTextEditor::DocumentPrivate::NoIndent);
3909 m_viewInternal->iconBorder()->updateForCursorLineChange();
3910 m_viewInternal->updateView();
3913void KTextEditor::ViewPrivate::newLineAbove()
3915 doc()->newLine(
this, KTextEditor::DocumentPrivate::Indent, KTextEditor::DocumentPrivate::Above);
3916 m_viewInternal->iconBorder()->updateForCursorLineChange();
3917 m_viewInternal->updateView();
3920void KTextEditor::ViewPrivate::newLineBelow()
3922 doc()->newLine(
this, KTextEditor::DocumentPrivate::Indent, KTextEditor::DocumentPrivate::Below);
3923 m_viewInternal->iconBorder()->updateForCursorLineChange();
3924 m_viewInternal->updateView();
3927void KTextEditor::ViewPrivate::backspace()
3930 doc()->backspace(
this);
3933void KTextEditor::ViewPrivate::insertTab()
3935 doc()->insertTab(
this, cursorPosition());
3938void KTextEditor::ViewPrivate::deleteWordLeft()
3941 m_viewInternal->wordPrev(
true);
3943 removeSelectedText();
3946 ensureUniqueCursors();
3948 m_viewInternal->tagRange(selection,
true);
3949 m_viewInternal->updateDirty();
3952void KTextEditor::ViewPrivate::keyDelete()
3960 selection = {selection.
start(),
end};
3961 doc()->removeText(selection, blockSelect);
3968 if (removeSelectedText()) {
3972 for (
const auto &c : m_secondaryCursors) {
3974 doc()->removeText(c.range->toRange());
3976 doc()->del(
this, c.cursor());
3981 doc()->del(
this, cursorPosition());
3983 ensureUniqueCursors();
3986void KTextEditor::ViewPrivate::deleteWordRight()
3989 m_viewInternal->wordNext(
true);
3991 removeSelectedText();
3994 ensureUniqueCursors();
3996 m_viewInternal->tagRange(selection,
true);
3997 m_viewInternal->updateDirty();
4000void KTextEditor::ViewPrivate::transpose()
4003 for (
const auto &c : m_secondaryCursors) {
4004 doc()->transpose(c.cursor());
4006 doc()->transpose(cursorPosition());
4010void KTextEditor::ViewPrivate::transposeWord()
4019 for (
const QChar &character : word) {
4020 if (character.isLetterOrNumber()) {
4027 if (wordIsInvalid(doc()->text(firstWord))) {
4031 setCursorPosition(firstWord.
end());
4036 setCursorPosition(firstWord.
start());
4038 curPos = cursorPosition();
4041 setCursorPosition(originalCurPos);
4046 if (wordIsInvalid(doc()->wordAt(curPos))) {
4047 setCursorPosition(originalCurPos);
4052 doc()->swapTextRanges(firstWord, secondWord);
4056 const int offsetFromWordEnd = firstWord.
end().
column() - originalCurPos.
column();
4060void KTextEditor::ViewPrivate::cursorLeft()
4062 if (selection() && !config()->persistentSelection() && !m_markedSelection) {
4063 if (isLineRTL(cursorPosition().line())) {
4064 m_viewInternal->updateCursor(selectionRange().
end());
4067 m_viewInternal->updateCursor(selectionRange().
start());
4071 for (
const auto &c : m_secondaryCursors) {
4075 const bool rtl = isLineRTL(c.cursor().
line());
4078 clearSecondarySelections();
4080 if (isLineRTL(cursorPosition().line())) {
4081 m_viewInternal->cursorNextChar(m_markedSelection);
4083 m_viewInternal->cursorPrevChar(m_markedSelection);
4088void KTextEditor::ViewPrivate::shiftCursorLeft()
4090 if (isLineRTL(cursorPosition().line())) {
4091 m_viewInternal->cursorNextChar(
true);
4093 m_viewInternal->cursorPrevChar(
true);
4097void KTextEditor::ViewPrivate::cursorRight()
4099 if (selection() && !config()->persistentSelection() && !m_markedSelection) {
4100 if (isLineRTL(cursorPosition().line())) {
4101 m_viewInternal->updateCursor(selectionRange().
start());
4104 m_viewInternal->updateCursor(selectionRange().
end());
4108 for (
const auto &c : m_secondaryCursors) {
4112 const bool rtl = doc()->line(c.cursor().
line()).isRightToLeft();
4115 clearSecondarySelections();
4117 if (isLineRTL(cursorPosition().line())) {
4118 m_viewInternal->cursorPrevChar(m_markedSelection);
4120 m_viewInternal->cursorNextChar(m_markedSelection);
4125void KTextEditor::ViewPrivate::shiftCursorRight()
4127 if (isLineRTL(cursorPosition().line())) {
4128 m_viewInternal->cursorPrevChar(
true);
4130 m_viewInternal->cursorNextChar(
true);
4134void KTextEditor::ViewPrivate::wordLeft()
4136 if (isLineRTL(cursorPosition().line())) {
4137 m_viewInternal->wordNext(m_markedSelection);
4139 m_viewInternal->wordPrev(m_markedSelection);
4143void KTextEditor::ViewPrivate::shiftWordLeft()
4145 if (isLineRTL(cursorPosition().line())) {
4146 m_viewInternal->wordNext(
true);
4148 m_viewInternal->wordPrev(
true);
4152void KTextEditor::ViewPrivate::wordRight()
4154 if (isLineRTL(cursorPosition().line())) {
4155 m_viewInternal->wordPrev(m_markedSelection);
4157 m_viewInternal->wordNext(m_markedSelection);
4161void KTextEditor::ViewPrivate::shiftWordRight()
4163 if (isLineRTL(cursorPosition().line())) {
4164 m_viewInternal->wordPrev(
true);
4166 m_viewInternal->wordNext(
true);
4170void KTextEditor::ViewPrivate::markSelection()
4172 if (m_markedSelection && selection()) {
4174 clearSecondarySelections();
4176 m_markedSelection = !m_markedSelection;
4180void KTextEditor::ViewPrivate::home()
4182 m_viewInternal->home(m_markedSelection);
4185void KTextEditor::ViewPrivate::shiftHome()
4187 m_viewInternal->home(
true);
4190void KTextEditor::ViewPrivate::end()
4192 m_viewInternal->end(m_markedSelection);
4195void KTextEditor::ViewPrivate::shiftEnd()
4197 m_viewInternal->end(
true);
4200void KTextEditor::ViewPrivate::up()
4202 m_viewInternal->cursorUp(m_markedSelection);
4205void KTextEditor::ViewPrivate::shiftUp()
4207 m_viewInternal->cursorUp(
true);
4210void KTextEditor::ViewPrivate::down()
4212 m_viewInternal->cursorDown(m_markedSelection);
4215void KTextEditor::ViewPrivate::shiftDown()
4217 m_viewInternal->cursorDown(
true);
4220void KTextEditor::ViewPrivate::scrollUp()
4222 m_viewInternal->scrollUp();
4225void KTextEditor::ViewPrivate::scrollDown()
4227 m_viewInternal->scrollDown();
4230void KTextEditor::ViewPrivate::topOfView()
4232 m_viewInternal->topOfView();
4235void KTextEditor::ViewPrivate::shiftTopOfView()
4237 m_viewInternal->topOfView(
true);
4240void KTextEditor::ViewPrivate::bottomOfView()
4242 m_viewInternal->bottomOfView();
4245void KTextEditor::ViewPrivate::shiftBottomOfView()
4247 m_viewInternal->bottomOfView(
true);
4250void KTextEditor::ViewPrivate::pageUp()
4252 m_viewInternal->pageUp(m_markedSelection);
4255void KTextEditor::ViewPrivate::shiftPageUp()
4257 m_viewInternal->pageUp(
true);
4260void KTextEditor::ViewPrivate::pageDown()
4262 m_viewInternal->pageDown(m_markedSelection);
4265void KTextEditor::ViewPrivate::shiftPageDown()
4267 m_viewInternal->pageDown(
true);
4270void KTextEditor::ViewPrivate::top()
4272 m_viewInternal->top_home(m_markedSelection);
4275void KTextEditor::ViewPrivate::shiftTop()
4277 m_viewInternal->top_home(
true);
4280void KTextEditor::ViewPrivate::bottom()
4282 m_viewInternal->bottom_end(m_markedSelection);
4285void KTextEditor::ViewPrivate::shiftBottom()
4287 m_viewInternal->bottom_end(
true);
4290void KTextEditor::ViewPrivate::toMatchingBracket()
4292 m_viewInternal->cursorToMatchingBracket();
4295void KTextEditor::ViewPrivate::shiftToMatchingBracket()
4297 m_viewInternal->cursorToMatchingBracket(
true);
4300void KTextEditor::ViewPrivate::toPrevModifiedLine()
4302 const int startLine = cursorPosition().line() - 1;
4303 const int line = doc()->findTouchedLine(startLine,
false);
4306 m_viewInternal->updateSelection(c,
false);
4307 m_viewInternal->updateCursor(c);
4311void KTextEditor::ViewPrivate::toNextModifiedLine()
4313 const int startLine = cursorPosition().line() + 1;
4314 const int line = doc()->findTouchedLine(startLine,
true);
4317 m_viewInternal->updateSelection(c,
false);
4318 m_viewInternal->updateCursor(c);
4332void KTextEditor::ViewPrivate::setContextMenu(
QMenu *menu)
4334 if (m_contextMenu) {
4335 disconnect(m_contextMenu.data(), &
QMenu::aboutToShow,
this, &KTextEditor::ViewPrivate::aboutToShowContextMenu);
4336 disconnect(m_contextMenu.data(), &
QMenu::aboutToHide,
this, &KTextEditor::ViewPrivate::aboutToHideContextMenu);
4338 m_contextMenu = menu;
4339 m_userContextMenuSet =
true;
4341 if (m_contextMenu) {
4347QMenu *KTextEditor::ViewPrivate::contextMenu()
const
4349 if (m_userContextMenuSet) {
4350 return m_contextMenu;
4352 KXMLGUIClient *client =
const_cast<KTextEditor::ViewPrivate *
>(
this);
4360 for (
QWidget *w : menuContainers) {
4361 if (w->objectName() ==
QLatin1String(
"ktexteditor_popup")) {
4381QMenu *KTextEditor::ViewPrivate::defaultContextMenu(
QMenu *menu)
const
4384 menu =
new QMenu(
const_cast<KTextEditor::ViewPrivate *
>(
this));
4398 if (m_pasteSelection) {
4407 QAction *editing = actionCollection()->action(QStringLiteral(
"tools_scripts_Editing"));
4411 if (
QAction *spellingSuggestions = actionCollection()->action(QStringLiteral(
"spelling_suggestions"))) {
4415 if (
QAction *bookmark = actionCollection()->action(QStringLiteral(
"bookmarks"))) {
4423void KTextEditor::ViewPrivate::aboutToShowContextMenu()
4425 QMenu *menu = qobject_cast<QMenu *>(sender());
4428 Q_EMIT contextMenuAboutToShow(
this, menu);
4432void KTextEditor::ViewPrivate::aboutToHideContextMenu()
4434 m_spellingMenu->cleanUpAfterShown();
4438QStringList KTextEditor::ViewPrivate::configKeys()
const
4440 static const QStringList keys = {QStringLiteral(
"icon-bar"),
4441 QStringLiteral(
"line-numbers"),
4442 QStringLiteral(
"dynamic-word-wrap"),
4443 QStringLiteral(
"background-color"),
4444 QStringLiteral(
"selection-color"),
4445 QStringLiteral(
"search-highlight-color"),
4446 QStringLiteral(
"replace-highlight-color"),
4447 QStringLiteral(
"default-mark-type"),
4448 QStringLiteral(
"allow-mark-menu"),
4449 QStringLiteral(
"folding-bar"),
4450 QStringLiteral(
"folding-preview"),
4451 QStringLiteral(
"icon-border-color"),
4452 QStringLiteral(
"folding-marker-color"),
4453 QStringLiteral(
"line-number-color"),
4454 QStringLiteral(
"current-line-number-color"),
4455 QStringLiteral(
"modification-markers"),
4456 QStringLiteral(
"keyword-completion"),
4457 QStringLiteral(
"word-count"),
4458 QStringLiteral(
"line-count"),
4459 QStringLiteral(
"scrollbar-minimap"),
4460 QStringLiteral(
"scrollbar-preview"),
4461 QStringLiteral(
"font"),
4462 QStringLiteral(
"theme")};
4469 return config()->iconBar();
4471 return config()->lineNumbers();
4473 return config()->dynWordWrap();
4475 return rendererConfig()->backgroundColor();
4477 return rendererConfig()->selectionColor();
4478 }
else if (key ==
QLatin1String(
"search-highlight-color")) {
4479 return rendererConfig()->searchHighlightColor();
4480 }
else if (key ==
QLatin1String(
"replace-highlight-color")) {
4481 return rendererConfig()->replaceHighlightColor();
4483 return config()->defaultMarkType();
4485 return config()->allowMarkMenu();
4487 return config()->foldingBar();
4489 return config()->foldingPreview();
4491 return rendererConfig()->iconBarColor();
4493 return rendererConfig()->foldingColor();
4495 return rendererConfig()->lineNumberColor();
4496 }
else if (key ==
QLatin1String(
"current-line-number-color")) {
4497 return rendererConfig()->currentLineNumberColor();
4499 return config()->lineModification();
4501 return config()->keywordCompletion();
4503 return config()->showWordCount();
4505 return config()->showLineCount();
4507 return config()->scrollBarMiniMap();
4509 return config()->scrollBarPreview();
4511 return rendererConfig()->baseFont();
4513 return rendererConfig()->schema();
4520void KTextEditor::ViewPrivate::setConfigValue(
const QString &key,
const QVariant &value)
4523 if (config()->setValue(key, value)) {
4526 }
else if (rendererConfig()->setValue(key, value)) {
4533 rendererConfig()->setBackgroundColor(value.
value<
QColor>());
4535 rendererConfig()->setSelectionColor(value.
value<
QColor>());
4536 }
else if (key ==
QLatin1String(
"search-highlight-color")) {
4537 rendererConfig()->setSearchHighlightColor(value.
value<
QColor>());
4538 }
else if (key ==
QLatin1String(
"replace-highlight-color")) {
4539 rendererConfig()->setReplaceHighlightColor(value.
value<
QColor>());
4541 rendererConfig()->setIconBarColor(value.
value<
QColor>());
4543 rendererConfig()->setFoldingColor(value.
value<
QColor>());
4545 rendererConfig()->setLineNumberColor(value.
value<
QColor>());
4546 }
else if (key ==
QLatin1String(
"current-line-number-color")) {
4547 rendererConfig()->setCurrentLineNumberColor(value.
value<
QColor>());
4554 config()->setDynWordWrap(value.
toBool());
4556 config()->setShowWordCount(value.
toBool());
4558 config()->setShowLineCount(value.
toBool());
4561 rendererConfig()->setFont(value.
value<
QFont>());
4563 rendererConfig()->setSchema(value.
toString());
4570void KTextEditor::ViewPrivate::userInvokedCompletion()
4572 completionWidget()->userInvokedCompletion();
4575KateViewBar *KTextEditor::ViewPrivate::bottomViewBar()
const
4577 return m_bottomViewBar;
4580KateGotoBar *KTextEditor::ViewPrivate::gotoBar()
4583 m_gotoBar =
new KateGotoBar(
this);
4584 bottomViewBar()->addBarWidget(m_gotoBar);
4590KateDictionaryBar *KTextEditor::ViewPrivate::dictionaryBar()
4592 if (!m_dictionaryBar) {
4593 m_dictionaryBar =
new KateDictionaryBar(
this);
4594 bottomViewBar()->addBarWidget(m_dictionaryBar);
4597 return m_dictionaryBar;
4603 m_annotationModel = model;
4604 m_viewInternal->m_leftBorder->annotationModelChanged(oldmodel, m_annotationModel);
4609 return m_annotationModel;
4612void KTextEditor::ViewPrivate::setAnnotationBorderVisible(
bool visible)
4614 m_viewInternal->m_leftBorder->setAnnotationBorderOn(visible);
4617bool KTextEditor::ViewPrivate::isAnnotationBorderVisible()
const
4619 return m_viewInternal->m_leftBorder->annotationBorderOn();
4624 return m_viewInternal->m_leftBorder->annotationItemDelegate();
4629 m_viewInternal->m_leftBorder->setAnnotationItemDelegate(delegate);
4632bool KTextEditor::ViewPrivate::uniformAnnotationItemSizes()
const
4634 return m_viewInternal->m_leftBorder->uniformAnnotationItemSizes();
4637void KTextEditor::ViewPrivate::setAnnotationUniformItemSizes(
bool enable)
4639 m_viewInternal->m_leftBorder->setAnnotationUniformItemSizes(enable);
4645 if (!m_viewInternal->endPos().isValid()) {
4646 m_viewInternal->updateView();
4648 return KTextEditor::Range(m_viewInternal->toRealCursor(m_viewInternal->startPos()), m_viewInternal->toRealCursor(m_viewInternal->endPos()));
4651bool KTextEditor::ViewPrivate::event(
QEvent *e)
4653 switch (e->
type()) {
4662void KTextEditor::ViewPrivate::toggleOnTheFlySpellCheck(
bool b)
4664 doc()->onTheFlySpellCheckingEnabled(b);
4667void KTextEditor::ViewPrivate::reflectOnTheFlySpellCheckStatus(
bool enabled)
4669 m_spellingMenu->setVisible(enabled);
4670 m_toggleOnTheFlySpellCheck->setChecked(enabled);
4673KateSpellingMenu *KTextEditor::ViewPrivate::spellingMenu()
4675 return m_spellingMenu;
4678void KTextEditor::ViewPrivate::notifyAboutRangeChange(
KTextEditor::LineRange lineRange,
bool needsRepaint)
4680#ifdef VIEW_RANGE_DEBUG
4682 qCDebug(LOG_KTE) <<
"trigger attribute changed in line range " << lineRange <<
"needsRepaint" << needsRepaint;
4686 if (needsRepaint && lineRange.
isValid()) {
4687 if (m_lineToUpdateRange.isValid()) {
4688 m_lineToUpdateRange.expandToRange(lineRange);
4690 m_lineToUpdateRange = lineRange;
4695 if (!m_delayedUpdateTimer.isActive()) {
4696 m_delayedUpdateTimer.
start();
4700void KTextEditor::ViewPrivate::slotDelayedUpdateOfView()
4702#ifdef VIEW_RANGE_DEBUG
4704 qCDebug(LOG_KTE) <<
"delayed attribute changed in line range" << m_lineToUpdateRange;
4711 if (m_lineToUpdateRange.isValid()) {
4712 tagLines(m_lineToUpdateRange,
true);
4735 if (doc()->
buffer().rangePointerValid(range)) {
4736 validRanges.
insert(range);
4741 if (currentCursor.
isValid() && currentCursor.
line() < doc()->
buffer().lines()) {
4748 auto attribute = range->attribute();
4749 if ((!attribute || !attribute->dynamicAttribute(activationType)) && !range->feedback()) {
4755 : (currentCursor <= range->toRange().
start())) {
4760 : (range->toRange().
end() < currentCursor)) {
4765 auto it = validRanges.
find(range);
4766 if (it != validRanges.
end()) {
4768 newRangesIn.
insert(range);
4769 validRanges.
erase(it);
4774 newRangesIn.
insert(range);
4776 if (attribute && attribute->dynamicAttribute(activationType)) {
4777 notifyAboutRangeChange(range->
toLineRange(),
true);
4781 if (range->feedback()) {
4783 range->feedback()->mouseEnteredRange(range,
this);
4785 range->feedback()->caretEnteredRange(range,
this);
4786 Q_EMIT caretChangedRange(
this);
4790#ifdef VIEW_RANGE_DEBUG
4792 qCDebug(LOG_KTE) <<
"activated new range" << range <<
"by" << activationType;
4800 if (range->toRange().
isValid() && range->attribute() && range->attribute()->dynamicAttribute(activationType)) {
4801 notifyAboutRangeChange(range->
toLineRange(),
true);
4805 if (range->feedback()) {
4807 range->feedback()->mouseExitedRange(range,
this);
4809 range->feedback()->caretExitedRange(range,
this);
4810 Q_EMIT caretChangedRange(
this);
4816 oldSet = newRangesIn;
4822 auto messageWidget = m_messageWidgets[message->
position()];
4823 if (!messageWidget) {
4826 m_messageWidgets[message->
position()] = messageWidget;
4827 m_notificationLayout->addWidget(messageWidget, message->
position());
4831 messageWidget->postMessage(message, std::move(actions));
4839void KTextEditor::ViewPrivate::saveFoldingState()
4841 m_savedFoldingState = m_textFolding.exportFoldingRanges();
4844void KTextEditor::ViewPrivate::clearFoldingState()
4846 m_savedFoldingState = {};
4849void KTextEditor::ViewPrivate::applyFoldingState()
4851 m_textFolding.importFoldingRanges(m_savedFoldingState);
4855void KTextEditor::ViewPrivate::exportHtmlToFile(
const QString &file)
4857 KateExporter(
this).exportToFile(file);
4860void KTextEditor::ViewPrivate::exportHtmlToClipboard()
4862 KateExporter(
this).exportToClipboard();
4865void KTextEditor::ViewPrivate::exportHtmlToFile()
4869 KateExporter(
this).exportToFile(file);
4873void KTextEditor::ViewPrivate::clearHighlights()
4875 m_rangesForHighlights.clear();
4876 m_currentTextForHighlights.clear();
4879void KTextEditor::ViewPrivate::selectionChangedForHighlights()
4883 if (selection() && selectionRange().onSingleLine()) {
4884 text = selectionText();
4885 if (text == m_currentTextForHighlights) {
4892 m_rangesForHighlights.clear();
4900 m_currentTextForHighlights = text;
4904void KTextEditor::ViewPrivate::createHighlights()
4907 if (m_currentTextForHighlights.isEmpty()) {
4912 m_rangesForHighlights.clear();
4918 QColor fgColor = defaultStyleAttribute(KSyntaxHighlighting::Theme::TextStyle::Normal)->foreground().color();
4919 QColor bgColor = rendererConfig()->searchHighlightColor();
4920 attr->setForeground(fgColor);
4921 attr->setBackground(bgColor);
4941 matches = doc()->searchText(searchRange, pattern, KTextEditor::Regex);
4943 if (matches.
first().isValid()) {
4944 if (matches.
first() != selectionRange()) {
4946 mr->setZDepth(-90000.0);
4947 mr->setAttribute(attr);
4949 mr->setAttributeOnlyForViews(
true);
4950 m_rangesForHighlights.push_back(std::move(mr));
4954 }
while (matches.
first().isValid());
4957KateAbstractInputMode *KTextEditor::ViewPrivate::currentInputMode()
const
4959 return m_viewInternal->m_currentInputMode;
4962void KTextEditor::ViewPrivate::toggleInputMode()
4964 if (
QAction *a = qobject_cast<QAction *>(sender())) {
4969void KTextEditor::ViewPrivate::cycleInputMode()
4971 InputMode current = currentInputMode()->viewInputMode();
4977bool KTextEditor::ViewPrivate::print()
4979 return KatePrinter::print(
this);
4982void KTextEditor::ViewPrivate::printPreview()
4984 KatePrinter::printPreview(
this);
4992 if (std::find(m_inlineNoteProviders.cbegin(), m_inlineNoteProviders.cend(), provider) == m_inlineNoteProviders.cend()) {
4993 m_inlineNoteProviders.push_back(provider);
5004 auto it = std::find(m_inlineNoteProviders.cbegin(), m_inlineNoteProviders.cend(), provider);
5005 if (it != m_inlineNoteProviders.cend()) {
5006 m_inlineNoteProviders.erase(it);
5019 for (
int column : columns) {
5020 const bool underMouse = Cursor(line, column) == m_viewInternal->m_activeInlineNote.m_position;
5022 {provider,
this, {line, column}, index, underMouse, m_viewInternal->renderer()->currentFont(), m_viewInternal->renderer()->lineHeight()};
5023 allInlineNotes.
append(note);
5027 return allInlineNotes;
5032 return m_viewInternal->inlineNoteRect(note);
5035void KTextEditor::ViewPrivate::inlineNotesReset()
5037 m_viewInternal->m_activeInlineNote = {};
5041void KTextEditor::ViewPrivate::inlineNotesLineChanged(
int line)
5043 if (line == m_viewInternal->m_activeInlineNote.m_position.line()) {
5044 m_viewInternal->m_activeInlineNote = {};
5046 tagLines({line, line},
true);
5053 KateRendererConfig *renderConfig =
const_cast<KTextEditor::ViewPrivate *
>(
this)->rendererConfig();
5059 style->setBackground(
QBrush(renderConfig->backgroundColor()));
5068 if (line < 0 || line >= doc()->lines()) {
5074 for (qsizetype i = 0; i < intAttrs.size(); ++i) {
5075 if (intAttrs[i].length > 0 && intAttrs[i].attributeValue > 0) {
5076 attribs <<
KTextEditor::AttributeBlock(intAttrs.at(i).offset, intAttrs.at(i).length, renderer()->attribute(intAttrs.at(i).attributeValue));
5083#include "moc_kateview.cpp"
Q_INVOKABLE QAction * action(const QString &name) const
void addAssociatedWidget(QWidget *widget)
QAction * addAction(const QString &name, const QObject *receiver=nullptr, const char *member=nullptr)
static void setDefaultShortcut(QAction *action, const QKeySequence &shortcut)
static Q_INVOKABLE void setDefaultShortcuts(QAction *action, const QList< QKeySequence > &shortcuts)
QList< QAction * > actions() const
void writeEntry(const char *key, const char *value, WriteConfigFlags pFlags=Normal)
void deleteGroup(const QString &group, WriteConfigFlags flags=Normal)
QString readEntry(const char *key, const char *aDefault=nullptr) const
static void setAutoHideCursor(QWidget *w, bool enable, bool customEventFilter=false)
void indexTriggered(int index)
A delegate for rendering line annotation information and handling events.
An model for providing line annotation information.
Attributes of a part of a line.
A class which provides customized text decorations.
ActivationType
Several automatic activation mechanisms exist for associated attributes.
@ ActivateMouseIn
Activate attribute on mouse in.
@ ActivateCaretIn
Activate attribute on caret in.
An item model for providing code completion, and meta information for enhanced presentation.
The Cursor represents a position in a Document.
constexpr int column() const noexcept
Retrieve the column on which this cursor is situated.
void setColumn(int column) noexcept
Set the cursor column to column.
void setPosition(Cursor position) noexcept
Set the current cursor position to position.
constexpr bool isValid() const noexcept
Returns whether the current position of this cursor is a valid position (line + column must both be >...
static constexpr Cursor start() noexcept
Returns a cursor representing the start of any document - i.e., line 0, column 0.
constexpr int line() const noexcept
Retrieve the line on which this cursor is situated.
static constexpr Cursor invalid() noexcept
Returns an invalid cursor.
Editing transaction support.
A KParts derived class representing a text document.
void copyToClipboard(const QString &text, const QString &fileName)
Copy text to clipboard an remember it in the history.
void deregisterView(KTextEditor::ViewPrivate *view)
unregister view at the factory
QTextToSpeech * speechEngine(KTextEditor::ViewPrivate *view)
text to speech engine to be use by the view actions, constructed on demand.
void configDialog(QWidget *parent) override
Configuration management.
void registerView(KTextEditor::ViewPrivate *view)
register view at the factory this allows us to loop over all views for example on config changes
static KTextEditor::EditorPrivate * self()
Kate Part Internal stuff ;)
A source of inline notes for a document.
void inlineNotesReset()
The provider should emit the signal inlineNotesReset() when almost all inline notes changed.
void inlineNotesChanged(int line)
The provider should emit the signal inlineNotesChanged() whenever one or more InlineNotes on the line...
virtual QList< int > inlineNotes(int line) const =0
Get list of inline notes for given line.
An object representing lines from a start line to an end line.
constexpr int start() const noexcept
Get the start line of this line range.
static constexpr LineRange invalid() noexcept
Returns an invalid line range.
constexpr bool isValid() const noexcept
Validity check.
constexpr int end() const noexcept
Get the end line of this line range.
This class allows the application that embeds the KTextEditor component to allow it to access parts o...
This class holds a Message to display in Views.
@ BelowView
show message below view.
@ AboveView
show message above view.
@ TopInView
show message as view overlay in the top right corner.
@ BottomInView
show message as view overlay in the bottom right corner.
void setAutoHide(int delay=0)
Set the auto hide time to delay milliseconds.
void setAutoHideMode(KTextEditor::Message::AutoHideMode mode)
Sets the auto hide mode to mode.
MessagePosition position() const
Returns the message position of this message.
@ Information
information message type
@ Immediate
auto-hide is triggered as soon as the message is shown
void setPosition(MessagePosition position)
Sets the position of the message to position.
@ StayOnInsert
stay on insert
@ ExpandRight
Expand to encapsulate new characters to the right of the range.
@ ExpandLeft
Expand to encapsulate new characters to the left of the range.
An object representing a section of text, from one Cursor to another.
constexpr LineRange toLineRange() const noexcept
Convert this Range to a LineRange.
constexpr Cursor end() const noexcept
Get the end position of this range.
constexpr Cursor start() const noexcept
Get the start position of this range.
void setEnd(Cursor end) noexcept
Set the end cursor to end.
constexpr bool isEmpty() const noexcept
Returns true if this range contains no characters, ie.
void setRange(Range range) noexcept
Set the start and end cursors to range.start() and range.end() respectively.
constexpr bool onSingleLine() const noexcept
Check whether this range is wholly contained within one line, ie.
static constexpr Range invalid() noexcept
Returns an invalid range.
constexpr bool isValid() const noexcept
Validity check.
constexpr bool containsLine(int line) const noexcept
Returns true if this range wholly encompasses line.
constexpr bool contains(Range range) const noexcept
Check whether the this range wholly encompasses range.
void setStart(Cursor start) noexcept
Set the start cursor to start.
Class to provide text hints for a View.
A text widget with KXMLGUIClient that represents a Document.
ViewMode
Possible view modes These correspond to various modes the text editor might be in.
InputMode
Possible input modes.
@ NormalInputMode
Normal Mode.
void cursorPositionChanged(KTextEditor::View *view, KTextEditor::Cursor newPosition)
This signal is emitted whenever the view's cursor position changed.
void selectionChanged(KTextEditor::View *view)
This signal is emitted whenever the view's selection changes.
KateBuffer & buffer()
Get access to buffer of this document.
int lastLine() const
gets the last line number (lines() - 1)
KTextEditor::MovingRange * newMovingRange(KTextEditor::Range range, KTextEditor::MovingRange::InsertBehaviors insertBehaviors=KTextEditor::MovingRange::DoNotExpand, KTextEditor::MovingRange::EmptyBehavior emptyBehavior=KTextEditor::MovingRange::AllowEmpty) override
Create a new moving range for this document.
KateDocumentConfig * config()
Configuration.
QString mode() const override
Return the name of the currently used mode.
KTextEditor::MovingCursor * newMovingCursor(KTextEditor::Cursor position, KTextEditor::MovingCursor::InsertBehavior insertBehavior=KTextEditor::MovingCursor::MoveOnInsert) override
Create a new moving cursor for this document.
KXMLGUIClient * parentClient() const
KXMLGUIFactory * factory() const
virtual void setComponentName(const QString &componentName, const QString &componentDisplayName)
void removeClient(KXMLGUIClient *client)
bool setValue(const int key, const QVariant &value)
Set a config value.
Internal data container for KTextEditor::InlineNote interface.
Class to layout KTextEditor::Messages in KateView.
Handles all of the work of rendering the text (used for the views and printing)
Inserts a template and offers advanced snippet features, like navigation and mirroring.
This action provides a list of available indenters and gets plugged into the KTextEditor::ViewPrivate...
Class representing a 'clever' text cursor.
@ Folded
Range is folded away.
Class representing a single text line.
const QString & text() const
Accessor to the text contained in this line.
const QList< Attribute > & attributesList() const
Accessor to attributes.
QString string(int column, int length) const
Returns the substring with length beginning at the given column.
int length() const
Returns the line's length.
QChar at(int column) const
Returns the character at the given column.
int firstChar() const
Returns the position of the first non-whitespace character.
Q_SCRIPTABLE Q_NOREPLY void start()
Q_SCRIPTABLE bool focusOut(int ms=-1)
Q_SCRIPTABLE bool focusIn(int ms=-1)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
AKONADI_CALENDAR_EXPORT QString displayName(Akonadi::ETMCalendar *calendar, const Akonadi::Collection &collection)
void update(Part *part, const QByteArray &data, qint64 dataSize)
KCOREADDONS_EXPORT Result match(QStringView pattern, QStringView str)
void error(QWidget *parent, const QString &text, const QString &title, const KGuiItem &buttonOk, Options options=Notify)
KIOCORE_EXPORT QStringList list(const QString &fileClass)
const QList< QKeySequence > & beginningOfLine()
const QList< QKeySequence > & begin()
const QList< QKeySequence > & reload()
const QList< QKeySequence > & cut()
const QList< QKeySequence > & zoomIn()
const QList< QKeySequence > & zoomOut()
const QList< QKeySequence > & next()
const QList< QKeySequence > & deleteWordBack()
const QList< QKeySequence > & find()
const QList< QKeySequence > & end()
const QList< QKeySequence > & copy()
const QList< QKeySequence > & backwardWord()
const QList< QKeySequence > & endOfLine()
const QList< QKeySequence > & forwardWord()
const QList< QKeySequence > & shortcut(StandardShortcut id)
const QList< QKeySequence > & deleteWordForward()
const QList< QKeySequence > & findNext()
const QList< QKeySequence > & prior()
const QList< QKeySequence > & selectAll()
const QList< QKeySequence > & replace()
const QList< QKeySequence > & gotoLine()
const QList< QKeySequence > & pasteSelection()
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
QVariant data() const const
void setIcon(const QIcon &icon)
void setText(const QString &text)
void triggered(bool checked)
void setWhatsThis(const QString &what)
bool isLetterOrNumber(char32_t ucs4)
bool isSpace(char32_t ucs4)
bool supportsSelection() const const
QString text(Mode mode) const const
QColor fromRgba(QRgb rgba)
QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, Options options)
virtual void addItem(QLayoutItem *item) override
void setColumnStretch(int column, int stretch)
void setRowStretch(int row, int stretch)
virtual void setSpacing(int spacing) override
QIcon fromTheme(const QString &name)
QString getText(QWidget *parent, const QString &title, const QString &label, QLineEdit::EchoMode mode, const QString &text, bool *ok, Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints)
QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error)
void setContentsMargins(const QMargins &margins)
void append(QList< T > &&value)
const T & constFirst() const const
bool isEmpty() const const
void push_back(parameter_type value)
void reserve(qsizetype size)
qsizetype size() const const
bool disconnect(const QMetaObject::Connection &connection)
UseUnicodePropertiesOption
QString escape(QStringView str)
iterator erase(const_iterator pos)
iterator find(const T &value)
iterator insert(const T &value)
const QChar at(qsizetype position) const const
bool isEmpty() const const
bool isRightToLeft() const const
qsizetype length() const const
QString & prepend(QChar ch)
void reserve(qsizetype size)
SH_ScrollView_FrameOnlyAroundContents
void initFrom(const QWidget *widget)
WidgetWithChildrenShortcut
QTextStream & bom(QTextStream &stream)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
bool canConvert() const const
bool toBool() const const
int toInt(bool *ok) const const
QString toString() const const
int userType() const const
iterator erase(const_iterator begin, const_iterator end)
qsizetype size() const const