mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Add a formatter
This commit is contained in:
parent
2faa9207de
commit
4fa64cdf33
12 changed files with 613 additions and 11 deletions
71
tests/formatting/correct1.blp
Normal file
71
tests/formatting/correct1.blp
Normal file
|
@ -0,0 +1,71 @@
|
|||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
|
||||
template $MyTemplate: Label {
|
||||
/**
|
||||
* A list of strings.
|
||||
*/
|
||||
StringList {
|
||||
// comment
|
||||
strings [
|
||||
"Hello",
|
||||
C_("Greeting", "World"),
|
||||
]
|
||||
}
|
||||
|
||||
object: Button {
|
||||
label: "Click me";
|
||||
};
|
||||
|
||||
flags: a | b;
|
||||
|
||||
[child]
|
||||
Label {
|
||||
}
|
||||
|
||||
[child]
|
||||
Label label2 {
|
||||
}
|
||||
|
||||
// Single line comment.
|
||||
|
||||
/**
|
||||
* Multiline comment.
|
||||
*/
|
||||
// Single line comment.
|
||||
value: bind 1.0 as <double>;
|
||||
as: 1;
|
||||
signal => $on_signal() after;
|
||||
}
|
||||
|
||||
Dialog {
|
||||
[action response=ok]
|
||||
$MyButton {
|
||||
}
|
||||
}
|
||||
|
||||
menu menu {
|
||||
item ("test")
|
||||
|
||||
item {
|
||||
label: "test";
|
||||
}
|
||||
|
||||
item ("test")
|
||||
}
|
||||
|
||||
Adw.MessageDialog {
|
||||
responses [
|
||||
save: "Save" suggested disabled,
|
||||
]
|
||||
}
|
||||
|
||||
Adw.Breakpoint {
|
||||
condition ("width < 100")
|
||||
|
||||
setters {
|
||||
label2.label: _("Hello, world!");
|
||||
label2.visible: false;
|
||||
label2.extra-menu: null;
|
||||
}
|
||||
}
|
1
tests/formatting/in1.blp
Normal file
1
tests/formatting/in1.blp
Normal file
|
@ -0,0 +1 @@
|
|||
using Gtk 4.0;using Adw 1;Overlay{Label label{label:_("'Hello World!' \"\n\t\"");}[overlay]Button{notify::icon-name=>$on_icon_name_changed(label)swapped;styles["destructive"]}visible:bind $isVisible(label.visible,my-menu)as<bool>;width-request:bind label.width-request no-sync-create;}menu my-menu{item(_("Label"), "action-name", "icon-name")item{action:"win.format";}}
|
40
tests/formatting/in2.blp
Normal file
40
tests/formatting/in2.blp
Normal file
|
@ -0,0 +1,40 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
using Adw 1;
|
||||
|
||||
Overlay {
|
||||
|
||||
Label
|
||||
label
|
||||
{
|
||||
label
|
||||
:
|
||||
_
|
||||
(
|
||||
"'Hello World!' \"\n\t\""
|
||||
)
|
||||
;
|
||||
}
|
||||
[
|
||||
overlay
|
||||
] Button
|
||||
{ notify
|
||||
:: icon-name
|
||||
=> $ on_icon_name_changed ( label )
|
||||
swapped ;
|
||||
styles
|
||||
[ "destructive" ]
|
||||
}
|
||||
visible
|
||||
: bind $ isVisible ( label.visible ,
|
||||
my-menu ) as
|
||||
< bool > ; width-request : bind label . width-request no-sync-create ; }
|
||||
menu my-menu
|
||||
{ item ( _ ( "Label" ) , "action-name" , "icon-name" ) item { action : "win.format" ; } }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
28
tests/formatting/out.blp
Normal file
28
tests/formatting/out.blp
Normal file
|
@ -0,0 +1,28 @@
|
|||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
|
||||
Overlay {
|
||||
Label label {
|
||||
label: _("'Hello World!' \"\n\t\"");
|
||||
}
|
||||
|
||||
[overlay]
|
||||
Button {
|
||||
notify::icon-name => $on_icon_name_changed(label) swapped;
|
||||
|
||||
styles [
|
||||
"destructive"
|
||||
]
|
||||
}
|
||||
|
||||
visible: bind $isVisible(label.visible, my-menu) as <bool>;
|
||||
width-request: bind label.width-request no-sync-create;
|
||||
}
|
||||
|
||||
menu my-menu {
|
||||
item (_("Label"), "action-name", "icon-name")
|
||||
|
||||
item {
|
||||
action: "win.format";
|
||||
}
|
||||
}
|
5
tests/formatting/string_in.blp
Normal file
5
tests/formatting/string_in.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Label {
|
||||
label: "\"'\'\t\n\\'";
|
||||
}
|
5
tests/formatting/string_out.blp
Normal file
5
tests/formatting/string_out.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Label {
|
||||
label: "\"'\'\t\n\\'";
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue