From fdc04ae0c45c48a900eedc8aa08d0021232b3c0a Mon Sep 17 00:00:00 2001 From: Guldoman Date: Tue, 9 Nov 2021 21:26:14 +0100 Subject: Add `extend_selection_line` --- plugins/extend_selection_line.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 plugins/extend_selection_line.lua (limited to 'plugins') diff --git a/plugins/extend_selection_line.lua b/plugins/extend_selection_line.lua new file mode 100644 index 0000000..a780fe0 --- /dev/null +++ b/plugins/extend_selection_line.lua @@ -0,0 +1,19 @@ +-- mod-version:2 -- lite-xl 2.0 +local DocView = require "core.docview" +local style = require "core.style" + +local draw_line_body = DocView.draw_line_body +function DocView:draw_line_body(idx, x, y, ...) + local lh = self:get_line_height() + for _, line1, _, line2, _ in self.doc:get_selections(true) do + if idx >= line1 and idx < line2 and line1 ~= line2 then + -- draw selection from the end of the line to the end of the available space + local x1 = x + self:get_col_x_offset(idx, #self.doc.lines[idx]) + local x2 = x + self.scroll.x + self.size.x + if x2 > x1 then + renderer.draw_rect(x1, y, x2 - x1, lh, style.selection) + end + end + end + draw_line_body(self, idx, x, y, ...) +end -- cgit v1.2.3 From dc64ff09521cf98a9adc44be8c5a019d62e7aa17 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Tue, 9 Nov 2021 21:46:13 +0100 Subject: `extend_selection_line`: Draw line body before drawing extension This avoids problems such as drawing the line highlight over the extension. This will probably conflict with other plugins that write after the end of the line. --- plugins/extend_selection_line.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/extend_selection_line.lua b/plugins/extend_selection_line.lua index a780fe0..e986597 100644 --- a/plugins/extend_selection_line.lua +++ b/plugins/extend_selection_line.lua @@ -4,6 +4,7 @@ local style = require "core.style" local draw_line_body = DocView.draw_line_body function DocView:draw_line_body(idx, x, y, ...) + draw_line_body(self, idx, x, y, ...) local lh = self:get_line_height() for _, line1, _, line2, _ in self.doc:get_selections(true) do if idx >= line1 and idx < line2 and line1 ~= line2 then @@ -15,5 +16,4 @@ function DocView:draw_line_body(idx, x, y, ...) end end end - draw_line_body(self, idx, x, y, ...) end -- cgit v1.2.3 From 333388602d6be6a967d07f0324bc8cefb8351a17 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Fri, 19 Nov 2021 19:15:50 +0100 Subject: Add `indent_convert` --- README.md | 1 + plugins/indent_convert.lua | 100 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 plugins/indent_convert.lua (limited to 'plugins') diff --git a/README.md b/README.md index 6647e2a..c304cb2 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ Plugin | Description [`hidelinenumbers`](plugins/hidelinenumbers.lua?raw=1) | Hides the line numbers on the left of documents *([screenshot](https://user-images.githubusercontent.com/3920290/81692043-b8b19c00-9455-11ea-8d74-ad99be4b9c5f.png))* [`hidestatus`](plugins/hidestatus.lua?raw=1) | Hides the status bar at the bottom of the window ~~[`inanimate`](plugins/inanimate.lua?raw=1)~~ | Integrated in lite-xl using `config.transitions = false` ~~Disables all transition animations~~ +*[`indent_convert`](plugins/indent_convert.lua?raw=1)* | Convert between tabs and spaces indentation *[`indentguide`](plugins/indentguide.lua?raw=1)* | Adds indent guides *([screenshot](https://user-images.githubusercontent.com/3920290/79640716-f9860000-818a-11ea-9c3b-26d10dd0e0c0.png))* *[`Kinc Projects`](https://github.com/Kode-Community/kinc_plugin)** | Adds [Kinc](https://github.com/Kode/Kinc) Project generation with basic build commands(depends on [`console`](https://github.com/franko/console)) [`language_angelscript`](plugins/language_angelscript.lua?raw=1) | Syntax for the [Angelscript](https://www.angelcode.com/angelscript/) programming language diff --git a/plugins/indent_convert.lua b/plugins/indent_convert.lua new file mode 100644 index 0000000..103f271 --- /dev/null +++ b/plugins/indent_convert.lua @@ -0,0 +1,100 @@ +-- mod-version:2 -- lite-xl 2.0 +local core = require "core" +local config = require "core.config" +local command = require "core.command" + +config.plugins.indent_convert = { + update_indent_type = true -- set to false to avoid updating the document indent type +} + +-- To replace N spaces with tabs, we match the last N spaces before the start of +-- the actual code and replace them with a tab. +-- We repeat this until we can't find any more spaces before the code. +-- The problem we encounter with this method is that if we have less than N +-- remaining spaces, those will end up at the start of the line. +-- Eg: +-- int main() { +-- __printf("Hello world\n"); +-- ___return 0; +-- } +-- +-- Becomes +-- int main() { +-- #printf("Hello world\n"); +-- _#return 0; +-- } +-- +-- Instead of +-- int main() { +-- #printf("Hello world\n"); +-- #_return 0; +-- } +-- With regex we could do something like +-- `regex.gsub("(^(?: {2})*)(?: {2})", "\\1\t")` +-- but the implementation of `regex.gsub` is very slow. +-- +-- The workaround is to find the longest possible repetition of N*X spaces and +-- use that information to replace the longest repetition of spaces starting +-- from the beginning of the line, then the second longest... +local function spaces_replacer(text) + local spaces = string.rep(" ", config.indent_size) + local total = 0 + local n + local reps = 0 + -- find the longest repetition of indent_size*spaces + repeat + reps = reps + 1 + local s, _ = string.find(text, "%f[^\0\n]"..string.rep(spaces, reps)) + until not s + reps = reps - 1 + while reps > 0 do + text, n = string.gsub(text, + "(%f[^\0\n])("..string.rep(spaces, reps)..")", + "%1"..string.rep("\t", reps)) + total = total + n + reps = reps - 1 + end + return text, total +end + +local function tabs_replacer(text) + local spaces = string.rep(" ", config.indent_size) + local total = 0 + local n + -- replace the last tab before the text until there aren't anymore + repeat + text, n = string.gsub(text, "(%f[^\0\n]\t*)(\t)", "%1"..spaces) + total = total + n + until n == 0 + return text, total +end + +local function tabs_to_spaces() + local doc = core.active_view.doc + doc:replace(tabs_replacer) + if config.plugins.indent_convert.update_indent_type then + doc.indent_info = { + type = "soft", + size = config.indent_size, + confirmed = true + } + end +end + +local function spaces_to_tabs() + local doc = core.active_view.doc + doc:replace(spaces_replacer) + if config.plugins.indent_convert.update_indent_type then + doc.indent_info = { + type = "hard", + size = config.indent_size, + confirmed = true + } + end +end + +command.add("core.docview", { + ["indent-convert:tabs-to-spaces"] = tabs_to_spaces, + ["indent-convert:spaces-to-tabs"] = spaces_to_tabs + } +) -- cgit v1.2.3 From 4f31214e176156add0edb409910979ba09536d28 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Sat, 20 Nov 2021 03:57:26 +0100 Subject: `indent_convert`: Use `Doc:get_indent_info` if available --- plugins/indent_convert.lua | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'plugins') diff --git a/plugins/indent_convert.lua b/plugins/indent_convert.lua index 103f271..6eb82b0 100644 --- a/plugins/indent_convert.lua +++ b/plugins/indent_convert.lua @@ -36,8 +36,8 @@ config.plugins.indent_convert = { -- The workaround is to find the longest possible repetition of N*X spaces and -- use that information to replace the longest repetition of spaces starting -- from the beginning of the line, then the second longest... -local function spaces_replacer(text) - local spaces = string.rep(" ", config.indent_size) +local function spaces_replacer(text, indent_size) + local spaces = string.rep(" ", indent_size) local total = 0 local n local reps = 0 @@ -57,8 +57,8 @@ local function spaces_replacer(text) return text, total end -local function tabs_replacer(text) - local spaces = string.rep(" ", config.indent_size) +local function tabs_replacer(text, indent_size) + local spaces = string.rep(" ", indent_size) local total = 0 local n -- replace the last tab before the text until there aren't anymore @@ -69,9 +69,20 @@ local function tabs_replacer(text) return text, total end +local function replacer(doc, fn) + local size = config.indent_size + if type(doc.get_indent_info) == "function" then + -- use the new `Doc:get_indent_info` function + size = select(2, doc:get_indent_info()) + end + return function(text) + return fn(text, size) + end +end + local function tabs_to_spaces() local doc = core.active_view.doc - doc:replace(tabs_replacer) + doc:replace(replacer(doc, tabs_replacer)) if config.plugins.indent_convert.update_indent_type then doc.indent_info = { type = "soft", @@ -83,7 +94,7 @@ end local function spaces_to_tabs() local doc = core.active_view.doc - doc:replace(spaces_replacer) + doc:replace(replacer(doc, spaces_replacer)) if config.plugins.indent_convert.update_indent_type then doc.indent_info = { type = "hard", -- cgit v1.2.3 From 381b1b944dee3e054fd534d9622dc4cdbb184ab6 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Sat, 20 Nov 2021 03:57:57 +0100 Subject: `indent_convert`: Restore selections --- plugins/indent_convert.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'plugins') diff --git a/plugins/indent_convert.lua b/plugins/indent_convert.lua index 6eb82b0..8d66033 100644 --- a/plugins/indent_convert.lua +++ b/plugins/indent_convert.lua @@ -7,6 +7,9 @@ config.plugins.indent_convert = { update_indent_type = true -- set to false to avoid updating the document indent type } +-- TODO: only set document indent type if there are no selections +-- TODO: correctly restore selections accounting for the offset caused by the conversion + -- To replace N spaces with tabs, we match the last N spaces before the start of -- the actual code and replace them with a tab. -- We repeat this until we can't find any more spaces before the code. @@ -82,7 +85,10 @@ end local function tabs_to_spaces() local doc = core.active_view.doc + local selections = doc.selections doc:replace(replacer(doc, tabs_replacer)) + doc.selections = selections + doc:sanitize_selection() if config.plugins.indent_convert.update_indent_type then doc.indent_info = { type = "soft", @@ -94,7 +100,10 @@ end local function spaces_to_tabs() local doc = core.active_view.doc + local selections = doc.selections doc:replace(replacer(doc, spaces_replacer)) + doc.selections = selections + doc:sanitize_selection() if config.plugins.indent_convert.update_indent_type then doc.indent_info = { type = "hard", -- cgit v1.2.3 From bcc2c09c4f900a1895e3a57b26e46b64a44c4671 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Sat, 20 Nov 2021 04:30:55 +0100 Subject: `indent_convert`: Update the `Doc` indent size with the correct one --- plugins/indent_convert.lua | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'plugins') diff --git a/plugins/indent_convert.lua b/plugins/indent_convert.lua index 8d66033..61d4a98 100644 --- a/plugins/indent_convert.lua +++ b/plugins/indent_convert.lua @@ -72,27 +72,32 @@ local function tabs_replacer(text, indent_size) return text, total end -local function replacer(doc, fn) - local size = config.indent_size +local function replacer(doc, fn, indent_size) + return function(text) + return fn(text, indent_size) + end +end + +local function get_indent_size(doc) + local indent_size = config.indent_size if type(doc.get_indent_info) == "function" then -- use the new `Doc:get_indent_info` function - size = select(2, doc:get_indent_info()) - end - return function(text) - return fn(text, size) + indent_size = select(2, doc:get_indent_info()) end + return indent_size end local function tabs_to_spaces() local doc = core.active_view.doc + local indent_size = get_indent_size(doc) local selections = doc.selections - doc:replace(replacer(doc, tabs_replacer)) + doc:replace(replacer(doc, tabs_replacer, indent_size)) doc.selections = selections doc:sanitize_selection() if config.plugins.indent_convert.update_indent_type then doc.indent_info = { type = "soft", - size = config.indent_size, + size = indent_size, confirmed = true } end @@ -100,14 +105,15 @@ end local function spaces_to_tabs() local doc = core.active_view.doc + local indent_size = get_indent_size(doc) local selections = doc.selections - doc:replace(replacer(doc, spaces_replacer)) + doc:replace(replacer(doc, spaces_replacer, indent_size)) doc.selections = selections doc:sanitize_selection() if config.plugins.indent_convert.update_indent_type then doc.indent_info = { type = "hard", - size = config.indent_size, + size = indent_size, confirmed = true } end -- cgit v1.2.3 From 139886fe31ff462e78d30c85baf76a1bab17aabb Mon Sep 17 00:00:00 2001 From: Guldoman Date: Sun, 21 Nov 2021 17:17:26 +0100 Subject: `indent_convert`: Use compatible `null` in patterns As LuaJIT uses patterns from Lua 5.1, we have to use `%z` instead of `\0`. --- plugins/indent_convert.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/indent_convert.lua b/plugins/indent_convert.lua index 61d4a98..c86686d 100644 --- a/plugins/indent_convert.lua +++ b/plugins/indent_convert.lua @@ -7,6 +7,8 @@ config.plugins.indent_convert = { update_indent_type = true -- set to false to avoid updating the document indent type } +local zero_pattern = _VERSION == "Lua 5.1" and "%z" or "\0" + -- TODO: only set document indent type if there are no selections -- TODO: correctly restore selections accounting for the offset caused by the conversion @@ -47,12 +49,12 @@ local function spaces_replacer(text, indent_size) -- find the longest repetition of indent_size*spaces repeat reps = reps + 1 - local s, _ = string.find(text, "%f[^\0\n]"..string.rep(spaces, reps)) + local s, _ = string.find(text, "%f[^"..zero_pattern.."\n]"..string.rep(spaces, reps)) until not s reps = reps - 1 while reps > 0 do text, n = string.gsub(text, - "(%f[^\0\n])("..string.rep(spaces, reps)..")", + "(%f[^"..zero_pattern.."\n])("..string.rep(spaces, reps)..")", "%1"..string.rep("\t", reps)) total = total + n reps = reps - 1 @@ -66,7 +68,7 @@ local function tabs_replacer(text, indent_size) local n -- replace the last tab before the text until there aren't anymore repeat - text, n = string.gsub(text, "(%f[^\0\n]\t*)(\t)", "%1"..spaces) + text, n = string.gsub(text, "(%f[^"..zero_pattern.."\n]\t*)(\t)", "%1"..spaces) total = total + n until n == 0 return text, total -- cgit v1.2.3 From 5426d76142d742fa0419f404e36af62e3a3236b9 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Tue, 23 Nov 2021 18:18:05 -0500 Subject: Commit on behalf of @mart-on-windows. --- README.md | 1 + plugins/opacity.lua | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 plugins/opacity.lua (limited to 'plugins') diff --git a/README.md b/README.md index 1f5f35f..970cb36 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,7 @@ Plugin | Description [`motiontrail`](plugins/motiontrail.lua?raw=1) | Adds a motion-trail to the caret *([screenshot](https://user-images.githubusercontent.com/3920290/83256814-085ccb00-a1ab-11ea-9e35-e6633cbed1a9.gif))* ~~[`nagbar`](https://github.com/takase1121/lite-nagbar)*~~ | integrated in lite-xl ~~consistent and _beautiful_ confirmation dialogs for lite and lite-xl *([gif](https://raw.githubusercontent.com/takase1121/lite-nagbar/master/assets/preview.gif))*~~ [`navigate`](plugins/navigate.lua?raw=1) | Allows moving back and forward between document positions, reducing the amount of scrolling +[`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 [`openfilelocation`](plugins/openfilelocation.lua?raw=1) | Opens the parent directory of the current file in the file manager [`openselected`](plugins/openselected.lua?raw=1) | Opens the selected filename or url diff --git a/plugins/opacity.lua b/plugins/opacity.lua new file mode 100644 index 0000000..8dd0d9a --- /dev/null +++ b/plugins/opacity.lua @@ -0,0 +1,62 @@ +-- mod-version:2 -- lite-xl 2.0 +local common = require "core.common" +local command = require "core.command" +local keymap = require "core.keymap" +local RootView = require "core.rootview" + +local opacity_on = true +local use_mousewheel = true +local opacity_steps = 0.05 +local default_opacity = 1 +local current_opacity = default_opacity + +local function set_opacity(opacity) + if not opacity_on then opacity_on = true end + current_opacity = common.clamp(opacity, 0.2, 1) + system.set_window_opacity(current_opacity) +end + +local on_mouse_wheel = RootView.on_mouse_wheel + +function RootView:on_mouse_wheel(d, ...) + if keymap.modkeys["shift"] and use_mousewheel then + if d < 0 then command.perform "opacity:decrease" end + if d > 0 then command.perform "opacity:increase" end + else + return on_mouse_wheel(self, d, ...) + end +end + +local function tog_opacity() + opacity_on = not opacity_on + if opacity_on then + system.set_window_opacity(current_opacity) + else + system.set_window_opacity(default_opacity) + end +end + +local function res_opacity() + set_opacity(default_opacity) +end + +local function inc_opacity() + set_opacity(current_opacity + opacity_steps) +end + +local function dec_opacity() + set_opacity(current_opacity - opacity_steps) +end + +command.add(nil, { + ["opacity:toggle" ] = function() tog_opacity() end, + ["opacity:reset" ] = function() res_opacity() end, + ["opacity:decrease"] = function() dec_opacity() end, + ["opacity:increase"] = function() inc_opacity() end, + ["opacity:toggle mouse wheel use"] = function() use_mousewheel = not use_mousewheel end, +}) + +keymap.add { + ["shift+f11"] = "opacity:toggle", + ["ctrl+f11"] = "opacity:toggle mouse wheel use", +} -- cgit v1.2.3 From 4665146db73a14ef6c5f4ee620ac581689860df8 Mon Sep 17 00:00:00 2001 From: JobinsJC Date: Thu, 25 Nov 2021 09:16:37 +0900 Subject: Julia Syntax Updated --- plugins/language_julia.lua | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/language_julia.lua b/plugins/language_julia.lua index 65bc1ce..cc4699a 100644 --- a/plugins/language_julia.lua +++ b/plugins/language_julia.lua @@ -1,5 +1,5 @@ -- mod-version:2 -- lite-xl 2.0 --- Support for the Julia programming language: +-- Support for the Julia programming language: -- Covers the most used keywords up to Julia version 1.6.4 local syntax = require "core.syntax" @@ -9,8 +9,9 @@ syntax.add { files = { "%.jl$" }, comment = "#", patterns = { - { pattern = { "#=", "=#" }, type = "comment" }, + { pattern = { "#=", "=#" }, type = "comment" }, { pattern = "#.-\n", type = "comment" }, + { pattern = { '[ruU]?"""', '"""'; '\\' }, type = "string" }, { pattern = { '"', '"', '\\' }, type = "string" }, { pattern = { "`", "`", '\\' }, type = "string" }, { pattern = "0[oO_][0-7]+", type = "number" }, @@ -18,13 +19,15 @@ syntax.add { { pattern = "-?%d+_%d", type = "number" }, { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, { pattern = "-?%.?%d+f?", type = "number" }, - { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, + { pattern = "[%+%-=/%*%^%%<>!~|&]%:", type = "operator"}, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, + { pattern = {"@"," "}, type = "operator" }, + { pattern = "[%a_][%w_]*%.*!", type = "keyword2" }, + { pattern = { "{", "}"}, type = "string"}, { pattern = "[%a_][%w_]*", type = "symbol" }, }, symbols = { -- keywords - ["abstract type"] = "keyword", ["baremodule"] = "keyword", ["begin"] = "keyword", ["break`"] = "keyword", @@ -44,6 +47,7 @@ syntax.add { ["function"] = "keyword", ["global"] = "keyword", ["if"] = "keyword", + ["in"] = "keyword", ["import"] = "keyword", ["let"] = "keyword", ["local"] = "keyword", @@ -55,9 +59,11 @@ syntax.add { ["typeof"] = "keyword", ["using"] = "keyword", ["while"] = "keyword", - + -- types ["struct"] = "keyword2", + ["abstract type"] = "keyword2", + ["primitive type"] = "keyword2", ["mutable struct"] = "keyword2", ["Char"] = "keyword2", ["Bool"] = "keyword2", @@ -77,6 +83,8 @@ syntax.add { ["Float64"] = "keyword2", ["Vector"] = "keyword2", ["Matrix"] = "keyword2", + ["Ref"] = "keyword2", + ["String"] = "keyword2", -- literals ["missing"] = "literal", -- cgit v1.2.3 From 70cf94a9fb0689634929fe0c2233377903d8402a Mon Sep 17 00:00:00 2001 From: JobinsJC Date: Thu, 25 Nov 2021 09:26:13 +0900 Subject: Minor fix --- plugins/language_julia.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/language_julia.lua b/plugins/language_julia.lua index cc4699a..1ae541e 100644 --- a/plugins/language_julia.lua +++ b/plugins/language_julia.lua @@ -19,7 +19,7 @@ syntax.add { { pattern = "-?%d+_%d", type = "number" }, { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, { pattern = "-?%.?%d+f?", type = "number" }, - { pattern = "[%+%-=/%*%^%%<>!~|&]%:", type = "operator"}, + { pattern = "[%+%-=/%*%^%%<>!~|&%:]", type = "operator"}, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, { pattern = {"@"," "}, type = "operator" }, { pattern = "[%a_][%w_]*%.*!", type = "keyword2" }, -- cgit v1.2.3 From d57c13ae29f9b5b5a6baec1ce3792c1123b644f2 Mon Sep 17 00:00:00 2001 From: JobinsJC Date: Thu, 25 Nov 2021 09:37:14 +0900 Subject: Minor bug fix --- me.jl | 144 +++++++++++++++++++++++++++++++++++++++++++++ plugins/language_julia.lua | 2 +- 2 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 me.jl (limited to 'plugins') diff --git a/me.jl b/me.jl new file mode 100644 index 0000000..20dc224 --- /dev/null +++ b/me.jl @@ -0,0 +1,144 @@ +# Handers for execute_request and related messages, which are +# the core of the Jupyter protocol: execution of Julia code and +# returning results. + +import Base.Libc: flush_cstdio +import Pkg + +# global variable so that display can be done in the correct Msg context +execute_msg = Msg(["julia"], Dict("username"=>"jlkernel", "session"=>uuid4()), Dict()) +# global variable tracking the number of bytes written in the current execution +# request +const stdio_bytes = Ref(0) + +import REPL: helpmode + +# use a global array to accumulate "payloads" for the execute_reply message +const execute_payloads = Dict[] + +function execute_request(socket, msg) + code = msg.content["code"] + @vprintln("EXECUTING", code) + global execute_msg = msg + global n, In, Out, ans + stdio_bytes[] = 0 + silent = msg.content["silent"] + store_history = get(msg.content, "store_history", !silent) + empty!(execute_payloads) + + if !silent + n += 1 + send_ipython(publish[], + msg_pub(msg, "execute_input", + Dict("execution_count" => n, + "code" => code))) + end + + silent = silent || REPL.ends_with_semicolon(code) + if store_history + In[n] = code + end + + # "; ..." cells are interpreted as shell commands for run + code = replace(code, r"^\s*;.*$" => + m -> string(replace(m, r"^\s*;" => "Base.repl_cmd(`"), + "`, stdout)")) + + + # "] ..." cells are interpreted as pkg shell commands + if occursin(r"^\].*$", code) + code = "IJulia.Pkg.REPLMode.do_cmd(IJulia.minirepl[], \"" * + escape_string(code[2:end]) * "\"; do_rethrow=true)" + end + + # a cell beginning with "? ..." is interpreted as a help request + hcode = replace(code, r"^\s*\?" => "") + + try + for hook in preexecute_hooks + invokelatest(hook) + end + + + ans = result = if hcode != code # help request + Core.eval(Main, helpmode(hcode)) + else + #run the code! + occursin(magics_regex, code) && match(magics_regex, code).offset == 1 ? magics_help(code) : + SOFTSCOPE[] ? softscope_include_string(current_module[], code, "In[$n]") : + include_string(current_module[], code, "In[$n]") + end + + if silent + result = nothing + elseif result !== nothing + if store_history + Out[n] = result + end + end + + user_expressions = Dict() + for (v,ex) in msg.content["user_expressions"] + try + value = include_string(current_module[], ex) + # Like the IPython reference implementation, we return + # something that looks like a `display_data` but also has a + # `status` field: + # https://github.com/ipython/ipython/blob/master/IPython/core/interactiveshell.py#L2609-L2614 + user_expressions[v] = Dict("status" => "ok", + "data" => display_dict(value), + "metadata" => metadata(value)) + catch e + # The format of user_expressions[v] is like `error` except that + # it also has a `status` field: + # https://jupyter-client.readthedocs.io/en/stable/messaging.html#execution-errors + user_expressions[v] = Dict("status" => "error", + error_content(e, catch_backtrace())...) + end + end + + for hook in postexecute_hooks + invokelatest(hook) + end + + # flush pending stdio + flush_all() + + undisplay(result) # dequeue if needed, since we display result in pyout + invokelatest(display) # flush pending display requests + + if result !== nothing + result_metadata = invokelatest(metadata, result) + result_data = invokelatest(display_dict, result) + send_ipython(publish[], + msg_pub(msg, "execute_result", + Dict("execution_count" => n, + "metadata" => result_metadata, + "data" => result_data))) + + end + send_ipython(requests[], + msg_reply(msg, "execute_reply", + Dict("status" => "ok", + "payload" => execute_payloads, + "execution_count" => n, + "user_expressions" => user_expressions))) + empty!(execute_payloads) + catch e + bt = catch_backtrace() + try + # flush pending stdio + flush_all() + for hook in posterror_hooks + invokelatest(hook) + end + catch + end + empty!(displayqueue) # discard pending display requests on an error + content = error_content(e,bt) + send_ipython(publish[], msg_pub(msg, "error", content)) + content["status"] = "error" + content["execution_count"] = n + send_ipython(requests[], msg_reply(msg, "execute_reply", content)) + end +end diff --git a/plugins/language_julia.lua b/plugins/language_julia.lua index 1ae541e..f9edebf 100644 --- a/plugins/language_julia.lua +++ b/plugins/language_julia.lua @@ -21,7 +21,7 @@ syntax.add { { pattern = "-?%.?%d+f?", type = "number" }, { pattern = "[%+%-=/%*%^%%<>!~|&%:]", type = "operator"}, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { pattern = {"@"," "}, type = "operator" }, + { pattern = "@[%a_][%w_]", type = "function" }, { pattern = "[%a_][%w_]*%.*!", type = "keyword2" }, { pattern = { "{", "}"}, type = "string"}, { pattern = "[%a_][%w_]*", type = "symbol" }, -- cgit v1.2.3 From ee62ab2adb35aff979621fe144662a8583566b15 Mon Sep 17 00:00:00 2001 From: JobinsJC Date: Thu, 25 Nov 2021 10:22:10 +0900 Subject: Updates Julia Syntax --- plugins/language_julia.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/language_julia.lua b/plugins/language_julia.lua index f9edebf..d47b87e 100644 --- a/plugins/language_julia.lua +++ b/plugins/language_julia.lua @@ -21,16 +21,16 @@ syntax.add { { pattern = "-?%.?%d+f?", type = "number" }, { pattern = "[%+%-=/%*%^%%<>!~|&%:]", type = "operator"}, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { pattern = "@[%a_][%w_]", type = "function" }, - { pattern = "[%a_][%w_]*%.*!", type = "keyword2" }, - { pattern = { "{", "}"}, type = "string"}, + { pattern = "@[%a_][%w_]*[%a_][%w_]", type = "function" }, + { pattern = "[%a_][%w_]*%.*!", type = "keyword2" }, + { pattern = "{[%a_][%w_]*}", type = "string"}, { pattern = "[%a_][%w_]*", type = "symbol" }, }, symbols = { -- keywords ["baremodule"] = "keyword", ["begin"] = "keyword", - ["break`"] = "keyword", + ["break"] = "keyword", ["catch"] = "keyword", ["const"] = "keyword", ["continue"] = "keyword", @@ -53,6 +53,7 @@ syntax.add { ["local"] = "keyword", ["macro"] = "keyword", ["module"] = "keyword", + ["mutable"] = "keyword", ["quote"] = "keyword", ["return"] = "keyword", ["try"] = "keyword", @@ -85,10 +86,11 @@ syntax.add { ["Matrix"] = "keyword2", ["Ref"] = "keyword2", ["String"] = "keyword2", + ["Function"] = "keyword2", -- literals ["missing"] = "literal", ["true"] = "literal", ["false"] = "literal", - }, + } } -- cgit v1.2.3 From dc518e4d03d39a789e65e46b1098b315eda1f8b3 Mon Sep 17 00:00:00 2001 From: JobinsJC Date: Thu, 25 Nov 2021 10:33:52 +0900 Subject: Added nothing literal --- plugins/language_julia.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/language_julia.lua b/plugins/language_julia.lua index d47b87e..5ae8e9b 100644 --- a/plugins/language_julia.lua +++ b/plugins/language_julia.lua @@ -92,5 +92,6 @@ syntax.add { ["missing"] = "literal", ["true"] = "literal", ["false"] = "literal", + ["nothing"] = "literal", } } -- cgit v1.2.3 From 8d3c856a3feb647f87b4a098e27f383bbedcda1d Mon Sep 17 00:00:00 2001 From: JobinsJC Date: Thu, 25 Nov 2021 10:42:36 +0900 Subject: Minor fix --- plugins/language_julia.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/language_julia.lua b/plugins/language_julia.lua index 5ae8e9b..b0f953f 100644 --- a/plugins/language_julia.lua +++ b/plugins/language_julia.lua @@ -30,7 +30,7 @@ syntax.add { -- keywords ["baremodule"] = "keyword", ["begin"] = "keyword", - ["break"] = "keyword", + ["break"] = "keyword", ["catch"] = "keyword", ["const"] = "keyword", ["continue"] = "keyword", @@ -60,6 +60,7 @@ syntax.add { ["typeof"] = "keyword", ["using"] = "keyword", ["while"] = "keyword", + ["where"] = "keyword", -- types ["struct"] = "keyword2", @@ -92,6 +93,6 @@ syntax.add { ["missing"] = "literal", ["true"] = "literal", ["false"] = "literal", - ["nothing"] = "literal", + ["nothing"] = "literal", } } -- cgit v1.2.3 From 4f5d7e9ddfde8feb0d8d9efb91f6cbb47e99137b Mon Sep 17 00:00:00 2001 From: JobinsJC Date: Sun, 28 Nov 2021 10:41:42 +0900 Subject: More improvements --- plugins/language_julia.lua | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'plugins') diff --git a/plugins/language_julia.lua b/plugins/language_julia.lua index b0f953f..6dea1a8 100644 --- a/plugins/language_julia.lua +++ b/plugins/language_julia.lua @@ -11,20 +11,21 @@ syntax.add { patterns = { { pattern = { "#=", "=#" }, type = "comment" }, { pattern = "#.-\n", type = "comment" }, - { pattern = { '[ruU]?"""', '"""'; '\\' }, type = "string" }, - { pattern = { '"', '"', '\\' }, type = "string" }, - { pattern = { "`", "`", '\\' }, type = "string" }, + { pattern = '[%a_][%w_]*"""*[%a_][%w_]*"""', type = "function" }, + { pattern = { '[ruU]?"', '"', '\\' }, type = "string" }, + { pattern = { "[ruU]?'", "'", '\\' }, type = "string" }, { pattern = "0[oO_][0-7]+", type = "number" }, { pattern = "-?0x[%x_]+", type = "number" }, + { pattern = "-?0b[%x_]+", type = "number" }, { pattern = "-?%d+_%d", type = "number" }, { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, { pattern = "-?%.?%d+f?", type = "number" }, - { pattern = "[%+%-=/%*%^%%<>!~|&%:]", type = "operator"}, - { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { pattern = "@[%a_][%w_]*[%a_][%w_]", type = "function" }, - { pattern = "[%a_][%w_]*%.*!", type = "keyword2" }, - { pattern = "{[%a_][%w_]*}", type = "string"}, - { pattern = "[%a_][%w_]*", type = "symbol" }, + { pattern = "[%+%-=/%*%^%%<>!~|&%:]", type = "operator" }, + { pattern = "[%a_][%w_]*%f[(]", type = "function" }, + { pattern = "@[%a_][%w_]*[%a_][%w_]", type = "function" }, + { pattern = "[%a_][%w_]*%.*!", type = "keyword2" }, + { pattern = "{[%a_][%w_]*}", type = "string" }, + { pattern = "[%a_][%w_]*", type = "symbol" }, }, symbols = { -- keywords @@ -88,11 +89,14 @@ syntax.add { ["Ref"] = "keyword2", ["String"] = "keyword2", ["Function"] = "keyword2", + ["Number"] = "keyword2", -- literals ["missing"] = "literal", ["true"] = "literal", ["false"] = "literal", ["nothing"] = "literal", + ["Inf"] = "literal", + ["NaN"] = "literal", } } -- cgit v1.2.3 From 3ef7a003366aea89827417e4a3ed7135feca6cd4 Mon Sep 17 00:00:00 2001 From: Joshua Minor Date: Sat, 27 Nov 2021 21:48:25 -0800 Subject: Highlight the cursor and selection in minimap. --- plugins/minimap.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'plugins') diff --git a/plugins/minimap.lua b/plugins/minimap.lua index b129f40..32bcf6f 100644 --- a/plugins/minimap.lua +++ b/plugins/minimap.lua @@ -222,6 +222,15 @@ DocView.draw_scrollbar = function(self) -- draw visual rect renderer.draw_rect(x, visible_y, w, scroller_height, visual_color) + -- highlight the selected lines, and the line with the caret on it + 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, style.dim) + renderer.draw_rect(x, selection_y, w, line_spacing, style.accent) + local highlight_align = config.plugins.minimap.highlight_align local highlight_width = config.plugins.minimap.highlight_width local gutter_width = config.plugins.minimap.gutter_width -- cgit v1.2.3 From 0652077a2532038483f487e5c925d9ba697bac75 Mon Sep 17 00:00:00 2001 From: Joshua Minor Date: Sat, 27 Nov 2021 21:48:32 -0800 Subject: Allow customization of minimap selection & caret colors. --- plugins/minimap.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/minimap.lua b/plugins/minimap.lua index 32bcf6f..2c383b8 100644 --- a/plugins/minimap.lua +++ b/plugins/minimap.lua @@ -16,6 +16,13 @@ config.plugins.minimap = { -- how many spaces one tab is equivalent to tab_width = 4, draw_background = true, + + -- you can override these colors + selection_color = nil, + caret_color = nil, + + -- If other plugins provide per-line highlights, + -- this controls the placement. (e.g. gitdiff_highlight) highlight_align = 'left', highlight_width = 3, gutter_width = 5, @@ -223,13 +230,15 @@ DocView.draw_scrollbar = function(self) renderer.draw_rect(x, visible_y, w, scroller_height, visual_color) -- 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, style.dim) - renderer.draw_rect(x, selection_y, w, line_spacing, style.accent) + renderer.draw_rect(x, selection_min_y, w, selection_h, selection_color) + renderer.draw_rect(x, selection_y, w, line_spacing, caret_color) local highlight_align = config.plugins.minimap.highlight_align local highlight_width = config.plugins.minimap.highlight_width -- cgit v1.2.3 From 29e90f290416e85765d0abda6daead452e853ae1 Mon Sep 17 00:00:00 2001 From: Nightwing Date: Wed, 1 Dec 2021 00:18:43 +0900 Subject: Added support for raw string --- plugins/language_rust.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/language_rust.lua b/plugins/language_rust.lua index a8dc017..40aeb5f 100644 --- a/plugins/language_rust.lua +++ b/plugins/language_rust.lua @@ -8,6 +8,7 @@ syntax.add { patterns = { { pattern = "//.-\n", type = "comment" }, { pattern = { "/%*", "%*/" }, type = "comment" }, + { pattern = { 'r#"', '"#', '\\' }, type = "string" }, { pattern = { '"', '"', '\\' }, type = "string" }, { pattern = { "`", "`", '\\' }, type = "string" }, { pattern = "0[oO_][0-7]+", type = "number" }, -- cgit v1.2.3 From fe42f455405f02a60319ca7056ba405080a3e640 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Wed, 1 Dec 2021 00:23:14 +0100 Subject: Add `force_syntax` --- README.md | 1 + plugins/force_syntax.lua | 132 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 plugins/force_syntax.lua (limited to 'plugins') diff --git a/README.md b/README.md index 6647e2a..dbb71f2 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Plugin | Description [`ephemeraldocviews`](plugins/ephemeraldocviews.lua?raw=1) | Preview tabs. Opening a doc will replace the contents of the preview tab. Marks tabs as non-preview on any change. [`fallbackfonts`](https://github.com/takase1121/lite-fallback-fonts)* | Adds support for fallback fonts *([gif](https://raw.githubusercontent.com/takase1121/lite-fallback-fonts/master/assets/Iw18fI57J0.gif))* [`fontconfig`](plugins/fontconfig.lua?raw=1) | Allows users to load fonts with [fontconfig](https://www.freedesktop.org/software/fontconfig/fontconfig-user.html). +*[`force_syntax`](plugins/force_syntax.lua?raw=1)* | Change the syntax used for a file. [`formatter`](https://github.com/vincens2005/lite-formatters)* | formatters for various languages [`ghmarkdown`](plugins/ghmarkdown.lua?raw=1) | Opens a preview of the current markdown file in a browser window *([screenshot](https://user-images.githubusercontent.com/3920290/82754898-f7394600-9dc7-11ea-8278-2305363ed372.png))* *[`gitdiff_highlight`](https://github.com/vincens2005/lite-xl-gitdiff-highlight)** | highlight changed lines from git *([screenshot](https://raw.githubusercontent.com/vincens2005/lite-xl-gitdiff-highlight/master/screenshot.png))* diff --git a/plugins/force_syntax.lua b/plugins/force_syntax.lua new file mode 100644 index 0000000..be9cbbc --- /dev/null +++ b/plugins/force_syntax.lua @@ -0,0 +1,132 @@ +-- mod-version:2 -- lite-xl 2.0 +local core = require "core" +local Doc = require "core.doc" +local syntax = require "core.syntax" +local command = require "core.command" +local common = require "core.common" +local style = require "core.style" +local StatusView = require "core.statusview" +local DocView = require "core.docview" + +local function doc() + if core.active_view and getmetatable(core.active_view) == DocView then return core.active_view.doc end + if core.last_active_view and getmetatable(core.last_active_view) == DocView then return core.last_active_view.doc end +end + +-- Force plaintext syntax to have a name +local plain_text_syntax = syntax.get("") +plain_text_syntax.name = plain_text_syntax.name or "Plain Text" + +local doc_reset_syntax = Doc.reset_syntax +function Doc:reset_syntax() + local syntax_get = syntax.get + if self.force_syntax then + syntax.get = function() return self.force_syntax end + end + doc_reset_syntax(self) + syntax.get = syntax_get +end + +local function get_syntax_name(s) + if not s then return "Undefined" end + local name = s.name + if not name then + local exts = type(s.files) == "string" and { s.files } or s.files + if exts then + name = table.concat(exts, ", ") + end + end + return name or "Undefined" +end + +local statusview_get_items = StatusView.get_items +function StatusView:get_items() + local left, right = statusview_get_items(self) + + local is_dv = core.active_view and getmetatable(core.active_view) == DocView + if not is_dv then return left, right end + + local syntax_name = get_syntax_name(doc().syntax) + + local ins = { + style.dim, + self.separator2, + style.text, + syntax_name + } + + if syntax_name then + for _,item in pairs(ins) do + table.insert(right, item) + end + end + + return left, right +end + +local function get_syntax_list() + local pt_name = plain_text_syntax.name + if doc().syntax == plain_text_syntax then + pt_name = "Current: "..pt_name + end + local list = { ["Auto detect"] = false, + [pt_name] = plain_text_syntax } + local keylist = { "Auto detect", pt_name } + + for _,s in pairs(syntax.items) do + local name = get_syntax_name(s) + local fullname = name + local i = 1 + while list[fullname] do + i = i + 1 + fullname = name.." ("..i..")" + end + if doc().syntax == s then + fullname = "Current: "..fullname + end + list[fullname] = s + table.insert(keylist, fullname) + end + + return list, keylist +end + +local function sorter(a, b) + -- Compare only syntax name + a = a:gsub("Current: ", "") + b = b:gsub("Current: ", "") + return string.upper(a) < string.upper(b) +end + +local function bias_sorter(a, b) + -- Bias towards Current and Auto detect syntax + if a:match("Current: ") then return true end + if b:match("Current: ") then return false end + if a:match("Auto detect") then return true end + if b:match("Auto detect") then return false end + return sorter(a, b) +end + +command.add("core.docview", { + ["force-syntax:select-file-syntax"] = + function() + core.command_view:enter( + "Set syntax for this file", + function(text, item) -- submit + local list, _ = get_syntax_list() + doc().force_syntax = list[item.text] + doc():reset_syntax() + end, + function(text) -- suggest + local _, keylist = get_syntax_list() + local res = common.fuzzy_match(keylist, text) + -- Force Current and Auto detect syntax to the bottom + -- if the text is empty + table.sort(res, #text == 0 and bias_sorter or sorter) + return res + end, + nil, -- cancel + nil -- validate + ) + end +}) -- cgit v1.2.3 From 4e0496ffcf96dfa0f7de70bcc055170d4f2f54c0 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Wed, 1 Dec 2021 04:32:08 +0100 Subject: `force_syntax`: Provide empty header to `syntax.get` --- plugins/force_syntax.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/force_syntax.lua b/plugins/force_syntax.lua index be9cbbc..dce4abc 100644 --- a/plugins/force_syntax.lua +++ b/plugins/force_syntax.lua @@ -14,7 +14,7 @@ local function doc() end -- Force plaintext syntax to have a name -local plain_text_syntax = syntax.get("") +local plain_text_syntax = syntax.get("", "") plain_text_syntax.name = plain_text_syntax.name or "Plain Text" local doc_reset_syntax = Doc.reset_syntax -- cgit v1.2.3 From e5f8317541b8b986c45b234f58192c90434a1365 Mon Sep 17 00:00:00 2001 From: Nightwing Date: Thu, 2 Dec 2021 14:40:07 +0900 Subject: Support for lifetime annotations --- plugins/language_rust.lua | 96 ++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 47 deletions(-) (limited to 'plugins') diff --git a/plugins/language_rust.lua b/plugins/language_rust.lua index 40aeb5f..eefc33a 100644 --- a/plugins/language_rust.lua +++ b/plugins/language_rust.lua @@ -11,6 +11,8 @@ syntax.add { { pattern = { 'r#"', '"#', '\\' }, type = "string" }, { pattern = { '"', '"', '\\' }, type = "string" }, { pattern = { "`", "`", '\\' }, type = "string" }, + { pattern = "%'[%a]*[>%s:]", type = "keyword2"}, + { pattern = { "'", "'", '\\' }, type = "string" }, { pattern = "0[oO_][0-7]+", type = "number" }, { pattern = "-?0x[%x_]+", type = "number" }, { pattern = "-?%d+_%d", type = "number" }, @@ -28,59 +30,59 @@ syntax.add { ["break"] = "keyword", ["const"] = "keyword", ["continue"] = "keyword", - ["crate"] = "keyword", - ["dyn"] = "keyword", - ["else"] = "keyword", - ["enum"] = "keyword", - ["extern"] = "keyword", - ["false"] = "keyword", - ["fn"] = "keyword", - ["for"] = "keyword", - ["if"] = "keyword", - ["impl"] = "keyword", - ["in"] = "keyword", - ["let"] = "keyword", - ["loop"] = "keyword", - ["match"] = "keyword", - ["mod"] = "keyword", - ["move"] = "keyword", - ["mut"] = "keyword", - ["pub"] = "keyword", - ["ref"] = "keyword", + ["crate"] = "keyword", + ["dyn"] = "keyword", + ["else"] = "keyword", + ["enum"] = "keyword", + ["extern"] = "keyword", + ["false"] = "keyword", + ["fn"] = "keyword", + ["for"] = "keyword", + ["if"] = "keyword", + ["impl"] = "keyword", + ["in"] = "keyword", + ["let"] = "keyword", + ["loop"] = "keyword", + ["match"] = "keyword", + ["mod"] = "keyword", + ["move"] = "keyword", + ["mut"] = "keyword", + ["pub"] = "keyword", + ["ref"] = "keyword", ["return"] = "keyword", - ["Self"] = "keyword", - ["self"] = "keyword", + ["Self"] = "keyword", + ["self"] = "keyword", ["static"] = "keyword", ["struct"] = "keyword", - ["super"] = "keyword", - ["trait"] = "keyword", - ["true"] = "keyword", - ["type"] = "keyword", + ["super"] = "keyword", + ["trait"] = "keyword", + ["true"] = "keyword", + ["type"] = "keyword", ["unsafe"] = "keyword", - ["use"] = "keyword", + ["use"] = "keyword", ["where"] = "keyword", ["while"] = "keyword", - ["i32"] = "keyword2", - ["i64"] = "keyword2", - ["i128"] = "keyword2", - ["i16"] = "keyword2", - ["i8"] = "keyword2", - ["u8"] = "keyword2", - ["u16"] = "keyword2", - ["u32"] = "keyword2", - ["u64"] = "keyword2", - ["usize"] = "keyword2", - ["isize"] = "keyword2", - ["f32"] = "keyword2", - ["f64"] = "keyword2", - ["f128"] = "keyword2", - ["String"] = "keyword2", - ["char"] = "keyword2", - ["&str"] = "keyword2", - ["bool"] = "keyword2", - ["true"] = "literal", - ["false"] = "literal", - ["None"] = "literal", + ["i32"] = "keyword2", + ["i64"] = "keyword2", + ["i128"] = "keyword2", + ["i16"] = "keyword2", + ["i8"] = "keyword2", + ["u8"] = "keyword2", + ["u16"] = "keyword2", + ["u32"] = "keyword2", + ["u64"] = "keyword2", + ["usize"] = "keyword2", + ["isize"] = "keyword2", + ["f32"] = "keyword2", + ["f64"] = "keyword2", + ["f128"] = "keyword2", + ["String"] = "keyword2", + ["char"] = "keyword2", + ["&str"] = "keyword2", + ["bool"] = "keyword2", + ["true"] = "literal", + ["false"] = "literal", + ["None"] = "literal", ["Some"] = "literal", ["Option"] = "literal", ["Result"] = "literal", -- cgit v1.2.3 From f54baa037ed026922302c17cac2748f0e0c58ef6 Mon Sep 17 00:00:00 2001 From: Nightwing Date: Fri, 3 Dec 2021 20:59:48 +0900 Subject: Bug fixes --- plugins/language_rust.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/language_rust.lua b/plugins/language_rust.lua index eefc33a..3a0d6b8 100644 --- a/plugins/language_rust.lua +++ b/plugins/language_rust.lua @@ -11,8 +11,8 @@ syntax.add { { pattern = { 'r#"', '"#', '\\' }, type = "string" }, { pattern = { '"', '"', '\\' }, type = "string" }, { pattern = { "`", "`", '\\' }, type = "string" }, - { pattern = "%'[%a]*[>%s:]", type = "keyword2"}, - { pattern = { "'", "'", '\\' }, type = "string" }, + { pattern = "'%a*[>%s:]", type = "keyword2"}, + { pattern = "'*'", type = "string" }, { pattern = "0[oO_][0-7]+", type = "number" }, { pattern = "-?0x[%x_]+", type = "number" }, { pattern = "-?%d+_%d", type = "number" }, @@ -78,7 +78,7 @@ syntax.add { ["f128"] = "keyword2", ["String"] = "keyword2", ["char"] = "keyword2", - ["&str"] = "keyword2", + ["str"] = "keyword2", ["bool"] = "keyword2", ["true"] = "literal", ["false"] = "literal", -- cgit v1.2.3 From 2fa38447cfe056be3c36a0c51800e788890edb08 Mon Sep 17 00:00:00 2001 From: Nightwing Date: Fri, 3 Dec 2021 21:03:50 +0900 Subject: OOps my bad --- plugins/language_rust.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/language_rust.lua b/plugins/language_rust.lua index 3a0d6b8..3732fef 100644 --- a/plugins/language_rust.lua +++ b/plugins/language_rust.lua @@ -10,9 +10,8 @@ syntax.add { { pattern = { "/%*", "%*/" }, type = "comment" }, { pattern = { 'r#"', '"#', '\\' }, type = "string" }, { pattern = { '"', '"', '\\' }, type = "string" }, - { pattern = { "`", "`", '\\' }, type = "string" }, - { pattern = "'%a*[>%s:]", type = "keyword2"}, - { pattern = "'*'", type = "string" }, + { pattern = "'.'", type = "string" }, + { pattern = "'%a", type = "keyword2" }, { pattern = "0[oO_][0-7]+", type = "number" }, { pattern = "-?0x[%x_]+", type = "number" }, { pattern = "-?%d+_%d", type = "number" }, -- cgit v1.2.3 From 6bdc51987ec0d08bb7664a00089dc165ea742e5d Mon Sep 17 00:00:00 2001 From: Nightwing Date: Fri, 3 Dec 2021 22:42:12 +0900 Subject: Improved Julia syntax --- plugins/language_julia.lua | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'plugins') diff --git a/plugins/language_julia.lua b/plugins/language_julia.lua index 6dea1a8..ecdbdc0 100644 --- a/plugins/language_julia.lua +++ b/plugins/language_julia.lua @@ -9,22 +9,25 @@ syntax.add { files = { "%.jl$" }, comment = "#", patterns = { - { pattern = { "#=", "=#" }, type = "comment" }, - { pattern = "#.-\n", type = "comment" }, - { pattern = '[%a_][%w_]*"""*[%a_][%w_]*"""', type = "function" }, - { pattern = { '[ruU]?"', '"', '\\' }, type = "string" }, - { pattern = { "[ruU]?'", "'", '\\' }, type = "string" }, + {pattern = {"#=", "=#"}, type="comment" }, + {pattern = "#.*$", type="comment" }, + { pattern = "%d%w*[%.-+*//]", type = "number" }, { pattern = "0[oO_][0-7]+", type = "number" }, { pattern = "-?0x[%x_]+", type = "number" }, { pattern = "-?0b[%x_]+", type = "number" }, { pattern = "-?%d+_%d", type = "number" }, { pattern = "-?%d+[%d%.eE]*f?", type = "number" }, { pattern = "-?%.?%d+f?", type = "number" }, - { pattern = "[%+%-=/%*%^%%<>!~|&%:]", type = "operator" }, + { pattern = "[^%d%g]%:%a*", type = "function" }, + { pattern = "[%+%-=/%*%^%%<>!~|&%:]",type = "operator"}, + { pattern = '""".*"""', type = "string" }, + { pattern = '".*"', type = "string" }, + { pattern = '[bv]".*"', type = "string" }, + { pattern = 'r".*$', type = "string" }, + { pattern = "'\\.*'", type = "string" }, + { pattern = "'.'", type = "string" }, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { pattern = "@[%a_][%w_]*[%a_][%w_]", type = "function" }, - { pattern = "[%a_][%w_]*%.*!", type = "keyword2" }, - { pattern = "{[%a_][%w_]*}", type = "string" }, + { pattern = ".*!", type="function"}, { pattern = "[%a_][%w_]*", type = "symbol" }, }, symbols = { @@ -53,6 +56,7 @@ syntax.add { ["let"] = "keyword", ["local"] = "keyword", ["macro"] = "keyword", + ["type"] = "keyword", ["module"] = "keyword", ["mutable"] = "keyword", ["quote"] = "keyword", @@ -65,12 +69,13 @@ syntax.add { -- types ["struct"] = "keyword2", - ["abstract type"] = "keyword2", - ["primitive type"] = "keyword2", - ["mutable struct"] = "keyword2", + ["abstract"] = "keyword2", + ["primitive"] = "keyword2", + ["mutable"] = "keyword2", ["Char"] = "keyword2", ["Bool"] = "keyword2", ["Int"] = "keyword2", + ["Integer"] = "keyword2", ["Int8"] = "keyword2", ["UInt8"] = "keyword2", ["Int16"] = "keyword2", -- cgit v1.2.3 From 9d91e39bf3711f14c5badb300d4ba8a4c24117c0 Mon Sep 17 00:00:00 2001 From: Nightwing Date: Fri, 3 Dec 2021 23:07:28 +0900 Subject: Finally --- plugins/language_julia.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/language_julia.lua b/plugins/language_julia.lua index ecdbdc0..e62a9b2 100644 --- a/plugins/language_julia.lua +++ b/plugins/language_julia.lua @@ -11,6 +11,11 @@ syntax.add { patterns = { {pattern = {"#=", "=#"}, type="comment" }, {pattern = "#.*$", type="comment" }, + { pattern = { 'icxx"""', '"""' }, type = "string", syntax = ".cpp" }, + { pattern = { 'cxx"""', '"""' }, type = "string", syntax = ".cpp" }, + { pattern = { 'py"""', '"""' }, type = "string", syntax = ".py" }, + { pattern = { 'js"""', '"""' }, type = "string", syntax = ".js" }, + { pattern = { 'md"""', '"""' }, type = "string", syntax = ".md" }, { pattern = "%d%w*[%.-+*//]", type = "number" }, { pattern = "0[oO_][0-7]+", type = "number" }, { pattern = "-?0x[%x_]+", type = "number" }, @@ -27,7 +32,7 @@ syntax.add { { pattern = "'\\.*'", type = "string" }, { pattern = "'.'", type = "string" }, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { pattern = ".*!", type="function"}, + { pattern = "%g*!", type="function"}, { pattern = "[%a_][%w_]*", type = "symbol" }, }, symbols = { -- cgit v1.2.3 From 8abe633e3923335e99cc49e0d7890263da141b98 Mon Sep 17 00:00:00 2001 From: Nightwing <94565465+Nightwing13@users.noreply.github.com> Date: Mon, 6 Dec 2021 21:34:25 +0900 Subject: Fix spacing --- plugins/language_rust.lua | 70 +++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'plugins') diff --git a/plugins/language_rust.lua b/plugins/language_rust.lua index 3732fef..42b167f 100644 --- a/plugins/language_rust.lua +++ b/plugins/language_rust.lua @@ -10,8 +10,8 @@ syntax.add { { pattern = { "/%*", "%*/" }, type = "comment" }, { pattern = { 'r#"', '"#', '\\' }, type = "string" }, { pattern = { '"', '"', '\\' }, type = "string" }, - { pattern = "'.'", type = "string" }, - { pattern = "'%a", type = "keyword2" }, + { pattern = "'.'", type = "string" }, + { pattern = "'%a", type = "keyword2" }, { pattern = "0[oO_][0-7]+", type = "number" }, { pattern = "-?0x[%x_]+", type = "number" }, { pattern = "-?%d+_%d", type = "number" }, @@ -23,11 +23,11 @@ syntax.add { { pattern = "[%a_][%w_]*", type = "symbol" }, }, symbols = { - ["as"] = "keyword", - ["async"] = "keyword", - ["await"] = "keyword", - ["break"] = "keyword", - ["const"] = "keyword", + ["as"] = "keyword", + ["async"] = "keyword", + ["await"] = "keyword", + ["break"] = "keyword", + ["const"] = "keyword", ["continue"] = "keyword", ["crate"] = "keyword", ["dyn"] = "keyword", @@ -48,33 +48,33 @@ syntax.add { ["mut"] = "keyword", ["pub"] = "keyword", ["ref"] = "keyword", - ["return"] = "keyword", - ["Self"] = "keyword", - ["self"] = "keyword", - ["static"] = "keyword", - ["struct"] = "keyword", - ["super"] = "keyword", - ["trait"] = "keyword", - ["true"] = "keyword", - ["type"] = "keyword", - ["unsafe"] = "keyword", - ["use"] = "keyword", - ["where"] = "keyword", - ["while"] = "keyword", - ["i32"] = "keyword2", - ["i64"] = "keyword2", - ["i128"] = "keyword2", - ["i16"] = "keyword2", - ["i8"] = "keyword2", - ["u8"] = "keyword2", - ["u16"] = "keyword2", - ["u32"] = "keyword2", - ["u64"] = "keyword2", - ["usize"] = "keyword2", - ["isize"] = "keyword2", - ["f32"] = "keyword2", - ["f64"] = "keyword2", - ["f128"] = "keyword2", + ["return"] = "keyword", + ["Self"] = "keyword", + ["self"] = "keyword", + ["static"] = "keyword", + ["struct"] = "keyword", + ["super"] = "keyword", + ["trait"] = "keyword", + ["true"] = "keyword", + ["type"] = "keyword", + ["unsafe"] = "keyword", + ["use"] = "keyword", + ["where"] = "keyword", + ["while"] = "keyword", + ["i32"] = "keyword2", + ["i64"] = "keyword2", + ["i128"] = "keyword2", + ["i16"] = "keyword2", + ["i8"] = "keyword2", + ["u8"] = "keyword2", + ["u16"] = "keyword2", + ["u32"] = "keyword2", + ["u64"] = "keyword2", + ["usize"] = "keyword2", + ["isize"] = "keyword2", + ["f32"] = "keyword2", + ["f64"] = "keyword2", + ["f128"] = "keyword2", ["String"] = "keyword2", ["char"] = "keyword2", ["str"] = "keyword2", @@ -84,7 +84,7 @@ syntax.add { ["None"] = "literal", ["Some"] = "literal", ["Option"] = "literal", - ["Result"] = "literal", + ["Result"] = "literal", }, } -- cgit v1.2.3 From 3627588317a953e1d4170507b1fd73dbcf68d64f Mon Sep 17 00:00:00 2001 From: Nightwing <94565465+Nightwing13@users.noreply.github.com> Date: Mon, 6 Dec 2021 21:37:02 +0900 Subject: Fix spacing 2 --- plugins/language_rust.lua | 50 +++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'plugins') diff --git a/plugins/language_rust.lua b/plugins/language_rust.lua index 42b167f..f20d35e 100644 --- a/plugins/language_rust.lua +++ b/plugins/language_rust.lua @@ -10,7 +10,7 @@ syntax.add { { pattern = { "/%*", "%*/" }, type = "comment" }, { pattern = { 'r#"', '"#', '\\' }, type = "string" }, { pattern = { '"', '"', '\\' }, type = "string" }, - { pattern = "'.'", type = "string" }, + { pattern = "'.'", type = "string" }, { pattern = "'%a", type = "keyword2" }, { pattern = "0[oO_][0-7]+", type = "number" }, { pattern = "-?0x[%x_]+", type = "number" }, @@ -61,30 +61,30 @@ syntax.add { ["use"] = "keyword", ["where"] = "keyword", ["while"] = "keyword", - ["i32"] = "keyword2", - ["i64"] = "keyword2", - ["i128"] = "keyword2", - ["i16"] = "keyword2", - ["i8"] = "keyword2", - ["u8"] = "keyword2", - ["u16"] = "keyword2", - ["u32"] = "keyword2", - ["u64"] = "keyword2", - ["usize"] = "keyword2", - ["isize"] = "keyword2", - ["f32"] = "keyword2", - ["f64"] = "keyword2", - ["f128"] = "keyword2", - ["String"] = "keyword2", - ["char"] = "keyword2", - ["str"] = "keyword2", - ["bool"] = "keyword2", - ["true"] = "literal", - ["false"] = "literal", - ["None"] = "literal", - ["Some"] = "literal", - ["Option"] = "literal", - ["Result"] = "literal", + ["i32"] = "keyword2", + ["i64"] = "keyword2", + ["i128"] = "keyword2", + ["i16"] = "keyword2", + ["i8"] = "keyword2", + ["u8"] = "keyword2", + ["u16"] = "keyword2", + ["u32"] = "keyword2", + ["u64"] = "keyword2", + ["usize"] = "keyword2", + ["isize"] = "keyword2", + ["f32"] = "keyword2", + ["f64"] = "keyword2", + ["f128"] = "keyword2", + ["String"] = "keyword2", + ["char"] = "keyword2", + ["str"] = "keyword2", + ["bool"] = "keyword2", + ["true"] = "literal", + ["false"] = "literal", + ["None"] = "literal", + ["Some"] = "literal", + ["Option"] = "literal", + ["Result"] = "literal", }, } -- cgit v1.2.3 From 56ab78215af3167cab4cc213e09a1ba88cf5a6af Mon Sep 17 00:00:00 2001 From: Jipok Date: Sat, 11 Dec 2021 00:05:24 +0500 Subject: EphemeralDocViews: improve with double clicks --- plugins/ephemeraldocviews.lua | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/ephemeraldocviews.lua b/plugins/ephemeraldocviews.lua index cb9f53d..1169d7f 100644 --- a/plugins/ephemeraldocviews.lua +++ b/plugins/ephemeraldocviews.lua @@ -4,6 +4,7 @@ local command = require "core.command" local RootView = require "core.rootview" local DocView = require "core.docview" local Doc = require "core.doc" +local TreeView = require "plugins.treeview" local open_doc = RootView.open_doc function RootView:open_doc(doc) @@ -29,7 +30,7 @@ end local get_name = DocView.get_name function DocView:get_name() - return self.doc and self.doc.ephemeral and ("-- " .. get_name(self) .. " --") or get_name(self) + return self.doc and self.doc.ephemeral and ("~ " .. get_name(self) .. " ~") or get_name(self) end local doc_insert = Doc.insert @@ -43,3 +44,27 @@ function Doc:remove(...) doc_remove(self, ...) self.ephemeral = false end + +-- Double clicking in the TreeView makes the tab normal +local TreeView_original_event = TreeView.on_mouse_pressed +function TreeView:on_mouse_pressed(button, x, y, clicks) + TreeView_original_event(self, button, x, y, clicks) + if (clicks > 1) and (core.active_view.doc ~= nil) then + core.active_view.doc.ephemeral = false + end +end + +-- Double clicking on a tab makes it normal +local RootView_original_event = RootView.on_mouse_pressed +function RootView:on_mouse_pressed(button, x, y, clicks) + if RootView_original_event(self, button, x, y, clicks) then + if clicks > 1 then + local node = self.root_node:get_child_overlapping_point(x, y) + local idx = node:get_tab_overlapping_point(x, y) + if idx then + node.views[idx].doc.ephemeral = false + end + end + return true + end +end -- cgit v1.2.3 From b561e4fc287e04d83d5374778dbeaeed4ee66850 Mon Sep 17 00:00:00 2001 From: Jipok Date: Sat, 11 Dec 2021 20:46:06 +0500 Subject: Rewrite ephemeral tabs plugin --- plugins/ephemeral_tabs.lua | 77 +++++++++++++++++++++++++++++++++++++++++++ plugins/ephemeraldocviews.lua | 70 --------------------------------------- 2 files changed, 77 insertions(+), 70 deletions(-) create mode 100644 plugins/ephemeral_tabs.lua delete mode 100644 plugins/ephemeraldocviews.lua (limited to 'plugins') diff --git a/plugins/ephemeral_tabs.lua b/plugins/ephemeral_tabs.lua new file mode 100644 index 0000000..5bfba6f --- /dev/null +++ b/plugins/ephemeral_tabs.lua @@ -0,0 +1,77 @@ +-- mod-version:2 -- lite-xl 2.0 +local core = require "core" +local command = require "core.command" +local RootView = require "core.rootview" +local DocView = require "core.docview" +local Doc = require "core.doc" +local TreeView = require "plugins.treeview" + +local RootView_open_doc = RootView.open_doc +function RootView:open_doc(doc) + local docview = RootView_open_doc(self, doc) + -- The absence of the ephemeral flag means that before this moment in this + -- node this document was not exists + if docview.ephemeral == nil then + local node = self:get_active_node_default() + -- We assume that ephemeral tab is always the last one + -- But user can drag and drop tabs so full check is needed + for i, v in ipairs(node.views) do + if v.ephemeral then + node:close_view(self.root_node, v) + end + end + docview.ephemeral = true + end + return docview +end + +local Doc_get_name = DocView.get_name +function DocView:get_name() + return self.doc and self.ephemeral and ("~ " .. Doc_get_name(self) .. " ~") + or Doc_get_name(self) +end + +-- Any change to the document makes the tab normal +local Doc_on_text_change = Doc.on_text_change +function Doc:on_text_change(type) + core.active_view.ephemeral = false + Doc_on_text_change(self, type) +end + +-- Double clicking in the TreeView makes the tab normal +local TreeView_on_mouse_pressed = TreeView.on_mouse_pressed +function TreeView:on_mouse_pressed(button, x, y, clicks) + TreeView_on_mouse_pressed(self, button, x, y, clicks) + if (clicks > 1) and (core.active_view.doc ~= nil) then + core.active_view.ephemeral = false + end +end + +-- Double clicking on a tab makes it normal +local RootView_on_mouse_pressed = RootView.on_mouse_pressed +function RootView:on_mouse_pressed(button, x, y, clicks) + if RootView_on_mouse_pressed(self, button, x, y, clicks) then + if clicks > 1 then + local node = self.root_node:get_child_overlapping_point(x, y) + local idx = node:get_tab_overlapping_point(x, y) + if idx then + node.views[idx].ephemeral = false + end + end + return true + end +end + +-- Dragging a tab makes it normal +local RootView_on_mouse_released = RootView.on_mouse_released +function RootView:on_mouse_released(button, x, y, ...) + if self.dragged_node then + if button == "left" then + if self.dragged_node.dragging then + local view = self.dragged_node.node.views[self.dragged_node.idx] + view.ephemeral = false + end + end + end + RootView_on_mouse_released(self, button, x, y, ...) +end diff --git a/plugins/ephemeraldocviews.lua b/plugins/ephemeraldocviews.lua deleted file mode 100644 index 1169d7f..0000000 --- a/plugins/ephemeraldocviews.lua +++ /dev/null @@ -1,70 +0,0 @@ --- mod-version:2 -- lite-xl 2.0 -local core = require "core" -local command = require "core.command" -local RootView = require "core.rootview" -local DocView = require "core.docview" -local Doc = require "core.doc" -local TreeView = require "plugins.treeview" - -local open_doc = RootView.open_doc -function RootView:open_doc(doc) - local node = self:get_active_node_default() - local ephemeral, existing_ephemeral = node.views, nil - for i, view in ipairs(node.views) do - if view.doc == doc then - ephemeral = false - end - if view.doc and view.doc.ephemeral then - existing_ephemeral = view - end - end - if ephemeral and existing_ephemeral then - node:close_view(self.root_node, existing_ephemeral) - end - local view = open_doc(self, doc) - if ephemeral then - view.doc.ephemeral = #node.views > 1 - end - return view -end - -local get_name = DocView.get_name -function DocView:get_name() - return self.doc and self.doc.ephemeral and ("~ " .. get_name(self) .. " ~") or get_name(self) -end - -local doc_insert = Doc.insert -function Doc:insert(...) - doc_insert(self, ...) - self.ephemeral = false -end - -local doc_remove = Doc.remove -function Doc:remove(...) - doc_remove(self, ...) - self.ephemeral = false -end - --- Double clicking in the TreeView makes the tab normal -local TreeView_original_event = TreeView.on_mouse_pressed -function TreeView:on_mouse_pressed(button, x, y, clicks) - TreeView_original_event(self, button, x, y, clicks) - if (clicks > 1) and (core.active_view.doc ~= nil) then - core.active_view.doc.ephemeral = false - end -end - --- Double clicking on a tab makes it normal -local RootView_original_event = RootView.on_mouse_pressed -function RootView:on_mouse_pressed(button, x, y, clicks) - if RootView_original_event(self, button, x, y, clicks) then - if clicks > 1 then - local node = self.root_node:get_child_overlapping_point(x, y) - local idx = node:get_tab_overlapping_point(x, y) - if idx then - node.views[idx].doc.ephemeral = false - end - end - return true - end -end -- cgit v1.2.3 From c883e1792a084c32ab79965c589e7f8e0e492958 Mon Sep 17 00:00:00 2001 From: Jipok Date: Sun, 12 Dec 2021 13:47:12 +0500 Subject: returns --- plugins/ephemeral_tabs.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/ephemeral_tabs.lua b/plugins/ephemeral_tabs.lua index 5bfba6f..e1505c3 100644 --- a/plugins/ephemeral_tabs.lua +++ b/plugins/ephemeral_tabs.lua @@ -41,10 +41,11 @@ end -- Double clicking in the TreeView makes the tab normal local TreeView_on_mouse_pressed = TreeView.on_mouse_pressed function TreeView:on_mouse_pressed(button, x, y, clicks) - TreeView_on_mouse_pressed(self, button, x, y, clicks) + local result = TreeView_on_mouse_pressed(self, button, x, y, clicks) if (clicks > 1) and (core.active_view.doc ~= nil) then core.active_view.ephemeral = false end + return result end -- Double clicking on a tab makes it normal @@ -60,6 +61,7 @@ function RootView:on_mouse_pressed(button, x, y, clicks) end return true end + return false end -- Dragging a tab makes it normal @@ -73,5 +75,5 @@ function RootView:on_mouse_released(button, x, y, ...) end end end - RootView_on_mouse_released(self, button, x, y, ...) + return RootView_on_mouse_released(self, button, x, y, ...) end -- cgit v1.2.3 From 72d30b00d6012d4ea432a5f680eac37040475279 Mon Sep 17 00:00:00 2001 From: Jipok Date: Sun, 12 Dec 2021 13:55:24 +0500 Subject: Support 2.0.3 --- plugins/ephemeral_tabs.lua | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'plugins') diff --git a/plugins/ephemeral_tabs.lua b/plugins/ephemeral_tabs.lua index e1505c3..dea4261 100644 --- a/plugins/ephemeral_tabs.lua +++ b/plugins/ephemeral_tabs.lua @@ -51,17 +51,15 @@ end -- Double clicking on a tab makes it normal local RootView_on_mouse_pressed = RootView.on_mouse_pressed function RootView:on_mouse_pressed(button, x, y, clicks) - if RootView_on_mouse_pressed(self, button, x, y, clicks) then - if clicks > 1 then - local node = self.root_node:get_child_overlapping_point(x, y) - local idx = node:get_tab_overlapping_point(x, y) - if idx then - node.views[idx].ephemeral = false - end + local result = RootView_on_mouse_pressed(self, button, x, y, clicks) + if clicks > 1 then + local node = self.root_node:get_child_overlapping_point(x, y) + local idx = node:get_tab_overlapping_point(x, y) + if idx then + node.views[idx].ephemeral = false end - return true end - return false + return result end -- Dragging a tab makes it normal -- cgit v1.2.3