Merge branch 'dev' of github.com:lite-xl/lite-xl into process-refactor

This commit is contained in:
takase1121 2021-07-07 14:46:49 +08:00
commit b07d37b89a
26 changed files with 141 additions and 25 deletions

6
.gitattributes vendored
View File

@ -1,3 +1,7 @@
# Set the default behavior, in case people don't have core.autocrlf set.
# See https://help.github.com/en/articles/dealing-with-line-endings
* text=auto
winlib/* linguist-vendored
src/lib/* linguist-vendored
icon.inl linguist-vendored
resources/icons/icon.inl linguist-vendored

2
.gitignore vendored
View File

@ -7,7 +7,7 @@ build*
subprojects/lua
subprojects/libagg
subprojects/reproc
lite
lite-xl
error.txt
.ccls-cache
compile_commands.json

View File

@ -44,7 +44,7 @@ lite_build_pgo () {
meson setup --buildtype=release -Db_pgo=generate "$build" || exit 1
ninja -C "$build" || exit 1
copy_directory_from_repo data "$build/src"
"$build/src/lite"
"$build/src/lite-xl"
meson configure -Db_pgo=use "$build"
ninja -C "$build" || exit 1
}
@ -74,8 +74,8 @@ lite_build_package_windows () {
for module_name in plugins colors; do
cp -r "$build/third/data/$module_name" "$datadir"
done
cp "$build/src/lite.exe" "$bindir"
strip --strip-all "$bindir/lite.exe"
cp "$build/src/lite-xl.exe" "$bindir"
strip --strip-all "$bindir/lite-xl.exe"
pushd ".package-build"
local package_name="lite-xl-$os-$arch$portable.zip"
zip "$package_name" -r "lite-xl"
@ -100,9 +100,9 @@ lite_build_package_macos () {
for module_name in plugins colors; do
cp -r "$build/third/data/$module_name" "$datadir"
done
cp dev-utils/icon.icns "$appdir/Contents/Resources/icon.icns"
cp dev-utils/Info.plist "$appdir/Contents/Info.plist"
cp "$build/src/lite" "$bindir/lite-xl"
cp resources/icons/icon.icns "$appdir/Contents/Resources/icon.icns"
cp resources/macos/Info.plist "$appdir/Contents/Info.plist"
cp "$build/src/lite-xl" "$bindir/lite-xl"
strip "$bindir/lite-xl"
pushd ".package-build"
local package_name="lite-xl-$os-$arch.zip"
@ -138,12 +138,12 @@ lite_build_package_linux () {
for module_name in plugins colors; do
cp -r "$build/third/data/$module_name" "$datadir"
done
cp "$build/src/lite" "$bindir"
strip "$bindir/lite"
cp "$build/src/lite-xl" "$bindir"
strip "$bindir/lite-xl"
if [ -z "$portable" ]; then
mkdir -p "$pdir/share/applications" "$pdir/share/icons/hicolor/scalable/apps"
cp "dev-utils/lite-xl.desktop" "$pdir/share/applications"
cp "dev-utils/lite.svg" "$pdir/share/icons/hicolor/scalable/apps/lite-xl.svg"
cp "resources/linux/lite-xl.desktop" "$pdir/share/applications"
cp "resources/icons/lite-xl.svg" "$pdir/share/icons/hicolor/scalable/apps/lite-xl.svg"
fi
pushd ".package-build"
local package_name="lite-xl-$os-$arch$portable.tar.gz"

View File

@ -12,7 +12,7 @@ if [[ $* == *windows* ]]; then
echo "cross compiling for windows is not yet supported"
exit 1
else
outfile="lite"
outfile="lite-xl"
compiler="gcc"
cxxcompiler="g++"
fi
@ -20,7 +20,7 @@ fi
lib/font_renderer/build.sh || exit 1
libs=libfontrenderer.a
echo "compiling lite..."
echo "compiling lite-xl..."
for f in `find src -name "*.c"`; do
$compiler -c $cflags $f -o "${f//\//_}.o"
if [[ $? -ne 0 ]]; then

View File

@ -129,6 +129,7 @@ local function split_cursor(direction)
end
end
for i,v in ipairs(new_cursors) do doc():add_selection(v[1], v[2]) end
core.blink_reset()
end
local commands = {

View File

@ -340,4 +340,51 @@ function common.mkdirp(path)
return true
end
function common.rm(path, recursively)
local stat = system.get_file_info(path)
if not stat or (stat.type ~= "file" and stat.type ~= "dir") then
return false, "invalid path given", path
end
if stat.type == "file" then
local removed, error = os.remove(path)
if not removed then
return false, error, path
end
else
local contents = system.list_dir(path)
if #contents > 0 and not recursively then
return false, "directory is not empty", path
end
for _, item in pairs(contents) do
local item_path = path .. PATHSEP .. item
local item_stat = system.get_file_info(item_path)
if not item_stat then
return false, "invalid file encountered", item_path
end
if item_stat.type == "dir" then
local deleted, error, ipath = common.rm(item_path, recursively)
if not deleted then
return false, error, ipath
end
elseif item_stat.type == "file" then
local removed, error = os.remove(item_path)
if not removed then
return false, error, item_path
end
end
end
local removed, error = system.rmdir(path)
if not removed then
return false, error, path
end
end
return true
end
return common

View File

@ -17,7 +17,7 @@ local function keymap_macos(keymap)
["cmd+ctrl+i"] = "root:switch-to-up",
["cmd+ctrl+k"] = "root:switch-to-down",
["ctrl+w"] = "root:close",
["cmd+w"] = "root:close",
["ctrl+tab"] = "root:switch-to-next-tab",
["ctrl+shift+tab"] = "root:switch-to-previous-tab",
["cmd+pageup"] = "root:move-tab-left",

View File

@ -12,7 +12,8 @@ else
local prefix = EXEDIR:match("^(.+)[/\\]bin$")
DATADIR = prefix and (prefix .. '/share/lite-xl') or (EXEDIR .. '/data')
end
USERDIR = os.getenv("XDG_CONFIG_HOME") or (HOME and (HOME .. '/.config/lite-xl') or (EXEDIR .. '/user'))
USERDIR = (os.getenv("XDG_CONFIG_HOME") and os.getenv("XDG_CONFIG_HOME") .. "/lite-xl")
or (HOME and (HOME .. '/.config/lite-xl') or (EXEDIR .. '/user'))
package.path = DATADIR .. '/?.lua;' .. package.path
package.path = DATADIR .. '/?/init.lua;' .. package.path

View File

@ -22,9 +22,9 @@ style.tab_width = common.round(170 * SCALE)
-- On High DPI monitor or non RGB monitor you may consider using antialiasing grayscale instead.
-- The antialiasing grayscale with full hinting is interesting for crisp font rendering.
style.font = renderer.font.load(DATADIR .. "/fonts/FiraSans-Regular.ttf", 13 * SCALE)
style.big_font = renderer.font.load(DATADIR .. "/fonts/FiraSans-Regular.ttf", 40 * SCALE)
style.big_font = style.font:copy(40 * SCALE)
style.icon_font = renderer.font.load(DATADIR .. "/fonts/icons.ttf", 14 * SCALE, {antialiasing="grayscale", hinting="full"})
style.icon_big_font = renderer.font.load(DATADIR .. "/fonts/icons.ttf", 20 * SCALE, {antialiasing="grayscale", hinting="full"})
style.icon_big_font = style.icon_font:copy(20 * SCALE)
style.code_font = renderer.font.load(DATADIR .. "/fonts/JetBrainsMono-Regular.ttf", 13 * SCALE)
style.background = { common.color "#2e2e32" }

View File

@ -1,4 +1,4 @@
project('lite', 'c', 'cpp', default_options : ['c_std=gnu11', 'cpp_std=c++03'])
project('lite-xl', 'c', 'cpp', default_options : ['c_std=gnu11', 'cpp_std=c++03'])
if host_machine.system() == 'darwin'
add_languages('objc')
@ -55,7 +55,7 @@ endif
lite_rc = []
if host_machine.system() == 'windows'
windows = import('windows')
lite_rc += windows.compile_resources('res.rc')
lite_rc += windows.compile_resources('resources/icons/icon.rc')
endif
# On macos we need to use the SDL renderer to support retina displays

View File

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 108 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -2,10 +2,9 @@
Type=Application
Name=Lite XL
Comment=A lightweight text editor written in Lua
Exec=lite %F
Exec=lite-xl %F
Icon=lite-xl
Terminal=false
StartupNotify=false
Categories=Utility;TextEditor;Development;
MimeType=text/plain;

View File

@ -55,6 +55,21 @@ static int f_load(lua_State *L) {
}
static int f_copy(lua_State *L) {
FontDesc *self = luaL_checkudata(L, 1, API_TYPE_FONT);
float size;
if (lua_gettop(L) >= 2) {
size = luaL_checknumber(L, 2);
} else {
size = self->size;
}
FontDesc *new_font_desc = lua_newuserdata(L, font_desc_alloc_size(self->filename));
font_desc_init(new_font_desc, self->filename, size, self->options);
luaL_setmetatable(L, API_TYPE_FONT);
return 1;
}
static int f_set_tab_size(lua_State *L) {
FontDesc *self = luaL_checkudata(L, 1, API_TYPE_FONT);
int n = luaL_checknumber(L, 2);
@ -123,6 +138,7 @@ static int f_set_size(lua_State *L) {
static const luaL_Reg lib[] = {
{ "__gc", f_gc },
{ "load", f_load },
{ "copy", f_copy },
{ "set_tab_size", f_set_tab_size },
{ "get_width", f_get_width },
{ "get_width_subpixel", f_get_width_subpixel },

View File

@ -10,6 +10,7 @@
#ifdef _WIN32
#include <direct.h>
#include <windows.h>
#include <fileapi.h>
#endif
extern SDL_Window *window;
@ -384,6 +385,52 @@ static int f_show_fatal_error(lua_State *L) {
}
// removes an empty directory
static int f_rmdir(lua_State *L) {
const char *path = luaL_checkstring(L, 1);
#ifdef _WIN32
int deleted = RemoveDirectoryA(path);
if(deleted > 0) {
lua_pushboolean(L, 1);
} else {
DWORD error_code = GetLastError();
LPVOID message;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
error_code,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &message,
0,
NULL
);
lua_pushboolean(L, 0);
lua_pushlstring(L, (LPCTSTR)message, lstrlen((LPCTSTR)message));
LocalFree(message);
return 2;
}
#else
int deleted = remove(path);
if(deleted < 0) {
lua_pushboolean(L, 0);
lua_pushstring(L, strerror(errno));
return 2;
} else {
lua_pushboolean(L, 1);
}
#endif
return 1;
}
static int f_chdir(lua_State *L) {
const char *path = luaL_checkstring(L, 1);
int err = chdir(path);
@ -604,6 +651,7 @@ static const luaL_Reg lib[] = {
{ "set_window_size", f_set_window_size },
{ "window_has_focus", f_window_has_focus },
{ "show_fatal_error", f_show_fatal_error },
{ "rmdir", f_rmdir },
{ "chdir", f_chdir },
{ "mkdir", f_mkdir },
{ "list_dir", f_list_dir },

View File

@ -79,7 +79,7 @@ static void get_exe_filename(char *buf, int sz) {
static void init_window_icon(void) {
#ifndef _WIN32
#include "../icon.inl"
#include "../resources/icons/icon.inl"
(void) icon_rgba_len; /* unused */
SDL_Surface *surf = SDL_CreateRGBSurfaceFrom(
icon_rgba, 64, 64,

View File

@ -17,7 +17,7 @@ if host_machine.system() == 'darwin'
lite_sources += 'bundle_open.m'
endif
executable('lite',
executable('lite-xl',
lite_sources + lite_rc,
include_directories: [lite_include, font_renderer_include],
dependencies: lite_deps,