* work save for symbol completion options

This commit is contained in:
royqh1979 2021-06-21 22:01:35 +08:00
parent bec57498ed
commit fd9b41ac6d
14 changed files with 58 additions and 18 deletions

Binary file not shown.

View File

@ -1003,7 +1003,7 @@ Are you really want to continue?</source>
<message>
<location filename="mainwindow.cpp" line="274"/>
<source>Open</source>
<translation></translation>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="499"/>

View File

@ -575,6 +575,7 @@ bool ColorManager::add(const QString &name, PColorScheme scheme)
scheme->setCustomed(false);
mSchemes[name] = scheme;
saveScheme(name);
return true;
}
PColorScheme ColorManager::get(const QString &name)
@ -634,6 +635,7 @@ bool ColorManager::saveScheme(const QString &name)
return false;
QString newFilepath = generateFullPathname(name,scheme->bundled(),scheme->customed());
scheme->save(newFilepath);
return true;
}
QString ColorManager::generateFullPathname(const QString &name, bool isBundled, bool isCustomed)

View File

@ -252,7 +252,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
bool handled = false;
QString t = event->text();
if (!t.isEmpty()) {
QChar ch = t;
QChar ch = t[0];
switch (ch.unicode()) {
case '"':
case '\'':

View File

@ -94,9 +94,9 @@ private:
// QWidget interface
protected:
void wheelEvent(QWheelEvent *event) override;
void focusInEvent(QFocusEvent *event);
void focusOutEvent(QFocusEvent *event);
void keyPressEvent(QKeyEvent *event);
void focusInEvent(QFocusEvent *event) override;
void focusOutEvent(QFocusEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
};
#endif // EDITOR_H

View File

@ -84,5 +84,6 @@ int main(int argc, char *argv[])
return retCode;
} catch (BaseError e) {
QMessageBox::critical(nullptr,QApplication::tr("Error"),e.reason());
return -1;
}
}

View File

@ -6,7 +6,7 @@ int SynEditFoldRegions::count()
return fRegions.size();
}
int SynEditFoldRegions::add(bool addEnding, const QChar &openSymbol, const QChar &closeSymbol, const QString &highlight)
PSynEditFoldRegion SynEditFoldRegions::add(bool addEnding, const QChar &openSymbol, const QChar &closeSymbol, const QString &highlight)
{
PSynEditFoldRegion region = std::make_shared<SynEditFoldRegion>();
region->addEnding = addEnding;
@ -14,6 +14,7 @@ int SynEditFoldRegions::add(bool addEnding, const QChar &openSymbol, const QChar
region->closeSymbol = closeSymbol;
region->highlight = highlight;
fRegions.push_back(region);
return region;
}
PSynEditFoldRegion SynEditFoldRegions::get(int index)
@ -104,7 +105,7 @@ void SynEditFoldRanges::insert(int index, PSynEditFoldRange range)
mRanges.insert(index,range);
}
int SynEditFoldRanges::remove(int index)
void SynEditFoldRanges::remove(int index)
{
mRanges.remove(index);
}

View File

@ -13,7 +13,7 @@ private:
std::vector<PSynEditFoldRegion> fRegions;
public:
int count();
int add(bool addEnding, const QChar& openSymbol, const QChar& closeSymbol, const QString& highlight);
PSynEditFoldRegion add(bool addEnding, const QChar& openSymbol, const QChar& closeSymbol, const QString& highlight);
PSynEditFoldRegion get(int index);
};
typedef std::shared_ptr<SynEditFoldRegions> PSynFoldRegions;
@ -54,7 +54,7 @@ public:
int aFromLine, PSynEditFoldRegion aFoldRegion, int aToLine);
void insert(int index, PSynEditFoldRange range);
int remove(int index);
void remove(int index);
void add(PSynEditFoldRange foldRange);
PSynEditFoldRange operator[](int index) const;
};

View File

@ -553,6 +553,7 @@ int SynEdit::charToColumn(int aLine, int aChar) const
QString s = mLines->getString(aLine - 1);
return charToColumn(s,aChar);
}
return aChar;
}
int SynEdit::charToColumn(const QString &s, int aChar) const
@ -587,6 +588,7 @@ int SynEdit::columnToChar(int aLine, int aColumn) const
}
return i+1;
}
return aColumn;
}
int SynEdit::stringColumns(const QString &line, int colsBefore) const
@ -2537,6 +2539,7 @@ QString SynEdit::expandAtWideGlyphs(const QString &S)
j++;
}
Result.resize(j);
return Result;
}
void SynEdit::updateModifiedStatus()
@ -2577,7 +2580,7 @@ int SynEdit::scanFrom(int Index)
return Result;
}
int SynEdit::scanRanges()
void SynEdit::scanRanges()
{
if (mHighlighter && !mLines->empty()) {
mHighlighter->resetState();
@ -4227,6 +4230,7 @@ int SynEdit::InsertTextByColumnMode(const QString &Value, bool AddToUndoList)
} while (P<Value.length());
mCaretX+=Str.length();
mStatusChanges.setFlag(SynStatusChange::scCaretX);
return Result;
}
int SynEdit::InsertTextByLineMode(const QString &Value)
@ -4258,6 +4262,7 @@ int SynEdit::InsertTextByLineMode(const QString &Value)
P++;
Start = P;
} while (P<Value.length());
return Result;
}
void SynEdit::DeleteFromTo(const BufferCoord &start, const BufferCoord &end)
@ -4829,7 +4834,7 @@ bool SynEdit::event(QEvent *event)
break;
}
}
QAbstractScrollArea::event(event);
return QAbstractScrollArea::event(event);
}
void SynEdit::focusInEvent(QFocusEvent *)

View File

@ -379,7 +379,7 @@ private:
QString expandAtWideGlyphs(const QString& S);
void updateModifiedStatus();
int scanFrom(int Index);
int scanRanges();
void scanRanges();
void uncollapse(PSynEditFoldRange FoldRange);
void collapse(PSynEditFoldRange FoldRange);

View File

@ -243,7 +243,7 @@ int SynEditStringList::add(const QString &s)
return Result;
}
int SynEditStringList::addStrings(const QStringList &Strings)
void SynEditStringList::addStrings(const QStringList &Strings)
{
if (Strings.count() > 0) {
mIndexOfLongestLine = -1;
@ -739,7 +739,7 @@ SynChangeReason SynEditUndoList::LastChangeReason()
if (mItems.count() == 0)
return SynChangeReason::crNothing;
else
mItems.last()->changeReason();
return mItems.last()->changeReason();
}
void SynEditUndoList::Lock()

View File

@ -75,7 +75,7 @@ public:
void endUpdate();
int add(const QString& s);
int addStrings(const QStringList& Strings);
void addStrings(const QStringList& Strings);
int getTextLength();
void clear();

View File

@ -89,13 +89,13 @@ bool SynHighlighter::isIdentChar(const QChar &ch) const
if (ch == '_') {
return true;
}
if (ch>='0' && ch <= '9') {
if ((ch>='0') && (ch <= '9')) {
return true;
}
if (ch>='a' && ch <= 'z') {
if ((ch>='a') && (ch <= 'z')) {
return true;
}
if (ch>='A' && ch <= 'Z') {
if ((ch>='A') && (ch <= 'Z')) {
return true;
}

View File

@ -1,5 +1,6 @@
#include "editorsymbolcompletionwidget.h"
#include "ui_editorsymbolcompletionwidget.h"
#include "../settings.h"
EditorSymbolCompletionWidget::EditorSymbolCompletionWidget(const QString& name, const QString& group, QWidget *parent) :
SettingsWidget(name,group,parent),
@ -12,3 +13,33 @@ EditorSymbolCompletionWidget::~EditorSymbolCompletionWidget()
{
delete ui;
}
void EditorSymbolCompletionWidget::doLoad()
{
ui->grpCompleSymbols->setChecked(pSettings->editor().completeSymbols());
ui->chkCompleteBrace->setChecked(pSettings->editor().completeBrace());
ui->chkCompleteBracket->setChecked(pSettings->editor().completeBracket());
ui->chkCompleteComments->setChecked(pSettings->editor().completeComment());
ui->chkCompleteDoubleQuotation->setChecked(pSettings->editor().completeDoubleQuote());
ui->chkCompleteGlobalInclude->setChecked(pSettings->editor().completeGlobalInclude());
ui->chkCompleteParenthesis->setChecked(pSettings->editor().completeParenthese());
ui->chkCompleteSingleQuotation->setChecked(pSettings->editor().completeSingleQuote());
ui->chkRemoveMatchingSymbols->setChecked(pSettings->editor().removeMathcingSymbol());
ui->chkSkipMathingSymbols->setChecked(pSettings->editor().overwriteSymbols());
}
void EditorSymbolCompletionWidget::doSave()
{
pSettings->editor().setCompleteSymbols(ui->grpCompleSymbols->isChecked());
pSettings->editor().setCompleteBrace(ui->chkCompleteBrace->isChecked());
pSettings->editor().setCompleteBracket(ui->chkCompleteBracket->isChecked());
pSettings->editor().setCompleteComment(ui->chkCompleteComments->isChecked());
pSettings->editor().setCompleteDoubleQuote(ui->chkCompleteDoubleQuotation->isChecked());
pSettings->editor().setCompleteGlobalInclude(ui->chkCompleteGlobalInclude->isChecked());
pSettings->editor().setCompleteParenthese(ui->chkCompleteParenthesis->isChecked());
pSettings->editor().setCompleteSingleQuote(ui->chkCompleteSingleQuotation->isChecked());
pSettings->editor().setRemoveMathcingSymbol(ui->chkRemoveMatchingSymbols->isChecked());
pSettings->editor().setOverwriteSymbols(ui->chkSkipMathingSymbols->isChecked());
pSettings->editor().save();
}