- feature: code completion settings dialog

- Simplified Chinese translation updated
- fix: crash when new a file
This commit is contained in:
royqh1979 2021-08-30 16:59:08 +08:00
parent 692ff570e2
commit dd39b251b4
13 changed files with 597 additions and 188 deletions

View File

@ -29,6 +29,7 @@ SOURCES += \
qsynedit/SearchBase.cpp \
qsynedit/SearchRegex.cpp \
settingsdialog/debuggeneralwidget.cpp \
settingsdialog/editorcodecompletionwidget.cpp \
widgets/classbrowser.cpp \
widgets/codecompletionlistview.cpp \
widgets/codecompletionpopup.cpp \
@ -95,6 +96,7 @@ HEADERS += \
qsynedit/SearchBase.h \
qsynedit/SearchRegex.h \
settingsdialog/debuggeneralwidget.h \
settingsdialog/editorcodecompletionwidget.h \
widgets/classbrowser.h \
widgets/codecompletionlistview.h \
widgets/codecompletionpopup.h \
@ -147,6 +149,7 @@ HEADERS += \
FORMS += \
settingsdialog/debuggeneralwidget.ui \
settingsdialog/editorcodecompletionwidget.ui \
widgets/cpudialog.ui \
mainwindow.ui \
settingsdialog/compilersetdirectorieswidget.ui \

Binary file not shown.

View File

