mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-30 14:47:16 +09:00
Pass the view into plugin callbacks
This commit is contained in:
@@ -9,12 +9,11 @@ end
|
||||
local autoclosePairs = {"\"\"", "''", "()", "{}", "[]"}
|
||||
local autoNewlinePairs = {"()", "{}", "[]"}
|
||||
|
||||
function onRune(r)
|
||||
function onRune(r, v)
|
||||
if not GetOption("autoclose") then
|
||||
return
|
||||
end
|
||||
|
||||
local v = CurView()
|
||||
for i = 1, #autoclosePairs do
|
||||
if r == charAt(autoclosePairs[i], 2) then
|
||||
local curLine = v.Buf:Line(v.Cursor.Y)
|
||||
@@ -43,12 +42,11 @@ function onRune(r)
|
||||
end
|
||||
end
|
||||
|
||||
function preInsertNewline()
|
||||
function preInsertNewline(v)
|
||||
if not GetOption("autoclose") then
|
||||
return
|
||||
end
|
||||
|
||||
local v = CurView()
|
||||
local curLine = v.Buf:Line(v.Cursor.Y)
|
||||
local curRune = charAt(curLine, v.Cursor.X)
|
||||
local nextRune = charAt(curLine, v.Cursor.X+1)
|
||||
@@ -68,13 +66,11 @@ function preInsertNewline()
|
||||
return true
|
||||
end
|
||||
|
||||
function preBackspace()
|
||||
function preBackspace(v)
|
||||
if not GetOption("autoclose") then
|
||||
return
|
||||
end
|
||||
|
||||
local v = CurView()
|
||||
|
||||
for i = 1, #autoclosePairs do
|
||||
local curLine = v.Buf:Line(v.Cursor.Y)
|
||||
if charAt(curLine, v.Cursor.X+1) == charAt(autoclosePairs[i], 2) and charAt(curLine, v.Cursor.X) == charAt(autoclosePairs[i], 1) then
|
||||
|
||||
Reference in New Issue
Block a user