// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
    \page creator-completing-code.html
    \previouspage creator-how-tos.html

    \ingroup creator-how-to-edit

    \title Complete code

    As you write code, \QC suggests properties, IDs, and code snippets to
    complete the code. It shows a list of suggestions to
    the statement currently under your cursor.

    Select \key Tab or \key Enter to accept the selected suggestion and complete
    the code.

    \image {qtcreator-codecompletion.png} {Suggestions for completing C++ code}
    \caption Suggestions for completing C++ code.

    \image {qml-code-completion.png} {Suggestions for completing QML code}
    \caption Suggestions for completing QML code.

    To open the list of suggestions at any time, select \key {Ctrl+Space}.
    If only one option is available, \QC inserts it automatically.

    \section1 Summary of Available Types

    The following table lists available types for code completion and icon used
    for each.

    \table
        \header
            \li  Icon
            \li  Description
        \row
            \li \inlineimage {completion/class.png} {Class icon}
            \li A class
        \row
            \li \inlineimage {completion/enum.png} {Enum icon}
            \li An enum
        \row
            \li \inlineimage {completion/enumerator.png} {Enum value icon}
            \li An enumerator (value of an enum)
        \row
            \li \inlineimage {completion/func.png} {Function icon}
            \li A function
        \row
            \li \inlineimage {completion/func_priv.png} {Private function icon}
            \li A private function
        \row
            \li \inlineimage {completion/func_prot.png} {Protected function icon}
            \li A protected function
        \row
            \li \inlineimage {completion/var.png} {Variable icon}
            \li A variable
        \row
            \li \inlineimage {completion/var_priv.png} {Private variable icon}
            \li A private variable
        \row
            \li \inlineimage {completion/var_prot.png} {Protected variable icon}
            \li A protected variable
        \row
            \li \inlineimage {completion/signal.png} {Signal icon}
            \li A signal
        \row
            \li \inlineimage {completion/slot.png} {Slot icon}
            \li A slot
        \row
            \li \inlineimage {completion/slot_priv.png} {Private slot icon}
            \li A private slot
        \row
            \li \inlineimage {completion/slot_prot.png} {Protected slot icon}
            \li A protected slot
        \row
            \li \inlineimage {completion/keyword.png} {C++ keyword icon}
            \li A C++ keyword
        \row
            \li \inlineimage {completion/snippet.png} {C++ code snippet icon}
            \li A C++ code snippet
        \row
            \li \inlineimage {completion/element.png} {QML type icon}
            \li A QML type
        \row
            \li \inlineimage {completion/qmlsnippet.png} {QML code snippet icon}
            \li A QML code snippet
        \row
            \li \inlineimage {completion/macro.png} {Macro icon}
            \li A macro
        \row
            \li \inlineimage {completion/namespace.png} {Namespace icon}
            \li A namespace
    \endtable

    \section1 Complete code snippets

    Code snippets can consist of multiple variables that you specify values for.
    Select an item in the list and select \key Tab or \key Enter to complete the
    code. Select \key Tab to move between the variables and specify values for
    them. When you specify a value for a variable, all instances of the variable
    within the snippet are renamed.

    \image {qmldesigner-code-completion.png } {C++ code snippet}
    \caption C++ code snippet.

    \image {qml-code-snippet.png}{QML code snippet}
    \caption QML code snippet.

    \sa {Add code snippets to the auto-complete menu}, {Complete CMake code},
    {Completion}, {Nim}, {Snippets}
*/

/*!
    \page creator-preferences-text-editor-completion.html
    \previouspage creator-reference.html

    \ingroup creator-reference-editors

    \title Completion

    \brief Set preferences for code completion and inserting matching characters
    in the text editor.

    To set preferences for code completion, select \preferences >
    \uicontrol {Text Editor} > \uicontrol Completion.

    \image {qtcreator-preferences-texteditor-completion.webp} {Completion tab in Text Editor preferences}

    \section1 Code completion behavior

    By default, code completion does not consider case. To apply full or
    first-letter case-sensitivity, select \uicontrol Full or
    \uicontrol {First Letter} in the \uicontrol {Case-sensitivity} field.

    By default, code completion is always invoked, but you can change this
    behavior in the \uicontrol {Activate completion} field to invoke
    it \uicontrol Manually or \uicontrol {When Triggered}.

    You can set a timeout in milliseconds for code completion in the
    \uicontrol {Timeout in ms} field.

    In the \uicontrol {Character threshold} field, specify the number of
    characters you need to enter before code completion is triggered.

    When completion is invoked manually, \QC completes the common prefix of the
    list of suggestions. This is especially useful for classes with several
    similarly named members. To disable this functionality, clear
    \uicontrol {Autocomplete common prefix}.

    Select \uicontrol {Automatically split strings} to split
    a string to two lines by adding an end quote at the cursor position when
    you select \key Enter and a start quote at the beginning of the next line,
    before the rest of the string. In addition, selecting \key {Shift+Enter}
    inserts an escape character at the cursor position and moves the rest of
    the string to the next line.

    \section1 Automatically inserting matching characters

    When you have selected code and enter brackets or quotes, the matching
    closing character is added automatically at the end of the selection.

    By default, the automatically inserted text is highlighted and animated,
    skipped when you type, and removed when you select \key Backspace.

    \sa {Configure editors}{How to: Configure editors}, {Complete CMake code},
    {Complete code}, {Enclose code in brackets or quotes}, {Nim}
*/

