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

📄 compform.pas

📁 源代码
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  else begin
    { Restore original priority }
    if FSavePriorityClass <> 0 then begin
      SetPriorityClass(GetCurrentProcess, FSavePriorityClass);
      FSavePriorityClass := 0;
    end;
  end;
end;

procedure TCompileForm.SyncEditorOptions;
begin
  if FOptions.UseSyntaxHighlighting then
    Memo.Highlighter := SynMultiSyn1
  else
    Memo.Highlighter := nil;

  if FOptions.CursorPastEOL then
    Memo.Options := Memo.Options + [eoScrollPastEol]
  else
    Memo.Options := Memo.Options - [eoScrollPastEol];

  Memo.TabWidth := FOptions.TabWidth;
end;

procedure TCompileForm.FMenuClick(Sender: TObject);

  function DoubleAmp(const S: String): String;
  var
    I: Integer;
  begin
    Result := S;
    I := 1;
    while I <= Length(Result) do begin
      if Result[I] = '&' then begin
        Inc(I);
        Insert('&', Result, I);
        Inc(I);
      end
      else
        Inc(I, CharLength(S, I));
    end;
  end;

var
  I: Integer;
begin
  ReadMRUList;
  FMRUSep.Visible := FMRUList.Count <> 0;
  for I := 0 to High(FMRUMenuItems) do
    with FMRUMenuItems[I] do begin
      if I < FMRUList.Count then begin
        Visible := True;
        Caption := '&' + IntToStr((I+1) mod 10) + ' ' + DoubleAmp(FMRUList[I]);
      end
      else
        Visible := False;
    end;
end;

procedure TCompileForm.FNewClick(Sender: TObject);
begin
  if ConfirmCloseFile(True) then
    NewFile;
end;

procedure TCompileForm.FNewWizardClick(Sender: TObject);
begin
  if ConfirmCloseFile(True) then
    NewWizardFile;
end;

procedure TCompileForm.ShowOpenDialog(const Examples: Boolean);
begin
  if Examples then begin
    OpenDialog.InitialDir := PathExtractPath(ParamStr(0)) + 'Examples';
    OpenDialog.Filename := PathExtractPath(ParamStr(0)) + 'Examples\Example1.iss';
  end
  else begin
    OpenDialog.InitialDir := '';
    OpenDialog.Filename := '';
  end;
  if ConfirmCloseFile(True) then
    if OpenDialog.Execute then
      OpenFile(OpenDialog.Filename);
end;

procedure TCompileForm.FOpenClick(Sender: TObject);
begin
  ShowOpenDialog(False);
end;

procedure TCompileForm.FSaveClick(Sender: TObject);
begin
  SaveFile(False);
end;

procedure TCompileForm.FSaveAsClick(Sender: TObject);
begin
  SaveFile(True);
end;

procedure TCompileForm.FMRUClick(Sender: TObject);
var
  I: Integer;
begin
  if ConfirmCloseFile(True) then
    for I := 0 to High(FMRUMenuItems) do
      if FMRUMenuItems[I] = Sender then begin
        OpenFile(FMRUList[I]);
        Break;
      end;
end;

procedure TCompileForm.FExitClick(Sender: TObject);
begin
  Close;
end;

procedure TCompileForm.EMenuClick(Sender: TObject);
begin
  EUndo.Enabled := Memo.CanUndo;
  ERedo.Enabled := Memo.CanRedo;
  ECut.Enabled := Memo.SelAvail;
  ECopy.Enabled := Memo.SelAvail;
  EPaste.Enabled := Clipboard.HasFormat(CF_TEXT);
  EDelete.Enabled := Memo.SelAvail;
end;

procedure TCompileForm.PopupMenu1Popup(Sender: TObject);
begin
  PUndo.Enabled := Memo.CanUndo;
  PRedo.Enabled := Memo.CanRedo;
  PCut.Enabled := Memo.SelAvail;
  PCopy.Enabled := Memo.SelAvail;
  PPaste.Enabled := Clipboard.HasFormat(CF_TEXT);
  PDelete.Enabled := Memo.SelAvail;
end;

procedure TCompileForm.EUndoClick(Sender: TObject);
begin
  Memo.Undo;
end;

procedure TCompileForm.ERedoClick(Sender: TObject);
begin
  Memo.Redo;
end;

procedure TCompileForm.ECutClick(Sender: TObject);
begin
  Memo.CutToClipboard;
end;

procedure TCompileForm.ECopyClick(Sender: TObject);
begin
  Memo.CopyToClipboard;
end;

procedure TCompileForm.EPasteClick(Sender: TObject);
begin
  Memo.PasteFromClipboard;
end;

procedure TCompileForm.EDeleteClick(Sender: TObject);
begin
  Memo.ClearSelection;
end;

procedure TCompileForm.ESelectAllClick(Sender: TObject);
begin
  Memo.SelectAll;
end;

procedure TCompileForm.VMenuClick(Sender: TObject);
begin
  VToolbar.Checked := ToolbarPanel.Visible;
  VStatusBar.Checked := StatusBar.Visible;
  VHide.Checked := not StatusPanel.Visible;
  VCompilerOutput.Checked := StatusPanel.Visible and (TabSet.TabIndex = tiCompilerOutput);
  VDebugOutput.Checked := StatusPanel.Visible and (TabSet.TabIndex = tiDebugOutput);
end;

procedure TCompileForm.VToolbarClick(Sender: TObject);
begin
  ToolbarPanel.Visible := not ToolbarPanel.Visible;
end;

procedure TCompileForm.VStatusBarClick(Sender: TObject);
begin
  StatusBar.Visible := not StatusBar.Visible;
end;

procedure TCompileForm.SetStatusPanelVisible(const AVisible: Boolean);
begin
  if StatusPanel.Visible <> AVisible then begin
    if AVisible then begin
      { Ensure the status panel height isn't out of range before showing }
      UpdateStatusPanelHeight(StatusPanel.Height);
      SplitPanel.Top := ClientHeight;
      StatusPanel.Top := ClientHeight;
    end;
    SplitPanel.Visible := AVisible;
    StatusPanel.Visible := AVisible;
  end;
end;

procedure TCompileForm.VHideClick(Sender: TObject);
begin
  SetStatusPanelVisible(False);
end;

procedure TCompileForm.VCompilerOutputClick(Sender: TObject);
begin
  TabSet.TabIndex := tiCompilerOutput;
  SetStatusPanelVisible(True);
end;

procedure TCompileForm.VDebugOutputClick(Sender: TObject);
begin
  TabSet.TabIndex := tiDebugOutput;
  SetStatusPanelVisible(True);
end;

procedure TCompileForm.BMenuClick(Sender: TObject);
begin
  BLowPriority.Checked := FOptions.LowPriorityDuringCompile;
end;

procedure TCompileForm.BCompileClick(Sender: TObject);
begin
  CompileFile(FFilename, False);
end;

procedure TCompileForm.BStopCompileClick(Sender: TObject);
begin
  FCompileWantAbort := True;
end;

procedure TCompileForm.BLowPriorityClick(Sender: TObject);
begin
  FOptions.LowPriorityDuringCompile := not FOptions.LowPriorityDuringCompile;
  { If a compile is already in progress, change the priority now }
  if FCompiling then
    SetLowPriority(FOptions.LowPriorityDuringCompile);
end;

procedure TCompileForm.HMenuClick(Sender: TObject);
begin
  HISPPDoc.Visible := NewFileExists(PathExtractPath(ParamStr(0)) + 'ISPP.hlp');
  HISPPWebsite.Visible := HISPPDoc.Visible;
  HISPPSep.Visible := HISPPDoc.Visible;
end;

procedure TCompileForm.HDocClick(Sender: TObject);
begin
  Application.HelpCommand(HELP_FINDER, 0);
end;

procedure TCompileForm.MemoKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  S: String;
begin
  if Key = VK_F1 then begin
    S := Memo.WordAtCursor;
    if S <> '' then
      Application.HelpCommand(HELP_KEY, Integer(PChar(S)))
    else
      Application.HelpCommand(HELP_FINDER, 0);
  end;
end;

procedure TCompileForm.HFaqClick(Sender: TObject);
begin
  ShellExecute(Application.Handle, 'open',
    PChar(PathExtractPath(ParamStr(0)) + 'isfaq.htm'), nil, nil, SW_SHOW);
end;

procedure TCompileForm.HWebsiteClick(Sender: TObject);
begin
  ShellExecute(Application.Handle, 'open', 'http://www.innosetup.com/', nil,
    nil, SW_SHOW);
end;

procedure TCompileForm.HPSWebsiteClick(Sender: TObject);
begin
  ShellExecute(Application.Handle, 'open', 'http://www.remobjects.com/?ps', nil,
    nil, SW_SHOW);
end;

procedure TCompileForm.HISPPDocClick(Sender: TObject);
begin
  WinHelp(Handle, PChar(PathExtractPath(ParamStr(0)) + 'ISPP.hlp'), HELP_INDEX, 0);
end;

procedure TCompileForm.HISPPWebsiteClick(Sender: TObject);
begin
  ShellExecute(Application.Handle, 'open', 'http://ispp.sourceforge.net/', nil,
    nil, SW_SHOW);
end;

procedure TCompileForm.HDonateClick(Sender: TObject);
begin
  ShellExecute(Application.Handle, 'open', 'http://www.jrsoftware.org/isdonate.php', nil,
    nil, SW_SHOW);
end;

procedure TCompileForm.HAboutClick(Sender: TObject);
var
  S: String;
begin
  { Removing the About box or modifying any existing text inside it is a
    violation of the Inno Setup license agreement; see LICENSE.TXT.
    However, adding additional lines to the About box is permitted, as long as
    they are placed below the original copyright notice. }
  S := FCompilerVersion.Title + ' Compiler version ' +
    FCompilerVersion.Version + SNewLine;
  if FCompilerVersion.Title <> 'Inno Setup' then
    S := S + (SNewLine + 'Based on Inno Setup' + SNewLine);
  S := S + ('Copyright (C) 1997-2004 Jordan Russell' + SNewLine +
    'Portions Copyright (C) 2000-2004 Martijn Laan' + SNewLine +
    'All rights reserved.' + SNewLine2 +
    'Inno Setup home page:' + SNewLine +
    'http://www.innosetup.com/' + SNewLine2 +
    'RemObjects Pascal Script home page:' + SNewLine +
    'http://www.remobjects.com/?ps' + SNewLine2 +
    'Refer to LICENSE.TXT for conditions of distribution and use.');
  MsgBox(S, 'About ' + FCompilerVersion.Title, mbInformation, MB_OK);
end;

procedure TCompileForm.WMStartCommandLineCompile(var Message: TMessage);
var
  Code: Integer;
begin
  UpdateStatusPanelHeight(ClientHeight);
  Code := 0;
  try
    try
      CompileFile(CommandLineFilename, True);
    except
      Code := 2;
      Application.HandleException(Self);
    end;
  finally
    Halt(Code);
  end;
end;

procedure TCompileForm.WMStartCommandLineWizard(var Message: TMessage);
var
  Code: Integer;
begin
  Code := 0;
  try
    try
      NewWizardFile;
    except
      Code := 2;
      Application.HandleException(Self);
    end;
  finally
    Halt(Code);
  end;
end;

procedure TCompileForm.WMShowStartupForm(var Message: TMessage);
var
  StartupForm: TStartupForm;
  Ini: TConfigIniFile;
begin
  ReadMRUList;
  StartupForm := TStartupForm.Create(Application);
  try
    StartupForm.MRUList := FMRUList;
    StartupForm.StartupCheck.Checked := not FOptions.ShowStartupForm;
    if StartupForm.ShowModal = mrOK then begin
      if FOptions.ShowStartupForm <> not StartupForm.StartupCheck.Checked then begin
        FOptions.ShowStartupForm := not StartupForm.StartupCheck.Checked;
        Ini := TConfigIniFile.Create;
        try
          Ini.WriteBool('Options', 'ShowStartupForm', FOptions.ShowStartupForm);
        finally
          Ini.Free;
        end;
      end;
      case StartupForm.Result of
        srEmpty:
          FNewClick(Self);
        srWizard:
          FNewWizardClick(Self);
        srOpenFile:
          if ConfirmCloseFile(True) then
            OpenFile(StartupForm.ResultFileName);
        srOpenDialog:
          ShowOpenDialog(False);
        srOpenDialogExamples:
          ShowOpenDialog(True);
      end;
    end;
  finally
    StartupForm.Free;
  end;
end;

procedure TCompileForm.InitializeFindText(Dlg: TFindDialog);
var
  S: String;
begin
  S := Memo.SelText;
  if (S <> '') and (Pos(#13, S) = 0) and (Pos(#10, S) = 0) then
    Dlg.FindText := S
  else
    Dlg.FindText := FLastFindText;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -