diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index ade7ac3..6e42dc0 100755 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -2,9 +2,12 @@ name: Build and Release on: push: - branches: [main, dev] + branches: + - main + - dev pull_request: - branches: [main] + branches: + - main jobs: build-and-release: @@ -53,7 +56,7 @@ jobs: rsync -a "$BUILD_DIR/" "$TEMP_DIR/" cd $TEMP_DIR tar -czvf application.tar.gz ./* - + # macOS Section - name: Install dependencies (macOS) if: matrix.os == 'macos-latest' @@ -75,28 +78,28 @@ jobs: cd "${{ github.workspace }}/build" hdiutil create -volname Application -srcfolder . -ov -format UDZO application.dmg zip application.zip application.dmg - + # Windows Section - name: Install dependencies (Windows) if: matrix.os == 'windows-latest' run: | + choco install visualstudio2022buildtools -y --install-arguments \ + '--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --quiet --norestart' + choco install qt --version=6.5.3 -y choco install ninja -y choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' -y - echo "Checking for Qt installation..." - $qtPath = "C:\Qt\6.5.3\msvc2019_64\lib\cmake" - if (!(Test-Path $qtPath)) { - Write-Output "Qt not found. Downloading Qt installer..." - Invoke-WebRequest -Uri "https://download.qt.io/official_releases/online_installers/qt-unified-windows-x64-online.exe" -OutFile "qt-installer.exe" - Start-Process -FilePath "qt-installer.exe" -ArgumentList "--silent", "--platform", "win", "--prefix", "C:\Qt", "--modules", "qt.qt6.653.win64_msvc2019_64" -Wait - } - if (!(Test-Path $qtPath)) { - Write-Output "Qt installation failed." + shell: cmd + - name: Check Visual Studio Build Tools Path + if: matrix.os == 'windows-latest' + run: | + $vcvarsPath = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat" + if (!(Test-Path $vcvarsPath)) { + Write-Host "Visual Studio Build Tools not found at $vcvarsPath" exit 1 } else { - Write-Output "Qt installed successfully at $qtPath" + Write-Host "Found Visual Studio Build Tools at $vcvarsPath" } shell: pwsh - - name: Configure CMake (Windows) if: matrix.os == 'windows-latest' run: | @@ -107,14 +110,12 @@ jobs: -G Ninja ^ -S D:\a\Notepad--\Notepad-- shell: cmd - - name: Build application (Windows) if: matrix.os == 'windows-latest' run: | call "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat" && ^ cmake --build D:\a\Notepad--\Notepad--\build --config Release shell: cmd - - name: Package application (Windows) if: matrix.os == 'windows-latest' run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index a95078e..7966de6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 0.0.58 + +- View -> Show Symbol -> Show Tabs + ## 0.0.57 - Indentation Implemented diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user index 744e487..763a076 100755 --- a/CMakeLists.txt.user +++ b/CMakeLists.txt.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -102,14 +102,14 @@ 2 false - -DCMAKE_GENERATOR:STRING=Ninja --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} + -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DCMAKE_GENERATOR:STRING=Ninja -DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DCMAKE_BUILD_TYPE:STRING=Debug +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} --DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} --DCMAKE_BUILD_TYPE:STRING=Debug +-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} /data/Code/Qt/Notepad-- 0 /data/Code/Qt/Notepad--/build/Desktop-Debug @@ -160,14 +160,14 @@ 2 false - -DCMAKE_GENERATOR:STRING=Ninja --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} + -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DCMAKE_GENERATOR:STRING=Ninja -DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DCMAKE_BUILD_TYPE:STRING=Release +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} --DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} --DCMAKE_BUILD_TYPE:STRING=Release +-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} /data/Code/Qt/Notepad-- /data/Code/Qt/Notepad--/build/Desktop-Release diff --git a/src/codeeditor.cpp b/src/codeeditor.cpp index 4c8017d..de48379 100755 --- a/src/codeeditor.cpp +++ b/src/codeeditor.cpp @@ -30,6 +30,8 @@ CodeEditor::CodeEditor(QWidget *parent) m_useTabs = Settings::instance()->loadSetting("Indentation", "Option", "Tabs") == "Tabs"; m_indentationWidth = Settings::instance()->loadSetting("Indentation", "Size", "1").toInt(); + m_showTabs = Settings::instance()->loadSetting("View", "ShowTabs", "false") == "true"; + m_tabWidth = Settings::instance()->loadSetting("View", "TabWidth", "4").toInt(); } int CodeEditor::lineNumberAreaWidth() { @@ -254,3 +256,55 @@ void CodeEditor::keyPressEvent(QKeyEvent *event) { QPlainTextEdit::keyPressEvent(event); } +void CodeEditor::setShowTabs(bool enabled) { + if (m_showTabs != enabled) { + m_showTabs = enabled; + viewport()->update(); // Redraw the editor to show or hide tab symbols + } +} + +bool CodeEditor::showTabs() const { + return m_showTabs; +} + +void CodeEditor::setTabWidth(int width = 4) { + m_tabWidth = width; + viewport()->update(); // Trigger a repaint to apply the new width +} + +void CodeEditor::paintEvent(QPaintEvent *event) { + QPlainTextEdit::paintEvent(event); + + if (!m_showTabs) return; + + QPainter painter(viewport()); + painter.setPen(Qt::gray); + + QTextBlock block = document()->firstBlock(); + QFontMetrics metrics(font()); + + while (block.isValid()) { + QString text = block.text(); + int blockStart = block.position(); + QTextCursor blockCursor(block); + + // Iterate over characters in the block + for (int i = 0; i < text.length(); ++i) { + if (text[i] == '\t') { + // Move the cursor to the tab character + blockCursor.setPosition(blockStart + i); + + // Get the rectangle of the cursor position + QRect rect = cursorRect(blockCursor); + + // Adjust the position for the tab symbol + //QPoint position(rect.left(), rect.top() + metrics.ascent()); + QPoint position(rect.left() + metrics.ascent(), rect.top() + metrics.ascent()); + + // Draw the tab symbol + painter.drawText(position, "→"); + } + } + block = block.next(); + } +} diff --git a/src/codeeditor.h b/src/codeeditor.h index a5d1789..a8a5360 100755 --- a/src/codeeditor.h +++ b/src/codeeditor.h @@ -24,10 +24,14 @@ class CodeEditor : public QPlainTextEdit { void highlightAllOccurrences(const QString& keyword); void goToLineInText(int lineNumber); void gotoLineInEditor(int lineNumber); + void setShowTabs(bool enabled); + bool showTabs() const; + void setTabWidth(int width); protected: void resizeEvent(QResizeEvent *event) override; virtual void keyPressEvent(QKeyEvent *event) override; + void paintEvent(QPaintEvent *event) override; signals: void textChanged(); // FIXME: Remove this line. @@ -41,6 +45,8 @@ private slots: QTabWidget* m_documentsTab; bool m_useTabs; int m_indentationWidth; + bool m_showTabs = false; + int m_tabWidth; }; class LineNumberArea : public QWidget { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 68de875..44150ce 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -492,15 +492,24 @@ void MainWindow::on_action_Find_triggered() { } } +/* View Menu */ +void MainWindow::on_action_Show_Tabs_triggered(bool checked) +{ + qDebug() << "Show Tabs is: " << checked; + Settings::instance()->saveSetting("View", "ShowTabs", checked ? "true" : "false"); + for (int i = 0; i < ui->documentsTab->count(); ++i) { + Document *doc = qobject_cast(ui->documentsTab->widget(i)); + if (doc) { + doc->editor()->setShowTabs(checked); + } + } +} -/* View Menu */ - - @@ -513,9 +522,6 @@ void MainWindow::on_action_Find_triggered() { /* Helper Functions */ - - - // FIXME: Wrong line selected void MainWindow::openSearchResult(const QString &filePath, int lineNumber) { qInfo() << "openSearchResult called. File Path:" << filePath << ", Line Number:" << lineNumber; @@ -645,6 +651,3 @@ void MainWindow::setActiveDocumentEditorInReplaceDialog() { - - - diff --git a/src/mainwindow.h b/src/mainwindow.h index 2556e63..be9e7f0 100755 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -145,6 +145,8 @@ private slots: void on_actionGo_to_Line_in_Editor_triggered(); + void on_action_Show_Tabs_triggered(bool checked); + private: Ui::MainWindow* ui; FileOperations* fileOperations;