Merged MOS and OS4 code. Did some more fixes before the 2.0.3r2 release.

This commit is contained in:
George Sokianos 2022-06-18 18:17:07 +01:00
parent ff3e5282f6
commit 69bd81188b
17 changed files with 246 additions and 38 deletions

81
Makefile.mos Normal file
View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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

15
data/core/modkeys-mos.lua Executable file
View File

@ -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

View File

@ -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

View File

@ -73,3 +73,4 @@ style.syntax_fonts = {}
-- style.syntax_fonts["comment"] = renderer.font.load(path_to_font, size_of_font, rendering_options)
return style

View File

@ -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 <sys/time.h>
# include <sys/stat.h>
# include <dispatch/dispatch.h>
#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__

View File

@ -16,6 +16,8 @@
#include <sys/vfs.h>
#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

View File

@ -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 <windows.h>
#elif __linux__
@ -14,6 +19,12 @@
#include <mach-o/dyld.h>
#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");

View File

@ -4,11 +4,6 @@
#include <proto/dos.h>
#include <proto/exec.h>
#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 *);

61
src/platform/morphos.c Executable file
View File

@ -0,0 +1,61 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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;
}

9
src/platform/morphos.h Executable file
View File

@ -0,0 +1,9 @@
#ifndef _MORPHOS_H
#define _MORPHOS_H
#include <proto/dos.h>
#include <proto/exec.h>
char *_fullpath(const char *);
#endif

View File

@ -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

View File

@ -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) {