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

// **********************************************************************
// NOTE: the sections are not ordered by their logical order to avoid
// reshuffling the file each time the index order changes (i.e., often).
// Run the fixnavi.pl script to adjust the links to the index order.
// **********************************************************************

/*!
    \page creator-diff-editor.html
    \previouspage creator-how-tos.html

    \ingroup creator-how-to-edit

    \title Compare files

    You can view unsaved changes in the current file or all open files,
    as well as compare any two text files. They can be either versions of
    the same file or arbitrary files.

    \section1 View unsaved changes

    To view unsaved changes in the current file, go to \uicontrol Tools >
    \uicontrol Diff > \uicontrol {Diff Current File}.

    To view unsaved changes in all open files, go to \uicontrol Tools >
    \uicontrol Diff > \uicontrol {Diff Open Files}.

    \section1 Compare two files

    To compare two files:

    \list 1

        \li Go to \uicontrol Tools > \uicontrol Diff >
            \uicontrol {Diff External Files}.

        \li Select two files to compare.

    \endlist

    To compare the currently opened file against another file in a project
    or the file system:

    \list 1

        \li Open the first file in an editor.

        \li Right-click the second file in the \uicontrol Projects
            or \uicontrol {File System} view and select
            \uicontrol {Diff Against Current File}.

    \endlist

    If \QC cannot detect the encoding of the files to compare, an info bar
    displays the option to reload the document using some other
    encoding. For more information, see \l {Change text encoding}.

    \section1 View changes

    \image {creator-diff-editor.png} {Diff editor output in the Edit mode}

    View the changes in the \uicontrol Edit mode. Color coding is
    used to mark changed lines. By default, red indicates lines that contain
    removed text (painted another shade of red) in the left pane and green
    indicates lines that contain added text (painted another shade of green)
    in the right pane.

    To view the differences in a unified view where changed rows are placed
    below each other, select
    \inlineimage {icons/unifieddiff.png} {Switch to Unified Diff Editor}
    (\uicontrol {Switch to Unified Diff Editor}).

    To switch back to the side-by-side view, select
    \inlineimage {icons/sidebysidediff.png} {Switch to Side by Side Diff Editor}
    (\uicontrol {Switch to Side by Side Diff Editor}).

    To only show text changes, select \uicontrol {Ignore Whitespace}.

    To expand the context for the changes, set the number of unchanged lines to
    show in \uicontrol {Context lines}.

    By default, the horizontal scroll bars in the left and right pane are
    synchronized. To use them independently of each other, select
    \inlineimage {icons/linkicon.png} {Synchronize Horizontal Scroll Bars}
    (\uicontrol {Synchronize Horizontal Scroll Bars}).

    \section1 Revert and apply changes

    To revert the changes, right-click added text and then select
    \uicontrol {Revert Chunk} in the context menu.

    To apply the changes, select removed text and then select
    \uicontrol {Apply Chunk}.

    \section1 Reload files

    If the files change outside \QC, select
    \inlineimage {icons/reload_gray.png} {Reload Editor}
    (\uicontrol {Reload Editor}) to compare them again and to show the results.

    \if defined(qtcreator)
    \section1 Paste changes for review

    To send a chunk of changes to a \l{Paste and fetch code snippets}
    {code pasting service}, select \uicontrol {Send Chunk to CodePaster} in the
    context menu.
    \endif

    \section1 Change colors

    To change the default colors, go to \preferences >
    \uicontrol {Text Editor} > \uicontrol {Font & Colors}. Create your own color
    scheme and select new colors for the following items:

    \list

        \li \uicontrol {Diff File Line} sets the color of the line that shows
            the path and filename of the changed file.

        \li \uicontrol {Diff Context Line} sets the color of the line that
            shows the number of hidden lines between changed lines.

        \li \uicontrol {Diff Source Line} sets the color of lines that contain
            removed text.

        \li \uicontrol {Diff Source Character} sets the color that indicates
            removed characters.

        \li \uicontrol {Diff Destination Line} sets the color of lines that
            contain added text.

        \li \uicontrol {Diff Destination Character} sets the color that
            indicates added characters.

    \endlist

    \sa {Paste and fetch code snippets}
*/
