IDE tricks/ko

From Free Pascal wiki
Jump to navigationJump to search

Deutsch (de) English (en) français (fr) magyar (hu) 日本語 (ja) 한국어 (ko) русский (ru) slovenčina (sk)

'Open file'로 새로운 파일 생성하기

새로운 파일을 만들어 저장할 수 있습니다. 또는, 한번의 작업으로 새로운 파일을 파일이름과 파일유형을 지정하여 만들 수 있습니다: 단지 Open File (Ctrl+o) 선택하고 존재하지 않는 파일을 지정합니다. 예를 들어, unit1.pas를 지정할 경우 IDE는 해당파일을 만들것인지 묻습니다.

사용자 정의 new unit / form

0.9.27 버전 부터 'New unit' (New form) 스피드버튼에서 마우스 오른쪽 클릭하고 생성될 파일 유형을 설정할 수 있습니다. IDEIntF 또는 프로젝트 템플릿 패키지를 통하여 더 많은 파일 유형을 등록할 수 있습니다.

IDE macros

IDE Macros in paths and filenames

IDE 에서 만들어지는 컴파일러 명령행 인수 알아내기

명령행 인수들은 Project -> Compiler Options -> Show Options 에서 찾을 수 있습니다. 이 곳의 경로는 프로젝트 디렉터리의 상대경로로 표현되므로 대부분 수정없이 사용할 수 있습니다.

인수들은 *.compiled 파일로도 저장됩니다. 예로, test1.lpi 라는 프로젝트가 있을 때 test1.compiled 파일이 동시에 생성됩니다. 간단한 텍스트 형식의 xml 파일이며 다른 컴퓨터에서 컴파일하기 위해 옵션을 복사하고 경로를 수정할 수 있습니다. 이 파일은 실행파일이 생성된 디렉터리에 들어가게 됩니다.

패키지에도 똑같이 적용될 수 있습니다.

이 방법으로, 생성된 소스 코드를 lazarus IDE 외부에서 컴파일 할 수 있습니다.

에디터 창을 한개 제외하고 모두 닫기

gtk 환경(리눅스, 맥OS X, FreeBSD에서 가능)의 소스 에디터 페이지의 경우 각 페이지 이름 오른쪽에 닫기 버튼이 있습니다. Ctrl키와 함께 닫기 버튼을 클릭하면 클릭한 페이지를 제외한 다른 모든 페이지가 닫히게 됩니다.

Component palette

Finding a component in the palette

You know the component name, or part of it, but you don't know in which page it was? This tool finds it: Right click on a component in the palette to open the popup menu. Choose 'Find component'. Type part of the name to filter the list.

Open the package of a component in the palette

Right click on the component to open the popup menu, then choose open package.

Find the source declaration of a component in the palette

Right click on the component to open the popup menu, then choose open unit.

My application freeze my linux desktop while debugging

X (your desktop) can freeze, when an application that grabbed the mouse is stopped by gdb (the debugger).

Using a second X session

You can start a second X by:

  X :1 &

with Ctrl-Alt-F7 you switch to :0 and with Ctrl-Alt-F8 you switch to :1 after that you can start a second gnome session by:

  gnome-session --display=:1 &

Using VNC

You can use vncserver/client by installing tightvncserver/realvncserver Start the server with:

  vncserver :1

AFAIK, a session is also started. You can connect to the vncserver with vncviewer.

Debug the application on the second server

In lazarus, in the run parameters for your project, check "use display" and enter

 :1

Now your application will run on the second server, so when it is being debugged, only the second server will freeze (but that won't affect you since you are debugging on the first).

Compiling the IDE fast

Working on Lazarus itself needs rebuilding the IDE many times. If you use the following tricks and have enough memory and a recent cpu, you should be able to recompile the IDE in a few seconds.

  • Put the Lazarus sources on a fast harddisk. Not on a slow network filesystem.
  • Install only needed packages.
  • Set USESVN2REVISIONINC=0 to skip the update of the revision.inc.
  • Compile only parts. If the packager registration is recompiled, then all installed packages are recompiled too. If the IDEIntf is recompiled, then all installed design-time packages are recompiled.

DebugLn of the IDE or a LCL application

The IDE writes many useful hints via debugln. Under windows you can get them by starting lazarus with the command line parameter --debug-log=filename.txt. Under Linux/BSD/Mac OS X/Solaris: Just start lazarus in a terminal. This is a general LCL feature.

Finding the source file of an IDE window

  • Open the IDE window.
  • Press Ctrl+Shift+F1 to open the help editor.
  • Remember the window classname. Close the window.
  • Use Find In Files to find the source file of the class.

Object Inspector: Events: Frames: Jump to the source of an inherited event

The Object Inspector shows the events of inherited events as ClassName.MethodName. Double clicking will create a new event. Ctrl+Mouse click on the combobox will jump directly to the inherited method body, without creating a new method.

Events (Method properties) in the Object Inspector

Events (Method properties) are special properties, because they need as value a code address pointer, which does not exist at design time. That's why Lazarus uses the same trick as the Delphi IDE: Every method value can be type casted to TMethod, which contains Data (the object or class pointer) and the Code (the address pointer). Normally both are not nil. The IDE sets Data to a special key value for its internal lookup table and sets Code to nil. This means:

  • At runtime when the program loads the .lfm file the real method (Data+Code) is used
  • At designtime a method value can either be a real method (Data<>nil and Code<>nil) or a fake method (Data<>nil,Code=nil)
  • The compiler has for Delphi compatibility some specials about comparing method values.

Do not use:

if OnMyEvent<>nil then OnMyEvent(...); // wrong, because it checks Data too

Because this checks both Data and Code and will execute the fake method, resulting in a jump to nil. This will only raise an exception, so it does not do much harm, but the IDE will show the user an error dialog. Use instead the Assigned function:

if Assigned(OnMyEvent) then OnMyEvent(...); // correct, checking only Code

Do not use:

if OnMyEvent=NewValue then exit; // wrong, because it compares only Code

Because this only compares the Code. Use instead

if CompareMem(@FOnMyEvent,@NewValue,SizeOf(TMethod)) then exit; // correct, checking both Data and Code