From 11df72216271ce015ef2fc48572f231d8df097af Mon Sep 17 00:00:00 2001 From: rxi Date: Sun, 21 Jun 2020 19:38:42 +0100 Subject: [PATCH 1/5] Version 1.09 --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index a17c60e6..8f853ff2 100644 --- a/src/main.c +++ b/src/main.c @@ -102,7 +102,7 @@ int main(int argc, char **argv) { } lua_setglobal(L, "ARGS"); - lua_pushstring(L, "1.08"); + lua_pushstring(L, "1.09"); lua_setglobal(L, "VERSION"); lua_pushstring(L, SDL_GetPlatform()); From 53d555b362f10044b473d452220d85c943f3dfd2 Mon Sep 17 00:00:00 2001 From: rxi Date: Thu, 25 Jun 2020 13:33:38 +0100 Subject: [PATCH 2/5] Added support for mouse double/triple click+drag selection Resolves #159 Resolves #161 --- data/core/docview.lua | 53 +++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/data/core/docview.lua b/data/core/docview.lua index 371f9c36..ef931ed4 100644 --- a/data/core/docview.lua +++ b/data/core/docview.lua @@ -192,28 +192,42 @@ function DocView:scroll_to_make_visible(line, col) end +local function mouse_selection(doc, clicks, line1, col1, line2, col2) + local swap = line2 < line1 or line2 == line1 and col2 <= col1 + if swap then + line1, col1, line2, col2 = line2, col2, line1, col1 + end + if clicks == 2 then + line1, col1 = translate.start_of_word(doc, line1, col1) + line2, col2 = translate.end_of_word(doc, line2, col2) + elseif clicks == 3 then + if line2 == #doc.lines and doc.lines[#doc.lines] ~= "\n" then + doc:insert(math.huge, math.huge, "\n") + end + line1, col1, line2, col2 = line1, 1, line2 + 1, 1 + end + if swap then + return line2, col2, line1, col1 + end + return line1, col1, line2, col2 +end + + function DocView:on_mouse_pressed(button, x, y, clicks) local caught = DocView.super.on_mouse_pressed(self, button, x, y, clicks) if caught then return end - local line, col = self:resolve_screen_position(x, y) - if clicks == 2 then - local line1, col1 = translate.start_of_word(self.doc, line, col) - local line2, col2 = translate.end_of_word(self.doc, line, col) - self.doc:set_selection(line2, col2, line1, col1) - elseif clicks == 3 then - if line == #self.doc.lines then - self.doc:insert(math.huge, math.huge, "\n") + if keymap.modkeys["shift"] then + if clicks == 1 then + local line, col = self.doc:get_selection() + self.mouse_selecting = { line, col, clicks = 1 } + self:on_mouse_moved(x, y) end - self.doc:set_selection(line + 1, 1, line, 1) else - local line2, col2 - if keymap.modkeys["shift"] then - line2, col2 = select(3, self.doc:get_selection()) - end - self.doc:set_selection(line, col, line2, col2) - self.mouse_selecting = true + local line, col = self:resolve_screen_position(x, y) + self.doc:set_selection(mouse_selection(self.doc, clicks, line, col, line, col)) + self.mouse_selecting = { line, col, clicks = clicks } end self.blink_timer = 0 end @@ -229,16 +243,17 @@ function DocView:on_mouse_moved(x, y, ...) end if self.mouse_selecting then - local _, _, line2, col2 = self.doc:get_selection() - local line1, col1 = self:resolve_screen_position(x, y) - self.doc:set_selection(line1, col1, line2, col2) + local l1, c1 = self:resolve_screen_position(x, y) + local l2, c2 = table.unpack(self.mouse_selecting) + local clicks = self.mouse_selecting.clicks + self.doc:set_selection(mouse_selection(self.doc, clicks, l1, c1, l2, c2)) end end function DocView:on_mouse_released(button) DocView.super.on_mouse_released(self, button) - self.mouse_selecting = false + self.mouse_selecting = nil end From 094cf0cc2cc5a91241994d93c06c0e22c62dbb86 Mon Sep 17 00:00:00 2001 From: rxi Date: Fri, 26 Jun 2020 10:44:56 +0100 Subject: [PATCH 3/5] Fixed shift+click select behavior --- data/core/docview.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/core/docview.lua b/data/core/docview.lua index ef931ed4..73191c23 100644 --- a/data/core/docview.lua +++ b/data/core/docview.lua @@ -220,9 +220,9 @@ function DocView:on_mouse_pressed(button, x, y, clicks) end if keymap.modkeys["shift"] then if clicks == 1 then - local line, col = self.doc:get_selection() - self.mouse_selecting = { line, col, clicks = 1 } - self:on_mouse_moved(x, y) + local line1, col1 = select(3, self.doc:get_selection()) + local line2, col2 = self:resolve_screen_position(x, y) + self.doc:set_selection(line2, col2, line1, col1) end else local line, col = self:resolve_screen_position(x, y) From 87532a4b3ae4a0398da933bf8ec924aaec791dfb Mon Sep 17 00:00:00 2001 From: rxi Date: Sun, 28 Jun 2020 14:40:07 +0100 Subject: [PATCH 4/5] Version 1.10 --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 8f853ff2..9092368c 100644 --- a/src/main.c +++ b/src/main.c @@ -102,7 +102,7 @@ int main(int argc, char **argv) { } lua_setglobal(L, "ARGS"); - lua_pushstring(L, "1.09"); + lua_pushstring(L, "1.10"); lua_setglobal(L, "VERSION"); lua_pushstring(L, SDL_GetPlatform()); From 99831bbc29122b42491ba0814355cef56a3640e8 Mon Sep 17 00:00:00 2001 From: rxi Date: Wed, 1 Jul 2020 09:24:39 +0100 Subject: [PATCH 5/5] Added lua5.4 attribute support to `language_lua` --- data/plugins/language_lua.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/data/plugins/language_lua.lua b/data/plugins/language_lua.lua index c577a28f..915d2732 100644 --- a/data/plugins/language_lua.lua +++ b/data/plugins/language_lua.lua @@ -13,6 +13,7 @@ syntax.add { { pattern = "-?0x%x+", type = "number" }, { pattern = "-?%d+[%d%.eE]*", type = "number" }, { pattern = "-?%.?%d+", type = "number" }, + { pattern = "<%a+>", type = "keyword2" }, { pattern = "%.%.%.?", type = "operator" }, { pattern = "[<>~=]=", type = "operator" }, { pattern = "[%+%-=/%*%^%%#<>]", type = "operator" },