Commit Graph

363 Commits

Author SHA1 Message Date
Marius Sincovici
a96ed0d4a0 Add option to configure file line ending for an open document
Add into the text editor toolbar a combo box which allows to change
the line endings for an open document.
The supported line endings are LF and CRLF.

Change-Id: I029ba7867e0087b162edba7aba1bd1d1e966fd69
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-08-07 20:07:16 +00:00
Andre Hartmann
839f45faa9 FancyLineEdit: Add camel case navigation
Use it for search and replace functions as well as for Locator.

The camel case navigation can be switched on / off with
the existing menu Options > Text Editor > Behavior >
Enable Build-in camel case navigation.

Fixes: QTCREATORBUG-21140
Change-Id: I3f2dcafff231366b3c8f08c14514dd8940cca2a0
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-08-02 06:40:56 +00:00
hjk
251287f0d3 Avoid warning on empty expressions
For some reason, Q_UNUSED includes already a semicolon, adding one
on the user side creates an additional empty statement.

Change-Id: I9c5e8fac381345a60792cb75e2938fd53958d3b0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-07-23 11:55:59 +00:00
David Schulz
09b9aa98a8 TextEditor: fix low contrast of hovered folding markers
When using the 'windowsvista' style the folding markers are blue when
hovered. This color is almost invisible on the default folding range
background color. Use the tested folding markers of the fusion style,
because it is already used when device pixel ratio != 1.0

Change-Id: I23659cce71a2eb101692597a1d256d43f6426920
Fixes: QTCREATORBUG-21702
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-06-18 11:45:26 +00:00
Joel Smith
e846b8717a TextEditor: Type over punctuation that can be auto completed
This restores a feature of older Qt Creator versions: typing "over"
closing punctuation.  For instance, if my cursor is at | and I have
something like this:

    if (statement|)

