Skip to content

Commit bdf9ed5

Browse files
Merge branch 'master' of https://github.com/dail8859/NotepadNext
2 parents 7d5695b + 2777659 commit bdf9ed5

File tree

7 files changed

+85
-1
lines changed

7 files changed

+85
-1
lines changed

src/NotepadNext/ScintillaNext.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,26 @@ void ScintillaNext::reload()
347347
if (readSuccessful) {
348348
updateTimestamp();
349349
setSavePoint();
350+
351+
// If this was a temporary file, make sure it is not any more
352+
setTemporary(false);
353+
354+
emit reloaded();
350355
}
351356

352357
return;
353358
}
354359

360+
void ScintillaNext::omitModifications()
361+
{
362+
// If file modifications will be omitted just update file timestamp
363+
// so pop-up will be displayed only once per file modifications.
364+
updateTimestamp();
365+
setTemporary(true);
366+
367+
return;
368+
}
369+
355370
QFileDevice::FileError ScintillaNext::saveAs(const QString &newFilePath)
356371
{
357372
bool isRenamed = bufferType == ScintillaNext::New || fileInfo.canonicalFilePath() != newFilePath;

src/NotepadNext/ScintillaNext.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public slots:
122122
void close();
123123
QFileDevice::FileError save();
124124
void reload();
125+
void omitModifications();
125126
QFileDevice::FileError saveAs(const QString &newFilePath);
126127
QFileDevice::FileError saveCopyAs(const QString &filePath);
127128
bool rename(const QString &newFilePath);
@@ -139,6 +140,7 @@ public slots:
139140
void renamed();
140141

141142
void lexerChanged();
143+
void reloaded();
142144

143145
protected:
144146
void dragEnterEvent(QDragEnterEvent *event) override;

src/NotepadNext/decorators/URLFinder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ URLFinder::URLFinder(ScintillaNext *editor) :
4646
connect(this, &EditorDecorator::stateChanged, this, [=](bool b) {
4747
if (b) {
4848
connect(editor, &ScintillaNext::resized, timer, qOverload<>(&QTimer::start));
49+
connect(editor, &ScintillaNext::reloaded, timer, qOverload<>(&QTimer::start));
4950
findURLs();
5051
}
5152
else {

src/NotepadNext/dialogs/MainWindow.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1854,7 +1854,15 @@ bool MainWindow::checkFileForModification(ScintillaNext *editor)
18541854
}
18551855
else if (state == ScintillaNext::Modified) {
18561856
qInfo("ScintillaNext::Modified");
1857-
editor->reload();
1857+
const QString filePath = editor->getFilePath();
1858+
auto reply = QMessageBox::question(this, tr("Reload File"), tr("<b>%1</b> has been modified by another program. Do you want to reload it?").arg(filePath));
1859+
1860+
if (reply == QMessageBox::Yes) {
1861+
editor->reload();
1862+
}
1863+
else {
1864+
editor->omitModifications();
1865+
}
18581866
}
18591867
else if (state == ScintillaNext::Deleted) {
18601868
qInfo("ScintillaNext::Deleted");
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
local L = {}
2+
3+
L.lexer = "abaqus"
4+
5+
L.singleLineComment = ""
6+
7+
L.extensions = {
8+
"inp",
9+
}
10+
11+
L.keywords = {
12+
}
13+
14+
L.styles = {
15+
["DEFAULT"] = {
16+
id = 0,
17+
fgColor = rgb(0x000000),
18+
bgColor = rgb(0xFFFFFF),
19+
},
20+
["COMMENT"] = {
21+
id = 1,
22+
fgColor = rgb(0x008000),
23+
bgColor = rgb(0xFFFFFF),
24+
},
25+
["NUMBER"] = {
26+
id = 3,
27+
fgColor = rgb(0xFF8000),
28+
bgColor = rgb(0xFFFFFF),
29+
},
30+
["STRING"] = {
31+
id = 4,
32+
fgColor = rgb(0xFF8000),
33+
bgColor = rgb(0xFFFFFF),
34+
},
35+
["OPERATOR"] = {
36+
id = 5,
37+
fgColor = rgb(0x000080),
38+
bgColor = rgb(0xFFFFFF),
39+
},
40+
["PROCESSORS"] = {
41+
id = 7,
42+
fgColor = rgb(0x8000FF),
43+
bgColor = rgb(0xFFFFFF),
44+
},
45+
["STARCOMMAND"] = {
46+
id = 10,
47+
fgColor = rgb(0x0000FF),
48+
bgColor = rgb(0xFFFFFF),
49+
},
50+
["ARGUMENT"] = {
51+
id = 11,
52+
fgColor = rgb(0x8800FF),
53+
bgColor = rgb(0xFFFFFF),
54+
},
55+
}
56+
return L

src/NotepadNext/scripts.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,6 @@
8787
<file>languages/go.lua</file>
8888
<file>languages/markdown.lua</file>
8989
<file>languages/nix.lua</file>
90+
<file>languages/abaqus.lua</file>
9091
</qresource>
9192
</RCC>

src/NotepadNext/scripts/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,4 @@ languages["VHDL"] = require("vhdl")
189189
languages["Visual Prolog"] = require("visualprolog")
190190
languages["XML"] = require("xml")
191191
languages["YAML"] = require("yaml")
192+
languages["Abaqus"] = require("abaqus")

0 commit comments

Comments
 (0)