@ -523,7 +523,7 @@ Are you really want to continue?</source>
<translation type="vanished"></translation>
</message>
<message>
<location filename="editor.cpp" line="75"/>
<location filename="editor.cpp" line="76"/>
<source>untitled%1</source>
<translation>%1</translation>
</message>
@ -532,55 +532,55 @@ Are you really want to continue?</source>
<translation type="vanished"></translation>
</message>
<message>
<location filename="editor.cpp" line="169"/>
<location filename="editor.cpp" line="181"/>
<location filename="editor.cpp" line="209"/>
<location filename="editor.cpp" line="762"/>
<location filename="editor.cpp" line="170"/>
<location filename="editor.cpp" line="182"/>
<location filename="editor.cpp" line="210"/>
<location filename="editor.cpp" line="767"/>
<location filename="editor.cpp" line="785"/>
<location filename="editor.cpp" line="772"/>
<location filename="editor.cpp" line="790"/>
<location filename="editor.cpp" line="795"/>
<source>Error</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="170"/>
<location filename="editor.cpp" line="171"/>
<source>File %1 is not writable!</source>
<translation>&quot;%1&quot;</translation>
</message>
<message>
<location filename="editor.cpp" line="197"/>
<location filename="editor.cpp" line="198"/>
<source>Save As</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="763"/>
<location filename="editor.cpp" line="768"/>
<source>The text to be copied exceeds count limit!</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="768"/>
<location filename="editor.cpp" line="773"/>
<source>The text to be copied exceeds character limit!</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="786"/>
<location filename="editor.cpp" line="791"/>
<source>The text to be cut exceeds count limit!</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="791"/>
<location filename="editor.cpp" line="796"/>
<source>The text to be cut exceeds character limit!</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="1972"/>
<location filename="editor.cpp" line="2008"/>
<location filename="editor.cpp" line="2057"/>
<location filename="editor.cpp" line="1965"/>
<location filename="editor.cpp" line="2002"/>
<location filename="editor.cpp" line="2053"/>
<source>Ctrl+click for more info</source>
<translation>Ctrl+</translation>
</message>
<message>
<location filename="editor.cpp" line="2560"/>
<location filename="editor.cpp" line="2556"/>
<source>Readonly</source>
<translation></translation>
</message>
@ -648,6 +648,84 @@ Are you really want to continue?</source>
<translation>RTF</translation>
</message>
</context>
<context>
<name>EditorCodeCompletionWidget</name>
<message>
<location filename="settingsdialog/editorcodecompletionwidget.ui" line="14"/>
<source>Form</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/editorcodecompletionwidget.ui" line="20"/>
<source>Enable code competion</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/editorcodecompletionwidget.ui" line="32"/>
<source>Show completion suggestions while typing</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/editorcodecompletionwidget.ui" line="39"/>
<source>Engine options</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/editorcodecompletionwidget.ui" line="45"/>
<source>Scan local header files</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/editorcodecompletionwidget.ui" line="52"/>
<source>Scan system header files</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/editorcodecompletionwidget.ui" line="62"/>
<source>Show keywords in suggestions</source>
<translation type="unfinished">C/C++</translation>
</message>
<message>
<location filename="settingsdialog/editorcodecompletionwidget.ui" line="69"/>
<source>Show code snippets in suggestions</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/editorcodecompletionwidget.ui" line="76"/>
<source>Append () when complete functions</source>
<translation>()</translation>
</message>
<message>
<location filename="settingsdialog/editorcodecompletionwidget.ui" line="83"/>
<source>Ignore case when search suggestions</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/editorcodecompletionwidget.ui" line="90"/>
<source>Prefer local symbols</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/editorcodecompletionwidget.ui" line="112"/>
<source>Prefer symbols mostly used</source>
<translation>使</translation>
</message>
<message>
<location filename="settingsdialog/editorcodecompletionwidget.ui" line="132"/>
<source>Clear usage data</source>
<translation>使</translation>
</message>
<message>
<location filename="settingsdialog/editorcodecompletionwidget.ui" line="151"/>
<source>Completion suggestion window width:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="settingsdialog/editorcodecompletionwidget.ui" line="181"/>
<source>Completion suggestion window height:</source>
<translation></translation>
</message>
</context>
<context>
<name>EditorColorSchemeWidget</name>
<message>
@ -895,52 +973,52 @@ Are you really want to continue?</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/editorsymbolcompletionwidget.ui" line="20"/>
<location filename="settingsdialog/editorsymbolcompletionwidget.ui" line="33"/>
<source>Complete Symbols</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/editorsymbolcompletionwidget.ui" line="47"/>
<location filename="settingsdialog/editorsymbolcompletionwidget.ui" line="60"/>
<source>Details</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/editorsymbolcompletionwidget.ui" line="65"/>
<location filename="settingsdialog/editorsymbolcompletionwidget.ui" line="78"/>
<source>Complete Braces{}</source>
<translation>{}</translation>
</message>
<message>
<location filename="settingsdialog/editorsymbolcompletionwidget.ui" line="72"/>
<location filename="settingsdialog/editorsymbolcompletionwidget.ui" line="85"/>
<source>Complete Brackets []</source>
<translation>[]</translation>
</message>
<message>
<location filename="settingsdialog/editorsymbolcompletionwidget.ui" line="79"/>
<location filename="settingsdialog/editorsymbolcompletionwidget.ui" line="92"/>
<source>Complete Parenthesis ()</source>
<translation>()</translation>
</message>
<message>
<location filename="settingsdialog/editorsymbolcompletionwidget.ui" line="86"/>
<location filename="settingsdialog/editorsymbolcompletionwidget.ui" line="99"/>
<source>Complete Multiline Comments /**/</source>
<translation>ANSI C风格注释/*和*/</translation>
</message>
<message>
<location filename="settingsdialog/editorsymbolcompletionwidget.ui" line="93"/>
<location filename="settingsdialog/editorsymbolcompletionwidget.ui" line="106"/>
<source>Complete Single Quotations &apos;&apos;</source>
<translation>&apos;&apos;</translation>
</message>
<message>
<location filename="settingsdialog/editorsymbolcompletionwidget.ui" line="100"/>
<location filename="settingsdialog/editorsymbolcompletionwidget.ui" line="113"/>
<source>Complete Double Quotations &quot;&quot;</source>
<translation>&quot;&quot;</translation>
</message>
<message>
<location filename="settingsdialog/editorsymbolcompletionwidget.ui" line="107"/>
<location filename="settingsdialog/editorsymbolcompletionwidget.ui" line="120"/>
<source>Complete #include &lt;&gt;</source>
<translation>#include语句中的&lt;&gt;</translation>
</message>
<message>
<location filename="settingsdialog/editorsymbolcompletionwidget.ui" line="117"/>
<location filename="settingsdialog/editorsymbolcompletionwidget.ui" line="130"/>
<source>Skip matching symbols while typing</source>
<translation></translation>
</message>
@ -1863,65 +1941,65 @@ Are you really want to continue?</source>
<translation>&quot;%1&quot;</translation>
</message>
<message>
<location filename="settings.cpp" line="1106"/>
<location filename="settings.cpp" line="1125"/>
<location filename="settings.cpp" line="1137"/>
<location filename="settings.cpp" line="1149"/>
<location filename="settings.cpp" line="1113"/>
<location filename="settings.cpp" line="1132"/>
<location filename="settings.cpp" line="1144"/>
<location filename="settings.cpp" line="1156"/>
<source>The following %1 directories don&apos;t exist:</source>
<translation>%1</translation>
</message>
<message>
<location filename="settings.cpp" line="1107"/>
<location filename="settings.cpp" line="1117"/>
<location filename="settings.cpp" line="1114"/>
<location filename="settings.cpp" line="1124"/>
<source>binary</source>
<translation></translation>
</message>
<message>
<location filename="settings.cpp" line="1116"/>
<location filename="settings.cpp" line="1123"/>
<source>No %1 directories have been specified.</source>
<translation>%1</translation>
</message>
<message>
<location filename="settings.cpp" line="1126"/>
<location filename="settings.cpp" line="1133"/>
<source>C include</source>
<translation>C包含</translation>
</message>
<message>
<location filename="settings.cpp" line="1138"/>
<location filename="settings.cpp" line="1150"/>
<location filename="settings.cpp" line="1145"/>
<location filename="settings.cpp" line="1157"/>
<source>C++ include</source>
<translation>C++</translation>
</message>
<message>
<location filename="settings.cpp" line="1169"/>
<location filename="settings.cpp" line="1174"/>
<location filename="settings.cpp" line="1179"/>
<location filename="settings.cpp" line="1184"/>
<location filename="settings.cpp" line="1176"/>
<location filename="settings.cpp" line="1181"/>
<location filename="settings.cpp" line="1186"/>
<location filename="settings.cpp" line="1191"/>
<source>Cannot find the %1 &quot;%2&quot;</source>
<translation>%1&quot;%2&quot;</translation>
</message>
<message>
<location filename="settings.cpp" line="1659"/>
<location filename="settings.cpp" line="1666"/>
<source>C options</source>
<translation>C语言选项</translation>
</message>
<message>
<location filename="settings.cpp" line="1665"/>
<location filename="settings.cpp" line="1672"/>
<source>Code Generation</source>
<translation></translation>
</message>
<message>
<location filename="settings.cpp" line="1976"/>
<location filename="settings.cpp" line="1983"/>
<source>The following problems were found during validation of compiler set &quot;%1&quot;:</source>
<translation>&quot;%1&quot;</translation>
</message>
<message>
<location filename="settings.cpp" line="2001"/>
<location filename="settings.cpp" line="2008"/>
<source>Compiler set not configuared.</source>
<translation></translation>
</message>
<message>
<location filename="settings.cpp" line="2003"/>
<location filename="settings.cpp" line="2010"/>
<source>Would you like Red Panda C++ to search for compilers in the following locations: &lt;BR /&gt;&apos;%1&apos;&lt;BR /&gt;&apos;%2&apos;? </source>
<translation>C++&lt;br /&gt;%1&lt;br /&gt;%2</translation>
</message>
@ -2426,147 +2504,147 @@ Are you really want to continue?</source>
<context>
<name>Settings::CompilerSet</name>
<message>
<location filename="settings.cpp" line="1660"/>
<location filename="settings.cpp" line="1667"/>
<source>Support all ANSI standard C programs (-ansi)</source>
<translation>ANSI标准C程序(-ansi)</translation>
</message>
<message>
<location filename="settings.cpp" line="1661"/>
<location filename="settings.cpp" line="1668"/>
<source>Do not recognize asm,inline or typeof as a keyword (-fno-asm)</source>
<translation>asminline和typeof作为关键字(-fno-asm)</translation>
</message>
<message>
<location filename="settings.cpp" line="1662"/>
<location filename="settings.cpp" line="1669"/>
<source>Imitate traditional C preprocessors (-traditional-cpp)</source>
<translation>仿C预处理器行为(-traditional-cpp)</translation>
</message>
<message>
<location filename="settings.cpp" line="1694"/>
<location filename="settings.cpp" line="1701"/>
<source>Optimize for the following machine (-march)</source>
<translation>(-march)</translation>
</message>
<message>
<location filename="settings.cpp" line="1695"/>
<location filename="settings.cpp" line="1702"/>
<source>Optimize less, while maintaining full compatibility (-tune)</source>
<translation>(-tune)</translation>
</message>
<message>
<location filename="settings.cpp" line="1715"/>
<location filename="settings.cpp" line="1722"/>
<source>Enable use of specific instructions (-mx)</source>
<translation>(-mx)</translation>
</message>
<message>
<location filename="settings.cpp" line="1726"/>
<location filename="settings.cpp" line="1733"/>
<source>Optimization level (-Ox)</source>
<translation>(-Ox)</translation>
</message>
<message>
<location filename="settings.cpp" line="1733"/>
<location filename="settings.cpp" line="1740"/>
<source>Compile with the following pointer size (-mx)</source>
<translation>使(-mx)</translation>
</message>
<message>
<location filename="settings.cpp" line="1756"/>
<location filename="settings.cpp" line="1763"/>
<source>Language standard (-std)</source>
<translation>(-std)</translation>
</message>
<message>
<location filename="settings.cpp" line="1757"/>
<location filename="settings.cpp" line="1764"/>
<source>Generate debugging information (-g3)</source>
<translation>(-g3)</translation>
</message>
<message>
<location filename="settings.cpp" line="1758"/>
<location filename="settings.cpp" line="1765"/>
<source>Generate profiling info for analysis (-pg)</source>
<translation>(-pg)</translation>
</message>
<message>
<location filename="settings.cpp" line="1761"/>
<location filename="settings.cpp" line="1768"/>
<source>Warnings</source>
<translation></translation>
</message>
<message>
<location filename="settings.cpp" line="1762"/>
<location filename="settings.cpp" line="1769"/>
<source>Inhibit all warning messages (-w)</source>
<translation>(-w)</translation>
</message>
<message>
<location filename="settings.cpp" line="1763"/>
<location filename="settings.cpp" line="1770"/>
<source>Show most warnings (-Wall)</source>
<translation>(-Wall)</translation>
</message>
<message>
<location filename="settings.cpp" line="1764"/>
<location filename="settings.cpp" line="1771"/>
<source>Show some more warnings (-Wextra)</source>
<translation>(-Wextra)</translation>
</message>
<message>
<location filename="settings.cpp" line="1765"/>
<location filename="settings.cpp" line="1772"/>
<source>Check ISO C/C++/C++0x conformance (-pedantic)</source>
<translation>ISO C/C++/C++0x(-pedantic)</translation>
</message>
<message>
<location filename="settings.cpp" line="1766"/>
<location filename="settings.cpp" line="1773"/>
<source>Only check the code for syntax errors (-fsyntax-only)</source>
<translation>(-fsyntax-only)</translation>
</message>
<message>
<location filename="settings.cpp" line="1767"/>
<location filename="settings.cpp" line="1774"/>
<source>Make all warnings into errors (-Werror)</source>
<translation>(-Werror)</translation>
</message>
<message>
<location filename="settings.cpp" line="1768"/>
<location filename="settings.cpp" line="1775"/>
<source>Abort compilation on first error (-Wfatal-errors)</source>
<translation>(-Wfatal-errors)</translation>
</message>
<message>
<location filename="settings.cpp" line="1771"/>
<location filename="settings.cpp" line="1778"/>
<source>Linker</source>
<translation></translation>
</message>
<message>
<location filename="settings.cpp" line="1772"/>
<location filename="settings.cpp" line="1779"/>
<source>Link an Objective C program (-lobjc)</source>
<translation>Ojbective C程序(-lobjc)</translation>
</message>
<message>
<location filename="settings.cpp" line="1773"/>
<location filename="settings.cpp" line="1780"/>
<source>Do not use standard system libraries (-nostdlib)</source>
<translation>使(-nostdlib)</translation>
</message>
<message>
<location filename="settings.cpp" line="1774"/>
<location filename="settings.cpp" line="1781"/>
<source>Do not create a console window (-mwindows)</source>
<translation>(-mwindows)</translation>
</message>
<message>
<location filename="settings.cpp" line="1775"/>
<location filename="settings.cpp" line="1782"/>
<source>Strip executable (-s)</source>
<translation>(-s)</translation>
</message>
<message>
<location filename="settings.cpp" line="1776"/>
<location filename="settings.cpp" line="1783"/>
<source>Link libraries statically (-static)</source>
<translation>(-static)</translation>
</message>
<message>
<location filename="settings.cpp" line="1779"/>
<location filename="settings.cpp" line="1786"/>
<source>Output</source>
<translation></translation>
</message>
<message>
<location filename="settings.cpp" line="1780"/>
<location filename="settings.cpp" line="1787"/>
<source>-fverbose-asm</source>
<translation></translation>
</message>
<message>
<location filename="settings.cpp" line="1781"/>
<location filename="settings.cpp" line="1788"/>
<source>Use pipes instead of temporary files during compilation (-pipe)</source>
<translation>使(-pipe)</translation>
</message>
<message>
<location filename="settings.cpp" line="1782"/>
<location filename="settings.cpp" line="1789"/>
<source>Do not assemble, compile and generate the assemble code (-S)</source>
<translation>(-S)</translation>
</message>
@ -2574,8 +2652,8 @@ Are you really want to continue?</source>
<context>
<name>Settings::CompilerSets</name>
<message>
<location filename="settings.cpp" line="1975"/>
<location filename="settings.cpp" line="2000"/>
<location filename="settings.cpp" line="1982"/>
<location filename="settings.cpp" line="2007"/>
<source>Confirm</source>
<translation></translation>
</message>
@ -2608,84 +2686,90 @@ Are you really want to continue?</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/settingsdialog.cpp" line="30"/>
<location filename="settingsdialog/settingsdialog.cpp" line="31"/>
<source>Appearence</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/settingsdialog.cpp" line="30"/>
<location filename="settingsdialog/settingsdialog.cpp" line="31"/>
<source>Environment</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/settingsdialog.cpp" line="34"/>
<location filename="settingsdialog/settingsdialog.cpp" line="35"/>
<source>Compiler Set</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/settingsdialog.cpp" line="34"/>
<location filename="settingsdialog/settingsdialog.cpp" line="35"/>
<source>Compiler</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/settingsdialog.cpp" line="38"/>
<location filename="settingsdialog/settingsdialog.cpp" line="63"/>
<location filename="settingsdialog/settingsdialog.cpp" line="67"/>
<location filename="settingsdialog/settingsdialog.cpp" line="39"/>
<location filename="settingsdialog/settingsdialog.cpp" line="68"/>
<location filename="settingsdialog/settingsdialog.cpp" line="72"/>
<source>General</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/settingsdialog.cpp" line="38"/>
<location filename="settingsdialog/settingsdialog.cpp" line="42"/>
<location filename="settingsdialog/settingsdialog.cpp" line="46"/>
<location filename="settingsdialog/settingsdialog.cpp" line="50"/>
<location filename="settingsdialog/settingsdialog.cpp" line="54"/>
<location filename="settingsdialog/settingsdialog.cpp" line="58"/>
<location filename="settingsdialog/settingsdialog.cpp" line="39"/>
<location filename="settingsdialog/settingsdialog.cpp" line="43"/>
<location filename="settingsdialog/settingsdialog.cpp" line="47"/>
<location filename="settingsdialog/settingsdialog.cpp" line="51"/>
<location filename="settingsdialog/settingsdialog.cpp" line="55"/>
<location filename="settingsdialog/settingsdialog.cpp" line="59"/>
<location filename="settingsdialog/settingsdialog.cpp" line="63"/>
<source>Editor</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/settingsdialog.cpp" line="42"/>
<location filename="settingsdialog/settingsdialog.cpp" line="43"/>
<source>Font</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/settingsdialog.cpp" line="46"/>
<location filename="settingsdialog/settingsdialog.cpp" line="47"/>
<source>Copy &amp; Export</source>
<translation>/</translation>
</message>
<message>
<location filename="settingsdialog/settingsdialog.cpp" line="50"/>
<location filename="settingsdialog/settingsdialog.cpp" line="51"/>
<source>Color</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/settingsdialog.cpp" line="54"/>
<source>Symbol Completion</source>
<translation></translation>
<location filename="settingsdialog/settingsdialog.cpp" line="55"/>
<source>Code Completion</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/settingsdialog.cpp" line="58"/>
<location filename="settingsdialog/settingsdialog.cpp" line="59"/>
<source>Symbol Completion</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="settingsdialog/settingsdialog.cpp" line="63"/>
<source>Auto Syntax Checking</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/settingsdialog.cpp" line="63"/>
<location filename="settingsdialog/settingsdialog.cpp" line="68"/>
<source>Program Runner</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/settingsdialog.cpp" line="67"/>
<location filename="settingsdialog/settingsdialog.cpp" line="72"/>
<source>Debugger</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/settingsdialog.cpp" line="159"/>
<location filename="settingsdialog/settingsdialog.cpp" line="164"/>
<source>Save Changes</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/settingsdialog.cpp" line="160"/>
<location filename="settingsdialog/settingsdialog.cpp" line="165"/>
<source>There are changes in the settings, do you want to save them before swtich to other page?</source>
<translation></translation>
</message>

