- enhancement: add "delete line"/"duplicate line"/"delete word"/"delete to EOL"/"delete to BOL" in the edit menu

This commit is contained in:
royqh1979@gmail.com 2021-11-22 16:16:58 +08:00
parent 2763ef1c60
commit 6ba2d47c81
10 changed files with 538 additions and 370 deletions

View File

@ -4,6 +4,7 @@ Version 0.9.2 For Dev-C++ 7 Beta
- fix: executor / problem set options not correctly saved - fix: executor / problem set options not correctly saved
- fix: option "Move caret to the first non-space char in the current line when press HOME key" dosen't work fine. - fix: option "Move caret to the first non-space char in the current line when press HOME key" dosen't work fine.
- fix: ctrl+left can't correctly move to the beginning of the last word - fix: ctrl+left can't correctly move to the beginning of the last word
- enhancement: add "delete line"/"duplicate line"/"delete word"/"delete to EOL"/"delete to BOL" in the edit menu
Version 0.9.1 For Dev-C++ 7 Beta Version 0.9.1 For Dev-C++ 7 Beta
- enhancement: code completion suggestion for "__func__" variable - enhancement: code completion suggestion for "__func__" variable

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1593,6 +1593,36 @@ bool Editor::notParsed()
return mParser->findFileIncludes(mFilename)==nullptr; return mParser->findFileIncludes(mFilename)==nullptr;
} }
void Editor::insertLine()
{
ExecuteCommand(SynEditorCommand::ecInsertLine,QChar(),nullptr);
}
void Editor::deleteWord()
{
ExecuteCommand(SynEditorCommand::ecDeleteWord,QChar(),nullptr);
}
void Editor::deleteLine()
{
ExecuteCommand(SynEditorCommand::ecDeleteLine,QChar(),nullptr);
}
void Editor::duplicateLine()
{
ExecuteCommand(SynEditorCommand::ecDuplicateLine,QChar(),nullptr);
}
void Editor::deleteToEOL()
{
ExecuteCommand(SynEditorCommand::ecDeleteEOL,QChar(),nullptr);
}
void Editor::deleteToBOL()
{
ExecuteCommand(SynEditorCommand::ecDeleteBOL,QChar(),nullptr);
}
QChar Editor::getCurrentChar() QChar Editor::getCurrentChar()
{ {
if (lineText().length()<caretX()) if (lineText().length()<caretX())

View File

@ -168,6 +168,12 @@ public:
void exportAsHTML(const QString& htmlFilename); void exportAsHTML(const QString& htmlFilename);
void resetBreakpoints(); void resetBreakpoints();
bool notParsed(); bool notParsed();
void insertLine();
void deleteWord();
void deleteLine();
void duplicateLine();
void deleteToEOL();
void deleteToBOL();
const PCppParser &parser(); const PCppParser &parser();

View File

@ -5695,3 +5695,57 @@ void MainWindow::on_actionProblem_triggered()
showHideMessagesTab(ui->tabProblem,state); showHideMessagesTab(ui->tabProblem,state);
} }
void MainWindow::on_actionInsert_Line_triggered()
{
Editor *e=mEditorList->getEditor();
if (e) {
e->insertLine();
}
}
void MainWindow::on_actionDelete_Line_triggered()
{
Editor *e=mEditorList->getEditor();
if (e) {
e->deleteLine();
}
}
void MainWindow::on_actionDuplicate_Line_triggered()
{
Editor *e=mEditorList->getEditor();
if (e) {
e->duplicateLine();
}
}
void MainWindow::on_actionDelete_Word_triggered()
{
Editor *e=mEditorList->getEditor();
if (e) {
e->deleteWord();
}
}
void MainWindow::on_actionDelete_to_EOL_triggered()
{
Editor *e=mEditorList->getEditor();
if (e) {
e->deleteToEOL();
}
}
void MainWindow::on_actionDelete_to_BOL_triggered()
{
Editor *e=mEditorList->getEditor();
if (e) {
e->deleteToBOL();
}
}

View File

@ -518,6 +518,18 @@ private slots:
void on_actionProblem_triggered(); void on_actionProblem_triggered();
void on_actionInsert_Line_triggered();
void on_actionDelete_Line_triggered();
void on_actionDuplicate_Line_triggered();
void on_actionDelete_Word_triggered();
void on_actionDelete_to_EOL_triggered();
void on_actionDelete_to_BOL_triggered();
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
EditorList *mEditorList; EditorList *mEditorList;

View File

