| 1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
| 2 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 |
| 3 | |
| 4 | // cSpell: ignore Heade |
| 5 | |
| 6 | import { ListView, VerticalBox } from "std-widgets.slint" ; |
| 7 | |
| 8 | export struct Diagnostics { |
| 9 | level: string, |
| 10 | message: string, |
| 11 | url: string, |
| 12 | line: int, |
| 13 | column: int, |
| 14 | } |
| 15 | |
| 16 | export component DiagnosticsOverlay { |
| 17 | in property <[Diagnostics]> diagnostics; |
| 18 | out property <bool> diagnostics-open: diagnostics.length != 0; |
| 19 | |
| 20 | callback show-document(file: string, line: int, column: int); |
| 21 | |
| 22 | if (root.diagnostics-open): Rectangle { |
| 23 | background: #fff; |
| 24 | |
| 25 | VerticalBox { |
| 26 | Text { |
| 27 | color: #000; |
| 28 | text: "Compilation failed:" ; |
| 29 | } |
| 30 | |
| 31 | ListView { |
| 32 | width: parent.width - 10px; |
| 33 | height: parent.height - 10px; |
| 34 | |
| 35 | padding: 5px; |
| 36 | |
| 37 | for diag in root.diagnostics: Rectangle { |
| 38 | TouchArea { |
| 39 | mouse-cursor: pointer; |
| 40 | clicked => { |
| 41 | root.show_document(diag.url, diag.line, diag.column); |
| 42 | } |
| 43 | |
| 44 | Text { |
| 45 | width: 100%; |
| 46 | wrap: word-wrap; |
| 47 | color: #000; |
| 48 | text: diag.level + ": " + diag.message; |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | |