Experimental GExperts Version 1.38 2016-01-09 released

New year, new GExperts 😉

I just want to show off the one new feature that resides in the IDE tab of the configuration dialog:

GExperts Configuration-Enhance-Install-Packages2

(I also fixed the tab order in this dialog.)

What does it do? Quite simpple: It shows a little ‘…’ button in the package list dialog(s). You get this dialog by either selecting Component -> Install Packages or as part of the Project Options dialog:

GExperts-Install-Packages

A click on this button will open a new explorer window showing the directory in which the selected package resides and where the file is selected.

The code for opening the explorer window btw. is very simple:

  ShellExecute(0, nil, 'explorer.exe', PChar('/select,' + FPkgNameLabel.Caption), nil, SW_SHOWNORMAL)

The more complex part this time was to find the controls to modify because their names and classes have changed between the various Delphi versions. I had to even hack two different dialogs one called DlgPackageCheckList: TDlgPackageCheckList the other DelphiProjectOptionsDialog: TDelphiProjectOptionsDialog or in earlier Delphi versions ProjectOptionsDialog: TProjectOptionsDialog.

Unfortunately one additional feature I had planned apparently isn’t possible: Changing the description of a package. I could have sworn that the descriptions are read from the registry, but my experiments have shown that even though these descriptions are stored there, apparently the Delphi IDE does not display them but rather reads them from the package files. That’s a pity because I already had the button and code for doing this in place.

OK, I lied, there is more:

A new Expert shows the bookmarks set in the currently active editor view plus some context. You can double click on the list to jump to these bookmarks or use context menu to add, edit or delete bookmarks.

GExperts-Bookmark-Expert

The Open Tools API functionality for bookmarks is rather rudimentary. There is no way to actually edit bookmarks, all you can do is read them, set a new one, toggle one and jump to one:

type
  IOTAEditView140 = interface(IOTAEditView40)
    function BookmarkGoto(BookmarkID: Integer): Boolean;
    function BookmarkRecord(BookmarkID: Integer): Boolean;
    function BookmarkToggle(BookmarkID: Integer): Boolean;
[...]
    function GetBookmarkPos(BookmarkID: Integer): TOTACharPos;

So in order to change the line of an existing bookmark, you have to:

  • Save the current cursor position
  • Move the cursor to the line of the bookmark
  • Place the bookmark
  • And finally restore the cursor position
procedure TfmGxBookmarksForm.SetBookmark(const _ModuleName: string; _LineNo: Integer; _BmIdx: Integer = -1);
var
  EditView: IOTAEditView;
  SaveCursorPos: TOTAEditPos;
  BmEditPos: TOTAEditPos;
begin
  if not TryGetEditView(_ModuleName, EditView) then
    Exit;

  SaveCursorPos := EditView.GetCursorPos;
  try
    BmEditPos.Line := _LineNo;
    BmEditPos.Col := 1;
    EditView.SetCursorPos(BmEditPos);
    EditView.BookmarkRecord(_BmIdx);
  finally
    EditView.SetCursorPos(SaveCursorPos);
  end;
end;

btw: Did you know that bookmarks not only store the line but also the character position? You can have two bookmarks in the same line at different character positions.

With that out of the way, there is one small enhancement to GExperts itself. On an additional tab of the configuration dialog you can now re-enable messages that you had permanently suppressed:

GExperts Configuration-Suppressed-Messages

Up to now you had to use RegEdit for doing that:

GExperts-Suppressed-Messages

The are stored in

HKEY_CURRENT_USER\Software\Embarcadero\BDS\17.0\GExperts\Misc\SuppressedMesages

The key changed with the Delphi version, older versions use Borland or Codegear instead of Embarcadero, and Delphi instead of BDS. Delphi 10 Seattle is actually the 16th Delphi version. They cowardly left out version 13 (and we all want to forget version 8).