- fix: The memory usage displayed after program execution is wrong.

- enhancement: New compiler option "stack size" in the link subpage.
  - change: Set "Ctrl+G" as the shortcut for "Goto page..."
  - change: Set "Ctrl+B" as the shortcut for "Toggle Bookmark"
This commit is contained in:
Roy Qu 2024-05-05 10:24:36 +08:00
parent 996dbc7055
commit eac49a90f0
16 changed files with 763 additions and 711 deletions

View File

@ -160,6 +160,10 @@ Red Panda C++ Version 2.27
- fix: project not correctly reparsed after rename unit. - fix: project not correctly reparsed after rename unit.
- enhancement: support C++ 17 structured binding in stl map containers foreach loop. - enhancement: support C++ 17 structured binding in stl map containers foreach loop.
- fix: Crash when has source line like "std::cout << (3+4*4>5*(4+3)-1 && (4-3>5)) <<std::endl;". - fix: Crash when has source line like "std::cout << (3+4*4>5*(4+3)-1 && (4-3>5)) <<std::endl;".
- fix: The memory usage displayed after program execution is wrong.
- enhancement: New compiler option "stack size" in the link subpage.
- change: Set "Ctrl+G" as the shortcut for "Goto page..."
- change: Set "Ctrl+B" as the shortcut for "Toggle Bookmark"
Red Panda C++ Version 2.26 Red Panda C++ Version 2.26
- enhancement: Code suggestion for embedded std::vectors. - enhancement: Code suggestion for embedded std::vectors.

View File

@ -724,7 +724,8 @@ void Compiler::runCommand(const QString &cmd, const QStringList &arguments, cons
} }
if (compilerSet() && compilerSet()->forceEnglishOutput()) if (compilerSet() && compilerSet()->forceEnglishOutput())
env.insert("LANG","en"); env.insert("LANG","en");
env.insert("LDFLAGS","-Wl,--stack,12582912"); //env.insert("LDFLAGS","-Wl,--stack,12582912");
env.insert("LDFLAGS","");
env.insert("CFLAGS",""); env.insert("CFLAGS","");
env.insert("CXXFLAGS",""); env.insert("CXXFLAGS","");
process.setProcessEnvironment(env); process.setProcessEnvironment(env);

View File

