Skip to content
This repository was archived by the owner on Oct 21, 2024. It is now read-only.

Commit d203ce9

Browse files
authored
v1.3.2 bug fix
1 parent 04249ab commit d203ce9

File tree

3 files changed

+53
-33
lines changed

3 files changed

+53
-33
lines changed

MicrologicIDE.cpp

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ MicrologicIDE::MicrologicIDE(QWidget *parent) : QMainWindow(parent), ui(new Ui::
4242

4343
connect(ui->getHelpAction, &QAction::triggered, this, &MicrologicIDE::seeHelp);
4444
connect(ui->dateAction, &QAction::triggered, this, &MicrologicIDE::setDateTime);
45+
connect(ui->refreshAction, &QAction::triggered, this, &MicrologicIDE::makeMarks);
4546

4647
connect(ui->copyAction, &QAction::triggered, ui->textEdit, &QTextEdit::copy);
4748
connect(ui->cutAction, &QAction::triggered, ui->textEdit, &QTextEdit::cut);
@@ -56,7 +57,7 @@ MicrologicIDE::MicrologicIDE(QWidget *parent) : QMainWindow(parent), ui(new Ui::
5657
connect(ui->runAction, &QAction::triggered, this, &MicrologicIDE::runFile);
5758
connect(debugger, SIGNAL(fileChanged(QString)), this, SLOT(updateDebug()));
5859

59-
connect(ui->textEdit, &QTextEdit::textChanged, this, &MicrologicIDE::makeMarks);
60+
connect(ui->textEdit, &QTextEdit::textChanged, this, &MicrologicIDE::makeNewMarks);
6061

6162
}
6263

@@ -97,6 +98,7 @@ void MicrologicIDE::openFile(void){
9798
path=currentfileName.toStdString().substr(0,currentfileName.toStdString().rfind("/")+1);
9899
path.replace(path.size()-1,1,"\\");
99100
}catch(...){}
101+
makeMarks();
100102
}
101103

