Merge branch 'master' of github.com:royqh1979/RedPanda-CPP

This commit is contained in:
Roy Qu 2024-04-12 12:28:14 +08:00
commit 30a8205058
9 changed files with 126 additions and 39 deletions

View File

@ -133,6 +133,9 @@ Red Panda C++ Version 2.27
- fix: Can't find symbols indirectly included by other files.
- enhancement: Function tip's width changes with editor width.
- fix: '<' / '>' not shown in function tips.
- enhancement: In debug console, Ctrl+C/Ctrl+X/Ctrl+V conflicts with application action.
- enhancement: Auto hide Edit/Selection/Code/Refactor menu if no file openning.
- enhancement: Auto hide Project menu if no project openning.
Red Panda C++ Version 2.26
- enhancement: Code suggestion for embedded std::vectors.

View File

@ -228,6 +228,25 @@ public:
static PCppParser sharedParser(ParserLanguage language);
void pageUp() { processCommand(QSynedit::EditCommand::PageUp); }
void pageDown() { processCommand(QSynedit::EditCommand::PageDown); }
void gotoLineStart() { processCommand(QSynedit::EditCommand::LineStart); }
void gotoLineEnd() { processCommand(QSynedit::EditCommand::LineEnd); }
void gotoPageStart() { processCommand(QSynedit::EditCommand::PageTop); }
void gotoPageEnd() { processCommand(QSynedit::EditCommand::PageBottom); }
void gotoFileStart() { processCommand(QSynedit::EditCommand::FileStart); }
void gotoFileEnd() { processCommand(QSynedit::EditCommand::FileEnd); }
void toggleReadonly();
void pageUpAndSelect() { processCommand(QSynedit::EditCommand::SelPageUp); }
void pageDownAndSelect() { processCommand(QSynedit::EditCommand::SelPageDown); }
void selectToLineStart() { processCommand(QSynedit::EditCommand::SelLineStart); }
void selectToLineEnd() { processCommand(QSynedit::EditCommand::SelLineEnd); }
void selectToPageStart() { processCommand(QSynedit::EditCommand::SelPageTop); }
void selectToPageEnd() { processCommand(QSynedit::EditCommand::SelPageBottom); }
void selectToFileStart() { processCommand(QSynedit::EditCommand::SelFileStart); }
void selectToFileEnd() { processCommand(QSynedit::EditCommand::SelFileEnd); }
signals:
void renamed(const QString& oldName, const QString& newName, bool firstSave);
void fileSaved(const QString& filename, bool inProject);

View File

@ -86,6 +86,7 @@ public:
signals:
void editorClosed();
void editorRenamed(const QString& oldFilename, const QString& newFilename, bool firstSave);
void editorOpenned();
private:
QTabWidget* getNewEditorPageControl() const;

View File

