⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fgoto.pas

📁 Delphi编写的一个支持语法高亮显示和很多语言的文本编辑器
💻 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 + -