feature: caret list

This commit is contained in:
royqh1979@gmail.com 2021-09-02 12:14:02 +08:00
parent 2778e9f4bd
commit 6353f40208
14 changed files with 583 additions and 222 deletions

View File

@ -14,6 +14,7 @@ QMAKE_CXXFLAGS_DEBUG += -Werror=return-type
SOURCES += \
HighlighterManager.cpp \
caretlist.cpp \
codeformatter.cpp \
colorscheme.cpp \
compiler/compiler.cpp \
@ -85,6 +86,7 @@ SOURCES += \
HEADERS += \
HighlighterManager.h \
caretlist.h \
codeformatter.h \
colorscheme.h \
compiler/compiler.h \

Binary file not shown.

View File

@ -532,61 +532,61 @@ Are you really want to continue?</source>
<translation type="vanished"></translation>
</message>
<message>
<location filename="editor.cpp" line="188"/>
<location filename="editor.cpp" line="202"/>
<location filename="editor.cpp" line="238"/>
<location filename="editor.cpp" line="818"/>
<location filename="editor.cpp" line="823"/>
<location filename="editor.cpp" line="841"/>
<location filename="editor.cpp" line="846"/>
<location filename="editor.cpp" line="186"/>
<location filename="editor.cpp" line="200"/>
<location filename="editor.cpp" line="236"/>
<location filename="editor.cpp" line="816"/>
<location filename="editor.cpp" line="821"/>
<location filename="editor.cpp" line="839"/>
<location filename="editor.cpp" line="844"/>
<source>Error</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="189"/>
<location filename="editor.cpp" line="187"/>
<source>File %1 is not writable!</source>
<translation>&quot;%1&quot;</translation>
</message>
<message>
<location filename="editor.cpp" line="223"/>
<location filename="editor.cpp" line="221"/>
<source>Save As</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="819"/>
<location filename="editor.cpp" line="817"/>
<source>The text to be copied exceeds count limit!</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="824"/>
<location filename="editor.cpp" line="822"/>
<source>The text to be copied exceeds character limit!</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="842"/>
<location filename="editor.cpp" line="840"/>
<source>The text to be cut exceeds count limit!</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="847"/>
<location filename="editor.cpp" line="845"/>
<source>The text to be cut exceeds character limit!</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="2045"/>
<location filename="editor.cpp" line="2082"/>
<location filename="editor.cpp" line="2133"/>
<location filename="editor.cpp" line="2043"/>
<location filename="editor.cpp" line="2080"/>
<location filename="editor.cpp" line="2131"/>
<source>Ctrl+click for more info</source>
<translation>Ctrl+</translation>
</message>
<message>
<location filename="editor.cpp" line="2151"/>
<location filename="editor.cpp" line="2181"/>
<location filename="editor.cpp" line="2149"/>
<location filename="editor.cpp" line="2179"/>
<source>Symbol &apos;%1&apos; not found!</source>
<translation>&apos;%1&apos;!</translation>
</message>
<message>
<location filename="editor.cpp" line="2691"/>
<location filename="editor.cpp" line="2717"/>
<source>Readonly</source>
<translation></translation>
</message>
@ -1691,187 +1691,187 @@ Are you really want to continue?</source>
<context>
<name>FormatterStyleModel</name>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="133"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="139"/>
<source>Default</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="134"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="140"/>
<source>The opening braces will not be changed and closing braces will be broken from the preceding line.</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="139"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="145"/>
<source>Allman</source>
<translation>Allman</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="140"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="146"/>
<source>Broken braces.</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="145"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="151"/>
<source>Java</source>
<translation>Java</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="146"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="152"/>
<source>Attached braces.</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="151"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="157"/>
<source>K&amp;R</source>
<translation>K&amp;R</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="152"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="158"/>
<source>Linux braces.</source>
<translation type="unfinished">Linux风格花括号</translation>
<translation>Linux风格花括号</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="157"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="163"/>
<source>Stroustrup</source>
<translation>Stroustrup</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="158"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="164"/>
<source>Linux braces, with broken closing headers.</source>
<translation>Linux风格花括号do-while的while</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="163"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="169"/>
<source>Whitesmith</source>
<translation>Whitesmith</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="164"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="170"/>
<source>Broken, indented braces.</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="166"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="172"/>
<source>Indented class blocks and switch blocks.</source>
<translation>switch代码段缩进</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="171"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="177"/>
<source>VTK</source>
<translation>VTK</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="172"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="178"/>
<source>Broken, indented braces except for the opening braces.</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="177"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="183"/>
<source>Ratliff</source>
<translation>Ratliff</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="178"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="184"/>
<source>Attached, indented braces.</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="183"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="189"/>
<source>GNU</source>
<translation>GNU</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="184"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="190"/>
<source>Broken braces, indented blocks.</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="189"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="195"/>
<source>Linux</source>
<translation>Linux</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="190"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="196"/>
<source>Linux braces, minimum conditional indent is one-half indent.</source>
<translation>Linux风格花括号1.5</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="195"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="201"/>
<source>Horstmann</source>
<translation>Horstmann</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="196"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="202"/>
<source>Run-in braces, indented switches.</source>
<translation>Run-in花括号switch语句缩进</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="201"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="207"/>
<source>One True Brace</source>
<translation>One True Brace</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="202"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="208"/>
<source>Linux braces, add braces to all conditionals.</source>
<translation>Linux封号花括号</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="207"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="213"/>
<source>Google</source>
<translation>Google</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="208"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="214"/>
<source>Attached braces, indented class modifiers.</source>
<translation>访</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="213"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="219"/>
<source>Mozilla</source>
<translation>Mozilla</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="214"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="220"/>
<source>Linux braces, with broken braces for structs and enums, and attached braces for namespaces.</source>
<translation>Linux风格花括号 </translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="219"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="225"/>
<source>Webkit</source>
<translation>Webkit</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="220"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="226"/>
<source>Linux braces, with attached closing headers.</source>
<translation>Linux风格花括号 do-while的while)</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="225"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="231"/>
<source>Pico</source>
<translation>Pico</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="226"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="232"/>
<source>Run-in opening braces and attached closing braces.</source>
<translation>Run-in左花括号</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="228"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="234"/>
<source>Uses keep one line blocks and keep one line statements.</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="233"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="239"/>
<source>Lisp</source>
<translation>Lisp</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="234"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="240"/>
<source>Attached opening braces and attached closing braces.</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="236"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="242"/>
<source>Uses keep one line statements.</source>
<translation></translation>
</message>
@ -1928,8 +1928,8 @@ Are you really want to continue?</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1010"/>
<location filename="mainwindow.ui" line="1013"/>
<location filename="mainwindow.ui" line="1017"/>
<location filename="mainwindow.ui" line="1020"/>
<source>Run</source>
<translation></translation>
</message>
@ -1965,8 +1965,8 @@ Are you really want to continue?</source>
</message>
<message>
<location filename="mainwindow.ui" line="366"/>
<location filename="mainwindow.ui" line="1209"/>
<location filename="mainwindow.ui" line="1212"/>
<location filename="mainwindow.ui" line="1216"/>
<location filename="mainwindow.ui" line="1219"/>
<source>Debug</source>
<translation></translation>
</message>
@ -2032,75 +2032,80 @@ Are you really want to continue?</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="835"/>
<location filename="mainwindow.ui" line="873"/>
<location filename="mainwindow.ui" line="894"/>
<location filename="mainwindow.ui" line="828"/>
<source>Code</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="842"/>
<location filename="mainwindow.ui" line="880"/>
<location filename="mainwindow.ui" line="901"/>
<source>toolBar</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="856"/>
<location filename="mainwindow.ui" line="863"/>
<source>toolBar_2</source>
<translation>2</translation>
</message>
<message>
<location filename="mainwindow.ui" line="924"/>
<location filename="mainwindow.ui" line="931"/>
<source>New</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="927"/>
<location filename="mainwindow.ui" line="934"/>
<source>Ctrl+N</source>
<translation>Ctrl+N</translation>
</message>
<message>
<location filename="mainwindow.ui" line="937"/>
<location filename="mainwindow.ui" line="944"/>
<source>Open...</source>
<translation>...</translation>
</message>
<message>
<location filename="mainwindow.ui" line="940"/>
<location filename="mainwindow.ui" line="947"/>
<source>Ctrl+O</source>
<translation>Ctrl+O</translation>
</message>
<message>
<location filename="mainwindow.ui" line="950"/>
<location filename="mainwindow.ui" line="957"/>
<source>Save</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="953"/>
<location filename="mainwindow.ui" line="960"/>
<source>Ctrl+S</source>
<translation>Ctrl+S</translation>
</message>
<message>
<location filename="mainwindow.ui" line="963"/>
<location filename="mainwindow.ui" line="970"/>
<source>Save As...</source>
<translation>...</translation>
</message>
<message>
<location filename="mainwindow.ui" line="966"/>
<location filename="mainwindow.ui" line="973"/>
<source>Save As</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="976"/>
<location filename="mainwindow.ui" line="983"/>
<source>Save All</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="979"/>
<location filename="mainwindow.ui" line="986"/>
<source>Ctrl+Shift+S</source>
<translation>Ctrl+Shift+S</translation>
</message>
<message>
<location filename="mainwindow.ui" line="984"/>
<location filename="mainwindow.ui" line="991"/>
<source>Options</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="994"/>
<location filename="mainwindow.ui" line="997"/>
<location filename="mainwindow.ui" line="1001"/>
<location filename="mainwindow.ui" line="1004"/>
<location filename="mainwindow.cpp" line="804"/>
<location filename="mainwindow.cpp" line="815"/>
<location filename="mainwindow.cpp" line="1053"/>
@ -2109,297 +2114,302 @@ Are you really want to continue?</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1000"/>
<location filename="mainwindow.ui" line="1007"/>
<source>F9</source>
<translation>F9</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1016"/>
<location filename="mainwindow.ui" line="1023"/>
<source>F10</source>
<translation>F10</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1026"/>
<location filename="mainwindow.ui" line="1033"/>
<source>Undo</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1029"/>
<location filename="mainwindow.ui" line="1036"/>
<source>Ctrl+Z</source>
<translation>Ctrl+Z</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1039"/>
<location filename="mainwindow.ui" line="1046"/>
<source>Redo</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1042"/>
<location filename="mainwindow.ui" line="1049"/>
<source>Ctrl+Y</source>
<translation>Ctrl+Y</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1052"/>
<location filename="mainwindow.ui" line="1059"/>
<source>Cut</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1055"/>
<location filename="mainwindow.ui" line="1062"/>
<source>Ctrl+X</source>
<translation>Ctrl+X</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1065"/>
<location filename="mainwindow.ui" line="1072"/>
<source>Copy</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1068"/>
<location filename="mainwindow.ui" line="1075"/>
<source>Ctrl+C</source>
<translation>Ctrl+C</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1078"/>
<location filename="mainwindow.ui" line="1085"/>
<source>Paste</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1081"/>
<location filename="mainwindow.ui" line="1088"/>
<source>Ctrl+V</source>
<translation>Ctrl+V</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1086"/>
<location filename="mainwindow.ui" line="1093"/>
<source>Select All</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1089"/>
<location filename="mainwindow.ui" line="1096"/>
<source>Ctrl+A</source>
<translation>Ctrl+A</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1099"/>
<location filename="mainwindow.ui" line="1106"/>
<source>Indent</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1109"/>
<location filename="mainwindow.ui" line="1116"/>
<source>UnIndent</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1114"/>
<location filename="mainwindow.ui" line="1121"/>
<source>Toggle Comment</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1117"/>
<location filename="mainwindow.ui" line="1124"/>
<source>Ctrl+/</source>
<translation>Ctrl+/</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1125"/>
<location filename="mainwindow.ui" line="1132"/>
<source>Collapse All</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1130"/>
<location filename="mainwindow.ui" line="1137"/>
<source>Uncollapse All</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1135"/>
<location filename="mainwindow.ui" line="1142"/>
<source>Encode in ANSI</source>
<translation>使ANSI编码</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1140"/>
<location filename="mainwindow.ui" line="1147"/>
<source>Encode in UTF-8</source>
<translation>使UTF-8</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1145"/>
<location filename="mainwindow.ui" line="1152"/>
<source>Auto Detect</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1150"/>
<location filename="mainwindow.ui" line="1157"/>
<source>Convert to ANSI</source>
<translation>ANSI编码</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1155"/>
<location filename="mainwindow.ui" line="1162"/>
<source>Convert to UTF-8</source>
<translation>UTF-8</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1165"/>
<location filename="mainwindow.ui" line="1168"/>
<location filename="mainwindow.ui" line="1172"/>
<location filename="mainwindow.ui" line="1175"/>
<source>Compile &amp; Run</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1171"/>
<location filename="mainwindow.ui" line="1178"/>
<source>F11</source>
<translation>F11</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1181"/>
<location filename="mainwindow.ui" line="1184"/>
<location filename="mainwindow.ui" line="1188"/>
<location filename="mainwindow.ui" line="1191"/>
<source>Rebuild All</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1187"/>
<location filename="mainwindow.ui" line="1194"/>
<source>F12</source>
<translation>F12</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1197"/>
<location filename="mainwindow.ui" line="1204"/>
<source>Stop Execution</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1200"/>
<location filename="mainwindow.ui" line="1207"/>
<source>F6</source>
<translation>F6</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1215"/>
<location filename="mainwindow.ui" line="1222"/>
<source>F5</source>
<translation>F5</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1225"/>
<location filename="mainwindow.ui" line="1232"/>
<source>Step Over</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1228"/>
<location filename="mainwindow.ui" line="1235"/>
<source>F7</source>
<translation>F7</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1238"/>
<location filename="mainwindow.ui" line="1245"/>
<source>Step Into</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1241"/>
<location filename="mainwindow.ui" line="1248"/>
<source>F8</source>
<translation>F8</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1251"/>
<location filename="mainwindow.ui" line="1258"/>
<source>Step Out</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1254"/>
<location filename="mainwindow.ui" line="1261"/>
<source>Ctrl+F8</source>
<translation>Ctrl+F8</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1259"/>
<location filename="mainwindow.ui" line="1266"/>
<source>Run To Cursor</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1262"/>
<location filename="mainwindow.ui" line="1269"/>
<source>Ctrl+F5</source>
<translation>Ctrl+F5</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1272"/>
<location filename="mainwindow.ui" line="1279"/>
<source>Continue</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1275"/>
<location filename="mainwindow.ui" line="1282"/>
<source>F4</source>
<translation>F4</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1285"/>
<location filename="mainwindow.ui" line="1292"/>
<source>Add Watch...</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1290"/>
<location filename="mainwindow.ui" line="1297"/>
<source>View CPU Window...</source>
<translation>CPU信息窗口...</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1295"/>
<location filename="mainwindow.ui" line="1302"/>
<source>Exit</source>
<translation>退</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1305"/>
<location filename="mainwindow.ui" line="1312"/>
<source>Find...</source>
<translation>...</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1308"/>
<location filename="mainwindow.ui" line="1315"/>
<source>Ctrl+F</source>
<translation>Ctrl+F</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1313"/>
<location filename="mainwindow.ui" line="1320"/>
<source>Find in Files...</source>
<translation>...</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1316"/>
<location filename="mainwindow.ui" line="1323"/>
<source>Ctrl+Shift+F</source>
<translation>Ctrl+Shift+F</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1326"/>
<location filename="mainwindow.ui" line="1333"/>
<source>Replace...</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1329"/>
<location filename="mainwindow.ui" line="1336"/>
<source>Ctrl+R</source>
<translation>Ctrl+R</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1334"/>
<location filename="mainwindow.ui" line="1341"/>
<source>Find Next</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1337"/>
<location filename="mainwindow.ui" line="1344"/>
<source>F3</source>
<translation>F3</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1342"/>
<location filename="mainwindow.ui" line="1349"/>
<source>Find Previous</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1345"/>
<location filename="mainwindow.ui" line="1352"/>
<source>Shift+F3</source>
<translation>Shift+F3</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1350"/>
<location filename="mainwindow.ui" line="1357"/>
<source>Remove Watch</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1355"/>
<location filename="mainwindow.ui" line="1362"/>
<source>Remove All</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1360"/>
<location filename="mainwindow.ui" line="1367"/>
<source>Modify Watch...</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="1377"/>
<source>Reformat Code</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="81"/>
<source>File Encoding</source>
@ -3693,12 +3703,12 @@ Are you really want to continue?</source>
<context>
<name>SynEditStringList</name>
<message>
<location filename="qsynedit/TextBuffer.cpp" line="468"/>
<location filename="qsynedit/TextBuffer.cpp" line="472"/>
<source>Can&apos;t open file &apos;%1&apos; for read!</source>
<translation>&apos;%1&apos;!</translation>
</message>
<message>
<location filename="qsynedit/TextBuffer.cpp" line="555"/>
<location filename="qsynedit/TextBuffer.cpp" line="559"/>
<source>Can&apos;t open file &apos;%1&apos; for save!</source>
<translation>&apos;%2&apos;!</translation>
</message>

