Skip to content

Commit

Permalink
v0.0.52
Browse files Browse the repository at this point in the history
  • Loading branch information
yousefvand committed Nov 23, 2024
1 parent a3f0c7f commit c2394bc
Show file tree
Hide file tree
Showing 21 changed files with 467 additions and 494 deletions.
74 changes: 0 additions & 74 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,79 +54,7 @@ jobs:
choco install visualstudio2022buildtools -y
choco install ninja -y
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' -y
choco install python3 -y
choco install gperf -y
choco install bison -y
choco install llvm -y
pip install html5lib
- name: Restore Qt Source Cache (Windows)
if: matrix.os == 'windows-latest'
uses: actions/cache@v3
with:
path: D:\qt-source
key: qt-source-6.5.3
enableCrossOsArchive: false

- name: Download Qt Source if Cache Miss (Windows)
if: matrix.os == 'windows-latest'
shell: powershell
run: |
$qtSourceDir = "D:\qt-source"
$qtZip = "$qtSourceDir\qt-everywhere-src-6.5.3.zip"
if (-Not (Test-Path "$qtSourceDir\qt-everywhere-src-6.5.3\qtbase\configure.bat")) {
Write-Host "Cache not found. Downloading Qt Source..."
New-Item -ItemType Directory -Path $qtSourceDir -Force
Invoke-WebRequest -Uri "https://download.qt.io/official_releases/qt/6.5/6.5.3/single/qt-everywhere-src-6.5.3.zip" -OutFile $qtZip
Expand-Archive -Path $qtZip -DestinationPath $qtSourceDir
} else {
Write-Host "Qt source found in cache."
}
dir "$qtSourceDir\qt-everywhere-src-6.5.3\qtbase"
- name: Build and Install Qt from Source (Windows)
if: matrix.os == 'windows-latest'
shell: cmd
run: |
REM Locate Visual Studio Build Tools
FOR /F "tokens=*" %%i IN ('"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" ^
-latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath') DO SET VS_PATH=%%i
IF NOT DEFINED VS_PATH (
echo Visual Studio Build Tools not found! && exit /b 1
)
SET "VS_VARS_CMD=%VS_PATH%\VC\Auxiliary\Build\vcvars64.bat"
CALL "%VS_VARS_CMD%" || exit /b 1
REM Build Qt from source
SET QT_SOURCE=D:\qt-source\qt-everywhere-src-6.5.3
IF NOT EXIST "%QT_SOURCE%\qtbase\configure.bat" (
echo "configure.bat not found in %QT_SOURCE%\qtbase" && exit /b 1
)
cd "%QT_SOURCE%\qtbase"
call configure.bat -top-level -prefix C:\Qt -release -opensource -confirm-license -nomake examples -nomake tests -platform win32-msvc -cmake-generator Ninja ^
-DFEATURE_clang=ON ^
-DFEATURE_clangcpp=ON ^
-DLLVM_INSTALL_DIR="C:/Program Files/LLVM" ^
-Wno-dev || exit /b 1
REM Verify if build.ninja exists
IF NOT EXIST build.ninja (
echo "Error: build.ninja not generated. Check configuration step for issues." && exit /b 1
)
REM Proceed with the build and install steps
ninja || exit /b 1
ninja install || exit /b 1
- name: Set Qt Environment Variables (Windows)
if: matrix.os == 'windows-latest'
shell: powershell
run: |
echo "Qt6_DIR=C:\Qt\lib\cmake\Qt6" >> $env:GITHUB_ENV
echo "QT_PLUGIN_PATH=C:\Qt\plugins" >> $env:GITHUB_ENV
echo "QML2_IMPORT_PATH=C:\Qt\qml" >> $env:GITHUB_ENV
# Configure CMake
- name: Configure CMake
run: |
cmake -B "${{ github.workspace }}/build" \
Expand All @@ -136,11 +64,9 @@ jobs:
-G "Ninja" \
-S "${{ github.workspace }}"
# Build the project
- name: Build
run: cmake --build "${{ github.workspace }}/build" --config Release

# Run tests
- name: Test
working-directory: "${{ github.workspace }}/build"
run: ctest --output-on-failure --build-config Release
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 0.0.52

- Implemented:
- Search Menu -> Find System completed

## 0.0.51

- Implemented:
Expand Down
20 changes: 10 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,31 +73,31 @@ set(PROJECT_SOURCES
src/indentation/indentationdialog.h
src/indentation/indentationmanager.cpp
src/indentation/indentationmanager.h
src/find/finddialog.cpp
src/find/finddialog.h
src/replace/replacedialog.cpp
src/replace/replacedialog.h
src/replace/replace.cpp
src/replace/replace.h
src/find/find.cpp
src/find/find.h
src/search/search.cpp
src/search/search.h
src/search/searchoptions.h
src/search/filesearchworker.cpp
src/search/filesearchworker.h
src/find/finddialog.cpp
src/find/finddialog.h
src/find/find.cpp
src/find/find.h
src/systemfind/systemfind.cpp
src/systemfind/systemfind.h
src/systemfind/systemfinddialog.cpp
src/systemfind/systemfinddialog.h
src/systemfind/richtextdelegate.cpp
src/systemfind/richtextdelegate.h
src/systemreplace/systemreplacedialog.cpp
src/systemreplace/systemreplacedialog.h
src/systemfind/systemfind.cpp
src/systemfind/systemfind.h
src/systemreplace/systemreplace.cpp
src/systemreplace/systemreplace.h
src/systemsearchresultdialog.cpp
src/systemsearchresultdialog.h
src/search/filesearchworker.cpp
src/search/filesearchworker.h
src/systemfind/richtextdelegate.cpp
src/systemfind/richtextdelegate.h
src/systemtextdelegate.cpp
src/systemtextdelegate.h
${PROJECT_UI}
Expand Down
22 changes: 11 additions & 11 deletions CMakeLists.txt.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 14.0.2, 2024-11-20T01:10:08. -->
<!-- Written by QtCreator 14.0.2, 2024-11-23T22:14:40. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down Expand Up @@ -102,14 +102,14 @@
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_BUILD_TYPE:STRING=Debug
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}</value>
-DCMAKE_GENERATOR:STRING=Ninja</value>
<value type="QString" key="CMake.Source.Directory">/data/Code/Qt/Notepad--</value>
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/data/Code/Qt/Notepad--/build/Desktop-Debug</value>
Expand Down Expand Up @@ -160,14 +160,14 @@
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_BUILD_TYPE:STRING=Release
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}</value>
-DCMAKE_GENERATOR:STRING=Ninja</value>
<value type="QString" key="CMake.Source.Directory">/data/Code/Qt/Notepad--</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/data/Code/Qt/Notepad--/build/Desktop-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
Expand Down
169 changes: 2 additions & 167 deletions src/find/find.cpp
Original file line number Diff line number Diff line change
@@ -1,168 +1,3 @@
#include "find.h"
#include <QMessageBox>
#include <QTextCursor>
#include <QDebug>
#include <QTabWidget>
#include <QRegularExpression>
#include <QCoreApplication>
#include "../search/search.h"

