- 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: auto detect "gbk" encoding when running in zh_CN locale under Linux
|
||||||
- enhancement: disable encoding submenu when editor closed
|
- enhancement: disable encoding submenu when editor closed
|
||||||
- enhancement: clear infos in the status bar 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
|
Red Panda C++ Version 0.14.5
|
||||||
- fix: the "gnu c++ 20" option in compiler set options is wrong
|
- 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_actionFilesView_Hide_Non_Support_Files_toggled(bool arg1);
|
||||||
|
|
||||||
|
void on_actionToggle_Block_Comment_triggered();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
EditorList *mEditorList;
|
EditorList *mEditorList;
|
||||||
|
|
|
@ -1489,6 +1489,7 @@
|
||||||
<addaction name="actionUnIndent"/>
|
<addaction name="actionUnIndent"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionToggleComment"/>
|
<addaction name="actionToggleComment"/>
|
||||||
|
<addaction name="actionToggle_Block_Comment"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionFoldAll"/>
|
<addaction name="actionFoldAll"/>
|
||||||
<addaction name="actionUnfoldAll"/>
|
<addaction name="actionUnfoldAll"/>
|
||||||
|
@ -2851,6 +2852,14 @@
|
||||||
<string>Hide Non Support Files</string>
|
<string>Hide Non Support Files</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</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>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
|
@ -162,7 +162,7 @@ enum class SynEditorCommand {
|
||||||
ecComment = 614,
|
ecComment = 614,
|
||||||
ecUncomment = 615,
|
ecUncomment = 615,
|
||||||
ecToggleComment = 616,
|
ecToggleComment = 616,
|
||||||
ecCommentInline = 617,
|
ecToggleBlockComment = 617,
|
||||||
|
|
||||||
ecUpperCase = 620, // apply to the current or previous word
|
ecUpperCase = 620, // apply to the current or previous word
|
||||||
ecLowerCase = 621,
|
ecLowerCase = 621,
|
||||||
|
|
|
@ -39,7 +39,8 @@
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
|
|
||||||
SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent),
|
||||||
|
mDropped(false)
|
||||||
{
|
{
|
||||||
mLastKey = 0;
|
mLastKey = 0;
|
||||||
mLastKeyModifiers = Qt::NoModifier;
|
mLastKeyModifiers = Qt::NoModifier;
|
||||||
|
@ -1789,8 +1790,38 @@ void SynEdit::doToggleComment()
|
||||||
doComment();
|
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)
|
void SynEdit::doMouseScroll(bool isDragging)
|
||||||
{
|
{
|
||||||
|
if (mDropped) {
|
||||||
|
mDropped=false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
QPoint iMousePos;
|
QPoint iMousePos;
|
||||||
DisplayCoord C;
|
DisplayCoord C;
|
||||||
int X, Y;
|
int X, Y;
|
||||||
|
@ -5643,6 +5674,9 @@ void SynEdit::ExecuteCommand(SynEditorCommand Command, QChar AChar, void *pData)
|
||||||
case SynEditorCommand::ecToggleComment:
|
case SynEditorCommand::ecToggleComment:
|
||||||
doToggleComment();
|
doToggleComment();
|
||||||
break;
|
break;
|
||||||
|
case SynEditorCommand::ecToggleBlockComment:
|
||||||
|
doToggleBlockComment();
|
||||||
|
break;
|
||||||
case SynEditorCommand::ecNormalSelect:
|
case SynEditorCommand::ecNormalSelect:
|
||||||
setSelectionMode(SynSelectionMode::smNormal);
|
setSelectionMode(SynSelectionMode::smNormal);
|
||||||
break;
|
break;
|
||||||
|
@ -6148,9 +6182,8 @@ void SynEdit::dropEvent(QDropEvent *event)
|
||||||
}
|
}
|
||||||
mUndoList->EndBlock();
|
mUndoList->EndBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
|
mDropped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::dragMoveEvent(QDragMoveEvent *event)
|
void SynEdit::dragMoveEvent(QDragMoveEvent *event)
|
||||||
|
|
|
@ -276,6 +276,7 @@ public:
|
||||||
virtual void tab() { commandProcessor(SynEditorCommand::ecTab);}
|
virtual void tab() { commandProcessor(SynEditorCommand::ecTab);}
|
||||||
virtual void shifttab() { commandProcessor(SynEditorCommand::ecShiftTab);}
|
virtual void shifttab() { commandProcessor(SynEditorCommand::ecShiftTab);}
|
||||||
virtual void toggleComment() { commandProcessor(SynEditorCommand::ecToggleComment);}
|
virtual void toggleComment() { commandProcessor(SynEditorCommand::ecToggleComment);}
|
||||||
|
virtual void toggleBlockComment() { commandProcessor(SynEditorCommand::ecToggleBlockComment);}
|
||||||
|
|
||||||
virtual void beginUpdate();
|
virtual void beginUpdate();
|
||||||
virtual void endUpdate();
|
virtual void endUpdate();
|
||||||
|
@ -589,6 +590,7 @@ private:
|
||||||
void doComment();
|
void doComment();
|
||||||
void doUncomment();
|
void doUncomment();
|
||||||
void doToggleComment();
|
void doToggleComment();
|
||||||
|
void doToggleBlockComment();
|
||||||
void doMouseScroll(bool isDragging);
|
void doMouseScroll(bool isDragging);
|
||||||
|
|
||||||
|
|
||||||
|
@ -729,7 +731,7 @@ private:
|
||||||
BufferCoord mDragCaretSave;
|
BufferCoord mDragCaretSave;
|
||||||
BufferCoord mDragSelBeginSave;
|
BufferCoord mDragSelBeginSave;
|
||||||
BufferCoord mDragSelEndSave;
|
BufferCoord mDragSelEndSave;
|
||||||
bool mDragging;
|
bool mDropped;
|
||||||
|
|
||||||
friend class SynEditTextPainter;
|
friend class SynEditTextPainter;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue