Difference between revisions of "IDE Window: Code Templates/es"

From Lazarus wiki
Jump to navigationJump to search
Line 15: Line 15:
  
 
El sinbolo | representa el cursor. Pulsa Ctrl+j. El texto se expandirá a
 
El sinbolo | representa el cursor. Pulsa Ctrl+j. El texto se expandirá a
 +
<delphi> if | then begin
  
<delphi> if | then begin
+
end;</delphi>
  
  end;</delphi>
+
Como antes | representa el cursor. Habrás comprobado que el cursor se ha moviso y parpadea en ese punto.
  
Again the pipe represents the cursor. You can see the cursor has moved as well.
+
Esta plantilla se llama 'ifb' y su definición es esta:
 +
<delphi> if | then begin
  
This template is called 'ifb' and is defined as follows:
+
end; </delphi>
<delphi>if | then begin
 
  
end; </delphi>
+
En esta ocasión | es el carácter | tal cual, con el definimos el punto en el que pondrá el cursor trás insertar el código de la plantilla.
 
 
This time the pipe '|' is a real character. It defines the cursor position after inserting the template.
 
  
 
== Example 2 - Using macros ==
 
== Example 2 - Using macros ==

Revision as of 19:48, 29 June 2008

Deutsch (de) English (en) español (es) suomi (fi) français (fr)

¿Qué son las plantillas de código?

   Las platillas de código son texto con una abreviatura. Por ejemplo escribes 'cl' en el editor de código y después pulsas Ctrl+J para ver las plantillas que comienzan con 'cl'. Esta característica nos permitirá un gran ahorro de tiempo.

  Este diálogo permite editar las plantillas existentes o añadir tus propias plantillas.

  El texto puede contener macros. Y usted puede agregar sus propias macros mediante la creación de un paquete de tiempo de diseño y usando macrointf.pas del paquete IDEIntf.

Ejemplo 1 - ifb

Escribe <delphi> ifb|</delphi>

El sinbolo | representa el cursor. Pulsa Ctrl+j. El texto se expandirá a <delphi> if | then begin

end;</delphi>

Como antes | representa el cursor. Habrás comprobado que el cursor se ha moviso y parpadea en ese punto.

Esta plantilla se llama 'ifb' y su definición es esta: <delphi> if | then begin

end; </delphi>

En esta ocasión | es el carácter | tal cual, con el definimos el punto en el que pondrá el cursor trás insertar el código de la plantilla.

Example 2 - Using macros

This example shows how to create a code template 'w' which inserts a line with the current procedure name.

  • Click on the 'Add' button. A dialog pops up. Set Token to 'w' and Comment to 'writeln(ProcName)', then click Ok.
  • Your new item has been added to the list box.
  • In the source below fill in
 writeln(' ',|);
  • The pipe is really a pipe and defines the new cursor position. Now place the cursor after the first ' and click on the 'Insert macro' button. A dialog pops up showing all available code macros. Choose 'ProcedureName' and click 'Insert Macro'. You should now have:
 writeln('$ProcedureName() ',|);
  • Click 'Ok' to save and close the code template dialog.
  • Move the cursor into a method body, type 'w':

For instance:

 procedure TForm1.FormDestroy(Sender: TObject);
 begin
   w|
 end;

The pipe should represent here the blinking cursor, not a character.

  • Press Ctrl+j. You will get:
 procedure TForm1.FormDestroy(Sender: TObject);
 begin
   writeln('TForm1.FormDestroy ',|);
 end;