Merge branch 'master' into 'dev'

This commit is contained in:
Francesco Abbate 2021-05-07 08:25:35 +02:00
commit 1c6325b40f
27 changed files with 116 additions and 77 deletions

View File

@ -50,16 +50,16 @@ lite_build_pgo () {
} }
lite_build_package_windows () { lite_build_package_windows () {
local portable="" local portable="-msys"
if [ "$1" == "-portable" ]; then if [ "$1" == "-portable" ]; then
portable="-portable" portable=""
shift shift
fi fi
local build="$1" local build="$1"
local arch="$2" local arch="$2"
local os="win" local os="win"
local pdir=".package-build/lite-xl" local pdir=".package-build/lite-xl"
if [ "$portable" == "-portable" ]; then if [ -z "$portable" ]; then
local bindir="$pdir" local bindir="$pdir"
local datadir="$pdir/data" local datadir="$pdir/data"
else else

View File

@ -2,7 +2,7 @@ Lite XL is following closely [rxi/lite](https://github.com/rxi/lite) but with so
This files document the changes done in Lite XL for each release. This files document the changes done in Lite XL for each release.
### 1.16.9 ### next release
[#126](https://github.com/franko/lite-xl/issues/126): Implemented changing fonts per syntax group. [#126](https://github.com/franko/lite-xl/issues/126): Implemented changing fonts per syntax group.
Example user module snippet that makes all comments italic: Example user module snippet that makes all comments italic:
@ -14,8 +14,34 @@ local style = require "core.style"
local italic = renderer.font.load("italic.ttf", 14) local italic = renderer.font.load("italic.ttf", 14)
style.syntax_fonts["comment"] = italic style.syntax_fonts["comment"] = italic
``` ```
### 1.16.9
Fix a bug related to nested panes resizing.
Fix problem preventing creating a new file.
### 1.16.8 ### 1.16.8
Fix application crash when using the command `core:restart`.
Improve application startup to reduce "flashing".
Move to new plugins versioning using tag `mod-version:1`.
The mod-version is a single digit version that tracks the
plugins compatibility version independently from the lite-xl
version.
For backward compatibility the tag `-- lite-xl 1.16` is considered equivalent to
`mod-version:1` so users don't need to update their plugins.
Both kind of tags can appear in new plugins in the form:
```lua
-- mod-version:1 -- lite-xl 1.16
```
where the old tag needs to appear at the end for compatibility.
### 1.16.7 ### 1.16.7
Add support for retina displays on Mac OS X. Add support for retina displays on Mac OS X.

View File

@ -229,7 +229,7 @@ end
function common.normalize_path(filename) function common.normalize_path(filename)
if PATHSEP == '\\' then if filename and PATHSEP == '\\' then
filename = filename:gsub('[/\\]', '\\') filename = filename:gsub('[/\\]', '\\')
local drive, rem = filename:match('^([a-zA-Z])(:.*)') local drive, rem = filename:match('^([a-zA-Z])(:.*)')
return drive and drive:upper() .. rem or filename return drive and drive:upper() .. rem or filename

View File

@ -589,18 +589,6 @@ function core.restart()
end end
local function version_components(version)
local a, b, c = version:match('(%d+)%.(%d+)%.(%d+)')
if a then
return tonumber(a), tonumber(b), tonumber(c)
end
a, b = version:match('(%d+)%.(%d+)')
if a then
return tonumber(a), tonumber(b)
end
end
local function check_plugin_version(filename) local function check_plugin_version(filename)
local info = system.get_file_info(filename) local info = system.get_file_info(filename)
if info ~= nil and info.type == "dir" then if info ~= nil and info.type == "dir" then
@ -612,12 +600,19 @@ local function check_plugin_version(filename)
if not f then return false end if not f then return false end
local version_match = false local version_match = false
for line in f:lines() do for line in f:lines() do
local version = line:match('%-%-%s*lite%-xl%s*(%d+%.%d+)%s*$') local mod_version = line:match('%-%-.*%f[%a]mod%-version%s*:%s*(%d+)')
if not version then break end if mod_version then
local ver_major, ver_minor = version_components(version) version_match = (mod_version == MOD_VERSION)
local ref_major, ref_minor = version_components(VERSION) break
version_match = (ver_major == ref_major and ver_minor == ref_minor) end
break -- The following pattern is used for backward compatibility only
-- Future versions will look only at the mod-version tag.
local version = line:match('%-%-%s*lite%-xl%s*(%d+%.%d+)$')
if version then
-- we consider the version tag 1.16 equivalent to mod-version:1
version_match = (version == '1.16' and MOD_VERSION == "1")
break
end
end end
f:close() f:close()
return version_match return version_match

View File

@ -484,7 +484,8 @@ function Node:close_all_docviews()
end end
end end
-- Returns true for nodes that accept either "proportional" resizes (based on the
-- node.divider) or "locked" resizable nodes (along the resize axis).
function Node:is_resizable(axis) function Node:is_resizable(axis)
if self.type == 'leaf' then if self.type == 'leaf' then
return not self.locked or not self.locked[axis] or self.resizable return not self.locked or not self.locked[axis] or self.resizable
@ -496,22 +497,42 @@ function Node:is_resizable(axis)
end end
-- Return true iff it is a locked pane along the rezise axis and is
-- declared "resizable".
function Node:is_locked_resizable(axis)
return self.locked and self.locked[axis] and self.resizable
end
function Node:resize(axis, value) function Node:resize(axis, value)
if self.type == 'leaf' then if self.type == 'leaf' then
-- The logic here is: accept the resize only if locked along the axis -- If it is not locked we don't accept the
-- and is declared "resizable". If it is not locked we don't accept the
-- resize operation here because for proportional panes the resize is -- resize operation here because for proportional panes the resize is
-- done using the "divider" value of the parent node. -- done using the "divider" value of the parent node.
if (self.locked and self.locked[axis]) and self.resizable then if self:is_locked_resizable(axis) then
assert(self.active_view.set_target_size, "internal error: the view of a resizable \"locked\" node do not provide a set_target_size method")
return self.active_view:set_target_size(axis, value) return self.active_view:set_target_size(axis, value)
end end
else else
local a_resizable = self.a:is_resizable(axis) if self.type == (axis == "x" and "hsplit" or "vsplit") then
local b_resizable = self.b:is_resizable(axis) -- we are resizing a node that is splitted along the resize axis
if a_resizable and b_resizable then if self.a:is_locked_resizable(axis) and self.b:is_locked_resizable(axis) then
self.a:resize(axis, value) local rem_value = value - self.a.size[axis]
self.b:resize(axis, value) if rem_value >= 0 then
return self.b.active_view:set_target_size(axis, rem_value)
else
self.b.active_view:set_target_size(axis, 0)
return self.a.active_view:set_target_size(axis, value)
end
end
else
-- we are resizing a node that is splitted along the axis perpendicular
-- to the resize axis
local a_resizable = self.a:is_resizable(axis)
local b_resizable = self.b:is_resizable(axis)
if a_resizable and b_resizable then
self.a:resize(axis, value)
self.b:resize(axis, value)
end
end end
end end
end end
@ -619,7 +640,10 @@ end
local function resize_child_node(node, axis, value, delta) local function resize_child_node(node, axis, value, delta)
local accept_resize = node.a:resize(axis, value) or node.b:resize(axis, node.size[axis] - value) local accept_resize = node.a:resize(axis, value)
if not accept_resize then
accept_resize = node.b:resize(axis, node.size[axis] - value)
end
if not accept_resize then if not accept_resize then
node.divider = node.divider + delta / node.size[axis] node.divider = node.divider + delta / node.size[axis]
end end
@ -645,7 +669,7 @@ function RootView:on_mouse_moved(x, y, dx, dy)
node.divider = common.clamp(node.divider, 0.01, 0.99) node.divider = common.clamp(node.divider, 0.01, 0.99)
return return
end end
self.mouse.x, self.mouse.y = x, y self.mouse.x, self.mouse.y = x, y
self.root_node:on_mouse_moved(x, y, dx, dy) self.root_node:on_mouse_moved(x, y, dx, dy)

View File

@ -1,6 +1,7 @@
-- this file is used by lite-xl to setup the Lua environment -- this file is used by lite-xl to setup the Lua environment
-- when starting -- when starting
VERSION = "1.16.7" VERSION = "1.16.9"
MOD_VERSION = "1"
SCALE = tonumber(os.getenv("LITE_SCALE")) or SCALE SCALE = tonumber(os.getenv("LITE_SCALE")) or SCALE
PATHSEP = package.config:sub(1, 1) PATHSEP = package.config:sub(1, 1)

View File

@ -1,4 +1,4 @@
-- lite-xl 1.16 -- mod-version:1 -- lite-xl 1.16
local core = require "core" local core = require "core"
local common = require "core.common" local common = require "core.common"
local config = require "core.config" local config = require "core.config"

View File

@ -1,4 +1,4 @@
-- lite-xl 1.16 -- mod-version:1 -- lite-xl 1.16
local core = require "core" local core = require "core"
local config = require "core.config" local config = require "core.config"
local Doc = require "core.doc" local Doc = require "core.doc"

View File

@ -1,4 +1,4 @@
-- lite-xl 1.16 -- mod-version:1 -- lite-xl 1.16
local core = require "core" local core = require "core"
local command = require "core.command" local command = require "core.command"
local common = require "core.common" local common = require "core.common"

View File

@ -1,4 +1,4 @@
-- lite-xl 1.16 -- mod-version:1 -- lite-xl 1.16
local syntax = require "core.syntax" local syntax = require "core.syntax"
syntax.add { syntax.add {

View File

@ -1,4 +1,4 @@
-- lite-xl 1.16 -- mod-version:1 -- lite-xl 1.16
local syntax = require "core.syntax" local syntax = require "core.syntax"
syntax.add { syntax.add {

View File

@ -1,4 +1,4 @@
-- lite-xl 1.16 -- mod-version:1 -- lite-xl 1.16
local syntax = require "core.syntax" local syntax = require "core.syntax"
syntax.add { syntax.add {

View File

@ -1,4 +1,4 @@
-- lite-xl 1.16 -- mod-version:1 -- lite-xl 1.16
local syntax = require "core.syntax" local syntax = require "core.syntax"
syntax.add { syntax.add {

View File

@ -1,4 +1,4 @@
-- lite-xl 1.16 -- mod-version:1 -- lite-xl 1.16
local syntax = require "core.syntax" local syntax = require "core.syntax"
syntax.add { syntax.add {

View File

@ -1,4 +1,4 @@
-- lite-xl 1.16 -- mod-version:1 -- lite-xl 1.16
local syntax = require "core.syntax" local syntax = require "core.syntax"
syntax.add { syntax.add {

View File

@ -1,4 +1,4 @@
-- lite-xl 1.16 -- mod-version:1 -- lite-xl 1.16
local syntax = require "core.syntax" local syntax = require "core.syntax"
syntax.add { syntax.add {

View File

@ -1,4 +1,4 @@
-- lite-xl 1.16 -- mod-version:1 -- lite-xl 1.16
local syntax = require "core.syntax" local syntax = require "core.syntax"
syntax.add { syntax.add {

View File

@ -1,4 +1,4 @@
-- lite-xl 1.16 -- mod-version:1 -- lite-xl 1.16
local core = require "core" local core = require "core"
local command = require "core.command" local command = require "core.command"
local keymap = require "core.keymap" local keymap = require "core.keymap"

View File

@ -1,4 +1,4 @@
-- lite-xl 1.16 -- mod-version:1 -- lite-xl 1.16
local core = require "core" local core = require "core"
local common = require "core.common" local common = require "core.common"
local keymap = require "core.keymap" local keymap = require "core.keymap"

View File

@ -1,4 +1,4 @@
-- lite-xl 1.16 -- mod-version:1 -- lite-xl 1.16
local core = require "core" local core = require "core"
local command = require "core.command" local command = require "core.command"
local keymap = require "core.keymap" local keymap = require "core.keymap"

View File

@ -1,4 +1,4 @@
-- lite-xl 1.16 -- mod-version:1 -- lite-xl 1.16
local core = require "core" local core = require "core"
local config = require "core.config" local config = require "core.config"
local command = require "core.command" local command = require "core.command"

View File

@ -1,4 +1,4 @@
-- lite-xl 1.16 -- mod-version:1 -- lite-xl 1.16
local core = require "core" local core = require "core"
local command = require "core.command" local command = require "core.command"
local translate = require "core.doc.translate" local translate = require "core.doc.translate"

View File

@ -1,4 +1,4 @@
-- lite-xl 1.16 -- mod-version:1 -- lite-xl 1.16
local core = require "core" local core = require "core"
local common = require "core.common" local common = require "core.common"
local command = require "core.command" local command = require "core.command"

View File

@ -1,4 +1,4 @@
-- lite-xl 1.16 -- mod-version:1 -- lite-xl 1.16
local core = require "core" local core = require "core"
local common = require "core.common" local common = require "core.common"
local command = require "core.command" local command = require "core.command"

View File

@ -1,4 +1,4 @@
-- lite-xl 1.16 -- mod-version:1 -- lite-xl 1.16
local core = require "core" local core = require "core"
local command = require "core.command" local command = require "core.command"
local Doc = require "core.doc" local Doc = require "core.doc"

View File

@ -1,4 +1,4 @@
-- lite-xl 1.16 -- mod-version:1 -- lite-xl 1.16
local core = require "core" local core = require "core"
local common = require "core.common" local common = require "core.common"
local DocView = require "core.docview" local DocView = require "core.docview"

View File

@ -12,6 +12,18 @@ static int query_surface_scale(RenWindow *ren) {
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;
} }
static void setup_renderer(RenWindow *ren, int w, int h) {
/* Note that w and h here should always be in pixels and obtained from
a call to SDL_GL_GetDrawableSize(). */
if (ren->renderer) {
SDL_DestroyTexture(ren->texture);
SDL_DestroyRenderer(ren->renderer);
}
ren->renderer = SDL_CreateRenderer(ren->window, -1, 0);
ren->texture = SDL_CreateTexture(ren->renderer, SDL_PIXELFORMAT_BGRA32, SDL_TEXTUREACCESS_STREAMING, w, h);
ren->surface_scale = query_surface_scale(ren);
}
#endif #endif
@ -23,7 +35,7 @@ void renwin_init_surface(RenWindow *ren) {
int w, h; int w, h;
SDL_GL_GetDrawableSize(ren->window, &w, &h); SDL_GL_GetDrawableSize(ren->window, &w, &h);
ren->surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 32, SDL_PIXELFORMAT_BGRA32); ren->surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 32, SDL_PIXELFORMAT_BGRA32);
ren->surface_scale = query_surface_scale(ren); setup_renderer(ren, w, h);
#endif #endif
} }
@ -60,20 +72,6 @@ SDL_Surface *renwin_get_surface(RenWindow *ren) {
#endif #endif
} }
#ifdef LITE_USE_SDL_RENDERER
static void setup_renderer(RenWindow *ren, int w, int h) {
/* Note that w and h here should always be in pixels and obtained from
a call to SDL_GL_GetDrawableSize(). */
if (ren->renderer) {
SDL_DestroyRenderer(ren->renderer);
SDL_DestroyTexture(ren->texture);
}
ren->renderer = SDL_CreateRenderer(ren->window, -1, 0);
ren->texture = SDL_CreateTexture(ren->renderer, SDL_PIXELFORMAT_BGRA32, SDL_TEXTUREACCESS_STREAMING, w, h);
ren->surface_scale = query_surface_scale(ren);
}
#endif
void renwin_resize_surface(RenWindow *ren) { void renwin_resize_surface(RenWindow *ren) {
#ifdef LITE_USE_SDL_RENDERER #ifdef LITE_USE_SDL_RENDERER
int new_w, new_h; int new_w, new_h;
@ -89,11 +87,6 @@ void renwin_resize_surface(RenWindow *ren) {
void renwin_show_window(RenWindow *ren) { void renwin_show_window(RenWindow *ren) {
SDL_ShowWindow(ren->window); SDL_ShowWindow(ren->window);
#ifdef LITE_USE_SDL_RENDERER
int w, h;
SDL_GL_GetDrawableSize(ren->window, &w, &h);
setup_renderer(ren, w, h);
#endif
} }
void renwin_update_rects(RenWindow *ren, RenRect *rects, int count) { void renwin_update_rects(RenWindow *ren, RenRect *rects, int count) {
@ -118,8 +111,8 @@ void renwin_free(RenWindow *ren) {
SDL_DestroyWindow(ren->window); SDL_DestroyWindow(ren->window);
ren->window = NULL; ren->window = NULL;
#ifdef LITE_USE_SDL_RENDERER #ifdef LITE_USE_SDL_RENDERER
SDL_DestroyRenderer(ren->renderer);
SDL_DestroyTexture(ren->texture); SDL_DestroyTexture(ren->texture);
SDL_DestroyRenderer(ren->renderer);
SDL_FreeSurface(ren->surface); SDL_FreeSurface(ren->surface);
#endif #endif
} }