1// SYNTAX TEST "source.slint" "Example code test"
2
3 import { DemoPalette, PageX as Page } from "common.slint";
4//^^^^^^ keyword.other.import.slint
5// ^^^^^^^^^^^ entity.name.type.import-list.slint
6// ^^ keyword.other.as.slint
7// ^^^^^^^^^^^^^^ string.quoted.double.import-path.slint
8
9 // re-export
10//^^^^^^^^^^^^ comment.line.double-slash.slint
11 export { PrinterQueue, PrinterSettings, Foo as Bar }
12//^^^^^^ keyword.other.export.slint
13// ^^^ entity.name.type.export-list.slint
14// ^^ keyword.other.as.slint
15// ^^^ entity.name.type.export-list.slint
16
17 /* Block comment */
18//^^^^^^^^^^^^^^^^^^^ comment.block.slint
19 struct InkLevel {
20//^^^^^^ keyword.declaration.struct.slint
21// ^^^^^^^^ entity.name.type.struct.slint
22 color: color,
23// ^^^^^ variable.other.struct.field.slint
24// ^^^^^ entity.name.type.struct.field.slint
25 level: percent,
26// ^^^^^ variable.other.struct.field.slint
27// ^^^^^^^ entity.name.type.struct.field.slint
28 }
29
30 export global Globus {
31//^^^^^^ keyword.other.export.slint
32// ^^^^^^ keyword.other.global.slint
33// ^^^^^^ entity.name.type.global.slint
34 }
35
36 component SideBarIcon inherits Rectangle {
37//^^^^^^^^^ keyword.other.component.slint
38// ^^^^^^^^^^^ entity.name.type.component.slint
39// ^^^^^^^^ keyword.other.inherits.slint
40// ^^^^^^^^^ entity.other.inherited-class.component.slint
41
42 in-out property <bool> active;
43// ^^^^^^ keyword.other.visibility.slint
44// ^^^^^^^^ keyword.other.property.slint
45// ^^^^ entity.name.type.property.slint
46// ^^^^^^ variable.other.property.slint
47
48 pure callback activate;
49// ^^^^ keyword.other.pure.slint
50// ^^^^^^^^ keyword.other.function.slint
51// ^^^^^^^^ entity.name.function.slint
52
53 width: DemoPalette.side-bar-width;
54// ^^^^^ variable.other.property.slint
55 height: 72px;
56// ^^^^^^ variable.other.property.slint
57// ^^^^ constant.numeric.slint
58
59 states [
60// ^^^^^^ keyword.other.states.slint
61 expanded when root.expanded : {
62// ^^^^ keyword.other.when.slint
63 height: layout.min-height;
64
65 in {
66// ^^ keyword.other.state-change.slint
67 animate height { duration: 200rem; easing: ease; }
68// ^^^^^^^ keyword.other.animate.slint
69// ^^^^^^ variable.other.property.slint
70// ^^^^^^^^ keyword.other.animate.setting.slint
71// ^^^^^^ constant.numeric.slint
72// ^^^^^^ keyword.other.animate.setting.slint
73 }
74 out {
75// ^^^ keyword.other.state-change.slint
76 }
77 }
78 ]
79
80 if false:id:=Rectangle {
81// ^^ keyword.control.conditional-element.slint
82// ^^^^^ constant.language.boolean.slint
83// ^^ entity.name.tag.element-id.slint
84// ^^^^^^^^^ entity.name.type.element.slint
85 i := Image {
86// ^ entity.name.tag.element-id.slint
87// ^^ punctuation.assignment.element-id.slint
88// ^^^^^ entity.name.type.element.slint
89 colorize: root.active ? DemoPalette.active-page-icon-color : DemoPalette.inactive-page-icon-color;
90// ^^^^^^^^ variable.other.property.slint
91 animate colorize { duration: 125ms; }
92// ^^^^^^^ keyword.other.animate.slint
93// ^^^^^^^^ keyword.other.animate.setting.slint
94// ^^^^^ constant.numeric.slint
95 }
96 clicked => { }
97// ^^^^^^^ entity.name.function.slint
98 }
99
100
101 for page-icon[idx] in [
102// ^^^ keyword.control.repeated-element.slint
103 @image-url("images/home.svg"),
104// ^^^^^^^^^^ support.function.macro.slint
105// ^^^^^^^^^^^^^^^^^ string.quoted.double.slint
106 ]: SideBarIcon { }
107
108 if true: Rectangle {
109// ^^ keyword.control.conditional-element.slint
110// ^^^^ constant.language.boolean.slint
111// ^^^^^^^^^ entity.name.type.element.slint
112 i := Image {
113// ^ entity.name.tag.element-id.slint
114// ^^ punctuation.assignment.element-id.slint
115// ^^^^^ entity.name.type.element.slint
116 colorize: root.active ? DemoPalette.active-page-icon-color : DemoPalette.inactive-page-icon-color;
117// ^^^^^^^^ variable.other.property.slint
118 animate colorize { duration: 125ms; }
119// ^^^^^^^ keyword.other.animate.slint
120// ^^^^^^^^ keyword.other.animate.setting.slint
121// ^^^^^ constant.numeric.slint
122 }
123 clicked => { root.activate(); }
124// ^^^^^^^ entity.name.function.slint
125 }
126
127 }
128
129