Skip to content

Commit

Permalink
v0.4.3 release
Browse files Browse the repository at this point in the history
  • Loading branch information
dail8859 committed Dec 5, 2021
2 parents 46cf4d9 + 8e96101 commit 90bfefd
Show file tree
Hide file tree
Showing 25 changed files with 482 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: |
mkdir build
cd build
qmake ..\src\NotepadNext.pro "APP_VERSION=0.3.3"
qmake ..\src\NotepadNext.pro
- name: Build
run: |
Expand Down
7 changes: 7 additions & 0 deletions installer/installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ Section "Notepad Next"
# Register the application (e.g. cmd> start notepadnext)
WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\App Paths\NotepadNext.exe" "" "$INSTDIR\NotepadNext.exe"

# Enable the auto updater
# TODO: later make this a selectable section by the user
WriteRegDWORD SHCTX "Software\NotepadNext\NotepadNext\" "AutoUpdate" 1

# Register 'Open With' menu suggestion. No real good documentation for this. https://stackoverflow.com/a/62783311
WriteRegStr SHCTX "Software\Classes\NotepadNext\shell" "" "open"
WriteRegStr SHCTX "Software\Classes\NotepadNext\shell\open\command" "" "$\"$INSTDIR\NotepadNext.exe$\" $\"%1$\""
Expand Down Expand Up @@ -161,6 +165,9 @@ Section "Uninstall"
# Remove application registration
DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\App Paths\NotepadNext.exe" "" "$INSTDIR\NotepadNext.exe"

# Custom configurations
DeleteRegKey SHCTX "Software\NotepadNext\"