/*!
    \page creator-preferences-text-editor-shippets.html
    \previouspage creator-reference.html

    \ingroup creator-reference-editors

    \title Snippets

    \brief Add, change, and remove snippets in the snippet editor.

    To add, change, and remove snippets in the snippet editor, select
    \preferences > \uicontrol {Text Editor} > \uicontrol Snippets.

    \QC has built-in snippets in the following categories:

    \list
        \li Text snippets, which can have any text string. For example, code
            comments
        \li C++ code snippets, which specify C++ code constructs
        \li CMake code snippets that you can use when editing \c CMakeLists.txt
            files in the CMake editor
        \li QML code snippets, which specify QML code constructs
        \li Nim code snippets, which specify Nim code constructs
    \endlist

    \image {qtcreator-edit-code-snippets.png} {Built in C++ code snippets in the Snippets tab in Text Editor preferences}
    \caption Built-in C++ code snippets.

    \image {qml-snippet-editor.png} {Built-in QML code snippets in the Snippets tab in Text Editor preferences}
    \caption Built-in QML code snippets.

    \section1 Editing snippets

    Select a snippet in the list to edit it in the snippet editor.

    The snippet editor offers:

    \list

        \li Highlighting

        \li Indentation

        \li Parentheses matching

        \li Basic code completion

    \endlist

    Specify the variables for the snippets in the following format:

    \code
    $variable$
    \endcode

    Specify \QC variables in the following format:

    \code
    %{variable}
    \endcode

    For example, the following variable expands to the name of the
    project containing the file that is currently open in the editor:
    \c {%{CurrentDocument:Project:Name}}.

    Use unique variable names within a snippet because all instances of a
    variable are renamed when you specify a value for it.

    To determine the case of values you enter in snippets, use the following
    modifiers:

    \list

        \li \c {:c} converts the initial letter of the string to upper case

        \li \c {:l} converts the string to lower case

        \li \c {:u} converts the string to upper case

    \endlist

    For example, add the following line to the \c class snippet to specify that
    the function name is converted to all lower case characters regardless of
    how you specify the value of the \c{$name$} variable:

    \code
        void $name:l$() {}
    \endcode

    \image {qtcreator-snippet-modifiers.png} {Snippet modifiers in the snippet editor}

    The snippet editor does not check the syntax of the snippets that you edit
    or add. However, when you use the snippets, the code editor marks any
    errors by underlining them in red.

    To discard the changes you made to a built-in snippet, select
    \uicontrol {Revert Built-in}.

    \section1 Removing snippets

    The list of suggestions might show several similar built-in snippets for
    different use cases. To make it shorter when you write code, remove the
    built-in snippets that you do not need. If you need them later, you can
    restore them.

    To remove snippets, select a snippet in the list, and then select
    \uicontrol Remove. To restore the removed snippets, select
    \uicontrol {Restore Removed Built-ins}.

    \section1 Resetting snippets

    To remove all added snippets and to restore all removed snippets, select
    \uicontrol {Reset All}.

    \note If you now select \uicontrol Apply, you permanently
    lose all your own snippets.

    \sa {Add code snippets to the auto-complete menu}, {Complete CMake code},
    {Complete code}, {Document code},
    {Configure editors}{How to: Configure editors}, {Use \QC variables},
    {Completion}, {Nim}
*/

/*!
    \page creator-how-to-add-code-snippets.html
    \previouspage creator-how-tos.html

    \ingroup creator-how-to-configure-editors

    \title Add code snippets to the auto-complete menu

    To add code or text snippets in the snippet editor:

    \list 1
        \li Select \preferences > \uicontrol {Text Editor} > \uicontrol Snippets.
            \image {qtcreator-snippet-modifiers.png} {Snippets tab in Text Editor preferences}
        \li In \uicontrol Group, select the type of snippet to add.
        \li Select \uicontrol Add.
        \li Specify a trigger. If the trigger is already in use, add an optional
            variant. They appear in the list of suggestions when you write code.
            Also specify a text string or C++ or QML code construct
            in the snippet editor, depending on the snippet category.

            You can use \l{Use \QC variables}{predefined variables} in
            snippets.
    \endlist

    \sa {Complete CMake code}, {Complete code}, {Use \QC variables},
    {Completion}, {Nim}, {Snippets}
*/