@ -53,7 +53,7 @@ PCompilerOption CompilerInfo::addOption(const QString &key, const QString &name,
return pOption; return pOption;
} }
PCompilerOption CompilerInfo::addNumberOption(const QString &key, const QString &name, const QString section, bool isC, bool isCpp, bool isLinker, const QString &setting, const QString &suffix, int scale, int minValue, int maxValue) PCompilerOption CompilerInfo::addNumberOption(const QString &key, const QString &name, const QString section, bool isC, bool isCpp, bool isLinker, const QString &setting, const QString &suffix, int scale, int defaultValue, int minValue, int maxValue)
{ {
PCompilerOption pOption = std::make_shared<CompilerOption>(); PCompilerOption pOption = std::make_shared<CompilerOption>();
pOption->key = key; pOption->key = key;
@ -64,8 +64,9 @@ PCompilerOption CompilerInfo::addNumberOption(const QString &key, const QString
pOption->isLinker = isLinker; pOption->isLinker = isLinker;
pOption->setting= setting; pOption->setting= setting;
pOption->type = CompilerOptionType::Number; pOption->type = CompilerOptionType::Number;
pOption->unit = suffix; pOption->suffix = suffix;
pOption->scale = scale; pOption->scale = scale;
pOption->defaultValue = defaultValue;
pOption->minValue = minValue; pOption->minValue = minValue;
pOption->maxValue = maxValue; pOption->maxValue = maxValue;
mCompilerOptions.insert(key,pOption); mCompilerOptions.insert(key,pOption);
@ -216,7 +217,7 @@ void CompilerInfo::prepareCompilerOptions()
// Linker // Linker
groupName = QObject::tr("Linker"); groupName = QObject::tr("Linker");
//addNumberOption(LINK_CMD_OPT_STACK_SIZE, QObject::tr("Stack Size"), groupName, false, false, true, "-Wl,--stack,","MB",1024*1024,0,99999); addNumberOption(LINK_CMD_OPT_STACK_SIZE, QObject::tr("Stack Size"), groupName, false, false, true, "-Wl,--stack,","MB",1024*1024,12,0,99999);
addOption(CC_CMD_OPT_USE_PIPE, QObject::tr("Use pipes instead of temporary files during compilation (-pipe)"), groupName, true, true, false, "-pipe"); addOption(CC_CMD_OPT_USE_PIPE, QObject::tr("Use pipes instead of temporary files during compilation (-pipe)"), groupName, true, true, false, "-pipe");
//addOption(LINK_CMD_OPT_LINK_OBJC, QObject::tr("Link an Objective C program (-lobjc)"), groupName, false, false, true, "-lobjc"); //addOption(LINK_CMD_OPT_LINK_OBJC, QObject::tr("Link an Objective C program (-lobjc)"), groupName, false, false, true, "-lobjc");

View File

@ -103,8 +103,9 @@ typedef struct {
CompilerOptionType type; CompilerOptionType type;
CompileOptionChoiceList choices; // replaces "Yes/No" standard choices (max 30 different choices) CompileOptionChoiceList choices; // replaces "Yes/No" standard choices (max 30 different choices)
/* for spin control */ /* for spin control */
QString unit; //suffix
int scale; //Scale int scale; //Scale
QString suffix; //suffix
int defaultValue;
int minValue; int minValue;
int maxValue; int maxValue;
} CompilerOption; } CompilerOption;
@ -150,6 +151,7 @@ protected:
const QString& setting, const QString& setting,
const QString& suffix, const QString& suffix,
int scale, int scale,
int defaultValue,
int minValue, int minValue,
int maxValue int maxValue
); );

View File

@ -160,7 +160,7 @@ void OJProblemCasesRunner::runCase(int index,POJProblemCase problemCase)
counter.cb = sizeof(counter); counter.cb = sizeof(counter);
if (GetProcessMemoryInfo(hProcess,&counter, if (GetProcessMemoryInfo(hProcess,&counter,
sizeof(counter))){ sizeof(counter))){
problemCase->runningMemory = counter.PeakWorkingSetSize; problemCase->runningMemory = counter.PeakPagefileUsage;
} }
FILETIME creationTime; FILETIME creationTime;
FILETIME exitTime; FILETIME exitTime;

View File

