-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.v
220 lines (198 loc) · 4.49 KB
/
config.v
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
// Copyright (c) 2019 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by a GPL license
// that can be found in the LICENSE file.
module main
import os
import gx
// Config structure
// TODO: Load user config from file
struct Config {
mut:
dark_mode bool
text_size int
tab_size int
tab int
backspace_go_up bool
vcolor gx.Color
split_color gx.Color
bgcolor gx.Color
errorbgcolor gx.Color
title_color gx.Color
cursor_color gx.Color
string_color gx.Color
string_cfg gx.TextCfg
key_color gx.Color
key_cfg gx.TextCfg
text_color gx.Color
txt_cfg gx.TextCfg
comment_color gx.Color
comment_cfg gx.TextCfg
file_name_color gx.Color
file_name_cfg gx.TextCfg
plus_color gx.Color
plus_cfg gx.TextCfg
minus_color gx.Color
minus_cfg gx.TextCfg
line_nr_color gx.Color
line_nr_cfg gx.TextCfg
green_color gx.Color
green_cfg gx.TextCfg
red_color gx.Color
red_cfg gx.TextCfg
}
fn (mut config Config) init_colors() {
config.dark_mode = '-dark' in os.args
config.reload_config()
}
fn (mut config Config) reload_config() {
config.set_textsize()
config.set_tab()
config.set_vcolor()
config.set_split()
config.set_bgcolor()
config.set_errorbgcolor()
config.set_string()
config.set_key()
config.set_title()
config.set_cursor()
config.set_txt()
config.set_comment()
config.set_filename()
config.set_plus()
config.set_minus()
config.set_line_nr()
config.set_green()
config.set_red()
}
fn (mut config Config) set_textsize() {
config.text_size = 18
}
fn (mut config Config) set_tab() {
config.tab_size = 4
config.tab = int(`\t`)
}
fn (mut config Config) set_vcolor() {
if !config.dark_mode {
config.vcolor = gx.rgb(226, 233, 241)
} else {
config.vcolor = gx.rgb(60, 60, 60)
}
}
fn (mut config Config) set_split() {
if !config.dark_mode {
config.split_color = gx.rgb(223, 223, 223)
} else {
config.split_color = gx.rgb(50, 50, 50)
}
}
fn (mut config Config) set_bgcolor() {
if !config.dark_mode {
config.bgcolor = gx.rgb(245, 245, 245)
} else {
config.bgcolor = gx.rgb(30, 30, 30)
}
}
fn (mut config Config) set_errorbgcolor() {
if !config.dark_mode {
config.errorbgcolor = gx.rgb(240, 0, 0)
} else {
config.errorbgcolor = gx.rgb(240, 0, 0)
}
}
fn (mut config Config) set_string() {
if !config.dark_mode {
config.string_color = gx.rgb(179, 58, 44)
} else {
config.string_color = gx.rgb(179, 58, 44)
}
config.string_cfg = gx.TextCfg{
size: config.text_size
color: config.string_color
}
}
fn (mut config Config) set_key() {
if !config.dark_mode {
config.key_color = gx.rgb(74, 103, 154)
} else {
config.key_color = gx.rgb(74, 103, 154)
}
config.key_cfg = gx.TextCfg{
size: config.text_size
color: config.key_color
}
}
fn (mut config Config) set_title() {
if !config.dark_mode {
config.title_color = gx.rgb(40, 40, 40)
} else {
config.title_color = gx.rgb(40, 40, 40)
}
}
fn (mut config Config) set_cursor() {
if !config.dark_mode {
config.cursor_color = gx.black
} else {
config.cursor_color = gx.white
}
}
fn (mut config Config) set_txt() {
if !config.dark_mode {
config.text_color = gx.black
} else {
config.text_color = gx.rgb(212, 212, 212)
}
config.txt_cfg = gx.TextCfg{
size: config.text_size
color: config.text_color
}
}
fn (mut config Config) set_comment() {
config.comment_color = gx.dark_gray
config.comment_cfg = gx.TextCfg{
size: config.text_size
color: config.comment_color
}
}
fn (mut config Config) set_filename() {
config.file_name_color = gx.white
config.file_name_cfg = gx.TextCfg{
size: config.text_size
color: config.file_name_color
}
}
fn (mut config Config) set_plus() {
config.plus_color = gx.green
config.plus_cfg = gx.TextCfg{
size: config.text_size
color: config.plus_color
}
}
fn (mut config Config) set_minus() {
config.minus_color = gx.green
config.minus_cfg = gx.TextCfg{
size: config.text_size
color: config.minus_color
}
}
fn (mut config Config) set_line_nr() {
config.line_nr_color = gx.dark_gray
config.line_nr_cfg = gx.TextCfg{
size: config.text_size
color: config.line_nr_color
align: gx.align_right
}
}
fn (mut config Config) set_green() {
config.green_color = gx.green
config.green_cfg = gx.TextCfg{
size: config.text_size
color: config.green_color
}
}
fn (mut config Config) set_red() {
config.red_color = gx.red
config.red_cfg = gx.TextCfg{
size: config.text_size
color: config.red_color
}
}