Skip to content

Commit a94f36e

Browse files
Add mouse support
1 parent 580c2c2 commit a94f36e

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

filemanager.lua

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = "2.0.0"
1+
VERSION = "2.1.0"
22

33
treeView = nil
44
cwd = WorkingDirectory()
@@ -72,6 +72,7 @@ function getSelection()
7272
end
7373

7474
-- don't use built-in view.Cursor:SelectLine() as it will copy to clipboard (in old versions of Micro)
75+
-- TODO: We require micro >= 1.3.2, so is this still an issue?
7576
function selectLineInTree(view)
7677
if view == treeView then
7778
debug("***** selectLineInTree() *****")
@@ -86,26 +87,34 @@ function onCursorDown(view) selectLineInTree(view) end
8687
function onCursorUp(view) selectLineInTree(view) end
8788

8889
-- mouse callback from micro editor when a left button is clicked on your view
89-
function onMousePress(view, event)
90+
function preMousePress(view, event)
9091
if view == treeView then -- check view is tree as only want inputs from that view.
9192
local columns, rows = event:Position()
9293
debug("INFO: --> Mouse pressed -> columns location rows location -> ",columns,rows)
93-
return false
94+
return true
9495
end
9596
end
97+
function onMousePress(view, event)
98+
if view == treeView then
99+
selectLineInTree(view)
100+
preInsertNewline(view)
101+
return false
102+
end
103+
end
104+
96105

97106
-- disallow selecting topmost line in treeView:
98107
function preCursorUp(view)
99108
if view == treeView then
100-
debug("***** preCursor(view) *****")
109+
debug("***** preCursor() *****")
101110
if view.Cursor.Loc.Y == 1 then
102111
return false
103112
end end end
104113

105114
-- allows for deleting files
106115
function preDelete(view)
107116
if view == treeView then
108-
if debug == true then messenger:AddLog("***** preDelete(view) *****") end
117+
if debug == true then messenger:AddLog("***** preDelete() *****") end
109118
local selected = getSelection()
110119
if selected == ".." then return false end
111120
local type, command
@@ -203,4 +212,4 @@ end
203212

204213
-- micro editor commands
205214
MakeCommand("tree", "filemanager.ToggleTree", 0)
206-
AddRuntimeFile("filemanager", "syntax", "syntax.yaml")
215+
AddRuntimeFile("filemanager", "syntax", "syntax.yaml")

repo.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"Tags": ["filetree", "filemanager", "file", "manager"],
55
"Versions": [
66
{
7-
"Version": "2.0.0",
8-
"Url": "https://github.com/NicolaiSoeborg/filemanager-plugin/archive/v2.0.0.zip",
7+
"Version": "2.1.0",
8+
"Url": "https://github.com/NicolaiSoeborg/filemanager-plugin/archive/v2.1.0.zip",
99
"Require": {
1010
"micro": ">=1.3.2"
1111
}

0 commit comments

Comments
 (0)