Moved commands out to the outer event loop.
This commit is contained in:
parent
6f53ee1b69
commit
ce2ec9f442
|
@ -389,6 +389,12 @@ local commands = {
|
|||
core.log("Removed \"%s\"", filename)
|
||||
end,
|
||||
|
||||
["doc:select-to-cursor"] = function(x, y, clicks)
|
||||
local line1, col1 = select(3, doc():get_selection())
|
||||
local line2, col2 = dv():resolve_screen_position(x, y)
|
||||
doc():set_selection(line2, col2, line1, col1)
|
||||
end,
|
||||
|
||||
["doc:set-cursor"] = function(x, y, clicks)
|
||||
local line, col = dv():resolve_screen_position(x, y)
|
||||
doc():set_selection(line, col, line, col)
|
||||
|
|
|
@ -922,7 +922,9 @@ function core.on_event(type, ...)
|
|||
elseif type == "mousemoved" then
|
||||
core.root_view:on_mouse_moved(...)
|
||||
elseif type == "mousepressed" then
|
||||
core.root_view:on_mouse_pressed(...)
|
||||
if not core.root_view:on_mouse_pressed(...) then
|
||||
did_keymap = keymap.on_mouse_pressed(...)
|
||||
end
|
||||
elseif type == "mousereleased" then
|
||||
core.root_view:on_mouse_released(...)
|
||||
elseif type == "mousewheel" then
|
||||
|
|
|
@ -96,6 +96,8 @@ local function keymap_macos(keymap)
|
|||
["shift+lclick"] = "doc:select-to-cursor",
|
||||
["ctrl+lclick"] = "doc:split-cursor",
|
||||
["lclick"] = "doc:set-cursor",
|
||||
["dlclick"] = "doc:select-word",
|
||||
["tlclick"] = "doc:select-lines",
|
||||
["shift+left"] = "doc:select-to-previous-char",
|
||||
["shift+right"] = "doc:select-to-next-char",
|
||||
["shift+up"] = "doc:select-to-previous-line",
|
||||
|
|
|
@ -85,6 +85,10 @@ function keymap.on_key_pressed(k, ...)
|
|||
return false
|
||||
end
|
||||
|
||||
local click_prefixes = { "", "d", "t" }
|
||||
function keymap.on_mouse_pressed(button, x, y, clicks)
|
||||
return keymap.on_key_pressed(click_prefixes[((clicks - 1) % 3) + 1] .. button:sub(1,1) .. "click", x, y, clicks)
|
||||
end
|
||||
|
||||
function keymap.on_key_released(k)
|
||||
local mk = modkey_map[k]
|
||||
|
|
|
@ -3,7 +3,7 @@ local config = require "core.config"
|
|||
local style = require "core.style"
|
||||
local common = require "core.common"
|
||||
local Object = require "core.object"
|
||||
local keymap = require "core.keymap"
|
||||
|
||||
|
||||
local View = Object:extend()
|
||||
|
||||
|
@ -76,13 +76,11 @@ function View:scrollbar_overlaps_point(x, y)
|
|||
end
|
||||
|
||||
|
||||
local click_prefixes = { "", "d", "t" }
|
||||
function View:on_mouse_pressed(button, x, y, clicks)
|
||||
if self:scrollbar_overlaps_point(x, y) then
|
||||
self.dragging_scrollbar = true
|
||||
return true
|
||||
end
|
||||
return keymap.on_key_pressed(click_prefixes[((clicks - 1) % 3) + 1] .. button:sub(1,1) .. "click", x, y, clicks)
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -18,9 +18,11 @@ extern SDL_Window *window;
|
|||
|
||||
static const char* button_name(int button) {
|
||||
switch (button) {
|
||||
case 1 : return "left";
|
||||
case 2 : return "middle";
|
||||
case 3 : return "right";
|
||||
case SDL_BUTTON_LEFT : return "left";
|
||||
case SDL_BUTTON_MIDDLE : return "middle";
|
||||
case SDL_BUTTON_RIGHT : return "right";
|
||||
case SDL_BUTTON_X1 : return "x1";
|
||||
case SDL_BUTTON_X2 : return "x2";
|
||||
default : return "?";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue