?? fgoto.pas
字號:
unit fGoto;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, CorelButton;
type
TGotoType = (gtLine, gtCol, gtByte, gtBookmark);
TfrmGoto = class(TForm)
Label1: TLabel;
Label2: TLabel;
cboError: TComboBox;
cboBookmark: TComboBox;
txtLineNum: TEdit;
btnOK: TCorelButton;
btnCancel: TCorelButton;
lstGoto: TListBox;
memDesc: TMemo;
procedure lstGotoClick(Sender: TObject);
procedure btnOKClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
fCurCaretPos: TPoint;
fByte: integer;
{ Private declarations }
procedure SetCurCaretPos(Value: TPoint);
function GetGotoType: TGotoType;
procedure SetGotoType(AValue: TGotoType);
public
{ Public declarations }
property CurCaretPos: TPoint read fCurCaretPos write SetCurCaretPos;
property ByteOffs: integer read fByte write fByte;
property GotoType: TGotoType read GetGotoType write SetGotoType;
end;
var
frmGoto: TfrmGoto;
implementation
{$R *.dfm}
uses fDoc, fMain, dMain;
procedure TfrmGoto.lstGotoClick(Sender: TObject);
resourcestring
SLineNum = 'Linenu&mber:';
SColNum = 'Columnnu&mber:';
SByte = 'By&te';
SBookMark = 'Book&mark:';
SError = 'O&utput/Error:';
begin
txtLineNum.Visible := (lstGoto.ItemIndex < 3);
cboBookmark.Visible := (lstGoto.ItemIndex = 3);
cboError.Visible := (lstGoto.ItemIndex = 4);
memDesc.Visible := (lstGoto.ItemIndex = 4);
case TGotoType(lstGoto.ItemIndex) of
gtLine:
begin
Label1.Caption := SLineNum;
txtLineNum.Text := IntToStr(fCurCaretPos.y);
Label1.FocusControl := txtLineNum;
btnOK.Enabled := length(Trim(txtLineNum.Text)) > 0;
end;
gtCol:
begin
Label1.Caption := SColNum;
txtLineNum.Text := IntToStr(fCurCaretPos.x);
Label1.FocusControl := txtLineNum;
btnOK.Enabled := length(Trim(txtLineNum.Text)) > 0;
end;
gtByte:
begin
Label1.Caption := SByte;
txtLineNum.Text := IntToStr(fByte);
Label1.FocusControl := txtLineNum;
btnOK.Enabled := length(Trim(txtLineNum.Text)) > 0;
end;
gtBookmark:
begin
Label1.Caption := SBookMark;
Label1.FocusControl := cboBookmark;
btnOK.Enabled := (cboBookmark.ItemIndex > -1);
end;
end;
end;
procedure TfrmGoto.SetCurCaretPos(Value: TPoint);
begin
fCurCaretPos := Value;
case lstGoto.ItemIndex of
0: txtLineNum.Text := IntToStr(fCurCaretPos.y);
1: txtLineNum.Text := IntToStr(fCurCaretPos.x);
end;
end;
function TfrmGoto.GetGotoType: TGotoType;
begin
Result := TGotoType(lstGoto.ItemIndex);
end;
procedure TfrmGoto.SetGotoType(AValue: TGotoType);
begin
lstGoto.ItemIndex := Ord(AValue);
lstGotoClick(nil);
end;
procedure TfrmGoto.btnOKClick(Sender: TObject);
var
i, x, y: integer;
begin
case lstGoto.ItemIndex of
0: fCurCaretPos.y := StrToInt(txtLineNum.Text);
1: fCurCaretPos.x := StrToInt(txtLineNum.Text);
2: fByte := StrToInt(txtLineNum.Text);
3:
begin
fByte := cboBookmark.ItemIndex; //;
//fCurCaretPos := Point(x, y);
end;
end;
end;
procedure TfrmGoto.FormShow(Sender: TObject);
begin
lstGotoClick(nil);
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -