glt 0.1.2

Glint compiler library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
<h1 align="center"><img alt="Glint" src="./logo.png"></h1>
<p align="center">A specialized, statically typed markup, styling, and state management language created exclusively for <strong>Eclipse DE</strong></p>

## About Glint

Unlike traditional configuration files (JSON, TOML, YAML) or heavyweight embedded languages (Lua, JS), Glint is designed as the live source code of the graphical shell itself. It parses in nanoseconds, compiles to compact bytecode on the fly, and allows for rebuilding the DE interface in real time without a system restart.

## Philosophy "Source-as-Configuration"

Eclipse doesn't have a concept of "default settings" in the form of hidden binary code. Everything you see on the screen, from the tray corner radius to the desktop layout logic, is written in Glint files. (`.gltm`, `.glts` and bytecode - `.glbc`)

- **Hot-Reload**: Any change in the `.gltm`/`.glts` file is instantly picked up, compiled into '.glbc' and rendered at runtime.
- **Crash resistance**: If the user makes a syntax or logic error, Glint will automatically roll back to the last working state from the bytecode cache. The system fundamentally cannot crash due to an incorrect configuration. Eclipse itself is a framework for writing Glint code to create a DE, although it has its own base source code, allowing you to enjoy the DE and use your PC like GNOME or KDE Plasma.
- **Who is Glint for?**: Knowing Glint is necessary for advanced users who want full control over their DE, however, no one forbids the use of the unmodified Eclipse DE

## Architecture

The language is designed with a focus on maximum predictability, determinism, and performance of the native application layer on 'iced' (Rust).

### Sigil system

| Symbol         | Type      | Description                                                |
| -------------- | --------- | ---------------------------------------------------------- |
| `@`            | Directive | Single symbol → instant dispatch                           |
| `$`            | Varialbe  | Distinguishes from item names and strings                  |
| `!rhei`        | call Rhei | '!' does not occur in names; The body is transmitted as-is |
| `//`           | Comment   | Two-character check                                        |
| `"…"`          | String    | An unambiguous beginning and end; escape via '\'           |
| `#RRGGBB`      | Color     | Only in the value position; parsed for 7 bytes             |
| `fs:/…`        | FS-path   | URI scheme; Recognized in 3 characters (f,s,:)             |
| Capital letter | Element   | Distinguishes from directives and keywords                 |
| `0-9 / -`      | Integer   | The first character uniquely indicates the numeric type    |

The parser spends **zero time** determining the type of token. It doesn't need to symbolically compare strings like `if`, `let`, or `function`.

### 2. Separation of scopes '()' and '{}'

- Parentheses '(...)' contain **only** the properties of the element in the format 'key=value'.
- Curly braces '{...}' contain **only** child elements and directives.

### 3. Native protocols

Instead of calling heavy functions like 'readFile("/path")' that require argument parsing in runtime, Glint uses built-in prefixes:

```gltm
Image(src=fs:/usr/share/backgrounds/wallpaper.png)
```

## Bytecode

Glint does not interpret pure text while DE is running. It compiles it into a compact binary bytecode. Each UI element is translated into `ELEM_PUSH`/`ELEM_POP` instructions. Each property is converted into a typed opcode of a fixed width (`PROP_INT`, `PROP_STR`, `PROP_COLOR`).

This allows the Render Hot-Path to run without memory allocations at all

## Syntax example