@ -1449,6 +1449,12 @@
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionFoldAll"/> <addaction name="actionFoldAll"/>
<addaction name="actionUnfoldAll"/> <addaction name="actionUnfoldAll"/>
<addaction name="separator"/>
<addaction name="actionDelete_Line"/>
<addaction name="actionDuplicate_Line"/>
<addaction name="actionDelete_Word"/>
<addaction name="actionDelete_to_BOL"/>
<addaction name="actionDelete_to_EOL"/>
</widget> </widget>
<widget class="QMenu" name="menuSearch"> <widget class="QMenu" name="menuSearch">
<property name="title"> <property name="title">
@ -2603,6 +2609,31 @@
<string>Problem</string> <string>Problem</string>
</property> </property>
</action> </action>
<action name="actionDelete_Line">
<property name="text">
<string>Delete Line</string>
</property>
</action>
<action name="actionDuplicate_Line">
<property name="text">
<string>Duplicate Line</string>
</property>
</action>
<action name="actionDelete_Word">
<property name="text">
<string>Delete Word</string>
</property>
</action>
<action name="actionDelete_to_EOL">
<property name="text">
<string>Delete to EOL</string>
</property>
</action>
<action name="actionDelete_to_BOL">
<property name="text">
<string>Delete to BOL</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>

View File

@ -219,11 +219,13 @@ void SynEditKeyStrokes::resetDefaults()
add(SynEditorCommand::ecCut, Qt::Key_X, Qt::ControlModifier); add(SynEditorCommand::ecCut, Qt::Key_X, Qt::ControlModifier);
add(SynEditorCommand::ecBlockIndent, Qt::Key_I, Qt::ControlModifier|Qt::ShiftModifier); add(SynEditorCommand::ecBlockIndent, Qt::Key_I, Qt::ControlModifier|Qt::ShiftModifier);
add(SynEditorCommand::ecBlockUnindent, Qt::Key_U, Qt::ControlModifier|Qt::ShiftModifier); add(SynEditorCommand::ecBlockUnindent, Qt::Key_U, Qt::ControlModifier|Qt::ShiftModifier);
add(SynEditorCommand::ecLineBreak, Qt::Key_M, Qt::ControlModifier); // add(SynEditorCommand::ecLineBreak, Qt::Key_M, Qt::ControlModifier);
add(SynEditorCommand::ecInsertLine, Qt::Key_N, Qt::ControlModifier); // add(SynEditorCommand::ecInsertLine, Qt::Key_N, Qt::ControlModifier);
add(SynEditorCommand::ecDeleteWord, Qt::Key_T, Qt::ControlModifier); // add(SynEditorCommand::ecDeleteWord, Qt::Key_T, Qt::ControlModifier);
add(SynEditorCommand::ecDeleteLine, Qt::Key_Y, Qt::ControlModifier); // add(SynEditorCommand::ecDeleteLine, Qt::Key_Y, Qt::ControlModifier);
add(SynEditorCommand::ecDeleteEOL, Qt::Key_Y, Qt::ControlModifier|Qt::ShiftModifier); // add(SynEditorCommand::ecDeleteEOL, Qt::Key_Y, Qt::ControlModifier|Qt::ShiftModifier);
// add(SynEditorCommand::ecDuplicateLine, Qt::Key_D, Qt::ControlModifier);
add(SynEditorCommand::ecUndo, Qt::Key_Z, Qt::ControlModifier); add(SynEditorCommand::ecUndo, Qt::Key_Z, Qt::ControlModifier);
add(SynEditorCommand::ecRedo, Qt::Key_Z, Qt::ControlModifier|Qt::ShiftModifier); add(SynEditorCommand::ecRedo, Qt::Key_Z, Qt::ControlModifier|Qt::ShiftModifier);
add(SynEditorCommand::ecGotoMarker0, Qt::Key_0, Qt::ControlModifier); add(SynEditorCommand::ecGotoMarker0, Qt::Key_0, Qt::ControlModifier);

View File

@ -5436,6 +5436,8 @@ void SynEdit::ExecuteCommand(SynEditorCommand Command, QChar AChar, void *pData)
clearAll(); clearAll();
break; break;
case SynEditorCommand::ecInsertLine: case SynEditorCommand::ecInsertLine:
insertLine(Command == SynEditorCommand::ecInsertLine);
break;
case SynEditorCommand::ecLineBreak: case SynEditorCommand::ecLineBreak:
insertLine(Command == SynEditorCommand::ecLineBreak); insertLine(Command == SynEditorCommand::ecLineBreak);
break; break;