- enhancement: Display ascii control chars.

This commit is contained in:
Roy Qu 2024-02-27 13:23:58 +08:00
parent 451e201881
commit bc0d55b1bb
8 changed files with 21 additions and 13 deletions

View File

@ -10,6 +10,7 @@ Red Panda C++ Version 2.27
- enhancement: Support unicode combining characters.
- enhancement: Don't force fixed-width when using non fixed-width fonts.
- change: Replace non-ascii font with fallback font.
- enhancement: Display ascii control chars.
Red Panda C++ Version 2.26
- enhancement: Code suggestion for embedded std::vectors.

View File

@ -555,6 +555,7 @@ else: unix:!android: target.path = $${PREFIX}/bin
!isEmpty(target.path): INSTALLS += target
RESOURCES += \
fonts.qrc \
codes.qrc \
defaultconfigs.qrc \
icons.qrc \

5
RedPandaIDE/fonts.qrc Normal file
View File

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/fonts">
<file alias="asciicontrol.ttf">resources/fonts/asciicontrol.ttf</file>
</qresource>
</RCC>

View File

@ -46,6 +46,7 @@
#include <QSharedMemory>
#include <QBuffer>
#include <winuser.h>
#include <QFontDatabase>
#include "widgets/cpudialog.h"
#endif
@ -404,6 +405,7 @@ int main(int argc, char *argv[])
e.reason(),
QMessageBox::Ok);
}
// qDebug()<<"Load font"<<QFontDatabase::addApplicationFont(":/fonts/asciicontrol.ttf");
MainWindow mainWindow;
pMainWindow = &mainWindow;

Binary file not shown.

View File

@ -723,6 +723,7 @@ QStringList Settings::Editor::fontFamilies() const
result.append(mFallbackFontName2);
if (mUseFallbackFont3)
result.append(mFallbackFontName3);
result.append("Red Panda Control");
return result;
}

View File

@ -669,8 +669,8 @@ void Document::loadFromFile(const QString& filename, const QByteArray& encoding,
} else if (line.endsWith("\n")){
line.remove(line.length()-1,1);
}
if (isBinaryContent(line))
throw BinaryFileError(tr("'%1' is a binaray File!").arg(filename));
// if (isBinaryContent(line))
// throw BinaryFileError(tr("'%1' is a binaray File!").arg(filename));
if (allAscii) {
allAscii = isTextAllAscii(line);
}

View File

@ -724,17 +724,15 @@ QStringList absolutePaths(const QString &dirPath, const QStringList &relativePat
return list;
}
bool isBinaryContent(const QByteArray &text)
{
for (char c:text) {
if (c>=0 && c<' ' && c!='\t' && c!='\n' && c!='\r') {
return true;
}
}
return false;
}
// bool isBinaryContent(const QByteArray &text)
// {
// for (char c:text) {
// if (c>=0 && c<' ' && c!='\t' && c!='\n' && c!='\r') {
// return true;
// }
// }
// return false;
// }
void clearQPlainTextEditFormat(QTextEdit *editor)
{