diff --git a/build-packages.sh b/build-packages.sh index 6fd6a0c4..76b0ebf5 100755 --- a/build-packages.sh +++ b/build-packages.sh @@ -50,16 +50,16 @@ lite_build_pgo () { } lite_build_package_windows () { - local portable="" + local portable="-msys" if [ "$1" == "-portable" ]; then - portable="-portable" + portable="" shift fi local build="$1" local arch="$2" local os="win" local pdir=".package-build/lite-xl" - if [ "$portable" == "-portable" ]; then + if [ -z "$portable" ]; then local bindir="$pdir" local datadir="$pdir/data" else diff --git a/changelog.md b/changelog.md index 600d0a09..6f95fd60 100644 --- a/changelog.md +++ b/changelog.md @@ -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. -### 1.16.9 +### next release [#126](https://github.com/franko/lite-xl/issues/126): Implemented changing fonts per syntax group. 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) 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 +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 Add support for retina displays on Mac OS X. diff --git a/data/core/common.lua b/data/core/common.lua index 022dd1dc..5f6e8bc9 100644 --- a/data/core/common.lua +++ b/data/core/common.lua @@ -229,7 +229,7 @@ end function common.normalize_path(filename) - if PATHSEP == '\\' then + if filename and PATHSEP == '\\' then filename = filename:gsub('[/\\]', '\\') local drive, rem = filename:match('^([a-zA-Z])(:.*)') return drive and drive:upper() .. rem or filename diff --git a/data/core/init.lua b/data/core/init.lua index 45de4f42..8d4d84c3 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -589,18 +589,6 @@ function core.restart() 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 info = system.get_file_info(filename) 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 local version_match = false for line in f:lines() do - local version = line:match('%-%-%s*lite%-xl%s*(%d+%.%d+)%s*$') - if not version then break end - local ver_major, ver_minor = version_components(version) - local ref_major, ref_minor = version_components(VERSION) - version_match = (ver_major == ref_major and ver_minor == ref_minor) - break + local mod_version = line:match('%-%-.*%f[%a]mod%-version%s*:%s*(%d+)') + if mod_version then + version_match = (mod_version == MOD_VERSION) + break + end + -- 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 f:close() return version_match diff --git a/data/core/rootview.lua b/data/core/rootview.lua index c1f7a857..5664c08f 100644 --- a/data/core/rootview.lua +++ b/data/core/rootview.lua @@ -484,7 +484,8 @@ function Node:close_all_docviews() 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) if self.type == 'leaf' then return not self.locked or not self.locked[axis] or self.resizable @@ -496,22 +497,42 @@ function Node:is_resizable(axis) 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) if self.type == 'leaf' then - -- The logic here is: accept the resize only if locked along the axis - -- and is declared "resizable". If it is not locked we don't accept the + -- If it is not locked we don't accept the -- resize operation here because for proportional panes the resize is -- done using the "divider" value of the parent node. - if (self.locked and self.locked[axis]) and self.resizable 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") + if self:is_locked_resizable(axis) then return self.active_view:set_target_size(axis, value) end else - 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) + if self.type == (axis == "x" and "hsplit" or "vsplit") then + -- we are resizing a node that is splitted along the resize axis + if self.a:is_locked_resizable(axis) and self.b:is_locked_resizable(axis) then + local rem_value = value - self.a.size[axis] + 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 @@ -619,7 +640,10 @@ end 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 node.divider = node.divider + delta / node.size[axis] end @@ -645,7 +669,7 @@ function RootView:on_mouse_moved(x, y, dx, dy) node.divider = common.clamp(node.divider, 0.01, 0.99) return end - + self.mouse.x, self.mouse.y = x, y self.root_node:on_mouse_moved(x, y, dx, dy) diff --git a/data/core/start.lua b/data/core/start.lua index e8c650e7..7d4ad9a8 100644 --- a/data/core/start.lua +++ b/data/core/start.lua @@ -1,6 +1,7 @@ -- this file is used by lite-xl to setup the Lua environment -- when starting -VERSION = "1.16.7" +VERSION = "1.16.9" +MOD_VERSION = "1" SCALE = tonumber(os.getenv("LITE_SCALE")) or SCALE PATHSEP = package.config:sub(1, 1) diff --git a/data/plugins/autocomplete.lua b/data/plugins/autocomplete.lua index c0a3d36a..c76eed02 100644 --- a/data/plugins/autocomplete.lua +++ b/data/plugins/autocomplete.lua @@ -1,4 +1,4 @@ --- lite-xl 1.16 +-- mod-version:1 -- lite-xl 1.16 local core = require "core" local common = require "core.common" local config = require "core.config" diff --git a/data/plugins/autoreload.lua b/data/plugins/autoreload.lua index cbef8a21..f84d87d6 100644 --- a/data/plugins/autoreload.lua +++ b/data/plugins/autoreload.lua @@ -1,4 +1,4 @@ --- lite-xl 1.16 +-- mod-version:1 -- lite-xl 1.16 local core = require "core" local config = require "core.config" local Doc = require "core.doc" diff --git a/data/plugins/detectindent.lua b/data/plugins/detectindent.lua index 9ee171e9..681dce26 100644 --- a/data/plugins/detectindent.lua +++ b/data/plugins/detectindent.lua @@ -1,4 +1,4 @@ --- lite-xl 1.16 +-- mod-version:1 -- lite-xl 1.16 local core = require "core" local command = require "core.command" local common = require "core.common" diff --git a/data/plugins/language_c.lua b/data/plugins/language_c.lua index 9bb074bf..1445d067 100644 --- a/data/plugins/language_c.lua +++ b/data/plugins/language_c.lua @@ -1,4 +1,4 @@ --- lite-xl 1.16 +-- mod-version:1 -- lite-xl 1.16 local syntax = require "core.syntax" syntax.add { diff --git a/data/plugins/language_css.lua b/data/plugins/language_css.lua index acd01398..08a256f9 100644 --- a/data/plugins/language_css.lua +++ b/data/plugins/language_css.lua @@ -1,4 +1,4 @@ --- lite-xl 1.16 +-- mod-version:1 -- lite-xl 1.16 local syntax = require "core.syntax" syntax.add { diff --git a/data/plugins/language_html.lua b/data/plugins/language_html.lua index 549a2b12..c45b43a3 100644 --- a/data/plugins/language_html.lua +++ b/data/plugins/language_html.lua @@ -1,4 +1,4 @@ --- lite-xl 1.16 +-- mod-version:1 -- lite-xl 1.16 local syntax = require "core.syntax" syntax.add { diff --git a/data/plugins/language_js.lua b/data/plugins/language_js.lua index 9f877ef0..a258bb3c 100644 --- a/data/plugins/language_js.lua +++ b/data/plugins/language_js.lua @@ -1,4 +1,4 @@ --- lite-xl 1.16 +-- mod-version:1 -- lite-xl 1.16 local syntax = require "core.syntax" syntax.add { diff --git a/data/plugins/language_lua.lua b/data/plugins/language_lua.lua index 64b7847f..168ea0ce 100644 --- a/data/plugins/language_lua.lua +++ b/data/plugins/language_lua.lua @@ -1,4 +1,4 @@ --- lite-xl 1.16 +-- mod-version:1 -- lite-xl 1.16 local syntax = require "core.syntax" syntax.add { diff --git a/data/plugins/language_md.lua b/data/plugins/language_md.lua index 0998c11e..ab2a7d8b 100644 --- a/data/plugins/language_md.lua +++ b/data/plugins/language_md.lua @@ -1,4 +1,4 @@ --- lite-xl 1.16 +-- mod-version:1 -- lite-xl 1.16 local syntax = require "core.syntax" syntax.add { diff --git a/data/plugins/language_python.lua b/data/plugins/language_python.lua index b9c07e4e..849bafc1 100644 --- a/data/plugins/language_python.lua +++ b/data/plugins/language_python.lua @@ -1,4 +1,4 @@ --- lite-xl 1.16 +-- mod-version:1 -- lite-xl 1.16 local syntax = require "core.syntax" syntax.add { diff --git a/data/plugins/language_xml.lua b/data/plugins/language_xml.lua index b87fcc56..d97fa9a8 100644 --- a/data/plugins/language_xml.lua +++ b/data/plugins/language_xml.lua @@ -1,4 +1,4 @@ --- lite-xl 1.16 +-- mod-version:1 -- lite-xl 1.16 local syntax = require "core.syntax" syntax.add { diff --git a/data/plugins/macro.lua b/data/plugins/macro.lua index c8873102..15d8a75e 100644 --- a/data/plugins/macro.lua +++ b/data/plugins/macro.lua @@ -1,4 +1,4 @@ --- lite-xl 1.16 +-- mod-version:1 -- lite-xl 1.16 local core = require "core" local command = require "core.command" local keymap = require "core.keymap" diff --git a/data/plugins/projectsearch.lua b/data/plugins/projectsearch.lua index c4499339..4c1fca6d 100644 --- a/data/plugins/projectsearch.lua +++ b/data/plugins/projectsearch.lua @@ -1,4 +1,4 @@ --- lite-xl 1.16 +-- mod-version:1 -- lite-xl 1.16 local core = require "core" local common = require "core.common" local keymap = require "core.keymap" diff --git a/data/plugins/quote.lua b/data/plugins/quote.lua index bca0797b..85a5874c 100644 --- a/data/plugins/quote.lua +++ b/data/plugins/quote.lua @@ -1,4 +1,4 @@ --- lite-xl 1.16 +-- mod-version:1 -- lite-xl 1.16 local core = require "core" local command = require "core.command" local keymap = require "core.keymap" diff --git a/data/plugins/reflow.lua b/data/plugins/reflow.lua index 621c361c..f0051c12 100644 --- a/data/plugins/reflow.lua +++ b/data/plugins/reflow.lua @@ -1,4 +1,4 @@ --- lite-xl 1.16 +-- mod-version:1 -- lite-xl 1.16 local core = require "core" local config = require "core.config" local command = require "core.command" diff --git a/data/plugins/tabularize.lua b/data/plugins/tabularize.lua index 31821525..2fa06d69 100644 --- a/data/plugins/tabularize.lua +++ b/data/plugins/tabularize.lua @@ -1,4 +1,4 @@ --- lite-xl 1.16 +-- mod-version:1 -- lite-xl 1.16 local core = require "core" local command = require "core.command" local translate = require "core.doc.translate" diff --git a/data/plugins/toolbarview.lua b/data/plugins/toolbarview.lua index 2edfa8bc..93102df2 100644 --- a/data/plugins/toolbarview.lua +++ b/data/plugins/toolbarview.lua @@ -1,4 +1,4 @@ --- lite-xl 1.16 +-- mod-version:1 -- lite-xl 1.16 local core = require "core" local common = require "core.common" local command = require "core.command" diff --git a/data/plugins/treeview.lua b/data/plugins/treeview.lua index 44422b77..73f4708c 100644 --- a/data/plugins/treeview.lua +++ b/data/plugins/treeview.lua @@ -1,4 +1,4 @@ --- lite-xl 1.16 +-- mod-version:1 -- lite-xl 1.16 local core = require "core" local common = require "core.common" local command = require "core.command" diff --git a/data/plugins/trimwhitespace.lua b/data/plugins/trimwhitespace.lua index 5a43653b..a6d3d140 100644 --- a/data/plugins/trimwhitespace.lua +++ b/data/plugins/trimwhitespace.lua @@ -1,4 +1,4 @@ --- lite-xl 1.16 +-- mod-version:1 -- lite-xl 1.16 local core = require "core" local command = require "core.command" local Doc = require "core.doc" diff --git a/data/plugins/workspace.lua b/data/plugins/workspace.lua index c24358c2..25c7f672 100644 --- a/data/plugins/workspace.lua +++ b/data/plugins/workspace.lua @@ -1,4 +1,4 @@ --- lite-xl 1.16 +-- mod-version:1 -- lite-xl 1.16 local core = require "core" local common = require "core.common" local DocView = require "core.docview" diff --git a/src/renwindow.c b/src/renwindow.c index 0800f7c8..f67002f8 100644 --- a/src/renwindow.c +++ b/src/renwindow.c @@ -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); 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 @@ -23,7 +35,7 @@ void renwin_init_surface(RenWindow *ren) { int w, h; SDL_GL_GetDrawableSize(ren->window, &w, &h); ren->surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 32, SDL_PIXELFORMAT_BGRA32); - ren->surface_scale = query_surface_scale(ren); + setup_renderer(ren, w, h); #endif } @@ -60,20 +72,6 @@ SDL_Surface *renwin_get_surface(RenWindow *ren) { #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) { #ifdef LITE_USE_SDL_RENDERER int new_w, new_h; @@ -89,11 +87,6 @@ void renwin_resize_surface(RenWindow *ren) { void renwin_show_window(RenWindow *ren) { 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) { @@ -118,8 +111,8 @@ void renwin_free(RenWindow *ren) { SDL_DestroyWindow(ren->window); ren->window = NULL; #ifdef LITE_USE_SDL_RENDERER - SDL_DestroyRenderer(ren->renderer); SDL_DestroyTexture(ren->texture); + SDL_DestroyRenderer(ren->renderer); SDL_FreeSurface(ren->surface); #endif }