* basic settings for the editor
This commit is contained in:
parent
35249d57df
commit
1f74245f0a
|
@ -10,23 +10,23 @@ HighlighterManager::HighlighterManager()
|
|||
|
||||
}
|
||||
|
||||
PSynHighlighter HighlighterManager::createHighlighter(const QString &filename)
|
||||
PSynHighlighter HighlighterManager::getHighlighter(const QString &filename)
|
||||
{
|
||||
if (filename.isEmpty() || filename.startsWith(QObject::tr("untitled"))) {
|
||||
return createCppHighlighter();
|
||||
return getCppHighlighter();
|
||||
} else {
|
||||
QFileInfo info(filename);
|
||||
QString suffix = info.suffix();
|
||||
if (suffix.isEmpty() || suffix == "c" || suffix == "cpp" || suffix == "cxx"
|
||||
|| suffix == "cc" || suffix == "h" || suffix == "hpp"
|
||||
|| suffix == "hxx" || suffix == "hh") {
|
||||
return createCppHighlighter();
|
||||
return getCppHighlighter();
|
||||
}
|
||||
}
|
||||
return PSynHighlighter();
|
||||
}
|
||||
|
||||
PSynHighlighter HighlighterManager::createCppHighlighter()
|
||||
PSynHighlighter HighlighterManager::getCppHighlighter()
|
||||
{
|
||||
SynEditCppHighlighter* highlighter = new SynEditCppHighlighter();
|
||||
PSynHighlighter pHighlighter(highlighter);
|
||||
|
|
|
@ -7,8 +7,8 @@ class HighlighterManager
|
|||
public:
|
||||
HighlighterManager();
|
||||
|
||||
PSynHighlighter createHighlighter(const QString& filename);
|
||||
PSynHighlighter createCppHighlighter();
|
||||
PSynHighlighter getHighlighter(const QString& filename);
|
||||
PSynHighlighter getCppHighlighter();
|
||||
};
|
||||
|
||||
extern HighlighterManager highlighterManager;
|
||||
|
|
|
@ -32,10 +32,12 @@ SOURCES += \
|
|||
settingsdialog/compilersetdirectorieswidget.cpp \
|
||||
settingsdialog/compilersetoptionwidget.cpp \
|
||||
settings.cpp \
|
||||
settingsdialog/editorgeneralwidget.cpp \
|
||||
settingsdialog/settingsdialog.cpp \
|
||||
settingsdialog/settingswidget.cpp \
|
||||
systemconsts.cpp \
|
||||
utils.cpp \
|
||||
widgets/coloredit.cpp \
|
||||
widgets/issuestable.cpp
|
||||
|
||||
HEADERS += \
|
||||
|
@ -62,17 +64,20 @@ HEADERS += \
|
|||
settingsdialog/compilersetdirectorieswidget.h \
|
||||
settingsdialog/compilersetoptionwidget.h \
|
||||
settings.h \
|
||||
settingsdialog/editorgeneralwidget.h \
|
||||
settingsdialog/settingsdialog.h \
|
||||
settingsdialog/settingswidget.h \
|
||||
systemconsts.h \
|
||||
utils.h \
|
||||
common.h \
|
||||
widgets/coloredit.h \
|
||||
widgets/issuestable.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui \
|
||||
settingsdialog/compilersetdirectorieswidget.ui \
|
||||
settingsdialog/compilersetoptionwidget.ui \
|
||||
settingsdialog/editorgeneralwidget.ui \
|
||||
settingsdialog/settingsdialog.ui
|
||||
|
||||
TRANSLATIONS += \
|
||||
|
|
|
@ -4,24 +4,58 @@
|
|||
<context>
|
||||
<name>Compiler</name>
|
||||
<message>
|
||||
<location filename="compiler/compiler.cpp" line="28"/>
|
||||
<location filename="compiler/compiler.cpp" line="30"/>
|
||||
<source>Compile Result:</source>
|
||||
<translation>编译结果:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="compiler/compiler.cpp" line="30"/>
|
||||
<location filename="compiler/compiler.cpp" line="32"/>
|
||||
<source>- Errors: %1</source>
|
||||
<translation>- 错误数: %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="compiler/compiler.cpp" line="31"/>
|
||||
<location filename="compiler/compiler.cpp" line="33"/>
|
||||
<source>- Warnings: %1</source>
|
||||
<translation>- 警告数: %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="compiler/compiler.cpp" line="32"/>
|
||||
<location filename="compiler/compiler.cpp" line="35"/>
|
||||
<source>- Output Filename: %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="compiler/compiler.cpp" line="37"/>
|
||||
<source>- Output Size: %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="compiler/compiler.cpp" line="39"/>
|
||||
<source>- Compilation Time: %1 secs</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="compiler/compiler.cpp" line="113"/>
|
||||
<source>[Error] </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="compiler/compiler.cpp" line="117"/>
|
||||
<source>[Warning] </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="compiler/compiler.cpp" line="121"/>
|
||||
<source>[Info] </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="compiler/compiler.cpp" line="125"/>
|
||||
<source>[Note] </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>- Time Elasped: %1 secs</source>
|
||||
<translation>- 编译时间: %1 秒</translation>
|
||||
<translation type="vanished">- 编译时间: %1 秒</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -220,43 +254,46 @@ Are you really want to continue?</source>
|
|||
<context>
|
||||
<name>Editor</name>
|
||||
<message>
|
||||
<location filename="editor.cpp" line="45"/>
|
||||
<location filename="editor.cpp" line="49"/>
|
||||
<source>untitled</source>
|
||||
<translation>无标题</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editor.cpp" line="130"/>
|
||||
<source>Error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editor.cpp" line="131"/>
|
||||
<source>Can't Open File %1:%2</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editor.cpp" line="185"/>
|
||||
<source>Failed to Save file %1: %2</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editor.cpp" line="189"/>
|
||||
<source>Failed to Open file %1: %2</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editor.cpp" line="200"/>
|
||||
<location filename="editor.cpp" line="209"/>
|
||||
<location filename="editor.cpp" line="235"/>
|
||||
<location filename="editor.cpp" line="148"/>
|
||||
<location filename="editor.cpp" line="157"/>
|
||||
<location filename="editor.cpp" line="183"/>
|
||||
<source>Fail</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editor.cpp" line="224"/>
|
||||
<location filename="editor.cpp" line="172"/>
|
||||
<source>Save As</source>
|
||||
<translation type="unfinished">另存为</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>EditorGeneralWidget</name>
|
||||
<message>
|
||||
<location filename="settingsdialog/editorgeneralwidget.cpp" line="14"/>
|
||||
<source>Vertical Line</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/editorgeneralwidget.cpp" line="15"/>
|
||||
<source>Horizontal Line</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/editorgeneralwidget.cpp" line="16"/>
|
||||
<source>Half Block</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/editorgeneralwidget.cpp" line="17"/>
|
||||
<source>Block</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>FileCompiler</name>
|
||||
<message>
|
||||
|
@ -301,6 +338,29 @@ Are you really want to continue?</source>
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>IssuesModel</name>
|
||||
<message>
|
||||
<location filename="widgets/issuestable.cpp" line="164"/>
|
||||
<source>Filename</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="widgets/issuestable.cpp" line="166"/>
|
||||
<source>Line</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="widgets/issuestable.cpp" line="168"/>
|
||||
<source>Col</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="widgets/issuestable.cpp" line="170"/>
|
||||
<source>Description</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
<message>
|
||||
|
@ -320,190 +380,215 @@ Are you really want to continue?</source>
|
|||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="165"/>
|
||||
<source>Compiler Output</source>
|
||||
<source>Issues</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="214"/>
|
||||
<location filename="mainwindow.ui" line="209"/>
|
||||
<source>Compile Log</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="258"/>
|
||||
<source>File</source>
|
||||
<translation>文件</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="225"/>
|
||||
<location filename="mainwindow.ui" line="269"/>
|
||||
<source>Tools</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="231"/>
|
||||
<location filename="mainwindow.ui" line="389"/>
|
||||
<location filename="mainwindow.ui" line="392"/>
|
||||
<location filename="mainwindow.ui" line="275"/>
|
||||
<location filename="mainwindow.ui" line="438"/>
|
||||
<location filename="mainwindow.ui" line="441"/>
|
||||
<source>Run</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="238"/>
|
||||
<location filename="mainwindow.ui" line="282"/>
|
||||
<source>Edit</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="259"/>
|
||||
<location filename="mainwindow.ui" line="285"/>
|
||||
<location filename="mainwindow.ui" line="308"/>
|
||||
<location filename="mainwindow.ui" line="334"/>
|
||||
<source>toolBar</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="274"/>
|
||||
<location filename="mainwindow.ui" line="323"/>
|
||||
<source>toolBar_2</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="303"/>
|
||||
<location filename="mainwindow.ui" line="352"/>
|
||||
<source>New</source>
|
||||
<translation>新建</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="306"/>
|
||||
<location filename="mainwindow.ui" line="355"/>
|
||||
<source>Ctrl+N</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="316"/>
|
||||
<location filename="mainwindow.ui" line="365"/>
|
||||
<source>Open...</source>
|
||||
<translation>打开...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="319"/>
|
||||
<location filename="mainwindow.ui" line="368"/>
|
||||
<source>Ctrl+O</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="329"/>
|
||||
<location filename="mainwindow.ui" line="378"/>
|
||||
<source>Save</source>
|
||||
<translation>保存</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="332"/>
|
||||
<location filename="mainwindow.ui" line="381"/>
|
||||
<source>Ctrl+S</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="342"/>
|
||||
<location filename="mainwindow.ui" line="391"/>
|
||||
<source>Save As...</source>
|
||||
<translation>另存为...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="345"/>
|
||||
<location filename="mainwindow.ui" line="394"/>
|
||||
<source>Save As</source>
|
||||
<translation>另存为</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="355"/>
|
||||
<location filename="mainwindow.ui" line="404"/>
|
||||
<source>Save All</source>
|
||||
<translation>全部保存</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="358"/>
|
||||
<location filename="mainwindow.ui" line="407"/>
|
||||
<source>Ctrl+Shift+S</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="363"/>
|
||||
<location filename="mainwindow.ui" line="412"/>
|
||||
<source>Options</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="373"/>
|
||||
<location filename="mainwindow.ui" line="376"/>
|
||||
<location filename="mainwindow.ui" line="422"/>
|
||||
<location filename="mainwindow.ui" line="425"/>
|
||||
<source>Compile</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="379"/>
|
||||
<location filename="mainwindow.ui" line="428"/>
|
||||
<source>F9</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="395"/>
|
||||
<location filename="mainwindow.ui" line="444"/>
|
||||
<source>F10</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="405"/>
|
||||
<location filename="mainwindow.ui" line="454"/>
|
||||
<source>Undo</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="408"/>
|
||||
<location filename="mainwindow.ui" line="457"/>
|
||||
<source>Ctrl+Z</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="418"/>
|
||||
<location filename="mainwindow.ui" line="467"/>
|
||||
<source>Redo</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="421"/>
|
||||
<location filename="mainwindow.ui" line="470"/>
|
||||
<source>Ctrl+Y</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="431"/>
|
||||
<location filename="mainwindow.ui" line="480"/>
|
||||
<source>Cut</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="434"/>
|
||||
<location filename="mainwindow.ui" line="483"/>
|
||||
<source>Ctrl+X</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="444"/>
|
||||
<location filename="mainwindow.ui" line="493"/>
|
||||
<source>Copy</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="447"/>
|
||||
<location filename="mainwindow.ui" line="496"/>
|
||||
<source>Ctrl+C</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="457"/>
|
||||
<location filename="mainwindow.ui" line="506"/>
|
||||
<source>Paste</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="460"/>
|
||||
<location filename="mainwindow.ui" line="509"/>
|
||||
<source>Ctrl+V</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="465"/>
|
||||
<location filename="mainwindow.ui" line="514"/>
|
||||
<source>Select All</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="468"/>
|
||||
<location filename="mainwindow.ui" line="517"/>
|
||||
<source>Ctrl+A</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="478"/>
|
||||
<location filename="mainwindow.ui" line="527"/>
|
||||
<source>Indent</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="488"/>
|
||||
<location filename="mainwindow.ui" line="537"/>
|
||||
<source>UnIndent</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.cpp" line="64"/>
|
||||
<location filename="mainwindow.ui" line="542"/>
|
||||
<source>Toggle Comment</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="545"/>
|
||||
<source>Ctrl+/</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="550"/>
|
||||
<source>Collapse All</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.ui" line="555"/>
|
||||
<source>Uncollapse All</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.cpp" line="70"/>
|
||||
<source>Line: %1 Col: %2 Lines: %3 Chars: %4</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mainwindow.cpp" line="129"/>
|
||||
<location filename="mainwindow.cpp" line="140"/>
|
||||
<source>Open</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -511,12 +596,12 @@ Are you really want to continue?</source>
|
|||
<context>
|
||||
<name>QObject</name>
|
||||
<message>
|
||||
<location filename="editorlist.cpp" line="71"/>
|
||||
<location filename="editorlist.cpp" line="72"/>
|
||||
<source>Save</source>
|
||||
<translation>保存</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editorlist.cpp" line="72"/>
|
||||
<location filename="editorlist.cpp" line="73"/>
|
||||
<source>Save changes to %1?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -525,7 +610,7 @@ Are you really want to continue?</source>
|
|||
<translation type="vanished">保存修改后的内容到"%s"?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editor.cpp" line="201"/>
|
||||
<location filename="editor.cpp" line="149"/>
|
||||
<source>File %s is not writable!</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -555,28 +640,28 @@ Are you really want to continue?</source>
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="main.cpp" line="31"/>
|
||||
<location filename="main.cpp" line="38"/>
|
||||
<location filename="main.cpp" line="32"/>
|
||||
<location filename="main.cpp" line="39"/>
|
||||
<source>Error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="main.cpp" line="32"/>
|
||||
<location filename="main.cpp" line="33"/>
|
||||
<source>Can't create configuration folder %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="main.cpp" line="39"/>
|
||||
<location filename="main.cpp" line="40"/>
|
||||
<source>Can't write to configuration file %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="697"/>
|
||||
<location filename="settings.cpp" line="889"/>
|
||||
<source>C options</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="703"/>
|
||||
<location filename="settings.cpp" line="895"/>
|
||||
<source>Code Generation</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -610,151 +695,161 @@ Are you really want to continue?</source>
|
|||
<source>Yes</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="HighlighterManager.cpp" line="15"/>
|
||||
<source>untitled</source>
|
||||
<translation type="unfinished">无标题</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="utils.cpp" line="323"/>
|
||||
<source>Index %1 out of range</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Settings::CompilerSet</name>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="698"/>
|
||||
<location filename="settings.cpp" line="890"/>
|
||||
<source>Support all ANSI standard C programs (-ansi)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="699"/>
|
||||
<location filename="settings.cpp" line="891"/>
|
||||
<source>Do not recognize asm,inline or typeof as a keyword (-fno-asm)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="700"/>
|
||||
<location filename="settings.cpp" line="892"/>
|
||||
<source>Imitate traditional C preprocessors (-traditional-cpp)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="732"/>
|
||||
<location filename="settings.cpp" line="924"/>
|
||||
<source>Optimize for the following machine (-march)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="733"/>
|
||||
<location filename="settings.cpp" line="925"/>
|
||||
<source>Optimize less, while maintaining full compatibility (-tune)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="753"/>
|
||||
<location filename="settings.cpp" line="945"/>
|
||||
<source>Enable use of specific instructions (-mx)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="764"/>
|
||||
<location filename="settings.cpp" line="956"/>
|
||||
<source>Optimization level (-Ox)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="771"/>
|
||||
<location filename="settings.cpp" line="963"/>
|
||||
<source>Compile with the following pointer size (-mx)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="794"/>
|
||||
<location filename="settings.cpp" line="986"/>
|
||||
<source>Language standard (-std)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="795"/>
|
||||
<location filename="settings.cpp" line="987"/>
|
||||
<source>Generate debugging information (-g3)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="796"/>
|
||||
<location filename="settings.cpp" line="988"/>
|
||||
<source>Generate profiling info for analysis (-pg)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="799"/>
|
||||
<location filename="settings.cpp" line="991"/>
|
||||
<source>Warnings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="800"/>
|
||||
<location filename="settings.cpp" line="992"/>
|
||||
<source>Inhibit all warning messages (-w)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="801"/>
|
||||
<location filename="settings.cpp" line="993"/>
|
||||
<source>Show most warnings (-Wall)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="802"/>
|
||||
<location filename="settings.cpp" line="994"/>
|
||||
<source>Show some more warnings (-Wextra)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="803"/>
|
||||
<location filename="settings.cpp" line="995"/>
|
||||
<source>Check ISO C/C++/C++0x conformance (-pedantic)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="804"/>
|
||||
<location filename="settings.cpp" line="996"/>
|
||||
<source>Only check the code for syntax errors (-fsyntax-only)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="805"/>
|
||||
<location filename="settings.cpp" line="997"/>
|
||||
<source>Make all warnings into errors (-Werror)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="806"/>
|
||||
<location filename="settings.cpp" line="998"/>
|
||||
<source>Abort compilation on first error (-Wfatal-errors)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="809"/>
|
||||
<location filename="settings.cpp" line="1001"/>
|
||||
<source>Linker</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="810"/>
|
||||
<location filename="settings.cpp" line="1002"/>
|
||||
<source>Link an Objective C program (-lobjc)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="811"/>
|
||||
<location filename="settings.cpp" line="1003"/>
|
||||
<source>Do not use standard system libraries (-nostdlib)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="812"/>
|
||||
<location filename="settings.cpp" line="1004"/>
|
||||
<source>Do not create a console window (-mwindows)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="813"/>
|
||||
<location filename="settings.cpp" line="1005"/>
|
||||
<source>Strip executable (-s)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="814"/>
|
||||
<location filename="settings.cpp" line="1006"/>
|
||||
<source>Link libraries statically (-static)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="817"/>
|
||||
<location filename="settings.cpp" line="1009"/>
|
||||
<source>Output</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="818"/>
|
||||
<location filename="settings.cpp" line="1010"/>
|
||||
<source>-fverbose-asm</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="819"/>
|
||||
<location filename="settings.cpp" line="1011"/>
|
||||
<source>Use pipes instead of temporary files during compilation (-pipe)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settings.cpp" line="820"/>
|
||||
<location filename="settings.cpp" line="1012"/>
|
||||
<source>Do not assemble, compile and generate the assemble code (-S)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -764,47 +859,156 @@ Are you really want to continue?</source>
|
|||
<message>
|
||||
<location filename="settingsdialog/settingsdialog.ui" line="14"/>
|
||||
<source>Options</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/settingsdialog.ui" line="92"/>
|
||||
<source>TextLabel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>选项</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/settingsdialog.ui" line="156"/>
|
||||
<source>OK</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>确定</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/settingsdialog.ui" line="163"/>
|
||||
<source>Apply</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>应用</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/settingsdialog.ui" line="170"/>
|
||||
<source>Cancle</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>取消</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/settingsdialog.cpp" line="20"/>
|
||||
<location filename="settingsdialog/settingsdialog.cpp" line="21"/>
|
||||
<source>Compiler Set</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>编译器配置集</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/settingsdialog.cpp" line="20"/>
|
||||
<location filename="settingsdialog/settingsdialog.cpp" line="21"/>
|
||||
<source>Compiler</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>编译器</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/settingsdialog.cpp" line="99"/>
|
||||
<location filename="settingsdialog/settingsdialog.cpp" line="25"/>
|
||||
<source>General</source>
|
||||
<translation>通用</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/settingsdialog.cpp" line="25"/>
|
||||
<source>Editor</source>
|
||||
<translation>编辑器</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/settingsdialog.cpp" line="107"/>
|
||||
<source>Save Changes</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>保存修改</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/settingsdialog.cpp" line="100"/>
|
||||
<location filename="settingsdialog/settingsdialog.cpp" line="108"/>
|
||||
<source>There are changes in the settings, do you want to save them before swtich to other page?</source>
|
||||
<translation>本页中有尚未保存的设置修改,是否保存后再切换到其他页?</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SynEdit</name>
|
||||
<message>
|
||||
<location filename="qsynedit/TextPainter.cpp" line="849"/>
|
||||
<source>The highlighter seems to be in an infinite loop</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SynEditStringList</name>
|
||||
<message>
|
||||
<location filename="qsynedit/TextBuffer.cpp" line="457"/>
|
||||
<source>Can't open file '%1' for read!</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qsynedit/TextBuffer.cpp" line="546"/>
|
||||
<source>Can't open file '%1' for save!</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>editorgeneralwidget</name>
|
||||
<message>
|
||||
<location filename="settingsdialog/editorgeneralwidget.ui" line="14"/>
|
||||
<source>Form</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/editorgeneralwidget.ui" line="20"/>
|
||||
<source>Indents</source>
|
||||
<translation>缩进</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/editorgeneralwidget.ui" line="26"/>
|
||||
<source>Auto Indent</source>
|
||||
<translation>自动计算缩进</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/editorgeneralwidget.ui" line="33"/>
|
||||
<source>Add Indent after { and :</source>
|
||||
<translation>在{和:的下一行添加缩进</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/editorgeneralwidget.ui" line="40"/>
|
||||
<source>Replace tab with spaces</source>
|
||||
<translation>自动使用空格代替制表符(Tab)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/editorgeneralwidget.ui" line="60"/>
|
||||
<source>Tab Width</source>
|
||||
<translation>制表符(Tab)宽度</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/editorgeneralwidget.ui" line="83"/>
|
||||
<source>Show Indent Lines</source>
|
||||
<translation>显示缩进提示线</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/editorgeneralwidget.ui" line="106"/>
|
||||
<source>Indent Line Color</source>
|
||||
<translation>缩进提示线颜色</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/editorgeneralwidget.ui" line="129"/>
|
||||
<source>Caret</source>
|
||||
<translation>光标</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/editorgeneralwidget.ui" line="135"/>
|
||||
<source>Move caret to the first non-space char in the current line when press HOME key</source>
|
||||
<translation>按下HOME键时,光标定位在本行的第一个非空格字符处</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/editorgeneralwidget.ui" line="142"/>
|
||||
<source>Move caret to the last non-space char in the current line when press END key</source>
|
||||
<translation>按下End键时,光标定位在本行的最后一个非空格字符处</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/editorgeneralwidget.ui" line="149"/>
|
||||
<source>Keep X position of the caret when moving vertically</source>
|
||||
<translation>在上下移动光标时,记住起始时光标所在栏数</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/editorgeneralwidget.ui" line="187"/>
|
||||
<source>Caret for inserting mode</source>
|
||||
<translation>插入状态下的光标</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/editorgeneralwidget.ui" line="194"/>
|
||||
<source>Caret for overwriting mode</source>
|
||||
<translation>覆写状态下的光标</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="settingsdialog/editorgeneralwidget.ui" line="204"/>
|
||||
<source>Caret Color</source>
|
||||
<translation>光标颜色</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -56,13 +56,13 @@ Editor::Editor(QWidget *parent, const QString& filename,
|
|||
PSynHighlighter highlighter;
|
||||
if (!isNew) {
|
||||
loadFile();
|
||||
highlighter = highlighterManager.createHighlighter(mFilename);
|
||||
highlighter = highlighterManager.getHighlighter(mFilename);
|
||||
} else {
|
||||
if (mEncodingOption == ENCODING_AUTO_DETECT)
|
||||
mFileEncoding = ENCODING_ASCII;
|
||||
else
|
||||
mFileEncoding = mEncodingOption;
|
||||
highlighter=highlighterManager.createCppHighlighter();
|
||||
highlighter=highlighterManager.getCppHighlighter();
|
||||
}
|
||||
|
||||
if (highlighter) {
|
||||
|
@ -72,9 +72,7 @@ Editor::Editor(QWidget *parent, const QString& filename,
|
|||
setUseCodeFolding(false);
|
||||
}
|
||||
|
||||
//SynEditCppHighlighter highlighter;
|
||||
|
||||
|
||||
applySettings();
|
||||
}
|
||||
|
||||
Editor::~Editor() {
|
||||
|
@ -229,15 +227,15 @@ void Editor::wheelEvent(QWheelEvent *event) {
|
|||
QFont oldFont = font();
|
||||
int size = oldFont.pointSize();
|
||||
if (event->angleDelta().y()>0) {
|
||||
size = std::max(5,size-1);
|
||||
oldFont.setPointSize(oldFont.pointSize());
|
||||
this->setFont(oldFont);
|
||||
//this->zoomIn();
|
||||
// size = std::max(5,size-1);
|
||||
// oldFont.setPointSize(oldFont.pointSize());
|
||||
// this->setFont(oldFont);
|
||||
this->zoomIn();
|
||||
} else {
|
||||
size = std::min(size+1,50);
|
||||
oldFont.setPointSize(oldFont.pointSize());
|
||||
this->setFont(oldFont);
|
||||
//this->zoomOut();
|
||||
// size = std::min(size+1,50);
|
||||
// oldFont.setPointSize(oldFont.pointSize());
|
||||
// this->setFont(oldFont);
|
||||
this->zoomOut();
|
||||
}
|
||||
onLinesChanged(0,0);
|
||||
}
|
||||
|
@ -249,7 +247,6 @@ void Editor::onModificationChanged(bool) {
|
|||
|
||||
void Editor::onCursorPositionChanged(int line, int index) {
|
||||
pMainWindow->updateStatusBarForEditingInfo(line,index+1,lines()->count(),lines()->getTextLength());
|
||||
|
||||
}
|
||||
|
||||
void Editor::onLinesChanged(int startLine, int count) {
|
||||
|
@ -257,6 +254,29 @@ void Editor::onLinesChanged(int startLine, int count) {
|
|||
qDebug()<<startLine<<count;
|
||||
}
|
||||
|
||||
void Editor::applySettings()
|
||||
{
|
||||
SynEditorOptions options = eoAltSetsColumnMode |
|
||||
eoDragDropEditing | eoDropFiles | eoKeepCaretX | eoTabsToSpaces |
|
||||
eoRightMouseMovesCursor | eoScrollByOneLess | eoTabIndent;
|
||||
options.setFlag(eoAddIndent,pSettings->editor().addIndent());
|
||||
options.setFlag(eoAutoIndent,pSettings->editor().autoIndent());
|
||||
options.setFlag(eoTabsToSpaces,pSettings->editor().tabToSpaces());
|
||||
|
||||
options.setFlag(eoKeepCaretX,pSettings->editor().keepCaretX());
|
||||
options.setFlag(eoEnhanceHomeKey,pSettings->editor().enhanceHomeKey());
|
||||
options.setFlag(eoEnhanceEndKey,pSettings->editor().enhanceEndKey());
|
||||
|
||||
setOptions(options);
|
||||
|
||||
setTabWidth(pSettings->editor().tabWidth());
|
||||
|
||||
setInsertCaret(pSettings->editor().caretForInsert());
|
||||
setOverwriteCaret(pSettings->editor().caretForOverwrite());
|
||||
setCaretColor(pSettings->editor().caretColor());
|
||||
//todo: show indent line
|
||||
}
|
||||
|
||||
void Editor::updateCaption(const QString& newCaption) {
|
||||
if (mParentPageControl==NULL) {
|
||||
return;
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
QTabWidget* pageControl() noexcept;
|
||||
|
||||
void updateCaption(const QString& newCaption=QString());
|
||||
void applySettings();
|
||||
|
||||
signals:
|
||||
|
||||
|
|
|
@ -104,6 +104,18 @@ void EditorList::endUpdate() {
|
|||
}
|
||||
}
|
||||
|
||||
void EditorList::applySettings()
|
||||
{
|
||||
for (int i=0;i<mLeftPageWidget->count();i++) {
|
||||
Editor* e = static_cast<Editor*>(mLeftPageWidget->widget(i));
|
||||
e->applySettings();
|
||||
}
|
||||
for (int i=0;i<mRightPageWidget->count();i++) {
|
||||
Editor* e = static_cast<Editor*>(mRightPageWidget->widget(i));
|
||||
e->applySettings();
|
||||
}
|
||||
}
|
||||
|
||||
bool EditorList::closeAll(bool force) {
|
||||
beginUpdate();
|
||||
auto end = finally([this] {
|
||||
|
|
|
@ -38,6 +38,7 @@ public:
|
|||
|
||||
void beginUpdate();
|
||||
void endUpdate();
|
||||
void applySettings();
|
||||
|
||||
private:
|
||||
QTabWidget* getNewEditorPageControl() const;
|
||||
|
|
|
@ -75,6 +75,7 @@ int main(int argc, char *argv[])
|
|||
// settings->compilerSets().findSets();
|
||||
// settings->compilerSets().saveSets();
|
||||
settings->compilerSets().loadSets();
|
||||
settings->editor().load();
|
||||
// qDebug() << settings->compilerSets().defaultSet()->binDirs();
|
||||
// settings->compilerSets().loadSets();
|
||||
// qDebug() << settings->compilerSets().defaultSet()->defines();
|
||||
|
|
|
@ -72,6 +72,11 @@ void MainWindow::updateStatusBarForEditingInfo(int line,int col,int lines,int ch
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateEditorSettings()
|
||||
{
|
||||
mEditorList->applySettings();
|
||||
}
|
||||
|
||||
void MainWindow::openFiles(const QStringList &files)
|
||||
{
|
||||
mEditorList->beginUpdate();
|
||||
|
@ -105,7 +110,7 @@ void MainWindow::updateCompilerSet()
|
|||
{
|
||||
mCompilerSet->clear();
|
||||
int index=pSettings->compilerSets().defaultIndex();
|
||||
for (int i=0;i<pSettings->compilerSets().list().size();i++) {
|
||||
for (size_t i=0;i<pSettings->compilerSets().list().size();i++) {
|
||||
mCompilerSet->addItem(pSettings->compilerSets().list()[i]->name());
|
||||
}
|
||||
if (index < 0 || index>=mCompilerSet->count()) {
|
||||
|
@ -210,7 +215,7 @@ void MainWindow::on_actionUndo_triggered()
|
|||
{
|
||||
Editor * editor = mEditorList->getEditor();
|
||||
if (editor != NULL ) {
|
||||
editor->CommandProcessor(SynEditorCommand::ecUndo);
|
||||
editor->undo();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,7 +223,7 @@ void MainWindow::on_actionRedo_triggered()
|
|||
{
|
||||
Editor * editor = mEditorList->getEditor();
|
||||
if (editor != NULL ) {
|
||||
editor->CommandProcessor(SynEditorCommand::ecRedo);
|
||||
editor->redo();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -226,7 +231,7 @@ void MainWindow::on_actionCut_triggered()
|
|||
{
|
||||
Editor * editor = mEditorList->getEditor();
|
||||
if (editor != NULL ) {
|
||||
editor->CommandProcessor(SynEditorCommand::ecCut);
|
||||
editor->cutToClipboard();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,7 +239,7 @@ void MainWindow::on_actionSelectAll_triggered()
|
|||
{
|
||||
Editor * editor = mEditorList->getEditor();
|
||||
if (editor != NULL ) {
|
||||
editor->CommandProcessor(SynEditorCommand::ecSelectAll);
|
||||
editor->selectAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -242,7 +247,7 @@ void MainWindow::on_actionCopy_triggered()
|
|||
{
|
||||
Editor * editor = mEditorList->getEditor();
|
||||
if (editor != NULL ) {
|
||||
editor->CommandProcessor(SynEditorCommand::ecCopy);
|
||||
editor->copyToClipboard();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -250,7 +255,7 @@ void MainWindow::on_actionPaste_triggered()
|
|||
{
|
||||
Editor * editor = mEditorList->getEditor();
|
||||
if (editor != NULL ) {
|
||||
editor->CommandProcessor(SynEditorCommand::ecPaste);
|
||||
editor->pasteFromClipboard();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -258,7 +263,7 @@ void MainWindow::on_actionIndent_triggered()
|
|||
{
|
||||
Editor * editor = mEditorList->getEditor();
|
||||
if (editor != NULL ) {
|
||||
editor->CommandProcessor(SynEditorCommand::ecTab);
|
||||
editor->tab();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,7 +271,7 @@ void MainWindow::on_actionUnIndent_triggered()
|
|||
{
|
||||
Editor * editor = mEditorList->getEditor();
|
||||
if (editor != NULL ) {
|
||||
editor->CommandProcessor(SynEditorCommand::ecShiftTab);
|
||||
editor->untab();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ public:
|
|||
|
||||
void updateStatusBarForEncoding();
|
||||
void updateStatusBarForEditingInfo(int line,int col,int lines,int charCount);
|
||||
void updateEditorSettings();
|
||||
|
||||
protected:
|
||||
void openFiles(const QStringList& files);
|
||||
|
|
|
@ -147,8 +147,6 @@ enum class SynEditorCommand {
|
|||
ecToggleComment = 616,
|
||||
ecCommentInline = 617,
|
||||
|
||||
ecAutoCompletion = 650,
|
||||
|
||||
ecUpperCase = 620, // apply to the current or previous word
|
||||
ecLowerCase = 621,
|
||||
ecToggleCase = 622,
|
||||
|
@ -158,9 +156,14 @@ enum class SynEditorCommand {
|
|||
ecToggleCaseBlock = 627,
|
||||
|
||||
ecString = 630, //Insert a whole string
|
||||
ecZoomOut = 631, //Increase Font Size
|
||||
ecZoomIn = 632, //Decrease Font Size
|
||||
|
||||
ecUserFirst = 1001, // Start of user-defined commands
|
||||
|
||||
ecAutoCompletion = 650,
|
||||
|
||||
|
||||
//### Code Folding ###
|
||||
ecCollapse = ecUserFirst + 100,
|
||||
ecUncollapse = ecUserFirst + 101,
|
||||
|
|
|
@ -118,7 +118,7 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
|||
mBlockEnd = mBlockBegin;
|
||||
mOptions = eoAutoIndent | eoAddIndent
|
||||
| eoDragDropEditing | eoEnhanceEndKey | eoTabIndent |
|
||||
eoShowScrollHint | eoGroupUndo | eoKeepCaretX | eoSelectWordByDblClick;
|
||||
eoGroupUndo | eoKeepCaretX | eoSelectWordByDblClick;
|
||||
qDebug()<<"init SynEdit: 9";
|
||||
|
||||
mScrollTimer = new QTimer(this);
|
||||
|
@ -147,6 +147,8 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
|||
|
||||
//enable input method
|
||||
setAttribute(Qt::WA_InputMethodEnabled);
|
||||
|
||||
setMouseTracking(true);
|
||||
}
|
||||
|
||||
int SynEdit::displayLineCount()
|
||||
|
@ -1053,7 +1055,7 @@ void SynEdit::SetWordBlock(BufferCoord Value)
|
|||
setCaretAndSelection(v_WordEnd, v_WordStart, v_WordEnd);
|
||||
}
|
||||
|
||||
void SynEdit::SelectAll()
|
||||
void SynEdit::doSelectAll()
|
||||
{
|
||||
BufferCoord LastPt;
|
||||
LastPt.Char = 1;
|
||||
|
@ -1068,7 +1070,7 @@ void SynEdit::SelectAll()
|
|||
statusChanged(SynStatusChange::scSelection);
|
||||
}
|
||||
|
||||
void SynEdit::DeleteLastChar()
|
||||
void SynEdit::doDeleteLastChar()
|
||||
{
|
||||
// if not ReadOnly then begin
|
||||
doOnPaintTransientEx(SynTransientType::ttBefore, true);
|
||||
|
@ -1187,7 +1189,7 @@ void SynEdit::DeleteLastChar()
|
|||
}
|
||||
}
|
||||
|
||||
void SynEdit::DeleteCurrentChar()
|
||||
void SynEdit::doDeleteCurrentChar()
|
||||
{
|
||||
QString helper;
|
||||
BufferCoord Caret;
|
||||
|
@ -1231,7 +1233,7 @@ void SynEdit::DeleteCurrentChar()
|
|||
}
|
||||
}
|
||||
|
||||
void SynEdit::DeleteWord()
|
||||
void SynEdit::doDeleteWord()
|
||||
{
|
||||
if (mReadOnly)
|
||||
return;
|
||||
|
@ -1241,14 +1243,14 @@ void SynEdit::DeleteWord()
|
|||
DeleteFromTo(start,end);
|
||||
}
|
||||
|
||||
void SynEdit::DeleteToEOL()
|
||||
void SynEdit::doDeleteToEOL()
|
||||
{
|
||||
if (mReadOnly)
|
||||
return;
|
||||
DeleteFromTo(caretXY(),BufferCoord{lineText().length()+1,mCaretY});
|
||||
}
|
||||
|
||||
void SynEdit::DeleteLastWord()
|
||||
void SynEdit::doDeleteLastWord()
|
||||
{
|
||||
if (mReadOnly)
|
||||
return;
|
||||
|
@ -1257,14 +1259,14 @@ void SynEdit::DeleteLastWord()
|
|||
DeleteFromTo(start,end);
|
||||
}
|
||||
|
||||
void SynEdit::DeleteFromBOL()
|
||||
void SynEdit::doDeleteFromBOL()
|
||||
{
|
||||
if (mReadOnly)
|
||||
return;
|
||||
DeleteFromTo(BufferCoord{1,mCaretY},caretXY());
|
||||
}
|
||||
|
||||
void SynEdit::DeleteLine()
|
||||
void SynEdit::doDeleteLine()
|
||||
{
|
||||
if (!mReadOnly && (mLines->count() > 0)
|
||||
&& ! ((mCaretY == mLines->count()) && (lineText().isEmpty()))) {
|
||||
|
@ -1292,7 +1294,7 @@ void SynEdit::DeleteLine()
|
|||
}
|
||||
}
|
||||
|
||||
void SynEdit::DuplicateLine()
|
||||
void SynEdit::doDuplicateLine()
|
||||
{
|
||||
if (!mReadOnly && (mLines->count() > 0)) {
|
||||
doOnPaintTransient(SynTransientType::ttBefore);
|
||||
|
@ -1305,7 +1307,7 @@ void SynEdit::DuplicateLine()
|
|||
}
|
||||
}
|
||||
|
||||
void SynEdit::MoveSelUp()
|
||||
void SynEdit::doMoveSelUp()
|
||||
{
|
||||
if (!mReadOnly && (mLines->count() > 0) && (blockBegin().Line > 1)) {
|
||||
doOnPaintTransient(SynTransientType::ttBefore);
|
||||
|
@ -1352,7 +1354,7 @@ void SynEdit::MoveSelUp()
|
|||
}
|
||||
}
|
||||
|
||||
void SynEdit::MoveSelDown()
|
||||
void SynEdit::doMoveSelDown()
|
||||
{
|
||||
if (!mReadOnly && (mLines->count() > 0) && (blockEnd().Line < mLines->count())) {
|
||||
doOnPaintTransient(SynTransientType::ttBefore);
|
||||
|
@ -1400,7 +1402,7 @@ void SynEdit::MoveSelDown()
|
|||
}
|
||||
}
|
||||
|
||||
void SynEdit::ClearAll()
|
||||
void SynEdit::clearAll()
|
||||
{
|
||||
mLines->clear();
|
||||
mMarkList.clear();
|
||||
|
@ -1409,7 +1411,7 @@ void SynEdit::ClearAll()
|
|||
setModified(false);
|
||||
}
|
||||
|
||||
void SynEdit::InsertLine(bool moveCaret)
|
||||
void SynEdit::insertLine(bool moveCaret)
|
||||
{
|
||||
if (mReadOnly)
|
||||
return;
|
||||
|
@ -1555,7 +1557,7 @@ void SynEdit::InsertLine(bool moveCaret)
|
|||
updateLastCaretX();
|
||||
}
|
||||
|
||||
void SynEdit::DoTabKey()
|
||||
void SynEdit::doTabKey()
|
||||
{
|
||||
// Provide Visual Studio like block indenting
|
||||
if (mOptions.testFlag(eoTabIndent) && CanDoBlockIndent()) {
|
||||
|
@ -1603,7 +1605,7 @@ void SynEdit::DoTabKey()
|
|||
ensureCursorPosVisible();
|
||||
}
|
||||
|
||||
void SynEdit::DoShiftTabKey()
|
||||
void SynEdit::doShiftTabKey()
|
||||
{
|
||||
// Provide Visual Studio like block indenting
|
||||
if (mOptions.testFlag(eoTabIndent) && CanDoBlockIndent()) {
|
||||
|
@ -1879,7 +1881,7 @@ void SynEdit::doBlockUnindent()
|
|||
setCaretAndSelection(OrgCaretPos, BB, BE);
|
||||
}
|
||||
|
||||
void SynEdit::DoAddChar(QChar AChar)
|
||||
void SynEdit::doAddChar(QChar AChar)
|
||||
{
|
||||
if (mReadOnly)
|
||||
return;
|
||||
|
@ -1932,7 +1934,7 @@ void SynEdit::DoAddChar(QChar AChar)
|
|||
//DoOnPaintTransient(ttAfter);
|
||||
}
|
||||
|
||||
void SynEdit::cutToClipboard()
|
||||
void SynEdit::doCutToClipboard()
|
||||
{
|
||||
if (mReadOnly || !selAvail())
|
||||
return;
|
||||
|
@ -1940,11 +1942,11 @@ void SynEdit::cutToClipboard()
|
|||
auto action = finally([this] {
|
||||
mUndoList->EndBlock();
|
||||
});
|
||||
DoCopyToClipboard(selText());
|
||||
internalDoCopyToClipboard(selText());
|
||||
setSelText("");
|
||||
}
|
||||
|
||||
void SynEdit::copyToClipboard()
|
||||
void SynEdit::doCopyToClipboard()
|
||||
{
|
||||
if (!selAvail())
|
||||
return;
|
||||
|
@ -1960,17 +1962,17 @@ void SynEdit::copyToClipboard()
|
|||
mOptions.setFlag(eoTrimTrailingSpaces,false);
|
||||
sText = selText();
|
||||
}
|
||||
DoCopyToClipboard(sText);
|
||||
internalDoCopyToClipboard(sText);
|
||||
}
|
||||
|
||||
void SynEdit::DoCopyToClipboard(const QString &s)
|
||||
void SynEdit::internalDoCopyToClipboard(const QString &s)
|
||||
{
|
||||
QClipboard* clipboard=QGuiApplication::clipboard();
|
||||
clipboard->clear();
|
||||
clipboard->setText(s);
|
||||
}
|
||||
|
||||
void SynEdit::pasteFromClipboard()
|
||||
void SynEdit::doPasteFromClipboard()
|
||||
{
|
||||
if (mReadOnly)
|
||||
return;
|
||||
|
@ -2744,7 +2746,7 @@ void SynEdit::paintCaret(QPainter &painter, const QRect rcClip)
|
|||
} else {
|
||||
ct =mOverwriteCaret;
|
||||
}
|
||||
painter.setPen(QColorConstants::Svg::red);
|
||||
painter.setPen(mCaretColor);
|
||||
switch(ct) {
|
||||
case SynEditCaretType::ctVerticalLine:
|
||||
painter.drawLine(rcClip.left()+1,rcClip.top(),rcClip.left()+1,rcClip.bottom());
|
||||
|
@ -2753,12 +2755,12 @@ void SynEdit::paintCaret(QPainter &painter, const QRect rcClip)
|
|||
painter.drawLine(rcClip.left(),rcClip.bottom()-1,rcClip.right(),rcClip.bottom()-1);
|
||||
break;
|
||||
case SynEditCaretType::ctBlock:
|
||||
painter.fillRect(rcClip, QColorConstants::Svg::red);
|
||||
painter.fillRect(rcClip, mCaretColor);
|
||||
break;
|
||||
case SynEditCaretType::ctHalfBlock:
|
||||
QRect rc=rcClip;
|
||||
rc.setTop(rcClip.top()+rcClip.height() / 2);
|
||||
painter.fillRect(rcClip, QColorConstants::Svg::red);
|
||||
painter.fillRect(rcClip, mCaretColor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2825,6 +2827,103 @@ void SynEdit::doScrolled(int)
|
|||
invalidate();
|
||||
}
|
||||
|
||||
SynEditCaretType SynEdit::getInsertCaret() const
|
||||
{
|
||||
return mInsertCaret;
|
||||
}
|
||||
|
||||
void SynEdit::setInsertCaret(const SynEditCaretType &insertCaret)
|
||||
{
|
||||
mInsertCaret = insertCaret;
|
||||
}
|
||||
|
||||
SynEditCaretType SynEdit::getOverwriteCaret() const
|
||||
{
|
||||
return mOverwriteCaret;
|
||||
}
|
||||
|
||||
void SynEdit::setOverwriteCaret(const SynEditCaretType &overwriteCaret)
|
||||
{
|
||||
mOverwriteCaret = overwriteCaret;
|
||||
}
|
||||
|
||||
QColor SynEdit::getActiveLineColor() const
|
||||
{
|
||||
return mActiveLineColor;
|
||||
}
|
||||
|
||||
void SynEdit::setActiveLineColor(const QColor &activeLineColor)
|
||||
{
|
||||
if (mActiveLineColor!=activeLineColor) {
|
||||
mActiveLineColor = activeLineColor;
|
||||
invalidateLine(mCaretY);
|
||||
}
|
||||
}
|
||||
|
||||
QColor SynEdit::getCaretColor() const
|
||||
{
|
||||
return mCaretColor;
|
||||
}
|
||||
|
||||
void SynEdit::setCaretColor(const QColor &caretColor)
|
||||
{
|
||||
mCaretColor = caretColor;
|
||||
}
|
||||
|
||||
int SynEdit::getTabWidth() const
|
||||
{
|
||||
return mTabWidth;
|
||||
}
|
||||
|
||||
void SynEdit::setTabWidth(int tabWidth)
|
||||
{
|
||||
if (tabWidth!=mTabWidth) {
|
||||
mTabWidth = tabWidth;
|
||||
mLines->resetColumns();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
SynEditorOptions SynEdit::getOptions() const
|
||||
{
|
||||
return mOptions;
|
||||
}
|
||||
|
||||
void SynEdit::setOptions(const SynEditorOptions &Value)
|
||||
{
|
||||
if (Value != mOptions) {
|
||||
bool bSetDrag = mOptions.testFlag(eoDropFiles) != Value.testFlag(eoDropFiles);
|
||||
if (!mOptions.testFlag(eoScrollPastEol))
|
||||
setLeftChar(mLeftChar);
|
||||
if (!mOptions.testFlag(eoScrollPastEof))
|
||||
setTopLine(mTopLine);
|
||||
|
||||
bool bUpdateAll = Value.testFlag(eoShowSpecialChars) != mOptions.testFlag(eoShowSpecialChars);
|
||||
if (!bUpdateAll)
|
||||
bUpdateAll = Value.testFlag(eoShowRainbowColor) != mOptions.testFlag(eoShowRainbowColor);
|
||||
//bool bUpdateScroll = (Options * ScrollOptions)<>(Value * ScrollOptions);
|
||||
bool bUpdateScroll = true;
|
||||
mOptions = Value;
|
||||
|
||||
// constrain caret position to MaxScrollWidth if eoScrollPastEol is enabled
|
||||
internalSetCaretXY(caretXY());
|
||||
if (mOptions.testFlag(eoScrollPastEol)) {
|
||||
BufferCoord vTempBlockBegin = blockBegin();
|
||||
BufferCoord vTempBlockEnd = blockEnd();
|
||||
setBlockBegin(vTempBlockBegin);
|
||||
setBlockEnd(vTempBlockEnd);
|
||||
}
|
||||
updateScrollbars();
|
||||
// (un)register HWND as drop target
|
||||
// if bSetDrag and not (csDesigning in ComponentState) and HandleAllocated then
|
||||
// DragAcceptFiles(Handle, (eoDropFiles in fOptions));
|
||||
if (bUpdateAll)
|
||||
invalidate();
|
||||
if (bUpdateScroll)
|
||||
updateScrollbars();
|
||||
}
|
||||
}
|
||||
|
||||
void SynEdit::doAddStr(const QString &s)
|
||||
{
|
||||
if (!selAvail() && !mInserting) {
|
||||
|
@ -3292,6 +3391,26 @@ void SynEdit::doRedoItem()
|
|||
}
|
||||
}
|
||||
|
||||
void SynEdit::doZoomIn()
|
||||
{
|
||||
QFont newFont = font();
|
||||
int size = newFont.pointSize();
|
||||
size++;
|
||||
newFont.setPointSize(size);
|
||||
setFont(newFont);
|
||||
}
|
||||
|
||||
void SynEdit::doZoomOut()
|
||||
{
|
||||
QFont newFont = font();
|
||||
int size = newFont.pointSize();
|
||||
size--;
|
||||
if (size<2)
|
||||
size = 2;
|
||||
newFont.setPointSize(size);
|
||||
setFont(newFont);
|
||||
}
|
||||
|
||||
SynSelectionMode SynEdit::selectionMode() const
|
||||
{
|
||||
return mSelectionMode;
|
||||
|
@ -4075,53 +4194,53 @@ void SynEdit::ExecuteCommand(SynEditorCommand Command, QChar AChar, void *pData)
|
|||
SetSelWord();
|
||||
break;
|
||||
case SynEditorCommand::ecSelectAll:
|
||||
SelectAll();
|
||||
doSelectAll();
|
||||
break;
|
||||
case SynEditorCommand::ecDeleteLastChar:
|
||||
DeleteLastChar();
|
||||
doDeleteLastChar();
|
||||
break;
|
||||
case SynEditorCommand::ecDeleteChar:
|
||||
DeleteCurrentChar();
|
||||
doDeleteCurrentChar();
|
||||
break;
|
||||
case SynEditorCommand::ecDeleteWord:
|
||||
DeleteWord();
|
||||
doDeleteWord();
|
||||
break;
|
||||
case SynEditorCommand::ecDeleteEOL:
|
||||
DeleteToEOL();
|
||||
doDeleteToEOL();
|
||||
break;
|
||||
case SynEditorCommand::ecDeleteLastWord:
|
||||
DeleteLastWord();
|
||||
doDeleteLastWord();
|
||||
break;
|
||||
case SynEditorCommand::ecDeleteBOL:
|
||||
DeleteFromBOL();
|
||||
doDeleteFromBOL();
|
||||
break;
|
||||
case SynEditorCommand::ecDeleteLine:
|
||||
DeleteLine();
|
||||
doDeleteLine();
|
||||
break;
|
||||
case SynEditorCommand::ecDuplicateLine:
|
||||
DuplicateLine();
|
||||
doDuplicateLine();
|
||||
break;
|
||||
case SynEditorCommand::ecMoveSelUp:
|
||||
MoveSelUp();
|
||||
doMoveSelUp();
|
||||
break;
|
||||
case SynEditorCommand::ecMoveSelDown:
|
||||
MoveSelDown();
|
||||
doMoveSelDown();
|
||||
break;
|
||||
case SynEditorCommand::ecClearAll:
|
||||
ClearAll();
|
||||
clearAll();
|
||||
break;
|
||||
case SynEditorCommand::ecInsertLine:
|
||||
case SynEditorCommand::ecLineBreak:
|
||||
InsertLine(Command == SynEditorCommand::ecLineBreak);
|
||||
insertLine(Command == SynEditorCommand::ecLineBreak);
|
||||
break;
|
||||
case SynEditorCommand::ecTab:
|
||||
DoTabKey();
|
||||
doTabKey();
|
||||
break;
|
||||
case SynEditorCommand::ecShiftTab:
|
||||
DoShiftTabKey();
|
||||
doShiftTabKey();
|
||||
break;
|
||||
case SynEditorCommand::ecChar:
|
||||
DoAddChar(AChar);
|
||||
doAddChar(AChar);
|
||||
break;
|
||||
case SynEditorCommand::ecInsertMode:
|
||||
if (!mReadOnly)
|
||||
|
@ -4139,17 +4258,18 @@ void SynEdit::ExecuteCommand(SynEditorCommand Command, QChar AChar, void *pData)
|
|||
break;
|
||||
case SynEditorCommand::ecCut:
|
||||
if (!mReadOnly && selAvail())
|
||||
cutToClipboard();
|
||||
doCutToClipboard();
|
||||
break;
|
||||
case SynEditorCommand::ecCopy:
|
||||
if (!mReadOnly && selAvail())
|
||||
copyToClipboard();
|
||||
doCopyToClipboard();
|
||||
break;
|
||||
case SynEditorCommand::ecPaste:
|
||||
if (!mReadOnly)
|
||||
pasteFromClipboard();
|
||||
doPasteFromClipboard();
|
||||
break;
|
||||
case SynEditorCommand::ecImeStr:
|
||||
case SynEditorCommand::ecString:
|
||||
if (!mReadOnly)
|
||||
doAddStr(*((QString*)pData));
|
||||
break;
|
||||
|
@ -4161,6 +4281,12 @@ void SynEdit::ExecuteCommand(SynEditorCommand Command, QChar AChar, void *pData)
|
|||
if (!mReadOnly)
|
||||
doRedo();
|
||||
break;
|
||||
case SynEditorCommand::ecZoomIn:
|
||||
doZoomIn();
|
||||
break;
|
||||
case SynEditorCommand::ecZoomOut:
|
||||
doZoomOut();
|
||||
break;
|
||||
}
|
||||
|
||||
// procedure ForceCaretX(aCaretX: integer);
|
||||
|
@ -4491,6 +4617,13 @@ bool SynEdit::event(QEvent *event)
|
|||
case QEvent::FontChange:
|
||||
synFontChanged();
|
||||
break;
|
||||
case QEvent::MouseMove: {
|
||||
QPoint p = mapFromGlobal(cursor().pos());
|
||||
if (p.y() >= clientHeight() || p.x()>= clientWidth()) {
|
||||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
QAbstractScrollArea::event(event);
|
||||
}
|
||||
|
@ -4507,6 +4640,7 @@ void SynEdit::focusOutEvent(QFocusEvent *)
|
|||
|
||||
void SynEdit::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
mMouseMoved = false;
|
||||
SynEditorCommand cmd=TranslateKeyCode(event->key(),event->modifiers());
|
||||
if (cmd!=SynEditorCommand::ecNone) {
|
||||
CommandProcessor(cmd,QChar(),nullptr);
|
||||
|
@ -4641,6 +4775,12 @@ void SynEdit::mouseMoveEvent(QMouseEvent *event)
|
|||
P.Row = displayY();
|
||||
internalSetCaretXY(displayToBufferPos(P));
|
||||
setBlockEnd(caretXY());
|
||||
} else if (buttons == Qt::NoButton) {
|
||||
if (X > mGutterWidth) {
|
||||
setCursor(Qt::IBeamCursor);
|
||||
} else {
|
||||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4667,6 +4807,11 @@ void SynEdit::inputMethodEvent(QInputMethodEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
void SynEdit::leaveEvent(QEvent *event)
|
||||
{
|
||||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
int SynEdit::maxScrollWidth() const
|
||||
{
|
||||
return mMaxScrollWidth;
|
||||
|
|
|
@ -28,7 +28,7 @@ enum class SynScrollStyle {
|
|||
};
|
||||
|
||||
enum class SynEditCaretType {
|
||||
ctVerticalLine, ctHorizontalLine, ctHalfBlock, ctBlock
|
||||
ctVerticalLine=0, ctHorizontalLine=1, ctHalfBlock=2, ctBlock=3
|
||||
};
|
||||
|
||||
enum class SynStatusChange {
|
||||
|
@ -80,10 +80,10 @@ enum SynEditorOption {
|
|||
eoNoSelection = 0x00004000, //Disables selecting text
|
||||
eoRightMouseMovesCursor = 0x00008000, //When clicking with the right mouse for a popup menu, move the cursor to that location
|
||||
eoScrollByOneLess = 0x00010000, //Forces scrolling to be one less
|
||||
eoScrollHintFollows = 0x00020000, //The scroll hint follows the mouse when scrolling vertically
|
||||
// eoScrollHintFollows = 0x00020000, //The scroll hint follows the mouse when scrolling vertically
|
||||
eoScrollPastEof = 0x00040000, //Allows the cursor to go past the end of file marker
|
||||
eoScrollPastEol = 0x00080000, //Allows the cursor to go past the last character into the white space at the end of a line
|
||||
eoShowScrollHint = 0x00100000, //Shows a hint of the visible line numbers when scrolling vertically
|
||||
// eoShowScrollHint = 0x00100000, //Shows a hint of the visible line numbers when scrolling vertically
|
||||
eoShowSpecialChars = 0x00200000, //Shows the special Characters
|
||||
// eoSmartTabDelete = 0x00400000, //similar to Smart Tabs, but when you delete characters
|
||||
// eoSmartTabs = 0x00800000, //When tabbing, the cursor will go to the next non-white space character of the previous line
|
||||
|
@ -218,7 +218,16 @@ public:
|
|||
SynHighlighterTokenType& TokenType, SynTokenKind &TokenKind, int &Start,
|
||||
PSynHighlighterAttribute& Attri);
|
||||
//Commands
|
||||
void SelectAll();
|
||||
void cutToClipboard() { CommandProcessor(SynEditorCommand::ecCut);}
|
||||
void copyToClipboard() { CommandProcessor(SynEditorCommand::ecCopy);}
|
||||
void pasteFromClipboard() { CommandProcessor(SynEditorCommand::ecPaste);}
|
||||
void undo() { CommandProcessor(SynEditorCommand::ecUndo);}
|
||||
void redo() { CommandProcessor(SynEditorCommand::ecRedo);}
|
||||
void zoomIn() { CommandProcessor(SynEditorCommand::ecZoomIn);}
|
||||
void zoomOut() { CommandProcessor(SynEditorCommand::ecZoomOut);}
|
||||
void selectAll() { { CommandProcessor(SynEditorCommand::ecSelectAll);}}
|
||||
void tab() { { CommandProcessor(SynEditorCommand::ecTab);}}
|
||||
void untab() { { CommandProcessor(SynEditorCommand::ecShiftTab);}}
|
||||
|
||||
|
||||
// setter && getters
|
||||
|
@ -270,6 +279,24 @@ public:
|
|||
|
||||
QString lineBreak();
|
||||
|
||||
SynEditorOptions getOptions() const;
|
||||
void setOptions(const SynEditorOptions &Value);
|
||||
|
||||
int getTabWidth() const;
|
||||
void setTabWidth(int tabWidth);
|
||||
|
||||
QColor getCaretColor() const;
|
||||
void setCaretColor(const QColor &caretColor);
|
||||
|
||||
QColor getActiveLineColor() const;
|
||||
void setActiveLineColor(const QColor &activeLineColor);
|
||||
|
||||
SynEditCaretType getOverwriteCaret() const;
|
||||
void setOverwriteCaret(const SynEditCaretType &overwriteCaret);
|
||||
|
||||
SynEditCaretType getInsertCaret() const;
|
||||
void setInsertCaret(const SynEditCaretType &insertCaret);
|
||||
|
||||
signals:
|
||||
void Changed();
|
||||
|
||||
|
@ -396,32 +423,38 @@ private:
|
|||
|
||||
void clearUndo();
|
||||
BufferCoord GetPreviousLeftBracket(int x,int y);
|
||||
bool CanDoBlockIndent();
|
||||
|
||||
//Commands
|
||||
void DeleteLastChar();
|
||||
void DeleteCurrentChar();
|
||||
void DeleteWord();
|
||||
void DeleteToEOL();
|
||||
void DeleteLastWord();
|
||||
void DeleteFromBOL();
|
||||
void DeleteLine();
|
||||
void DuplicateLine();
|
||||
void MoveSelUp();
|
||||
void MoveSelDown();
|
||||
void ClearAll();
|
||||
void InsertLine(bool moveCaret);
|
||||
void DoTabKey();
|
||||
void DoShiftTabKey();
|
||||
void doDeleteLastChar();
|
||||
void doDeleteCurrentChar();
|
||||
void doDeleteWord();
|
||||
void doDeleteToEOL();
|
||||
void doDeleteLastWord();
|
||||
void doDeleteFromBOL();
|
||||
void doDeleteLine();
|
||||
void doDuplicateLine();
|
||||
void doMoveSelUp();
|
||||
void doMoveSelDown();
|
||||
void clearAll();
|
||||
void insertLine(bool moveCaret);
|
||||
void doTabKey();
|
||||
void doShiftTabKey();
|
||||
void doBlockIndent();
|
||||
void doBlockUnindent();
|
||||
void DoAddChar(QChar AChar);
|
||||
void cutToClipboard();
|
||||
void copyToClipboard();
|
||||
void DoCopyToClipboard(const QString& s);
|
||||
void pasteFromClipboard();
|
||||
|
||||
|
||||
bool CanDoBlockIndent();
|
||||
void doAddChar(QChar AChar);
|
||||
void doCutToClipboard();
|
||||
void doCopyToClipboard();
|
||||
void internalDoCopyToClipboard(const QString& s);
|
||||
void doPasteFromClipboard();
|
||||
void doAddStr(const QString& s);
|
||||
void doUndo();
|
||||
void doUndoItem();
|
||||
void doRedo();
|
||||
void doRedoItem();
|
||||
void doZoomIn();
|
||||
void doZoomOut();
|
||||
void doSelectAll();
|
||||
|
||||
private:
|
||||
void setBlockBegin(BufferCoord value);
|
||||
|
@ -443,11 +476,6 @@ private slots:
|
|||
void sizeOrFontChanged(bool bFont);
|
||||
void doChange();
|
||||
void doScrolled(int value);
|
||||
void doAddStr(const QString& s);
|
||||
void doUndo();
|
||||
void doUndoItem();
|
||||
void doRedo();
|
||||
void doRedoItem();
|
||||
|
||||
private:
|
||||
std::shared_ptr<QImage> mContentImage;
|
||||
|
@ -555,6 +583,8 @@ private:
|
|||
int m_blinkTimerId;
|
||||
int m_blinkStatus;
|
||||
|
||||
QCursor mDefaultCursor;
|
||||
|
||||
friend class SynEditTextPainter;
|
||||
|
||||
// QWidget interface
|
||||
|
@ -571,6 +601,7 @@ void mouseReleaseEvent(QMouseEvent *event) override;
|
|||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
void inputMethodEvent(QInputMethodEvent *event) override;
|
||||
void leaveEvent(QEvent *event) override;
|
||||
};
|
||||
|
||||
#endif // SYNEDIT_H
|
||||
|
|
|
@ -367,6 +367,7 @@ void SynEditStringList::putString(int Index, const QString &s) {
|
|||
beginUpdate();
|
||||
mIndexOfLongestLine = -1;
|
||||
mList[Index]->fString = s;
|
||||
mList[Index]->fColumns = -1;
|
||||
emit putted(Index,1);
|
||||
endUpdate();
|
||||
}
|
||||
|
@ -626,6 +627,16 @@ bool SynEditStringList::empty()
|
|||
return count()==0;
|
||||
}
|
||||
|
||||
void SynEditStringList::resetColumns()
|
||||
{
|
||||
mIndexOfLongestLine = -1;
|
||||
if (mList.count() > 0 ) {
|
||||
for (int i=0;i<mList.size();i++) {
|
||||
mList[i]->fColumns = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SynEditStringList::invalidAllLineColumns()
|
||||
{
|
||||
mIndexOfLongestLine = -1;
|
||||
|
|
|
@ -98,6 +98,8 @@ public:
|
|||
void setFileEndingType(const FileEndingType &fileEndingType);
|
||||
|
||||
bool empty();
|
||||
|
||||
void resetColumns();
|
||||
public slots:
|
||||
void invalidAllLineColumns();
|
||||
|
||||
|
|
|
@ -20,23 +20,19 @@ Settings::Settings(const QString &filename):
|
|||
mEditor(this),
|
||||
mCompilerSets(this)
|
||||
{
|
||||
// default values for editors
|
||||
mEditor.setDefault(SETTING_EDITOR_DEFAULT_ENCODING, QTextCodec::codecForLocale()->name());
|
||||
mEditor.setDefault(SETTING_EDITOR_AUTO_INDENT,true);
|
||||
|
||||
}
|
||||
|
||||
void Settings::setDefault(const QString&group,const QString &key, const QVariant &value) {
|
||||
void Settings::beginGroup(const QString &group)
|
||||
{
|
||||
mSettings.beginGroup(group);
|
||||
auto act = finally([this] {
|
||||
this->mSettings.endGroup();
|
||||
});
|
||||
if (!mSettings.contains(key)) {
|
||||
mSettings.setValue(key,value);
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::setValue(const QString& group, const QString &key, const QVariant &value) {
|
||||
void Settings::endGroup()
|
||||
{
|
||||
mSettings.endGroup();
|
||||
}
|
||||
|
||||
void Settings::saveValue(const QString& group, const QString &key, const QVariant &value) {
|
||||
mSettings.beginGroup(group);
|
||||
auto act = finally([this] {
|
||||
this->mSettings.endGroup();
|
||||
|
@ -44,22 +40,23 @@ void Settings::setValue(const QString& group, const QString &key, const QVariant
|
|||
mSettings.setValue(key,value);
|
||||
}
|
||||
|
||||
void Settings::setValue(const QString &key, const QVariant &value)
|
||||
void Settings::saveValue(const QString &key, const QVariant &value)
|
||||
{
|
||||
mSettings.setValue(key,value);
|
||||
}
|
||||
|
||||
QVariant Settings::value(const QString& group, const QString &key) {
|
||||
QVariant Settings::value(const QString &group, const QString &key, const QVariant &defaultValue)
|
||||
{
|
||||
mSettings.beginGroup(group);
|
||||
auto act = finally([this] {
|
||||
this->mSettings.endGroup();
|
||||
});
|
||||
return mSettings.value(key);
|
||||
return mSettings.value(key,defaultValue);
|
||||
}
|
||||
|
||||
QVariant Settings::value(const QString &key)
|
||||
QVariant Settings::value(const QString &key, const QVariant &defaultValue)
|
||||
{
|
||||
return mSettings.value(key);
|
||||
return mSettings.value(key,defaultValue);
|
||||
}
|
||||
|
||||
Settings::Dirs &Settings::dirs()
|
||||
|
@ -87,6 +84,16 @@ QString Settings::Dirs::app() const
|
|||
return QApplication::instance()->applicationDirPath();
|
||||
}
|
||||
|
||||
void Settings::Dirs::doSave()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Settings::Dirs::doLoad()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Settings::_Base::_Base(Settings *settings, const QString &groupName):
|
||||
mSettings(settings),
|
||||
mGroup(groupName)
|
||||
|
@ -94,19 +101,58 @@ Settings::_Base::_Base(Settings *settings, const QString &groupName):
|
|||
|
||||
}
|
||||
|
||||
void Settings::_Base::setDefault(const QString &key, const QVariant &value)
|
||||
void Settings::_Base::beginGroup()
|
||||
{
|
||||
mSettings->setDefault(mGroup,key,value);
|
||||
mSettings->beginGroup(mGroup);
|
||||
}
|
||||
|
||||
void Settings::_Base::setValue(const QString &key, const QVariant &value)
|
||||
void Settings::_Base::endGroup()
|
||||
{
|
||||
mSettings->setValue(mGroup,key,value);
|
||||
mSettings->endGroup();
|
||||
}
|
||||
|
||||
QVariant Settings::_Base::value(const QString &key)
|
||||
void Settings::_Base::saveValue(const QString &key, const QVariant &value)
|
||||
{
|
||||
return mSettings->value(mGroup,key);
|
||||
mSettings->saveValue(key,value);
|
||||
}
|
||||
|
||||
QVariant Settings::_Base::value(const QString &key, const QVariant &defaultValue)
|
||||
{
|
||||
return mSettings->value(key,defaultValue);
|
||||
}
|
||||
|
||||
bool Settings::_Base::boolValue(const QString &key, bool defaultValue)
|
||||
{
|
||||
return value(key,defaultValue).toBool();
|
||||
}
|
||||
|
||||
int Settings::_Base::intValue(const QString &key, int defaultValue)
|
||||
{
|
||||
return value(key,defaultValue).toInt();
|
||||
}
|
||||
|
||||
QColor Settings::_Base::colorValue(const QString &key, const QColor& defaultValue)
|
||||
{
|
||||
return value(key,defaultValue).value<QColor>();
|
||||
}
|
||||
|
||||
QString Settings::_Base::stringValue(const QString &key, const QString& defaultValue)
|
||||
{
|
||||
return value(key,defaultValue).toString();
|
||||
}
|
||||
|
||||
void Settings::_Base::save()
|
||||
{
|
||||
beginGroup();
|
||||
doSave();
|
||||
endGroup();
|
||||
}
|
||||
|
||||
void Settings::_Base::load()
|
||||
{
|
||||
beginGroup();
|
||||
doLoad();
|
||||
endGroup();
|
||||
}
|
||||
|
||||
Settings::Editor::Editor(Settings *settings): _Base(settings, SETTING_EDITOR)
|
||||
|
@ -116,25 +162,171 @@ Settings::Editor::Editor(Settings *settings): _Base(settings, SETTING_EDITOR)
|
|||
|
||||
QByteArray Settings::Editor::defaultEncoding()
|
||||
{
|
||||
return value(SETTING_EDITOR_DEFAULT_ENCODING).toByteArray();
|
||||
return mDefaultEncoding;
|
||||
}
|
||||
|
||||
void Settings::Editor::setDefaultEncoding(const QByteArray &encoding)
|
||||
void Settings::Editor::setDefaultEncoding(const QByteArray &value)
|
||||
{
|
||||
setValue(SETTING_EDITOR_DEFAULT_ENCODING,encoding);
|
||||
mDefaultEncoding = value;
|
||||
}
|
||||
|
||||
bool Settings::Editor::autoIndent()
|
||||
{
|
||||
return value(SETTING_EDITOR_AUTO_INDENT).toBool();
|
||||
return mAutoIndent;
|
||||
}
|
||||
|
||||
void Settings::Editor::setAutoIndent(bool indent)
|
||||
void Settings::Editor::setAutoIndent(bool value)
|
||||
{
|
||||
setValue(SETTING_EDITOR_AUTO_INDENT,indent);
|
||||
mAutoIndent = value;
|
||||
}
|
||||
|
||||
QColor Settings::Editor::caretColor() const
|
||||
{
|
||||
return mCaretColor;
|
||||
}
|
||||
|
||||
void Settings::Editor::setCaretColor(const QColor &caretColor)
|
||||
{
|
||||
mCaretColor = caretColor;
|
||||
}
|
||||
|
||||
bool Settings::Editor::Editor::keepCaretX() const
|
||||
{
|
||||
return mKeepCaretX;
|
||||
}
|
||||
|
||||
void Settings::Editor::Editor::setKeepCaretX(bool keepCaretX)
|
||||
{
|
||||
mKeepCaretX = keepCaretX;
|
||||
}
|
||||
|
||||
void Settings::Editor::doSave()
|
||||
{
|
||||
saveValue("default_encoding",mDefaultEncoding);
|
||||
// indents
|
||||
saveValue("auto_indent", mAutoIndent);
|
||||
saveValue("add_indent", mAddIndent);
|
||||
saveValue("tab_to_spaces", mTabToSpaces);
|
||||
saveValue("tab_width", mTabWidth);
|
||||
saveValue("show_indent_lines", mShowIndentLines);
|
||||
saveValue("indent_line_color",mIndentLineColor);
|
||||
// caret
|
||||
saveValue("enhance_home_key",mEnhanceHomeKey);
|
||||
saveValue("enhance_end_key",mEnhanceEndKey);
|
||||
saveValue("keep_caret_x",mKeepCaretX);
|
||||
saveValue("caret_for_insert",static_cast<int>(mCaretForInsert));
|
||||
saveValue("caret_for_overwrite",static_cast<int>(mCaretForOverwrite));
|
||||
saveValue("caret_color",mCaretColor);
|
||||
}
|
||||
|
||||
void Settings::Editor::doLoad()
|
||||
{
|
||||
mDefaultEncoding = value("default_encoding", ENCODING_SYSTEM_DEFAULT).toByteArray();
|
||||
// indents
|
||||
mAutoIndent = boolValue("auto_indent", true);
|
||||
mAddIndent = boolValue("add_indent", true);
|
||||
mTabToSpaces = boolValue("tab_to_spaces",false);
|
||||
mTabWidth = intValue("tab_width",4);
|
||||
mShowIndentLines = boolValue("show_indent_lines",true);
|
||||
mIndentLineColor = colorValue("indent_line_color",QColorConstants::Svg::silver);
|
||||
// caret
|
||||
mEnhanceHomeKey = boolValue("enhance_home_key", true);
|
||||
mEnhanceEndKey = boolValue("enhance_end_key",true);
|
||||
mKeepCaretX = boolValue("keep_caret_x",true);
|
||||
mCaretForInsert = static_cast<SynEditCaretType>( intValue("caret_for_insert",static_cast<int>(SynEditCaretType::ctVerticalLine)));
|
||||
mCaretForOverwrite = static_cast<SynEditCaretType>( intValue("caret_for_overwrite",static_cast<int>(SynEditCaretType::ctBlock)));
|
||||
mCaretColor = colorValue("caret_color",QColorConstants::Svg::black);
|
||||
}
|
||||
|
||||
SynEditCaretType Settings::Editor::caretForOverwrite() const
|
||||
{
|
||||
return mCaretForOverwrite;
|
||||
}
|
||||
|
||||
void Settings::Editor::setCaretForOverwrite(const SynEditCaretType &caretForOverwrite)
|
||||
{
|
||||
mCaretForOverwrite = caretForOverwrite;
|
||||
}
|
||||
|
||||
SynEditCaretType Settings::Editor::caretForInsert() const
|
||||
{
|
||||
return mCaretForInsert;
|
||||
}
|
||||
|
||||
void Settings::Editor::setCaretForInsert(const SynEditCaretType &caretForInsert)
|
||||
{
|
||||
mCaretForInsert = caretForInsert;
|
||||
}
|
||||
|
||||
bool Settings::Editor::enhanceEndKey() const
|
||||
{
|
||||
return mEnhanceEndKey;
|
||||
}
|
||||
|
||||
void Settings::Editor::setEnhanceEndKey(bool enhanceEndKey)
|
||||
{
|
||||
mEnhanceEndKey = enhanceEndKey;
|
||||
}
|
||||
|
||||
bool Settings::Editor::enhanceHomeKey() const
|
||||
{
|
||||
return mEnhanceHomeKey;
|
||||
}
|
||||
|
||||
void Settings::Editor::setEnhanceHomeKey(bool enhanceHomeKey)
|
||||
{
|
||||
mEnhanceHomeKey = enhanceHomeKey;
|
||||
}
|
||||
|
||||
QColor Settings::Editor::indentLineColor() const
|
||||
{
|
||||
return mIndentLineColor;
|
||||
}
|
||||
|
||||
void Settings::Editor::setIndentLineColor(const QColor &indentLineColor)
|
||||
{
|
||||
mIndentLineColor = indentLineColor;
|
||||
}
|
||||
|
||||
bool Settings::Editor::showIndentLines() const
|
||||
{
|
||||
return mShowIndentLines;
|
||||
}
|
||||
|
||||
void Settings::Editor::setShowIndentLines(bool showIndentLines)
|
||||
{
|
||||
mShowIndentLines = showIndentLines;
|
||||
}
|
||||
|
||||
int Settings::Editor::tabWidth() const
|
||||
{
|
||||
return mTabWidth;
|
||||
}
|
||||
|
||||
void Settings::Editor::setTabWidth(int tabWidth)
|
||||
{
|
||||
mTabWidth = tabWidth;
|
||||
}
|
||||
|
||||
bool Settings::Editor::tabToSpaces() const
|
||||
{
|
||||
return mTabToSpaces;
|
||||
}
|
||||
|
||||
void Settings::Editor::setTabToSpaces(bool tabToSpaces)
|
||||
{
|
||||
mTabToSpaces = tabToSpaces;
|
||||
}
|
||||
|
||||
bool Settings::Editor::addIndent() const
|
||||
{
|
||||
return mAddIndent;
|
||||
}
|
||||
|
||||
void Settings::Editor::setAddIndent(bool addIndent)
|
||||
{
|
||||
mAddIndent = addIndent;
|
||||
}
|
||||
|
||||
Settings::CompilerSet::CompilerSet(const QString& compilerFolder):
|
||||
mAutoAddCharsetParams(true)
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include <QSettings>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <QColor>
|
||||
#include "qsynedit/SynEdit.h"
|
||||
|
||||
/**
|
||||
* use the following command to get gcc's default bin/library folders:
|
||||
|
@ -46,9 +48,19 @@ private:
|
|||
class _Base {
|
||||
public:
|
||||
explicit _Base(Settings* settings, const QString& groupName);
|
||||
void setDefault(const QString &key, const QVariant &value);
|
||||
void setValue(const QString &key, const QVariant &value);
|
||||
QVariant value(const QString &key);
|
||||
void beginGroup();
|
||||
void endGroup();
|
||||
void saveValue(const QString &key, const QVariant &value);
|
||||
QVariant value(const QString &key, const QVariant& defaultValue);
|
||||
bool boolValue(const QString &key, bool defaultValue);
|
||||
int intValue(const QString &key, int defaultValue);
|
||||
QColor colorValue(const QString &key, const QColor& defaultValue);
|
||||
QString stringValue(const QString &key, const QString& defaultValue);
|
||||
void save();
|
||||
void load();
|
||||
protected:
|
||||
virtual void doSave() = 0;
|
||||
virtual void doLoad() = 0;
|
||||
protected:
|
||||
Settings* mSettings;
|
||||
QString mGroup;
|
||||
|
@ -59,15 +71,74 @@ public:
|
|||
public:
|
||||
explicit Dirs(Settings * settings);
|
||||
QString app() const;
|
||||
|
||||
// _Base interface
|
||||
protected:
|
||||
void doSave() override;
|
||||
void doLoad() override;
|
||||
};
|
||||
|
||||
class Editor: public _Base {
|
||||
public:
|
||||
explicit Editor(Settings * settings);
|
||||
QByteArray defaultEncoding();
|
||||
void setDefaultEncoding(const QByteArray& encoding);
|
||||
void setDefaultEncoding(const QByteArray& value);
|
||||
bool autoIndent();
|
||||
void setAutoIndent(bool indent);
|
||||
void setAutoIndent(bool value);
|
||||
bool addIndent() const;
|
||||
void setAddIndent(bool addIndent);
|
||||
|
||||
bool tabToSpaces() const;
|
||||
void setTabToSpaces(bool tabToSpaces);
|
||||
|
||||
int tabWidth() const;
|
||||
void setTabWidth(int tabWidth);
|
||||
|
||||
bool showIndentLines() const;
|
||||
void setShowIndentLines(bool showIndentLines);
|
||||
|
||||
QColor indentLineColor() const;
|
||||
void setIndentLineColor(const QColor &indentLineColor);
|
||||
|
||||
bool enhanceHomeKey() const;
|
||||
void setEnhanceHomeKey(bool enhanceHomeKey);
|
||||
|
||||
bool enhanceEndKey() const;
|
||||
void setEnhanceEndKey(bool enhanceEndKey);
|
||||
|
||||
SynEditCaretType caretForInsert() const;
|
||||
void setCaretForInsert(const SynEditCaretType &caretForInsert);
|
||||
|
||||
SynEditCaretType caretForOverwrite() const;
|
||||
void setCaretForOverwrite(const SynEditCaretType &caretForOverwrite);
|
||||
|
||||
QColor caretColor() const;
|
||||
void setCaretColor(const QColor &caretColor);
|
||||
|
||||
bool keepCaretX() const;
|
||||
void setKeepCaretX(bool keepCaretX);
|
||||
|
||||
private:
|
||||
QByteArray mDefaultEncoding;
|
||||
// indents
|
||||
bool mAutoIndent;
|
||||
bool mAddIndent;
|
||||
bool mTabToSpaces;
|
||||
int mTabWidth;
|
||||
bool mShowIndentLines;
|
||||
QColor mIndentLineColor;
|
||||
// caret
|
||||
bool mEnhanceHomeKey;
|
||||
bool mEnhanceEndKey;
|
||||
bool mKeepCaretX;
|
||||
SynEditCaretType mCaretForInsert;
|
||||
SynEditCaretType mCaretForOverwrite;
|
||||
QColor mCaretColor;
|
||||
|
||||
// _Base interface
|
||||
protected:
|
||||
void doSave() override;
|
||||
void doLoad() override;
|
||||
};
|
||||
|
||||
class CompilerSet {
|
||||
|
@ -230,11 +301,12 @@ public:
|
|||
|
||||
Settings& operator= (const Settings& settings) = delete;
|
||||
Settings& operator= (const Settings&& settings) = delete;
|
||||
void setDefault(const QString& group, const QString &key, const QVariant &value);
|
||||
void setValue(const QString& group, const QString &key, const QVariant &value);
|
||||
void setValue(const QString &key, const QVariant &value);
|
||||
QVariant value(const QString& group, const QString &key);
|
||||
QVariant value(const QString &key);
|
||||
void beginGroup(const QString& group);
|
||||
void endGroup();
|
||||
void saveValue(const QString& group, const QString &key, const QVariant &value);
|
||||
void saveValue(const QString &key, const QVariant &value);
|
||||
QVariant value(const QString& group, const QString &key, const QVariant& defaultValue);
|
||||
QVariant value(const QString &key, const QVariant& defaultValue);
|
||||
|
||||
Dirs& dirs();
|
||||
Editor& editor();
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
#include "editorgeneralwidget.h"
|
||||
#include "ui_editorgeneralwidget.h"
|
||||
#include "../settings.h"
|
||||
#include "../mainwindow.h"
|
||||
|
||||
#include <QStandardItemModel>
|
||||
|
||||
EditorGeneralWidget::EditorGeneralWidget(const QString& name, const QString& group, QWidget *parent) :
|
||||
SettingsWidget(name,group,parent),
|
||||
ui(new Ui::editorgeneralwidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QStringList caretTypes;
|
||||
caretTypes.append(tr("Vertical Line"));
|
||||
caretTypes.append(tr("Horizontal Line"));
|
||||
caretTypes.append(tr("Half Block"));
|
||||
caretTypes.append(tr("Block"));
|
||||
ui->cbCaretForInsert->addItems(caretTypes);
|
||||
ui->cbCaretForOverwrite->addItems(caretTypes);
|
||||
}
|
||||
|
||||
EditorGeneralWidget::~EditorGeneralWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
static void setCaretTypeIndex(QComboBox* combo, SynEditCaretType caretType) {
|
||||
int t = static_cast<int>(caretType);
|
||||
combo->setCurrentIndex(t);
|
||||
}
|
||||
|
||||
static SynEditCaretType getCaretTypeIndex(QComboBox* combo) {
|
||||
if (combo->currentIndex()<0)
|
||||
return SynEditCaretType::ctVerticalLine;
|
||||
return static_cast<SynEditCaretType>(combo->currentIndex());
|
||||
}
|
||||
void EditorGeneralWidget::doLoad()
|
||||
{
|
||||
pSettings->editor().load();
|
||||
//indents
|
||||
ui->chkAddIndent->setChecked(pSettings->editor().addIndent());
|
||||
ui->chkAutoIndent->setChecked(pSettings->editor().autoIndent());
|
||||
ui->chkTabToSpaces->setChecked(pSettings->editor().autoIndent());
|
||||
ui->spTabWidth->setValue(pSettings->editor().tabWidth());
|
||||
ui->chkShowIndentLines->setChecked(pSettings->editor().showIndentLines());
|
||||
ui->colorIndentLine->setColor(pSettings->editor().indentLineColor());
|
||||
//carets
|
||||
ui->chkEnhanceHome->setChecked(pSettings->editor().enhanceHomeKey());
|
||||
ui->chkEnhanceEndKey->setChecked(pSettings->editor().enhanceEndKey());
|
||||
ui->chkKeepCaretX->setChecked(pSettings->editor().keepCaretX());
|
||||
setCaretTypeIndex(ui->cbCaretForInsert,pSettings->editor().caretForInsert());
|
||||
setCaretTypeIndex(ui->cbCaretForOverwrite,pSettings->editor().caretForOverwrite());
|
||||
ui->colorCaret->setColor(pSettings->editor().caretColor());
|
||||
}
|
||||
|
||||
void EditorGeneralWidget::doSave()
|
||||
{
|
||||
//indents
|
||||
pSettings->editor().setAddIndent(ui->chkAddIndent->isChecked());
|
||||
pSettings->editor().setAutoIndent(ui->chkAutoIndent->isChecked());
|
||||
pSettings->editor().setAutoIndent(ui->chkTabToSpaces->isChecked());
|
||||
pSettings->editor().setTabWidth(ui->spTabWidth->value());
|
||||
pSettings->editor().setShowIndentLines(ui->chkShowIndentLines->isChecked());
|
||||
pSettings->editor().setIndentLineColor(ui->colorIndentLine->color());
|
||||
//carets
|
||||
pSettings->editor().setEnhanceHomeKey(ui->chkEnhanceHome->isChecked());
|
||||
pSettings->editor().setEnhanceEndKey(ui->chkEnhanceEndKey->isChecked());
|
||||
pSettings->editor().setKeepCaretX(ui->chkKeepCaretX->isChecked());
|
||||
pSettings->editor().setCaretForInsert(getCaretTypeIndex(ui->cbCaretForInsert));
|
||||
pSettings->editor().setCaretForOverwrite(getCaretTypeIndex(ui->cbCaretForOverwrite));
|
||||
pSettings->editor().setCaretColor(ui->colorCaret->color());
|
||||
|
||||
pSettings->editor().save();
|
||||
pMainWindow->updateEditorSettings();
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef EDITORGENERALWIDGET_H
|
||||
#define EDITORGENERALWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "settingswidget.h"
|
||||
|
||||
namespace Ui {
|
||||
class editorgeneralwidget;
|
||||
}
|
||||
|
||||
class EditorGeneralWidget : public SettingsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EditorGeneralWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
|
||||
~EditorGeneralWidget();
|
||||
|
||||
private:
|
||||
Ui::editorgeneralwidget *ui;
|
||||
|
||||
// SettingsWidget interface
|
||||
protected:
|
||||
void doLoad() override;
|
||||
void doSave() override;
|
||||
};
|
||||
|
||||
#endif // EDITORGENERALWIDGET_H
|
|
@ -0,0 +1,249 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>editorgeneralwidget</class>
|
||||
<widget class="QWidget" name="editorgeneralwidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>721</width>
|
||||
<height>636</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="grpIndents">
|
||||
<property name="title">
|
||||
<string>Indents</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkAutoIndent">
|
||||
<property name="text">
|
||||
<string>Auto Indent</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkAddIndent">
|
||||
<property name="text">
|
||||
<string>Add Indent after { and :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkTabToSpaces">
|
||||
<property name="text">
|
||||
<string>Replace tab with spaces</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="spTabWidth">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>16</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbCaretColor_2">
|
||||
<property name="text">
|
||||
<string>Tab Width</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkShowIndentLines">
|
||||
<property name="text">
|
||||
<string>Show Indent Lines</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_3" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbCaretColor_4">
|
||||
<property name="text">
|
||||
<string>Indent Line Color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="ColorEdit" name="colorIndentLine">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="grpCarets">
|
||||
<property name="title">
|
||||
<string>Caret</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkEnhanceHome">
|
||||
<property name="text">
|
||||
<string>Move caret to the first non-space char in the current line when press HOME key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkEnhanceEndKey">
|
||||
<property name="text">
|
||||
<string>Move caret to the last non-space char in the current line when press END key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkKeepCaretX">
|
||||
<property name="text">
|
||||
<string>Keep X position of the caret when moving vertically</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>7</number>
|
||||
</property>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="cbCaretForInsert"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbCaretForInsert">
|
||||
<property name="text">
|
||||
<string>Caret for inserting mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbCaretForOverwrite">
|
||||
<property name="text">
|
||||
<string>Caret for overwriting mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="cbCaretForOverwrite"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbCaretColor">
|
||||
<property name="text">
|
||||
<string>Caret Color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="ColorEdit" name="colorCaret">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ColorEdit</class>
|
||||
<extends>QFrame</extends>
|
||||
<header location="global">widgets/coloredit.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -2,6 +2,7 @@
|
|||
#include "ui_settingsdialog.h"
|
||||
#include "settingswidget.h"
|
||||
#include "compilersetoptionwidget.h"
|
||||
#include "editorgeneralwidget.h"
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
|
||||
|
@ -19,8 +20,11 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
|
|||
|
||||
pCompilerSetOptionWidget = new CompilerSetOptionWidget(tr("Compiler Set"),tr("Compiler"));
|
||||
pCompilerSetOptionWidget->init();
|
||||
|
||||
addWidget(pCompilerSetOptionWidget);
|
||||
|
||||
pEditorGeneralWidget = new EditorGeneralWidget(tr("General"),tr("Editor"));
|
||||
pEditorGeneralWidget->init();
|
||||
addWidget(pEditorGeneralWidget);
|
||||
}
|
||||
|
||||
SettingsDialog::~SettingsDialog()
|
||||
|
@ -60,6 +64,10 @@ void SettingsDialog::on_widgetsView_clicked(const QModelIndex &index)
|
|||
if (i>=0) {
|
||||
saveCurrentPageSettings(true);
|
||||
SettingsWidget* pWidget = mSettingWidgets[i];
|
||||
if (ui->scrollArea->widget()!=nullptr) {
|
||||
QWidget* w = ui->scrollArea->takeWidget();
|
||||
w->setParent(nullptr);
|
||||
}
|
||||
ui->scrollArea->setWidget(pWidget);
|
||||
ui->lblWidgetCaption->setText(QString("%1 > %2").arg(pWidget->group()).arg(pWidget->name()));
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ class SettingsDialog;
|
|||
}
|
||||
|
||||
class CompilerSetOptionWidget;
|
||||
class EditorGeneralWidget;
|
||||
class PCompilerSet;
|
||||
class SettingsWidget;
|
||||
class SettingsDialog : public QDialog
|
||||
|
@ -42,6 +43,7 @@ private:
|
|||
QStandardItemModel model;
|
||||
|
||||
CompilerSetOptionWidget* pCompilerSetOptionWidget;
|
||||
EditorGeneralWidget* pEditorGeneralWidget;
|
||||
};
|
||||
|
||||
#endif // SETTINGSDIALOG_H
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#include <QLineEdit>
|
||||
#include <QListView>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QSpinBox>
|
||||
#include "../widgets/coloredit.h"
|
||||
|
||||
SettingsWidget::SettingsWidget(const QString &name, const QString &group, QWidget *parent):
|
||||
QWidget(parent),
|
||||
|
@ -63,6 +65,12 @@ void SettingsWidget::connectInputs()
|
|||
for (QPlainTextEdit* p:findChildren<QPlainTextEdit*>()) {
|
||||
connect(p, &QPlainTextEdit::textChanged, this, &SettingsWidget::setSettingsChanged);
|
||||
}
|
||||
for (QSpinBox* p:findChildren<QSpinBox*>()) {
|
||||
connect(p, QOverload<int>::of(&QSpinBox::valueChanged), this, &SettingsWidget::setSettingsChanged);
|
||||
}
|
||||
for (ColorEdit* p:findChildren<ColorEdit*>()) {
|
||||
connect(p, &ColorEdit::colorChanged, this, &SettingsWidget::setSettingsChanged);
|
||||
}
|
||||
for (QComboBox* p: findChildren<QComboBox*>()) {
|
||||
connect(p, QOverload<int>::of(&QComboBox::currentIndexChanged) ,this, &SettingsWidget::setSettingsChanged);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
#include "coloredit.h"
|
||||
|
||||
#include <QColorDialog>
|
||||
#include <QPainter>
|
||||
#include <QDebug>
|
||||
|
||||
ColorEdit::ColorEdit(QWidget *parent):QFrame(parent)
|
||||
{
|
||||
setFrameStyle(QFrame::Panel);
|
||||
setLineWidth(1);
|
||||
mColor = QColorConstants::Black;
|
||||
}
|
||||
|
||||
QColor ColorEdit::color()
|
||||
{
|
||||
return mColor;
|
||||
}
|
||||
|
||||
void ColorEdit::setColor(const QColor &value)
|
||||
{
|
||||
if (mColor!=value) {
|
||||
mColor=value;
|
||||
emit colorChanged(value);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
QColor ColorEdit::contrast()
|
||||
{
|
||||
int crBg = mColor.rgb() & 0xFFFFFF;
|
||||
int TOLERANCE = 30;
|
||||
int result;
|
||||
|
||||
if (
|
||||
abs(((crBg ) & 0xFF) - 0x80) <= TOLERANCE &&
|
||||
abs(((crBg >> 8) & 0xFF) - 0x80) <= TOLERANCE &&
|
||||
abs(((crBg >> 16) & 0xFF) - 0x80) <= TOLERANCE
|
||||
)
|
||||
result = (0x7F7F7F + crBg) & 0xFFFFFF;
|
||||
else
|
||||
result = crBg ^ 0xFFFFFF;
|
||||
return QColor(result);
|
||||
}
|
||||
|
||||
QSize ColorEdit::sizeHint() const
|
||||
{
|
||||
QRect rect = fontMetrics().boundingRect(mColor.name());
|
||||
return QSize{rect.width()+ 10,
|
||||
rect.width()+ 6 };
|
||||
}
|
||||
|
||||
void ColorEdit::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter painter(this);
|
||||
QRect rect = QRect(lineWidth(),lineWidth(),width()-2*lineWidth(),height()-2*lineWidth());
|
||||
painter.fillRect(rect,mColor);
|
||||
painter.setPen(contrast());
|
||||
painter.drawText(rect,Qt::AlignCenter, mColor.name());
|
||||
qDebug()<<rect<<mColor<<contrast();
|
||||
}
|
||||
|
||||
void ColorEdit::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
QColor c = QColorDialog::getColor();
|
||||
if (c.isValid()) {
|
||||
setColor(c);
|
||||
}
|
||||
}
|
||||
|
||||
void ColorEdit::enterEvent(QEvent *event)
|
||||
{
|
||||
setCursor(Qt::PointingHandCursor);
|
||||
}
|
||||
|
||||
void ColorEdit::leaveEvent(QEvent *event)
|
||||
{
|
||||
setCursor(Qt::ArrowCursor);
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef COLOREDIT_H
|
||||
#define COLOREDIT_H
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
class ColorEdit : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ColorEdit(QWidget* parent = nullptr);
|
||||
QColor color();
|
||||
void setColor(const QColor& value);
|
||||
signals:
|
||||
void colorChanged(const QColor& value);
|
||||
private:
|
||||
QColor mColor;
|
||||
|
||||
QColor contrast();
|
||||
|
||||
public:
|
||||
QSize sizeHint() const override;
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void enterEvent(QEvent *event) override;
|
||||
void leaveEvent(QEvent *event) override;
|
||||
};
|
||||
|
||||
#endif // COLOREDIT_H
|
Loading…
Reference in New Issue