mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2024-10-01 01:06:10 -04:00
Update codeblock font
This commit is contained in:
parent
71a7032421
commit
fd4081aed8
@ -616,7 +616,17 @@ void ResponseText::handleCodeBlocks()
|
|||||||
QTextCursor codeCellCursor = codeCell.firstCursorPosition();
|
QTextCursor codeCellCursor = codeCell.firstCursorPosition();
|
||||||
QTextTable *codeTable = codeCellCursor.insertTable(1, 1, codeBlockTableFormat);
|
QTextTable *codeTable = codeCellCursor.insertTable(1, 1, codeBlockTableFormat);
|
||||||
QTextTableCell code = codeTable->cellAt(0, 0);
|
QTextTableCell code = codeTable->cellAt(0, 0);
|
||||||
|
|
||||||
|
QTextCharFormat codeBlockCharFormat;
|
||||||
|
QFont monospaceFont("Courier");
|
||||||
|
if (monospaceFont.family() != "Courier") {
|
||||||
|
monospaceFont.setFamily("Monospace"); // Fallback if Courier isn't available
|
||||||
|
}
|
||||||
|
|
||||||
QTextCursor codeCursor = code.firstCursorPosition();
|
QTextCursor codeCursor = code.firstCursorPosition();
|
||||||
|
codeBlockCharFormat.setFont(monospaceFont); // Update the font for the codeblock
|
||||||
|
codeCursor.setCharFormat(codeBlockCharFormat);
|
||||||
|
|
||||||
if (!codeLanguage.isEmpty()) {
|
if (!codeLanguage.isEmpty()) {
|
||||||
codeCursor.block().setUserState(stringToLanguage(codeLanguage));
|
codeCursor.block().setUserState(stringToLanguage(codeLanguage));
|
||||||
for (const QString &line : lines) {
|
for (const QString &line : lines) {
|
||||||
|
Loading…
Reference in New Issue
Block a user