- enhancement: auto clear parsed symbols when the editor is hidden ( to reduce memory usage of un-active editors)

This commit is contained in:
royqh1979 2021-11-08 09:19:50 +08:00
parent 3e0925ba70
commit f167e10c12
10 changed files with 373 additions and 309 deletions

View File

@ -1,7 +1,8 @@
Version 0.8.2 For Dev-C++ 7 Beta
- fix: highlighter can't correctly find the end of ANSI C-style Comments
- enhancement: Add default color scheme to themes. Change theme option will change color scheme too.
- enhancement: add default color scheme to themes. Change theme option will change color scheme too.
- fix: when changing options in the option dialog's color scheme panle, color of the demo editor won't be not correctly updated
- enhancement: auto clear parsed symbols when the editor is hidden ( to reduce memory usage of un-active editors)
Version 0.8.1 For Dev-C++ 7 Beta
- fix: ConsolePaurser.exe only exits when press ENTER

View File

@ -5,7 +5,6 @@
#include "qsynedit/highlighter/asm.h"
#include "qsynedit/Constants.h"
#include "colorscheme.h"
#include <QDebug>
HighlighterManager highlighterManager;

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -564,7 +564,9 @@ void Editor::keyPressEvent(QKeyEvent *event)
handled = true;
QStringList insertString;
insertString.append("");
PStatement function = mParser->findFunctionAt(mFilename,caretY()+1);
PStatement function;
if (mParser)
function = mParser->findFunctionAt(mFilename,caretY()+1);
if (function) {
QStringList params;
QString funcName = function->command;
@ -678,7 +680,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
if (pSettings->codeCompletion().enabled()
&& pSettings->codeCompletion().showCompletionWhileInput() ) {
if (mLastIdCharPressed==1) {
if (mParser->isIncludeLine(lineText())) {
if (mParser && mParser->isIncludeLine(lineText())) {
// is a #include line
setSelText(ch);
showHeaderCompletion(false);

View File

@ -4772,12 +4772,33 @@ PSymbolUsageManager &MainWindow::symbolUsageManager()
return mSymbolUsageManager;
}
static void updateEditorParser(QTabWidget* tabWidget,
Editor* editor) {
qDebug()<<"update editors";
qDebug()<<pSettings->codeCompletion().clearWhenEditorHidden();
if (pSettings->codeCompletion().clearWhenEditorHidden()) {
for (int i=0;i<tabWidget->count();i++) {
Editor * e = (Editor*)(tabWidget->widget(i));
if (!e->inProject()) {
if (e==editor) {
resetCppParser(e->parser());
e->reparse();
} else {
qDebug()<<"clear editor:"<<e->filename();
//e->initParser();
e->parser()->reset();
}
}
}
}
}
void MainWindow::on_EditorTabsLeft_currentChanged(int)
{
Editor * editor = mEditorList->getEditor(-1,ui->EditorTabsLeft);
if (editor) {
editor->reparseTodo();
}
updateEditorParser(ui->EditorTabsLeft,editor);
}
@ -4787,6 +4808,7 @@ void MainWindow::on_EditorTabsRight_currentChanged(int)
if (editor) {
editor->reparseTodo();
}
updateEditorParser(ui->EditorTabsRight,editor);
}

View File

@ -3109,6 +3109,16 @@ void Settings::CodeCompletion::setShowCodeIns(bool newShowCodeIns)
mShowCodeIns = newShowCodeIns;
}
bool Settings::CodeCompletion::clearWhenEditorHidden() const
{
return mClearWhenEditorHidden;
}
void Settings::CodeCompletion::setClearWhenEditorHidden(bool newClearWhenEditorHidden)
{
mClearWhenEditorHidden = newClearWhenEditorHidden;
}
bool Settings::CodeCompletion::appendFunc() const
{
return mAppendFunc;
@ -3233,6 +3243,7 @@ void Settings::CodeCompletion::doSave()
saveValue("ignore_case",mIgnoreCase);
saveValue("append_func",mAppendFunc);
saveValue("show_code_ins",mShowCodeIns);
saveValue("clear_when_editor_hidden",mClearWhenEditorHidden);
}
@ -3251,6 +3262,7 @@ void Settings::CodeCompletion::doLoad()
mIgnoreCase = boolValue("ignore_case",true);
mAppendFunc = boolValue("append_func",true);
mShowCodeIns = boolValue("show_code_ins",true);
mClearWhenEditorHidden = boolValue("clear_when_editor_hidden",true);
}
Settings::CodeFormatter::CodeFormatter(Settings *settings):

View File

@ -521,6 +521,9 @@ public:
bool showCodeIns() const;
void setShowCodeIns(bool newShowCodeIns);
bool clearWhenEditorHidden() const;
void setClearWhenEditorHidden(bool newClearWhenEditorHidden);
private:
int mWidth;
int mHeight;
@ -534,6 +537,7 @@ public:
bool mIgnoreCase;
bool mAppendFunc;
bool mShowCodeIns;
bool mClearWhenEditorHidden;
// _Base interface
protected:

View File

@ -34,6 +34,7 @@ void EditorCodeCompletionWidget::doLoad()
ui->chkIgnoreCases->setChecked(pSettings->codeCompletion().ignoreCase());
ui->chkAppendFunc->setChecked(pSettings->codeCompletion().appendFunc());
ui->chkShowCodeIns->setChecked(pSettings->codeCompletion().showCodeIns());
ui->chkClearWhenEditorHidden->setChecked(pSettings->codeCompletion().clearWhenEditorHidden());
}
void EditorCodeCompletionWidget::doSave()
@ -54,6 +55,7 @@ void EditorCodeCompletionWidget::doSave()
pSettings->codeCompletion().setIgnoreCase(ui->chkIgnoreCases->isChecked());
pSettings->codeCompletion().setAppendFunc(ui->chkAppendFunc->isChecked());
pSettings->codeCompletion().setShowCodeIns(ui->chkShowCodeIns->isChecked());
pSettings->codeCompletion().setClearWhenEditorHidden(ui->chkClearWhenEditorHidden->isChecked());
pSettings->codeCompletion().save();
}

View File

@ -26,6 +26,13 @@
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="chkClearWhenEditorHidden">
<property name="text">
<string>Clear all parsed symbols when editor is hidden</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkShowSuggestionWhileTyping">
<property name="text">