Skip to content

Commit

Permalink
Add mouse support
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolaiSoeborg committed Oct 24, 2017
1 parent 580c2c2 commit a94f36e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
21 changes: 15 additions & 6 deletions filemanager.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = "2.0.0"
VERSION = "2.1.0"

treeView = nil
cwd = WorkingDirectory()
Expand Down Expand Up @@ -72,6 +72,7 @@ function getSelection()
end

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

-- mouse callback from micro editor when a left button is clicked on your view
function onMousePress(view, event)
function preMousePress(view, event)
if view == treeView then -- check view is tree as only want inputs from that view.
local columns, rows = event:Position()
debug("INFO: --> Mouse pressed -> columns location rows location -> ",columns,rows)
return false
return true
end
end
function onMousePress(view, event)
if view == treeView then
selectLineInTree(view)
preInsertNewline(view)
return false
end
end


-- disallow selecting topmost line in treeView:
function preCursorUp(view)
if view == treeView then
debug("***** preCursor(view) *****")
debug("***** preCursor() *****")
if view.Cursor.Loc.Y == 1 then
return false
end end end

-- allows for deleting files
function preDelete(view)
if view == treeView then
if debug == true then messenger:AddLog("***** preDelete(view) *****") end
if debug == true then messenger:AddLog("***** preDelete() *****") end
local selected = getSelection()
if selected == ".." then return false end
local type, command
Expand Down Expand Up @@ -203,4 +212,4 @@ end

-- micro editor commands
MakeCommand("tree", "filemanager.ToggleTree", 0)
AddRuntimeFile("filemanager", "syntax", "syntax.yaml")
AddRuntimeFile("filemanager", "syntax", "syntax.yaml")
4 changes: 2 additions & 2 deletions repo.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"Tags": ["filetree", "filemanager", "file", "manager"],
"Versions": [
{
"Version": "2.0.0",
"Url": "https://github.com/NicolaiSoeborg/filemanager-plugin/archive/v2.0.0.zip",
"Version": "2.1.0",
"Url": "https://github.com/NicolaiSoeborg/filemanager-plugin/archive/v2.1.0.zip",
"Require": {
"micro": ">=1.3.2"
}
Expand Down

0 comments on commit a94f36e

Please sign in to comment.