# Remove 'Open With' menu suggestion
DeleteRegValue SHCTX "Software\Classes\.txt\OpenWithProgids" "NotepadNext"
DeleteRegKey SHCTX "Software\Classes\NotepadNext"
Expand Down
2 changes: 1 addition & 1 deletion src/NotepadNext.pro
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ win32 {
package.commands = \
xcopy $$shell_path($${OUT_PWD}/NotepadNext/NotepadNext.exe) $$shell_path($${OUT_PWD}/package/) /Y && \
xcopy $$shell_path($${OUT_PWD}/NotepadNext/*.dll) $$shell_path($${OUT_PWD}/package/) /Y && \
xcopy $$shell_path($${PWD}/../LICENSE) $$shell_path($${OUT_PWD}/package/) /Y && \
xcopy $$shell_path($${OUT_PWD}/NotepadNext/LICENSE) $$shell_path($${OUT_PWD}/package/) /Y && \
windeployqt --release --no-translations --no-system-d3d-compiler --no-compiler-runtime --no-angle --no-opengl-sw $$shell_path($${OUT_PWD}/package/NotepadNext.exe)

zip.target = zip
Expand Down
6 changes: 4 additions & 2 deletions src/NotepadNext/DockedEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

#include "ScintillaNext.h"

#include <QDir>


class DockedEditorComponentsFactory : public ads::CDockComponentsFactory
{
Expand Down Expand Up @@ -174,7 +176,7 @@ void DockedEditor::addEditor(ScintillaNext *editor)

// Set the tooltip based on the buffer
if (editor->isFile()) {
dw->tabWidget()->setToolTip(editor->canonicalFilePath());
dw->tabWidget()->setToolTip(QDir::toNativeSeparators(editor->canonicalFilePath()));
}
else {
dw->tabWidget()->setToolTip(editor->getName());
Expand Down Expand Up @@ -219,7 +221,7 @@ void DockedEditor::renameEditor(ScintillaNext *editor)
dockWidget->setWindowTitle(newName);

if (editor->isFile()) {
dockWidget->tabWidget()->setToolTip(editor->canonicalFilePath());
dockWidget->tabWidget()->setToolTip(QDir::toNativeSeparators(editor->canonicalFilePath()));
}
else {
dockWidget->tabWidget()->setToolTip(editor->getName());
Expand Down
3 changes: 2 additions & 1 deletion src/NotepadNext/EditorManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
#define EDITORMANAGER_H

#include <QObject>
#include <QPointer>


class ScintillaBuffer;
class ScintillaNext;

class EditorManager : public QObject
Expand Down
2 changes: 1 addition & 1 deletion src/NotepadNext/IFaceTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <iterator>

template<typename Iter>
typename const std::iterator_traits<Iter>::value_type *binary_find(Iter begin, Iter end, const char *name) {
typename std::iterator_traits<Iter>::value_type const *binary_find(Iter begin, Iter end, const char *name) {
auto it = std::lower_bound(begin, end, name, [](const auto &lhs, const char *rhs) {
return strcmp(lhs.name, rhs) < 0;
});
Expand Down
7 changes: 6 additions & 1 deletion src/NotepadNext/NotepadNext.pro
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,24 @@ include(../QSimpleUpdater/QSimpleUpdater.pri)
# Set variables for output executable
VERSION = $$APP_VERSION

CONFIG += file_copies

win32 {
QMAKE_TARGET_COMPANY = Notepad Next
QMAKE_TARGET_DESCRIPTION = Notepad Next
QMAKE_TARGET_COPYRIGHT = $$APP_COPYRIGHT
QMAKE_TARGET_PRODUCT = Notepad Next
RC_ICONS = ../../icon/nn.ico

CONFIG += file_copies
COPIES += openssl
openssl.files = $$files(../../deploy/windows/*.dll)
openssl.path = $$OUT_PWD
}

COPIES += license
license.files = ../../LICENSE
license.path = $$OUT_PWD


SOURCES += \
ColorPickerDelegate.cpp \
Expand Down
3 changes: 2 additions & 1 deletion src/NotepadNext/RecentFilesListManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/


#include <QDir>
#include <QMenu>

#include "RecentFilesListManager.h"
Expand Down Expand Up @@ -82,7 +83,7 @@ void RecentFilesListManager::populateMenu(QMenu *menu)
QList<QAction *> recentFileListActions;
foreach (const QString &file, recentFiles) {
++i;
QAction *action = new QAction(QString("%1%2: %3").arg(i < 10 ? "&" : "").arg(i).arg(file), menu);
QAction *action = new QAction(QString("%1%2: %3").arg(i < 10 ? "&" : "").arg(i).arg(QDir::toNativeSeparators(file)), menu);

action->setData(file);
connect(action, &QAction::triggered, this, &RecentFilesListManager::recentFileActionTriggered);
Expand Down
20 changes: 12 additions & 8 deletions src/NotepadNext/decorators/AutoIndentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,18 @@ void AutoIndentation::notify(const NotificationData *pscn)
const int eolMode = editor->eOLMode();

if (((eolMode == SC_EOL_CRLF || eolMode == SC_EOL_LF) && ch == '\n') || (eolMode == SC_EOL_CR && ch == '\r')) {
const int currentLine = editor->lineFromPosition(editor->currentPos());
const int previousLine = currentLine - 1;
const int previousIndentation = editor->lineIndentation(previousLine);

if (previousIndentation > 0) {
editor->setLineIndentation(currentLine, previousIndentation);
editor->gotoPos(editor->findColumn(currentLine, previousIndentation));
}
autoIndentLine(editor->lineFromPosition(editor->currentPos()));
}
}
}

void AutoIndentation::autoIndentLine(int line) const
{
const int previousLine = line - 1;
const int previousIndentation = editor->lineIndentation(previousLine);

if (previousIndentation > 0) {
editor->setLineIndentation(line, previousIndentation);
editor->gotoPos(editor->findColumn(line, previousIndentation));
}
}
3 changes: 3 additions & 0 deletions src/NotepadNext/decorators/AutoIndentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class AutoIndentation : public EditorDecorator

public slots:
void notify(const Scintilla::NotificationData *pscn) override;

private:
void autoIndentLine(int line) const;
};

#endif // AUTOINDENTATION_H
4 changes: 2 additions & 2 deletions src/NotepadNext/decorators/BraceMatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ void BraceMatch::doHighlighting()

if (match != INVALID_POSITION) {
editor->braceHighlight(pos - 1, match);
editor->setHighlightGuide(editor->column(pos - 1));
editor->setHighlightGuide(editor->column(editor->lineIndentPosition(editor->lineFromPosition(pos - 1))));
}
else {
// Check the character after the caret
match = editor->braceMatch(pos, 0);
if (match != INVALID_POSITION) {
editor->braceHighlight(pos, match);
editor->setHighlightGuide(editor->column(pos));
editor->setHighlightGuide(editor->column(editor->lineIndentPosition(editor->lineFromPosition(pos))));
}
else {
// Nothing was found, now check to see if we need to badlight something
Expand Down
84 changes: 59 additions & 25 deletions src/NotepadNext/decorators/HighlightedScrollBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@

using namespace Scintilla;

const int DEFAULT_TICK_HEIGHT = 3;
const int DEFAULT_TICK_PADDING = 3;
const QColor CURSOR_SELECTION_COLOR = QColor(0, 0, 0, 25);
const QColor CURSOR_CARET_COLOR = QColor(0, 0, 0, 100);

HighlightedScrollBarDecorator::HighlightedScrollBarDecorator(ScintillaEdit *editor)
: EditorDecorator(editor), scrollBar(new HighlightedScrollBar(this, Qt::Vertical, editor))
: EditorDecorator(editor), scrollBar(new HighlightedScrollBar(editor, Qt::Vertical, editor))
{
connect(scrollBar, &QScrollBar::valueChanged, editor, &ScintillaEdit::scrollVertical);

editor->setVerticalScrollBar(scrollBar);

cursor.line = -1;
cursor.color = Qt::darkGray;
}

HighlightedScrollBarDecorator::~HighlightedScrollBarDecorator()
Expand All @@ -42,62 +44,94 @@ HighlightedScrollBarDecorator::~HighlightedScrollBarDecorator()
void HighlightedScrollBarDecorator::notify(const NotificationData *pscn)
{
if (pscn->nmhdr.code == Notification::UpdateUI && (FlagSet(pscn->updated, Update::Content) || FlagSet(pscn->updated, Update::Selection))) {
cursor.line = editor->visibleFromDocLine(editor->lineFromPosition(editor->currentPos()));
scrollBar->update();
}
else if (pscn->nmhdr.code == Notification::Modified && FlagSet(pscn->modificationType, ModificationFlags::ChangeMarker)) {
scrollBar->update();
}
}




void HighlightedScrollBar::paintEvent(QPaintEvent *event)
{
// Paint the default scrollbar first
QScrollBar::paintEvent(event);

ScintillaEdit *editor = decorator->getEditor();
QPainter p(this);

double lineCount = static_cast<double>(editor->visibleFromDocLine(editor->lineCount()));

drawMarker(p, 24);
drawIndicator(p, 29);

// Draw the current line
if (decorator->cursor.line != -1) {
int yy = decorator->cursor.line / lineCount * rect().height();
yy = qMin(yy, rect().height() - 4);
p.fillRect(rect().x() + 2, yy, rect().width() - 4, 3, decorator->cursor.color);
}
drawCursors(p);
}

void HighlightedScrollBar::drawMarker(QPainter &p, int marker)
{
ScintillaEdit *editor = decorator->getEditor();
const double lineCount = static_cast<double>(editor->visibleFromDocLine(editor->lineCount()));
// NOTE: SCI_MARKERGETBACK doesn't exist...so can't use the marker color
int curLine = 0;

while ((curLine = editor->markerNext(curLine, 1 << marker)) != -1) {
int yy = (curLine + 1) / lineCount * rect().height();
p.fillRect(rect().x() + 2, yy, rect().width() - 4, 3, Qt::blue);
drawTickMark(p, lineToScrollBarY(curLine), DEFAULT_TICK_HEIGHT, QColor(100, 100, 255));

curLine++;
}
}

void HighlightedScrollBar::drawIndicator(QPainter &p, int indicator)
{
ScintillaEdit *editor = decorator->getEditor();
const double lineCount = static_cast<double>(editor->visibleFromDocLine(editor->lineCount()));
int curPos = editor->indicatorEnd(indicator, 0);
int color = editor->indicFore(indicator);

if (curPos > 0) {
while ((curPos = editor->indicatorEnd(29, curPos)) < editor->length()) {
int yy = editor->lineFromPosition(curPos) / lineCount * rect().height();
yy = qMin(yy, rect().height() - 4);
p.fillRect(rect().x() + 2, yy, rect().width() - 4, 3, color);
drawTickMark(p, posToScrollBarY(curPos), DEFAULT_TICK_HEIGHT, color);

curPos = editor->indicatorEnd(29, curPos);
}
}
}

void HighlightedScrollBar::drawCursors(QPainter &p)
{
for (int i = 0; i < editor->selections() ; i++) {
int startCaretY = posToScrollBarY(editor->selectionNCaret(i));
int startAnchorY = posToScrollBarY(editor->selectionNAnchor(i));

if (startCaretY != startAnchorY) {
drawTickMark(p, startAnchorY, startCaretY - startAnchorY, CURSOR_SELECTION_COLOR);
}

drawTickMark(p, startCaretY, DEFAULT_TICK_HEIGHT, CURSOR_CARET_COLOR);
}
}

void HighlightedScrollBar::drawTickMark(QPainter &p, int y, int height, QColor color)
{
p.fillRect(rect().x() + DEFAULT_TICK_PADDING, y + scrollbarArrowHeight(), rect().width() - (DEFAULT_TICK_PADDING * 2), height, color);
}

int HighlightedScrollBar::posToScrollBarY(int pos) const
{
int line = editor->visibleFromDocLine(editor->lineFromPosition(pos));

return lineToScrollBarY(line);
}

int HighlightedScrollBar::lineToScrollBarY(int line) const
{
int lineCount = editor->visibleFromDocLine(editor->lineCount());

if (!editor->endAtLastLine()) {
lineCount += editor->linesOnScreen();
}

return static_cast<double>(line) / lineCount * (rect().height() - scrollbarArrowHeight() * 2);
}

int HighlightedScrollBar::scrollbarArrowHeight() const
{
// NOTE: There is no offical way to get the height of the scrollbar arrow buttons, however for now we can
// assume that the buttons are square, meaning the height of them will be the same as the width of
// the scroll bar.
return rect().width();
}
19 changes: 10 additions & 9 deletions src/NotepadNext/decorators/HighlightedScrollBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ class HighlightedScrollBarDecorator : public EditorDecorator
HighlightedScrollBarDecorator(ScintillaEdit *editor);
~HighlightedScrollBarDecorator() override;

struct Highlight {
int line;
Qt::GlobalColor color;
};
Highlight cursor;

public slots:
void notify(const Scintilla::NotificationData *pscn) override;

Expand All @@ -56,17 +50,24 @@ class HighlightedScrollBar : public QScrollBar
Q_OBJECT

public:
explicit HighlightedScrollBar(HighlightedScrollBarDecorator *decorator, Qt::Orientation orientation, QWidget *parent = nullptr)
: QScrollBar(orientation, parent), decorator(decorator) {}
explicit HighlightedScrollBar(ScintillaEdit *editor, Qt::Orientation orientation, QWidget *parent = nullptr)
: QScrollBar(orientation, parent), editor(editor) {}

protected:
void paintEvent(QPaintEvent *event) override;

private:
void drawMarker(QPainter &p, int marker);
void drawIndicator(QPainter &p, int indicator);
void drawCursors(QPainter &p);

void drawTickMark(QPainter &p, int y, int height, QColor color);

int posToScrollBarY(int pos) const;
int lineToScrollBarY(int line) const;
int scrollbarArrowHeight() const;

HighlightedScrollBarDecorator *decorator;
ScintillaEdit *editor;
};

#endif // HIGHLIGHTEDSCROLLBAR_H
2 changes: 1 addition & 1 deletion src/NotepadNext/decorators/LineNumbers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void LineNumbers::adjustMarginWidth()

void LineNumbers::notify(const NotificationData *pscn)
{
if (pscn->nmhdr.code == Notification::UpdateUI && (FlagSet(pscn->updated, Update::VScroll) || FlagSet(pscn->nmhdr.code, Notification::Zoom))) {
if ((pscn->nmhdr.code == Notification::UpdateUI && FlagSet(pscn->updated, Update::VScroll)) || (pscn->nmhdr.code == Notification::Zoom)) {
adjustMarginWidth();
}
}
11 changes: 11 additions & 0 deletions src/NotepadNext/dialogs/LanguageInspectorDock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,23 @@ void LanguageInspectorDock::updateInformation(ScintillaNext *editor)
// Don't update if the dock widget is not visible
if (this->isHidden()) return;

// Make sure we are connected to this editor already (only once)
connect(editor, &ScintillaNext::updateUi, this, &LanguageInspectorDock::updatePositionInfo, Qt::UniqueConnection);

this->updateLanguageName(editor);
this->updatePropertyInfo(editor);
this->updateKeywordInfo(editor);
this->updateStyleInfo(editor);
}

void LanguageInspectorDock::updatePositionInfo(Scintilla::Update updated)
{
if (FlagSet(updated, Scintilla::Update::Content) || FlagSet(updated, Scintilla::Update::Selection)) {
ScintillaNext *editor = qobject_cast<ScintillaNext*>(sender());
ui->lblInfo->setText(QString("Postion %1 Style %2").arg(editor->currentPos()).arg(editor->styleAt(editor->currentPos())));
}
}

void LanguageInspectorDock::updateLanguageName(ScintillaNext *editor)
{
ui->editLanguage->setText(editor->languageName);
Expand Down
Loading

0 comments on commit 90bfefd

Please sign in to comment.