```gltm
@version 1
@style "desktop.glts"

@global $username   = !rhei: os.env("USER")
@global $hostname   = !rhei: os.hostname()
@global $locale     = "ru_RU"
@global $scaleFactor = 1.0

@singleton Config {
    wallpaper      = fs:/home/$username/.config/de/wallpaper.jpg
    wallpaperFit   = "cover"
    iconTheme      = "papirus-dark"
    fontMain       = "Inter"
    fontMono       = "JetBrains Mono"
    fontSize       = 13
    workspaces     = 4
    animEnabled    = true
    accentColor    = #cba6f7
    taskbarPos     = "bottom"
}

@singleton SystemState {
    battery    = !rhei: sys.battery()
    volume     = !rhei: sys.volume.get()
    brightness = !rhei: sys.brightness.get()
    network    = !rhei: sys.network.status()
    timezone   = !rhei: os.timezone()
}

@component DesktopIcon(label: str, icon: fspath, exec: str) {
    Button(class="desktop-icon") {
        @on click {
            !rhei: process.spawn($exec)
        }
        @on dblclick {
            !rhei {
                process.spawn($exec)
                wm.raise(process.lastPid())
            }
        }
        Image(src=$icon, class="icon-img") {}
        Label(class="icon-label") $label
    }
}

@component BatteryWidget {
    @if $SystemState.battery.present {
        @let $lvl = $SystemState.battery.level
        @let $ico = !rhei: icons.battery($lvl)

        Panel(class="tray-item") {
            Icon(src=$ico, class="tray-icon") {}
            @if $SystemState.battery.charging {
                Icon(src=fs:/usr/share/eclipse/icons/charging.svg,
                     class="tray-icon tray-icon--accent") {}
            }
        }
    }
}

@component ClockWidget {
    @let $time = !rhei: sys.time.format("%H:%M", $SystemState.timezone)
    @let $date = !rhei: sys.time.format("%d %b", $SystemState.timezone)

    Panel(class="clock-widget") {
        @on click {
            !rhei: ui.toggle("calendar-popup")
        }
        Label(class="clock-time") $time
        Label(class="clock-date") $date
    }
}

@component SystemTray {
    Panel(id="system-tray", class="tray") {
        BatteryWidget {}

        @if $SystemState.network.connected {
            Icon(class="tray-icon",
                 src=!rhei: icons.network($SystemState.network.type)) {}
        } @else {
            Icon(class="tray-icon tray-icon--warn",
                 src=fs:/usr/share/eclipse/icons/net-offline.svg) {}
        }

        Slider(id="vol-slider", class="tray-slider",
               value=$SystemState.volume, min=0, max=100) {
            @on change {
                !rhei: sys.volume.set($self.value)
            }
        }

        ClockWidget {}
    }
}

Screen(id="root", width=1920, height=1080, scale=$scaleFactor) {

    Wallpaper(id="bg",
              src=$Config.wallpaper,
              fallback=fs:/usr/share/eclipse/wallpapers/default.jpg,
              fit=$Config.wallpaperFit,
              watch=true) {}

    Panel(id="desktop", class="desktop") {
        @let $desktopFiles = !rhei: fs.glob("/home/$username/Desktop/*.desktop")

        @each $f in $desktopFiles {
            @let $entry = !rhei: xdg.parseDesktop($f)
            DesktopIcon(
                label=$entry.name,
                icon=!rhei: icons.resolve($entry.icon, $Config.iconTheme),
                exec=$entry.exec
            ) {}
        }

        @on contextmenu {
            !rhei: ui.show("desktop-ctx")
        }
    }

    ContextMenu(id="desktop-ctx", class="ctx-menu", visible=false) {
        MenuItem(class="ctx-item") {
            @on click { !rhei: ui.show("settings") }
            "Settings"
        }
        MenuItem(class="ctx-item") {
            @on click { !rhei: wallpaper.showPicker() }
            "Change wallpaper"
        }
        MenuDivider {}
        MenuItem(class="ctx-item ctx-item--danger") {
            @on click { !rhei: session.logout() }
            "Logout"
        }
    }

    Panel(id="taskbar", class="taskbar") {

        Button(id="launcher-btn", class="launcher-button") {
            @on click { !rhei: ui.toggle("app-launcher") }
            Image(src=fs:/usr/share/eclipse/logo.svg) {}
        }

        Panel(id="window-list", class="window-list") {
            @let $wins = !rhei: wm.getWindows()

            @each $w in $wins {
                Button(class="taskbar-win", data-wid=$w.id,
                       active=$w.focused) {
                    @on click     { !rhei: wm.focus($w.id) }
                    @on middleclick { !rhei: wm.close($w.id) }
                    Icon(src=$w.icon, class="win-icon") {}
                    Label(class="win-title") $w.title
                }
            }
        }

        SystemTray {}
    }

    Overlay(id="app-launcher", class="launcher", visible=false) {
        @on keydown(key="Escape") {
            !rhei: ui.hide("app-launcher")
        }

        Input(id="launcher-search", class="launcher-search",
              placeholder="Search...",
              autofocus=true) {
            @on input {
                !rhei: launcher.filter($self.value)
            }
        }

        Grid(id="app-grid", class="launcher-grid", columns=6) {
            @let $apps = !rhei: apps.listAll()

            @each $app in $apps {
                Button(class="launcher-app") {
                    @on click {
                        !rhei {
                            process.spawn($app.exec)
                            ui.hide("app-launcher")
                        }
                    }
                    Image(src=$app.icon, class="app-icon") {}
                    Label(class="app-name") $app.name
                }
            }
        }
    }

    Overlay(id="notif-layer", class="notif-layer") {
        @let $notifs = !rhei: notifications.active()

        @each $n in $notifs {
            Panel(class="notif-card", data-id=$n.id) {
                Panel(class="notif-header") {
                    Icon(src=$n.appIcon, class="notif-icon") {}
                    Label(class="notif-app") $n.appName
                    Button(class="notif-close") {
                        @on click { !rhei: notifications.dismiss($n.id) }
                        "×"
                    }
                }
                Label(class="notif-title") $n.summary
                @if $n.body {
                    Label(class="notif-body") $n.body
                }
            }
        }
    }

    @if !rhei: os.env("GLINT_DEV") {
        !rhei {
            debug.overlay.show()
            debug.log("DE is init. User: " + $username)
            debug.log("Singletones: Config, SystemState")
        }
    }
}
```

