Sign in Join
Wiki copytemporary

Lazarus IDE Tools/ko: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## 개관
22
33이 IDE는 파스칼 라이브러리를 이용하여 소스를 파싱하고 편집하는 도구, 즉 "코드툴"입니다. 이 툴은 선언을 검색하고, 코드완성, 추출, 파스칼 코드를 이동, 삽입하며 보기좋게 할수 있는 특징을 제공합니다. 이 기능들은 많은 시간을 절약하게 하고 작업능률을 배가 시킵니다. 이것들은 커스터마이즈 할 수 있으며 각 특징들은 단축키를 통해 사용할 수 있습니다(에디터 옵션을 보세요).
44
55이것들은 소스코드상에서 독립적으로 동작하고 fpc, 델파이 및 카일리스를 인식하기 때문에 볼랜드 컴파일러로 컴파일된 유닛이나 설치를 필요로 하지 않는다. 또한 델파이 및 FPC 코드를 동시에 편집할 수 있다. 여러개의 델파이와 FPC 버젼과도 작업할 수 있어 델파이 코드를 포팅하기 훨씬더 쉽게 해준다.
66
77## IDE 단축키 요약표
88
99| | |
1010|----|----|
1111| [[Lazarus IDE Tools|선언부 이동]] | Ctrl+Click 또는 Alt+Up (변수나 형 선언부로 이동) |
1212| [[Lazarus IDE Tools|메쏘드 이동]] | Ctrl+Shift+Up (정의와 함수 본체 사이를 번갈아 이동) |
1313| [[Lazarus IDE Tools|코드 템플리트]] | Ctrl+J |
1414| [[Lazarus IDE Tools|코드 완성]] (클래스 완성) | Ctrl+Shift+C |
1515| [[Lazarus IDE Tools|식별자 완성]] | Ctrl+Space |
1616| [[Lazarus IDE Tools|단어 완성]] | Ctrl+W |
1717| [[Lazarus IDE Tools|파라메터 힌트]] | Ctrl+Shift+Space |
1818
1919## 메쏘드 이동
2020
2121함수 본체(begin..end_)와 함수 정의부(procedure Name;) 사이를 이동하기 위해서는 Ctrl+Shift+Up을 사용하세요.
2222
2323예제:
2424
25-`interface`\
25+``` pascal
26+interface
2627
27-`procedure DoSomething; // 함수 정의`\
28-` `\
29-`implementation`\
30-` `\
31-`procedure DoSomething; // 함수 몸체 `\
32-`begin`\
33-`end;`
28+procedure DoSomething; // 함수 정의
29+
30+implementation
31+
32+procedure DoSomething; // 함수 몸체
33+begin
34+end;
35+```
3436
3537만약 커서가 함수 몸체위에 있을 때 Ctrl+Shift+Up을 누르면 커서는 선언부로 이동할 것이다.Ctrl+Shift+Up을 다시 누르면 본체의 'begin'다음으로 이동할 것이다.
3638
3739이것은 메쏘드(클래스내에 있는 프로시저)사이에서도 동일하게 동작한다.
3840
3941힌트: '메소드 점프'는 같은 이름의 같은 파라메터 리스트를 가진 함수로 이동을 한다. 만약 정확한 함수가 없다면 가장 근접한 프로시저와 첫번째 차이가 나는 위치로 커서가 이동할 것이다.(델파이 사용자:델파이에는 이런 기능이 없다).
4042
4143예를 들어 서로 다른 파라메터 타입을 가진 프로시저일 때:
4244
43-`interface`\
45+``` pascal
46+interface
4447
45-`procedure DoSomething(p: char); // 프로시저 정의`\
48+procedure DoSomething(p: char); // 프로시저 정의
4649
47-`implementation`\
48-`  `\
49-`procedure DoSomething(p: string); // 프로시저 본체`\
50-`begin`\
51-`end;`
50+implementation
51+
52+procedure DoSomething(p: string); // 프로시저 본체
53+begin
54+end;
55+```
5256
5357정의부에서 본체로 점프하여 'string' 키워드 커서가 위치할 것이다.이것은 메쏘드 이름을 변경하거나 파라메터를 변경 혹은 이름를 바꿀 떄 사용할 수 있다.
5458
5559예:\
5660'DoSomething' 을 'MakeIt'으로 이름을 변경할 때:
5761
58-`interface`\
62+``` pascal
63+interface
5964
60-`procedure MakeIt; // 함수 정의`\
65+procedure MakeIt; // 함수 정의
6166
62-`implementation`\
67+implementation
6368
64-`procedure DoSomething; // 함수 본체`\
65-`begin`\
66-`end;`
69+procedure DoSomething; // 함수 본체
70+begin
71+end;
72+```
6773
6874MakeIt에서 본체로 점프할 것이다. IDE는 적절한 본체를 검색하지만 찾를 못할 것이고 비슷한 후보자를 찾을 것이다. 한개의 프로시저만 이름을 바꾸었다면 정의(DoSomething)가 없는 몸체가 될 것이어서 커서는 DoSomething으로 점프하여 'DoSomething'의 우측에 위치할 것이다. 그러면 간단히 이름을 바꾸기만 하면 될 것이다. 이것은 파라메터에서동 동일하게 동작한다.
6975
7076## 인클루드 파일
7177
7278인클루드 파일은 소스에 {\$I 파일명} 또는 {\$INCLUDE 파일명} 컴파일러 지시자와 함께 삽입되는 파일이다. 라자루스와 FPC는 중복을 피하고, 이기종 플랫폼을 지원하기위해 사용되는 읽기 어려운 {IFDEF}구조를 피하고자 인클루드파일을 많이 사용한다.
7379
7480델파이와는 반대로 라자루스 IDE는 인크르루드 파일을 완전히 지원한다. 예를 들어 .pas 파일상의 메쏘드에서 인클루드 파일의 메쏘드 본체로 점프할 수도 있다. 코드 완성과 마찬가지로 모든 코드툴은 인클루드 파일을 특별한 부분으로 고려한다.
7581
7682예를 들어: 코드 완성기능으로 다른 메쏘드 본체 뒤에 새로운 메쏘드 본체를 더할 때도 같은 파일에서 둘을 유지시킨다. 이러한 방법은 인크루드 파일에 완전한 클래스 선언을 할 수 있어 LCL과 같이 거의 모든 컨트롤을 가능하게 한다.
7783
7884그러나 여기에도 함정은 있다: 만약 인크루드 파일을 처음 열어 메쏘드 점핑을 하거나 선언을 찾으려고 하면 에러가 날 것이다. IDE는 어떤 유닛이 인클루드 파일을 포함하는지 모르므로 유닛 을 먼저 열어야만 한다.
7985
8086IDE가 유닛을 파싱하자마자 유닛에서 인클루드 지시어를 파싱할 수 있으므로 IDE는 이 관계를 기억하게 될 것이다. IDE는 종료시 이 정보를 저장하며 프로젝트에서는 ~/.lazarus/includelinks.xml로 저장할 수 있다. 다음번에 이 인클루드 파일을 열거 점프하거나 선언을 검색할 수 있어, IDE는 내부적을 유닛을 열어 점프하는 동작을 한게 된다.
8187
8288이 동작 방법은 물론 한계가 있다. 몇몇 인클루드 파일은 두번 또는 그 이상으로 인클루드 되어있다. 예: lcl/include/winapih.inc.
8389
8490이 인클루드 파일의 procedure/method 정의에서 몸체로 점프하는 것은 바로 전에 행한 동작과 관련이 있다. 만약 lcl/lclintf.pp에서 작업했다면 IDE는 winapi.inc로 점프할 것이다. 만약 lcl/interfacebase.pp에서 작업했다면 lcl/include/interfacebase.inc(또는 다른 인클루드 파일중의 하나)로 점프할 것이다. 만약 둘다에서 작업하고 있다면 예상과 다른 결과를 얻을 수도 있을 것이다 ;)
8591
8692## 코드 템플릿
8793
8894코드 템플릿은 식별자를 텍스트나 또는 코드 조각으로 전환한다.
8995
9096코드 템플릿에 대한 디폴트 단축키는 Ctrl+J이다. 식별자를 타이핑하고 Ctrl+J를 누르면 식별자는 식별자에따라 정의된 텍스트로 교체된다. 코드 템플릿은 Environment -\> Editor Options -\> CodeTools에서 정의할 수 있다.
9197
9298예: 'classf' 식별자를 쓰로 커서를 f의 바로 뒤에 옮긴 후 Ctrl+J를 누른다. 'classf'는 다음 문장으로 치환 될 것이다.
9399
94-`T = class(T)`\
95-`private`\
100+``` pascal
101+T = class(T)
102+private
96103
97-`public`\
98-`  constructor Create;`\
99-`  destructor Destroy; override;`\
100-`end;`
104+public
105+ constructor Create;
106+ destructor Destroy; override;
107+end;
108+```
101109
102110그리고 커서는 'T'다음에 있을 것이다. 이러한 템플릿의 리스트는 커서를 공백에 위치하고(식별자 위가 아니다) Ctrl+J를 누르면 얻을 수 있다. 코드 템플릿의 리스트가 팝업으로 나올 것이다. 키나 선택할 수 있는 문자를 눌러 선택한다. 엔터는 선택된 템플릿을 만들고, Escape는 팝업을 닫는다.
103111
104112가장 크게 시간을 절약할 수 있는 템플릿은 'b'+Ctrl+J로 정의된 begin..end이다.
105113
106114## 파라메터 힌트
107115
108116파라메터 힌트는 현재 파라메터 리스트에 대해서 파라메터 선언을 힌트박스로 보여준다.
109117
110118예
111119
112-` Canvas.FillRect(|);`
120+```text
121+ Canvas.FillRect(|);
122+```
113123
114124커서를 괄호안에 위치하고 Ctrl+Shift+Space를 누르면 힌트박스로 FillRect에 대한 파라메터를 보여줄 것이다.
115125
116126## 코드 완성
117127
118128코드 완성은 IDE메뉴의 Edit -\> Complete Code에서 찾을 수 있으며 Ctrl+Shift+C를 표준 단축키로 제공한다.
119129
120130델파이 사용자: 델파이는 "code completion"함수를 불러 현재 소스 위치(Ctrl+Space)의 식별자 리스트를 보여준다. 라자우스에서는 "Identifier completion"을 부른다..
121131
122132코드 완성은 몇가지 강력한 함수와 결부되어 있다. 예:
123133
124134- 클래스 완성: 프로퍼티를 완성하며, 메소드 본체를 더하거나 업데이트하며, private 변화와 private 접근 메쏘드를 더한다.
125135- 포워드 프로시저 완성: 프러시저 본체를 더한다.
126136- 이벤트 할당 완성: 이벤트 할당을 완성하고 메쏘드 정의와 본체를 더한다.
127137- 변수 선언 완성: 지역변수 정의를 더한다.
128138- 프로시저 호출 완성: 새로운 프로시저를 더한다.
129139- 역 프로시저 완성: 프로시저/함수에 본체에 대한 프로시저 선언을 더한다.
130140- 역 클래스 완성: 메쏘드 본체에 대한 메쏘드 선언을 더한다
131141
132142어느 함수가 사용되는지는 에디터상의 커서 위치에 따라 달라진다.
133143
134144코드완성은 IDE메뉴의 Edit -\> Complete Code에서 찾을 수 있으며 표준 단축키는 Ctrl+Shift+C이다.
135145
136146### 클래스 완성
137147
138148가장 강력한 코드 완성 특징은 "클래스 완성"이다. 클래스를 작성하고 메쏘드와 프로퍼티를 추가하면 코드완성은 메쏘드 본체를 더하게되고 프로퍼티는 메쏘드/변수 및 private 변수에 접근하게 된다.
139149
140150예: 클래스를 만든다(타이핑하는 수고를 조금라도 덜려면 코드템플릿을 보세요):
141151
142-`TExample = class(TObject)`\
143-`public`\
144-`  constructor Create;`\
145-`  destructor Destroy; override;`\
146-`end;`
152+``` pascal
153+TExample = class(TObject)
154+public
155+ constructor Create;
156+ destructor Destroy; override;
157+end;
158+```
147159
148160커서를 클래스내의 아무 위치에나 놓고 Ctrl+Shift+C를 누른면 본체가 없는 메쏘드를 만들고 커서를 첫번째 메쏘드 바디에 위치시키므로 그 자리에서 클래스 코드를 작성하면 된다:
149161
150-`{ TExample }`\
162+``` pascal
163+{ TExample }
151164
152-`constructor TExample.Create;`\
153-`begin`\
154-`  |`\
155-`end;`\
165+constructor TExample.Create;
166+begin
167+ |
168+end;
156169
157-`destructor TExample.Destroy;`\
158-`begin`\
159-`  inherited Destroy;`\
160-`end;`
170+destructor TExample.Destroy;
171+begin
172+ inherited Destroy;
173+end;
174+```
161175
162176노트: '\|'는 커서이고 추가되지 않는다.
163177
164178힌트: 메쏘드와 몸체사이를 Ctrl+Shift+Up을 사용하여 이동할 수 있다.
165179
166180IDE가 'inherited Destroy' 콜 함수를 더한 것을 역시 볼 수 있을 것이다. 클래스 정의에 'override' 키워드가 있다면 말이다.
167181
168182이제 DoSomething 메쏘드를 추가해보자:
169183
170-`TExample = class(TObject)`\
171-`public`\
172-`  constructor Create;`\
173-`  procedure DoSomething(i: integer);`\
174-`  destructor Destroy; override;`\
175-`end;`
184+``` pascal
185+TExample = class(TObject)
186+public
187+ constructor Create;
188+ procedure DoSomething(i: integer);
189+ destructor Destroy; override;
190+end;
191+```
176192
177193그리고 Ctrl+Shift+C를 누르면 IDE가 추가해 줄 것이다.
178194
179-`procedure TExample.DoSomething(i: integer);`\
180-`begin`\
181-`  |`\
182-`end;`
195+``` pascal
196+procedure TExample.DoSomething(i: integer);
197+begin
198+ |
199+end;
200+```
183201
184202새로운 메쏘드 몸체가 클래스 정의에서 그랬던 것처럼 정확히 Create와 Destroy 사이에 삽입되어 있는 것을 알수 있을 것이다. 이러한 방식으로 정의된 순서와 같이 동일한 눈리적인 순서를 유지하도록 해준다. Environment \> Codetools Options -\> Code Creation 에서 삽입 규칙들을 정의할 수 있다.
185203
186204**프로퍼티 완성**\
187205AnInteger 프로퍼티를 추가한다:
188206
189-`TExample = class(TObject)`\
190-`public`\
191-`  constructor Create;`\
192-`  procedure DoSomething(i: integer);`\
193-`  destructor Destroy; override;`\
194-`  property AnInteger: Integer;`\
195-`end;`
207+``` pascal
208+TExample = class(TObject)
209+public
210+ constructor Create;
211+ procedure DoSomething(i: integer);
212+ destructor Destroy; override;
213+ property AnInteger: Integer;
214+end;
215+```
196216
197217Ctrl+Shift+C를 누르면 다음이 나타난다:
198218
199-`procedure TExample.SetAnInteger(const AValue: integer);`\
200-`begin`\
201-`  |if FAnInteger=AValue then exit;`\
202-`  FAnInteger:=AValue;`\
203-`end;`
219+``` pascal
220+procedure TExample.SetAnInteger(const AValue: integer);
221+begin
222+ |if FAnInteger=AValue then exit;
223+ FAnInteger:=AValue;
224+end;
225+```
204226
205227코드완성은 Write 접근 modifier를 추가하고 몇몇 공통 코드를 추가한다. 새로운 클래스를 보기위해서는 Ctrl+Shift+Up를 이용하여 클래스로 점프할 수 있을 것이다:
206228
207-`TExample = class(TObject)`\
208-`private`\
209-`  FAnInteger: integer;`\
210-`  procedure SetAnInteger(const AValue: integer);`\
211-`public`\
212-`  constructor Create;`\
213-`  procedure DoSomething(i: integer);`\
214-`  destructor Destroy; override;`\
215-`  property AnInteger: integer read FAnInteger write SetAnInteger;`\
216-`end;`
229+``` pascal
230+TExample = class(TObject)
231+private
232+ FAnInteger: integer;
233+ procedure SetAnInteger(const AValue: integer);
234+public
235+ constructor Create;
236+ procedure DoSomething(i: integer);
237+ destructor Destroy; override;
238+ property AnInteger: integer read FAnInteger write SetAnInteger;
239+end;
240+```
217241
218242프로퍼티는 Read와 Write 접근 modifier에 의해 확장될 수 있다. 클래스는 'FAnInteger' 에 private성질을 가진 새로운 섹션과 'SetAnInteger' 메쏘드를 추가한다. private 변수에 F르 붙이고 write 메쏘드에 'Set'을 붙이는 것은 전형적인 델파이 스타일이다. 이런 방식이 싫다면 Environment \> Codetools Options -\> Code Creation에서 변경할 수 있다.
219243
220244읽기만 가능한 프로퍼티 생성:
221245
222-`property PropName: PropType read;`
246+```text
247+property PropName: PropType read;
248+```
223249
224250다음과 같이 확장될 수 있다
225251
226-`property PropName: PropType read FPropName;`
252+```text
253+property PropName: PropType read FPropName;
254+```
227255
228256쓰기만 가능한 프로퍼티 생성:
229257
230-` property PropName: PropType write;`
258+```text
259+ property PropName: PropType write;
260+```
231261
232262다음과 같이 확장될 수 있다
233263
234-`property PropName: PropType write SetPropName;`
264+```text
265+property PropName: PropType write SetPropName;
266+```
235267
236268Read 메쏘드를 가진 읽기만 가능한 프로퍼티 생성:
237269
238-`property PropName: PropType read GetPropName;`
270+```text
271+property PropName: PropType read GetPropName;
272+```
239273
240274그대로 둔 상태로 GetPropName 이 추가된다:
241275
242-`function GetpropName: PropType;`
276+``` pascal
277+function GetpropName: PropType;
278+```
243279
244280stored modifier를 가진 프로퍼티 생성:
245281
246-`property PropName: PropType stored;`
282+```text
283+property PropName: PropType stored;
284+```
247285
248286다음과 같이 확장될 수 있다
249287
250-`property PropName: PropType read FPropName write SetPropName stored PropNameIsStored;`
288+```text
289+property PropName: PropType read FPropName write SetPropName stored PropNameIsStored;
290+```
251291
252292stored는 스트리밍 읽기와 쓰기 modifier가 자동적으로 추가 되도록 할 떄 사용된다.
253293
254294힌트: 식별자완성은 불완전한 프로퍼니를 인식하여 디폴트 이름을 제시해준다. 에를 들면:
255295
256-`property PropName: PropType read |;`
296+```text
297+property PropName: PropType read |;
298+```
257299
258300커서를 'read' 키워드 뒤의 공백에 놓고 Ctrl+Space를 누르면 식별자완성을 부르게된다. 이는 'FPropName'과 'SetPropName'을 보여줄 것이다.
259301
260302### Forward 프로시져 완성
261303
262304"Forward Procedure Completion"은 코드 완성의 일부분이며 송실된 프로시져 본체를 추가해준다. 이것은 커서가 전방에 정의된 프로시져 위에 있을 때 일어난다.
263305
264306예: 인터페이스 섹션에 새로운 프로시져를 추가한다: procedure DoSomething; 커서를 그 위에 놓고 Ctrl+Shift+C 를 눌러 코드완성을 하게 한다. 그러면 implementation 섹션에 다음 부분이 생성된다:
265307
266-`procedure DoSomething;`\
267-`begin`\
268-`  |`\
269-`end;`
308+``` pascal
309+procedure DoSomething;
310+begin
311+ |
312+end;
313+```
270314
271315힌트: 프로서져 정의 부분과 몸체 사이를 Ctrl+Shift+Up 키를 이용해서 왔다 갔다 할 수 있다.
272316
273317새로운 프로시져 몸체는 클래스 메써드의 첫 부분에 추가될 것이다. 만약 인터페이스 부에 어떤 프로시져가 이미 있다면 IDE는 순서를 지킬 것이다. 예:
274318
275-` procedure Proc1;`\
276-` procedure Proc2; // 새로운 프로시져`\
277-` procedure Proc3;`
319+``` pascal
320+ procedure Proc1;
321+ procedure Proc2; // 새로운 프로시져
322+ procedure Proc3;
323+```
278324
279325만약 Proc1 과 Proc3의 몸체가 이미 있었다면 Proc2 몸체는 Proc1 과 Proc3 의 몸체 사이에 삽입될 것이다. 이러한 행동은 Environment \> Codetools Options -\> Code Creation 에서 설정할 수 있다.
280326
281327복수의 프로시져:
282328
283-`procedure Proc1_Old; // 몸체 존재`\
284-`procedure Proc2_New; // 몸체 없음`\
285-`procedure Proc3_New; //  "`\
286-`procedure Proc4_New; //  "`\
287-`procedure Proc5_Old; // 몸체 존재`
329+``` pascal
330+procedure Proc1_Old; // 몸체 존재
331+procedure Proc2_New; // 몸체 없음
332+procedure Proc3_New; // "
333+procedure Proc4_New; // "
334+procedure Proc5_Old; // 몸체 존재
335+```
288336
289337코드완성은 3개의 프로시져 바디를 모두 추가할 것이다 (Proc2_New, Proc3_New, Proc4_New).
290338
291339왜 "Forward Procedure Completion"이라고 부를까?
292340
293341이것은 인터페이스에서 정의된 프로시져에대해 동작할 뿐아니라 "forward" modifier가 있는 프로시져에도 똑같이 동작한다. 그리고 코드툴은 인터페이스 내의 프로시져가 암시적인 'forward' modifier를 가진것처럼 취급하기 때문이다.
294342
295343### 이벤트 할당 완성
296344
297345"이벤트 할당 완성"은 코드완성의 일부분이며 단일 이벤트 Event:=\| 문장을 완성한다. 이것은 커서가 이벤트에 대해 할당된 배후에 있을 때 일어난다.
298346
299347예를 들면: 메써드 내에서, FormCreate 이벤트가 있고, 'OnPaint:='라인을 추가하면:
300348
301-`procedure TForm1.Form1Create(Sender: TObject);`\
302-`begin`\
303-`  OnPaint:=|`\
304-`end;`
349+``` pascal
350+procedure TForm1.Form1Create(Sender: TObject);
351+begin
352+ OnPaint:=|
353+end;
354+```
305355
306356'\|'는 커서이고 타이프하면 안된다. 그리고 Ctrl+Shift+C를 눌러 코드완성을 한다. 문장은 OnPaint:=@Form1Paint; 로 완성된다 새로운 메쏘드 Form1Paint는 TForm1 에 추가된다. 그러면 클래스 완성이 시작되고 다음과 같이 될 것이다:
307357
308-`procedure TForm1.Form1Paint(Sender: TObject);`\
309-`begin`\
310-`  |`\
311-`end;`
358+``` pascal
359+procedure TForm1.Form1Paint(Sender: TObject);
360+begin
361+ |
362+end;
363+```
312364
313365이것은 오브젝트 인스펙터상에서 메써드를 추가하는 것과 같다.
314366
315367Note:\
316368커서를 ':=' 할당 오퍼레이터의 뒤에 놓아야 한다. 커서를 identifier (예, OnPaint) 위에 놓으면 OnPaint가 이미 정의되었기 때문에 코드 완성은 "지역변수 완성"을 일으키고 만다. Hint:\
317369새로운 메써드 이름을 자의적으로 만들 수 있다. 예를 들면:
318370
319-` OnPaint:=@ThePaintMethod;`
371+``` pascal
372+ OnPaint:=@ThePaintMethod;
373+```
320374
321375### 변수 선언 완성
322376
323377"변수 선언 완성" 은 코드 완성의 일부이며 Identifier:=Term; 문장에 대한 지역변수 정의를 추가한다. 커서가 할당문 또는 파라메터의 identifier 위에 있을 때 일어난다.
324378
325379예를 들면:
326380
327381``` pascal
328382procedure TForm1.Form1Create(Sender: TObject);
329383begin
330384 i:=3;
331385end;
332386```
333387
334388커서를 'i' 또는 바로 뒤에 놓고 Ctrl+Shift+C 를 누르면 코드완성이 이루어지고 다음을 얻게 된다:
335389
336390``` pascal
337391procedure TForm1.Form1Create(Sender: TObject);
338392var
339393 i: Integer;
340394begin
341395 i:=3;
342396end;
343397```
344398
345399코드 툴은 먼저 식별자 'i'가 이미 정의 되어있는지 확인하고 없으면 'var i: integer;'을 선언을 추가한다. 식별자의 종류는 할달문 ':=' 연산자의 우측을 보고 판단한다. 3과 같은 숫자는 Integer 로 지정되어있다.
346400
347401다른 예:
348402
349403``` pascal
350404type
351405 TWhere = (Behind, Middle, InFront);
352406
353407 procedure TForm1.Form1Create(Sender: TObject);
354408 var
355409 a: array[TWhere] of char;
356410 begin
357411 for Where:=Low(a) to High(a) do writeln(a[Where]);
358412 end;
359413```
360414
361415커서를 'Where'에 놓고 Ctrl+Shift+C 를 누르고 코드완성을 하면 다음을 얻는다:
362416
363417``` pascal
364418 procedure TForm1.Form1Create(Sender: TObject);
365419 var
366420 a: array[TWhere] of char;
367421 Where: TWhere;
368422 begin
369423 for Where:=Low(a) to High(a) do writeln(a[Where]);
370424 end;
371425```
372426
373427라자루스 0.9.11은 파라메터 완성도 한다. 예를 들면:
374428
375429``` pascal
376430 procedure TForm1.FormPaint(Sender: TObject);
377431 begin
378432 with Canvas do begin
379433 Line(x1,y1,x2,y2);
380434 end;
381435 end;
382436```
383437
384438커서를 'x1'에 놓고 Ctrl+Shift+C 를 눌러 코드완성을 하면 다음을 얻는다:
385439
386440``` pascal
387441 procedure TForm1.FormPaint(Sender: TObject);
388442 var
389443 x1: integer;
390444 begin
391445 with Canvas do begin
392446 Line(x1,y1,x2,y2);
393447 end;
394448 end;
395449```
396450
397451### 프로시져 호출 완성
398452
399453코드 완성은 호출문 자체에서 새로운 프로시져를 만들어낸다.
400454
401455"DoSomething(Width);" 문을 작성했다고 가정하자
402456
403457``` pascal
404458procedure SomeProcedure;
405459var
406460 Width: integer;
407461begin
408462 Width:=3;
409463 DoSomething(Width);
410464end;
411465```
412466
413467커서를 식별자 "DoSomething" 위에 놓고 Ctrl+Shift+C 를 눌러 다음을 얻는다:
414468
415469``` pascal
416470procedure DoSomething(aWidth: LongInt);
417471begin
418472
419473end;
420474
421475procedure SomeProcedure;
422476var
423477 Width: integer;
424478begin
425479 Width:=3;
426480 DoSomething(Width);
427481end;
428482```
429483
430484이것은 아직 함수나 메써드를 만들지 않았다.
431485
432486### Reversed Class Completion
433487
434488"Reversed Class Completion" is part of the **Code Completion** and adds a private method declaration for the current method body. It is invoked, when the cursor is in a method body, not yet defined in the class. This feature is available since Lazarus 0.9.21.
435489
436490For example:
437491
438-` procedure TForm1.DoSomething(Sender: TObject);`\
439-` begin`\
440-` end;`
492+``` pascal
493+ procedure TForm1.DoSomething(Sender: TObject);
494+ begin
495+ end;
496+```
441497
442498The method DoSomething is not yet declared in TForm1. Press Ctrl+Shift+C and the IDE will add "procedure DoSomething(Sender: TObject);" to the private methods of TForm1.
443499
444500For Delphians: Class completion works under Lazarus always in one way: From class interface to implementation or backwards/reversed from class implementation to interface. Delphi always invokes both directions. The Delphi way has the disadvantage, that if a typo will easily create a new method stub without noticing.
445501
446502### Comments and Code Completion
447503
448504Code completion tries to keep comments where they belong. For example:
449505
450-` FList: TList; // list of TComponent`\
451-` FInt: integer;`
506+```text
507+ FList: TList; // list of TComponent
508+ FInt: integer;
509+```
452510
453511When inserting a new variable between FList and FInt, the comment is kept in the FList line. Same is true for
454512
455-` FList: TList; { list of TComponent`\
456-`   This is a comment over several lines, starting`\
457-`   in the FList line, so codetools assumes it belongs `\
458-`   to the FLIst line and will not break this `\
459-`   relationship. Code is inserted behind the comment. }`\
460-` FInt: integer;`
513+```text
514+ FList: TList; { list of TComponent
515+ This is a comment over several lines, starting
516+ in the FList line, so codetools assumes it belongs
517+ to the FLIst line and will not break this
518+ relationship. Code is inserted behind the comment. }
519+ FInt: integer;
520+```
461521
462522If the comment starts in the next line, then it will be treated as if it belongs to the code below. For example:
463523
464-` FList: TList; // list of TComponent`\
465-`   { This comment belongs to the statement below. `\
466-`     New code is inserted above this comment and `\
467-`     behind the comment of the FList line. }`\
468-` FInt: integer;`
524+```text
525+ FList: TList; // list of TComponent
526+ { This comment belongs to the statement below.
527+ New code is inserted above this comment and
528+ behind the comment of the FList line. }
529+ FInt: integer;
530+```
469531
470532### Method update
471533
472534Normally class completion will add all missing method bodies. (Since 0.9.27) But if exactly one method differ between class and bodies then the method body is updated. For example: You have a method *DoSomething*.
473535
474536``` pascal
475537 public
476538 procedure DoSomething;
477539 end;
478540
479541procedure TForm.DoSomething;
480542begin
481543end;
482544```
483545
484546Now add a parameter:
485547
486548``` pascal
487549 public
488550 procedure DoSomething(i: integer);
489551 end;
490552```
491553
492554and invoke Code Completion (Ctrl+Shift+C). The method body will be updated and the new parameter will be copied:
493555
494556``` pascal
495557procedure TForm.DoSomething(i: integer);
496558begin
497559end;
498560```
499561
500562## Refactoring
501563
502564### Invert Assignments
503565
504566Abstract
505567
506568"Invert Assignments" takes some selected pascal statements and inverts all assignments from this code. This tool is usefull for transforming a "save" code to a "load" one and inverse operation.
507569
508570Example:\
509-procedure DoSomething;
510571
511-`begin`\
512-`  AValueStudio:= BValueStudio;`\
513-`  AValueAppartment :=BValueAppartment;`\
514-`  AValueHouse:=BValueHouse;`\
515-`end;`
572+``` pascal
573+procedure DoSomething;
574+begin
575+ AValueStudio:= BValueStudio;
576+ AValueAppartment :=BValueAppartment;
577+ AValueHouse:=BValueHouse;
578+end;
579+```
516580
517581Select the lines with assignments (between begin and end) and do Invert Assignments. All assignments will be inverted and identation will be add automatically. For example:
518582
519583Result:
520584
521-`procedure DoSomething;`\
522-`begin`\
523-`  BValueStudio     := AValueStudio;`\
524-`  BValueAppartment := AValueAppartment;`\
525-`  BValueHouse      := AValueHouse;`\
526-`end;`
585+``` pascal
586+procedure DoSomething;
587+begin
588+ BValueStudio := AValueStudio;
589+ BValueAppartment := AValueAppartment;
590+ BValueHouse := AValueHouse;
591+end;
592+```
527593
528594### Enclose Selection
529595
530596Select some text and invoke it. A dialog will popup where you can select if the selection should be enclosed into **try..finally** or many other common blocks.
531597
532598### Rename Identifier
533599
534600Place the cursor on an identifier and invoke it. A dialog will appear, where you can setup the search scope and the new name.
535601
536602- It will rename all occurences and only those that actually use this declaration. That means it does not rename declarations with the same name.
537603- And it will first check for name conflicts.
538604- Limits: It only works on pascal sources, does not yet rename files nor adapt lfm/lrs files nor lazdoc files.
539605
540606### Find Identifier References
541607
542608Place the cursor on an identifier and invoke it. A dialog will appear, where you can setup the search scope. The IDE will then search for all occurences and only those that actually use this declaration. That means it does not show other declarations with the same name.
543609
544610### Show abstract methods
545611
546612This feature lists and auto completes virtual, abstracts methods that need to be implemented. Place the cursor on a class declaration and invoke it. If there are missing abstract methods a dialog will appear listing them. Select the methods to implement and the IDE creates the method stubs.
547613
548614### Extract Procedure
549615
550616See [[IDE Window: Extract Procedure|Extract Procedure]]
551617
552618## Find Declaration
553619
554620Position the cursor on an identifier and do 'Find Declaration'. Then it will search the declaration of this identifier, open the file and jump to it.
555621
556622Every find declaration sets a Jump Point. That means you jump with find declaration to the declaration and easily jump back with Search -\> Jump back.
557623
558624There are some differences to Delphi: The codetools work on sources following the normal pascal rules, instead of using the compiler output. The compiler returns the final type. The codetools see the sources and all steps in between. For example:
559625
560626The *Visible* property is first defined in TControl (controls.pp), then redefined in TCustomForm and finally redefined in TForm. Invoking find declaration on Visible will you first bring to Visible in TForm. Then you can invoke Find Declaration again to jump to Visible in TCustomForm and again to jump to Visible in TControl.
561627
562628Same is true for types like TColor. For the compiler it is simply a 'longint'. But in the sources it is defined as
563629
564-`TGraphicsColor = -$7FFFFFFF-1..$7FFFFFFF;`\
565-`TColor = TGraphicsColor;`
630+```text
631+TGraphicsColor = -$7FFFFFFF-1..$7FFFFFFF;
632+TColor = TGraphicsColor;
633+```
566634
567635And the same for **forward defined classes**: For instance in TControl, there is a private variable
568636
569-`FHostDockSite: TWinControl;`
637+```text
638+FHostDockSite: TWinControl;
639+```
570640
571641Find declaration on TWinControl jumps to the forward definition
572642
573-`TWinControl = class;`
643+```text
644+TWinControl = class;
645+```
574646
575647And invoking it again jumps to the real implementation
576648
577-`TWinControl = class(TControl)`
649+```text
650+TWinControl = class(TControl)
651+```
578652
579653This way you can track down every identifier and find every overload.
580654
581655**Hints:** You can jump back with Ctrl+H.
582656
583657## Identifier Completion
584658
585659"Identifier Completion" is invoked by Ctrl+Space. It shows all identifiers in scope. For example:
586660
587-` procedure TForm1.FormCreate(Sender: TObject);`\
588-` begin`\
589-`   |`\
590-` end;`
661+``` pascal
662+ procedure TForm1.FormCreate(Sender: TObject);
663+ begin
664+ |
665+ end;
666+```
591667
592668Place the cursor between *begin* and *end* and press Ctrl+Space. The IDE/CodeTools will now parse all reachable code and present you a list of all found identifiers. The CodeTools cache the results, so invoking it a second time will be much faster.
593669
594670**Note for Delphians:** Delphi calls it *Code completion*.
595671
596672Some identifiers like 'Write', 'ReadLn', 'Low', 'SetLength', 'Self', 'Result', 'Copy' are built into the compiler and are not defined anywhere in source. The identifier completion has a lot of these things built in as well. If you find one missing, just create a feature request in the bug tracker.
597673
598674Identifier completion does not complete **keywords**. So you can not use it to complete 'proc' to 'procedure'. For these things use Ctrl+W Word Completion instead or Ctrl+J Code Templates.
599675
600676Identifier completion shows even those identifiers, that are not compatible.
601677
602678### Prefix
603679
604680You can start identifier completion in a word. Then the letters to the left will be taken as prefix. For example:
605681
606-` procedure TForm1.FormCreate(Sender: TObject);`\
607-` begin`\
608-`   Ca|ption`\
609-` end;`
682+``` pascal
683+ procedure TForm1.FormCreate(Sender: TObject);
684+ begin
685+ Ca|ption
686+ end;
687+```
610688
611689The box will show you only the identifiers beginning with 'Ca'.
612690
613691### Keys
614692
615693- Letter or number: add the character to the source editor and the current prefix. This will update the list.
616694- Backspace: remove the last character from source editor and prefix. Updates the list.
617695- Return: replace the whole word at cursor with the selected identifier and close the popup window.
618696- Shift+Return: as *Return*, but replaces only the prefix (left part) of the word at the cursor.
619697- Up/Down: move selection
620698- Escape: close popup without change
621699- Tab: completes the prefix to next choice. For example: The current prefix is 'But' and the identifier completion only shows 'Button1' and 'Button1Click'. Then pressing *Tab* will complete the prefix to 'Button1'.
622700- Else: as *Return* and add the character to the source editor
623701
624702### Methods
625703
626704When cursor is in a class definition and you identifier complete a method defined in an ancestor class the parameters and the override keyword. For example:
627705
628706``` pascal
629707TMainForm = class(TForm)
630708protected
631709 mous|
632710end;
633711```
634712
635713Completing **MouseDown** gives:
636714
637715``` pascal
638716TMainForm = class(TForm)
639717protected
640718 procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X,
641719 Y: Integer); override;
642720end;
643721```
644722
645723### Properties
646724
647725``` pascal
648726property MyInt: integer read |;
649727```
650728
651729Identifier completion will show **FMyInt** and **GetMyInt**.
652730
653731``` pascal
654732property MyInt: integer write |;
655733```
656734
657735Identifier completion will show **FMyInt** and **SetMyInt**.
658736
659737### Uses section / Unit names
660738
661739In uses sections the identifier completion will show the filenames of all units in the search path. These will show all lowercase (e.g. **avl_tree**), because most units have lowercase filenames. On completion it will insert the nice case of the unit (e.g. **AVL_Tree**).
662740
663741### Statements
664742
665743\<DELPHI\> procedure TMainForm.Button1Click(Sender: TObject); begin
666744
667-` ModalRe|;`
745+```text
746+ ModalRe|;
747+```
668748
669749end;
670750
671751becomes:
672752
673753\<DELPHI\> procedure TMainForm.Button1Click(Sender: TObject); begin
674754
675-` ModalResult:=|;`
755+``` pascal
756+ ModalResult:=|;
757+```
676758
677759end;
678760
679761## Word Completion
680762
681763"Word Completion" is invoked by Ctrl+W. It shows all words of all currently open editors and can therefore be used in non pascal sources, in comments and for keywords.
682764
683765Otherwise it works the same as identifier completion.
684766
685767## Goto Include Directive
686768
687769"Goto Include Directive" in the search menu of the IDE jumps to {\$I filename} statement where the current include file is used.
688770
689771## Publish Project
690772
691773Creates a copy of the whole project. If you want to send someone just the sources and compiler settings of your code, this function is your friend.
692774
693775A normal project directory contains a lot of information. Most of it is not needed to be published: The .lpi file contains session information (like caret position and bookmarks of closed units) and the project directory contains a lot of .ppu, .o files and the executable. To create a lpi file with only the base information and only the sources, along with all sub directories use "Publish Project".
694776
695777**Note**: Since version 0.9.13 there is a new *Project Option* that allows you to store session information in a seperate file from the normal .lpi file. This new file ends with the .lps extension and only contains session information, which will leave you .lpi file much cleaner.
696778
697779In the dialog you can setup the exclude and include filter, and with the command after you can compress the output into one archive.
698780
699781## Original contributors
700782
701783This page has been converted from the epikwiki [version](http://lazarus-ccr.sourceforge.net/index.php?wiki=LazarusIdeTools).
702784
703785- Created page and initial template - 4/6/2004 VlxAdmin
704786- Initial content posted - 4/10/2004 MattiasG
705787- Small wiki and formatting fixes - 4/11/2004 VlxAdmin
706788- Added a summary table for IdeTools shortcuts - 12 July 2004 User:Kirkpatc
707789
708790---
709791*From the Free Pascal wiki, page "Lazarus IDE Tools/ko", as it stood on 2020-02-18 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history