Commit Graph

628 Commits

Author SHA1 Message Date
David Schulz
411100b037 TextEditor: remove text editor action handler
Give each editor a context and register editor actions individually for
that context. This removes the need to tell the action handler the
current editor. Additionally all actions are now available in editor
widgets outside of the EditorManager.

Change-Id: I0109866b180889762f8bd8aa07874d8d7c55bfa6
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2024-04-09 10:52:26 +00:00
David Schulz
d4e775ebc6 TextEditor: handle syntax highlight in batches
Use an elapsed timer in the syntax highlighter to periodically return
from the highlight and push a continue highlight to the end of the event
loop.
This allows the user to interact with the editor in between those
batches. If the user modifies the document in between highlighting
batches, the area that still needs a rehighlight is increased if needed.

This also reverts 62ea85ee6a and the
related changes.

Task-number: QTCREATORBUG-28727
Change-Id: I7c394dbdff658330bb72f3b68b9928980947db75
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2024-03-25 08:57:37 +00:00
Christian Kandeler
3f457c158f TextEditor: Add type hierarchy infrastructure
We want to support more than one back-end in the future.

Task-number: QTCREATORBUG-28116
Change-Id: I72020c94b36072a297e13f44130e5e2482922cd4
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-03-12 13:22:51 +00:00
David Schulz
3691053760 TextEditor: fix finding whole words
'_' was handled as a word separator, in contrast the global search did
not. So the user received different results when using find toolbar or
the advanced search while searching with the same option and pattern.

Fixes: QTCREATORBUG-10276
Change-Id: Ie07303fbaa35475bb98bdb813358169474c3ba1d
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2024-03-05 11:48:49 +00:00
Artem Sokolovskii
38ea622416 TextEditor: Fix jump to a search result to a folded block
Change-Id: Id9963bdf2a02930911753af046443e9b657bc9b9
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-02-29 13:32:49 +00:00
Artem Sokolovskii
49ab0c4109 TextEditor: Fix jump to search result
Change-Id: Ie570936b0b96290d95999b8b501c12610ebfc9a8
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-02-29 09:48:42 +00:00
Artem Sokolovskii
95a5f01096 TextEditor: Fix folding for async syntax highlighter
- Made restoreState, ensureBlockIsUnfolded, fold, unfold and unfoldAll
functions to be called only after highlighting is done
- Improved management of foldValidator in async case
- Removed optimizations in cpphighlighter and glshighlighter.
The highlighters are async now and optimization is not necessary.
In these optimizations in the function highlightBlock the highlighting
changes not only for currentBlock but and for several next. Which is
contradict with the function name.

Change-Id: Ib413e6b982eb39d52f36c3066ff0fa8c28fbe231
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-02-28 11:53:02 +00:00
David Schulz
8feb31b2ac TextEditor: bound increase and decreaseFontZoom to a 10% grid
This allows to get back to a 100% font zoom with the keyboard shortcuts
by zooming to an odd zoom factor by other means.

Change-Id: Ie90853367b17c207e9c47fc108b8d6f451e0f838
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2024-02-23 12:01:29 +00:00
David Schulz
a18522334c TextEditor: fix multi text cursor unindent via backspace
Change-Id: Iec2e9251b977ccbd7433009ac3e706a9327c704c
(cherry picked from commit 971bcb1a5a)
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-02-22 06:32:39 +00:00
Jarek Kobus
acb449bb2b TextEditor: Fix a leak of CompletionAssistProvider
The c'tor of QmlJSEditorFactory allocates QmlJSCompletionAssistProvider
and sets it via setCompletionAssistProvider.
The QbsEditorFactory subclass allocates QbsCompletionAssistProvider
and overrides the previous one via setCompletionAssistProvider.
So, the old one was leaking.

Use std::unique_ptr to ensure the ownership.

Change-Id: I6fb7da2b97c50919e422482c858d3503403b788d
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-02-13 08:26:23 +00:00
Jarek Kobus
f2dbd28165 CircularClipboard: Replace QSharedPointer with std::shared_ptr
According to https://wiki.qt.io/Things_To_Look_Out_For_In_Reviews
QSharedPointer impl is poor and it's going to be removed from Qt 7.

