Merge branch 'master' of github.com:royqh1979/RedPanda-CPP

This commit is contained in:
Roy Qu 2023-04-25 20:09:06 +08:00
commit b93dac458a
19 changed files with 466 additions and 345 deletions

11
NEWS.md
View File

@ -1,3 +1,14 @@
Red Panda C++ Version 2.21
- change: The option "Check for stack smashing attacks (-fstack-protector)" is turned off by default in the Debug compiler set settings.
- fix: Project makefile generated for C files is not correct.
- fix: Horizontal scroll by touchpad is not working.
- fix: Horizontal scroll by touchpad is inversed.
- fix: Error message when save bookmarks.
- enhancement: Auto skip ; and , when input.
- enhancement: Add 'characters' column in the file properties dialog.
- enhancement: Just keeping two digits after the decimal point for file size in the file properties dialog.
Red Panda C++ Version 2.20
- change: Remove the compiler set option "Syntax error when object larger than"

View File

@ -8,7 +8,7 @@ isEmpty(APP_NAME) {
}
isEmpty(APP_VERSION) {
APP_VERSION = 2.20
APP_VERSION = 2.21
}
contains(QMAKE_HOST.arch, x86_64):{

View File

@ -467,12 +467,12 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file)
}
}
if (fileType==FileType::CppSource || fileType==FileType::CppSource) {
if (fileType==FileType::CSource || fileType==FileType::CppSource) {
if (mOnlyCheckSyntax) {
if (unit->compileCpp())
writeln(file, "\t$(CPP) -c " + genMakePath1(shortFileName) + " $(CXXFLAGS) " + encodingStr);
else
writeln(file, "\t(CC) -c " + genMakePath1(shortFileName) + " $(CFLAGS) " + encodingStr);
writeln(file, "\t$(CC) -c " + genMakePath1(shortFileName) + " $(CFLAGS) " + encodingStr);
} else {
if (unit->compileCpp())
writeln(file, "\t$(CPP) -c " + genMakePath1(shortFileName) + " -o " + objFileName2 + " $(CXXFLAGS) " + encodingStr);

View File

@ -745,7 +745,13 @@ void Debugger::save(const QString &filename, const QString& projectFolder)
foreach (const PWatchVar& watchVar, watchVars) {
watchVarCompareSet.insert(watchVar->expression);
}
std::shared_ptr<DebugConfig> pConfig = load(filename, forProject);
std::shared_ptr<DebugConfig> pConfig;
try {
pConfig = load(filename, forProject);
} catch (FileError& e) {
}
QFile file(filename);
if (file.open(QFile::WriteOnly | QFile::Truncate)) {
foreach (const PBreakpoint& breakpoint, pConfig->breakpoints) {

View File

@ -1005,6 +1005,8 @@ void Editor::keyPressEvent(QKeyEvent *event)
case ']':
case '<':
case '*':
case ';':
case ',':
handled = handleSymbolCompletion(ch);
return;
case '(': {
@ -2561,6 +2563,20 @@ bool Editor::handleSymbolCompletion(QChar key)
return handleGlobalIncludeSkip();
}
return false;
case ';':
if (selAvail())
return false;
if (pSettings->editor().overwriteSymbols()) {
return handleSemiColonSkip();
}
return false;
case ',':
if (selAvail())
return false;
if (pSettings->editor().overwriteSymbols()) {
return handlePeriodSkip();
}
return false;
}
return false;
}
@ -2758,6 +2774,29 @@ bool Editor::handleBraceSkip()
return false;
}
bool Editor::handleSemiColonSkip()
{
if (getCurrentChar() != ';')
return false;
bool oldInsertMode = insertMode();
setInsertMode(false); //set mode to overwrite
processCommand(QSynedit::EditCommand::Char,';');
setInsertMode(oldInsertMode);
return true;
}
bool Editor::handlePeriodSkip()
{
if (getCurrentChar() != ',')
return false;
bool oldInsertMode = insertMode();
setInsertMode(false); //set mode to overwrite
processCommand(QSynedit::EditCommand::Char,',');
setInsertMode(oldInsertMode);
return true;
}
bool Editor::handleSingleQuoteCompletion()
{
QuoteStatus status = getQuoteStatus();

View File

@ -254,6 +254,8 @@ private:
bool handleMultilineCommentCompletion();
bool handleBraceCompletion();
bool handleBraceSkip();
bool handleSemiColonSkip();
bool handlePeriodSkip();
bool handleSingleQuoteCompletion();
bool handleDoubleQuoteCompletion();
bool handleGlobalIncludeCompletion();

View File

@ -2748,7 +2748,8 @@ static void setDebugOptions(Settings::PCompilerSet pSet, bool enableAsan = false
// pSet->setCustomLinkParams("-fsanitize=address");
// pSet->setUseCustomLinkParams(true);
}
pSet->setCompileOption(CC_CMD_OPT_STACK_PROTECTOR, "-strong");
//Some windows gcc don't correctly support this
//pSet->setCompileOption(CC_CMD_OPT_STACK_PROTECTOR, "-strong");
pSet->setStaticLink(false);
}

View File

@ -757,11 +757,7 @@
</message>
<message>
<source>MB</source>
<translation type="unfinished">MB</translation>
</message>
<message>
<source>Syntax error for stack frame larger than</source>
<translation type="unfinished"></translation>
<translation type="obsolete">MB</translation>
</message>
</context>
<context>
@ -2215,6 +2211,10 @@
<source>OK</source>
<translation>OK</translation>
</message>
<message>
<source>Characters:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FormatterGeneralWidget</name>

File diff suppressed because it is too large Load Diff

View File

@ -652,14 +652,6 @@
<source>Locate windres</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>MB</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Syntax error for stack frame larger than</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CppRefacter</name>
@ -2048,6 +2040,10 @@
<source>OK</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Characters:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FormatterGeneralWidget</name>

View File

@ -523,7 +523,7 @@ QString getSizeString(int size)
if (size < 1024) {
return QString("%1 ").arg(size)+QObject::tr("bytes");
} else if (size < 1024 * 1024) {
return QString("%1 ").arg(size / 1024.0)+QObject::tr("KB");
return QString("%1 ").arg(size / 1024.0,0,'f',2)+QObject::tr("KB");
} else if (size < 1024 * 1024 * 1024) {
return QString("%1 ").arg(size / 1024.0 / 1024.0)+QObject::tr("MB");
} else {

View File

@ -226,7 +226,13 @@ void BookmarkModel::save(const QString &filename, const QString& projectFolder)
QString key = QString("%1-%2").arg(filename).arg(bookmark->line);
compareHash.insert(key,i);
}
QList<PBookmark> fileBookmarks=load(filename, t,&fileTimestamp);
QList<PBookmark> fileBookmarks;
try {
fileBookmarks=load(filename, t,&fileTimestamp);
} catch (FileError& e) {
}
QFile file(filename);
if (file.open(QFile::WriteOnly | QFile::Truncate)) {

View File

@ -15,6 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "filepropertiesdialog.h"
#include "systemconsts.h"
#include "ui_filepropertiesdialog.h"
#include "../mainwindow.h"
#include "../editorlist.h"
@ -42,22 +43,25 @@ void FilePropertiesDialog::calcFile(Editor *editor,
int &commentLines,
int &emptyLines,
int &codeLines,
int &includeLines)
int &includeLines,
int &charCounts)
{
totalLines = editor->document()->count();
codeLines = 0;
commentLines = 0;
emptyLines = 0;
includeLines = 0;
charCounts = 0;
int lineBreakerLen = QString(LINE_BREAKER).length();
// iterate through all lines of file
for (int i=0;i<editor->document()->count();i++) {
QString line = editor->document()->getLine(i);
int j=0;
while (j<line.length() && (line[j]=='\t' || line[j]==' '))
j++;
charCounts+=line.length()+lineBreakerLen;
// while (j<line.length() && (line[j]=='\t' || line[j]==' '))
// j++;
QString token;
QSynedit::PTokenAttribute attr;
if (editor->getTokenAttriAtRowCol(QSynedit::BufferCoord{j+1,i+1},
if (editor->getTokenAttriAtRowCol(QSynedit::BufferCoord{1,i+1},
token,attr)) {
// if it is preprocessor...
if (attr->name() == SYNS_AttrPreprocessor) {
@ -134,14 +138,15 @@ void FilePropertiesDialog::on_cbFiles_currentIndexChanged(int index)
ui->txtRelativeToProject->setText("_");
ui->txtLines->setText(QString("%1").arg(editor->document()->count()));
int totalLines, codeLines,emptyLines,commentLines,includeLines;
calcFile(editor,totalLines,commentLines,emptyLines,codeLines,includeLines);
int totalLines, codeLines,emptyLines,commentLines,includeLines, charCounts;
calcFile(editor,totalLines,commentLines,emptyLines,codeLines,includeLines,charCounts);
ui->txtLines->setText(QString("%1").arg(totalLines));
ui->txtEmptyLines->setText(QString("%1").arg(emptyLines));
ui->txtCodeLines->setText(QString("%1").arg(codeLines));
ui->txtCommentLines->setText(QString("%1").arg(commentLines));
ui->txtIncludes->setText(QString("%1").arg(includeLines));
ui->txtCharacters->setText(QString("%1").arg(charCounts));
}
}

View File

@ -49,7 +49,8 @@ private:
int &commentLines,
int &emptyLines,
int &codeLines,
int &includeLines);
int &includeLines,
int &charCounts);
private:
FilePropertiesModel mModel;
Editor * mActiveEditor;

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>726</width>
<height>444</height>
<height>471</height>
</rect>
</property>
<property name="windowTitle">
@ -228,58 +228,6 @@
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QFrame" name="frame_6">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>File size:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="txtFileSize">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QFrame" name="frame_8">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>File date:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="txtFileDate">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_8">
@ -319,6 +267,84 @@
</layout>
</widget>
</item>
<item row="4" column="1">
<widget class="QFrame" name="frame_8">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>File date:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="txtFileDate">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<widget class="QFrame" name="frame_6">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>File size:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="txtFileSize">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QFrame" name="frame_9">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>Characters:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="txtCharacters">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>

View File

@ -14,7 +14,7 @@ qsynedit.subdir = libs/qsynedit
APP_NAME = RedPandaCPP
APP_VERSION = 2.20
APP_VERSION = 2.21
# Add the dependencies so that the RedPandaIDE project can add the depended programs
# into the main app bundle

View File

@ -6307,11 +6307,11 @@ void QSynEdit::wheelEvent(QWheelEvent *event)
mWheelAccumulatedDeltaX+=event->angleDelta().y();
while (mWheelAccumulatedDeltaX>=120) {
mWheelAccumulatedDeltaX-=120;
horizontalScrollBar()->setValue(horizontalScrollBar()->value()-mMouseWheelScrollSpeed);
horizontalScrollBar()->setValue(horizontalScrollBar()->value()+mMouseWheelScrollSpeed);
}
while (mWheelAccumulatedDeltaX<=-120) {
mWheelAccumulatedDeltaX+=120;
horizontalScrollBar()->setValue(horizontalScrollBar()->value()+mMouseWheelScrollSpeed);
horizontalScrollBar()->setValue(horizontalScrollBar()->value()-mMouseWheelScrollSpeed);
}
} else {
if ( (mWheelAccumulatedDeltaY>0 &&event->angleDelta().y()<0)
@ -6326,6 +6326,19 @@ void QSynEdit::wheelEvent(QWheelEvent *event)
mWheelAccumulatedDeltaY+=120;
verticalScrollBar()->setValue(verticalScrollBar()->value()+mMouseWheelScrollSpeed);
}
if ( (mWheelAccumulatedDeltaX>0 &&event->angleDelta().x()<0)
|| (mWheelAccumulatedDeltaX<0 &&event->angleDelta().x()>0))
mWheelAccumulatedDeltaX=0;
mWheelAccumulatedDeltaX+=event->angleDelta().x();
while (mWheelAccumulatedDeltaX>=120) {
mWheelAccumulatedDeltaX-=120;
horizontalScrollBar()->setValue(horizontalScrollBar()->value()+mMouseWheelScrollSpeed);
}
while (mWheelAccumulatedDeltaX<=-120) {
mWheelAccumulatedDeltaX+=120;
horizontalScrollBar()->setValue(horizontalScrollBar()->value()-mMouseWheelScrollSpeed);
}
}
event->accept();
}

View File

@ -2,6 +2,9 @@
set -xe
VERSION=$(sed -nr -e '/APP_VERSION\s*=/ s/APP_VERSION\s*=\s*(([0-9]+\.)*[0-9]+)\s*/\1/p' /build/RedPanda-CPP/Red_Panda_CPP.pro)
APPIMAGE_FILE=RedPandaIDE-$VERSION-$CARCH.AppImage
# build RedPanda C++
mkdir -p /build/redpanda-build
cd /build/redpanda-build
@ -13,18 +16,19 @@ make install INSTALL_ROOT=/build/RedPandaIDE.AppDir
# setup AppImage resource
cd /build/RedPandaIDE.AppDir
ln -s usr/bin/RedPandaIDE AppRun
ln -s usr/share/applications/redpandaide.desktop redpandaide.desktop
ln -s usr/share/icons/hicolor/scalable/apps/redpandaide.svg redpandaide.svg
cp /build/RedPanda-CPP/platform/linux/redpandaide.png .DirIcon
# following files may come from Windows filesystem, use `install` to preseve file permission
install -m755 /build/RedPanda-CPP/packages/appimage/AppRun.sh AppRun
install -m644 /build/RedPanda-CPP/platform/linux/redpandaide.png .DirIcon
# copy dependency
cp /usr/local/bin/alacritty usr/bin
# create AppImage
cd /build
appimagetool --appimage-extract-and-run RedPandaIDE.AppDir RedPandaIDE-$CARCH.AppImage
appimagetool --appimage-extract-and-run RedPandaIDE.AppDir $APPIMAGE_FILE
# copy back to host
mkdir -p /build/RedPanda-CPP/dist
cp RedPandaIDE-$CARCH.AppImage /build/RedPanda-CPP/dist
cp $APPIMAGE_FILE /build/RedPanda-CPP/dist

7
packages/appimage/AppRun.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
# AppImage runtime set `argv[0]` to AppImage file, which is not reliable.
# Qt framework expects reliable `argv[0]` to locate configuration files.
# This wrapper fixes `argv[0]`.
exec "$(dirname "$0")/usr/bin/RedPandaIDE" "$@"