- enhancement: "Remove trailing spaces" in options / editor / misc
- enhancement: show special chars
This commit is contained in:
parent
4985191120
commit
16db14e761
1
NEWS.md
1
NEWS.md
|
@ -2,6 +2,7 @@ Red Panda C++ Version 2.7
|
|||
|
||||
- enhancement: Remove multiple problems in the problem set view
|
||||
- enhancement: Clear the proble view after a new problem set created
|
||||
- enhancement: "Remove trailing spaces" in options / editor / misc
|
||||
|
||||
Red Panda C++ Version 2.6
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ isEmpty(APP_NAME) {
|
|||
}
|
||||
|
||||
isEmpty(APP_VERSION) {
|
||||
APP_VERSION = 2.6
|
||||
APP_VERSION = 2.7
|
||||
}
|
||||
|
||||
macos: {
|
||||
|
|
|
@ -265,6 +265,8 @@ bool Editor::save(bool force, bool doReparse) {
|
|||
try {
|
||||
if (pSettings->editor().autoFormatWhenSaved()) {
|
||||
reformat(false);
|
||||
} else if (pSettings->editor().removeTrailingSpacesWhenSaved()) {
|
||||
trimTrailingSpaces();
|
||||
}
|
||||
saveFile(mFilename);
|
||||
pMainWindow->fileSystemWatcher()->addPath(mFilename);
|
||||
|
@ -356,6 +358,8 @@ bool Editor::saveAs(const QString &name, bool fromProject){
|
|||
|
||||
if (pSettings->editor().autoFormatWhenSaved()) {
|
||||
reformat(false);
|
||||
} else if (pSettings->editor().removeTrailingSpacesWhenSaved()) {
|
||||
trimTrailingSpaces();
|
||||
}
|
||||
try {
|
||||
mFilename = newName;
|
||||
|
@ -521,7 +525,7 @@ void Editor::undoSymbolCompletion(int pos)
|
|||
(pSettings->editor().completeBrace() && (DeletedChar == '{') && (NextChar == '}')) ||
|
||||
(pSettings->editor().completeSingleQuote() && (DeletedChar == '\'') && (NextChar == '\'')) ||
|
||||
(pSettings->editor().completeDoubleQuote() && (DeletedChar == '\"') && (NextChar == '\"'))) {
|
||||
commandProcessor(QSynedit::EditCommand::ecDeleteChar);
|
||||
processCommand(QSynedit::EditCommand::DeleteChar);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -723,7 +727,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
|
|||
if (mParser && mParser->isIncludeLine(lineText())
|
||||
&& mLastIdCharPressed==pSettings->codeCompletion().minCharRequired()) {
|
||||
// is a #include line
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr);
|
||||
processCommand(QSynedit::EditCommand::Char,ch,nullptr);
|
||||
showHeaderCompletion(false);
|
||||
handled=true;
|
||||
return;
|
||||
|
@ -731,12 +735,12 @@ void Editor::keyPressEvent(QKeyEvent *event)
|
|||
QString lastWord = getPreviousWordAtPositionForSuggestion(caretXY());
|
||||
if (mParser && !lastWord.isEmpty()) {
|
||||
if (lastWord == "using") {
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr);
|
||||
processCommand(QSynedit::EditCommand::Char,ch,nullptr);
|
||||
showCompletion(lastWord,false, CodeCompletionType::ComplexKeyword);
|
||||
handled=true;
|
||||
return;
|
||||
} else if (lastWord == "namespace") {
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr);
|
||||
processCommand(QSynedit::EditCommand::Char,ch,nullptr);
|
||||
showCompletion(lastWord,false, CodeCompletionType::Namespaces);
|
||||
handled=true;
|
||||
return;
|
||||
|
@ -747,7 +751,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
|
|||
}
|
||||
if (!currentScope || currentScope->kind == StatementKind::skNamespace) {
|
||||
//may define a function
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr);
|
||||
processCommand(QSynedit::EditCommand::Char,ch,nullptr);
|
||||
showCompletion(lastWord,false,CodeCompletionType::FunctionWithoutDefinition);
|
||||
handled=true;
|
||||
return;
|
||||
|
@ -757,7 +761,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
|
|||
lastWord == "signed" ||
|
||||
lastWord == "unsigned"
|
||||
) {
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr);
|
||||
processCommand(QSynedit::EditCommand::Char,ch,nullptr);
|
||||
showCompletion(lastWord,false, CodeCompletionType::ComplexKeyword);
|
||||
handled=true;
|
||||
return;
|
||||
|
@ -783,7 +787,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
|
|||
}
|
||||
if (!currentScope || currentScope->kind == StatementKind::skNamespace) {
|
||||
//may define a function
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr);
|
||||
processCommand(QSynedit::EditCommand::Char,ch,nullptr);
|
||||
showCompletion("",false,CodeCompletionType::FunctionWithoutDefinition);
|
||||
handled=true;
|
||||
return;
|
||||
|
@ -801,13 +805,13 @@ void Editor::keyPressEvent(QKeyEvent *event)
|
|||
}
|
||||
if (!currentScope || currentScope->kind == StatementKind::skNamespace) {
|
||||
//may define a function
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr);
|
||||
processCommand(QSynedit::EditCommand::Char,ch,nullptr);
|
||||
showCompletion("",false,CodeCompletionType::FunctionWithoutDefinition);
|
||||
handled=true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr);
|
||||
processCommand(QSynedit::EditCommand::Char,ch,nullptr);
|
||||
showCompletion("",false,CodeCompletionType::Normal);
|
||||
handled=true;
|
||||
return;
|
||||
|
@ -819,7 +823,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
|
|||
if (pSettings->codeCompletion().enabled()
|
||||
&& pSettings->codeCompletion().showCompletionWhileInput() ) {
|
||||
mLastIdCharPressed++;
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr);
|
||||
processCommand(QSynedit::EditCommand::Char,ch,nullptr);
|
||||
showCompletion("",false,CodeCompletionType::Normal);
|
||||
handled=true;
|
||||
return;
|
||||
|
@ -831,7 +835,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
|
|||
if (pSettings->codeCompletion().enabled()
|
||||
&& pSettings->codeCompletion().showCompletionWhileInput() ) {
|
||||
mLastIdCharPressed++;
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr);
|
||||
processCommand(QSynedit::EditCommand::Char,ch,nullptr);
|
||||
showCompletion("",false,CodeCompletionType::Normal);
|
||||
handled=true;
|
||||
return;
|
||||
|
@ -1877,52 +1881,52 @@ bool Editor::notParsed()
|
|||
|
||||
void Editor::insertLine()
|
||||
{
|
||||
commandProcessor(QSynedit::EditCommand::ecInsertLine,QChar(),nullptr);
|
||||
processCommand(QSynedit::EditCommand::InsertLine,QChar(),nullptr);
|
||||
}
|
||||
|
||||
void Editor::deleteWord()
|
||||
{
|
||||
commandProcessor(QSynedit::EditCommand::ecDeleteWord,QChar(),nullptr);
|
||||
processCommand(QSynedit::EditCommand::DeleteWord,QChar(),nullptr);
|
||||
}
|
||||
|
||||
void Editor::deleteToWordStart()
|
||||
{
|
||||
commandProcessor(QSynedit::EditCommand::ecDeleteWordStart,QChar(),nullptr);
|
||||
processCommand(QSynedit::EditCommand::DeleteWordStart,QChar(),nullptr);
|
||||
}
|
||||
|
||||
void Editor::deleteToWordEnd()
|
||||
{
|
||||
commandProcessor(QSynedit::EditCommand::ecDeleteWordEnd,QChar(),nullptr);
|
||||
processCommand(QSynedit::EditCommand::DeleteWordEnd,QChar(),nullptr);
|
||||
}
|
||||
|
||||
void Editor::deleteLine()
|
||||
{
|
||||
commandProcessor(QSynedit::EditCommand::ecDeleteLine,QChar(),nullptr);
|
||||
processCommand(QSynedit::EditCommand::DeleteLine,QChar(),nullptr);
|
||||
}
|
||||
|
||||
void Editor::duplicateLine()
|
||||
{
|
||||
commandProcessor(QSynedit::EditCommand::ecDuplicateLine,QChar(),nullptr);
|
||||
processCommand(QSynedit::EditCommand::DuplicateLine,QChar(),nullptr);
|
||||
}
|
||||
|
||||
void Editor::deleteToEOL()
|
||||
{
|
||||
commandProcessor(QSynedit::EditCommand::ecDeleteEOL,QChar(),nullptr);
|
||||
processCommand(QSynedit::EditCommand::DeleteEOL,QChar(),nullptr);
|
||||
}
|
||||
|
||||
void Editor::deleteToBOL()
|
||||
{
|
||||
commandProcessor(QSynedit::EditCommand::ecDeleteBOL,QChar(),nullptr);
|
||||
processCommand(QSynedit::EditCommand::DeleteBOL,QChar(),nullptr);
|
||||
}
|
||||
|
||||
void Editor::gotoBlockStart()
|
||||
{
|
||||
commandProcessor(QSynedit::EditCommand::ecBlockStart,QChar(),nullptr);
|
||||
processCommand(QSynedit::EditCommand::BlockStart,QChar(),nullptr);
|
||||
}
|
||||
|
||||
void Editor::gotoBlockEnd()
|
||||
{
|
||||
commandProcessor(QSynedit::EditCommand::ecBlockEnd,QChar(),nullptr);
|
||||
processCommand(QSynedit::EditCommand::BlockEnd,QChar(),nullptr);
|
||||
}
|
||||
|
||||
QStringList Editor::getOwnerExpressionAndMemberAtPositionForCompletion(
|
||||
|
@ -2302,17 +2306,17 @@ bool Editor::handleParentheseCompletion()
|
|||
QString text=selText();
|
||||
beginUpdate();
|
||||
beginUndoBlock();
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,'(');
|
||||
processCommand(QSynedit::EditCommand::Char,'(');
|
||||
setSelText(text);
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,')');
|
||||
processCommand(QSynedit::EditCommand::Char,')');
|
||||
endUndoBlock();
|
||||
endUpdate();
|
||||
} else {
|
||||
beginUpdate();
|
||||
beginUndoBlock();
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,'(');
|
||||
processCommand(QSynedit::EditCommand::Char,'(');
|
||||
QSynedit::BufferCoord oldCaret = caretXY();
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,')');
|
||||
processCommand(QSynedit::EditCommand::Char,')');
|
||||
setCaretXY(oldCaret);
|
||||
endUndoBlock();
|
||||
endUpdate();
|
||||
|
@ -2363,17 +2367,17 @@ bool Editor::handleBracketCompletion()
|
|||
QString text=selText();
|
||||
beginUpdate();
|
||||
beginUndoBlock();
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,'[');
|
||||
processCommand(QSynedit::EditCommand::Char,'[');
|
||||
setSelText(text);
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,']');
|
||||
processCommand(QSynedit::EditCommand::Char,']');
|
||||
endUndoBlock();
|
||||
endUpdate();
|
||||
} else {
|
||||
beginUpdate();
|
||||
beginUndoBlock();
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,'[');
|
||||
processCommand(QSynedit::EditCommand::Char,'[');
|
||||
QSynedit::BufferCoord oldCaret = caretXY();
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,']');
|
||||
processCommand(QSynedit::EditCommand::Char,']');
|
||||
setCaretXY(oldCaret);
|
||||
endUndoBlock();
|
||||
endUpdate();
|
||||
|
@ -2411,14 +2415,14 @@ bool Editor::handleMultilineCommentCompletion()
|
|||
QString text=selText();
|
||||
beginUpdate();
|
||||
beginUndoBlock();
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,'*');
|
||||
processCommand(QSynedit::EditCommand::Char,'*');
|
||||
QSynedit::BufferCoord oldCaret;
|
||||
if (text.isEmpty())
|
||||
oldCaret = caretXY();
|
||||
else
|
||||
setSelText(text);
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,'*');
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,'/');
|
||||
processCommand(QSynedit::EditCommand::Char,'*');
|
||||
processCommand(QSynedit::EditCommand::Char,'/');
|
||||
if (text.isEmpty())
|
||||
setCaretXY(oldCaret);
|
||||
endUndoBlock();
|
||||
|
@ -2439,16 +2443,16 @@ bool Editor::handleBraceCompletion()
|
|||
QString text=selText();
|
||||
beginUpdate();
|
||||
beginUndoBlock();
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,'{');
|
||||
processCommand(QSynedit::EditCommand::Char,'{');
|
||||
QSynedit::BufferCoord oldCaret;
|
||||
if (text.isEmpty()) {
|
||||
oldCaret = caretXY();
|
||||
} else {
|
||||
commandProcessor(QSynedit::EditCommand::ecInsertLine);
|
||||
processCommand(QSynedit::EditCommand::InsertLine);
|
||||
setSelText(text);
|
||||
commandProcessor(QSynedit::EditCommand::ecInsertLine);
|
||||
processCommand(QSynedit::EditCommand::InsertLine);
|
||||
}
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,'}');
|
||||
processCommand(QSynedit::EditCommand::Char,'}');
|
||||
if (
|
||||
( (s.startsWith("struct")
|
||||
|| s.startsWith("class")
|
||||
|
@ -2459,7 +2463,7 @@ bool Editor::handleBraceCompletion()
|
|||
|| s.startsWith("enum") )
|
||||
&& !s.contains(';')
|
||||
) || s.endsWith('=')) {
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,';');
|
||||
processCommand(QSynedit::EditCommand::Char,';');
|
||||
}
|
||||
if (text.isEmpty())
|
||||
setCaretXY(oldCaret);
|
||||
|
@ -2481,7 +2485,7 @@ bool Editor::handleBraceSkip()
|
|||
if (lastLineState.braceLevel==0) {
|
||||
bool oldInsertMode = insertMode();
|
||||
setInsertMode(false); //set mode to overwrite
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,'}');
|
||||
processCommand(QSynedit::EditCommand::Char,'}');
|
||||
setInsertMode(oldInsertMode);
|
||||
return true;
|
||||
}
|
||||
|
@ -2490,7 +2494,7 @@ bool Editor::handleBraceSkip()
|
|||
if (pos.line != 0) {
|
||||
bool oldInsertMode = insertMode();
|
||||
setInsertMode(false); //set mode to overwrite
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,'}');
|
||||
processCommand(QSynedit::EditCommand::Char,'}');
|
||||
setInsertMode(oldInsertMode);
|
||||
return true;
|
||||
}
|
||||
|
@ -2513,9 +2517,9 @@ bool Editor::handleSingleQuoteCompletion()
|
|||
QString text=selText();
|
||||
beginUpdate();
|
||||
beginUndoBlock();
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,'\'');
|
||||
processCommand(QSynedit::EditCommand::Char,'\'');
|
||||
setSelText(text);
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,'\'');
|
||||
processCommand(QSynedit::EditCommand::Char,'\'');
|
||||
endUndoBlock();
|
||||
endUpdate();
|
||||
return true;
|
||||
|
@ -2524,9 +2528,9 @@ bool Editor::handleSingleQuoteCompletion()
|
|||
// insert ''
|
||||
beginUpdate();
|
||||
beginUndoBlock();
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,'\'');
|
||||
processCommand(QSynedit::EditCommand::Char,'\'');
|
||||
QSynedit::BufferCoord oldCaret = caretXY();
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,'\'');
|
||||
processCommand(QSynedit::EditCommand::Char,'\'');
|
||||
setCaretXY(oldCaret);
|
||||
endUndoBlock();
|
||||
endUpdate();
|
||||
|
@ -2553,9 +2557,9 @@ bool Editor::handleDoubleQuoteCompletion()
|
|||
QString text=selText();
|
||||
beginUpdate();
|
||||
beginUndoBlock();
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,'"');
|
||||
processCommand(QSynedit::EditCommand::Char,'"');
|
||||
setSelText(text);
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,'"');
|
||||
processCommand(QSynedit::EditCommand::Char,'"');
|
||||
endUndoBlock();
|
||||
endUpdate();
|
||||
return true;
|
||||
|
@ -2564,9 +2568,9 @@ bool Editor::handleDoubleQuoteCompletion()
|
|||
// insert ""
|
||||
beginUpdate();
|
||||
beginUndoBlock();
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,'"');
|
||||
processCommand(QSynedit::EditCommand::Char,'"');
|
||||
QSynedit::BufferCoord oldCaret = caretXY();
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,'"');
|
||||
processCommand(QSynedit::EditCommand::Char,'"');
|
||||
setCaretXY(oldCaret);
|
||||
endUndoBlock();
|
||||
endUpdate();
|
||||
|
@ -2586,9 +2590,9 @@ bool Editor::handleGlobalIncludeCompletion()
|
|||
return false;
|
||||
beginUpdate();
|
||||
beginUndoBlock();
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,'<');
|
||||
processCommand(QSynedit::EditCommand::Char,'<');
|
||||
QSynedit::BufferCoord oldCaret = caretXY();
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,'>');
|
||||
processCommand(QSynedit::EditCommand::Char,'>');
|
||||
setCaretXY(oldCaret);
|
||||
endUpdate();
|
||||
endUndoBlock();
|
||||
|
@ -2617,17 +2621,17 @@ bool Editor::handleCodeCompletion(QChar key)
|
|||
if (mParser) {
|
||||
switch(key.unicode()) {
|
||||
case '.':
|
||||
commandProcessor(QSynedit::EditCommand::ecChar, key);
|
||||
processCommand(QSynedit::EditCommand::Char, key);
|
||||
showCompletion("",false,CodeCompletionType::Normal);
|
||||
return true;
|
||||
case '>':
|
||||
commandProcessor(QSynedit::EditCommand::ecChar, key);
|
||||
processCommand(QSynedit::EditCommand::Char, key);
|
||||
if ((caretX() > 2) && (lineText().length() >= 2) &&
|
||||
(lineText()[caretX() - 3] == '-'))
|
||||
showCompletion("",false,CodeCompletionType::Normal);
|
||||
return true;
|
||||
case ':':
|
||||
commandProcessor(QSynedit::EditCommand::ecChar,':',nullptr);
|
||||
processCommand(QSynedit::EditCommand::Char,':',nullptr);
|
||||
//setSelText(key);
|
||||
if ((caretX() > 2) && (lineText().length() >= 2) &&
|
||||
(lineText()[caretX() - 3] == ':'))
|
||||
|
@ -2635,7 +2639,7 @@ bool Editor::handleCodeCompletion(QChar key)
|
|||
return true;
|
||||
case '/':
|
||||
case '\\':
|
||||
commandProcessor(QSynedit::EditCommand::ecChar, key);
|
||||
processCommand(QSynedit::EditCommand::Char, key);
|
||||
if (mParser->isIncludeLine(lineText())) {
|
||||
showHeaderCompletion(false);
|
||||
}
|
||||
|
@ -3395,8 +3399,8 @@ bool Editor::onCompletionKeyPressed(QKeyEvent *event)
|
|||
//ignore it
|
||||
return true;
|
||||
case Qt::Key_Backspace:
|
||||
commandProcessor(
|
||||
QSynedit::EditCommand::ecDeleteLastChar,
|
||||
processCommand(
|
||||
QSynedit::EditCommand::DeleteLastChar,
|
||||
QChar(), nullptr); // Simulate backspace in editor
|
||||
if (purpose == WordPurpose::wpCompletion) {
|
||||
phrase = getWordForCompletionSearch(caretXY(), mCompletionPopup->memberOperator()=="::");
|
||||
|
@ -3429,7 +3433,7 @@ bool Editor::onCompletionKeyPressed(QKeyEvent *event)
|
|||
}
|
||||
QChar ch = event->text().front();
|
||||
if (isIdentChar(ch)) {
|
||||
commandProcessor(QSynedit::EditCommand::ecChar, ch);
|
||||
processCommand(QSynedit::EditCommand::Char, ch);
|
||||
if (purpose == WordPurpose::wpCompletion) {
|
||||
phrase = getWordForCompletionSearch(caretXY(),mCompletionPopup->memberOperator()=="::");
|
||||
} else
|
||||
|
@ -3457,8 +3461,8 @@ bool Editor::onHeaderCompletionKeyPressed(QKeyEvent *event)
|
|||
QSynedit::BufferCoord pBeginPos,pEndPos;
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Backspace:
|
||||
commandProcessor(
|
||||
QSynedit::EditCommand::ecDeleteLastChar,
|
||||
processCommand(
|
||||
QSynedit::EditCommand::DeleteLastChar,
|
||||
QChar(), nullptr); // Simulate backspace in editor
|
||||
phrase = getWordAtPosition(this,caretXY(),
|
||||
pBeginPos,pEndPos,
|
||||
|
@ -3489,7 +3493,7 @@ bool Editor::onHeaderCompletionKeyPressed(QKeyEvent *event)
|
|||
|
||||
if (isIdentChar(ch) || ch == '.'
|
||||
|| ch =='_' || ch=='+') {
|
||||
commandProcessor(QSynedit::EditCommand::ecChar, ch);
|
||||
processCommand(QSynedit::EditCommand::Char, ch);
|
||||
phrase = getWordAtPosition(this,caretXY(),
|
||||
pBeginPos,pEndPos,
|
||||
WordPurpose::wpHeaderCompletion);
|
||||
|
@ -4698,7 +4702,10 @@ void Editor::applySettings()
|
|||
{
|
||||
QSynedit::EditorOptions options = QSynedit::eoAltSetsColumnMode |
|
||||
QSynedit::eoDragDropEditing | QSynedit::eoDropFiles | QSynedit::eoKeepCaretX | QSynedit::eoTabsToSpaces |
|
||||
QSynedit::eoRightMouseMovesCursor | QSynedit::eoScrollByOneLess | QSynedit::eoTabIndent | QSynedit::eoHideShowScrollbars | QSynedit::eoGroupUndo;
|
||||
QSynedit::eoRightMouseMovesCursor | QSynedit::eoScrollByOneLess | QSynedit::eoTabIndent | QSynedit::eoHideShowScrollbars | QSynedit::eoGroupUndo
|
||||
| QSynedit::eoSelectWordByDblClick;
|
||||
|
||||
options.setFlag(QSynedit::eoShowSpecialChars);
|
||||
|
||||
//options
|
||||
options.setFlag(QSynedit::eoAutoIndent,pSettings->editor().autoIndent());
|
||||
|
|
|
@ -7818,7 +7818,6 @@ void MainWindow::on_btnRemoveProblem_clicked()
|
|||
std::sort(idxList.begin(),idxList.end(),[](int i1, int i2){
|
||||
return i1>i2;
|
||||
});
|
||||
qDebug()<<idxList;
|
||||
foreach (int id,idxList) {
|
||||
mOJProblemSetModel.removeProblem(id);
|
||||
}
|
||||
|
|
|
@ -720,6 +720,16 @@ void Settings::Editor::setEnableCustomCTypeKeywords(bool newEnableCustomCTypeKey
|
|||
mEnableCustomCTypeKeywords = newEnableCustomCTypeKeywords;
|
||||
}
|
||||
|
||||
bool Settings::Editor::removeTrailingSpacesWhenSaved() const
|
||||
{
|
||||
return mRemoveTrailingSpacesWhenSaved;
|
||||
}
|
||||
|
||||
void Settings::Editor::setRemoveTrailingSpacesWhenSaved(bool newRemoveTrailingSpacesWhenSaved)
|
||||
{
|
||||
mRemoveTrailingSpacesWhenSaved = newRemoveTrailingSpacesWhenSaved;
|
||||
}
|
||||
|
||||
bool Settings::Editor::highlightCurrentWord() const
|
||||
{
|
||||
return mHighlightCurrentWord;
|
||||
|
@ -1301,6 +1311,7 @@ void Settings::Editor::doSave()
|
|||
saveValue("undo_limit",mUndoLimit);
|
||||
saveValue("undo_memory_usage", mUndoMemoryUsage);
|
||||
saveValue("auto_format_when_saved", mAutoFormatWhenSaved);
|
||||
saveValue("remove_trailing_spaces_when_saved",mRemoveTrailingSpacesWhenSaved);
|
||||
saveValue("parse_todos",mParseTodos);
|
||||
|
||||
saveValue("custom_c_type_keywords", mCustomCTypeKeywords);
|
||||
|
@ -1448,6 +1459,7 @@ void Settings::Editor::doLoad()
|
|||
mUndoLimit = intValue("undo_limit",0);
|
||||
mUndoMemoryUsage = intValue("undo_memory_usage", 10);
|
||||
mAutoFormatWhenSaved = boolValue("auto_format_when_saved", false);
|
||||
mRemoveTrailingSpacesWhenSaved = boolValue("remove_trailing_spaces_when_saved",false);
|
||||
mParseTodos = boolValue("parse_todos",true);
|
||||
|
||||
mCustomCTypeKeywords = stringListValue("custom_c_type_keywords");
|
||||
|
|
|
@ -379,6 +379,9 @@ public:
|
|||
bool enableCustomCTypeKeywords() const;
|
||||
void setEnableCustomCTypeKeywords(bool newEnableCustomCTypeKeywords);
|
||||
|
||||
bool removeTrailingSpacesWhenSaved() const;
|
||||
void setRemoveTrailingSpacesWhenSaved(bool newRemoveTrailingSpacesWhenSaved);
|
||||
|
||||
private:
|
||||
//General
|
||||
// indents
|
||||
|
@ -488,6 +491,7 @@ public:
|
|||
int mUndoLimit;
|
||||
int mUndoMemoryUsage;
|
||||
bool mAutoFormatWhenSaved;
|
||||
bool mRemoveTrailingSpacesWhenSaved;
|
||||
bool mParseTodos;
|
||||
|
||||
QStringList mCustomCTypeKeywords;
|
||||
|
|
|
@ -66,7 +66,13 @@ void EditorMiscWidget::doLoad()
|
|||
}
|
||||
ui->spinMaxUndo->setValue(pSettings->editor().undoLimit());
|
||||
ui->spinMaxUndoMemory->setValue(pSettings->editor().undoMemoryUsage());
|
||||
ui->chkAutoReformat->setChecked(pSettings->editor().autoFormatWhenSaved());
|
||||
if (pSettings->editor().removeTrailingSpacesWhenSaved())
|
||||
ui->rbRemoveTrailingSpaces->setChecked(true);
|
||||
else if (pSettings->editor().autoFormatWhenSaved())
|
||||
ui->rbAutoReformat->setChecked(true);
|
||||
else
|
||||
ui->rbNone->setChecked(true);
|
||||
|
||||
ui->chkParseTodos->setChecked(pSettings->editor().parseTodos());
|
||||
}
|
||||
|
||||
|
@ -84,7 +90,8 @@ void EditorMiscWidget::doSave()
|
|||
}
|
||||
pSettings->editor().setUndoLimit(ui->spinMaxUndo->value());
|
||||
pSettings->editor().setUndoMemoryUsage(ui->spinMaxUndoMemory->value());
|
||||
pSettings->editor().setAutoFormatWhenSaved(ui->chkAutoReformat->isChecked());
|
||||
pSettings->editor().setAutoFormatWhenSaved(ui->rbAutoReformat->isChecked());
|
||||
pSettings->editor().setRemoveTrailingSpacesWhenSaved(ui->rbRemoveTrailingSpaces->isChecked());
|
||||
pSettings->editor().setParseTodos(ui->chkParseTodos->isChecked());
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>515</width>
|
||||
<height>408</height>
|
||||
<height>510</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -36,10 +36,55 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkAutoReformat">
|
||||
<property name="text">
|
||||
<string>Auto reformat code before saving files</string>
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="title">
|
||||
<string>Limits for Undo</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Memory Usage</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="spinMaxUndo">
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000000000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Steps</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QSpinBox" name="spinMaxUndoMemory">
|
||||
<property name="suffix">
|
||||
<string>MB</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>50</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -57,42 +102,6 @@
|
|||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Max Undo Steps</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinMaxUndo">
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000000000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -111,28 +120,38 @@
|
|||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Action before saving files</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="1">
|
||||
<widget class="QRadioButton" name="rbAutoReformat">
|
||||
<property name="text">
|
||||
<string>Max Undo Memory Usage</string>
|
||||
<string>Reformat Code</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinMaxUndoMemory">
|
||||
<property name="suffix">
|
||||
<string>MB</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>50</number>
|
||||
<item row="0" column="2">
|
||||
<widget class="QRadioButton" name="rbRemoveTrailingSpaces">
|
||||
<property name="text">
|
||||
<string>Remove Trailing Spaces</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="rbNone">
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
|
@ -187,7 +206,14 @@
|
|||
<property name="title">
|
||||
<string>Default file type</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbCFile">
|
||||
<property name="text">
|
||||
<string>C files</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbCppFile">
|
||||
<property name="text">
|
||||
|
@ -196,11 +222,17 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbCFile">
|
||||
<property name="text">
|
||||
<string>C files</string>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
|
@ -1433,7 +1433,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>Max Undo Steps</source>
|
||||
<translation>Quantidade máxima de passos a serem desfeitos</translation>
|
||||
<translation type="vanished">Quantidade máxima de passos a serem desfeitos</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Default file encoding</source>
|
||||
|
@ -1463,20 +1463,40 @@
|
|||
<source>UTF-8 BOM</source>
|
||||
<translation>UTF-8 BOM</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Max Undo Memory Usage</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MB</source>
|
||||
<translation type="unfinished">MB</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Auto reformat code before saving files</source>
|
||||
<source>Parse TODOs</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Parse TODOs</source>
|
||||
<source>Memory Usage</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Steps</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Action before saving files</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reformat Code</source>
|
||||
<translation type="unfinished">Reformatar código</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Remove Trailing Spaces</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>None</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Limits for Undo</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
|
@ -6947,6 +6967,10 @@
|
|||
<source>Command: %1 %2</source>
|
||||
<translation>Comando: %1 %2</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Compiling...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SymbolUsageManager</name>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1324,10 +1324,6 @@
|
|||
<source>Auto detect encoding when openning files</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Max Undo Steps</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Default file encoding</source>
|
||||
<translation type="unfinished"></translation>
|
||||
|
@ -1356,20 +1352,40 @@
|
|||
<source>UTF-8 BOM</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Max Undo Memory Usage</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MB</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Auto reformat code before saving files</source>
|
||||
<source>Parse TODOs</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Parse TODOs</source>
|
||||
<source>Memory Usage</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Steps</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Action before saving files</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reformat Code</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Remove Trailing Spaces</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>None</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Limits for Undo</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
|
@ -6560,6 +6576,10 @@
|
|||
<source>Command: %1 %2</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Compiling...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SymbolUsageManager</name>
|
||||
|
|
|
@ -33,7 +33,7 @@ RedPandaIDE.depends += redpanda-git-askpass
|
|||
|
||||
APP_NAME = RedPandaCPP
|
||||
|
||||
APP_VERSION = 2.6
|
||||
APP_VERSION = 2.7
|
||||
|
||||
linux: {
|
||||
isEmpty(PREFIX) {
|
||||
|
|
|
@ -21,7 +21,7 @@ const QSet<QChar> WordBreakChars{'.', ',', ';', ':',
|
|||
'"', '\'', '!', '?', '[', ']', '(', ')', '{', '}', '^', '-', '=', '+',
|
||||
'-', '*', '/', '\\', '|'};
|
||||
const QChar TabGlyph(0x2192);
|
||||
const QChar SpaceGlyph('.');
|
||||
const QChar SpaceGlyph(0x2027);
|
||||
const QChar LineBreakGlyph(0x2193);
|
||||
const QChar SoftBreakGlyph(0x2193);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ EditKeyStroke::EditKeyStroke()
|
|||
mKeyModifiers = Qt::NoModifier;
|
||||
mKey2 = 0;
|
||||
mKeyModifiers2 = Qt::NoModifier;
|
||||
mCommand = EditCommand::ecNone;
|
||||
mCommand = EditCommand::None;
|
||||
}
|
||||
|
||||
QKeySequence EditKeyStroke::keySequence() const
|
||||
|
@ -181,105 +181,71 @@ void EditKeyStrokes::clear()
|
|||
void EditKeyStrokes::resetDefaults()
|
||||
{
|
||||
clear();
|
||||
add(EditCommand::ecUp, Qt::Key_Up, Qt::NoModifier);
|
||||
add(EditCommand::ecSelUp, Qt::Key_Up, Qt::ShiftModifier);
|
||||
add(EditCommand::ecSelUp, Qt::Key_Up, Qt::ShiftModifier | Qt::AltModifier);
|
||||
add(EditCommand::ecScrollUp, Qt::Key_Up, Qt::ControlModifier);
|
||||
add(EditCommand::ecDown, Qt::Key_Down, Qt::NoModifier);
|
||||
add(EditCommand::ecSelDown, Qt::Key_Down, Qt::ShiftModifier);
|
||||
add(EditCommand::ecSelDown, Qt::Key_Down, Qt::ShiftModifier | Qt::AltModifier);
|
||||
add(EditCommand::ecScrollDown, Qt::Key_Down, Qt::ControlModifier);
|
||||
add(EditCommand::ecLeft, Qt::Key_Left, Qt::NoModifier);
|
||||
add(EditCommand::ecSelLeft, Qt::Key_Left, Qt::ShiftModifier);
|
||||
add(EditCommand::ecWordLeft, Qt::Key_Left, Qt::ControlModifier);
|
||||
add(EditCommand::ecSelWordLeft, Qt::Key_Left, Qt::ShiftModifier|Qt::ControlModifier);
|
||||
add(EditCommand::ecRight, Qt::Key_Right, Qt::NoModifier);
|
||||
add(EditCommand::ecSelRight, Qt::Key_Right, Qt::ShiftModifier);
|
||||
add(EditCommand::ecWordRight, Qt::Key_Right, Qt::ControlModifier);
|
||||
add(EditCommand::ecSelWordRight, Qt::Key_Right, Qt::ShiftModifier|Qt::ControlModifier);
|
||||
add(EditCommand::Up, Qt::Key_Up, Qt::NoModifier);
|
||||
add(EditCommand::SelUp, Qt::Key_Up, Qt::ShiftModifier);
|
||||
add(EditCommand::SelUp, Qt::Key_Up, Qt::ShiftModifier | Qt::AltModifier);
|
||||
add(EditCommand::ScrollUp, Qt::Key_Up, Qt::ControlModifier);
|
||||
add(EditCommand::Down, Qt::Key_Down, Qt::NoModifier);
|
||||
add(EditCommand::SelDown, Qt::Key_Down, Qt::ShiftModifier);
|
||||
add(EditCommand::SelDown, Qt::Key_Down, Qt::ShiftModifier | Qt::AltModifier);
|
||||
add(EditCommand::ScrollDown, Qt::Key_Down, Qt::ControlModifier);
|
||||
add(EditCommand::Left, Qt::Key_Left, Qt::NoModifier);
|
||||
add(EditCommand::SelLeft, Qt::Key_Left, Qt::ShiftModifier);
|
||||
add(EditCommand::WordLeft, Qt::Key_Left, Qt::ControlModifier);
|
||||
add(EditCommand::SelWordLeft, Qt::Key_Left, Qt::ShiftModifier|Qt::ControlModifier);
|
||||
add(EditCommand::Right, Qt::Key_Right, Qt::NoModifier);
|
||||
add(EditCommand::SelRight, Qt::Key_Right, Qt::ShiftModifier);
|
||||
add(EditCommand::WordRight, Qt::Key_Right, Qt::ControlModifier);
|
||||
add(EditCommand::SelWordRight, Qt::Key_Right, Qt::ShiftModifier|Qt::ControlModifier);
|
||||
|
||||
add(EditCommand::ecBlockStart, Qt::Key_Up, Qt::MetaModifier|Qt::ControlModifier);
|
||||
add(EditCommand::ecSelBlockStart, Qt::Key_Up, Qt::ShiftModifier|Qt::ControlModifier|Qt::MetaModifier);
|
||||
add(EditCommand::ecBlockEnd, Qt::Key_Down, Qt::MetaModifier|Qt::ControlModifier);
|
||||
add(EditCommand::ecSelBlockEnd, Qt::Key_Down, Qt::ShiftModifier|Qt::ControlModifier|Qt::MetaModifier);
|
||||
add(EditCommand::BlockStart, Qt::Key_Up, Qt::MetaModifier|Qt::ControlModifier);
|
||||
add(EditCommand::SelBlockStart, Qt::Key_Up, Qt::ShiftModifier|Qt::ControlModifier|Qt::MetaModifier);
|
||||
add(EditCommand::BlockEnd, Qt::Key_Down, Qt::MetaModifier|Qt::ControlModifier);
|
||||
add(EditCommand::SelBlockEnd, Qt::Key_Down, Qt::ShiftModifier|Qt::ControlModifier|Qt::MetaModifier);
|
||||
|
||||
// add(SynEditorCommand::ecExpandSelection, Qt::Key_Right, Qt::ShiftModifier|Qt::AltModifier);
|
||||
// add(SynEditorCommand::ecShrinkSelection, Qt::Key_Left, Qt::ShiftModifier | Qt::AltModifier);
|
||||
add(EditCommand::PageDown, Qt::Key_PageDown, Qt::NoModifier);
|
||||
add(EditCommand::SelPageDown, Qt::Key_PageDown, Qt::ShiftModifier);
|
||||
add(EditCommand::PageBottom, Qt::Key_PageDown, Qt::ControlModifier);
|
||||
add(EditCommand::SelPageBottom, Qt::Key_PageDown, Qt::ShiftModifier|Qt::ControlModifier);
|
||||
add(EditCommand::PageUp, Qt::Key_PageUp, Qt::NoModifier);
|
||||
add(EditCommand::SelPageUp, Qt::Key_PageUp, Qt::ShiftModifier);
|
||||
add(EditCommand::PageTop, Qt::Key_PageUp, Qt::ControlModifier);
|
||||
add(EditCommand::SelPageTop, Qt::Key_PageUp, Qt::ShiftModifier|Qt::ControlModifier);
|
||||
add(EditCommand::LineStart, Qt::Key_Home, Qt::NoModifier);
|
||||
add(EditCommand::SelLineStart, Qt::Key_Home, Qt::ShiftModifier);
|
||||
add(EditCommand::EditorStart, Qt::Key_Home, Qt::ControlModifier);
|
||||
add(EditCommand::SelEditorStart, Qt::Key_Home, Qt::ShiftModifier|Qt::ControlModifier);
|
||||
add(EditCommand::LineEnd, Qt::Key_End, Qt::NoModifier);
|
||||
add(EditCommand::SelLineEnd, Qt::Key_End, Qt::ShiftModifier);
|
||||
add(EditCommand::EditorEnd, Qt::Key_End, Qt::ControlModifier);
|
||||
add(EditCommand::SelEditorEnd, Qt::Key_End, Qt::ShiftModifier|Qt::ControlModifier);
|
||||
add(EditCommand::ToggleMode, Qt::Key_Insert, Qt::NoModifier);
|
||||
add(EditCommand::DeleteChar, Qt::Key_Delete, Qt::NoModifier);
|
||||
add(EditCommand::DeleteLastChar, Qt::Key_Backspace, Qt::NoModifier);
|
||||
add(EditCommand::LineBreak, Qt::Key_Return, Qt::NoModifier);
|
||||
add(EditCommand::LineBreak, Qt::Key_Return, Qt::ShiftModifier);
|
||||
add(EditCommand::LineBreakAtEnd, Qt::Key_Return, Qt::ControlModifier);
|
||||
add(EditCommand::LineBreak, Qt::Key_Enter, Qt::NoModifier);
|
||||
add(EditCommand::LineBreak, Qt::Key_Enter, Qt::ShiftModifier);
|
||||
add(EditCommand::LineBreakAtEnd, Qt::Key_Enter, Qt::ControlModifier);
|
||||
|
||||
add(EditCommand::ecPageDown, Qt::Key_PageDown, Qt::NoModifier);
|
||||
add(EditCommand::ecSelPageDown, Qt::Key_PageDown, Qt::ShiftModifier);
|
||||
add(EditCommand::ecPageBottom, Qt::Key_PageDown, Qt::ControlModifier);
|
||||
add(EditCommand::ecSelPageBottom, Qt::Key_PageDown, Qt::ShiftModifier|Qt::ControlModifier);
|
||||
add(EditCommand::ecPageUp, Qt::Key_PageUp, Qt::NoModifier);
|
||||
add(EditCommand::ecSelPageUp, Qt::Key_PageUp, Qt::ShiftModifier);
|
||||
add(EditCommand::ecPageTop, Qt::Key_PageUp, Qt::ControlModifier);
|
||||
add(EditCommand::ecSelPageTop, Qt::Key_PageUp, Qt::ShiftModifier|Qt::ControlModifier);
|
||||
add(EditCommand::ecLineStart, Qt::Key_Home, Qt::NoModifier);
|
||||
add(EditCommand::ecSelLineStart, Qt::Key_Home, Qt::ShiftModifier);
|
||||
add(EditCommand::ecEditorStart, Qt::Key_Home, Qt::ControlModifier);
|
||||
add(EditCommand::ecSelEditorStart, Qt::Key_Home, Qt::ShiftModifier|Qt::ControlModifier);
|
||||
add(EditCommand::ecLineEnd, Qt::Key_End, Qt::NoModifier);
|
||||
add(EditCommand::ecSelLineEnd, Qt::Key_End, Qt::ShiftModifier);
|
||||
add(EditCommand::ecEditorEnd, Qt::Key_End, Qt::ControlModifier);
|
||||
add(EditCommand::ecSelEditorEnd, Qt::Key_End, Qt::ShiftModifier|Qt::ControlModifier);
|
||||
add(EditCommand::ecToggleMode, Qt::Key_Insert, Qt::NoModifier);
|
||||
// add(SynEditorCommand::ecCopy, Qt::Key_Insert, Qt::ControlModifier);
|
||||
// add(SynEditorCommand::ecCut, Qt::Key_Delete, Qt::ShiftModifier);
|
||||
// add(SynEditorCommand::ecPaste, Qt::Key_Insert, Qt::ShiftModifier);
|
||||
add(EditCommand::ecDeleteChar, Qt::Key_Delete, Qt::NoModifier);
|
||||
add(EditCommand::ecDeleteLastChar, Qt::Key_Backspace, Qt::NoModifier);
|
||||
// add(SynEditorCommand::ecDeleteLastChar, Qt::Key_Backspace, Qt::ShiftModifier);
|
||||
// add(SynEditorCommand::ecDeleteWordStart, Qt::Key_Backspace, Qt::ControlModifier);
|
||||
// add(SynEditorCommand::ecDeleteWordEnd, Qt::Key_Delete, Qt::ControlModifier);
|
||||
// add(SynEditorCommand::ecUndo, Qt::Key_Backspace, Qt::AltModifier);
|
||||
// add(SynEditorCommand::ecRedo, Qt::Key_Backspace, Qt::AltModifier|Qt::ShiftModifier);
|
||||
add(EditCommand::ecLineBreak, Qt::Key_Return, Qt::NoModifier);
|
||||
add(EditCommand::ecLineBreak, Qt::Key_Return, Qt::ShiftModifier);
|
||||
add(EditCommand::ecLineBreakAtEnd, Qt::Key_Return, Qt::ControlModifier);
|
||||
add(EditCommand::ecLineBreak, Qt::Key_Enter, Qt::NoModifier);
|
||||
add(EditCommand::ecLineBreak, Qt::Key_Enter, Qt::ShiftModifier);
|
||||
add(EditCommand::ecLineBreakAtEnd, Qt::Key_Enter, Qt::ControlModifier);
|
||||
// add(SynEditorCommand::ecTab, Qt::Key_Tab, Qt::NoModifier);
|
||||
// add(SynEditorCommand::ecShiftTab, Qt::Key_Backtab, Qt::ShiftModifier);
|
||||
// add(SynEditorCommand::ecShiftTab, Qt::Key_Tab, Qt::ShiftModifier);
|
||||
add(EditCommand::ecContextHelp, Qt::Key_F1, Qt::NoModifier);
|
||||
|
||||
// add(SynEditorCommand::ecSelectAll, Qt::Key_A, Qt::ControlModifier);
|
||||
// add(SynEditorCommand::ecCopy, Qt::Key_C, Qt::ControlModifier);
|
||||
// add(SynEditorCommand::ecPaste, Qt::Key_V, Qt::ControlModifier);
|
||||
// add(SynEditorCommand::ecCut, Qt::Key_X, Qt::ControlModifier);
|
||||
// add(SynEditorCommand::ecBlockIndent, Qt::Key_I, Qt::ControlModifier|Qt::ShiftModifier);
|
||||
// add(SynEditorCommand::ecBlockUnindent, Qt::Key_U, Qt::ControlModifier|Qt::ShiftModifier);
|
||||
// add(SynEditorCommand::ecLineBreak, Qt::Key_M, Qt::ControlModifier);
|
||||
// add(SynEditorCommand::ecInsertLine, Qt::Key_N, Qt::ControlModifier);
|
||||
// add(SynEditorCommand::ecDeleteWord, Qt::Key_T, Qt::ControlModifier);
|
||||
// add(SynEditorCommand::ecDeleteLine, Qt::Key_Y, Qt::ControlModifier);
|
||||
// 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::ecRedo, Qt::Key_Z, Qt::ControlModifier|Qt::ShiftModifier);
|
||||
// add(SynEditorCommand::ecNormalSelect, Qt::Key_N, Qt::ControlModifier | Qt::ShiftModifier);
|
||||
// add(SynEditorCommand::ecColumnSelect, Qt::Key_C, Qt::ControlModifier | Qt::ShiftModifier);
|
||||
// add(SynEditorCommand::ecLineSelect, Qt::Key_L, Qt::ControlModifier | Qt::ShiftModifier);
|
||||
// add(SynEditorCommand::ecMatchBracket, Qt::Key_B, Qt::ControlModifier | Qt::ShiftModifier);
|
||||
}
|
||||
|
||||
void EditKeyStrokes::setExtraKeyStrokes()
|
||||
{
|
||||
add(EditCommand::ecDeleteWordStart, Qt::Key_Backspace, Qt::ControlModifier);
|
||||
add(EditCommand::ecDeleteWordEnd, Qt::Key_Delete, Qt::ControlModifier);
|
||||
add(EditCommand::DeleteWordStart, Qt::Key_Backspace, Qt::ControlModifier);
|
||||
add(EditCommand::DeleteWordEnd, Qt::Key_Delete, Qt::ControlModifier);
|
||||
|
||||
add(EditCommand::ecDuplicateLine, Qt::Key_D, Qt::ControlModifier);
|
||||
add(EditCommand::ecDeleteLine, Qt::Key_E, Qt::ControlModifier);
|
||||
add(EditCommand::DuplicateLine, Qt::Key_D, Qt::ControlModifier);
|
||||
add(EditCommand::DeleteLine, Qt::Key_E, Qt::ControlModifier);
|
||||
|
||||
add(EditCommand::ecSelectAll, Qt::Key_A, Qt::ControlModifier);
|
||||
add(EditCommand::ecCopy, Qt::Key_C, Qt::ControlModifier);
|
||||
add(EditCommand::ecPaste, Qt::Key_V, Qt::ControlModifier);
|
||||
add(EditCommand::ecCut, Qt::Key_X, Qt::ControlModifier);
|
||||
add(EditCommand::SelectAll, Qt::Key_A, Qt::ControlModifier);
|
||||
add(EditCommand::Copy, Qt::Key_C, Qt::ControlModifier);
|
||||
add(EditCommand::Paste, Qt::Key_V, Qt::ControlModifier);
|
||||
add(EditCommand::Cut, Qt::Key_X, Qt::ControlModifier);
|
||||
|
||||
add(EditCommand::ecUndo, Qt::Key_Z, Qt::ControlModifier);
|
||||
add(EditCommand::ecRedo, Qt::Key_Y, Qt::ControlModifier);
|
||||
add(EditCommand::Undo, Qt::Key_Z, Qt::ControlModifier);
|
||||
add(EditCommand::Redo, Qt::Key_Y, Qt::ControlModifier);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,144 +39,139 @@ namespace QSynedit {
|
|||
// read-only mode
|
||||
|
||||
enum class EditCommand {
|
||||
ecNone = 0, // Nothing. Useful for user event to handle command
|
||||
ecViewCommandFirst = 0,
|
||||
ecViewCommandLast = 500,
|
||||
ecEditCommandFirst = 501,
|
||||
ecEditCommandLast = 1000,
|
||||
None = 0, // Nothing. Useful for user event to handle command
|
||||
|
||||
ecLeft = 1, // Move cursor left one char
|
||||
ecRight = 2, // Move cursor right one char
|
||||
ecUp = 3, // Move cursor up one line
|
||||
ecDown = 4, // Move cursor down one line
|
||||
ecWordLeft = 5, // Move cursor left one word
|
||||
ecWordRight = 6, // Move cursor right one word
|
||||
ecLineStart = 7, // Move cursor to beginning of line
|
||||
ecLineEnd = 8, // Move cursor to end of line
|
||||
ecPageUp = 9, // Move cursor up one page
|
||||
ecPageDown = 10, // Move cursor down one page
|
||||
ecPageLeft = 11, // Move cursor right one page
|
||||
ecPageRight = 12, // Move cursor left one page
|
||||
ecPageTop = 13, // Move cursor to top of page
|
||||
ecPageBottom = 14, // Move cursor to bottom of page
|
||||
ecEditorStart = 15, // Move cursor to absolute beginning
|
||||
ecEditorEnd = 16, // Move cursor to absolute end
|
||||
ecGotoXY = 17, // Move cursor to specific coordinates, Data = PPoint
|
||||
ecBlockStart = 18, // Move cursor to begin of block
|
||||
ecBlockEnd = 19, // Move cursor to end of block
|
||||
Left = 1, // Move cursor left one char
|
||||
Right = 2, // Move cursor right one char
|
||||
Up = 3, // Move cursor up one line
|
||||
Down = 4, // Move cursor down one line
|
||||
WordLeft = 5, // Move cursor left one word
|
||||
WordRight = 6, // Move cursor right one word
|
||||
LineStart = 7, // Move cursor to beginning of line
|
||||
LineEnd = 8, // Move cursor to end of line
|
||||
PageUp = 9, // Move cursor up one page
|
||||
PageDown = 10, // Move cursor down one page
|
||||
PageLeft = 11, // Move cursor right one page
|
||||
PageRight = 12, // Move cursor left one page
|
||||
PageTop = 13, // Move cursor to top of page
|
||||
PageBottom = 14, // Move cursor to bottom of page
|
||||
EditorStart = 15, // Move cursor to absolute beginning
|
||||
EditorEnd = 16, // Move cursor to absolute end
|
||||
GotoXY = 17, // Move cursor to specific coordinates, Data = PPoint
|
||||
BlockStart = 18, // Move cursor to begin of block
|
||||
BlockEnd = 19, // Move cursor to end of block
|
||||
|
||||
//******************************************************************************
|
||||
// Maybe the command processor should just take a boolean that signifies if
|
||||
// selection is affected or not?
|
||||
//******************************************************************************
|
||||
|
||||
ecSelection = 100, // Add this to ecXXX command to get equivalent
|
||||
Selection = 100, // Add this to ecXXX command to get equivalent
|
||||
// command, but with selection enabled. This is not
|
||||
// a command itself.
|
||||
// Same as commands above, except they affect selection, too
|
||||
ecSelLeft = ecLeft + ecSelection,
|
||||
ecSelRight = ecRight + ecSelection,
|
||||
ecSelUp = ecUp + ecSelection,
|
||||
ecSelDown = ecDown + ecSelection,
|
||||
ecSelWordLeft = ecWordLeft + ecSelection,
|
||||
ecSelWordRight = ecWordRight + ecSelection,
|
||||
ecSelLineStart = ecLineStart + ecSelection,
|
||||
ecSelLineEnd = ecLineEnd + ecSelection,
|
||||
ecSelPageUp = ecPageUp + ecSelection,
|
||||
ecSelPageDown = ecPageDown + ecSelection,
|
||||
ecSelPageLeft = ecPageLeft + ecSelection,
|
||||
ecSelPageRight = ecPageRight + ecSelection,
|
||||
ecSelPageTop = ecPageTop + ecSelection,
|
||||
ecSelPageBottom = ecPageBottom + ecSelection,
|
||||
ecSelEditorStart = ecEditorStart + ecSelection,
|
||||
ecSelEditorEnd = ecEditorEnd + ecSelection,
|
||||
ecSelGotoXY = ecGotoXY + ecSelection, // Data = PPoint
|
||||
ecSelBlockStart = ecBlockStart + ecSelection, // Move cursor to begin of scope
|
||||
ecSelBlockEnd = ecBlockEnd + ecSelection, // Move cursor to end of scope
|
||||
SelLeft = Left + Selection,
|
||||
SelRight = Right + Selection,
|
||||
SelUp = Up + Selection,
|
||||
SelDown = Down + Selection,
|
||||
SelWordLeft = WordLeft + Selection,
|
||||
SelWordRight = WordRight + Selection,
|
||||
SelLineStart = LineStart + Selection,
|
||||
SelLineEnd = LineEnd + Selection,
|
||||
SelPageUp = PageUp + Selection,
|
||||
SelPageDown = PageDown + Selection,
|
||||
SelPageLeft = PageLeft + Selection,
|
||||
SelPageRight = PageRight + Selection,
|
||||
SelPageTop = PageTop + Selection,
|
||||
SelPageBottom = PageBottom + Selection,
|
||||
SelEditorStart = EditorStart + Selection,
|
||||
SelEditorEnd = EditorEnd + Selection,
|
||||
SelGotoXY = GotoXY + Selection, // Data = PPoint
|
||||
SelBlockStart = BlockStart + Selection, // Move cursor to begin of scope
|
||||
SelBlockEnd = BlockEnd + Selection, // Move cursor to end of scope
|
||||
|
||||
|
||||
ecCopy = 201, // Copy selection to clipboard
|
||||
ecSelWord = 202,
|
||||
ecSelectAll = 203, // Select entire contents of editor, cursor to end
|
||||
ecExpandSelection = 204, // expand selection
|
||||
ecShrinkSelection = 205, // shrink selection
|
||||
Copy = 201, // Copy selection to clipboard
|
||||
SelWord = 202,
|
||||
SelectAll = 203, // Select entire contents of editor, cursor to end
|
||||
ExpandSelection = 204, // expand selection
|
||||
ShrinkSelection = 205, // shrink selection
|
||||
|
||||
ecScrollUp = 211, // Scroll up one line leaving cursor position unchanged.
|
||||
ecScrollDown = 212, // Scroll down one line leaving cursor position unchanged.
|
||||
ecScrollLeft = 213, // Scroll left one char leaving cursor position unchanged.
|
||||
ecScrollRight = 214, // Scroll right one char leaving cursor position unchanged.
|
||||
ScrollUp = 211, // Scroll up one line leaving cursor position unchanged.
|
||||
ScrollDown = 212, // Scroll down one line leaving cursor position unchanged.
|
||||
ScrollLeft = 213, // Scroll left one char leaving cursor position unchanged.
|
||||
ScrollRight = 214, // Scroll right one char leaving cursor position unchanged.
|
||||
|
||||
ecInsertMode = 221, // Set insert mode
|
||||
ecOverwriteMode = 222, // Set overwrite mode
|
||||
ecToggleMode = 223, // Toggle ins/ovr mode
|
||||
InsertMode = 221, // Set insert mode
|
||||
OverwriteMode = 222, // Set overwrite mode
|
||||
ToggleMode = 223, // Toggle ins/ovr mode
|
||||
|
||||
ecNormalSelect = 231, // Normal selection mode
|
||||
ecColumnSelect = 232, // Column selection mode
|
||||
ecLineSelect = 233, // Line selection mode
|
||||
NormalSelect = 231, // Normal selection mode
|
||||
ColumnSelect = 232, // Column selection mode
|
||||
LineSelect = 233, // Line selection mode
|
||||
|
||||
ecMatchBracket = 250, // Go to matching bracket
|
||||
MatchBracket = 250, // Go to matching bracket
|
||||
|
||||
ecContextHelp = 490, // Help on Word, Data = Word
|
||||
ContextHelp = 490, // Help on Word, Data = Word
|
||||
|
||||
ecDeleteLastChar = 501, // Delete last char (i.e. backspace key)
|
||||
ecDeleteChar = 502, // Delete char at cursor (i.e. delete key)
|
||||
ecDeleteWordEnd = 503, // Delete from cursor to end of word
|
||||
ecDeleteWordStart = 504, // Delete from cursor to start of word
|
||||
ecDeleteBOL = 505, // Delete from cursor to beginning of line
|
||||
ecDeleteEOL = 506, // Delete from cursor to end of line
|
||||
ecDeleteLine = 507, // Delete current line
|
||||
ecClearAll = 508, // Delete everything
|
||||
ecLineBreak = 509, // Break line at current position, move caret to new line
|
||||
ecInsertLine = 510, // Break line at current position, leave caret
|
||||
ecChar = 511, // Insert a character at current position
|
||||
ecDuplicateLine = 512, // Duplicate current line
|
||||
ecMoveSelUp = 513, // Move selection up
|
||||
ecMoveSelDown = 514, // Move selection down
|
||||
ecImeStr = 550, // Insert character(s) from IME
|
||||
ecDeleteWord = 551, // Delete current Word
|
||||
DeleteLastChar = 501, // Delete last char (i.e. backspace key)
|
||||
DeleteChar = 502, // Delete char at cursor (i.e. delete key)
|
||||
DeleteWordEnd = 503, // Delete from cursor to end of word
|
||||
DeleteWordStart = 504, // Delete from cursor to start of word
|
||||
DeleteBOL = 505, // Delete from cursor to beginning of line
|
||||
DeleteEOL = 506, // Delete from cursor to end of line
|
||||
DeleteLine = 507, // Delete current line
|
||||
ClearAll = 508, // Delete everything
|
||||
LineBreak = 509, // Break line at current position, move caret to new line
|
||||
InsertLine = 510, // Break line at current position, leave caret
|
||||
Char = 511, // Insert a character at current position
|
||||
DuplicateLine = 512, // Duplicate current line
|
||||
MoveSelUp = 513, // Move selection up
|
||||
MoveSelDown = 514, // Move selection down
|
||||
ImeStr = 550, // Insert character(s) from IME
|
||||
DeleteWord = 551, // Delete current Word
|
||||
|
||||
ecUndo = 601, // Perform undo if available
|
||||
ecRedo = 602, // Perform redo if available
|
||||
ecCut = 603, // Cut selection to clipboard
|
||||
ecPaste = 604, // Paste clipboard to current position
|
||||
Undo = 601, // Perform undo if available
|
||||
Redo = 602, // Perform redo if available
|
||||
Cut = 603, // Cut selection to clipboard
|
||||
Paste = 604, // Paste clipboard to current position
|
||||
|
||||
ecBlockIndent = 610, // Indent selection
|
||||
ecBlockUnindent = 611, // Unindent selection
|
||||
ecTab = 612, // Tab key
|
||||
ecShiftTab = 613, // Shift+Tab key
|
||||
ecComment = 614,
|
||||
ecUncomment = 615,
|
||||
ecToggleComment = 616,
|
||||
ecToggleBlockComment = 617,
|
||||
BlockIndent = 610, // Indent selection
|
||||
BlockUnindent = 611, // Unindent selection
|
||||
Tab = 612, // Tab key
|
||||
ShiftTab = 613, // Shift+Tab key
|
||||
Comment = 614,
|
||||
Uncomment = 615,
|
||||
ToggleComment = 616,
|
||||
ToggleBlockComment = 617,
|
||||
|
||||
ecUpperCase = 620, // apply to the current or previous word
|
||||
ecLowerCase = 621,
|
||||
ecToggleCase = 622,
|
||||
ecTitleCase = 623,
|
||||
ecUpperCaseBlock = 625, // apply to current selection, or current char if no selection
|
||||
ecLowerCaseBlock = 626,
|
||||
ecToggleCaseBlock = 627,
|
||||
UpperCase = 620, // apply to the current or previous word
|
||||
LowerCase = 621,
|
||||
ToggleCase = 622,
|
||||
TitleCase = 623,
|
||||
UpperCaseBlock = 625, // apply to current selection, or current char if no selection
|
||||
LowerCaseBlock = 626,
|
||||
ToggleCaseBlock = 627,
|
||||
|
||||
ecString = 630, //Insert a whole string
|
||||
ecZoomOut = 631, //Increase Font Size
|
||||
ecZoomIn = 632, //Decrease Font Size
|
||||
String = 630, //Insert a whole string
|
||||
ZoomOut = 631, //Increase Font Size
|
||||
ZoomIn = 632, //Decrease Font Size
|
||||
|
||||
ecLineBreakAtBegin = 651, //add a line break at the begin of the line
|
||||
ecLineBreakAtEnd = 652,
|
||||
LineBreakAtBegin = 651, //add a line break at the begin of the line
|
||||
LineBreakAtEnd = 652,
|
||||
|
||||
TrimTrailingSpaces = 653,
|
||||
|
||||
//### Code Folding ###
|
||||
ecCollapse = 700,
|
||||
ecUncollapse = 701,
|
||||
ecCollapseLevel = 702,
|
||||
ecUncollapseLevel = 703,
|
||||
ecCollapseAll = 704,
|
||||
ecUncollapseAll = 705,
|
||||
Collapse = 700,
|
||||
Uncollapse = 701,
|
||||
CollapseLevel = 702,
|
||||
UncollapseLevel = 703,
|
||||
CollapseAll = 704,
|
||||
UncollapseAll = 705,
|
||||
//### End Code Folding ###
|
||||
|
||||
ecUserFirst = 1001, // Start of user-defined commands
|
||||
|
||||
|
||||
|
||||
UserFirst = 1001, // Start of user-defined commands
|
||||
};
|
||||
|
||||
class KeyError: public BaseError {
|
||||
|
|
|
@ -462,6 +462,65 @@ void SynEdit::addSelectionToUndo()
|
|||
mBlockEnd,QStringList(),mActiveSelectionMode);
|
||||
}
|
||||
|
||||
void SynEdit::doTrimTrailingSpaces()
|
||||
{
|
||||
if (mDocument->count()<=0)
|
||||
return;
|
||||
|
||||
if (mSyntaxer) {
|
||||
for (int i=0;i<mDocument->count();i++) {
|
||||
if (mDocument->ranges(i).hasTrailingSpaces) {
|
||||
int line = i+1;
|
||||
QString oldLine = mDocument->getString(i);
|
||||
QString newLine = trimRight(oldLine);
|
||||
if (newLine.isEmpty())
|
||||
continue;
|
||||
properSetLine(i,newLine);
|
||||
mUndoList->addChange(
|
||||
ChangeReason::Delete,
|
||||
BufferCoord{1,line},
|
||||
BufferCoord{oldLine.length()+1, line},
|
||||
QStringList(oldLine),
|
||||
SelectionMode::Normal
|
||||
);
|
||||
mUndoList->addChange(
|
||||
ChangeReason::Insert,
|
||||
BufferCoord{1, line},
|
||||
BufferCoord{newLine.length()+1, line},
|
||||
QStringList(),
|
||||
SelectionMode::Normal
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
for (int i=0;i<mDocument->count();i++) {
|
||||
int line = i+1;
|
||||
QString oldLine = mDocument->getString(i);
|
||||
QString newLine = trimRight(oldLine);
|
||||
if (newLine.isEmpty())
|
||||
continue;
|
||||
properSetLine(i,newLine);
|
||||
mUndoList->addChange(
|
||||
ChangeReason::Delete,
|
||||
BufferCoord{1,line},
|
||||
BufferCoord{oldLine.length()+1, line},
|
||||
QStringList(oldLine),
|
||||
SelectionMode::Normal
|
||||
);
|
||||
mUndoList->addChange(
|
||||
ChangeReason::Insert,
|
||||
BufferCoord{1, line},
|
||||
BufferCoord{newLine.length()+1, line},
|
||||
QStringList(),
|
||||
SelectionMode::Normal
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
mUndoList->endBlock();
|
||||
}
|
||||
|
||||
void SynEdit::beginUpdate()
|
||||
{
|
||||
incPaintLock();
|
||||
|
@ -2025,8 +2084,6 @@ void SynEdit::doDeleteLastChar()
|
|||
internalSetCaretX(mDocument->getString(mCaretY - 1).length() + 1);
|
||||
mDocument->deleteAt(mCaretY);
|
||||
doLinesDeleted(mCaretY+1, 1);
|
||||
if (mOptions.testFlag(eoTrimTrailingSpaces))
|
||||
Temp = trimRight(Temp);
|
||||
setLineText(lineText() + Temp);
|
||||
helper.append("");
|
||||
helper.append("");
|
||||
|
@ -3021,18 +3078,8 @@ void SynEdit::doCopyToClipboard()
|
|||
bool selected=selAvail();
|
||||
if (!selected)
|
||||
doSelecteLine();
|
||||
bool ChangeTrim = (mActiveSelectionMode == SelectionMode::Column) &&
|
||||
mOptions.testFlag(eoTrimTrailingSpaces);
|
||||
QString sText;
|
||||
{
|
||||
auto action = finally([&,this] {
|
||||
if (ChangeTrim)
|
||||
mOptions.setFlag(eoTrimTrailingSpaces);
|
||||
});
|
||||
if (ChangeTrim)
|
||||
mOptions.setFlag(eoTrimTrailingSpaces,false);
|
||||
sText = selText();
|
||||
}
|
||||
internalDoCopyToClipboard(sText);
|
||||
if (!selected) {
|
||||
setBlockBegin(caretXY());
|
||||
|
@ -3867,7 +3914,7 @@ EditCommand SynEdit::TranslateKeyCode(int key, Qt::KeyboardModifiers modifiers)
|
|||
{
|
||||
PEditKeyStroke keyStroke = mKeyStrokes.findKeycode2(mLastKey,mLastKeyModifiers,
|
||||
key, modifiers);
|
||||
EditCommand cmd=EditCommand::ecNone;
|
||||
EditCommand cmd=EditCommand::None;
|
||||
if (keyStroke)
|
||||
cmd = keyStroke->command();
|
||||
else {
|
||||
|
@ -3875,7 +3922,7 @@ EditCommand SynEdit::TranslateKeyCode(int key, Qt::KeyboardModifiers modifiers)
|
|||
if (keyStroke)
|
||||
cmd = keyStroke->command();
|
||||
}
|
||||
if (cmd == EditCommand::ecNone) {
|
||||
if (cmd == EditCommand::None) {
|
||||
mLastKey = key;
|
||||
mLastKeyModifiers = modifiers;
|
||||
} else {
|
||||
|
@ -4147,9 +4194,9 @@ void SynEdit::setOptions(const EditorOptions &Value)
|
|||
//if (!mOptions.testFlag(eoScrollPastEof))
|
||||
setTopLine(mTopLine);
|
||||
|
||||
bool bUpdateAll = Value.testFlag(eoShowSpecialChars) != mOptions.testFlag(eoShowSpecialChars);
|
||||
if (!bUpdateAll)
|
||||
bUpdateAll = Value.testFlag(eoShowRainbowColor) != mOptions.testFlag(eoShowRainbowColor);
|
||||
bool bUpdateAll =
|
||||
(Value.testFlag(eoShowSpecialChars) != mOptions.testFlag(eoShowSpecialChars))
|
||||
|| (Value.testFlag(eoShowRainbowColor) != mOptions.testFlag(eoShowRainbowColor));
|
||||
//bool bUpdateScroll = (Options * ScrollOptions)<>(Value * ScrollOptions);
|
||||
bool bUpdateScroll = true;
|
||||
mOptions = Value;
|
||||
|
@ -4525,7 +4572,7 @@ void SynEdit::doRedoItem()
|
|||
item->changeEndPos(),item->changeText(),
|
||||
item->changeSelMode(),item->changeNumber());
|
||||
setCaretAndSelection(CaretPt, CaretPt, CaretPt);
|
||||
commandProcessor(EditCommand::ecLineBreak);
|
||||
processCommand(EditCommand::LineBreak);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -4791,11 +4838,11 @@ bool SynEdit::empty()
|
|||
return mDocument->empty();
|
||||
}
|
||||
|
||||
void SynEdit::commandProcessor(EditCommand Command, QChar AChar, void *pData)
|
||||
void SynEdit::processCommand(EditCommand Command, QChar AChar, void *pData)
|
||||
{
|
||||
// first the program event handler gets a chance to process the command
|
||||
onProcessCommand(Command, AChar, pData);
|
||||
if (Command != EditCommand::ecNone)
|
||||
if (Command != EditCommand::None)
|
||||
executeCommand(Command, AChar, pData);
|
||||
onCommandProcessed(Command, AChar, pData);
|
||||
}
|
||||
|
@ -5306,12 +5353,8 @@ void SynEdit::doLinesInserted(int firstLine, int count)
|
|||
|
||||
void SynEdit::properSetLine(int ALine, const QString &ALineText, bool notify)
|
||||
{
|
||||
if (mOptions.testFlag(eoTrimTrailingSpaces)) {
|
||||
mDocument->putString(ALine,trimRight(ALineText),notify);
|
||||
} else {
|
||||
mDocument->putString(ALine,ALineText,notify);
|
||||
}
|
||||
}
|
||||
|
||||
void SynEdit::doDeleteText(BufferCoord startPos, BufferCoord endPos, SelectionMode mode)
|
||||
{
|
||||
|
@ -5520,9 +5563,6 @@ int SynEdit::doInsertTextByNormalMode(const BufferCoord& pos, const QStringList&
|
|||
if (bChangeScroll)
|
||||
mOptions.setFlag(eoScrollPastEol,false);
|
||||
});
|
||||
if (mOptions.testFlag(eoTrimTrailingSpaces) && (sRightSide == "")) {
|
||||
newPos=BufferCoord{mDocument->getString(caretY-1).length()+1,caretY};
|
||||
} else
|
||||
newPos=BufferCoord{str.length() - sRightSide.length()+1,caretY};
|
||||
onLinesPutted(startLine-1,result+1);
|
||||
if (!mUndoing) {
|
||||
|
@ -5699,43 +5739,43 @@ void SynEdit::executeCommand(EditCommand command, QChar ch, void *pData)
|
|||
});
|
||||
switch(command) {
|
||||
//horizontal caret movement or selection
|
||||
case EditCommand::ecLeft:
|
||||
case EditCommand::ecSelLeft:
|
||||
moveCaretHorz(-1, command == EditCommand::ecSelLeft);
|
||||
case EditCommand::Left:
|
||||
case EditCommand::SelLeft:
|
||||
moveCaretHorz(-1, command == EditCommand::SelLeft);
|
||||
break;
|
||||
case EditCommand::ecRight:
|
||||
case EditCommand::ecSelRight:
|
||||
moveCaretHorz(1, command == EditCommand::ecSelRight);
|
||||
case EditCommand::Right:
|
||||
case EditCommand::SelRight:
|
||||
moveCaretHorz(1, command == EditCommand::SelRight);
|
||||
break;
|
||||
case EditCommand::ecPageLeft:
|
||||
case EditCommand::ecSelPageLeft:
|
||||
moveCaretHorz(-mCharsInWindow, command == EditCommand::ecSelPageLeft);
|
||||
case EditCommand::PageLeft:
|
||||
case EditCommand::SelPageLeft:
|
||||
moveCaretHorz(-mCharsInWindow, command == EditCommand::SelPageLeft);
|
||||
break;
|
||||
case EditCommand::ecPageRight:
|
||||
case EditCommand::ecSelPageRight:
|
||||
moveCaretHorz(mCharsInWindow, command == EditCommand::ecSelPageRight);
|
||||
case EditCommand::PageRight:
|
||||
case EditCommand::SelPageRight:
|
||||
moveCaretHorz(mCharsInWindow, command == EditCommand::SelPageRight);
|
||||
break;
|
||||
case EditCommand::ecLineStart:
|
||||
case EditCommand::ecSelLineStart:
|
||||
moveCaretToLineStart(command == EditCommand::ecSelLineStart);
|
||||
case EditCommand::LineStart:
|
||||
case EditCommand::SelLineStart:
|
||||
moveCaretToLineStart(command == EditCommand::SelLineStart);
|
||||
break;
|
||||
case EditCommand::ecLineEnd:
|
||||
case EditCommand::ecSelLineEnd:
|
||||
moveCaretToLineEnd(command == EditCommand::ecSelLineEnd);
|
||||
case EditCommand::LineEnd:
|
||||
case EditCommand::SelLineEnd:
|
||||
moveCaretToLineEnd(command == EditCommand::SelLineEnd);
|
||||
break;
|
||||
// vertical caret movement or selection
|
||||
case EditCommand::ecUp:
|
||||
case EditCommand::ecSelUp:
|
||||
moveCaretVert(-1, command == EditCommand::ecSelUp);
|
||||
case EditCommand::Up:
|
||||
case EditCommand::SelUp:
|
||||
moveCaretVert(-1, command == EditCommand::SelUp);
|
||||
break;
|
||||
case EditCommand::ecDown:
|
||||
case EditCommand::ecSelDown:
|
||||
moveCaretVert(1, command == EditCommand::ecSelDown);
|
||||
case EditCommand::Down:
|
||||
case EditCommand::SelDown:
|
||||
moveCaretVert(1, command == EditCommand::SelDown);
|
||||
break;
|
||||
case EditCommand::ecPageUp:
|
||||
case EditCommand::ecSelPageUp:
|
||||
case EditCommand::ecPageDown:
|
||||
case EditCommand::ecSelPageDown:
|
||||
case EditCommand::PageUp:
|
||||
case EditCommand::SelPageUp:
|
||||
case EditCommand::PageDown:
|
||||
case EditCommand::SelPageDown:
|
||||
{
|
||||
int counter = mLinesInWindow;
|
||||
if (mOptions.testFlag(eoHalfPageScroll))
|
||||
|
@ -5745,112 +5785,112 @@ void SynEdit::executeCommand(EditCommand command, QChar ch, void *pData)
|
|||
}
|
||||
if (counter<0)
|
||||
break;
|
||||
if (command == EditCommand::ecPageUp || command == EditCommand::ecSelPageUp) {
|
||||
if (command == EditCommand::PageUp || command == EditCommand::SelPageUp) {
|
||||
counter = -counter;
|
||||
}
|
||||
moveCaretVert(counter, command == EditCommand::ecSelPageUp || command == EditCommand::ecSelPageDown);
|
||||
moveCaretVert(counter, command == EditCommand::SelPageUp || command == EditCommand::SelPageDown);
|
||||
break;
|
||||
}
|
||||
case EditCommand::ecPageTop:
|
||||
case EditCommand::ecSelPageTop:
|
||||
moveCaretVert(mTopLine-mCaretY, command == EditCommand::ecSelPageTop);
|
||||
case EditCommand::PageTop:
|
||||
case EditCommand::SelPageTop:
|
||||
moveCaretVert(mTopLine-mCaretY, command == EditCommand::SelPageTop);
|
||||
break;
|
||||
case EditCommand::ecPageBottom:
|
||||
case EditCommand::ecSelPageBottom:
|
||||
moveCaretVert(mTopLine+mLinesInWindow-1-mCaretY, command == EditCommand::ecSelPageBottom);
|
||||
case EditCommand::PageBottom:
|
||||
case EditCommand::SelPageBottom:
|
||||
moveCaretVert(mTopLine+mLinesInWindow-1-mCaretY, command == EditCommand::SelPageBottom);
|
||||
break;
|
||||
case EditCommand::ecEditorStart:
|
||||
case EditCommand::ecSelEditorStart:
|
||||
doGotoEditorStart(command == EditCommand::ecSelEditorStart);
|
||||
case EditCommand::EditorStart:
|
||||
case EditCommand::SelEditorStart:
|
||||
doGotoEditorStart(command == EditCommand::SelEditorStart);
|
||||
break;
|
||||
case EditCommand::ecEditorEnd:
|
||||
case EditCommand::ecSelEditorEnd:
|
||||
doGotoEditorEnd(command == EditCommand::ecSelEditorEnd);
|
||||
case EditCommand::EditorEnd:
|
||||
case EditCommand::SelEditorEnd:
|
||||
doGotoEditorEnd(command == EditCommand::SelEditorEnd);
|
||||
break;
|
||||
case EditCommand::ecBlockStart:
|
||||
case EditCommand::ecSelBlockStart:
|
||||
doGotoBlockStart(command == EditCommand::ecSelBlockStart);
|
||||
case EditCommand::BlockStart:
|
||||
case EditCommand::SelBlockStart:
|
||||
doGotoBlockStart(command == EditCommand::SelBlockStart);
|
||||
break;
|
||||
case EditCommand::ecBlockEnd:
|
||||
case EditCommand::ecSelBlockEnd:
|
||||
doGotoBlockEnd(command == EditCommand::ecSelBlockEnd);
|
||||
case EditCommand::BlockEnd:
|
||||
case EditCommand::SelBlockEnd:
|
||||
doGotoBlockEnd(command == EditCommand::SelBlockEnd);
|
||||
break;
|
||||
// goto special line / column position
|
||||
case EditCommand::ecGotoXY:
|
||||
case EditCommand::ecSelGotoXY:
|
||||
case EditCommand::GotoXY:
|
||||
case EditCommand::SelGotoXY:
|
||||
if (pData)
|
||||
moveCaretAndSelection(caretXY(), *((BufferCoord *)(pData)), command == EditCommand::ecSelGotoXY);
|
||||
moveCaretAndSelection(caretXY(), *((BufferCoord *)(pData)), command == EditCommand::SelGotoXY);
|
||||
break;
|
||||
// word selection
|
||||
case EditCommand::ecWordLeft:
|
||||
case EditCommand::ecSelWordLeft:
|
||||
case EditCommand::WordLeft:
|
||||
case EditCommand::SelWordLeft:
|
||||
{
|
||||
BufferCoord CaretNew = prevWordPos();
|
||||
moveCaretAndSelection(caretXY(), CaretNew, command == EditCommand::ecSelWordLeft);
|
||||
moveCaretAndSelection(caretXY(), CaretNew, command == EditCommand::SelWordLeft);
|
||||
break;
|
||||
}
|
||||
case EditCommand::ecWordRight:
|
||||
case EditCommand::ecSelWordRight:
|
||||
case EditCommand::WordRight:
|
||||
case EditCommand::SelWordRight:
|
||||
{
|
||||
BufferCoord CaretNew = nextWordPos();
|
||||
moveCaretAndSelection(caretXY(), CaretNew, command == EditCommand::ecSelWordRight);
|
||||
moveCaretAndSelection(caretXY(), CaretNew, command == EditCommand::SelWordRight);
|
||||
break;
|
||||
}
|
||||
case EditCommand::ecSelWord:
|
||||
case EditCommand::SelWord:
|
||||
setSelWord();
|
||||
break;
|
||||
case EditCommand::ecSelectAll:
|
||||
case EditCommand::SelectAll:
|
||||
doSelectAll();
|
||||
break;
|
||||
case EditCommand::ecExpandSelection:
|
||||
case EditCommand::ExpandSelection:
|
||||
doExpandSelection(caretXY());
|
||||
break;
|
||||
case EditCommand::ecShrinkSelection:
|
||||
case EditCommand::ShrinkSelection:
|
||||
doShrinkSelection(caretXY());
|
||||
break;
|
||||
case EditCommand::ecDeleteLastChar:
|
||||
case EditCommand::DeleteLastChar:
|
||||
doDeleteLastChar();
|
||||
break;
|
||||
case EditCommand::ecDeleteChar:
|
||||
case EditCommand::DeleteChar:
|
||||
doDeleteCurrentChar();
|
||||
break;
|
||||
case EditCommand::ecDeleteWord:
|
||||
case EditCommand::DeleteWord:
|
||||
doDeleteWord();
|
||||
break;
|
||||
case EditCommand::ecDeleteEOL:
|
||||
case EditCommand::DeleteEOL:
|
||||
doDeleteToEOL();
|
||||
break;
|
||||
case EditCommand::ecDeleteWordStart:
|
||||
case EditCommand::DeleteWordStart:
|
||||
doDeleteToWordStart();
|
||||
break;
|
||||
case EditCommand::ecDeleteWordEnd:
|
||||
case EditCommand::DeleteWordEnd:
|
||||
doDeleteToWordEnd();
|
||||
break;
|
||||
case EditCommand::ecDeleteBOL:
|
||||
case EditCommand::DeleteBOL:
|
||||
doDeleteFromBOL();
|
||||
break;
|
||||
case EditCommand::ecDeleteLine:
|
||||
case EditCommand::DeleteLine:
|
||||
doDeleteLine();
|
||||
break;
|
||||
case EditCommand::ecDuplicateLine:
|
||||
case EditCommand::DuplicateLine:
|
||||
doDuplicateLine();
|
||||
break;
|
||||
case EditCommand::ecMoveSelUp:
|
||||
case EditCommand::MoveSelUp:
|
||||
doMoveSelUp();
|
||||
break;
|
||||
case EditCommand::ecMoveSelDown:
|
||||
case EditCommand::MoveSelDown:
|
||||
doMoveSelDown();
|
||||
break;
|
||||
case EditCommand::ecClearAll:
|
||||
case EditCommand::ClearAll:
|
||||
clearAll();
|
||||
break;
|
||||
case EditCommand::ecInsertLine:
|
||||
case EditCommand::InsertLine:
|
||||
insertLine(false);
|
||||
break;
|
||||
case EditCommand::ecLineBreak:
|
||||
case EditCommand::LineBreak:
|
||||
insertLine(true);
|
||||
break;
|
||||
case EditCommand::ecLineBreakAtEnd:
|
||||
case EditCommand::LineBreakAtEnd:
|
||||
mUndoList->beginBlock();
|
||||
addCaretToUndo();
|
||||
addSelectionToUndo();
|
||||
|
@ -5858,98 +5898,102 @@ void SynEdit::executeCommand(EditCommand command, QChar ch, void *pData)
|
|||
insertLine(true);
|
||||
mUndoList->endBlock();
|
||||
break;
|
||||
case EditCommand::ecTab:
|
||||
case EditCommand::Tab:
|
||||
doTabKey();
|
||||
break;
|
||||
case EditCommand::ecShiftTab:
|
||||
case EditCommand::ShiftTab:
|
||||
doShiftTabKey();
|
||||
break;
|
||||
case EditCommand::ecChar:
|
||||
case EditCommand::Char:
|
||||
doAddChar(ch);
|
||||
break;
|
||||
case EditCommand::ecInsertMode:
|
||||
case EditCommand::InsertMode:
|
||||
if (!mReadOnly)
|
||||
setInsertMode(true);
|
||||
break;
|
||||
case EditCommand::ecOverwriteMode:
|
||||
case EditCommand::OverwriteMode:
|
||||
if (!mReadOnly)
|
||||
setInsertMode(false);
|
||||
break;
|
||||
case EditCommand::ecToggleMode:
|
||||
case EditCommand::ToggleMode:
|
||||
if (!mReadOnly) {
|
||||
setInsertMode(!mInserting);
|
||||
}
|
||||
break;
|
||||
case EditCommand::ecCut:
|
||||
case EditCommand::Cut:
|
||||
if (!mReadOnly)
|
||||
doCutToClipboard();
|
||||
break;
|
||||
case EditCommand::ecCopy:
|
||||
case EditCommand::Copy:
|
||||
doCopyToClipboard();
|
||||
break;
|
||||
case EditCommand::ecPaste:
|
||||
case EditCommand::Paste:
|
||||
if (!mReadOnly)
|
||||
doPasteFromClipboard();
|
||||
break;
|
||||
case EditCommand::ecImeStr:
|
||||
case EditCommand::ecString:
|
||||
case EditCommand::ImeStr:
|
||||
case EditCommand::String:
|
||||
if (!mReadOnly)
|
||||
doAddStr(*((QString*)pData));
|
||||
break;
|
||||
case EditCommand::ecUndo:
|
||||
case EditCommand::Undo:
|
||||
if (!mReadOnly)
|
||||
doUndo();
|
||||
break;
|
||||
case EditCommand::ecRedo:
|
||||
case EditCommand::Redo:
|
||||
if (!mReadOnly)
|
||||
doRedo();
|
||||
break;
|
||||
case EditCommand::ecZoomIn:
|
||||
case EditCommand::ZoomIn:
|
||||
doZoomIn();
|
||||
break;
|
||||
case EditCommand::ecZoomOut:
|
||||
case EditCommand::ZoomOut:
|
||||
doZoomOut();
|
||||
break;
|
||||
case EditCommand::ecComment:
|
||||
case EditCommand::Comment:
|
||||
doComment();
|
||||
break;
|
||||
case EditCommand::ecUncomment:
|
||||
case EditCommand::Uncomment:
|
||||
doUncomment();
|
||||
break;
|
||||
case EditCommand::ecToggleComment:
|
||||
case EditCommand::ToggleComment:
|
||||
doToggleComment();
|
||||
break;
|
||||
case EditCommand::ecToggleBlockComment:
|
||||
case EditCommand::ToggleBlockComment:
|
||||
doToggleBlockComment();
|
||||
break;
|
||||
case EditCommand::ecNormalSelect:
|
||||
case EditCommand::NormalSelect:
|
||||
setSelectionMode(SelectionMode::Normal);
|
||||
break;
|
||||
case EditCommand::ecLineSelect:
|
||||
case EditCommand::LineSelect:
|
||||
setSelectionMode(SelectionMode::Line);
|
||||
break;
|
||||
case EditCommand::ecColumnSelect:
|
||||
case EditCommand::ColumnSelect:
|
||||
setSelectionMode(SelectionMode::Column);
|
||||
break;
|
||||
case EditCommand::ecScrollLeft:
|
||||
case EditCommand::ScrollLeft:
|
||||
horizontalScrollBar()->setValue(horizontalScrollBar()->value()-mMouseWheelScrollSpeed);
|
||||
break;
|
||||
case EditCommand::ecScrollRight:
|
||||
case EditCommand::ScrollRight:
|
||||
horizontalScrollBar()->setValue(horizontalScrollBar()->value()+mMouseWheelScrollSpeed);
|
||||
break;
|
||||
case EditCommand::ecScrollUp:
|
||||
case EditCommand::ScrollUp:
|
||||
verticalScrollBar()->setValue(verticalScrollBar()->value()-mMouseWheelScrollSpeed);
|
||||
break;
|
||||
case EditCommand::ecScrollDown:
|
||||
case EditCommand::ScrollDown:
|
||||
verticalScrollBar()->setValue(verticalScrollBar()->value()+mMouseWheelScrollSpeed);
|
||||
break;
|
||||
case EditCommand::ecMatchBracket:
|
||||
case EditCommand::MatchBracket:
|
||||
{
|
||||
BufferCoord coord = getMatchingBracket();
|
||||
if (coord.ch!=0 && coord.line!=0)
|
||||
internalSetCaretXY(coord);
|
||||
}
|
||||
break;
|
||||
case EditCommand::TrimTrailingSpaces:
|
||||
if (!mReadOnly)
|
||||
doTrimTrailingSpaces();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -6169,13 +6213,13 @@ void SynEdit::keyPressEvent(QKeyEvent *event)
|
|||
event->accept();
|
||||
} else {
|
||||
EditCommand cmd=TranslateKeyCode(event->key(),event->modifiers());
|
||||
if (cmd!=EditCommand::ecNone) {
|
||||
commandProcessor(cmd,QChar(),nullptr);
|
||||
if (cmd!=EditCommand::None) {
|
||||
processCommand(cmd,QChar(),nullptr);
|
||||
event->accept();
|
||||
} else if (!event->text().isEmpty()) {
|
||||
QChar c = event->text().at(0);
|
||||
if (c=='\t' || c.isPrint()) {
|
||||
commandProcessor(EditCommand::ecChar,c,nullptr);
|
||||
processCommand(EditCommand::Char,c,nullptr);
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
@ -6306,6 +6350,7 @@ void SynEdit::mouseDoubleClickEvent(QMouseEvent *event)
|
|||
QAbstractScrollArea::mouseDoubleClickEvent(event);
|
||||
QPoint ptMouse = event->pos();
|
||||
if (ptMouse.x() >= mGutterWidth + 2) {
|
||||
if (mOptions.testFlag(EditorOption::eoSelectWordByDblClick))
|
||||
setSelWord();
|
||||
mStateFlags.setFlag(StateFlag::sfDblClicked);
|
||||
}
|
||||
|
@ -6328,7 +6373,7 @@ void SynEdit::inputMethodEvent(QInputMethodEvent *event)
|
|||
}
|
||||
QString s = event->commitString();
|
||||
if (!s.isEmpty()) {
|
||||
commandProcessor(EditCommand::ecImeStr,QChar(),&s);
|
||||
processCommand(EditCommand::ImeStr,QChar(),&s);
|
||||
// for (QChar ch:s) {
|
||||
// CommandProcessor(SynEditorCommand::ecChar,ch);
|
||||
// }
|
||||
|
|
|
@ -94,16 +94,7 @@ enum EditorOption {
|
|||
eoTabIndent = 0x00020000, //When active <Tab> and <Shift><Tab> act as block indent, unindent when text is selected
|
||||
eoTabsToSpaces = 0x00040000, //Converts a tab character to a specified number of space characters
|
||||
eoShowRainbowColor = 0x00080000,
|
||||
eoTrimTrailingSpaces =0x00100000, //Spaces at the end of lines will be trimmed and not saved
|
||||
eoSelectWordByDblClick=0x00200000,
|
||||
// eoNoSelection = 0x00400000, //Disables selecting text
|
||||
//eoAutoSizeMaxScrollWidth = 0x00000008, //Automatically resizes the MaxScrollWidth property when inserting text
|
||||
//eoDisableScrollArrows = 0x00000010 , //Disables the scroll bar arrow buttons when you can't scroll in that direction any more
|
||||
// eoScrollHintFollows = 0x00020000, //The scroll hint follows the mouse when scrolling vertically
|
||||
// eoShowScrollHint = 0x00100000, //Shows a hint of the visible line numbers when scrolling vertically
|
||||
// eoSmartTabDelete = 0x00400000, //similar to Smart Tabs, but when you delete characters
|
||||
// eoSmartTabs = 0x00800000, //When tabbing, the cursor will go to the next non-white space character of the previous line
|
||||
// eoNoCaret = 0x00000800, //Makes it so the caret is never visible
|
||||
eoSelectWordByDblClick= 0x00100000,
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(EditorOptions, EditorOption)
|
||||
|
@ -215,7 +206,7 @@ public:
|
|||
BufferCoord prevWordPos();
|
||||
BufferCoord prevWordPosEx(const BufferCoord& XY);
|
||||
|
||||
void commandProcessor(EditCommand Command, QChar AChar = QChar(), void * pData = nullptr);
|
||||
void processCommand(EditCommand Command, QChar AChar = QChar(), void * pData = nullptr);
|
||||
//Caret
|
||||
void showCaret();
|
||||
void hideCaret();
|
||||
|
@ -261,28 +252,31 @@ public:
|
|||
selectAll();
|
||||
setSelText(text);
|
||||
}
|
||||
void trimTrailingSpaces() {
|
||||
processCommand(EditCommand::TrimTrailingSpaces);
|
||||
}
|
||||
|
||||
//Commands
|
||||
virtual void cutToClipboard() { commandProcessor(EditCommand::ecCut);}
|
||||
virtual void copyToClipboard() { commandProcessor(EditCommand::ecCopy);}
|
||||
virtual void pasteFromClipboard() { commandProcessor(EditCommand::ecPaste);}
|
||||
virtual void undo() { commandProcessor(EditCommand::ecUndo);}
|
||||
virtual void redo() { commandProcessor(EditCommand::ecRedo);}
|
||||
virtual void zoomIn() { commandProcessor(EditCommand::ecZoomIn);}
|
||||
virtual void zoomOut() { commandProcessor(EditCommand::ecZoomOut);}
|
||||
virtual void cutToClipboard() { processCommand(EditCommand::Cut);}
|
||||
virtual void copyToClipboard() { processCommand(EditCommand::Copy);}
|
||||
virtual void pasteFromClipboard() { processCommand(EditCommand::Paste);}
|
||||
virtual void undo() { processCommand(EditCommand::Undo);}
|
||||
virtual void redo() { processCommand(EditCommand::Redo);}
|
||||
virtual void zoomIn() { processCommand(EditCommand::ZoomIn);}
|
||||
virtual void zoomOut() { processCommand(EditCommand::ZoomOut);}
|
||||
virtual void selectAll() {
|
||||
commandProcessor(EditCommand::ecSelectAll);
|
||||
processCommand(EditCommand::SelectAll);
|
||||
}
|
||||
virtual void selectWord() {
|
||||
commandProcessor(EditCommand::ecSelWord);
|
||||
processCommand(EditCommand::SelWord);
|
||||
}
|
||||
virtual void tab() { commandProcessor(EditCommand::ecTab);}
|
||||
virtual void shifttab() { commandProcessor(EditCommand::ecShiftTab);}
|
||||
virtual void toggleComment() { commandProcessor(EditCommand::ecToggleComment);}
|
||||
virtual void toggleBlockComment() { commandProcessor(EditCommand::ecToggleBlockComment);}
|
||||
virtual void matchBracket() { commandProcessor(EditCommand::ecMatchBracket);}
|
||||
virtual void moveSelUp(){ commandProcessor(EditCommand::ecMoveSelUp);}
|
||||
virtual void moveSelDown(){ commandProcessor(EditCommand::ecMoveSelDown);}
|
||||
virtual void tab() { processCommand(EditCommand::Tab);}
|
||||
virtual void shifttab() { processCommand(EditCommand::ShiftTab);}
|
||||
virtual void toggleComment() { processCommand(EditCommand::ToggleComment);}
|
||||
virtual void toggleBlockComment() { processCommand(EditCommand::ToggleBlockComment);}
|
||||
virtual void matchBracket() { processCommand(EditCommand::MatchBracket);}
|
||||
virtual void moveSelUp(){ processCommand(EditCommand::MoveSelUp);}
|
||||
virtual void moveSelDown(){ processCommand(EditCommand::MoveSelDown);}
|
||||
|
||||
virtual void beginUpdate();
|
||||
virtual void endUpdate();
|
||||
|
@ -555,6 +549,7 @@ private:
|
|||
int doInsertTextByColumnMode(const BufferCoord& pos, const QStringList& text, BufferCoord &newPos, int startLine, int endLine);
|
||||
int doInsertTextByLineMode(const BufferCoord& pos, const QStringList& text, BufferCoord &newPos);
|
||||
|
||||
void doTrimTrailingSpaces();
|
||||
void deleteFromTo(const BufferCoord& start, const BufferCoord& end);
|
||||
void setSelWord();
|
||||
void setWordBlock(BufferCoord value);
|
||||
|
|
|
@ -389,9 +389,26 @@ void SynEditTextPainter::paintToken(const QString &token, int tokenCols, int col
|
|||
drawed = true;
|
||||
}
|
||||
if (!drawed) {
|
||||
if (token[i].unicode()<=0xFF)
|
||||
painter->drawText(nX,rcToken.bottom()-painter->fontMetrics().descent() , token[i]);
|
||||
else {
|
||||
if (token[i].unicode()<=0xFF) {
|
||||
QChar ch;
|
||||
int padding=0;
|
||||
if (edit->mOptions.testFlag(eoShowSpecialChars)) {
|
||||
switch(token[i].unicode()) {
|
||||
case '\t':
|
||||
ch=TabGlyph;
|
||||
padding=(charCols-1)/2*edit->mCharWidth;
|
||||
break;
|
||||
case ' ':
|
||||
ch=SpaceGlyph;
|
||||
break;
|
||||
default:
|
||||
ch=token[i];
|
||||
}
|
||||
} else {
|
||||
ch=token[i];
|
||||
}
|
||||
painter->drawText(nX+padding,rcToken.bottom()-painter->fontMetrics().descent() , ch);
|
||||
} else {
|
||||
painter->setFont(fontForNonAscii);
|
||||
painter->drawText(nX,rcToken.bottom()-painter->fontMetrics().descent() , token[i]);
|
||||
painter->setFont(font);
|
||||
|
|
|
@ -242,6 +242,8 @@ void ASMSyntaxer::SpaceProc()
|
|||
if (mLine[mRun] > 32)
|
||||
break;
|
||||
}
|
||||
if (mRun>=mStringLen)
|
||||
mHasTrailingSpaces = true;
|
||||
}
|
||||
|
||||
void ASMSyntaxer::StringProc()
|
||||
|
@ -441,17 +443,19 @@ bool ASMSyntaxer::isLastLineStringNotFinished(int /*state*/) const
|
|||
|
||||
SyntaxerState ASMSyntaxer::getState() const
|
||||
{
|
||||
return SyntaxerState();
|
||||
SyntaxerState state;
|
||||
state.hasTrailingSpaces = mHasTrailingSpaces;
|
||||
return state;
|
||||
}
|
||||
|
||||
void ASMSyntaxer::setState(const SyntaxerState&)
|
||||
{
|
||||
|
||||
mHasTrailingSpaces = false;
|
||||
}
|
||||
|
||||
void ASMSyntaxer::resetState()
|
||||
{
|
||||
|
||||
mHasTrailingSpaces = false;
|
||||
}
|
||||
|
||||
QSet<QString> ASMSyntaxer::keywords() const
|
||||
|
|
|
@ -61,6 +61,7 @@ private:
|
|||
QChar mToIdent;
|
||||
int mTokenPos;
|
||||
TokenId mTokenID;
|
||||
bool mHasTrailingSpaces;
|
||||
PTokenAttribute mNumberAttribute;
|
||||
PTokenAttribute mDirectiveAttribute;
|
||||
PTokenAttribute mRegisterAttribute;
|
||||
|
|
|
@ -290,20 +290,17 @@ void CppSyntaxer::andSymbolProc()
|
|||
void CppSyntaxer::ansiCppProc()
|
||||
{
|
||||
mTokenId = TokenId::Comment;
|
||||
if (mRun>=mLineSize) {
|
||||
nullProc();
|
||||
if ( (mRun-1<0) || (mLine[mRun-1]!='\\')) {
|
||||
mRange.state = RangeState::rsUnknown;
|
||||
}
|
||||
return;
|
||||
}
|
||||
while (mRun<mLineSize) {
|
||||
mRun+=1;
|
||||
if (isSpaceChar(mLine[mRun]))
|
||||
break;
|
||||
mRun++;
|
||||
}
|
||||
mRange.state = RangeState::rsCppCommentEnded;
|
||||
if (mRun == mLineSize-1 && mLine[mRun-1] == '\\' ) { // continues on next line
|
||||
if (mRun<mLineSize) {
|
||||
mRange.state = RangeState::rsCppComment;
|
||||
}
|
||||
} else if (mRun-1>=0 && mLine[mRun-1] == '\\' ) { // continues on next line
|
||||
mRange.state = RangeState::rsCppComment;
|
||||
} else
|
||||
mRange.state = RangeState::rsUnknown;
|
||||
}
|
||||
|
||||
void CppSyntaxer::ansiCProc()
|
||||
|
@ -316,6 +313,9 @@ void CppSyntaxer::ansiCProc()
|
|||
}
|
||||
while (mRun<mLineSize) {
|
||||
switch(mLine[mRun].unicode()) {
|
||||
case ' ':
|
||||
case '\t':
|
||||
return;
|
||||
case '*':
|
||||
if (mRun+1<mLineSize && mLine[mRun+1] == '/') {
|
||||
mRun += 2;
|
||||
|
@ -449,10 +449,7 @@ void CppSyntaxer::directiveProc()
|
|||
mRun+=1;
|
||||
}
|
||||
if (directive == "define") {
|
||||
while(mRun < mLineSize && isSpaceChar(mLine[mRun]))
|
||||
mRun++;
|
||||
mRange.state = RangeState::rsDefineIdentifier;
|
||||
return;
|
||||
} else
|
||||
mRange.state = RangeState::rsUnknown;
|
||||
}
|
||||
|
@ -460,6 +457,7 @@ void CppSyntaxer::directiveProc()
|
|||
void CppSyntaxer::defineIdentProc()
|
||||
{
|
||||
mTokenId = TokenId::Identifier;
|
||||
|
||||
while(mRun < mLineSize && isIdentChar(mLine[mRun]))
|
||||
mRun++;
|
||||
mRange.state = RangeState::rsDefineRemaining;
|
||||
|
@ -468,8 +466,11 @@ void CppSyntaxer::defineIdentProc()
|
|||
void CppSyntaxer::defineRemainingProc()
|
||||
{
|
||||
mTokenId = TokenId::Directive;
|
||||
do {
|
||||
while (mRun<mLineSize) {
|
||||
switch(mLine[mRun].unicode()) {
|
||||
case ' ':
|
||||
case '\t':
|
||||
return;
|
||||
case '/': //comment?
|
||||
if (mRun+1<mLineSize) {
|
||||
switch (mLine[mRun+1].unicode()) {
|
||||
|
@ -491,7 +492,7 @@ void CppSyntaxer::defineRemainingProc()
|
|||
break;
|
||||
}
|
||||
mRun+=1;
|
||||
} while (mRun<mLineSize);
|
||||
}
|
||||
mRange.state=RangeState::rsUnknown;
|
||||
}
|
||||
|
||||
|
@ -642,17 +643,6 @@ void CppSyntaxer::notSymbolProc()
|
|||
|
||||
void CppSyntaxer::nullProc()
|
||||
{
|
||||
if (
|
||||
(mRange.state == RangeState::rsCppComment
|
||||
|| mRange.state == RangeState::rsDirective
|
||||
|| mRange.state == RangeState::rsString
|
||||
|| mRange.state == RangeState::rsMultiLineString
|
||||
|| mRange.state == RangeState::rsMultiLineDirective)
|
||||
&& (mRun-1>=0)
|
||||
&& (mRun-1<mLineSize)
|
||||
&& isSpaceChar(mLine[mRun-1]) ) {
|
||||
mRange.state = RangeState::rsUnknown;
|
||||
} else
|
||||
mTokenId = TokenId::Null;
|
||||
}
|
||||
|
||||
|
@ -882,21 +872,23 @@ void CppSyntaxer::questionProc()
|
|||
void CppSyntaxer::rawStringProc()
|
||||
{
|
||||
bool noEscaping = false;
|
||||
if (mRange.state == RangeState::rsRawStringNotEscaping)
|
||||
noEscaping = true;
|
||||
mTokenId = TokenId::RawString;
|
||||
mRange.state = RangeState::rsRawString;
|
||||
|
||||
while (mRun<mLineSize) {
|
||||
if ((!noEscaping) && (mLine[mRun]=='"')) {
|
||||
if (!noEscaping && (mLine[mRun]=='"')) {
|
||||
mRun+=1;
|
||||
break;
|
||||
}
|
||||
switch (mLine[mRun].unicode()) {
|
||||
case ' ':
|
||||
case '\t':
|
||||
return;
|
||||
case '(':
|
||||
if (!noEscaping)
|
||||
noEscaping = true;
|
||||
break;
|
||||
case ')':
|
||||
if (noEscaping)
|
||||
noEscaping = false;
|
||||
break;
|
||||
}
|
||||
|
@ -984,7 +976,8 @@ void CppSyntaxer::spaceProc()
|
|||
mTokenId = TokenId::Space;
|
||||
while (mRun<mLineSize && mLine[mRun]>=1 && mLine[mRun]<=32)
|
||||
mRun+=1;
|
||||
mRange.state = RangeState::rsUnknown;
|
||||
if (mRun>=mLineSize)
|
||||
mRange.hasTrailingSpaces = true;
|
||||
}
|
||||
|
||||
void CppSyntaxer::squareCloseProc()
|
||||
|
@ -1015,60 +1008,62 @@ void CppSyntaxer::starProc()
|
|||
}
|
||||
}
|
||||
|
||||
void CppSyntaxer::stringEndProc()
|
||||
{
|
||||
mTokenId = TokenId::String;
|
||||
if (mRun>=mLineSize) {
|
||||
nullProc();
|
||||
return;
|
||||
}
|
||||
mRange.state = RangeState::rsUnknown;
|
||||
//void CppSyntaxer::stringEndProc()
|
||||
//{
|
||||
// mTokenId = TokenId::String;
|
||||
// if (mRun>=mLineSize) {
|
||||
// nullProc();
|
||||
// return;
|
||||
// }
|
||||
// mRange.state = RangeState::rsUnknown;
|
||||
|
||||
while (mRun<mLineSize) {
|
||||
if (mLine[mRun]=='"') {
|
||||
mRun += 1;
|
||||
break;
|
||||
}
|
||||
if (mLine[mRun]=='\\') {
|
||||
if (mRun == mLineSize-1) {
|
||||
mRun+=1;
|
||||
mRange.state = RangeState::rsMultiLineString;
|
||||
return;
|
||||
}
|
||||
if (mRun+1<mLineSize) {
|
||||
switch(mLine[mRun+1].unicode()) {
|
||||
case '\'':
|
||||
case '"':
|
||||
case '\\':
|
||||
case '?':
|
||||
case 'a':
|
||||
case 'b':
|
||||
case 'f':
|
||||
case 'n':
|
||||
case 'r':
|
||||
case 't':
|
||||
case 'v':
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
case 'x':
|
||||
case 'u':
|
||||
case 'U':
|
||||
mRange.state = RangeState::rsMultiLineStringEscapeSeq;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
mRun += 1;
|
||||
}
|
||||
}
|
||||
// while (mRun<mLineSize) {
|
||||
// if (mLine[mRun]=='"') {
|
||||
// mRun += 1;
|
||||
// break;
|
||||
// } else if (isSpaceChar(mLine[mRun])) {
|
||||
// mRange.state = RangeState::rsString;
|
||||
// return;
|
||||
// } else if (mLine[mRun]=='\\') {
|
||||
// if (mRun == mLineSize-1) {
|
||||
// mRun+=1;
|
||||
// mRange.state = RangeState::rsMultiLineString;
|
||||
// return;
|
||||
// }
|
||||
// if (mRun+1<mLineSize) {
|
||||
// switch(mLine[mRun+1].unicode()) {
|
||||
// case '\'':
|
||||
// case '"':
|
||||
// case '\\':
|
||||
// case '?':
|
||||
// case 'a':
|
||||
// case 'b':
|
||||
// case 'f':
|
||||
// case 'n':
|
||||
// case 'r':
|
||||
// case 't':
|
||||
// case 'v':
|
||||
// case '0':
|
||||
// case '1':
|
||||
// case '2':
|
||||
// case '3':
|
||||
// case '4':
|
||||
// case '5':
|
||||
// case '6':
|
||||
// case '7':
|
||||
// case '8':
|
||||
// case '9':
|
||||
// case 'x':
|
||||
// case 'u':
|
||||
// case 'U':
|
||||
// mRange.state = RangeState::rsMultiLineStringEscapeSeq;
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// mRun += 1;
|
||||
// }
|
||||
//}
|
||||
|
||||
void CppSyntaxer::stringEscapeSeqProc()
|
||||
{
|
||||
|
@ -1156,9 +1151,6 @@ void CppSyntaxer::stringEscapeSeqProc()
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (mRange.state == RangeState::rsMultiLineStringEscapeSeq)
|
||||
mRange.state = RangeState::rsMultiLineString;
|
||||
else
|
||||
mRange.state = RangeState::rsString;
|
||||
}
|
||||
|
||||
|
@ -1169,16 +1161,14 @@ void CppSyntaxer::stringProc()
|
|||
return;
|
||||
}
|
||||
mTokenId = TokenId::String;
|
||||
mRange.state = RangeState::rsString;
|
||||
while (mRun < mLineSize) {
|
||||
if (mLine[mRun]=='"') {
|
||||
mRun+=1;
|
||||
mRun++;
|
||||
break;
|
||||
}
|
||||
if (mLine[mRun]=='\\') {
|
||||
} else if (mLine[mRun]=='\\') {
|
||||
if (mRun == mLineSize-1) {
|
||||
mRun+=1;
|
||||
mRange.state = RangeState::rsMultiLineString;
|
||||
mRun++;
|
||||
mRange.state = RangeState::rsString;
|
||||
return;
|
||||
}
|
||||
if (mRun+1<mLineSize) {
|
||||
|
@ -1271,10 +1261,6 @@ void CppSyntaxer::processChar()
|
|||
case '{':
|
||||
braceOpenProc();
|
||||
break;
|
||||
case '\r':
|
||||
case '\n':
|
||||
spaceProc();
|
||||
break;
|
||||
case ':':
|
||||
colonProc();
|
||||
break;
|
||||
|
@ -1362,8 +1348,6 @@ void CppSyntaxer::processChar()
|
|||
default:
|
||||
if (isIdentChar(mLine[mRun])) {
|
||||
identProc();
|
||||
} else if (isSpaceChar(mLine[mRun])) {
|
||||
spaceProc();
|
||||
} else {
|
||||
unknownProc();
|
||||
}
|
||||
|
@ -1429,7 +1413,7 @@ bool CppSyntaxer::isLastLineCommentNotFinished(int state) const
|
|||
|
||||
bool CppSyntaxer::isLastLineStringNotFinished(int state) const
|
||||
{
|
||||
return state == RangeState::rsMultiLineString;
|
||||
return state == RangeState::rsString;
|
||||
}
|
||||
|
||||
bool CppSyntaxer::eol() const
|
||||
|
@ -1493,6 +1477,10 @@ void CppSyntaxer::next()
|
|||
mAsmStart = false;
|
||||
mTokenPos = mRun;
|
||||
do {
|
||||
if (mRun<mLineSize && isSpaceChar(mLine[mRun])) {
|
||||
spaceProc();
|
||||
break;
|
||||
}
|
||||
switch (mRange.state) {
|
||||
case RangeState::rsAnsiC:
|
||||
case RangeState::rsAnsiCAsm:
|
||||
|
@ -1513,17 +1501,11 @@ void CppSyntaxer::next()
|
|||
//qDebug()<<"*3-0-0*";
|
||||
directiveEndProc();
|
||||
break;
|
||||
case RangeState::rsMultiLineString:
|
||||
//qDebug()<<"*4-0-0*";
|
||||
stringEndProc();
|
||||
break;
|
||||
case RangeState::rsRawStringEscaping:
|
||||
case RangeState::rsRawStringNotEscaping:
|
||||
//qDebug()<<"*5-0-0*";
|
||||
rawStringProc();
|
||||
break;
|
||||
// case RangeState::rsMultiLineString:
|
||||
// //qDebug()<<"*4-0-0*";
|
||||
// stringEndProc();
|
||||
// break;
|
||||
case RangeState::rsStringEscapeSeq:
|
||||
case RangeState::rsMultiLineStringEscapeSeq:
|
||||
//qDebug()<<"*6-0-0*";
|
||||
stringEscapeSeqProc();
|
||||
break;
|
||||
|
@ -1601,6 +1583,7 @@ void CppSyntaxer::setState(const SyntaxerState& rangeState)
|
|||
mRange.blockEnded = 0;
|
||||
mRange.blockEndedLastLine = 0;
|
||||
mRange.firstIndentThisLine = mRange.indents.length();
|
||||
mRange.hasTrailingSpaces = false;
|
||||
mRange.matchingIndents.clear();
|
||||
}
|
||||
|
||||
|
@ -1617,6 +1600,7 @@ void CppSyntaxer::resetState()
|
|||
mRange.indents.clear();
|
||||
mRange.firstIndentThisLine = 0;
|
||||
mRange.matchingIndents.clear();
|
||||
mRange.hasTrailingSpaces = false;
|
||||
mAsmStart = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,9 +48,9 @@ class CppSyntaxer: public Syntaxer
|
|||
rsUnknown, rsAnsiC, rsAnsiCAsm, rsAnsiCAsmBlock, rsAsm,
|
||||
rsAsmBlock, rsDirective, rsDirectiveComment, rsString,
|
||||
rsMultiLineString, rsMultiLineDirective, rsCppComment,
|
||||
rsStringEscapeSeq, rsMultiLineStringEscapeSeq,
|
||||
rsRawString, rsSpace,rsRawStringEscaping,rsRawStringNotEscaping,rsChar,
|
||||
rsCppCommentEnded, rsDefineStart, rsDefineIdentifier, rsDefineRemaining
|
||||
rsStringEscapeSeq,
|
||||
rsRawString, rsSpace,rsRawStringNotEscaping,rsRawStringEnd,rsChar,
|
||||
rsDefineIdentifier, rsDefineRemaining
|
||||
};
|
||||
|
||||
public:
|
||||
|
@ -124,7 +124,7 @@ private:
|
|||
void squareCloseProc();
|
||||
void squareOpenProc();
|
||||
void starProc();
|
||||
void stringEndProc();
|
||||
// void stringEndProc();
|
||||
void stringEscapeSeqProc();
|
||||
void stringProc();
|
||||
void stringStartProc();
|
||||
|
|
|
@ -203,14 +203,8 @@ const PTokenAttribute &GLSLSyntaxer::localVarAttribute() const
|
|||
|
||||
GLSLSyntaxer::TokenId GLSLSyntaxer::getTokenId()
|
||||
{
|
||||
if ((mRange.state == RangeState::rsAsm || mRange.state == RangeState::rsAsmBlock)
|
||||
&& !mAsmStart && !(mTokenId == TokenId::Comment || mTokenId == TokenId::Space
|
||||
|| mTokenId == TokenId::Null)) {
|
||||
return TokenId::Asm;
|
||||
} else {
|
||||
return mTokenId;
|
||||
}
|
||||
}
|
||||
|
||||
void GLSLSyntaxer::andSymbolProc()
|
||||
{
|
||||
|
@ -259,11 +253,7 @@ void GLSLSyntaxer::ansiCProc()
|
|||
case '*':
|
||||
if (mLine[mRun+1] == '/') {
|
||||
mRun += 2;
|
||||
if (mRange.state == RangeState::rsAnsiCAsm) {
|
||||
mRange.state = RangeState::rsAsm;
|
||||
} else if (mRange.state == RangeState::rsAnsiCAsmBlock){
|
||||
mRange.state = RangeState::rsAsmBlock;
|
||||
} else if (mRange.state == RangeState::rsDirectiveComment &&
|
||||
if (mRange.state == RangeState::rsDirectiveComment &&
|
||||
mLine[mRun] != 0 && mLine[mRun]!='\r' && mLine[mRun]!='\n') {
|
||||
mRange.state = RangeState::rsMultiLineDirective;
|
||||
} else {
|
||||
|
@ -307,10 +297,6 @@ void GLSLSyntaxer::braceCloseProc()
|
|||
{
|
||||
mRun += 1;
|
||||
mTokenId = TokenId::Symbol;
|
||||
if (mRange.state == RangeState::rsAsmBlock) {
|
||||
mRange.state = rsUnknown;
|
||||
}
|
||||
|
||||
mRange.braceLevel -= 1;
|
||||
mRange.blockLevel -= 1;
|
||||
if (mRange.braceLevel<0) {
|
||||
|
@ -329,10 +315,6 @@ void GLSLSyntaxer::braceOpenProc()
|
|||
{
|
||||
mRun += 1;
|
||||
mTokenId = TokenId::Symbol;
|
||||
if (mRange.state == RangeState::rsAsm) {
|
||||
mRange.state = RangeState::rsAsmBlock;
|
||||
mAsmStart = true;
|
||||
}
|
||||
mRange.braceLevel += 1;
|
||||
mRange.blockLevel += 1;
|
||||
mRange.blockStarted += 1;
|
||||
|
@ -836,8 +818,6 @@ void GLSLSyntaxer::semiColonProc()
|
|||
{
|
||||
mRun += 1;
|
||||
mTokenId = TokenId::Symbol;
|
||||
if (mRange.state == RangeState::rsAsm)
|
||||
mRange.state = RangeState::rsUnknown;
|
||||
while (mRange.getLastIndent() == IndentForStatement) {
|
||||
popIndents(IndentForStatement);
|
||||
}
|
||||
|
@ -853,11 +833,7 @@ void GLSLSyntaxer::slashProc()
|
|||
return;
|
||||
case '*': // C style comment
|
||||
mTokenId = TokenId::Comment;
|
||||
if (mRange.state == RangeState::rsAsm) {
|
||||
mRange.state = RangeState::rsAnsiCAsm;
|
||||
} else if (mRange.state == RangeState::rsAsmBlock) {
|
||||
mRange.state = RangeState::rsAnsiCAsmBlock;
|
||||
} else if (mRange.state == RangeState::rsDirective) {
|
||||
if (mRange.state == RangeState::rsDirective) {
|
||||
mRange.state = RangeState::rsDirectiveComment;
|
||||
} else {
|
||||
mRange.state = RangeState::rsAnsiC;
|
||||
|
@ -883,6 +859,8 @@ void GLSLSyntaxer::spaceProc()
|
|||
while (mLine[mRun]>=1 && mLine[mRun]<=32)
|
||||
mRun+=1;
|
||||
mRange.state = RangeState::rsUnknown;
|
||||
if (mRun>=mLineSize)
|
||||
mRange.hasTrailingSpaces=true;
|
||||
}
|
||||
|
||||
void GLSLSyntaxer::squareCloseProc()
|
||||
|
@ -1284,8 +1262,6 @@ bool GLSLSyntaxer::getTokenFinished() const
|
|||
bool GLSLSyntaxer::isLastLineCommentNotFinished(int state) const
|
||||
{
|
||||
return (state == RangeState::rsAnsiC ||
|
||||
state == RangeState::rsAnsiCAsm ||
|
||||
state == RangeState::rsAnsiCAsmBlock ||
|
||||
state == RangeState::rsDirectiveComment||
|
||||
state == RangeState::rsCppComment);
|
||||
}
|
||||
|
@ -1353,13 +1329,10 @@ int GLSLSyntaxer::getTokenPos()
|
|||
|
||||
void GLSLSyntaxer::next()
|
||||
{
|
||||
mAsmStart = false;
|
||||
mTokenPos = mRun;
|
||||
do {
|
||||
switch (mRange.state) {
|
||||
case RangeState::rsAnsiC:
|
||||
case RangeState::rsAnsiCAsm:
|
||||
case RangeState::rsAnsiCAsmBlock:
|
||||
case RangeState::rsDirectiveComment:
|
||||
ansiCProc();
|
||||
break;
|
||||
|
@ -1439,6 +1412,7 @@ void GLSLSyntaxer::setState(const SyntaxerState& rangeState)
|
|||
mRange.blockEndedLastLine = 0;
|
||||
mRange.firstIndentThisLine = mRange.indents.length();
|
||||
mRange.matchingIndents.clear();
|
||||
mRange.hasTrailingSpaces = false;
|
||||
}
|
||||
|
||||
void GLSLSyntaxer::resetState()
|
||||
|
@ -1454,7 +1428,7 @@ void GLSLSyntaxer::resetState()
|
|||
mRange.indents.clear();
|
||||
mRange.firstIndentThisLine = 0;
|
||||
mRange.matchingIndents.clear();
|
||||
mAsmStart = false;
|
||||
mRange.hasTrailingSpaces = false;
|
||||
}
|
||||
|
||||
QString GLSLSyntaxer::languageName()
|
||||
|
|
|
@ -45,8 +45,7 @@ class GLSLSyntaxer: public Syntaxer
|
|||
};
|
||||
|
||||
enum RangeState {
|
||||
rsUnknown, rsAnsiC, rsAnsiCAsm, rsAnsiCAsmBlock, rsAsm,
|
||||
rsAsmBlock, rsDirective, rsDirectiveComment, rsString,
|
||||
rsUnknown, rsAnsiC, rsDirective, rsDirectiveComment, rsString,
|
||||
rsMultiLineString, rsMultiLineDirective, rsCppComment,
|
||||
rsStringEscapeSeq, rsMultiLineStringEscapeSeq,
|
||||
rsRawString, rsSpace,rsRawStringEscaping,rsRawStringNotEscaping,rsChar,
|
||||
|
@ -133,7 +132,6 @@ private:
|
|||
void pushIndents(int indentType);
|
||||
|
||||
private:
|
||||
bool mAsmStart;
|
||||
SyntaxerState mRange;
|
||||
// SynRangeState mSpaceRange;
|
||||
QString mLineString;
|
||||
|
|
|
@ -201,6 +201,8 @@ void MakefileSyntaxer::procSpace()
|
|||
mTokenID = TokenId::Space;
|
||||
while (mLine[mRun]!=0 && mLine[mRun]<=32)
|
||||
mRun++;
|
||||
if (mRun>=mStringLen)
|
||||
mHasTrailingSpaces = true;
|
||||
}
|
||||
|
||||
void MakefileSyntaxer::procNumber()
|
||||
|
@ -666,6 +668,7 @@ SyntaxerState MakefileSyntaxer::getState() const
|
|||
{
|
||||
SyntaxerState state;
|
||||
state.state = (int)mState;
|
||||
state.hasTrailingSpaces = mHasTrailingSpaces;
|
||||
return state;
|
||||
}
|
||||
|
||||
|
@ -673,12 +676,14 @@ void MakefileSyntaxer::setState(const SyntaxerState & rangeState)
|
|||
{
|
||||
mState = (RangeState)rangeState.state;
|
||||
mStates.clear();
|
||||
mHasTrailingSpaces = false;
|
||||
}
|
||||
|
||||
void MakefileSyntaxer::resetState()
|
||||
{
|
||||
mState = RangeState::Unknown;
|
||||
mStates.clear();
|
||||
mHasTrailingSpaces = false;
|
||||
}
|
||||
|
||||
QSet<QString> MakefileSyntaxer::keywords() const
|
||||
|
|
|
@ -79,6 +79,7 @@ private:
|
|||
QVector<RangeState> mStates;
|
||||
RangeState mState;
|
||||
TokenId mTokenID;
|
||||
bool mHasTrailingSpaces;
|
||||
|
||||
PTokenAttribute mTargetAttribute;
|
||||
PTokenAttribute mCommandAttribute;
|
||||
|
|
|
@ -274,7 +274,8 @@ SyntaxerState::SyntaxerState():
|
|||
parenthesisLevel(0),
|
||||
// leftBraces(0),
|
||||
// rightBraces(0),
|
||||
firstIndentThisLine(0)
|
||||
firstIndentThisLine(0),
|
||||
hasTrailingSpaces(false)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ struct SyntaxerState {
|
|||
QVector<int> matchingIndents; /* the indent matched ( and removed )
|
||||
but not started at this line
|
||||
(need by auto indent) */
|
||||
bool hasTrailingSpaces;
|
||||
bool operator==(const SyntaxerState& s2);
|
||||
int getLastIndent();
|
||||
SyntaxerState();
|
||||
|
|
Loading…
Reference in New Issue