Merge remote-tracking branch 'rxi/master'

This commit is contained in:
Francesco Abbate 2020-07-04 22:08:25 +02:00
commit 14ec61511d
3 changed files with 36 additions and 20 deletions

View File

@ -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")
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())
if clicks == 1 then
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
self.doc:set_selection(line, col, line2, col2)
self.mouse_selecting = true
else
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

View File

@ -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" },

View File

@ -102,7 +102,7 @@ int main(int argc, char **argv) {
}
lua_setglobal(L, "ARGS");
lua_pushstring(L, "1.08");
lua_pushstring(L, "1.10");
lua_setglobal(L, "VERSION");
lua_pushstring(L, SDL_GetPlatform());