1- const app = "main.bas?"
2- const boldOn = chr( 27 ) + "[1m"
3- const boldOff = chr( 27 ) + "[21m"
4- const scrollHome = chr( 27 ) + "m"
1+ const boldOn = "\033[1m"
2+ const boldOff = "\033[21m"
3+ const scrollHome = "\033m"
54const char_h = txth( "Q" )
65const char_w = txtw( "." )
76const lineSpacing = 2 + char_h
8- const idxEdit = 6
9- const idxFiles = 7
10- const colGrey = rgb( 100 , 100 , 100 )
11- const colBkGnd = rgb( 31 , 28 , 31 )
12- const colText = 2
13- const colLink = 3
7+ const wnd = window()
8+ const theme = wnd.theme
9+ const colBkGnd = theme.background
10+ const colText = theme.text1
11+ const colFile = theme.text2
12+ const colDir = theme.text3
13+ const colText2 = theme.text4
14+ const colNav = theme.text5
15+ const colNav2 = theme.text6
1416const menu_gap = -(char_w / 2 )
1517const is_sdl = instr(sbver, "SDL" ) != 0
1618const onlineUrl = "http://smallbasic.github.io/samples/index.bas"
19+ const idxEdit = 6
20+ const idxFiles = 7
1721const saveasId = "__bn_saveas__"
1822const renameId = "__bn_rename__"
1923const deleteId = "__bn_delete__"
@@ -37,7 +41,7 @@ func mk_bn(value, lab, fg)
3741 bn.value = value
3842 bn.label = lab
3943 bn.color = fg
40- mk_bn = bn
44+ return bn
4145end
4246
4347func mk_menu(value, lab, x)
@@ -46,9 +50,9 @@ func mk_menu(value, lab, x)
4650 bn.y = ypos * char_h
4751 bn.value = value
4852 bn.label = "[" + lab + "]"
49- bn.color = colLink
53+ bn.color = colNav
5054 bn.type = "link"
51- mk_menu = bn
55+ return bn
5256end
5357
5458func mk_scratch()
@@ -72,7 +76,6 @@ func mk_scratch()
7276 tsave scratch_file, text
7377 result = true
7478 catch e
75- local wnd = window()
7679 logprint e
7780 wnd.alert( "Failed to create: " + scratch_file)
7881 end try
@@ -87,7 +90,7 @@ sub do_okay_button(bn_extra)
8790 button.label = "[Close]"
8891 button.x = (xmax - txtw(button.label)) / 2
8992 button.y = ypos * char_h
90- button.color = colLink
93+ button.color = colNav
9194 button.type = "link"
9295 if (ismap(bn_extra)) then
9396 frm.inputs << bn_extra
@@ -117,7 +120,7 @@ sub do_about()
117120 print "__)| | |(_||||_)/--\__)|\_"
118121 endif
119122 print
120- color 7
123+ color colText
121124 print "Version " ; sbver
122125 print
123126 print "Copyright (c) 2002-2020 Chris Warren-Smith"
@@ -133,17 +136,17 @@ sub do_about()
133136 else
134137 bn_home.label = "https://smallbasic.github.io/pages/android.html"
135138 endif
136- bn_home.color = colLink
139+ bn_home.color = colNav
137140 print:print
138141
139- color colGrey
142+ color colText2
140143 print "SmallBASIC comes with ABSOLUTELY NO WARRANTY. " ;
141144 print "This program is free software; you can use it " ;
142145 print "redistribute it and/or modify it under the terms of the " ;
143146 print "GNU General Public License version 2 as published by " ;
144147 print "the Free Software Foundation." + chr( 10 )
145148 print
146- color 7
149+ color colText
147150 server_info()
148151 do_okay_button(bn_home)
149152 clear_screen()
152155sub do_setup()
153156 local frm
154157
155- color 3 , colBkGnd
158+ color colText , colBkGnd
156159 cls
157160 print boldOn + "Setup web service port number."
158161 print boldOff
@@ -161,7 +164,7 @@ sub do_setup()
161164 print "this screen without making any changes."
162165 print "The current setting is: " + env( "serverSocket" )
163166 print
164- color 15 , 3
167+ color colText, colBkGnd
165168 input socket
166169
167170 if (len(socket) > 0 ) then
@@ -174,7 +177,7 @@ sub do_setup()
174177 env( "serverToken=" + token)
175178 endif
176179
177- color 3 , colBkGnd
180+ color colText , colBkGnd
178181 cls
179182 print "Web service port number: " + env( "serverSocket" )
180183 print
@@ -196,7 +199,6 @@ sub do_setup()
196199 env( "fontId=" + frm.inputs( 0 ).selectedIndex)
197200
198201 local msg = "You must restart SmallBASIC for this change to take effect."
199- local wnd = window()
200202 wnd.alert(msg, "Restart required" )
201203 clear_screen()
202204end
293295
294296sub listFiles( byref frm, path, sortDir, byref basList)
295297 local lastItem, bn, abbr, gap, n, lab, name, txtcol, i
296- local name_col = 3
297- local size_col = 3
298- local date_col = 3
298+ local name_col = colNav
299+ local size_col = colNav
300+ local date_col = colNav
299301
300302 if (right(path, 1 ) != "/" ) then
301303 path += "/"
@@ -307,28 +309,28 @@ sub listFiles(byref frm, path, sortDir, byref basList)
307309 sort basList use filecmpfunc0(x,y)
308310 case 1
309311 sort basList use filecmpfunc1(x,y)
310- name_col = 6
312+ name_col = colNav2
311313 case 2
312314 sort basList use filecmpfunc2(x,y)
313- size_col = 5
315+ size_col = colNav2
314316 case 3
315317 sort basList use filecmpfunc3(x,y)
316- size_col = 6
318+ size_col = colNav2
317319 case 4
318320 sort basList use filecmpfunc4(x,y)
319- date_col = 5
321+ date_col = colNav2
320322 case 5
321323 sort basList use filecmpfunc5(x,y)
322- date_col = 6
324+ date_col = colNav2
323325 end select
324326
325- bn = mk_bn( 0 , "Files in " + path, 7 )
327+ bn = mk_bn( 0 , "Files in " + path, colText )
326328 bn.type = "label"
327329 bn.x = 0
328330 bn.y = -lineSpacing
329331 frm.inputs << bn
330332
331- bn = mk_bn(backId, "[Go up]" , 3 )
333+ bn = mk_bn(backId, "[Go up]" , colNav )
332334 bn.type = "link"
333335 bn.x = 0
334336 bn.y = -linespacing
@@ -358,7 +360,7 @@ sub listFiles(byref frm, path, sortDir, byref basList)
358360 lastItem = len(basList) - 1
359361 for i = 0 to lastItem
360362 node = basList(i)
361- txtcol = iff(node.dir, 3 , 2 )
363+ txtcol = iff(node.dir, colDir, colFile )
362364 name = node.name
363365 if (abbr) then
364366 bn = mk_bn(path + name, name, txtcol)
@@ -377,7 +379,7 @@ sub listFiles(byref frm, path, sortDir, byref basList)
377379
378380 gap = 12 - len(str(node.size))
379381 n = iff(gap > 1 , gap, 1 )
380- bn = mk_bn( 0 , node.size + space(n) + timestamp(node.mtime), colGrey )
382+ bn = mk_bn( 0 , node.size + space(n) + timestamp(node.mtime), colText )
381383 bn.type = "label"
382384 bn.y = - 1
383385 gap = 29 - len(name)
@@ -388,7 +390,7 @@ sub listFiles(byref frm, path, sortDir, byref basList)
388390end
389391
390392sub manageFiles()
391- local f, wnd, bn_edit, bn_files, selectedFile
393+ local f, bn_edit, bn_files, selectedFile
392394
393395 func fileCmpFunc(l, r)
394396 local f1 = lower(l)
@@ -425,7 +427,7 @@ sub manageFiles()
425427 bn_edit.y = char_h + 4
426428 bn_edit.width = xmax
427429 bn_edit.type = "text"
428- bn_edit.color = "white"
430+ bn_edit.color = colText2
429431 bn_edit.resizable = TRUE
430432 bn_edit.help = "Enter file name, and then click New."
431433 bn_files.x = x1
@@ -518,7 +520,7 @@ sub manageFiles()
518520 else
519521 tload selectedFile, buffer
520522 wnd.graphicsScreen2()
521- color 7
523+ color colText
522524 cls
523525 len_buffer = len(buffer) - 1
524526 for i = 0 to len_buffer
@@ -569,7 +571,6 @@ sub manageFiles()
569571
570572 createUI()
571573 reloadList( 0 )
572- wnd = window()
573574 wnd.showKeypad()
574575
575576 while 1
@@ -606,7 +607,6 @@ func changeDir(s)
606607 chdir s
607608 return true
608609 catch e
609- local wnd = window()
610610 wnd.alert(e)
611611 return false
612612 end try
@@ -695,17 +695,17 @@ sub main
695695 elif (frm.value == sortNameId) then
696696 cls
697697 sortDir = iff(sortDir== 0 , 1 , 0 )
698- env( "sortDir=" + sortDir)
698+ env( "sortDir=" + sortDir)
699699 frm = makeUI(path, sortDir)
700700 elif (frm.value == sortSizeId) then
701701 cls
702702 sortDir = iff(sortDir== 3 , 2 , 3 )
703- env( "sortDir=" + sortDir)
703+ env( "sortDir=" + sortDir)
704704 frm = makeUI(path, sortDir)
705705 elif (frm.value == sortDateId) then
706706 cls
707707 sortDir = iff(sortDir== 5 , 4 , 5 )
708- env( "sortDir=" + sortDir)
708+ env( "sortDir=" + sortDir)
709709 frm = makeUI(path, sortDir)
710710 fi
711711 wend
0 commit comments