@ -281,12 +281,6 @@ MainWindow::MainWindow(QWidget *parent)
mCPUDialog = nullptr;
// applySettings();
// applyUISettings();
// updateProjectView();
// updateEditorActions();
// updateCaretActions();
ui->cbReplaceInHistory->completer()->setCaseSensitivity(Qt::CaseSensitive);
ui->cbEvaluate->completer()->setCaseSensitivity(Qt::CaseSensitive);
ui->cbMemoryAddress->completer()->setCaseSensitivity(Qt::CaseSensitive);
@ -481,6 +475,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(ui->menuGit, &QMenu::aboutToShow,
this, &MainWindow::updateVCSActions);
#endif
initEditorActions();
initToolButtons();
buildContextMenus();
updateAppTitle();
@ -602,6 +597,11 @@ void MainWindow::updateEncodingActions(const Editor *e)
void MainWindow::updateEditorActions(const Editor *e)
{
ui->menuCode->menuAction()->setVisible(mEditorList->pageCount()>0);
ui->menuEdit->menuAction()->setVisible(mEditorList->pageCount()>0);
ui->menuSelection->menuAction()->setVisible(mEditorList->pageCount()>0);
ui->menuRefactor->menuAction()->setVisible(mEditorList->pageCount()>0);
//it's not a compile action, but put here for convinience
ui->actionSaveAll->setEnabled(
(mProject!=nullptr || mEditorList->pageCount()>0));
@ -779,6 +779,8 @@ void MainWindow::updateEditorActions(const Editor *e)
void MainWindow::updateProjectActions()
{
bool hasProject = (mProject != nullptr);
ui->menuProject->menuAction()->setVisible(hasProject);
ui->actionNew_Template->setEnabled(hasProject);
ui->actionView_Makefile->setEnabled(hasProject);
ui->actionProject_New_File->setEnabled(hasProject);
@ -7844,6 +7846,65 @@ void MainWindow::modifyBreakpointCondition(int index)
}
void MainWindow::initEditorActions()
{
ui->menuCode->menuAction()->setVisible(false);
ui->menuEdit->menuAction()->setVisible(false);
ui->menuSelection->menuAction()->setVisible(false);
ui->menuRefactor->menuAction()->setVisible(false);
foreach (QAction* action, ui->menuEdit->actions()) {
if (action->objectName().isEmpty())
continue;
changeEditorActionParent(action);
}
foreach (QAction* action, ui->menuSelection->actions()) {
if (action->objectName().isEmpty())
continue;
changeEditorActionParent(action);
}
foreach (QAction* action, ui->menuCode->actions()) {
if (action->objectName().isEmpty())
continue;
changeEditorActionParent(action);
}
foreach (QAction* action, ui->menuRefactor->actions()) {
if (action->objectName().isEmpty())
continue;
changeEditorActionParent(action);
}
foreach (QAction* action, mMenuEncoding->actions()) {
if (action->objectName().isEmpty())
continue;
changeEditorActionParent(action);
}
changeEditorActionParent(ui->actionPrint);
changeEditorActionParent(ui->actionExport_As_HTML);
changeEditorActionParent(ui->actionExport_As_RTF);
changeEditorActionParent(ui->actionSave);
changeEditorActionParent(ui->actionSaveAs);
changeEditorActionParent(ui->actionClose);
changeEditorActionParent(ui->actionFind);
changeEditorActionParent(ui->actionReplace);
changeEditorActionParent(ui->actionFind_references);
changeEditorActionParent(ui->actionFind_Next);
changeEditorActionParent(ui->actionFind_Previous);
changeEditorActionParent(ui->actionToggle_Breakpoint);
changeEditorActionParent(ui->actionGoto_Declaration);
changeEditorActionParent(ui->actionGoto_Definition);
changeEditorActionParent(ui->actionFile_Properties);
changeEditorActionParent(ui->actionLocate_in_Files_View);
changeEditorActionParent(ui->actionSwitchHeaderSource);
}
void MainWindow::changeEditorActionParent(QAction *action)
{
action->setParent(ui->splitterEditorPanel);
ui->splitterEditorPanel->addAction(action);
action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
}
void MainWindow::setupSlotsForProject()
{
connect(mProject.get(), &Project::unitAdded,
@ -10090,7 +10151,7 @@ void MainWindow::on_actionPage_Up_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor && editor->hasFocus()) {
editor->processCommand(QSynedit::EditCommand::PageUp);
editor->pageUp();
}
}
@ -10099,7 +10160,7 @@ void MainWindow::on_actionPage_Down_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor && editor->hasFocus()) {
editor->processCommand(QSynedit::EditCommand::PageDown);
editor->pageDown();
}
}
@ -10108,7 +10169,7 @@ void MainWindow::on_actionGoto_Line_Start_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor && editor->hasFocus()) {
editor->processCommand(QSynedit::EditCommand::LineStart);
editor->gotoLineStart();
}
}
@ -10117,7 +10178,7 @@ void MainWindow::on_actionGoto_Line_End_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor && editor->hasFocus()) {
editor->processCommand(QSynedit::EditCommand::LineEnd);
editor->gotoLineEnd();
}
}
@ -10126,7 +10187,7 @@ void MainWindow::on_actionGoto_File_Start_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor && editor->hasFocus()) {
editor->processCommand(QSynedit::EditCommand::EditorStart);
editor->gotoFileStart();
}
}
@ -10135,7 +10196,7 @@ void MainWindow::on_actionGoto_File_End_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor && editor->hasFocus()) {
editor->processCommand(QSynedit::EditCommand::EditorEnd);
editor->gotoFileEnd();
}
}
@ -10144,7 +10205,7 @@ void MainWindow::on_actionPage_Up_and_Select_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor && editor->hasFocus()) {
editor->processCommand(QSynedit::EditCommand::SelPageUp);
editor->pageUpAndSelect();;
}
}
@ -10153,7 +10214,7 @@ void MainWindow::on_actionPage_Down_and_Select_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor && editor->hasFocus()) {
editor->processCommand(QSynedit::EditCommand::SelPageDown);
editor->pageDownAndSelect();
}
}
@ -10162,7 +10223,7 @@ void MainWindow::on_actionGoto_Page_Start_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor && editor->hasFocus()) {
editor->processCommand(QSynedit::EditCommand::PageTop);
editor->gotoPageStart();
}
}
@ -10171,7 +10232,7 @@ void MainWindow::on_actionGoto_Page_End_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor && editor->hasFocus()) {
editor->processCommand(QSynedit::EditCommand::PageBottom);
editor->gotoPageEnd();
}
}
@ -10180,7 +10241,7 @@ void MainWindow::on_actionGoto_Page_Start_and_Select_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor && editor->hasFocus()) {
editor->processCommand(QSynedit::EditCommand::SelPageTop);
editor->selectToPageStart();
}
}
@ -10189,7 +10250,7 @@ void MainWindow::on_actionGoto_Page_End_and_Select_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor && editor->hasFocus()) {
editor->processCommand(QSynedit::EditCommand::SelPageBottom);
editor->selectToPageEnd();
}
}
@ -10198,7 +10259,7 @@ void MainWindow::on_actionGoto_Line_Start_and_Select_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor && editor->hasFocus()) {
editor->processCommand(QSynedit::EditCommand::SelLineStart);
editor->selectToLineStart();
}
}
@ -10207,7 +10268,7 @@ void MainWindow::on_actionGoto_Line_End_and_Select_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor && editor->hasFocus()) {
editor->processCommand(QSynedit::EditCommand::SelLineEnd);
editor->selectToLineEnd();
}
}
@ -10216,7 +10277,7 @@ void MainWindow::on_actionGoto_File_Start_and_Select_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor && editor->hasFocus()) {
editor->processCommand(QSynedit::EditCommand::SelEditorStart);
editor->selectToFileStart();
}
}
@ -10225,7 +10286,7 @@ void MainWindow::on_actionGoto_File_End_and_Select_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor && editor->hasFocus()) {
editor->processCommand(QSynedit::EditCommand::SelEditorEnd);
editor->selectToFileEnd();
}
}

