aboutsummaryrefslogtreecommitdiffstats
path: root/doc/qtcreator/src/editors/creator-semantic-highlighting.qdoc
blob: ae6cb6a65351f4a19881128d16523a914730dea1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Creator documentation.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
**
****************************************************************************/

/*!
    \contentspage index.html
    \previouspage creator-coding-navigating.html
    \page creator-highlighting.html
    \nextpage creator-checking-code-syntax.html

    \title Semantic Highlighting

    \QC understands the C++, QML, and JavaScript languages as code, not as plain
    text. It reads the source code, analyzes it, and highlights it based on the
    semantic checks that it does for the following code elements:

    \list
        \li Types (such as classes, structs, and type definitions)
        \li Local variables
        \li Class fields
        \li Virtual functions
    \endlist

    To specify the color scheme to use for semantic highlighting, select
    \uicontrol Tools > \uicontrol Options > \uicontrol {Text Editor} >
    \uicontrol {Fonts & Color}.

    \QC supports syntax highlighting also for other types of files than C++,
    QML, or JavaScript.

    \section1 Generic Highlighting

    Generic highlighting is provided by
    \l{https://api.kde.org/frameworks/syntax-highlighting/html/index.html}
    {KSyntaxHighlighting}, which is the syntax highlighting engine for Kate
    syntax definitions. \QC comes with most of the commonly used syntax files,
    and you can download additional files. For more information about the
    definition files, see
    \l{https://docs.kde.org/stable5/en/applications/katepart/highlight.html}
    {Working with Syntax Highlighting}.

    Font attributes that a syntax definition file explicitly specifies, such as
    bold, italic, underline, or strike through, are applied. Colors are applied
    if they are readable with \QC themes.

    If the editor cannot find the highlight definition for a file that you open
    for editing, it prompts you to update the highlight definition files. Select
    \uicontrol {Update Definitions} to update the files.

    To suppress the message for a particular file pattern, select
    \uicontrol Tools > \uicontrol Options > \uicontrol {Text Editor}
    > \uicontrol {Generic Highlighter} and add the pattern to the
    \uicontrol {Ignored file patterns} field.

    \image qtcreator-syntax-highlighter.png "Generic Highlighter options"

    If you have written your own syntax definition files, you
    can provide an additional definition search path in the
    \uicontrol {User Highlight Definition Files} field.

    To manually update the highlight definition files, select
    \uicontrol {Update Definitions}.

    \section1 Highlighting and Folding Blocks

    Use block highlighting to visually separate parts of the code that belong
    together. For example, when you place the cursor within the braces, the code
    enclosed in braces is highlighted.

    \image qtcreator-blockhighlighting.png

    To enable block highlighting, select \uicontrol Tools >
    \uicontrol Options > \uicontrol {Text Editor} > \uicontrol Display >
    \uicontrol {Highlight blocks}.

    Use the folding markers to collapse and expand blocks of code within braces.
    Click the folding marker to collapse or expand a block. In the figure above,
    the folding markers are located between the line number and the text pane.

    To show the folding markers, select \uicontrol Tools > \uicontrol Options >
    \uicontrol {Text Editor} > \uicontrol Display >
    \uicontrol {Display folding markers}. This option is enabled by default.

    When the cursor is on a brace, the matching brace is animated by default. To
    turn off the animation and just highlight the block and the braces, select
    \uicontrol Tools > \uicontrol Options > \uicontrol {Text Editor} >
    \uicontrol Display and deselect \uicontrol {Animate matching parentheses}.

    You can use keyboard shortcuts to move within and between blocks. To go to
    block end, press \key {Ctrl+]} and to go to block start, press
    \key {Ctrl+[}. To also select the lines from the cursor position to the end
    or beginning of the block, press \key {Ctrl+Shift+]} and
    \key {Ctrl+Shift+[}, respectively.

    To select the current block, press \key Ctrl+U. A second key press extends
    the selection to the parent block. To undo the last selection, press
    \key {Ctrl+Alt+Shift+U}. To enable smart block selection, select
    \uicontrol Tools > \uicontrol Options > \uicontrol {Text Editor} >
    \uicontrol Behavior > \uicontrol {Enable smart selection changing}.
*/