Change-Id: I3ec37f65318fe1e41f6daf98238a543f85293c48
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-02-05 08:54:31 +00:00
hjk
bc15dcd8fe TextEditor: Move access to smaller settings chunks
Change-Id: Id827edbd19dde54b66cb4349d9c832bc23110adc
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-02-01 13:50:53 +00:00
David Schulz
f4b3b85fee TextEditor: Merge Base- and ThreadedSyntaxHighlighterRunner
Change-Id: I38ad01a895eabba99b2e554f3ae9bef85f32bb3b
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
2024-01-31 10:20:56 +00:00
Eike Ziller
e1da48bf86 CodecSelector: Hide dialog class behind function
It isn't necessary to export the class (which would then best have a d-
pointer etc). Just provide a function that asks the user for a codec and
returns their decision. This makes the whole dialog an implementation
detail.

Change-Id: I7d574561cbe7f079a6d383ba65ba70f6868bbf05
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2024-01-24 10:00:18 +00:00
David Schulz
15a1fd6afc TextEditor: reduce complexity of bookmark requests
Since the book mark support is nowadays part of the text editor plugin
we can directly access the bookmark manager from within the editor
without the indirection over the TextEditorPluginPrivate.

Change-Id: I5c04679d6583c06d615d489d3891431adcb64834
Reviewed-by: hjk <hjk@qt.io>
2024-01-19 12:45:16 +00:00
Mathias Hasselmann
2e353aa1b2 TextEditor: Give access to m_toolBarWidget
The TextEditor doesn't export its actual toolbar via IEditor::toolBar(),
but an internal container widget. This forces other editors that want to
reuse TextEditorWidget to poke into internal details of TextEditorWidget
if they want to provide the full toolbar including line number button.

By giving access to m_toolBarWidget, other editors like the Markdown
editor can show the full toolbar including line numbers without risking
to break, if TextEditorWidget should refactor its toolbar container.

Task-number: QTCREATORBUG-30166
Change-Id: Ic54f21be1897f00801c6a3cfe29c89131d61e3a5
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-01-11 11:34:05 +00:00
Eike Ziller
cf63b1884e Merge remote-tracking branch 'origin/12.0'
Conflicts:
	src/libs/utils/treemodel.cpp
	src/libs/utils/treemodel.h

Change-Id: I9c5e8ef77905745c201cfc647218c9e747d268d6
2024-01-08 14:56:54 +01:00
David Schulz
419eae839a TextEditor: improve line column button tooltip
Automatically hide the tooltip of the line column button in the editor
toolbar when the cursor leaves the widget.

Change-Id: Ia17f40029d0821584c8a804b44431a5d7e639066
Reviewed-by: hjk <hjk@qt.io>
2024-01-08 12:37:21 +00:00
Mathias Hasselmann
a213ce3875 TextEditor: Repair insertExtraToolBarWidget()
New extra widgets for the right side were wrongly inserted between the
buttons for line-ending text-encoding.

Task-number: QTCREATORBUG-30166
Change-Id: I0f55c44344f9586e6aa97da20f5e25c28adf964c
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-01-08 10:21:13 +00:00
Marcus Tillmanns
7cc970ce5a TextEditor: Sort extraSelections
When applied to the QPlainTextEdit, the first selection for a range wins.
We want "OtherSelection" which is used for links to win, so we "sort"
it to the beginning of the final list.

Change-Id: Idf84c92ad5bd12d9f6ad6381f7e556e51ee459a9
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-12-14 08:45:12 +00:00
Artem Sokolovskii
e396f84d10 SyntaxHighlighter: Move generic highlighter to separate thread
Adds a full copy of KSyntaxHighlighting::Repository class
to the Highlighter class, enabling the relocation of the
Highlighter class to a separate thread. This adjustment ensures
that all Definitions come from the copy of the repository, making
them immutable from external code.

The "reload Definition" function stays supported, as triggering
it results in the recreation of the highlighter for the document,
thereby reconstructing the Repository class.

Change-Id: Id7a4d865228c7e7e20e4770601a3fde55b8a6513
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-12-12 13:03:59 +00:00
hjk
016936a450 Clean up some lambdas
Change-Id: Id947c0935b1aa4579e1c64d3e510db41103fbe27
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-12-12 10:55:32 +00:00
Artem Sokolovskii
62ea85ee6a SyntaxHighlighter: Move SyntaxHighlighter to separate thread
This change involves the relocation of SyntaxHighlighter processing
to another thread. The core idea is to create a duplicate of the
original TextDocument using SyntaxHighlighterRunnerPrivate::cloneDocument.
A new SyntaxHighlighter is then instantiated by SyntaxHighLighterCreator
for the cloned document. The entire SyntaxHighLighterCreator class is
moved to a new thread, where it performs highlighting on the cloned
document. Upon completion of the highlighting process, the resultsReady
signal is emitted, and the updated highlighting data is applied to the
original document.

This shift of SyntaxHighlighter to another thread enhances the user
experience by preventing UI slowdowns during the highlighting process.

- Introduction of BaseSyntaxHighlighterRunner as an interface class for
future *SyntaxHighlighterRunner.
- Inclusion of DirectSyntaxHighlighterRunner class for performing
highlighting in the main thread, suitable for syntax highlighters
that cannot be moved to another thread.
- Introduction of ThreadedSyntaxHighlighterRunner class for highlighting
in a separate thread, preventing UI blocking during the process.
- Addition of Result data to the SyntaxHighlighter class to facilitate
data exchange between threads.

Task-number: QTCREATORBUG-28727
Change-Id: I4b6a38d15f5ec9b8828055d38d2a0c6f21a657b4
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-12-11 09:55:02 +00:00
Marcus Tillmanns
4153520fb6 TextEditor: Allow opening links without filename
... in editors displaying a document without a filename.

Change-Id: I857018e2532b406a37983d8fd77e52daa31ae70d
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-12-04 08:33:11 +00:00
Eike Ziller
c75a3bcd5d Merge remote-tracking branch 'origin/12.0'
Change-Id: I0ee9c73d7a7e12f98f88b161c35d00ada069cc9d
2023-11-21 14:46:01 +01:00
Artem Sokolovskii
b26c43f133 SyntaxHighlighter: Move static functions to other namespace
- Created HighlighterHelper namespace and static functions
were moved there from the highlighter class

Change-Id: Ib93785a3819317d7c1d5cc480652d4635cb9339b
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-11-20 16:04:59 +00:00
Artem Sokolovskii
4bfc3476f4 SyntaxHighlighter: Move highlighter creating to TextDocument
Added setSyntaxHighlighterCreator function to TextDocument
which allows the creation of highlighters inside TextDocument.

Change-Id: I454f800c878c48a154dad5abd68b7a4f9ceb378a
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-11-20 14:52:20 +00:00
David Schulz
d81d41032a TextEditor: do not collapse doc comments in the beginning of a file
The auto fold license header functionality also automatically folds
documentation comments. Automatically collapsing documentation comments
is never correct in the first place so just skip the fold when encounter
a documentation marker in the first comment.

