--[[-------------------------------------------------- MoveLines.lua Authors: codewarlock1101 Version: 1.1 ------------------------------------------------------ Description: Перемещение выделенных строк (или 1 строки) вверх, вниз, вправо, влево перемещение выделенного стринга по строке вправо и влево ------------------------------------------------------ * PIE_MOVE_TYPE * 0 Не премещать * 1 Для цикличного перемещения по соседним строкам * 2 Для цикличного перемещения по одной строке * 3 блокировка цикличности --]]-------------------------------------------------- local PIE_MOVE_TYPE=2 local sel_start_line = editor:LineFromPosition(editor.SelectionStart) local sel_end_line = editor:LineFromPosition(editor.SelectionEnd-1) local slend=editor:GetLineSelEndPosition(sel_end_line) local slend2=editor:GetLineSelEndPosition(sel_end_line-1) local sel_txt=editor:GetSelText() local nap=0 if slend==slend2 then nap=1 end local anti_nap=math.abs(nap-1) if horizontal==1 then if PIE_MOVE_TYPE==0 or (sel_start_line~=sel_end_line or sel_txt=="" or (editor:PositionFromLine(sel_start_line)==editor.SelectionStart and editor.LineEndPosition[sel_end_line]==editor.SelectionEnd)) then for i = sel_start_line, sel_end_line-nap do if string.gsub(editor:textrange(editor:PositionFromLine(i),editor.LineEndPosition[i]),' ','')~='' then editor.LineIndentation [i]=editor.LineIndentation [i]+vertical*(-1) end end else if editor.SelectionStart~=0 or vertical==-1 then editor:ReplaceSel('') if editor.SelectionStart==editor:PositionFromLine(sel_start_line) and vertical==1 then if PIE_MOVE_TYPE==1 then editor:CharLeft() end if PIE_MOVE_TYPE==1 or PIE_MOVE_TYPE==3 then editor.SelectionStart=editor.SelectionStart+vertical end if PIE_MOVE_TYPE==2 then editor.SelectionStart=editor.LineEndPosition[sel_end_line]+vertical end end if editor.SelectionStart==editor.LineEndPosition[sel_start_line] and vertical==-1 then if PIE_MOVE_TYPE==1 then editor:CharRight() end if PIE_MOVE_TYPE==1 or PIE_MOVE_TYPE==3 then editor.SelectionStart=editor.SelectionStart+vertical end if PIE_MOVE_TYPE==2 then editor.SelectionStart=editor:PositionFromLine(sel_start_line)+vertical end end editor.SelectionStart=editor.SelectionStart+(-1)*vertical local strt=editor.SelectionStart editor:InsertText(editor.SelectionStart, sel_txt) if vertical==1 then editor.SelectionEnd=editor.SelectionStart-1 editor.SelectionStart=editor.SelectionStart-string.len(sel_txt) else editor.SelectionStart=strt editor.SelectionEnd=editor.SelectionStart+string.len(sel_txt) end end 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 vertical==1 then if sel_end_line-nap0 and vertical==-1) or (sel_end_line-nap