View File

@ -334,6 +334,8 @@ private:
QString switchHeaderSourceTarget(Editor *editor);
void modifyBreakpointCondition(int index);
void initEditorActions();
void changeEditorActionParent(QAction *action);
private slots:
void setupSlotsForProject();
@ -1024,7 +1026,7 @@ private:
QSortFilterProxyModel *mProjectProxyModel;
// QWidget interface
// QWidget interface
protected:
void closeEvent(QCloseEvent *event) override;
void showEvent(QShowEvent* event) override;

View File

@ -215,12 +215,12 @@ void EditKeyStrokes::resetDefaults()
add(EditCommand::SelPageTop, Qt::Key_PageUp, Qt::KeyboardModifiers(Qt::ShiftModifier|Qt::ControlModifier));
add(EditCommand::LineStart, Qt::Key_Home, Qt::NoModifier);
add(EditCommand::SelLineStart, Qt::Key_Home, Qt::ShiftModifier);
add(EditCommand::EditorStart, Qt::Key_Home, Qt::ControlModifier);
add(EditCommand::SelEditorStart, Qt::Key_Home, Qt::KeyboardModifiers(Qt::ShiftModifier|Qt::ControlModifier));
add(EditCommand::FileStart, Qt::Key_Home, Qt::ControlModifier);
add(EditCommand::SelFileStart, Qt::Key_Home, Qt::KeyboardModifiers(Qt::ShiftModifier|Qt::ControlModifier));
add(EditCommand::LineEnd, Qt::Key_End, Qt::NoModifier);
add(EditCommand::SelLineEnd, Qt::Key_End, Qt::ShiftModifier);
add(EditCommand::EditorEnd, Qt::Key_End, Qt::ControlModifier);
add(EditCommand::SelEditorEnd, Qt::Key_End, Qt::KeyboardModifiers(Qt::ShiftModifier|Qt::ControlModifier));
add(EditCommand::FileEnd, Qt::Key_End, Qt::ControlModifier);
add(EditCommand::SelFileEnd, Qt::Key_End, Qt::KeyboardModifiers(Qt::ShiftModifier|Qt::ControlModifier));
add(EditCommand::ToggleMode, Qt::Key_Insert, Qt::NoModifier);
add(EditCommand::DeleteChar, Qt::Key_Delete, Qt::NoModifier);
add(EditCommand::DeleteLastChar, Qt::Key_Backspace, Qt::NoModifier);

