diff --git a/NEWS.md b/NEWS.md index f27be844..8640ba59 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ Version 0.7.0 - fix: Backspace still works in readonly mode - fix: save as file dialog's operation mode is not correct + - enhancement: fill indents in the editor (Turned off by default) Version 0.6.8 - enhancement: add link to cppreference in the help menu diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.qm b/RedPandaIDE/RedPandaIDE_zh_CN.qm index 20a92073..5292606d 100644 Binary files a/RedPandaIDE/RedPandaIDE_zh_CN.qm and b/RedPandaIDE/RedPandaIDE_zh_CN.qm differ diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.ts b/RedPandaIDE/RedPandaIDE_zh_CN.ts index 7ecf54f0..c3f7a47d 100644 --- a/RedPandaIDE/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/RedPandaIDE_zh_CN.ts @@ -933,11 +933,11 @@ Are you really want to continue? - - + - + + Error 错误 @@ -947,60 +947,60 @@ Are you really want to continue? 无法写入文件"%1" - + Save As 另存为 - + The text to be copied exceeds count limit! 要复制的内容超过了行数限制! - + The text to be copied exceeds character limit! 要复制的内容超过了字符数限制! - + The text to be cut exceeds count limit! 要剪切的内容超过了行数限制! - + The text to be cut exceeds character limit! 要剪切的内容超过了字符数限制! - + Print Document 打印文档 - - - + + + Ctrl+click for more info Ctrl+单击以获取更多信息 - - + + Symbol '%1' not found! 未找到符号'%1'! - + Break point condition 断点条件 - + Enter the condition of the breakpoint: 输入当前断点的生效条件: - + Readonly 只读 @@ -4857,175 +4857,175 @@ Are you really want to continue? 无法载入自动链接设置 - - + + The following %1 directories don't exist: 下列%1文件夹不存在: - - + + binary 二进制 - + No %1 directories have been specified. 未指定%1文件夹 - + C include C包含 - + C++ include C++包含 - - - - + + + + Cannot find the %1 "%2" 无法找到%1程序"%2" - + C options C语言选项 - + Support all ANSI standard C programs (-ansi) 支持所有ANSI标准C程序(-ansi) - + Do not recognize asm,inline or typeof as a keyword (-fno-asm) 不支持将asm、inline和typeof作为关键字(-fno-asm) - + Imitate traditional C preprocessors (-traditional-cpp) 模仿传统C预处理器行为(-traditional-cpp) - + Code Generation 代码生成 - + Optimize for the following machine (-march) 生成特定机器的专用指令(-march) - + Optimize less, while maintaining full compatibility (-tune) 完整兼容特定机器,较少优化(-tune) - + Enable use of specific instructions (-mx) 启用特定指令集(-mx) - + Optimization level (-Ox) 优化级别(-Ox) - + Compile with the following pointer size (-mx) 使用下列指针大小编译(-mx) - + Language standard (-std) 语言标准(-std) - + Profile 性能分析 - + Generate debugging information (-g3) 生成调试信息(-g3) - + Generate profiling info for analysis (-pg) 生成性能分析信息(-pg) - + Warnings 代码警告 - + Inhibit all warning messages (-w) 忽略所有警告信息(-w) - + Show most warnings (-Wall) 启用常见问题警告(-Wall) - + Show some more warnings (-Wextra) 启用更多问题警告(-Wextra) - + Check ISO C/C++/C++0x conformance (-pedantic) 检查ISO C/C++/C++0x语法一致性(-pedantic) - + Only check the code for syntax errors (-fsyntax-only) 只进行语法检查(不编译)(-fsyntax-only) - + Make all warnings into errors (-Werror) 将警告作为错误处理(-Werror) - + Abort compilation on first error (-Wfatal-errors) 遇到第一个错误后立即中止编译(-Wfatal-errors) - + Linker 链接器 - + Link an Objective C program (-lobjc) 链接Objective-C程序 (-lobjc) - + Do not use standard system libraries (-nostdlib) 不使用标准库和系统启动文件(-nostdlib) - + Do not create a console window (-mwindows) 不产生控制台窗口(-mwindows) - + Strip executable (-s) 剥除附加信息(-s) @@ -5034,43 +5034,43 @@ Are you really want to continue? 链接Ojbective C程序(-lobjc) - + Output 输出 - + Put comments in generated assembly code (-fverbose-asm) 在生成的汇编代码中加入注释(-fverbose-asm) - + Use pipes instead of temporary files during compilation (-pipe) 编译时使用管道而不是临时文件(-pipe) - + Do not assemble, compile and generate the assemble code (-S) 只生成汇编代码(-S) - - + + Confirm 确认 - + The following problems were found during validation of compiler set "%1": 在验证编译器设置"%1"时遇到了下列问题: - + Compiler set not configuared. 未配置编译器设置。 - + Would you like Red Panda C++ to search for compilers in the following locations: <BR />'%1'<BR />'%2'? 您需要小熊猫C++在下列位置搜索编译器吗:<br />%1<br />%2 @@ -6097,8 +6097,8 @@ Are you really want to continue? SynEdit - - + + The highlighter seems to be in an infinite loop 高亮处理进入了死循环 @@ -6320,87 +6320,92 @@ Are you really want to continue? 缩进提示线颜色 - + + Fill Indents + 填充缩进区域 + + + Caret 光标 - + Move caret to the first non-space char in the current line when press HOME key 按下HOME键时,光标定位在本行的第一个非空格字符处 - + Move caret to the last non-space char in the current line when press END key 按下End键时,光标定位在本行的最后一个非空格字符处 - + Keep X position of the caret when moving vertically 在上下移动光标时,记住起始时光标所在栏数 - + Caret for inserting mode 插入状态下的光标 - + Use text color as caret color 使用文字颜色作为光标颜色 - + Scroll 滚动条 - + Auto hide scroll bars 自动隐藏滚动条 - + Can scroll the last char to the left edge of the editor 可以将每行末尾字符滚动到编辑器最左侧 - + Can scroll the last line to the top edge of the editor 可以将最后一行滚动到编辑器最上方 - + Page Up/Down scrolls half a page 翻页键只滚动半页 - + Forces page scroll to be one line less 在滚动页时少滚动一行 - + Show right edge line 显示右边缘线 - + Right egde width 右边缘宽度 - + Right edge line color 右边缘颜色 - + Caret for overwriting mode 覆写状态下的光标 - + Caret Color 光标颜色 diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index d99ba82e..10c33532 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -3581,6 +3581,7 @@ void Editor::applySettings() codeFolding().indentGuides = pSettings->editor().showIndentLines(); codeFolding().indentGuidesColor = pSettings->editor().indentLineColor(); + codeFolding().fillIndents = pSettings->editor().fillIndents(); QFont f=QFont(pSettings->editor().fontName(),pSettings->editor().fontSize()); f.setStyleStrategy(QFont::PreferAntialias); diff --git a/RedPandaIDE/qsynedit/CodeFolding.cpp b/RedPandaIDE/qsynedit/CodeFolding.cpp index 7eb65b99..7724cb59 100644 --- a/RedPandaIDE/qsynedit/CodeFolding.cpp +++ b/RedPandaIDE/qsynedit/CodeFolding.cpp @@ -23,6 +23,7 @@ PSynEditFoldRegion SynEditFoldRegions::get(int index) } SynEditCodeFolding::SynEditCodeFolding(): + fillIndents(false), indentGuides(true), showCollapsedLine(true), collapsedLineColor(QColor("black")), diff --git a/RedPandaIDE/qsynedit/CodeFolding.h b/RedPandaIDE/qsynedit/CodeFolding.h index 1dbf6689..41e0004e 100644 --- a/RedPandaIDE/qsynedit/CodeFolding.h +++ b/RedPandaIDE/qsynedit/CodeFolding.h @@ -29,6 +29,7 @@ struct SynEditFoldRegion { struct SynEditCodeFolding { bool indentGuides; + bool fillIndents; bool showCollapsedLine; QColor collapsedLineColor; QColor folderBarLinesColor; diff --git a/RedPandaIDE/qsynedit/TextPainter.cpp b/RedPandaIDE/qsynedit/TextPainter.cpp index 6182bdb9..522034a6 100644 --- a/RedPandaIDE/qsynedit/TextPainter.cpp +++ b/RedPandaIDE/qsynedit/TextPainter.cpp @@ -650,12 +650,17 @@ void SynEditTextPainter::PaintFoldAttributes() // Paint indent guides. Use folds to determine indent value of these // Use a separate loop so we can use a custom pen // Paint indent guides using custom pen - if (edit->mCodeFolding.indentGuides) { - QPen dottedPen(Qt::PenStyle::DashLine); - dottedPen.setColor(edit->mCodeFolding.indentGuidesColor); - + if (edit->mCodeFolding.indentGuides || edit->mCodeFolding.fillIndents) { + QColor paintColor; + if (edit->mCodeFolding.indentGuidesColor.isValid()) { + paintColor = edit->mCodeFolding.indentGuidesColor; + } else { + paintColor = edit->palette().color(QPalette::Text); + } + QColor gradientStart = paintColor; + QColor gradientEnd = paintColor; QPen oldPen = painter->pen(); - painter->setPen(dottedPen); + // Now loop through all the lines. The indices are valid for Lines. for (cRow = aFirstRow; cRow<=aLastRow;cRow++) { vLine = edit->rowToLine(cRow); @@ -682,21 +687,43 @@ void SynEditTextPainter::PaintFoldAttributes() //TabSteps = edit->mTabWidth; TabSteps = 0; indentLevel = 0; + while (TabSteps < LineIndent) { X = TabSteps * edit->mCharWidth + edit->textOffset() - 2; TabSteps+=edit->mTabWidth; indentLevel++ ; if (edit->mHighlighter) { - PSynHighlighterAttribute attr = edit->mHighlighter->symbolAttribute(); - GetBraceColorAttr(indentLevel,attr); - if (attr!=edit->mHighlighter->symbolAttribute()) { - dottedPen.setColor(attr->foreground()); - painter->setPen(dottedPen); + if (edit->mCodeFolding.indentGuides) { + PSynHighlighterAttribute attr = edit->mHighlighter->symbolAttribute(); + GetBraceColorAttr(indentLevel,attr); + paintColor = attr->foreground(); } + if (edit->mCodeFolding.fillIndents) { + PSynHighlighterAttribute attr = edit->mHighlighter->symbolAttribute(); + GetBraceColorAttr(indentLevel,attr); + gradientStart=attr->foreground(); + attr = edit->mHighlighter->symbolAttribute(); + GetBraceColorAttr(indentLevel+1,attr); + gradientStart=attr->foreground(); + } + } + if (edit->mCodeFolding.fillIndents) { + int X1=TabSteps * edit->mCharWidth + edit->textOffset() - 2; + gradientStart.setAlpha(20); + gradientEnd.setAlpha(10); + QLinearGradient gradient(X,Y,X1,Y); + gradient.setColorAt(0,gradientStart); + gradient.setColorAt(1,gradientEnd); + painter->fillRect(X,Y,edit->mTabWidth * edit->mCharWidth,edit->mTextHeight,gradient); } // Move to top of vertical line - painter->drawLine(X,Y,X,Y+edit->mTextHeight); + if (edit->mCodeFolding.indentGuides) { + QPen dottedPen(Qt::PenStyle::DashLine); + dottedPen.setColor(paintColor); + painter->setPen(dottedPen); + painter->drawLine(X,Y,X,Y+edit->mTextHeight); + } } } painter->setPen(oldPen); @@ -920,18 +947,24 @@ void SynEditTextPainter::PaintLines() } // It's at least partially visible. Get the token attributes now. attr = edit->mHighlighter->getTokenAttribute(); - if (sToken == "[") { - GetBraceColorAttr(edit->mHighlighter->getRangeState().bracketLevel,attr); - } else if (sToken == "]") { - GetBraceColorAttr(edit->mHighlighter->getRangeState().bracketLevel+1,attr); - } else if (sToken == "(") { - GetBraceColorAttr(edit->mHighlighter->getRangeState().parenthesisLevel,attr); - } else if (sToken == ")") { - GetBraceColorAttr(edit->mHighlighter->getRangeState().parenthesisLevel+1,attr); - } else if (sToken == "{") { - GetBraceColorAttr(edit->mHighlighter->getRangeState().braceLevel,attr); - } else if (sToken == "}") { - GetBraceColorAttr(edit->mHighlighter->getRangeState().braceLevel+1,attr); + if (sToken == "[" + || sToken == "(" + || sToken == "{" + ) { + SynRangeState rangeState = edit->mHighlighter->getRangeState(); + GetBraceColorAttr(rangeState.bracketLevel + +rangeState.braceLevel + +rangeState.parenthesisLevel + ,attr); + } else if (sToken == "]" + || sToken == ")" + || sToken == "}" + ){ + SynRangeState rangeState = edit->mHighlighter->getRangeState(); + GetBraceColorAttr(rangeState.bracketLevel + +rangeState.braceLevel + +rangeState.parenthesisLevel+1, + attr); } if (bCurrentLine && edit->mInputPreeditString.length()>0) { int startPos = edit->mHighlighter->getTokenPos()+1; diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 99217cf9..406cb7af 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -487,6 +487,16 @@ void Settings::Editor::setShowFunctionTips(bool newShowFunctionTips) mShowFunctionTips = newShowFunctionTips; } +bool Settings::Editor::fillIndents() const +{ + return mfillIndents; +} + +void Settings::Editor::setFillIndents(bool newFillIndents) +{ + mfillIndents = newFillIndents; +} + bool Settings::Editor::enableTooltips() const { return mEnableTooltips; @@ -957,6 +967,7 @@ void Settings::Editor::doSave() saveValue("tab_width", mTabWidth); saveValue("show_indent_lines", mShowIndentLines); saveValue("indent_line_color",mIndentLineColor); + saveValue("fill_indents",mfillIndents); // caret saveValue("enhance_home_key",mEnhanceHomeKey); saveValue("enhance_end_key",mEnhanceEndKey); @@ -1063,6 +1074,7 @@ void Settings::Editor::doLoad() mTabWidth = intValue("tab_width",4); mShowIndentLines = boolValue("show_indent_lines",true); mIndentLineColor = colorValue("indent_line_color",QColorConstants::Svg::silver); + mfillIndents = boolValue("fill_indents", false); // caret mEnhanceHomeKey = boolValue("enhance_home_key", true); mEnhanceEndKey = boolValue("enhance_end_key",true); diff --git a/RedPandaIDE/settings.h b/RedPandaIDE/settings.h index 2b3d89c7..f2893888 100644 --- a/RedPandaIDE/settings.h +++ b/RedPandaIDE/settings.h @@ -320,6 +320,9 @@ public: bool showFunctionTips() const; void setShowFunctionTips(bool newShowFunctionTips); + bool fillIndents() const; + void setFillIndents(bool newFillIndents); + private: //General // indents @@ -329,6 +332,7 @@ public: int mTabWidth; bool mShowIndentLines; QColor mIndentLineColor; + bool mfillIndents; // caret bool mEnhanceHomeKey; bool mEnhanceEndKey; diff --git a/RedPandaIDE/settingsdialog/editorgeneralwidget.cpp b/RedPandaIDE/settingsdialog/editorgeneralwidget.cpp index 88f7831d..40e10921 100644 --- a/RedPandaIDE/settingsdialog/editorgeneralwidget.cpp +++ b/RedPandaIDE/settingsdialog/editorgeneralwidget.cpp @@ -44,6 +44,7 @@ void EditorGeneralWidget::doLoad() ui->spTabWidth->setValue(pSettings->editor().tabWidth()); ui->chkShowIndentLines->setChecked(pSettings->editor().showIndentLines()); ui->colorIndentLine->setColor(pSettings->editor().indentLineColor()); + ui->chkFillIndents->setChecked(pSettings->editor().fillIndents()); //carets ui->chkEnhanceHome->setChecked(pSettings->editor().enhanceHomeKey()); ui->chkEnhanceEndKey->setChecked(pSettings->editor().enhanceEndKey()); @@ -73,6 +74,8 @@ void EditorGeneralWidget::doSave() pSettings->editor().setTabWidth(ui->spTabWidth->value()); pSettings->editor().setShowIndentLines(ui->chkShowIndentLines->isChecked()); pSettings->editor().setIndentLineColor(ui->colorIndentLine->color()); + pSettings->editor().setFillIndents(ui->chkFillIndents->isChecked()); + //carets pSettings->editor().setEnhanceHomeKey(ui->chkEnhanceHome->isChecked()); pSettings->editor().setEnhanceEndKey(ui->chkEnhanceEndKey->isChecked()); diff --git a/RedPandaIDE/settingsdialog/editorgeneralwidget.ui b/RedPandaIDE/settingsdialog/editorgeneralwidget.ui index aa26d386..2edd34b8 100644 --- a/RedPandaIDE/settingsdialog/editorgeneralwidget.ui +++ b/RedPandaIDE/settingsdialog/editorgeneralwidget.ui @@ -120,6 +120,13 @@ + + + + Fill Indents + + + diff --git a/RedPandaIDE/systemconsts.h b/RedPandaIDE/systemconsts.h index b9ffa4bd..324224fd 100644 --- a/RedPandaIDE/systemconsts.h +++ b/RedPandaIDE/systemconsts.h @@ -5,8 +5,8 @@ #define DEVCPP_VERSION "0.6.9" -#ifdef Q_OS_WIN #define APP_SETTSINGS_FILENAME "redpandacpp.ini" +#ifdef Q_OS_WIN #define GCC_PROGRAM "gcc.exe" #define GPP_PROGRAM "g++.exe" #define GDB_PROGRAM "gdb.exe" @@ -16,8 +16,17 @@ #define GPROF_PROGRAM "gprof.exe" #define CLEAN_PROGRAM "del /q /f" #define CPP_PROGRAM "cpp.exe" +#elif defined(Q_OS_LINUX) +#define GCC_PROGRAM "gcc" +#define GPP_PROGRAM "g++" +#define GDB_PROGRAM "gdb" +#define GDB32_PROGRAM "gdb32" +#define MAKE_PROGRAM "make" +#define GPROF_PROGRAM "gprof" +#define CLEAN_PROGRAM "rm -rf" +#define CPP_PROGRAM "cpp" #else -#error "Only support windows now!" +#error "Only support windows and linux now!" #endif #define DEV_PROJECT_EXT "dev" @@ -46,7 +55,7 @@ # define STATIC_LIB_EXT "a" # define DYNAMIC_LIB_EXT "dll" # define MAKEFILE_NAME "makefile.win" -#elif Q_OS_LINUX +#elif defined(Q_OS_LINUX) # define PATH_SENSITIVITY Qt::CaseSensitive # define PATH_SEPARATOR ":" # define NULL_FILE "/dev/null"