Skip to content

Commit b5b794b

Browse files
committed
UI: fix colour handling
1 parent f3ea970 commit b5b794b

File tree

4 files changed

+35
-25
lines changed

4 files changed

+35
-25
lines changed

src/platform/android/app/src/main/assets/main.bas

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ const char_w = txtw(".")
77
const lineSpacing = 2 + char_h
88
const idxEdit = 6
99
const idxFiles = 7
10-
const colGrey = rgb(100,100,100)
10+
const colGrey = rgb(100, 100, 100)
11+
const colBkGnd = rgb(31, 28, 31)
12+
const colText = 2
13+
const colLink = 3
1114
const menu_gap = -(char_w / 2)
1215
const is_sdl = instr(sbver, "SDL") != 0
1316
const onlineUrl = "http://smallbasic.github.io/samples/index.bas"
@@ -43,8 +46,7 @@ func mk_menu(value, lab, x)
4346
bn.y = ypos * char_h
4447
bn.value = value
4548
bn.label = "[" + lab + "]"
46-
bn.color = 3
47-
bn.backgroundColor = 0
49+
bn.color = colLink
4850
bn.type = "link"
4951
mk_menu = bn
5052
end
@@ -84,8 +86,7 @@ sub do_okay_button(bn_extra)
8486
button.label = "[Close]"
8587
button.x = (xmax - txtw(button.label)) / 2
8688
button.y = ypos * char_h
87-
button.backgroundColor = 0
88-
button.color = 3
89+
button.color = colLink
8990
button.type = "link"
9091
if (ismap(bn_extra)) then
9192
frm.inputs << bn_extra
@@ -96,9 +97,14 @@ sub do_okay_button(bn_extra)
9697
frm.doEvents()
9798
end
9899

100+
sub clear_screen()
101+
color colText, colBkGnd
102+
cls
103+
end
104+
99105
sub do_about()
100106
cls
101-
color 2,0
107+
color colText
102108
if (char_w * 45 < xmax) then
103109
print " ____ _______ ___ _____________"
104110
print " / ____ _ ___ _/ / / _ )/ _ | / __/ _/ ___/"
@@ -110,7 +116,7 @@ sub do_about()
110116
print "__)| | |(_||||_)/--\__)|\_"
111117
endif
112118
print
113-
color 7,0
119+
color 7
114120
print "Version "; sbver
115121
print
116122
print "Copyright (c) 2002-2018 Chris Warren-Smith"
@@ -122,26 +128,26 @@ sub do_about()
122128
bn_home.type = "link"
123129
bn_home.isExternal = true
124130
bn_home.label = "https://smallbasic.github.io"
125-
bn_home.color = 3
131+
bn_home.color = colLink
126132
print:print
127133

128-
color colGrey,0
134+
color colGrey
129135
print "SmallBASIC comes with ABSOLUTELY NO WARRANTY. ";
130136
print "This program is free software; you can use it ";
131137
print "redistribute it and/or modify it under the terms of the ";
132138
print "GNU General Public License version 2 as published by ";
133139
print "the Free Software Foundation." + chr(10)
134140
print
135-
color 7,0
141+
color 7
136142
server_info()
137143
do_okay_button(bn_home)
138-
cls
144+
clear_screen()
139145
end
140146

141147
sub do_setup()
142148
local frm
143149

144-
color 3, 0
150+
color 3
145151
cls
146152
print boldOn + "Setup web service port number."
147153
print boldOff
@@ -163,7 +169,7 @@ sub do_setup()
163169
env("serverToken=" + token)
164170
endif
165171

166-
color 3, 0
172+
color 3
167173
cls
168174
print "Web service port number: " + env("serverSocket")
169175
print
@@ -187,8 +193,7 @@ sub do_setup()
187193
local msg = "You must restart SmallBASIC for this change to take effect."
188194
local wnd = window()
189195
wnd.alert(msg, "Restart required")
190-
color 7, 0
191-
cls
196+
clear_screen()
192197
end
193198

194199
sub server_info()
@@ -422,7 +427,7 @@ sub manageFiles()
422427
bn_files.y = bn_edit.y + char_h + 2
423428
bn_files.height = ymax - bn_files.y
424429
bn_files.width = xmax - x1
425-
bn_files.color = 2
430+
bn_files.color = colText
426431
bn_files.type = "list"
427432
bn_files.resizable = TRUE
428433
bn_files.help = "No .bas files in " + cwd
@@ -508,13 +513,14 @@ sub manageFiles()
508513
else
509514
tload selectedFile, buffer
510515
wnd.graphicsScreen2()
516+
color 7
511517
cls
512-
color 7,0
513518
len_buffer = len(buffer) - 1
514519
for i = 0 to len_buffer
515520
print buffer(i)
516521
next i
517522
do_okay_button(nil)
523+
clear_screen()
518524
wnd.graphicsScreen1()
519525
f.value = selectedFile
520526
endIf
@@ -649,6 +655,7 @@ sub main
649655
path = backPath
650656
end
651657

658+
clear_screen()
652659
path = cwd
653660
frm = makeUI(path, sortDir)
654661

src/ui/system.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,15 @@ char *System::readSource(const char *fileName) {
537537
buffer = (char *)malloc(len + 1);
538538
len = read(h, buffer, len);
539539
buffer[len] = '\0';
540-
_activeFile = fileName;
541-
_modifiedTime = getModifiedTime();
540+
_modifiedTime = st.st_mtime;
541+
char fullPath[PATH_MAX + 1];
542+
char *path = realpath(fileName, fullPath);
543+
if (path != NULL) {
544+
// set full path for getModifiedTime()
545+
_activeFile = fullPath;
546+
} else {
547+
_activeFile = fileName;
548+
}
542549
}
543550
close(h);
544551
}

src/ui/textedit.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -978,11 +978,7 @@ void TextEditInput::updateField(var_p_t form) {
978978
bool TextEditInput::updateUI(var_p_t form, var_p_t field) {
979979
bool updated = (form && field) ? FormInput::updateUI(form, field) : false;
980980
if (!_theme) {
981-
if (_fg == DEFAULT_FOREGROUND && _bg == DEFAULT_BACKGROUND) {
982-
_theme = new EditTheme();
983-
} else {
984-
_theme = new EditTheme(_fg, _bg);
985-
}
981+
_theme = new EditTheme();
986982
updated = true;
987983
}
988984
return updated;

src/ui/utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#endif
1818

1919
#define DEFAULT_FOREGROUND 0xa1a1a1
20-
#define DEFAULT_BACKGROUND 0x121212
20+
#define DEFAULT_BACKGROUND 0
2121
#define HANDLE_SCREEN_BUFFER HANDLE_SCREEN
2222
#define USER_MESSAGE_EXIT 1000
2323

0 commit comments

Comments
 (0)