Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<farconfig>
<macros>
<keymacros>
<macro area="Editor" key="AltShiftI" flags="DisableOutput|EVSelection" description="Движение текста в вертикальном блоке. © SimSU ¡ Max Rusov">
<text>
<![CDATA[
%comment="Движение текста в вертикальном блоке вправо. © SimSU ¡ Max Rusov";
%comment="Назначается, напримен на AltShiftI в редакторе.";
editor.undo(0)
%comment="Запомним состояние редактора.";
%Y0=editor.pos(0,4); %X0=editor.pos(0,5); %comment="Координаты экрана.";
%Yc=editor.pos(0,1); %Xc=editor.pos(0,3); %Xs=editor.pos(0,2); %comment="Координаты курсора в тексте.";
%St=editor.sel(0,4); %Yb=iif(%St==0,%Yc,editor.sel(0,0)); %Xb=iif(%St==0,%Xc,editor.sel(0,1)); %Ye=iif(%St==0,%Yc,editor.sel(0,2)); %Xe=iif(%St==0,%Xc,editor.sel(0,3)); %comment="Тип и координаты выделения.";
%Sd=%Ye-%Yb+1; %comment="Число строк с выделением, если выделения нет, то посчитаем одну строку с курсором.";
%Sl=iif(%St==0 || (%St>0 && %Yc<=%Ye && %Yc>=%Yb),1,0); %comment="Курсор в строках где есть выделение.";
%Sp=iif(%Sl==1 && ((%Xc<=%Xe && %Xc>=%Xb) || (%St==1 && %Yc<%Ye && %Yc>%Yb)),1,0); %comment="Курсор точно в выделении.";
%Sb=iif(%St==1 && %Xe==1,1,0); %comment="Выделен обычный блок, но в последней строке нет выделенных символов.";
%Se=iif(%St==2 && %Xe==%Xb,1,0); %comment="Выделен вертикальный блок 0 ширены - нет выделенных символов.";
$IF (%St==2 && %Sp==1 && %Se!=1 ) %comment="Курсор в вертикальном блоке не 0 ширены";
%txt=Editor.SelValue;
%ntxt=""; %changed=0;
%len=%Xe-%Xb;
%beg=0;
$REP (%Sd)
%str=substr(%txt,%beg,%len);
$IF (substr(%str,%len-1,1)==" ")
%str=" "+%str;
%changed=1;
$END
%ntxt=%ntxt+%str+"\n";
%beg=%beg+%len+2;
$END
$IF (%changed==1)
ShiftF4 Enter print(%ntxt)
editor.pos(1,1,1) editor.pos(1,2,1) editor.sel(3,0)
editor.pos(1,1,%Sd) editor.pos(1,2,%len+1) editor.sel(3,1)
%CT=clip(5,2); %CV=clip(0);
CtrlC F4 Tab Enter
CtrlD CtrlV
clip(1,%CV) clip(5,%CT)
$END
$END
%comment="Восстановим состояние редактора.";
$IF (%St!=0) editor.pos(1,1,%Yb) editor.pos(1,4-%St,%Xb) editor.sel(%St+1,0) editor.pos(1,1,%Ye) editor.pos(1,4-%St,%Xe) editor.sel(%St+1,1) $END %comment="Выделение.";
editor.pos(1,4,%Y0) editor.pos(4,5,%X0) %comment="Координаты экрана.";
editor.pos(1,1,%Yc) editor.pos(1,3,%Xc) %comment="Координаты курсора в тексте.";
editor.undo(1)
]]>
</text>
</macro>
<macro area="Editor" key="AltShiftU" flags="DisableOutput|EVSelection" description="Движение текста в вертикальном блоке. © SimSU ¡ Max Rusov">
<text>
<![CDATA[
%comment="Движение текста в вертикальном блоке влево. © SimSU ¡ Max Rusov";
%comment="Назначается, напримен на AltShiftU в редакторе.";
editor.undo(0)
%comment="Запомним состояние редактора.";
%Y0=editor.pos(0,4); %X0=editor.pos(0,5); %comment="Координаты экрана.";
%Yc=editor.pos(0,1); %Xc=editor.pos(0,3); %Xs=editor.pos(0,2); %comment="Координаты курсора в тексте.";
%St=editor.sel(0,4); %Yb=iif(%St==0,%Yc,editor.sel(0,0)); %Xb=iif(%St==0,%Xc,editor.sel(0,1)); %Ye=iif(%St==0,%Yc,editor.sel(0,2)); %Xe=iif(%St==0,%Xc,editor.sel(0,3)); %comment="Тип и координаты выделения.";
%Sd=%Ye-%Yb+1; %comment="Число строк с выделением, если выделения нет, то посчитаем одну строку с курсором.";
%Sl=iif(%St==0 || (%St>0 && %Yc<=%Ye && %Yc>=%Yb),1,0); %comment="Курсор в строках где есть выделение.";
%Sp=iif(%Sl==1 && ((%Xc<=%Xe && %Xc>=%Xb) || (%St==1 && %Yc<%Ye && %Yc>%Yb)),1,0); %comment="Курсор точно в выделении.";
%Sb=iif(%St==1 && %Xe==1,1,0); %comment="Выделен обычный блок, но в последней строке нет выделенных символов.";
%Se=iif(%St==2 && %Xe==%Xb,1,0); %comment="Выделен вертикальный блок 0 ширены - нет выделенных символов.";
$IF (%St==2 && %Sp==1 && %Se!=1 ) %comment="Курсор в вертикальном блоке не 0 ширены";
%txt=Editor.SelValue;
%ntxt=""; %changed=0;
%len=%Xe-%Xb;
%beg=0;
$REP (%Sd)
%str=substr(%txt,%beg,%len);
$IF (substr(%str,0,1)!=" ")
%str=" "+%str;
$ELSE
%changed=1;
$END
%ntxt=%ntxt+%str+"\n";
%beg=%beg+%len+2;
$END
$IF (%changed==1)
ShiftF4 Enter print(%ntxt)
editor.pos(1,1,1) editor.pos(1,2,2) editor.sel(3,0)
editor.pos(1,1,%Sd) editor.pos(1,2,%len+2) editor.sel(3,1)
%CT=clip(5,2); %CV=clip(0);
CtrlC F4 Tab Enter
CtrlD CtrlV
clip(1,%CV) clip(5,%CT)
$END
$END
%comment="Восстановим состояние редактора.";
$IF (%St!=0) editor.pos(1,1,%Yb) editor.pos(1,4-%St,%Xb) editor.sel(%St+1,0) editor.pos(1,1,%Ye) editor.pos(1,4-%St,%Xe) editor.sel(%St+1,1) $END %comment="Выделение.";
editor.pos(1,4,%Y0) editor.pos(4,5,%X0) %comment="Координаты экрана.";
editor.pos(1,1,%Yc) editor.pos(1,3,%Xc) %comment="Координаты курсора в тексте.";
editor.undo(1)
]]>
</text>
</macro>
</keymacros>
</macros>
</farconfig>