Skip to content
Merged

12 25 #170

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
2022-11-13 (12.25)
ANDROID: Updated file manager web UI:
- Implemented delete command
- Implemented upload support for non .bas files
- Fixed date column sorting
COMMON: SPLIT with empty input now gives zero length output #147
COMMON: Fix for bug #166: Display floating point numbers with high precision (by J7M)
COMMON: Fixed functions Polyarea, Polycent (by J7M)
CONSOLE: vt100 (esc sequences) support for console (by J7M)

2022-11-06 (12.25)
ANDROID: fix crash with INPUT command while scrolled #160

2022-08-26 (12.25)
CONSOLE: Fixed TAB handling
COMMON: Only TRIM Strings
Expand Down
4 changes: 4 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ function buildWeb() {
function buildEmscripten() {
TARGET="Building Emscripten version."
BUILD_SUBDIRS="src/common src/platform/emcc"
AC_CHECK_PROG(have_xxd, xxd, [yes], [no])
if test "${have_xxd}" = "no" ; then
AC_MSG_ERROR([xxd command not installed: configure failed.])
fi
AC_CHECK_HEADERS([emscripten.h], [], [AC_MSG_ERROR([emscripten is not installed])])
AM_CONDITIONAL(WITH_CYGWIN_CONSOLE, false)
AC_DEFINE(_UnixOS, 1, [Building under Unix like systems.])
Expand Down
9 changes: 9 additions & 0 deletions samples/distro-examples/tests/split-join.bas
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,12 @@ if (9 != ubound(a)) then
throw "Final empty entry was ignored"
endif

row = ""
split row, ":", fields()
if (len(fields) != 0) then throw "Empty input gave non-empty output"

s="$$$1$2$3$4$5$$$6$7$"
split s, "!@#$%^", a
if (ubound(a) - lbound(a) != len(a) - 1) then throw "Dimension error"


5 changes: 3 additions & 2 deletions src/common/blib.c
Original file line number Diff line number Diff line change
Expand Up @@ -2249,10 +2249,11 @@ void cmd_wsplit() {
elem_p = v_elem(var_p, count);
if (*ps) {
v_setstr(elem_p, ps);
} else {
count++;
} else if (count) {
v_setstr(elem_p, "");
count++;
}
count++;

// final resize
v_resize_array(var_p, count);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/lodepng
Submodule lodepng updated 3 files
+2 −2 lodepng.cpp
+1 −1 lodepng.h
+9 −9 pngdetail.cpp
2 changes: 1 addition & 1 deletion src/lib/miniaudio
2 changes: 1 addition & 1 deletion src/lib/stb
Submodule stb updated 2 files
+6 −5 README.md
+428 −0 stb_perlin.h
7 changes: 4 additions & 3 deletions src/platform/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
defaultConfig {
applicationId 'net.sourceforge.smallbasic'
minSdkVersion 16
targetSdkVersion 31
versionCode 52
targetSdkVersion 33
versionCode 54
versionName '12.25'
resConfigs 'en'
}
Expand Down Expand Up @@ -47,9 +47,10 @@ android {
path '../jni/Android.mk'
}
}
namespace 'net.sourceforge.smallbasic'
}

dependencies {
implementation 'androidx.core:core:1.8.0'
implementation 'androidx.core:core:1.9.0'
testImplementation 'junit:junit:4.13.2'
}
3 changes: 1 addition & 2 deletions src/platform/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.sourceforge.smallbasic">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- support large + xlarge screens to avoid compatibility mode -->
<supports-screens android:largeScreens="true" />
<supports-screens android:xlargeScreens="true" />
Expand Down
38 changes: 30 additions & 8 deletions src/platform/android/app/src/main/assets/main.bas
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const aboutId = "_about"
const backId = "_back"
const scratchId = "_scratch"
const scratch_file = HOME + "/scratch.bas"
const sortEnd = chr(255)

func mk_menu(value, lab, x)
local bn
Expand Down Expand Up @@ -76,16 +77,20 @@ func mk_scratch()
return result
end

sub do_okay_button(bn_extra)
sub do_okay_button(bn_extra1, bn_extra2)
local frm, button
button.label = "[Close]"
button.x = (xmax - txtw(button.label)) / 2
button.y = ypos * char_h
button.color = colNav
button.type = "link"
if (ismap(bn_extra)) then
frm.inputs << bn_extra
if (ismap(bn_extra1)) then
frm.inputs << bn_extra1
endif
if (ismap(bn_extra2)) then
frm.inputs << bn_extra2
endif

frm.inputs << button
frm = form(frm)
print
Expand Down Expand Up @@ -130,6 +135,17 @@ sub do_about()
bn_home.color = colNav
print:print

local bn_privacy
color colNav2
bn_privacy.x = 2
bn_privacy.y = ypos * char_h + char_h + 2
bn_privacy.type = "link"
bn_privacy.isExternal = true
bn_privacy.color = colNav
bn_privacy.label = "https://smallbasic.github.io/pages/privacy.html"
print "Privacy Policy:"
print:print

color colText2
print "SmallBASIC comes with ABSOLUTELY NO WARRANTY. ";
print "This program is free software; you can use it ";
Expand All @@ -139,7 +155,7 @@ sub do_about()
print
color colText
server_info()
do_okay_button(bn_home)
do_okay_button(bn_home, bn_privacy)
clear_screen()
end

Expand Down Expand Up @@ -215,13 +231,17 @@ end
func fileCmpFunc0(l, r)
local f1 = lower(l.name)
local f2 = lower(r.name)
if (right(f1, 4) != ".bas") then f1 = sortEnd + f1
if (right(f2, 4) != ".bas") then f2 = sortEnd + f2
local n = iff(f1 == f2, 0, iff(f1 > f2, 1, -1))
return iff(l.dir == r.dir, n, iff(l.dir, 1, -1))
end

func fileCmpFunc1(l, r)
local f1 = lower(l.name)
local f2 = lower(r.name)
if (right(f1, 4) != ".bas") then f1 = sortEnd + f1
if (right(f2, 4) != ".bas") then f2 = sortEnd + f2
local n = iff(f1 == f2, 0, iff(f1 > f2, -1, 1))
return iff(l.dir == r.dir, n, iff(l.dir, 1, -1))
end
Expand Down Expand Up @@ -270,7 +290,7 @@ sub loadFileList(path, byref basList)
end

func androidWalker(node)
if (node.dir == 0 && lower(right(node.name, 4)) == ".bas") then
if (node.dir == 0) then
basList << node
endif
return node.depth == 0
Expand Down Expand Up @@ -377,7 +397,8 @@ sub listFiles(byref frm, path, sortDir, byref basList)
endif
if (abbr) then
bn = mk_bn(path + name, name, txtcol)
bn.type = "link"
bn.type = iff(lower(right(name, 4)) == ".bas", "link", "label")
if (bn.type == "label") then bn.color = colText
if (!node.dir) then bn.isExit = true
else
if (len(name) > 27) then
Expand All @@ -386,7 +407,8 @@ sub listFiles(byref frm, path, sortDir, byref basList)
lab = name
endif
bn = mk_bn(path + name, lab, txtcol)
bn.type = "link"
bn.type = iff(lower(right(name, 4)) == ".bas", "link", "label")
if (bn.type == "label") then bn.color = colText
if (!node.dir) then bn.isExit = true
frm.inputs << bn
gap = 12 - len(str(node.size))
Expand Down Expand Up @@ -538,7 +560,7 @@ sub manageFiles()
for i = 0 to len_buffer
print buffer(i)
next i
do_okay_button(nil)
do_okay_button(nil, nil)
clear_screen()
wnd.graphicsScreen1()
f.value = selectedFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ private Uri getSharedFile(File file) {
try {
File sharesPath = new File(getExternalFilesDir(null), "shares");
if (sharesPath.mkdirs()) {
Log.i(TAG, "created folder: " + sharesPath.toString());
Log.i(TAG, "created folder: " + sharesPath);
}
File shareFile = new File(sharesPath, file.getName());
copy(file, sharesPath);
Expand Down Expand Up @@ -938,6 +938,25 @@ private boolean isPublicStorage(String dir) {
private class WebServerImpl extends WebServer {
private final Map<String, Long> fileLengths = new HashMap<>();

@Override
protected byte[] decodeBase64(String data) {
return Base64.decode(data, Base64.DEFAULT);
}

@Override
protected void deleteFile(String fileName) throws IOException {
if (fileName == null) {
throw new IOException("Empty file name");
}
File file = getFile(fileName);
if (file == null) {
throw new IOException("File not found");
}
if (!file.delete()) {
throw new IOException("Failed to delete file:" + fileName);
}
}

@Override
protected void execStream(InputStream inputStream) throws IOException {
MainActivity.this.execStream(inputStream);
Expand Down Expand Up @@ -983,8 +1002,8 @@ protected void log(String message) {

@Override
protected void renameFile(String from, String to) throws IOException {
if (to == null || !to.endsWith(".bas")) {
throw new IOException("Invalid file name: " + to);
if (to == null) {
throw new IOException("Empty file name");
}
File toFile = getFile(to);
if (toFile != null) {
Expand Down Expand Up @@ -1047,7 +1066,7 @@ private long getFileLength(String name) throws IOException {
private Collection<FileData> getFiles(File path) {
Collection<FileData> result = new ArrayList<>();
if (path.isDirectory() && path.canRead()) {
File[] files = path.listFiles(new BasFileFilter());
File[] files = path.listFiles((FilenameFilter)null);
if (files != null) {
for (File file : files) {
result.add(new FileData(file));
Expand All @@ -1056,5 +1075,5 @@ private Collection<FileData> getFiles(File path) {
}
return result;
}
};
}
}
Loading