@@ -7,7 +7,7 @@ const char_w = txtw(".")
77const lineSpacing = 2 + char_h
88const idxEdit = 6
99const idxFiles = 7
10- const sizeDateCol = rgb( 100 , 100 , 100 )
10+ const colGrey = rgb( 100 , 100 , 100 )
1111const menu_gap = -(char_w / 2 )
1212const is_sdl = instr(sbver, "SDL" ) != 0
1313const onlineUrl = "http://smallbasic.github.io/samples/index.bas"
@@ -24,6 +24,7 @@ const filesId = "_files"
2424const setupId = "_setup"
2525const aboutId = "_about"
2626const backId = "_back"
27+ const scratchId = "_scratch"
2728
2829func mk_bn(value, lab, fg)
2930 local bn
@@ -47,23 +48,34 @@ func mk_menu(value, lab, x)
4748 mk_menu = bn
4849end
4950
50- sub mk_scratch()
51+ func mk_scratch()
5152 local text
5253 local file = "scratch.bas"
54+ local result = false
5355
5456 if ( not exist(file)) then
5557 dim text
5658 text << "rem Welcome to SmallBASIC"
5759 text << "rem"
58- text << "rem Press F1 for keyword help."
59- text << "rem Press and hold Ctrl then press 'h' for editor help."
60- text << "rem Press and hold Ctrl then press 'r' to RUN this program."
60+ if (is_sdl) then
61+ text << "rem Press F1 for keyword help."
62+ text << "rem Press and hold Ctrl then press 'h' for editor help."
63+ text << "rem Press and hold Ctrl then press 'r' to RUN this program."
64+ text << "rem Click the right mouse button for menu options."
65+ else
66+ text << "rem Press the 3 vertical dots for menu options."
67+ endif
6168 try
6269 tsave file, text
70+ result = true
6371 catch e
64- logprint "Failed to create scratch file: " + e
72+ local wnd = window()
73+ wnd.alert( "Failed to create scratch file: " + e)
6574 end try
75+ else
76+ result = true
6677 endif
78+ return result
6779end
6880
6981sub do_okay_button()
@@ -93,14 +105,14 @@ sub do_about()
93105 print "(_ ._ _ _.|||_) /\ (_ |/ "
94106 print "__)| | |(_||||_)/--\__)|\_"
95107 endif
96- print
108+ print
97109 color 7 , 0
98110 print "Version " ; sbver
99111 print
100112 print "Copyright (c) 2002-2017 Chris Warren-Smith"
101113 print "Copyright (c) 1999-2006 Nic Christopoulos" + chr( 10 )
102114 print "https://smallbasic.sourceforge.io" + chr( 10 )
103- color sizeDateCol ,0
115+ color colGrey ,0
104116 print "SmallBASIC comes with ABSOLUTELY NO WARRANTY. " ;
105117 print "This program is free software; you can use it " ;
106118 print "redistribute it and/or modify it under the terms of the " ;
@@ -285,7 +297,7 @@ sub listFiles(byref frm, path, sortDir, byref basList)
285297 bn.y = - 1
286298 frm.inputs << bn
287299
288- abbr = iff(char_w * 65 > xmax, true , false )
300+ abbr = iff(char_w * 38 > xmax, true , false )
289301 if ( not abbr) then
290302 bn = mk_bn(sortSizeId, "[Size]" , size_col)
291303 bn.type = "link"
@@ -322,7 +334,7 @@ sub listFiles(byref frm, path, sortDir, byref basList)
322334
323335 gap = 12 - len(str(node.size))
324336 n = iff(gap > 1 , gap, 1 )
325- bn = mk_bn( 0 , node.size + space(n) + timestamp(node.mtime), sizeDateCol )
337+ bn = mk_bn( 0 , node.size + space(n) + timestamp(node.mtime), colGrey )
326338 bn.type = "label"
327339 bn.y = - 1
328340 gap = 29 - len(name)
@@ -561,23 +573,21 @@ sub main
561573 local sortDir = env( "sortDir" )
562574 if (len(sortDir) == 0 ) then sortDir = 0
563575
564- if (command == "welcome" && len(files( "*.bas" )) == 0 ) then
565- mk_scratch()
566- endif
567-
568576 func makeUI(path, sortDir)
569- local frm, bn_files, bn_online, bn_setup, bn_about, bn_new
577+ local frm, bn_files, bn_online, bn_setup, bn_about, bn_new, bn_scratch
570578 local basList
571579 dim basList
572580
573581 bn_files = mk_menu(filesId, "File" , 0 )
574582 bn_online = mk_menu(onlineUrl, "Online" , menu_gap)
583+ bn_scratch = mk_menu(scratchId, "Scratch" , menu_gap)
575584 bn_setup = mk_menu(setupId, "Setup" , menu_gap)
576585 bn_about = mk_menu(aboutId, "About" , menu_gap)
577586 bn_online.isExit = true
578587
579588 frm.inputs << bn_files
580589 frm.inputs << bn_online
590+ frm.inputs << bn_scratch
581591 if (!is_sdl) then
582592 frm.inputs << bn_setup
583593 endif
@@ -629,6 +639,10 @@ sub main
629639 managefiles()
630640 endif
631641 frm = makeUI(path, sortDir)
642+ elif frm.value == scratchId then
643+ if (mk_scratch())
644+ frm.close( "scratch.bas" )
645+ endif
632646 elif frm.value == backId then
633647 cls
634648 go_back()
0 commit comments