- enhacement: alt+shift+arrow do column selection
This commit is contained in:
parent
96631049eb
commit
c979ef1505
1
NEWS.md
1
NEWS.md
|
@ -18,6 +18,7 @@ Red Panda C++ Version 1.0.1
|
|||
- enhancement: switch capslock won't cancel code completion
|
||||
- enhancement: double click on item in code completion list will use it to complete
|
||||
- fix: goto declaration by ctrl+click will incorrectly select contents
|
||||
- enhacement: alt+shift+arrow do column selection
|
||||
|
||||
Red Panda C++ Version 1.0.0
|
||||
- fix: calculation for code snippets's tab stop positions is not correct
|
||||
|
|
|
@ -181,19 +181,23 @@ void SynEditKeyStrokes::resetDefaults()
|
|||
clear();
|
||||
add(SynEditorCommand::ecUp, Qt::Key_Up, Qt::NoModifier);
|
||||
add(SynEditorCommand::ecSelUp, Qt::Key_Up, Qt::ShiftModifier);
|
||||
add(SynEditorCommand::ecSelUp, Qt::Key_Up, Qt::ShiftModifier | Qt::AltModifier);
|
||||
add(SynEditorCommand::ecScrollUp, Qt::Key_Up, Qt::ControlModifier);
|
||||
add(SynEditorCommand::ecDown, Qt::Key_Down, Qt::NoModifier);
|
||||
add(SynEditorCommand::ecSelDown, Qt::Key_Down, Qt::ShiftModifier);
|
||||
add(SynEditorCommand::ecSelDown, Qt::Key_Down, Qt::ShiftModifier | Qt::AltModifier);
|
||||
add(SynEditorCommand::ecScrollDown, Qt::Key_Down, Qt::ControlModifier);
|
||||
add(SynEditorCommand::ecLeft, Qt::Key_Left, Qt::NoModifier);
|
||||
add(SynEditorCommand::ecSelLeft, Qt::Key_Left, Qt::ShiftModifier);
|
||||
add(SynEditorCommand::ecSelLeft, Qt::Key_Left, Qt::ShiftModifier | Qt::AltModifier);
|
||||
add(SynEditorCommand::ecWordLeft, Qt::Key_Left, Qt::ControlModifier);
|
||||
add(SynEditorCommand::ecSelWordLeft, Qt::Key_Left, Qt::ShiftModifier|Qt::ControlModifier);
|
||||
add(SynEditorCommand::ecRight, Qt::Key_Right, Qt::NoModifier);
|
||||
|
||||
add(SynEditorCommand::ecSelRight, Qt::Key_Right, Qt::ShiftModifier);
|
||||
add(SynEditorCommand::ecSelRight, Qt::Key_Right, Qt::ShiftModifier | Qt::AltModifier);
|
||||
add(SynEditorCommand::ecWordRight, Qt::Key_Right, Qt::ControlModifier);
|
||||
add(SynEditorCommand::ecSelWordRight, Qt::Key_Right, Qt::ShiftModifier|Qt::ControlModifier);
|
||||
|
||||
add(SynEditorCommand::ecPageDown, Qt::Key_PageDown, Qt::NoModifier);
|
||||
add(SynEditorCommand::ecSelPageDown, Qt::Key_PageDown, Qt::ShiftModifier);
|
||||
add(SynEditorCommand::ecPageBottom, Qt::Key_PageDown, Qt::ControlModifier);
|
||||
|
|
|
@ -87,10 +87,10 @@ enum class SynEditorCommand {
|
|||
ecSelEditorEnd = ecEditorEnd + ecSelection,
|
||||
ecSelGotoXY = ecGotoXY + ecSelection, // Data = PPoint
|
||||
|
||||
ecSelWord = 198,
|
||||
ecSelectAll = 199, // Select entire contents of editor, cursor to end
|
||||
|
||||
ecCopy = 201, // Copy selection to clipboard
|
||||
ecSelWord = 202,
|
||||
ecSelectAll = 203, // Select entire contents of editor, cursor to end
|
||||
|
||||
ecScrollUp = 211, // Scroll up one line leaving cursor position unchanged.
|
||||
ecScrollDown = 212, // Scroll down one line leaving cursor position unchanged.
|
||||
|
@ -176,14 +176,16 @@ enum class SynEditorCommand {
|
|||
ecZoomOut = 631, //Increase Font Size
|
||||
ecZoomIn = 632, //Decrease Font Size
|
||||
|
||||
ecUserFirst = 1001, // Start of user-defined commands
|
||||
|
||||
ecAutoCompletion = 650,
|
||||
ecLineBreakAtBegin = 651, //add a line break at the begin of the line
|
||||
ecLineBreakAtEnd = 652,
|
||||
ecInsertLineAtBegin = 653,
|
||||
ecInsertLineAtEnd = 654,
|
||||
|
||||
ecUserFirst = 1001, // Start of user-defined commands
|
||||
|
||||
|
||||
|
||||
//### Code Folding ###
|
||||
ecCollapse = ecUserFirst + 100,
|
||||
ecUncollapse = ecUserFirst + 101,
|
||||
|
|
|
@ -235,6 +235,7 @@ void SynEdit::setCaretXYEx(bool CallEnsureCursorPosVisible, BufferCoord value)
|
|||
int nMaxX;
|
||||
if (value.Line > mLines->count())
|
||||
value.Line = mLines->count();
|
||||
if (mActiveSelectionMode!=SynSelectionMode::smColumn) {
|
||||
if (value.Line < 1) {
|
||||
// this is just to make sure if Lines stringlist should be empty
|
||||
value.Line = 1;
|
||||
|
@ -247,6 +248,7 @@ void SynEdit::setCaretXYEx(bool CallEnsureCursorPosVisible, BufferCoord value)
|
|||
nMaxX = mLines->getString(value.Line-1).length()+1;
|
||||
}
|
||||
value.Char = std::min(value.Char,nMaxX);
|
||||
}
|
||||
value.Char = std::max(value.Char,1);
|
||||
// if ((value.Char > nMaxX) && (! (mOptions.testFlag(SynEditorOption::eoScrollPastEol)) ) )
|
||||
// value.Char = nMaxX;
|
||||
|
@ -1824,6 +1826,8 @@ void SynEdit::doMouseScroll(bool isDragging)
|
|||
mDropped=false;
|
||||
return;
|
||||
}
|
||||
if (!hasFocus())
|
||||
return;
|
||||
Qt::MouseButtons buttons = qApp->mouseButtons();
|
||||
if (!buttons.testFlag(Qt::LeftButton))
|
||||
return;
|
||||
|
@ -4742,7 +4746,16 @@ void SynEdit::moveCaretHorz(int DX, bool isSelection)
|
|||
ptDst.Char = std::min(ptDst.Char, nLineLen + 1);
|
||||
}
|
||||
// set caret and block begin / end
|
||||
incPaintLock();
|
||||
if (mOptions.testFlag(eoAltSetsColumnMode) &&
|
||||
(mActiveSelectionMode != SynSelectionMode::smLine)) {
|
||||
if (qApp->keyboardModifiers().testFlag(Qt::AltModifier)) {
|
||||
setActiveSelectionMode(SynSelectionMode::smColumn);
|
||||
} else
|
||||
setActiveSelectionMode(selectionMode());
|
||||
}
|
||||
moveCaretAndSelection(mBlockBegin, ptDst, isSelection);
|
||||
decPaintLock();
|
||||
}
|
||||
|
||||
void SynEdit::moveCaretVert(int DY, bool isSelection)
|
||||
|
@ -4768,6 +4781,13 @@ void SynEdit::moveCaretVert(int DY, bool isSelection)
|
|||
|
||||
// set caret and block begin / end
|
||||
incPaintLock();
|
||||
if (mOptions.testFlag(eoAltSetsColumnMode) &&
|
||||
(mActiveSelectionMode != SynSelectionMode::smLine)) {
|
||||
if (qApp->keyboardModifiers().testFlag(Qt::AltModifier))
|
||||
setActiveSelectionMode(SynSelectionMode::smColumn);
|
||||
else
|
||||
setSelectionMode(selectionMode());
|
||||
}
|
||||
moveCaretAndSelection(mBlockBegin, vDstLineChar, isSelection);
|
||||
decPaintLock();
|
||||
|
||||
|
@ -4784,6 +4804,7 @@ void SynEdit::moveCaretAndSelection(const BufferCoord &ptBefore, const BufferCoo
|
|||
|
||||
incPaintLock();
|
||||
if (isSelection) {
|
||||
|
||||
if (!selAvail())
|
||||
setBlockBegin(ptBefore);
|
||||
setBlockEnd(ptAfter);
|
||||
|
@ -6007,9 +6028,9 @@ void SynEdit::mousePressEvent(QMouseEvent *event)
|
|||
} else if (mOptions.testFlag(eoAltSetsColumnMode) &&
|
||||
(mActiveSelectionMode != SynSelectionMode::smLine)) {
|
||||
if (event->modifiers() == Qt::AltModifier)
|
||||
setSelectionMode(SynSelectionMode::smColumn);
|
||||
setActiveSelectionMode(SynSelectionMode::smColumn);
|
||||
else
|
||||
setSelectionMode(SynSelectionMode::smNormal);
|
||||
setActiveSelectionMode(selectionMode());
|
||||
//Selection mode must be set before calling SetBlockBegin
|
||||
setBlockBegin(caretXY());
|
||||
}
|
||||
|
@ -6065,10 +6086,13 @@ void SynEdit::mouseMoveEvent(QMouseEvent *event)
|
|||
//BeginDrag(false);
|
||||
}
|
||||
} else if ((buttons == Qt::LeftButton)) {
|
||||
if (mOptions.testFlag(eoAltSetsColumnMode) &&
|
||||
(mActiveSelectionMode != SynSelectionMode::smLine)) {
|
||||
if (event->modifiers() == Qt::AltModifier)
|
||||
setSelectionMode(SynSelectionMode::smColumn);
|
||||
setActiveSelectionMode(SynSelectionMode::smColumn);
|
||||
else
|
||||
setSelectionMode(SynSelectionMode::smNormal);
|
||||
setActiveSelectionMode(selectionMode());
|
||||
}
|
||||
// should we begin scrolling?
|
||||
//computeScroll(X, Y,false);
|
||||
// DisplayCoord P = pixelsToNearestRowColumn(X, Y);
|
||||
|
@ -6460,7 +6484,7 @@ BufferCoord SynEdit::blockEnd() const
|
|||
|
||||
void SynEdit::setBlockEnd(BufferCoord Value)
|
||||
{
|
||||
setActiveSelectionMode(mSelectionMode);
|
||||
//setActiveSelectionMode(mSelectionMode);
|
||||
if (!mOptions.testFlag(eoNoSelection)) {
|
||||
Value.Line = minMax(Value.Line, 1, mLines->count());
|
||||
Value.Char = minMax(Value.Char, 1, mLines->lengthOfLongestLine()+1);
|
||||
|
@ -6555,7 +6579,7 @@ void SynEdit::setBlockBegin(BufferCoord value)
|
|||
{
|
||||
int nInval1, nInval2;
|
||||
bool SelChanged;
|
||||
setActiveSelectionMode(mSelectionMode);
|
||||
//setActiveSelectionMode(mSelectionMode);
|
||||
value.Char = minMax(value.Char, 1, mLines->lengthOfLongestLine()+1);
|
||||
value.Line = minMax(value.Line, 1, mLines->count());
|
||||
if (mActiveSelectionMode == SynSelectionMode::smNormal) {
|
||||
|
|
|
@ -252,7 +252,7 @@ void SynEditTextPainter::ComputeSelectionInfo()
|
|||
vEnd = edit->mBlockBegin;
|
||||
vStart = edit->mBlockEnd;
|
||||
} else if (edit->mBlockBegin.Char != edit->mBlockEnd.Char) {
|
||||
// No selection at all, or it is only on this line.
|
||||
// it is only on this line.
|
||||
vStart.Line = edit->mBlockBegin.Line;
|
||||
vEnd.Line = vStart.Line;
|
||||
if (edit->mBlockBegin.Char < edit->mBlockEnd.Char) {
|
||||
|
@ -1058,6 +1058,12 @@ void SynEditTextPainter::PaintLines()
|
|||
PaintEditAreas(areaList);
|
||||
}
|
||||
|
||||
if (nLineSelStart!=0 && nLineSelEnd!=0
|
||||
&& nLineSelStart == nLineSelEnd) {
|
||||
painter->setPen(edit->selectedBackground());
|
||||
int x =ColumnToXValue(nLineSelStart);
|
||||
painter->drawLine(x,rcLine.top(),x,rcLine.bottom()+1);
|
||||
}
|
||||
// Now paint the right edge if necessary. We do it line by line to reduce
|
||||
// the flicker. Should not cost very much anyway, compared to the many
|
||||
// calls to ExtTextOut.
|
||||
|
|
Loading…
Reference in New Issue