Checking whether a position is inside the first line is also not for
free. Only check the line number of a cursor position if we expect the
editor to have multiple lines per block or in other words line wrapping is
enabled.
Change-Id: I0e3cb1fbd11c250677f7c11d1a5c780f60085ec2
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
QTextLines cursorToX indirectly calls shapeText which is not for free.
We just want to have the x position for the line so there is no need to
shape the complete text to get the position of the first cursor.
Change-Id: I0ae636ed8250385b7ac77c6f37d45922bbf2e9bf
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Detected by clazy analyzer. The possible context was
TextEditorWidget::dropEvent(). In some branches we ensure
that mime is not null, but later we call insertFromMimeData()
unconditionally.
Change-Id: Iee5138bc19d405050eafc9617d3c2ed123b767c7
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
Otherwise some overrides of extraAreaWidth() may leave passed
value unmodified and we may end up with uninitialized value.
Change-Id: Ica89019fc2cff93f0bc7d784624730ec9d8c0224
Reviewed-by: David Schulz <david.schulz@qt.io>
If the rectangle of an annotation changes we need to completely redraw
the annotation since the content might have shifted and the eliding
character is now at a different position.
Fixes: QTCREATORBUG-28411
Change-Id: I41b0f38a73b287e6a5d5318ba797aac6e2ff71b0
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Text editors need to know the actual mimetype of a file to be able to
open the correct editor view. Just checking the extension is not
enough. Especially on linux there are many text files without
an extension.
Change-Id: I7e5c935b0619f5d86e97f10bfd7ff9b65da62f4b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Do not add the find usage action to an editor context menu if it is
already there.
Change-Id: I0a98d81ae0e08be69ca2579af5701b5fbc8ccbda
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Take m_visibleIndentOffset into account when drawing
right margin.
Fixes: QTCREATORBUG-26601
Change-Id: I50839098953181c667a5fe0e5fac7dfa5bc95327
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
Do not missinterpret the new block count after a document change as the
requested extra area width.
Fixes: QTCREATORBUG-27267
Change-Id: Id724f68d223741bc36e4566e51e5d1d051f6cca3
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Use the indenter based visual indent only for the cpp qt style indenter
since it gives accurate results. In all other casess Look for the next
and previous not empty lines and use the minimum indent depth of those
lines as the visual indent depth for empty lines.
Task-number: QTCREATORBUG-28179
Change-Id: Ic456fba5adfb2a12f20e2bd4fc663010c752b65c
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.
Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace.
Task-number: QTBUG-99313
Change-Id: I88edd91395849574436299b8badda21bb93bea39
Reviewed-by: hjk <hjk@qt.io>
Do not try to find the first none space character of a block if we
already handled the home key for a line that does not contain the start
of the block.
Fixes: QTCREATORBUG-28198
Change-Id: Ia2966baeae8f068cd21d716e097782ae3b5a1d86
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This fixes saving documents and copy texts that contain non breaking
spaces.
Task-number: QTCREATORBUG-17875
Change-Id: Ie0b0e68cf7d67e768ff99c9acae1937aafc78ce7
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Moving all initializations that are not influenced by the document to
the TextEditorWidget(Private) constructor. So we do not reinitialize or
double connect unintendedly.
Change-Id: I42f4e8166c21aec9c8b780033b12eb8dae5f72a6
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
After setting the document the display settings that are configured in a
widget might differ from the ones configured in the document. So Check
those values against the desired values from the editor and update if
they differ.
Change-Id: I30c5eddbb09803451fe03769d8e6d189293c5e86
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
The crash happens when calling TextEditorWidget::setTextDocument()
second time for the same editor instance.
Change-Id: I0a2febb50702673e2751a0d41fc0bc80cb6ba4a2
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
... of the generic text editor if the editor has the FindUsage optional
action mask set. This is mainly used to show this action when a language
server is configured for this editor that supports find usages.
Change-Id: I55c6983cd553c46817332144f78f1207185ac3f6
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
... in rewrapParagraph().
One could argue that this functionality is only for pure text and should
not be used on code, but since it was apparently contributed with
doxygen in mind, we might as well go out of our way a bit to support it
a little better.
The simple approach here is to treat a doxygen command at the start of a
line as the end of the reflow region.
Fixes: QTCREATORBUG-9739
Change-Id: I5affee9c441bd9e862bdaf38930fcf8e770b6d97
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
This already has been implemented in change
dc64f3207b, but was reverted with
change f220cb0e23) because this does not
work with text wrapping rendering, due to internal limitations of Qt.
Since this is a highly requested feature (e.g. QTCREATORBUG-13727), but
an internal change within Qt is not in sight, the approach taken here
is to offer the text wrapping feature in the settings only when the
line spacing is set to 100%. Additionally, a change has been made to
the layout of the display settings page to reflect this.
Fixes: QTCREATORBUG-13727
Change-Id: Ib233cf90a5f336bc591fa1bf860e162fa774dfe3
Reviewed-by: David Schulz <david.schulz@qt.io>
The location marker is updated very regularly and especially while
stepping moves one line at a time. Resizing this marker when it enters a
line that already contains a marker is visually distracting. To prevent
this paint the marker over all other markers in that line.
Change-Id: I63ad72384e77eeae4dc6d2e2c2ac77c88da92c56
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This is known to be expensive and a lot of users actually prefer plain
text in the copied mime data to avoid unwanted coloring in 3rd party
tools. Add a separate action (Edit > Advanced > Copy With Highlighting)
that preserves the original functionality.
Change-Id: I0f3c529146ab94d0cd9ce9e3b997c8501a577f03
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Only remove the selected text if the drag source is the editor and we
want to move the selection.
Fixes: QTCREATORBUG-28126
Change-Id: Iaa54d54c432df2da99e30ddb569e06e3ccd0df00
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
In order to remove the selected text of another editor widget when
dragging text from one editor to another the drop event needs to be
accepted.
Fixes: QTCREATORBUG-28125
Change-Id: I8333fe096baf589e5669fc43370fc3519c72bb2d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Results in a cleaner look since the indent marker are not interrupted on
lines that are for code formatting reasons empty.
Change-Id: I887071715e0224210684d131a93b3799f8504501
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Since we are now requiring macOS 10.14 we can remove our local
implementation of optional and use std::optional for macOS too.
Change-Id: I2bd018261b68da64f7f031a812045dd7784697e1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Instead of painting them visually on top of each other paint them in a
grid with a number indicating how much marks are in total in that line.
Fixes: QTCREATORBUG-27415
Change-Id: Ifbf35c956670976b54e5084569d77a6f9e7f59a7
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Task-number: QTBUG-67283
Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Simplifies switching between c++ builtin code model and clangd since we
can now react on new outlines in the c++ editor widget.
Fixes: QTCREATORBUG-27594
Change-Id: I76bdc301d78572cbdf4196658f751b5204743fbb
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Since version 4.14 the right margin of the text editor is tinted. The
fill color corresponds to a darkened editor background color (for light
UI themes), or a lightened background color (for dark themes). However,
the default for most other editors and IDEs is just a single vertical
line, as was the case in Qt Creator up until version 4.13. The different
colored area may be considered uncommon and irritating by some users.
Therefore, the new checkbox "Tint whole margin area" has been added under the
"Text Editor/Display/Text Wrapping" section in the settings for switching
between <= 4.13 and 4.14+ behavior.
Change-Id: I6761943477738a4c78b97a5f70a19f1ff8a428e5
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
Adds a new function that creates new cursors at the end of
each line that was previously selected.
Change-Id: I6510002eae17af9cf00a2eedc5e56ef6fdcc8ef3
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
The global event filter function is executed often, for events
originating deep in the widget hierarchy even multiple times.
Triggering the timer only by mouse and key presses on the main
application and on texteditor is less intrusive and still happens
often enough (TM).
Change-Id: I848d55a347bd62d12e8523965d1750c59da33116
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
When omitting separator lines take the selection start
position instead of the position of the block where
selection starts.
Amends c98bd449523dc05f8875e96d06cf7c21e18eef0d
Fixes: QTCREATORBUG-27813
Change-Id: I6067a3ef6396d50162d8e253fe4a825d47d326b9
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
The mouse cursor is hidden unconditionally in Qt, so do not give the
impression that this can be disabled. Also we have a bunch of bug
reports that claim that the cursor does not come back if the mouse is
moved after typing. This might be caused by the double hide of Qt
Creator, Qt and the moon phase.
Fixes: QTCREATORBUG-27572
Change-Id: I11b39cac6cd8eb0717fca00d1812a4e052223f21
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
... after split in new window.
Fixes: QTCREATORBUG-27748
Change-Id: Idc6270e3bbc39a5c1e679357ba0fbd840e5312c7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>