diff --git a/Makefile.mos b/Makefile.mos new file mode 100644 index 00000000..dabd3d47 --- /dev/null +++ b/Makefile.mos @@ -0,0 +1,81 @@ +# +# Project: Lite XL +# +# Created on: 26-12-2021 +# + +LiteXL_OBJ := \ + src/dirmonitor.o src/main.o src/rencache.o src/renderer.o \ + src/renwindow.o src/api/api.o src/api/regex.o \ + src/api/renderer.o src/api/system.o src/platform/morphos.o + + +outfile := lite +compiler := gcc +cxxcompiler := g++ + +INCPATH := -Isrc -Ilib/dmon -I/sdk/gg/usr/local/include/SDL2 -I/sdk/gg/usr/include/freetype -I/sdk/gg/usr/include/lua5.2 +DFLAGS := -D__USE_INLINE__ -DLITE_XL_DATA_USE_EXEDIR +CFLAGS := -Wall -Wwrite-strings -O2 -noixemul -g -std=gnu11 -fno-strict-aliasing +LFLAGS := -noixemul -lpcre2 -lSDL2 -llua52 -lagg -lfreetype -lm -lc -L/usr/local/lib + + +.PHONY: LiteXL clean release + +default: LiteXL + +clean: + @echo "Cleaning compiler objects..." + @rm -f $(LiteXL_OBJ) + +LiteXL: $(LiteXL_OBJ) + @echo "Linking LiteXL" + @$(cxxcompiler) -o $(outfile) $(LiteXL_OBJ) $(LFLAGS) + + + +.c.o: + @echo "Compiling $<" + @$(compiler) -c $< -o $*.o $(CFLAGS) $(INCPATH) $(DFLAGS) + +src/dirmonitor.o: src/dirmonitor.c src/platform/amigaos4.h + +src/main.o: src/main.c src/api/api.h src/rencache.h \ + src/renderer.h src/platform/amigaos4.h src/dirmonitor.h + +src/rencache.o: src/rencache.c + +src/renderer.o: src/renderer.c + +src/renwindow.o: src/renwindow.c + +src/api/api.o: src/api/api.c + +src/api/regex.o: src/api/regex.c + +src/api/renderer.o: src/api/renderer.c + +src/api/system.o: src/api/system.c + +src/platform/morphos.o: src/platform/morphos.c + + + + +release: clean LiteXL + @echo "Creating release files..." + @mkdir -p release/LiteXL2 + @cp release_files/* release/LiteXL2/ -r + @mv release/LiteXL2/LiteXL2.info release/ + @cp data release/LiteXL2/ -r + @cp changelog.md release/LiteXL2/ + @cp lite release/LiteXL2/ + @strip release/LiteXL2/lite + @cp README.md release/LiteXL2/ + @cp README_Amiga.md release/LiteXL2/ + @cp LICENSE release/LiteXL2/ + @echo "Creating release archive..." + @lha -aeqr3 a LiteXL2_MOS.lha release/ + @echo "Clean release files..." + @delete release ALL QUIET FORCE + diff --git a/Makefile.os4 b/Makefile.os4 index 840105b9..32eef1b4 100644 --- a/Makefile.os4 +++ b/Makefile.os4 @@ -38,7 +38,6 @@ LiteXL: $(LiteXL_OBJ) @$(cxxcompiler) -o $(outfile) $(LiteXL_OBJ) $(LFLAGS) - .c.o: @echo "Compiling $<" @$(compiler) -c $< -o $*.o $(CFLAGS) $(INCPATH) $(DFLAGS) @@ -67,16 +66,20 @@ src/platform/amigaos4.o: src/platform/amigaos4.c -release: - mkdir -p release/LiteXL2 - cp release_files/* release/LiteXL2/ -r - mv release/LiteXL2/LiteXL2.info release/ - cp data release/LiteXL2/ -r - cp changelog.md release/LiteXL2/ - cp lite release/LiteXL2/ - strip release/LiteXL2/lite - cp README.md release/LiteXL2/ - cp README_OS4.md release/LiteXL2/ - cp LICENSE release/LiteXL2/ - lha -aeqr3 a LiteXL2_OS4.lha release/ +release: clean LiteXL + @echo "Creating release files..." + @mkdir -p release/LiteXL2 + @cp release_files/* release/LiteXL2/ -r + @mv release/LiteXL2/LiteXL2.info release/ + @cp data release/LiteXL2/ -r + @cp changelog.md release/LiteXL2/ + @cp lite release/LiteXL2/ + @strip release/LiteXL2/lite + @cp README.md release/LiteXL2/ + @cp README_Amiga.md release/LiteXL2/ + @cp LICENSE release/LiteXL2/ + @echo "Creating release archive..." + @lha -aeqr3 a LiteXL2_OS4.lha release/ + @echo "Clean release files..." + @delete release ALL QUIET FORCE diff --git a/README_OS4.md b/README_Amiga.md similarity index 82% rename from README_OS4.md rename to README_Amiga.md index d63cdd94..3b49d784 100644 --- a/README_OS4.md +++ b/README_Amiga.md @@ -1,13 +1,14 @@ -# Lite XL v2 for AmigaOS 4.1 FE +# Lite XL v2 for AmigaOS 4.1 FE & MorphOS 3 Lite XL is a lightweight text editor written in Lua. -The port is not perfect and might has issues here and there. For example +The port is not perfect and it might have issues here and there. For example the filesystem notifications are not working yet. So when you make changes at a project folder those will not be reflected in Lite XL automatically. It might crash from time to time, if there is a path problem, but overall it works pretty well. This is my daily editor for any kind of development. +If it crashes on your system, try to delete to `.config` folder. ## New features against Lite XL v1 - Faster file scrolling @@ -24,9 +25,9 @@ editor. ## Configuration folder This editor creates a `.config` folder where the configuration is saved, as -well as plugins, themes etc.. By default this AmigaOS 4.1 FE version uses the -executable folder, but if you want to ovveride it, create an ENV variable -named `HOME` and set there your path. +well as plugins, themes etc.. By default this version uses the +executable folder, but if you want to overide it, you can create an ENV +variable named `HOME` and set there your prefferable path. You can check if there is one already set by executing the following command in a shell @@ -65,10 +66,10 @@ The themes can also be found at https://github.com/lite-xl/lite-xl-colors ### Plugins -The Lite XL that you are using on AmigaOS 4 is based on version 2.0.4 -and not the latest version that is available by the development team. -This means that some of the latest plugins might not working at all -or need some modifications to work. +This Lite XL release is based on version 2.0.3 of the application as +released on other systems, by the original development team. +This not the latest version. This means that some of the latest +plugins might not working at all or need modifications to work. To make it easier for you, I gathered some of the plugins that are working well, and I included them under `addons/plugins`. For you to install the @@ -175,8 +176,10 @@ folders, as you like. ## I would like to thank - IconDesigner for the proper glow icons that are included in the release -- Capehill for his tireless work on SDL port +- Capehill for his tireless work on SDL port for AmigaOS 4.1 FE - Michael Trebilcock for his port on liblua +- Bruno "BeWorld" Peloille for his great work on porting SDL to MorphOS + and for his valuable help - Lite XL original team for being helpful and providing info Without all the above Lite XL would not be possible @@ -192,6 +195,19 @@ https://git.walkero.gr/walkero/lite-xl/issues # Changelog +## [2.0.3r2] - 2022-06-18 +### Added +- First public MorphOS version released + +### Changed +- Merged source code for both AmigaOS 4 and MorphOS +- Moved the declaration of the $VER and $STACK for the AmigaOS 4 version, + so to happen only once (reported by capehill) + +### Fixed +- Fixed the usage of NumPad (reported by root) + + ## [2.0.3r1] - 2022-03-30 ### Changed - Applied all the necessary changes to make it run under AmigaOS 4.1 FE @@ -199,6 +215,6 @@ https://git.walkero.gr/walkero/lite-xl/issues # Disclaimer YOU MAY USE IT AT YOUR OWN RISK! -I will not be held responsible for any data loss or problem you might get +I will not be held responsible for any data loss or problems you might get by using this software. diff --git a/README_OS4.md.info b/README_Amiga.md.info similarity index 95% rename from README_OS4.md.info rename to README_Amiga.md.info index cfd4ecb5..7e6d1d14 100644 Binary files a/README_OS4.md.info and b/README_Amiga.md.info differ diff --git a/data/core/common.lua b/data/core/common.lua index df7d435a..8d153f57 100644 --- a/data/core/common.lua +++ b/data/core/common.lua @@ -1,5 +1,6 @@ local common = {} +local mos = PLATFORM == "MORPHOS" function common.is_utf8_cont(s, offset) local byte = s:byte(offset or 1) @@ -58,7 +59,14 @@ function common.color(str) r = (f() or 0) g = (f() or 0) b = (f() or 0) - a = (f() or 1) * 0xff + if mos then + a = (f() or "1.0"):gsub("%.", ",") * 0xff -- This is necessary for Lua 5.2 on MOS + -- having issues with float numbers having + -- a dot instead of comma + else + a = (f() or 1) * 0xff + end + else error(string.format("bad color string '%s'", str)) end @@ -438,3 +446,4 @@ function common.rm(path, recursively) end return common + diff --git a/data/core/keymap.lua b/data/core/keymap.lua index 0999dc53..bb33d9c4 100644 --- a/data/core/keymap.lua +++ b/data/core/keymap.lua @@ -8,9 +8,10 @@ keymap.reverse_map = {} local macos = PLATFORM == "Mac OS X" local os4 = PLATFORM == "AmigaOS 4" +local mos = PLATFORM == "MORPHOS" -- Thanks to mathewmariani, taken from his lite-macos github repository. -local modkeys_os = require("core.modkeys-" .. (macos and "macos" or os4 and "os4" or "generic")) +local modkeys_os = require("core.modkeys-" .. (macos and "macos" or os4 and "os4" or mos and "mos" or "generic")) local modkey_map = modkeys_os.map local modkeys = modkeys_os.keys diff --git a/data/core/modkeys-mos.lua b/data/core/modkeys-mos.lua new file mode 100755 index 00000000..45522e66 --- /dev/null +++ b/data/core/modkeys-mos.lua @@ -0,0 +1,15 @@ +local modkeys = {} + +modkeys.map = { + ["left amiga"] = "cmd", + ["right amiga"] = "cmd", + ["control"] = "ctrl", + ["left shift"] = "shift", + ["right shift"] = "shift", + ["left alt"] = "alt", + ["right alt"] = "altgr", +} + +modkeys.keys = { "cmd", "ctrl", "alt", "altgr", "shift" } + +return modkeys diff --git a/data/core/start.lua b/data/core/start.lua index f8d14283..c7bde38d 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.0.3r1" +VERSION = "2.0.3r2" MOD_VERSION = "2" SCALE = tonumber(os.getenv("LITE_SCALE") or os.getenv("GDK_SCALE") or os.getenv("QT_SCALE_FACTOR")) or SCALE diff --git a/data/core/style.lua b/data/core/style.lua index 79ef47e1..2c70d3dc 100644 --- a/data/core/style.lua +++ b/data/core/style.lua @@ -73,3 +73,4 @@ style.syntax_fonts = {} -- style.syntax_fonts["comment"] = renderer.font.load(path_to_font, size_of_font, rendering_options) return style + diff --git a/lib/dmon/dmon.h b/lib/dmon/dmon.h index 1650bc00..3c8be357 100644 --- a/lib/dmon/dmon.h +++ b/lib/dmon/dmon.h @@ -140,6 +140,9 @@ DMON_API_DECL void dmon_unwatch(dmon_watch_id id); #elif defined(__amigaos4__) # undef DMON_OS_AMIGAOS4 # define DMON_OS_AMIGAOS4 1 +#elif defined(__morphos__) +# undef DMON_OS_MORPHOS +# define DMON_OS_MORPHOS 1 #else # define DMON_OS 0 # error "unsupported platform" @@ -178,7 +181,7 @@ DMON_API_DECL void dmon_unwatch(dmon_watch_id id); # include # include # include -#elif DMON_OS_AMIGAOS4 +#elif DMON_OS_AMIGAOS4 || DMON_OS_MORPHOS #endif #ifndef DMON_MALLOC @@ -1593,3 +1596,4 @@ DMON_API_IMPL void dmon_unwatch(dmon_watch_id id) #endif // DMON_IMPL #endif // __DMON_H__ + diff --git a/src/api/system.c b/src/api/system.c index 4ea405c8..c5343b7d 100644 --- a/src/api/system.c +++ b/src/api/system.c @@ -16,6 +16,8 @@ #include #elif __amigaos4__ #include "platform/amigaos4.h" +#elif __morphos__ + #include "platform/morphos.h" #endif extern SDL_Window *window; @@ -102,7 +104,7 @@ static const char *numpad[] = { "end", "down", "pagedown", "left", "", "right", static const char *get_key_name(const SDL_Event *e, char *buf) { SDL_Scancode scancode = e->key.keysym.scancode; - #if !defined(__amigaos4__) && !defined(__MORPHOS__) + #if !defined(__amigaos4__) && !defined(__morphos__) /* Is the scancode from the keypad and the number-lock off? ** We assume that SDL_SCANCODE_KP_1 up to SDL_SCANCODE_KP_9 and SDL_SCANCODE_KP_0 ** and SDL_SCANCODE_KP_PERIOD are declared in SDL2 in that order. */ @@ -530,7 +532,7 @@ static int f_list_dir(lua_State *L) { #define realpath(x, y) _fullpath(y, x, MAX_PATH) #endif -#ifdef __amigaos4__ +#if defined(__amigaos4__) || defined(__morphos__) #define realpath(x, y) _fullpath(x) #endif diff --git a/src/main.c b/src/main.c index cef68ad7..832737ea 100644 --- a/src/main.c +++ b/src/main.c @@ -5,6 +5,11 @@ #include "rencache.h" #include "renderer.h" +#if defined(__amigaos4__) || defined(__morphos__) +#define VSTRING "Lite XL 2.0.3r2 (18.06.2022)" +#define VERSTAG "\0$VER: " VSTRING +#endif + #ifdef _WIN32 #include #elif __linux__ @@ -14,6 +19,12 @@ #include #elif __amigaos4__ #include "platform/amigaos4.h" + static CONST_STRPTR stack USED = "$STACK:102400"; + static CONST_STRPTR version USED = VERSTAG; +#elif __morphos__ + #include "platform/morphos.h" + unsigned long __stack = 1000000; + UBYTE VString[] = VERSTAG; #endif #include "dirmonitor.h" @@ -47,7 +58,7 @@ static void get_exe_filename(char *buf, int sz) { char exepath[size]; _NSGetExecutablePath(exepath, &size); realpath(exepath, buf); -#elif __amigaos4__ +#elif defined(__amigaos4__) || defined(__morphos__) strcpy(buf, _fullpath("./lite")); #else strcpy(buf, "./lite"); diff --git a/src/platform/amigaos4.h b/src/platform/amigaos4.h index 5b1b692f..8ab9a85f 100644 --- a/src/platform/amigaos4.h +++ b/src/platform/amigaos4.h @@ -4,11 +4,6 @@ #include #include -#define VSTRING "Lite XL OS4 2.0.3r1 (30.04.2022)" -#define VERSTAG "\0$VER: " VSTRING - -static CONST_STRPTR stack USED = "$STACK:102400"; -static CONST_STRPTR version USED = VERSTAG; char *_fullpath(const char *); diff --git a/src/platform/morphos.c b/src/platform/morphos.c new file mode 100755 index 00000000..029cd20e --- /dev/null +++ b/src/platform/morphos.c @@ -0,0 +1,61 @@ + +#include +#include +#include + +#include "morphos.h" +#define MAX_DOS_NAME FILENAME_MAX + +static char *getFullPath(const char *path) +{ + char *appPath = malloc(sizeof(char) * MAX_DOS_NAME); + BPTR pathLock = Lock(path, SHARED_LOCK); + if (pathLock) + { + NameFromLock(pathLock, appPath, sizeof(char) * MAX_DOS_NAME); + UnLock(pathLock); + + return appPath; + } + return NULL; +} + +static char *getCurrentPath(void) +{ + char *appPath = malloc(sizeof(char) * MAX_DOS_NAME); + BOOL success = GetCurrentDirName(appPath, sizeof(char) * MAX_DOS_NAME); + if (!success) { + strncpy(appPath, "PROGDIR:", sizeof(char) * MAX_DOS_NAME); + } + + return appPath; +} + +char *_fullpath(const char *path) +{ + static char prvPath[MAX_DOS_NAME]; + static char result[MAX_DOS_NAME]; + + if (!strcmp(path, prvPath)) + { + return result; + } + + strcpy(prvPath, path); + + if (!strcmp(path, "./lite")) + { + // TODO: Add code to get the name of the executable + strcpy(result, getFullPath("PROGDIR:lite")); + return result; + } + + if (!strcmp(path, ".")) + { + strcpy(result, getCurrentPath()); + return result; + } + + strcpy(result, getFullPath(path)); + return result; +} diff --git a/src/platform/morphos.h b/src/platform/morphos.h new file mode 100755 index 00000000..7b94ab80 --- /dev/null +++ b/src/platform/morphos.h @@ -0,0 +1,9 @@ +#ifndef _MORPHOS_H +#define _MORPHOS_H + +#include +#include + +char *_fullpath(const char *); + +#endif diff --git a/src/renderer.c b/src/renderer.c index 43c94b28..190d64f5 100644 --- a/src/renderer.c +++ b/src/renderer.c @@ -334,7 +334,7 @@ void ren_draw_rect(RenRect rect, RenColor color) { SDL_Surface *surface = renwin_get_surface(&window_renderer); uint32_t *d = surface->pixels; - #ifdef __amigaos4__ + #if defined(__amigaos4__) || defined(__morphos__) d += x1 + y1 * surface->pitch/sizeof(uint32_t); int dr = surface->pitch/sizeof(uint32_t) - (x2 - x1); #else diff --git a/src/renwindow.c b/src/renwindow.c index 245f8a05..dde9fc2f 100644 --- a/src/renwindow.c +++ b/src/renwindow.c @@ -10,7 +10,7 @@ static int query_surface_scale(RenWindow *ren) { /* We consider that the ratio pixel/point will always be an integer and it is the same along the x and the y axis. */ - #ifdef __amigaos4__ + #if defined(__amigaos4__) || defined(__morphos__) // This is a workaround when the w_pixels != w_points and h_pixels != h_points // because of redraw delays, especially when the "Resize with contents" is enabled if (w_pixels != w_points) {