... and I type the ) character, older versions of Qt Creator would not
end up with )).  With newer versions of Qt Creator, this behavior is
limited to the case where an autocompletion has just happened (i.e. if I
typed the opening ( character, the closing ) is auto inserted and
highlighted - and if I type it myself, it won't add a second one).

Task-number: QTCREATORBUG-16946
Change-Id: I45af3ac139d5e7c76e5f0a8a9d66762f9209a525
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-05-27 14:09:12 +00:00
David Schulz
c874f07d53 LanguageClient: add hover handler
Change-Id: Iddf30828ef26a157ab935d0abe708087ab123dd6
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-05-17 09:18:41 +00:00
Eike Ziller
4545c81e57 Merge remote-tracking branch 'origin/4.9'
Conflicts:
	doc/src/howto/creator-sidebar-views.qdoc
	doc/src/howto/creator-ui.qdoc
	qbs/modules/qtc/qtc.qbs
	qtcreator.pri
	src/plugins/autotest/testresultmodel.cpp
	src/plugins/autotest/testresultmodel.h

Change-Id: I24cc585ca7782cb1d9cb0b8b73b46892b41937fd
2019-05-08 12:41:25 +02:00
David Schulz
81f342ea00 TextEditor: Fix including folding end
Instead of the first visible block we need to check the last invisible
block whether we should add the folding end text to the fold
replacement.
Introduced in b6b756e737

Change-Id: Id93403a14145c09069281d32d5b622bad80c4ae6
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-03 08:59:20 +00:00
David Schulz
132d813343 TextEditor: Indent line when comment marker is not in the first column
Change-Id: I02713f1151264411451c5d9b476847e451ccef05
Fixes: QTCREATORBUG-21852
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-04-29 09:51:25 +00:00
Eike Ziller
c53ccceff1 Merge remote-tracking branch 'origin/4.9'
Conflicts:
	qbs/modules/qtc/qtc.qbs
	qtcreator.pri
	src/plugins/debugger/debuggerkitinformation.cpp
	src/plugins/languageclient/languageclientmanager.cpp
	src/plugins/plugins.pro
	src/plugins/projectexplorer/kit.cpp
	src/plugins/projectexplorer/kitmanager.cpp

Change-Id: I66fb941202991f35f7d7761430b21e42dfc678a8
2019-03-14 15:51:15 +01:00
David Schulz
6b59d711a8 TextEditor: return all BaseTextEditor for a document
Change-Id: Iab483528357fdba1b7107130c19370974c03979c
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-03-13 05:38:00 +00:00
Orgad Shaneh
cbfc6e522d Merge remote-tracking branch 'origin/4.9'
Change-Id: I801042a53ae4d02d1891ea582ca9ea89b00d3181
2019-03-01 13:06:57 +02:00
David Schulz
8a0f7bcfd5 TextEditor: add option to remember highlighter definition
Add a button to the multiple definition found info that saves the
definition of the current highlighter for the open document.

Change-Id: I04b1b7571a864d781747547a1d315ec25bb6b5a1
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2019-02-28 07:14:43 +00:00
hjk
6f37348b4c Replace static_casts by QOverload where possible
Mainly to get rid of the QProcess::finished deprecation warning.

Also adjust coding style in the surrounding connects when needed.

Change-Id: I12f9b248c7974b892c4a069356e578e80f8c59e9
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-02-26 15:18:14 +00:00
Eike Ziller
6d43aaf134 Merge remote-tracking branch 'origin/4.9'
Change-Id: I7bdb6a4658c5fca1a7e1dda5adbb5613dabc6d18
2019-02-19 09:08:53 +01:00
Friedemann Kleint
ec6b38dea0 Fix Qt 5.13 deprecation warning about QFontMetrics::width()
Replace by QFontMetrics::horizontalAdvance(), fixing:
warning: ‘int QFontMetrics::width(const QString&, int) const’ is deprecated:
 Use QFontMetrics::horizontalAdvance [-Wdeprecated-declarations]

Change-Id: I9991ffefe6e87e872dc35ba291d562e06b28ca64
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2019-02-15 15:12:02 +00:00
Alessandro Portale
88d1d92728 Bump minimum Qt version (to build Qt Creator) to 5.11
Recent adaptations to Qt 5.13's API deprecations require using APIs
which were introduces in Qt 5.11.

Change-Id: I6c077d824c9ce716e019543b290c355a5d512fad
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-02-15 14:39:12 +00:00
Eike Ziller
2bebfe9985 Help: Add fallback word lookup for context help to base text editor
If we do not have a hover handler, or that did not produce any result,
use the word under cursor and try with that.
This adds at least some help fallback mechanism to all text editors,
e.g. we get some context help (though a bit crude) for Pyside
"for free".

Change-Id: I1b6d91ad6f46bfd12e242b1aec9f4fcadae23403
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-02-15 14:06:50 +00:00
Christian Stenger
6ae786bcc8 TextEditor: Fix build for Qt5.9
Do not use functions that are not supported with
the minimum supported Qt for building QC.
Partially reverts 963dc84cc5.

Change-Id: Ife03143a7cf5a8f428754040e7004efe42d70a8a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-02-11 13:39:21 +00:00
David Schulz
82466375b9 TextEditor: Show info when multiple highlight definitions are available
Show an editor info bar when multiple highlight definitions can be found
for a single file or mime type. Add a combo box to the info that allows
the user to choose between them.

Change-Id: I07278d065e19d4e04fba24a6d789c8b6c9f55d60
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-02-11 12:45:04 +00:00
Friedemann Kleint
963dc84cc5 Fix some deprecation warnings in basic plugins
Fix warnings apppearing in 5.13, for example:
warning: ‘QDir& QDir::operator=(const QString&)’ is deprecated: Use QDir::setPath() instead [-Wdeprecated-declarations]
...
warning: ‘static QRgb QColorDialog::getRgba(QRgb, bool*, QWidget*)’ is deprecated: Use getColor() [-Wdeprecated-declarations]
warning: ‘Qt::DropAction QDrag::start(Qt::DropActions)’ is deprecated: Use QDrag::exec() instead [-Wdeprecated-declarations]
warning: ‘void QProcess::finished(int)’ is deprecated: Use QProcess::finished(int, QProcess::ExitStatus) instead [-Wdeprecated-declarations]
...
warning: ‘const QRect QDesktopWidget::availableGeometry(int) const’ is deprecated: Use QGuiApplication::screens() [-Wdeprecated-declarations]
...
warning: ‘const QBrush& QPalette::background() const’ is deprecated: Use QPalette::window() instead [-Wdeprecated-declarations]
...
warning: ‘const QBrush& QPalette::foreground() const’ is deprecated: Use QPalette::windowText() instead [-Wdeprecated-declarations]
...
warning: ‘void QTextOption::setTabStop(qreal)’ is deprecated [-Wdeprecated-declarations]
warning: ‘void QList<T>::swap(int, int) [with T = ProjectExplorer::BuildStep*]’ is deprecated: Use QList<T>::swapItemsAt() [-Wdeprecated-declarations]
warning: ‘void QProcess::setReadChannelMode(QProcess::ProcessChannelMode)’ is deprecated: Use QProcess::setProcessChannelMode() instead [-Wdeprecated-declarations]
...
warning: ‘QString QFileInfo::readLink() const’ is deprecated: Use QFileInfo::symLinkTarget() instead [-Wdeprecated-declarations]

Change-Id: I1d893d42d372245892f2de8406f52dbe7bbd552a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-02-11 09:32:06 +00:00
David Schulz
874dde6863 TextEditor: extract initilizing the generic highlighter
Change-Id: Ibdd37aeb761087118dd4974a06d82c0dbe1f1731
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-02-07 13:49:00 +00:00
David Schulz
f75934f297 TextEditor: shorten namespace noise
Change-Id: I16bc218ccefb7234cb9c1299ee3022549b178600
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-02-07 12:51:27 +00:00
David Schulz
f4a45884ca TextEditor: add convenient definition for document function
Change-Id: I8bbaec71a4682e36d3919924932b410e2e9d74a9
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-02-07 12:51:19 +00:00
David Schulz
1dd462ac4d TextEditor: update the infobar after setting up the highlighter
removes the need of public function and member carrying the
information whether a highlight definition was found.

Change-Id: I8a0f24c9b376c01246116b502f5bbc06b3c65d21
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-02-07 12:51:12 +00:00
David Schulz
bf6dfa0db9 TextEditor: remove senseless function call
updating the info bar only makes sense after trying to set
a generic highlighter, otherwise the member capturing the
information whether a highlight definition for the current
file is available might be uninitialized.

Change-Id: I5cce70ecf1df0ba34f43eeb01743c1fae729cc6b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-02-07 12:51:05 +00:00
Eike Ziller
a0969a3c09 Merge remote-tracking branch 'origin/4.8' into 4.9
Change-Id: I216c7dcbef1e840751332e7a6558c9d633444af3
2019-02-07 10:03:28 +01:00
Eike Ziller
f369556dca Merge remote-tracking branch 'origin/master' into 4.9
Change-Id: I0768e59f13f2fae0bdf13047431de9fac870bf74
2019-02-07 07:43:26 +01:00
Eike Ziller
14f66e0eb5 Fix highlighting of regexp search results in editor
The highlighting in the editor was still done with QRegExp,
so if you used Perl regular expression features, highlighting in
the editor was incorrect.

Fixes: QTCREATORBUG-21940
Change-Id: I785f0b2413a291d9f06de5877b18067a30d58588
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-02-07 06:19:10 +00:00
Christian Kandeler
6ab9078e87 Project tree: Do not pretend to support moving files via Drag & Drop
We claimed to support the move action, so on Windows the user could drag
files away to e.g. the Desktop or the Explorer. This resulted in
inconsistent state, because we do not (cannot?) handle an "external
drop" in any of our build system managers.
Instead, we now support only the copy action, which leaves our project
sources untouched. This is also more likely to be what the user wants.

Fixes: QTCREATORBUG-14494
Change-Id: Ie327780768f1ac68d6dbe95c3daa4aa4dc3f0f41
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2019-02-05 11:30:12 +00:00
Nikolai Kosjar
c5e43d86d1 Clang: Make diagnostic tooltips consistent
Fix that triggering a diagnostic tooltip from the diagnostic
location/range itself (underlined text) did not show the icon on the
left and the actions/toolbuttons on the right in the tooltip.

Instead of showing the tooltip content itself, request the tooltip for
the corresponding text mark to get the extra decoration and actions.

Change-Id: I5e94aca117a761f7a798d4f4b33db6e386e54d84
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-05 11:22:27 +00:00
Nikolai Kosjar
a5317cdaa5 TextEditor: Polish separator in text mark tooltip
Use one row instead of two for showing "Other annotations" and the
separator line.

Change-Id: I25234fc2fb49ccb71125a1cf762c89b668032b77
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-02-05 08:44:01 +00:00
Eike Ziller
66226453a1 Merge remote-tracking branch 'origin/4.9'
Change-Id: I873266bc23680ea02aaff6387790f2a834335113
2019-02-05 09:02:01 +01:00
Nikolai Kosjar
107028dd19 TextEditor: Remove duplication when handling textmark tooltips
Change-Id: I1df48c91a6248f3e8a5feb62bbcd7644d765eeab
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-02-05 07:40:11 +00:00
Eike Ziller
92ddaea43e Help: Make a difference between "empty" and "valid"
Context help should take the HelpItem from the tool tip if it was set,
even if it isn't valid.
Similarly, if the help item was set on the text editor, it should not
ask the hover handlers (again), even if that is invalid

Change-Id: I481f8ad73c3cf8fdbb90f737ab36b4e380467026
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-02-04 09:20:55 +00:00
Eike Ziller
32429e11c9 Help: Avoid double lookup for help tooltips
Save the HelpItem directly in the tooltip instead of the help ID which
would need to be looked up again.

Change-Id: I107e82e89d9ea26cad9d6532ad4c687d1ac8f1ec
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-02-01 11:00:55 +00:00
Ivan Donchevskii
1dee275f58 ClangFormat: Add cursor position to the indenter interface
Sometimes it's imnportant where the cursor currently is
to properly format the code without affecting the current line.

Change-Id: I8b1fb11d2303adb5f960c7cb80a0ed2e6e45010f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-01-31 10:25:18 +00:00
Ivan Donchevskii
80fb0178fd ClangFormat: Introduce check to format code instead of indenting
Ctrl+I with the new check will reformat the selected code or
the current line instead.

Change-Id: Ia5a72c4a09621034d0dfe463f669fe1ca36b0b5f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-01-31 10:25:05 +00:00
Eike Ziller
282805b66d Rename IContext::HelpIdCallback -> IContext::HelpCallback
It no longer takes an ID but a HelpItem.

Change-Id: I0aa738549fea4fcfd0151adc2dfd642c63f0f60d
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-01-29 07:58:19 +00:00
Eike Ziller
418dcfbcbb Help: Avoid multiple lookups of help id for context help
Context help would first query the database with potential IDs, and
afterwards the help plugin would look up the links for the resulting ID
again.
Pass the HelpItem (which potentially contains the cached links) directly
to context help.

Change-Id: I73bddcd3cd4eacaea412b98d53c5e5354a31f3d5
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-01-29 07:57:19 +00:00
David Schulz
14834e6b0a TextEditor: replace generic highlighter with ksyntaxhighlighting
Fixes: QTCREATORBUG-21029
Change-Id: I9894c4384e0e47da6bf030b7b8e07c3ad4737ff3
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2019-01-28 11:37:08 +00:00
David Schulz
7b7a2ad630 TextEditor: Use callback in refactoring markers
Allows to trigger actions without adding specific handling into the
editor.

Change-Id: Ia63d65d3feca37bcefca1b6322ade039027a92d8
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-01-25 06:13:11 +00:00
Ivan Donchevskii
d7058e1afe ClangFormat: Refactor indenter to allow ClangFormat unit-tests
We do not build texteditor files in unit-tests so some tricks
were required to make ClangFormatIndenter available.

First simple unit-test proofs it builds and runs.

Change-Id: I81d5ea099bd27fd1c1ed8b5b7877299dcc62a67f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-01-22 09:52:15 +00:00
Alessandro Portale
616e19ff9e Fix warning: "Missing emit keyword on signal call"
[-Wclazy-incorrect-emit]

Change-Id: I93bdc6e23cdaccf35c9899ae16870ccc65a54f80
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2019-01-17 15:54:56 +00:00
Eike Ziller
9084ca73df Merge remote-tracking branch 'origin/4.8'
Conflicts:
	qbs/modules/qtc/qtc.qbs
	qtcreator.pri
	src/plugins/cpptools/compileroptionsbuilder.cpp

Change-Id: I87f47cecbb924064296a002fd9446a0627acad8e
2018-12-12 09:44:13 +01:00
David Schulz
318b83587f TextEditor: fix painting annotations
The painting of annotations for one line will be aborted as soon as we
hit the first text mark that returns an empty bounding rect for the
annotation. This results in no painting at all when having a line with
multiple text marks with and without annotation. Prefilter the text
marks to make sure we only try to paint text marks with an annotation.

Change-Id: I4f07127fafe935b2ad4ed418b326b6f2ab5b1c50
Fixes: QTCREATORBUG-21628
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-12-10 11:19:33 +00:00
Alessandro Portale
2e2059e8b5 TextEditor: Modernize
modernize-*

Change-Id: Ic497fea1942a77cf017be3b0033f92e3807066f1
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: hjk <hjk@qt.io>
2018-11-30 17:35:18 +00:00
Eike Ziller
29c9f8080d Merge remote-tracking branch 'origin/4.8'
Conflicts:
	src/plugins/android/androidrunnerworker.cpp

Change-Id: Ibd8b99435365fb7e7d488313fd1d2b3a75adad1b
2018-11-29 13:36:14 +01:00
David Schulz
95cba448a1 move find usages to TextEditor
In preperation for supporting find usages by the language client plugin

Task-number: QTCREATORBUG-21577
Change-Id: I7a6da3a9d53478c1d486e0ddc5829c9ea09a2a20
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-11-28 12:29:44 +00:00
Nikolai Kosjar
03ee0e6acc Clang: Abort hover handlers on ~TextEditorWidget
We have a QPointer<QTextEditorWidget> in HoverHandlerRunner and a check
in onHandlerFinished() to handle the editor-closed-case. However, the
HoverHandlerRunner and thus the QPointer<> do not outlive the
TextEditorWidget.

Abort the handlers in ~HoverHandlerRunner instead.

Task-number: QTCREATORBUG-21582
Change-Id: I03b78802ca75ddd4be9fea994e3dd9b152060e72
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-11-28 09:22:30 +00:00