View File

@ -55,8 +55,8 @@ enum class EditCommand {
PageRight = 12, // Move cursor left one page
PageTop = 13, // Move cursor to top of page
PageBottom = 14, // Move cursor to bottom of page
EditorStart = 15, // Move cursor to absolute beginning
EditorEnd = 16, // Move cursor to absolute end
FileStart = 15, // Move cursor to absolute beginning
FileEnd = 16, // Move cursor to absolute end
GotoXY = 17, // Move cursor to specific coordinates, Data = PPoint
BlockStart = 18, // Move cursor to begin of block
BlockEnd = 19, // Move cursor to end of block
@ -84,8 +84,8 @@ enum class EditCommand {
SelPageRight = PageRight + Selection,
SelPageTop = PageTop + Selection,
SelPageBottom = PageBottom + Selection,
SelEditorStart = EditorStart + Selection,
SelEditorEnd = EditorEnd + Selection,
SelFileStart = FileStart + Selection,
SelFileEnd = FileEnd + Selection,
SelGotoXY = GotoXY + Selection, // Data = PPoint
SelBlockStart = BlockStart + Selection, // Move cursor to begin of scope
SelBlockEnd = BlockEnd + Selection, // Move cursor to end of scope

View File

@ -5643,13 +5643,13 @@ void QSynEdit::executeCommand(EditCommand command, QChar ch, void *pData)
case EditCommand::SelPageBottom:
moveCaretVert(yposToRow(0)+mLinesInWindow-1-mCaretY, command == EditCommand::SelPageBottom);
break;
case EditCommand::EditorStart:
case EditCommand::SelEditorStart:
doGotoEditorStart(command == EditCommand::SelEditorStart);
case EditCommand::FileStart:
case EditCommand::SelFileStart:
doGotoEditorStart(command == EditCommand::SelFileStart);
break;
case EditCommand::EditorEnd:
case EditCommand::SelEditorEnd:
doGotoEditorEnd(command == EditCommand::SelEditorEnd);
case EditCommand::FileEnd:
case EditCommand::SelFileEnd:
doGotoEditorEnd(command == EditCommand::SelFileEnd);
break;
case EditCommand::BlockStart:
case EditCommand::SelBlockStart:

View File

@ -234,7 +234,6 @@ public:
BufferCoord prevWordPos();
BufferCoord prevWordPosEx(const BufferCoord& XY);
void processCommand(EditCommand Command, QChar AChar = QChar(), void * pData = nullptr);
//Caret
void showCaret();
void hideCaret();
@ -500,6 +499,8 @@ protected:
void incPaintLock();
void decPaintLock();
SyntaxState calcSyntaxStateAtLine(int line, const QString &newLineText);
void processCommand(EditCommand Command, QChar AChar = QChar(), void * pData = nullptr);
private:
int calcLineAlignedTopPos(int currentValue, bool passFirstLine);
void ensureLineAlignedWithTop(void);