diff --git a/README.md b/README.md index 89137aa..a3c15e1 100755 --- a/README.md +++ b/README.md @@ -14,10 +14,7 @@ 最新版本下载地址:https://gitee.com/cxasm/notepad--/releases/tag/v1.21 -Arch Linux 及其衍生版可以通过 AUR 仓库安装:[notepad---git](https://aur.archlinux.org/packages/notepad---git) -``` -yay -S notepad---git -``` +最新开发版本下载地址:https://gitee.com/cxasm/notepad--/releases/tag/v1.22 NDD已初步推出插件编写功能,希望广大的CPP/QT开发者加入我们,插件功能均可以留上您的大名和捐赠渠道,希望 开发者参与插件功能开发。 @@ -36,6 +33,11 @@ NDD已初步推出插件编写功能,希望广大的CPP/QT开发者加入我 代码上线不久,删除了商业的对比功能和注册功能(这部分有商业原因,请理解),除此以外,所有功能全部保留。 +4)Arch Linux 及其衍生版可以通过 AUR 仓库安装:[notepad---git](https://aur.archlinux.org/packages/notepad---git) +``` +yay -S notepad---git +``` + ![输入图片说明](png/20221107_160824.png) ![输入图片说明](png/6.png) diff --git a/changelog.txt b/changelog.txt index f849442..8a713b8 100755 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,18 @@ +Ndd V1.22 预发布 20230202 +1 提供大文本、超大文本打开两种方式;并尽量显示行号。 +2 增加ASM语言的语法高亮;增加shell语法高亮。 +3 大文本打开时,显示行号。 +4 BUG: 超大文本打开乱码。 +5 批量查找窗口大小记住恢复。 +6 块注释崩溃。 +7 替换ctrl+h 自动填充选中内容,查找替换切换自动带过去关键字。 +8 查找结果框,可以放大缩小,避免看不清楚;完善配色。 +9 第一次安装后,新建NEW文件,下次打开无法自动恢复的问题。 +10 win10下面管理员授权打开文件后,旧文件修改跟随到新打开窗口 +11 解决一些列小bug等。 +12 提供ARCH LINUX的构建版本等。 + + Ndd V1.21 预发布 20230107 1 支持主题的修改,完善八种新主题 2 初步支持插件开发 diff --git a/src/CmpareMode.cpp b/src/CmpareMode.cpp index b8fb335..ae8a250 100755 --- a/src/CmpareMode.cpp +++ b/src/CmpareMode.cpp @@ -2,6 +2,7 @@ #include "Encode.h" #include "rcglobal.h" + #include #include #include @@ -87,12 +88,22 @@ bool CmpareMode::recognizeTextCode(QByteArray & text, LineFileInfo &lineInfo, QS return result; } - -CODE_ID CmpareMode::getTextFileEncodeType(uchar* fileFpr, int fileLength, QString filePath) +//LE编码要特殊对待。 +bool CmpareMode::isUnicodeLeBomFile(uchar* fileFpr, int fileLength) { - if (fileLength >= 2 && fileFpr[0] == 0xFF && fileFpr[1] == 0xFE) { + return true; + } + return false; +} +//isCheckHead:是否检测头。只有文件开头,才有。如果是分块加载,中间打开的文件,则不需要检测。默认检测 +CODE_ID CmpareMode::getTextFileEncodeType(uchar* fileFpr, int fileLength, QString filePath, bool isCheckHead) +{ + if (isCheckHead) + { + if (fileLength >= 2 && fileFpr[0] == 0xFF && fileFpr[1] == 0xFE) + { return CODE_ID::UNICODE_LE; //skip 2 } else if (fileLength >= 2 && fileFpr[0] == 0xFE && fileFpr[1] == 0xFF) @@ -103,7 +114,7 @@ CODE_ID CmpareMode::getTextFileEncodeType(uchar* fileFpr, int fileLength, QStrin { return CODE_ID::UTF8_BOM; //skip 3 with BOM } - + } //走到这里说明没有文件头BOM,进行全盘文件扫描 if (!filePath.isEmpty()) { @@ -113,6 +124,83 @@ CODE_ID CmpareMode::getTextFileEncodeType(uchar* fileFpr, int fileLength, QStrin return CODE_ID::UNKOWN; } +//20230201新增:把Unicode_LE的字节流,转换为QString 发现如果是CODE_ID::UNICODE_LE,\r\n变成了\r\0\n\0,读取readLine遇到\n就结束了,而且toUnicode也会变成乱码失败 +//所以UNICODE_LE需要单独处理。该函数只处理Unicode_LE编码文件,事先一定要检查文件编码 +//返回字符数,不是编码类型,注意是字符数,不是bytes + +//这里有个问题,当初读取文件分块是,是无条件读取到\n就结束,则可能最后不是\n\0,而是\n。这种情况要特殊处理。标记为A。 +//是否跳过前面的LE头。默认不跳过。只有文件块开头第一块,才需要跳过。 +bool CmpareMode::tranUnicodeLeToUtf8Bytes(uchar* fileFpr, const int fileLength, QString &outUtf8Bytes, bool isSkipHead) +{ + int lineNums = 0; + CODE_ID code = CODE_ID::UNICODE_LE; + + int lineStartPos = (isSkipHead ? 2:0); //uicode_le前面有2个特殊标识,故跳过2 + + //获取一行在文件中 + auto getOneLineFromFile = [fileFpr](int& startPos, const int fileLength, QByteArray& ret)->bool { + + if (startPos < fileLength) + { + ret.clear(); + + int lineLens = 0; + + bool isFindLine = false; + + for (int i = startPos; i < fileLength; ++i, ++lineLens) + { + //遇到换行符号 + if (fileFpr[i] == 0x0A) + { + //lineLens需要加2,因为当前这个没有加,而且后面还有一个\0,这是le格式规定的。 + //特殊对待A。如果后续还要一个\0,及长度足够,则+2,否则只能加1 + if (startPos + lineLens + 2 < fileLength) + { + ret.append((char*)(fileFpr + startPos), lineLens + 2); + startPos += lineLens + 2; + } + else + { + //这里就是特殊情况,尾部后面没有\0,只能前进1个。 + ret.append((char*)(fileFpr + startPos), lineLens + 1); + //必须手动补上一个\0。避免格式残缺 + ret.append('\0'); + startPos += lineLens + 1; + } + isFindLine = true; + break; + } + } + + //没有找到一行 + if (!isFindLine) + { + //最后一行,可能没有带\r\0直接返回 + ret.append((char*)(fileFpr + startPos), fileLength - startPos); + + startPos = fileLength; + } + + return true; + + } + + return false; + }; + + QByteArray line; + + QByteArray tempUtf8Bytes; + tempUtf8Bytes.reserve(fileLength+1); + + while (getOneLineFromFile(lineStartPos, fileLength, line)) { + tempUtf8Bytes.append(line); + } + + return Encode::tranStrToUNICODE(code, tempUtf8Bytes.data(), tempUtf8Bytes.count(), outUtf8Bytes); +} + //20210802:发现如果是CODE_ID::UNICODE_LE,\r\n变成了\r\0\n\0,读取readLine遇到\n就结束了,而且toUnicode也会变成乱码失败 //所以UNICODE_LE需要单独处理。该函数只处理Unicode_LE编码文件,事先一定要检查文件编码 //返回字符数,不是编码类型,注意是字符数,不是bytes @@ -141,9 +229,21 @@ quint32 CmpareMode::readLineFromFileWithUnicodeLe(uchar* m_fileFpr, const int fi //遇到换行符号 if (m_fileFpr[i] == 0x0A) { + if (startPos + lineLens + 2 < fileLength) + { //lineLens需要加2,因为当前这个没有加,而且后面还有一个\0,这是le格式规定的 ret.append((char*)(m_fileFpr + startPos), lineLens + 2); startPos += lineLens + 2; + } + else + { + //这里就是特殊情况,尾部后面没有\0,只能前进1个。 + //其实是容错,可能最后一个没有\0 + ret.append((char*)(m_fileFpr + startPos), lineLens + 1); + //必须手动补上一个\0。避免格式残缺 + ret.append('\0'); + startPos += lineLens + 1; + } isFindLine = true; break; } @@ -952,7 +1052,8 @@ CODE_ID CmpareMode::scanFileRealCode(QString filePath) ++lineNums; - if (lineNums >= 1000) + //最多扫描200行,加块速度。速度与精确性的权衡 + if (lineNums >= 200) { break; } diff --git a/src/CmpareMode.h b/src/CmpareMode.h index 836311f..d150c0d 100755 --- a/src/CmpareMode.h +++ b/src/CmpareMode.h @@ -73,18 +73,12 @@ public: static CODE_ID scanFileRealCode(QString filePath); static CODE_ID scanFileOutPut(CODE_ID code, QString filePath, QList& outputLineInfoVec, int & maxLineSize, int & charsNums, bool &isHexFile); - - inline QList* getLeftLineInfo(); - inline QList* getRightLineInfo(); - - - void getLines(RC_DIRECTION direction, QList& lines); - void getLinesExternInfo(QList*& leftExternBlockInfo, QList*& rightExternBlockInfo); - + static CODE_ID getTextFileEncodeType(uchar* fileFpr, int fileLength, QString filePath="", bool isCheckHead = true); + static bool tranUnicodeLeToUtf8Bytes(uchar* fileFpr, const int fileLength, QString& outUtf8Bytes, bool isSkipHead=false); + static bool isUnicodeLeBomFile(uchar* fileFpr, int fileLength); private: static bool recognizeTextCode(QByteArray & text, LineFileInfo & lineInfo, QString & outUnicodeText); - static CODE_ID getTextFileEncodeType(uchar* fileFpr, int fileLength, QString filePath); quint32 static readLineFromFileWithUnicodeLe(uchar* m_fileFpr, const int fileLength, QList& lineInfoVec, QList& blankLineInfoVec,int mode, int &maxLineSize); diff --git a/src/RealCompare.rc b/src/RealCompare.rc index dfe696a..6a8f8d3 100755 Binary files a/src/RealCompare.rc and b/src/RealCompare.rc differ diff --git a/src/RealCompare.vcxproj b/src/RealCompare.vcxproj deleted file mode 100755 index abe6aa6..0000000 --- a/src/RealCompare.vcxproj +++ /dev/null @@ -1,1195 +0,0 @@ - - - - - Release - x64 - - - Debug - x64 - - - - {26BC87D0-189B-3661-B87D-347CF9E0A47F} - Notepad-- - QtVS_v304 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - v141 - x64\Debug\ - false - NotSet - Application - release\ - Notepad-- - - - v141 - x64\Debug\ - false - NotSet - Application - debug\ - Notepad-- - - - - - - - - - - x64\Debug\debug\Notepad--truex64\Debug\release\Notepad--truefalse5.12.10_msvc2017_64core;network;gui;xmlpatterns;widgets;concurrent5.12.10_msvc2017_64core;network;gui;xmlpatterns;widgets;concurrent - - - - GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;qscint\src;qscint\src\Qsci;qscint\scintilla\include;cceditor;./x64/Release;release;/include;%(AdditionalIncludeDirectories) - -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions) - release\ - false - None - 4577;4467;%(DisableSpecificWarnings) - Sync - release\ - MaxSpeed - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions) - false - - MultiThreadedDLL - true - true - Level3 - true - - qmyedit_qt5d.lib;shell32.lib;%(AdditionalDependencies) - x64\Debug;C:\openssl\lib;C:\Utils\my_sql\mysql-5.6.11-winx64\lib;C:\Utils\postgresql\pgsql\lib;%(AdditionalLibraryDirectories) - "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" %(AdditionalOptions) - true - false - true - false - $(OutDir)\Notepad--.exe - true - Windows - true - - - Unsigned - None - 0 - - - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_NO_DEBUG;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CONCURRENT_LIB;QT_XMLPATTERNS_LIB;QT_NETWORK_LIB;QT_CORE_LIB;%(PreprocessorDefinitions) - - msvc./$(Configuration)/moc_predefs.hMoc'ing %(Identity)...output$(Configuration)moc_%(Filename).cppRealComparedefaultRcc'ing %(Identity)...$(Configuration)qrc_%(Filename).cppUic'ing %(Identity)...$(ProjectDir)ui_%(Filename).h - - - GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;qscint\src;qscint\src\Qsci;qscint\scintilla\include;cceditor;./x64/Release;debug;/include;%(AdditionalIncludeDirectories) - -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions) - debug\ - false - ProgramDatabase - 4577;4467;%(DisableSpecificWarnings) - Sync - debug\ - Disabled - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;%(PreprocessorDefinitions) - false - MultiThreadedDebugDLL - true - true - Level3 - true - - qmyedit_qt5d.lib;shell32.lib;%(AdditionalDependencies) - x64\Debug;C:\openssl\lib;C:\Utils\my_sql\mysql-5.6.11-winx64\lib;C:\Utils\postgresql\pgsql\lib;%(AdditionalLibraryDirectories) - "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" %(AdditionalOptions) - true - true - true - $(OutDir)\Notepad--.exe - true - Windows - true - - - Unsigned - None - 0 - - - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CONCURRENT_LIB;QT_XMLPATTERNS_LIB;QT_NETWORK_LIB;QT_CORE_LIB;_DEBUG;%(PreprocessorDefinitions) - - msvc./$(Configuration)/moc_predefs.hMoc'ing %(Identity)...output$(Configuration)moc_%(Filename).cppRealComparedefaultRcc'ing %(Identity)...$(Configuration)qrc_%(Filename).cppUic'ing %(Identity)...$(ProjectDir)ui_%(Filename).h - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Document - true - $(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs) - cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -Zi -MDd -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >debug\moc_predefs.h - Generate moc_predefs.h - debug\moc_predefs.h;%(Outputs) - - - Document - $(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs) - cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >release\moc_predefs.h - Generate moc_predefs.h - release\moc_predefs.h;%(Outputs) - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/RealCompare.vcxproj.filters b/src/RealCompare.vcxproj.filters deleted file mode 100755 index e534af7..0000000 --- a/src/RealCompare.vcxproj.filters +++ /dev/null @@ -1,1039 +0,0 @@ - - - - - {99349809-55BA-4b9d-BF79-8FDBB0286EB3} - ui - false - - - {99349809-55BA-4b9d-BF79-8FDBB0286EB3} - ui - false - - - {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} - cpp;c;cxx;moc;h;def;odl;idl;res; - - - {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} - cpp;c;cxx;moc;h;def;odl;idl;res; - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} - qrc;* - false - - - {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} - qrc;* - false - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {639EADAA-A684-42e4-A9AD-28FC9BCB8F7C} - ts;xlf - false - - - {639EADAA-A684-42e4-A9AD-28FC9BCB8F7C} - ts;xlf - false - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Generated Files - - - Generated Files - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Translation Files - - - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - - - - \ No newline at end of file diff --git a/src/RealCompare.vcxproj.user b/src/RealCompare.vcxproj.user deleted file mode 100755 index 5761481..0000000 --- a/src/RealCompare.vcxproj.user +++ /dev/null @@ -1,10 +0,0 @@ - - - - - 2023-01-07T07:01:11.4235283Z - - - 2023-01-07T07:01:11.5050188Z - - \ No newline at end of file diff --git a/src/batchfindreplace.cpp b/src/batchfindreplace.cpp index cb071c3..0a49e15 100755 --- a/src/batchfindreplace.cpp +++ b/src/batchfindreplace.cpp @@ -2,6 +2,7 @@ #include "scintillaeditview.h" #include "ccnotepad.h" #include "progresswin.h" +#include "nddsetting.h" #include #include @@ -15,7 +16,15 @@ BatchFindReplace::BatchFindReplace(QWidget *parent) } BatchFindReplace::~BatchFindReplace() -{} +{ + +} + +void BatchFindReplace::closeEvent(QCloseEvent* event) +{ + QByteArray curGeo = this->saveGeometry(); + NddSetting::updataWinPos(BATCH_FIND_REPLACE_POS, curGeo); +} void BatchFindReplace::setTabWidget(QTabWidget* editTabWidget) { diff --git a/src/batchfindreplace.h b/src/batchfindreplace.h index 740209d..7ae86f9 100755 --- a/src/batchfindreplace.h +++ b/src/batchfindreplace.h @@ -2,6 +2,7 @@ #include #include +#include #include "ui_batchfindreplace.h" class CCNotePad; @@ -15,6 +16,9 @@ public: virtual ~BatchFindReplace(); void setTabWidget(QTabWidget* editTabWidget); +protected: + void closeEvent(QCloseEvent* event); + private slots: void on_freshBtClick(); void on_findBtClick(); diff --git a/src/bigfilemessage.cpp b/src/bigfilemessage.cpp index 1537e4d..247d876 100755 --- a/src/bigfilemessage.cpp +++ b/src/bigfilemessage.cpp @@ -9,6 +9,28 @@ BigFileMessage::BigFileMessage(QWidget *parent) BigFileMessage::~BigFileMessage() {} +void BigFileMessage::setDefOpenMode(NddDocType defMode) +{ + switch (defMode) + { + case TXT_TYPE: + ui.textMode->setChecked(true); + break; + case BIG_TEXT_RO_TYPE: + ui.bigTextMode->setChecked(true); + break; + case BIG_EDIT_RW_TYPE: + break; + case SUPER_BIG_TEXT_RO_TYPE: + ui.superBigTextMode->setChecked(true); + break; + case HEX_TYPE: + ui.hexMode->setChecked(true); + break; + default: + break; + } +} void BigFileMessage::setTip(QString msg) { @@ -19,15 +41,19 @@ void BigFileMessage::slot_okBt() { if (ui.textMode->isChecked()) { - m_result = 0; + m_result = TXT_TYPE;//普通文本 } else if(ui.bigTextMode->isChecked()) { - m_result = 1; + m_result = BIG_TEXT_RO_TYPE; //小于8G的大文本 + } + else if (ui.superBigTextMode->isChecked()) + { + m_result = SUPER_BIG_TEXT_RO_TYPE;//8G以上的大文本 } else if (ui.hexMode->isChecked()) { - m_result = 2; + m_result = HEX_TYPE;//二进制 } done(m_result); } @@ -36,4 +62,4 @@ void BigFileMessage::slot_cancelBt() { m_result = -1; done(m_result); -} \ No newline at end of file +} diff --git a/src/bigfilemessage.h b/src/bigfilemessage.h index d036bd4..a66a162 100755 --- a/src/bigfilemessage.h +++ b/src/bigfilemessage.h @@ -1,4 +1,5 @@ #pragma once +#include "ccnotepad.h" #include #include @@ -12,6 +13,7 @@ public: BigFileMessage(QWidget *parent = nullptr); ~BigFileMessage(); void setTip(QString msg); + void setDefOpenMode(NddDocType defMode); private slots: void slot_okBt(); diff --git a/src/bigfilemessage.ui b/src/bigfilemessage.ui index f914b24..c3514c6 100755 --- a/src/bigfilemessage.ui +++ b/src/bigfilemessage.ui @@ -6,8 +6,8 @@ 0 0 - 509 - 203 + 770 + 195 @@ -39,6 +39,34 @@ Open Mode + + + + Big Text File(< 8G) Read only open, load in blocks, and turn pages manually. + + + + + + + Hex Bin + + + + + + + Super Big Text Edit + + + + + + + Binary Open,load in blocks, and turn pages manually. + + + @@ -46,7 +74,7 @@ - + Open directly in text mode.May be slow, Need wait. @@ -63,24 +91,10 @@ - - + + - Read only open, load in blocks, and turn pages manually. - - - - - - - Hex Bin - - - - - - - Binary Open,load in blocks, and turn pages manually. + Super big Text File(> 8G bits) Read only open, load in blocks, and turn pages manually. diff --git a/src/cceditor/ccnotepad.cpp b/src/cceditor/ccnotepad.cpp index 1f04879..76b895a 100755 --- a/src/cceditor/ccnotepad.cpp +++ b/src/cceditor/ccnotepad.cpp @@ -22,9 +22,15 @@ #include "filelistview.h" #include "bigfilemessage.h" #include "batchfindreplace.h" +#include "langextset.h" +#include "shortcutkeymgr.h" +#include "CmpareMode.h" + +#ifdef NO_PLUGIN #include "pluginmgr.h" #include "plugin.h" #include "pluginGl.h" +#endif #include @@ -63,6 +69,8 @@ #include #include #endif +#include + #ifdef Q_OS_WIN extern bool s_isAdminAuth; @@ -132,7 +140,13 @@ const QString OpenAttrToString(OpenAttr openType) ret = QObject::tr("Hex ReadOnly Mode"); break; case BigTextReadOnly: - ret = QObject::tr("Bit Text ReadOnly Mode"); + ret = QObject::tr("Big Text ReadOnly Mode"); + break; + case BigTextReadWrite: + ret = QObject::tr("Big Text ReadWrite Mode"); + break; + case SuperBigTextReadOnly: + ret = QObject::tr("Super Big Text ReadOnly Mode"); break; case TextReadOnly: ret = QObject::tr("Text ReadOnly Mode"); @@ -217,12 +231,7 @@ QString getSwapFilePath(QString filePath) #endif } -//1 文本 2 hex -enum NddDocType { - TXT_TYPE = 1, - BIG_TEXT_TYPE, - HEX_TYPE, -}; + void setDocTypeProperty(QWidget* pwidget, NddDocType type) { @@ -434,13 +443,6 @@ int CCNotePad::s_hightWebAddr = 0; //lexerName to index -struct FileExtLexer -{ - QString ext; - LangType id; -}; - -const int FileExtMapLexerIdLen = L_EXTERNAL; //这里是静态的默认文件后缀类型与词法类型。还有一个动态的,用来管理用户新增语言的部分 FileExtLexer s_fileExtMapLexerId[FileExtMapLexerIdLen] = { @@ -482,6 +484,26 @@ FileExtLexer s_fileExtMapLexerId[FileExtMapLexerIdLen] = { {QString("NULL"), L_EXTERNAL}, }; +RC_LINE_FORM getLineEndTypeFromBigText(QString& text) +{ + for (int i = 0, s = text.size(); i < s; ++i) + { + if (text.at(i) == '\n' && ((i > 1) && text.at(i - 1) == '\r')) + { + return DOS_LINE; + } + else if (text.at(i) == '\n' && ((i > 1) && text.at(i - 1) != '\r')) + { + return UNIX_LINE; + } + else if (text.at(i) == '\r' && ((i != (s - 1)) && text.at(i + 1) != '\n')) + { + return MAC_LINE; + } + } + //默认windws + return DOS_LINE; +} //根据文件的后缀来确定文件的编程语言,进而设置默认的LEXER void initFileTypeLangMap() @@ -500,7 +522,7 @@ void initFileTypeLangMap() FileExtLexer& v = s_fileExtMapLexerId[i]; //标准的定义可以忽略后面的tag,因为标准lexer的tag都是存在的。 - ExtLexerManager::getInstance()->addNewExtType(v.ext, v.id); + ExtLexerManager::getInstance()->addNewExtType(v.ext, v.id, ScintillaEditView::getTagByLexerId(v.id)); } } //在加载动态的关联部分,这部分是用户自定义的类型。这里最好不要放在多个文件,否则会慢,单独放一个文件即可。 @@ -531,6 +553,9 @@ void initFileTypeLangMap() } } } + + //最后加载用户自定义的文件后缀名和语法关联文件 + LangExtSet::loadExtRelevanceToMagr(); } } @@ -542,11 +567,18 @@ void CCNotePad::initLexerNameToIndex() int i = 0; - pNodes[i].pAct = ui.actionAVS; - pNodes[i].index = L_AVS; + //pNodes[i].pAct = ui.actionAVS; + //pNodes[i].index = L_AVS; QVariant data((int)L_AVS); - ui.actionAVS->setData(data); - m_lexerNameToIndex.insert("avs", pNodes[i]); + //ui.actionAVS->setData(data); + //m_lexerNameToIndex.insert("avs", pNodes[i]); + // ++i; + + pNodes[i].pAct = ui.actionAssembly; + pNodes[i].index = L_ASM; + data.setValue(int(L_ASM)); + ui.actionAssembly->setData(data); + m_lexerNameToIndex.insert("asm", pNodes[i]); ++i; pNodes[i].pAct = ui.actionbash; @@ -773,6 +805,14 @@ void CCNotePad::initLexerNameToIndex() ui.actionRust->setData(data); m_lexerNameToIndex.insert("rust", pNodes[i]); ++i; + + + pNodes[i].pAct = ui.actionShell; + pNodes[i].index = L_BASH; + data.setValue(int(L_BASH)); + ui.actionShell->setData(data); + m_lexerNameToIndex.insert("shell", pNodes[i]); + ++i; pNodes[i].pAct = ui.actionSpice; pNodes[i].index = L_SPICE; @@ -970,6 +1010,17 @@ int CCNotePad::runAsAdmin(const QString& filePath) } #endif +//需要临时写一些文件,保存在该目录中。目前就是管理员提权时,保存之前的文件。 +QString getGlboalTempSaveDir() +{ + //就是app/notepad/temp的目录 + QString tempFileList = QString("notepad/temp/list"); + QSettings qs(QSettings::IniFormat, QSettings::UserScope, tempFileList); + QString qsSavePath = qs.fileName(); + QFileInfo fi(qsSavePath); + return fi.dir().absolutePath(); +} + //根据文件类型给出语言id LexerInfo CCNotePad::getLangLexerIdByFileExt(QString filePath) { @@ -989,7 +1040,7 @@ LexerInfo CCNotePad::getLangLexerIdByFileExt(QString filePath) CCNotePad::CCNotePad(bool isMainWindows, QWidget *parent) : QMainWindow(parent), m_cutFile(nullptr),m_copyFile(nullptr), m_dockSelectTreeWin(nullptr), \ m_pResultWin(nullptr),m_isQuitCancel(false), m_tabRightClickMenu(nullptr), m_shareMem(nullptr),m_isMainWindows(isMainWindows),\ - m_openInNewWinAct(nullptr), m_showFileDirAct(nullptr), m_timerAutoSave(nullptr), m_curColorIndex(-1), m_fileListView(nullptr), m_isInReloadFile(false) + m_openInNewWinAct(nullptr), m_showFileDirAct(nullptr), m_timerAutoSave(nullptr), m_curColorIndex(-1), m_fileListView(nullptr), m_isInReloadFile(false), m_isToolMenuLoaded(false) { ui.setupUi(this); @@ -1243,11 +1294,209 @@ void CCNotePad::quickshow() s_hightWebAddr = 1; ui.actionShow_Web_Addr->setChecked(true); } + + //恢复用户自定义快捷键 + setUserDefShortcutKey(); +} + +void CCNotePad::setUserDefShortcutKey(int shortcutId) +{ + QKeySequence keySeq; + + switch (shortcutId) + { + case New_File_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(New_File); + if (!keySeq.isEmpty()) + { + ui.actionNewFile->setShortcut(keySeq); + } + break; + case Open_File_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Open_File); + if (!keySeq.isEmpty()) + { + ui.actionOpenFile->setShortcut(keySeq); + } + break; + case Save_File_ID: + break; + case Save_All_File_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Save_All_File); + if (!keySeq.isEmpty()) + { + ui.actionSave_as->setShortcut(keySeq); + } + break; + case Close_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Close); + if (!keySeq.isEmpty()) + { + ui.actionClose->setShortcut(keySeq); + } + break; + case Close_All_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Close_All); + if (!keySeq.isEmpty()) + { + ui.actionClose_All->setShortcut(keySeq); + } + break; + case Cut_ID: + break; + case Copy_ID: + break; + case Paste_ID: + break; + case Undo_ID: + break; + case Redo_ID: + break; + case Find_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Find); + if (!keySeq.isEmpty()) + { + ui.actionFind->setShortcut(keySeq); + } + break; + case Replace_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Replace); + if (!keySeq.isEmpty()) + { + ui.actionReplace->setShortcut(keySeq); + } + break; + case Dir_Find_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(DirFind); + if (!keySeq.isEmpty()) + { + ui.actionFind_In_Dir->setShortcut(keySeq); + } + break; + case Mark_ID: + + break; + case Word_highlight_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Word_highlight); + if (!keySeq.isEmpty()) + { + m_signText->setShortcut(keySeq); + } + break; + case Clear_all_highlight_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Clear_all_highlight); + if (!keySeq.isEmpty()) + { + m_clearMark->setShortcut(keySeq); + } + break; + case Zoom_In_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Zoom_In); + if (!keySeq.isEmpty()) + { + m_zoomin->setShortcut(keySeq); + } + break; + case Zoom_Out_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Zoom_Out); + if (!keySeq.isEmpty()) + { + m_zoomout->setShortcut(keySeq); + } + break; + case Word_Wrap_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Word_Wrap); + if (!keySeq.isEmpty()) + { + ui.actionWrap->setShortcut(keySeq); + } + break; + case Show_Blank_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Show_Blank); + if (!keySeq.isEmpty()) + { + ui.actionShowAll->setShortcut(keySeq); + } + break; + case Indent_Guide_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Indent_Guide); + if (!keySeq.isEmpty()) + { + m_indentGuide->setShortcut(keySeq); + } + break; + case Pre_Page_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Pre_Page); + if (!keySeq.isEmpty()) + { + m_preHexPage->setShortcut(keySeq); + } + break; + case Next_Page_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Next_Page); + if (!keySeq.isEmpty()) + { + m_nextHexPage->setShortcut(keySeq); + } + break; + case Goto_Page_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Goto_Page); + if (!keySeq.isEmpty()) + { + ui.actionGoline->setShortcut(keySeq); + } + break; + + case Trans_code_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Trans_code); + if (!keySeq.isEmpty()) + { + m_transcode->setShortcut(keySeq); + } + break; + case Batch_rename_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Batch_rename); + if (!keySeq.isEmpty()) + { + m_rename->setShortcut(keySeq); + } + break; + + case Format_Xml_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Format_Xml); + if (!keySeq.isEmpty()) + { + m_formatXml->setShortcut(keySeq); + } + break; + + case Format_Json_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Format_Json); + if (!keySeq.isEmpty()) + { + m_formatJson->setShortcut(keySeq); + } + break; + + default: + break; + } +} +//设置用户自定义快捷键 +void CCNotePad::setUserDefShortcutKey() +{ + ShortcutKeyMgr::initShortcutKeysMap(); + + for (int i = New_File_ID; i < Shortcut_End_ID; ++i) + { + setUserDefShortcutKey(i); + } } void CCNotePad::init_toolsMenu() { - connect(ui.menuTools,&QMenu::aboutToShow,this,&CCNotePad::slot_dynamicLoadToolMenu); + slot_dynamicLoadToolMenu(); + //connect(ui.menuTools,&QMenu::aboutToShow,this,&CCNotePad::slot_dynamicLoadToolMenu); } enum ToolMenuAct { @@ -1260,22 +1509,27 @@ void CCNotePad::slot_dynamicLoadToolMenu() { m_isToolMenuLoaded = true; +#ifdef NO_PLUGIN ui.menuTools->addAction(tr("Plugin Manager"), this, &CCNotePad::slot_pluginMgr); +#endif QMenu* formatMenu = new QMenu(tr("Format Language"), this); - formatMenu->addAction(tr("Format Xml"), this, &CCNotePad::slot_formatXml); - formatMenu->addAction(tr("Format Json"), this, &CCNotePad::slot_formatJson); + m_formatXml = formatMenu->addAction(tr("Format Xml"), this, &CCNotePad::slot_formatXml); + m_formatJson = formatMenu->addAction(tr("Format Json"), this, &CCNotePad::slot_formatJson); ui.menuTools->addMenu(formatMenu); QAction* pAct = nullptr; pAct = ui.menuTools->addAction(tr("Batch Find"), this, &CCNotePad::slot_batchFind); pAct->setData(BATCH_FIND); +#ifdef NO_PLUGIN //动态加载插件 loadPluginLib(); +#endif } } +#ifdef NO_PLUGIN void CCNotePad::slot_pluginMgr() { PluginMgr* pWin = new PluginMgr(this, m_pluginList); @@ -1283,6 +1537,7 @@ void CCNotePad::slot_pluginMgr() pWin->show(); } + void CCNotePad::loadPluginLib() { QString strDir = qApp->applicationDirPath(); @@ -1357,10 +1612,15 @@ void CCNotePad::loadPluginProcs(QString strLibDir, QMenu* pMenu) delete pSubMenu; } } +#endif - +//批量查找替换 void CCNotePad::slot_batchFind() { +#ifdef uos + bool isPosAdjust = false; +#endif + if (m_batchFindWin.isNull()) { m_batchFindWin = new BatchFindReplace(this); @@ -1368,12 +1628,24 @@ void CCNotePad::slot_batchFind() BatchFindReplace* pWin = dynamic_cast(m_batchFindWin.data()); pWin->setTabWidget(ui.editTabWidget); - + + QByteArray lastGeo = NddSetting::getWinPos(BATCH_FIND_REPLACE_POS); + if (!lastGeo.isEmpty()) + { + m_batchFindWin->restoreGeometry(lastGeo); +#ifdef uos + isPosAdjust = true; +#endif + } + } m_batchFindWin->show(); #ifdef uos + if (!isPosAdjust) + { adjustWInPos(m_batchFindWin); + } #endif } @@ -1576,6 +1848,14 @@ void CCNotePad::slot_changeChinese() m_curSoftLangs = 1; NddSetting::updataKeyValueFromNumSets(LANGS_KEY, m_curSoftLangs); } + + //如果已经加载了,则冲加载,否则中英文切换不生效 + if (m_isToolMenuLoaded) + { + ui.menuTools->clear(); + m_isToolMenuLoaded = false; + slot_dynamicLoadToolMenu(); +} } } @@ -1600,6 +1880,14 @@ void CCNotePad::slot_changeEnglish() m_curSoftLangs = 2; NddSetting::updataKeyValueFromNumSets(LANGS_KEY, m_curSoftLangs); } + + //如果已经加载了,则冲加载,否则中英文切换不生效 + if (m_isToolMenuLoaded) + { + ui.menuTools->clear(); + m_isToolMenuLoaded = false; + slot_dynamicLoadToolMenu(); +} } #if 0 void CCNotePad::saveDefFont() @@ -1811,7 +2099,7 @@ void CCNotePad::slot_tabBarClicked(int index) m_selectLeftCmp->setEnabled(false); m_selectRightCmp->setEnabled(false); } - else if(BIG_TEXT_TYPE == docType) + else if(BIG_TEXT_RO_TYPE == docType || SUPER_BIG_TEXT_RO_TYPE == docType) { m_openWithText->setEnabled(false); m_openWithHex->setEnabled(true); @@ -1942,7 +2230,10 @@ void CCNotePad::slot_openFileInNewWin() } } -void CCNotePad::autoSetDocLexer(ScintillaEditView* pEdit) +//int defLexerId:如果失败,则按照该语法类型的id赋值;如果-1则不给与默认值。 +//因为发现如果是新建的文件,而且手动设置了语法,其文件名还是*.txt,此时如果根据 +//后缀名自动赋值与否,会导致手动设置的语法失效。 +void CCNotePad::autoSetDocLexer(ScintillaEditView* pEdit, int defLexerId) { QString filePath = pEdit->property(Edit_View_FilePath).toString(); @@ -1954,7 +2245,17 @@ void CCNotePad::autoSetDocLexer(ScintillaEditView* pEdit) LexerInfo lxdata = getLangLexerIdByFileExt(filePath); - QsciLexer* lexer = pEdit->createLexer(lxdata.lexerId, lxdata.tagName); + QsciLexer* lexer = nullptr; + + //如果没有特殊语法,而且默认给与语法不是-1,则按照默认语法设置 + if (lxdata.lexerId == L_TXT && defLexerId != -1) + { + lexer = pEdit->createLexer(defLexerId); + } + else + { + lexer = pEdit->createLexer(lxdata.lexerId, lxdata.tagName); + } if (lexer != nullptr) { @@ -1998,7 +2299,7 @@ void CCNotePad::slot_tabCurrentChanged(int index) fileListSetCurItem(filePath); return; } - else if ((TXT_TYPE == docType)||(BIG_TEXT_TYPE == docType)) + else if ((TXT_TYPE == docType)||(BIG_TEXT_RO_TYPE == docType)||(SUPER_BIG_TEXT_RO_TYPE == docType)) { int code = pw->property(Edit_Text_Code).toInt(); @@ -2021,12 +2322,16 @@ void CCNotePad::slot_tabCurrentChanged(int index) //setWindowTitle(pw->property(Edit_View_FilePath).toString()); setWindowTitleMode(filePath, (OpenAttr)pw->property(Open_Attr).toInt()); } - else if (BIG_TEXT_TYPE == docType) + else if (BIG_TEXT_RO_TYPE == docType) { //setWindowTitle(QString("%1 (%2)").arg(pw->property(Edit_View_FilePath).toString()).arg(tr("Big Text File ReadOnly"))); setWindowTitleMode(filePath, OpenAttr::BigTextReadOnly); } - + else if (SUPER_BIG_TEXT_RO_TYPE == docType) + { + //setWindowTitle(QString("%1 (%2)").arg(pw->property(Edit_View_FilePath).toString()).arg(tr("Big Text File ReadOnly"))); + setWindowTitleMode(filePath, OpenAttr::SuperBigTextReadOnly); + } syncCurDocEncodeToMenu(pw); syncCurDocLineEndStatusToMenu(pw); syncCurDocLexerToMenu(pw); @@ -2502,7 +2807,8 @@ void CCNotePad::initToolBar() m_pLexerActGroup = new QActionGroup(this); - m_pLexerActGroup->addAction(ui.actionAVS); + /*m_pLexerActGroup->addAction(ui.actionAVS);*/ + m_pLexerActGroup->addAction(ui.actionAssembly); m_pLexerActGroup->addAction(ui.actionbash); m_pLexerActGroup->addAction(ui.actionBatch); m_pLexerActGroup->addAction(ui.actionCMake); @@ -2856,6 +3162,25 @@ int CCNotePad::findFileIsOpenAtPad(QString filePath) return ret; } +//判断新建名称是否已经存在,是 true +bool CCNotePad::isNewFileNameExist(QString& fileName) +{ + + for (int i = ui.editTabWidget->count() -1; i >=0 ; --i) + { + QWidget* pw = ui.editTabWidget->widget(i); + if (pw != nullptr && (-1 != getFileNewIndexProperty(pw))) + { + if (getFilePathProperty(pw) == fileName) + { + return true; + } + } + } + + return false; +} + //通过菜单打开最近文档 void CCNotePad::slot_openReceneFile() { @@ -2949,11 +3274,40 @@ bool CCNotePad::checkRoladFile(ScintillaEditView* pEdit) //这个函数是在paint中调用,所以不要直连,否则调用QMessagebox后崩溃 void CCNotePad::slot_LineNumIndexChange(int line, int index) { - QString lineNums = tr("Ln: %1 Col: %2").arg(line+1).arg(index); - m_lineNumLabel->setText(lineNums); - ScintillaEditView* pEdit = dynamic_cast(sender()); + if (pEdit == nullptr) + { + return; + } + QString lineNums; + + int type = getDocTypeProperty(pEdit); + + switch (type) + { + case TXT_TYPE: + //文本文件可能被修改。 checkRoladFile(pEdit); + lineNums = tr("Ln: %1 Col: %2").arg(line + 1).arg(index); + break; + case BIG_TEXT_RO_TYPE: + //大文本分块加载,只读格式 + { + quint32 bLineStart = pEdit->getBigTextBlockStartLine(); + lineNums = tr("Ln: %1 Col: %2").arg(bLineStart + line + 1).arg(index); +} + break; + case BIG_EDIT_RW_TYPE: + break;//暂时没有 + case SUPER_BIG_TEXT_RO_TYPE: + case HEX_TYPE: + //这两种是没有行号的,只有列号 + lineNums = tr("Ln: %1 Col: %2").arg("unknown").arg(index); + break; + default: + break; + } + m_lineNumLabel->setText(lineNums); } //打开监控文件修改的信号 @@ -2991,15 +3345,8 @@ void CCNotePad::slot_editViewMofidyChange() int index = ui.editTabWidget->indexOf(pEditView); if (index != -1) { - if (StyleSet::getCurrentSytleId() != DEEP_BLACK) - { ui.editTabWidget->setTabIcon(index, QIcon(TabNeedSave)); } - else - { - ui.editTabWidget->setTabIcon(index, QIcon(TabNeedSaveDark32)); - } - } //设置状态栏也是红色 /*m_saveFile->setIcon(QIcon(NeedSaveBarIcon)); @@ -3083,12 +3430,12 @@ void CCNotePad::tabClose(int index, bool isInQuit) delFileListView(filePath); return; } - else if (BIG_TEXT_TYPE == type) + else if (BIG_TEXT_RO_TYPE == type) { ui.editTabWidget->removeTab(index); pw->deleteLater(); - FileManager::getInstance().closeBigTextFileHand(filePath); + FileManager::getInstance().closeBigTextRoFileHand(filePath); if (!isInQuit) { initTabNewOne(); @@ -3096,6 +3443,19 @@ void CCNotePad::tabClose(int index, bool isInQuit) delFileListView(filePath); return; } + else if (SUPER_BIG_TEXT_RO_TYPE == type) + { + ui.editTabWidget->removeTab(index); + pw->deleteLater(); + + FileManager::getInstance().closeSuperBigTextFileHand(filePath); + if (!isInQuit) + { + initTabNewOne(); + } + delFileListView(filePath); + return; + } //关闭之前,检查是否要保存。如果文档为脏,则询问是否要保存 ScintillaEditView* pEdit = dynamic_cast(pw); @@ -3212,7 +3572,7 @@ void CCNotePad::tabClose(int index, bool isInQuit) } } //点击tab上的关闭事件执行槽函数。注意这个index是其在tab中的序号。 -//当中间有删除时,是会动态变化的。所以不能以这个id为一起的固定索引 +//当中间有删除时,是会动态变化的。所以不能以这个id为一直的固定索引 void CCNotePad::slot_tabClose(int index) { tabClose(index); @@ -3264,10 +3624,6 @@ ScintillaEditView* CCNotePad::newTxtFile(QString name, int index, QString conten enableEditTextChangeSign(pEdit); - //int index = FileManager::getInstance().getNextNewFileId(); - - //QString label = QString("New %1").arg(index); - QString label = name; disconnect(ui.editTabWidget, &QTabWidget::currentChanged, this, &CCNotePad::slot_tabCurrentChanged); @@ -3344,7 +3700,20 @@ ScintillaEditView* CCNotePad::newTxtFile(QString name, int index, QString conten void CCNotePad::slot_actionNewFile_toggle(bool /*checked*/) { int index = FileManager::getInstance().getNextNewFileId(); - QString name = QString("New %1").arg(index); + int nameId = index; + QString name; + + while (true) + { + name = QString("New %1").arg(nameId); + + //检测一下是否重名New 文件,如果存在,则重新命名。注意id肯定是唯一的,但是名称其实可以重复 + if (!isNewFileNameExist(name)) + { + break; + } + ++nameId; + } newTxtFile(name,index); } @@ -3364,7 +3733,10 @@ bool CCNotePad::reloadTextFileWithCode(CODE_ID code) { QWidget* pw = ui.editTabWidget->currentWidget(); //16进制的处理逻辑 - if (HEX_TYPE == getDocTypeProperty(pw)) + + int docType = getDocTypeProperty(pw); + + if (HEX_TYPE == docType) { ui.statusBar->showMessage(tr("Only Text File Can Use it, Current Doc is a Hex File !"), 10000); QApplication::beep(); @@ -3384,16 +3756,52 @@ bool CCNotePad::reloadTextFileWithCode(CODE_ID code) pEdit->clear(); - int errCode = FileManager::getInstance().loadFileDataInText(pEdit, filePath, code, lineEnd,this, false); + if (docType == TXT_TYPE) + { + int errCode = FileManager::getInstance().loadFileDataInText(pEdit, filePath, code, lineEnd, this, false); if (errCode == 5) { //只读模式。暂时什么也不做 } - else if(errCode != 0) + else if (errCode != 0) { delete pEdit; return false; } + } + else if (BIG_TEXT_RO_TYPE == docType) + { + //大文本索引加载模式,不需要再读取文本。只需要进行编码的转换即可 + BigTextEditFileMgr* fileMgr = FileManager::getInstance().getBigFileEditMgr(filePath); + if (fileMgr != nullptr) + { + fileMgr->loadWithCode = code; + showBigTextFile(pEdit, fileMgr, fileMgr->m_curBlockIndex); + } + else + { + return false; + } + } + else if (SUPER_BIG_TEXT_RO_TYPE == docType) + { + TextFileMgr* fileMgr = FileManager::getInstance().getSuperBigFileMgr(filePath); + if (fileMgr != nullptr) + { + fileMgr->loadWithCode = code; + showBigTextFile(pEdit, fileMgr); + + //如果切换了编码,可能乱码,把当前的行号缓存清空一下,因为旧行号已经没有意义了。 + pEdit->clearSuperBitLineCache(); + + pEdit->showBigTextLineAddr(fileMgr->fileOffset - fileMgr->contentRealSize, fileMgr->fileOffset); + + } + else + { + return false; + } + } if (pEdit->lexer() == nullptr) { @@ -3412,17 +3820,18 @@ bool CCNotePad::reloadTextFileWithCode(CODE_ID code) const int MAX_TEXT_FILE_SIZE = 100 * 1024 * 1024; -//按照大文本文件进行只读打开 -bool CCNotePad::openBigTextFile(QString filePath) +//大文本打开只读模式。20230126新增,这种模式打开时建立索引;todo:后续可多线程在后台建立索引 +bool CCNotePad::openBigTextRoFile(QString filePath) { QFileInfo fi(filePath); QString fileLabel(fi.fileName()); - TextFileMgr* txtFile = nullptr; + //如果4M一个分块,则1024则是4G文件,2048则是8G文件。目前暂时最大支持8G的文件,进行文本编辑。 + BigTextEditFileMgr* txtFile = nullptr; RC_LINE_FORM lineEnd(UNKNOWN_LINE); - if (!FileManager::getInstance().loadFileData(filePath, txtFile, lineEnd)) + if (!FileManager::getInstance().loadFileDataWithIndex(filePath, txtFile)) { return false; } @@ -3433,9 +3842,11 @@ bool CCNotePad::openBigTextFile(QString filePath) //必须要在editTabWidget->addTab之前,因为一旦add时会出发tabchange,其中没有doctype会导致错误 pEdit->execute(SCI_SETSCROLLWIDTH, 80 * 10); - setDocTypeProperty(pEdit, BIG_TEXT_TYPE); + setDocTypeProperty(pEdit, BIG_TEXT_RO_TYPE); - showBigTextFile(pEdit, txtFile); + showBigTextFile(pEdit, txtFile,0); + + lineEnd = (RC_LINE_FORM)txtFile->lineEndType; disconnect(ui.editTabWidget, &QTabWidget::currentChanged, this, &CCNotePad::slot_tabCurrentChanged); int curIndex = ui.editTabWidget->addTab(pEdit, QIcon((StyleSet::getCurrentSytleId() != DEEP_BLACK) ? TabNoNeedSave : TabNoNeedSaveDark32), getShortName(fileLabel)); @@ -3443,16 +3854,17 @@ bool CCNotePad::openBigTextFile(QString filePath) ui.editTabWidget->setCurrentIndex(curIndex); connect(ui.editTabWidget, &QTabWidget::currentChanged, this, &CCNotePad::slot_tabCurrentChanged, Qt::UniqueConnection); + connect(pEdit, &ScintillaEditView::cursorPositionChanged, this, &CCNotePad::slot_LineNumIndexChange, Qt::QueuedConnection); autoSetDocLexer(pEdit); - pEdit->showBigTextLineAddr(txtFile->fileOffset - txtFile->contentRealSize); + //pEdit->showBigEidTextLineNum(txtFile); QVariant editViewFilePath(filePath); pEdit->setProperty(Edit_View_FilePath, editViewFilePath); //setWindowTitle(QString("%1 (%2)").arg(filePath).arg(tr("Big Text File ReadOnly"))); - + ui.editTabWidget->setTabToolTip(curIndex, filePath); QVariant editViewNewFile(-1); @@ -3461,7 +3873,12 @@ bool CCNotePad::openBigTextFile(QString filePath) QVariant editTextChange(false); pEdit->setProperty(Edit_Text_Change, editTextChange); + setCodeTypeProperty(pEdit, txtFile->loadWithCode); + setCodeBarLabel((CODE_ID)txtFile->loadWithCode); + setLineEndBarLabel(lineEnd); + setEndTypeProperty(pEdit, lineEnd); + setDocEolMode(pEdit, lineEnd); syncCurDocEncodeToMenu(pEdit); setFileOpenAttrProperty(pEdit, OpenAttr::BigTextReadOnly); @@ -3494,11 +3911,101 @@ bool CCNotePad::openBigTextFile(QString filePath) return true; } +//按照超大文本文件进行只读打开 +bool CCNotePad::openSuperBigTextFile(QString filePath) +{ + QFileInfo fi(filePath); + QString fileLabel(fi.fileName()); + + TextFileMgr* txtFile = nullptr; + + RC_LINE_FORM lineEnd(UNKNOWN_LINE); + + if (!FileManager::getInstance().loadFileData(filePath, txtFile, lineEnd)) + { + return false; + } + + ScintillaEditView* pEdit = FileManager::getInstance().newEmptyDocument(true); + pEdit->setReadOnly(true); + pEdit->setNoteWidget(this); + + //必须要在editTabWidget->addTab之前,因为一旦add时会出发tabchange,其中没有doctype会导致错误 + pEdit->execute(SCI_SETSCROLLWIDTH, 80 * 10); + setDocTypeProperty(pEdit, SUPER_BIG_TEXT_RO_TYPE); + + showBigTextFile(pEdit, txtFile); + lineEnd = (RC_LINE_FORM)txtFile->lineEndType; + + disconnect(ui.editTabWidget, &QTabWidget::currentChanged, this, &CCNotePad::slot_tabCurrentChanged); + int curIndex = ui.editTabWidget->addTab(pEdit, QIcon((StyleSet::getCurrentSytleId() != DEEP_BLACK) ? TabNoNeedSave : TabNoNeedSaveDark32), getShortName(fileLabel)); + + ui.editTabWidget->setCurrentIndex(curIndex); + connect(ui.editTabWidget, &QTabWidget::currentChanged, this, &CCNotePad::slot_tabCurrentChanged, Qt::UniqueConnection); + connect(pEdit, &ScintillaEditView::cursorPositionChanged, this, &CCNotePad::slot_LineNumIndexChange, Qt::QueuedConnection); + + + autoSetDocLexer(pEdit); + + pEdit->showBigTextLineAddr(txtFile->fileOffset - txtFile->contentRealSize, txtFile->fileOffset); + + QVariant editViewFilePath(filePath); + pEdit->setProperty(Edit_View_FilePath, editViewFilePath); + + //setWindowTitle(QString("%1 (%2)").arg(filePath).arg(tr("Big Text File ReadOnly"))); + + ui.editTabWidget->setTabToolTip(curIndex, filePath); + + QVariant editViewNewFile(-1); + pEdit->setProperty(Edit_File_New, editViewNewFile); + + QVariant editTextChange(false); + pEdit->setProperty(Edit_Text_Change, editTextChange); + + setCodeTypeProperty(pEdit, txtFile->loadWithCode); + setCodeBarLabel((CODE_ID)txtFile->loadWithCode); + + setLineEndBarLabel(lineEnd); + setEndTypeProperty(pEdit, lineEnd); + setDocEolMode(pEdit, lineEnd); + + syncCurDocEncodeToMenu(pEdit); + setFileOpenAttrProperty(pEdit, OpenAttr::SuperBigTextReadOnly); + setWindowTitleMode(filePath, OpenAttr::SuperBigTextReadOnly); + + + //设置自动转换和缩进参考线 + if (s_autoWarp != QsciScintilla::WrapNone) + { + pEdit->setWrapMode(QsciScintilla::WrapCharacter); + } + if (s_showblank == 1) + { + pEdit->setWhitespaceVisibility(QsciScintilla::WsVisible); + pEdit->setEolVisibility(true); + } + + if (s_indent == 1) + { + pEdit->setIndentGuide(true); + } + + if (s_zoomValue != 0) + { + pEdit->zoomTo(s_zoomValue); + } + + addFileListView(filePath, pEdit); + + return true; +} + + void CCNotePad::showChangePageTips(QWidget* pEdit) { int type = getDocTypeProperty(pEdit); - if (BIG_TEXT_TYPE == type || HEX_TYPE == type) + if ((BIG_TEXT_RO_TYPE == type) || (SUPER_BIG_TEXT_RO_TYPE == type) || (HEX_TYPE == type)) { ui.statusBar->showMessage(tr("Use < (Pre) or > (Next) and Goto Buttons to Change Page Num ."), 10000); } @@ -3510,7 +4017,7 @@ void CCNotePad::setWindowTitleMode(QString filePath, OpenAttr attr) setWindowTitle(title); } -const quint32 MAX_TRY_OPEN_FILE_SIZE = 1024 * 1024 * 1000; +const quint64 MAX_TRY_OPEN_FILE_SIZE = 1024 * 1024 * 1024; //打开普通文本文件。 bool CCNotePad::openTextFile(QString filePath, bool isCheckHex, CODE_ID code) @@ -3524,7 +4031,7 @@ bool CCNotePad::openTextFile(QString filePath, bool isCheckHex, CODE_ID code) QFileInfo fi(filePath); - //如果文件大于300M,按照只读文件打开 + //如果文件大于设定最大值,询问是否只读文件打开 if (ScintillaEditView::s_bigTextSize <= 0 || ScintillaEditView::s_bigTextSize > 300) { ScintillaEditView::s_bigTextSize = 100; @@ -3536,7 +4043,7 @@ bool CCNotePad::openTextFile(QString filePath, bool isCheckHex, CODE_ID code) if (fi.size() < MAX_TRY_OPEN_FILE_SIZE) { BigFileMessage askMsgBox(this); - askMsgBox.setTip(tr("File %1 \nFile Size %2 > %3M, How to Open it ?").arg(filePath).arg(fi.size()).arg(ScintillaEditView::s_bigTextSize)); + askMsgBox.setTip(tr("File %1 \nFile Size %2 > %3M, How to Open it ?").arg(filePath).arg(tranFileSize(fi.size())).arg(ScintillaEditView::s_bigTextSize)); int openMode = askMsgBox.exec(); //放弃打开 @@ -3544,15 +4051,20 @@ bool CCNotePad::openTextFile(QString filePath, bool isCheckHex, CODE_ID code) { return false; } - else if (openMode == 0) + else if (openMode == TXT_TYPE) { //正常普通文本打开,不做什么,继续往下走 } - else if (openMode == 1) + else if (openMode == BIG_TEXT_RO_TYPE) { - //大文本只读打开 - return openBigTextFile(filePath); + //大文本只读打开。20230125新增,做了内部索引,适合4G-8G左右的文件。 + return openBigTextRoFile(filePath); } + else if (openMode == SUPER_BIG_TEXT_RO_TYPE) + { + //超大文本编辑模式。8G以上 + return openSuperBigTextFile(filePath); + } else { //二进制打开 @@ -3561,8 +4073,15 @@ bool CCNotePad::openTextFile(QString filePath, bool isCheckHex, CODE_ID code) } else { - //大文本只读打开 - return openBigTextFile(filePath); + //如果小于8G,则大文本只读打开;反之则超大文本只读打开 + if (fi.size() <= 8 * MAX_TRY_OPEN_FILE_SIZE) + { + return openBigTextRoFile(filePath); + } + else + { + return openSuperBigTextFile(filePath); + } } } @@ -3589,8 +4108,6 @@ bool CCNotePad::openTextFile(QString filePath, bool isCheckHex, CODE_ID code) } } - QString fileLabel(fi.fileName()); - ScintillaEditView* pEdit = FileManager::getInstance().newEmptyDocument(); pEdit->setNoteWidget(this); @@ -3635,9 +4152,28 @@ bool CCNotePad::openTextFile(QString filePath, bool isCheckHex, CODE_ID code) saveFile(filePath, pEdit, false); } + //下面函数太长,进行一个重构到setNormalTextEditInitPro,后面其他地方也需要使用 + setNormalTextEditInitPro(pEdit, filePath, code, lineEnd, isReadOnly,false); + + return true; +} + +//初始化普通可编辑文件的基本属性 +//fileLabel:label显示名称 +//filePath:对应的文件路径名 +//code 文件编码 +//lineEnd 文件换行符 +//isReadOnly 是否只读 +//isModifyed 是否修改过的脏状态 +void CCNotePad::setNormalTextEditInitPro(ScintillaEditView* pEdit, QString filePath, CODE_ID code, RC_LINE_FORM lineEnd, bool isReadOnly, bool isModifyed) +{ //防止addTab触发currentChanged信号,应发不必要的连锁反应 disconnect(ui.editTabWidget, &QTabWidget::currentChanged, this, &CCNotePad::slot_tabCurrentChanged); - int curIndex = ui.editTabWidget->addTab(pEdit, QIcon((StyleSet::getCurrentSytleId() != DEEP_BLACK) ? TabNoNeedSave : TabNoNeedSaveDark32), getShortName(fileLabel)); + + QFileInfo fi(filePath); + QString fileLabel(fi.fileName()); + + int curIndex = ui.editTabWidget->addTab(pEdit, QIcon(TabNoNeedSave), getShortName(fileLabel)); ui.editTabWidget->setCurrentWidget(pEdit); connect(ui.editTabWidget, &QTabWidget::currentChanged, this, &CCNotePad::slot_tabCurrentChanged, Qt::UniqueConnection); @@ -3660,14 +4196,20 @@ bool CCNotePad::openTextFile(QString filePath, bool isCheckHex, CODE_ID code) QVariant editViewFilePath(filePath); pEdit->setProperty(Edit_View_FilePath, editViewFilePath); - //setWindowTitle(filePath); - ui.editTabWidget->setTabToolTip(curIndex, filePath); QVariant editViewNewFile(-1); pEdit->setProperty(Edit_File_New, editViewNewFile); - setTextChangeProperty(pEdit, false); + setTextChangeProperty(pEdit, isModifyed); + + //如果是脏,还需要设置保存等按钮 + if (isModifyed) + { + m_saveFile->setEnabled(true); + m_saveAllFile->setEnabled(true); + ui.editTabWidget->setTabIcon(curIndex, QIcon(TabNeedSave)); + } QVariant editTextCode((int)code); pEdit->setProperty(Edit_Text_Code, editTextCode); @@ -3702,14 +4244,14 @@ bool CCNotePad::openTextFile(QString filePath, bool isCheckHex, CODE_ID code) setFileOpenAttrProperty(pEdit, OpenAttr::Text); setWindowTitleMode(filePath, OpenAttr::Text); int zoomValue = 100 + 10 * s_zoomValue; - ui.statusBar->showMessage(tr("File %1 Open Finished [Text Mode] Zoom %2%").arg(filePath).arg(zoomValue),8000); + ui.statusBar->showMessage(tr("File %1 Open Finished [Text Mode] Zoom %2%").arg(filePath).arg(zoomValue), 8000); setZoomLabelValue(zoomValue); } else { setFileOpenAttrProperty(pEdit, OpenAttr::TextReadOnly); setWindowTitleMode(filePath, OpenAttr::TextReadOnly); - ui.statusBar->showMessage(tr("File %1 Open Finished [Text ReadOnly Mode] (Note: display up to 50K bytes ...)").arg(fi.fileName()),8000); + ui.statusBar->showMessage(tr("File %1 Open Finished [Text ReadOnly Mode] (Note: display up to 50K bytes ...)").arg(fi.fileName()), 8000); } if (pEdit->lexer() == nullptr) @@ -3717,8 +4259,6 @@ bool CCNotePad::openTextFile(QString filePath, bool isCheckHex, CODE_ID code) autoSetDocLexer(pEdit); } addFileListView(filePath, pEdit); - - return true; } //显示二进制文件 @@ -3816,18 +4356,155 @@ bool CCNotePad::showHexFile(ScintillaHexEditView* pEdit, HexFileMgr* hexFile) return true; } -//显示大文本文件只读 +//显示超大文本文件只读 bool CCNotePad::showBigTextFile(ScintillaEditView* pEdit, TextFileMgr* txtFile) { qint64 addr = txtFile->fileOffset - txtFile->contentRealSize; - ui.statusBar->showMessage(tr("Current offset is %1 , load Contens Size is %2, File Total Size is %3").arg(addr).arg(txtFile->contentRealSize).arg(txtFile->fileSize)); - pEdit->setUtf8Text(txtFile->contentBuf, txtFile->contentRealSize); + CODE_ID code = (CODE_ID)txtFile->loadWithCode; + + //不知道编码,则需要自动判断编码 + if (txtFile->loadWithCode == UNKOWN) + { + //自动从头部或文件中判断编码 + code = CmpareMode::getTextFileEncodeType((uchar *)txtFile->contentBuf, txtFile->contentRealSize, txtFile->filePath); + } + + QString outUtf8Text; + + bool tranSucess = true; + + + //UNICODE_LE格式需要单独处理 + if (code == UNICODE_LE) + { + tranSucess = CmpareMode::tranUnicodeLeToUtf8Bytes((uchar*)txtFile->contentBuf, txtFile->contentRealSize, outUtf8Text); + } + else + { + //如果还是unknown,则没法了,默认按照Utf8解析。 + if (code == UNKOWN) + { + code = UTF8_NOBOM; + } + tranSucess = Encode::tranStrToUNICODE(code, (const char*)txtFile->contentBuf, txtFile->contentRealSize, outUtf8Text); + } + + if (txtFile->loadWithCode != code) + { + txtFile->loadWithCode = code; + } + + //获取行结尾信息 + if (txtFile->lineEndType == RC_LINE_FORM::UNKNOWN_LINE) + { + txtFile->lineEndType = getLineEndTypeFromBigText(outUtf8Text); + } + + pEdit->setText(outUtf8Text); + + if (tranSucess) + { + ui.statusBar->showMessage(tr("Current offset is %1 , load Contens Size is %2, File Total Size is %3").arg(addr).arg(txtFile->contentRealSize).arg(txtFile->fileSize)); + } + else + { + //文件乱码 + if (txtFile->contentBuf == 0) + { + QMessageBox::warning(this, tr("Format Error"), tr("Not a txt format file , load with big txt is garbled code!")); + } + else + { + ui.statusBar->showMessage(tr("Not a txt format file , load with big txt is garbled code!")); + } + } + + //pEdit->setUtf8Text(txtFile->contentBuf, txtFile->contentRealSize); return true; } +//显示大文本文件,可编辑。, int blockIndex显示第几块。txtFile->loadWithCode 如果是UNKONW,则自动判断编码;反之以code指定的加载 +bool CCNotePad::showBigTextFile(ScintillaEditView* pEdit, BigTextEditFileMgr* txtFile, int blockIndex) +{ + if (blockIndex >= 0 && blockIndex < txtFile->blocks.size()) + { + + BlockIndex bi = txtFile->blocks.at(blockIndex); + + CODE_ID code = (CODE_ID)txtFile->loadWithCode; + + //不知道编码,则需要自动判断编码 + if (txtFile->loadWithCode == UNKOWN) + { + //自动从头部或文件中判断编码。如果是第0块即文件开头,才能从头部检测 + code = CmpareMode::getTextFileEncodeType(txtFile->filePtr + bi.fileOffset, bi.fileSize, txtFile->filePath, (blockIndex == 0)); + } + + QString outUtf8Text; + + bool tranSucess = true; + + //UNICODE_LE格式需要单独处理 + if (code == UNICODE_LE) + { + tranSucess = CmpareMode::tranUnicodeLeToUtf8Bytes(txtFile->filePtr + bi.fileOffset, bi.fileSize, outUtf8Text, (blockIndex == 0)); + } + else + { + //如果还是unknown,则没法了,默认按照Utf8解析。 + if (code == UNKOWN) + { + code = UTF8_NOBOM; + } + tranSucess = Encode::tranStrToUNICODE(code, (const char*)txtFile->filePtr + bi.fileOffset, bi.fileSize, outUtf8Text); + } + + if (txtFile->loadWithCode != code) + { + txtFile->loadWithCode = code; + } + + //获取行结尾信息 + if (txtFile->lineEndType == RC_LINE_FORM::UNKNOWN_LINE) + { + txtFile->lineEndType = getLineEndTypeFromBigText(outUtf8Text); + } + //int ret = pEdit->setUtf8Text((char*)txtFile->filePtr + bi.fileOffset, bi.fileSize); + + pEdit->setText(outUtf8Text); + + pEdit->showBigTextRoLineNum(txtFile, blockIndex); + pEdit->setBigTextBlockStartLine(bi.lineNumStart); + txtFile->m_curBlockIndex = blockIndex; + + if (tranSucess) + { + ui.statusBar->showMessage(tr("Current offset is %1 , line nums is %2 - %3 load Contens Size is %4, File Total Size is %5").arg(bi.fileOffset).arg(bi.lineNumStart + 1).arg(bi.lineNumStart + bi.lineNum + 1).arg(bi.fileSize).arg(txtFile->file->size())); + } + else + { + //文件乱码 + if (blockIndex == 0) + { + QMessageBox::warning(this, tr("Format Error"), tr("Not a txt format file , load with big txt is garbled code!")); + } + else + { + ui.statusBar->showMessage(tr("Not a txt format file , load with big txt is garbled code!")); + } + } + return true; + } + + BlockIndex bi = txtFile->blocks.at(txtFile->m_curBlockIndex); + ui.statusBar->showMessage(tr("Current offset is %1 , line nums is %2 - %3 load Contens Size is %4, File Total Size is %5").arg(bi.fileOffset).arg(bi.lineNumStart + 1).arg(bi.lineNumStart + bi.lineNum + 1).arg(bi.fileSize).arg(txtFile->file->size())); + + QApplication::beep(); + return false; +} //打开并显示二进制文件 bool CCNotePad::openHexFile(QString filePath) @@ -4018,6 +4695,47 @@ static QString fileSuffix(const QString& filePath) return fi.suffix(); } +//打开之前保存的恢复文件 +bool CCNotePad::tryRestoreFile(QString filePath) +{ + getRegularFilePath(filePath); + + QFileInfo fi(filePath); + QString fileName = fi.fileName(); + + QString tempDir = getGlboalTempSaveDir(); + QString restoreTempFile = QString("%1\\%2").arg(tempDir).arg(fi.fileName()); + + QFileInfo restoreFi(restoreTempFile); + + //存在恢复文件,则加载打开 + if (restoreFi.exists()) + { + ScintillaEditView* pEdit = FileManager::getInstance().newEmptyDocument(); + pEdit->setNoteWidget(this); + + //使用上次的swap文件恢复当前文件 + CODE_ID code; + RC_LINE_FORM lineEnd; + + if (0 != FileManager::getInstance().loadFileDataInText(pEdit, restoreTempFile, code, lineEnd, nullptr,false)) + { + ui.statusBar->showMessage(tr("File %1 Open Failed").arg(restoreTempFile)); + delete pEdit; + QFile::remove(restoreTempFile); + return openFile(filePath); + } + else + { + //打开成功 + setNormalTextEditInitPro(pEdit, filePath, code, lineEnd, false,true); + //删除临时备份文件 + QFile::remove(restoreTempFile); + return true; + } + } + return openFile(filePath); +} bool CCNotePad::openFile(QString filePath) { s_padTimes++; @@ -4052,7 +4770,7 @@ bool CCNotePad::openFile(QString filePath) return openHexFile(filePath); } - //非已知的后缀文件,暂时无条件以二进制打开 + //非已知的后缀文件,暂时无条件以文本模式打开 return openTextFile(filePath); } @@ -4132,7 +4850,13 @@ bool CCNotePad::saveFile(QString fileName, ScintillaEditView* pEdit, bool isBak //打开失败,这里一般是权限问题导致。如果是windows,在外面申请权限后继续处理 if (QFileDevice::OpenError == file.error()) { - + //先把当前文件的内容,保存到临时的目录中。 + QString tempDir = getGlboalTempSaveDir(); + QFileInfo fi(fileName); + QString saveTempFile = QString("%1\\%2").arg(tempDir).arg(fi.fileName()); + saveFile(saveTempFile, pEdit, false, true, false); + + //后面新打开的文件,再去读取该文件。 this->runAsAdmin(fileName); return false; @@ -4754,7 +5478,8 @@ void CCNotePad::slot_timerAutoSave() //凡是存在临时文件的,一定是脏文件,即关闭时没有保存的文件。 //而不存在临时文件,只有一个记录在list中的文件,表示不脏的文件,直接打开原始文件即可。 //1:非脏新建文件 2 非脏的已存在文件 3 脏的新建文件 4 脏的老文件。 -//5和3一样,但是多了一个语法设置保存 +//5和3一样,但是多了一个语法设置保存。 +//20230119 对于1非脏的新建文件,不再保存。 void CCNotePad::saveTempFile(ScintillaEditView* pEdit,int index, QSettings& qs) { //16进制的处理逻辑 @@ -4775,7 +5500,8 @@ void CCNotePad::saveTempFile(ScintillaEditView* pEdit,int index, QSettings& qs) //如果是新建的文件 if (pEdit->property(Edit_File_New) >= 0) { - qs.setValue(QString("%1").arg(index), QString("%1|1").arg(fileName)); + //不再保存新建的非脏文件。因为一定是空的,意义不大 + //qs.setValue(QString("%1").arg(index), QString("%1|1").arg(fileName)); } else { @@ -4878,12 +5604,20 @@ void CCNotePad::closeFileStatic(int index, QSettings& qs) FileManager::getInstance().closeHexFileHand(filePath); return; } - else if (BIG_TEXT_TYPE == type) + else if (BIG_TEXT_RO_TYPE == type) { ui.editTabWidget->removeTab(index); pw->deleteLater(); - FileManager::getInstance().closeBigTextFileHand(filePath); + FileManager::getInstance().closeBigTextRoFileHand(filePath); + return; + } + else if (SUPER_BIG_TEXT_RO_TYPE == type) + { + ui.editTabWidget->removeTab(index); + pw->deleteLater(); + + FileManager::getInstance().closeSuperBigTextFileHand(filePath); return; } @@ -4964,6 +5698,15 @@ void CCNotePad::closeAllFileStatic() QString tempFileList = QString("notepad/temp/list"); QSettings qs(QSettings::IniFormat, QSettings::UserScope, tempFileList); qs.setIniCodec("UTF-8"); + QString qsSavePath = qs.fileName(); + QFileInfo fi(qsSavePath); + QDir saveDir = fi.dir(); + //检查文件夹temp是否存在,不然就创建。发现第一次时,没有该文件夹,文件保存时失败。 + if (!saveDir.exists()) + { + saveDir.mkdir(saveDir.absolutePath()); + } + qs.clear(); //从尾部开始依次调用保存所有文件。没修改的不需要保存 @@ -5031,6 +5774,7 @@ void CCNotePad::closeEvent(QCloseEvent * event) NddSetting::updataKeyValueFromNumSets(FILELISTSHOW, 0); } + #ifdef Q_OS_WIN if ((s_restoreLastFile==1) && m_isMainWindows && !s_isAdminAuth) { @@ -5047,7 +5791,7 @@ void CCNotePad::closeEvent(QCloseEvent * event) #else if ((s_restoreLastFile == 1) && m_isMainWindows) { - closeAllFileStatic(); + closeAllFileStatic(); m_isQuitCancel = false; } else @@ -5094,9 +5838,9 @@ void CCNotePad::closeEvent(QCloseEvent * event) { c->showNormal(); } - qlonglong winId = (qlonglong)c->effectiveWinId(); - m_shareMem->lock(); - memcpy(m_shareMem->data(), &winId, sizeof(qlonglong)); + qlonglong winId = (qlonglong)c->effectiveWinId(); + m_shareMem->lock(); + memcpy(m_shareMem->data(), &winId, sizeof(qlonglong)); m_shareMem->unlock(); c->m_isMainWindows = true; } @@ -5393,7 +6137,7 @@ void CCNotePad::slot_indentGuide(bool willBeShowed) void CCNotePad::find(FindTabIndex findType) { - initFindWindow(); + initFindWindow(findType); FindWin* pFind = dynamic_cast(m_pFindWin.data()); #ifdef uos pFind->activateWindow(); @@ -5414,7 +6158,7 @@ void CCNotePad::slot_findInDir() void CCNotePad::slot_find() { - initFindWindow(); + initFindWindow(FIND_TAB); FindWin* pFind = dynamic_cast(m_pFindWin.data()); #ifdef uos pFind->activateWindow(); @@ -5455,7 +6199,7 @@ int CCNotePad::markAtBack(QString keyword) } -void CCNotePad::initFindWindow() +void CCNotePad::initFindWindow(FindTabIndex type) { FindWin* pFind = nullptr; QWidget* pw = ui.editTabWidget->currentWidget(); @@ -5493,7 +6237,7 @@ void CCNotePad::initFindWindow() pFind->setTabWidget(ui.editTabWidget); - if((TXT_TYPE == docType) || (BIG_TEXT_TYPE == docType)) + if((TXT_TYPE == docType) || (BIG_TEXT_RO_TYPE == docType) || (SUPER_BIG_TEXT_RO_TYPE == docType)) { connect(pFind, &FindWin::sign_findAllInCurDoc, this, &CCNotePad::slot_showFindAllInCurDocResult); connect(pFind, &FindWin::sign_findAllInOpenDoc, this, &CCNotePad::slot_showfindAllInOpenDocResult); @@ -5518,13 +6262,41 @@ void CCNotePad::initFindWindow() } - if ((TXT_TYPE == docType) || (BIG_TEXT_TYPE == docType)) + if ((TXT_TYPE == docType) || (BIG_TEXT_RO_TYPE == docType) || (SUPER_BIG_TEXT_RO_TYPE == docType)) { ScintillaEditView* pEdit = dynamic_cast(pw); if (pEdit != nullptr && pEdit->hasSelectedText()) { QString text = pEdit->selectedText(); + if (FIND_TAB == type) + { pFind->setFindText(text); + //如果字段比较短,则字段填充到替换中 + if (text.size() <= 60) + { + pFind->setReplaceFindText(text); + } + } + else if (REPLACE_TAB == type) + { + pFind->setReplaceFindText(text); + //如果字段比较短,则字段填充到替换中 + if (text.size() <= 60) + { + pFind->setFindText(text); + } + } + else if (DIR_FIND_TAB == type) + { + pFind->setDirFindText(text); + } + } + else + { + QString text; + pFind->setFindText(text); + pFind->setReplaceFindText(text); + pFind->setDirFindText(text); } } else if (HEX_TYPE == docType) @@ -5535,7 +6307,12 @@ void CCNotePad::initFindWindow() QString text = pEdit->selectedText(); pFind->setFindText(text); } + else + { + QString text; + pFind->setFindText(text); } +} } @@ -5557,7 +6334,7 @@ void CCNotePad::slot_saveSearchHistory() void CCNotePad::slot_replace() { - initFindWindow(); + initFindWindow(REPLACE_TAB); FindWin* pFind = dynamic_cast(m_pFindWin.data()); pFind->setCurrentTab(REPLACE_TAB); pFind->activateWindow(); @@ -5586,7 +6363,7 @@ void CCNotePad::slot_clearMark() QWidget* pw = ui.editTabWidget->currentWidget(); int docType = getDocTypeProperty(pw); - if ((TXT_TYPE == docType) || (BIG_TEXT_TYPE == docType)) + if ((TXT_TYPE == docType) || (BIG_TEXT_RO_TYPE == docType) || (SUPER_BIG_TEXT_RO_TYPE == docType)) { ScintillaEditView* pEdit = dynamic_cast(pw); int docEnd = pEdit->length(); @@ -5654,7 +6431,7 @@ void CCNotePad::slot_clearWordHighlight() ScintillaEditView* pEdit; int srcPostion = -1; - if ((TXT_TYPE == docType) || (BIG_TEXT_TYPE == docType)) + if ((TXT_TYPE == docType) || (BIG_TEXT_RO_TYPE == docType) || (SUPER_BIG_TEXT_RO_TYPE == docType)) { pEdit = dynamic_cast(pw); if (pEdit != nullptr && pEdit->hasSelectedText()) @@ -5688,7 +6465,7 @@ void CCNotePad::slot_wordHighlight() ScintillaEditView* pEdit; int srcPostion = -1; - if ((TXT_TYPE == docType) || (BIG_TEXT_TYPE == docType)) + if ((TXT_TYPE == docType) || (BIG_TEXT_RO_TYPE == docType) || (SUPER_BIG_TEXT_RO_TYPE == docType)) { pEdit = dynamic_cast(pw); if (pEdit != nullptr && pEdit->hasSelectedText()) @@ -6037,13 +6814,49 @@ void CCNotePad::slot_gotoline() if (pEdit != nullptr) { - int lineCounts = 99999999; + int lineCounts = 2147483647; bool ok; int num = QInputDialog::getInt(this, tr("Go to line"), tr("Line Num:"), 1, 1, lineCounts, 1, &ok); if (ok) { - pEdit->execute(SCI_GOTOLINE, num-1); + + if (TXT_TYPE == getDocTypeProperty(pw)) + { + pEdit->execute(SCI_GOTOLINE, num - 1); + } + else if (BIG_TEXT_RO_TYPE == getDocTypeProperty(pw)) + { + //如果是大文本只读加载的,则逻辑不一样,需要根据行号定位到块,再定位到行 + int blockid = FileManager::getInstance().getBigFileBlockId(getFilePathProperty(pw), num - 1); + if (blockid != -1) + { + BigTextEditFileMgr* mgr = FileManager::getInstance().getBigFileEditMgr(getFilePathProperty(pw)); + const BlockIndex& v = mgr->blocks.at(blockid); + + showBigTextFile(pEdit, mgr, blockid); + + int offsetLineNum = (num - v.lineNumStart); + + pEdit->execute(SCI_SETFIRSTVISIBLELINE, (long)offsetLineNum); + + pEdit->execute(SCI_GOTOLINE, offsetLineNum - 1); + + } + else + { + BigTextEditFileMgr* mgr = FileManager::getInstance().getBigFileEditMgr(getFilePathProperty(pw)); + const BlockIndex& v = mgr->blocks.last(); + + QApplication::beep(); + ui.statusBar->showMessage(tr("out of file line range,mar line num is %1 !").arg(v.lineNum + v.lineNumStart -1)); +} + } + else + { + //超大文本不支持跳转行号,只支持跳转地址。先留着 + } + } } } @@ -6296,8 +7109,12 @@ void CCNotePad::slot_preHexPage() ScintillaHexEditView* pEdit = dynamic_cast(pw); showHexFile(pEdit, fileMgr); } + else + { + QApplication::beep(); } - if (pw != nullptr && (BIG_TEXT_TYPE == getDocTypeProperty(pw))) + } + else if (pw != nullptr && (SUPER_BIG_TEXT_RO_TYPE == getDocTypeProperty(pw))) { QString filePath = getFilePathProperty(pw); TextFileMgr *fileMgr = nullptr; @@ -6306,9 +7123,21 @@ void CCNotePad::slot_preHexPage() { ScintillaEditView* pEdit = dynamic_cast(pw); showBigTextFile(pEdit, fileMgr); - pEdit->showBigTextLineAddr(fileMgr->fileOffset - fileMgr->contentRealSize); + pEdit->showBigTextLineAddr(fileMgr->fileOffset - fileMgr->contentRealSize, fileMgr->fileOffset); } } + else if (pw != nullptr && (BIG_TEXT_RO_TYPE == getDocTypeProperty(pw))) + { + QString filePath = getFilePathProperty(pw); + BigTextEditFileMgr* fileMgr = FileManager::getInstance().getBigFileEditMgr(filePath); + if(fileMgr != nullptr) + { + ScintillaEditView* pEdit = dynamic_cast(pw); + + int id = fileMgr->m_curBlockIndex - 1; + showBigTextFile(pEdit, fileMgr, id); +} + } } void CCNotePad::slot_nextHexPage() @@ -6343,7 +7172,7 @@ void CCNotePad::slot_nextHexPage() QApplication::beep(); } } - else if (pw != nullptr && (BIG_TEXT_TYPE == getDocTypeProperty(pw))) + else if (pw != nullptr && (SUPER_BIG_TEXT_RO_TYPE == getDocTypeProperty(pw))) { QString filePath = getFilePathProperty(pw); TextFileMgr *fileMgr = nullptr; @@ -6353,7 +7182,7 @@ void CCNotePad::slot_nextHexPage() { ScintillaEditView* pEdit = dynamic_cast(pw); showBigTextFile(pEdit, fileMgr); - pEdit->showBigTextLineAddr(fileMgr->fileOffset - fileMgr->contentRealSize); + pEdit->showBigTextLineAddr(fileMgr->fileOffset - fileMgr->contentRealSize, fileMgr->fileOffset); } else if (1 == ret) { @@ -6361,8 +7190,21 @@ void CCNotePad::slot_nextHexPage() QApplication::beep(); } } + else if (pw != nullptr && (BIG_TEXT_RO_TYPE == getDocTypeProperty(pw))) + { + QString filePath = getFilePathProperty(pw); + BigTextEditFileMgr* fileMgr = FileManager::getInstance().getBigFileEditMgr(filePath); + if (fileMgr != nullptr) + { + ScintillaEditView* pEdit = dynamic_cast(pw); + + int id = fileMgr->m_curBlockIndex + 1; + showBigTextFile(pEdit, fileMgr, id); +} + } } +//菜单上面的GOTO按钮的执行槽函数 void CCNotePad::slot_gotoHexPage() { if (m_pHexGotoWin.isNull()) @@ -6377,21 +7219,31 @@ void CCNotePad::slot_gotoHexPage() registerEscKeyShort(m_pHexGotoWin); } + + + QWidget* pw = ui.editTabWidget->currentWidget(); + if (pw != nullptr && (HEX_TYPE == getDocTypeProperty(pw))) + { m_pHexGotoWin.data()->activateWindow(); m_pHexGotoWin.data()->show(); #ifdef uos adjustWInPos(m_pHexGotoWin.data()); #endif - - QWidget* pw = ui.editTabWidget->currentWidget(); - if (pw != nullptr && (HEX_TYPE == getDocTypeProperty(pw))) - { - } - else if (pw != nullptr && (BIG_TEXT_TYPE == getDocTypeProperty(pw))) + else if (pw != nullptr && (SUPER_BIG_TEXT_RO_TYPE == getDocTypeProperty(pw))) { - + m_pHexGotoWin.data()->activateWindow(); + m_pHexGotoWin.data()->show(); + +#ifdef uos + adjustWInPos(m_pHexGotoWin.data()); +#endif + } + else if (pw != nullptr && (BIG_TEXT_RO_TYPE == getDocTypeProperty(pw))) + { + //这里直接按跳转到行号进行处理 + slot_gotoline(); } else { @@ -6428,7 +7280,7 @@ void CCNotePad::slot_hexGotoFile(qint64 addr) QApplication::beep(); } } - else if (pw != nullptr && (BIG_TEXT_TYPE == getDocTypeProperty(pw))) + else if (pw != nullptr && (SUPER_BIG_TEXT_RO_TYPE == getDocTypeProperty(pw))) { QString filePath = getFilePathProperty(pw); TextFileMgr *fileMgr = nullptr; @@ -6446,7 +7298,7 @@ void CCNotePad::slot_hexGotoFile(qint64 addr) { ScintillaEditView* pEdit = dynamic_cast(pw); showBigTextFile(pEdit, fileMgr); - pEdit->showBigTextLineAddr(fileMgr->fileOffset - fileMgr->contentRealSize); + pEdit->showBigTextLineAddr(fileMgr->fileOffset - fileMgr->contentRealSize, fileMgr->fileOffset); } else if (-2 == ret) { @@ -6573,7 +7425,7 @@ bool CCNotePad::eventFilter(QObject * watched, QEvent * event) } return false; } - + #ifdef Q_OS_WIN static const ULONG_PTR CUSTOM_TYPE = 10000; @@ -6581,16 +7433,16 @@ static const ULONG_PTR OPEN_NOTEPAD_TYPE = 10001; bool CCNotePad::nativeEvent(const QByteArray & eventType, void * message, long * result) { - MSG *param = static_cast(message); - - switch (param->message) - { - case WM_COPYDATA: - { - COPYDATASTRUCT *cds = reinterpret_cast(param->lParam); - if (cds->dwData == CUSTOM_TYPE) - { - QString openFilePath = QString::fromUtf8(reinterpret_cast(cds->lpData), cds->cbData); + MSG *param = static_cast(message); + + switch (param->message) + { + case WM_COPYDATA: + { + COPYDATASTRUCT *cds = reinterpret_cast(param->lParam); + if (cds->dwData == CUSTOM_TYPE) + { + QString openFilePath = QString::fromUtf8(reinterpret_cast(cds->lpData), cds->cbData); int retIndex = findFileIsOpenAtPad(openFilePath); if (-1 == retIndex) @@ -6622,9 +7474,9 @@ bool CCNotePad::nativeEvent(const QByteArray & eventType, void * message, long * this->activateWindow(); - *result = 1; - return true; - } + *result = 1; + return true; + } else if (cds->dwData == OPEN_NOTEPAD_TYPE) { activateWindow(); @@ -6632,8 +7484,8 @@ bool CCNotePad::nativeEvent(const QByteArray & eventType, void * message, long * *result = 1; return true; - } - } + } + } } return QWidget::nativeEvent(eventType, message, result); @@ -6697,7 +7549,7 @@ void CCNotePad::slot_txtFontChange(QFont &font) pw = ui.editTabWidget->widget(i); int docType = getDocTypeProperty(pw); - if ((TXT_TYPE == docType) || (BIG_TEXT_TYPE == docType)) + if ((TXT_TYPE == docType) || (BIG_TEXT_RO_TYPE == docType)) { ScintillaEditView* pEdit = dynamic_cast(pw); if (pEdit != nullptr ) @@ -6734,7 +7586,7 @@ void CCNotePad::slot_proLangFontChange(QFont &font) pw = ui.editTabWidget->widget(i); int docType = getDocTypeProperty(pw); - if ((TXT_TYPE == docType) || (BIG_TEXT_TYPE == docType)) + if ((TXT_TYPE == docType) || (BIG_TEXT_RO_TYPE == docType)) { ScintillaEditView* pEdit = dynamic_cast(pw); if (pEdit != nullptr) @@ -6763,7 +7615,7 @@ void CCNotePad::slot_tabFormatChange(bool tabLenChange, bool useTabChange) pw = ui.editTabWidget->widget(i); docType = getDocTypeProperty(pw); - if ((TXT_TYPE == docType) || (BIG_TEXT_TYPE == docType)) + if ((TXT_TYPE == docType) || (BIG_TEXT_RO_TYPE == docType) || (SUPER_BIG_TEXT_RO_TYPE == docType)) { ScintillaEditView* pEdit = dynamic_cast(pw); if (pEdit != nullptr) @@ -6888,6 +7740,7 @@ void CCNotePad::slot_viewStyleChange(QString tag, int styleId, QColor& fgColor, void CCNotePad::slot_viewLexerChange(QString tag) { + int lexerId = -1; for (int i = ui.editTabWidget->count() - 1; i >= 0; --i) { QWidget* pw = ui.editTabWidget->widget(i); @@ -6896,10 +7749,12 @@ void CCNotePad::slot_viewLexerChange(QString tag) { QsciLexer* lexer = pEdit->lexer(); + if (lexer != nullptr && lexer->lexerTag() == tag) { + lexerId = lexer->lexerId(); delete lexer; - autoSetDocLexer(pEdit); + autoSetDocLexer(pEdit, lexerId); } } } @@ -6940,8 +7795,15 @@ void CCNotePad::restoreDirtyNewFile(QString& fileName, QString& tempFilePath, in syncCurDocLexerToMenu(pEdit); } } + setTextChangeProperty(pEdit,true); m_saveFile->setEnabled(true); m_saveAllFile->setEnabled(true); + + int tabIndex = ui.editTabWidget->indexOf(pEdit); + if (tabIndex != -1) + { + ui.editTabWidget->setTabIcon(tabIndex, QIcon(TabNeedSave)); +} } //4 脏的老文件。内容在tempFilePath中 @@ -7058,6 +7920,11 @@ bool CCNotePad::restoreDirtyExistFile(QString& filePath, QString& tempFilePath) setTextChangeProperty(pEdit, isChange); + if (isChange) + { + ui.editTabWidget->setTabIcon(curIndex, QIcon(TabNeedSave)); + } + QVariant editTextCode((int)code); pEdit->setProperty(Edit_Text_Code, editTextCode); @@ -7127,15 +7994,23 @@ int CCNotePad::restoreLastFiles() qs.setIniCodec("UTF-8"); QStringList fileList = qs.allKeys(); - //从小到大排序一下 - fileList.sort(); + //从小到大排序一下。这里是按照ASCII排序,不得行。 + // 需要转换为数字0-N进行排序,否则排序结果错误。 + QList fileIdList; + for (int i = 0; i < fileList.size(); ++i) + { + fileIdList.append(fileList.at(i).toInt()); + } + std::sort(fileIdList.begin(), fileIdList.end(), [](int& a, int& b) { + return a < b; + }); - QString key; + int key; QString value; - foreach(key, fileList) + foreach(key, fileIdList) { - value = qs.value(key).toString(); + value = qs.value(QString::number(key)).toString(); if (!value.isEmpty()) { bool ok = false; @@ -7926,8 +8801,10 @@ void CCNotePad::slot_clearHistoryOpenList() { for (QMap ::iterator it = m_receneOpenFile.begin(); it != m_receneOpenFile.end(); ++it) { + ui.menuFile->removeAction(*it); delete (*it); } + m_receneOpenFile.clear(); m_receneOpenFileList.clear(); @@ -7974,6 +8851,13 @@ void CCNotePad::updateThemes() } } } + + //切换主题后,如果存在查找框,则暴力关闭一下,因为查找框的颜色实时生效还存在问题 + if (m_dockSelectTreeWin != nullptr) + { + m_dockSelectTreeWin->deleteLater(); + m_dockSelectTreeWin = nullptr; +} } void CCNotePad::setGlobalFgColor(int style) @@ -8014,3 +8898,26 @@ void CCNotePad::setGlobalFont(int style) } } } + +//文件后缀的编程语法关联 +void CCNotePad::slot_langFileSuffix() +{ + LangExtSet* pWin = new LangExtSet(this); + pWin->setAttribute(Qt::WA_DeleteOnClose); +#ifdef uos + adjustWInPos(pWin); +#endif + pWin->show(); +} + +//快捷键管理 +void CCNotePad::slot_shortcutManager() +{ + ShortcutKeyMgr* pWin = new ShortcutKeyMgr(this); + pWin->setAttribute(Qt::WA_DeleteOnClose); +#ifdef uos + adjustWInPos(pWin); +#endif + pWin->show(); +} + diff --git a/src/cceditor/ccnotepad.h b/src/cceditor/ccnotepad.h index 62e640a..b4c51cd 100755 --- a/src/cceditor/ccnotepad.h +++ b/src/cceditor/ccnotepad.h @@ -33,12 +33,15 @@ class CompareDirs; class CompareWin; struct HexFileMgr; struct TextFileMgr; +struct BigTextEditFileMgr; enum OpenAttr { Text = 1, HexReadOnly, BigTextReadOnly, + BigTextReadWrite, + SuperBigTextReadOnly, TextReadOnly }; @@ -58,7 +61,24 @@ enum LINE_SORT_TYPE { SORTLINES_REVERSE_ORDER, }; +struct FileExtLexer +{ + QString ext; + LangType id; +}; +const int FileExtMapLexerIdLen = L_EXTERNAL; + +//1 文本 2 hex +enum NddDocType { + TXT_TYPE = 1, + //BIG_TEXT_RO_TYPE,//大文本,只读模式 BIG_TEXT_RO_TYPE。是只读模式 + BIG_TEXT_RO_TYPE,//大文本,只读模式,可以显示行号,可以跳转。理论上4G-8G比较合适。再大就属于超大文本 + BIG_EDIT_RW_TYPE,//大文本,读写模式。目前还不支持 + SUPER_BIG_TEXT_RO_TYPE,//超大文本,只读模式,理论上任意多大文件都可以。不一定支持行号。4G以上的文件。 + + HEX_TYPE, +}; //打开模式。1 文本 2 二进制 3 大文本只读 4 文本只读 //const char* Open_Attr = "openid"; @@ -93,7 +113,8 @@ public: #endif bool openFile(QString filePath); - + bool tryRestoreFile(QString filePath); + void initTabNewOne(); void setShareMem(QSharedMemory* v) @@ -132,9 +153,11 @@ public: void setGlobalFont(int style); void changeMarkColor(int sytleId); + void setUserDefShortcutKey(int shortcutId); signals: void signSendRegisterKey(QString key); void signRegisterReplay(int code); + void signLinkNetServer(); public slots: void slot_changeChinese(); void slot_changeEnglish(); @@ -324,10 +347,13 @@ private slots: void slot_showToolBar(bool); void slot_dynamicLoadToolMenu(); void slot_batchFind(); +#ifdef NO_PLUGIN void slot_pluginMgr(); - void slot_showWebAddr(bool check); void onPlugWork(bool check); - +#endif + void slot_showWebAddr(bool check); + void slot_langFileSuffix(); + void slot_shortcutManager(); private: void initFindResultDockWin(); @@ -345,6 +371,7 @@ private: void initReceneOpenFileMenu(); int findFileIsOpenAtPad(QString filePath); + bool isNewFileNameExist(QString& fileName); void updateCurTabSaveStatus(); void setSaveButtonStatus(bool needSave); void setSaveAllButtonStatus(bool needSave); @@ -359,7 +386,7 @@ private: void cmpSelectFile(); - void autoSetDocLexer(ScintillaEditView * pEdit); + void autoSetDocLexer(ScintillaEditView * pEdit, int defLexerId=-1); void updateTitleToCurDocFilePath(); void addWatchFilePath(QString filePath); @@ -367,7 +394,7 @@ private: bool checkRoladFile(ScintillaEditView * pEdit); void reloadEditFile(ScintillaEditView * pEidt); - void initFindWindow(); + void initFindWindow(FindTabIndex type= FIND_TAB); void setToFileRightMenu(); @@ -375,15 +402,19 @@ private: bool reloadTextFileWithCode(CODE_ID code); - bool openBigTextFile(QString filePath); + bool openSuperBigTextFile(QString filePath); + + bool openBigTextRoFile(QString filePath); void setWindowTitleMode(QString filePath, OpenAttr attr); bool openTextFile(QString filePath, bool isCheckHex = true, CODE_ID code=CODE_ID::UNKOWN); bool openHexFile(QString filePath); + bool showHexFile(ScintillaHexEditView * pEdit, HexFileMgr * hexFile); bool showBigTextFile(ScintillaEditView * pEdit, TextFileMgr * hexFile); + bool showBigTextFile(ScintillaEditView* pEdit, BigTextEditFileMgr* txtFile, int blockIndex); void initNotePadSqlOptions(); void saveNotePadSqlOptions(); @@ -419,9 +450,15 @@ private: void tabClose(QWidget* pEdit); void init_toolsMenu(); + +#ifdef NO_PLUGIN void loadPluginLib(); void loadPluginProcs(QString strLibDir, QMenu* pMenu); void onPlugFound(NDD_PROC_DATA& procData, QMenu* pUserData); +#endif + + void setUserDefShortcutKey(); + void setNormalTextEditInitPro(ScintillaEditView* pEdit, QString filePath, CODE_ID code, RC_LINE_FORM lineEnd, bool isReadOnly, bool isModifyed); private: Ui::CCNotePad ui; @@ -507,6 +544,7 @@ private: static int s_showblank; //显示空白 static int s_zoomValue; + QTranslator* m_translator; QTimer * m_timerAutoSave; @@ -539,6 +577,9 @@ private: QToolButton* m_transcode; QToolButton* m_rename; + QAction* m_formatXml; + QAction* m_formatJson; + QPointer m_batchFindWin; diff --git a/src/cceditor/ccnotepad.ui b/src/cceditor/ccnotepad.ui index 62847ef..2062894 100755 --- a/src/cceditor/ccnotepad.ui +++ b/src/cceditor/ccnotepad.ui @@ -363,7 +363,6 @@ - @@ -1583,7 +1582,7 @@ - Language Format + Theme Style @@ -2024,6 +2023,16 @@ Show Web Addr(Not recommended) + + + Language File Suffix + + + + + Shortcut Key Manager + + @@ -3406,6 +3415,38 @@ + + actionLanguage_File_Suffix + triggered() + CCNotePad + slot_langFileSuffix() + + + -1 + -1 + + + 728 + 394 + + + + + actionShortcut_Key_Manager + triggered() + CCNotePad + slot_shortcutManager() + + + -1 + -1 + + + 728 + 394 + + + slot_actionNewFile_toggle(bool) @@ -3507,5 +3548,7 @@ slot_fileListView(bool) slot_showToolBar(bool) slot_showWebAddr(bool) + slot_langFileSuffix() + slot_shortcutManager() diff --git a/src/cceditor/filemanager.cpp b/src/cceditor/filemanager.cpp index f93a9c9..725c360 100755 --- a/src/cceditor/filemanager.cpp +++ b/src/cceditor/filemanager.cpp @@ -3,6 +3,7 @@ #include "scintillahexeditview.h" #include "CmpareMode.h" #include "ccnotepad.h" +#include "progresswin.h" #include #include @@ -31,7 +32,10 @@ ScintillaHexEditView* FileManager::newEmptyHexDocument() } //从尾部找前面的换行符号。返回的是需要回溯的个数 -int findLineEndPos(const char* buf, int size) +//注意如果是LE编码,字节流是\n\0的格式。从尾部往前回溯,找到\n,要回退1个\0。\n\0是一个整体,不能分割开 +//20230201发现一个bug,在LE模式下,不能单纯用\n做换行识别。因为发现其它字符也存在\n,必须要完整以\n\0才能确定是换行。 +//同样发现BE模式下,是\0\n的格式,也不能单独使用\n做换行识别,因为发现其他字符也存在\n,必须要完整以\0\n才能确定是换行 +int findLineEndPos(const char* buf, int size, CODE_ID code = UNKOWN) { int ret = 0; bool isfound = false; @@ -39,6 +43,18 @@ int findLineEndPos(const char* buf, int size) { if (buf[i] == '\n') { + ////如果是LE,还要确定\n的下一个是否是\0 + if ((code == UNICODE_LE) && ((i != size -1) && (buf[i+1] != '\0'))) + { + ++ret; + continue; + } + ////如果是BE,还要确定\n的前一个是否是\0 + if ((code == UNICODE_BE) && ((i != 0) && (buf[i - 1] != '\0'))) + { + ++ret; + continue; + } isfound = true; break; } @@ -52,6 +68,16 @@ int findLineEndPos(const char* buf, int size) { if (buf[i] == '\r') { + ////如果是LE,还要确定\n的下一个是否是\0 + if ((code == UNICODE_LE) && ((i != size - 1) && (buf[i + 1] != '\0'))) + { + continue; + } + ////如果是BE,还要确定\n的前一个是否是\0 + if ((code == UNICODE_BE) && ((i != 0) && (buf[i - 1] != '\0'))) + { + continue; + } isfound = true; break; } @@ -61,6 +87,13 @@ int findLineEndPos(const char* buf, int size) if (isfound) { + //注意好好想想,这里是--ret,而不是++ret。 + if (code == UNICODE_LE) + { + --ret; + } + //UNICODE_BE不需要处理 + return ret; } @@ -69,7 +102,7 @@ int findLineEndPos(const char* buf, int size) } //从行首找后面的换行符号。返回的是需要前进的个数,即把前面掐掉一节,让返回在一行的行首位置 -int findLineStartPos(const char* buf, int size) +int findLineStartPos(const char* buf, int size, CODE_ID code = UNKOWN) { int ret = 0; bool isfound = false; @@ -78,6 +111,17 @@ int findLineStartPos(const char* buf, int size) ++ret; if (buf[i] == '\n') { + ////如果是LE,还要确定\n的下一个是否是\0 + if ((code == UNICODE_LE) && ((i != size - 1) && (buf[i + 1] != '\0'))) + { + continue; + } + ////如果是BE,还要确定\n的前一个是否是\0 + if ((code == UNICODE_BE) && ((i != 0) && (buf[i - 1] != '\0'))) + { + continue; + } + isfound = true; break; } @@ -91,6 +135,16 @@ int findLineStartPos(const char* buf, int size) ++ret; if (buf[i] == '\r') { + ////如果是LE,还要确定\n的下一个是否是\0 + if ((code == UNICODE_LE) && ((i != size - 1) && (buf[i + 1] != '\0'))) + { + continue; + } + ////如果是BE,还要确定\n的前一个是否是\0 + if ((code == UNICODE_BE) && ((i != 0) && (buf[i - 1] != '\0'))) + { + continue; + } isfound = true; break; } @@ -99,6 +153,11 @@ int findLineStartPos(const char* buf, int size) if (isfound) { + //注意好好想想,这里是++ret,而不是--ret。 + if (code == UNICODE_LE) + { + ++ret; + } return ret; } @@ -451,6 +510,11 @@ int FileManager::loadFilePreNextPage(int dir, QString& filePath, HexFileMgr* & { hexFileOut = m_hexFileMgr.value(filePath); + //小于LITTLE_FILE_MAX的已经一次性全部在内存,没有上下页可以翻到 + if (hexFileOut->onetimeRead) + { + return 1; + } qint64 pos = hexFileOut->fileOffset; if (dir == 1 && (pos >= 0)) @@ -468,7 +532,7 @@ int FileManager::loadFilePreNextPage(int dir, QString& filePath, HexFileMgr* & } else { - return 1; + return 1;//没有上下页,已经是最后一页或最前一页 } char* buf = new char[ONE_PAGE_BYTES+1]; @@ -497,7 +561,7 @@ int FileManager::loadFilePreNextPage(int dir, QString& filePath, HexFileMgr* & return -1; } -const int ONE_PAGE_TEXT_SIZE = 200 * 1024; +const int ONE_PAGE_TEXT_SIZE = 1000 * 1024; //加载下一页或者上一页。(文本模式) //返回值:0表示成功 @@ -555,13 +619,14 @@ int FileManager::loadFilePreNextPage(int dir, QString& filePath, TextFileMgr* & if (dir == 2) { //读取了1M的内容,从内容尾部往前查找,找到第一个换行符号。如果没有怎么办?说明是一个巨长的行,不妙 + //如果是巨长的行,一行超过ONE_PAGE_TEXT_SIZE(1M),则可能存在单个字符截断的可能。 buf[ret] = '\0'; int preLineEndPos = 0; if (textFileOut->file->pos() < textFileOut->fileSize)//反之已经到尾部了,不需要往前找行首了 { - preLineEndPos = findLineEndPos(buf, ret); + preLineEndPos = findLineEndPos(buf, ret, (CODE_ID)textFileOut->loadWithCode); if (preLineEndPos > 0) { //给后面的字符填\0,让字符串正常结尾\0 @@ -587,14 +652,14 @@ int FileManager::loadFilePreNextPage(int dir, QString& filePath, TextFileMgr* & else if (dir == 1) { //如果是往前读取 - //读取了1M的内容,往内容前面往后查找,找到第一个换行符号。如果没有怎么办?说明是一个巨长的行,不妙 + //读取了1M的内容,从内容前面往后查找,找到第一个换行符号。如果没有怎么办?说明是一个巨长的行,不妙 buf[ret] = '\0'; int preLineStartPos = 0; if (textFileOut->file->pos() > canReadSize)//==canReadSize说明已经在文件最前面了。不在最前面,需要 { - preLineStartPos = findLineStartPos(buf, ret); + preLineStartPos = findLineStartPos(buf, ret, (CODE_ID)textFileOut->loadWithCode); if (preLineStartPos > 0) { //把\n前面的内容去掉,通过内存move的方式。 @@ -693,7 +758,7 @@ int FileManager::loadFileFromAddr(QString filePath, qint64 addr, TextFileMgr* & if (textFileOut->file->pos() < textFileOut->fileSize)//反之已经到尾部了,不需要往前找行了 { - preLineEndPos = findLineEndPos(buf, ret); + preLineEndPos = findLineEndPos(buf, ret, (CODE_ID)textFileOut->loadWithCode); if (preLineEndPos > 0) { //给后面的字符填\0,让字符串正常结尾\0 @@ -701,7 +766,16 @@ int FileManager::loadFileFromAddr(QString filePath, qint64 addr, TextFileMgr* & } } - int preLineStartPos = findLineStartPos(buf, ret); + //如果本来就在开头开始,则不需要计算findLineStartPos + int preLineStartPos = 0; + + if (addr == 0) + { + + } + else + { + preLineStartPos = findLineStartPos(buf, ret, (CODE_ID)textFileOut->loadWithCode); if (preLineStartPos > 0 && preLineStartPos < ret) //preLineStartPos如果大于ret,则全部都被跳过了,不会显示,是个特例 { memmove(buf, buf + preLineStartPos, ret - preLineStartPos); @@ -712,7 +786,8 @@ int FileManager::loadFileFromAddr(QString filePath, qint64 addr, TextFileMgr* & //如果没做调整,则后续不需要偏移,这里必须preLineStartPos赋0值 preLineStartPos = 0; } - + } + //只需要文件调到上一行的行位即可。 textFileOut->fileOffset = textFileOut->file->pos() - preLineEndPos; if (preLineEndPos > 0) @@ -745,8 +820,7 @@ bool FileManager::loadFileData(QString filePath, HexFileMgr* & hexFileOut) return false; } - //小于10k的文件一次性全部读取完毕 - const int LITTLE_FILE_MAX = 10240; + int readBytes = 0; @@ -783,6 +857,7 @@ bool FileManager::loadFileData(QString filePath, HexFileMgr* & hexFileOut) hexFile->fileSize = file->size(); hexFile->contentBuf = buf; hexFile->contentRealSize = ret; + hexFile->onetimeRead = (file->size() <= LITTLE_FILE_MAX); m_hexFileMgr.insert(filePath, hexFile); } else @@ -792,6 +867,7 @@ bool FileManager::loadFileData(QString filePath, HexFileMgr* & hexFileOut) hexFile->fileOffset = file->pos(); hexFile->contentBuf = buf; hexFile->contentRealSize = ret; + hexFile->onetimeRead = (file->size() <= LITTLE_FILE_MAX); } hexFileOut = hexFile; @@ -830,7 +906,10 @@ bool FileManager::loadFileData(QString filePath, TextFileMgr* & textFileOut, RC_ //读取了1M的内容,从尾部往找,找到第一个换行符号。如果没有怎么办?说明是一个巨长的行,不妙 buf[ret] = '\0'; - int preLineEndPos = findLineEndPos(buf,ret); + + CODE_ID code = CmpareMode::getTextFileEncodeType((uchar*)buf, ret, filePath, true); + + int preLineEndPos = findLineEndPos(buf,ret, code); if (preLineEndPos > 0) { //给后面的字符填\0,让字符串正常结尾\0 @@ -858,6 +937,8 @@ bool FileManager::loadFileData(QString filePath, TextFileMgr* & textFileOut, RC_ if (!m_bigTxtFileMgr.contains(filePath)) { txtFile = new TextFileMgr(); + txtFile->loadWithCode = code; + txtFile->filePath = filePath; txtFile->file = file; txtFile->fileOffset = file->pos() - preLineEndPos; @@ -889,6 +970,227 @@ bool FileManager::loadFileData(QString filePath, TextFileMgr* & textFileOut, RC_ return false; } +//返回行的数量 +int getLineNumInBuf(char* buf, int size, CODE_ID code = UNKOWN) +{ + int lineNums = 0; + + for (int i = 0; i < size; ++i) + { + if (buf[i] == '\n') + { + ////如果是LE,还要确定\n的下一个是否是\0 + if ((code == UNICODE_LE) && ((i != size - 1) && (buf[i + 1] != '\0'))) + { + continue; + } + //如果是BE,简单\0\n是否连续存在,不能单纯检查\n,还有确定\n的前一个是不是\0 + if ((code == UNICODE_BE) && ((i != 0) && (buf[i - 1] != '\0'))) + { + continue; + } + ++lineNums; + } + } + + //如果没有找到,怀疑是mac格式,按照\r结尾解析 + if (lineNums == 0) + { + for (int i = 0; i < size; ++i) + { + if (buf[i] == '\r') + { + ////如果是LE,还要确定\n的前面一个是否是\0 + if ((code == UNICODE_LE) && ((i != size - 1) && (buf[i + 1] != '\0'))) + { + continue; + } + //如果是BE,简单\0\n是否连续存在,不能单纯检查\n,还有确定\n的前一个是不是\0 + if ((code == UNICODE_BE) && ((i != 0) && (buf[i - 1] != '\0'))) + { + continue; + } + ++lineNums; + } + } + } + + return lineNums; +} + +//创建大文件编辑模式的索引文件。0 成功,-1取消 +int FileManager::createBlockIndex(BigTextEditFileMgr* txtFile) +{ + //每次filePtr 4M的速度进行建块 + qint64 fileSize = txtFile->file->size(); + + qint64 curOffset = 0; + + uchar* curPtr = txtFile->filePtr; + + //检测是否为unicode_le编码,要特殊对待。 + //bool isUnLeCode = CmpareMode::isUnicodeLeBomFile(curPtr, 2); + + CODE_ID code = CmpareMode::getTextFileEncodeType(curPtr, fileSize, txtFile->filePath, true); + txtFile->loadWithCode = code; + + const int blockBytes = BigTextEditFileMgr::BLOCK_SIZE * 1024 * 1024; + + int lineEndPos = 0; + + int steps = fileSize / blockBytes; + + txtFile->blocks.reserve(steps + 10); + + ProgressWin* loadFileProcessWin = nullptr; + + if (steps > 200) + { + loadFileProcessWin = new ProgressWin(nullptr); + + loadFileProcessWin->setWindowModality(Qt::ApplicationModal); + + loadFileProcessWin->info(tr("load bit text file tree in progress\nfile size %1, please wait ...").arg(tranFileSize(fileSize))); + + loadFileProcessWin->setTotalSteps(steps); + + loadFileProcessWin->show(); + } + + quint32 lineNumStart = 0; + quint32 lineNum = 0; + + while ((curOffset + blockBytes) < fileSize) + { + BlockIndex bi; + bi.fileOffset = curOffset; + + curOffset += blockBytes; + + lineEndPos = findLineEndPos((char*)curPtr+ bi.fileOffset, blockBytes, code); + + bi.fileSize = blockBytes - lineEndPos; + + lineNum = getLineNumInBuf((char*)curPtr + bi.fileOffset, bi.fileSize, code); + + curOffset -= lineEndPos; + + bi.lineNum = lineNum; + bi.lineNumStart = lineNumStart; + + lineNumStart += lineNum; + + txtFile->blocks.append(bi); + + if (loadFileProcessWin != nullptr) + { + if (loadFileProcessWin->isCancel()) + { + delete loadFileProcessWin; + txtFile->blocks.clear(); + return -1; + } + loadFileProcessWin->moveStep(true); + } + + } + //最后一块 + int lastBlockBytes = fileSize - curOffset; + + BlockIndex bi; + bi.fileOffset = curOffset; + + curOffset += lastBlockBytes; + + bi.fileSize = lastBlockBytes; + + lineNum = getLineNumInBuf((char*)curPtr + bi.fileOffset, bi.fileSize); + + bi.lineNum = lineNum; + bi.lineNumStart = lineNumStart; + + txtFile->blocks.append(bi); + + if (loadFileProcessWin != nullptr) + { + delete loadFileProcessWin; + } + + return 0; +} + +//加载大文件,以索引的方式打开大文件 +bool FileManager::loadFileDataWithIndex(QString filePath, BigTextEditFileMgr*& textFileOut) +{ + QFile* file = new QFile(filePath); + file->open(QIODevice::ReadOnly); + + + uchar* filePtr = file->map(0, file->size()); + + BigTextEditFileMgr* txtFile = nullptr; + + if (!m_bigTxtEditFileMgr.contains(filePath)) + { + txtFile = new BigTextEditFileMgr(); + txtFile->filePath = filePath; + txtFile->file = file; + txtFile->filePtr = filePtr; + textFileOut = txtFile; + + if (-1 == createBlockIndex(txtFile)) + { + //取消。 + delete txtFile; + txtFile = nullptr; + return false; + } + m_bigTxtEditFileMgr.insert(filePath, txtFile); + } + else + { + //理论上这里永远不走 + assert(false); + } + + return true; +} + +BigTextEditFileMgr* FileManager::getBigFileEditMgr(QString filepath) +{ + if (m_bigTxtEditFileMgr.contains(filepath)) + { + return m_bigTxtEditFileMgr.value(filepath); + } + + return nullptr; +} + +TextFileMgr* FileManager::getSuperBigFileMgr(QString filepath) +{ + if (m_bigTxtFileMgr.contains(filepath)) + { + return m_bigTxtFileMgr.value(filepath); + } + + return nullptr; +} + +int FileManager::getBigFileBlockId(QString filepath, quint32 lineNum) +{ + BigTextEditFileMgr* v = m_bigTxtEditFileMgr.value(filepath); + + for (int i = 0, s = v->blocks.size(); i < s; ++i) + { + const BlockIndex& k = v->blocks.at(i); + if (lineNum >= k.lineNumStart && lineNum < (k.lineNumStart + k.lineNum)) + { + return i; + } + } + return -1; +} + HexFileMgr * FileManager::getHexFileHand(QString filepath) { if (m_hexFileMgr.contains(filepath)) @@ -910,7 +1212,7 @@ void FileManager::closeHexFileHand(QString filepath) } } -void FileManager::closeBigTextFileHand(QString filepath) +void FileManager::closeSuperBigTextFileHand(QString filepath) { if (m_bigTxtFileMgr.contains(filepath)) { @@ -921,6 +1223,16 @@ void FileManager::closeBigTextFileHand(QString filepath) } } +void FileManager::closeBigTextRoFileHand(QString filepath) +{ + if (m_bigTxtEditFileMgr.contains(filepath)) + { + BigTextEditFileMgr* v = m_bigTxtEditFileMgr.value(filepath); + v->destory(); + delete v; + m_bigTxtEditFileMgr.remove(filepath); + } +} //检查文件的编程语言 LangType FileManager::detectLanguageFromTextBegining(const unsigned char *data, size_t dataLen) diff --git a/src/cceditor/filemanager.h b/src/cceditor/filemanager.h index 78a9f9f..95f829a 100755 --- a/src/cceditor/filemanager.h +++ b/src/cceditor/filemanager.h @@ -11,6 +11,9 @@ class ScintillaEditView; class ScintillaHexEditView; +//С100kļһȫȡ +const int LITTLE_FILE_MAX = 1024000; + enum ERROR_TYPE { NONE_ERROR=-1, OPEN_EMPTY_FILE=0, @@ -35,7 +38,8 @@ struct HexFileMgr { qint16 lineSize;//ÿζȡУĬΪ64Уû16ַ char* contentBuf; int contentRealSize; - HexFileMgr() :file(nullptr), fileOffset(0), lineSize(64), fileSize(0), contentBuf(nullptr), contentRealSize(0) + bool onetimeRead; //Ƿһȫȡڴ档СڵLITTLE_FILE_MAXIJŻȫȡ + HexFileMgr() :file(nullptr), fileOffset(0), lineSize(64), fileSize(0), contentBuf(nullptr), contentRealSize(0),onetimeRead(false) { } @@ -67,7 +71,10 @@ struct TextFileMgr { qint16 lineSize;//ÿζȡУĬÿζȡ1024С󲻳1Mݡ char* contentBuf; int contentRealSize; - TextFileMgr() :file(nullptr), fileOffset(0), lineSize(64), fileSize(0), contentBuf(nullptr), contentRealSize(0) + int loadWithCode; + int lineEndType;//βͣwin linux mac + + TextFileMgr() :file(nullptr), fileOffset(0), lineSize(64), fileSize(0), contentBuf(nullptr), contentRealSize(0), loadWithCode(CODE_ID::UNKOWN),lineEndType(RC_LINE_FORM::UNKNOWN_LINE) { } @@ -90,6 +97,47 @@ private: TextFileMgr(const TextFileMgr&) = delete; }; +struct BlockIndex { + qint64 fileOffset;//Ŀʼַ + quint32 fileSize;//ĴС + quint32 lineNumStart;//кŵĿʼֵ + quint32 lineNum;//е +}; + +//ıļ,Ա༭Ϣ +struct BigTextEditFileMgr { + QString filePath; + QFile* file; + uchar* filePtr;//ʹõļӳķʽ + quint32 m_curBlockIndex; //ǰչʾеĿ + int loadWithCode; //ԺֱؽļĬUTF8 + int lineEndType;//βͣwin linux mac + static const qint16 BLOCK_SIZE = 1;//СλMʼ4MֿԽԽ࣬ôһжλеλԽ + + QVector blocks;//ÿһļʱҪ + + BigTextEditFileMgr():filePtr(nullptr), file(nullptr), m_curBlockIndex(0), loadWithCode(CODE_ID::UNKOWN), lineEndType(RC_LINE_FORM::UNKNOWN_LINE) + { + } + void destory() + { + if (filePtr != nullptr) + { + if (file != nullptr) + { + file->unmap(filePtr); + file->close(); + delete file; + file = nullptr; + } + filePtr = nullptr; + } + } +private: + BigTextEditFileMgr& operator=(const TextFileMgr&) = delete; + BigTextEditFileMgr(const TextFileMgr&) = delete; +}; + class CCNotePad; class FileManager:public QObject @@ -124,11 +172,21 @@ public: bool loadFileData(QString filePath, TextFileMgr *& textFileOut, RC_LINE_FORM & lineEnd); + bool loadFileDataWithIndex(QString filePath, BigTextEditFileMgr*& textFileOut); + HexFileMgr* getHexFileHand(QString filepath); + BigTextEditFileMgr* getBigFileEditMgr(QString filepath); + + TextFileMgr* getSuperBigFileMgr(QString filepath); + + int getBigFileBlockId(QString filepath, quint32 lineNum); + void closeHexFileHand(QString filepath); - void closeBigTextFileHand(QString filepath); + void closeSuperBigTextFileHand(QString filepath); + + void closeBigTextRoFileHand(QString filepath); LangType detectLanguageFromTextBegining(const unsigned char * data, size_t dataLen); @@ -150,6 +208,7 @@ public: private: FileManager(); ~FileManager(); + int createBlockIndex(BigTextEditFileMgr* txtFile); FileManager(const FileManager&) = delete; FileManager& operator=(const FileManager&) = delete; @@ -160,6 +219,8 @@ private: QMap m_bigTxtFileMgr; + QMap m_bigTxtEditFileMgr; + ERROR_TYPE m_lastErrorCode; }; diff --git a/src/doctypelistview.cpp b/src/doctypelistview.cpp index 46b3a79..3ab3ca2 100755 --- a/src/doctypelistview.cpp +++ b/src/doctypelistview.cpp @@ -19,7 +19,7 @@ QMap* DocTypeListView::s_binFileExts = nullptr; QStringList DocTypeListView::s_extBindFileType; QStringList HEX_FILE_EXTS_LIST = (QStringList() << "exe" << "dll" << "png" << "jpg" << "doc" << "docx" << "ppt" << "pptx" \ - << "zip" << "gz" << "rar" << "pdf" << "7z" << "lib" << "so" << "db" << "obj" << "pdb" << "bmp" << "ico" << "qm" << "icns" << "jpeg" << "res" << "exp" << "ilk" << "deb"); + << "zip" << "gz" << "rar" << "pdf" << "7z" << "lib" << "so" << "db" << "obj" << "bmp" << "ico" << "qm" << "icns" << "jpeg" << "res" << "exp" << "ilk" << "deb"); QStringList INIT_EXTS_TYPES = (QStringList() << ".txt:.log" << ".ini:.inf" << ".h:.hh:.hpp:.hxx:.c:.cpp:.cxx:.cc:.m:.mm:.vcxproj:.vcproj:.props:vsprops:mainfest:.go:.mod" \ << ".java:.cs:.pas:.pp:.inc" << ".html:.htm:.shtml:.shtm:.hta:.asp:.aspx:.css:.js:.json:.jsm:.jsp:.php:.php3:.php4:.php5:.phps:.phpt:.phtml:.xml:.xhtml:.xht:.xul:.kml:.xaml:.xsml" \ diff --git a/src/extLexermanager.cpp b/src/extLexermanager.cpp index f197b51..af9d2a1 100755 --- a/src/extLexermanager.cpp +++ b/src/extLexermanager.cpp @@ -60,3 +60,35 @@ bool ExtLexerManager::getLexerTypeByExt(QString ext, LexerInfo& lexer) } return false; } + +//гtagйļ׺б +void ExtLexerManager::getExtlistByLangTag(QString tag, QStringList& extList) +{ + for (QMap::iterator it = m_extToLexerIdMap.begin(); it != m_extToLexerIdMap.end(); ++it) + { + LexerInfo& v = it.value(); + if (v.tagName == tag) + { + extList.append(it.key()); + } + + } +} + +//гtagйļ׺б +void ExtLexerManager::getExtlistByLangTag(QMap& extLangMap) +{ + for (QMap::iterator it = m_extToLexerIdMap.begin(); it != m_extToLexerIdMap.end(); ++it) + { + LexerInfo& v = it.value(); + + if (extLangMap.contains(v.tagName)) + { + extLangMap[v.tagName].append(it.key()); + } + else + { + extLangMap[v.tagName] = QStringList(it.key()); + } + } +} diff --git a/src/extlexermanager.h b/src/extlexermanager.h index c6948b2..cc59df6 100755 --- a/src/extlexermanager.h +++ b/src/extlexermanager.h @@ -55,6 +55,13 @@ public: bool getLexerTypeByExt(QString ext, LexerInfo& lexer); + //гtagйļ׺б + void getExtlistByLangTag(QString tag, QStringList& extList); + + //гйļ׺б + void getExtlistByLangTag(QMap& extLangMap); + + private: ExtLexerManager(); diff --git a/src/findresultwin.cpp b/src/findresultwin.cpp index 7d86701..75af255 100755 --- a/src/findresultwin.cpp +++ b/src/findresultwin.cpp @@ -2,6 +2,8 @@ #include "findwin.h" #include "common.h" #include "styleset.h" +#include "nddsetting.h" + #include #include #include @@ -10,6 +12,7 @@ #include #include #include +#include #include "ndstyleditemdelegate.h" @@ -17,7 +20,7 @@ //使用Html的转义解决了该问题 FindResultWin::FindResultWin(QWidget *parent) - : QWidget(parent), m_menu(nullptr), m_parent(parent) + : QWidget(parent), m_menu(nullptr), m_parent(parent),m_defaultFontSize(14), m_defFontSizeChange(false) { ui.setupUi(this); @@ -47,10 +50,37 @@ FindResultWin::FindResultWin(QWidget *parent) // ui.resultTreeView->setStyleSheet(qss); connect(ui.resultTreeView, &QTreeView::doubleClicked, this, &FindResultWin::itemDoubleClicked); + + connect(ui.resultTreeView, SIGNAL(pressed(QModelIndex)), this, SLOT(slot_treeView_pressed(QModelIndex))); + connect(ui.resultTreeView, SIGNAL(expanded(QModelIndex)), this, SLOT(slot_treeView_pressed(QModelIndex))); + + ui.resultTreeView->verticalScrollBar()->setStyle(QStyleFactory::create("vis")); + ui.resultTreeView->horizontalScrollBar()->setStyle(QStyleFactory::create("vis")); + + int defFontSize = NddSetting::getKeyValueFromNumSets(FIND_RESULT_FONT_SIZE); + if (defFontSize >= 8) + { + m_defaultFontSize = defFontSize; + + QFont curFt = ui.resultTreeView->font(); + curFt.setPointSize(m_defaultFontSize); + ui.resultTreeView->setFont(curFt); + + m_delegate->setFontSize(m_defaultFontSize); +} } FindResultWin::~FindResultWin() { + if (m_defFontSizeChange) + { + NddSetting::updataKeyValueFromNumSets(FIND_RESULT_FONT_SIZE, m_defaultFontSize); +} +} + +void FindResultWin::slot_treeView_pressed(QModelIndex modeIndex) +{ + ui.resultTreeView->resizeColumnToContents(modeIndex.column()); } void FindResultWin::contextMenuEvent(QContextMenuEvent *) @@ -71,6 +101,8 @@ void FindResultWin::contextMenuEvent(QContextMenuEvent *) m_menu->addAction(tr("copy select Line (Ctrl Muli)"), this, &FindResultWin::slot_copyContents); m_menu->addSeparator(); + m_menu->addAction(tr("Zoom In"), this, &FindResultWin::slot_fontZoomIn); + m_menu->addAction(tr("Zoom Out"), this, &FindResultWin::slot_fontZoomOut); m_menu->addAction(tr("close"), m_parent, &QWidget::close); } @@ -370,7 +402,7 @@ void FindResultWin::highlightFindText(int index, QString &srcText, QString &find } index--; } - srcText.replace(pos, lens, QString("%1").arg(srcText.mid(pos,lens))); + srcText.replace(pos, lens, QString("%1").arg(srcText.mid(pos,lens))); } const int MAX_HEAD_LENTGH = 20; @@ -403,9 +435,9 @@ QString FindResultWin::highlightFindText(FindRecord& record) { if (!isNeedCut) { - head = QString(utf8bytes.mid(0, targetStart)).toHtmlEscaped(); - src = QString("%1").arg(QString(utf8bytes.mid(targetStart, targetLens)).toHtmlEscaped()); - tail = QString(utf8bytes.mid(tailStart)).toHtmlEscaped(); + head = QString("%1").arg(QString(utf8bytes.mid(0, targetStart)).toHtmlEscaped()); + src = QString("%1").arg(QString(utf8bytes.mid(targetStart, targetLens)).toHtmlEscaped()); + tail = QString("%1").arg(QString(utf8bytes.mid(tailStart)).toHtmlEscaped()); } else { @@ -418,7 +450,8 @@ QString FindResultWin::highlightFindText(FindRecord& record) { head = head.toHtmlEscaped(); } - src = QString("%1").arg(QString(utf8bytes.mid(targetStart, targetLens)).toHtmlEscaped()); + head = QString("%1").arg(head); + src = QString("%1").arg(QString(utf8bytes.mid(targetStart, targetLens)).toHtmlEscaped()); tail = QString(utf8bytes.mid(tailStart)); if (tail > MAX_TAIL_LENGTH) { @@ -428,15 +461,16 @@ QString FindResultWin::highlightFindText(FindRecord& record) { tail = tail.toHtmlEscaped(); } + tail = QString("%1").arg(tail); } } else { if (!isNeedCut) { - head = QString("%1").arg(QString(utf8bytes.mid(0, targetStart)).toHtmlEscaped()); - src = QString("%1").arg(QString(utf8bytes.mid(targetStart, targetLens)).toHtmlEscaped()); - tail = QString("%1").arg(QString(utf8bytes.mid(tailStart)).toHtmlEscaped()); + head = QString("%1").arg(QString(utf8bytes.mid(0, targetStart)).toHtmlEscaped()); + src = QString("%1").arg(QString(utf8bytes.mid(targetStart, targetLens)).toHtmlEscaped()); + tail = QString("%1").arg(QString(utf8bytes.mid(tailStart)).toHtmlEscaped()); } else { @@ -450,8 +484,8 @@ QString FindResultWin::highlightFindText(FindRecord& record) headContens = headContens.toHtmlEscaped(); } - head = QString("%1").arg(headContens); - src = QString("%1").arg(QString(utf8bytes.mid(targetStart, targetLens)).toHtmlEscaped()); + head = QString("%1").arg(headContens); + src = QString("%1").arg(QString(utf8bytes.mid(targetStart, targetLens)).toHtmlEscaped()); QString tailContens = QString(utf8bytes.mid(tailStart)); if (tailContens > MAX_TAIL_LENGTH) @@ -462,7 +496,7 @@ QString FindResultWin::highlightFindText(FindRecord& record) { tailContens = tailContens.toHtmlEscaped(); } - tail = QString("%1").arg(tailContens); + tail = QString("%1").arg(tailContens); } } @@ -476,18 +510,27 @@ void FindResultWin::appendResultsToShow(FindRecords* record) return; } - QString findTitle = tr("Search \"%1\" (%2 hits)").arg(record->findText.toHtmlEscaped()).arg(record->records.size()); + QString findTitle; + //if (!StyleSet::isCurrentDeepStyle()) + //{ + findTitle = tr("Search \"%1\" (%2 hits)").arg(record->findText.toHtmlEscaped()).arg(record->records.size()); + /*} + else + { + findTitle = tr("Search \"%1\" (%2 hits)").arg(record->findText.toHtmlEscaped()).arg(record->records.size()); + }*/ + QStandardItem* titleItem = new QStandardItem(findTitle); - if (!StyleSet::isCurrentDeepStyle()) - { - setItemBackground(titleItem, QColor(0xbbbbff)); - } - else - { - setItemBackground(titleItem, QColor(0xd5ffd5)); - } + //if (!StyleSet::isCurrentDeepStyle()) + //{ + setItemBackground(titleItem, QColor(0xbbbbff)); + //} + //else + //{ + // setItemBackground(titleItem, QColor(0x423328));//0xd5ffd5 + //} m_model->insertRow(0, titleItem); titleItem->setData(QVariant(true), ResultItemRoot); @@ -509,11 +552,11 @@ void FindResultWin::appendResultsToShow(FindRecords* record) QString desc; if (!StyleSet::isCurrentDeepStyle()) { - desc = tr("%1 (%2 hits)").arg(record->findFilePath.toHtmlEscaped()).arg(record->records.size()); + desc = tr("%1 (%2 hits)").arg(record->findFilePath.toHtmlEscaped()).arg(record->records.size()); } else { - desc = tr("%1 (%2 hits)").arg(record->findFilePath.toHtmlEscaped()).arg(record->records.size()); + desc = tr("%1 (%2 hits)").arg(record->findFilePath.toHtmlEscaped()).arg(record->records.size()); } QStandardItem* descItem = new QStandardItem(desc); @@ -545,8 +588,15 @@ void FindResultWin::appendResultsToShow(FindRecords* record) QString richText = highlightFindText(v); - QString text = tr("Line %1 : %2").arg(v.lineNum + 1).arg(richText); - + QString text; + if (!StyleSet::isCurrentDeepStyle()) + { + text = tr("Line %1 : %2").arg(v.lineNum + 1).arg(richText); + } + else + { + text = tr("Line %1 : %2").arg(v.lineNum + 1).arg(richText); + } QStandardItem* childItem = new QStandardItem(text); childItem->setData(QVariant(v.pos), ResultItemPos); childItem->setData(QVariant(v.end - v.pos), ResultItemLen); @@ -566,7 +616,7 @@ void FindResultWin::appendResultsToShow(QVector* record, int hits, return; } - QString findTitle = tr("Search \"%1\" (%2 hits in %3 files)").arg(whatFind.toHtmlEscaped()).arg(hits).arg(record->size()); + QString findTitle = tr("Search \"%1\" (%2 hits in %3 files)").arg(whatFind.toHtmlEscaped()).arg(hits).arg(record->size()); QStandardItem* titleItem = new QStandardItem(findTitle); setItemBackground(titleItem, QColor(0xbbbbff)); titleItem->setData(QVariant(true), ResultItemRoot); @@ -594,8 +644,16 @@ void FindResultWin::appendResultsToShow(QVector* record, int hits, { FindRecords* pr = record->at(i); - QString desc = tr("%1 (%2 hits)").arg(pr->findFilePath.toHtmlEscaped()).arg(pr->records.size()); - + QString desc; + if (!StyleSet::isCurrentDeepStyle()) + { + desc = tr("%1 (%2 hits)").arg(pr->findFilePath.toHtmlEscaped()).arg(pr->records.size()); + } + else + { + desc = tr("%1 (%2 hits)").arg(pr->findFilePath.toHtmlEscaped()).arg(pr->records.size()); + } + QStandardItem* descItem = new QStandardItem(desc); if (!StyleSet::isCurrentDeepStyle()) @@ -627,8 +685,15 @@ void FindResultWin::appendResultsToShow(QVector* record, int hits, FindRecord v = pr->records.at(i); QString richText = highlightFindText(v); - QString text = QString("Line %1 : %2").arg(v.lineNum + 1).arg(richText); - + QString text; + if (!StyleSet::isCurrentDeepStyle()) + { + text = tr("Line %1 : %2").arg(v.lineNum + 1).arg(richText); + } + else + { + text = tr("Line %1 : %2").arg(v.lineNum + 1).arg(richText); + } QStandardItem* childItem = new QStandardItem(text); childItem->setData(QVariant(v.pos), ResultItemPos); childItem->setData(QVariant(v.end - v.pos), ResultItemLen); @@ -655,3 +720,48 @@ void FindResultWin::setItemForeground(QStandardItem* item, const QColor& color) QBrush b(color); item->setForeground(b); } + +//查找结果框的字体变大 +void FindResultWin::slot_fontZoomIn() +{ + QFont curFt = ui.resultTreeView->font(); + + int s = curFt.pointSize(); + s += 2; + curFt.setPointSize(s); + + m_defaultFontSize += 2; + + ui.resultTreeView->setFont(curFt); + + m_delegate->setFontSize(m_defaultFontSize); + + m_defFontSizeChange = true; +} + +void FindResultWin::slot_fontZoomOut() +{ + QFont curFt = ui.resultTreeView->font(); + + int s = curFt.pointSize(); + s -= 2; + + if (s >= 8) + { + m_defFontSizeChange = true; + m_defaultFontSize -= 2; + curFt.setPointSize(s); + ui.resultTreeView->setFont(curFt); + m_delegate->setFontSize(m_defaultFontSize); + } +} + +int FindResultWin::getDefaultFontSize() +{ + return m_defaultFontSize; +} + +void FindResultWin::setDefaultFontSize(int defSize) +{ + m_defaultFontSize = defSize; +} diff --git a/src/findresultwin.h b/src/findresultwin.h index c1e2f8f..408c101 100755 --- a/src/findresultwin.h +++ b/src/findresultwin.h @@ -21,7 +21,8 @@ public: void appendResultsToShow(FindRecords * record); void appendResultsToShow(QVector* record, int hits, QString whatFind); - + int getDefaultFontSize(); + void setDefaultFontSize(int defSize); signals: void itemDoubleClicked(const QModelIndex &index); void showMsg(QString &msg); @@ -32,6 +33,9 @@ private slots: void slot_copyContents(); void slot_copyItemContents(); void slot_selectSection(); + void slot_treeView_pressed(QModelIndex modeIndex); + void slot_fontZoomIn(); + void slot_fontZoomOut(); public slots: void slot_clearAllContents(); @@ -53,4 +57,6 @@ private: NdStyledItemDelegate* m_delegate; QWidget* m_parent; + int m_defaultFontSize; + bool m_defFontSizeChange; }; diff --git a/src/findresultwin.ui b/src/findresultwin.ui index 338355f..d7152e0 100755 --- a/src/findresultwin.ui +++ b/src/findresultwin.ui @@ -55,9 +55,6 @@ Qt::ScrollBarAsNeeded - - QAbstractScrollArea::AdjustIgnored - QAbstractItemView::DoubleClicked diff --git a/src/findwin.cpp b/src/findwin.cpp index 7a55059..c3998ed 100755 --- a/src/findwin.cpp +++ b/src/findwin.cpp @@ -72,13 +72,34 @@ void FindWin::slot_tabIndexChange(int index) { TAB_TYPES type = (TAB_TYPES)index; + if (RELPACE_TYPE == type) + { + if (ui.replaceTextBox->currentText().isEmpty() && !ui.findComboBox->currentText().isEmpty()) + { + if (ui.findComboBox->currentText().size() < 255) + { + ui.replaceTextBox->setCurrentText(ui.findComboBox->currentText()); + } + } + } + else if(FIND_TYPE == type) + { + if (ui.findComboBox->currentText().isEmpty() && !ui.replaceTextBox->currentText().isEmpty()) + { + if (ui.replaceTextBox->currentText().size() < 255) + { + ui.findComboBox->setCurrentText(ui.replaceTextBox->currentText()); + } + } + } + m_isFindFirst = true; if (m_findHistory->isEmpty()) { return; } - } +} void FindWin::slot_dealFileTypeChange(int state) { @@ -144,6 +165,18 @@ void FindWin::setFindText(QString &text) addFindHistory(text); } +void FindWin::setReplaceFindText(QString& text) +{ + ui.replaceTextBox->setEditText(text); + addFindHistory(text); +} + +void FindWin::setDirFindText(QString& text) +{ + ui.dirFindWhat->setEditText(text); + addFindHistory(text); +} + void FindWin::disableReplace() { ui.tab_replace->setEnabled(false); @@ -201,7 +234,7 @@ void FindWin::removeLineHeadEndBlank(int mode) { ui.replaceTextBox->setCurrentText("\\s+$"); } - ui.replaceWithBox->setCurrentText(""); + ui.replaceWithBox->setText(""); ui.replaceModeRegularBt->setChecked(true); @@ -355,9 +388,9 @@ void FindWin::updateParameterFromUI() m_isFindFirst = true; } - if (m_replaceWithText != ui.replaceWithBox->currentText()) + if (m_replaceWithText != ui.replaceWithBox->text()) { - m_replaceWithText = ui.replaceWithBox->currentText(); + m_replaceWithText = ui.replaceWithBox->text(); m_isFindFirst = true; } @@ -417,9 +450,9 @@ void FindWin::updateParameterFromUI() m_isFindFirst = true; } - if (m_replaceWithText != ui.dirReplaceWhat->currentText()) + if (m_replaceWithText != ui.dirReplaceWhat->text()) { - m_replaceWithText = ui.dirReplaceWhat->currentText(); + m_replaceWithText = ui.dirReplaceWhat->text(); m_isFindFirst = true; } @@ -523,6 +556,11 @@ void FindWin::updateParameterFromUI() void FindWin::addFindHistory(QString &text) { + //太长会导致看起来很杂乱,也不记录 + if (text.isEmpty() || text.size() >= 255) + { + return; + } if ((m_findHistory != nullptr) && (-1 == m_findHistory->indexOf(text))) { m_findHistory->push_front(text); @@ -712,7 +750,7 @@ void FindWin::removeEmptyLine(bool isBlankContained) { ui.replaceTextBox->setCurrentText("^$(\\r\\n|\\r|\\n)"); } - ui.replaceWithBox->setCurrentText(""); + ui.replaceWithBox->setText(""); ui.replaceModeRegularBt->setChecked(true); @@ -1080,12 +1118,12 @@ int FindWin::replaceAtBack(QStringList& keyword, QStringList& replace) } ui.replaceTextBox->setCurrentText(keyword.at(i)); - ui.replaceWithBox->setCurrentText(replace.at(i)); + ui.replaceWithBox->setText(replace.at(i)); updateParameterFromUI(); QString whatFind = ui.replaceTextBox->currentText(); - QString replaceText = ui.replaceWithBox->currentText(); + QString replaceText = ui.replaceWithBox->text(); times += doReplaceAll(pEdit, whatFind, replaceText, false); @@ -1384,7 +1422,7 @@ bool FindWin::replace(ScintillaEditView* pEdit) } QString findText = ui.replaceTextBox->currentText(); - QString replaceText = ui.replaceWithBox->currentText(); + QString replaceText = ui.replaceWithBox->text(); if (m_extend) { @@ -1750,7 +1788,7 @@ int FindWin::replaceAll() updateParameterFromUI(); QString whatFind = ui.replaceTextBox->currentText(); - QString replaceText = ui.replaceWithBox->currentText(); + QString replaceText = ui.replaceWithBox->text(); if (m_extend) { @@ -2445,7 +2483,7 @@ void FindWin::slot_dirReplaceAll() { QString dirPath = ui.destFindDir->text(); QString whatFind = ui.dirFindWhat->currentText(); - QString dirReplaceWhat = ui.dirReplaceWhat->currentText(); + QString dirReplaceWhat = ui.dirReplaceWhat->text(); if (dirPath.isEmpty()) { diff --git a/src/findwin.h b/src/findwin.h index c32a7d4..11105b3 100755 --- a/src/findwin.h +++ b/src/findwin.h @@ -60,6 +60,8 @@ public: void setCurrentTab(FindTabIndex index); void setTabWidget(QTabWidget * editTabWidget); void setFindText(QString & text); + void setReplaceFindText(QString& text); + void setDirFindText(QString& text); void disableReplace(); void setFindHistory(QList* findHistory); int markAllWord(QString& word); diff --git a/src/findwin.ui b/src/findwin.ui index a985552..06403f7 100755 --- a/src/findwin.ui +++ b/src/findwin.ui @@ -6,7 +6,7 @@ 0 0 - 633 + 689 384 @@ -396,7 +396,13 @@ - + + + + 0 + 0 + + 300 @@ -409,9 +415,6 @@ 16777215 - - true - @@ -777,25 +780,6 @@ - - - - - 300 - 0 - - - - - 350 - 16777215 - - - - true - - - @@ -863,6 +847,28 @@ + + + + + 0 + 0 + + + + + 300 + 0 + + + + + 350 + 16777215 + + + + @@ -1392,7 +1398,6 @@ findModeNormalBt findModeRegularBt replaceTextBox - replaceWithBox replaceBackwardBox replaceMatchWholeBox replaceMatchCaseBox diff --git a/src/installer/newinstall_dync.iss b/src/installer/newinstall_dync.iss new file mode 100755 index 0000000..0d5bcf4 --- /dev/null +++ b/src/installer/newinstall_dync.iss @@ -0,0 +1,66 @@ +; Script generated by the Inno Setup Script Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! + +#define MyAppName "Notepad--" +#define MyAppVersion "1.22.0" +#define MyAppPublisher "nddԴ֯" +#define MyAppURL "https://gitee.com/cxasm/notepad--" +#define MyAppExeName "Notepad--.exe" +#define MyAppAssocName "nddfile" +#define MyAppAssocExt ".txt" +#define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt + +[Setup] +; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{FA6189F1-03B8-44A2-BE8E-F6CD8E7857B6} +AppName={#MyAppName} +AppVersion={#MyAppVersion} +;AppVerName={#MyAppName} {#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +ArchitecturesInstallIn64BitMode=x64 +DefaultDirName={autopf}\{#MyAppName} +ChangesAssociations=yes +DisableProgramGroupPage=yes +; Uncomment the following line to run in non administrative install mode (install for current user only.) +;PrivilegesRequired=lowest +PrivilegesRequiredOverridesAllowed=dialog +OutputDir=D:\CCNotePad\installer +OutputBaseFilename=Notepad--v1.22.0-Installer +SetupIconFile=D:\CCNotePad\Resources\edit\global\ndd.ico +Compression=lzma +SolidCompression=yes +WizardStyle=modern + +[Languages] +Name: "ChineseSimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked + +[Files] +Source: "D:\CCNotePad\x64\Release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\CCNotePad\x64\Release\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Registry] +Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue +Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletekey +Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0" +Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1""" +Root: HKA; Subkey: "Software\Classes\Applications\{#MyAppExeName}\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: "" +Root: HKA; Subkey: "Software\Classes\*\shell\Notepad--"; ValueType: string; ValueName: ""; ValueData: "Edit with Notepad--"; Flags: uninsdeletekey +Root: HKA; Subkey: "Software\Classes\*\shell\Notepad--"; ValueType: string; ValueName: "Icon"; ValueData: """{app}\{#MyAppExeName}""" +Root: HKA; Subkey: "Software\Classes\*\shell\Notepad--\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1""" ; + + +[Icons] +Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" +Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon + +[Run] +Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent + diff --git a/src/langextset.cpp b/src/langextset.cpp new file mode 100755 index 0000000..3db6f03 --- /dev/null +++ b/src/langextset.cpp @@ -0,0 +1,228 @@ +#include "langextset.h" +#include "scintillaeditview.h" +#include "extlexermanager.h" +#include "ccnotepad.h" + +#include +#include +#include +#include + +int ITEM_CHANGED = Qt::UserRole; +int ITEM_LEX_ID = Qt::UserRole + 1; //Ӧ﷨lexer ID +int ITEM_LEX_EXT_OLD_VALUE = Qt::UserRole + 2; //Ӧ﷨EXTļľֵ + +LangExtSet::LangExtSet(QWidget *parent) + : QMainWindow(parent), m_isChanged(false) +{ + ui.setupUi(this); + + ui.langTableWidget->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents); + initLangName(); + + connect(ui.langTableWidget, &QTableWidget::itemChanged, this, &LangExtSet::slot_itemChanged); + connect(ui.langTableWidget, &QTableWidget::currentItemChanged, this, &LangExtSet::slot_currentItemChanged); +} + +LangExtSet::~LangExtSet() +{} + +void LangExtSet::initLangName() +{ + int langId = 0; + + QMap extLangMap; + + ExtLexerManager::getInstance()->getExtlistByLangTag(extLangMap); + + for (int i = 0; i <= L_TXT; ++i) + { + if (i == L_GLOBAL) + { + continue; + } + + QsciLexer* pLexer = ScintillaEditView::createLexer(i); + if (nullptr != pLexer) + { + QString langName = pLexer->lexerTag(); + QTableWidgetItem* item = new QTableWidgetItem(langName); + item->setFlags(item->flags() & ~Qt::ItemIsEditable); + item->setData(ITEM_LEX_ID, QVariant(i)); + + ui.langTableWidget->insertRow(langId); + ui.langTableWidget->setItem(langId, 0, item); + + QStringList extList; + if (extLangMap.contains(langName)) + { + extList = extLangMap.value(langName); + } + + QTableWidgetItem* item1 = new QTableWidgetItem(extList.join(',')); + item1->setData(ITEM_CHANGED, QVariant(false)); + + //Ѿֵ޸ĺԱʵʱ޸ڴеĸĶ + item1->setData(ITEM_LEX_EXT_OLD_VALUE, QVariant(extList)); + + ui.langTableWidget->setItem(langId, 1, item1); + delete pLexer; + + ++langId; + } + } + ui.langTableWidget->sortItems(0, Qt::AscendingOrder); +} + +void LangExtSet::slot_itemChanged(QTableWidgetItem* item) +{ + item->setData(ITEM_CHANGED, QVariant(true)); + + slot_currentItemChanged(item, nullptr); + + if (!m_isChanged) + { + m_isChanged = true; + } +} + +void LangExtSet::slot_currentItemChanged(QTableWidgetItem* current, QTableWidgetItem* previous) +{ + if (current != nullptr) + { + int row = current->row(); + QTableWidgetItem* tagItem = ui.langTableWidget->item(row, 0); + QTableWidgetItem* extItem = ui.langTableWidget->item(row, 1); + + if (tagItem != nullptr && extItem != nullptr) + { + ui.plainTextEdit->setPlainText(tr("current lang: %1 \next file suffix is : %2\nDouble-click a column item to modify the syntax association file.").arg(tagItem->text()).arg(extItem->text())); + } + } +} + +void LangExtSet::slot_save() +{ + if (!m_isChanged) + { + ui.statusBar->showMessage(tr("Not change, no need save !"), 10000); + return; + } + + int rowNums = ui.langTableWidget->rowCount(); + + QString userLangFile = QString("notepad/tag_ext"); + QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile); + qs.setIniCodec("UTF-8"); + + for (int i = 0; i < rowNums; ++i) + { + QTableWidgetItem* item = ui.langTableWidget->item(i, 1); + if (item != nullptr && item->data(ITEM_CHANGED).toBool()) + { + QTableWidgetItem* langItem = ui.langTableWidget->item(i, 0); + if (langItem != nullptr) + { + QString langTag = langItem->text(); + int lexId = langItem->data(ITEM_LEX_ID).toInt(); + + QStringList extList = item->text().split(','); + + for (int i = extList.size() - 1; i >= 0; --i) + { + if (extList.at(i).isEmpty()) + { + extList.removeAt(i); + } + } + + qs.setValue(langTag, extList); + + QString langLexerTag = QString("%1_lexId").arg(langTag); + qs.setValue(langLexerTag, lexId); + + //ǸļǸڴ棬ʵʱЧ + QStringList oldExtList = item->data(ITEM_LEX_EXT_OLD_VALUE).toStringList(); + + updataExtLexerManager(langTag, lexId, oldExtList, extList); + + //ֵΪܲرʱٴ޸ + item->setData(ITEM_LEX_EXT_OLD_VALUE, QVariant(extList)); + } + } + } + qs.sync(); + m_isChanged = false; + ui.statusBar->showMessage(tr("Save Finished !"), 10000); +} + +//ExtLexerManagertagֵ +void LangExtSet::updataExtLexerManager(QString tag, int lexId, QStringList & oldExtList, QStringList & newExtList) +{ + //Ѿɵֱɾ + for (int i = 0; i < oldExtList.size(); ++i) + { + ExtLexerManager::getInstance()->remove(oldExtList.at(i)); + } + //µ¼һ + for (int i = 0; i < newExtList.size(); ++i) + { + FileExtLexer v; + v.ext = newExtList.at(i); + v.id = (LangType)lexId; + + ExtLexerManager::getInstance()->addNewExtType(v.ext, v.id, tag); + } +} + +//ļĹ׺﷨ +void LangExtSet::loadExtRelevanceToMagr() +{ + QString userLangFile = QString("notepad/tag_ext");//Զв.ַдҪ + QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile); + qs.setIniCodec("UTF-8"); + + if (!QFile::exists(qs.fileName())) + { + return; + } + + QStringList keylist = qs.allKeys(); + QString langTag; + QStringList extList; + QString key_id; + int lexid = 0; + + for (int i = 0; i < keylist.size(); ++i) + { + langTag = keylist.at(i); + if (langTag.endsWith("_lexId")) + { + continue; + } + key_id = QString("%1_lexId").arg(langTag); + extList = qs.value(langTag).toStringList(); + lexid = qs.value(key_id).toInt(); + + for (int j = 0; j < extList.size(); ++j) + { + FileExtLexer v; + v.ext = extList.at(j); + v.id = (LangType)lexid; + + ExtLexerManager::getInstance()->addNewExtType(v.ext, v.id, langTag); + + } + } +} + +void LangExtSet::closeEvent(QCloseEvent* e) +{ + if (m_isChanged) + { + if (QMessageBox::Yes == QMessageBox::question(this, tr("Save Change"), tr("Configuration has been modified. Do you want to save it?"))) + { + slot_save(); + } + } +} \ No newline at end of file diff --git a/src/langextset.h b/src/langextset.h new file mode 100755 index 0000000..e6ef42b --- /dev/null +++ b/src/langextset.h @@ -0,0 +1,30 @@ +#pragma once + +#include +#include "ui_langextset.h" + +class LangExtSet : public QMainWindow +{ + Q_OBJECT + +public: + LangExtSet(QWidget *parent = nullptr); + ~LangExtSet(); + static void loadExtRelevanceToMagr(); + +private: + void initLangName(); + void updataExtLexerManager(QString tag, int lexId, QStringList& oldExtList, QStringList& newExtList); + +protected: + void closeEvent(QCloseEvent* e); + +private slots: + void slot_itemChanged(QTableWidgetItem* item); + void slot_currentItemChanged(QTableWidgetItem* current, QTableWidgetItem* previous); + void slot_save(); + +private: + Ui::LangExtSetClass ui; + bool m_isChanged; +}; diff --git a/src/langextset.ui b/src/langextset.ui new file mode 100755 index 0000000..981a33d --- /dev/null +++ b/src/langextset.ui @@ -0,0 +1,149 @@ + + + LangExtSetClass + + + + 0 + 0 + 809 + 504 + + + + LangExtSet + + + + + 3 + + + 3 + + + 3 + + + 3 + + + + + + Language + + + + + File Suffix + + + + + + + + + 16777215 + 100 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Save + + + + + + + Close + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + TopToolBarArea + + + false + + + + + + + + + pushButton + clicked() + LangExtSetClass + slot_save() + + + 374 + 466 + + + 394 + 509 + + + + + pushButton_2 + clicked() + LangExtSetClass + close() + + + 467 + 467 + + + 529 + 479 + + + + + + slot_save() + + diff --git a/src/main.cpp b/src/main.cpp index 0cb48fb..b3b4fd6 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -352,8 +352,16 @@ drop_old: if (arguments.size() == 2) { + if (!s_isAdminAuth) + { pMainNotepad->openFile(arguments[1]); - pMainNotepad->showNormal(); + } + else + { + //如果是管理员,还不能直接打开文件,需要恢复之前文件的修改内容 + //恢复不了,再直接打开 + pMainNotepad->tryRestoreFile(arguments[1]); + } } #ifdef Q_OS_WIN pMainNotepad->checkAppFont(); diff --git a/src/nddsetting.cpp b/src/nddsetting.cpp index ed20f73..24fd83d 100755 --- a/src/nddsetting.cpp +++ b/src/nddsetting.cpp @@ -7,7 +7,7 @@ #include #include - +static short version_num = 29; //1.22.0 29 //ļǷڡʼʧܣ򲻴 bool NddSetting::s_isExistDb = false; int NddSetting::s_reference = 0; @@ -15,7 +15,7 @@ bool NddSetting::s_isContentChanged = false; QSettings* NddSetting::s_nddSet = nullptr; -const int version_num = 25; +QSettings* NddSetting::s_winPosSet = nullptr; //keyڣkey-valueڣtrue bool NddSetting::checkNoExistAdd(QString key, QVariant& value) @@ -115,6 +115,9 @@ void NddSetting::init() //ҳĬϲѡԴķѶ addKeyValueToNumSets(SHOWWEBADDR, 0); + + //ҽĬС + addKeyValueToNumSets(FIND_RESULT_FONT_SIZE, 14); }; if (!s_nddSet->contains(VERSION)) @@ -220,6 +223,10 @@ void NddSetting::init() QVariant v(0); checkNoExistAdd(SHOWWEBADDR, v); } + { + QVariant v(14); + checkNoExistAdd(FIND_RESULT_FONT_SIZE, v); + } } while (false); } @@ -301,7 +308,39 @@ void NddSetting::close() s_nddSet = nullptr; s_isContentChanged = false; } + + //ﱣһӴڵλáųпӴڻڣѾ˳ⲻ + if (s_winPosSet != nullptr) + { + s_winPosSet->sync(); + s_winPosSet = nullptr; } } } +} +//Ӵڵλãһwinpos.iniļУʱҪȡɱʱٶ +QByteArray NddSetting::getWinPos(QString key) +{ + winPosInit(); + return s_winPosSet->value(key, "").toByteArray(); +} + +void NddSetting::updataWinPos(QString key, QByteArray& value) +{ + winPosInit(); + s_winPosSet->setValue(key, QVariant(value)); +} + +void NddSetting::winPosInit() +{ + if (s_winPosSet == nullptr) + { + QString settingDir = QString("notepad/delayset"); + QSettings qs(QSettings::IniFormat, QSettings::UserScope, settingDir); + QString qsSetPath = qs.fileName(); + + s_winPosSet = new QSettings(QSettings::IniFormat, QSettings::UserScope, settingDir); + s_winPosSet->setIniCodec("UTF-8"); + } +} diff --git a/src/nddsetting.h b/src/nddsetting.h index 25bf155..2fc34d8 100755 --- a/src/nddsetting.h +++ b/src/nddsetting.h @@ -23,6 +23,11 @@ static QString FILELISTSHOW = "showfilelist"; // static QString TOOLBARSHOW = "showbar"; //Ƿʾ static QString FINDWINSIZE = "findwinsize";//ҿĴС150%Ŵʱáÿֶ static QString SHOWWEBADDR = "showweb";//webַ˫ҳ +static QString FIND_RESULT_FONT_SIZE = "frfs";//ҽĬСĬΪ14 + + +//winpos.iniеkeyⵥļ̫ٶ +static QString BATCH_FIND_REPLACE_POS = "bfpos";//滻ڵĴС class NddSetting { @@ -49,11 +54,18 @@ public: static void close(); + static QByteArray getWinPos(QString key); + + static void updataWinPos(QString key, QByteArray& value); + + + static bool isDbExist() { return s_isExistDb; } - +private: + static void winPosInit(); private: static bool s_isExistDb; @@ -61,4 +73,6 @@ private: static int s_reference; static QSettings* s_nddSet; + + static QSettings* s_winPosSet; }; diff --git a/src/ndstyleditemdelegate.cpp b/src/ndstyleditemdelegate.cpp index 6eef523..9ee86d0 100755 --- a/src/ndstyleditemdelegate.cpp +++ b/src/ndstyleditemdelegate.cpp @@ -6,7 +6,7 @@ #include NdStyledItemDelegate::NdStyledItemDelegate(QObject *parent) - : QStyledItemDelegate(parent) + : QStyledItemDelegate(parent), m_defaultFontSize(14) { } @@ -14,6 +14,13 @@ NdStyledItemDelegate::~NdStyledItemDelegate() { } + +void NdStyledItemDelegate::setFontSize(int size) +{ + m_defaultFontSize = size; + +} + //ʹָ֧ıʽ void NdStyledItemDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const { @@ -27,6 +34,13 @@ void NdStyledItemDelegate::paint(QPainter * painter, const QStyleOptionViewItem QStyle *pStyle = viewOption.widget ? viewOption.widget->style() : QApplication::style(); QTextDocument doc; + + //ⲿ޸Сڲиı޸Ļơ + if (m_defaultFontSize != 14) + { + viewOption.text.replace("font-size:14px",QString("font-size:%1px").arg(m_defaultFontSize)); + } + doc.setHtml(viewOption.text); viewOption.text.clear(); diff --git a/src/ndstyleditemdelegate.h b/src/ndstyleditemdelegate.h index e65ff5b..c9b29da 100755 --- a/src/ndstyleditemdelegate.h +++ b/src/ndstyleditemdelegate.h @@ -9,7 +9,11 @@ class NdStyledItemDelegate : public QStyledItemDelegate public: NdStyledItemDelegate(QObject *parent); virtual ~NdStyledItemDelegate(); + void setFontSize(int size); protected: void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + +private: + int m_defaultFontSize; }; diff --git a/src/plugin/helloworld/helloworld.vcxproj.user b/src/plugin/helloworld/helloworld.vcxproj.user index 66071d4..b7a75e9 100755 --- a/src/plugin/helloworld/helloworld.vcxproj.user +++ b/src/plugin/helloworld/helloworld.vcxproj.user @@ -2,9 +2,9 @@ - 2023-01-07T13:40:17.4741087Z + 2023-01-06T12:23:11.3148927Z - 2023-01-07T13:40:17.5339488Z + 2023-01-06T12:23:11.4036545Z \ No newline at end of file diff --git a/src/progresswin.cpp b/src/progresswin.cpp index 43deb3c..e8911ab 100755 --- a/src/progresswin.cpp +++ b/src/progresswin.cpp @@ -25,12 +25,16 @@ void ProgressWin::setTotalSteps(int step) m_curStep = 0; } -void ProgressWin::moveStep() +void ProgressWin::moveStep(bool isRest) { ++m_curStep; ui.progressBar->setValue(m_curStep); ui.progressBar->update(); - //QCoreApplication::processEvents(); + + if (isRest) + { + QCoreApplication::processEvents(); +} } int ProgressWin::getTotalStep() diff --git a/src/progresswin.h b/src/progresswin.h index efb6415..94cb3ef 100755 --- a/src/progresswin.h +++ b/src/progresswin.h @@ -15,7 +15,7 @@ public: void info(QString text); void setTotalSteps(int step); - void moveStep(); + void moveStep(bool isRest = false); int getTotalStep(); void setStep(int step); diff --git a/src/qscidisplaywindow.cpp b/src/qscidisplaywindow.cpp index 5240d46..5d5584b 100755 --- a/src/qscidisplaywindow.cpp +++ b/src/qscidisplaywindow.cpp @@ -89,32 +89,8 @@ void QsciDisplayWindow::setStyleOptions() setMarginsForegroundColor(QColor(0x80, 0x80, 0x80)); //默认0x80, 0x80, 0x80 } else - { - setMarginsForegroundColor(QColor(0xde, 0xde, 0xde)); //默认0x80, 0x80, 0x80 - } - setMarginsBackgroundColor(StyleSet::marginsBackgroundColor); - setFoldMarginColors(StyleSet::marginsBackgroundColor, StyleSet::marginsBackgroundColor); - - //如果是黑色主题,则单独做一些风格设置 - if (StyleSet::m_curStyleId == BLACK_SE) - { - this->setColor(QColor(0xff, 0xff, 0xff));//有lexer时无效 - this->setPaper(QColor(0x282020));//有lexer时无效 - - - setCaretLineBackgroundColor(QColor(0x333333)); - setMatchedBraceForegroundColor(QColor(246, 81, 246)); - setMatchedBraceBackgroundColor(QColor(18, 90, 36)); - setCaretForegroundColor(QColor(255, 255, 255)); - setFoldColor(SC_MARKNUM_FOLDEROPEN, QColor(45, 130, 45), QColor(222, 222, 222)); - setFoldColor(SC_MARKNUM_FOLDER, QColor(45, 130, 45), QColor(222, 222, 222)); - setFoldColor(SC_MARKNUM_FOLDERSUB, QColor(45, 130, 45), QColor(222, 222, 222)); - setFoldColor(SC_MARKNUM_FOLDERTAIL, QColor(45, 130, 45), QColor(222, 222, 222)); - setFoldColor(SC_MARKNUM_FOLDEREND, QColor(45, 130, 45), QColor(222, 222, 222)); - setFoldColor(SC_MARKNUM_FOLDEROPENMID, QColor(45, 130, 45), QColor(222, 222, 222)); - setFoldColor(SC_MARKNUM_FOLDERMIDTAIL, QColor(45, 130, 45), QColor(222, 222, 222)); - } - else + setMarginsBackgroundColor(0xf0f0f0); + setFoldMarginColors(0xf0f0f0, 0xf0f0f0); { //setCaretLineBackgroundColor(QColor(0xe8e8ff)); setCaretLineBackgroundColor(QColor(0xFAF9DE)); diff --git a/src/qscint/scintilla/boostregex/AnsiDocumentIterator.h b/src/qscint/scintilla/boostregex/AnsiDocumentIterator.h index 619679c..f94bab8 100755 --- a/src/qscint/scintilla/boostregex/AnsiDocumentIterator.h +++ b/src/qscint/scintilla/boostregex/AnsiDocumentIterator.h @@ -1,5 +1,5 @@ -// This file is part of Notepad++ project -// Copyright (C) 2021 Notepad++ authors. +// This file is part of Notepad-- project +// Copyright (C) 2023 Notepad-- authors. // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/qscint/scintilla/boostregex/BoostRegExSearch.cpp b/src/qscint/scintilla/boostregex/BoostRegExSearch.cpp index 0cf38df..1d80986 100755 --- a/src/qscint/scintilla/boostregex/BoostRegExSearch.cpp +++ b/src/qscint/scintilla/boostregex/BoostRegExSearch.cpp @@ -6,7 +6,7 @@ * (c) 2012 Dave Brotherstone - Changes for boost::regex * (c) 2013 Francois-R.Boyer@PolyMtl.ca - Empty match modes and best match backward search * (c) 2019 Don Ho - Adapt for upgrading Scitilla (to version 4.1.4) and boost (to version 1.70) - * + * (c) 2022 zuowei yin - Upgrading QScitilla and boost */ #include diff --git a/src/qscint/scintilla/boostregex/UTF8DocumentIterator.cpp b/src/qscint/scintilla/boostregex/UTF8DocumentIterator.cpp index 5a43057..4e118b2 100755 --- a/src/qscint/scintilla/boostregex/UTF8DocumentIterator.cpp +++ b/src/qscint/scintilla/boostregex/UTF8DocumentIterator.cpp @@ -1,5 +1,5 @@ -// This file is part of Notepad++ project -// Copyright (C) 2021 Notepad++ authors. +// This file is part of Notepad-- project +// Copyright (C) 2023 Notepad-- authors. // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/qscint/scintilla/boostregex/UTF8DocumentIterator.h b/src/qscint/scintilla/boostregex/UTF8DocumentIterator.h index 1179800..6271d11 100755 --- a/src/qscint/scintilla/boostregex/UTF8DocumentIterator.h +++ b/src/qscint/scintilla/boostregex/UTF8DocumentIterator.h @@ -1,5 +1,5 @@ -// This file is part of Notepad++ project -// Copyright (C) 2021 Notepad++ authors. +// This file is part of Notepad-- project +// Copyright (C) 2023 Notepad-- authors. // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/qscint/scintilla/lexers/LexAVS.cpp b/src/qscint/scintilla/lexers/LexAVS.cpp index 272f04b..2092ba5 100755 --- a/src/qscint/scintilla/lexers/LexAVS.cpp +++ b/src/qscint/scintilla/lexers/LexAVS.cpp @@ -1,4 +1,4 @@ -// Scintilla source code edit control +// Scintilla source code edit control /** @file LexAVS.cxx ** Lexer for AviSynth. **/ @@ -288,4 +288,4 @@ static const char * const avsWordLists[] = { 0, }; -LexerModule lmAVS(SCLEX_AVS, ColouriseAvsDoc, "avs", FoldAvsDoc, avsWordLists); +//LexerModule lmAVS(SCLEX_AVS, ColouriseAvsDoc, "avs", FoldAvsDoc, avsWordLists); diff --git a/src/qscint/scintilla/src/Catalogue.cpp b/src/qscint/scintilla/src/Catalogue.cpp index 0367f20..20e90d8 100755 --- a/src/qscint/scintilla/src/Catalogue.cpp +++ b/src/qscint/scintilla/src/Catalogue.cpp @@ -1,4 +1,4 @@ -// Scintilla source code edit control +// Scintilla source code edit control /** @file Catalogue.cxx ** Lexer infrastructure. ** Contains a list of LexerModules which can be searched to find a module appropriate for a @@ -82,7 +82,7 @@ int Scintilla_LinkLexers() { LINK_LEXER(lmASY); LINK_LEXER(lmAU3); LINK_LEXER(lmAVE); - LINK_LEXER(lmAVS); + //LINK_LEXER(lmAVS); LINK_LEXER(lmBaan); LINK_LEXER(lmBash); LINK_LEXER(lmBatch); diff --git a/src/qscint/src/Qsci/qsciglobal.h b/src/qscint/src/Qsci/qsciglobal.h index 74383a1..61e48d5 100755 --- a/src/qscint/src/Qsci/qsciglobal.h +++ b/src/qscint/src/Qsci/qsciglobal.h @@ -38,11 +38,6 @@ // define QSCINTILLA_DLL to link against a QScintilla shared library, or define // neither to either build or link against a static QScintilla library. -//在编译插件的时候,先打开QSCINTILLA_MAKE_DLL宏,让qscitilla生成lib dll文件 -//#define QSCINTILLA_MAKE_DLL - -//编译完成后,注释掉QSCINTILLA_MAKE_DLL - #if defined(QSCINTILLA_DLL) #define QSCINTILLA_EXPORT Q_DECL_IMPORT #elif defined(QSCINTILLA_MAKE_DLL) diff --git a/src/qscint/src/Qsci/qscilexerasm.h b/src/qscint/src/Qsci/qscilexerasm.h new file mode 100755 index 0000000..4ab60c9 --- /dev/null +++ b/src/qscint/src/Qsci/qscilexerasm.h @@ -0,0 +1,127 @@ +#pragma once +// This defines the interface to the QsciLexerAsm class. +// +// Copyright (c) 2021 Riverbank Computing Limited +// +// This file is part of QScintilla. +// +// This file may be used under the terms of the GNU General Public License +// version 3.0 as published by the Free Software Foundation and appearing in +// the file LICENSE included in the packaging of this file. Please review the +// following information to ensure the GNU General Public License version 3.0 +// requirements will be met: http://www.gnu.org/copyleft/gpl.html. +// +// If you do not wish to use this file under the terms of the GPL version 3.0 +// then you may purchase a commercial license. For more information contact +// info@riverbankcomputing.com. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + +#include + +#include +#include + + +//! \brief The QsciLexerAsm class encapsulates the Scintilla Bash lexer. +class QSCINTILLA_EXPORT QsciLexerAsm : public QsciLexer +{ + Q_OBJECT + +public: + //! This enum defines the meanings of the different styles used by the + //! Bash lexer. + enum { + DEFAULT = 0, + COMMENT, + NUMBER, + STRING, + OPERATOR, + IDENTIFIER, + CPUINSTRUCTION, + MATHINSTRUCTION, + REGISTER, + DIRECTIVE, + DIRECTIVEOPERAND, + COMMENTBLOCK, + CHARACTER, + STRINGEOL, + EXTINSTRUCTION, + COMMENTDIRECTIVE, + }; + + //! Construct a QsciLexerAsm with parent \a parent. \a parent is + //! typically the QsciScintilla instance. + QsciLexerAsm(QObject* parent = 0); + + //! Destroys the QsciLexerAsm instance. + virtual ~QsciLexerAsm(); + + //! Returns the name of the language. + const char* language() const; + + //! Returns the name of the lexer. Some lexers support a number of + //! languages. + const char* lexer() const; + + //! Returns the string of characters that comprise a word. + const char* wordCharacters() const; + + //! Returns the foreground colour of the text for style number \a style. + //! + //! \sa defaultPaper() + QColor defaultColor(int style) const; + + //! Returns the end-of-line fill for style number \a style. + bool defaultEolFill(int style) const; + + //! Returns the font for style number \a style. + QFont defaultFont(int style) const; + + //! Returns the background colour of the text for style number \a style. + //! + //! \sa defaultColor() + QColor defaultPaper(int style) const; + + //! Returns the set of keywords for the keyword set \a set recognised + //! by the lexer as a space separated string. + const char* keywords(int set); + + //! Returns the descriptive name for style number \a style. If the + //! style is invalid for this language then an empty QString is returned. + //! This is intended to be used in user preference dialogs. + QString description(int style) const; + + //! Causes all properties to be refreshed by emitting the + //! propertyChanged() signal as required. + void refreshProperties(); + + + //! Returns true if trailing blank lines are included in a fold block. + //! + //! \sa setFoldCompact() + bool foldCompact() const; + +public slots: + //! If \a fold is true then multi-line comment blocks can be folded. + //! The default is false. + //! If \a fold is true then trailing blank lines are included in a fold + //! block. The default is true. + //! + //! \sa foldCompact() + virtual void setFoldCompact(bool fold); + +protected: + //! The lexer's properties are read from the settings \a qs. \a prefix + //! (which has a trailing '/') should be used as a prefix to the key of + //! each setting. true is returned if there is no error. + //! +private: + void setCompactProp(); + + bool fold_compact; + + QsciLexerAsm(const QsciLexerAsm&); + QsciLexerAsm& operator=(const QsciLexerAsm&); +}; diff --git a/src/qscint/src/qscilexer.cpp b/src/qscint/src/qscilexer.cpp index b49fdc5..716e652 100755 --- a/src/qscint/src/qscilexer.cpp +++ b/src/qscint/src/qscilexer.cpp @@ -29,7 +29,7 @@ #include "Qsci/qsciscintilla.h" #include "Qsci/qsciscintillabase.h" -int QsciLexer::s_defaultFontSize = 14; +int QsciLexer::s_defaultFontSize = 12; int QsciLexer::m_themesId = 0; @@ -38,7 +38,7 @@ QFont QsciLexer::s_defaultLangFont("Courier New", QsciLexer::s_defaultFontSize); #elif defined(Q_OS_MAC) QFont QsciLexer::s_defaultLangFont("Menlo", s_defaultFontSize); #else -QFont QsciLexer::s_defaultLangFont("Courier 10 Pitch", 14); +QFont QsciLexer::s_defaultLangFont("Courier 10 Pitch", 12); #endif // The ctor. @@ -948,4 +948,4 @@ void QsciLexer::setCommentEnd(QByteArray commentEnd) void QsciLexer::setCurThemes(int themesId) { m_themesId = themesId; -} \ No newline at end of file +} diff --git a/src/qscint/src/qscilexerasm.cpp b/src/qscint/src/qscilexerasm.cpp new file mode 100755 index 0000000..fbf35e9 --- /dev/null +++ b/src/qscint/src/qscilexerasm.cpp @@ -0,0 +1,283 @@ +// This module implements the QsciLexerAsm class. +// +// Copyright (c) 2021 Riverbank Computing Limited +// +// This file is part of QScintilla. +// +// This file may be used under the terms of the GNU General Public License +// version 3.0 as published by the Free Software Foundation and appearing in +// the file LICENSE included in the packaging of this file. Please review the +// following information to ensure the GNU General Public License version 3.0 +// requirements will be met: http://www.gnu.org/copyleft/gpl.html. +// +// If you do not wish to use this file under the terms of the GPL version 3.0 +// then you may purchase a commercial license. For more information contact +// info@riverbankcomputing.com. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + +#include "Qsci/qscilexerasm.h" + +#include +#include +#include + + +// The ctor. +QsciLexerAsm::QsciLexerAsm(QObject* parent) + : QsciLexer(parent), fold_compact(true) +{ + m_commentSymbol = "#"; +} + + +// The dtor. +QsciLexerAsm::~QsciLexerAsm() +{ +} + + +// Returns the language name. +const char* QsciLexerAsm::language() const +{ + return "Asm"; +} + + +// Returns the lexer name. +const char* QsciLexerAsm::lexer() const +{ + return "asm"; +} + +// Return the string of characters that comprise a word. +const char* QsciLexerAsm::wordCharacters() const +{ + return "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$@%&"; +} + +// Returns the foreground colour of the text for a style. +QColor QsciLexerAsm::defaultColor(int style) const +{ + switch (style) + { + case DEFAULT: + return QColor(0x80, 0x80, 0x80); + + case REGISTER: + return QColor(0x80, 0x80, 0xff); + + case COMMENT: + return QColor(0x00, 0x7f, 0x00); + + case NUMBER: + return QColor(0x00, 0x7f, 0x7f); + + case IDENTIFIER: + return QColor(0x80, 0x00, 0xff); + + case STRINGEOL: + return QColor(0x7f, 0x00, 0x7f); + + case CPUINSTRUCTION: //key word: + return QColor(0x00, 0x00, 0xff); + } + + return QsciLexer::defaultColor(style); +} + + +// Returns the end-of-line fill for a style. +bool QsciLexerAsm::defaultEolFill(int style) const +{ + return QsciLexer::defaultEolFill(style); +} + + +// Returns the font of the text for a style. +QFont QsciLexerAsm::defaultFont(int style) const +{ + QFont f; + + switch (style) + { + case COMMENT: +#if defined(Q_OS_WIN) + f = QFont("Courier New", 11); +#elif defined(Q_OS_MAC) + f = QFont("Comic Sans MS", 12); +#else + f = QFont("Bitstream Vera Serif", 9); +#endif + break; + + case REGISTER: + f = QsciLexer::defaultFont(style); + f.setBold(false); + break; + + case CPUINSTRUCTION: + f = QsciLexer::defaultFont(style); + f.setBold(true); + break; + + case STRINGEOL: + case DEFAULT: +#if defined(Q_OS_WIN) + f = QFont("Courier New", QsciLexer::s_defaultFontSize); +#elif defined(Q_OS_MAC) + f = QFont("Courier", 12); +#else + f = QFont("Bitstream Vera Sans Mono", 9); +#endif + break; + + default: + f = QsciLexer::defaultFont(style); + } + + return f; +} + + +// Returns the set of keywords. +const char* QsciLexerAsm::keywords(int set) +{ + if (set == 1) + { + return "aaa aad aam aas adc add and call cbw cdqe clc cld cli cmc cmp cmps cmpsb cmpsw cwd daa das dec div esc hlt idiv imul " + "in inc int into iret ja jae jb jbe jc jcxz je jg jge jl jle jmp jna jnae jnb jnbe jnc jne jng jnge jnl jnle jno jnp jns " + "jnz jo jp jpe jpo js jz lahf lds lea les lods lodsb lodsw loop loope loopew loopne loopnew loopnz loopnzw loopw loopz " + "loopzw mov movabs movs movsb movsw mul neg nop not or out pop popf push pushf rcl rcr ret retf retn rol ror sahf sal sar " + "sbb scas scasb scasw shl shr stc std sti stos stosb stosw sub test wait xchg xlat xlatb xor bound enter ins insb insw " + "leave outs outsb outsw popa pusha pushw arpl lar lsl sgdt sidt sldt smsw str verr verw clts lgdt lidt lldt lmsw ltr " + "bsf bsr bt btc btr bts cdq cmpsd cwde insd iretd iretdf iretf jecxz lfs lgs lodsd loopd looped loopned loopnzd loopzd " + "lss movsd movsx movsxd movzx outsd popad popfd pushad pushd pushfd scasd seta setae setb setbe setc sete setg setge setl " + "setle setna setnae setnb setnbe setnc setne setng setnge setnl setnle setno setnp setns setnz seto setp setpe setpo sets " + "setz shld shrd stosd bswap cmpxchg invd invlpg wbinvd xadd lock rep repe repne repnz repz cflush cpuid emms femms cmovo " + "cmovno cmovb cmovc cmovnae cmovae cmovnb cmovnc cmove cmovz cmovne cmovnz cmovbe cmovna cmova cmovnbe cmovs cmovns cmovp " + "cmovpe cmovnp cmovpo cmovl cmovnge cmovge cmovnl cmovle cmovng cmovg cmovnle cmpxchg486 cmpxchg8b loadall loadall286 ibts " + "icebp int1 int3 int01 int03 iretw popaw popfw pushaw pushfw rdmsr rdpmc rdshr rdtsc rsdc rsldt rsm rsts salc smi smint smintold " + "svdc svldt svts syscall sysenter sysexit sysret ud0 ud1 ud2 umov xbts wrmsr wrshr"; + } + else if (set == 2) + { + return "f2xm1 fabs fadd faddp fbld fbstp fchs fclex fcom fcomp fcompp fdecstp fdisi fdiv fdivp fdivr fdivrp " + "feni ffree fiadd ficom ficomp fidiv fidivr fild fimul fincstp finit fist fistp fisub fisubr fld " + "fld1 fldcw fldenv fldenvw fldl2e fldl2t fldlg2 fldln2 fldpi fldz fmul fmulp fnclex fndisi fneni " + "fninit fnop fnsave fnsavew fnstcw fnstenv fnstenvw fnstsw fpatan fprem fptan frndint frstor frstorw " + "fsave fsavew fscale fsqrt fst fstcw fstenv fstenvw fstp fstsw fsub fsubp fsubr fsubrp ftst fwait " + "fxam fxch fxtract fyl2x fyl2xp1 fsetpm fcos fldenvd fnsaved fnstenvd fprem1 frstord fsaved fsin " + "fsincos fstenvd fucom fucomp fucompp fcomi fcomip ffreep fcmovb fcmove fcmovbe fcmovu fcmovnb " + "fcmovne fcmovnbe fcmovnu"; + } + else if (set == 3) + { + return "ah al ax bh bl bp bx ch cl cr0 cr2 cr3 cr4 cs cx dh di dl dr0 dr1 dr2 dr3 dr6 dr7 ds dx eax ebp ebx ecx edi edx es " + "esi esp fs gs rax rbx rcx rdx rdi rsi rbp rsp r8 r9 r10 r11 r12 r13 r14 r15 r8d r9d r10d r11d r12d r13d r14d r15d r8w r9w " + "r10w r11w r12w r13w r14w r15w r8b r9b r10b r11b r12b r13b r14b r15b si sp ss st tr3 tr4 tr5 tr6 tr7 st0 st1 st2 st3 st4 st5 st6 " + "st7 mm0 mm1 mm2 mm3 mm4 mm5 mm6 mm7 xmm0 xmm1 xmm2 xmm3 xmm4 xmm5 xmm6 xmm7 xmm8 xmm9 xmm10 xmm11 xmm12 xmm13 xmm14 xmm15"; + } + else if (set == 4) + { + return ".186 .286 .286c .286p .287 .386 .386c .386p .387 .486 .486p .8086 .8087 .alpha .break .code .const .continue .cref .data .data? .dosseg .else .elseif .endif .endw .err .err1 .err2 .errb .errdef .errdif .errdifi .erre .erridn .erridni .errnb .errndef .errnz .exit .fardata .fardata? .if .lall .lfcond .list .listall .listif .listmacro .listmacroall .model .no87 .nocref .nolist .nolistif .nolistmacro .radix .repeat .sall .seq .sfcond .stack .startup .tfcond .type .until .untilcxz .while .xall .xcref .xlist alias align assume catstr comm comment db dd df dosseg dq dt dup dw echo else elseif elseif1 elseif2 elseifb elseifdef elseifdif elseifdifi elseife elseifidn elseifidni elseifnb elseifndef end endif endm endp ends eq equ even exitm extern externdef extrn for forc ge goto group gt high highword if if1 if2 ifb ifdef ifdif ifdifi ife ifidn ifidni ifnb ifndef include includelib instr invoke irp irpc label le length lengthof local low lowword lroffset lt macro mask mod .msfloat name ne offset opattr option org %out page popcontext proc proto ptr public purge pushcontext record repeat rept seg segment short size sizeof sizestr struc struct substr subtitle subttl textequ this title type typedef union while width resb resw resd resq rest incbin times %define %idefine %xdefine %xidefine %undef %assign %iassign %strlen %substr %macro %imacro %endmacro %rotate %if %elif %else %endif %ifdef %ifndef %elifdef %elifndef %ifmacro %ifnmacro %elifmacro %elifnmacro %ifctk %ifnctk %elifctk %elifnctk %ifidn %ifnidn %elifidn %elifnidn %ifidni %ifnidni %elifidni %elifnidni %ifid %ifnid %elifid %elifnid %ifstr %ifnstr %elifstr %elifnstr %ifnum %ifnnum %elifnum %elifnnum %error %rep %endrep %exitrep %include %push %pop %repl endstruc istruc at iend alignb %arg %stacksize %local %line bits use16 use32 section absolute global common cpu import export"; + } + else if (set == 5) + { + return "$ ? @b @f addr basic byte c carry? dword far far16 fortran fword near near16 overflow? parity? pascal qword real4 real8 real10 sbyte sdword sign? stdcall sword syscall tbyte vararg word zero? flat near32 far32 abs all assumes at casemap common compact cpu dotname emulator epilogue error export expr16 expr32 farstack forceframe huge language large listing ljmp loadds m510 medium memory nearstack nodotname noemulator nokeyword noljmp nom510 none nonunique nooldmacros nooldstructs noreadonly noscoped nosignextend nothing notpublic oldmacros oldstructs os_dos para private prologue radix readonly req scoped setif2 smallstack tiny use16 use32 uses a16 a32 o16 o32 nosplit $$ seq wrt small .text .data .bss %0 %1 %2 %3 %4 %5 %6 %7 %8 %9"; + } + else if (set == 6) + { + return "addpd addps addsd addss andpd andps andnpd andnps cmpeqpd cmpltpd cmplepd cmpunordpd cmpnepd cmpnltpd cmpnlepd cmpordpd cmpeqps cmpltps cmpleps cmpunordps cmpneps cmpnltps cmpnleps cmpordps cmpeqsd cmpltsd cmplesd cmpunordsd cmpnesd cmpnltsd cmpnlesd cmpordsd cmpeqss cmpltss cmpless cmpunordss cmpness cmpnltss cmpnless cmpordss comisd comiss cvtdq2pd cvtdq2ps cvtpd2dq cvtpd2pi cvtpd2ps cvtpi2pd cvtpi2ps cvtps2dq cvtps2pd cvtps2pi cvtss2sd cvtss2si cvtsd2si cvtsd2ss cvtsi2sd cvtsi2ss cvttpd2dq cvttpd2pi cvttps2dq cvttps2pi cvttsd2si cvttss2si divpd divps divsd divss fxrstor fxsave ldmxscr lfence mfence maskmovdqu maskmovdq maxpd maxps paxsd maxss minpd minps minsd minss movapd movaps movdq2q movdqa movdqu movhlps movhpd movhps movd movq movlhps movlpd movlps movmskpd movmskps movntdq movnti movntpd movntps movntq movq2dq movsd movss movupd movups mulpd mulps mulsd mulss orpd orps packssdw packsswb packuswb paddb paddsb paddw paddsw paddd paddsiw paddq paddusb paddusw pand pandn pause paveb pavgb pavgw pavgusb pdistib pextrw pcmpeqb pcmpeqw pcmpeqd pcmpgtb pcmpgtw pcmpgtd pf2id pf2iw pfacc pfadd pfcmpeq pfcmpge pfcmpgt pfmax pfmin pfmul pmachriw pmaddwd pmagw pmaxsw pmaxub pminsw pminub pmovmskb pmulhrwc pmulhriw pmulhrwa pmulhuw pmulhw pmullw pmuludq pmvzb pmvnzb pmvlzb pmvgezb pfnacc pfpnacc por prefetch prefetchw prefetchnta prefetcht0 prefetcht1 prefetcht2 pfrcp pfrcpit1 pfrcpit2 pfrsqit1 pfrsqrt pfsub pfsubr pi2fd pinsrw psadbw pshufd pshufhw pshuflw pshufw psllw pslld psllq pslldq psraw psrad psrlw psrld psrlq psrldq psubb psubw psubd psubq psubsb psubsw psubusb psubusw psubsiw pswapd punpckhbw punpckhwd punpckhdq punpckhqdq punpcklbw punpcklwd punpckldq punpcklqdq pxor rcpps rcpss rsqrtps rsqrtss sfence shufpd shufps sqrtpd sqrtps sqrtsd sqrtss stmxcsr subpd subps subsd subss ucomisd ucomiss unpckhpd unpckhps unpcklpd unpcklps xorpd xorps"; + } +} + + +// Returns the user name of a style. +QString QsciLexerAsm::description(int style) const +{ + switch (style) + { + case DEFAULT: + return tr("Default"); + + case COMMENT: + return tr("Comment"); + + case NUMBER: + return tr("Number"); + + case STRING: + return tr("String"); + + case OPERATOR: + return tr("Operator"); + + case IDENTIFIER: + return tr("Identifier"); + + case CPUINSTRUCTION: //key word + return tr("Keyword (Cpu instruction)"); + + case MATHINSTRUCTION: + return tr("Math instruction"); + + case REGISTER: + return tr("Register"); + + case DIRECTIVE: + return tr("Directive"); + + case DIRECTIVEOPERAND: + return tr("Directive Operand"); + + case COMMENTBLOCK: + return tr("Comment Block"); + + case CHARACTER: + return tr("Character"); + + case STRINGEOL: + return tr("String eol"); + + case EXTINSTRUCTION: + return tr("Extinstruction"); + + case COMMENTDIRECTIVE: + return tr("Comment Directive"); + } + + return QString(); +} + + +// Returns the background colour of the text for a style. +QColor QsciLexerAsm::defaultPaper(int style) const +{ + return QsciLexer::defaultPaper(style); +} + + +// Refresh all properties. +void QsciLexerAsm::refreshProperties() +{ + setCompactProp(); +} + + +// Set if folds are compact +void QsciLexerAsm::setFoldCompact(bool fold) +{ + fold_compact = fold; + + setCompactProp(); +} + + +// Set the "fold.compact" property. +void QsciLexerAsm::setCompactProp() +{ + emit propertyChanged("fold.compact", (fold_compact ? "1" : "0")); +} diff --git a/src/qscint/src/qscilexerglobal.cpp b/src/qscint/src/qscilexerglobal.cpp index ddc49c3..fdbb54d 100755 --- a/src/qscint/src/qscilexerglobal.cpp +++ b/src/qscint/src/qscilexerglobal.cpp @@ -100,11 +100,11 @@ QString QsciLexerGlobal::description(int style) const QFont QsciLexerGlobal::defaultFont(int style) const { #if defined(Q_OS_WIN) - QFont f("Courier New", 14); + QFont f("Courier New", s_defaultFontSize); #elif defined(Q_OS_MAC) QFont f("Menlo", s_defaultFontSize); #else - QFont f("Courier 10 Pitch", 14); + QFont f("Courier 10 Pitch", s_defaultFontSize); #endif switch (style) diff --git a/src/qscint/src/qscilexertext.cpp b/src/qscint/src/qscilexertext.cpp index 9017bad..87dfa92 100755 --- a/src/qscint/src/qscilexertext.cpp +++ b/src/qscint/src/qscilexertext.cpp @@ -8,9 +8,9 @@ #if defined(Q_OS_WIN) QFont QsciLexerText::s_defaultTxtFont(u8"宋体", QsciLexer::s_defaultFontSize); #elif defined(Q_OS_MAC) - QFont QsciLexerText::s_defaultTxtFont("STSong",18); + QFont QsciLexerText::s_defaultTxtFont("STSong",14); #else - QFont QsciLexerText::s_defaultTxtFont("Courier 10 Pitch", 14); + QFont QsciLexerText::s_defaultTxtFont("Courier 10 Pitch", 12); #endif @@ -83,9 +83,9 @@ QFont QsciLexerText::defaultFont(int style) const break; case Ascii: #if defined(Q_OS_WIN) - return QFont("Courier New", 14); + return QFont("Courier New", 12); #elif defined(Q_OS_MAC) - return QFont("Courier New", 18); + return QFont("Courier New", 14); #else return s_defaultTxtFont; #endif diff --git a/src/qscint/src/qscintilla.pro b/src/qscint/src/qscintilla.pro index c50aab5..f0f9852 100755 --- a/src/qscint/src/qscintilla.pro +++ b/src/qscint/src/qscintilla.pro @@ -103,7 +103,7 @@ HEADERS = \ ./Qsci/qscicommandset.h \ ./Qsci/qscidocument.h \ ./Qsci/qscilexer.h \ - ./Qsci/qscilexeravs.h \ + ./Qsci/qscilexerasm.h \ ./Qsci/qscilexerbash.h \ ./Qsci/qscilexerbatch.h \ ./Qsci/qscilexercmake.h \ @@ -234,7 +234,7 @@ SOURCES = \ qscicommandset.cpp \ qscidocument.cpp \ qscilexer.cpp \ - qscilexeravs.cpp \ + qscilexerasm.cpp \ qscilexerbash.cpp \ qscilexerbatch.cpp \ qscilexercmake.cpp \ diff --git a/src/qscint/src/qscintilla.pro.user b/src/qscint/src/qscintilla.pro.user deleted file mode 100755 index 09e53f5..0000000 --- a/src/qscint/src/qscintilla.pro.user +++ /dev/null @@ -1,261 +0,0 @@ - - - - - - EnvironmentId - {ee8a8311-48c9-435d-8d33-c3e67e1c3f3d} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - false - true - false - 0 - true - true - 0 - 8 - true - false - 1 - true - true - true - *.md, *.MD, Makefile - false - true - true - - - - ProjectExplorer.Project.PluginSettings - - - true - false - true - true - true - true - - - 0 - true - - true - true - Builtin.DefaultTidyAndClazy - 3 - - - - true - - - - - ProjectExplorer.Project.Target.0 - - Desktop - Desktop Qt 5.15.2 MSVC2019 64bit - Desktop Qt 5.15.2 MSVC2019 64bit - qt.qt5.5152.win64_msvc2019_64_kit - 1 - 0 - 0 - - 0 - D:\notepad--\qscint\src\..\build-qscintilla-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug - D:/notepad--/qscint/build-qscintilla-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug - - - true - QtProjectManager.QMakeBuildStep - false - - - - true - Qt4ProjectManager.MakeStep - - 2 - 构建 - 构建 - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - clean - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - - - D:\notepad--\qscint\src\..\build-qscintilla-Desktop_Qt_5_15_2_MSVC2019_64bit-Release - D:/notepad--/qscint/build-qscintilla-Desktop_Qt_5_15_2_MSVC2019_64bit-Release - - - true - QtProjectManager.QMakeBuildStep - false - - - - true - Qt4ProjectManager.MakeStep - - 2 - 构建 - 构建 - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - clean - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - 0 - - - 0 - D:\notepad--\qscint\src\..\build-qscintilla-Desktop_Qt_5_15_2_MSVC2019_64bit-Profile - D:/notepad--/qscint/build-qscintilla-Desktop_Qt_5_15_2_MSVC2019_64bit-Profile - - - true - QtProjectManager.QMakeBuildStep - false - - - - true - Qt4ProjectManager.MakeStep - - 2 - 构建 - 构建 - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - clean - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - 0 - 0 - - 3 - - - 0 - 部署 - 部署 - ProjectExplorer.BuildSteps.Deploy - - 1 - - false - ProjectExplorer.DefaultDeployConfiguration - - 1 - - true - true - true - - 2 - - ProjectExplorer.CustomExecutableRunConfiguration - - false - true - false - true - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 22 - - - Version - 22 - - diff --git a/src/qscint/src/qscintilla.vcxproj b/src/qscint/src/qscintilla.vcxproj deleted file mode 100755 index d64ecad..0000000 --- a/src/qscint/src/qscintilla.vcxproj +++ /dev/null @@ -1,585 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {9BC42707-EE25-3B28-9906-F7919E273020} - qmyedit_qt5d - QtVS_v304 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - v141 - ..\..\x64\Debug\ - false - NotSet - DynamicLibrary - debug\ - qmyedit_qt5d - - - v141 - ..\..\x64\Debug\ - false - NotSet - StaticLibrary - release\ - qmyedit_qt5d - - - - - - - - - - - - - - - - - - ..\..\x64\Debug\ - release\ - qmyedit_qt5d - true - - - ..\..\x64\Debug\ - debug\ - qmyedit_qt5d - true - - - 5.12.10_msvc2017_64 - core;gui;widgets;printsupport - - - 5.12.10_msvc2017_64 - core;gui;widgets;printsupport - - - - - - - GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\scintilla\include;..\scintilla\lexlib;..\scintilla\src;..\scintilla\boostregex;debug;/include;%(AdditionalIncludeDirectories) - -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus %(AdditionalOptions) - debug\ - false - ProgramDatabase - Sync - debug\ - Disabled - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;SCINTILLA_QT;SCI_LEXER;INCLUDE_DEPRECATED_FEATURES;%(PreprocessorDefinitions) - false - MultiThreadedDebugDLL - true - true - TurnOffAllWarnings - true - - - $(OutDir)\qmyedit_qt5d.lib - true - - - Unsigned - None - 0 - - - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;SCINTILLA_QT;SCI_LEXER;INCLUDE_DEPRECATED_FEATURES;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;_DEBUG;%(PreprocessorDefinitions) - - - msvc - ./$(Configuration)/moc_predefs.h - Moc'ing %(Identity)... - output - $(Configuration) - moc_%(Filename).cpp - - - - - GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\scintilla\include;..\scintilla\lexlib;..\scintilla\src;..\scintilla\boostregex;release;/include;%(AdditionalIncludeDirectories) - -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus %(AdditionalOptions) - release\ - false - None - Sync - release\ - MaxSpeed - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;SCINTILLA_QT;SCI_LEXER;INCLUDE_DEPRECATED_FEATURES;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions) - false - - - MultiThreadedDLL - true - true - TurnOffAllWarnings - true - - - $(OutDir)\qmyedit_qt5d.lib - true - - - Unsigned - None - 0 - - - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;SCINTILLA_QT;SCI_LEXER;INCLUDE_DEPRECATED_FEATURES;QT_NO_DEBUG;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;%(PreprocessorDefinitions) - - - msvc - ./$(Configuration)/moc_predefs.h - Moc'ing %(Identity)... - output - $(Configuration) - moc_%(Filename).cpp - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Document - $(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs) - cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -Zi -MDd -EHsc -W0 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >debug\moc_predefs.h - Generate moc_predefs.h - debug\moc_predefs.h;%(Outputs) - true - - - Document - true - $(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs) - cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -O2 -MD -EHsc -W0 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >release\moc_predefs.h - Generate moc_predefs.h - release\moc_predefs.h;%(Outputs) - - - - - - - - - - - \ No newline at end of file diff --git a/src/qscint/src/qscintilla.vcxproj.filters b/src/qscint/src/qscintilla.vcxproj.filters deleted file mode 100755 index 1fdb1a0..0000000 --- a/src/qscint/src/qscintilla.vcxproj.filters +++ /dev/null @@ -1,1193 +0,0 @@ - - - - - {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} - cpp;c;cxx;moc;h;def;odl;idl;res; - - - {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} - cpp;c;cxx;moc;h;def;odl;idl;res; - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {639EADAA-A684-42e4-A9AD-28FC9BCB8F7C} - ts;xlf - false - - - {639EADAA-A684-42e4-A9AD-28FC9BCB8F7C} - ts;xlf - false - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - - - - Generated Files - - - Generated Files - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Translation Files - - - \ No newline at end of file diff --git a/src/qscint/src/qscintilla.vcxproj.user b/src/qscint/src/qscintilla.vcxproj.user deleted file mode 100755 index 9bb571e..0000000 --- a/src/qscint/src/qscintilla.vcxproj.user +++ /dev/null @@ -1,10 +0,0 @@ - - - - - 2023-01-07T13:40:52.0407809Z - - - 2023-01-07T13:40:52.1883856Z - - \ No newline at end of file diff --git a/src/qscint/src/xmlMatchedTagsHighlighter.cpp b/src/qscint/src/xmlMatchedTagsHighlighter.cpp index 4554602..13c9fd1 100755 --- a/src/qscint/src/xmlMatchedTagsHighlighter.cpp +++ b/src/qscint/src/xmlMatchedTagsHighlighter.cpp @@ -1,5 +1,5 @@ -// This file is part of Notepad++ project -// Copyright (C)2021 Don HO +// This file is part of Notepad-- project +// Copyright (C)2023 zuowei.yin // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/qscint/src/xmlMatchedTagsHighlighter.h b/src/qscint/src/xmlMatchedTagsHighlighter.h index e041f37..fec5211 100755 --- a/src/qscint/src/xmlMatchedTagsHighlighter.h +++ b/src/qscint/src/xmlMatchedTagsHighlighter.h @@ -1,5 +1,5 @@ -// This file is part of Notepad++ project -// Copyright (C)2021 Don HO +// This file is part of Notepad-- project +// Copyright (C)2023 zuowei.yin // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/qtlangset.cpp b/src/qtlangset.cpp index e88d132..70f1672 100755 --- a/src/qtlangset.cpp +++ b/src/qtlangset.cpp @@ -4,6 +4,7 @@ #include "rcglobal.h" #include "ccnotepad.h" #include "styleset.h" +#include "extlexermanager.h" #include #include @@ -917,6 +918,12 @@ void QtLangSet::slot_itemSelect(QListWidgetItem *item) ui.keywordTe->setPlainText(keyword); ui.motherLangCb->setCurrentIndex(0); + //ùļ + QString langName = item->text(); + QStringList extList; + ExtLexerManager::getInstance()->getExtlistByLangTag(langName, extList); + ui.extFileType->setText(extList.join(',')); + for (int i = 0; i <= 255; ++i) { QString desc = pLexer->description(i); @@ -941,7 +948,7 @@ void QtLangSet::slot_itemSelect(QListWidgetItem *item) m_isStyleChange = false; - ui.extFileType->clear(); + //ui.extFileType->clear(); ui.motherLangCb->setCurrentIndex(0); } diff --git a/src/qtlangset.ui b/src/qtlangset.ui index 4100aba..0ad13c5 100755 --- a/src/qtlangset.ui +++ b/src/qtlangset.ui @@ -454,7 +454,7 @@ - 1 + 0 diff --git a/src/rcglobal.cpp b/src/rcglobal.cpp index 6cfe791..b14f6c4 100755 --- a/src/rcglobal.cpp +++ b/src/rcglobal.cpp @@ -20,6 +20,38 @@ QString getUserLangDirPath() return s_userLangDirPath; } +const int M_SIZE = 1024 * 1024; +const int G_SIZE = 1024 * 1024 * 1024; + +//把字节大小文件,转换为M 或 G 单位 +QString tranFileSize(qint64 fileSize) +{ + float num = 0.0f; + QString unit; + + if (fileSize >= G_SIZE) + { + num = double(fileSize) / G_SIZE; + unit = "GB"; + } + else if (fileSize >= M_SIZE) + { + num = double(fileSize) / M_SIZE; + unit = "MB"; + } + else if (fileSize > 1024) + { + num = float(fileSize) / 1024; + unit = "KB"; + } + else + { + return QString("%1").arg(fileSize); + } + + return QString("%1 %2").arg(num, 0, 'f' , 2).arg(unit); +} + void showFileInExplorer(QString path) { QString cmd; diff --git a/src/rcglobal.h b/src/rcglobal.h index 404bde0..9ecbe0e 100755 --- a/src/rcglobal.h +++ b/src/rcglobal.h @@ -5,7 +5,17 @@ #include #include -static const char* VersionStr = "v1.21.0"; +//#define TEST_PRE + +#ifdef TEST_PRE +static const char* VersionStr = u8"(内部测试非稳定) v1.22.0"; +#else + +static const char* VersionStr = "v1.22.0"; +#endif // TEST_PRE + + +//#define NO_PLUGIN 1 #define CMP_CODE_NOEQUAL @@ -158,3 +168,4 @@ QString getUserLangDirPath(); #endif void showFileInExplorer(QString path); +QString tranFileSize(qint64 fileSize); diff --git a/src/realcompare_zh.qm b/src/realcompare_zh.qm index 3c8d99c..9f992f6 100755 Binary files a/src/realcompare_zh.qm and b/src/realcompare_zh.qm differ diff --git a/src/realcompare_zh.ts b/src/realcompare_zh.ts index bd1dc2d..16d7070 100755 --- a/src/realcompare_zh.ts +++ b/src/realcompare_zh.ts @@ -70,7 +70,7 @@ BatchFindReplace - + $1 has no find match work item %1 没有对应的查找匹配项! @@ -79,7 +79,7 @@ 最多支持10000条关键字! - + Please input find keyword ! 请输入批量查找的关键字! @@ -88,43 +88,43 @@ 批量查找完成! - + Max find key word 20000 ! 最多支持10000条关键字! {20000 ?} - - + + total %1 keyword, please wait ... - + Batch Find Finished! total %1 found. - + Batch Replace Finished, total Replace %1 times ! 批量替换完成,一共替换 %1 处! - + Save File As ... 另存为文件 ... - + Export File finished ! 导出配置文件成功 ! - + No Content to Export ! 没有内容以供导出! - + Batch Mark Finished, total Mark %1 times ! 批量标记完成,一共标记 %1 处! @@ -210,67 +210,83 @@ BigFileMessageClass - + BigFileMessage 大文件打开方式 - + TextLabel - + Open Mode 打开方式 - + + Big Text File(< 8G) Read only open, load in blocks, and turn pages manually. + 大文本只读模式(文件小于8G时推荐)可显示行号,行号跳转。 + + + + + Super Big Text Edit + 超大文本模式 + + + + Text Mode 文本模式 - - + + Open directly in text mode.May be slow, Need wait. 直接以普通文本打开,注意:可能比较慢或卡顿,需要等待。(不推荐) - - + + Big Text 大文本模式 - - Read only open, load in blocks, and turn pages manually. - 分块只读打开大文件,速度快,需要手动进行前后翻页。(推荐) + 分块只读打开大文件,速度快,需要手动进行前后翻页。(推荐) - - + + Hex Bin 二进制模式 - - + + Binary Open,load in blocks, and turn pages manually. 二进制打开,速度快,需要手动进行前后翻页。 - - + + + Super big Text File(> 8G bits) Read only open, load in blocks, and turn pages manually. + 超大文本只读模式(文件大于8G时推荐)顺序翻页可显示行号,支持地址跳转。 + + + + Ok 确定 - - + + Cancel 取消 @@ -287,7 +303,7 @@ - + Format Conversion 格式转换 @@ -301,7 +317,7 @@ - + Display symbols 显示符号 @@ -310,130 +326,130 @@ 编码 - - + + Language 语言 - + P - - - + + + C - + J - - - + + + R - + H - + M - + B - + I - + N - + A - - + + S - - + + V - - + + L - - + + T - - + + F - - - - - - + + + + + + D - - + + O - - + + E - - + + G @@ -446,8 +462,8 @@ 皮肤风格 - - + + About 关于 @@ -456,8 +472,8 @@ 对比 - - + + Recently 最近对比 @@ -470,373 +486,373 @@ 文件... - - + + New 新建 - - + + Open ... 打开 - - + + Ctrl+O - - + + Save 保存 - - + + Ctrl+S - - + + Save As ... 另存为 - - + + Ctrl+Alt+S - - - - + + + + Close 关闭 - - + + Ctrl+W - - + + Exit 退出 - - + + Ctrl+Q - - - + + + Close All 关闭所有 - - + + Ctrl+Shift+W - - - + + + Undo 撤销 - - + + Ctrl+Z - - - + + + Redo 重做 - - + + Ctrl+Y - - - + + + Cut 剪切 - - + + Ctrl+X - - + + Copy 拷贝 - - + + Ctrl+C - - - + + + Paste 粘贴 - - + + Ctrl+V - - + + Select All 全选 - - + + Ctrl+A - - + + Windows(CR+LF) - - + + Unix(LF) - - + + Mac(CR) - - - + + + Find 查找 - - + + Ctrl+F - - - + + + Replace 替换 - - + + Go line 跳转 - - + + Ctrl+G - - + + Show spaces/tabs 显示空格 - - + + Show end of line 显示行尾 - - + + Show all 显示所有 - - + + Encode in GBK 编码 GBK - - + + Encode in UTF8 编码 UTF8 - - + + Encode in UTF8-BOM 编码 UTF8-BOM - - + + Encode in UCS-2 BE BOM 编码 UCS-2 BE BOM - - + + Encode in UCS-2 LE BOM 编码 UCS-2 LE BOM - - + + Convert to GBK 转换为 GBK 编码 - - + + Convert to UTF8 转换为 UTF8 编码 - - + + Convert to UTF8-BOM 转换为 UTF8-BOM 编码 - - + + Convert to UCS-2 BE BOM 转换为 UCS-2 BE BOM 编码 - - + + Convert to UCS-2 LE BOM 转换为 UCS-2 LE BOM 编码 - - + + Batch convert 批量转换编码 - - + + Options 选项 - - + + BugFix 问题反馈 - - + + Donate 捐赠作者 - - + + Default 默认 - - + + LightBlue 亮蓝 - - + + ThinBlue 淡蓝 - - + + RiceYellow 纸黄 - - - - + + + + Yellow 黄色 - - + + Silver 银色 - - + + LavenderBlush 淡紫红 - - + + MistyRose 浅玫瑰色 - - + + English 英文 - - + + Chinese 中文 @@ -845,147 +861,147 @@ 捐赠软件 - - + + TXT - - + + Search Result 查找结果 - - - - + + + + test - - + + go - - + + File compare 文件对比 - + notepad-- - + File(&F) 文件(&F) - + Edit(&E) 编辑(&E) - + Blank CharOperate 空白字符操作 - + Convert Case to 大小写转换 - + Line Operations 行编辑 - + Search(&S) 查找(&S) - + Book Mark 书签 - + Mark Color 标记颜色... - + View(&V) 视图(&V) - + Icon Size 图标大小 - + Encoding(&N) 编码(&N) - + Other 其它编码 - + Convert to Other 转换为其它编码 - + Language(&L) 语言(&L) - - + + Set(&T) 设置(&T) - + Format Language 格式化语言 - - + + Feedback 反馈问题 - - + + Compare(&C) 对比(&C) @@ -994,995 +1010,1011 @@ 最近对比(&R) - - + + Ctrl+T - - + + Ctrl+H - - + + Dir compare 目录对比 - - + + XML - - + + YAML - - + + Php - - + + C++ - - + + C# - - + + Objective C - - + + Java - - + + RC - - + + HTML - - + + Makefile - - + + Pascal - - + + Batch - - + + ini - - + + Nfo - - + + Asp - - + + Sql - - + + Virsual Basic - - + + JavaScript - - + + Css - - + + Perl - - + + Python - - + + Lua - - + + Tex - - + + Fortran - - + + Shell - - + + ActionScript - - + + NSIS - - + + Tcl - - + + Lisp - - + + Scheme - - + + Assembly - - + + Diff - - + + Properties file - - + + PostScript - - + + Ruby - - + + Smalltalk - - + + VHDL - - + + AutoIt - - + + CMake - - + + PowerShell - - + + Jsp - - + + CoffeeScript - - + + BaanC - - + + S-Record - - + + TypeScript - - + + Visual Prolog - - + + Txt2tags - - + + Rust - - + + Registry - - + + REBOL - - + + OScript - - + + Nncrontab - - + + Nim - - + + MMIXAL - - + + LaTex - - + + Forth - - + + ESCRIPT - - + + Erlang - - + + Csound - - + + FreeBasic - - + + BlitzBasic - - + + PureBasic - - + + AviSynth - - + + ASN.1 - - + + Swift - - + + Intel HEX - - + + Fortran77 - - + + Edifact - - - - + + + + MarkDown - - + + Octave - - + + Po - - + + Pov - - + + json - - + + AVS - - + + Bash - - + + IDL - - + + Matlab - - + + Spice - - + + Verilog - - + + Register 注册版本 - - - Language Format - 编程语言格式 + + + Language File Suffix + 语法文件后缀关联 - - + + + Shortcut Key Manager + 快捷键管理 + + + Language Format + 编程语言格式 + + + + Open In Text 以文本模式打开 - - + + Open In Bin 以二进制模式打开 - - + + Remove Head Blank 去除行首空白 - - + + Remove End Blank 去除行尾空白 - - + + Remove Head End Blank 去除行首尾空白 - - + + Column Block Editing 列块编辑 - - + + Wrap 自动换行 - - + + Define Language 自定义语言 - - + + UPPERCASE 转成大写 - - + + lowercase 转成小写 - - + + Proper Case 每词转成仅首字母大写 - - + + Proper Case (blend) 每词的首字母转成大写 - - + + Sentence case 每句转成仅首字母大写 - - + + Sentence case (blend) 每句的首字母转成大写 - - + + Invert Case 大小写互换 - - + + Random Case 随机大小写 - - + + Remove Empty Lines 移除空行 - - + + Remove Empty Lines (Containing Blank characters) 移除空行(包括空白字符) - - + + UserDefine 用户自定义 - - + + Column Block Mode 列块模式... - - + + TAB to Space TAB 转空格 - - + + Space to TAB (All) 空格转 TAB (全部) - - + + Space to TAB (Leading) 空格转 TAB (行首) - - + + Duplicate Current Line 复制当前行 - - + + Ctrl+D - - + + Remove Duplicate Lines 删除重复行 - - + + Remove Consecutive Duplicate Lines 删除连续的重复行 - - + + Split Lines 分隔行 - - + + Join Lines 合并行 - - + + Move Up Current Line 上移当前行 - - + + Ctrl+Shift+Up - - + + Move Down Current Line 下移当前行 - - + + Ctrl+Shift+Down - - + + Insert Blank Line Above Current 在当前行上方插入空行 - - + + Ctrl+Alt+Return - - + + Insert Blank Line Below Current 在当前行下方插入空行 - - + + Ctrl+Alt+Shift+Return - - + + Reverse Line Order 反排序行 - - + + Randomize Line Order - - + + Sort Lines Lexicographically Ascending 升序排列文本行 - - + + Sort Lines Lex. Ascending Ignoring Case 升序排列文本行(不分大小写) - - + + Sort Lines As Integers Ascending - - + + Sort Lines As Decimals (Comma) Ascending - - + + Sort Lines As Decimals (Dot) Ascending - - + + Sort Lines Lexicographically Descending 降序排列文本行 - - + + Sort Lines Lex. Descending Ignoring Case 降序排列文本行(不分大小写) - - + + Sort Lines As Integers Descending - - + + Sort Lines As Decimals (Comma) Descending - - + + Sort Lines As Decimals (Dot) Descending - - + + Find In Dir 在目录查找 - - + + Ctrl+Shift+D - - - - + + + + 1 - - - + + + Format Xml 格式化 Xml - - - + + + Format Json 格式化 Json - - + + Dark 深色 - - + + VB - - + + 2 - - + + 3 - - + + 4 - - + + 5 - - + + loop - - + + Clear History 清除历史打开记录 - - + + FileListView 文件列表窗口 - - + + Show ToolBar 显示工具栏 - - - + + + Batch Find 批量查找替换 - - + + Show Web Addr(Not recommended) 显示网站(不推荐开启) - - + + Find Next 查找下一个 - - + + menuDir 目录对比记录 - - + + menuReceFile 文件对比记录 - - + + Tools(&O) 工具(&O) - - + + + Theme Style + 主题与语法样式 + + + + F3 - - + + Find Prev 查找前一个 - - + + F4 - - + + Red - - + + Blue - - - - + + + + Big5 Big5(繁体中文) - - + + 24x24 - - + + 36x36 - - + + 48x48 - - + + AboutNdd About ndd 关于Ndd @@ -1992,90 +2024,90 @@ 信息 - - + + Ln:0 Col:0 行 0 列 0 - - + + Quit 退出 - + Edit with Notepad-- Edit with Notebook CC - + Close Current Document 关闭当前文档 - + Close Non-Current documents 关闭所有非当前文档 - + Close Left All 关闭左边所有文档 - + Close Right All 关闭右边所有文档 - + Current Document Sava as... 当前文件另存为 - + Show File in Explorer... 定位到文件路径 - + Open in New Window 在新窗口中打开 - + Can't Get Admin Auth, Open File %1 failed 获取管理员权限失败,打开文件 %1 失败。修改系统文件请以管理员权限执行ndd程序。 - + Please run in admin auth 请在管理员权限下执行程序 - + Rename Current Document 重命名当前文件 - + Reload With Text Mode 重新以文本模式打开 - + Reload With Hex Mode 重新以二进制模式打开 - + Select Left Cmp File 选择为左边对比文件 - + Select Right Cmp File 选择为右边对比文件 @@ -2084,213 +2116,238 @@ 大文本文件只读模式 - + New File 新建 - + Open File 打开 - - + + Save File 保存 - + Save All File 保存所有 - + Cycle Auto Save 周期自动保存 - + Mark 标记 - + word highlight(F8) 高亮单词(F8) - + clear all highlight(F7) 取消所有高亮(F7) - + Zoom In 放大 - + Zoom Out 缩小 - + Word Wrap 自动换行 - + Show Blank 显示空白字符 - + Indent Guide 缩进参考线 - + Pre Hex Page 上一页/位置 - + Next Hex Page 下一页/位置 - + Goto Hex Page 跳转到文件偏移地址 - + File Compare 文件对比 - + Dir Compare 目录对比 - + Bin Compare 二进制对比 - + transform encoding 转换编码 - + batch rename file 批量重命名 - + Zoom: %1% 缩放率: %1% - + Big5(Traditional Chinese) Big5(繁体中文) - + New File Finished [Text Mode] Zoom %1% 创建新文件成功 缩放率 %1% - + Use < (Pre) or > (Next) and Goto Buttons to Change Page Num . 使用工具栏按钮 < (前一页) >(下一页) Go(跳转) 进行翻页。 - + File %1 File Size %2 > %3M, How to Open it ? 文件 %1 文件大小 %2 大于 %3M,请选择打开方式。 - + File %1 Open Finished [Text Mode] Zoom %2% 文件 %1 打开成功 [文本模式] 缩放率 %2% - + + + Format Error + + + + + + + + Not a txt format file , load with big txt is garbled code! + 文件不是文本格式,强制以大文本打开时乱码! + + + + + Current offset is %1 , line nums is %2 - %3 load Contens Size is %4, File Total Size is %5 + 当前文件偏移 %1 ,行号 %2-%3 ,分块加载大小 %4 ,文件大小是 %5 + + + File List 文件列表 - + Save Swap File %1 failed. Write the target file directly ? 保存交换文件 %1 失败,是否直接保存写入原始文件? - - + + Current Zoom Value is %1% 当前缩放率 %1% - + + out of file line range,mar line num is %1 ! + + + + Ndd Version %1 - + Registered Version 注册过的正版软件!(恭喜) - + Free Trial 免费永久试用版本(捐赠可获取注册码) - + %1 is not a file, skip open it... %1 不是一个文件,跳过打开它...... - - - + + + The ReadOnly document does not allow this operation. 当前只读显示文件不允许该操作! - + Column Edit Mode Tips 列块模式提示 - + "ALT+Mouse Click" or "Alt+Shift+Arrow keys" Switch to mode! 请使用'ALT+鼠标点选' 或 'Alt+Shif+箭头键'切换列块模式。 - + SortingError 排序错误 - + Unable to perform numeric sorting due to line %1. 行 %1 不能进行排序操作! - + Xml format error, please check! Xml 格式化错误,请检查文件格式! - + Json format error, please check! Json 格式化错误,请检查文件格式! @@ -2299,75 +2356,76 @@ File Size %2 > %3M, How to Open it ? 已打开的窗口背景颜色,将在文件重新打开后才会生效! - + GB18030(Simplified Chinese) GB18030(简体中文) - + Language: %1 语法:%1 - + Reload 重加载 - + Yes 保存 - - + + No 放弃修改 - + Cancel 取消 - - + + Restore Last Temp File %1 Failed 恢复临时文件 %1 失败! - + Recover File? 是否恢复文件? - + File %1 abnormally closed last time , Restore it ? 文件 %1 上次异常退出并留下未保存存档,是否恢复文件存档? - + Restore 恢复文件? - + + File %1 Open Failed 文件 %1 打开失败! - + File %1 Open Finished [Text Mode] 文件 %1 打开成功 [文本模式] - - + + Current offset is %1 , load Contens Size is %2, File Total Size is %3 当前文件偏移 %1 , 加载内容大小是 %2,文件总大小是 %3 (字节) - + File %1 Open Finished [Hex ReayOnly Mode] 文件 %1 打开成功 [二进制只读模式] @@ -2376,23 +2434,23 @@ File Size %2 > %3M, How to Open it ? 文件 %1 可能是二进制文件,尝试以文本格式打开。 - + Save File %1 failed. You may not have write privileges Please save as a new file! 保存文件 %1 失败! 你可能没有文件写权限,请另存为一个新文件! - + Cycle autosave on ... 周期性自动保存文件已开启... - + Cycle autosave off ... 周期性自动保存文件已关闭... - + The current document has been automatically saved 当前文件周期性自动保存完毕! @@ -2409,17 +2467,19 @@ Do you want to reload it? %1\n\n \n文件已在外部被其它程序修改。\n是否重新加载该文件? - + + + Ln: %1 Col: %2 行:%1 列:%2 - + Save File? 保存文件? - + if save file %1 ? 是否保存文件 %1 ? @@ -2428,31 +2488,31 @@ Do you want to reload it? 当前文件偏移 %1 , 文件大小是 %2 (字节) - - - - - - - - + + + + + + + + Error 错误 - + file %1 not exist. 文件 %1 不存在 - - + + file %1 already open at tab %2 文件 %1 已经在页面 %2 中打开 - - + + Save File %1 failed. Can not write auth, Please save as new file 保存 %1 失败。当前文件没有写权限,请另存为一个新文件 @@ -2461,143 +2521,148 @@ Do you want to reload it? 打开文件 %1 失败 - - - - + + + + Only Text File Can Use it, Current Doc is a Hex File ! 只有文本模式才能使用该功能,当前文件是二进制文件! - + "%1" This file has been modified by another program. Do you want to reload it? %1 该文件已在外部被其它程序修改,是否重新加载? - + Run As Admin Failed to save the file. Please check the file permissions. 以管理员模式保存文件失败!请检查文件的权限。 - + Plugin Manager 插件管理 - + + plugin %1 load failed ! + + + + Plugin 插件 - + If display exceptions,Please Install System Font Courier 如果界面字体不满意,还请安装windows系统字体 Courier - + Set/Remove BookMark 设置/取消书签 - + Next BookMark 下一书签 - + Prev BookMark 上一书签 - + ClearAll BookMark 清除所有书签 - + Cut BookMark Lines 剪切书签行 - + Copy BookMark Lines 复制书签行 - + Paste BookMark Lines 粘贴(替换)书签行 - + Delete BookMark Lines 删除书签行 - + Delete UnBookMark Lines 删除未标记行 - + Clip BookMark 反向标记书签 - + Color %1 颜色 %1 - + The currently file %1 is already in text mode 当前文件 %1 已经是文本模式 - + The currently file %1 is already in bin mode 当前文件 %1 已经是二进制模式 - - + + File %1 Open Finished [Text ReadOnly Mode] (Note: display up to 50K bytes ...) 文件 %1 打开成功 [文本只读模式] (乱码:二进制文件强行以文本格式显示,最多显示50K字节的内容,后面忽略...) - - + + file %1 already open at tab %2, please select other file name. 文件 %1 已经存在于页面 %2 中,请选择一个其它名称 - + Rename File As ... 重命名... - + file %1 reanme failed! 文件 %1 重命名失败! - - + + Save File As ... 另存为文件 ... - + Close ? 关闭? - + already has child window open, close all ? 目前还有子窗口处于打开状态,关闭所有窗口吗? - + Find result 查找结果 @@ -2606,50 +2671,50 @@ Do you want to reload it? 文件已关闭 - - + + Find result - %1 hit 查找结果 - %1 命中 - + Convert end of line In progress, please wait ... 行尾转换中,请等待... - + Convert end of line finish. 行尾转换完毕 - + Go to line 跳转到行 - + Line Num: 行号 - + no more pre pos 没有前一个位置了 - + no more next pos 没有后一个位置了 - - - + + + The Last Page ! Current offset is %1 , load Contens Size is %2, File Total Size is %3 最后一页!当前文件偏移是 %1 ,加载内容大小是 %2 ,文件总大小是 %3 (字节) - + Only Hex File Can Use it, Current Doc not a Hex File ! 只有二进制文件具备该功能。当前文件不是二进制文件! @@ -2658,31 +2723,31 @@ Do you want to reload it? 最后一页!当前文件偏移是 %1 ,文件大小是 %2 (字节) - + file %1 was not exists ! 文件 %1 不存在! - - + + Error file offset addr , please check ! 错误的文件偏移量地址,请检查! - - + + File Size is %1, addr %2 is exceeds file size 文件大小是 %1,当前地址 %2 超过了文件大小。 - + Current Text Doc Can Not Use it ! Current Text Doc Canp Not Use it ! 当前是常规文本文档,不能使用该功能! - - + + bugfix: https://github.com/cxasm/notepad-- china: https://gitee.com/cxasm/notepad-- bugfix: https://github.com/cxasm/notepad-- @@ -2690,14 +2755,14 @@ china: https://gitee.com/cxasm/notepad-- 国内:https://gitee.com/cxasm/notepad-- - - + + notice 消息 - - + + file path not exist, remove recent record! 文件路径不存在,删除历史记录! @@ -2730,7 +2795,7 @@ china: https://gitee.com/cxasm/notepad-- 文件开始偏移位置超过文件长度! - + BigFile Compare, left linenum %1 , right lineNum %2, Please Waiting ! 大文件对比,左文件行数 %1 ,右文件行数 %2, 请等待 ! @@ -3168,23 +3233,33 @@ china: https://gitee.com/cxasm/notepad-- 当前文件:%1 - - - Yes - - - - - No - 放弃修改 + 放弃修改 + + Cancel 取消 + + + + + + Yes[hex cmp] + 是[进行二进制对比] + + + + + + + No[text cmp] + 否[进行文件对比] + current exec rule mode is quick mode, please wait ... @@ -4399,52 +4474,58 @@ Left Equal ratio %4 Right Equal ratio %5 FileManager - - + + Error 错误 - + Open File %1 failed Can not read auth 打开文件 %1 失败。没有读文件的权限。 - + Open File %1 failed 打开文件 %1 失败。 - + File is too big to be opened by Notepad-- 文件太大,不能使用Notepad--打开! - + The file %1 is likely to be binary. Do you want to open it in binary? 文件 %1 可能是二进制格式,你想以二进制(只读)格式打开文件吗? - + Open with Text or Hex? 二进制或文本打开? - + Hex Open 以二进制打开 - + Text Open 以文本打开 - + Cancel 取消 + + + load bit text file tree in progress +file size %1, please wait ... + 加载大文件中,文件大小 %1,请等待... + File is too big to be opened by CC Notepad 文件太大不能使用Notepad打开! @@ -4568,7 +4649,7 @@ Left Equal ratio %4 Right Equal ratio %5 FindResultWin - + FindResultWin 查找结果 @@ -4577,12 +4658,12 @@ Left Equal ratio %4 Right Equal ratio %5 清空 - + clear this find result 清除当前结果 - + clear all find result 清除所有结果 @@ -4591,72 +4672,106 @@ Left Equal ratio %4 Right Equal ratio %5 拷贝到剪切板 - + copy select item (Ctrl Muli) 复制选中项(按ctrl多选) - + copy select Line (Ctrl Muli) 复制选中行(按ctrl多选) - + select section 选中所在节 - + select all item 全部选择 - + + Zoom In + 放大 + + + + Zoom Out + 缩小 + + + close 关闭 - - + + %1 rows selected ! %1 行被选中! - + %1 items have been copied to the clipboard ! %1 项已经被复制到剪切板 - + %1 lines have been copied to the clipboard ! %1 行已经被复制到剪切板 - - - <font style='font-weight:bold;color:#343497'>Search "%1" (%2 hits)</font> - <font style='font-weight:bold;color:#343497'>查找 "%1" (%2 命中)</font> - - - - - <font style='font-weight:bold;color:#309730'>%1 (%2 hits)</font> - <font style='font-weight:bold;color:#309730'>%1 (%2 命中)</font> - - <font style='color:#99cc99'>%1 (%2 hits)</font> - + <font style='font-size:14px;font-weight:bold;color:#343497'>Search "%1" (%2 hits)</font> + <font style='font-size:14px;font-weight:bold;color:#343497'>查找 "%1" (%2 命中)</font> + + + + + <font style='font-size:14px;font-weight:bold;color:#309730'>%1 (%2 hits)</font> + <font style='font-size:14px;font-weight:bold;color:#309730'>%1 (%2 命中)</font> + + + + + <font style='font-size:14px;color:#99cc99'>%1 (%2 hits)</font> + <font style='font-size:14px;color:#99cc99'>%1 (%2 命中)</font> + + + + + <font style='font-size:14px;'>Line </font><font style='font-size:14px;color:#ff8040'>%1</font> : %2 + <font style='font-size:14px;'>行 </font><font style='font-size:14px;color:#ff8040'>%1</font> : %2 + + + + + <font style='font-size:14px;color:#ffffff'>Line </font><font style='font-size:14px;color:#ff8040'>%1</font> : %2 + <font style='font-size:14px;color:#ffffff'>行 </font><font style='font-size:14px;color:#ff8040'>%1</font> : %2 + + + + <font style='font-size:14px;font-weight:bold;color:#343497'>Search "%1" (%2 hits in %3 files)</font> + <font style='font-size:14px;font-weight:bold;color:#343497'>查找 "%1" (%2 命中在 %3 文件)</font> + + + <font style='font-weight:bold;color:#343497'>Search "%1" (%2 hits)</font> + <font style='font-weight:bold;color:#343497'>查找 "%1" (%2 命中)</font> + + + <font style='font-weight:bold;color:#309730'>%1 (%2 hits)</font> + <font style='font-weight:bold;color:#309730'>%1 (%2 命中)</font> - <font style='color:#ff8040'>Line %1</font> : %2 Line <font style='color:#ff8040'>%1</font> : %2 - 行 <font style='color:#ff8040'>%1</font> : %2 + <font style='color:#ff8040'>行 %1</font> : %2 - <font style='font-weight:bold;color:#343497'>Search "%1" (%2 hits in %3 files)</font> - <font style='font-weight:bold;color:#343497'>查找 "%1" (%2 命中在 %3 个文件)</font> + <font style='font-weight:bold;color:#343497'>查找 "%1" (%2 命中在 %3 个文件)</font> Search "%1" (%2 hits) @@ -4675,282 +4790,282 @@ Left Equal ratio %4 Right Equal ratio %5 FindWin - + MainWindow 查找与替换 - + find 查找 - - - - + + + + Find what : 查找目标: - - - + + + Backward direction 反向查找 - - - - - - - + + + + + + + Match whole word only 全词匹配 - - - - - - - + + + + + + + Match case 匹配大小写 - - - + + + Wrap around 循环查找 - - - - - - - + + + + + + + Search Mode 查找模式 - - - - - - - + + + + + + + Regular expression 正则表达式 - - - - - - - + + + + + + + Normal 普通 - - - - - - - + + + + + + + Extend(\n,\r,\t,\0,\x...) 扩展(\n,\r,\t,\0,\x...) - + Find Next(F3) 查找下一个(F3) - + F3 - + Find Prev(F4) 查找上一个(F4) - + F4 - + Counter(T) 计数(T) - + Ctrl+T - - + + Find Next 查找下一个 - - + + File Type : 文件类型: - - + + Skip Dir Name : 跳过目录名: - - + + Clear All 清除全部标记 - + Find All in Current Document 在当前文件中查找 - + Find All in All Opened Documents 查找所有打开文件 - - - - - - - + + + + + + + Close 关闭 - - - + + + Replace 替换 - - - + + + Replace with : 替换为: - - + + Replace All 在当前文件中替换 - - + + Replace All in All Opened Documents 替换所有打开文件 - - + + Replace In File 在目录文件中替换 - - - + + + Clear Result 清空结果 - - + + Mark 标记 - - + + Mark What 标记目标: - - + + Mark All 全部标记 - - + + Clear Mark 清除 - - + + Dir Find 在目录查找 - - + + Dest Dir : 目标目录: - - + + Select 选择 @@ -4959,8 +5074,8 @@ Left Equal ratio %4 Right Equal ratio %5 文件类型: - - + + *.c:*.cpp:*.h @@ -4969,278 +5084,278 @@ Left Equal ratio %4 Right Equal ratio %5 跳过目录名 - - + + debug:Debug:.vs:.git:.svn - - + + Options 选项 - - + + Skip child dirs 跳过子目录 - - + + Skip hide file 跳过隐藏文件 - - + + Skip binary file 跳过二进制文件 - - + + Skip Big file exceed 跳过超过大小的文件 - - + + MB - - + + Find All 全部查找 - - - - - - - - - - - + + + + + + + + + + + what find is null ! 查找字段为空 - - - - - + + + + + cant't find text '%1' 找不到字段 '%1' - - + + no more find text '%1' 没有更多的字段 '%1' - - - - + + + + The ReadOnly document does not allow this operation. 当前只读显示文件不允许该操作! - - + + find finished, total %1 found! 查找完成,一共 %1 处发现。 - - + + The mode of the current document does not allow this operation. 当前模式下的文档不允许该操作! - - - - + + + + The ReadOnly document does not allow replacement. 当前只读文档不允许执行替换操作! - - + + no more replace text '%1' 没有更多替换文本 '%1' - + find-regex-zero-length-match 正则查找零长匹配 - + target info linenum %1 pos is %2 - %3 目标在行 %1 位置 %2 - %3 - - + + count %1 times with '%2' 计数 %1 次匹配 '%2' - + total %1 keyword, please wait ... - - + + The mode of the current document does not allow replacement. 当前模式的文档不允许执行替换操作! - - + + Replace All current Doc 在所有打开文件中替换 - - + + Are you sure replace all occurrences in current documents? 是否确认在当前打开的文档中替换? - - + + replace finished, total %1 replaced! 替换完成,一共 %1 处替换! - + Replace All Open Doc 替换所有打开的文档 - + Are you sure replace all occurrences in all open documents? 是否确认在所有打开的文档中替换? - + Replace in Opened Files: %1 occurrences were replaced. 在打开的文档中替换:%1 处已经被替换。 - - + + what mark is null ! 标记字段为空! - + cant't mark text '%1' 不能标记文本 ‘%1’ - + mark finished, total %1 found! 标记完成,一共 %1 处发现! - + The mode of the current document does not allow mark. 当前模式的文档不允许执行标记操作! - + Open Directory 打开目录 - + load dir file in progress , please wait ... 加载目录文件中,请等待... - - + + skip dir %1 跳过目录 %1 - + found %1 dir %2 发现 %1 个目录 %2 - + ext type skip file %1 跳过类型文件 %1 - + found in dir canceled ... 查找取消... - + Continue Find ? 是否继续查找? - + The search results have been greater than %1 times in %2 files, and more may be slow. Continue to search? 查找结果已经有 %1 处在 %2 个文件中,结果太多会比较慢,是否继续查找? - + Yes 继续查找 - + Abort 终止查找 - - + + please select find dest dir ! 请选择目标文件夹! - + dest dir %1 not exist ! 目标文件夹 %1 不存在! - + find finished, total %1 found in %2 file! 查找完成,一共发现 %1 处在 %2 个文件中! - + Replace All Dirs 目录全部替换 - + Are you sure replace all "%1" to "%2" occurrences in selected dirs ? 您确定替换目录文件中所有 "%1" 为 "%2" 吗? - + replace finished, total %1 replace in %2 file! 替换完成,一共替换 %1 处在 %2 个文件中! @@ -5453,6 +5568,71 @@ Select a shorter range for comparison. 取消 + + LangExtSet + + + current lang: %1 +ext file suffix is : %2 +Double-click a column item to modify the syntax association file. + 当前语言:%1 +关联文件后缀是: %2 +双击列可修改关联文件后缀,多个后缀用 ','号分隔开。 + + + + Not change, no need save ! + 没有改变,无需保存! + + + + Save Finished ! + 保存成功! + + + + Save Change + 保存修改 + + + + Configuration has been modified. Do you want to save it? + 配置已经被修改,您是否要保存? + + + + LangExtSetClass + + + + LangExtSet + 语法文件后缀关联 + + + + + Language + 语言 + + + + + File Suffix + 文件后缀 + + + + + Save + 保存 + + + + + Close + 关闭 + + LangStyleDefine @@ -5635,15 +5815,15 @@ Select a shorter range for comparison. 请安装至少一种系统字体[[Courier/SimSun/Times New Roman]。软件界面字体显示可能不满意。 - - - + + + The new software has been released, please update it timely! 软件新版本已经发布,请及时更新! - - + + Software status is normal. 软件状态正常 @@ -5660,7 +5840,7 @@ Select a shorter range for comparison. 消息 - + Please contact us. QQ Group:959439826 请加入我们QQ群:959439826 @@ -5805,12 +5985,12 @@ Select a shorter range for comparison. 关闭 - + Notice 消息 - + Are you sure to cancel? 您确定取消吗? @@ -5818,27 +5998,38 @@ Select a shorter range for comparison. QObject - + Text Mode 文本模式 - + Hex ReadOnly Mode 二进制只读模式 - - Bit Text ReadOnly Mode + + Big Text ReadOnly Mode + Bit Text ReadOnly Mode 大文本只读模式 - + + Big Text ReadWrite Mode + + + + + Super Big Text ReadOnly Mode + 超大文本只读模式 + + + Text ReadOnly Mode 文本只读模式 - + File Mode 文件模式 @@ -5846,79 +6037,37 @@ Select a shorter range for comparison. QsciDisplayWindow - + Find Text 查找文本 - + Show File in Explorer 定位到文件目录 - + Save As ... 另存为 - - + + Not Find 没有找到 - + Not Find Next! 找不到下一个! - + Not Find Prev! 找不到前一个! - - QsciLexerText - - Chinese And Others - 中文字符及其它 - - - Ascii - 英文字符 - - - Keyword - 关键词 - - - - QsciScintilla - - &Cut - 剪切 - - - &Copy - 复制 - - - &Paste - 粘贴 - - - Delete - 删除 - - - Select All - 全选 - - - Show File in Explorer - 定位到文件目录 - - QsciLexerGlobal @@ -5937,10 +6086,6 @@ Select a shorter range for comparison. Brace highlight style 括弧高亮风格 - - Bad brace colour - - Current line background colour 当前行背景色 @@ -5953,10 +6098,6 @@ Select a shorter range for comparison. Caret colour 光标颜色 - - Edge colour - - Line number margin 行号风格 @@ -6009,27 +6150,57 @@ Select a shorter range for comparison. Mark Style 5 标记样式5 - - Incremental highlight - - - - Tags match highlight - - - - Tags attribute - - URL hovered 网址鼠标悬浮样式 + + QsciLexerText + + Chinese And Others + 中文字符及其它 + + + Ascii + 英文字符 + + + Keyword + 关键词 + + + + QsciScintilla + + &Cut + 剪切 + + + &Copy + 复制 + + + &Paste + 粘贴 + + + Delete + 删除 + + + Select All + 全选 + + + Show File in Explorer + 定位到文件目录 + + QtLangSet - + Save Change 保存修改 @@ -6038,74 +6209,74 @@ Select a shorter range for comparison. 当前语言的格式风格已经被修改,是否保存? - - + + AllGlobal 全局格式统一设置 - + Current themes : %1, language : %2 当前主题:%1,当前语言:%2 - + %1 style configuration has been modified. Do you want to save it? %1 类型的显示风格已经被修改,是否保存? - + Read %1 language user define format error. 读取 %1 语言用户自定义格式失败! - + Save Finished ! 保存成功! - + Not change, no need save ! 没有改变,无需保存! - + Style Foreground Color 风格背景色 风格前景色 - + Style Background Color 风格背景色 - + Reset Style 重置风格 - + Are you sure to reset language %1 sytle 您确定重置语言 %1 的风格吗? - + Reset All Style 重置所有风格 - + Are you sure to reset All language sytle 您确定重置所有语言风格吗? - + themes changing, please waiting ... 主题切换中,请等待 ... - + themes changed finished ... 主题切换完成 ... @@ -6716,50 +6887,353 @@ Select a shorter range for comparison. ScintillaEditView - + Show File in Explorer 定位到文件目录 - - + + mark with color 使用颜色标记 - - + + Color %1 颜色 %1 - - + + + Clear Select 清除选择标记 - - + + + Clear All 清除全部标记 - + Add/Del line comment 添加/删除当行注释 - + Add Block comment 区块注释 - + Del Block comment 清除区块注释 + + ShortcutKeyEditWin + + + Error + 错误 + + + + input right key ! + 请键入正确的键盘码 ! + + + + ShortcutKeyEditWinClass + + + + ShortcutKeyEditWin + 快捷键编辑 + + + + + Current Key Sequence: + 当前快捷键: + + + + + New Key Sequence: + 新的快捷键: + + + + + Ok + 确定 + + + + + Cancel + 取消 + + + + ShortcutKeyMgr + + + New File + 新建 + + + + Open File + 打开 + + + + Save File + 保存 + + + + Save All File + 保存所有 + + + + Close + 关闭 + + + + Close All + 关闭所有 + + + + Cut + 剪切 + + + + Copy + 拷贝 + + + + Paste + 粘贴 + + + + Undo + 撤销 + + + + Redo + 重做 + + + + Find + 查找 + + + + Replace + 替换 + + + + Dir Find + 在目录查找 + + + + Mark + 标记 + + + + word highlight(F8) + 高亮单词(F8) + + + + clear all highlight(F7) + 取消所有高亮(F7) + + + + Zoom In + 放大 + + + + Zoom Out + 缩小 + + + + Word Wrap + 自动换行 + + + + Show Blank + 显示空白字符 + + + + Indent Guide + 缩进参考线 + + + + Pre Hex Page + 上一页/位置 + + + + Next Hex Page + 下一页/位置 + + + + Goto Hex Page + 跳转到文件偏移地址 + + + + File Compare + 文件对比 + + + + Dir Compare + 目录对比 + + + + Bin Compare + 二进制对比 + + + + transform encoding + 转换编码 + + + + batch rename file + 批量重命名 + + + + Format Xml + 格式化 Xml + + + + Format Json + 格式化 Json + + + + + Can't Modify + 不可修改 + + + + Double Click To Modify + 双击修改快捷键 + + + + row %1 shortcut key '%2' can't modify ! + 行 %1 快捷键 ‘%2’不可修改! + + + + modify row %1 to '%2' shortcut key success! + 修改行 %1 快捷键为 %2 成功! + + + + error:modify row %1 to '%2' shortcut key failed ! + 错误:修改行 %1 为快捷键 %2 失败! + + + + conflict error! '%1' Already exist at row %2 + 冲突错误!'%1' 已经存在行 %2 + + + + conflict error! '%1' Already exist at qscint row %2 + 冲突错误!'%1' 已经存在于qscint表格行 %2 + + + + modify canceled ! + 修改取消! + + + + ShortcutKeyMgrClass + + + + ShortcutKeyMgr + 快捷键管理 + + + + + Ndd Shortcut + Ndd 快捷键 + + + + + + + Function + 功能 + + + + + + + Shortcut Key + 快捷键 + + + + + + + Comment + 说明 + + + + + Qscint Shortcut + Qscint 快捷键 + + + + + Close + 关闭 + + StatusWidget @@ -6773,63 +7247,101 @@ Select a shorter range for comparison. TextEditSetWin - + TextEditSetWin - + Tab Setting Tab 设置 - + Set Tab Length Tab 字符长度 - + Space Replacement Tab 使用空格替换tab - + Big Text Size 大文本文件大小 - + Beyond this size, it can only be read-only and displayed in blocks 文本文件超过该值时,只能以只读的方式进行分块加载显示。 - + Exceed(MB) 超过(MB) - + (50-300MB) - - - Remember files opened on close - 记住最后打开的文件 + + + Font Setting + 字体设置 + + + + + Txt File Font: + Txt 文件字体 + + + + + Set + 设置 + + + + + App Font Color: + + + + + + TextLabel + + + + + + Set + 设置 + + + + + Restore files opened on close + 恢复上次关闭时的打开文件 + + + Remember files opened on close + 记住最后打开的文件 - - Txt File Font Set - txt 文件字体设置 + txt 文件字体设置 Txt Font Set(Only Text File) @@ -6853,8 +7365,17 @@ Select a shorter range for comparison. 选择字体 - - + + App Font Foreground Color + + + + + The App Font + + + + User define Txt Font 用户自定义文本字体 diff --git a/src/rgba_icons.h b/src/rgba_icons.h index effbfaa..bcd47f4 100755 --- a/src/rgba_icons.h +++ b/src/rgba_icons.h @@ -1,5 +1,5 @@ -// This file is part of Notepad++ project -// Copyright (C)2021 Don HO +// This file is part of Notepad-- project +// Copyright (C)2023 zuowei.yin // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/scintillaeditview.cpp b/src/scintillaeditview.cpp index 60181dd..f09b962 100755 --- a/src/scintillaeditview.cpp +++ b/src/scintillaeditview.cpp @@ -6,11 +6,14 @@ #include "styleset.h" #include "qtlangset.h" #include "findwin.h" +#include "filemanager.h" + #include #include #include #include -#include +//#include +#include #include #include #include @@ -88,6 +91,8 @@ const int SC_BIGTEXT_LINES = 0; const int MAX_PRE_NEXT_TIMES = 30; +const int INIT_BIG_RO_TEXT_LINE_WIDTH = 8; + #ifdef Q_OS_WIN LanguageName ScintillaEditView::langNames[L_EXTERNAL + 1] = { {QString("normal"), QString("Normal QString"), QString("Normal text file"), L_TXT, SCLEX_NULL}, @@ -190,7 +195,7 @@ LanguageName ScintillaEditView::langNames[L_EXTERNAL + 1] = { #endif ScintillaEditView::ScintillaEditView(QWidget *parent,bool isBigText) - : QsciScintilla(parent), m_NoteWin(nullptr), m_preFirstLineNum(0), m_curPos(0), m_hasHighlight(false), m_bookmarkPng(nullptr), m_styleColorMenu(nullptr), m_isBigText(isBigText) + : QsciScintilla(parent), m_NoteWin(nullptr), m_preFirstLineNum(0), m_curPos(0), m_hasHighlight(false), m_bookmarkPng(nullptr), m_styleColorMenu(nullptr), m_isBigText(isBigText), m_curBlockLineStartNum(0) { init(); } @@ -232,6 +237,12 @@ void ScintillaEditView::setNoteWidget(QWidget * win) if (pv != nullptr) { m_NoteWin = pv; + + if (m_styleColorMenu != nullptr) + { + m_styleColorMenu->addAction(tr("Clear Select"), m_NoteWin, &CCNotePad::slot_clearWordHighlight); + m_styleColorMenu->addAction(tr("Clear All"), m_NoteWin, &CCNotePad::slot_clearMark); +} } } @@ -251,7 +262,7 @@ void ScintillaEditView::updateLineNumbersMargin(bool forcedToHide) { //根据现有滚动条来决定是否更新屏幕线宽长度。每滚动200个单位必须调整line宽 void ScintillaEditView::autoAdjustLineWidth(int xScrollValue) { - //如果是大文本模式,是没有行号的,直接返回 + //如果是大文本模式,行号长度目前是固定不变的,不需要动态调整。 if (m_isBigText) { return; @@ -297,8 +308,7 @@ void ScintillaEditView::updateLineNumberWidth(int lineNumberMarginDynamicWidth) } else { - int nbDigits = 9; - int pixelWidth = 6 + nbDigits * execute(SCI_TEXTWIDTH, STYLE_LINENUMBER, reinterpret_cast("8")); + int pixelWidth = 6 + INIT_BIG_RO_TEXT_LINE_WIDTH * execute(SCI_TEXTWIDTH, STYLE_LINENUMBER, reinterpret_cast("8")); execute(SCI_SETMARGINWIDTHN, SC_BIGTEXT_LINES, pixelWidth); } @@ -335,6 +345,246 @@ sptr_t ScintillaEditView::execute(quint32 Msg, uptr_t wParam, sptr_t lParam) con } }; + +QString ScintillaEditView::getTagByLexerId(int lexerId) +{ + switch (lexerId) + { + case L_PHP: + return "php"; + + case L_HTML: + return ("html"); + + case L_ASP: + return ("asp"); + + case L_JSP: + return("jsp"); + + case L_C: + return("c"); + + case L_RC: + return("rc"); + + case L_CPP: + return "cpp"; + + case L_OBJC: + return ("objc"); + + case L_CS: + return ("csharp"); + + case L_JAVA: + return ("java"); + + case L_XML: + return "xml"; + + case L_MAKEFILE: + return "makefile"; + + case L_PASCAL: + return "pascal"; + + case L_BATCH: + return "batch"; + + case L_INI: + return("ini"); + + case L_ASCII: + break; + + case L_USER: + break; + + case L_SQL: + return "sql"; + + case L_VB: + return "vb"; + + case L_CSS: + return "css"; + + case L_PERL: + return "perl"; + + case L_PYTHON: + return "python"; + + case L_LUA: + return "lua"; + + case L_TEX: + break; + case L_FORTRAN: + return "fortran"; + + case L_BASH: + return "bash"; + + case L_FLASH: + return("flash"); + + case L_NSIS: + return "nsis"; + + case L_TCL: + return "tcl"; + + case L_LISP: + break; + case L_SCHEME: + break; + case L_ASM: + break; + case L_DIFF: + return "diff"; + + case L_PROPS: + return "props"; + + case L_PS: + break; + case L_RUBY: + return "ruby"; + + case L_SMALLTALK: + break; + case L_VHDL: + return "vhdl"; + + case L_KIX: + break; + case L_AU3: + break; + case L_CAML: + break; + case L_ADA: + break; + case L_VERILOG: + return "verilog"; + + case L_MATLAB: + return "matlab"; + + case L_HASKELL: + break; + case L_INNO: + break; + case L_SEARCHRESULT: + break; + case L_CMAKE: + return "cmake"; + + case L_YAML: + return "yaml"; + + case L_COBOL: + break; + case L_GUI4CLI: + break; + case L_D: + break; + case L_POWERSHELL: + break; + + case L_COFFEESCRIPT: + return "coffeescript"; + + case L_JSON: + return "json"; + + case L_JAVASCRIPT: + return ("javascript"); + + case L_FORTRAN_77: + return "fortran77"; + + case L_BAANC: + break; + case L_SREC: + break; + case L_IHEX: + break; + case L_TEHEX: + break; + case L_SWIFT: + break; + case L_ASN1: + break; + //case L_AVS: + // return "avs"; + + case L_BLITZBASIC: + break; + case L_PUREBASIC: + break; + case L_FREEBASIC: + break; + case L_CSOUND: + break; + case L_ERLANG: + break; + case L_ESCRIPT: + break; + case L_FORTH: + break; + case L_LATEX: + break; + case L_MMIXAL: + break; + case L_NIM: + break; + case L_NNCRONTAB: + break; + case L_OSCRIPT: + break; + case L_REBOL: + break; + case L_REGISTRY: + break; + case L_RUST: + return "rust"; + case L_SPICE: + return "spice"; + case L_TXT2TAGS: + break; + case L_VISUALPROLOG: + break; + case L_TYPESCRIPT: + return("typescript"); + + case L_EXTERNAL: + break; + case L_IDL: + return("idl"); + + case L_GO: + return("go"); + + case L_GLOBAL: + return("AllGlobal"); + + case L_TXT: + return("txt"); + + case L_USER_TXT: + break; + case L_USER_CPP: + + break; + default: + break; + } + + return ""; +} + //status : true 表示存在, false 表示不存在 //tag,只有在用户自定义语法是,才需要给出。内部自带的语法不需要给出 //isOrigin:是否原生lexer,即不读取用户修改过的配置风格 @@ -444,6 +694,7 @@ QsciLexer* ScintillaEditView::createLexer(int lexerId, QString tag, bool isOrigi case L_SCHEME: break; case L_ASM: + ret = new QsciLexerAsm(); break; case L_DIFF: ret = new QsciLexerDiff(); @@ -522,7 +773,7 @@ QsciLexer* ScintillaEditView::createLexer(int lexerId, QString tag, bool isOrigi case L_ASN1: break; case L_AVS: - ret = new QsciLexerAVS(); + //ret = new QsciLexerAVS(); break; case L_BLITZBASIC: break; @@ -800,18 +1051,6 @@ void ScintillaEditView::init() execute(SCI_SETWHITESPACESIZE,3); setCaretLineVisible(true); - - - //execute(SCI_INDICSETHOVERFORE, URL_INDIC, 0x80ffff); - - //if (StyleSet::m_curStyleId != BLACK_SE) - //{ - // setCaretLineBackgroundColor(QColor(0xe8e8ff)); - //} - //else - //{ - // setCaretLineBackgroundColor(QColor(0x333333)); - //} //统一设置全局前景、背景、字体大小三个要素 updateThemes(); @@ -876,7 +1115,7 @@ void ScintillaEditView::showBigTextLineAddr(qint64 fileOffset) memset(lineString, 0, 17); lineLength = this->lineLength(i); - + if (fileOffset < 0xffffffff) { sprintf(lineString, "%08llX ", fileOffset); @@ -895,6 +1134,196 @@ void ScintillaEditView::showBigTextLineAddr(qint64 fileOffset) delete[]lineString; } +void ScintillaEditView::clearSuperBitLineCache() +{ + m_addrLineNumMap.clear(); +} +//20230116新增,尽可能的还是显示行号。如果发生了跳转,则没有办法计算前面的行号, +//则只能显示地址。如果没跳转,而是动态顺序翻页,则可以显示行号 +//20230201发现一个问题。底层qscint是按照utf8字节流来计算字符大小的。如果原始文件的编码 +//不是utf8,比如GBK LE等,则大小是不能统一的。这是一个显示问题,但是不影响什么。 +//通过this->lineLength(i);来计算是以utf8计算。 +void ScintillaEditView::showBigTextLineAddr(qint64 fileOffset, qint64 fileEndOffset) +{ + int nbDigits = 0; + + if (fileOffset < 0xffffffff) + { + nbDigits = INIT_BIG_RO_TEXT_LINE_WIDTH; + } + else + { + nbDigits = 12; + } + char* lineString = new char[17]; + memset(lineString, 0, 17); + + auto pixelWidth = 6 + nbDigits * execute(SCI_TEXTWIDTH, STYLE_LINENUMBER, reinterpret_cast("8")); + this->execute(SCI_SETMARGINWIDTHN, SC_BIGTEXT_LINES, pixelWidth); + + int lineNums = this->lines(); + int lineLength = 0; + + qint64 curLineAddr = fileOffset; + + int style = STYLE_LINENUMBER; + + quint32 startLineNumOffset = 0; + quint32 endLineNumOffset = 0; + + bool isShowLineNum = false; //显示行号还是地址 + bool startLineExist = false; + bool endLineExist = false; + + + if (fileOffset == 0) + { + isShowLineNum = true; + startLineExist = true; + m_addrLineNumMap.insert(0, 1); //0地址对应第1行 + m_addrLineNumMap.insert(fileEndOffset, lineNums+1); //fileEndOffset地址对应最后一行 + } + + if (lineNums >= 1) + { + if (m_addrLineNumMap.contains(fileOffset)) + { + isShowLineNum = true; + startLineExist = true; + + startLineNumOffset = m_addrLineNumMap.value(fileOffset); + } + else if (m_addrLineNumMap.contains(fileEndOffset)) + { + isShowLineNum = true; + endLineExist = true; + + endLineNumOffset = m_addrLineNumMap.value(fileEndOffset); + } + } + + //不存在行号,只能显示地址 + if (!isShowLineNum) + { + for (int i = 0; i < lineNums; ++i) + { + memset(lineString, 0, 17); + + lineLength = this->lineLength(i); + + if (fileOffset < 0xffffffff) + { + sprintf(lineString, "%08llX ", fileOffset); + } + else + { + sprintf(lineString, "%012llX ", fileOffset); + } + + QString num(lineString); + + fileOffset += lineLength; + this->setMarginText(i, num, style); + } + } + else + { + //首行地址存在,从头到尾增加行号 + if (startLineExist) + { + + for (int i = 0; i < lineNums; ++i) + { + if (i == (lineNums - 1)) + { + //m_addrLineNumMap.insert(fileOffset, startLineNumOffset + i); + m_addrLineNumMap.insert(fileEndOffset, startLineNumOffset + i); + } + + memset(lineString, 0, 17); + //lineLength = this->lineLength(i); + sprintf(lineString, "%08lld ", startLineNumOffset + i); + QString num(lineString); + + //fileOffset += lineLength; + this->setMarginText(i, num, style); + } + } + else if (endLineExist) + { + + startLineNumOffset = endLineNumOffset - lineNums; + + for (int i = 0; i < lineNums; ++i) + { + if (i == 0) + { + //m_addrLineNumMap.insert(fileOffset, startLineNumOffset + i); + m_addrLineNumMap.insert(fileOffset, startLineNumOffset + i); + } + + memset(lineString, 0, 17); + //lineLength = this->lineLength(i); + sprintf(lineString, "%08lld ", startLineNumOffset + i); + QString num(lineString); + + //fileOffset += lineLength; + this->setMarginText(i, num, style); + } + } + } + + delete[]lineString; +} + +//大文本只读模式下,显示其文本 +void ScintillaEditView::showBigTextRoLineNum(BigTextEditFileMgr* txtFile, int blockIndex) +{ + + BlockIndex bi = txtFile->blocks.at(blockIndex); + + int nbDigits = 0; + + if (bi.fileOffset < 0xffffffff) + { + nbDigits = INIT_BIG_RO_TEXT_LINE_WIDTH; + } + else + { + nbDigits = 12; + } + char* lineString = new char[17]; + memset(lineString, 0, 17); + + auto pixelWidth = 6 + nbDigits * execute(SCI_TEXTWIDTH, STYLE_LINENUMBER, reinterpret_cast("8")); + this->execute(SCI_SETMARGINWIDTHN, SC_BIGTEXT_LINES, pixelWidth); + + int lineNums = this->lines(); + + qint64 curLineNum = bi.lineNumStart + 1;//行号从1开始 + + int style = STYLE_LINENUMBER; + + for (int i = 0; i < lineNums; ++i) + { + memset(lineString, 0, 17); + + if (bi.fileOffset < 0xffffffff) + { + sprintf(lineString, "%08lld ", curLineNum+i); + } + else + { + sprintf(lineString, "%012lld ", curLineNum + i); + } + + QString num(lineString); + this->setMarginText(i, num, style); + } + + delete[]lineString; +} + void ScintillaEditView::bookmarkNext(bool forwardScan) { size_t lineno = this->getCurrentLineNumber(); @@ -1395,10 +1824,13 @@ void ScintillaEditView::initStyleColorMenu() m_styleColorMenu->addSeparator(); + if (m_NoteWin != nullptr) + { m_styleColorMenu->addAction(tr("Clear Select"), m_NoteWin, &CCNotePad::slot_clearWordHighlight); m_styleColorMenu->addAction(tr("Clear All"), m_NoteWin, &CCNotePad::slot_clearMark); } } +} void ScintillaEditView::contextUserDefineMenuEvent(QMenu* menu) { @@ -1799,7 +2231,7 @@ bool ScintillaEditView::undoStreamComment(bool tryBlockComment) // BlockToStreamComment: If there is no stream-comment symbol and we came not from doBlockComment, try the block comment: if (commentStart.isEmpty() || commentEnd.isEmpty()) { - if (!(commentLineSymbol.isEmpty() && tryBlockComment)) + if (!commentLineSymbol.isEmpty() && tryBlockComment) return doBlockComment(cm_uncomment); else return false; @@ -3031,6 +3463,16 @@ bool isUrl(QString& text, int textLen, int start, int* segmentLen) return false; } +quint32 ScintillaEditView::getBigTextBlockStartLine() +{ + return m_curBlockLineStartNum; +} + +void ScintillaEditView::setBigTextBlockStartLine(quint32 line) +{ + m_curBlockLineStartNum = line; +} + void ScintillaEditView::addHotSpot() { if (CCNotePad::s_hightWebAddr == 1) diff --git a/src/scintillaeditview.h b/src/scintillaeditview.h index c97e110..867f7ab 100755 --- a/src/scintillaeditview.h +++ b/src/scintillaeditview.h @@ -113,6 +113,7 @@ enum Font_Set_Bit { class FindRecords; class CCNotePad; +struct BigTextEditFileMgr; class ScintillaEditView : public QsciScintilla { @@ -129,7 +130,8 @@ public: sptr_t execute(quint32 Msg, uptr_t wParam = 0, sptr_t lParam = 0) const; static QsciLexer * createLexer(int lexerId, QString tag="", bool isOrigin=false, int styleId=-1); - + static QString getTagByLexerId(int lexerId); + void appendMarkRecord(FindRecords *r); void releaseAllMark(); QList& getCurMarkRecord(); @@ -195,14 +197,19 @@ public: void setBigTextMode(bool isBigText); void showBigTextLineAddr(qint64 fileOffset); - + void showBigTextLineAddr(qint64 fileStartOffset, qint64 fileEndOffset); + void showBigTextRoLineNum(BigTextEditFileMgr* txtFile, int blockIndex); void updateThemes(); + void clearSuperBitLineCache(); //下面三个函数,是设置全局样式的接口。全局样式不同于每个语法中的样式 void setGlobalFgColor(int style); void setGlobalBgColor(int style); void setGlobalFont(int style); - //void setGlobalFont(int style, const QFont& f,int stylePointSize = -1); + + //获取当前块的开始行号。只在大文件只读模式下有效。其余模式下均返回0 + quint32 getBigTextBlockStartLine(); + void setBigTextBlockStartLine(quint32 line); signals: void delayWork(); @@ -300,6 +307,10 @@ private: QList m_styleMarkActList; bool m_isBigText;//大文本 + + quint32 m_curBlockLineStartNum; + + QMap m_addrLineNumMap;//大文本模式下,地址和行号的对应关系。只需要首尾即可 public: static int s_tabLens; static bool s_noUseTab; diff --git a/src/shortcutkeyeditwin.cpp b/src/shortcutkeyeditwin.cpp new file mode 100755 index 0000000..5a8fc30 --- /dev/null +++ b/src/shortcutkeyeditwin.cpp @@ -0,0 +1,42 @@ +#include "shortcutkeyeditwin.h" + +#include + +ShortcutKeyEditWin::ShortcutKeyEditWin(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + ui.keySequenceEdit->setFocus(); +} + +ShortcutKeyEditWin::~ShortcutKeyEditWin() +{} + +void ShortcutKeyEditWin::setCurKeyDesc(QString desc) +{ + ui.curKeylineEdit->setText(desc); +} + +void ShortcutKeyEditWin::setTitle(QString title) +{ + this->setWindowTitle(title); +} + +QKeySequence ShortcutKeyEditWin::getNewKeySeq() +{ + return m_newKeys; +} + +//ȷ޸ģȼһ¡ĸ +void ShortcutKeyEditWin::slot_ok() +{ + QKeySequence keys = ui.keySequenceEdit->keySequence(); + if (keys.isEmpty()) + { + QMessageBox::warning(this, tr("Error"), tr("input right key !")); + return; + } + + m_newKeys = keys; + done(1); +} \ No newline at end of file diff --git a/src/shortcutkeyeditwin.h b/src/shortcutkeyeditwin.h new file mode 100755 index 0000000..6d2ba66 --- /dev/null +++ b/src/shortcutkeyeditwin.h @@ -0,0 +1,24 @@ +#pragma once + +#include +#include "ui_shortcutkeyeditwin.h" + +class ShortcutKeyEditWin : public QDialog +{ + Q_OBJECT + +public: + ShortcutKeyEditWin(QWidget *parent = nullptr); + ~ShortcutKeyEditWin(); + + void setCurKeyDesc(QString desc); + QKeySequence getNewKeySeq(); + void setTitle(QString title); + +private slots: + void slot_ok(); + +private: + Ui::ShortcutKeyEditWinClass ui; + QKeySequence m_newKeys; +}; diff --git a/src/shortcutkeyeditwin.ui b/src/shortcutkeyeditwin.ui new file mode 100755 index 0000000..98186a4 --- /dev/null +++ b/src/shortcutkeyeditwin.ui @@ -0,0 +1,116 @@ + + + ShortcutKeyEditWinClass + + + + 0 + 0 + 459 + 137 + + + + ShortcutKeyEditWin + + + + 3 + + + 3 + + + 3 + + + 3 + + + + + + + Current Key Sequence: + + + + + + + true + + + + + + + New Key Sequence: + + + + + + + + + + + + + + Ok + + + + + + + Cancel + + + + + + + + + + + + pushButton_2 + clicked() + ShortcutKeyEditWinClass + reject() + + + 388 + 103 + + + 414 + 131 + + + + + pushButton + clicked() + ShortcutKeyEditWinClass + slot_ok() + + + 153 + 95 + + + 186 + 128 + + + + + + slot_ok() + + diff --git a/src/shortcutkeymgr.cpp b/src/shortcutkeymgr.cpp new file mode 100755 index 0000000..601ade5 --- /dev/null +++ b/src/shortcutkeymgr.cpp @@ -0,0 +1,317 @@ +#include "shortcutkeymgr.h" +#include "shortcutkeyeditwin.h" +#include "ccnotepad.h" + +#include +#include +#include +#include +#include + +QMap* ShortcutKeyMgr::s_shortcutKeysMap = nullptr; + +//QMap * qScintShortcutKeyValueMap = nullptr; + +struct ShortcutKeySt { + QString iniTag;//Iniļе + QString name;//ʾڱе + //QString keyDesc;//qkeysequence + QKeySequence key; + + bool canModify;//ܷ޸ + + ShortcutKeySt() = default; + ShortcutKeySt(QString name_, QString iniTag_, bool canMofidy=true) :name(name_), iniTag(iniTag_), canModify(canMofidy) + { + + } + ShortcutKeySt(QString name_, QString iniTag_, QString keySeq, bool canMofidy = true) :name(name_), iniTag(iniTag_), canModify(canMofidy) + { + key = QKeySequence(keySeq); + } + +}; + +QVector shortCutTable; + + +ShortcutKeyMgr::ShortcutKeyMgr(QWidget *parent) + : QMainWindow(parent) +{ + ui.setupUi(this); + initShortcutKeysMap(); + initNddShortcutTable(); + m_pNoteEdit = parent; + initQscintShortcutTable(); + + connect(ui.tableWidget, &QTableWidget::itemDoubleClicked, this, &ShortcutKeyMgr::slot_edit); + + ui.tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents); + ui.tableWidget->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents); + ui.tableWidget->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents); + ui.qscintTableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents); + ui.qscintTableWidget->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents); + ui.qscintTableWidget->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents); +} + +ShortcutKeyMgr::~ShortcutKeyMgr() +{} + +void ShortcutKeyMgr::initShortcutKeysMap() +{ + if (s_shortcutKeysMap == nullptr) + { + s_shortcutKeysMap = new QMap(); + + shortCutTable << ShortcutKeySt(tr("New File"), New_File, QString("Ctrl+T")) \ + << ShortcutKeySt(tr("Open File"), Open_File, QString("Ctrl+O")) \ + << ShortcutKeySt(tr("Save File"), Save_File, QString("Ctrl+S"), false) \ + << ShortcutKeySt(tr("Save All File"), Save_All_File) \ + << ShortcutKeySt(tr("Close"), Close, QString("Ctrl+W")) \ + << ShortcutKeySt(tr("Close All"), Close_All, QString("Ctrl+Shift+W")) \ + << ShortcutKeySt(tr("Cut"), Cut, QString("Ctrl+X"),false) \ + << ShortcutKeySt(tr("Copy"), Copy, QString("Ctrl+C"), false) \ + << ShortcutKeySt(tr("Paste"), Paste, QString("Ctrl+V"), false) \ + << ShortcutKeySt(tr("Undo"), Undo, QString("Ctrl+Z"), false) \ + << ShortcutKeySt(tr("Redo"), Redo, QString("Ctrl+Y"), false) \ + << ShortcutKeySt(tr("Find"), Find, QString("Ctrl+F"),false) \ + << ShortcutKeySt(tr("Replace"), Replace, QString("Ctrl+H")) \ + << ShortcutKeySt(tr("Dir Find"), DirFind, QString("Ctrl+Shift+D")) \ + << ShortcutKeySt(tr("Mark"), Mark) \ + << ShortcutKeySt(tr("word highlight(F8)"), Word_highlight, QString("F8"))\ + << ShortcutKeySt(tr("clear all highlight(F7)"), Clear_all_highlight, QString("F7")) \ + << ShortcutKeySt(tr("Zoom In"), Zoom_In) \ + << ShortcutKeySt(tr("Zoom Out"), Zoom_Out) \ + << ShortcutKeySt(tr("Word Wrap"), Word_Wrap) \ + << ShortcutKeySt(tr("Show Blank"), Show_Blank) \ + << ShortcutKeySt(tr("Indent Guide"), Indent_Guide) \ + << ShortcutKeySt(tr("Pre Hex Page"), Pre_Page) \ + << ShortcutKeySt(tr("Next Hex Page"), Next_Page)\ + << ShortcutKeySt(tr("Goto Hex Page"), Goto_Page, QString("Ctrl+G")) \ + << ShortcutKeySt(tr("File Compare"), File_Compare) \ + << ShortcutKeySt(tr("Dir Compare"), Dir_Compare) \ + << ShortcutKeySt(tr("Bin Compare"), Bin_Compare) \ + << ShortcutKeySt(tr("transform encoding"), Trans_code) \ + << ShortcutKeySt(tr("batch rename file"), Batch_rename) \ + << ShortcutKeySt(tr("Format Xml"), Format_Xml) \ + << ShortcutKeySt(tr("Format Json"), Format_Json); + + + for (int i = 0; i < shortCutTable.size(); ++i) + { + s_shortcutKeysMap->insert(shortCutTable.at(i).iniTag, i); + } + + //ļжȡû޸Ĺñ + loadUserDefSet(); + } +} + +//ȵinitShortcutKeysMap() +QKeySequence ShortcutKeyMgr::getUserDefShortcutKey(QString iniTag) +{ + if (s_shortcutKeysMap->contains(iniTag)) + { + return shortCutTable.at(s_shortcutKeysMap->value(iniTag)).key; + } + return QKeySequence(); +} + +//ûiniмؿݼ +void ShortcutKeyMgr::loadUserDefSet() +{ + QString userDefFile = QString("notepad/shortcuttab"); + QSettings qs(QSettings::IniFormat, QSettings::UserScope, userDefFile); + qs.setIniCodec("UTF-8"); + + QStringList keys = qs.allKeys(); + + QString keySeqStr; + + for (int i = 0; i < keys.size(); ++i) + { + const QString & initTag = keys.at(i); + + keySeqStr = qs.value(initTag).toString(); + + if (s_shortcutKeysMap->contains(initTag)) + { + int index = s_shortcutKeysMap->value(initTag); + shortCutTable[index].key = QKeySequence(keySeqStr); + } + } +} + +//޸ļеĿݼ塣inittag inikey, keySeqStr inivalueڴҲ޸ +bool ShortcutKeyMgr::ModifyShortCutKey(QString initTag, QString keySeqStr) +{ + QString userDefFile = QString("notepad/shortcuttab"); + QSettings qs(QSettings::IniFormat, QSettings::UserScope, userDefFile); + qs.setIniCodec("UTF-8"); + + if (s_shortcutKeysMap->contains(initTag)) + { + int index = s_shortcutKeysMap->value(initTag); + if (!shortCutTable[index].canModify) + { + return false; + } + + shortCutTable[index].key = QKeySequence(keySeqStr); + qs.setValue(initTag, keySeqStr); + qs.sync(); + return true; + } + return false; +} + +void ShortcutKeyMgr::initNddShortcutTable() +{ + for (int i = 0; i < shortCutTable.size(); ++i) + { + ui.tableWidget->insertRow(i); + + QTableWidgetItem* item = new QTableWidgetItem(shortCutTable.at(i).name); + item->setFlags(item->flags() & ~Qt::ItemIsEditable); + ui.tableWidget->setItem(i, 0, item); + + qDebug() << shortCutTable.at(i).key.toString(); + QTableWidgetItem* item1 = new QTableWidgetItem(shortCutTable.at(i).key.toString()); + ui.tableWidget->setItem(i, 1, item1); + + if (!shortCutTable.at(i).canModify) + { + QTableWidgetItem* item2 = new QTableWidgetItem(tr("Can't Modify")); + ui.tableWidget->setItem(i, 2, item2); + } + else + { + QTableWidgetItem* item2 = new QTableWidgetItem(tr("Double Click To Modify")); + ui.tableWidget->setItem(i, 2, item2); + } + + } +} + +//ʼqscintڲĿݼĿǰⲿֲ޸ġ +void ShortcutKeyMgr::initQscintShortcutTable() +{ + QsciScintilla* pNote = new QsciScintilla(nullptr); + QsciCommandSet* cmdSet = pNote->standardCommands(); + + QList& cmdList = cmdSet->commands(); + + int rowNum = 0; + for (int i = 0; i < cmdList.size(); ++i) + { + if (cmdList.at(i)->key() == 0) + { + continue; + } + ui.qscintTableWidget->insertRow(rowNum); + + QTableWidgetItem* item = new QTableWidgetItem(cmdList.at(i)->description()); + item->setFlags(item->flags() & ~Qt::ItemIsEditable); + ui.qscintTableWidget->setItem(rowNum, 0, item); + + QTableWidgetItem* item1 = new QTableWidgetItem(QKeySequence(cmdList.at(i)->key()).toString()); + ui.qscintTableWidget->setItem(rowNum, 1, item1); + + QTableWidgetItem* item2 = new QTableWidgetItem(tr("Can't Modify")); + ui.qscintTableWidget->setItem(rowNum, 2, item2); + + ++rowNum; + + } + delete pNote; +} + +//type 0 ndd 1 qscint +int ShortcutKeyMgr::isKeySeqExist(int row, QString keySeq, int &type) +{ + int c = ui.tableWidget->rowCount(); + for (int i = 0; i < c; ++i) + { + if (i == row) + { + continue; + } + + if (ui.tableWidget->item(i, 1)->text() == keySeq) + { + type = 0; + return i; + } + } + + c = ui.qscintTableWidget->rowCount(); + + for (int i = 0; i < c; ++i) + { + if (ui.qscintTableWidget->item(i, 1)->text() == keySeq) + { + type = 1; + return i; + } + } + return -1; +} +//˫޸IJۺ +void ShortcutKeyMgr::slot_edit(QTableWidgetItem* item) +{ + int row = item->row(); + + if (!shortCutTable.at(row).canModify) + { + ui.plainTextEdit->setPlainText(tr("row %1 shortcut key '%2' can't modify !").arg(row + 1).arg(shortCutTable.at(row).key.toString())); + return; + } + + ShortcutKeyEditWin* pWin = new ShortcutKeyEditWin(this); + pWin->setTitle(shortCutTable.at(row).name); + pWin->setCurKeyDesc(shortCutTable.at(row).key.toString()); + if (1 == pWin->exec()) + { + QKeySequence newKeySeq = pWin->getNewKeySeq(); + + QTableWidgetItem* item = ui.tableWidget->item(row, 1); + if (item != nullptr) + { + //ǷͻͻáԤ + int conflictType = 0; + int existId = isKeySeqExist(row, newKeySeq.toString(), conflictType); + if (-1 == existId) + { + if (ModifyShortCutKey(shortCutTable.at(row).iniTag, newKeySeq.toString())) + { + CCNotePad* pNotePad = dynamic_cast(m_pNoteEdit); + if (pNotePad != nullptr) + { + pNotePad->setUserDefShortcutKey(row); + } + item->setText(newKeySeq.toString()); + ui.plainTextEdit->setPlainText(tr("modify row %1 to '%2' shortcut key success!").arg(row + 1).arg(newKeySeq.toString())); + } + else + { + ui.plainTextEdit->setPlainText(tr("error:modify row %1 to '%2' shortcut key failed !").arg(row + 1).arg(newKeySeq.toString())); + } + } + else + { + if (conflictType == 0) + { + ui.plainTextEdit->setPlainText(tr("conflict error! '%1' Already exist at row %2").arg(newKeySeq.toString()).arg(existId + 1)); + } + else + { + ui.plainTextEdit->setPlainText(tr("conflict error! '%1' Already exist at qscint row %2").arg(newKeySeq.toString()).arg(existId + 1)); + } + } + } + } + else + { + ui.plainTextEdit->setPlainText(tr("modify canceled !")); + } +} \ No newline at end of file diff --git a/src/shortcutkeymgr.h b/src/shortcutkeymgr.h new file mode 100755 index 0000000..f7c4e34 --- /dev/null +++ b/src/shortcutkeymgr.h @@ -0,0 +1,104 @@ +#pragma once + +#include +#include "ui_shortcutkeymgr.h" + +enum Shortcut_Key_ID { + New_File_ID=0, + Open_File_ID, + Save_File_ID, + Save_All_File_ID, + Close_ID, + Close_All_ID, + Cut_ID, + Copy_ID, + Paste_ID, + Undo_ID, + Redo_ID, + Find_ID, + Replace_ID, + Dir_Find_ID, + Mark_ID, + Word_highlight_ID, + Clear_all_highlight_ID, + Zoom_In_ID, + Zoom_Out_ID, + Word_Wrap_ID, + Show_Blank_ID, + Indent_Guide_ID, + Pre_Page_ID, + Next_Page_ID, + Goto_Page_ID, + File_Compare_ID, + Dir_Compare_ID, + Bin_Compare_ID, + Trans_code_ID, + Batch_rename_ID, + Format_Xml_ID, + Format_Json_ID, + + + Shortcut_End_ID,// +}; + +static const char* New_File = "newfile"; +static const char* Open_File = "openfile"; +static const char* Save_File = "savefile"; +static const char* Save_All_File = "saveall"; +static const char* Close = "close"; +static const char* Close_All = "closeall"; +static const char* Cut = "cut"; +static const char* Copy = "copy"; +static const char* Paste = "paste"; +static const char* Undo = "undo"; +static const char* Redo = "redo"; +static const char* Find = "find"; +static const char* Replace = "replace"; +static const char* DirFind = "dirfind"; +static const char* Mark = "mark"; +static const char* Word_highlight = "wordlight"; +static const char* Clear_all_highlight = "clearwordlight"; +static const char* Zoom_In = "zoomin"; +static const char* Zoom_Out ="zoomout"; +static const char* Word_Wrap = "wordwrap"; +static const char* Show_Blank = "showblank"; +static const char* Indent_Guide = "indentguide"; +static const char* Pre_Page = "prepage"; +static const char* Next_Page = "nextpage"; +static const char* Goto_Page = "goto"; +static const char* File_Compare = "filecmp"; +static const char* Dir_Compare ="dircmp"; +static const char* Bin_Compare ="bincmp"; +static const char* Trans_code = "transcode"; +static const char* Batch_rename = "batchrename"; +static const char* Format_Xml = "formatxml"; +static const char* Format_Json = "formatjson"; + + +class ShortcutKeyMgr : public QMainWindow +{ + Q_OBJECT + +public: + ShortcutKeyMgr(QWidget *parent = nullptr); + ~ShortcutKeyMgr(); + static void initShortcutKeysMap(); + static QKeySequence getUserDefShortcutKey(QString iniTag); + +private: + + void initNddShortcutTable(); + void initQscintShortcutTable(); + + static void loadUserDefSet(); + int isKeySeqExist(int row, QString keySeq, int& type); + bool ModifyShortCutKey(QString initTag, QString keySeqStr); +private slots: + void slot_edit(QTableWidgetItem* item); + +private: + Ui::ShortcutKeyMgrClass ui; + static QMap* s_shortcutKeysMap; + + QWidget* m_pNoteEdit; +}; diff --git a/src/shortcutkeymgr.ui b/src/shortcutkeymgr.ui new file mode 100755 index 0000000..a4f550b --- /dev/null +++ b/src/shortcutkeymgr.ui @@ -0,0 +1,201 @@ + + + ShortcutKeyMgrClass + + + + 0 + 0 + 766 + 508 + + + + ShortcutKeyMgr + + + + + 2 + + + 3 + + + 3 + + + 2 + + + 3 + + + + + 0 + + + + Ndd Shortcut + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QAbstractItemView::NoEditTriggers + + + + Function + + + + + Shortcut Key + + + + + Comment + + + + + + + + + Qscint Shortcut + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QAbstractItemView::NoEditTriggers + + + + Function + + + + + Shortcut Key + + + + + Comment + + + + + + + + + + + + + 16777215 + 50 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Close + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + TopToolBarArea + + + false + + + + + + + + + pushButton_2 + clicked() + ShortcutKeyMgrClass + close() + + + 432 + 465 + + + 465 + 481 + + + + + diff --git a/src/texteditsetwin.cpp b/src/texteditsetwin.cpp index 76e1cd9..10d70a7 100755 --- a/src/texteditsetwin.cpp +++ b/src/texteditsetwin.cpp @@ -3,6 +3,7 @@ #include "ccnotepad.h" #include "qtlangset.h" #include +#include TextEditSetWin::TextEditSetWin(QWidget *parent) : QWidget(parent), m_notepadWin(nullptr) @@ -19,6 +20,10 @@ TextEditSetWin::TextEditSetWin(QWidget *parent) ui.BigTextSizeLimit->setValue(ScintillaEditView::s_bigTextSize); ui.restoreFile->setChecked((CCNotePad::s_restoreLastFile == 1)); + + + QPalette pal = QApplication::palette(); + } TextEditSetWin::~TextEditSetWin() @@ -31,17 +36,7 @@ void TextEditSetWin::setNotePadWin(QWidget *w) m_notepadWin = w; } -#if 0 -//弹出对话框时,默认初始化该值 -void TextEditSetWin::setFont(QFont &font) -{ - if (m_curFont != font) - { - m_curFont = font; - } - ui.curTextFontEdit->setText(font.toString()); -} -#endif + #if 0 //弹出对话框时,默认初始化该值 void TextEditSetWin::setProgramLangFont(QFont &font) diff --git a/src/texteditsetwin.ui b/src/texteditsetwin.ui index 4ad8d1d..69c1e89 100755 --- a/src/texteditsetwin.ui +++ b/src/texteditsetwin.ui @@ -7,7 +7,7 @@ 0 0 617 - 140 + 300 @@ -132,18 +132,92 @@ - - - - - Remember files opened on close + + + Font Setting + + + + + + + Txt File Font: + + + + + + + Set + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + App Font Color: + + + + + + + TextLabel + + + + + + + false + + + Set + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + - + + + - Txt File Font Set + Restore files opened on close @@ -170,7 +244,7 @@ 20 - 7 + 40 @@ -181,18 +255,34 @@ - pushButton + toolButton clicked() TextEditSetWin slot_txtFontSet() - 295 - 105 + 129 + 126 - 369 - 132 + 567 + 292 + + + + + toolButton1 + clicked() + TextEditSetWin + slot_appFontColor() + + + 195 + 151 + + + 193 + 304 @@ -201,5 +291,7 @@ slot_selectFont() slot_selectProLangFont() slot_txtFontSet() + slot_selectAppFont() + slot_appFontColor() diff --git a/vs2017_sln/RealCompare.sln b/vs2017_sln/RealCompare.sln deleted file mode 100755 index 119d403..0000000 --- a/vs2017_sln/RealCompare.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.1972 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RealCompare", "..\src\RealCompare.vcxproj", "{26BC87D0-189B-3661-B87D-347CF9E0A47F}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qscintilla", "..\src\qscint\src\qscintilla.vcxproj", "{9BC42707-EE25-3B28-9906-F7919E273020}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {26BC87D0-189B-3661-B87D-347CF9E0A47F}.Debug|x64.ActiveCfg = Debug|x64 - {26BC87D0-189B-3661-B87D-347CF9E0A47F}.Debug|x64.Build.0 = Debug|x64 - {26BC87D0-189B-3661-B87D-347CF9E0A47F}.Release|x64.ActiveCfg = Release|x64 - {26BC87D0-189B-3661-B87D-347CF9E0A47F}.Release|x64.Build.0 = Release|x64 - {9BC42707-EE25-3B28-9906-F7919E273020}.Debug|x64.ActiveCfg = Debug|x64 - {9BC42707-EE25-3B28-9906-F7919E273020}.Debug|x64.Build.0 = Debug|x64 - {9BC42707-EE25-3B28-9906-F7919E273020}.Release|x64.ActiveCfg = Release|x64 - {9BC42707-EE25-3B28-9906-F7919E273020}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {F8D03E96-542B-49CA-8FE2-21F7AF7CDD2E} - EndGlobalSection -EndGlobal diff --git a/vs2017_sln/helloworld.sln b/vs2017_sln/helloworld.sln deleted file mode 100755 index ad39c03..0000000 --- a/vs2017_sln/helloworld.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.1972 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "helloworld", "..\src\plugin\helloworld\helloworld.vcxproj", "{06EED29A-D357-39F4-B1B8-25129EBC2852}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qscintilla", "..\src\qscint\src\qscintilla.vcxproj", "{9BC42707-EE25-3B28-9906-F7919E273020}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {06EED29A-D357-39F4-B1B8-25129EBC2852}.Debug|x64.ActiveCfg = Debug|x64 - {06EED29A-D357-39F4-B1B8-25129EBC2852}.Debug|x64.Build.0 = Debug|x64 - {06EED29A-D357-39F4-B1B8-25129EBC2852}.Release|x64.ActiveCfg = Release|x64 - {06EED29A-D357-39F4-B1B8-25129EBC2852}.Release|x64.Build.0 = Release|x64 - {9BC42707-EE25-3B28-9906-F7919E273020}.Debug|x64.ActiveCfg = Debug|x64 - {9BC42707-EE25-3B28-9906-F7919E273020}.Debug|x64.Build.0 = Debug|x64 - {9BC42707-EE25-3B28-9906-F7919E273020}.Release|x64.ActiveCfg = Release|x64 - {9BC42707-EE25-3B28-9906-F7919E273020}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {4AF45FF1-9FBE-4C6B-A177-E7BBD96267C5} - EndGlobalSection -EndGlobal diff --git a/vs2017_sln/qscintilla.sln b/vs2017_sln/qscintilla.sln deleted file mode 100755 index aa35a8e..0000000 --- a/vs2017_sln/qscintilla.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.1738 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qscintilla", "..\src\qscint\src\qscintilla.vcxproj", "{1A6F5081-AC34-3289-B3D1-C03725833468}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RealCompare", "..\src\RealCompare.vcxproj", "{3842E8A0-CF86-31D6-A247-40F65F8611D3}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1A6F5081-AC34-3289-B3D1-C03725833468}.Debug|x64.ActiveCfg = Debug|x64 - {1A6F5081-AC34-3289-B3D1-C03725833468}.Debug|x64.Build.0 = Debug|x64 - {1A6F5081-AC34-3289-B3D1-C03725833468}.Release|x64.ActiveCfg = Release|x64 - {1A6F5081-AC34-3289-B3D1-C03725833468}.Release|x64.Build.0 = Release|x64 - {3842E8A0-CF86-31D6-A247-40F65F8611D3}.Debug|x64.ActiveCfg = Debug|x64 - {3842E8A0-CF86-31D6-A247-40F65F8611D3}.Debug|x64.Build.0 = Debug|x64 - {3842E8A0-CF86-31D6-A247-40F65F8611D3}.Release|x64.ActiveCfg = Release|x64 - {3842E8A0-CF86-31D6-A247-40F65F8611D3}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {B9B2FC3E-0F05-46A6-86A0-BDCE3D56484F} - EndGlobalSection -EndGlobal