From c50b87a6dc3cbefd4466e91f1b703758947f39fe Mon Sep 17 00:00:00 2001 From: Matthew Yang Date: Mon, 27 Oct 2025 07:11:18 -0700 Subject: [PATCH 1/8] Create new checkbox for bookmarkin --- src/NotepadNext/dialogs/FindReplaceDialog.cpp | 2 ++ src/NotepadNext/dialogs/FindReplaceDialog.ui | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/NotepadNext/dialogs/FindReplaceDialog.cpp b/src/NotepadNext/dialogs/FindReplaceDialog.cpp index cb29307ad..56d5e1386 100644 --- a/src/NotepadNext/dialogs/FindReplaceDialog.cpp +++ b/src/NotepadNext/dialogs/FindReplaceDialog.cpp @@ -502,6 +502,7 @@ void FindReplaceDialog::changeTab(int index) ui->buttonReplaceAllInFiles->hide(); ui->buttonFindInFilesSelector->hide(); + ui->checkBoxMarkRes->show(); ui->buttonCount->show(); ui->buttonFindAllInCurrent->show(); ui->buttonFindAllInDocuments->show(); @@ -521,6 +522,7 @@ void FindReplaceDialog::changeTab(int index) ui->buttonReplaceAllInFiles->show(); ui->buttonFindInFilesSelector->show(); + ui->checkBoxMarkRes->hide(); ui->buttonCount->hide(); ui->buttonFindAllInCurrent->hide(); ui->buttonFindAllInDocuments->hide(); diff --git a/src/NotepadNext/dialogs/FindReplaceDialog.ui b/src/NotepadNext/dialogs/FindReplaceDialog.ui index 5d18604fe..20410275f 100644 --- a/src/NotepadNext/dialogs/FindReplaceDialog.ui +++ b/src/NotepadNext/dialogs/FindReplaceDialog.ui @@ -11,10 +11,10 @@ - - 600 - 350 - + + 600 + 350 + Find @@ -470,6 +470,13 @@ 0 + + + + Mark Results + + + From a21fa0747f84ced92d23d7d40876c75524521305 Mon Sep 17 00:00:00 2001 From: Matthew Yang Date: Mon, 27 Oct 2025 07:18:17 -0700 Subject: [PATCH 2/8] Add some (non-working) code for line markers --- src/NotepadNext/dialogs/FindReplaceDialog.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/NotepadNext/dialogs/FindReplaceDialog.cpp b/src/NotepadNext/dialogs/FindReplaceDialog.cpp index 56d5e1386..120c50ee7 100644 --- a/src/NotepadNext/dialogs/FindReplaceDialog.cpp +++ b/src/NotepadNext/dialogs/FindReplaceDialog.cpp @@ -330,6 +330,9 @@ void FindReplaceDialog::findAllInCurrentDocument() } const int line = editor->lineFromPosition(start); + if (ui->checkBoxMarkRes->isChecked()) { + editor->markerAdd(line, 1); + } const int lineStartPosition = editor->positionFromLine(line); const int lineEndPosition = editor->lineEndPosition(line); const int startPositionFromBeginning = start - lineStartPosition; From fe701d967f5bc5790700c2f93a069cb6262cdf9d Mon Sep 17 00:00:00 2001 From: Matthew Yang Date: Mon, 27 Oct 2025 20:35:00 -0700 Subject: [PATCH 3/8] Use both marker decorators & don't use unusable Scintilla default bindings --- src/NotepadNext/dialogs/FindReplaceDialog.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/NotepadNext/dialogs/FindReplaceDialog.cpp b/src/NotepadNext/dialogs/FindReplaceDialog.cpp index 120c50ee7..062dc6bce 100644 --- a/src/NotepadNext/dialogs/FindReplaceDialog.cpp +++ b/src/NotepadNext/dialogs/FindReplaceDialog.cpp @@ -20,6 +20,8 @@ #include "FindReplaceDialog.h" #include "ApplicationSettings.h" #include "ui_FindReplaceDialog.h" +#include "MarkerAppDecorator.h" +#include "BookMarkDecorator.h" #include #include @@ -317,6 +319,10 @@ void FindReplaceDialog::findAllInCurrentDocument() { qInfo(Q_FUNC_INFO); + qDebug() << "Editor pointer:" << editor; + + BookMarkDecorator *bookMarkDecorator = editor->findChild(QString(), Qt::FindDirectChildrenOnly); + bool firstMatch = true; QString text = findString(); @@ -330,8 +336,17 @@ void FindReplaceDialog::findAllInCurrentDocument() } const int line = editor->lineFromPosition(start); + qDebug() << "Found result on line " << line; if (ui->checkBoxMarkRes->isChecked()) { - editor->markerAdd(line, 1); + qDebug() << "Marking result at line " << line; + bookMarkDecorator->toggleBookmark(line); + auto app = qobject_cast(qApp); + MarkerAppDecorator *decorator = app->findChild(QString(), Qt::FindDirectChildrenOnly); + if (decorator && decorator->isEnabled()) { + // Options: 0, 1, 2 + int markerNumber = 1; + decorator->mark(editor, markerNumber); + } } const int lineStartPosition = editor->positionFromLine(line); const int lineEndPosition = editor->lineEndPosition(line); From c879eaf91ef48acfd3c0b3f13087ec03ecb39904 Mon Sep 17 00:00:00 2001 From: Matthew Yang Date: Mon, 27 Oct 2025 20:35:10 -0700 Subject: [PATCH 4/8] Add a few pointer debugging bits --- src/NotepadNext/dialogs/MainWindow.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/NotepadNext/dialogs/MainWindow.cpp b/src/NotepadNext/dialogs/MainWindow.cpp index 13bbc6296..edecec279 100644 --- a/src/NotepadNext/dialogs/MainWindow.cpp +++ b/src/NotepadNext/dialogs/MainWindow.cpp @@ -2245,4 +2245,7 @@ void MainWindow::languageMenuTriggered() QVariant v = act->data(); setLanguage(editor, v.toString()); + + // Some debugging stuff + qDebug() << "MainWindow editor pointer:" << currentEditor(); } From ef3fd02f7f1dd70dbdbbd063a6e166a1d5d313cf Mon Sep 17 00:00:00 2001 From: Matthew Yang Date: Mon, 27 Oct 2025 20:38:11 -0700 Subject: [PATCH 5/8] Consolidate this a bit because we use this variable nowhere else --- src/NotepadNext/dialogs/FindReplaceDialog.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/NotepadNext/dialogs/FindReplaceDialog.cpp b/src/NotepadNext/dialogs/FindReplaceDialog.cpp index 062dc6bce..67816320c 100644 --- a/src/NotepadNext/dialogs/FindReplaceDialog.cpp +++ b/src/NotepadNext/dialogs/FindReplaceDialog.cpp @@ -344,8 +344,7 @@ void FindReplaceDialog::findAllInCurrentDocument() MarkerAppDecorator *decorator = app->findChild(QString(), Qt::FindDirectChildrenOnly); if (decorator && decorator->isEnabled()) { // Options: 0, 1, 2 - int markerNumber = 1; - decorator->mark(editor, markerNumber); + decorator->mark(editor, 1); } } const int lineStartPosition = editor->positionFromLine(line); From 2090a23daa820e95f5ca77d405c8e88d6b77b3dc Mon Sep 17 00:00:00 2001 From: Matthew Yang Date: Mon, 27 Oct 2025 20:42:39 -0700 Subject: [PATCH 6/8] Organize the objects by getting them earlier in the function --- src/NotepadNext/dialogs/FindReplaceDialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NotepadNext/dialogs/FindReplaceDialog.cpp b/src/NotepadNext/dialogs/FindReplaceDialog.cpp index 67816320c..11357a039 100644 --- a/src/NotepadNext/dialogs/FindReplaceDialog.cpp +++ b/src/NotepadNext/dialogs/FindReplaceDialog.cpp @@ -321,6 +321,8 @@ void FindReplaceDialog::findAllInCurrentDocument() qDebug() << "Editor pointer:" << editor; + auto app = qobject_cast(qApp); + MarkerAppDecorator *decorator = app->findChild(QString(), Qt::FindDirectChildrenOnly); BookMarkDecorator *bookMarkDecorator = editor->findChild(QString(), Qt::FindDirectChildrenOnly); bool firstMatch = true; @@ -340,8 +342,6 @@ void FindReplaceDialog::findAllInCurrentDocument() if (ui->checkBoxMarkRes->isChecked()) { qDebug() << "Marking result at line " << line; bookMarkDecorator->toggleBookmark(line); - auto app = qobject_cast(qApp); - MarkerAppDecorator *decorator = app->findChild(QString(), Qt::FindDirectChildrenOnly); if (decorator && decorator->isEnabled()) { // Options: 0, 1, 2 decorator->mark(editor, 1); From c7f2a5ec38c1e40b5cb82cd4d1402ac803f08e4d Mon Sep 17 00:00:00 2001 From: Matthew Yang Date: Tue, 28 Oct 2025 06:49:12 -0700 Subject: [PATCH 7/8] Only set a bookmark if the line ain't already marked --- src/NotepadNext/dialogs/FindReplaceDialog.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/NotepadNext/dialogs/FindReplaceDialog.cpp b/src/NotepadNext/dialogs/FindReplaceDialog.cpp index 11357a039..1b55ded92 100644 --- a/src/NotepadNext/dialogs/FindReplaceDialog.cpp +++ b/src/NotepadNext/dialogs/FindReplaceDialog.cpp @@ -340,8 +340,10 @@ void FindReplaceDialog::findAllInCurrentDocument() const int line = editor->lineFromPosition(start); qDebug() << "Found result on line " << line; if (ui->checkBoxMarkRes->isChecked()) { - qDebug() << "Marking result at line " << line; - bookMarkDecorator->toggleBookmark(line); + if (!bookMarkDecorator->isBookmarkSet(line)){ + qDebug() << "Marking result at line " << line; + bookMarkDecorator->toggleBookmark(line); + } if (decorator && decorator->isEnabled()) { // Options: 0, 1, 2 decorator->mark(editor, 1); From 78f1927ce7a1f0e37e85ce5ccee79434b1dd7a00 Mon Sep 17 00:00:00 2001 From: Matthew Yang Date: Tue, 28 Oct 2025 06:55:55 -0700 Subject: [PATCH 8/8] Give new button ability to clear all marks --- src/NotepadNext/dialogs/FindReplaceDialog.cpp | 10 ++++++++++ src/NotepadNext/dialogs/FindReplaceDialog.ui | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/src/NotepadNext/dialogs/FindReplaceDialog.cpp b/src/NotepadNext/dialogs/FindReplaceDialog.cpp index 1b55ded92..c90040570 100644 --- a/src/NotepadNext/dialogs/FindReplaceDialog.cpp +++ b/src/NotepadNext/dialogs/FindReplaceDialog.cpp @@ -207,6 +207,14 @@ FindReplaceDialog::FindReplaceDialog(ISearchResultsHandler *searchResults, MainW showMessage(tr("Replaced matches in %Ln files", "", count), "green"); }); + connect(ui->buttonClearBookmarks, &QPushButton::clicked, this, [=]() { + auto app = qobject_cast(qApp); + MarkerAppDecorator *decorator = app->findChild(QString(), Qt::FindDirectChildrenOnly); + BookMarkDecorator *bookMarkDecorator = editor->findChild(QString(), Qt::FindDirectChildrenOnly); + + bookMarkDecorator->clearAllBookmarks(); + decorator->clearAll(editor); + }); connect(ui->buttonClose, &QPushButton::clicked, this, &FindReplaceDialog::close); loadSettings(); @@ -522,6 +530,7 @@ void FindReplaceDialog::changeTab(int index) ui->buttonFindInFilesSelector->hide(); ui->checkBoxMarkRes->show(); + ui->buttonClearBookmarks->show(); ui->buttonCount->show(); ui->buttonFindAllInCurrent->show(); ui->buttonFindAllInDocuments->show(); @@ -542,6 +551,7 @@ void FindReplaceDialog::changeTab(int index) ui->buttonFindInFilesSelector->show(); ui->checkBoxMarkRes->hide(); + ui->buttonClearBookmarks->hide(); ui->buttonCount->hide(); ui->buttonFindAllInCurrent->hide(); ui->buttonFindAllInDocuments->hide(); diff --git a/src/NotepadNext/dialogs/FindReplaceDialog.ui b/src/NotepadNext/dialogs/FindReplaceDialog.ui index 20410275f..223a401dd 100644 --- a/src/NotepadNext/dialogs/FindReplaceDialog.ui +++ b/src/NotepadNext/dialogs/FindReplaceDialog.ui @@ -315,6 +315,13 @@ + + + + Clear All Marks + + +