diff options
-rw-r--r-- | README.md | 6 | ||||
-rw-r--r-- | manifest.json | 55 | ||||
-rw-r--r-- | plugins/ipc.lua | 2 | ||||
-rw-r--r-- | plugins/settings.lua | 63 | ||||
-rw-r--r-- | plugins/spellcheck.lua | 100 |
5 files changed, 187 insertions, 39 deletions
@@ -58,6 +58,8 @@ but only with a `url` must provide a `checksum` that matches the existing plugin | [`discord-presence`](https://github.com/vincens2005/lite-xl-discord)\* | Adds the current workspace and file to your Discord Rich Presence | | [`dragdropselected`](plugins/dragdropselected.lua?raw=1) | Provides basic drag and drop of selected text (in same document) | | [`editorconfig`](plugins/editorconfig) | [EditorConfig](https://editorconfig.org/) implementation for Lite XL | +| [`encoding`](https://github.com/jgmdev/lite-xl-encoding)\* | Add support for detecting file and string encodings as converting between them. | +| [`encodings`](https://github.com/jgmdev/lite-xl-encoding)\* | Properly read files that are not encoded in UTF-8 or ASCII by auto-detecting their encoding and allows saving on different text encodings. | | [`eofnewline`](https://github.com/bokunodev/lite_modules/blob/master/plugins/eofnewline-xl.lua?raw=1) | Make sure the file ends with one blank line. | | [`ephemeral_tabs`](plugins/ephemeral_tabs.lua?raw=1) | Preview tabs. Opening a doc will replace the contents of the preview tab. Marks tabs as non-preview on any change or tab double clicking. | | [`equationgrapher`](https://github.com/ThaCuber/equationgrapher?raw=1)\* | Graphs y=x equations. | @@ -166,7 +168,10 @@ but only with a `url` must provide a `checksum` that matches the existing plugin | [`memoryusage`](plugins/memoryusage.lua?raw=1) | Show memory usage in the status view | | [`minimap`](plugins/minimap.lua?raw=1) | Shows a minimap on the right-hand side of the docview. Taken from [@andsve](https://github.com/andsve/lite-plugins/tree/minimap-plugin), and improved upon. | | [`motiontrail`](plugins/motiontrail.lua?raw=1) | Adds a motion-trail to the caret *([gif](https://user-images.githubusercontent.com/3920290/83256814-085ccb00-a1ab-11ea-9e35-e6633cbed1a9.gif))* | +| [`Multithreaded Find File`](https://github.com/jgmdev/lite-xl-threads)\* | Threaded project find files. | +| [`Multithreaded Project Search`](https://github.com/jgmdev/lite-xl-threads)\* | Threaded project search with 5-10x better performance. | | [`navigate`](plugins/navigate.lua?raw=1) | Allows moving back and forward between document positions, reducing the amount of scrolling | +| [`net`](https://github.com/jgmdev/lite-xl-net)\* | Add support for TCP and UDP sockets using SDL_net. | | [`nonicons`](plugins/nonicons.lua?raw=1) | File icons set for TreeView. Download [font](https://github.com/yamatsum/nonicons/raw/6a2faf4fbdfbe353c5ae6a496740ac4bfb6d0e74/dist/nonicons.ttf) to your config/fonts folder | | [`opacity`](plugins/opacity.lua?raw=1) | Change the opaqueness/transparency of `lite-xl` using shift+mousewheel or a command. | | [`open_ext`](plugins/open_ext.lua?raw=1) | Automatically prompts you if you tried to open a binary file in the editor | @@ -192,6 +197,7 @@ but only with a `url` must provide a `checksum` that matches the existing plugin | [`texcompile`](plugins/texcompile.lua?raw=1) | Compile Tex files into PDF | | [`theme16`](https://github.com/monolifed/theme16)\* | Theme manager with base16 themes | | [`themeselect`](plugins/themeselect.lua?raw=1) | Select a theme based on filename of active document | +| [`Threads`](https://github.com/jgmdev/lite-xl-threads)\* | Adds the missing multithreading functionality. | | [`titleize`](plugins/titleize.lua?raw=1) | Titleizes selected string (`hello world` => `Hello World`) | | [`todotreeview`](https://github.com/drmargarido/TodoTreeView)\* | Todo tree viewer for annotations in code like `TODO`, `BUG`, `FIX`, `IMPROVEMENT` | | [`togglesnakecamel`](plugins/togglesnakecamel.lua?raw=1) | Toggles symbols between `snake_case` and `camelCase` | diff --git a/manifest.json b/manifest.json index feac449..3768dde 100644 --- a/manifest.json +++ b/manifest.json @@ -141,6 +141,22 @@ "mod_version": "3" }, { + "description": "Add support for detecting file and string encodings as converting between them.", + "version": "1.1", + "type": "library", + "remote": "https://github.com/jgmdev/lite-xl-encoding:b1ddf226277ea12a03ed9db2ddda458988020e91", + "mod_version": "3", + "id": "encoding" + }, + { + "description": "Properly read files that are not encoded in UTF-8 or ASCII by auto-detecting their encoding and allows saving on different text encodings.", + "version": "1.0", + "remote": "https://github.com/jgmdev/lite-xl-encoding:b1ddf226277ea12a03ed9db2ddda458988020e91", + "mod_version": "3", + "id": "encodings", + "dependencies": { "encoding": { } } + }, + { "checksum": "e3607f5107f4e42fd99006289b8214a473824c6973b8e9c637b4657eba763650", "description": "Make sure the file ends with one blank line.", "version": "0.1", @@ -205,6 +221,15 @@ "id": "fallbackfonts" }, { + "name": "Multithreaded Find File", + "description": "Threaded project find files.", + "version": "1.0", + "remote": "https://github.com/jgmdev/lite-xl-threads:e61ffd28fc852b143fe468c4b43c68d605f22335", + "mod_version": "3", + "id": "findfileimproved", + "dependencies": { "thread": { } } + }, + { "description": "Allows users to load fonts with [fontconfig](https://www.freedesktop.org/software/fontconfig/fontconfig-user.html).", "version": "0.1", "path": "plugins/fontconfig.lua", @@ -283,7 +308,7 @@ }, { "description": "Adds inter-process communication support", - "version": "0.1", + "version": "0.2", "path": "plugins/ipc.lua", "id": "ipc", "mod_version": "3" @@ -912,6 +937,14 @@ "mod_version": "3" }, { + "description": "Add support for TCP and UDP sockets using SDL_net.", + "version": "1.1", + "type": "library", + "remote": "https://github.com/jgmdev/lite-xl-net:a1930395c89e24344db686f2e83ce67a602c5dbf", + "mod_version": "3", + "id": "net" + }, + { "description": "File icons set for TreeView. Download [font](https://github.com/yamatsum/nonicons/raw/6a2faf4fbdfbe353c5ae6a496740ac4bfb6d0e74/dist/nonicons.ttf) to your config/fonts folder", "version": "0.1", "path": "plugins/nonicons.lua", @@ -968,6 +1001,15 @@ "mod_version": "3" }, { + "name": "Multithreaded Project Search", + "description": "Threaded project search with 5-10x better performance.", + "version": "1.2", + "remote": "https://github.com/jgmdev/lite-xl-threads:e61ffd28fc852b143fe468c4b43c68d605f22335", + "mod_version": "3", + "id": "projectsearch", + "dependencies": { "thread": { } } + }, + { "description": "Show nesting of parentheses with rainbow colours", "version": "0.1", "path": "plugins/rainbowparen.lua", @@ -1011,7 +1053,7 @@ }, { "description": "Provides a GUI to manage core and plugin settings, bindings and select color theme *([video](https://user-images.githubusercontent.com/1702572/169743674-ececae24-f6b7-4ff2-bfa2-c4762cd327d9.mp4))*. (depends on [`widget`](https://github.com/lite-xl/lite-xl-widgets))", - "version": "0.1", + "version": "0.4", "path": "plugins/settings.lua", "id": "settings", "mod_version": "3" @@ -1111,6 +1153,15 @@ "mod_version": "3" }, { + "name": "Threads", + "description": "Adds the missing multithreading functionality.", + "version": "1.1", + "type": "library", + "remote": "https://github.com/jgmdev/lite-xl-threads:e61ffd28fc852b143fe468c4b43c68d605f22335", + "mod_version": "3", + "id": "thread" + }, + { "description": "Extend Lite XL's treeview menu *([screenshot](https://raw.githubusercontent.com/juliardi/lite-xl-treeview-menu-extender/main/screenshot.png))*", "version": "0.1", "remote": "https://github.com/juliardi/lite-xl-treeview-menu-extender:bd9063e453b4024dcd0bf6a4f775ded32ca24d1f", diff --git a/plugins/ipc.lua b/plugins/ipc.lua index 0f9a172..16eab5d 100644 --- a/plugins/ipc.lua +++ b/plugins/ipc.lua @@ -866,7 +866,7 @@ end local system_get_time = system.get_time system.get_time = function() - if settings_found and not settings.ui then + if settings_found and settings and not settings.ui then return system_get_time() end diff --git a/plugins/settings.lua b/plugins/settings.lua index 17ce998..d6c524e 100644 --- a/plugins/settings.lua +++ b/plugins/settings.lua @@ -9,28 +9,28 @@ local View = require "core.view" local DocView = require "core.docview" -- check if widget is installed before proceeding -local widget_found, Widget = pcall(require, "widget") +local widget_found, Widget = pcall(require, "libraries.widget") if not widget_found then core.error("Widget library not found: https://github.com/lite-xl/lite-xl-widgets") - return + return false end -local Label = require "widget.label" -local Line = require "widget.line" -local NoteBook = require "widget.notebook" -local Button = require "widget.button" -local TextBox = require "widget.textbox" -local SelectBox = require "widget.selectbox" -local NumberBox = require "widget.numberbox" -local Toggle = require "widget.toggle" -local ListBox = require "widget.listbox" -local FoldingBook = require "widget.foldingbook" -local FontsList = require "widget.fontslist" -local ItemsList = require "widget.itemslist" -local KeybindingDialog = require "widget.keybinddialog" -local Fonts = require "widget.fonts" -local FilePicker = require "widget.filepicker" -local MessageBox = require "widget.messagebox" +local Label = require "libraries.widget.label" +local Line = require "libraries.widget.line" +local NoteBook = require "libraries.widget.notebook" +local Button = require "libraries.widget.button" +local TextBox = require "libraries.widget.textbox" +local SelectBox = require "libraries.widget.selectbox" +local NumberBox = require "libraries.widget.numberbox" +local Toggle = require "libraries.widget.toggle" +local ListBox = require "libraries.widget.listbox" +local FoldingBook = require "libraries.widget.foldingbook" +local FontsList = require "libraries.widget.fontslist" +local ItemsList = require "libraries.widget.itemslist" +local KeybindingDialog = require "libraries.widget.keybinddialog" +local Fonts = require "libraries.widget.fonts" +local FilePicker = require "libraries.widget.filepicker" +local MessageBox = require "libraries.widget.messagebox" ---@class plugins.settings local settings = {} @@ -1624,11 +1624,13 @@ function Settings:load_keymap_settings() end table.sort(ordered) + ---@type widget.textbox + local textbox = TextBox(self.keybinds, "", "filter bindings...") + ---@type widget.listbox local listbox = ListBox(self.keybinds) listbox.border.width = 0 - listbox:enable_expand(true) listbox:add_column("Command") listbox:add_column("Bindings") @@ -1653,8 +1655,15 @@ function Settings:load_keymap_settings() }, name) end - function listbox:on_row_click(idx, data) - if not keymap_dialog:is_visible() then + function textbox:on_change(value) + listbox:filter(value) + end + + function listbox:on_mouse_pressed(button, x, y, clicks) + listbox.super.on_mouse_pressed(self, button, x, y, clicks) + local idx = listbox:get_selected() + local data = listbox:get_row_data(idx) + if clicks == 2 and not keymap_dialog:is_visible() then local bindings = { keymap.get_binding(data) } keymap_dialog:set_bindings(bindings) keymap_dialog.row_id = idx @@ -1663,6 +1672,14 @@ function Settings:load_keymap_settings() keymap_dialog:show() end end + + ---@param self widget + function self.keybinds:update_positions() + textbox:set_position(0, 0) + textbox:set_size(self:get_width() - self.border.width * 2) + listbox:set_position(0, textbox:get_bottom()) + listbox:set_size(self:get_width() - self.border.width * 2, self:get_height() - textbox:get_height()) + end end function Settings:setup_about() @@ -1819,6 +1836,10 @@ function Settings:update() end end + if self.keybinds:is_visible() then + self.keybinds:update_positions() + end + if self.about:is_visible() then self.about:update_positions() end diff --git a/plugins/spellcheck.lua b/plugins/spellcheck.lua index 29db94c..fbe40f9 100644 --- a/plugins/spellcheck.lua +++ b/plugins/spellcheck.lua @@ -5,6 +5,7 @@ local config = require "core.config" local command = require "core.command" local common = require "core.common" local DocView = require "core.docview" +local Highlighter = require "core.doc.highlighter" local Doc = require "core.doc" local platform_dictionary_file @@ -24,6 +25,58 @@ local last_input_time = 0 local word_pattern = "%a+" local words +local spell_cache = setmetatable({}, { __mode = "k" }) +local font_canary +local font_size_canary + + +-- Move cache to make space for new lines +local prev_insert_notify = Highlighter.insert_notify +function Highlighter:insert_notify(line, n, ...) + prev_insert_notify(self, line, n, ...) + local blanks = { } + if not spell_cache[self] then + spell_cache[self] = {} + end + for i = 1, n do + blanks[i] = false + end + common.splice(spell_cache[self], line, 0, blanks) +end + + +-- Close the cache gap created by removed lines +local prev_remove_notify = Highlighter.remove_notify +function Highlighter:remove_notify(line, n, ...) + prev_remove_notify(self, line, n, ...) + if not spell_cache[self] then + spell_cache[self] = {} + end + common.splice(spell_cache[self], line, n) +end + + +-- Remove changed lines from the cache +local prev_tokenize_line = Highlighter.tokenize_line +function Highlighter:tokenize_line(idx, state, ...) + local res = prev_tokenize_line(self, idx, state, ...) + if not spell_cache[self] then + spell_cache[self] = {} + end + spell_cache[self][idx] = false + return res +end + +local function reset_cache() + for i=1,#spell_cache do + local cache = spell_cache[i] + for j=1,#cache do + cache[j] = false + end + end +end + + local function load_dictionary() core.add_thread(function() local t = {} @@ -61,7 +114,6 @@ end local text_input = Doc.text_input - function Doc:text_input(...) text_input(self, ...) last_input_time = system.get_time() @@ -69,7 +121,6 @@ end local draw_line_text = DocView.draw_line_text - function DocView:draw_line_text(idx, x, y) local lh = draw_line_text(self, idx, x, y) @@ -83,20 +134,39 @@ function DocView:draw_line_text(idx, x, y) return lh end - local s, e = 0, 0 - local text = self.doc.lines[idx] - - while true do - s, e = text:find(word_pattern, e + 1) - if not s then break end - local word = text:sub(s, e):lower() - if not words[word] and not active_word(self.doc, idx, e + 1) then - local color = style.spellcheck_error or style.syntax.keyword2 - local x1, y1 = self:get_line_screen_position(idx, s) - local x2, y2 = self:get_line_screen_position(idx, e + 1) - local h = math.ceil(1 * SCALE) - renderer.draw_rect(x1, y1 + self:get_line_height() - h, x2 - x1, h, color) + if font_canary ~= style.code_font + or font_size_canary ~= style.code_font:get_size() + then + spell_cache[self.doc.highlighter] = {} + font_canary = style.code_font + font_size_canary = style.code_font:get_size() + reset_cache() + end + if not spell_cache[self.doc.highlighter][idx] then + local calculated = {} + local s, e = 0, 0 + local text = self.doc.lines[idx] + + while true do + s, e = text:find(word_pattern, e + 1) + if not s then break end + local word = text:sub(s, e):lower() + if not words[word] and not active_word(self.doc, idx, e + 1) then + table.insert(calculated, self:get_col_x_offset(idx, s)) + table.insert(calculated, self:get_col_x_offset(idx, e + 1)) + end end + + spell_cache[self.doc.highlighter][idx] = calculated + end + + local color = style.spellcheck_error or style.syntax.keyword2 + local h = math.ceil(1 * SCALE) + local lh = self:get_line_height() + local calculated = spell_cache[self.doc.highlighter][idx] + for i=1,#calculated,2 do + local x1, x2 = calculated[i] + x, calculated[i+1] + x + renderer.draw_rect(x1, y + lh - h, x2 - x1, h, color) end return lh end |