-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
102 lines (78 loc) · 2.42 KB
/
Copy pathtest.py
File metadata and controls
102 lines (78 loc) · 2.42 KB
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
from pygments import highlight
from pygments_lexers.cksp_lexer import CKSPLexer
from pygments.formatters import TerminalFormatter
code = """
#pragma output_path("Samples/resources/scripts/time-textures-2.txt")
import "Samples/resources/scripts/other-script.txt"
struct List
declare value: string
declare next: List
function __init__(self, value: int, next: List)
self.value := value
self.next := next
end function
end struct
struct Note
declare pitch: int // maybe default value := 0
declare velocity: int
declare samplestart: int
function __init__(self, p: int, v: int, s: int)
self.pitch := p
self.velocity := v
self.samplestart := s
end function
function play(self): int
return play_note(self.pitch, self.velocity, self.samplestart, 0)
end function
end struct
define GLOBAL_VAR(x) := 42 + x
on init
sli_test -> hide := HIDE_WHOLE_CONTROL
declare read var1, pers var2, instpers var3, const NUM_VARS := 1, 0.69, "var3", 3
declare ui_slider sli_test(0,1000)
sli_test -> hide := HIDE_WHOLE_CONTROL
declare x: int, y: int := 42
declare str: string := "Hello, 'other string' World!"
call test
message(EVENT_NOTE, 3, 5, ALL_EVENTS[0])
end on
on note
play_note(EVENT_NOTE, EVENT_VELOCITY, 0, -1)
end on
on ui_control(sli_test)
message("Slider value: ", sli_test)
end on
function test(x: int, y: int)
if ($x > 10 and y < 20)
return true
else
message("Hello, World")
return false
end if
end function
namespace UI
declare const HEIGHT := 100e10
declare const WIDTH := 0.1e-10
function set_bg_frame(frame: int)
set_skin_offset(frame * HEIGHT)
end function
namespace Layout
function content_height(): int
return HEIGHT-68 // unqualified access to outer member
end function
end namespace
namespace Fonts
declare types: int[] := [CONTROL_PAR_FONT_TYPE, CONTROL_PAR_FONT_TYPE_ON, CONTROL_PAR_FONT_TYPE_OFF_PRESSED, CONTROL_PAR_FONT_TYPE_ON_PRESSED, CONTROL_PAR_FONT_TYPE_OFF_HOVER, CONTROL_PAR_FONT_TYPE_ON_HOVER]
function apply(ref ui_control, font_array: int[])
for u in range(num_elements(types))
ui_control -> types[u] := font_array[u]
end for
end function
end namespace
message(f"This is a UI with height <HEIGHT> and width <WIDTH>")
end namespace
"""
lexer = CKSPLexer()
formatter = TerminalFormatter()
highlighted = highlight(code, lexer, formatter)
print(highlighted)