Procedure search_replace
to_repl := Read_line("Enter string to be replaced : ");
If to_repl = ""
then
return;
Endif;
sens := Get_info(current_buffer,"DIRECTION");
tmp := Search_quietly(to_repl,sens);
if tmp = 0
Then
message ('--- No string matched ---');
Return;
Endif;
repl := Read_line("Enter new string : ");
home := Mark(none);
choix:= Key_name("S");
Loop
Position(tmp);
Update(current_window);
Loop
Exitif (choix = Key_name("a")) or (choix = Key_name("A"));
Message("A(all),R(replace current),E(exit),S(skip) : ");
choix := Read_key;
Exitif (choix = Key_name(" ")) or (choix = Key_name("a"))
or (choix = Key_name("A")) or (choix = Key_name("r"))
or (choix = Key_name("R")) or (choix = Key_name("e"))
or (choix = Key_name("E")) or (choix = Key_name("s"))
or (choix = Key_name("S"));
Endloop;
If (choix = Key_name("r")) Or (choix = Key_name("R")) or
(choix = Key_name("a")) or (choix = Key_name("A"))
Then
erase (tmp);
copy_text(repl);
Endif;
If (choix = Key_name("e")) Or (choix = Key_name("E"))
Then
Position(home);
Return;
Endif;
If (choix = Key_name("s")) Or (choix = Key_name("S"))
Then
If sens = FORWARD
Then
Move_horizontal(1);
Else
Move_horizontal(-1);
Endif;
Endif;
tmp := Search_quietly(to_repl,sens);
if tmp = 0
Then
Position(home);
Return;
Endif;
Endloop;
Endprocedure;
La touche "PF1 r" associée à la procédure search_replace sera définie :
Define_key('search_replace',Key_name("R",Shift_key));