aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/plaintextedit/plaintextedit.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Utils: fix layout update ranges on document changes againDavid Schulz2025-10-011-1/+1
| | | | | | | | | | | | | amends 37545e6d0060d644edf75995201cfb49f2126855 The assumption that from always points at the first character that differs was wrong. The range can start with unmodified content. So in total it is not save to base the end position for clear layouts on the diff between added and removed characters, but we always need to clear layout from 'from' to 'from + charsAdded'. Change-Id: I5ad2678818b089f1ab722006bc1cb9e9ae9ec196 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Utils: use QTC_ASSERT instead of Q_ASSERT or removeDavid Schulz2025-09-301-2/+1
| | | | | Change-Id: Ia65b241fecd56c21864c89a10b66ed4d6d1ae8a8 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Utils: fix layout update ranges on document changesDavid Schulz2025-09-301-2/+2
| | | | | | | Fixes an issue with missing highlights in lines. Change-Id: I38d6b23dae4327c8e215865f369ec2cf3c58e14e Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Utils: Tweak compressing scrollbar updatesChristian Stenger2025-09-251-1/+6
| | | | | | | | | | | In case there is an updated scheduled already when updating the top block of the widget we might end up with an uninitialized scrollbar on first open. Fixes jumping to correct line when using git blame. Amends 3b5dd15562bdc9660395dc9d014f5374a32ebb1c. Change-Id: I339519259c354c3f473331e1d3dfe1a8876123ae Reviewed-by: David Schulz <david.schulz@qt.io>
* Utils: fix scrolling to end of documentDavid Schulz2025-09-251-2/+5
| | | | | Change-Id: I6346fede81ece0bcce8a1ca8068aac5b69e34c15 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Utils: avoid using QFontMetricsF::lineSpacing for block offsetDavid Schulz2025-09-241-1/+10
| | | | | | | | | | | | QScriptLine that is used in the QTextLayout implementation only takes positive leading into account when calculating the line height. If we assume the QFontMetricsF::lineSpacing as the offset for unlayouted blocks we get a lot unnecessary updates during the layout process. So provide a static function in PlainTextDocumentLayout that provides a lineSpacing that is closer to the lineSpacing in a plain text document. Change-Id: I0ee114cf29f8a2fcbd5a2efe3fcea636a98c7739 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Utils: ensure the offset cache is cleared after block size changesDavid Schulz2025-09-241-2/+13
| | | | | | | | | | If the size of a layouted block is different than our assumed block size we need to make sure that the offset cache is cleared for all items that follow this block, otherwise the adjust scrollbar call uses wrong offsets wich results in wrong scrollbar ranges. Change-Id: I245e12e2b1b2c7822079f61e42b5bf18f617a168 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Utils: compress scrollbar updatesDavid Schulz2025-09-241-4/+15
| | | | | | | | | Push an update of the scrollbar to the end of the eventloop to avoid updating the scrollbar multiple times for multiple document changes in a single loop iteration. Change-Id: Ia08ff7c047278e5cfa6eeb492bb132949df52040 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Utils: fix clearing layout data after document changesDavid Schulz2025-09-151-1/+1
| | | | | | Fixes: QTCREATORBUG-33308 Change-Id: I1f5f86ec14932d00f2bb8815cbc299ed01c11486 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: improve page up/down in plain text editDavid Schulz2025-09-111-88/+19
| | | | | | | | | | Just increasing the scrollbar by page step and moving the cursor to the closest previous vertical offset is way cleaner than the previous aproach. Fixes: QTCREATORBUG-33447 Change-Id: I8c6fcfabd263d11ac088f93d34967c2a0682e61b Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Utils: Set pagestep to a multiple of line heightDavid Schulz2025-09-111-1/+2
| | | | | | | | This will usually result in having the same block offset after increasing the scrollbar value by page step. Change-Id: I6e16dd52af2f6c0269b07329085b37dfaf565c94 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* TextEditor: Fix embedded Widget positioningMarcus Tillmanns2025-09-081-2/+8
| | | | | Change-Id: If3267f6fca4a2abbcb4d4917653f814209283ea4 Reviewed-by: David Schulz <david.schulz@qt.io>
* Utils: introduce additional layout items per block layoutDavid Schulz2025-08-281-28/+36
| | | | | Change-Id: Idceed0491f610637d38defece1643686f95151d5 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Utils: fix setTopBlock for blocks close to the bottom of the fileDavid Schulz2025-08-251-5/+8
| | | | | | | | | This ensures we do not set the top block number to a value that is not reachable with the current scrollbar max value. Fixes: QTCREATORBUG-33319 Change-Id: I150c4ba420416b059302848437fc5041e1dcdc0e Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* Editor: use one layout per editor instead of per documentDavid Schulz2025-07-181-199/+219
| | | | | | | | | This allows to wrap one document differently in editors with a different width. In the future this will allow us also to display additional information in just a single editor. Change-Id: Ie1a07517be8756c473207e0db58f7d9924fdb5b1 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Merge remote-tracking branch 'origin/17.0'Eike Ziller2025-07-021-128/+124
|\ | | | | | | | | | | | | | | | | | | Conflicts: cmake/QtCreatorIDEBranding.cmake qbs/modules/qtc/qtc.qbs src/plugins/coreplugin/plugininstallwizard.cpp src/plugins/coreplugin/textdocument.cpp Change-Id: I6c8d13a019f1e7142856037481172889f69ae971
| * Doc: Fix QDoc warnings for PlainTextDocumentLayout and PlainTextEditLeena Miettinen2025-06-231-128/+119
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Add the Utils namespace to \class commands and \property commands to show the docs - Remove \since commands because they refer to Qt versions - Use \inmodule QtCreator - Remove \reimp commands or replace them with \overload - Marks some docs \internal - Add \c formatting for references to functions that are not documented - Consistently format true and false with \c - Replaced references to code snippets in the Qt module docs with hard-coded snippets - Fix other minor issues Change-Id: I63da28c137145d65c6455540fa55d4dc5761318c Reviewed-by: David Schulz <david.schulz@qt.io>
| * DiffEditor: fix jumping to selected file from toolbar dropdownDavid Schulz2025-06-191-0/+5
| | | | | | | | | | Change-Id: I968ddc798c6f66072947031bab2dd3855a99bdee Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
* | Merge remote-tracking branch 'origin/17.0'Eike Ziller2025-06-171-1/+1
|\| | | | | | | | | | | | | | | Conflicts: cmake/QtCreatorIDEBranding.cmake qbs/modules/qtc/qtc.qbs Change-Id: Iac555437405e993475736232b3cf2402cf9fe8ed
| * Editor: fix artifacts when scrolling horizontallyDavid Schulz2025-06-051-1/+1
| | | | | | | | | | | | | | ... while the topline is only partially visible. Change-Id: I21d0f576c70f91dd804cb71cf60f62c06f11fe77 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* | Merge remote-tracking branch 'origin/17.0'Eike Ziller2025-06-041-5/+12
|\| | | | | | | | | | | | | Conflicts: tests/auto/utils/unarchiver/unarchiver.qbs Change-Id: Id20ff632e87c22147fb2f7a355cf7cc00ff5086c
| * Utils: fix expected block heightDavid Schulz2025-06-021-5/+12
| | | | | | | | | | | | | | | | | | | | | | The assumtion that QFontMetrics::lineSpacing is equal to the height of a text layout with a single line is wrong. In the layouting process the height is rounded up, but in QFontMetrics::lineSpacing it is rounded to the closest integer. Fixes: QTCREATORBUG-32979 Change-Id: Ic0dc9016d0e9cdca0691b3fc3f88868b11b8950a Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* | PlainTextEdit: avoid layouting invisible blocksDavid Schulz2025-05-221-13/+9
|/ | | | | Change-Id: I983e4c74a9a2d5c271056a75a5301e566076f524 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Utils: Silence warning about unused parameterChristian Stenger2025-05-131-1/+1
| | | | | | | Amends 333beeb8223fad146ee78bc646640d529d3f01d2. Change-Id: I8b071904691e086dc0e35b10ff8ec854c0bc586a Reviewed-by: David Schulz <david.schulz@qt.io>
* Utils: do not reset documentLayoutPtr on relayoutDocumentDavid Schulz2025-05-131-9/+7
| | | | | | | | The code paths that changes the document layout already resets the member. Change-Id: I6045ff9c9da2c7e14811234a33c43b670973786f Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Utils: enable per pixel scrolling in PlainTextEditDavid Schulz2025-05-131-75/+113
| | | | | Change-Id: Id693de1d3a5f2f272523d7f8608901a505687ce4 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Editor: fix squish testsDavid Schulz2025-04-291-0/+5
| | | | | | | | | | | | Changing the base of TextEditor::TextEditorWidget from QPlainTextEdit to Utils::PlainTextEdit made some functions of the base class inaccessible for squish. So we need to use the properties or make the used functions available via Q_PROPERTY. Fixes: QTCREATORBUG-32776 Change-Id: Ie3c45b2de958a9b82a4b4323558830c993187c52 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io>
* Editor: optimize clearing layouts after edit width changeDavid Schulz2025-04-161-1/+11
| | | | | Change-Id: Ic3f700c48f05e2d231021379a5e154b23c2d1858 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Fix warning for ';'Marco Bubke2025-04-151-4/+4
| | | | | | | | The macro already contain a ';'. Removing the argument or [[maybe_unused]] would maybe even a better approach. Change-Id: I31750d10a4f252c667e7c0e5e13bf1085dbe11a2 Reviewed-by: hjk <hjk@qt.io>
* Utils: Fix warningsMarcus Tillmanns2025-04-081-1/+3
| | | | | Change-Id: Ibc8eb9b5aac4329cc38f4e8e0421d17d8628d2bf Reviewed-by: David Schulz <david.schulz@qt.io>
* Editor: Fork QPlainTextEditDavid Schulz2025-04-021-0/+3222
The layout of a text editor is part of the document and not the editor. This results in not being able to position blocks differently in multiple editors. As a first step fork QPlainTextEdit with all the private dependencies. Change-Id: Ie2da2613a966fe1958b6dbade4b7ff40e8858f62 Reviewed-by: Eike Ziller <eike.ziller@qt.io>