From 79f42686a7a14bd97430ada4c024d84a9071f798 Mon Sep 17 00:00:00 2001 From: George Sokianos Date: Mon, 18 Mar 2024 23:06:01 +0000 Subject: [PATCH] Added ability to open files with drag 'n drop --- README_Amiga.md | 8 ++++++++ data/core/init.lua | 2 +- data/core/start.lua | 2 +- src/main.c | 24 +++++++++++++++++++++++- src/platform/amigaos4.c | 9 +++++++++ src/platform/amigaos4.h | 2 +- 6 files changed, 43 insertions(+), 4 deletions(-) diff --git a/README_Amiga.md b/README_Amiga.md index 3e00895b..5299806e 100644 --- a/README_Amiga.md +++ b/README_Amiga.md @@ -230,6 +230,14 @@ https://git.walkero.gr/walkero/lite-xl/issues # Changelog +## [2.1.3r2] - future +### Added +- Added the ability to open files and folders by drag 'n drop them on the + LiteXL icon when this is on the AmiDock + +### Fixed +- Fix opening files from the root of a device + ## [2.1.3r1] - 2024-03-09 ### Added - Added AmiUpdate support diff --git a/data/core/init.lua b/data/core/init.lua index 02d8c787..b34376da 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -714,7 +714,7 @@ function core.init() local file_abs = core.project_absolute_path(arg_filename) if file_abs then table.insert(files, file_abs) - project_dir = file_abs:match("^(.+)[/\\].+$") + project_dir = file_abs:match("^(.+)[:/\\].+$") end end end diff --git a/data/core/start.lua b/data/core/start.lua index 08470204..7b0f553e 100644 --- a/data/core/start.lua +++ b/data/core/start.lua @@ -1,5 +1,5 @@ -- this file is used by lite-xl to setup the Lua environment when starting -VERSION = "2.1.3r1" +VERSION = "2.1.3r2" MOD_VERSION = "3" SCALE = tonumber(os.getenv("LITE_SCALE") or os.getenv("GDK_SCALE") or os.getenv("QT_SCALE_FACTOR")) or 1 diff --git a/src/main.c b/src/main.c index dc55323b..3831009c 100644 --- a/src/main.c +++ b/src/main.c @@ -8,7 +8,7 @@ #include #if defined(__amigaos4__) || defined(__morphos__) -#define VSTRING "Lite XL 2.1.3r1 (09.03.2024)" +#define VSTRING "Lite XL 2.1.3r2 (18.03.2024)" #define VERSTAG "\0$VER: " VSTRING #endif @@ -20,6 +20,7 @@ #include #elif defined(__amigaos4__) #include + #include #include "platform/codesets.h" #include "platform/amigaos4.h" static CONST_STRPTR stack USED = "$STACK:102400"; @@ -223,6 +224,27 @@ init_lua: lua_pushstring(L, argv[i]); lua_rawseti(L, -2, i + 1); } + #if defined(__amigaos4__) + if (!argc) + { + struct WBStartup *wbs = (struct WBStartup *)argv; + if (wbs->sm_NumArgs > 1) + { + char result[MAX_DOS_PATH]; + for (int i = 0; i < wbs->sm_NumArgs; i++) { + getFullPathFromLock(wbs->sm_ArgList[i].wa_Lock, result); + if (result[strlen(result) -1] == ':') + strcat(result, wbs->sm_ArgList[i].wa_Name); + else + sprintf(result, "%s/%s", result, wbs->sm_ArgList[i].wa_Name); + + lua_pushstring(L, result); + lua_rawseti(L, -2, i + 1); + } + } + } + #endif + lua_setglobal(L, "ARGS"); lua_pushstring(L, SDL_GetPlatform()); diff --git a/src/platform/amigaos4.c b/src/platform/amigaos4.c index afe5f71d..cb864a51 100644 --- a/src/platform/amigaos4.c +++ b/src/platform/amigaos4.c @@ -70,3 +70,12 @@ char *_fullpath(const char *path) return NULL; } + +void getFullPathFromLock(BPTR lock, char *result) +{ + if (lock) + { + DevNameFromLock(lock, result, MAX_DOS_PATH, DN_FULLPATH); + return; + } +} diff --git a/src/platform/amigaos4.h b/src/platform/amigaos4.h index a3848cb3..ee756e9c 100644 --- a/src/platform/amigaos4.h +++ b/src/platform/amigaos4.h @@ -6,6 +6,6 @@ char *_fullpath(const char *); - +void getFullPathFromLock(BPTR, char *); #endif