Skip to content

Commit 50d713e

Browse files
committed
v0.4.5 release
2 parents 97f50b3 + 216859e commit 50d713e

22 files changed

+868
-313
lines changed

installer/installer.nsi

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,13 @@ Section "Notepad Next"
105105
SectionIn RO
106106
SetOutPath $INSTDIR
107107

108-
File /r ..\build\package\*
108+
File /r /x libcrypto-1_1-x64.dll /x libssl-1_1-x64.dll ..\build\package\*
109109

110110
SetRegView 64
111111

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-
119115
# Register 'Open With' menu suggestion. No real good documentation for this. https://stackoverflow.com/a/62783311
120116
WriteRegStr SHCTX "Software\Classes\NotepadNext\shell" "" "open"
121117
WriteRegStr SHCTX "Software\Classes\NotepadNext\shell\open\command" "" "$\"$INSTDIR\NotepadNext.exe$\" $\"%1$\""
@@ -147,6 +143,15 @@ Section /o "Context Menu"
147143
WriteRegStr SHCTX "Software\Classes\*\shell\NotepadNext\command" "" "$\"$INSTDIR\NotepadNext.exe$\" $\"%1$\""
148144
SectionEnd
149145

146+
Section /o "Auto Updater"
147+
SetRegView 64
148+
SetOutPath $INSTDIR
149+
150+
File ..\build\package\libcrypto-1_1-x64.dll ..\build\package\libssl-1_1-x64.dll
151+
152+
WriteRegDWORD SHCTX "Software\NotepadNext\NotepadNext\" "AutoUpdate" 1
153+
SectionEnd
154+
150155

151156
Section "Uninstall"
152157
SetRegView 64

