Небольшое дополнение... Теперь выдеделние внутри строки не снимается, когда перемещаешь одну строку.
Код:
local sel_start_line = editor:LineFromPosition(editor.SelectionStart)
local sel_end_line = editor:LineFromPosition(editor.SelectionEnd)
local slend=editor:GetLineSelEndPosition(sel_end_line)
local slend2=editor:GetLineSelEndPosition(sel_end_line-1)
local nap=0
local sel_txt=editor:GetSelText()
if slend==slend2 then
nap=1
end
if gorizont==1 then
for i = sel_start_line, sel_end_line-nap do
editor.LineIndentation [i]=editor.LineIndentation [i]+-1*d
end
else
if (sel_txt == "") or (sel_start_line==sel_end_line) then
local xsel_s=editor.SelectionStart-editor:PositionFromLine(sel_start_line)
local xsel_e=editor.SelectionEnd-editor:PositionFromLine(sel_end_line)
if d==1 then
if sel_end_line-nap<editor.LineCount-1 then
editor:LineDown()
editor:LineTranspose()
else
d=0
end
else
editor:LineTranspose()
editor:LineUp()
end
if (sel_txt ~= "") then
xsel_s = editor:PositionFromLine(sel_start_line+d)+xsel_s
xsel_e = xsel_s + string.len(sel_txt)
editor:SetSel(xsel_s,xsel_e)
end
else
if (sel_start_line>0 and d==-1) or (sel_end_line-nap<editor.LineCount-1 and d==1) then
editor:BeginUndoAction()
if d==1 then
-- Down
editor:GotoLine(sel_end_line)
for i = sel_end_line-nap, sel_start_line, -1 do
editor:LineTranspose()
editor:LineUp()
end
else
-- Up
editor:GotoLine(sel_start_line)
for i = sel_start_line, sel_end_line-nap do
editor:LineTranspose()
editor:LineDown()
end
end
local sel_start = editor:PositionFromLine(sel_start_line+d)
nap=math.abs(nap-1)
local sel_end = editor:PositionFromLine(sel_end_line+d+nap)
editor:SetSel(sel_start,sel_end)
editor:EndUndoAction()
end
end
end
Код:
local sel_start_line = editor:LineFromPosition(editor.SelectionStart)
local sel_end_line = editor:LineFromPosition(editor.SelectionEnd)
local slend=editor:GetLineSelEndPosition(sel_end_line)
local slend2=editor:GetLineSelEndPosition(sel_end_line-1)
local nap=0
local sel_txt=editor:GetSelText()
if slend==slend2 then
nap=1
end
if gorizont==1 then
for i = sel_start_line, sel_end_line-nap do
editor.LineIndentation [i]=editor.LineIndentation [i]+-1*d
end
else
if (sel_txt == "") or (sel_start_line==sel_end_line) then
local xsel_s=editor.SelectionStart-editor:PositionFromLine(sel_start_line)
local xsel_e=editor.SelectionEnd-editor:PositionFromLine(sel_end_line)
if d==1 then
if sel_end_line-nap<editor.LineCount-1 then
editor:LineDown()
editor:LineTranspose()
else
d=0
end
else
editor:LineTranspose()
editor:LineUp()
end
if (sel_txt ~= "") then
xsel_s = editor:PositionFromLine(sel_start_line+d)+xsel_s
xsel_e = xsel_s + string.len(sel_txt)
editor:SetSel(xsel_s,xsel_e)
end
else
if (sel_start_line>0 and d==-1) or (sel_end_line-nap<editor.LineCount-1 and d==1) then
editor:BeginUndoAction()
if d==1 then
-- Down
editor:GotoLine(sel_end_line)
for i = sel_end_line-nap, sel_start_line, -1 do
editor:LineTranspose()
editor:LineUp()
end
else
-- Up
editor:GotoLine(sel_start_line)
for i = sel_start_line, sel_end_line-nap do
editor:LineTranspose()
editor:LineDown()
end
end
local sel_start = editor:PositionFromLine(sel_start_line+d)
nap=math.abs(nap-1)
local sel_end = editor:PositionFromLine(sel_end_line+d+nap)
editor:SetSel(sel_start,sel_end)
editor:EndUndoAction()
end
end
end