-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuilder.n
More file actions
108 lines (100 loc) · 2.56 KB
/
builder.n
File metadata and controls
108 lines (100 loc) · 2.56 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
103
104
105
106
107
108
import webview.{Webview, webview_t, create, destroy, run, terminate, set_title, set_size, set_html, bind, eval}
import libc
// ============================================================
// Builder API
// ============================================================
type WebviewBuilder = struct {
rawptr<void> _w
i32 _debug
i32 _width
i32 _height
i32 _hint
string _title
string _html
}
fn new() : WebviewBuilder {
return WebviewBuilder {
_w: null,
_debug: 0,
_width: 800,
_height: 600,
_hint: 0,
_title: "Webview",
_html: "<h1>Hello, World!</h1>",
}
}
fn WebviewBuilder.build() : Webview {
webview_t webview = create(self._debug, null);
set_title(webview, self._title.to_cstr());
set_size(webview, self._width, self._height, self._hint);
set_html(webview, self._html.to_cstr());
return Webview {
webview: webview,
}
}
fn WebviewBuilder.debug(i32 debug) : WebviewBuilder {
return WebviewBuilder {
_w: self._w,
_debug: debug,
_width: self._width,
_height: self._height,
_hint: self._hint,
_title: self._title,
_html: self._html,
}
}
fn WebviewBuilder.width(i32 width) : WebviewBuilder {
return WebviewBuilder {
_w: self._w,
_debug: self._debug,
_width: width,
_height: self._height,
_hint: self._hint,
_title: self._title,
_html: self._html,
}
}
fn WebviewBuilder.height(i32 height) : WebviewBuilder {
return WebviewBuilder {
_w: self._w,
_debug: self._debug,
_width: self._width,
_height: height,
_hint: self._hint,
_title: self._title,
_html: self._html,
}
}
fn WebviewBuilder.hint(i32 hint) : WebviewBuilder {
return WebviewBuilder {
_w: self._w,
_debug: self._debug,
_width: self._width,
_height: self._height,
_hint: hint,
_title: self._title,
_html: self._html,
}
}
fn WebviewBuilder.title(string title) : WebviewBuilder {
return WebviewBuilder {
_w: self._w,
_debug: self._debug,
_width: self._width,
_height: self._height,
_hint: self._hint,
_title: title,
_html: self._html,
}
}
fn WebviewBuilder.html(string html) : WebviewBuilder {
return WebviewBuilder {
_w: self._w,
_debug: self._debug,
_width: self._width,
_height: self._height,
_hint: self._hint,
_title: self._title,
_html: html,
}
}