@ -5212,6 +5212,15 @@ bool Editor::hasBreakpoint(int line)
return mBreakpointLines.contains(line); return mBreakpointLines.contains(line);
} }
void Editor::toggleBookmark(int line)
{
if (hasBookmark(line)) {
removeBookmark(line);
} else {
addBookmark(line);
}
}
void Editor::addBookmark(int line) void Editor::addBookmark(int line)
{ {
mBookmarkLines.insert(line); mBookmarkLines.insert(line);

View File

@ -178,6 +178,7 @@ public:
void toggleBreakpoint(int line); void toggleBreakpoint(int line);
void clearBreakpoints(); void clearBreakpoints();
bool hasBreakpoint(int line); bool hasBreakpoint(int line);
void toggleBookmark(int line);
void addBookmark(int line); void addBookmark(int line);
void removeBookmark(int line); void removeBookmark(int line);
bool hasBookmark(int line) const; bool hasBookmark(int line) const;

View File

@ -673,8 +673,7 @@ void MainWindow::updateEditorActions(const Editor *e)
ui->actionClose_All->setEnabled(false); ui->actionClose_All->setEnabled(false);
ui->actionClose_Others->setEnabled(false); ui->actionClose_Others->setEnabled(false);
ui->actionAdd_bookmark->setEnabled(false); ui->actionToggle_Bookmark->setEnabled(false);
ui->actionRemove_Bookmark->setEnabled(false);
ui->actionModify_Bookmark_Description->setEnabled(false); ui->actionModify_Bookmark_Description->setEnabled(false);
ui->actionMatch_Bracket->setEnabled(false); ui->actionMatch_Bracket->setEnabled(false);
@ -755,8 +754,7 @@ void MainWindow::updateEditorActions(const Editor *e)
ui->actionClose_Others->setEnabled(mEditorList->pageCount()>1); ui->actionClose_Others->setEnabled(mEditorList->pageCount()>1);
int line = e->caretY(); int line = e->caretY();
ui->actionAdd_bookmark->setEnabled(e->lineCount()>0 && !e->hasBookmark(line)); ui->actionToggle_Bookmark->setEnabled(e->lineCount()>0);
ui->actionRemove_Bookmark->setEnabled(e->hasBookmark(line));
ui->actionModify_Bookmark_Description->setEnabled(e->hasBookmark(line)); ui->actionModify_Bookmark_Description->setEnabled(e->hasBookmark(line));
ui->actionMatch_Bracket->setEnabled(true); ui->actionMatch_Bracket->setEnabled(true);
@ -2018,8 +2016,7 @@ void MainWindow::updateActionIcons()
ui->actionBack->setIcon(pIconsManager->getIcon(IconsManager::ACTION_CODE_BACK)); ui->actionBack->setIcon(pIconsManager->getIcon(IconsManager::ACTION_CODE_BACK));
ui->actionForward->setIcon(pIconsManager->getIcon(IconsManager::ACTION_CODE_FORWARD)); ui->actionForward->setIcon(pIconsManager->getIcon(IconsManager::ACTION_CODE_FORWARD));
ui->actionAdd_bookmark->setIcon(pIconsManager->getIcon(IconsManager::ACTION_CODE_ADD_BOOKMARK)); ui->actionToggle_Bookmark->setIcon(pIconsManager->getIcon(IconsManager::ACTION_CODE_ADD_BOOKMARK));
ui->actionRemove_Bookmark->setIcon(pIconsManager->getIcon(IconsManager::ACTION_CODE_REMOVE_BOOKMARK));
ui->actionReformat_Code->setIcon(pIconsManager->getIcon(IconsManager::ACTION_CODE_REFORMAT)); ui->actionReformat_Code->setIcon(pIconsManager->getIcon(IconsManager::ACTION_CODE_REFORMAT));
ui->actionProject_New_File->setIcon(pIconsManager->getIcon(IconsManager::ACTION_PROJECT_NEW_FILE)); ui->actionProject_New_File->setIcon(pIconsManager->getIcon(IconsManager::ACTION_PROJECT_NEW_FILE));
@ -5189,8 +5186,7 @@ void MainWindow::onEditorContextMenu(const QPoint& pos)
menu.addAction(ui->actionClear_all_breakpoints); menu.addAction(ui->actionClear_all_breakpoints);
menu.addSeparator(); menu.addSeparator();
} }
menu.addAction(ui->actionAdd_bookmark); menu.addAction(ui->actionToggle_Bookmark);
menu.addAction(ui->actionRemove_Bookmark);
menu.addAction(ui->actionModify_Bookmark_Description); menu.addAction(ui->actionModify_Bookmark_Description);
menu.addSeparator(); menu.addSeparator();
menu.addAction(ui->actionGo_to_Line); menu.addAction(ui->actionGo_to_Line);
@ -5207,19 +5203,16 @@ void MainWindow::onEditorContextMenu(const QPoint& pos)
menu.addAction(ui->actionClear_all_breakpoints); menu.addAction(ui->actionClear_all_breakpoints);
menu.addSeparator(); menu.addSeparator();
} }
menu.addAction(ui->actionAdd_bookmark); menu.addAction(ui->actionToggle_Bookmark);
menu.addAction(ui->actionRemove_Bookmark);
menu.addAction(ui->actionModify_Bookmark_Description); menu.addAction(ui->actionModify_Bookmark_Description);
menu.addSeparator(); menu.addSeparator();
menu.addAction(ui->actionGo_to_Line); menu.addAction(ui->actionGo_to_Line);
} }
ui->actionLocate_in_Files_View->setEnabled(!editor->isNew()); ui->actionLocate_in_Files_View->setEnabled(!editor->isNew());
ui->actionBreakpoint_property->setEnabled(editor->hasBreakpoint(line)); ui->actionBreakpoint_property->setEnabled(editor->hasBreakpoint(line));
ui->actionAdd_bookmark->setEnabled( ui->actionToggle_Bookmark->setEnabled(
line>=0 && editor->lineCount()>0 line>=0 && editor->lineCount()>0
&& !editor->hasBookmark(line)
); );
ui->actionRemove_Bookmark->setEnabled(editor->hasBookmark(line));
ui->actionModify_Bookmark_Description->setEnabled(editor->hasBookmark(line)); ui->actionModify_Bookmark_Description->setEnabled(editor->hasBookmark(line));
menu.exec(editor->viewport()->mapToGlobal(pos)); menu.exec(editor->viewport()->mapToGlobal(pos));
} }
@ -8572,35 +8565,6 @@ TodoModel *MainWindow::todoModel()
return &mTodoModel; return &mTodoModel;
} }
void MainWindow::on_actionAdd_bookmark_triggered()
{
Editor* editor = mEditorList->getEditor();
if (editor) {
if (editor->lineCount()<=0)
return;
int line = editor->caretY();
QString desc = QInputDialog::getText(editor,tr("Bookmark Description"),
tr("Description:"),QLineEdit::Normal,
editor->lineText(line).trimmed());
desc = desc.trimmed();
editor->addBookmark(line);
mBookmarkModel->addBookmark(editor->filename(),line,desc,editor->inProject());
}
}
void MainWindow::on_actionRemove_Bookmark_triggered()
{
Editor* editor = mEditorList->getEditor();
if (editor) {
int line = editor->caretY();
editor->removeBookmark(line);
mBookmarkModel->removeBookmark(editor->filename(),line,editor->inProject());
}
}
void MainWindow::on_tableBookmark_doubleClicked(const QModelIndex &index) void MainWindow::on_tableBookmark_doubleClicked(const QModelIndex &index)
{ {
if (!index.isValid()) if (!index.isValid())
@ -10319,3 +10283,23 @@ void MainWindow::on_cbProblemCaseValidateType_currentIndexChanged(int index)
pSettings->executor().save(); pSettings->executor().save();
} }
void MainWindow::on_actionToggle_Bookmark_triggered()
{
Editor* editor = mEditorList->getEditor();
if (editor) {
if (editor->lineCount()<=0)
return;
int line = editor->caretY();
editor->toggleBookmark(line);
if (editor->hasBookmark(line)) {
QString desc = QInputDialog::getText(editor,tr("Bookmark Description"),
tr("Description:"),QLineEdit::Normal,
editor->lineText(line).trimmed());
desc = desc.trimmed();
mBookmarkModel->addBookmark(editor->filename(),line,desc,editor->inProject());
} else
mBookmarkModel->removeBookmark(editor->filename(),line,editor->inProject());
}
}