src/NotepadNext.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ win32 {
4242

4343
zip.target = zip
4444
zip.depends = package
45-
zip.commands = 7z a -tzip $$quote(NotepadNext-v$${APP_VERSION}.zip) $$shell_path(./package/*)
45+
zip.commands = 7z a -tzip $$quote(NotepadNext-v$${APP_VERSION}.zip) $$shell_path(./package/*) -x!libssl-1_1-x64.dll -x!libcrypto-1_1-x64.dll
4646

4747
installer.target = installer
4848
installer.depends = package

src/NotepadNext/EditorManager.cpp

Lines changed: 22 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "EditorManager.h"
2121
#include "ScintillaNext.h"
2222
#include "Scintilla.h"
23-
#include "ScintillaTypes.h"
2423

2524
// Editor decorators
2625
#include "BraceMatch.h"
@@ -31,15 +30,17 @@
3130
#include "BetterMultiSelection.h"
3231
#include "AutoIndentation.h"
3332

33+
3434
const int MARK_BOOKMARK = 24;
3535
const int MARK_HIDELINESBEGIN = 23;
3636
const int MARK_HIDELINESEND = 22;
3737
const int MARK_HIDELINESUNDERLINE = 21;
3838

39+
3940
EditorManager::EditorManager(QObject *parent) : QObject(parent)
4041
{
41-
connect(this, &EditorManager::editorCreated, [=](ScintillaNext *editor) {
42-
connect(editor, &ScintillaNext::closed, [=]() {
42+
connect(this, &EditorManager::editorCreated, this, [=](ScintillaNext *editor) {
43+
connect(editor, &ScintillaNext::closed, this, [=]() {
4344
emit editorClosed(editor);
4445
});
4546
});
@@ -48,8 +49,8 @@ EditorManager::EditorManager(QObject *parent) : QObject(parent)
4849
ScintillaNext *EditorManager::createEmptyEditor(const QString &name)
4950
{
5051
ScintillaNext *editor = new ScintillaNext(name);
51-
QPointer<ScintillaNext> pointer = QPointer<ScintillaNext>(editor);
52-
editors.append(pointer);
52+
53+
manageEditor(editor);
5354

5455
setupEditor(editor);
5556

@@ -61,8 +62,8 @@ ScintillaNext *EditorManager::createEmptyEditor(const QString &name)
6162
ScintillaNext *EditorManager::createEditorFromFile(const QString &filePath)
6263
{
6364
ScintillaNext *editor = ScintillaNext::fromFile(filePath);
64-
QPointer<ScintillaNext> pointer = QPointer<ScintillaNext>(editor);
65-
editors.append(pointer);
65+
66+
manageEditor(editor);
6667

6768
setupEditor(editor);
6869

@@ -74,8 +75,8 @@ ScintillaNext *EditorManager::createEditorFromFile(const QString &filePath)
7475
ScintillaNext *EditorManager::cloneEditor(ScintillaNext *editor)
7576
{
7677
ScintillaNext *clonedEditor = new ScintillaNext("Clone");
77-
QPointer<ScintillaNext> pointer = QPointer<ScintillaNext>(clonedEditor);
78-
editors.append(pointer);
78+
79+
manageEditor(editor);
7980

8081
setupEditor(clonedEditor);
8182

@@ -100,13 +101,24 @@ ScintillaNext *EditorManager::getEditorByFilePath(const QString &filePath)
100101
return Q_NULLPTR;
101102
}
102103

104+
void EditorManager::manageEditor(ScintillaNext *editor)
105+
{
106+
editors.append(QPointer<ScintillaNext>(editor));
107+
}
108+
103109
void EditorManager::setupEditor(ScintillaNext *editor)
104110
{
105111
qInfo(Q_FUNC_INFO);
106112

107113
editor->clearCmdKey(SCK_INSERT);
108114

109-
setFoldMarkers(editor, "box");
115+
editor->setFoldMarkers(QStringLiteral("box"));
116+
for (int i = SC_MARKNUM_FOLDEREND; i <= SC_MARKNUM_FOLDEROPEN; ++i) {
117+
editor->markerSetFore(i, 0xF3F3F3);
118+
editor->markerSetBack(i, 0x808080);
119+
editor->markerSetBackSelected(i, 0x0000FF);
120+
}
121+
110122
editor->setIdleStyling(SC_IDLESTYLING_TOVISIBLE);
111123
editor->setEndAtLastLine(false);
112124

@@ -229,35 +241,6 @@ void EditorManager::setupEditor(ScintillaNext *editor)
229241
ai->setEnabled(true);
230242
}
231243

232-
// TODO: Move this into the editor eventually?
233-
void EditorManager::setFoldMarkers(ScintillaNext *editor, const QString &type)
234-
{
235-
QMap<QString, QList<int>> map{
236-
{"simple", {SC_MARK_MINUS, SC_MARK_PLUS, SC_MARK_EMPTY, SC_MARK_EMPTY, SC_MARK_EMPTY, SC_MARK_EMPTY, SC_MARK_EMPTY}},
237-
{"arrow", {SC_MARK_ARROWDOWN, SC_MARK_ARROW, SC_MARK_EMPTY, SC_MARK_EMPTY, SC_MARK_EMPTY, SC_MARK_EMPTY, SC_MARK_EMPTY}},
238-
{"circle", {SC_MARK_CIRCLEMINUS, SC_MARK_CIRCLEPLUS, SC_MARK_VLINE, SC_MARK_LCORNERCURVE, SC_MARK_CIRCLEPLUSCONNECTED, SC_MARK_CIRCLEMINUSCONNECTED, SC_MARK_TCORNERCURVE }},
239-
{"box", {SC_MARK_BOXMINUS, SC_MARK_BOXPLUS, SC_MARK_VLINE, SC_MARK_LCORNER, SC_MARK_BOXPLUSCONNECTED, SC_MARK_BOXMINUSCONNECTED, SC_MARK_TCORNER }},
240-
};
241-
242-
if (!map.contains(type))
243-
return;
244-
245-
const auto types = map[type];
246-
editor->markerDefine(SC_MARKNUM_FOLDEROPEN, types[0]);
247-
editor->markerDefine(SC_MARKNUM_FOLDER, types[1]);
248-
editor->markerDefine(SC_MARKNUM_FOLDERSUB, types[2]);
249-
editor->markerDefine(SC_MARKNUM_FOLDERTAIL, types[3]);
250-
editor->markerDefine(SC_MARKNUM_FOLDEREND, types[4]);
251-
editor->markerDefine(SC_MARKNUM_FOLDEROPENMID, types[5]);
252-
editor->markerDefine(SC_MARKNUM_FOLDERMIDTAIL, types[6]);
253-
254-
for (int i = SC_MARKNUM_FOLDEREND; i <= SC_MARKNUM_FOLDEROPEN; ++i) {
255-
editor->markerSetFore(i, 0xF3F3F3);
256-
editor->markerSetBack(i, 0x808080);
257-
editor->markerSetBackSelected(i, 0x0000FF);
258-
}
259-
}
260-
261244
void EditorManager::purgeOldEditorPointers()
262245
{
263246
QMutableListIterator<QPointer<ScintillaNext>> it(editors);

src/NotepadNext/EditorManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class EditorManager : public QObject
4444
void editorClosed(ScintillaNext *editor);
4545

4646
private:
47+
void manageEditor(ScintillaNext *editor);
4748
void setupEditor(ScintillaNext *editor);
48-
void setFoldMarkers(ScintillaNext *editor, const QString &type);
4949
void purgeOldEditorPointers();
5050

5151
QList<QPointer<ScintillaNext>> editors;

src/NotepadNext/NotepadNext.pro

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ SOURCES += \
8585
decorators/BetterMultiSelection.cpp \
8686
decorators/EditorConfigAppDecorator.cpp \
8787
decorators/SurroundSelection.cpp \
88+
dialogs/EditorInspectorDock.cpp \
8889
dialogs/FindReplaceDialog.cpp \
8990
dialogs/LanguageInspectorDock.cpp \
9091
dialogs/LuaConsoleDock.cpp \
@@ -98,6 +99,7 @@ SOURCES += \
9899
decorators/HighlightedScrollBar.cpp \
99100
decorators/LineNumbers.cpp \
100101
decorators/SmartHighlighter.cpp \
102+
widgets/EditorInfoStatusBar.cpp \
101103
widgets/StatusLabel.cpp
102104

103105
HEADERS += \
@@ -130,6 +132,7 @@ HEADERS += \
130132
decorators/BetterMultiSelection.h \
131133
decorators/EditorConfigAppDecorator.h \
132134
decorators/SurroundSelection.h \
135+
dialogs/EditorInspectorDock.h \
133136
dialogs/FindReplaceDialog.h \
134137
dialogs/LanguageInspectorDock.h \
135138
dialogs/LuaConsoleDock.h \
@@ -142,10 +145,12 @@ HEADERS += \
142145
decorators/HighlightedScrollBar.h \
143146
decorators/LineNumbers.h \
144147
decorators/SmartHighlighter.h \
148+
widgets/EditorInfoStatusBar.h \
145149
widgets/StatusLabel.h
146150

147151
FORMS += \
148152
QuickFindWidget.ui \
153+
dialogs/EditorInspectorDock.ui \
149154
dialogs/LanguageInspectorDock.ui \
150155
dialogs/MainWindow.ui \
151156
dialogs/FindReplaceDialog.ui \

src/NotepadNext/NotepadNextApplication.cpp

Lines changed: 92 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929

3030
#include "EditorConfigAppDecorator.h"
3131

32+
#include "ILexer.h"
33+
#include "Lexilla.h"
34+
#include "SciLexer.h"
35+
3236
#include <QCommandLineParser>
3337
#include <QSettings>
3438

@@ -156,15 +160,21 @@ bool NotepadNextApplication::initGui()
156160
}
157161
});
158162

159-
applyArguments(SingleApplication::arguments());
163+
// Keep Lua's editor reference up to date
164+
connect(windows.first(), &MainWindow::editorActivated, this, [](ScintillaNext *editor) {
165+
LuaExtension::Instance().setEditor(editor);
166+
});
160167

161-
// Everything should be ready at this point
168+
applyArguments(SingleApplication::arguments());
162169

163170
// If the window does not have any editors (meaning the applyArguments() did not
164171
// have any files to open) then create a new empty file
165-
if (windows.first()->getDockedEditor()->count() == 0) {
172+
if (windows.first()->editorCount() == 0) {
166173
windows.first()->newFile();
167174
}
175+
176+
// Everything should be ready at this point
177+
168178
windows.first()->show();
169179
windows.first()->bringWindowToForeground();
170180

@@ -188,7 +198,85 @@ QString NotepadNextApplication::getFileDialogFilter() const
188198
return table.concat(filter, ";;")
189199
)=");
190200

191-
return filter;
201+
return filter;
202+
}
203+
204+
QStringList NotepadNextApplication::getLanguages() const
205+
{
206+
return getLuaState()->executeAndReturn<QStringList>(
207+
R"(
208+
local names = {}
209+
for k in pairs(languages) do table.insert(names, k) end
210+
table.sort(names, function (a, b) return string.lower(a) < string.lower(b) end)
211+
return names
212+
)");
213+
}
214+
215+
void NotepadNextApplication::setEditorLanguage(ScintillaNext *editor, const QString &languageName) const
216+
{
217+
LuaExtension::Instance().setEditor(editor);
218+
219+
getLuaState()->execute(QString("languageName = \"%1\"").arg(QString(languageName)).toLatin1().constData());
220+
const QString lexer = getLuaState()->executeAndReturn<QString>("return languages[languageName].lexer");
221+
222+
editor->languageName = languageName;
223+
auto lexerInstance = CreateLexer(lexer.toLatin1().constData());
224+
editor->setILexer((sptr_t) lexerInstance);
225+
226+
getLuaState()->execute(R"(
227+
local L = languages[languageName]
228+
229+
editor.UseTabs = (L.tabSettings or "tabs") == "tabs"
230+
editor.TabWidth = L.tabSize or 4
231+
if L.styles then
232+
for name, style in pairs(L.styles) do
233+
editor.StyleFore[style.id] = style.fgColor
234+
editor.StyleBack[style.id] = style.bgColor
235+
if style.fontStyle then
236+
if style.fontStyle & 1 == 1 then
237+
editor.StyleBold[style.id] = true
238+
end
239+
if style.fontStyle & 2 == 2 then
240+
editor.StyleItalic[style.id] = true
241+
end
242+
if style.fontStyle & 4 == 4 then
243+
editor.StyleUnderline[style.id] = true
244+
end
245+
end
246+
end
247+
end
248+
if L.keywords then
249+
for id, kw in pairs(L.keywords) do
250+
editor.KeyWords[id] = kw
251+
end
252+
end
253+
if L.properties then
254+
for p,v in pairs(L.properties) do
255+
editor.Property[p] = v
256+
end
257+
end
258+
editor.Property["fold"] = "1"
259+
editor.Property["fold.compact"] = "0"
260+
261+
-- The document needs redone, but don't force it to do the whole thing
262+
-- since SC_IDLESTYLING_TOVISIBLE is used
263+
editor:Colourise(0, 1);
264+
)");
265+
}
266+
267+
QString NotepadNextApplication::detectLanguageFromExtension(const QString &extension) const
268+
{
269+
return getLuaState()->executeAndReturn<QString>(QString(R"(
270+
local ext = "%1"
271+
for name, L in pairs(languages) do
272+
for _, v in ipairs(L.extensions) do
273+
if v == ext then
274+
return name
275+
end
276+
end
277+
end
278+
return "null"
279+
)").arg(extension).toLatin1().constData());
192280
}
193281

194282
void NotepadNextApplication::applyArguments(const QStringList &args)

src/NotepadNext/NotepadNextApplication.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class MainWindow;
3131
class LuaState;
3232
class EditorManager;
3333
class RecentFilesListManager;
34+
class ScintillaNext;
3435

3536
class NotepadNextApplication : public SingleApplication
3637
{
@@ -48,6 +49,10 @@ class NotepadNextApplication : public SingleApplication
4849
QString getFileDialogFilter() const;
4950
Settings *getSettings() const { return settings; }
5051

52+
QStringList getLanguages() const;
53+
void setEditorLanguage(ScintillaNext *editor, const QString &languageName) const;
54+
QString detectLanguageFromExtension(const QString &extension) const;
55+
5156
private:
5257
EditorManager *editorManager;
5358
RecentFilesListManager *recentFilesListManager;

0 commit comments

Comments
 (0)