- fix: selection's position not correctly set after input a char / insert string (and causes error under OVERWRITE mode)
This commit is contained in:
parent
3ea32031af
commit
04e11dbc3b
1
NEWS.md
1
NEWS.md
|
@ -34,6 +34,7 @@ Red Panda C++ Version 2.0
|
||||||
- fix: Encoding info in the status bar not correctly updated when save a new file
|
- fix: Encoding info in the status bar not correctly updated when save a new file
|
||||||
- enhancement: auto sort TODO items
|
- enhancement: auto sort TODO items
|
||||||
- fix: Correctly set file's real encoding to ASCII after saving
|
- fix: Correctly set file's real encoding to ASCII after saving
|
||||||
|
- fix: selection's position not correctly set after input a char / insert string (and causes error under OVERWRITE mode)
|
||||||
|
|
||||||
Red Panda C++ Version 1.5
|
Red Panda C++ Version 1.5
|
||||||
|
|
||||||
|
|
|
@ -708,7 +708,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
|
||||||
if (mParser && mParser->isIncludeLine(lineText())
|
if (mParser && mParser->isIncludeLine(lineText())
|
||||||
&& mLastIdCharPressed==pSettings->codeCompletion().minCharRequired()) {
|
&& mLastIdCharPressed==pSettings->codeCompletion().minCharRequired()) {
|
||||||
// is a #include line
|
// is a #include line
|
||||||
setSelText(ch);
|
commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr);
|
||||||
showHeaderCompletion(false);
|
showHeaderCompletion(false);
|
||||||
handled=true;
|
handled=true;
|
||||||
return;
|
return;
|
||||||
|
@ -721,7 +721,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
|
||||||
lastWord == "signed" ||
|
lastWord == "signed" ||
|
||||||
lastWord == "unsigned"
|
lastWord == "unsigned"
|
||||||
) {
|
) {
|
||||||
setSelText(ch);
|
commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr);
|
||||||
showCompletion(lastWord,false);
|
showCompletion(lastWord,false);
|
||||||
handled=true;
|
handled=true;
|
||||||
return;
|
return;
|
||||||
|
@ -746,7 +746,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setSelText(ch);
|
commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr);
|
||||||
showCompletion("",false);
|
showCompletion("",false);
|
||||||
handled=true;
|
handled=true;
|
||||||
return;
|
return;
|
||||||
|
@ -758,7 +758,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
|
||||||
if (pSettings->codeCompletion().enabled()
|
if (pSettings->codeCompletion().enabled()
|
||||||
&& pSettings->codeCompletion().showCompletionWhileInput() ) {
|
&& pSettings->codeCompletion().showCompletionWhileInput() ) {
|
||||||
mLastIdCharPressed++;
|
mLastIdCharPressed++;
|
||||||
setSelText(ch);
|
commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr);
|
||||||
showCompletion("",false);
|
showCompletion("",false);
|
||||||
handled=true;
|
handled=true;
|
||||||
return;
|
return;
|
||||||
|
@ -770,7 +770,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
|
||||||
if (pSettings->codeCompletion().enabled()
|
if (pSettings->codeCompletion().enabled()
|
||||||
&& pSettings->codeCompletion().showCompletionWhileInput() ) {
|
&& pSettings->codeCompletion().showCompletionWhileInput() ) {
|
||||||
mLastIdCharPressed++;
|
mLastIdCharPressed++;
|
||||||
setSelText(ch);
|
commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr);
|
||||||
showCompletion("",false);
|
showCompletion("",false);
|
||||||
handled=true;
|
handled=true;
|
||||||
return;
|
return;
|
||||||
|
@ -1785,42 +1785,42 @@ bool Editor::notParsed()
|
||||||
|
|
||||||
void Editor::insertLine()
|
void Editor::insertLine()
|
||||||
{
|
{
|
||||||
ExecuteCommand(QSynedit::EditCommand::ecInsertLine,QChar(),nullptr);
|
commandProcessor(QSynedit::EditCommand::ecInsertLine,QChar(),nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::deleteWord()
|
void Editor::deleteWord()
|
||||||
{
|
{
|
||||||
ExecuteCommand(QSynedit::EditCommand::ecDeleteWord,QChar(),nullptr);
|
commandProcessor(QSynedit::EditCommand::ecDeleteWord,QChar(),nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::deleteToWordStart()
|
void Editor::deleteToWordStart()
|
||||||
{
|
{
|
||||||
ExecuteCommand(QSynedit::EditCommand::ecDeleteWordStart,QChar(),nullptr);
|
commandProcessor(QSynedit::EditCommand::ecDeleteWordStart,QChar(),nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::deleteToWordEnd()
|
void Editor::deleteToWordEnd()
|
||||||
{
|
{
|
||||||
ExecuteCommand(QSynedit::EditCommand::ecDeleteWordEnd,QChar(),nullptr);
|
commandProcessor(QSynedit::EditCommand::ecDeleteWordEnd,QChar(),nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::deleteLine()
|
void Editor::deleteLine()
|
||||||
{
|
{
|
||||||
ExecuteCommand(QSynedit::EditCommand::ecDeleteLine,QChar(),nullptr);
|
commandProcessor(QSynedit::EditCommand::ecDeleteLine,QChar(),nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::duplicateLine()
|
void Editor::duplicateLine()
|
||||||
{
|
{
|
||||||
ExecuteCommand(QSynedit::EditCommand::ecDuplicateLine,QChar(),nullptr);
|
commandProcessor(QSynedit::EditCommand::ecDuplicateLine,QChar(),nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::deleteToEOL()
|
void Editor::deleteToEOL()
|
||||||
{
|
{
|
||||||
ExecuteCommand(QSynedit::EditCommand::ecDeleteEOL,QChar(),nullptr);
|
commandProcessor(QSynedit::EditCommand::ecDeleteEOL,QChar(),nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::deleteToBOL()
|
void Editor::deleteToBOL()
|
||||||
{
|
{
|
||||||
ExecuteCommand(QSynedit::EditCommand::ecDeleteBOL,QChar(),nullptr);
|
commandProcessor(QSynedit::EditCommand::ecDeleteBOL,QChar(),nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Editor::getOwnerExpressionAndMemberAtPositionForCompletion(
|
QStringList Editor::getOwnerExpressionAndMemberAtPositionForCompletion(
|
||||||
|
@ -2524,17 +2524,17 @@ bool Editor::handleCodeCompletion(QChar key)
|
||||||
if (mParser) {
|
if (mParser) {
|
||||||
switch(key.unicode()) {
|
switch(key.unicode()) {
|
||||||
case '.':
|
case '.':
|
||||||
setSelText(key);
|
commandProcessor(QSynedit::EditCommand::ecChar, key);
|
||||||
showCompletion("",false);
|
showCompletion("",false);
|
||||||
return true;
|
return true;
|
||||||
case '>':
|
case '>':
|
||||||
setSelText(key);
|
commandProcessor(QSynedit::EditCommand::ecChar, key);
|
||||||
if ((caretX() > 2) && (lineText().length() >= 2) &&
|
if ((caretX() > 2) && (lineText().length() >= 2) &&
|
||||||
(lineText()[caretX() - 3] == '-'))
|
(lineText()[caretX() - 3] == '-'))
|
||||||
showCompletion("",false);
|
showCompletion("",false);
|
||||||
return true;
|
return true;
|
||||||
case ':':
|
case ':':
|
||||||
ExecuteCommand(QSynedit::EditCommand::ecChar,':',nullptr);
|
commandProcessor(QSynedit::EditCommand::ecChar,':',nullptr);
|
||||||
//setSelText(key);
|
//setSelText(key);
|
||||||
if ((caretX() > 2) && (lineText().length() >= 2) &&
|
if ((caretX() > 2) && (lineText().length() >= 2) &&
|
||||||
(lineText()[caretX() - 3] == ':'))
|
(lineText()[caretX() - 3] == ':'))
|
||||||
|
@ -2542,7 +2542,7 @@ bool Editor::handleCodeCompletion(QChar key)
|
||||||
return true;
|
return true;
|
||||||
case '/':
|
case '/':
|
||||||
case '\\':
|
case '\\':
|
||||||
setSelText(key);
|
commandProcessor(QSynedit::EditCommand::ecChar, key);
|
||||||
if (mParser->isIncludeLine(lineText())) {
|
if (mParser->isIncludeLine(lineText())) {
|
||||||
showHeaderCompletion(false);
|
showHeaderCompletion(false);
|
||||||
}
|
}
|
||||||
|
@ -3196,6 +3196,7 @@ void Editor::completionInsert(bool appendFunc)
|
||||||
&& (statement->command.startsWith('#')
|
&& (statement->command.startsWith('#')
|
||||||
|| statement->command.startsWith('@'))
|
|| statement->command.startsWith('@'))
|
||||||
) {
|
) {
|
||||||
|
|
||||||
setSelText(statement->command.mid(1));
|
setSelText(statement->command.mid(1));
|
||||||
} else
|
} else
|
||||||
setSelText(statement->command + funcAddOn);
|
setSelText(statement->command + funcAddOn);
|
||||||
|
@ -3282,7 +3283,7 @@ bool Editor::onCompletionKeyPressed(QKeyEvent *event)
|
||||||
//ignore it
|
//ignore it
|
||||||
return true;
|
return true;
|
||||||
case Qt::Key_Backspace:
|
case Qt::Key_Backspace:
|
||||||
ExecuteCommand(
|
commandProcessor(
|
||||||
QSynedit::EditCommand::ecDeleteLastChar,
|
QSynedit::EditCommand::ecDeleteLastChar,
|
||||||
QChar(), nullptr); // Simulate backspace in editor
|
QChar(), nullptr); // Simulate backspace in editor
|
||||||
if (purpose == WordPurpose::wpCompletion) {
|
if (purpose == WordPurpose::wpCompletion) {
|
||||||
|
@ -3316,7 +3317,7 @@ bool Editor::onCompletionKeyPressed(QKeyEvent *event)
|
||||||
}
|
}
|
||||||
QChar ch = event->text().front();
|
QChar ch = event->text().front();
|
||||||
if (isIdentChar(ch)) {
|
if (isIdentChar(ch)) {
|
||||||
setSelText(ch);
|
commandProcessor(QSynedit::EditCommand::ecChar, ch);
|
||||||
if (purpose == WordPurpose::wpCompletion) {
|
if (purpose == WordPurpose::wpCompletion) {
|
||||||
phrase = getWordForCompletionSearch(caretXY(),mCompletionPopup->memberOperator()=="::");
|
phrase = getWordForCompletionSearch(caretXY(),mCompletionPopup->memberOperator()=="::");
|
||||||
} else
|
} else
|
||||||
|
@ -3344,7 +3345,7 @@ bool Editor::onHeaderCompletionKeyPressed(QKeyEvent *event)
|
||||||
QSynedit::BufferCoord pBeginPos,pEndPos;
|
QSynedit::BufferCoord pBeginPos,pEndPos;
|
||||||
switch (event->key()) {
|
switch (event->key()) {
|
||||||
case Qt::Key_Backspace:
|
case Qt::Key_Backspace:
|
||||||
ExecuteCommand(
|
commandProcessor(
|
||||||
QSynedit::EditCommand::ecDeleteLastChar,
|
QSynedit::EditCommand::ecDeleteLastChar,
|
||||||
QChar(), nullptr); // Simulate backspace in editor
|
QChar(), nullptr); // Simulate backspace in editor
|
||||||
phrase = getWordAtPosition(this,caretXY(),
|
phrase = getWordAtPosition(this,caretXY(),
|
||||||
|
@ -3376,7 +3377,8 @@ bool Editor::onHeaderCompletionKeyPressed(QKeyEvent *event)
|
||||||
|
|
||||||
if (isIdentChar(ch) || ch == '.'
|
if (isIdentChar(ch) || ch == '.'
|
||||||
|| ch =='_' || ch=='+') {
|
|| ch =='_' || ch=='+') {
|
||||||
setSelText(ch);
|
commandProcessor(QSynedit::EditCommand::ecChar, ch);
|
||||||
|
|
||||||
phrase = getWordAtPosition(this,caretXY(),
|
phrase = getWordAtPosition(this,caretXY(),
|
||||||
pBeginPos,pEndPos,
|
pBeginPos,pEndPos,
|
||||||
WordPurpose::wpHeaderCompletion);
|
WordPurpose::wpHeaderCompletion);
|
||||||
|
|
|
@ -4887,7 +4887,7 @@ void SynEdit::commandProcessor(EditCommand Command, QChar AChar, void *pData)
|
||||||
// first the program event handler gets a chance to process the command
|
// first the program event handler gets a chance to process the command
|
||||||
onProcessCommand(Command, AChar, pData);
|
onProcessCommand(Command, AChar, pData);
|
||||||
if (Command != EditCommand::ecNone)
|
if (Command != EditCommand::ecNone)
|
||||||
ExecuteCommand(Command, AChar, pData);
|
executeCommand(Command, AChar, pData);
|
||||||
onCommandProcessed(Command, AChar, pData);
|
onCommandProcessed(Command, AChar, pData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5469,6 +5469,7 @@ void SynEdit::doInsertText(const BufferCoord& pos,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
internalSetCaretXY(newPos);
|
internalSetCaretXY(newPos);
|
||||||
|
setBlockBegin(newPos);
|
||||||
ensureCursorPosVisible();
|
ensureCursorPosVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5721,7 +5722,7 @@ void SynEdit::onCommandProcessed(EditCommand , QChar , void *)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::ExecuteCommand(EditCommand Command, QChar AChar, void *pData)
|
void SynEdit::executeCommand(EditCommand Command, QChar AChar, void *pData)
|
||||||
{
|
{
|
||||||
hideCaret();
|
hideCaret();
|
||||||
incPaintLock();
|
incPaintLock();
|
||||||
|
|
|
@ -468,7 +468,7 @@ protected:
|
||||||
FontStyles& style, QColor& foreground, QColor& background);
|
FontStyles& style, QColor& foreground, QColor& background);
|
||||||
virtual void onProcessCommand(EditCommand Command, QChar AChar, void * pData);
|
virtual void onProcessCommand(EditCommand Command, QChar AChar, void * pData);
|
||||||
virtual void onCommandProcessed(EditCommand Command, QChar AChar, void * pData);
|
virtual void onCommandProcessed(EditCommand Command, QChar AChar, void * pData);
|
||||||
virtual void ExecuteCommand(EditCommand Command, QChar AChar, void * pData);
|
virtual void executeCommand(EditCommand Command, QChar AChar, void * pData);
|
||||||
virtual void onEndFirstPaintLock();
|
virtual void onEndFirstPaintLock();
|
||||||
virtual void onBeginFirstPaintLock();
|
virtual void onBeginFirstPaintLock();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue