From 2d393cb5099710b023c24f32abdf327b1933306d Mon Sep 17 00:00:00 2001 From: "royqh1979@gmail.com" Date: Tue, 28 Sep 2021 22:26:12 +0800 Subject: [PATCH] - enhancement: more charset selection in the edit menu - fix: can't correctly get system default encoding name when save file - fix: Tokenizer can't correctly handle array parameters - fix: debug actions enabled states not correct updated when processing debug mouse tooltips --- NEWS.md | 5 + RedPandaIDE/RedPandaIDE_zh_CN.ts | 410 +++++++++++++++++---------- RedPandaIDE/debugger.cpp | 3 +- RedPandaIDE/mainwindow.cpp | 100 +++++-- RedPandaIDE/mainwindow.h | 1 + RedPandaIDE/parser/cppparser.cpp | 12 +- RedPandaIDE/parser/cpptokenizer.cpp | 1 + RedPandaIDE/platform.cpp | 332 ++++++++++++---------- RedPandaIDE/platform.h | 4 +- RedPandaIDE/qsynedit/TextBuffer.cpp | 7 +- RedPandaIDE/widgets/classbrowser.cpp | 3 +- 11 files changed, 541 insertions(+), 337 deletions(-) diff --git a/NEWS.md b/NEWS.md index 9accc884..55a93cfb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,11 @@ Version 0.2.2 - enhancement: support C++ using type alias; - fix: when press shift, completion popu window will hide - enhancement: options in debugger setting widget, to skip system/project/custom header&project files when step into + - fix: icon not correctly displayed for global variables in the class browser + - enhancement: more charset selection in the edit menu + - fix: can't correctly get system default encoding name when save file + - fix: Tokenizer can't correctly handle array parameters + - fix: debug actions enabled states not correct updated when processing debug mouse tooltips Version 0.2.1 - fix: crash when load last opens diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.ts b/RedPandaIDE/RedPandaIDE_zh_CN.ts index c18325be..bd40c898 100644 --- a/RedPandaIDE/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/RedPandaIDE_zh_CN.ts @@ -88,6 +88,120 @@ 混合模式 + + CharsetInfoManager + + + + + Arabic + 阿拉伯语系 + + + + + + + Greek + 希腊语系 + + + + + + + Baltic + 巴尔干语系 + + + + + + + + + + Western Europe + 西欧语言 + + + + + Central Europe + 中欧语言 + + + + + + + + + + Cyrillic + 西里尔语系 + + + + + + + Turkish + 土耳其语系 + + + + + Northern Europe + 北欧语系 + + + + + + Hebrew + 希伯来语 + + + + Thai + 泰语 + + + + + Japanese + 日语 + + + + + + Chinese + 中文 + + + + + Korean + 韩语 + + + + Vietnamese + 越南语 + + + + Eastern Europe + 东欧语系 + + + + Celtic + 凯尔特语系 + + ColorEdit @@ -2190,7 +2304,7 @@ Are you really want to continue? - + Issues 编译器 @@ -2334,7 +2448,7 @@ Are you really want to continue? 工具栏2 - + New 新建 @@ -2392,10 +2506,10 @@ Are you really want to continue? - - - - + + + + Compile 编译 @@ -2441,7 +2555,7 @@ Are you really want to continue? - + Copy 复制 @@ -2795,7 +2909,7 @@ Are you really want to continue? - + Clear all breakpoints 删除所有断点 @@ -2890,42 +3004,42 @@ Are you really want to continue? 在终端中打开 - + File Encoding 文件编码 - + Recent Files 文件历史 - - - - - - + + + + + + Debugging 正在调试 - - - - - - + + + + + + Running 正在运行 - - - - - - + + + + + + Compiling 正在编译 @@ -2934,421 +3048,427 @@ Are you really want to continue? 行:%1 列:%2 已选择:%3 总行数:%4 总长度:%5 - + Line:%1 Col:%2 Selected:%3 Lines:%4 Length:%5 行:%1 列:%2 已选择:%3 总行数:%4 总长度:%5 - + Read Only 只读 - + Insert 插入 - + Overwrite 覆写 - + Close project 关闭项目 - + Are you sure you want to close %1? 你确定要关闭'%1'吗? - - + + Confirm 确认 - - - + + + Source file is not compiled. 源文件尚未编译。 - - + + Compile now? 现在编译? - - + + Source file is more recent than executable. 源文件比可执行程序新。 - + Recompile now? 重新编译? - + No compiler set 无编译器设置 - + No compiler set is configured. 没有配置编译器设置。 - + Can't start debugging. 无法启动调试器 - - + + Enable debugging 启用调试参数 - - + + You have not enabled debugging info (-g3) and/or stripped it from the executable (-s) in Compiler Options.<BR /><BR />Do you want to correct this now? 当前编译设置中未启用调试选项(-g3),或启用了信息剥除选项(-s)<br /><br/>是否纠正这一问题? - + Project not built 项目尚未构建 - + Project hasn't been built. Build it now? 项目尚未构建。是否构建? - + Host applcation missing 宿主程序不存在 - + DLL project needs a host application to run. 动态链接库(DLL)需要一个宿主程序来运行。 - + But it's missing. 但它不存在。 - + Host application not exists 宿主程序不存在 - + Host application file '%1' doesn't exist. 宿主程序'%1'不存在。 - + Recompile? 重新编译? - - + + Save last open info error 保存上次打开信息失败 - + Can't remove old last open information file '%1' 无法删除旧上次打开信息文件'%1' - + Can't save last open info file '%1' 无法保存上次打开信息文件'%1' - + Load last open info error 载入上次打开信息失败 - + Can't load last open info file '%1' 无法载入上次打开信息文件'%1' - + Copy all 全部复制 - + Clear 清除 - + Remove this search 清除这次搜索 - + Clear all searches 删除所有搜索 - + Breakpoint condition... 断点条件... - + Break point condition 断点条件 - + Enter the condition of the breakpoint: 输入当前断点的生效条件: - + Remove all breakpoints 清除所有断点 - + Rename File 重命名文件 - - + + Add Folder 添加文件夹 - + New folder 新文件夹 - + Folder name: 文件夹: - + Rename Folder 重命名 - + Remove Folder 删除文件夹 - + Sort By Type 按类型排序 - + Sort alphabetically 按名称排序 - + Show inherited members 显示继承的成员 - + Goto declaration 跳转到声明处 - + Goto definition 跳转到定义处 - + + Character sets + 字符集 + + + %1 files autosaved 已自动保存%1个文件 - + Save project 保存项目 - + The project '%1' has modifications. 项目'%1'有改动。 - + Do you want to save it? 需要保存吗? - + Do you really want to clear all breakpoints in this file? 您真的要清除该文件的所有断点吗? - + New project 新建项目 - + Close %1 and start new project? 关闭'%1'以打开新项目? - + Folder not exist 文件夹不存在 - + Folder '%1' doesn't exist. Create it now? 文件夹'%1'不存在。是否创建? - + Can't create folder 无法创建文件夹 - + Failed to create folder '%1'. 创建文件夹'%1'失败。 - + Save new project as - + Red panda Dev-C++ project file (*.dev) 小熊猫Dev-C++项目文件 (*.dev) - + New project fail 新建项目失败 - + Can't assign project template 无法使用模板创建项目 - + Add to project 添加到项目 - - - - - - - - + + + + + + + + + Error 错误 - + Recent Projects 项目历史 - + File '%1' was changed. 磁盘文件'%1'已被修改。 - + Reload its content from disk? 是否重新读取它的内容? - + File '%1' was removed. 磁盘文件'%1'已被删除。 - + Keep it open? 是否保持它在小熊猫C++中打开的编辑窗口? - + Open 打开 - + Compile Failed 编译失败 - + Run Failed 运行失败 - - + + Confirm Convertion 确认转换 - - + + The editing file will be saved using %1 encoding. <br />This operation can't be reverted. <br />Are you sure to continue? 当前编辑器中的文件将会使用%1编码保存。<br />这项操作无法被撤回。<br />你确定要继续吗? - + New Watch Expression 新监视表达式 - + Enter Watch Expression (it is recommended to use 'this->' for class members): 输入监视表达式 - + Parsing file %1 of %2: "%3" (%1/%2)正在解析文件"%3" - - + + Done parsing %1 files in %2 seconds 完成%1个文件的解析,用时%2秒 - + (%1 files per second) (每秒%1个文件) @@ -3551,32 +3671,32 @@ Are you really want to continue? - 资源文件: %1 - + Compiling project changes... 正在编译项目修改... - + - Project Filename: %1 - 项目文件名: %1 - + - Compiler Set Name: %1 - 编译器配置: %1 - + Processing makefile: 正在处理makefile... - + - makefile processer: %1 - makefile处理器: %1 - + - Command: %1 %2 - 命令: %1 %2 @@ -3668,32 +3788,32 @@ Are you really want to continue? 文件属性 - + Include in linking 参与链接 - + Build Priority: 构建优先级: - + Include in compilation 参与编译 - + Compile files as C++ 作为C++文件编译 - + Encoding 编码 - + Override build command: 自定义构建命令 @@ -4088,7 +4208,7 @@ Are you really want to continue? QApplication - + Error 错误 @@ -4142,23 +4262,23 @@ Are you really want to continue? - - + + Error 错误 - + Can't create configuration folder %1 无法创建配置文件夹"%1" - + Can't write to configuration file %1 无法写入配置文件夹"%1" - + Can't load autolink settings 无法载入自动链接设置 diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index bb2ab171..90a0ef55 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -1390,10 +1390,11 @@ void DebugReader::runNextCmd() mCurrentCmd.reset(); } - emit cmdStarted(); PDebugCommand pCmd = mCmdQueue.dequeue(); mCmdRunning = true; mCurrentCmd = pCmd; + if (mCurrentCmd->updateWatch) + emit cmdStarted(); QByteArray s; s=pCmd->command.toLocal8Bit(); diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 4332d36e..54e9bef9 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -12,6 +12,7 @@ #include "project.h" #include "projecttemplate.h" #include "widgets/newprojectdialog.h" +#include "platform.h" #include #include @@ -94,19 +95,8 @@ MainWindow::MainWindow(QWidget *parent) mMenuNew->addAction(ui->actionNew); mMenuNew->addAction(ui->actionNew_Project); ui->menuFile->insertMenu(ui->actionOpen,mMenuNew); - mMenuEncoding = new QMenu(); - mMenuEncoding->setTitle(tr("File Encoding")); - mMenuEncoding->addAction(ui->actionAuto_Detect); - mMenuEncoding->addAction(ui->actionEncode_in_ANSI); - mMenuEncoding->addAction(ui->actionEncode_in_UTF_8); - mMenuEncoding->addSeparator(); - mMenuEncoding->addAction(ui->actionConvert_to_ANSI); - mMenuEncoding->addAction(ui->actionConvert_to_UTF_8); - ui->menuEdit->insertMenu(ui->actionFoldAll,mMenuEncoding); - ui->menuEdit->insertSeparator(ui->actionFoldAll); - ui->actionAuto_Detect->setCheckable(true); - ui->actionEncode_in_ANSI->setCheckable(true); - ui->actionEncode_in_UTF_8->setCheckable(true); + + buildEncodingMenu(); mMenuRecentProjects = new QMenu(); mMenuRecentProjects->setTitle(tr("Recent Projects")); @@ -181,10 +171,17 @@ MainWindow::~MainWindow() void MainWindow::updateForEncodingInfo() { Editor * editor = mEditorList->getEditor(); if (editor!=NULL) { - mFileEncodingStatus->setText( - QString("%1(%2)") - .arg(QString(editor->encodingOption()) - ,QString(editor->fileEncoding()))); + if (editor->encodingOption() != editor->fileEncoding()) { + mFileEncodingStatus->setText( + QString("%1(%2)") + .arg(QString(editor->encodingOption()) + ,QString(editor->fileEncoding()))); + } else { + mFileEncodingStatus->setText( + QString("%1") + .arg(QString(editor->encodingOption())) + ); + } ui->actionAuto_Detect->setChecked(editor->encodingOption() == ENCODING_AUTO_DETECT); ui->actionEncode_in_ANSI->setChecked(editor->encodingOption() == ENCODING_SYSTEM_DEFAULT); ui->actionEncode_in_UTF_8->setChecked(editor->encodingOption() == ENCODING_UTF8); @@ -312,12 +309,9 @@ void MainWindow::updateCompileActions() ui->actionDebug->setEnabled(true); } - - ui->actionStep_Into->setEnabled(mDebugger->executing()); - ui->actionStep_Out->setEnabled(mDebugger->executing()); - ui->actionStep_Over->setEnabled(mDebugger->executing()); - ui->actionContinue->setEnabled(mDebugger->executing()); - ui->actionRun_To_Cursor->setEnabled(mDebugger->executing()); + if (!mDebugger->executing()) { + disableDebugActions(); + } ui->actionStop_Execution->setEnabled(mCompilerManager->running() || mDebugger->executing()); //it's not a compile action, but put here for convinience @@ -362,10 +356,6 @@ void MainWindow::updateEditorColorSchemes() if (item) { mStatementColors->insert(StatementKind::skGlobalVariable,item->foreground()); } - item = pColorManager->getItem(schemeName, SYNS_AttrGlobalVariable); - if (item) { - mStatementColors->insert(StatementKind::skGlobalVariable,item->foreground()); - } item = pColorManager->getItem(schemeName, SYNS_AttrPreprocessor); if (item) { mStatementColors->insert(StatementKind::skPreprocessor,item->foreground()); @@ -1818,6 +1808,60 @@ void MainWindow::buildContextMenus() hlayout->addStretch(); } +void MainWindow::buildEncodingMenu() +{ + QMenu* menuCharsets = new QMenu(); + menuCharsets->setTitle(tr("Character sets")); + QStringList languages = pCharsetInfoManager->languageNames(); + foreach (const QString& langName, languages) { + QMenu* menuLang = new QMenu(); + menuLang->setTitle(langName); + menuCharsets->addMenu(menuLang); + QList charInfos = pCharsetInfoManager->findCharsetsByLanguageName(langName); + connect(menuLang,&QMenu::aboutToShow, + [langName,menuLang,this]() { + menuLang->clear(); + Editor* editor = mEditorList->getEditor(); + QList charInfos = pCharsetInfoManager->findCharsetsByLanguageName(langName); + foreach (const PCharsetInfo& info, charInfos) { + QAction * action = new QAction(info->name); + action->setCheckable(true); + if (editor) + action->setChecked(info->name == editor->encodingOption()); + connect(action, &QAction::triggered, + [info,this](){ + Editor * editor = mEditorList->getEditor(); + if (editor == nullptr) + return; + try { + editor->setEncodingOption(info->name); + } catch(FileError e) { + QMessageBox::critical(this,tr("Error"),e.reason()); + } + }); + menuLang->addAction(action); + } + }); + } + + mMenuEncoding = new QMenu(); + mMenuEncoding->setTitle(tr("File Encoding")); + mMenuEncoding->addAction(ui->actionAuto_Detect); + mMenuEncoding->addAction(ui->actionEncode_in_ANSI); + mMenuEncoding->addAction(ui->actionEncode_in_UTF_8); + + mMenuEncoding->addMenu(menuCharsets); + mMenuEncoding->addSeparator(); + mMenuEncoding->addAction(ui->actionConvert_to_ANSI); + mMenuEncoding->addAction(ui->actionConvert_to_UTF_8); + + ui->menuEdit->insertMenu(ui->actionFoldAll,mMenuEncoding); + ui->menuEdit->insertSeparator(ui->actionFoldAll); + ui->actionAuto_Detect->setCheckable(true); + ui->actionEncode_in_ANSI->setCheckable(true); + ui->actionEncode_in_UTF_8->setCheckable(true); +} + void MainWindow::maximizeEditor() { if (mLeftPanelOpenned || mBottomPanelOpenned) { @@ -2074,6 +2118,7 @@ void MainWindow::onEditorTabContextMenu(const QPoint &pos) void MainWindow::disableDebugActions() { + qDebug()<<"disabled"; ui->actionStep_Into->setEnabled(false); ui->actionStep_Over->setEnabled(false); ui->actionStep_Out->setEnabled(false); @@ -2084,6 +2129,7 @@ void MainWindow::disableDebugActions() void MainWindow::enableDebugActions() { + qDebug()<<"enabled"; ui->actionStep_Into->setEnabled(true); ui->actionStep_Over->setEnabled(true); ui->actionStep_Out->setEnabled(true); diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index 4028fcbd..ef506e72 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -149,6 +149,7 @@ private: void prepareDebugger(); void doAutoSave(Editor *e); void buildContextMenus(); + void buildEncodingMenu(); void maximizeEditor(); void openShell(const QString& folder, const QString& shellCommand); QAction* createActionFor(const QString& text, diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index bb5c560b..3e34afa5 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -3107,12 +3107,12 @@ void CppParser::internalParse(const QString &fileName) break; } #ifdef QT_DEBUG - StringsToFile(mPreprocessor.result(),"f:\\preprocess.txt"); - mPreprocessor.dumpDefinesTo("f:\\defines.txt"); - mPreprocessor.dumpIncludesListTo("f:\\includes.txt"); - mStatementList.dump("f:\\stats.txt"); - mTokenizer.dumpTokens("f:\\tokens.txt"); - mStatementList.dumpAll("f:\\all-stats.txt"); +// StringsToFile(mPreprocessor.result(),"f:\\preprocess.txt"); +// mPreprocessor.dumpDefinesTo("f:\\defines.txt"); +// mPreprocessor.dumpIncludesListTo("f:\\includes.txt"); +// mStatementList.dump("f:\\stats.txt"); +// mTokenizer.dumpTokens("f:\\tokens.txt"); +// mStatementList.dumpAll("f:\\all-stats.txt"); #endif } } diff --git a/RedPandaIDE/parser/cpptokenizer.cpp b/RedPandaIDE/parser/cpptokenizer.cpp index 9e55148b..85cb986e 100644 --- a/RedPandaIDE/parser/cpptokenizer.cpp +++ b/RedPandaIDE/parser/cpptokenizer.cpp @@ -295,6 +295,7 @@ QString CppTokenizer::getWord(bool bSkipParenthesis, bool bSkipArray, bool bSkip } else if (bSkipArray && (*mCurrent == '[')) { // Append array stuff while(true) { + offset = mCurrent; skipPair('[', ']'); result += QString(offset,mCurrent-offset); simplifyArgs(result); diff --git a/RedPandaIDE/platform.cpp b/RedPandaIDE/platform.cpp index 2fc4de88..4dbe194e 100644 --- a/RedPandaIDE/platform.cpp +++ b/RedPandaIDE/platform.cpp @@ -4,6 +4,7 @@ #include #ifdef Q_OS_WIN +#include #include #endif @@ -31,161 +32,186 @@ PCharsetInfo CharsetInfoManager::findCharsetByCodepage(int codepage) return PCharsetInfo(); } +QStringList CharsetInfoManager::languageNames() +{ + QSet languages; + foreach (const PCharsetInfo& info, mCodePages) { + if (info->enabled) + languages.insert(info->language); + } + QStringList lst; + foreach (const QString& s, languages) + lst.append(s); + lst.sort(Qt::CaseInsensitive); + return lst; +} + +QList CharsetInfoManager::findCharsetsByLanguageName(const QString &languageName) +{ + QList result; + foreach (const PCharsetInfo& info, mCodePages) { + if (info->language == languageName + && info->enabled) + result.append(info); + } + return result; +} + CharsetInfoManager::CharsetInfoManager():QObject() { - mCodePages.insert(37,std::make_shared(37,"IBM037","",false)); - mCodePages.insert(437,std::make_shared(437,"IBM437","",false)); - mCodePages.insert(500,std::make_shared(500,"IBM500","",false)); - mCodePages.insert(708,std::make_shared(708,"ASMO-708","",false)); - mCodePages.insert(709,std::make_shared(709,"","",false)); - mCodePages.insert(710,std::make_shared(710,"","",false)); - mCodePages.insert(720,std::make_shared(720,"DOS-720",tr("Arabic"),false)); - mCodePages.insert(737,std::make_shared(737,"ibm737",tr("Greek"),false)); - mCodePages.insert(775,std::make_shared(775,"ibm775",tr("Baltic"),false)); - mCodePages.insert(850,std::make_shared(850,"ibm850",tr("Western Europe"),false)); - mCodePages.insert(852,std::make_shared(852,"ibm852",tr("Central Europe"),false)); - mCodePages.insert(855,std::make_shared(855,"IBM855",tr("Cyrillic"),false)); - mCodePages.insert(857,std::make_shared(857,"ibm857",tr("Turkish"),false)); - mCodePages.insert(858,std::make_shared(858,"ibm858",tr("Western Europe"),false)); - mCodePages.insert(860,std::make_shared(860,"IBM860",tr("Western Europe"),false)); - mCodePages.insert(861,std::make_shared(861,"ibm861",tr("Northern Europe"),false)); - mCodePages.insert(862,std::make_shared(862,"DOS-862",tr("Hebrew"),false)); - mCodePages.insert(863,std::make_shared(863,"IBM863",tr("Western Europe"),false)); - mCodePages.insert(864,std::make_shared(864,"IBM864","",false)); - mCodePages.insert(865,std::make_shared(865,"IBM865",tr("Northern Europe"),false)); - mCodePages.insert(866,std::make_shared(866,"cp866",tr("Cyrillic"),false)); - mCodePages.insert(869,std::make_shared(869,"ibm869",tr("Greek"),false)); - mCodePages.insert(870,std::make_shared(870,"IBM870","",false)); - mCodePages.insert(874,std::make_shared(874,"tis-620",tr("Thai"),true)); - mCodePages.insert(875,std::make_shared(875,"cp875","",false)); - mCodePages.insert(932,std::make_shared(932,"shift_jis",tr("Japanese"),true)); - mCodePages.insert(936,std::make_shared(936,"gbk",tr("Chinese"),true)); - mCodePages.insert(949,std::make_shared(949,"windows-949",tr("Korean"),true)); - mCodePages.insert(950,std::make_shared(950,"big5",tr("Chinese"),true)); - mCodePages.insert(1026,std::make_shared(1026,"IBM1026","",false)); - mCodePages.insert(1047,std::make_shared(1047,"IBM01047","",false)); - mCodePages.insert(1140,std::make_shared(1140,"IBM01140","",false)); - mCodePages.insert(1141,std::make_shared(1141,"IBM01141","",false)); - mCodePages.insert(1142,std::make_shared(1142,"IBM01142","",false)); - mCodePages.insert(1143,std::make_shared(1143,"IBM01143","",false)); - mCodePages.insert(1144,std::make_shared(1144,"IBM01144","",false)); - mCodePages.insert(1145,std::make_shared(1145,"IBM01145","",false)); - mCodePages.insert(1146,std::make_shared(1146,"IBM01146","",false)); - mCodePages.insert(1147,std::make_shared(1147,"IBM01147","",false)); - mCodePages.insert(1148,std::make_shared(1148,"IBM01148","",false)); - mCodePages.insert(1149,std::make_shared(1149,"IBM01149","",false)); - mCodePages.insert(1200,std::make_shared(1200,"utf-16","",false)); - mCodePages.insert(1201,std::make_shared(1201,"unicodeFFFE","",false)); - mCodePages.insert(1250,std::make_shared(1250,"windows-1250",tr("Central Europe"),true)); - mCodePages.insert(1251,std::make_shared(1251,"windows-1251",tr("Cyrillic"),true)); - mCodePages.insert(1252,std::make_shared(1252,"windows-1252",tr("Western Europe"),true)); - mCodePages.insert(1253,std::make_shared(1253,"windows-1253",tr("Greek"),true)); - mCodePages.insert(1254,std::make_shared(1254,"windows-1254",tr("Turkish"),true)); - mCodePages.insert(1255,std::make_shared(1255,"windows-1255",tr("Hebrew"),true)); - mCodePages.insert(1256,std::make_shared(1256,"windows-1256",tr("Arabic"),true)); - mCodePages.insert(1257,std::make_shared(1257,"windows-1257",tr("Baltic"),true)); - mCodePages.insert(1258,std::make_shared(1258,"windows-1258",tr("Vietnamese"),true)); - mCodePages.insert(1361,std::make_shared(1361,"Johab","",false)); - mCodePages.insert(10000,std::make_shared(10000,"macintosh",tr("Cyrillic"),true)); - mCodePages.insert(10001,std::make_shared(10001,"x-mac-japanese","",false)); - mCodePages.insert(10002,std::make_shared(10002,"x-mac-chinesetrad","",false)); - mCodePages.insert(10003,std::make_shared(10003,"x-mac-korean","",false)); - mCodePages.insert(10004,std::make_shared(10004,"x-mac-arabic","",false)); - mCodePages.insert(10005,std::make_shared(10005,"x-mac-hebrew","",false)); - mCodePages.insert(10006,std::make_shared(10006,"x-mac-greek","",false)); - mCodePages.insert(10007,std::make_shared(10007,"x-mac-cyrillic","",false)); - mCodePages.insert(10008,std::make_shared(10008,"x-mac-chinesesimp","",false)); - mCodePages.insert(10010,std::make_shared(10010,"x-mac-romanian","",false)); - mCodePages.insert(10017,std::make_shared(10017,"x-mac-ukrainian","",false)); - mCodePages.insert(10021,std::make_shared(10021,"x-mac-thai","",false)); - mCodePages.insert(10029,std::make_shared(10029,"x-mac-ce","",false)); - mCodePages.insert(10079,std::make_shared(10079,"x-mac-icelandic","",false)); - mCodePages.insert(10081,std::make_shared(10081,"x-mac-turkish","",false)); - mCodePages.insert(10082,std::make_shared(10082,"x-mac-croatian","",false)); - mCodePages.insert(12000,std::make_shared(12000,"utf-32","",false)); - mCodePages.insert(12001,std::make_shared(12001,"utf-32BE","",false)); - mCodePages.insert(20000,std::make_shared(20000,"x-Chinese_CNS","",false)); - mCodePages.insert(20001,std::make_shared(20001,"x-cp20001","",false)); - mCodePages.insert(20002,std::make_shared(20002,"x_Chinese-Eten","",false)); - mCodePages.insert(20003,std::make_shared(20003,"x-cp20003","",false)); - mCodePages.insert(20004,std::make_shared(20004,"x-cp20004","",false)); - mCodePages.insert(20005,std::make_shared(20005,"x-cp20005","",false)); - mCodePages.insert(20105,std::make_shared(20105,"x-IA5","",false)); - mCodePages.insert(20106,std::make_shared(20106,"x-IA5-German","",false)); - mCodePages.insert(20107,std::make_shared(20107,"x-IA5-Swedish","",false)); - mCodePages.insert(20108,std::make_shared(20108,"x-IA5-Norwegian","",false)); - mCodePages.insert(20127,std::make_shared(20127,"us-ascii","",false)); - mCodePages.insert(20261,std::make_shared(20261,"x-cp20261","",false)); - mCodePages.insert(20269,std::make_shared(20269,"x-cp20269","",false)); - mCodePages.insert(20273,std::make_shared(20273,"IBM273","",false)); - mCodePages.insert(20277,std::make_shared(20277,"IBM277","",false)); - mCodePages.insert(20278,std::make_shared(20278,"IBM278","",false)); - mCodePages.insert(20280,std::make_shared(20280,"IBM280","",false)); - mCodePages.insert(20284,std::make_shared(20284,"IBM284","",false)); - mCodePages.insert(20285,std::make_shared(20285,"IBM285","",false)); - mCodePages.insert(20290,std::make_shared(20290,"IBM290","",false)); - mCodePages.insert(20297,std::make_shared(20297,"IBM297","",false)); - mCodePages.insert(20420,std::make_shared(20420,"IBM420","",false)); - mCodePages.insert(20423,std::make_shared(20423,"IBM423","",false)); - mCodePages.insert(20424,std::make_shared(20424,"IBM424","",false)); - mCodePages.insert(20833,std::make_shared(20833,"x-EBCDIC-KoreanExtended","",false)); - mCodePages.insert(20838,std::make_shared(20838,"IBM-Thai","",false)); - mCodePages.insert(20866,std::make_shared(20866,"koi8-r",tr("Cyrillic"),true)); - mCodePages.insert(20871,std::make_shared(20871,"IBM871","",false)); - mCodePages.insert(20880,std::make_shared(20880,"IBM880","",false)); - mCodePages.insert(20905,std::make_shared(20905,"IBM905","",false)); - mCodePages.insert(20924,std::make_shared(20924,"IBM00924","",false)); - mCodePages.insert(20932,std::make_shared(20932,"EUC-JP","",false)); - mCodePages.insert(20936,std::make_shared(20936,"x-cp20936","",false)); - mCodePages.insert(20949,std::make_shared(20949,"x-cp20949","",false)); - mCodePages.insert(21025,std::make_shared(21025,"cp1025","",false)); - mCodePages.insert(21027,std::make_shared(21027,"","",false)); - mCodePages.insert(21866,std::make_shared(21866,"koi8-u",tr("Cyrillic"),true)); - mCodePages.insert(28591,std::make_shared(28591,"iso-8859-1",tr("Western Europe"),true)); - mCodePages.insert(28592,std::make_shared(28592,"iso-8859-2",tr("Eastern Europe"),true)); - mCodePages.insert(28593,std::make_shared(28593,"iso-8859-3",tr("Turkish"),true)); - mCodePages.insert(28594,std::make_shared(28594,"iso-8859-4",tr("Baltic"),true)); - mCodePages.insert(28595,std::make_shared(28595,"iso-8859-5",tr("Cyrillic"),true)); - mCodePages.insert(28596,std::make_shared(28596,"iso-8859-6",tr("Arabic"),true)); - mCodePages.insert(28597,std::make_shared(28597,"iso-8859-7",tr("Greek"),true)); - mCodePages.insert(28598,std::make_shared(28598,"iso-8859-8",tr("Hebrew"),true)); - mCodePages.insert(28599,std::make_shared(28599,"iso-8859-9",tr("Turkish"),true)); - mCodePages.insert(28603,std::make_shared(28603,"iso-8859-13",tr("Baltic"),true)); - mCodePages.insert(-1,std::make_shared(28605,"iso-8859-14",tr("Celtic"),true)); - mCodePages.insert(28605,std::make_shared(28605,"iso-8859-15",tr("Western Europe"),true)); - mCodePages.insert(29001,std::make_shared(29001,"x-Europa","",false)); - mCodePages.insert(38598,std::make_shared(38598,"iso-8859-8-i","",false)); - mCodePages.insert(50220,std::make_shared(50220,"iso-2022-jp","",false)); - mCodePages.insert(50221,std::make_shared(50221,"csISO2022JP","",false)); - mCodePages.insert(50222,std::make_shared(50222,"iso-2022-jp","",false)); - mCodePages.insert(50225,std::make_shared(50225,"iso-2022-kr","",false)); - mCodePages.insert(50227,std::make_shared(50227,"x-cp50227","",false)); - mCodePages.insert(50229,std::make_shared(50229,"","",false)); - mCodePages.insert(50930,std::make_shared(50930,"","",false)); - mCodePages.insert(50931,std::make_shared(50931,"","",false)); - mCodePages.insert(50933,std::make_shared(50933,"","",false)); - mCodePages.insert(50935,std::make_shared(50935,"","",false)); - mCodePages.insert(50936,std::make_shared(50936,"","",false)); - mCodePages.insert(50937,std::make_shared(50937,"","",false)); - mCodePages.insert(50939,std::make_shared(50939,"","",false)); - mCodePages.insert(51932,std::make_shared(51932,"euc-jp",tr("Japanese"),true)); - mCodePages.insert(51936,std::make_shared(51936,"euc-cn","",false)); - mCodePages.insert(51949,std::make_shared(51949,"euc-kr",tr("Korean"),true)); - mCodePages.insert(51950,std::make_shared(51950,"","",false)); - mCodePages.insert(52936,std::make_shared(52936,"hz-gb-2312","",false)); - mCodePages.insert(54936,std::make_shared(54936,"gb18030",tr("Chinese"),true)); - mCodePages.insert(57002,std::make_shared(57002,"x-iscii-de","",false)); - mCodePages.insert(57003,std::make_shared(57003,"x-iscii-be","",false)); - mCodePages.insert(57004,std::make_shared(57004,"x-iscii-ta","",false)); - mCodePages.insert(57005,std::make_shared(57005,"x-iscii-te","",false)); - mCodePages.insert(57006,std::make_shared(57006,"x-iscii-as","",false)); - mCodePages.insert(57007,std::make_shared(57007,"x-iscii-or","",false)); - mCodePages.insert(57008,std::make_shared(57008,"x-iscii-ka","",false)); - mCodePages.insert(57009,std::make_shared(57009,"x-iscii-ma","",false)); - mCodePages.insert(57010,std::make_shared(57010,"x-iscii-gu","",false)); - mCodePages.insert(57011,std::make_shared(57011,"x-iscii-pa","",false)); - mCodePages.insert(65000,std::make_shared(65000,"utf-7","",false)); - mCodePages.insert(65001,std::make_shared(65001,"utf-8","",false)); + mCodePages.append(std::make_shared(37,"IBM037","",false)); + mCodePages.append(std::make_shared(437,"IBM437","",false)); + mCodePages.append(std::make_shared(500,"IBM500","",false)); + mCodePages.append(std::make_shared(708,"ASMO-708","",false)); + mCodePages.append(std::make_shared(709,"","",false)); + mCodePages.append(std::make_shared(710,"","",false)); + mCodePages.append(std::make_shared(720,"DOS-720",tr("Arabic"),false)); + mCodePages.append(std::make_shared(737,"ibm737",tr("Greek"),false)); + mCodePages.append(std::make_shared(775,"ibm775",tr("Baltic"),false)); + mCodePages.append(std::make_shared(850,"ibm850",tr("Western Europe"),false)); + mCodePages.append(std::make_shared(852,"ibm852",tr("Central Europe"),false)); + mCodePages.append(std::make_shared(855,"IBM855",tr("Cyrillic"),false)); + mCodePages.append(std::make_shared(857,"ibm857",tr("Turkish"),false)); + mCodePages.append(std::make_shared(858,"ibm858",tr("Western Europe"),false)); + mCodePages.append(std::make_shared(860,"IBM860",tr("Western Europe"),false)); + mCodePages.append(std::make_shared(861,"ibm861",tr("Northern Europe"),false)); + mCodePages.append(std::make_shared(862,"DOS-862",tr("Hebrew"),false)); + mCodePages.append(std::make_shared(863,"IBM863",tr("Western Europe"),false)); + mCodePages.append(std::make_shared(864,"IBM864","",false)); + mCodePages.append(std::make_shared(865,"IBM865",tr("Northern Europe"),false)); + mCodePages.append(std::make_shared(866,"cp866",tr("Cyrillic"),false)); + mCodePages.append(std::make_shared(869,"ibm869",tr("Greek"),false)); + mCodePages.append(std::make_shared(870,"IBM870","",false)); + mCodePages.append(std::make_shared(874,"tis-620",tr("Thai"),true)); + mCodePages.append(std::make_shared(875,"cp875","",false)); + mCodePages.append(std::make_shared(932,"shift_jis",tr("Japanese"),true)); + mCodePages.append(std::make_shared(936,"gbk",tr("Chinese"),true)); + mCodePages.append(std::make_shared(949,"windows-949",tr("Korean"),true)); + mCodePages.append(std::make_shared(950,"big5",tr("Chinese"),true)); + mCodePages.append(std::make_shared(1026,"IBM1026","",false)); + mCodePages.append(std::make_shared(1047,"IBM01047","",false)); + mCodePages.append(std::make_shared(1140,"IBM01140","",false)); + mCodePages.append(std::make_shared(1141,"IBM01141","",false)); + mCodePages.append(std::make_shared(1142,"IBM01142","",false)); + mCodePages.append(std::make_shared(1143,"IBM01143","",false)); + mCodePages.append(std::make_shared(1144,"IBM01144","",false)); + mCodePages.append(std::make_shared(1145,"IBM01145","",false)); + mCodePages.append(std::make_shared(1146,"IBM01146","",false)); + mCodePages.append(std::make_shared(1147,"IBM01147","",false)); + mCodePages.append(std::make_shared(1148,"IBM01148","",false)); + mCodePages.append(std::make_shared(1149,"IBM01149","",false)); + mCodePages.append(std::make_shared(1200,"utf-16","",false)); + mCodePages.append(std::make_shared(1201,"unicodeFFFE","",false)); + mCodePages.append(std::make_shared(1250,"windows-1250",tr("Central Europe"),true)); + mCodePages.append(std::make_shared(1251,"windows-1251",tr("Cyrillic"),true)); + mCodePages.append(std::make_shared(1252,"windows-1252",tr("Western Europe"),true)); + mCodePages.append(std::make_shared(1253,"windows-1253",tr("Greek"),true)); + mCodePages.append(std::make_shared(1254,"windows-1254",tr("Turkish"),true)); + mCodePages.append(std::make_shared(1255,"windows-1255",tr("Hebrew"),true)); + mCodePages.append(std::make_shared(1256,"windows-1256",tr("Arabic"),true)); + mCodePages.append(std::make_shared(1257,"windows-1257",tr("Baltic"),true)); + mCodePages.append(std::make_shared(1258,"windows-1258",tr("Vietnamese"),true)); + mCodePages.append(std::make_shared(1361,"Johab","",false)); + mCodePages.append(std::make_shared(10000,"macintosh",tr("Cyrillic"),true)); + mCodePages.append(std::make_shared(10001,"x-mac-japanese","",false)); + mCodePages.append(std::make_shared(10002,"x-mac-chinesetrad","",false)); + mCodePages.append(std::make_shared(10003,"x-mac-korean","",false)); + mCodePages.append(std::make_shared(10004,"x-mac-arabic","",false)); + mCodePages.append(std::make_shared(10005,"x-mac-hebrew","",false)); + mCodePages.append(std::make_shared(10006,"x-mac-greek","",false)); + mCodePages.append(std::make_shared(10007,"x-mac-cyrillic","",false)); + mCodePages.append(std::make_shared(10008,"x-mac-chinesesimp","",false)); + mCodePages.append(std::make_shared(10010,"x-mac-romanian","",false)); + mCodePages.append(std::make_shared(10017,"x-mac-ukrainian","",false)); + mCodePages.append(std::make_shared(10021,"x-mac-thai","",false)); + mCodePages.append(std::make_shared(10029,"x-mac-ce","",false)); + mCodePages.append(std::make_shared(10079,"x-mac-icelandic","",false)); + mCodePages.append(std::make_shared(10081,"x-mac-turkish","",false)); + mCodePages.append(std::make_shared(10082,"x-mac-croatian","",false)); + mCodePages.append(std::make_shared(12000,"utf-32","",false)); + mCodePages.append(std::make_shared(12001,"utf-32BE","",false)); + mCodePages.append(std::make_shared(20000,"x-Chinese_CNS","",false)); + mCodePages.append(std::make_shared(20001,"x-cp20001","",false)); + mCodePages.append(std::make_shared(20002,"x_Chinese-Eten","",false)); + mCodePages.append(std::make_shared(20003,"x-cp20003","",false)); + mCodePages.append(std::make_shared(20004,"x-cp20004","",false)); + mCodePages.append(std::make_shared(20005,"x-cp20005","",false)); + mCodePages.append(std::make_shared(20105,"x-IA5","",false)); + mCodePages.append(std::make_shared(20106,"x-IA5-German","",false)); + mCodePages.append(std::make_shared(20107,"x-IA5-Swedish","",false)); + mCodePages.append(std::make_shared(20108,"x-IA5-Norwegian","",false)); + mCodePages.append(std::make_shared(20127,"us-ascii","",false)); + mCodePages.append(std::make_shared(20261,"x-cp20261","",false)); + mCodePages.append(std::make_shared(20269,"x-cp20269","",false)); + mCodePages.append(std::make_shared(20273,"IBM273","",false)); + mCodePages.append(std::make_shared(20277,"IBM277","",false)); + mCodePages.append(std::make_shared(20278,"IBM278","",false)); + mCodePages.append(std::make_shared(20280,"IBM280","",false)); + mCodePages.append(std::make_shared(20284,"IBM284","",false)); + mCodePages.append(std::make_shared(20285,"IBM285","",false)); + mCodePages.append(std::make_shared(20290,"IBM290","",false)); + mCodePages.append(std::make_shared(20297,"IBM297","",false)); + mCodePages.append(std::make_shared(20420,"IBM420","",false)); + mCodePages.append(std::make_shared(20423,"IBM423","",false)); + mCodePages.append(std::make_shared(20424,"IBM424","",false)); + mCodePages.append(std::make_shared(20833,"x-EBCDIC-KoreanExtended","",false)); + mCodePages.append(std::make_shared(20838,"IBM-Thai","",false)); + mCodePages.append(std::make_shared(20866,"koi8-r",tr("Cyrillic"),true)); + mCodePages.append(std::make_shared(20871,"IBM871","",false)); + mCodePages.append(std::make_shared(20880,"IBM880","",false)); + mCodePages.append(std::make_shared(20905,"IBM905","",false)); + mCodePages.append(std::make_shared(20924,"IBM00924","",false)); + mCodePages.append(std::make_shared(20932,"EUC-JP","",false)); + mCodePages.append(std::make_shared(20936,"x-cp20936","",false)); + mCodePages.append(std::make_shared(20949,"x-cp20949","",false)); + mCodePages.append(std::make_shared(21025,"cp1025","",false)); + mCodePages.append(std::make_shared(21027,"","",false)); + mCodePages.append(std::make_shared(21866,"koi8-u",tr("Cyrillic"),true)); + mCodePages.append(std::make_shared(28591,"iso-8859-1",tr("Western Europe"),true)); + mCodePages.append(std::make_shared(28592,"iso-8859-2",tr("Eastern Europe"),true)); + mCodePages.append(std::make_shared(28593,"iso-8859-3",tr("Turkish"),true)); + mCodePages.append(std::make_shared(28594,"iso-8859-4",tr("Baltic"),true)); + mCodePages.append(std::make_shared(28595,"iso-8859-5",tr("Cyrillic"),true)); + mCodePages.append(std::make_shared(28596,"iso-8859-6",tr("Arabic"),true)); + mCodePages.append(std::make_shared(28597,"iso-8859-7",tr("Greek"),true)); + mCodePages.append(std::make_shared(28598,"iso-8859-8",tr("Hebrew"),true)); + mCodePages.append(std::make_shared(28599,"iso-8859-9",tr("Turkish"),true)); + mCodePages.append(std::make_shared(28603,"iso-8859-13",tr("Baltic"),true)); + mCodePages.append(std::make_shared(-1,"iso-8859-14",tr("Celtic"),true)); + mCodePages.append(std::make_shared(28605,"iso-8859-15",tr("Western Europe"),true)); + mCodePages.append(std::make_shared(29001,"x-Europa","",false)); + mCodePages.append(std::make_shared(38598,"iso-8859-8-i","",false)); + mCodePages.append(std::make_shared(50220,"iso-2022-jp","",false)); + mCodePages.append(std::make_shared(50221,"csISO2022JP","",false)); + mCodePages.append(std::make_shared(50222,"iso-2022-jp","",false)); + mCodePages.append(std::make_shared(50225,"iso-2022-kr","",false)); + mCodePages.append(std::make_shared(50227,"x-cp50227","",false)); + mCodePages.append(std::make_shared(50229,"","",false)); + mCodePages.append(std::make_shared(50930,"","",false)); + mCodePages.append(std::make_shared(50931,"","",false)); + mCodePages.append(std::make_shared(50933,"","",false)); + mCodePages.append(std::make_shared(50935,"","",false)); + mCodePages.append(std::make_shared(50936,"","",false)); + mCodePages.append(std::make_shared(50937,"","",false)); + mCodePages.append(std::make_shared(50939,"","",false)); + mCodePages.append(std::make_shared(51932,"euc-jp",tr("Japanese"),true)); + mCodePages.append(std::make_shared(51936,"euc-cn","",false)); + mCodePages.append(std::make_shared(51949,"euc-kr",tr("Korean"),true)); + mCodePages.append(std::make_shared(51950,"","",false)); + mCodePages.append(std::make_shared(52936,"hz-gb-2312","",false)); + mCodePages.append(std::make_shared(54936,"gb18030",tr("Chinese"),true)); + mCodePages.append(std::make_shared(57002,"x-iscii-de","",false)); + mCodePages.append(std::make_shared(57003,"x-iscii-be","",false)); + mCodePages.append(std::make_shared(57004,"x-iscii-ta","",false)); + mCodePages.append(std::make_shared(57005,"x-iscii-te","",false)); + mCodePages.append(std::make_shared(57006,"x-iscii-as","",false)); + mCodePages.append(std::make_shared(57007,"x-iscii-or","",false)); + mCodePages.append(std::make_shared(57008,"x-iscii-ka","",false)); + mCodePages.append(std::make_shared(57009,"x-iscii-ma","",false)); + mCodePages.append(std::make_shared(57010,"x-iscii-gu","",false)); + mCodePages.append(std::make_shared(57011,"x-iscii-pa","",false)); + mCodePages.append(std::make_shared(65000,"utf-7","",false)); + mCodePages.append(std::make_shared(65001,"utf-8","",false)); } diff --git a/RedPandaIDE/platform.h b/RedPandaIDE/platform.h index 868a67fb..5b645476 100644 --- a/RedPandaIDE/platform.h +++ b/RedPandaIDE/platform.h @@ -19,7 +19,7 @@ struct CharsetInfo{ using PCharsetInfo = std::shared_ptr; class CharsetInfoManager: public QObject { - Q_OBJECT; + Q_OBJECT public: explicit CharsetInfoManager(); QByteArray getDefaultSystemEncoding(); @@ -27,7 +27,7 @@ public: QStringList languageNames(); QList findCharsetsByLanguageName(const QString& languageName); private: - static QList mCodePages; + QList mCodePages; }; using PCharsetInfoManager = std::shared_ptr; diff --git a/RedPandaIDE/qsynedit/TextBuffer.cpp b/RedPandaIDE/qsynedit/TextBuffer.cpp index 78e6f0a8..0fdaa9d3 100644 --- a/RedPandaIDE/qsynedit/TextBuffer.cpp +++ b/RedPandaIDE/qsynedit/TextBuffer.cpp @@ -546,7 +546,7 @@ void SynEditStringList::LoadFromFile(const QString& filename, const QByteArray& } if (realEncoding == ENCODING_SYSTEM_DEFAULT) { - realEncoding = getDefaultSystemEncoding(); + realEncoding = pCharsetInfoManager->getDefaultSystemEncoding(); } file.reset(); QTextStream textStream(&file); @@ -603,8 +603,11 @@ void SynEditStringList::SaveToFile(QFile &file, const QByteArray& encoding, QByt if (encoding == ENCODING_AUTO_DETECT) { if (allAscii) realEncoding = ENCODING_ASCII; - else + else if (codec->name() == "System") { + realEncoding = pCharsetInfoManager->getDefaultSystemEncoding(); + } else { realEncoding = codec->name(); + } } } diff --git a/RedPandaIDE/widgets/classbrowser.cpp b/RedPandaIDE/widgets/classbrowser.cpp index 2b5e3f58..21b33181 100644 --- a/RedPandaIDE/widgets/classbrowser.cpp +++ b/RedPandaIDE/widgets/classbrowser.cpp @@ -183,9 +183,10 @@ QVariant ClassBrowserModel::data(const QModelIndex &index, int role) const return QIcon(":/icons/images/classparser/method_private.ico"); } } + case StatementKind::skGlobalVariable: + return QIcon(":/icons/images/classparser/global.ico"); case StatementKind::skVariable: if (statement->scope == StatementScope::ssGlobal) - return QIcon(":/icons/images/classparser/global.ico"); if (statement->isInherited) { if (statement->classScope == StatementClassScope::scsProtected) { return QIcon(":/icons/images/classparser/var_inherited_protected.ico");