Skip to content

Commit 90bfefd

Browse files
committed
v0.4.3 release
2 parents 46cf4d9 + 8e96101 commit 90bfefd

25 files changed

+482
-92
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
run: |
2727
mkdir build
2828
cd build
29-
qmake ..\src\NotepadNext.pro "APP_VERSION=0.3.3"
29+
qmake ..\src\NotepadNext.pro
3030
3131
- name: Build
3232
run: |

installer/installer.nsi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ Section "Notepad Next"
112112
# Register the application (e.g. cmd> start notepadnext)
113113
WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\App Paths\NotepadNext.exe" "" "$INSTDIR\NotepadNext.exe"
114114

115+
# Enable the auto updater
116+
# TODO: later make this a selectable section by the user
117+
WriteRegDWORD SHCTX "Software\NotepadNext\NotepadNext\" "AutoUpdate" 1
118+
115119
# Register 'Open With' menu suggestion. No real good documentation for this. https://stackoverflow.com/a/62783311
116120
WriteRegStr SHCTX "Software\Classes\NotepadNext\shell" "" "open"
117121
WriteRegStr SHCTX "Software\Classes\NotepadNext\shell\open\command" "" "$\"$INSTDIR\NotepadNext.exe$\" $\"%1$\""
@@ -161,6 +165,9 @@ Section "Uninstall"
161165
# Remove application registration
162166
DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\App Paths\NotepadNext.exe" "" "$INSTDIR\NotepadNext.exe"
163167

168+
# Custom configurations
169+
DeleteRegKey SHCTX "Software\NotepadNext\"
170+
164171
# Remove 'Open With' menu suggestion
165172
DeleteRegValue SHCTX "Software\Classes\.txt\OpenWithProgids" "NotepadNext"
166173
DeleteRegKey SHCTX "Software\Classes\NotepadNext"

