Disabled dmon and process and added all fixes for OS4

This commit is contained in:
George Sokianos 2022-01-11 23:32:45 +00:00
parent 05cf40c1c9
commit b919e5b942
12 changed files with 176 additions and 39 deletions

View File

@ -7,9 +7,10 @@ keymap.map = {}
keymap.reverse_map = {} keymap.reverse_map = {}
local macos = PLATFORM == "Mac OS X" local macos = PLATFORM == "Mac OS X"
local os4 = PLATFORM == "AmigaOS 4"
-- Thanks to mathewmariani, taken from his lite-macos github repository. -- Thanks to mathewmariani, taken from his lite-macos github repository.
local modkeys_os = require("core.modkeys-" .. (macos and "macos" or "generic")) local modkeys_os = require("core.modkeys-" .. (macos and "macos" or os4 and "os4" or "generic"))
local modkey_map = modkeys_os.map local modkey_map = modkeys_os.map
local modkeys = modkeys_os.keys local modkeys = modkeys_os.keys
@ -259,3 +260,4 @@ keymap.add_direct {
} }
return keymap return keymap

15
data/core/modkeys-os4.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 -- this file is used by lite-xl to setup the Lua environment when starting
VERSION = "@PROJECT_VERSION@" VERSION = "2.0.4"
MOD_VERSION = "2" MOD_VERSION = "2"
SCALE = tonumber(os.getenv("LITE_SCALE") or os.getenv("GDK_SCALE") or os.getenv("QT_SCALE_FACTOR")) or SCALE SCALE = tonumber(os.getenv("LITE_SCALE") or os.getenv("GDK_SCALE") or os.getenv("QT_SCALE_FACTOR")) or SCALE
@ -31,3 +31,4 @@ end }
table.pack = table.pack or pack or function(...) return {...} end table.pack = table.pack or pack or function(...) return {...} end
table.unpack = table.unpack or unpack table.unpack = table.unpack or unpack

View File

@ -137,6 +137,9 @@ DMON_API_DECL void dmon_unwatch(dmon_watch_id id);
#elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) #elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
# undef DMON_OS_MACOS # undef DMON_OS_MACOS
# define DMON_OS_MACOS __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ # define DMON_OS_MACOS __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
#elif defined(__amigaos4__)
# undef DMON_OS_AMIGAOS4
# define DMON_OS_AMIGAOS4 1
#else #else
# define DMON_OS 0 # define DMON_OS 0
# error "unsupported platform" # error "unsupported platform"
@ -175,6 +178,7 @@ DMON_API_DECL void dmon_unwatch(dmon_watch_id id);
# include <sys/time.h> # include <sys/time.h>
# include <sys/stat.h> # include <sys/stat.h>
# include <dispatch/dispatch.h> # include <dispatch/dispatch.h>
#elif DMON_OS_AMIGAOS4
#endif #endif
#ifndef DMON_MALLOC #ifndef DMON_MALLOC

View File

@ -4,13 +4,13 @@
int luaopen_system(lua_State *L); int luaopen_system(lua_State *L);
int luaopen_renderer(lua_State *L); int luaopen_renderer(lua_State *L);
int luaopen_regex(lua_State *L); int luaopen_regex(lua_State *L);
int luaopen_process(lua_State *L); // int luaopen_process(lua_State *L);
static const luaL_Reg libs[] = { static const luaL_Reg libs[] = {
{ "system", luaopen_system }, { "system", luaopen_system },
{ "renderer", luaopen_renderer }, { "renderer", luaopen_renderer },
{ "regex", luaopen_regex }, { "regex", luaopen_regex },
{ "process", luaopen_process }, // { "process", luaopen_process },
{ NULL, NULL } { NULL, NULL }
}; };
@ -18,3 +18,4 @@ void api_load_libs(lua_State *L) {
for (int i = 0; libs[i].name; i++) for (int i = 0; libs[i].name; i++)
luaL_requiref(L, libs[i].name, libs[i].func, 1); luaL_requiref(L, libs[i].name, libs[i].func, 1);
} }

View File

