From df8eaa64d1dbfd864ebf0e5aa578eecc2d3c66d1 Mon Sep 17 00:00:00 2001 From: George Sokianos Date: Sun, 11 Feb 2024 22:11:30 +0000 Subject: [PATCH] Paths fixes, Open in System changes and a few others done --- Makefile.os4 | 6 +++--- README_Amiga.md | 17 +++++++++++++++++ data/core/dirwatch.lua | 16 ++++++++++++++-- data/core/init.lua | 1 + data/core/start.lua | 5 +++-- data/plugins/treeview.lua | 8 +++++--- src/api/system.c | 11 +++++++++-- src/main.c | 2 +- 8 files changed, 53 insertions(+), 13 deletions(-) diff --git a/Makefile.os4 b/Makefile.os4 index 4c80c92d..f41b5a56 100644 --- a/Makefile.os4 +++ b/Makefile.os4 @@ -12,8 +12,8 @@ LiteXL_OBJ := \ src/api/dirmonitor/os4.o src/platform/codesets.o outfile := lite-xl -compiler := gcc-11 -cxxcompiler := g++-11 +compiler := gcc +cxxcompiler := g++ INCPATH := -Isrc -I/sdk/local/newlib/include/SDL2 \ -I/sdk/local/common/include/lua54 -I/sdk/local/common/include/freetype2 @@ -23,7 +23,7 @@ DFLAGS += -D__USE_INLINE__ -DLITE_XL_DATA_USE_EXEDIR CFLAGS += -Werror -Wwrite-strings -O3 -std=gnu11 -fno-strict-aliasing LFLAGS += -mcrt=newlib \ - -lpcre2 -lSDL2 -llua54 -lfreetype -lpng -lz -lpthread -athread=native + -lpcre2-8 -lSDL2 -llua54 -lfreetype -lpng -lz -lpthread -athread=native ifeq ($(DEBUG),1) CFLAGS += -g -gstabs diff --git a/README_Amiga.md b/README_Amiga.md index 1be8e77e..f7a4bcd1 100644 --- a/README_Amiga.md +++ b/README_Amiga.md @@ -223,6 +223,23 @@ https://git.walkero.gr/walkero/lite-xl/issues # Changelog +## [2.1.2r1] - future +### Updated +- Updated the code to the upstream 2.1.3 release +- Compiled with SDL 2.30.x that supports writing in ISO encodings, other + than English. Now the editor should be able to support any language + and in conjuction with the codesets plugin be able to make text + encodings conversions (AmigsOS 4 version only) + +### Changed +- Changed the way the "Open in system" option executes the WBRun command + in AmigaOS 4, with a more secure way +- Did a lot of code cleanup in sync with the upstream, and parts that + were left over + +### Fixed +- Fixed opening partition and assign paths + ## [2.1.2r1] - 2023-12-19 ### Added - Added the new experimental codesets plugin (AmigaOS4 version only). diff --git a/data/core/dirwatch.lua b/data/core/dirwatch.lua index d9ac4523..b0a45df0 100644 --- a/data/core/dirwatch.lua +++ b/data/core/dirwatch.lua @@ -177,7 +177,13 @@ end -- compute a file's info entry completed with "filename" to be used -- in project scan or falsy if it shouldn't appear in the list. local function get_project_file_info(root, file, ignore_compiled) - local info = system.get_file_info(root .. PATHSEP .. file) + local info + if (PLATFORM == "AmigaOS 4" or PLATFORM == "MorphOS") and (string.sub(root, -1) == ":") then + info = system.get_file_info(root .. file) + else + info = system.get_file_info(root .. PATHSEP .. file) + end + -- info can be not nil but info.type may be nil if is neither a file neither -- a directory, for example for /dev/* entries on linux. if info and info.type then @@ -200,7 +206,13 @@ function dirwatch.get_directory_files(dir, root, path, entries_count, recurse_pr local t0 = system.get_time() local ignore_compiled = compile_ignore_files() - local all = system.list_dir(root .. PATHSEP .. path) + local all + if (PLATFORM == "AmigaOS 4" or PLATFORM == "MorphOS") and (string.sub(root, -1) == ":") then + all = system.list_dir(root .. path) + else + all = system.list_dir(root .. PATHSEP .. path) + end + if not all then return nil end local entries = { } for _, file in ipairs(all) do diff --git a/data/core/init.lua b/data/core/init.lua index d298922d..614d7ff3 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -250,6 +250,7 @@ function core.add_project_directory(path) -- will be simply the name of the directory, without its path. -- The field item.topdir will identify it as a top level directory. path = common.normalize_volume(path) + local topdir = { name = path, item = {filename = common.basename(path), type = "dir", topdir = true}, diff --git a/data/core/start.lua b/data/core/start.lua index 7858770a..a509f678 100644 --- a/data/core/start.lua +++ b/data/core/start.lua @@ -5,13 +5,14 @@ MOD_VERSION = "3" SCALE = tonumber(os.getenv("LITE_SCALE") or os.getenv("GDK_SCALE") or os.getenv("QT_SCALE_FACTOR")) or 1 PATHSEP = package.config:sub(1, 1) -EXEDIR = EXEFILE:match("^(.+)[/\\][^/\\]+$") +EXEDIR = EXEFILE:match("^(.+)[:/\\][^/\\]+$") if MACOS_RESOURCES then DATADIR = MACOS_RESOURCES else - local prefix = os.getenv('LITE_PREFIX') or EXEDIR:match("^(.+)[/\\]bin$") + local prefix = os.getenv('LITE_PREFIX') or EXEDIR:match("^(.+)[:/\\]bin$") DATADIR = prefix and (prefix .. PATHSEP .. 'share' .. PATHSEP .. 'lite-xl') or (EXEDIR .. PATHSEP .. 'data') end + USERDIR = (system.get_file_info(EXEDIR .. PATHSEP .. 'user') and (EXEDIR .. PATHSEP .. 'user')) or os.getenv("LITE_USERDIR") or ((os.getenv("XDG_CONFIG_HOME") and os.getenv("XDG_CONFIG_HOME") .. PATHSEP .. "lite-xl")) diff --git a/data/plugins/treeview.lua b/data/plugins/treeview.lua index f1dd6310..d31be569 100644 --- a/data/plugins/treeview.lua +++ b/data/plugins/treeview.lua @@ -789,10 +789,12 @@ command.add( ["treeview:open-in-system"] = function(item) if PLATFORM == "Windows" then system.exec(string.format("start \"\" %q", item.abs_filename)) - elseif string.find(PLATFORM, "Mac") then + elseif string.find(PLATFORM, "Mac") or PLATFORM == "MorphOS" then system.exec(string.format("open %q", item.abs_filename)) elseif PLATFORM == "Linux" or string.find(PLATFORM, "BSD") then system.exec(string.format("xdg-open %q", item.abs_filename)) + elseif PLATFORM == "AmigaOS 4" then + system.exec(string.format("WBRUN %q SHOW=all VIEWBY=name", item.abs_filename)) end end }) @@ -802,8 +804,8 @@ if projectsearch then menu:register(function() local item = treeitem() return item and item.type == "dir" - end, { - { text = "Find in directory", command = "treeview:search-in-directory" } + end, { + { text = "Find in directory", command = "treeview:search-in-directory" } }) command.add(function() return view.hovered_item and view.hovered_item.type == "dir" diff --git a/src/api/system.c b/src/api/system.c index dcdb035e..74f2827c 100644 --- a/src/api/system.c +++ b/src/api/system.c @@ -876,6 +876,13 @@ static int f_exec(lua_State *L) { #if _WIN32 sprintf(buf, "cmd /c \"%s\"", cmd); WinExec(buf, SW_HIDE); +#elif defined(__amigaos4__) + SystemTags( cmd, + SYS_Input, ZERO, + SYS_Output, NULL, + SYS_Error, ZERO, + SYS_Asynch, TRUE, + TAG_DONE); #else sprintf(buf, "%s &", cmd); int res = system(buf); @@ -1006,7 +1013,7 @@ static int f_library_gc(lua_State *L) { lua_getfield(L, 1, "handle"); void* handle = lua_touserdata(L, -1); SDL_UnloadObject(handle); - + return 0; } @@ -1180,7 +1187,7 @@ static const luaL_Reg lib[] = { int luaopen_system(lua_State *L) { - luaL_newmetatable(L, API_TYPE_NATIVE_PLUGIN); + luaL_newmetatable(L, API_TYPE_NATIVE_PLUGIN); lua_pushcfunction(L, f_library_gc); lua_setfield(L, -2, "__gc"); luaL_newlib(L, lib); diff --git a/src/main.c b/src/main.c index 6daf3f44..85abefcd 100644 --- a/src/main.c +++ b/src/main.c @@ -273,7 +273,7 @@ init_lua: " error_dir=USERDIR\n" " pcall(core.on_error, err)\n" " else\n" - " error_dir=system.absolute_path('.')\n" + " error_dir=system.absolute_path(error_dir)\n" " local fp = io.open('error.txt', 'wb')\n" " fp:write('Error: ' .. tostring(err) .. '\\n')\n" " fp:write(debug.traceback(nil, 4)..'\\n')\n"