src/NotepadNext.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ win32 {
3232
package.commands = \
3333
xcopy $$shell_path($${OUT_PWD}/NotepadNext/NotepadNext.exe) $$shell_path($${OUT_PWD}/package/) /Y && \
3434
xcopy $$shell_path($${OUT_PWD}/NotepadNext/*.dll) $$shell_path($${OUT_PWD}/package/) /Y && \
35-
xcopy $$shell_path($${PWD}/../LICENSE) $$shell_path($${OUT_PWD}/package/) /Y && \
35+
xcopy $$shell_path($${OUT_PWD}/NotepadNext/LICENSE) $$shell_path($${OUT_PWD}/package/) /Y && \
3636
windeployqt --release --no-translations --no-system-d3d-compiler --no-compiler-runtime --no-angle --no-opengl-sw $$shell_path($${OUT_PWD}/package/NotepadNext.exe)
3737

3838
zip.target = zip

src/NotepadNext/DockedEditor.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
#include "ScintillaNext.h"
2727

28+
#include <QDir>
29+
2830

2931
class DockedEditorComponentsFactory : public ads::CDockComponentsFactory
3032
{
@@ -174,7 +176,7 @@ void DockedEditor::addEditor(ScintillaNext *editor)
174176

175177
// Set the tooltip based on the buffer
176178
if (editor->isFile()) {
177-
dw->tabWidget()->setToolTip(editor->canonicalFilePath());
179+
dw->tabWidget()->setToolTip(QDir::toNativeSeparators(editor->canonicalFilePath()));
178180
}
179181
else {
180182
dw->tabWidget()->setToolTip(editor->getName());
@@ -219,7 +221,7 @@ void DockedEditor::renameEditor(ScintillaNext *editor)
219221
dockWidget->setWindowTitle(newName);
220222

221223
if (editor->isFile()) {
222-
dockWidget->tabWidget()->setToolTip(editor->canonicalFilePath());
224+
dockWidget->tabWidget()->setToolTip(QDir::toNativeSeparators(editor->canonicalFilePath()));
223225
}
224226
else {
225227
dockWidget->tabWidget()->setToolTip(editor->getName());

src/NotepadNext/EditorManager.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
#define EDITORMANAGER_H
2222

2323
#include <QObject>
24+
#include <QPointer>
25+
2426

25-
class ScintillaBuffer;
2627
class ScintillaNext;
2728

2829
class EditorManager : public QObject

src/NotepadNext/IFaceTable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <iterator>
2525

2626
template<typename Iter>
27-
typename const std::iterator_traits<Iter>::value_type *binary_find(Iter begin, Iter end, const char *name) {
27+
typename std::iterator_traits<Iter>::value_type const *binary_find(Iter begin, Iter end, const char *name) {
2828
auto it = std::lower_bound(begin, end, name, [](const auto &lhs, const char *rhs) {
2929
return strcmp(lhs.name, rhs) < 0;
3030
});

src/NotepadNext/NotepadNext.pro

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,24 @@ include(../QSimpleUpdater/QSimpleUpdater.pri)
3838
# Set variables for output executable
3939
VERSION = $$APP_VERSION
4040

41+
CONFIG += file_copies
42+
4143
win32 {
4244
QMAKE_TARGET_COMPANY = Notepad Next
4345
QMAKE_TARGET_DESCRIPTION = Notepad Next
4446
QMAKE_TARGET_COPYRIGHT = $$APP_COPYRIGHT
4547
QMAKE_TARGET_PRODUCT = Notepad Next
4648
RC_ICONS = ../../icon/nn.ico
4749

48-
CONFIG += file_copies
4950
COPIES += openssl
5051
openssl.files = $$files(../../deploy/windows/*.dll)
5152
openssl.path = $$OUT_PWD
5253
}
5354

55+
COPIES += license
56+
license.files = ../../LICENSE
57+
license.path = $$OUT_PWD
58+
5459

5560
SOURCES += \
5661
ColorPickerDelegate.cpp \

src/NotepadNext/RecentFilesListManager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919

20+
#include <QDir>
2021
#include <QMenu>
2122

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

8788
action->setData(file);
8889
connect(action, &QAction::triggered, this, &RecentFilesListManager::recentFileActionTriggered);

src/NotepadNext/decorators/AutoIndentation.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,18 @@ void AutoIndentation::notify(const NotificationData *pscn)
3434
const int eolMode = editor->eOLMode();
3535

3636
if (((eolMode == SC_EOL_CRLF || eolMode == SC_EOL_LF) && ch == '\n') || (eolMode == SC_EOL_CR && ch == '\r')) {
37-
const int currentLine = editor->lineFromPosition(editor->currentPos());
38-
const int previousLine = currentLine - 1;
39-
const int previousIndentation = editor->lineIndentation(previousLine);
40-
41-
if (previousIndentation > 0) {
42-
editor->setLineIndentation(currentLine, previousIndentation);
43-
editor->gotoPos(editor->findColumn(currentLine, previousIndentation));
44-
}
37+
autoIndentLine(editor->lineFromPosition(editor->currentPos()));
4538
}
4639
}
4740
}
41+
42+
void AutoIndentation::autoIndentLine(int line) const
43+
{
44+
const int previousLine = line - 1;
45+
const int previousIndentation = editor->lineIndentation(previousLine);
46+
47+
if (previousIndentation > 0) {
48+
editor->setLineIndentation(line, previousIndentation);
49+
editor->gotoPos(editor->findColumn(line, previousIndentation));
50+
}
51+
}

src/NotepadNext/decorators/AutoIndentation.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ class AutoIndentation : public EditorDecorator
3232

3333
public slots:
3434
void notify(const Scintilla::NotificationData *pscn) override;
35+
36+
private:
37+
void autoIndentLine(int line) const;
3538
};
3639

3740
#endif // AUTOINDENTATION_H

src/NotepadNext/decorators/BraceMatch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ void BraceMatch::doHighlighting()
6969

7070
if (match != INVALID_POSITION) {
7171
editor->braceHighlight(pos - 1, match);
72-
editor->setHighlightGuide(editor->column(pos - 1));
72+
editor->setHighlightGuide(editor->column(editor->lineIndentPosition(editor->lineFromPosition(pos - 1))));
7373
}
7474
else {
7575
// Check the character after the caret
7676
match = editor->braceMatch(pos, 0);
7777
if (match != INVALID_POSITION) {
7878
editor->braceHighlight(pos, match);
79-
editor->setHighlightGuide(editor->column(pos));
79+
editor->setHighlightGuide(editor->column(editor->lineIndentPosition(editor->lineFromPosition(pos))));
8080
}
8181
else {
8282
// Nothing was found, now check to see if we need to badlight something

src/NotepadNext/decorators/HighlightedScrollBar.cpp

Lines changed: 59 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,17 @@
2424

2525
using namespace Scintilla;
2626

27+
const int DEFAULT_TICK_HEIGHT = 3;
28+
const int DEFAULT_TICK_PADDING = 3;
29+
const QColor CURSOR_SELECTION_COLOR = QColor(0, 0, 0, 25);
30+
const QColor CURSOR_CARET_COLOR = QColor(0, 0, 0, 100);
31+
2732
HighlightedScrollBarDecorator::HighlightedScrollBarDecorator(ScintillaEdit *editor)
28-
: EditorDecorator(editor), scrollBar(new HighlightedScrollBar(this, Qt::Vertical, editor))
33+
: EditorDecorator(editor), scrollBar(new HighlightedScrollBar(editor, Qt::Vertical, editor))
2934
{
3035
connect(scrollBar, &QScrollBar::valueChanged, editor, &ScintillaEdit::scrollVertical);
3136

3237
editor->setVerticalScrollBar(scrollBar);
33-
34-
cursor.line = -1;
35-
cursor.color = Qt::darkGray;
3638
}
3739

3840
HighlightedScrollBarDecorator::~HighlightedScrollBarDecorator()
@@ -42,62 +44,94 @@ HighlightedScrollBarDecorator::~HighlightedScrollBarDecorator()
4244
void HighlightedScrollBarDecorator::notify(const NotificationData *pscn)
4345
{
4446
if (pscn->nmhdr.code == Notification::UpdateUI && (FlagSet(pscn->updated, Update::Content) || FlagSet(pscn->updated, Update::Selection))) {
45-
cursor.line = editor->visibleFromDocLine(editor->lineFromPosition(editor->currentPos()));
4647
scrollBar->update();
4748
}
4849
else if (pscn->nmhdr.code == Notification::Modified && FlagSet(pscn->modificationType, ModificationFlags::ChangeMarker)) {
4950
scrollBar->update();
5051
}
5152
}
5253

54+
55+
56+
5357
void HighlightedScrollBar::paintEvent(QPaintEvent *event)
5458
{
5559
// Paint the default scrollbar first
5660
QScrollBar::paintEvent(event);
57-
58-
ScintillaEdit *editor = decorator->getEditor();
5961
QPainter p(this);
6062

61-
double lineCount = static_cast<double>(editor->visibleFromDocLine(editor->lineCount()));
62-
6363
drawMarker(p, 24);
6464
drawIndicator(p, 29);
65-
66-
// Draw the current line
67-
if (decorator->cursor.line != -1) {
68-
int yy = decorator->cursor.line / lineCount * rect().height();
69-
yy = qMin(yy, rect().height() - 4);
70-
p.fillRect(rect().x() + 2, yy, rect().width() - 4, 3, decorator->cursor.color);
71-
}
65+
drawCursors(p);
7266
}
7367

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

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

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

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

10089
curPos = editor->indicatorEnd(29, curPos);
10190
}
10291
}
10392
}
93+
94+
void HighlightedScrollBar::drawCursors(QPainter &p)
95+
{
96+
for (int i = 0; i < editor->selections() ; i++) {
97+
int startCaretY = posToScrollBarY(editor->selectionNCaret(i));
98+
int startAnchorY = posToScrollBarY(editor->selectionNAnchor(i));
99+
100+
if (startCaretY != startAnchorY) {
101+
drawTickMark(p, startAnchorY, startCaretY - startAnchorY, CURSOR_SELECTION_COLOR);
102+
}
103+
104+
drawTickMark(p, startCaretY, DEFAULT_TICK_HEIGHT, CURSOR_CARET_COLOR);
105+
}
106+
}
107+
108+
void HighlightedScrollBar::drawTickMark(QPainter &p, int y, int height, QColor color)
109+
{
110+
p.fillRect(rect().x() + DEFAULT_TICK_PADDING, y + scrollbarArrowHeight(), rect().width() - (DEFAULT_TICK_PADDING * 2), height, color);
111+
}
112+
113+
int HighlightedScrollBar::posToScrollBarY(int pos) const
114+
{
115+
int line = editor->visibleFromDocLine(editor->lineFromPosition(pos));
116+
117+
return lineToScrollBarY(line);
118+
}
119+
120+
int HighlightedScrollBar::lineToScrollBarY(int line) const
121+
{
122+
int lineCount = editor->visibleFromDocLine(editor->lineCount());
123+
124+
if (!editor->endAtLastLine()) {
125+
lineCount += editor->linesOnScreen();
126+
}
127+
128+
return static_cast<double>(line) / lineCount * (rect().height() - scrollbarArrowHeight() * 2);
129+
}
130+
131+
int HighlightedScrollBar::scrollbarArrowHeight() const
132+
{
133+
// NOTE: There is no offical way to get the height of the scrollbar arrow buttons, however for now we can
134+
// assume that the buttons are square, meaning the height of them will be the same as the width of
135+
// the scroll bar.
136+
return rect().width();
137+
}

src/NotepadNext/decorators/HighlightedScrollBar.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ class HighlightedScrollBarDecorator : public EditorDecorator
3737
HighlightedScrollBarDecorator(ScintillaEdit *editor);
3838
~HighlightedScrollBarDecorator() override;
3939

40-
struct Highlight {
41-
int line;
42-
Qt::GlobalColor color;
43-
};
44-
Highlight cursor;
45-
4640
public slots:
4741
void notify(const Scintilla::NotificationData *pscn) override;
4842

@@ -56,17 +50,24 @@ class HighlightedScrollBar : public QScrollBar
5650
Q_OBJECT
5751

5852
public:
59-
explicit HighlightedScrollBar(HighlightedScrollBarDecorator *decorator, Qt::Orientation orientation, QWidget *parent = nullptr)
60-
: QScrollBar(orientation, parent), decorator(decorator) {}
53+
explicit HighlightedScrollBar(ScintillaEdit *editor, Qt::Orientation orientation, QWidget *parent = nullptr)
54+
: QScrollBar(orientation, parent), editor(editor) {}
6155

6256
protected:
6357
void paintEvent(QPaintEvent *event) override;
6458

6559
private:
6660
void drawMarker(QPainter &p, int marker);
6761
void drawIndicator(QPainter &p, int indicator);
62+
void drawCursors(QPainter &p);
63+
64+
void drawTickMark(QPainter &p, int y, int height, QColor color);
65+
66+
int posToScrollBarY(int pos) const;
67+
int lineToScrollBarY(int line) const;
68+
int scrollbarArrowHeight() const;
6869

69-
HighlightedScrollBarDecorator *decorator;
70+
ScintillaEdit *editor;
7071
};
7172

7273
#endif // HIGHLIGHTEDSCROLLBAR_H

src/NotepadNext/decorators/LineNumbers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void LineNumbers::adjustMarginWidth()
6060

6161
void LineNumbers::notify(const NotificationData *pscn)
6262
{
63-
if (pscn->nmhdr.code == Notification::UpdateUI && (FlagSet(pscn->updated, Update::VScroll) || FlagSet(pscn->nmhdr.code, Notification::Zoom))) {
63+
if ((pscn->nmhdr.code == Notification::UpdateUI && FlagSet(pscn->updated, Update::VScroll)) || (pscn->nmhdr.code == Notification::Zoom)) {
6464
adjustMarginWidth();
6565
}
6666
}

src/NotepadNext/dialogs/LanguageInspectorDock.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,23 @@ void LanguageInspectorDock::updateInformation(ScintillaNext *editor)
110110
// Don't update if the dock widget is not visible
111111
if (this->isHidden()) return;
112112

113+
// Make sure we are connected to this editor already (only once)
114+
connect(editor, &ScintillaNext::updateUi, this, &LanguageInspectorDock::updatePositionInfo, Qt::UniqueConnection);
115+
113116
this->updateLanguageName(editor);
114117
this->updatePropertyInfo(editor);
115118
this->updateKeywordInfo(editor);
116119
this->updateStyleInfo(editor);
117120
}
118121

122+
void LanguageInspectorDock::updatePositionInfo(Scintilla::Update updated)
123+
{
124+
if (FlagSet(updated, Scintilla::Update::Content) || FlagSet(updated, Scintilla::Update::Selection)) {
125+
ScintillaNext *editor = qobject_cast<ScintillaNext*>(sender());
126+
ui->lblInfo->setText(QString("Postion %1 Style %2").arg(editor->currentPos()).arg(editor->styleAt(editor->currentPos())));
127+
}
128+
}
129+
119130
void LanguageInspectorDock::updateLanguageName(ScintillaNext *editor)
120131
{
121132
ui->editLanguage->setText(editor->languageName);

0 commit comments

Comments
 (0)