Skip to content

Commit

Permalink
- fix: Installer should install the app in "program files", not "prog…
Browse files Browse the repository at this point in the history
…ram files (x86)"

 - fix: symbol completion for '/*' not work
 - fix: javadoc-style docstring indents calculation
  • Loading branch information
[email protected] authored and [email protected] committed Nov 7, 2021
1 parent 4d48cca commit c98e169
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 712 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Version 0.8.1 For Dev-C++ 7 Beta
- fix: one line 'while' statement dosen't correctly indents
- fix: line start with '{' that follow an un-ended 'if'/'for' statement is not correctly un-indented
- fix: multi-line comments indents calculation
- fix: Installer should install the app in "program files", not "program files (x86)"
- fix: symbol completion for '/*' not work
- fix: javadoc-style docstring indents calculation

Version 0.8 For Dev-C++ 7 Beta
- fix: find in the current file is not correcly saved in the search history
Expand Down
9 changes: 6 additions & 3 deletions RedPandaIDE/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
insertString.append(" * ");
insertString.append(QString(" * @return ")+USER_CODE_IN_INSERT_POS);
}
insertString.append(" **/");
insertString.append(" */");
// } else if (caretY()==1) { /* file header */
// insertString.append(QString(" * @file %1<SOURCEPATH>%2")
// .arg(USER_CODE_IN_REPL_POS_BEGIN)
Expand All @@ -597,7 +597,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
// insertString.append(" **/");
} else {
insertString.append(QString(" * ")+USER_CODE_IN_INSERT_POS);
insertString.append(" **/");
insertString.append(" */");
}
insertCodeSnippet(LinesToText(insertString));
} else if (highlighter()
Expand Down Expand Up @@ -1664,7 +1664,9 @@ bool Editor::handleSymbolCompletion(QChar key)
}
return false;
case '*':
qDebug()<<"???";
status = getQuoteStatus();
qDebug()<<(int)status;
if (pSettings->editor().completeComment() && (status == QuoteStatus::NotQuote)) {
return handleMultilineCommentCompletion();
}
Expand Down Expand Up @@ -1769,7 +1771,8 @@ bool Editor::handleBracketSkip()