117
RedPandaIDE/caretlist.cpp Normal file
View File

@ -0,0 +1,117 @@
#include "caretlist.h"
#include <QDebug>
CaretList::CaretList(QObject* parent):
QObject(parent),
mIndex(-1),
mPauseAdd(false)
{
}
void CaretList::addCaret(Editor *editor, int line, int aChar)
{
if (mPauseAdd)
return;
for (int i=mList.count()-1;i>mIndex;i--) {
removeCaret(i);
}
PEditorCaret caret = std::make_shared<EditorCaret>();
caret->editor = editor;
caret->line = line;
caret->aChar = aChar;
mList.append(caret);
mIndex++;
qDebug()<<"add caret:"<<mIndex<<":"<<mList.count();
}
bool CaretList::hasPrevious() const
{
qDebug()<<"has previous:"<<mIndex<<":"<<mList.count();
return mIndex>0;
}
bool CaretList::hasNext() const
{
qDebug()<<"has next:"<<mIndex<<":"<<mList.count();
return mIndex<mList.count()-1;
}
PEditorCaret CaretList::gotoAndGetPrevious()
{
if (!hasPrevious())
return PEditorCaret();
mIndex--;
qDebug()<<"move previous:"<<mIndex<<":"<<mList.count();
if (mIndex<mList.count())
return mList[mIndex];
return PEditorCaret();
}
PEditorCaret CaretList::gotoAndGetNext()
{
if (!hasNext())
return PEditorCaret();
mIndex++;
qDebug()<<"move next:"<<mIndex<<":"<<mList.count();
if (mIndex>=0)
return mList[mIndex];
return PEditorCaret();
}
void CaretList::removeEditor(const Editor *editor)
{
for (int i = mList.count()-1;i>=0;i--) {
if (mList[i]->editor == editor)
removeCaret(i);
}
}
void CaretList::reset()
{
mList.clear();
mIndex = -1;
}
void CaretList::pause()
{
mPauseAdd = true;
}
void CaretList::unPause()
{
mPauseAdd = false;
}
void CaretList::linesDeleted(const Editor *editor, int firstLine, int count)
{
qDebug()<<"deleted:"<<mIndex<<":"<<mList.count();
for (int i=mList.count()-1;i>=0;i--) {
if (mList[i]->editor == editor
&& mList[i]->line>=firstLine) {
if (mList[i]->line < (firstLine+count))
removeCaret(i);
else
mList[i]->line-=count;
}
}
}
void CaretList::linesInserted(const Editor *editor, int firstLine, int count)
{
qDebug()<<"inserted:"<<mIndex<<":"<<mList.count();
for(PEditorCaret& caret:mList) {
if (caret->editor == editor
&& caret->line >= firstLine)
caret->line+=count;
}
}
void CaretList::removeCaret(int index)
{
if (index<0 || index>=mList.count())
return;
mList.removeAt(index);
if (mIndex>=index)
mIndex--;
}

43
RedPandaIDE/caretlist.h Normal file
View File

@ -0,0 +1,43 @@
#ifndef CARETLIST_H
#define CARETLIST_H
#include <QString>
#include <memory>
#include <QVector>
#include <QObject>
class Editor;
struct EditorCaret{
Editor* editor;
int line;
int aChar;
};
using PEditorCaret = std::shared_ptr<EditorCaret>;
class CaretList:public QObject
{
Q_OBJECT
public:
explicit CaretList(QObject* parent = nullptr);
public:
void addCaret(Editor *editor, int line, int aChar);
bool hasPrevious() const;
bool hasNext() const;
PEditorCaret gotoAndGetPrevious();
PEditorCaret gotoAndGetNext();
void removeEditor(const Editor* editor);
void reset();
void pause();
void unPause();
public slots:
void linesDeleted(const Editor* editor, int firstLine, int count);
void linesInserted(const Editor* editor, int firstLine, int count);
private:
void removeCaret(int index);
private:
QVector<PEditorCaret> mList;
int mIndex;
bool mPauseAdd;
};
#endif // CARETLIST_H

View File

@ -127,9 +127,16 @@ Editor::Editor(QWidget *parent, const QString& filename,
onStatusChanged(SynStatusChange::scOpenFile);
setAttribute(Qt::WA_Hover,true);
connect(this,&SynEdit::linesDeleted,
this, &Editor::onLinesDeleted);
connect(this,&SynEdit::linesInserted,
this, &Editor::onLinesInserted);
}
Editor::~Editor() {
pMainWindow->caretList().removeEditor(this);
pMainWindow->updateCaretActions();
if (mParentPageControl!=nullptr) {
int index = mParentPageControl->indexOf(this);
mParentPageControl->removeTab(index);
@ -143,8 +150,6 @@ void Editor::loadFile() {
this->setModified(false);
updateCaption();
pMainWindow->updateForEncodingInfo();
if (pSettings->editor().syntaxCheck() && pSettings->editor().syntaxCheckWhenSave())
pMainWindow->checkSyntaxInBack(this);
switch(getFileType(mFilename)) {
case FileType::CppSource:
mUseCppSyntax = true;
@ -157,8 +162,8 @@ void Editor::loadFile() {
}
if (highlighter() && mParser) {
reparse();
if (pSettings->editor().syntaxCheck() && pSettings->editor().syntaxCheckWhenLineChanged()) {
pMainWindow->checkSyntaxInBack(this);
if (pSettings->editor().syntaxCheckWhenLineChanged()) {
checkSyntaxInBack();
}
}
}
@ -167,8 +172,8 @@ void Editor::saveFile(const QString &filename) {
QFile file(filename);
this->lines()->SaveToFile(file,mEncodingOption,mFileEncoding);
pMainWindow->updateForEncodingInfo();
if (pSettings->editor().syntaxCheck() && pSettings->editor().syntaxCheckWhenSave())
pMainWindow->checkSyntaxInBack(this);
if (pSettings->editor().syntaxCheckWhenSave())
checkSyntaxInBack();
}
void Editor::convertToEncoding(const QByteArray &encoding)
@ -264,7 +269,7 @@ bool Editor::saveAs(){
reparse();
if (highlighter() && pSettings->editor().syntaxCheck() && pSettings->editor().syntaxCheckWhenLineChanged())
if (pSettings->editor().syntaxCheckWhenSave())
pMainWindow->checkSyntaxInBack(this);
return true;
@ -1020,8 +1025,8 @@ void Editor::onStatusChanged(SynStatusChanges changes)
&& (lines()->count()!=mLineCount)
&& (lines()->count()!=0) && ((mLineCount>0) || (lines()->count()>1))) {
reparse();
if (!readOnly() && highlighter() && pSettings->editor().syntaxCheck() && pSettings->editor().syntaxCheckWhenLineChanged())
pMainWindow->checkSyntaxInBack(this);
if (pSettings->editor().syntaxCheckWhenLineChanged())
checkSyntaxInBack();
}
mLineCount = lines()->count();
if (changes.testFlag(scModified)) {
@ -1116,7 +1121,10 @@ void Editor::onStatusChanged(SynStatusChanges changes)
pMainWindow->updateEditorActions();
// mainForm.CaretList.AddCaret(self,fText.CaretY,fText.CaretX);
if (changes.testFlag(SynStatusChange::scCaretY)) {
pMainWindow->caretList().addCaret(this,caretY(),caretX());
pMainWindow->updateCaretActions();
}
}
void Editor::onGutterClicked(Qt::MouseButton button, int , int , int line)
@ -1136,6 +1144,16 @@ void Editor::onTipEvalValueReady(const QString &value)
this, &Editor::onTipEvalValueReady);
}
void Editor::onLinesDeleted(int first, int count)
{
pMainWindow->caretList().linesDeleted(this,first,count);
}
void Editor::onLinesInserted(int first, int count)
{
pMainWindow->caretList().linesInserted(this,first,count);
}
QChar Editor::getCurrentChar()
{
if (lineText().length()<caretX())
@ -2462,6 +2480,34 @@ QString Editor::getPreviousWordAtPositionForSuggestion(const BufferCoord &p)
return result;
}
void Editor::reformat()
{
if (readOnly())
return;
QFile file(":/codes/formatdemo.cpp");
if (!file.open(QFile::ReadOnly))
return;
QByteArray content = lines()->text().toUtf8();
QStringList args = pSettings->codeFormatter().getArguments();
QByteArray newContent = runAndGetOutput("astyle.exe",
pSettings->dirs().app(),
args,
content);
selectAll();
setSelText(QString::fromUtf8(newContent));
reparse();
}
void Editor::checkSyntaxInBack()
{
if (readOnly())
return;
if(pSettings->editor().syntaxCheck())
pMainWindow->checkSyntaxInBack(this);
}
const PCppParser &Editor::parser() const
{
return mParser;

View File

@ -140,14 +140,18 @@ public:
BufferCoord& pWordEnd,
WordPurpose purpose);
QString getPreviousWordAtPositionForSuggestion(const BufferCoord& p);
void reformat();
void checkSyntaxInBack();
const PCppParser &parser() const;
protected slots:
private slots:
void onModificationChanged(bool status) ;
void onStatusChanged(SynStatusChanges changes);
void onGutterClicked(Qt::MouseButton button, int x, int y, int line);
void onTipEvalValueReady(const QString& value);
void onLinesDeleted(int first,int count);
void onLinesInserted(int first,int count);
private:
QChar getCurrentChar();

View File

@ -100,6 +100,7 @@ MainWindow::MainWindow(QWidget *parent)
mCPUDialog = nullptr;
updateEditorActions();
updateCaretActions();
applySettings();
openCloseMessageSheet(false);
@ -206,6 +207,9 @@ void MainWindow::updateEditorActions()
ui->actionReplace->setEnabled(false);
ui->actionFind_Next->setEnabled(false);
ui->actionFind_Previous->setEnabled(false);
//code
ui->actionReformat_Code->setEnabled(false);
} else {
ui->actionAuto_Detect->setEnabled(true);
ui->actionEncode_in_ANSI->setEnabled(true);
@ -234,6 +238,9 @@ void MainWindow::updateEditorActions()
ui->actionFind_Next->setEnabled(true);
ui->actionFind_Previous->setEnabled(true);
//code
ui->actionReformat_Code->setEnabled(true);
updateCompileActions();
}
@ -1885,3 +1892,48 @@ void MainWindow::on_actionModify_Watch_triggered()
}
void MainWindow::on_actionReformat_Code_triggered()
{
Editor* e = mEditorList->getEditor();
if (e) {
e->reformat();
e->activate();
}
}
CaretList &MainWindow::caretList()
{
return mCaretList;
}
void MainWindow::updateCaretActions()
{
ui->actionBack->setEnabled(mCaretList.hasPrevious());
ui->actionForward->setEnabled(mCaretList.hasNext());
}
void MainWindow::on_actionBack_triggered()
{
PEditorCaret caret = mCaretList.gotoAndGetPrevious();
mCaretList.pause();
if (caret) {
caret->editor->setCaretPositionAndActivate(caret->line,caret->aChar);
}
mCaretList.unPause();
updateCaretActions();
}
void MainWindow::on_actionForward_triggered()
{
PEditorCaret caret = mCaretList.gotoAndGetNext();
mCaretList.pause();
if (caret) {
caret->editor->setCaretPositionAndActivate(caret->line,caret->aChar);
}
mCaretList.unPause();
updateCaretActions();
}