@ -1,6 +1,6 @@
#include "api.h" #include "api.h"
#include "../renderer.h" #include "renderer.h"
#include "../rencache.h" #include "rencache.h"
static int f_font_load(lua_State *L) { static int f_font_load(lua_State *L) {
const char *filename = luaL_checkstring(L, 1); const char *filename = luaL_checkstring(L, 1);
@ -249,3 +249,4 @@ int luaopen_renderer(lua_State *L) {
lua_setfield(L, -2, "font"); lua_setfield(L, -2, "font");
return 1; return 1;
} }

View File

@ -6,8 +6,8 @@
#include <errno.h> #include <errno.h>
#include <sys/stat.h> #include <sys/stat.h>
#include "api.h" #include "api.h"
#include "../dirmonitor.h" // #include "dirmonitor.h"
#include "../rencache.h" #include "rencache.h"
#ifdef _WIN32 #ifdef _WIN32
#include <direct.h> #include <direct.h>
#include <windows.h> #include <windows.h>
@ -252,20 +252,20 @@ top:
case SDL_USEREVENT: case SDL_USEREVENT:
lua_pushstring(L, "dirchange"); lua_pushstring(L, "dirchange");
lua_pushnumber(L, e.user.code >> 16); lua_pushnumber(L, e.user.code >> 16);
switch (e.user.code & 0xffff) { // switch (e.user.code & 0xffff) {
case DMON_ACTION_DELETE: // case DMON_ACTION_DELETE:
lua_pushstring(L, "delete"); // lua_pushstring(L, "delete");
break; // break;
case DMON_ACTION_CREATE: // case DMON_ACTION_CREATE:
lua_pushstring(L, "create"); // lua_pushstring(L, "create");
break; // break;
case DMON_ACTION_MODIFY: // case DMON_ACTION_MODIFY:
lua_pushstring(L, "modify"); // lua_pushstring(L, "modify");
break; // break;
default: // default:
return luaL_error(L, "unknown dmon event action: %d", e.user.code & 0xffff); // return luaL_error(L, "unknown dmon event action: %d", e.user.code & 0xffff);
} // }
lua_pushstring(L, e.user.data1); // lua_pushstring(L, e.user.data1);
free(e.user.data1); free(e.user.data1);
return 4; return 4;
@ -335,7 +335,11 @@ static int f_set_window_mode(lua_State *L) {
int n = luaL_checkoption(L, 1, "normal", window_opts); int n = luaL_checkoption(L, 1, "normal", window_opts);
SDL_SetWindowFullscreen(window, SDL_SetWindowFullscreen(window,
n == WIN_FULLSCREEN ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); n == WIN_FULLSCREEN ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
if (n == WIN_NORMAL) { SDL_RestoreWindow(window); } if (n == WIN_NORMAL)
{
ren_resize_window();
SDL_RestoreWindow(window);
}
if (n == WIN_MAXIMIZED) { SDL_MaximizeWindow(window); } if (n == WIN_MAXIMIZED) { SDL_MaximizeWindow(window); }
if (n == WIN_MINIMIZED) { SDL_MinimizeWindow(window); } if (n == WIN_MINIMIZED) { SDL_MinimizeWindow(window); }
return 0; return 0;
@ -517,6 +521,10 @@ static int f_list_dir(lua_State *L) {
#define realpath(x, y) _fullpath(y, x, MAX_PATH) #define realpath(x, y) _fullpath(y, x, MAX_PATH)
#endif #endif
#ifdef __amigaos4__
#define realpath(x, y) _fullpath(x)
#endif
static int f_absolute_path(lua_State *L) { static int f_absolute_path(lua_State *L) {
const char *path = luaL_checkstring(L, 1); const char *path = luaL_checkstring(L, 1);
char *res = realpath(path, NULL); char *res = realpath(path, NULL);
@ -789,27 +797,29 @@ static int f_load_native_plugin(lua_State *L) {
static int f_watch_dir(lua_State *L) { static int f_watch_dir(lua_State *L) {
const char *path = luaL_checkstring(L, 1); const char *path = luaL_checkstring(L, 1);
const int recursive = lua_toboolean(L, 2); const int recursive = lua_toboolean(L, 2);
uint32_t dmon_flags = (recursive ? DMON_WATCHFLAGS_RECURSIVE : 0); // uint32_t dmon_flags = (recursive ? DMON_WATCHFLAGS_RECURSIVE : 0);
dmon_watch_id watch_id = dmon_watch(path, dirmonitor_watch_callback, dmon_flags, NULL); uint32_t dmon_flags = 0;
if (watch_id.id == 0) { luaL_error(L, "directory monitoring watch failed"); } // dmon_watch_id watch_id = dmon_watch(path, dirmonitor_watch_callback, dmon_flags, NULL);
lua_pushnumber(L, watch_id.id); // if (watch_id.id == 0) { luaL_error(L, "directory monitoring watch failed"); }
// lua_pushnumber(L, watch_id.id);
lua_pushnumber(L, 0);
return 1; return 1;
} }
#if __linux__ #if __linux__
static int f_watch_dir_add(lua_State *L) { static int f_watch_dir_add(lua_State *L) {
dmon_watch_id watch_id; // dmon_watch_id watch_id;
watch_id.id = luaL_checkinteger(L, 1); // watch_id.id = luaL_checkinteger(L, 1);
const char *subdir = luaL_checkstring(L, 2); // const char *subdir = luaL_checkstring(L, 2);
lua_pushboolean(L, dmon_watch_add(watch_id, subdir)); // lua_pushboolean(L, dmon_watch_add(watch_id, subdir));
return 1; return 1;
} }
static int f_watch_dir_rm(lua_State *L) { static int f_watch_dir_rm(lua_State *L) {
dmon_watch_id watch_id; // dmon_watch_id watch_id;
watch_id.id = luaL_checkinteger(L, 1); // watch_id.id = luaL_checkinteger(L, 1);
const char *subdir = luaL_checkstring(L, 2); // const char *subdir = luaL_checkstring(L, 2);
lua_pushboolean(L, dmon_watch_rm(watch_id, subdir)); // lua_pushboolean(L, dmon_watch_rm(watch_id, subdir));
return 1; return 1;
} }
#endif #endif
@ -914,3 +924,4 @@ int luaopen_system(lua_State *L) {
luaL_newlib(L, lib); luaL_newlib(L, lib);
return 1; return 1;
} }

View File

@ -12,6 +12,8 @@
#include <signal.h> #include <signal.h>
#elif __APPLE__ #elif __APPLE__
#include <mach-o/dyld.h> #include <mach-o/dyld.h>
#elif __amigaos4__
#include "platform/amigaos4.h"
#endif #endif
#include "dirmonitor.h" #include "dirmonitor.h"
@ -45,6 +47,8 @@ static void get_exe_filename(char *buf, int sz) {
char exepath[size]; char exepath[size];
_NSGetExecutablePath(exepath, &size); _NSGetExecutablePath(exepath, &size);
realpath(exepath, buf); realpath(exepath, buf);
#elif __amigaos4__
strcpy(buf, _fullpath("./lite"));
#else #else
strcpy(buf, "./lite"); strcpy(buf, "./lite");
#endif #endif
@ -108,11 +112,13 @@ int main(int argc, char **argv) {
SDL_DisplayMode dm; SDL_DisplayMode dm;
SDL_GetCurrentDisplayMode(0, &dm); SDL_GetCurrentDisplayMode(0, &dm);
dirmonitor_init(); // dirmonitor_init();
window = SDL_CreateWindow( window = SDL_CreateWindow(
"", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, dm.w * 0.8, dm.h * 0.8, "", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, dm.w * 0.8, dm.h * 0.8,
SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_HIDDEN); SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_HIDDEN);
SDL_SetWindowDisplayMode(window, &dm);
init_window_icon(); init_window_icon();
ren_init(window); ren_init(window);
@ -154,6 +160,9 @@ init_lua:
" HOME = os.getenv('" LITE_OS_HOME "')\n" " HOME = os.getenv('" LITE_OS_HOME "')\n"
" local exedir = EXEFILE:match('^(.*)" LITE_PATHSEP_PATTERN LITE_NONPATHSEP_PATTERN "$')\n" " local exedir = EXEFILE:match('^(.*)" LITE_PATHSEP_PATTERN LITE_NONPATHSEP_PATTERN "$')\n"
" local prefix = exedir:match('^(.*)" LITE_PATHSEP_PATTERN "bin$')\n" " local prefix = exedir:match('^(.*)" LITE_PATHSEP_PATTERN "bin$')\n"
" if not HOME then\n"
" HOME = exedir\n"
" end\n"
" dofile((MACOS_RESOURCES or (prefix and prefix .. '/share/lite-xl' or exedir .. '/data')) .. '/core/start.lua')\n" " dofile((MACOS_RESOURCES or (prefix and prefix .. '/share/lite-xl' or exedir .. '/data')) .. '/core/start.lua')\n"
" core = require(os.getenv('LITE_XL_RUNTIME') or 'core')\n" " core = require(os.getenv('LITE_XL_RUNTIME') or 'core')\n"
" core.init()\n" " core.init()\n"
@ -192,7 +201,8 @@ init_lua:
lua_close(L); lua_close(L);
ren_free_window_resources(); ren_free_window_resources();
dirmonitor_deinit(); // dirmonitor_deinit();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

61
src/platform/amigaos4.c Normal file
View File

@ -0,0 +1,61 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "amigaos4.h"
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);
BPTR pathLock = GetCurrentDir();
if (pathLock)
{
NameFromLock(pathLock, appPath, sizeof(char) * MAX_DOS_NAME);
return appPath;
}
return NULL;
}
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;
}

17
src/platform/amigaos4.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef _AMIGAOS4_H
#define _AMIGAOS4_H
#include <proto/dos.h>
#include <proto/exec.h>
#define VSTRING "Lite XL OS4 2.0.4 (04.01.2022)"
#define VERSTAG "\0$VER: " VSTRING
static CONST_STRPTR stack USED = "$STACK:102400";
static CONST_STRPTR version USED = VERSTAG;
char *_fullpath(const char *);
#endif

View File

@ -15,3 +15,4 @@ void rencache_begin_frame(lua_State *L);
void rencache_end_frame(lua_State *L); void rencache_end_frame(lua_State *L);
#endif #endif

View File

@ -9,6 +9,18 @@ static int query_surface_scale(RenWindow *ren) {
SDL_GetWindowSize(ren->window, &w_points, &h_points); SDL_GetWindowSize(ren->window, &w_points, &h_points);
/* We consider that the ratio pixel/point will always be an integer and /* We consider that the ratio pixel/point will always be an integer and
it is the same along the x and the y axis. */ it is the same along the x and the y axis. */
#ifdef __amigaos4__
// 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) {
w_pixels = w_points;
}
if (h_pixels != h_points) {
h_pixels = h_points;
}
#endif
assert(w_pixels % w_points == 0 && h_pixels % h_points == 0 && w_pixels / w_points == h_pixels / h_points); assert(w_pixels % w_points == 0 && h_pixels % h_points == 0 && w_pixels / w_points == h_pixels / h_points);
return w_pixels / w_points; return w_pixels / w_points;
} }
@ -20,7 +32,7 @@ static void setup_renderer(RenWindow *ren, int w, int h) {
SDL_DestroyTexture(ren->texture); SDL_DestroyTexture(ren->texture);
SDL_DestroyRenderer(ren->renderer); SDL_DestroyRenderer(ren->renderer);
} }
ren->renderer = SDL_CreateRenderer(ren->window, -1, 0); ren->renderer = SDL_CreateRenderer(ren->window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
ren->texture = SDL_CreateTexture(ren->renderer, SDL_PIXELFORMAT_BGRA32, SDL_TEXTUREACCESS_STREAMING, w, h); ren->texture = SDL_CreateTexture(ren->renderer, SDL_PIXELFORMAT_BGRA32, SDL_TEXTUREACCESS_STREAMING, w, h);
ren->surface_scale = query_surface_scale(ren); ren->surface_scale = query_surface_scale(ren);
} }
@ -116,3 +128,4 @@ void renwin_free(RenWindow *ren) {
SDL_FreeSurface(ren->surface); SDL_FreeSurface(ren->surface);
#endif #endif
} }