Find::Find(CodeEditor* editor)
: m_editor(editor), m_cursor(editor ? editor->document() : nullptr) {}

void Find::setEditor(CodeEditor* editor) {
m_editor = editor;
m_cursor = m_editor ? QTextCursor(m_editor->document()) : QTextCursor();
}

void Find::setSearchOptions(const SearchOptions& options) {
m_options = options;
}

QString Find::expandSpecialCharacters(const QString& input) const {
QString result = input;

result.replace("\\n", "\n");
result.replace("\\r", "\r");
result.replace("\\t", "\t");
result.replace("\\\\", "\\");
result.replace("\\0", "\0");

qDebug() << "Expanded search keyword:" << result;
return result;
}

QTextDocument::FindFlags Find::buildFlags(bool backward) const {
QTextDocument::FindFlags flags;
if (m_options.matchCase) {
flags |= QTextDocument::FindCaseSensitively;
}
if (m_options.matchWholeWord) {
flags |= QTextDocument::FindWholeWords;
}
if (backward) {
flags |= QTextDocument::FindBackward;
}
return flags;
}

bool Find::search(bool backward) {
if (!m_editor) {
qWarning() << "Error: m_editor is null!";
return false;
}

QTextDocument::FindFlags flags = buildFlags(backward);
QString keyword = expandSpecialCharacters(m_options.keyword);

// Perform the search
m_cursor = m_editor->document()->find(keyword, m_cursor, flags);

bool found = !m_cursor.isNull();
if (found) {
m_editor->setTextCursor(m_cursor);
}

return found;
}

bool Find::findNext() {
return search(false);
}

bool Find::findPrevious() {
return search(true);
}

void Find::selectAll() {
if (!m_editor) {
qWarning() << "Error: m_editor is null!";
return;
}

QTextDocument* document = m_editor->document();
QTextCursor cursor(document);
cursor.movePosition(QTextCursor::Start);
QString keyword = expandSpecialCharacters(m_options.keyword);

QTextDocument::FindFlags flags = buildFlags(false);
QList<QTextEdit::ExtraSelection> extraSelections;

while (true) {
cursor = document->find(keyword, cursor, flags);

if (cursor.isNull()) {
break;
}

QTextEdit::ExtraSelection selection;
selection.cursor = cursor;
selection.format.setBackground(Qt::yellow);
extraSelections.append(selection);
}

m_editor->setExtraSelections(extraSelections);
}

bool Find::iterateOverTabs(bool backward) {
if (!m_editor) {
qWarning() << "Error: m_editor is null!";
return false;
}

// Get the tab widget (DocumentsTab) from the current editor
QTabWidget* tabWidget = m_editor->DocumentsTab();
if (!tabWidget) {
qWarning() << "Error: No DocumentsTab available!";
return false;
}

int tabCount = tabWidget->count();
if (tabCount == 0) {
qWarning() << "No tabs available for search!";
return false;
}

int currentIndex = tabWidget->currentIndex();
int startIndex = currentIndex; // Store the starting tab to avoid infinite loops

qDebug() << "Starting search across all tabs. Total tabs:" << tabCount;

do {
qDebug() << "Switching to tab index:" << currentIndex;

// Switch to the current tab
tabWidget->setCurrentIndex(currentIndex);
QCoreApplication::processEvents(); // Ensure the UI reflects the active tab change

// Retrieve the CodeEditor for the active tab
QWidget* currentWidget = tabWidget->currentWidget();
if (!currentWidget) {
qWarning() << "No widget found in tab index:" << currentIndex;
continue;
}

CodeEditor* editor = qobject_cast<CodeEditor*>(currentWidget);
if (!editor) {
qWarning() << "Widget is not a CodeEditor at tab index:" << currentIndex;
continue;
}

// Set the editor for the Find object and reset the cursor
setEditor(editor);
m_cursor = QTextCursor(m_editor->document());

qDebug() << "Searching in tab index:" << currentIndex;
if (search(backward)) {
qDebug() << "Match found in tab index:" << currentIndex;
return true; // Stop if a match is found
}

// Move to the next or previous tab
currentIndex = backward ? (currentIndex - 1 + tabCount) % tabCount
: (currentIndex + 1) % tabCount;

} while (currentIndex != startIndex);

qDebug() << "No matches found across all tabs.";
return false; // No matches found
}
class Find : public Search {};
29 changes: 4 additions & 25 deletions src/find/find.h
Original file line number Diff line number Diff line change
@@ -1,30 +1,9 @@
#pragma once

#include <QString>
#include <QTextEdit>
#include "../codeeditor.h"
#include "../search/searchoptions.h"
#include "../search/search.h"

class Find {
public:
explicit Find(CodeEditor* editor = nullptr);

void setEditor(CodeEditor* editor);
void setSearchOptions(const SearchOptions& options);

bool findNext(); // Search forward
bool findPrevious(); // Search backward
void selectAll(); // Highlight all occurrences of the keyword
bool searchAcrossAllTabs(bool backward);
bool iterateOverTabs(bool backward);
class Find : public Search {

private:
QString expandSpecialCharacters(const QString& input) const;
bool performSearch(bool backward);
QTextDocument::FindFlags buildFlags(bool backward) const;
bool search(bool backward);

CodeEditor* m_editor;
QTextCursor m_cursor;
SearchOptions m_options;
public:
using Search::Search;
};
Loading

0 comments on commit c2394bc

Please sign in to comment.