home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 3
/
CDASC03.ISO
/
sorties
/
2078
/
abbrev.kml
< prev
next >
Wrap
Text File
|
1993-04-01
|
9KB
|
278 lines
: > expand abbreviations;
: > 0=Internal, 1=Select, 2=Common, 3=First, 4=Exact, 5=LongSel
:EXPABBR
'editv set RCD'; N0 = 0; if ARG() then N0 = ARG(1);
MSG = 'macro KEYMSG'; MSG 'expand'; 'refresh';
ALT = 'set alt' ALT.1() ALT.2();
$AS = 'set autosave' AUTOSAVE.1(); 'set autosave OFF';
$WW = 'set wordwrap' WORDWRAP.1(); WW = 'set wordwrap OFF';
'modify msgline'; $MSG = CMDLINE.3(); 'set msgline ON';
'modify case'; $CS = CMDLINE.3(); 'cmsg'; 'cursor home';
'set insertmode ON'; 'text '; E = COLUMN.1();
T = 'set word' WORD.1(); 'set word ALPHANUM'; 'sos cl cl startword';
if \ DATATYPE(FIELD.2(),'A') then
do; 'sos cl'; if SPACECHAR() then 'sos cr'; else 'sos startword'; end;
T; C = CURSOR.4(); $C = 'macro LOCATECURS' CURSOR.3() C FILEID.1();
ABB = SUBSTR(FIELD.1(),C,E-C-1);
'cursor cmdline'; 'point .WINDLINE'; N = N0; T = '+';
CLC = 'nomsg clocate'; CLH = 'clocate -//'; DCH = 'sos delchar'; TFD = 'nomsg tfind';
RDK = 'readv KEY'; RLK = 'macro LASTKEY'; RSB = 'reset BLOCK';
do forever
'editv getf ABBREV'.N; if ABBREV.N = '' then leave;
if POS('[',ABBREV.N) = 0 then
do
$A = 'kedit' ABBREV.N; $A '(profile HIDDEN';
if RC > 1 then leave; ABBREV.N = FILEID.1(); MEC = MARGINS.3();
if LENGTH( ABB ) < MARGINS.1() then MEC = -1;
I = 'set alt' ALT.1()+\FOCUSTOF() ALT.2();
if POS('+',MEC) > 0 then 'move 1 :0'; I;
if T = '+' then 'backward *'; else 'forward *';
EXP = 'macro ABBRMEC' (0+MEC) || ( CASE.2()<CASE.3() & DATATYPE(SUBSTR(ABB,1,1),'U') ) ZONE.1();
end
else if POS(' ',ABB) > 0 then
do
MEC = 0; STR = SUBSTR(ABBREV.N,2,LENGTH(ABBREV.N)-2);
end
else
MEC = -1;
if MEC = -1 then
$C;
else if MEC = 0 then
do
$WR = 'set wrap' WRAP.1(); 'set wrap OFF'; 'set case MIXED IGNORE';
'cursor home'; 'cdelete :'E;
L = '-'; ID = 0; IABB = SUBSTR(ABB,1,POS(' ',ABB)-1); S = IABB;
do forever
if L \= '' then CLC L''S''; if RC \= 0 then do; RSB; leave; end
if \ FIRST() then
do; 'sos cl'; if POS(FIELD.2(),STR) = 0 then iterate; 'sos cr'; end
RSB; 'mark STREAM';
'macro BYMODE \A-G\' SUBSTR('*',1+ID);
if SPACECHAR() then do; 'sos cl'; 'mark' BLOCK.1(); end
'sos blockstart'; 'editv getf ABBOPTI.'N;
if ABBOPTI.N \= '' then
do
K = BLOCK.3();
if \ ID then
if DATATYPE(SUBSTR(FIELD.1(),K,BLOCK.5()-K+1),ABBOPTI.N) then
iterate;
end
do forever
MSG WORD( 'identifier occurrence' , ID+1 ) 'TAB=up S-TAB=down C-TAB=mode CURU/D=scroll ENTER=this';
RDK; K = READV.1; L = '';
if K = 'TAB' then do; L = '-'; leave; end
else if K = 'S-TAB' then do; L = '+'; leave; end
else if K = 'CURD' then 'forward 1 line';
else if K = 'CURU' then 'backward 1 line';
else if K = 'C-TAB' | K = 'ESC' | K = 'ENTER' then leave;
end
if K = 'C-TAB' then
do
'sos blockstart'; K = BLOCK.3();
if ID then S = IABB;
else S = SUBSTR( FIELD.1() , K , BLOCK.5()-K+2 );
ID = \ ID; iterate;
end
if K = 'ESC' then RSB;
if K = 'ESC' | K = 'ENTER' then leave;
end
$C;
if BLOCK() then do; 'copy BLOCK'; RSB; T = 0; 'sos endword cr'; 'text '; end
else 'text' ABB'';
$WR; $CS;
end
else if MEC = 1 then
do forever
if T \= 0 then do; TFD T''ABB''; I = RC; end
if I = 0 then L = CURLINE.3(); else 'top';
$C; 'cdelete :'E; WW; if I \= 0 then do; 'text' ABB''; leave; end
EXP L; T = 0; E = COLUMN.1(); CLH; DCH;
MSG 'expand... TAB=next S-TAB=previous C-BKSP=delete ESC=exit';
RDK; K = READV.1; 'text '; if K = 'C-TAB' then leave;
if K = 'ESC' then do; T = 0; I = 1; end
else if K = 'TAB' then T = '+';
else if K = 'S-TAB' then T = '-';
else if K = 'C-BKSP' then T = 'D';
else do; RLK; leave; end
$A;
if T = 'D' then do; 'delete 1'; T = '-'; end
end
else if MEC = 2 then
do
S = ABB; P = '';
do forever
if S = '' then
'top';
else if T \= 0 then
do
TFD ''S'';
if RC = 0 then
do
'point .TOPMATCH'; L = CURLINE.3();
TFD '^'S''; if RC = 0 then 'up'; else 'bottom';
L1 = UPPER( L ); L2 = UPPER( CURLINE.3() );
if L1 = L2 then
T = 0;
else
do Y = LENGTH(S)+1
if SUBSTR(L1,Y,1) == SUBSTR(L2,Y,1) then iterate;
S = SUBSTR(L,1,Y-1); L = S''; P = S;
'locate .TOPMATCH'; 'up'; leave;
end
if SUBSTR( L , LENGTH( L ) ) = '' then
do
T = 1; TFD 'BLANK';
S = SUBSTR( L , 1 , LENGTH(L)-1 ); L = S'';
end
end
else if L1 = UPPER( L ) then
do; T = 0; RLK; end
else if P = '' then
do; T = '00'; L = ABB''; end
else
do
S = P; TFD ''S'';
if RC = 0 then do; T = 0; L = CURLINE.3(); RLK; end
else 'sos beep';
end
end
$C; 'cdelete :'E; WW;
if T \= 0 then 'text' L; else do; EXP L; leave; end
E = COLUMN.1(); CLH; DCH;
MSG 'expand... char=choice ESC=exit';
RDK; K = READV.1; 'text '; if K = 'C-TAB' then leave;
if K = 'ESC' then
do; T = '00'; S = ''; L = ABB''; end
else if K = 'ENTER' then
T = 0;
else
do
K = READV.2;
if K << ' ' | READV.3 > 57 then do; K = ''; RLK; end; S = S||K;
end
$A;
end
end
else if MEC = 3 then
do
TFD ''ABB''; if RC = 0 then T = 0; L = CURLINE.3();
$C; if T = 0 then do; 'cdelete :'E; WW; EXP L; end
end
else if MEC = 4 then
do forever
TFD ''ABB''; I = RC; if I = 0 then L = CURLINE.3(); else 'top';
$C; if I \= 0 then leave;
'set case MIXED IGNORE IGNORE'; EXP L; I = RC; $CS;
if I = 0 then do; T = 0; leave; end; $A;
end
else if MEC = 5 then
do
do forever
if T \= 0 then do; TFD T''ABB''; I = RC; end
if I = 0 then
do
L = CURLINE.3(); 'cursor column'; 'sos cdn firstcol';
'mark STREAM'; 'clocate //';
'sos cr'; Y = FIELD.2(); 'sos cl'; if FIRST() then Y = 'L';
if Y = 'L' then do; 'sos cup'; 'mark LINE'; end
else do; 'sos cl'; if Y = 'B' then 'mark BOX'; else 'mark STREAM'; end
end
else
'top';
$C; 'nomsg cdelete :'E; E = COLUMN.1(); WW;
if I \= 0 then do; 'text' ABB''; leave; end
EXP L; T = 0; CLH; DCH;
MSG 'expand... TAB=next S-TAB=previous ESC=exit';
RDK; K = READV.1; 'text '; if K = 'C-TAB' then leave;
if K = 'ESC' then do; T = 0; I = 1; end
else if K = 'TAB' then T = '+';
else if K = 'S-TAB' then T = '-';
else do; RLK; leave; end
'delete BLOCK'; $A;
end
RSB;
end
else
$C;
'editv putf ABBREV'.N;
if T = '+' then N = N+1; else if T = '-' then N = N-1;
if T = 0 | N < N0 then leave;
end
if T == '0' then
do
'set stream OFF'; 'sos firstchar'; if FIELD.2() = '' then DCH;
EDC = 'sos endchar'; EDC 'cl'; if FIELD.2() = '' then DCH;
do forever
EDC; CLC '-//'; if RC \= 0 then leave;
DCH; 'split aligned'; 'down';
do forever
EDC; CLC '-//'; if RC \= 0 then leave; DCH; 'sos instab';
end
'up';
end
end
else
'sos beep';
$C; 'set stream ON'; 'clocate //'; DCH;
$WW; 'text '; 'sos delback'; 'cdelete 0'; ALT; $AS; $MSG;
: > hook for variants of mecanisms
:ABBRMEC
Z = WORD( ARG(1) , 2 );
V = SUBSTR( ARG(1) , 6 , Z-1 ); V = SUBSTR( V , 1 , POS( ' ' , V' ' ) );
'macro ABBRMEC'WORD( ARG(1) , 1 ) || V || SUBSTR( ARG(1) , Z+5 );
: > default mecanisms
:ABBRMEC10
'macro USEASCII text #'SUBSTR( ARG(1) , POS( '' , ARG(1) ) + 1 );
:ABBRMEC11
'macro CONVNAT U 2 macro USEASCII text ##'SUBSTR( ARG(1) , POS( '' , ARG(1) ) + 1 );
:ABBRMEC20
'text 'SUBSTR( ARG(1) , POS( '' , ARG(1) ) + 1 );
:ABBRMEC21
'macro ABBRMEC20' UPPER( ARG(1) );
:ABBRMEC30
'macro ABBRMEC20' ARG(1);
:ABBRMEC31
'macro ABBRMEC20' UPPER( ARG(1) );
:ABBRMEC40
'nomsg change'ARG(1);
:ABBRMEC41
'nomsg change'UPPER( ARG(1) );
:ABBRMEC50
if \ AFTER() & BLOCK.1() = 'LINE' then 'split aligned';
'copy BLOCK'; 'sos blockend endchar';
'msg 'SUBSTR( ARG(1) , MAX( 2 , POS( '' , ARG(1) , 2 ) + 1 ) );
: > show abbreviations
:ALLABBR
$F = 'macro LOCATECURS -1 1' FILEID.1(); 'point .WINDLINE';
C = 1; M = 'msg ALLABBR'; T = ARG(1); N = WORD( T , 1 );
if DATATYPE( N , 'N' ) then T = SUBSTR( T , POS( ' ' , T ) + 1 );
else N = 0;
do N = N
'editv getf ABBREV'.N; if ABBREV.N = '' then leave;
'kedit' ABBREV.N '(profile HIDDEN'; if RC \= 0 then leave;
I = 'set alt' ALT.1()+\FOCUSTOF() ALT.2();
if POS( '+' , MARGINS.3() ) > 0 then 'move 1 :0'; I;
ABBREV.N = FILEID.1(); 'nomsg all' T;
if RC = 0 then
do forever
M 'SPACE=next CURU/D=scroll PLUS=input ESC=end BKSP=quit' T 'matches';
C = 0; RDK; K = READV.1;
if K = 'ESC' | K = 'SPACE' then
leave;
else if K = 'BKSP' then
do; 'quit'; leave; end
else if K = 'CURU' then
'backward 1 line';
else if K = 'CURD' then
'forward 1 line';
else if K = 'PLUS' & CASE.1() = 'MIXED' then
do
M 'input:'; 'readv CMD';
if READV.1 \= '' then 'input' READV.1;
end
end
'all'; 'top'; $F; 'editv putf ABBREV.'N;
if K = 'ESC' | K = 'BKSP' then leave;
end
if C then M 'no match -' N 'file(s)';