- fix: wrong selection when drag & dropped in editor
This commit is contained in:
parent
5789aeee45
commit
9eac0fed26
1
NEWS.md
1
NEWS.md
|
@ -10,6 +10,7 @@ Red Panda C++ Version 1.0.0
|
|||
- enhancement: auto detect "gbk" encoding when running in zh_CN locale under Linux
|
||||
- enhancement: disable encoding submenu when editor closed
|
||||
- enhancement: clear infos in the status bar when editor closed
|
||||
- fix: wrong selection when drag & dropped in editor
|
||||
|
||||
Red Panda C++ Version 0.14.5
|
||||
- fix: the "gnu c++ 20" option in compiler set options is wrong
|
||||
|
|
|
@ -7121,3 +7121,12 @@ void MainWindow::on_actionFilesView_Hide_Non_Support_Files_toggled(bool /* arg1
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_actionToggle_Block_Comment_triggered()
|
||||
{
|
||||
Editor * editor = mEditorList->getEditor();
|
||||
if (editor != NULL ) {
|
||||
editor->toggleBlockComment();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -607,6 +607,8 @@ private slots:
|
|||
|
||||
void on_actionFilesView_Hide_Non_Support_Files_toggled(bool arg1);
|
||||
|
||||
void on_actionToggle_Block_Comment_triggered();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
EditorList *mEditorList;
|
||||
|
|
|
@ -1489,6 +1489,7 @@
|
|||
<addaction name="actionUnIndent"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionToggleComment"/>
|
||||
<addaction name="actionToggle_Block_Comment"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionFoldAll"/>
|
||||
<addaction name="actionUnfoldAll"/>
|
||||
|
@ -2851,6 +2852,14 @@
|
|||
<string>Hide Non Support Files</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionToggle_Block_Comment">
|
||||
<property name="text">
|
||||
<string>Toggle Block Comment</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Alt+Shift+A</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
|
@ -162,7 +162,7 @@ enum class SynEditorCommand {
|
|||
ecComment = 614,
|
||||
ecUncomment = 615,
|
||||
ecToggleComment = 616,
|
||||
ecCommentInline = 617,
|
||||
ecToggleBlockComment = 617,
|
||||
|
||||
ecUpperCase = 620, // apply to the current or previous word
|
||||
ecLowerCase = 621,
|
||||
|
|
|
@ -39,7 +39,8 @@
|
|||
#include <QMimeData>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
||||
SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent),
|
||||
mDropped(false)
|
||||
{
|
||||
mLastKey = 0;
|
||||
mLastKeyModifiers = Qt::NoModifier;
|
||||
|
@ -1789,8 +1790,38 @@ void SynEdit::doToggleComment()
|
|||
doComment();
|
||||
}
|
||||
|
||||
void SynEdit::doToggleBlockComment()
|
||||
{
|
||||
QString s;
|
||||
if (mReadOnly)
|
||||
return;
|
||||
doOnPaintTransient(SynTransientType::ttBefore);
|
||||
|
||||
QString text=selText().trimmed();
|
||||
if (text.length()>4 && text.startsWith("/*") && text.endsWith("*/")) {
|
||||
QString newText=selText();
|
||||
int pos = newText.indexOf("/*");
|
||||
if (pos>=0) {
|
||||
newText.remove(pos,2);
|
||||
}
|
||||
pos = newText.lastIndexOf("*/");
|
||||
if (pos>=0) {
|
||||
newText.remove(pos,2);
|
||||
}
|
||||
setSelText(newText);
|
||||
} else {
|
||||
QString newText="/*"+selText()+"*/";
|
||||
setSelText(newText);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SynEdit::doMouseScroll(bool isDragging)
|
||||
{
|
||||
if (mDropped) {
|
||||
mDropped=false;
|
||||
return;
|
||||
}
|
||||
QPoint iMousePos;
|
||||
DisplayCoord C;
|
||||
int X, Y;
|
||||
|
@ -5643,6 +5674,9 @@ void SynEdit::ExecuteCommand(SynEditorCommand Command, QChar AChar, void *pData)
|
|||
case SynEditorCommand::ecToggleComment:
|
||||
doToggleComment();
|
||||
break;
|
||||
case SynEditorCommand::ecToggleBlockComment:
|
||||
doToggleBlockComment();
|
||||
break;
|
||||
case SynEditorCommand::ecNormalSelect:
|
||||
setSelectionMode(SynSelectionMode::smNormal);
|
||||
break;
|
||||
|
@ -6148,9 +6182,8 @@ void SynEdit::dropEvent(QDropEvent *event)
|
|||
}
|
||||
mUndoList->EndBlock();
|
||||
}
|
||||
|
||||
event->acceptProposedAction();
|
||||
|
||||
mDropped = true;
|
||||
}
|
||||
|
||||
void SynEdit::dragMoveEvent(QDragMoveEvent *event)
|
||||
|
|
|
@ -276,6 +276,7 @@ public:
|
|||
virtual void tab() { commandProcessor(SynEditorCommand::ecTab);}
|
||||
virtual void shifttab() { commandProcessor(SynEditorCommand::ecShiftTab);}
|
||||
virtual void toggleComment() { commandProcessor(SynEditorCommand::ecToggleComment);}
|
||||
virtual void toggleBlockComment() { commandProcessor(SynEditorCommand::ecToggleBlockComment);}
|
||||
|
||||
virtual void beginUpdate();
|
||||
virtual void endUpdate();
|
||||
|
@ -589,6 +590,7 @@ private:
|
|||
void doComment();
|
||||
void doUncomment();
|
||||
void doToggleComment();
|
||||
void doToggleBlockComment();
|
||||
void doMouseScroll(bool isDragging);
|
||||
|
||||
|
||||
|
@ -729,7 +731,7 @@ private:
|
|||
BufferCoord mDragCaretSave;
|
||||
BufferCoord mDragSelBeginSave;
|
||||
BufferCoord mDragSelEndSave;
|
||||
bool mDragging;
|
||||
bool mDropped;
|
||||
|
||||
friend class SynEditTextPainter;
|
||||
|
||||
|
|
Loading…
Reference in New Issue