slint/tools/lsp/ui/components/diagnostics-overlay.slint
Olivier Goffart 3a59950751 Experimental support for named callback parameters
And use that in the lsp/ui implementation instead of comments.

This is only a parser support for now, the name is otherwise unused.
Hence I rather keep that experimental.
2024-08-19 14:10:01 +02:00

55 lines
1.5 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
// cSpell: ignore Heade
import { ListView, VerticalBox } from "std-widgets.slint";
export struct Diagnostics {
level: string,
message: string,
url: string,
line: int,
column: int,
}
export component DiagnosticsOverlay {
in property <[Diagnostics]> diagnostics;
out property <bool> diagnostics-open: diagnostics.length != 0;
callback show-document(file: string, line: int, column: int);
if (root.diagnostics-open): Rectangle {
background: #fff;
VerticalBox {
Text {
color: #000;
text: "Compilation failed:";
}
ListView {
width: parent.width - 10px;
height: parent.height - 10px;
padding: 5px;
for diag in root.diagnostics: Rectangle {
TouchArea {
mouse-cursor: pointer;
clicked => {
root.show_document(diag.url, diag.line, diag.column);
}
Text {
width: 100%;
wrap: word-wrap;
color: #000;
text: diag.level + ": " + diag.message;
}
}
}
}
}
}
}