Skip to content

Commit

Permalink
Merge pull request #18 from yousefvand/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
yousefvand authored Nov 23, 2024
2 parents 419b9c7 + 0670101 commit d4f3d95
Show file tree
Hide file tree
Showing 47 changed files with 2,404 additions and 616 deletions.
41 changes: 1 addition & 40 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
brew install ninja qt
echo "CMAKE_PREFIX_PATH=$(brew --prefix qt)" >> $GITHUB_ENV
### Windows Setup with Qt Installation
### Windows Setup
- name: Install dependencies (Windows)
if: matrix.os == 'windows-latest'
shell: powershell
Expand All @@ -55,43 +55,6 @@ jobs:
choco install ninja -y
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' -y
- name: Download and Install Qt (Windows)
if: matrix.os == 'windows-latest'
shell: powershell
run: |
$installer = "qt-unified-windows-x64-online.exe"
Invoke-WebRequest -Uri "https://download.qt.io/official_releases/online_installers/qt-unified-windows-x64-online.exe" -OutFile $installer -TimeoutSec 1200
# Install Qt in a non-interactive mode
Start-Process -FilePath $installer -ArgumentList `
'install', `
'--platform', 'minimal', `
'--accept-licenses', `
'--no-default-installations', `
'--root', 'C:\Qt' `
-NoNewWindow -Wait
# Verify the Qt installation by checking for installation folders
if (-Not (Test-Path "C:\Qt\6*")) {
throw "Qt installation failed!"
} else {
Write-Host "Qt installation verified"
}
- name: Set up MSVC environment (Windows)
if: matrix.os == 'windows-latest'
shell: cmd
run: |
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
where cl || (echo cl.exe not found in PATH && exit /b 1)
# Configure CMake
- name: Configure CMake
run: |
cmake -B "${{ github.workspace }}/build" \
Expand All @@ -101,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
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
# Change Log

## 0.0.53

- Implemented:
- Search Menu -> Find System revised


## 0.0.52

- Implemented:
- Search Menu -> Find System completed

## 0.0.51

- Implemented:
- Search Menu -> Find System (partially 4)

## 0.0.50

- Implemented:
- Search Menu -> Find System (partially 3)

## 0.0.49

- Implemented:
- Search Menu -> Find System (partially 2)

## 0.0.48

- Implemented:
- Search Menu -> Find System (partially)

## 0.0.47

- Implemented:
Expand Down
31 changes: 21 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ set(PROJECT_UI
src/indentation/indentationdialog.ui
src/systemfind/systemfinddialog.ui
src/systemreplace/systemreplacedialog.ui
src/systemsearchresultdialog.ui
)

set(PROJECT_SOURCES
Expand Down Expand Up @@ -72,23 +73,33 @@ 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/systemfind/systemfinddialog.cpp
src/systemfind/systemfinddialog.h
src/systemreplace/systemreplacedialog.cpp
src/systemreplace/systemreplacedialog.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/systemreplace/systemreplace.cpp
src/systemreplace/systemreplace.h
src/systemsearchresultdialog.cpp
src/systemsearchresultdialog.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-10T04:16:59. -->
<!-- Written by QtCreator 14.0.2, 2024-11-23T23:54:00. -->
<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_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_BUILD_TYPE:STRING=Debug</value>
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake</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_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_BUILD_TYPE:STRING=Release</value>
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake</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
22 changes: 22 additions & 0 deletions assets/count_text_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# Check if a path is provided
if [ -z "$1" ]; then
echo "Usage: $0 <directory-path>"
exit 1
fi

# Assign the provided path to a variable
DIR="$1"

# Check if the provided path is a valid directory
if [ ! -d "$DIR" ]; then
echo "Error: $DIR is not a valid directory."
exit 1
fi

# Find files, check MIME type, and count text files
total_text_files=$(find "$DIR" -type f -exec file --mime-type {} + | grep -c "text/")

# Output the result
echo "Total text files in '$DIR' and its subdirectories: $total_text_files"
57 changes: 55 additions & 2 deletions src/codeeditor.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "codeeditor.h"
#include <QPainter>
#include <QTextBlock>
#include <QScrollBar>
#include "helpers.h"

CodeEditor::CodeEditor(QWidget *parent)
Expand Down Expand Up @@ -153,10 +154,62 @@ void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event) {
}

void CodeEditor::applyIndentation(bool useTabs, int indentationWidth) {
// TODO: Implement indentation
qDebug() << "Indentation. Use Tabs: " << useTabs << ". Indentation width: " << indentationWidth;
QTextCursor cursor = textCursor();
QString indentation = useTabs ? "\t" : QString(indentationWidth, ' ');
cursor.insertText(indentation);
}

QTabWidget* CodeEditor::DocumentsTab() {
return m_documentsTab;
}

void CodeEditor::highlightAllOccurrences(const QString& keyword) {
QList<QTextEdit::ExtraSelection> extraSelections;

QTextCursor cursor(document());
QTextCursor highlightCursor(document());
QTextCharFormat highlightFormat;
highlightFormat.setBackground(Qt::cyan);

while (!cursor.isNull() && !cursor.atEnd()) {
cursor = document()->find(keyword, cursor);
if (!cursor.isNull()) {
QTextEdit::ExtraSelection selection;
selection.cursor = cursor;
selection.format = highlightFormat;
extraSelections.append(selection);
}
}

setExtraSelections(extraSelections);
}

void CodeEditor::goToLineInText(int lineNumber) {
if (lineNumber < 1 || lineNumber > document()->blockCount()) {
qWarning() << "Line number: " << lineNumber << ". Line number is out of range.";
return;
}

QTextCursor cursor(document()->findBlockByNumber(lineNumber - 1));
setTextCursor(cursor);
centerCursor(); // Ensure the cursor is centered in the view

qDebug() << "Moved to line:" << lineNumber;

// Log current cursor position
qDebug() << "Cursor position after move:" << textCursor().position();
}

void CodeEditor::gotoLineInEditor(int lineNumber) {
// Ensure the line number is within the valid range
if (lineNumber > 0 && lineNumber <= blockCount()) {
QTextCursor cursor = textCursor();
cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, lineNumber - 1);
setTextCursor(cursor);
centerCursor();
} else {
qWarning() << "Invalid Line Number: " << lineNumber << " .The specified line is out of range.";
}
}

5 changes: 4 additions & 1 deletion src/codeeditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ class CodeEditor : public QPlainTextEdit {
void highlightCurrentLine();
void applyIndentation(bool useTabs, int indentationWidth);
QTabWidget* DocumentsTab();
void highlightAllOccurrences(const QString& keyword);
void goToLineInText(int lineNumber);
void gotoLineInEditor(int lineNumber);

protected:
void resizeEvent(QResizeEvent *event) override;

signals:
void textChanged();
void textChanged(); // FIXME: Remove this line.

private slots:
void updateLineNumberAreaWidth(int newBlockCount);
Expand Down
Loading

0 comments on commit d4f3d95

Please sign in to comment.