From 2d088256b1981c068f528d87e9be57f7a0485004 Mon Sep 17 00:00:00 2001 From: harens Date: Wed, 18 Aug 2021 13:26:51 +0100 Subject: [PATCH] Add unix-like behaviour on macOS Closes https://github.com/lite-xl/lite-xl/issues/398 --- data/core/keymap.lua | 2 +- meson.build | 3 ++- meson_options.txt | 1 + src/main.c | 10 ++++++++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/data/core/keymap.lua b/data/core/keymap.lua index 93ca39a3..0b08259d 100644 --- a/data/core/keymap.lua +++ b/data/core/keymap.lua @@ -5,7 +5,7 @@ keymap.modkeys = {} keymap.map = {} keymap.reverse_map = {} -local macos = rawget(_G, "MACOS_RESOURCES") +local macos = rawget(_G, "MACOS") -- Thanks to mathewmariani, taken from his lite-macos github repository. local modkeys_os = require("core.modkeys-" .. (macos and "macos" or "generic")) diff --git a/meson.build b/meson.build index 442c8d5f..709288d7 100644 --- a/meson.build +++ b/meson.build @@ -86,7 +86,8 @@ if get_option('portable') or host_machine.system() == 'windows' lite_bindir = '/' lite_docdir = '/doc' lite_datadir = '/data' -elif host_machine.system() == 'darwin' +elif get_option('bundle') and host_machine.system() == 'darwin' + lite_cargs += '-DMACOS_USE_BUNDLE' lite_bindir = 'Contents/MacOS' lite_docdir = 'Contents/Resources' lite_datadir = 'Contents/Resources' diff --git a/meson_options.txt b/meson_options.txt index 9fcd0da0..9621ff64 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,2 +1,3 @@ +option('bundle', type : 'boolean', value : true, description: 'Build a macOS bundle') option('portable', type : 'boolean', value : false, description: 'Portable install') option('renderer', type : 'boolean', value : false, description: 'Use SDL renderer') diff --git a/src/main.c b/src/main.c index 576b7fcf..6537ba36 100644 --- a/src/main.c +++ b/src/main.c @@ -74,8 +74,10 @@ static void init_window_icon(void) { #endif #ifdef __APPLE__ -void set_macos_bundle_resources(lua_State *L); void enable_momentum_scroll(); +#ifdef MACOS_USE_BUNDLE +void set_macos_bundle_resources(lua_State *L); +#endif #endif int main(int argc, char **argv) { @@ -134,8 +136,12 @@ init_lua: lua_setglobal(L, "EXEFILE"); #ifdef __APPLE__ - set_macos_bundle_resources(L); + lua_pushboolean(L, true); + lua_setglobal(L, "MACOS"); enable_momentum_scroll(); + #ifdef MACOS_USE_BUNDLE + set_macos_bundle_resources(L); + #endif #endif const char *init_lite_code = \