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

📄 umfgeneratemessages_kyl.pas

📁 DelphiDoc is a program for automatic generation of documentation on a Delphi-Project. At the momen
💻 PAS
📖 第 1 页 / 共 3 页
字号:
     Result := Result + Message.Position.TheFile.InternalFileName;
     if Message.Position.Position.Row > 0 then
      Result := Result +
                Format(':%d:%d',
                       [Message.Position.Position.Row,
                        Message.Position.Position.Column]);
    end
   else
    if (Message.Position.UserDocPage <> '') or
       (Message.Position.UserDocFile <> '') then
     Result := Result + '~[userDoc ' + Message.Position.UserDocPage + '.' +
                        ExtractFileName(Message.Position.UserDocFile)
    else
     if (Message.Position.GUIPageFile <> '') or
        (Message.Position.GUIPageTopic <> '') then
      Result := Result + '~gui ' + Message.Position.GUIPageFile +
                         '#' + Message.Position.GUIPageTopic
     else
      HasPos := False;                          //no position for message known

  if HasPos then
   Result := Result + ': ';

  Result := Result + Message.Message;
 end;


          //kinds of shown messages
var       Filter             :TMessageSeriousnesses;
          i                  :Integer;           //counter through all messages
          Message            :TGeneratorMessage; //each message
          Heap               :PSortTree;         //tree to sort
          Data               :THeapDataItem;     //each item of the heap
begin
 try
//   SortOrder := soIndex;                 //set default sort order
   //get the set sort order
   SortOrder := TMessageSortOrder(ComboBoxSortOrder.ItemIndex);

   Filter := [];                         //no messages so far
   if CheckBoxFatal.Checked then         //fatal error messages wanted?
    Include(Filter, msFatal);
   if CheckBoxError.Checked then         //error messages wanted?
    Include(Filter, msError);
   if CheckBoxWarning.Checked then       //warning messages wanted?
    Include(Filter, msWarning);
   if CheckBoxHint.Checked then          //hints wanted?
    Include(Filter, msHint);
   if CheckBoxInformational.Checked then //informational messages wanted?
    Include(Filter, msInformational);

   Heap := nil;                            //empty heap so far
   try
     if Filter <> [] then                  //not all messages filtered?
      //add messages of generator
      for i := 0 to State.GenerationMessages.Count - 1 do //add messages
       begin
        Message := State.GenerationMessages[i];
        //message not filtered?
        if (State.GenerationMessageDescriptions[Message.MessageID][
                              Message.MessageNumber].Seriousness in Filter) and
           not FFilter.IsFiltered[
                  State.GenerationMessageDescriptions[Message.MessageID].Title,
                  Message.MessageNumber] then
         Heap := InsertElem(Message, i, Heap);        //message will be shown
       end;


     ListBox.Items.BeginUpdate;
     try
       ListBox.Clear;                               //clear messages

       while assigned(Heap) do                      //now fill the list
        begin
         Heap := GetDeleteMinElem(Heap, Data);        //sorted from the heap
         ListBox.Items.AddObject(GetMessageCaption(Data.Message),
                                 TObject(Data.Index));
        end;

     finally
      ListBox.Items.EndUpdate;
     end;

     assert(not assigned(Heap));
   finally
    while assigned(Heap) do                        //just in case:
     Heap := GetDeleteMinElem(Heap, Data);           //free heap
   end;
 except
   MessageDlg('Can''t show all messages in the list box.',
              mtWarning, [mbOK], ListBox.HelpContext);
 end;
end;
















{Called when a messages of the generation of the documentation is selected.
~param Sender the sender of the event, ~[link ListBox] }
procedure TMFGenerateMessagesKylix.ListBoxClick(Sender: TObject);
var       Pos                :String;      //position of the message
begin
 Memo.Text := '';                          //no information so far
 if (ListBox.ItemIndex >= 0) and (ListBox.ItemIndex < ListBox.Items.Count) then
  with State.GenerationMessages[TMessageNumber(
                                  ListBox.Items.Objects[ListBox.ItemIndex])],
       State.GenerationMessageDescriptions[MessageID],
       Descriptions[MessageNumber] do
   begin                                     //show the information
    Memo.Lines.Append('Seriousness: ' + MessageSeriousnesses[Seriousness]);
    Memo.Lines.Append(Format('Message IDs: %s (%d) - %d: ',
                             [Title, MessageID, MessageNumber]));

    if assigned(Position.Identifier) then
     begin
      Pos := Position.Identifier.InFile.InternalFileName + '.';
      if assigned(Position.Identifier.MemberOf) then
       Pos := Pos + Position.Identifier.MemberOf.Name + '.';
      Pos := Pos + Position.Identifier.Name;
     end
    else
     if assigned(Position.TheFile) then
      begin
       Pos := Position.TheFile.InternalFileName;
       if Position.Position.Row > 0 then
        Pos := Pos + Format(':%d:%d', [Position.Position.Row,
                                       Position.Position.Column]);
      end
     else
      if (Position.UserDocPage <> '') or (Position.UserDocFile <> '') then
       Pos := '~[userDoc ' + Position.UserDocPage + '.' +
              ExtractFileName(Position.UserDocFile)
      else
       if (Position.GUIPageFile <> '') or (Position.GUIPageTopic <> '') then
        Pos := Pos + '~gui ' + Position.GUIPageFile + '#' +
                     Position.GUIPageTopic
       else
        Pos := '';
    if Pos <> '' then
     Memo.Lines.Append('Position: ' + Pos);


    Memo.Lines.Append(Message);

    Memo.Lines.Append('');
    Memo.Lines.Append('General Description:');
    Memo.Lines.Append(Text);
    Memo.Lines.Append('');
    Memo.Lines.Append('Help:');
    Memo.Lines.Append(HelpText);
    Memo.SelStart := 0;
    Memo.SelLength := 0;
   end;