View File

@ -630,10 +630,6 @@ private slots:
void on_actionEGE_Manual_triggered(); void on_actionEGE_Manual_triggered();
void on_actionAdd_bookmark_triggered();
void on_actionRemove_Bookmark_triggered();
void on_tableBookmark_doubleClicked(const QModelIndex &index); void on_tableBookmark_doubleClicked(const QModelIndex &index);
void on_actionModify_Bookmark_Description_triggered(); void on_actionModify_Bookmark_Description_triggered();
@ -860,6 +856,8 @@ private slots:
void on_cbProblemCaseValidateType_currentIndexChanged(int index); void on_cbProblemCaseValidateType_currentIndexChanged(int index);
void on_actionToggle_Bookmark_triggered();
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
bool mFullInitialized; bool mFullInitialized;

View File

@ -241,8 +241,7 @@
<addaction name="actionGoto_block_start"/> <addaction name="actionGoto_block_start"/>
<addaction name="actionGoto_block_end"/> <addaction name="actionGoto_block_end"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionAdd_bookmark"/> <addaction name="actionToggle_Bookmark"/>
<addaction name="actionRemove_Bookmark"/>
<addaction name="actionModify_Bookmark_Description"/> <addaction name="actionModify_Bookmark_Description"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionTrim_trailing_spaces"/> <addaction name="actionTrim_trailing_spaces"/>
@ -2562,9 +2561,6 @@
<property name="text"> <property name="text">
<string>Open containing folder</string> <string>Open containing folder</string>
</property> </property>
<property name="shortcut">
<string>Ctrl+B</string>
</property>
<property name="shortcutContext"> <property name="shortcutContext">
<enum>Qt::ApplicationShortcut</enum> <enum>Qt::ApplicationShortcut</enum>
</property> </property>
@ -2687,16 +2683,6 @@
<string>EGE Manual</string> <string>EGE Manual</string>
</property> </property>
</action> </action>
<action name="actionAdd_bookmark">
<property name="text">
<string>Add Bookmark</string>
</property>
</action>
<action name="actionRemove_Bookmark">
<property name="text">
<string>Remove Bookmark</string>
</property>
</action>
<action name="actionModify_Bookmark_Description"> <action name="actionModify_Bookmark_Description">
<property name="text"> <property name="text">
<string>Modify Bookmark Description</string> <string>Modify Bookmark Description</string>
@ -3271,6 +3257,17 @@
<enum>QAction::NoRole</enum> <enum>QAction::NoRole</enum>
</property> </property>
</action> </action>
<action name="actionToggle_Bookmark">
<property name="text">
<string>Toggle Bookmark</string>
</property>
<property name="shortcut">
<string>Ctrl+B</string>
</property>
<property name="menuRole">
<enum>QAction::NoRole</enum>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -177,11 +177,12 @@ void CompileArgumentsWidget::resetUI(Settings::PCompilerSet pSet, const QMap<QSt
{ {
pLayout->addWidget(new QLabel(pOption->name,pWidget),row,1); pLayout->addWidget(new QLabel(pOption->name,pWidget),row,1);
QSpinBox* pInput = new QSpinBox(pWidget); QSpinBox* pInput = new QSpinBox(pWidget);
QString defaultValue = QString("%1").arg(pOption->defaultValue);
bool ok; bool ok;
int val = options.value(pOption->key,"").toInt(&ok); int val = options.value(pOption->key,defaultValue).toInt(&ok);
if (!ok) if (!ok)
val = 0; val = 0;
pInput->setSuffix(pOption->unit); pInput->setSuffix(pOption->suffix);
pInput->setMinimum(pOption->minValue); pInput->setMinimum(pOption->minValue);
pInput->setMaximum(pOption->maxValue); pInput->setMaximum(pOption->maxValue);
pInput->setValue(val); pInput->setValue(val);

View File

@ -4288,7 +4288,7 @@
<context> <context>
<name>QSynedit::Document</name> <name>QSynedit::Document</name>
<message> <message>
<location filename="qsynedit/document.cpp" line="+617"/> <location filename="qsynedit/document.cpp" line="+613"/>
<source>Can&apos;t open file &apos;%1&apos; for read!</source> <source>Can&apos;t open file &apos;%1&apos; for read!</source>
<translation>&quot;%1&quot;.</translation> <translation>&quot;%1&quot;.</translation>
</message> </message>

View File

@ -154,7 +154,7 @@ DWORD ExecuteCommand(string& command,bool reInp, LONGLONG &peakMemory, LONGLONG
counter.cb = sizeof(counter); counter.cb = sizeof(counter);
if (GetProcessMemoryInfo(pi.hProcess,&counter, if (GetProcessMemoryInfo(pi.hProcess,&counter,
sizeof(counter))){ sizeof(counter))){
peakMemory = counter.PeakWorkingSetSize/1024; peakMemory = counter.PeakPagefileUsage/1024;
} }
FILETIME creationTime; FILETIME creationTime;
FILETIME exitTime; FILETIME exitTime;