Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package lite-xl-plugins for openSUSE:Factory checked in at 2022-11-04 17:38:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/lite-xl-plugins (Old) and /work/SRC/openSUSE:Factory/.lite-xl-plugins.new.2275 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "lite-xl-plugins" Fri Nov 4 17:38:18 2022 rev:3 rq:1033565 version:git20221101.0971a7a Changes: -------- --- /work/SRC/openSUSE:Factory/lite-xl-plugins/lite-xl-plugins.changes 2022-10-19 13:18:04.757272127 +0200 +++ /work/SRC/openSUSE:Factory/.lite-xl-plugins.new.2275/lite-xl-plugins.changes 2022-11-04 17:42:07.871056623 +0100 @@ -1,0 +2,23 @@ +Fri Nov 4 00:09:38 UTC 2022 - Scott Bradnick <scott.bradn...@suse.com> + +- Adjusting gitdiff_highlight-{gitdiff,init}.lua to play nice with + lite-xl v2.1 plugin scheme (produces red notification bar and + disables plugin when lite-xl loads otherwise) + +------------------------------------------------------------------- +Thu Nov 03 18:02:36 UTC 2022 - scott.bradn...@suse.com + +- Update to version git20221101.0971a7a: + * Changed minimap to accomodate new API. + * language_php: fix strings not getting terminated + * minimap: check docview has minimap scroll + * minimap: fixed small mistake + * Minimap Rework with Scrollbar (#134) + * language_meson: added meson_options.txt and fixed meson.build patter + * indentguide: do not apply on CommandView and allow toggling it. + * Map ruby syntax to Gemfile and Gemfile.lock (#132) + * Add `language_erb` to README + * Add language plugin for ERB files (#130) + * Removed language_cpp, as it's in the core, and not in this repo at all, in this branch. + +------------------------------------------------------------------- @@ -4,0 +28 @@ +- Renaming nonicons-userdir.patch to nonicons-userdir.diff Old: ---- lite-xl-plugins-git20221005.b1bc52f.tar.gz nonicons-userdir.patch New: ---- lite-xl-plugins-git20221101.0971a7a.tar.gz nonicons-userdir.diff ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ lite-xl-plugins.spec ++++++ --- /var/tmp/diff_new_pack.z6vy9U/_old 2022-11-04 17:42:08.535060092 +0100 +++ /var/tmp/diff_new_pack.z6vy9U/_new 2022-11-04 17:42:08.539060113 +0100 @@ -17,7 +17,7 @@ %define programname lite-xl Name: lite-xl-plugins -Version: git20221005.b1bc52f +Version: git20221101.0971a7a Release: 0 Summary: Additional plugins for %{programname} License: MIT @@ -32,8 +32,10 @@ ### https://raw.githubusercontent.com/vincens2005/lite-xl-gitdiff-highlight/master/gitdiff.lua Source4: gitdiff_highlight-gitdiff.lua Source5: smb-addl-nonicons.txt -Patch0: nonicons-userdir.patch +Patch0: nonicons-userdir.diff Recommends: words +Requires: lite-xl +Requires: lite-xl-widgets BuildArch: noarch %description ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.z6vy9U/_old 2022-11-04 17:42:08.603060447 +0100 +++ /var/tmp/diff_new_pack.z6vy9U/_new 2022-11-04 17:42:08.603060447 +0100 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/lite-xl/lite-xl-plugins</param> - <param name="changesrevision">b1bc52ffc0ac7b288297ca48e7f4232399f53e43</param></service></servicedata> + <param name="changesrevision">0971a7a686a4e18ee31b576c460966a5ec20ff01</param></service></servicedata> (No newline at EOF) ++++++ console.lua ++++++ --- /var/tmp/diff_new_pack.z6vy9U/_old 2022-11-04 17:42:08.635060614 +0100 +++ /var/tmp/diff_new_pack.z6vy9U/_new 2022-11-04 17:42:08.639060635 +0100 @@ -139,7 +139,7 @@ local function thread() local command if PLATFORM == "Windows" then - command = { "cmd", "/c", string.format("(%s) 2>&1", opt.command) } + command = string.format("cmd /c (%s) 2>&1", opt.command) else command = { "bash", "-c", "--", string.format("(%s) 2>&1", opt.command) } end ++++++ gitdiff_highlight-gitdiff.lua ++++++ --- /var/tmp/diff_new_pack.z6vy9U/_old 2022-11-04 17:42:08.663060761 +0100 +++ /var/tmp/diff_new_pack.z6vy9U/_new 2022-11-04 17:42:08.667060782 +0100 @@ -1,4 +1,3 @@ --- mod-version:1 local gitdiff = {} -- liquidev is a genius ++++++ gitdiff_highlight-init.lua ++++++ --- /var/tmp/diff_new_pack.z6vy9U/_old 2022-11-04 17:42:08.699060949 +0100 +++ /var/tmp/diff_new_pack.z6vy9U/_new 2022-11-04 17:42:08.707060990 +0100 @@ -10,9 +10,9 @@ local _, MiniMap = pcall(require, "plugins.minimap") -- vscode defaults -style.gitdiff_addition = {common.color "#587c0c"} -style.gitdiff_modification = {common.color "#0c7d9d"} -style.gitdiff_deletion = {common.color "#94151b"} +style.gitdiff_addition = style.gitdiff_addition or {common.color "#587c0c"} +style.gitdiff_modification = style.gitdiff_modification or {common.color "#0c7d9d"} +style.gitdiff_deletion = style.gitdiff_deletion or {common.color "#94151b"} local function color_for_diff(diff) if diff == "addition" then @@ -24,7 +24,7 @@ end end -style.gitdiff_width = 3 +style.gitdiff_width = style.gitdiff_width or 3 local last_doc_lines = 0 @@ -42,6 +42,10 @@ diffs[doc] = {is_in_repo = true} end +local function gitdiff_padding(dv) + return style.padding.x * 1.5 + dv:get_font():get_width(#dv.doc.lines) +end + local function update_diff(doc) if doc == nil or doc.filename == nil then return end @@ -80,11 +84,6 @@ diffs[doc].is_in_repo = true end - -local function gitdiff_padding(dv) - return style.padding.x * 1.5 + dv:get_font():get_width(#dv.doc.lines) -end - local old_docview_gutter = DocView.draw_line_gutter local old_gutter_width = DocView.get_gutter_width function DocView:draw_line_gutter(idx, x, y, width) @@ -104,12 +103,14 @@ -- add margin in between highlight and text x = x + gitdiff_padding(self) + + local yoffset = self:get_line_text_y_offset() if diffs[self.doc][idx] ~= "deletion" then renderer.draw_rect(x, y + yoffset, style.gitdiff_width, self:get_line_height(), color) return end - renderer.draw_rect(x, y + (yoffset * 4), style.gitdiff_width, self:get_line_height() / 2, color) + renderer.draw_rect(x - style.gitdiff_width * 2, y + yoffset, style.gitdiff_width * 4, 2, color) end function DocView:get_gutter_width() ++++++ lite-xl-plugins-git20221005.b1bc52f.tar.gz -> lite-xl-plugins-git20221101.0971a7a.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-plugins-git20221005.b1bc52f/README.md new/lite-xl-plugins-git20221101.0971a7a/README.md --- old/lite-xl-plugins-git20221005.b1bc52f/README.md 2022-10-05 18:28:09.000000000 +0200 +++ new/lite-xl-plugins-git20221101.0971a7a/README.md 2022-11-01 23:44:26.000000000 +0100 @@ -65,7 +65,6 @@ | [`language_caddyfile`](plugins/language_caddyfile.lua?raw=1) | Syntax for the Caddyfile used on the [Caddy](https://caddyserver.com/) web server | | [`language_cmake`](plugins/language_cmake.lua?raw=1) | Syntax for the CMake build system language | | [`language_containerfile`](https://github.com/FilBot3/lite-xl-language-containerfile)\* | Syntax for [Containerfile](https://github.com/containers/common/blob/main/docs/Containerfile.5.md)/[Dockerfile](https://docs.docker.com/engine/reference/builder/) | -| [`language_cpp`](plugins/language_cpp.lua?raw=1) | Syntax for the [C++](https://isocpp.org/) programming language | | [`language_crystal`](https://github.com/Tamnac/lite-plugin-crystal)\* | Syntax for the [Crystal](https://crystal-lang.org) programming language | | [`language_csharp`](plugins/language_csharp.lua?raw=1) | Syntax for the [C#](http://csharp.net) programming language | | [`language_d`](plugins/language_d.lua?raw=1) | Syntax for the [D](https://dlang.org/) programming language | @@ -73,6 +72,7 @@ | [`language_diff`](plugins/language_diff.lua?raw=1) | Syntax for diff and patch files | | [`language_elixir`](plugins/language_elixir.lua?raw=1) | Syntax for the [Elixir](https://elixir-lang.org) programming language | | [`language_elm`](plugins/language_elm.lua?raw=1) | Syntax for the [Elm](https://elm-lang.org) programming language | +| [`language_erb`](plugins/language_erb.lua?raw=1) | Syntax for the [ERB](https://github.com/ruby/erb) programming language. Also known as eRuby or Embedded Ruby. | | [`language_env`](https://github.com/anthonyaxenov/lite-xl-env-syntax)\* | Syntax for the [env](https://hexdocs.pm/dotenvy/dotenv-file-format.html) (dotenv) files | | [`language_fe`](plugins/language_fe.lua?raw=1) | Syntax for the [fe](https://github.com/rxi/fe) programming language | | [`language_fennel`](plugins/language_fennel.lua?raw=1) | Syntax for the [fennel](https://fennel-lang.org) programming language | diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-plugins-git20221005.b1bc52f/plugins/indentguide.lua new/lite-xl-plugins-git20221101.0971a7a/plugins/indentguide.lua --- old/lite-xl-plugins-git20221005.b1bc52f/plugins/indentguide.lua 2022-10-05 18:28:09.000000000 +0200 +++ new/lite-xl-plugins-git20221101.0971a7a/plugins/indentguide.lua 2022-11-01 23:44:26.000000000 +0100 @@ -1,8 +1,23 @@ -- mod-version:3 local style = require "core.style" local config = require "core.config" +local common = require "core.common" local DocView = require "core.docview" +config.plugins.indentguide = common.merge({ + enabled = true, + -- The config specification used by the settings gui + config_spec = { + name = "Indent Guide", + { + label = "Enable", + description = "Toggle the drawing of indentation indicator lines.", + path = "enabled", + type = "toggle", + default = true + } + } +}, config.plugins.indentguide) -- TODO: replace with `doc:get_indent_info()` when 2.1 releases local function get_indent_info(doc) @@ -44,6 +59,10 @@ function DocView:update() docview_update(self) + if not config.plugins.indentguide.enabled or not self:is(DocView) then + return + end + local function get_indent(line) if line < 1 or line > #self.doc.lines then return -1 end if not self.indentguide_indents[line] then @@ -104,20 +123,22 @@ local draw_line_text = DocView.draw_line_text function DocView:draw_line_text(line, x, y) - local spaces = self.indentguide_indents[line] or -1 - local _, indent_size = get_indent_info(self.doc) - local w = math.max(1, SCALE) - local h = self:get_line_height() - local font = self:get_font() - local space_sz = font:get_width(" ") - for i = 0, spaces - 1, indent_size do - local color = style.guide or style.selection - local active_lvl = self.indentguide_indent_active[line] or -1 - if i < active_lvl and i + indent_size >= active_lvl then - color = style.guide_highlight or style.accent + if config.plugins.indentguide.enabled and self:is(DocView) then + local spaces = self.indentguide_indents[line] or -1 + local _, indent_size = get_indent_info(self.doc) + local w = math.max(1, SCALE) + local h = self:get_line_height() + local font = self:get_font() + local space_sz = font:get_width(" ") + for i = 0, spaces - 1, indent_size do + local color = style.guide or style.selection + local active_lvl = self.indentguide_indent_active[line] or -1 + if i < active_lvl and i + indent_size >= active_lvl then + color = style.guide_highlight or style.accent + end + local sw = space_sz * i + renderer.draw_rect(math.ceil(x + sw), y, w, h, color) end - local sw = space_sz * i - renderer.draw_rect(math.ceil(x + sw), y, w, h, color) end return draw_line_text(self, line, x, y) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-plugins-git20221005.b1bc52f/plugins/language_erb.lua new/lite-xl-plugins-git20221101.0971a7a/plugins/language_erb.lua --- old/lite-xl-plugins-git20221005.b1bc52f/plugins/language_erb.lua 1970-01-01 01:00:00.000000000 +0100 +++ new/lite-xl-plugins-git20221101.0971a7a/plugins/language_erb.lua 2022-11-01 23:44:26.000000000 +0100 @@ -0,0 +1,55 @@ +-- mod-version:3 +local syntax = require "core.syntax" + +syntax.add { + name = "html-eruby", + files = { "%.html?%.erb$", "%.erb$" }, + block_comment = { "<!--", "-->" }, + patterns = { + { + pattern = { + "<%s*[sS][cC][rR][iI][pP][tT]%f[%s>].->", + "<%s*/%s*[sS][cC][rR][iI][pP][tT]%s*>" + }, + syntax = ".js", + type = "function" + }, + { + pattern = { + "<%s*[sS][tT][yY][lL][eE]%f[%s>].->", + "<%s*/%s*[sS][tT][yY][lL][eE]%s*>" + }, + syntax = ".css", + type = "function" + }, + { + pattern = { + "<%%", + "%%>" + }, + syntax = ".rb", + type = "function" + }, + { + pattern = { + "<%%=", + "%%>" + }, + syntax = ".rb", + type = "function" + }, + { pattern = { "<!%-%-", "%-%->" }, type = "comment" }, + { pattern = { '%f[^>][^<]', '%f[<]' }, type = "normal" }, + { pattern = { '"', '"', '\\' }, type = "string" }, + { pattern = { "'", "'", '\\' }, type = "string" }, + { pattern = "0x[%da-fA-F]+", type = "number" }, + { pattern = "-?%d+[%d%.]*f?", type = "number" }, + { pattern = "-?%.?%d+f?", type = "number" }, + { pattern = "%f[^<]![%a_][%w_]*", type = "keyword2" }, + { pattern = "%f[^<][%a_][%w_]*", type = "function" }, + { pattern = "%f[^<]/[%a_][%w_]*", type = "function" }, + { pattern = "[%a_][%w_]*", type = "keyword" }, + { pattern = "[/<>=]", type = "operator" }, + }, + symbols = {}, +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-plugins-git20221005.b1bc52f/plugins/language_meson.lua new/lite-xl-plugins-git20221101.0971a7a/plugins/language_meson.lua --- old/lite-xl-plugins-git20221005.b1bc52f/plugins/language_meson.lua 2022-10-05 18:28:09.000000000 +0200 +++ new/lite-xl-plugins-git20221101.0971a7a/plugins/language_meson.lua 2022-11-01 23:44:26.000000000 +0100 @@ -3,7 +3,7 @@ syntax.add { name = "Meson", - files = "meson.build$", + files = { "^meson%.build$", "^meson_options%.txt$" }, comment = "#", patterns = { { pattern = { "#", "\n" }, type = "comment" }, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-plugins-git20221005.b1bc52f/plugins/language_php.lua new/lite-xl-plugins-git20221101.0971a7a/plugins/language_php.lua --- old/lite-xl-plugins-git20221005.b1bc52f/plugins/language_php.lua 2022-10-05 18:28:09.000000000 +0200 +++ new/lite-xl-plugins-git20221101.0971a7a/plugins/language_php.lua 2022-11-01 23:44:26.000000000 +0100 @@ -87,6 +87,7 @@ }, { pattern = "%$[%a_][%w_]*", type = "keyword2" }, { pattern = "%w+", type = "string" }, + { pattern = "[^\"]", type = "string" }, } local function combine_patterns(t1, t2) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-plugins-git20221005.b1bc52f/plugins/language_ruby.lua new/lite-xl-plugins-git20221101.0971a7a/plugins/language_ruby.lua --- old/lite-xl-plugins-git20221005.b1bc52f/plugins/language_ruby.lua 2022-10-05 18:28:09.000000000 +0200 +++ new/lite-xl-plugins-git20221101.0971a7a/plugins/language_ruby.lua 2022-11-01 23:44:26.000000000 +0100 @@ -3,7 +3,7 @@ syntax.add { name = "Ruby", - files = { "%.rb", "%.gemspec" }, + files = { "%.rb$", "%.gemspec$", "^Gemfile$", "^Gemfile%.lock$" }, headers = "^#!.*[ /]ruby", comment = "#", patterns = { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-plugins-git20221005.b1bc52f/plugins/minimap.lua new/lite-xl-plugins-git20221101.0971a7a/plugins/minimap.lua --- old/lite-xl-plugins-git20221005.b1bc52f/plugins/minimap.lua 2022-10-05 18:28:09.000000000 +0200 +++ new/lite-xl-plugins-git20221101.0971a7a/plugins/minimap.lua 2022-11-01 23:44:26.000000000 +0100 @@ -7,6 +7,7 @@ local DocView = require "core.docview" local Highlighter = require "core.doc.highlighter" local Object = require "core.object" +local Scrollbar = require "core.scrollbar" -- Sample configurations: -- full width: @@ -235,12 +236,6 @@ end --- minimap status per DocView -local per_docview -local function reset_per_docview() - per_docview = setmetatable({}, { __mode = "k" }) -end -reset_per_docview() -- Move cache to make space for new lines @@ -307,35 +302,30 @@ end -local MiniMap = Object:extend() +local MiniMap = Scrollbar:extend() + -function MiniMap:new() +function MiniMap:new(dv) + MiniMap.super.new(self, { direction = "v", alignment = "e" }) + self.dv = dv + self.enabled = nil end + function MiniMap:line_highlight_color(line_index) -- other plugins can override this, and return a color end -local minimap = MiniMap() -local function show_minimap(docview) - if not docview:is(DocView) then return false end - if - not config.plugins.minimap.enabled - and per_docview[docview] ~= true - then - return false - elseif - config.plugins.minimap.enabled - and per_docview[docview] == false - then - return false - end +function MiniMap:is_minimap_enabled() + if self.enabled ~= nil then return self.enabled end + if not config.plugins.minimap.enabled then return false end if config.plugins.minimap.avoid_small_docs then - local last_line = #docview.doc.lines + local last_line = #self.dv.doc.lines if type(config.plugins.minimap.avoid_small_docs) == "number" then return last_line > config.plugins.minimap.avoid_small_docs else + local docview = self.dv local _, y = docview:get_line_screen_position(last_line, docview.doc.lines[last_line]) y = y + docview.scroll.y - docview.position.y + docview:get_line_height() return y > docview.size.y @@ -344,203 +334,132 @@ return true end --- Overloaded since the default implementation adds a extra x3 size of hotspot for the mouse to hit the scrollbar. -local prev_scrollbar_overlaps_point = DocView.scrollbar_overlaps_point -DocView.scrollbar_overlaps_point = function(self, x, y) - if not show_minimap(self) then - return prev_scrollbar_overlaps_point(self, x, y) - end - local sx, sy, sw, sh = self:get_scrollbar_rect() - return x >= sx and x < sx + sw and y >= sy and y < sy + sh -end - --- Helper function to determine if current file is too large to be shown fully inside the minimap area. -local function is_file_too_large(self) - local line_count = #self.doc.lines - local _, _, _, sh = self:get_scrollbar_rect() - - -- check if line count is too large to fit inside the minimap area - local max_minmap_lines = math.floor(sh / line_spacing) - return line_count > 1 and line_count > max_minmap_lines -end - --- Overloaded with an extra check if the user clicked inside the minimap to automatically scroll to that line. -local prev_on_mouse_pressed = DocView.on_mouse_pressed -DocView.on_mouse_pressed = function(self, button, x, y, clicks) - if not show_minimap(self) then - return prev_on_mouse_pressed(self, button, x, y, clicks) - end - - -- check if user clicked in the minimap area and jump directly to that line - -- unless they are actually trying to perform a drag - local minimap_hit = self:scrollbar_overlaps_point(x, y) - if minimap_hit then - local line_count = #self.doc.lines - local minimap_height = line_count * line_spacing - - -- check if line count is too large to fit inside the minimap area - local is_too_large = is_file_too_large(self) - if is_too_large then - local _, _, _, sh = self:get_scrollbar_rect() - minimap_height = sh - end +function MiniMap:get_minimap_dimensions() + local x, y, w, h = self:get_track_rect() + local _, cy, _, cy2 = self.dv:get_content_bounds() + local lh = self.dv:get_line_height() - -- calc which line to jump to - local dy = y - self.position.y - local jump_to_line = math.floor((dy / minimap_height) * line_count) + 1 - - local _, cy, _, cy2 = self:get_content_bounds() - local lh = self:get_line_height() - local visible_lines_count = math.max(1, (cy2 - cy) / lh) - local visible_lines_start = math.max(1, math.floor(cy / lh)) - - -- calc if user hit the currently visible area - local hit_visible_area = true - if is_too_large then - - local visible_height = visible_lines_count * line_spacing - local scroll_pos = (visible_lines_start - 1) / - (line_count - visible_lines_count - 1) - scroll_pos = math.min(1.0, scroll_pos) -- 0..1 - local visible_y = self.position.y + scroll_pos * - (minimap_height - visible_height) - - local t = (line_count - visible_lines_start) / visible_lines_count - if t <= 1 then visible_y = visible_y + visible_height * (1.0 - t) end - - if y < visible_y or y > visible_y + visible_height then - hit_visible_area = false - end - else + local visible_lines_start = math.max(1, math.floor(cy / lh)) + local visible_lines_count = math.max(1, (cy2 - cy) / lh) + local minimap_lines_start = 1 + local minimap_lines_count = math.floor(h / line_spacing) + local line_count = #self.dv.doc.lines - -- If the click is on the currently visible line numbers, - -- ignore it since then they probably want to initiate a drag instead. - if jump_to_line < visible_lines_start or jump_to_line > visible_lines_start + - visible_lines_count then hit_visible_area = false end - end + local is_file_too_large = line_count > 1 and line_count > minimap_lines_count + if is_file_too_large then + local scroll_pos = (visible_lines_start - 1) / + (line_count - visible_lines_count - 1) + scroll_pos = math.min(1.0, scroll_pos) -- 0..1, procent of visual area scrolled - -- if user didn't click on the visible area (ie not dragging), scroll accordingly - if not hit_visible_area then - self:scroll_to_line(jump_to_line, false, config.plugins.minimap.instant_scroll) - end + local thumb_height = visible_lines_count * line_spacing + local scroll_pos_pixels = scroll_pos * (h - thumb_height) + minimap_lines_start = visible_lines_start - + math.floor(scroll_pos_pixels / line_spacing) + minimap_lines_start = math.max(1, minimap_lines_start) end - - return prev_on_mouse_pressed(self, button, x, y, clicks) + return visible_lines_start, visible_lines_count, minimap_lines_start, minimap_lines_count, is_file_too_large end --- Overloaded with pretty much the same logic as original DocView implementation, --- with the exception of the dragging scrollbar delta. We want it to behave a bit snappier --- since the "scrollbar" essentially represents the lines visible in the content view. -local prev_on_mouse_moved = DocView.on_mouse_moved -DocView.on_mouse_moved = function(self, x, y, dx, dy) - if not show_minimap(self) then - return prev_on_mouse_moved(self, x, y, dx, dy) - end - if self.dragging_scrollbar then - local line_count = #self.doc.lines - local lh = self:get_line_height() - local delta = lh / line_spacing * dy +function MiniMap:_get_track_rect_normal() + if not self:is_minimap_enabled() then return MiniMap.super._get_track_rect_normal(self) end + return self.dv.size.x + self.dv.position.x - config.plugins.minimap.width, self.dv.position.y, config.plugins.minimap.width, self.dv.size.y +end - if is_file_too_large(self) then - local _, sy, _, sh = self:get_scrollbar_rect() - delta = (line_count * lh) / sh * dy - end - self.scroll.to.y = self.scroll.to.y + delta - end +function MiniMap:get_active_margin() if self:is_minimap_enabled() then return 0 else return MiniMap.super.get_active_margin(self) end end - -- we need to "hide" that the scrollbar is dragging so that View doesnt does its own scrolling logic - local t = self.dragging_scrollbar - self.dragging_scrollbar = false - local r = prev_on_mouse_moved(self, x, y, dx, dy) - self.dragging_scrollbar = t - return r -end --- Overloaded since we want the mouse to interact with the full size of the minimap area, --- not juse the scrollbar. -local prev_get_scrollbar_rect = DocView.get_scrollbar_rect -DocView.get_scrollbar_rect = function(self) - if not show_minimap(self) then return prev_get_scrollbar_rect(self) end +function MiniMap:_get_thumb_rect_normal() + if not self:is_minimap_enabled() then return MiniMap.super._get_thumb_rect_normal(self) end + local visible_lines_start, visible_lines_count, minimap_lines_start, minimap_lines_count, is_file_too_large = self:get_minimap_dimensions() + local visible_y = self.dv.position.y + (visible_lines_start - 1) * line_spacing + if is_file_too_large then + local line_count = #self.dv.doc.lines + local scroll_pos = (visible_lines_start - 1) / + (line_count - visible_lines_count - 1) + scroll_pos = math.min(1.0, scroll_pos) -- 0..1, procent of visual area scrolled - return self.position.x + self.size.x - config.plugins.minimap.width * SCALE, - self.position.y, config.plugins.minimap.width * SCALE, self.size.y + local thumb_height = visible_lines_count * line_spacing + local scroll_pos_pixels = scroll_pos * (self.dv.size.y - thumb_height) + visible_y = self.dv.position.y + scroll_pos_pixels + end + return self.dv.size.x + self.dv.position.x - config.plugins.minimap.width, visible_y, config.plugins.minimap.width, visible_lines_count * line_spacing end -local prev_get_scrollbar_track_rect = DocView.get_scrollbar_track_rect -DocView.get_scrollbar_track_rect = function(self) - if not show_minimap(self) then return prev_get_scrollbar_track_rect(self) end - return self.position.x + self.size.x - config.plugins.minimap.width * SCALE, - self.position.y, config.plugins.minimap.width * SCALE, self.size.y +function MiniMap:on_mouse_pressed(button, x, y, clicks) + local percent = MiniMap.super.on_mouse_pressed(self, button, x, y, clicks) + if not self:is_minimap_enabled() or not percent then return percent end + local _, visible_lines_count, minimap_lines_start, minimap_lines_count, is_file_too_large = self:get_minimap_dimensions() + local _, _, w, h = self:get_track_rect() + local tx, ty, tw, th = self:get_thumb_rect() + if y >= ty and y < ty + th then self.drag_start_offset = (y - ty) - th / 2 return self.percent end + self.drag_start_offset = 0 + self.hovering.thumb = x >= tx and x < tx + tw and y >= ty and y < ty + th + self.dragging = self.hovering.thumb + local lh = self.dv:get_line_height() + percent = math.max(0.0, math.min((y - self.dv.position.y) / h, 1.0)) + return (((percent * minimap_lines_count) + minimap_lines_start) * lh / self.dv:get_scrollable_size()) - (visible_lines_count / #self.dv.doc.lines / 2) end --- Overloaded so we can render the minimap in the "scrollbar area". -local prev_draw_scrollbar = DocView.draw_scrollbar -DocView.draw_scrollbar = function(self) - if not show_minimap(self) then return prev_draw_scrollbar(self) end - local x, y, w, h = self:get_scrollbar_rect() +function MiniMap:on_mouse_moved(x, y, dx, dy) + local percent = MiniMap.super.on_mouse_moved(self, x, y, dx, dy) + if not self:is_minimap_enabled() or type(percent) ~= "number" then return percent end + local _, visible_lines_count, minimap_lines_start, minimap_lines_count, is_file_too_large = self:get_minimap_dimensions() + local lh = self.dv:get_line_height() + local _, _, w, h = self:get_track_rect() + local tx, ty, tw, th = self:get_thumb_rect() + if x >= tx and x < tx + tw and y >= ty and y < ty + th then self.hovering.thumb = true end + if not self.hovering.thumb then return self.percent end + y = y - self.drag_start_offset + percent = math.max(0.0, math.min((y - self.dv.position.y) / h, 1.0)) + return (((percent * minimap_lines_count) + minimap_lines_start) * lh / self.dv:get_scrollable_size()) - (visible_lines_count / #self.dv.doc.lines / 2) +end + +function MiniMap:draw_thumb() + local color = self.hovering.thumb and style.scrollbar2 or style.scrollbar + local x, y, w, h = self:get_thumb_rect() + renderer.draw_rect(x, y, w, h, color) +end + +function MiniMap:draw() + if not self:is_minimap_enabled() then return MiniMap.super.draw(self) end + local dv = self.dv + local x, y, w, h = self:get_track_rect() - local highlight = self.hovered_scrollbar or self.dragging_scrollbar + local highlight = dv.hovered_scrollbar or dv.dragging_scrollbar local visual_color = highlight and style.scrollbar2 or style.scrollbar - local _, cy, _, cy2 = self:get_content_bounds() - local lh = self:get_line_height() - local visible_lines_count = math.max(1, (cy2 - cy) / lh) - local visible_lines_start = math.max(1, math.floor(cy / lh)) - local scroller_height = visible_lines_count * line_spacing - local line_count = #self.doc.lines - - local visible_y = self.position.y + (visible_lines_start - 1) * line_spacing - - -- check if file is too large to fit inside the minimap area - local max_minmap_lines = math.floor(h / line_spacing) - local minimap_start_line = 1 - if is_file_too_large(self) then - - local scroll_pos = (visible_lines_start - 1) / - (line_count - visible_lines_count - 1) - scroll_pos = math.min(1.0, scroll_pos) -- 0..1, procent of visual area scrolled - - local scroll_pos_pixels = scroll_pos * (h - scroller_height) - visible_y = self.position.y + scroll_pos_pixels - - -- offset visible area if user is scrolling past end - local t = (line_count - visible_lines_start) / visible_lines_count - if t <= 1 then visible_y = visible_y + scroller_height * (1.0 - t) end - - minimap_start_line = visible_lines_start - - math.floor(scroll_pos_pixels / line_spacing) - minimap_start_line = math.max(1, math.min(minimap_start_line, - line_count - max_minmap_lines)) - end + local visible_lines_start, visible_lines_count, + minimap_lines_start, minimap_lines_count = self:get_minimap_dimensions() if config.plugins.minimap.draw_background then renderer.draw_rect(x, y, w, h, style.minimap_background or style.background) end - -- draw visual rect - renderer.draw_rect(x, visible_y, w, scroller_height, visual_color) + self:draw_thumb() -- highlight the selected lines, and the line with the caret on it local selection_color = config.plugins.minimap.selection_color or style.dim local caret_color = config.plugins.minimap.caret_color or style.caret - local selection_line, selection_col, selection_line2, selection_col2 = self.doc:get_selection() - local selection_y = y + (selection_line - minimap_start_line) * line_spacing - local selection2_y = y + (selection_line2 - minimap_start_line) * line_spacing - local selection_min_y = math.min(selection_y, selection2_y) - local selection_h = math.abs(selection2_y - selection_y)+1 - renderer.draw_rect(x, selection_min_y, w, selection_h, selection_color) - renderer.draw_rect(x, selection_y, w, line_spacing, caret_color) + + for i, line1, col1, line2, col2 in dv.doc:get_selections() do + local selection1_y = y + (line1 - minimap_lines_start) * line_spacing + local selection2_y = y + (line2 - minimap_lines_start) * line_spacing + local selection_min_y = math.min(selection1_y, selection2_y) + local selection_h = math.abs(selection2_y - selection1_y)+1 + renderer.draw_rect(x, selection_min_y, w, selection_h, selection_color) + renderer.draw_rect(x, selection1_y, w, line_spacing, caret_color) + end local highlight_align = config.plugins.minimap.highlight_align local highlight_width = config.plugins.minimap.highlight_width local gutter_width = config.plugins.minimap.gutter_width - -- time to draw the actual code, setup some local vars that are used in both highlighted and plain renderind. + -- time to draw the actual code, setup some local vars that are used in both highlighted and plain rendering. local line_y = y -- when not using syntax highlighted rendering, just use the normal color but dim it 50%. @@ -600,35 +519,34 @@ highlight_x = x + w - highlight_width end local function render_highlight(idx, line_y) - local highlight_color = minimap:line_highlight_color(idx) + local highlight_color = self:line_highlight_color(idx) if highlight_color then renderer.draw_rect(highlight_x, line_y, highlight_width, line_spacing, highlight_color) end end - local endidx = minimap_start_line + max_minmap_lines - endidx = math.min(endidx, line_count) + local endidx = math.min(minimap_lines_start + minimap_lines_count, #self.dv.doc.lines) reset_cache_if_needed() - if not highlighter_cache[self.doc.highlighter] then - highlighter_cache[self.doc.highlighter] = {} + if not highlighter_cache[dv.doc.highlighter] then + highlighter_cache[dv.doc.highlighter] = {} end -- per line - for idx = minimap_start_line, endidx do + for idx = minimap_lines_start, endidx do batch_syntax_type = nil batch_start = 0 batch_width = 0 last_batch_end = -1 render_highlight(idx, line_y) - local cache = highlighter_cache[self.doc.highlighter][idx] - if not highlighter_cache[self.doc.highlighter][idx] then -- need to cache - highlighter_cache[self.doc.highlighter][idx] = {} - cache = highlighter_cache[self.doc.highlighter][idx] + local cache = highlighter_cache[dv.doc.highlighter][idx] + if not highlighter_cache[dv.doc.highlighter][idx] then -- need to cache + highlighter_cache[dv.doc.highlighter][idx] = {} + cache = highlighter_cache[dv.doc.highlighter][idx] -- per token - for _, type, text in self.doc.highlighter:each_token(idx) do + for _, type, text in dv.doc.highlighter:each_token(idx) do if not config.plugins.minimap.syntax_highlight then type = nil end @@ -681,17 +599,52 @@ end end -local prev_update = DocView.update -DocView.update = function (self) - if not show_minimap(self) then return prev_update(self) end - self.size.x = self.size.x - config.plugins.minimap.width * SCALE - return prev_update(self) + +local old_docview_new = DocView.new +function DocView:new(doc) + old_docview_new(self, doc) + if self:is(DocView) then self.v_scrollbar = MiniMap(self) end +end + +local old_docview_scroll_to_make_visible = DocView.scroll_to_make_visible +function DocView:scroll_to_make_visible(line, col, ...) + if + not self:is(DocView) or not self.v_scrollbar:is(MiniMap) + or + not self.v_scrollbar:is_minimap_enabled() + then + return old_docview_scroll_to_make_visible(self, line, col, ...) + end + local old_size = self.size.x + self.size.x = math.max(0, self.size.x - config.plugins.minimap.width) + local result = old_docview_scroll_to_make_visible(self, line, col, ...) + self.size.x = old_size + return result +end + + +local function get_all_docviews(node, t) + t = t or {} + if not node then return end + if node.type == "leaf" then + for i,v in ipairs(node.views) do + if v:is(DocView) then + table.insert(t, v) + end + end + end + get_all_docviews(node.a, t) + get_all_docviews(node.b, t) + return t end + command.add(nil, { ["minimap:toggle-visibility"] = function() config.plugins.minimap.enabled = not config.plugins.minimap.enabled - reset_per_docview() + for i,v in ipairs(get_all_docviews(core.root_view.root_node)) do + v.v_scrollbar.enabled = nil + end end, ["minimap:toggle-syntax-highlighting"] = function() config.plugins.minimap.syntax_highlight = not config.plugins.minimap.syntax_highlight @@ -700,12 +653,14 @@ command.add("core.docview!", { ["minimap:toggle-visibility-for-current-view"] = function() - if config.plugins.minimap.enabled then - per_docview[core.active_view] = per_docview[core.active_view] == false + local sb = core.active_view.v_scrollbar + if sb.enabled ~= nil then + sb.enabled = not sb.enabled else - per_docview[core.active_view] = not per_docview[core.active_view] + sb.enabled = not config.plugins.minimap.enabled end end }) -return minimap +return MiniMap + ++++++ lite-xl-plugins.obsinfo ++++++ --- /var/tmp/diff_new_pack.z6vy9U/_old 2022-11-04 17:42:08.839061680 +0100 +++ /var/tmp/diff_new_pack.z6vy9U/_new 2022-11-04 17:42:08.843061701 +0100 @@ -1,5 +1,5 @@ name: lite-xl-plugins -version: git20221005.b1bc52f -mtime: 1664987289 -commit: b1bc52ffc0ac7b288297ca48e7f4232399f53e43 +version: git20221101.0971a7a +mtime: 1667342666 +commit: 0971a7a686a4e18ee31b576c460966a5ec20ff01 ++++++ nonicons-userdir.diff ++++++ --- plugins/nonicons.lua.orig 2022-10-05 10:14:24.516441700 -0400 +++ plugins/nonicons.lua 2022-10-05 10:14:48.868524604 -0400 @@ -49,7 +49,7 @@ } }, config.plugins.nonicons) -local icon_font = renderer.font.load(USERDIR.."/fonts/nonicons.ttf", 15 * SCALE) +local icon_font = renderer.font.load(DATADIR.."/fonts/nonicons.ttf", 15 * SCALE) local chevron_width = icon_font:get_width("???") local previous_scale = SCALE local extension_icons = { ++++++ nonicons.ttf ++++++ Binary files /var/tmp/diff_new_pack.z6vy9U/_old and /var/tmp/diff_new_pack.z6vy9U/_new differ