View File

@ -9,6 +9,7 @@
#include "widgets/classbrowser.h"
#include "widgets/codecompletionpopup.h"
#include "widgets/headercompletionpopup.h"
#include "caretlist.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
@ -99,6 +100,9 @@ public:
const std::shared_ptr<CodeCompletionPopup> &completionPopup() const;
const std::shared_ptr<HeaderCompletionPopup> &headerCompletionPopup() const;
CaretList &caretList();
void updateCaretActions();
public slots:
void onCompileLog(const QString& msg);
void onCompileIssue(PCompileIssue issue);
@ -233,6 +237,12 @@ private slots:
void on_actionModify_Watch_triggered();
void on_actionReformat_Code_triggered();
void on_actionBack_triggered();
void on_actionForward_triggered();
private:
Ui::MainWindow *ui;
EditorList *mEditorList;
@ -269,6 +279,8 @@ private:
QTimer mAutoSaveTimer;
CaretList mCaretList;
// QWidget interface
protected:

View File

@ -823,9 +823,21 @@
<addaction name="actionFind_Next"/>
<addaction name="actionFind_Previous"/>
</widget>
<widget class="QMenu" name="menuCode">
<property name="title">
<string>Code</string>
</property>
<addaction name="separator"/>
<addaction name="actionBack"/>
<addaction name="actionForward"/>
<addaction name="separator"/>
<addaction name="separator"/>
<addaction name="actionReformat_Code"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuEdit"/>
<addaction name="menuSearch"/>
<addaction name="menuCode"/>
<addaction name="menuExecute"/>
<addaction name="menuTools"/>
</widget>
@ -914,6 +926,21 @@
<addaction name="separator"/>
<addaction name="actionAdd_Watch"/>
</widget>
<widget class="QToolBar" name="toolbarCode">
<property name="windowTitle">
<string>toolBar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionBack"/>
<addaction name="actionForward"/>
<addaction name="separator"/>
<addaction name="actionReformat_Code"/>
</widget>
<action name="actionNew">
<property name="icon">
<iconset>
@ -1360,6 +1387,45 @@
<string>Modify Watch...</string>
</property>
</action>
<action name="actionReformat_Code">
<property name="icon">
<iconset>
<normalon>:/icons/images/newlook24/063-reformat.png</normalon>
</iconset>
</property>
<property name="text">
<string>Reformat Code</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+A</string>
</property>
</action>
<action name="actionBack">
<property name="icon">
<iconset>
<normalon>:/icons/images/newlook24/006-Back.png</normalon>
</iconset>
</property>
<property name="text">
<string>Go back</string>
</property>
<property name="shortcut">
<string>Ctrl+Alt+Left</string>
</property>
</action>
<action name="actionForward">
<property name="icon">
<iconset>
<normalon>:/icons/images/newlook24/038-Forward.png</normalon>
</iconset>
</property>
<property name="text">
<string>Forward</string>
</property>
<property name="shortcut">
<string>Ctrl+Alt+Right</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@ -28,12 +28,12 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
//fPlugins := TList.Create;
mMouseMoved = false;
mUndoing = false;
mLines->connect(mLines.get(), &SynEditStringList::changed, this, &SynEdit::linesChanged);
mLines->connect(mLines.get(), &SynEditStringList::changing, this, &SynEdit::linesChanging);
mLines->connect(mLines.get(), &SynEditStringList::cleared, this, &SynEdit::linesCleared);
mLines->connect(mLines.get(), &SynEditStringList::deleted, this, &SynEdit::linesDeleted);
mLines->connect(mLines.get(), &SynEditStringList::inserted, this, &SynEdit::linesInserted);
mLines->connect(mLines.get(), &SynEditStringList::putted, this, &SynEdit::linesPutted);
mLines->connect(mLines.get(), &SynEditStringList::changed, this, &SynEdit::onLinesChanged);
mLines->connect(mLines.get(), &SynEditStringList::changing, this, &SynEdit::onLinesChanging);
mLines->connect(mLines.get(), &SynEditStringList::cleared, this, &SynEdit::onLinesCleared);
mLines->connect(mLines.get(), &SynEditStringList::deleted, this, &SynEdit::onLinesDeleted);
mLines->connect(mLines.get(), &SynEditStringList::inserted, this, &SynEdit::onLinesInserted);
mLines->connect(mLines.get(), &SynEditStringList::putted, this, &SynEdit::onLinesPutted);
#ifdef Q_OS_WIN
mFontDummy = QFont("Consolas",12);
@ -46,10 +46,10 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
setFont(mFontDummy);
mUndoList = std::make_shared<SynEditUndoList>();
mUndoList->connect(mUndoList.get(), &SynEditUndoList::addedUndo, this, &SynEdit::undoAdded);
mUndoList->connect(mUndoList.get(), &SynEditUndoList::addedUndo, this, &SynEdit::onUndoAdded);
mOrigUndoList = mUndoList;
mRedoList = std::make_shared<SynEditUndoList>();
mRedoList->connect(mRedoList.get(), &SynEditUndoList::addedUndo, this, &SynEdit::redoAdded);
mRedoList->connect(mRedoList.get(), &SynEditUndoList::addedUndo, this, &SynEdit::onRedoAdded);
mOrigRedoList = mRedoList;
mCaretColor = QColorConstants::Red;
@ -57,12 +57,12 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
mSelectedBackground = palette().color(QPalette::Highlight);
mSelectedForeground = palette().color(QPalette::HighlightedText);
mBookMarkOpt.connect(&mBookMarkOpt, &SynBookMarkOpt::changed, this, &SynEdit::bookMarkOptionsChanged);
mBookMarkOpt.connect(&mBookMarkOpt, &SynBookMarkOpt::changed, this, &SynEdit::onBookMarkOptionsChanged);
// fRightEdge has to be set before FontChanged is called for the first time
mRightEdge = 80;
mGutter.setRightOffset(21);
mGutter.connect(&mGutter, &SynGutter::changed, this, &SynEdit::gutterChanged);
mGutter.connect(&mGutter, &SynGutter::changed, this, &SynEdit::onGutterChanged);
mGutterWidth = mGutter.realGutterWidth(charWidth());
//ControlStyle := ControlStyle + [csOpaque, csSetCaption, csNeedsBorderPaint];
//Height := 150;
@ -111,7 +111,7 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
mScrollTimer = new QTimer(this);
mScrollTimer->setInterval(100);
connect(mScrollTimer, &QTimer::timeout,this, &SynEdit::scrollTimerHandler);
connect(mScrollTimer, &QTimer::timeout,this, &SynEdit::onScrollTimeout);
mScrollHintColor = QColorConstants::Yellow;
mScrollHintFormat = SynScrollHintFormat::shfTopLineOnly;
@ -127,9 +127,9 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
showCaret();
connect(horizontalScrollBar(),&QScrollBar::valueChanged,
this, &SynEdit::doScrolled);
this, &SynEdit::onScrolled);
connect(verticalScrollBar(),&QScrollBar::valueChanged,
this, &SynEdit::doScrolled);
this, &SynEdit::onScrolled);
//enable input method
setAttribute(Qt::WA_InputMethodEnabled);
@ -1535,7 +1535,7 @@ void SynEdit::doDeleteLastChar()
internalSetCaretY(mCaretY - 1);
internalSetCaretX(mLines->getString(mCaretY - 1).length() + 1);
mLines->deleteAt(mCaretY);
DoLinesDeleted(mCaretY+1, 1);
doLinesDeleted(mCaretY+1, 1);
if (mOptions.testFlag(eoTrimTrailingSpaces))
Temp = TrimRight(Temp);
setLineText(lineText() + Temp);
@ -1629,9 +1629,9 @@ void SynEdit::doDeleteCurrentChar()
helper = lineBreak();
mLines->deleteAt(mCaretY);
if (mCaretX==1)
DoLinesDeleted(mCaretY, 1);
doLinesDeleted(mCaretY, 1);
else
DoLinesDeleted(mCaretY + 1, 1);
doLinesDeleted(mCaretY + 1, 1);
}
}
if ((Caret.Char != mCaretX) || (Caret.Line != mCaretY)) {
@ -1697,7 +1697,7 @@ void SynEdit::doDeleteLine()
BufferCoord{1, mCaretY},
BufferCoord{helper.length() + 1, mCaretY},
helper, SynSelectionMode::smNormal);
DoLinesDeleted(mCaretY, 1);
doLinesDeleted(mCaretY, 1);
}
internalSetCaretXY(BufferCoord{1, mCaretY}); // like seen in the Delphi editor
doOnPaintTransient(SynTransientType::ttAfter);
@ -1709,7 +1709,7 @@ void SynEdit::doDuplicateLine()
if (!mReadOnly && (mLines->count() > 0)) {
doOnPaintTransient(SynTransientType::ttBefore);
mLines->Insert(mCaretY, lineText());
DoLinesInserted(mCaretY + 1, 1);
doLinesInserted(mCaretY + 1, 1);
mUndoList->AddChange(SynChangeReason::crLineBreak,
caretXY(), caretXY(), "", SynSelectionMode::smNormal);
internalSetCaretXY(BufferCoord{1, mCaretY}); // like seen in the Delphi editor
@ -1729,11 +1729,11 @@ void SynEdit::doMoveSelUp()
// Delete line above selection
QString s = mLines->getString(OrigBlockBegin.Line - 2); // before start, 0 based
mLines->deleteAt(OrigBlockBegin.Line - 2); // before start, 0 based
DoLinesDeleted(OrigBlockBegin.Line - 1, 1); // before start, 1 based
doLinesDeleted(OrigBlockBegin.Line - 1, 1); // before start, 1 based
// Insert line below selection
mLines->Insert(OrigBlockEnd.Line - 1, s);
DoLinesInserted(OrigBlockEnd.Line, 1);
doLinesInserted(OrigBlockEnd.Line, 1);
// Restore caret and selection
setCaretAndSelection(
@ -1775,11 +1775,11 @@ void SynEdit::doMoveSelDown()
// Delete line below selection
QString s = mLines->getString(OrigBlockEnd.Line); // after end, 0 based
mLines->deleteAt(OrigBlockEnd.Line); // after end, 0 based
DoLinesDeleted(OrigBlockEnd.Line, 1); // before start, 1 based
doLinesDeleted(OrigBlockEnd.Line, 1); // before start, 1 based
// Insert line above selection
mLines->Insert(OrigBlockBegin.Line - 1, s);
DoLinesInserted(OrigBlockBegin.Line, 1);
doLinesInserted(OrigBlockBegin.Line, 1);
// Restore caret and selection
setCaretAndSelection(
@ -1954,7 +1954,7 @@ void SynEdit::insertLine(bool moveCaret)
internalSetCaretXY(BufferCoord{1, mCaretY + 1});
}
}
DoLinesInserted(mCaretY - InsDelta, nLinesInserted);
doLinesInserted(mCaretY - InsDelta, nLinesInserted);
setBlockBegin(caretXY());
setBlockEnd(caretXY());
ensureCursorPosVisible();
@ -2483,7 +2483,7 @@ QRect SynEdit::clientRect()
void SynEdit::synFontChanged()
{
recalcCharExtent();
sizeOrFontChanged(true);
onSizeOrFontChanged(true);
}
void SynEdit::doOnPaintTransient(SynTransientType TransientType)
@ -3210,7 +3210,7 @@ SynEditorCommand SynEdit::TranslateKeyCode(int key, Qt::KeyboardModifiers modifi
return cmd;
}
void SynEdit::sizeOrFontChanged(bool bFont)
void SynEdit::onSizeOrFontChanged(bool bFont)
{
if (mCharWidth != 0) {
@ -3218,7 +3218,7 @@ void SynEdit::sizeOrFontChanged(bool bFont)
mLinesInWindow = clientHeight() / mTextHeight;
if (bFont) {
if (mGutter.showLineNumbers())
gutterChanged();
onGutterChanged();
else
updateScrollbars();
mStateFlags.setFlag(SynStateFlag::sfCaretChanged,false);
@ -3233,12 +3233,12 @@ void SynEdit::sizeOrFontChanged(bool bFont)
}
}
void SynEdit::doChange()
void SynEdit::onChanged()
{
emit Changed();
}
void SynEdit::doScrolled(int)
void SynEdit::onScrolled(int)
{
mLeftChar = horizontalScrollBar()->value();
mTopLine = verticalScrollBar()->value();
@ -3583,7 +3583,7 @@ void SynEdit::doUndoItem()
TmpStr = TmpStr + QString(mCaretX - 1 - TmpStr.length(), ' ');
ProperSetLine(mCaretY - 1, TmpStr + Item->changeStr());
mLines->deleteAt(mCaretY);
DoLinesDeleted(mCaretY, 1);
doLinesDeleted(mCaretY, 1);
}
mRedoList->AddChange(
Item->changeReason(),
@ -4002,7 +4002,7 @@ void SynEdit::setHighlighter(const PSynHighlighter &highlighter)
});
scanRanges();
}
sizeOrFontChanged(true);
onSizeOrFontChanged(true);
invalidate();
}
@ -4377,8 +4377,9 @@ int SynEdit::searchReplace(const QString &sSearch, const QString &sReplace, SynS
return result;
}
void SynEdit::DoLinesDeleted(int , int )
void SynEdit::doLinesDeleted(int firstLine, int count)
{
emit linesDeleted(firstLine, count);
// // gutter marks
// for i := 0 to Marks.Count - 1 do begin
// if Marks[i].Line >= FirstLine + Count then
@ -4393,8 +4394,9 @@ void SynEdit::DoLinesDeleted(int , int )
// end;
}
void SynEdit::DoLinesInserted(int , int )
void SynEdit::doLinesInserted(int firstLine, int count)
{
emit linesInserted(firstLine, count);
// // gutter marks
// for i := 0 to Marks.Count - 1 do begin
// if Marks[i].Line >= FirstLine then
@ -4471,7 +4473,7 @@ void SynEdit::DeleteSelection(const BufferCoord &BB, const BufferCoord &BE)
}
// Update marks
if (UpdateMarks)
DoLinesDeleted(BB.Line, BE.Line - BB.Line + MarkOffset);
doLinesDeleted(BB.Line, BE.Line - BB.Line + MarkOffset);
}
void SynEdit::InsertText(const QString &Value, SynSelectionMode PasteMode,bool AddToUndoList)
@ -4499,7 +4501,7 @@ void SynEdit::InsertText(const QString &Value, SynSelectionMode PasteMode,bool A
if (InsertedLines > 0) {
if ((PasteMode == SynSelectionMode::smNormal) && (StartCol > 1))
StartLine++;
DoLinesInserted(StartLine, InsertedLines);
doLinesInserted(StartLine, InsertedLines);
}
ensureCursorPosVisible();
}
@ -5239,7 +5241,7 @@ void SynEdit::resizeEvent(QResizeEvent *)
mContentImage = image;
sizeOrFontChanged(false);
onSizeOrFontChanged(false);
}
void SynEdit::timerEvent(QTimerEvent *event)
@ -5510,7 +5512,7 @@ void SynEdit::setGutterWidth(int Value)
Value = std::max(Value, 0);
if (mGutterWidth != Value) {
mGutterWidth = Value;
sizeOrFontChanged(false);
onSizeOrFontChanged(false);
invalidate();
}
}
@ -5525,12 +5527,12 @@ int SynEdit::charsInWindow() const
return mCharsInWindow;
}
void SynEdit::bookMarkOptionsChanged()
void SynEdit::onBookMarkOptionsChanged()
{
invalidateGutter();
}
void SynEdit::linesChanged()
void SynEdit::onLinesChanged()
{
SynSelectionMode vOldMode;
mStateFlags.setFlag(SynStateFlag::sfLinesChanging, false);
@ -5553,12 +5555,12 @@ void SynEdit::linesChanged()
setTopLine(mTopLine);
}
void SynEdit::linesChanging()
void SynEdit::onLinesChanging()
{
mStateFlags.setFlag(SynStateFlag::sfLinesChanging);
}
void SynEdit::linesCleared()
void SynEdit::onLinesCleared()
{
if (mUseCodeFolding)
foldOnListCleared();
@ -5574,7 +5576,7 @@ void SynEdit::linesCleared()
mStatusChanges.setFlag(SynStatusChange::scAll);
}
void SynEdit::linesDeleted(int index, int count)
void SynEdit::onLinesDeleted(int index, int count)
{
if (mUseCodeFolding)
foldOnListDeleted(index + 1, count);
@ -5584,7 +5586,7 @@ void SynEdit::linesDeleted(int index, int count)
invalidateGutterLines(index + 1, INT_MAX);
}
void SynEdit::linesInserted(int index, int count)
void SynEdit::onLinesInserted(int index, int count)
{
if (mUseCodeFolding)
foldOnListInserted(index + 1, count);
@ -5599,7 +5601,7 @@ void SynEdit::linesInserted(int index, int count)
invalidateGutterLines(index + 1, INT_MAX);
}
void SynEdit::linesPutted(int index, int)
void SynEdit::onLinesPutted(int index, int)
{
int vEndLine = index + 1;
if (mHighlighter) {
@ -5612,7 +5614,7 @@ void SynEdit::linesPutted(int index, int)
invalidateLines(index + 1, vEndLine);
}
void SynEdit::undoAdded()
void SynEdit::onUndoAdded()
{
updateModifiedStatus();
@ -5622,7 +5624,7 @@ void SynEdit::undoAdded()
mUndoList->PeekItem() && (mUndoList->PeekItem()->changeReason()!=SynChangeReason::crGroupBreak))
mRedoList->Clear();
if (mUndoList->blockCount() == 0 )
doChange();
onChanged();
}
SynSelectionMode SynEdit::activeSelectionMode() const
@ -5816,15 +5818,15 @@ void SynEdit::setTopLine(int Value)
}
}
void SynEdit::redoAdded()
void SynEdit::onRedoAdded()
{
updateModifiedStatus();
if (mRedoList->blockCount() == 0 )
doChange();
onChanged();
}
void SynEdit::gutterChanged()
void SynEdit::onGutterChanged()
{
if (mGutter.showLineNumbers() && mGutter.autoSize())
mGutter.autoSizeDigitCount(mLines->count());
@ -5841,7 +5843,7 @@ void SynEdit::gutterChanged()
setGutterWidth(nW);
}
void SynEdit::scrollTimerHandler()
void SynEdit::onScrollTimeout()
{
QPoint iMousePos;
DisplayCoord C;

View File

@ -342,6 +342,9 @@ public:
void setSelectedBackground(const QColor &newSelectedBackground);
signals:
void linesDeleted(int FirstLine, int Count);
void linesInserted(int FirstLine, int Count);
void Changed();
void ChainUndoAdded();
@ -455,8 +458,8 @@ private:
void SetSelTextPrimitive(const QString& aValue);
void SetSelTextPrimitiveEx(SynSelectionMode PasteMode,
const QString& Value, bool AddToUndoList);
void DoLinesDeleted(int FirstLine, int Count);
void DoLinesInserted(int FirstLine, int Count);
void doLinesDeleted(int FirstLine, int Count);
void doLinesInserted(int FirstLine, int Count);
void ProperSetLine(int ALine, const QString& ALineText);
void DeleteSelection(const BufferCoord& BB, const BufferCoord& BE);
void InsertText(const QString& Value, SynSelectionMode PasteMode,bool AddToUndoList);
@ -510,20 +513,20 @@ private:
private slots:
void bookMarkOptionsChanged();
void gutterChanged();
void linesChanged();
void linesChanging();
void linesCleared();
void linesDeleted(int index, int count);
void linesInserted(int index, int count);
void linesPutted(int index, int count);
void redoAdded();
void scrollTimerHandler();
void undoAdded();
void sizeOrFontChanged(bool bFont);
void doChange();
void doScrolled(int value);
void onBookMarkOptionsChanged();
void onGutterChanged();
void onLinesChanged();
void onLinesChanging();
void onLinesCleared();
void onLinesDeleted(int index, int count);
void onLinesInserted(int index, int count);
void onLinesPutted(int index, int count);
void onRedoAdded();
void onScrollTimeout();
void onUndoAdded();
void onSizeOrFontChanged(bool bFont);
void onChanged();
void onScrolled(int value);
private:
std::shared_ptr<QImage> mContentImage;

View File

@ -360,12 +360,16 @@ void SynEditStringList::deleteAt(int Index)
QString SynEditStringList::getTextStr()
{
QString Result;
for (PSynEditStringRec& line:mList) {
Result.append(line->fString);
Result.append(lineBreak());
QString result;
for (int i=0;i<mList.count()-1;i++) {
const PSynEditStringRec& line = mList[i];
result.append(line->fString);
result.append(lineBreak());
}
return Result;
if (mList.length()>0) {
result.append(mList.back()->fString);
}
return result;
}
void SynEditStringList::putString(int Index, const QString &s) {

View File

@ -71,7 +71,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>7</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">