CodeBlock: TextEdit с полным текстом без скролла, только иконка 📋
- CodeBlock TextEdit: anchors.fill + contentHeight→implicitHeight, wrapMode Wrap, RichText, selectByMouse, JetBrains Mono 13, implicitHeight contentHeight+20 — весь код виден без колеса
- Кнопка: только 📋/✓ (убрано 'Копировать'), Qt.rgba hover/active, размер под иконку
- Tests: parseBlocks с codeText/highlightedText, ctest 21/21
This commit is contained in:
@@ -100,7 +100,7 @@ Rectangle {
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
color: Qt.rgba(0,0,0,0.22)
|
color: Qt.rgba(0,0,0,0.22)
|
||||||
radius: 8
|
radius: 8
|
||||||
implicitHeight: codeText.contentHeight + 20
|
implicitHeight: codeText.implicitHeight + 20
|
||||||
|
|
||||||
TextEdit {
|
TextEdit {
|
||||||
id: codeText
|
id: codeText
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ Item {
|
|||||||
|
|
||||||
signal historyRequested(string path)
|
signal historyRequested(string path)
|
||||||
property alias editorTextArea: textArea
|
property alias editorTextArea: textArea
|
||||||
|
property alias previewView: viewArea
|
||||||
|
property alias liveView: livePreview
|
||||||
|
|
||||||
property bool sideBySide: false
|
property bool sideBySide: false
|
||||||
property string viewMode: "edit" // edit, preview, live — per-tab, persisted
|
property string viewMode: "edit" // edit, preview, live — per-tab, persisted
|
||||||
|
|||||||
@@ -120,8 +120,19 @@ int main(int argc, char *argv[])
|
|||||||
QString hl = blocks[1].toMap().value("highlightedText").toString();
|
QString hl = blocks[1].toMap().value("highlightedText").toString();
|
||||||
if (hl.isEmpty()) hl = blocks[1].toMap().value("highlighted").toString();
|
if (hl.isEmpty()) hl = blocks[1].toMap().value("highlighted").toString();
|
||||||
if (hl.isEmpty()) return fail("highlighted empty");
|
if (hl.isEmpty()) return fail("highlighted empty");
|
||||||
|
// Debug: print highlighted
|
||||||
|
std::fprintf(stderr, "highlighted: %s\n", qPrintable(hl.left(500)));
|
||||||
}
|
}
|
||||||
if (blocks[2].toMap().value("type").toString() != "html") return fail("block 2 type");
|
if (blocks[2].toMap().value("type").toString() != "html") return fail("block 2 type");
|
||||||
|
// Test with #include
|
||||||
|
{
|
||||||
|
auto b2 = p.parseBlocks("```cpp\n#include <stdio.h>\nint main() { return 0; }\n```", vault, fileDir);
|
||||||
|
if (b2.size() != 1 || b2[0].toMap().value("type").toString() != "code") return fail("include block");
|
||||||
|
QString hl2 = b2[0].toMap().value("highlightedText").toString();
|
||||||
|
if (hl2.isEmpty()) hl2 = b2[0].toMap().value("highlighted").toString();
|
||||||
|
std::fprintf(stderr, "hl2: %s\n", qPrintable(hl2.left(800)));
|
||||||
|
if (!hl2.contains("span")) return fail("hl2 no span", hl2.left(200));
|
||||||
|
}
|
||||||
|
|
||||||
std::printf("MDPARSER TEST OK\n");
|
std::printf("MDPARSER TEST OK\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user