102104
void MicrologicIDE::saveFile(void){
@@ -325,22 +327,26 @@ void MicrologicIDE::unmark(){
325327
ui->textEdit->setText(text.c_str());
326328
}
327329

328-
void MicrologicIDE::makeMarks(){
330+
void MicrologicIDE::makeNewMarks(){
329331
if(currentContent!=ui->textEdit->document()->toPlainText().toStdString()){
330-
currentContent=ui->textEdit->document()->toPlainText().toStdString();
331-
QTextCursor cursor=ui->textEdit->textCursor();
332-
int pos=cursor.position();
333-
unmark();
334-
std::vector<int> errorList;
335-
auto grammar=grammarCheck(content());
336-
for(int i=0;i<content().size();i++) if(!grammar[i]) errorList.push_back(i);
337-
mark(errorList);
338-
cursor=ui->textEdit->textCursor();
339-
cursor.setPosition(pos);
340-
ui->textEdit->setTextCursor(cursor);
332+
makeMarks();
341333
}
342334
}
343335

336+
void MicrologicIDE::makeMarks(){
337+
currentContent=ui->textEdit->document()->toPlainText().toStdString();
338+
QTextCursor cursor=ui->textEdit->textCursor();
339+
int pos=cursor.position();
340+
unmark();
341+
std::vector<int> errorList;
342+
auto grammar=grammarCheck(content());
343+
for(int i=0;i<content().size();i++) if(!grammar[i]) errorList.push_back(i);
344+
mark(errorList);
345+
cursor=ui->textEdit->textCursor();
346+
cursor.setPosition(pos);
347+
ui->textEdit->setTextCursor(cursor);
348+
}
349+
344350
void MicrologicIDE::lightMode(){
345351
this->setStyleSheet("background-color: white; color: black;");
346352
ui->textEdit->setStyleSheet("border-top-style: solid; border-bottom-style: solid; border-width: 1px; border-color: black;");
@@ -430,13 +436,13 @@ std::map<std::string,std::pair<int,int>> MicrologicIDE::findMods(std::vector<std
430436
args.push_back(s);
431437
}
432438
if(args.size()>0){
433-
if (args[0] == "path" && count(line.begin(), line.end(), '\"') >= 2) {
434-
int x = line.find("\""), y = line.rfind("\"");
435-
std::string f = line.substr(x + 1, y - x - 1);
436-
path = f;
439+
if (args[0]=="path"&&count(line.begin(),line.end(),'\"')>=2) {
440+
int x=line.find("\""),y=line.rfind("\"");
441+
std::string f = line.substr(x+1,y-x-1);
442+
path=f;
437443
}
438-
else if (args[0] == "path" && args.size() == 2) {
439-
path = args[1];
444+
else if (args[0]=="path"&&args.size()==2) {
445+
path=args[1];
440446
}
441447
else if(args[0]=="mod"&&args.size()==3){
442448
try{
@@ -632,6 +638,10 @@ std::vector<bool> MicrologicIDE::grammarCheck(std::vector<std::string> lines){
632638
if(mods.count(args[1])!=0){
633639
if(args.size()==2+mods[args[1]].first+mods[args[1]].second) ans[i]=true;
634640
else ans[i]=false;
641+
for(int j=2;j<args.size();j++){
642+
if(!isNumber(args[j])) ans[i]=false;
643+
if(atoi(args[j].c_str())>=Ls.size()) ans[i]=false;
644+
}
635645
modBlock[args[1]]++;
636646
}
637647
else ans[i]=false;

MicrologicIDE.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class MicrologicIDE : public QMainWindow
6666
void unmark();
6767
std::map<std::string,std::pair<int,int>> findMods(std::vector<std::string>);
6868
std::vector<bool> grammarCheck(std::vector<std::string>);
69+
void makeNewMarks();
6970
void makeMarks();
7071

7172
void lightMode();

MicrologicIDE.ui

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
</widget>
7474
<widget class="QMenu" name="menu_E">
7575
<property name="title">
76-
<string>编辑(E)</string>
76+
<string>编辑(&amp;E)</string>
7777
</property>
7878
<addaction name="undoAction"/>
7979
<addaction name="separator"/>
@@ -84,6 +84,7 @@
8484
<addaction name="separator"/>
8585
<addaction name="selectAllAction"/>
8686
<addaction name="dateAction"/>
87+
<addaction name="refreshAction"/>
8788
</widget>
8889
<widget class="QMenu" name="menu_V">
8990
<property name="title">
@@ -102,7 +103,7 @@
102103
</widget>
103104
<widget class="QMenu" name="menu_F5">
104105
<property name="title">
105-
<string>运行(R)</string>
106+
<string>运行(&amp;R)</string>
106107
</property>
107108
<addaction name="runAction"/>
108109
</widget>
@@ -119,7 +120,7 @@
119120
<normaloff>:/images/new.png</normaloff>:/images/new.png</iconset>
120121
</property>
121122
<property name="text">
122-
<string>新建(N)</string>
123+
<string>新建(&amp;N)</string>
123124
</property>
124125
<property name="shortcut">
125126
<string>Ctrl+N</string>
@@ -131,7 +132,7 @@
131132
<normaloff>:/images/open.png</normaloff>:/images/open.png</iconset>
132133
</property>
133134
<property name="text">
134-
<string>打开(O)</string>
135+
<string>打开(&amp;O)</string>
135136
</property>
136137
<property name="shortcut">
137138
<string>Ctrl+O</string>
@@ -143,7 +144,7 @@
143144
<normaloff>:/images/save.png</normaloff>:/images/save.png</iconset>
144145
</property>
145146
<property name="text">
146-
<string>保存(S)</string>
147+
<string>保存(&amp;S)</string>
147148
</property>
148149
<property name="shortcut">
149150
<string>Ctrl+S</string>
@@ -155,7 +156,7 @@
155156
<normaloff>:/images/saveAs.png</normaloff>:/images/saveAs.png</iconset>
156157
</property>
157158
<property name="text">
158-
<string>另存为(A)</string>
159+
<string>另存为(&amp;A)</string>
159160
</property>
160161
</action>
161162
<action name="exitNotepadAction">
@@ -164,7 +165,7 @@
164165
<normaloff>:/images/exit.png</normaloff>:/images/exit.png</iconset>
165166
</property>
166167
<property name="text">
167-
<string>退出(X)</string>
168+
<string>退出(&amp;X)</string>
168169
</property>
169170
<property name="shortcut">
170171
<string>Ctrl+X</string>
@@ -176,7 +177,7 @@
176177
<normaloff>:/images/undo.png</normaloff>:/images/undo.png</iconset>
177178
</property>
178179
<property name="text">
179-
<string>撤销(U)</string>
180+
<string>撤销(&amp;U)</string>
180181
</property>
181182
<property name="shortcut">
182183
<string>Ctrl+U</string>
@@ -188,7 +189,7 @@
188189
<normaloff>:/images/cut.png</normaloff>:/images/cut.png</iconset>
189190
</property>
190191
<property name="text">
191-
<string>剪切(T)</string>
192+
<string>剪切(&amp;T)</string>
192193
</property>
193194
<property name="shortcut">
194195
<string>Ctrl+T</string>
@@ -200,7 +201,7 @@
200201
<normaloff>:/images/copy.png</normaloff>:/images/copy.png</iconset>
201202
</property>
202203
<property name="text">
203-
<string>复制(C)</string>
204+
<string>复制(&amp;C)</string>
204205
</property>
205206
<property name="shortcut">
206207
<string>Ctrl+C</string>
@@ -212,31 +213,31 @@
212213
<normaloff>:/images/paste.png</normaloff>:/images/paste.png</iconset>
213214
</property>
214215
<property name="text">
215-
<string>粘贴(P)</string>
216+
<string>粘贴(&amp;P)</string>
216217
</property>
217218
<property name="shortcut">
218219
<string>Ctrl+P</string>
219220
</property>
220221
</action>
221222
<action name="deleteAction">
222223
<property name="text">
223-
<string>删除(L)</string>
224+
<string>删除(&amp;L)</string>
224225
</property>
225226
<property name="shortcut">
226227
<string>Del</string>
227228
</property>
228229
</action>
229230
<action name="selectAllAction">
230231
<property name="text">
231-
<string>全选(A)</string>
232+
<string>全选(&amp;A)</string>
232233
</property>
233234
<property name="shortcut">
234235
<string>Ctrl+A</string>
235236
</property>
236237
</action>
237238
<action name="dateAction">
238239
<property name="text">
239-
<string>时间/日期(D)</string>
240+
<string>时间/日期(&amp;D)</string>
240241
</property>
241242
<property name="shortcut">
242243
<string>Ctrl+D</string>
@@ -298,6 +299,14 @@
298299
<string>Alt+S</string>
299300
</property>
300301
</action>
302+
<action name="refreshAction">
303+
<property name="text">
304+
<string>刷新(&amp;R)</string>
305+
</property>
306+
<property name="shortcut">
307+
<string>Ctrl+R</string>
308+
</property>
309+
</action>
301310
</widget>
302311
<layoutdefault spacing="6" margin="11"/>
303312
<resources>

0 commit comments

Comments
 (0)