```glts
$bg          = #1e1e2e
$bg-s0       = #313244
$bg-s1       = #45475a
$text        = #cdd6f4
$text-dim    = #a6adc8
$accent      = #cba6f7
$accent-h    = #b4befe
$red         = #f38ba8
$warn        = #fab387
$green       = #a6e3a1
$r           = 8px
$r-sm        = 4px
$taskbar-h   = 36px
$t-fast      = 120ms
$t-mid       = 240ms

@mixin flex-row {
    display: flex
    flex-direction: row
    align-items: center
}

@mixin flex-col {
    display: flex
    flex-direction: column
    align-items: flex-start
}

@mixin glass {
    background: rgba(30, 30, 46, 0.88)
    backdrop-filter: blur(14px)
    border: 1px solid rgba(203, 166, 247, 0.15)
}

@mixin shadow-sm {
    box-shadow: 0 2px 8px rgba(0,0,0,0.45)
}

@mixin shadow-lg {
    box-shadow: 0 6px 24px rgba(0,0,0,0.65)
}

@mixin btn-reset {
    border: none
    background: transparent
    cursor: pointer
    padding: 0
}

@anim fade-in {
    from { opacity: 0; transform: scale(0.95) }
    to   { opacity: 1; transform: scale(1.0)  }
}

@anim slide-up {
    from { opacity: 0; transform: translateY(10px) }
    to   { opacity: 1; transform: translateY(0)    }
}

@anim slide-down {
    from { opacity: 0; transform: translateY(-10px) }
    to   { opacity: 1; transform: translateY(0)     }
}

@anim pulse-warn {
    0%   { opacity: 1.0 }
    50%  { opacity: 0.4 }
    100% { opacity: 1.0 }
}

Screen {
    font-family: $Config.fontMain
    font-size:   $Config.fontSizepx
    color:       $text
    background:  transparent
}

Wallpaper {
    position: absolute
    inset:    0
    z-index:  0
    object-fit: cover
}

Panel.desktop {
    position: absolute
    inset:    0 0 $taskbar-h 0
    z-index:  1
    padding:  16px
    display:  grid
    grid-template-columns: repeat(auto-fill, 80px)
    grid-template-rows:    repeat(auto-fill, 88px)
    align-content: start
    gap: 8px
}

Button.desktop-icon {
    @use flex-col
    @use btn-reset

    width:         76px
    padding:       6px 4px
    border-radius: $r-sm
    border:        1px solid transparent
    align-items:   center
    gap:           5px
    transition:    background $t-fast, border-color $t-fast
}

Button.desktop-icon:hover {
    background:   rgba(203,166,247,0.12)
    border-color: rgba(203,166,247,0.30)
}

Button.desktop-icon:active {
    background: rgba(203,166,247,0.22)
    transform:  scale(0.96)
}

Button.desktop-icon > Image.icon-img {
    width:  48px
    height: 48px
}

Button.desktop-icon > Label.icon-label {
    font-size:   11px
    color:       $text
    text-align:  center
    text-shadow: 0 1px 4px rgba(0,0,0,0.85)
    max-width:   72px
    overflow:    ellipsis
}

Panel.taskbar {
    @use flex-row
    @use glass
    @use shadow-sm

    position: absolute
    bottom:   0; left: 0
    width:    100%
    height:   $taskbar-h
    z-index:  100
    padding:  0 8px
    gap:      4px
}

Button.launcher-button {
    @use flex-row
    @use btn-reset

    width:         30px
    height:        28px
    border-radius: $r-sm
    padding:       5px
    transition:    background $t-fast
}

Button.launcher-button:hover  { background: rgba(203,166,247,0.20) }
Button.launcher-button:active { background: rgba(203,166,247,0.36) }

Panel.window-list {
    @use flex-row
    flex:     1
    gap:      2px
    height:   28px
    overflow: hidden
}

Button.taskbar-win {
    @use flex-row
    @use btn-reset

    max-width:     180px
    height:        28px
    padding:       0 8px
    border-radius: $r-sm
    background:    rgba(255,255,255,0.06)
    color:         $text-dim
    font-size:     12px
    gap:           6px
    overflow:      hidden
    transition:    background $t-fast, color $t-fast
}

Button.taskbar-win:hover {
    background: rgba(255,255,255,0.12)
    color:      $text
}

Button.taskbar-win[active=true] {
    background:    rgba(203,166,247,0.18)
    color:         $accent
    border-bottom: 2px solid $accent
}

Button.taskbar-win > Icon.win-icon {
    width:       16px
    height:      16px
    flex-shrink: 0
}

Button.taskbar-win > Label.win-title {
    white-space: nowrap
    overflow:    ellipsis
}

Panel.tray {
    @use flex-row
    margin-left: auto
    gap:         4px
}

Panel.tray-item      { @use flex-row; gap: 2px }

Icon.tray-icon {
    width:      16px
    height:     16px
    opacity:    0.82
    cursor:     pointer
    transition: opacity $t-fast
}

Icon.tray-icon:hover     { opacity: 1.0 }
Icon.tray-icon--accent   { color: $green }
Icon.tray-icon--warn {
    color:     $warn
    animation: pulse-warn 2s ease infinite
}

Slider.tray-slider {
    width:        68px
    height:       4px
    accent-color: $accent
}

Panel.clock-widget {
    @use flex-col
    padding:    0 8px
    cursor:     pointer
    gap:        0
    border-radius: $r-sm
    transition:    background $t-fast
}

Panel.clock-widget:hover { background: rgba(255,255,255,0.07) }

Label.clock-time {
    font-family:  $Config.fontMono
    font-size:    13px
    font-weight:  500
    color:        $text
    letter-spacing: 0.4px
}

Label.clock-date {
    font-size: 10px
    color:     $text-dim
}

ContextMenu.ctx-menu {
    @use glass
    @use shadow-lg

    border-radius: $r
    padding:       4px
    min-width:     200px
    animation:     fade-in $t-fast ease
}

MenuItem.ctx-item {
    padding:       7px 12px
    border-radius: $r-sm
    font-size:     13px
    color:         $text
    cursor:        pointer
    transition:    background $t-fast
}

MenuItem.ctx-item:hover          { background: rgba(255,255,255,0.08) }
MenuItem.ctx-item--danger        { color: $red }
MenuItem.ctx-item--danger:hover  { background: rgba(243,139,168,0.12) }
MenuDivider {
    height:     1px
    background: rgba(255,255,255,0.08)
    margin:     4px 0
}

Overlay.launcher {
    @use glass
    @use flex-col
    @use shadow-lg

    position:      absolute
    bottom:        $taskbar-h
    left:          50%
    transform:     translateX(-50%)
    width:         700px
    max-height:    540px
    border-radius: $r
    padding:       16px
    z-index:       200
    gap:           12px
    animation:     slide-up $t-mid ease
}

Input.launcher-search {
    width:         100%
    height:        40px
    background:    rgba(255,255,255,0.06)
    border:        1px solid rgba(203,166,247,0.25)
    border-radius: $r-sm
    padding:       0 14px
    font-size:     14px
    color:         $text
    outline:       none
    transition:    border-color $t-fast, background $t-fast
}

Input.launcher-search:focused {
    border-color: $accent
    background:   rgba(255,255,255,0.09)
}

Grid.launcher-grid {
    width:                  100%
    grid-template-columns:  repeat(6, 1fr)
    gap:                    8px
    overflow-y:             scroll
    max-height:             420px
    padding:                4px
}

Button.launcher-app {
    @use flex-col
    @use btn-reset

    padding:       10px 6px
    border-radius: $r-sm
    border:        1px solid transparent
    align-items:   center
    gap:           6px
    transition:    background $t-fast, border-color $t-fast
    animation:     fade-in $t-mid ease
}

Button.launcher-app:hover {
    background:   rgba(203,166,247,0.12)
    border-color: rgba(203,166,247,0.25)
}

Button.launcher-app > Image.app-icon {
    width: 44px; height: 44px
}

Button.launcher-app > Label.app-name {
    font-size:  11px
    color:      $text-dim
    text-align: center
    max-width:  80px
    overflow:   ellipsis
}

Overlay.notif-layer {
    @use flex-col
    position: absolute
    top:      12px; right: 12px
    gap:      8px
    z-index:  300
    max-width: 360px
}

Panel.notif-card {
    @use glass
    @use flex-col
    @use shadow-sm

    border-radius: $r
    padding:       12px
    gap:           4px
    animation:     slide-down $t-mid ease
}

Panel.notif-header {
    @use flex-row
    gap:           6px
    margin-bottom: 4px
}

Icon.notif-icon     { width: 16px; height: 16px }
Label.notif-app     { font-size: 11px; color: $text-dim }
Label.notif-title   { font-size: 13px; font-weight: 500; color: $text }
Label.notif-body    { font-size: 12px; color: $text-dim; line-height: 1.5 }

Button.notif-close {
    @use btn-reset
    margin-left:   auto
    color:         $text-dim
    font-size:     16px
    line-height:   1
    transition:    color $t-fast
}

Button.notif-close:hover { color: $red }

@if $Config.accentColor != #cba6f7 {
    Button.desktop-icon:hover {
        background:   rgba($Config.accentColor, 0.12)
        border-color: rgba($Config.accentColor, 0.30)
    }
    Button.taskbar-win[active=true] {
        background:    rgba($Config.accentColor, 0.18)
        color:         $Config.accentColor
        border-bottom: 2px solid $Config.accentColor
    }
    Input.launcher-search:focused { border-color: $Config.accentColor }
}

```