View File

@ -70,6 +70,7 @@ Editor::Editor(QWidget *parent, const QString& filename,
mCurrentWord(),
mCurrentTipType(TipType::None)
{
mUseCppSyntax = true;
if (mFilename.isEmpty()) {
newfileCount++;
mFilename = tr("untitled%1").arg(newfileCount);
@ -373,65 +374,70 @@ void Editor::keyPressEvent(QKeyEvent *event)
QChar ch = t[0];
if (isIdentChar(ch)) {
mLastIdCharPressed++;
// if devCodeCompletion.Enabled and devCodeCompletion.ShowCompletionWhileInput then begin
if (mLastIdCharPressed==1) {
if (mParser->isIncludeLine(lineText())) {
// is a #include line
setSelText(ch);
showHeaderCompletion(false);
handled=true;
return;
} else {
QString lastWord = getPreviousWordAtPositionForSuggestion(caretXY());
if (!lastWord.isEmpty()) {
if (CppTypeKeywords.contains(lastWord)) {
//last word is a type keyword, this is a var or param define, and dont show suggestion
// if devEditor.UseTabnine then
// ShowTabnineCompletion;
return;
}
PStatement statement = mParser->findStatementOf(
mFilename,
lastWord,
caretY());
StatementKind kind = mParser->getKindOfStatement(statement);
if (kind == StatementKind::skClass
|| kind == StatementKind::skEnumClassType
|| kind == StatementKind::skEnumType
|| kind == StatementKind::skTypedef) {
//last word is a typedef/class/struct, this is a var or param define, and dont show suggestion
// if devEditor.UseTabnine then
// ShowTabnineCompletion;
return;
if (pSettings->codeCompletion().enabled()
&& pSettings->codeCompletion().showCompletionWhileInput() ) {
if (mLastIdCharPressed==1) {
if (mParser->isIncludeLine(lineText())) {
// is a #include line
setSelText(ch);
showHeaderCompletion(false);
handled=true;
return;
} else {
QString lastWord = getPreviousWordAtPositionForSuggestion(caretXY());
if (!lastWord.isEmpty()) {
if (CppTypeKeywords.contains(lastWord)) {
//last word is a type keyword, this is a var or param define, and dont show suggestion
// if devEditor.UseTabnine then
// ShowTabnineCompletion;
return;
}
PStatement statement = mParser->findStatementOf(
mFilename,
lastWord,
caretY());
StatementKind kind = mParser->getKindOfStatement(statement);
if (kind == StatementKind::skClass
|| kind == StatementKind::skEnumClassType
|| kind == StatementKind::skEnumType
|| kind == StatementKind::skTypedef) {
//last word is a typedef/class/struct, this is a var or param define, and dont show suggestion
// if devEditor.UseTabnine then
// ShowTabnineCompletion;
return;
}
}
setSelText(ch);
showCompletion(false);
handled=true;
return;
}
}
}
} else {
//preprocessor ?
if ((mLastIdCharPressed=0) && (ch=='#') && lineText().isEmpty()) {
if (pSettings->codeCompletion().enabled()
&& pSettings->codeCompletion().showCompletionWhileInput() ) {
mLastIdCharPressed++;
setSelText(ch);
showCompletion(false);
handled=true;
return;
}
}
// }
} else {
//preprocessor ?
if ((mLastIdCharPressed=0) && (ch=='#') && lineText().isEmpty()) {
// and devCodeCompletion.Enabled and devCodeCompletion.ShowCompletionWhileInput
mLastIdCharPressed++;
setSelText(ch);
showCompletion(false);
handled=true;
return;
}
//javadoc directive?
if ((mLastIdCharPressed=0) && (ch=='#') &&
lineText().trimmed().startsWith('*')) {
// and devCodeCompletion.Enabled and devCodeCompletion.ShowCompletionWhileInput
mLastIdCharPressed++;
setSelText(ch);
showCompletion(false);
handled=true;
return;
if (pSettings->codeCompletion().enabled()
&& pSettings->codeCompletion().showCompletionWhileInput() ) {
mLastIdCharPressed++;
setSelText(ch);
showCompletion(false);
handled=true;
return;
}
}
mLastIdCharPressed = 0;
switch (ch.unicode()) {
@ -452,9 +458,8 @@ void Editor::keyPressEvent(QKeyEvent *event)
}
// Spawn code completion window if we are allowed to
// if devCodeCompletion.Enabled then begin
handled = handleCodeCompletion(ch);
// end;
if (pSettings->codeCompletion().enabled())
handled = handleCodeCompletion(ch);
}
void Editor::onGutterPaint(QPainter &painter, int aLine, int X, int Y)
@ -968,20 +973,6 @@ void Editor::onStatusChanged(SynStatusChanges changes)
pMainWindow->checkSyntaxInBack(this);
}
mLineCount = lines()->count();
// if (not (scOpenFile in Changes)) and (fText.Lines.Count <> fLineCount)
// and (fText.Lines.Count <> 0) and ((fLineCount>0) or (fText.Lines.Count>1)) then begin
// if devCodeCompletion.Enabled
// and SameStr(mainForm.ClassBrowser.CurrentFile,FileName) // Don't reparse twice
// then begin
// Reparse;
// end;
// if fText.Focused and devEditor.AutoCheckSyntax and devEditor.CheckSyntaxWhenReturn
// and (fText.Highlighter = dmMain.Cpp) then begin
// mainForm.CheckSyntaxInBack(self);
// end;
// end;
// fLineCount := fText.Lines.Count;
// // scModified is only fired when the modified state changes
if (changes.testFlag(scModified)) {
updateCaption();
}
@ -1542,8 +1533,8 @@ void Editor::reparse()
void Editor::showCompletion(bool autoComplete)
{
// if not devCodeCompletion.Enabled then
// Exit;
if (!pSettings->codeCompletion().enabled())
return;
if (!mParser->enabled())
return;
@ -1585,11 +1576,13 @@ void Editor::showCompletion(bool autoComplete)
p+=QPoint(0,textHeight()+2);
mCompletionPopup->move(mapToGlobal(p));
// fCompletionBox.RecordUsage := devCodeCompletion.RecordUsage;
// fCompletionBox.SortByScope := devCodeCompletion.SortByScope;
// fCompletionBox.ShowKeywords := devCodeCompletion.ShowKeywords;
// fCompletionBox.ShowCodeIns := devCodeCompletion.ShowCodeIns;
// fCompletionBox.IgnoreCase := devCodeCompletion.IgnoreCase;
mCompletionPopup->setRecordUsage(pSettings->codeCompletion().recordUsage());
mCompletionPopup->setSortByScope(pSettings->codeCompletion().sortByScope());
mCompletionPopup->setShowKeywords(pSettings->codeCompletion().showKeywords());
mCompletionPopup->setShowCodeIns(pSettings->codeCompletion().showCodeIns());
mCompletionPopup->setIgnoreCase(pSettings->codeCompletion().ignoreCase());
mCompletionPopup->resize(pSettings->codeCompletion().width(),
pSettings->codeCompletion().height());
// fCompletionBox.CodeInsList := dmMain.CodeInserts.ItemList;
// fCompletionBox.SymbolUsage := dmMain.SymbolUsage;
// fCompletionBox.ShowCount := devCodeCompletion.MaxCount;
@ -1602,8 +1595,7 @@ void Editor::showCompletion(bool autoComplete)
return onCompletionKeyPressed(event);
});
mCompletionPopup->setParser(mParser);
//todo:
//mCompletionPopup->setUseCppKeyword(mUseCppSyntax);
mCompletionPopup->setUseCppKeyword(mUseCppSyntax);
mCompletionPopup->show();
// Scan the current function body
@ -1618,12 +1610,14 @@ void Editor::showCompletion(bool autoComplete)
// Filter the whole statement list
if (mCompletionPopup->search(word, autoComplete)) { //only one suggestion and it's not input while typing
completionInsert(); // if only have one suggestion, just use it
completionInsert(pSettings->codeCompletion().appendFunc());
}
}
void Editor::showHeaderCompletion(bool autoComplete)
{
if (!pSettings->codeCompletion().enabled())
return;
// if not devCodeCompletion.Enabled then
// Exit;
@ -1636,8 +1630,9 @@ void Editor::showHeaderCompletion(bool autoComplete)
mHeaderCompletionPopup->move(mapToGlobal(p));
// fHeaderCompletionBox.IgnoreCase := devCodeCompletion.IgnoreCase;
// fHeaderCompletionBox.ShowCount := devCodeCompletion.MaxCount;
mHeaderCompletionPopup->setIgnoreCase(pSettings->codeCompletion().ignoreCase());
mHeaderCompletionPopup->resize(pSettings->codeCompletion().width(),
pSettings->codeCompletion().height());
//Set Font size;
mHeaderCompletionPopup->setFont(font());
@ -1842,8 +1837,7 @@ bool Editor::onCompletionKeyPressed(QKeyEvent *event)
return true;
case Qt::Key_Return:
case Qt::Key_Tab:
//CompletionInsert(devCodeCompletion.AppendFunc);
completionInsert(false);
completionInsert(pSettings->codeCompletion().appendFunc());
return true;
default:
if (event->text().isEmpty()) {
@ -1894,7 +1888,6 @@ bool Editor::onHeaderCompletionKeyPressed(QKeyEvent *event)
return true;
case Qt::Key_Return:
case Qt::Key_Tab:
//CompletionInsert(devCodeCompletion.AppendFunc);
headerCompletionInsert();
mHeaderCompletionPopup->hide();
return true;

View File

@ -75,6 +75,9 @@ int main(int argc, char *argv[])
trans.load("RedPandaIDE_"+pSettings->environment().language(),":/translations");
app.installTranslator(&trans);
//must do it after translation is loaded
pSettings->compilerSets().loadSets();
//Color scheme settings must be loaded after translation
pColorManager = new ColorManager();
pIconsManager = new IconsManager();

View File

@ -731,8 +731,7 @@ QString SynEdit::GetLeftSpacing(int charCount, bool wantTabs) const
int SynEdit::charToColumn(int aLine, int aChar) const
{
Q_ASSERT( (aLine <= mLines->count()) && (aLine >= 1));
if (aLine <= mLines->count()) {
if (aLine>=1 && aLine <= mLines->count()) {
QString s = mLines->getString(aLine - 1);
return charToColumn(s,aChar);
}

View File

@ -23,6 +23,7 @@ Settings::Settings(const QString &filename):
mCompilerSets(this),
mExecutor(this),
mDebugger(this),
mCodeCompletion(this),
mHistory(this)
{
load();
@ -73,12 +74,13 @@ QVariant Settings::value(const QString &key, const QVariant &defaultValue)
void Settings::load()
{
mCompilerSets.loadSets();
//mCompilerSets.loadSets();
mEnvironment.load();
mEditor.load();
mExecutor.load();
mDebugger.load();
mHistory.load();
mCodeCompletion.load();
}
Settings::Dirs &Settings::dirs()
@ -111,6 +113,11 @@ QString Settings::filename() const
return mFilename;
}
Settings::CodeCompletion& Settings::codeCompletion()
{
return mCodeCompletion;
}
Settings::History& Settings::history()
{
return mHistory;
@ -2572,7 +2579,6 @@ void Settings::CodeCompletion::setWidth(int newWidth)
void Settings::CodeCompletion::doSave()
{
//Appearence
saveValue("width",mWidth);
saveValue("height",mHeight);
saveValue("enabled",mEnabled);
@ -2591,8 +2597,16 @@ void Settings::CodeCompletion::doSave()
void Settings::CodeCompletion::doLoad()
{
//Appearence
mTheme = stringValue("theme","dark");
mInterfaceFont = stringValue("interface font","Segoe UI");
mInterfaceFontSize = intValue("interface font size",10);
mLanguage = stringValue("language", QLocale::system().name());
mWidth = intValue("width",700);
mHeight = intValue("height",400);
mEnabled = boolValue("enabled",true);
mParseLocalHeaders = boolValue("parse_local_headers",true);
mParseGlobalHeaders = boolValue("parse_global_headers",true);
mShowCompletionWhileInput = boolValue("show_completion_while_input",true);
mRecordUsage = boolValue("record_usage",true);
mSortByScope = boolValue("sort_by_scope",true);
mShowKeywords = boolValue("show_keywords",true);
mIgnoreCase = boolValue("ignore_case",true);
mAppendFunc = boolValue("append_func",true);
mShowCodeIns = boolValue("show_code_ins",true);
}

View File

@ -691,6 +691,7 @@ public:
Executor& executor();
Debugger& debugger();
History& history();
CodeCompletion &codeCompletion();
QString filename() const;
private:
@ -702,6 +703,7 @@ private:
CompilerSets mCompilerSets;
Executor mExecutor;
Debugger mDebugger;
CodeCompletion mCodeCompletion;
History mHistory;
};

View File

@ -0,0 +1,58 @@
#include "editorcodecompletionwidget.h"
#include "ui_editorcodecompletionwidget.h"
#include "../settings.h"
EditorCodeCompletionWidget::EditorCodeCompletionWidget(const QString& name, const QString& group,
QWidget *parent) :
SettingsWidget(name,group,parent),
ui(new Ui::EditorCodeCompletionWidget)
{
ui->setupUi(this);
}
EditorCodeCompletionWidget::~EditorCodeCompletionWidget()
{
delete ui;
}
void EditorCodeCompletionWidget::doLoad()
{
ui->grpEnabled->setChecked(pSettings->codeCompletion().enabled());
ui->chkParseLocalFiles->setChecked(pSettings->codeCompletion().parseLocalHeaders());
ui->chkParseSystemFiles->setChecked(pSettings->codeCompletion().parseGlobalHeaders());
ui->spinWidth->setValue(pSettings->codeCompletion().width());
ui->spinHeight->setValue(pSettings->codeCompletion().height());
ui->chkShowSuggestionWhileTyping->setChecked(pSettings->codeCompletion().showCompletionWhileInput());
ui->chkRecordUsage->setChecked(pSettings->codeCompletion().recordUsage());
ui->chkSortByScope->setChecked(pSettings->codeCompletion().sortByScope());
ui->chkShowKeywords->setChecked(pSettings->codeCompletion().showKeywords());
ui->chkIgnoreCases->setChecked(pSettings->codeCompletion().ignoreCase());
ui->chkAppendFunc->setChecked(pSettings->codeCompletion().appendFunc());
ui->chkShowCodeIns->setChecked(pSettings->codeCompletion().showCodeIns());
}
void EditorCodeCompletionWidget::doSave()
{
//font
pSettings->codeCompletion().setEnabled(ui->grpEnabled->isChecked());
pSettings->codeCompletion().setParseLocalHeaders(ui->chkParseLocalFiles->isChecked());
pSettings->codeCompletion().setParseGlobalHeaders(ui->chkParseSystemFiles->isChecked());
pSettings->codeCompletion().setWidth(ui->spinWidth->value());
pSettings->codeCompletion().setHeight(ui->spinHeight->value());
pSettings->codeCompletion().setShowCompletionWhileInput(ui->chkShowSuggestionWhileTyping->isChecked());
pSettings->codeCompletion().setRecordUsage(ui->chkRecordUsage->isChecked());
pSettings->codeCompletion().setSortByScope(ui->chkSortByScope->isChecked());
pSettings->codeCompletion().setShowKeywords(ui->chkShowKeywords->isChecked());
pSettings->codeCompletion().setIgnoreCase(ui->chkIgnoreCases->isChecked());
pSettings->codeCompletion().setAppendFunc(ui->chkAppendFunc->isChecked());
pSettings->codeCompletion().setShowCodeIns(ui->chkShowCodeIns->isChecked());
pSettings->editor().save();
}

View File

@ -0,0 +1,28 @@
#ifndef EDITORCODECOMPLETIONWIDGET_H
#define EDITORCODECOMPLETIONWIDGET_H
#include <QWidget>
#include "settingswidget.h"
namespace Ui {
class EditorCodeCompletionWidget;
}
class EditorCodeCompletionWidget : public SettingsWidget
{
Q_OBJECT
public:
explicit EditorCodeCompletionWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
~EditorCodeCompletionWidget();
private:
Ui::EditorCodeCompletionWidget *ui;
// SettingsWidget interface
protected:
void doLoad() override;
void doSave() override;
};
#endif // EDITORCODECOMPLETIONWIDGET_H

View File

@ -0,0 +1,218 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EditorCodeCompletionWidget</class>
<widget class="QWidget" name="EditorCodeCompletionWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>599</width>
<height>576</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="grpEnabled">
<property name="title">
<string>Enable code competion</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="chkShowSuggestionWhileTyping">
<property name="text">
<string>Show completion suggestions while typing</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Engine options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="chkParseLocalFiles">
<property name="text">
<string>Scan local header files</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkParseSystemFiles">
<property name="text">
<string>Scan system header files</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkShowKeywords">
<property name="text">
<string>Show keywords in suggestions</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkShowCodeIns">
<property name="text">
<string>Show code snippets in suggestions</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkAppendFunc">
<property name="text">
<string>Append () when complete functions</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkIgnoreCases">
<property name="text">
<string>Ignore case when search suggestions</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkSortByScope">
<property name="text">
<string>Prefer local symbols</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="chkRecordUsage">
<property name="text">
<string>Prefer symbols mostly used</string>
</property>
</widget>
</item>
<item>
<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>
<widget class="QPushButton" name="btnClearUsageData">
<property name="text">
<string>Clear usage data</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>11</number>
</property>
<property name="topMargin">
<number>11</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Completion suggestion window 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>
<item row="0" column="1">
<widget class="QSpinBox" name="spinWidth">
<property name="minimum">
<number>100</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Completion suggestion window height:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="spinHeight">
<property name="minimum">
<number>100</number>
</property>
<property name="maximum">
<number>10000</number>
</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>
<resources/>
<connections/>
</ui>

View File

@ -6,6 +6,7 @@
#include "editorfontwidget.h"
#include "editorclipboardwidget.h"
#include "editorcolorschemewidget.h"
#include "editorcodecompletionwidget.h"
#include "editorsyntaxcheckwidget.h"
#include "editorsymbolcompletionwidget.h"
#include "environmentappearencewidget.h"
@ -51,6 +52,10 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
pEditorColorSchemeWidget->init();
addWidget(pEditorColorSchemeWidget);
pEditorCodeCompletionWidget = new EditorCodeCompletionWidget(tr("Code Completion"),tr("Editor"));
pEditorCodeCompletionWidget->init();
addWidget(pEditorCodeCompletionWidget);
pEditorSymbolCompletionWidget = new EditorSymbolCompletionWidget(tr("Symbol Completion"),tr("Editor"));
pEditorSymbolCompletionWidget->init();
addWidget(pEditorSymbolCompletionWidget);

View File

@ -17,6 +17,7 @@ class EditorClipboardWidget;
class EditorSymbolCompletionWidget;
class EditorColorSchemeWidget;
class EditorSyntaxCheckWidget;
class EditorCodeCompletionWidget;
class EnvironmentAppearenceWidget;
class ExecutorGeneralWidget;
class DebugGeneralWidget;
@ -56,6 +57,7 @@ private:
EditorColorSchemeWidget *pEditorColorSchemeWidget;
EnvironmentAppearenceWidget *pEnvironmentAppearenceWidget;
EditorSymbolCompletionWidget *pEditorSymbolCompletionWidget;
EditorCodeCompletionWidget *pEditorCodeCompletionWidget;
EditorSyntaxCheckWidget *pEditorSyntaxCheckWidget;
ExecutorGeneralWidget *pExecutorGeneralWidget;
DebugGeneralWidget *pDebugGeneralWidget;