113 lines
2.7 KiB
Plaintext
113 lines
2.7 KiB
Plaintext
{
|
|
JVCL Server Pages specific support
|
|
}
|
|
|
|
unit rasp;
|
|
|
|
{ Global variables }
|
|
var
|
|
RaspItem: TMenuItem;
|
|
RaspItemAdd: TMenuItem;
|
|
RaspItemFind: TMenuItem;
|
|
RaspItemGoto: TMenuItem;
|
|
|
|
|
|
{ function NewItem(const ACaption: string; AShortCut: TShortCut; AChecked, AEnabled: Boolean; AOnClick: TNotifyEvent; hCtx: Word; const AName: string): TMenuItem; }
|
|
|
|
procedure InitRasp;
|
|
var
|
|
Empty: Integer;
|
|
Ctrl: Integer;
|
|
begin
|
|
RaspItem := nil;
|
|
RaspItem := NewItem('&RASP', 0, False, True, 0, nil {ignored - always must be nil}, 'miRasp');
|
|
MainWindow.Menu.Items.Insert(MainWindow.Menu.Items.Count - 1, RaspItem);
|
|
RaspItem.OnClick := RASPClick;
|
|
RaspItem.Visible := False;
|
|
|
|
Empty := [];
|
|
Ctrl := [ssCtrl];
|
|
|
|
RaspItemFind := NewItem('Find Program Item', ShortCut(VK_F5, Empty), False, True, 0, 0, 'miRaspFindProgramItem');
|
|
RaspItemFind.OnClick := RASPFindProgramItemClick;
|
|
RaspItem.Add(RaspItemFind);
|
|
|
|
RaspItemGoto := NewItem('Go To Line Number', ShortCut(ord('G'), Ctrl), False, True, 0, 0, 'miRaspGotoLineNumber');
|
|
RaspItemGoto.OnClick := RASPGotoLineNumberClick;
|
|
RaspItem.Add(RaspItemGoto);
|
|
|
|
end;
|
|
|
|
function IsRaspFile(FileName: string): Boolean;
|
|
begin
|
|
Result := Cmp(ExtractFileExt(FileName), '.rasp') or
|
|
Cmp(ExtractFileExt(FileName), '.thtm');
|
|
//Result := True; // line for debug purposes
|
|
end;
|
|
|
|
procedure OpenRasp(FileName: string);
|
|
begin
|
|
RaspItem.Visible := IsRaspFile(FileName);
|
|
end;
|
|
|
|
procedure CloseRasp(FileName: string);
|
|
begin
|
|
RaspItem.Visible := False;
|
|
end;
|
|
|
|
procedure RASPClick(Sender: TObject);
|
|
var
|
|
P: Integer;
|
|
begin
|
|
P := Pos('#item program', Editor.Lines.Text);
|
|
RASPItemFind.Enabled := P > 0;
|
|
RASPItemGoto.Enabled := RASPItemFind.Enabled;
|
|
end;
|
|
|
|
procedure RASPFindProgramItemClick(Sender: TObject);
|
|
var
|
|
P: Integer;
|
|
L: Integer;
|
|
begin
|
|
P := Pos('#item program', Editor.Lines.Text);
|
|
if P > 0 then
|
|
begin
|
|
//Editor.SelStart := P;
|
|
L := GetLineByPos(Editor.Lines.Text, P);
|
|
Editor.BeginUpdate;
|
|
try
|
|
Editor.SetLeftTop(0, L);
|
|
Editor.CaretX := 0;
|
|
Editor.CaretY := L + 1;
|
|
Editor.BaseLine := L;
|
|
finally
|
|
Editor.EndUpdate;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure RASPGotoLineNumberClick(Sender: TObject);
|
|
var
|
|
P: Integer;
|
|
L: Integer;
|
|
S: string;
|
|
N: Integer;
|
|
begin
|
|
if InputQuery('Go to line number', 'Line number:', S) then
|
|
begin
|
|
P := Pos('#item program', Editor.Lines.Text);
|
|
if P > 0 then
|
|
L := GetLineByPos(Editor.Lines.Text, P)
|
|
else
|
|
L := 0;
|
|
Editor.BaseLine := L + 1;
|
|
N := L + StrToInt(S);
|
|
Editor.CaretX := 0;
|
|
Editor.CaretY := N;
|
|
Editor.SetLeftTop(0, N - Editor.VisibleRowCount div 2);
|
|
end;
|
|
end;
|
|
|
|
|
|
end.
|