From ef708b8ba22eba5210fc72bbeb16cc2aa3d504fa Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 30 Aug 2025 15:57:52 +0000 Subject: [PATCH 1/5] Initial plan From d1301f8243c4fba2d70e8e7c669dce7e481866e9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 30 Aug 2025 16:03:20 +0000 Subject: [PATCH 2/5] Initial analysis and plan for implementing configurable indent guides Co-authored-by: sunderme <14033169+sunderme@users.noreply.github.com> --- additionaltranslations.o | Bin 0 -> 952 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 additionaltranslations.o diff --git a/additionaltranslations.o b/additionaltranslations.o new file mode 100644 index 0000000000000000000000000000000000000000..6f58ae46fad4cffd0f2b566a2adc34e1b21f6271 GIT binary patch literal 952 zcmbVK%}N6?5T32|_oO#L59>(<8`idpc#wrsdl7F1uh}28xPNT2U@!U#K2jgVm+%R6 zCQUSE!9xdTCi8vsWs}*wjqh$do(IM}xPjlwpa54E7%Dh~9oPn#j7Hb~$uw#T+4$!J zHef;TvQcIKwLfIR@KnP})y24rzK%Y*pF#&Nv{4IoGd_R literal 0 HcmV?d00001 From 12fc5c6151d424a44e41ade41b0c35c66d4dc79f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 30 Aug 2025 16:07:38 +0000 Subject: [PATCH 3/5] Add basic configuration setup for indent guides feature Co-authored-by: sunderme <14033169+sunderme@users.noreply.github.com> --- additionaltranslations.o | Bin 952 -> 0 bytes src/configdialog.ui | 8 ++++++++ src/configmanager.cpp | 5 +++-- src/latexeditorview.cpp | 1 + src/latexeditorview_config.h | 1 + src/qcodeedit/lib/qeditor.h | 8 +++++--- 6 files changed, 18 insertions(+), 5 deletions(-) delete mode 100644 additionaltranslations.o diff --git a/additionaltranslations.o b/additionaltranslations.o deleted file mode 100644 index 6f58ae46fad4cffd0f2b566a2adc34e1b21f6271..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 952 zcmbVK%}N6?5T32|_oO#L59>(<8`idpc#wrsdl7F1uh}28xPNT2U@!U#K2jgVm+%R6 zCQUSE!9xdTCi8vsWs}*wjqh$do(IM}xPjlwpa54E7%Dh~9oPn#j7Hb~$uw#T+4$!J zHef;TvQcIKwLfIR@KnP})y24rzK%Y*pF#&Nv{4IoGd_R diff --git a/src/configdialog.ui b/src/configdialog.ui index d8684f25ae..9f4ab66532 100644 --- a/src/configdialog.ui +++ b/src/configdialog.ui @@ -1698,6 +1698,13 @@ Then you can select a new shortcut by one of the following ways: + + + + Show Indent Guides + + + @@ -5111,6 +5118,7 @@ Note: Changing this setting will only affect documents that are opened afterward spinBoxSize comboBoxEncoding checkBoxFolding + checkBoxShowIndentGuides comboBoxAutoIndent comboBoxReplaceQuotes checkBoxRealTimeCheck diff --git a/src/configmanager.cpp b/src/configmanager.cpp index 7ef6ffb68d..cbac5fd047 100644 --- a/src/configmanager.cpp +++ b/src/configmanager.cpp @@ -533,8 +533,9 @@ ConfigManager::ConfigManager(QObject *parent): QObject (parent), registerOption("Editor/Indent with Spaces", &editorConfig->replaceIndentTabs, false, &pseudoDialog->checkBoxReplaceIndentTabByWhitespace); registerOption("Editor/ReplaceTextTabs", &editorConfig->replaceTextTabs, false, &pseudoDialog->checkBoxReplaceTextTabByWhitespace); registerOption("Editor/RemoveTrailingWsOnSave", &editorConfig->removeTrailingWsOnSave, false, &pseudoDialog->checkboxRemoveTrailingWsOnSave); - registerOption("Editor/Folding", &editorConfig->folding, true, &pseudoDialog->checkBoxFolding); - registerOption("Editor/Show Line State", &editorConfig->showlinestate, true, &pseudoDialog->checkBoxLineState); + registerOption("Editor/Folding", &editorConfig->folding, true, &pseudoDialog->checkBoxFolding); + registerOption("Editor/Show Line State", &editorConfig->showlinestate, true, &pseudoDialog->checkBoxLineState); + registerOption("Editor/Show Indent Guides", &editorConfig->showIndentGuides, false, &pseudoDialog->checkBoxShowIndentGuides); registerOption("Editor/Show Cursor State", &editorConfig->showcursorstate, true, &pseudoDialog->checkBoxState); registerOption("Editor/Real-Time Spellchecking", &editorConfig->realtimeChecking, true, &pseudoDialog->checkBoxRealTimeCheck); //named for compatibility reasons with older txs versions registerOption("Editor/Check Spelling", &editorConfig->inlineSpellChecking, true, &pseudoDialog->checkBoxInlineSpellCheck); diff --git a/src/latexeditorview.cpp b/src/latexeditorview.cpp index 949cf667b2..353ecaf40f 100644 --- a/src/latexeditorview.cpp +++ b/src/latexeditorview.cpp @@ -1859,6 +1859,7 @@ void LatexEditorView::updateSettings() editor->setFlag(QEditor::VerticalOverScroll, config->verticalOverScroll); editor->setFlag(QEditor::AutoInsertLRM, config->autoInsertLRM); editor->setFlag(QEditor::BidiVisualColumnMode, config->visualColumnMode); + editor->setFlag(QEditor::ShowIndentGuides, config->showIndentGuides); editor->setFlag(QEditor::OverwriteOpeningBracketFollowedByPlaceholder, config->overwriteOpeningBracketFollowedByPlaceholder); editor->setFlag(QEditor::OverwriteClosingBracketFollowingPlaceholder, config->overwriteClosingBracketFollowingPlaceholder); //TODO: parenmatch diff --git a/src/latexeditorview_config.h b/src/latexeditorview_config.h index 01a0a5df2e..20a86e3d37 100644 --- a/src/latexeditorview_config.h +++ b/src/latexeditorview_config.h @@ -21,6 +21,7 @@ class LatexEditorViewConfig int cursorSurroundLines; bool boldCursor; bool centerDocumentInEditor; + bool showIndentGuides; bool folding, showlinestate, showcursorstate, realtimeChecking; bool inlineSpellChecking, inlineCitationChecking, inlineReferenceChecking, inlineSyntaxChecking, inlineGrammarChecking, inlinePackageChecking; bool inlineCheckNonTeXFiles; diff --git a/src/qcodeedit/lib/qeditor.h b/src/qcodeedit/lib/qeditor.h index cf227a1839..6a137a2a65 100644 --- a/src/qcodeedit/lib/qeditor.h +++ b/src/qcodeedit/lib/qeditor.h @@ -106,9 +106,11 @@ class QCE_EXPORT QEditor : public QAbstractScrollArea AutoCloseChars = 0x00200000, AutoIndent = 0x00400000, WeakIndent = 0x00800000, - AutoInsertLRM = 0x01000000, - BidiVisualColumnMode= 0x02000000, - + AutoInsertLRM = 0x01000000, + BidiVisualColumnMode= 0x02000000, + + ShowIndentGuides = 0x04000000, + ShowPlaceholders = 0x10000000, OverwriteOpeningBracketFollowedByPlaceholder = 0x20000000, OverwriteClosingBracketFollowingPlaceholder = 0x40000000, From 0d2792157bf7db82ce011fbc34ab483ff254d3d6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 30 Aug 2025 16:11:03 +0000 Subject: [PATCH 4/5] Implement basic indent guides drawing with reviewer feedback addressed Co-authored-by: sunderme <14033169+sunderme@users.noreply.github.com> --- additionaltranslations.o | Bin 0 -> 952 bytes src/qcodeedit/lib/qeditor.cpp | 72 +++++++++++++++++++++++++++++++--- src/qcodeedit/lib/qeditor.h | 5 ++- 3 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 additionaltranslations.o diff --git a/additionaltranslations.o b/additionaltranslations.o new file mode 100644 index 0000000000000000000000000000000000000000..6f58ae46fad4cffd0f2b566a2adc34e1b21f6271 GIT binary patch literal 952 zcmbVK%}N6?5T32|_oO#L59>(<8`idpc#wrsdl7F1uh}28xPNT2U@!U#K2jgVm+%R6 zCQUSE!9xdTCi8vsWs}*wjqh$do(IM}xPjlwpa54E7%Dh~9oPn#j7Hb~$uw#T+4$!J zHef;TvQcIKwLfIR@KnP})y24rzK%Y*pF#&Nv{4IoGd_R literal 0 HcmV?d00001 diff --git a/src/qcodeedit/lib/qeditor.cpp b/src/qcodeedit/lib/qeditor.cpp index ed6ad4396f..b362a05636 100644 --- a/src/qcodeedit/lib/qeditor.cpp +++ b/src/qcodeedit/lib/qeditor.cpp @@ -3213,8 +3213,10 @@ void QEditor::paintEvent(QPaintEvent */*e*/) const QRectF rect(0, 0, width, height); p.fillRect(rect, bg); - p.save(); - m_doc->draw(&p, ctx); + p.save(); + // Draw indent guides first so they appear behind text + drawIndentGuides(&p, ctx); + m_doc->draw(&p, ctx); p.restore(); //qDebug("drawn %d ms",tm.elapsed()); @@ -6468,9 +6470,69 @@ void QEditor::removeAllMarks(){ scrlBar->removeAllShades(); } -void QEditor::addMarkRange(int start, int end, QColor color, QString type){ - MarkedScrollBar *scrlBar=qobject_cast(verticalScrollBar()); - scrlBar->addShade(start,end,color,type); +void QEditor::addMarkRange(int start, int end, QColor color, QString type){ + MarkedScrollBar *scrlBar=qobject_cast(verticalScrollBar()); + scrlBar->addShade(start,end,color,type); +} + +/*! + \brief Draw indent guides (vertical lines showing indentation levels) +*/ +void QEditor::drawIndentGuides(QPainter *painter, const QDocument::PaintContext &ctx) +{ + if (!flag(ShowIndentGuides) || !m_doc) { + return; + } + + const QFontMetrics fm = fontMetrics(); + const int tabSize = m_doc->tabStop(); + const int charWidth = fm.averageCharWidth(); + + // Use a very subtle color for the guides + QColor guideColor = palette().color(QPalette::Text); + guideColor.setAlpha(50); // Make it very subtle + + painter->save(); + painter->setPen(QPen(guideColor, 1, Qt::DotLine)); + + const int firstLine = qMax(0, int((ctx.yoffset) / m_doc->getLineSpacing())); + const int lastLine = qMin(firstLine + int(ctx.height / m_doc->getLineSpacing()) + 2, m_doc->lines() - 1); + + // Only draw guides on lines that actually have indentation + for (int line = firstLine; line <= lastLine; ++line) { + QDocumentLine docLine = m_doc->line(line); + if (!docLine.isValid()) continue; + + QString text = docLine.text(); + if (text.trimmed().isEmpty()) continue; // Skip empty lines + + // Calculate indentation level + int indentLevel = 0; + int i = 0; + while (i < text.length() && text[i].isSpace()) { + if (text[i] == '\t') { + indentLevel += tabSize - (indentLevel % tabSize); // Round up to next tab stop + } else { + indentLevel += 1; + } + i++; + } + + if (indentLevel == 0) continue; // Skip lines with no indentation + + // Draw vertical guides for this line's indentation levels + const qreal lineY = line * m_doc->getLineSpacing(); + const qreal lineHeight = m_doc->getLineSpacing(); + + for (int level = tabSize; level <= indentLevel; level += tabSize) { + qreal x = level * charWidth; + if (x < ctx.width && x > 0) { + painter->drawLine(QPointF(x, lineY), QPointF(x, lineY + lineHeight)); + } + } + } + + painter->restore(); } /*! @} */ diff --git a/src/qcodeedit/lib/qeditor.h b/src/qcodeedit/lib/qeditor.h index 6a137a2a65..35fbd624f0 100644 --- a/src/qcodeedit/lib/qeditor.h +++ b/src/qcodeedit/lib/qeditor.h @@ -670,8 +670,9 @@ public slots: Conflict }; - void init(bool actions = true,QDocument *doc=0); - void updateBindingsMenu(); + void init(bool actions = true,QDocument *doc=0); + void updateBindingsMenu(); + void drawIndentGuides(QPainter *painter, const QDocument::PaintContext &ctx); QMenu *pMenu; QHash m_actions; From cb3e7d9eabf636b9e5601a3dd3a319eed3395eea Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 30 Aug 2025 16:12:10 +0000 Subject: [PATCH 5/5] Clean up build artifacts and improve gitignore Co-authored-by: sunderme <14033169+sunderme@users.noreply.github.com> --- .gitignore | 1 + additionaltranslations.o | Bin 952 -> 0 bytes 2 files changed, 1 insertion(+) delete mode 100644 additionaltranslations.o diff --git a/.gitignore b/.gitignore index b6bfc8af1d..f61f086dd5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .moc Makefile .obj +*.o .ui .vscode .cache diff --git a/additionaltranslations.o b/additionaltranslations.o deleted file mode 100644 index 6f58ae46fad4cffd0f2b566a2adc34e1b21f6271..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 952 zcmbVK%}N6?5T32|_oO#L59>(<8`idpc#wrsdl7F1uh}28xPNT2U@!U#K2jgVm+%R6 zCQUSE!9xdTCi8vsWs}*wjqh$do(IM}xPjlwpa54E7%Dh~9oPn#j7Hb~$uw#T+4$!J zHef;TvQcIKwLfIR@KnP})y24rzK%Y*pF#&Nv{4IoGd_R