Fixes: QTCREATORBUG-29900
Change-Id: If0dd7842804f3ff0bcd725b54413e9568d5b5ab3
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-11-20 13:39:30 +00:00
Eike Ziller
583a9dcea1 Add Line/Column indicator to Markdown editor
And make the LineColumnButton independent of IEditor for that (since the
IEditor for the Markdown editor is not a TextEditor.

Change-Id: I52d378ec46d86b1c7928d18f7d39f9726bb6ad23
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-11-17 08:15:43 +00:00
Tim Jenssen
9f1d23df00 Merge remote-tracking branch 'origin/qds/dev'
Change-Id: Ic852bc9977d0292fb6cd93a319f4bfdebb22a1b0
2023-11-16 17:17:46 +01:00
Tim Jenssen
39d1dae0d3 Merge remote-tracking branch 'origin/12.0' into qds/dev
Change-Id: Ic6e557806a3209e2c6d983d3c3fcfad66f6e3066
2023-11-16 15:56:06 +01:00
hjk
d739a14950 TextEditor: Delay-construct ClipboardAssistProvider
Change-Id: I34d1e2e8f99e55e574e148bef700811fb33d9449
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-11-16 12:15:45 +00:00
Eike Ziller
0269626a17 Make LineColumnButton re-usable
Change-Id: I34e755018eef41e7e7cf254ccba72a1ec5a1c5ff
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-11-15 09:30:17 +00:00
Eike Ziller
206000a3d6 Fix state of LineColumButton after clicking
When using the `pressed` signal, the button stays in the "pressed" state
forever afterwards. Using the `clicked` signal behaves correctly, so use
that instead.

Change-Id: I646c93f1db3b1176630f1cfa718aba01d0aaf252
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-11-14 13:38:04 +00:00
The Qt Project
841d9d739e Merge "Merge remote-tracking branch 'origin/12.0' into qds/dev" into qds/dev 2023-11-09 09:24:26 +00:00
Thomas Hartmann
070022e9e2 TextEditor: Allow to programmatically highlight a block by cursor
This can be used in QmlDesigner to highlight the currently selected
QML object.

Change-Id: I9907d54f767c7d034739d4111a46cd994c961426
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2023-11-09 08:53:25 +00:00
Eike Ziller
363d2d161c Merge remote-tracking branch 'origin/12.0'
Change-Id: I35cb28b759fb200c45a1496299584132336fcd1c
2023-11-08 10:07:29 +01:00
David Schulz
4a081cb386 TextEditor: remove texteditor_p.h
There is no need to have an extra file for one struct that is only used
inside texteditor.cpp

Change-Id: Iee8f7ce5e0d19da7b444660d81c350eb10b501ef
Reviewed-by: hjk <hjk@qt.io>
2023-11-07 15:24:57 +00:00
Eike Ziller
df80454d26 Merge remote-tracking branch 'origin/12.0'
Change-Id: I04104ef638b28d99da11b9b7a22f31f8d0ddf460
2023-10-24 13:05:55 +02:00
David Schulz
2e93051aaf TextEditor: improve sort selected lines
Try to get a sensible scope when there is no selection when sorting
lines.

Use the indent level of the current block and select all blocks that are
not empty with the same indent level around that block before sorting
the lines.

Change-Id: I68cbd95f95a0cc4425a0339b992225c3946a6858
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-10-24 07:38:38 +00:00
David Schulz
6f4b9639ce TextEditor: highlight selected text
Change-Id: Ib46908decef51d478f6954a116108c48e4a07ed3
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-10-23 07:33:45 +00:00
Leena Miettinen
61088bba69 Fix UI text capitalization, punctuation, and phrasing
Change-Id: I41951660a464601063e5cedd417db2cb7cd37e44
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-10-20 14:55:38 +00:00
David Schulz
5f45c36b6f TextEditor: do not scroll to cursor postion on select all
Since Qt 6.5.1 QPlainTextEdit::selectAll emits correctly
cursorPositionChanged on selectAll which calls some multitextcursor
update code on our side. Avoid setting the cursor back to the
QPlainTextEdit in this update code by setting the expected
MultiTextCursor before calling selectAll.

Fixes: QTCREATORBUG-29763
Change-Id: I77f05ac40a9dd126efcd72089a699c908c68da21
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-10-20 10:47:34 +00:00
Eike Ziller
a253a2aa95 Tr: Fix lupdate issues
Add missing `Tr::` and use some fully qualified namespaces where lupdate
fails to resolve it correctly.

Change-Id: Ied4ac7bf0438a9080d0b76a9a1f5033dbc94a163
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-10-18 11:21:52 +00:00
Marcus Tillmanns
fdeff13ca3 TextEditor: Don't export KSyntaxHighlighting
Change-Id: I84fa8c758af412d8847391a628deac60279b9448
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-10-17 13:25:50 +00:00
Marcus Tillmanns
d8a75d48a3 TextEditor: Add selecting highlighter by name
Change-Id: I5c706dd151173bf08c5fbd4dacbf6e5d6416b87b
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-10-17 08:47:45 +00:00
David Schulz
483a340e73 TextEditor: speed up searching in huge documents
Avoid creating QTextCursors for checking whether a search result is
inside the find scope. QTextCursor::setPosition seems to layout the
block the cursor is positioned at, which is not for free and not needed
to verify whether a search result is inside the find scope.

Change-Id: Ia1658fbbaa89a61f862e0b97eaa5b059972e2311
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-10-13 11:37:29 +00:00
David Schulz
eda0dbd8dd TextEditor: modernize highlighting search results
Change-Id: I365a09dfd9d371119044da5567a1adb397f3ac93
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-10-12 07:58:49 +00:00
David Schulz
80633a59aa LanguageClient: support additional goto targets in symbol support
Allow to follow to the symbol definition as well as to the type
definition for the symbol under the cursor position.

Change-Id: I8ff50b33a1e739f81b0832b1b28ffc525e1f7177
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-09-29 09:10:14 +00:00
David Schulz
7c28cc0565 Editor: transform the encoding label into button
Like for the line number label: Having a button instead of a labal makes
it more obvious that there is an action triggered when clicking the
label.

Change-Id: Ied15c05658c0b0b7df75cbcf1704808e94f6985d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-09-22 09:00:24 +00:00