bool Editor::handleMultilineCommentCompletion()
{
if (((caretX() > 1) && (caretX()-1 < lineText().length())) && (lineText()[caretX() - 1] == '/')) {
qDebug()<<caretX()-1<<" "<<lineText().length();
if ((caretX()-2 < lineText().length()) && (lineText()[caretX() - 2] == '/')) {
beginUpdate();
commandProcessor(SynEditorCommand::ecChar,'*');
BufferCoord oldCaret = caretXY();
Expand Down
2 changes: 2 additions & 0 deletions RedPandaIDE/icons.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -487,5 +487,7 @@
<file>images/classparser/var_protected.ico</file>
<file>images/classparser/var_public.ico</file>
<file>images/editor/bookmark.png</file>
<file>images/newlook24/091-openproblemanswer.png</file>
<file>images/newlook24/092-runallproblemcases.png</file>
</qresource>
</RCC>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions RedPandaIDE/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/images/newlook24/047-makefl.png</normaloff>:/icons/images/newlook24/047-makefl.png</iconset>
<normaloff>:/icons/images/newlook24/091-openproblemanswer.png</normaloff>:/icons/images/newlook24/091-openproblemanswer.png</iconset>
</property>
</widget>
</item>
Expand All @@ -1254,7 +1254,7 @@
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/images/newlook24/069-run.png</normaloff>:/icons/images/newlook24/069-run.png</iconset>
<normaloff>:/icons/images/newlook24/092-runallproblemcases.png</normaloff>:/icons/images/newlook24/092-runallproblemcases.png</iconset>
</property>
</widget>
</item>
Expand Down
50 changes: 13 additions & 37 deletions RedPandaIDE/qsynedit/SynEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,9 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent)
SynRangeState rangePreceeding = mLines->ranges(startLine-1);
mHighlighter->setState(rangePreceeding);
if (addIndent) {
mHighlighter->setLine(lineText.trimmed(),line-1);
QString trimmedS = s.trimmed();
QString trimmedLineText = lineText.trimmed();
mHighlighter->setLine(trimmedLineText,line-1);
SynRangeState rangeAfterFirstToken = mHighlighter->getRangeState();
QString firstToken = mHighlighter->getToken();
PSynHighlighterAttribute attr = mHighlighter->getTokenAttribute();
Expand All @@ -1436,7 +1438,7 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent)
attr = mHighlighter->getTokenAttribute();
}
bool dontAddIndent = false;
bool addOwnIndent = false;
int additionIndent = 0;
QVector<int> matchingIndents;
int l;
if (attr == mHighlighter->symbolAttribute()
Expand All @@ -1446,12 +1448,12 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent)
dontAddIndent = true;
l = startLine;
} else if (mHighlighter->isLastLineCommentNotFinished(rangePreceeding.state)
&& (lineText.startsWith(' ')
|| lineText.startsWith('\t'))
&& (trimmedLineText.startsWith("*"))
) {
// last line is a not finished comment, and this line start with indents
// we should use indents of the line comment beginning, plus this line's indents
addOwnIndent=true;
// last line is a not finished comment, and this line start with "*"
// it means this line is a docstring, should indents according to
// the line the comment beginning , and add 1 additional space
additionIndent = 1;
int commentStartLine = startLine-1;
SynRangeState range;
while (commentStartLine>=1) {
Expand All @@ -1472,33 +1474,9 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent)
matchingIndents = range.matchingIndents;
dontAddIndent = true;
l = commentStartLine;
} else if (mHighlighter->isLastLineStringNotFinished(rangePreceeding.state)
&& (lineText.startsWith(' ')
|| lineText.startsWith('\t'))
) {
// last line is a not finished string, and this line start with indents
// we should use indents of the line string beginning, plus this line's indents
addOwnIndent=true;
int commentStartLine = startLine-1;
SynRangeState range;
while (commentStartLine>=1) {
range = mLines->ranges(commentStartLine-1);
if (!mHighlighter->isLastLineStringNotFinished(range.state)){
commentStartLine++;
break;
}
if (!range.matchingIndents.isEmpty()
|| range.firstIndentThisLine<range.indents.length())
break;
commentStartLine--;
}
if (commentStartLine<1)
commentStartLine = 1;
indentSpaces = leftSpaces(mLines->getString(commentStartLine-1));
range = mLines->ranges(commentStartLine-1);
matchingIndents = range.matchingIndents;
dontAddIndent = true;
l = commentStartLine;
} else if (trimmedS.startsWith("*")) {
// fix indents for line like " */"
indentSpaces--;
} else {
// we just use infos till preceeding line's end to calc indents
matchingIndents = rangePreceeding.matchingIndents;
Expand Down Expand Up @@ -1564,9 +1542,7 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent)
dontAddIndent = true;
}
}
if (addOwnIndent) {
indentSpaces += leftSpaces(lineText);
}
indentSpaces += additionIndent;
}
}
return std::max(0,indentSpaces);
Expand Down
1 change: 0 additions & 1 deletion RedPandaIDE/qsynedit/highlighter/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ bool SynRangeState::operator==(const SynRangeState &s2)
{
// indents contains the information of brace/parenthesis/brackets embedded levels
return (state == s2.state)
&& (spaceState == s2.spaceState)
&& (indents == s2.indents)
;
}
Expand Down
1 change: 0 additions & 1 deletion RedPandaIDE/qsynedit/highlighter/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ enum SynIndentType {

struct SynRangeState {
int state; // current syntax parsing state
int spaceState; // the last syntax parsing state before meeting space
int braceLevel; // current braces embedding level (needed by rainbow color)
int bracketLevel; // current brackets embedding level (needed by rainbow color)
int parenthesisLevel; // current parenthesis embedding level (needed by rainbow color)
Expand Down
53 changes: 1 addition & 52 deletions RedPandaIDE/qsynedit/highlighter/cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,6 @@ void SynEditCppHighlighter::ansiCppProc()
}
}
while (mLine[mRun]!=0) {
if ( isSpaceChar(mLine[mRun]) ) {
mRange.spaceState = mRange.state;
mRange.state = RangeState::rsSpace;
return;
}
mRun+=1;
}
mRange.state = RangeState::rsCppCommentEnded;
Expand Down Expand Up @@ -321,12 +316,6 @@ void SynEditCppHighlighter::ansiCProc()
} else
mRun+=1;
break;
case 9:
case 32:
mRange.spaceState = mRange.state;
mRange.state = RangeState::rsSpace;
finishProcess = true;
break;
default:
mRun+=1;
}
Expand All @@ -339,11 +328,6 @@ void SynEditCppHighlighter::asciiCharProc()
{
mTokenId = TokenKind::Char;
do {
if (isSpaceChar(mLine[mRun])) {
mRange.spaceState = RangeState::rsChar;
mRange.state = RangeState::rsSpace;
return;
}
if (mLine[mRun] == '\\') {
if (mLine[mRun+1] == '\'' || mLine[mRun+1] == '\\') {
mRun+=1;
Expand Down Expand Up @@ -436,11 +420,6 @@ void SynEditCppHighlighter::directiveProc()
}
mTokenId = TokenKind::Directive;
do {
if (isSpaceChar(mLine[mRun])) {
mRange.spaceState = RangeState::rsMultiLineDirective;
mRange.state = RangeState::rsSpace;
return;
}
switch(mLine[mRun].unicode()) {
case '/': //comment?
switch (mLine[mRun+1].unicode()) {
Expand Down Expand Up @@ -473,11 +452,6 @@ void SynEditCppHighlighter::directiveEndProc()
}
mRange.state = RangeState::rsUnknown;
do {
if (isSpaceChar(mLine[mRun])) {
mRange.spaceState = RangeState::rsMultiLineDirective;
mRange.state = RangeState::rsSpace;
return;
}
switch(mLine[mRun].unicode()) {
case '/': //comment?
switch (mLine[mRun+1].unicode()) {
Expand Down Expand Up @@ -887,16 +861,6 @@ void SynEditCppHighlighter::rawStringProc()
case ')':
noEscaping = false;
break;
case ' ':
case '\t':
mRange.state = rsSpace;
if (noEscaping) {
mRange.spaceState = RangeState::rsRawStringNotEscaping;
} else {
mRange.spaceState = RangeState::rsRawStringEscaping;
}
return;
break;
}
mRun+=1;
}
Expand Down Expand Up @@ -974,8 +938,7 @@ void SynEditCppHighlighter::spaceProc()
mTokenId = TokenKind::Space;
while (mLine[mRun]>=1 && mLine[mRun]<=32)
mRun+=1;
mRange.state = mRange.spaceState;
mRange.spaceState = RangeState::rsUnknown;
mRange.state = RangeState::rsUnknown;
}

void SynEditCppHighlighter::squareCloseProc()
Expand Down Expand Up @@ -1022,11 +985,6 @@ void SynEditCppHighlighter::stringEndProc()
mRun += 1;
break;
}
if (isSpaceChar(mLine[mRun])) {
mRange.spaceState = RangeState::rsMultiLineString;
mRange.state = RangeState::rsSpace;
return;
}
if (mLine[mRun].unicode()=='\\') {
switch(mLine[mRun+1].unicode()) {
case '\'':
Expand Down Expand Up @@ -1160,11 +1118,6 @@ void SynEditCppHighlighter::stringProc()
mRun+=1;
break;
}
if (isSpaceChar(mLine[mRun])) {
mRange.spaceState = RangeState::rsString;
mRange.state = RangeState::rsSpace;
return;
}
if (mLine[mRun].unicode()=='\\') {
switch(mLine[mRun+1].unicode()) {
case '\'':
Expand Down Expand Up @@ -1488,9 +1441,6 @@ void SynEditCppHighlighter::next()
case RangeState::rsMultiLineString:
stringEndProc();
break;
case RangeState::rsSpace:
spaceProc();
break;
case RangeState::rsRawStringEscaping:
case RangeState::rsRawStringNotEscaping:
rawStringProc();
Expand Down Expand Up @@ -1608,7 +1558,6 @@ void SynEditCppHighlighter::setState(const SynRangeState& rangeState)
void SynEditCppHighlighter::resetState()
{
mRange.state = RangeState::rsUnknown;
mRange.spaceState = RangeState::rsUnknown;
mRange.braceLevel = 0;
mRange.bracketLevel = 0;
mRange.parenthesisLevel = 0;
Expand Down
Loading

0 comments on commit c98e169

Please sign in to comment.