end;

{Called when a messages of the generation of the documentation is double
 clicked.
~param Sender the sender of the event, ~[link ListBox] }
procedure TMFGenerateMessagesKylix.ListBoxDblClick(Sender: TObject);
begin
 //a message selected in the list box?
 if (ListBox.ItemIndex >= 0) and (ListBox.ItemIndex < ListBox.Items.Count) then
  with State.GenerationMessages[TMessageNumber(
                                  ListBox.Items.Objects[ListBox.ItemIndex])] do
   if assigned(Position.Identifier) or assigned(Position.TheFile) then
    //show the source code at the delcaration of the identifier/file in the
    ShowSourceCode(Self, Position.Identifier,                   //message
                   Position.TheFile, Position.Position,
                   Position.TheFile, Position.Position);
end;




{Called when of the button to filter the messages is chosen.
~param Sender the sender of the event, ~[link BitBtnFilter] }
procedure TMFGenerateMessagesKylix.BitBtnFilterClick(Sender: TObject);
begin
 //edit the filter
 if EditMessageFilter(State.GenerationMessageDescriptions, FFilter) then
  ShowMessages;                //update the shown messages with the new filter
end;

{Called when of the check boxes to filter the messages or the combo box of
 their sort order is changed.
~param Sender the sender of the event, ~[link CheckBoxFatal],
              ~[link CheckBoxError], ~[link CheckBoxWarning],
              ~[link CheckBoxHint], ~[link CheckBoxInformational] or
              ~[link ComboBoxSortOrder] }
procedure TMFGenerateMessagesKylix.CheckBoxesClick(Sender: TObject);
begin
 ShowMessages;         //update the shown messages with the new filter or order
end;




{Called when of the menu item to filter all messages with the same ID as the
 current is chosen.
~param Sender the sender of the event, ~[link MenuItemFilterMessage] }
procedure TMFGenerateMessagesKylix.MenuItemFilterMessageClick(Sender: TObject);
begin
 //a message selected in the list box?
 if (ListBox.ItemIndex >= 0) and (ListBox.ItemIndex < ListBox.Items.Count) then
  with State.GenerationMessages[TMessageNumber(
                                  ListBox.Items.Objects[ListBox.ItemIndex])] do
   begin                        //filter the current message
    FFilter.IsFiltered[State.GenerationMessageDescriptions[MessageID].Title,
                       MessageNumber] := True;
    ShowMessages;               //update the shown messages with the new filter
   end;
end;

{Called when of the menu item to filter all messages of the same source as the
 current is chosen.
~param Sender the sender of the event, ~[link MenuItemFilterMessagesOfSource] }
procedure TMFGenerateMessagesKylix.MenuItemFilterMessagesOfSourceClick(Sender: TObject);
begin
 //a message selected in the list box?
 if (ListBox.ItemIndex >= 0) and (ListBox.ItemIndex < ListBox.Items.Count) then
  with State.GenerationMessages[TMessageNumber(
                                  ListBox.Items.Objects[ListBox.ItemIndex])],
       State.GenerationMessageDescriptions[MessageID] do
   begin
                     //make sure the filter contains all messages
    FFilter.IsFiltered[Title, Count - 1] := True;
                     //filter all messages of the source of the current message
    FFilter.AllFiltered[Title] := mfsFiltered;
    ShowMessages;    //update the shown messages with the new filter
   end;
end;

{Called when of the menu item to show all messages (remove the filter) is
 chosen.
~param Sender the sender of the event, ~[link MenuItemShowAllMessages] }
procedure TMFGenerateMessagesKylix.MenuItemShowAllMessagesClick(Sender: TObject);
begin                           //show all messages of the last generation
 FFilter.DescFiltered[State.GenerationMessageDescriptions] := mfsNotFiltered;
 ShowMessages;                  //update the shown messages with the new filter
end;

{Called when of the menu item to show clear the filter completely is chosen.
~param Sender the sender of the event, ~[link MenuItemClearFilter] }
procedure TMFGenerateMessagesKylix.MenuItemClearFilterClick(Sender: TObject);
begin
 FFilter.ClearFilter;           //clear the filter
 ShowMessages;                  //update the shown messages with the new filter
end;


{Called when the menu item to copy the selected items is clicked.
~param Sender the sender of the event, ~[link MenuItemCopySelected] }
procedure TMFGenerateMessagesKylix.MenuItemCopySelectedClick(Sender: TObject);
begin
 SelectedListBoxItemsToClipboard(ListBox);
end;

{Called when the menu item to copy the whole content is clicked.
~param Sender the sender of the event, ~[link MenuItemCopyAll] }
procedure TMFGenerateMessagesKylix.MenuItemCopyAllClick(Sender: TObject);
begin
 ListBoxItemsToClipboard(ListBox);
end;

{Called when the menu item to save the content is clicked.
~param Sender the sender of the event, ~[link MenuItemSaveTo] }
procedure TMFGenerateMessagesKylix.MenuItemSaveToClick(Sender: TObject);
begin
 ListBoxItemsToFile(ListBox, MenuItemSaveTo.HelpContext);
end;

end.
 

⌨️ 快捷键说明

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