From 69bd81188bd889ad807572464b2d4dcf372abeef Mon Sep 17 00:00:00 2001 From: George Sokianos Date: Sat, 18 Jun 2022 18:17:07 +0100 Subject: [PATCH] Merged MOS and OS4 code. Did some more fixes before the 2.0.3r2 release. --- Makefile.mos | 81 +++++++++++++++++++++ Makefile.os4 | 29 ++++---- README_OS4.md => README_Amiga.md | 38 +++++++--- README_OS4.md.info => README_Amiga.md.info | Bin 5092 -> 5092 bytes data/core/common.lua | 11 ++- data/core/keymap.lua | 3 +- data/core/modkeys-mos.lua | 15 ++++ data/core/start.lua | 2 +- data/core/style.lua | 1 + lib/dmon/dmon.h | 6 +- src/api/system.c | 6 +- src/main.c | 13 +++- src/platform/amigaos4.h | 5 -- src/platform/morphos.c | 61 ++++++++++++++++ src/platform/morphos.h | 9 +++ src/renderer.c | 2 +- src/renwindow.c | 2 +- 17 files changed, 246 insertions(+), 38 deletions(-) create mode 100644 Makefile.mos rename README_OS4.md => README_Amiga.md (82%) rename README_OS4.md.info => README_Amiga.md.info (95%) create mode 100755 data/core/modkeys-mos.lua create mode 100755 src/platform/morphos.c create mode 100755 src/platform/morphos.h 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 cfd4ecb595010fa5f6f2f337dfcd4b841d0513d4..7e6d1d145e5e6a4c1fa9ec207c4257754ae38ac6 100644 GIT binary patch delta 99 zcmaE&{zQF(n0w5@mjN*cUkEUu14b5xn1gRVK!lm}f%J5Qk_HIVfx&@+Dc&cCfq7$M YJ>$dzmdy_sdzhHxJsCFVvy}1!03p{DUjP6A delta 99 zcmaE&{zQF(n0rW3nn6fW>I4RKz{tW7Qj~oGB-{YSAT|UvKqv # 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) {