converted msgview to lfm from Darius

git-svn-id: trunk@7910 -
This commit is contained in:
mattias 2005-10-04 21:25:31 +00:00
parent 5c7856fa49
commit db444336d3
4 changed files with 274 additions and 219 deletions

2
.gitattributes vendored
View File

@ -917,6 +917,8 @@ ide/mainbase.pas svneol=native#text/pascal
ide/mainintf.pas svneol=native#text/pascal
ide/makeresstrdlg.pas svneol=native#text/pascal
ide/miscoptions.pas svneol=native#text/pascal
ide/msgview.lfm svneol=native#text/plain
ide/msgview.lrs svneol=native#text/plain
ide/msgview.pp svneol=native#text/pascal
ide/msgvieweditor.lfm svneol=native#text/plain
ide/msgvieweditor.lrs svneol=native#text/pascal

29
ide/msgview.lfm Normal file
View File

@ -0,0 +1,29 @@
object MessagesView: TMessagesView
BorderStyle = bsSizeToolWin
Caption = 'MessagesView'
ClientHeight = 79
ClientWidth = 722
KeyPreview = True
OnKeyDown = MessagesViewKeyDown
PixelsPerInch = 96
Position = poScreenCenter
HorzScrollBar.Page = 721
VertScrollBar.Page = 78
Left = 262
Height = 79
Top = 518
Width = 722
object MessageView: TListBox
Align = alClient
BorderSpacing.OnChange = nil
MultiSelect = True
PopupMenu = MainPopupMenu
TabOrder = 0
Height = 79
Width = 722
end
object MainPopupMenu: TPopupMenu
left = 46
top = 41
end
end

12
ide/msgview.lrs Normal file
View File

@ -0,0 +1,12 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TMessagesView','FORMDATA',[
'TPF0'#13'TMessagesView'#12'MessagesView'#11'BorderStyle'#7#13'bsSizeToolWin'
+#7'Caption'#6#12'MessagesView'#12'ClientHeight'#2'O'#11'ClientWidth'#3#210#2
+#10'KeyPreview'#9#9'OnKeyDown'#7#19'MessagesViewKeyDown'#13'PixelsPerInch'#2
+'`'#8'Position'#7#14'poScreenCenter'#18'HorzScrollBar.Page'#3#209#2#18'VertS'
+'crollBar.Page'#2'N'#4'Left'#3#6#1#6'Height'#2'O'#3'Top'#3#6#2#5'Width'#3#210
+#2#0#8'TListBox'#11'MessageView'#5'Align'#7#8'alClient'#11'MultiSelect'#9#9
+'PopupMenu'#7#13'MainPopupMenu'#8'TabOrder'#2#0#6'Height'#2'O'#5'Width'#3#210
+#2#0#0#10'TPopupMenu'#13'MainPopupMenu'#4'left'#2'.'#3'top'#2')'#0#0#0
]);

View File

@ -37,21 +37,35 @@ unit MsgView;
interface
uses
Classes, SysUtils, LCLProc, Controls, StdCtrls, Forms, Menus, LResources,
ClipBrd, Dialogs, InputHistory, FileUtil,
Classes,
ClipBrd,
Controls,
DialogProcs,
Dialogs,
EnvironmentOpts,
FileUtil,
Forms,
IDECommands,
IDEOptionDefs,
IDEProcs,
InputHistory,
KeyMapping,
LazarusIDEStrConsts,
LCLProc,
LResources,
MenuIntf,
IDEProcs, IDEOptionDefs, DialogProcs, IDECommands, EnvironmentOpts,
LazarusIDEStrConsts, KeyMapping;
Menus,
StdCtrls,
SysUtils;
type
{ TMessageLine }
TMessageLine = class
private
FDirectory: string;
FMsg: string;
FMsg: string;
FOriginalIndex: integer;
FParts: TStrings;
FParts: TStrings;
FPosition: integer;
FVisiblePosition: integer;
procedure SetDirectory(const AValue: string);
@ -59,31 +73,27 @@ type
public
constructor Create;
destructor Destroy; override;
property Msg: string read FMsg write SetMsg;
property Directory: string read FDirectory write SetDirectory;
property Position: integer read FPosition;
property VisiblePosition: integer read FVisiblePosition;
property OriginalIndex: integer read FOriginalIndex;
property Parts: TStrings read FParts write FParts;
property Msg: string Read FMsg Write SetMsg;
property Directory: string Read FDirectory Write SetDirectory;
property Position: integer Read FPosition;
property VisiblePosition: integer Read FVisiblePosition;
property OriginalIndex: integer Read FOriginalIndex;
property Parts: TStrings Read FParts Write FParts;
end;
{ TMessagesView }
TOnFilterLine = procedure(MsgLine: TMessageLine; var Show: boolean) of object;
{ TMessagesView }
{ TMessagesView }
TMessagesView = class(TForm)
MessageView: TListBox;
MessageView: TListBox;
MainPopupMenu: TPopupMenu;
procedure CopyAllMenuItemClick(Sender: TObject);
procedure CopyMenuItemClick(Sender: TObject);
procedure HelpMenuItemClick(Sender: TObject);
procedure MessageViewDblClicked(Sender: TObject);
Procedure MessageViewClicked(sender : TObject);
procedure MessagesViewKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure MessageViewClicked(Sender: TObject);
procedure MessagesViewKeyDown(Sender: TObject; var Key: word;
Shift: TShiftState);
procedure SaveAllToFileMenuItemClick(Sender: TObject);
private
FItems: TList; // list of TMessageLine
@ -92,21 +102,21 @@ type
FOnSelectionChanged: TNotifyEvent;
function GetDirectory: string;
function GetItems(Index: integer): TMessageLine;
Function GetMessage: String;
function GetMessage: string;
function GetVisibleItems(Index: integer): TMessageLine;
procedure SetLastLineIsProgress(const AValue: boolean);
protected
fBlockCount: integer;
Function GetSelectedLineIndex: Integer;
procedure SetSelectedLineIndex(const AValue: Integer);
function GetSelectedLineIndex: integer;
procedure SetSelectedLineIndex(const AValue: integer);
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure DeleteLine(Index: integer);
procedure Add(const Msg, CurDir: String; ProgressLine,
VisibleLine: boolean; OriginalIndex: integer);
procedure AddMsg(const Msg, CurDir: String; OriginalIndex: integer);
procedure AddProgress(const Msg, CurDir: String);
procedure Add(const Msg, CurDir: string;
ProgressLine, VisibleLine: boolean; OriginalIndex: integer);
procedure AddMsg(const Msg, CurDir: string; OriginalIndex: integer);
procedure AddProgress(const Msg, CurDir: string);
procedure AddSeparator;
procedure ClearTillLastSeparator;
procedure ShowTopMessage;
@ -121,16 +131,16 @@ type
procedure FilterLines(Filter: TOnFilterLine);
procedure SaveMessagesToFile(const Filename: string);
public
property LastLineIsProgress: boolean read FLastLineIsProgress
write SetLastLineIsProgress;
property Message: String read GetMessage;
property Directory: string read GetDirectory;
property SelectedMessageIndex: Integer read GetSelectedLineIndex // visible index
write SetSelectedLineIndex;
property OnSelectionChanged: TNotifyEvent read FOnSelectionChanged
write FOnSelectionChanged;
property Items[Index: integer]: TMessageLine read GetItems;
property VisibleItems[Index: integer]: TMessageLine read GetVisibleItems;
property LastLineIsProgress: boolean Read FLastLineIsProgress
Write SetLastLineIsProgress;
property Message: string Read GetMessage;
property Directory: string Read GetDirectory;
property SelectedMessageIndex: integer Read GetSelectedLineIndex // visible index
Write SetSelectedLineIndex;
property OnSelectionChanged: TNotifyEvent
Read FOnSelectionChanged Write FOnSelectionChanged;
property Items[Index: integer]: TMessageLine Read GetItems;
property VisibleItems[Index: integer]: TMessageLine Read GetVisibleItems;
end;
var
@ -147,60 +157,49 @@ procedure RegisterStandardMessagesViewMenuItems;
implementation
const SeparatorLine = '---------------------------------------------';
const
SeparatorLine = '---------------------------------------------';
procedure RegisterStandardMessagesViewMenuItems;
var
Path: String;
Path: string;
begin
MessagesMenuRoot:=RegisterIDEMenuRoot(MessagesMenuRootName);
Path:=MessagesMenuRoot.Name;
MsgCopyIDEMenuCommand:=RegisterIDEMenuCommand(Path,'Copy selected',
lisCopySelectedMessagesToClipboard);
MsgCopyAllIDEMenuCommand:=RegisterIDEMenuCommand(Path,'Copy all',
lisCopyAllMessagesToClipboard);
MsgHelpIDEMenuCommand:=RegisterIDEMenuCommand(Path,'Help',
srVK_HELP);
MsgSaveAllToFileIDEMenuCommand:=RegisterIDEMenuCommand(Path,'Copy selected',
lisSaveAllMessagesToFile);
MessagesMenuRoot := RegisterIDEMenuRoot(MessagesMenuRootName);
Path := MessagesMenuRoot.Name;
MsgCopyIDEMenuCommand := RegisterIDEMenuCommand(Path, 'Copy selected',
lisCopySelectedMessagesToClipboard);
MsgCopyAllIDEMenuCommand := RegisterIDEMenuCommand(Path, 'Copy all',
lisCopyAllMessagesToClipboard);
MsgHelpIDEMenuCommand := RegisterIDEMenuCommand(Path, 'Help',
srVK_HELP);
MsgSaveAllToFileIDEMenuCommand :=
RegisterIDEMenuCommand(Path, 'Copy selected',
lisSaveAllMessagesToFile);
end;
{ TMessagesView }
{------------------------------------------------------------------------------
TMessagesView.Create
------------------------------------------------------------------------------}
constructor TMessagesView.Create(TheOwner : TComponent);
Begin
constructor TMessagesView.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
Name := NonModalIDEWindowNames[nmiwMessagesViewName];
FItems:=TList.Create;
FVisibleItems:=TList.Create;
Name := NonModalIDEWindowNames[nmiwMessagesViewName];
FItems := TList.Create;
FVisibleItems := TList.Create;
Caption:=lisMenuViewMessages;
MessageView := TListBox.Create(Self);
With MessageView do Begin
Parent:= Self;
Align:= alClient;
end;
MainPopupMenu:=TPopupMenu.Create(Self);
MessageView.PopupMenu:=MainPopupMenu;
Caption := lisMenuViewMessages;
// assign the root TMenuItem to the registered menu root.
// This will automatically create all registered items
MessagesMenuRoot.MenuItem:=MainPopupMenu.Items;
MessagesMenuRoot.MenuItem := MainPopupMenu.Items;
//MainPopupMenu.Items.WriteDebugReport('TMessagesView.Create ');
MsgHelpIDEMenuCommand.OnClick:=@HelpMenuItemClick;
MsgCopyIDEMenuCommand.OnClick:=@CopyMenuItemClick;
MsgCopyAllIDEMenuCommand.OnClick:=@CopyAllMenuItemClick;
MsgSaveAllToFileIDEMenuCommand.OnClick:=@SaveAllToFileMenuItemClick;
EnvironmentOptions.IDEWindowLayoutList.Apply(Self,Name);
KeyPreview:=true;
OnKeyDown:=@MessagesViewKeyDown;
MsgHelpIDEMenuCommand.OnClick := @HelpMenuItemClick;
MsgCopyIDEMenuCommand.OnClick := @CopyMenuItemClick;
MsgCopyAllIDEMenuCommand.OnClick := @CopyAllMenuItemClick;
MsgSaveAllToFileIDEMenuCommand.OnClick := @SaveAllToFileMenuItemClick;
EnvironmentOptions.IDEWindowLayoutList.Apply(Self, Name);
end;
destructor TMessagesView.Destroy;
@ -214,191 +213,202 @@ end;
procedure TMessagesView.DeleteLine(Index: integer);
var
Line: TMessageLine;
VisibleIndex: Integer;
i: Integer;
VisibleIndex: integer;
i: integer;
begin
Line:=Items[Index];
Line := Items[Index];
FItems.Delete(Line.Position);
VisibleIndex:=Line.VisiblePosition;
if VisibleIndex>=0 then begin
VisibleIndex := Line.VisiblePosition;
if VisibleIndex >= 0 then
begin
MessageView.Items.Delete(VisibleIndex);
FVisibleItems.Delete(VisibleIndex);
end;
Line.Free;
// adjust Positions
for i:=Index to FItems.Count-1 do begin
Line:=Items[i];
dec(Line.FPosition);
if Line.VisiblePosition>VisibleIndex then
dec(Line.FVisiblePosition);
for i := Index to FItems.Count - 1 do
begin
Line := Items[i];
Dec(Line.FPosition);
if Line.VisiblePosition > VisibleIndex then
Dec(Line.FVisiblePosition);
end;
end;
{------------------------------------------------------------------------------
TMessagesView.Add
------------------------------------------------------------------------------}
Procedure TMessagesView.Add(const Msg, CurDir: String; ProgressLine,
VisibleLine: boolean; OriginalIndex: integer);
procedure TMessagesView.Add(const Msg, CurDir: string;
ProgressLine, VisibleLine: boolean; OriginalIndex: integer);
var
NewMsg: TMessageLine;
i: Integer;
Begin
NewMsg:=TMessageLine.Create;
NewMsg.Msg:=Msg;
NewMsg.Directory:=CurDir;
NewMsg.FPosition:=FItems.Count;
NewMsg.FOriginalIndex:=OriginalIndex;
i: integer;
begin
NewMsg := TMessageLine.Create;
NewMsg.Msg := Msg;
NewMsg.Directory := CurDir;
NewMsg.FPosition := FItems.Count;
NewMsg.FOriginalIndex := OriginalIndex;
FItems.Add(NewMsg);
if VisibleLine then begin
if FLastLineIsProgress then begin
if VisibleLine then
begin
if FLastLineIsProgress then
begin
// replace old progress line
i:=FVisibleItems.Count-1;
VisibleItems[i].FVisiblePosition:=-1;
i := FVisibleItems.Count - 1;
VisibleItems[i].FVisiblePosition := -1;
FVisibleItems.Delete(i);
MessageView.Items[i]:=Msg;
end else begin
// add line
MessageView.Items.Add(Msg);
end;
NewMsg.FVisiblePosition:=FVisibleItems.Count;
MessageView.Items[i] := Msg;
end
else
MessageView.Items.Add(Msg)// add line
;
NewMsg.FVisiblePosition := FVisibleItems.Count;
FVisibleItems.Add(NewMsg);
FLastLineIsProgress:=ProgressLine;
MessageView.TopIndex:=MessageView.Items.Count-1;
FLastLineIsProgress := ProgressLine;
MessageView.TopIndex := MessageView.Items.Count - 1;
end;
end;
procedure TMessagesView.AddMsg(const Msg, CurDir: String;
OriginalIndex: integer);
procedure TMessagesView.AddMsg(const Msg, CurDir: string; OriginalIndex: integer);
begin
Add(Msg,CurDir,false,true,OriginalIndex);
Add(Msg, CurDir, False, True, OriginalIndex);
end;
procedure TMessagesView.AddProgress(const Msg, CurDir: String);
procedure TMessagesView.AddProgress(const Msg, CurDir: string);
begin
Add(Msg,CurDir,true,true,-1);
Add(Msg, CurDir, True, True, -1);
end;
Procedure TMessagesView.AddSeparator;
procedure TMessagesView.AddSeparator;
begin
Add(SeparatorLine,'',false,true,-1);
Add(SeparatorLine, '', False, True, -1);
end;
procedure TMessagesView.ClearTillLastSeparator;
var LastSeparator: integer;
var
LastSeparator: integer;
begin
BeginBlock;
LastSeparator:=VisibleItemCount-1;
while (LastSeparator>=0)
and (VisibleItems[LastSeparator].Msg<>SeparatorLine) do
dec(LastSeparator);
if LastSeparator>=0 then begin
while (VisibleItemCount>LastSeparator) do
DeleteLine(ItemCount-1);
FLastLineIsProgress:=false;
LastSeparator := VisibleItemCount - 1;
while (LastSeparator >= 0) and (VisibleItems[LastSeparator].Msg <> SeparatorLine) do
Dec(LastSeparator);
if LastSeparator >= 0 then
begin
while (VisibleItemCount > LastSeparator) do
DeleteLine(ItemCount - 1);
FLastLineIsProgress := False;
end;
EndBlock;
end;
procedure TMessagesView.ShowTopMessage;
begin
if MessageView.Items.Count>0 then
MessageView.TopIndex:=0;
if MessageView.Items.Count > 0 then
MessageView.TopIndex := 0;
end;
function TMessagesView.MsgCount: integer;
begin
Result:=VisibleItemCount;
Result := VisibleItemCount;
end;
procedure TMessagesView.FilterLines(Filter: TOnFilterLine);
// recalculate visible lines
var
i: Integer;
i: integer;
Line: TMessageLine;
ShowLine: Boolean;
ShowLine: boolean;
begin
// remove temporary lines
ClearTillLastSeparator;
FLastLineIsProgress:=false;
FLastLineIsProgress := False;
// recalculate visible lines
FVisibleItems.Clear;
for i:=0 to FItems.Count-1 do begin
Line:=Items[i];
ShowLine:=true;
Filter(Line,ShowLine);
if ShowLine then begin
Line.FVisiblePosition:=FVisibleItems.Count;
for i := 0 to FItems.Count - 1 do
begin
Line := Items[i];
ShowLine := True;
Filter(Line, ShowLine);
if ShowLine then
begin
Line.FVisiblePosition := FVisibleItems.Count;
FVisibleItems.Add(Line);
end else
Line.FVisiblePosition:=-1;
end
else
Line.FVisiblePosition := -1;
end;
// rebuild MessageView.Items
MessageView.Items.BeginUpdate;
for i:=0 to FVisibleItems.Count-1 do begin
Line:=VisibleItems[i];
if MessageView.Items.Count>i then
MessageView.Items[i]:=Line.Msg
for i := 0 to FVisibleItems.Count - 1 do
begin
Line := VisibleItems[i];
if MessageView.Items.Count > i then
MessageView.Items[i] := Line.Msg
else
MessageView.Items.Add(Line.Msg);
end;
while MessageView.Items.Count>FVisibleItems.Count do
MessageView.Items.Delete(MessageView.Items.Count-1);
while MessageView.Items.Count > FVisibleItems.Count do
MessageView.Items.Delete(MessageView.Items.Count - 1);
MessageView.Items.EndUpdate;
end;
procedure TMessagesView.SaveMessagesToFile(const Filename: string);
begin
SaveStringToFile(Filename,MessageView.Items.Text,[]);
SaveStringToFile(Filename, MessageView.Items.Text, []);
end;
{------------------------------------------------------------------------------
TMessagesView.Clear
------------------------------------------------------------------------------}
Procedure TMessagesView.Clear;
Begin
if fBlockCount>0 then exit;
FLastLineIsProgress:=false;
procedure TMessagesView.Clear;
begin
if fBlockCount > 0 then
exit;
FLastLineIsProgress := False;
ClearItems;
if not Assigned(MessageView.OnClick) then
MessageView.OnClick := @MessageViewClicked;
if not Assigned(MessageView.OnDblClick) then
MessageView.OnDblClick :=@MessageViewDblClicked;
MessageView.OnDblClick := @MessageViewDblClicked;
end;
procedure TMessagesView.GetVisibleMessageAt(Index: integer;
var Msg, MsgDirectory: string);
begin
// consistency checks
if (Index<0) then
if (Index < 0) then
RaiseException('TMessagesView.GetVisibleMessageAt');
if MessageView.Items.Count<=Index then
if MessageView.Items.Count <= Index then
RaiseException('TMessagesView.GetVisibleMessageAt');
if (FItems=nil) then
if (FItems = nil) then
RaiseException('TMessagesView.GetVisibleMessageAt');
if (FItems.Count<=Index) then
if (FItems.Count <= Index) then
RaiseException('TMessagesView.GetVisibleMessageAt');
Msg:=VisibleItems[Index].Msg;
MsgDirectory:=VisibleItems[Index].Directory;
Msg := VisibleItems[Index].Msg;
MsgDirectory := VisibleItems[Index].Directory;
end;
procedure TMessagesView.BeginBlock;
begin
Clear;
inc(fBlockCount);
Inc(fBlockCount);
end;
procedure TMessagesView.EndBlock;
begin
if fBlockCount<=0 then RaiseException('TMessagesView.EndBlock Internal Error');
dec(fBlockCount);
if fBlockCount <= 0 then
RaiseException('TMessagesView.EndBlock Internal Error');
Dec(fBlockCount);
end;
procedure TMessagesView.ClearItems;
var
i: Integer;
i: integer;
begin
for i:=0 to FItems.Count-1 do TObject(FItems[i]).Free;
for i := 0 to FItems.Count - 1 do
TObject(FItems[i]).Free;
FItems.Clear;
FVisibleItems.Clear;
MessageView.Clear;
@ -406,19 +416,19 @@ end;
function TMessagesView.ItemCount: integer;
begin
Result:=FItems.Count;
Result := FItems.Count;
end;
function TMessagesView.VisibleItemCount: integer;
begin
Result:=FVisibleItems.Count;
Result := FVisibleItems.Count;
end;
{------------------------------------------------------------------------------
TMessagesView.GetMessage
------------------------------------------------------------------------------}
Function TMessagesView.GetMessage: String;
Begin
function TMessagesView.GetMessage: string;
begin
Result := '';
if (MessageView.Items.Count > 0) and (MessageView.SelCount > 0) then
Result := MessageView.Items.Strings[GetSelectedLineIndex];
@ -426,64 +436,66 @@ end;
function TMessagesView.GetVisibleItems(Index: integer): TMessageLine;
begin
Result:=TMessageLine(FVisibleItems[Index]);
Result := TMessageLine(FVisibleItems[Index]);
end;
procedure TMessagesView.MessageViewDblClicked(Sender: TObject);
begin
if not EnvironmentOptions.MsgViewDblClickJumps then exit;
if (MessageView.Items.Count > 0) and (MessageView.SelCount > 0) then Begin
If Assigned(OnSelectionChanged) then
if not EnvironmentOptions.MsgViewDblClickJumps then
exit;
if (MessageView.Items.Count > 0) and (MessageView.SelCount > 0) then
if Assigned(OnSelectionChanged) then
OnSelectionChanged(self);
end;
end;
procedure TMessagesView.CopyAllMenuItemClick(Sender: TObject);
begin
Clipboard.AsText:=MessageView.Items.Text;
Clipboard.AsText := MessageView.Items.Text;
end;
procedure TMessagesView.CopyMenuItemClick(Sender: TObject);
begin
if MessageView.ItemIndex<0 then exit;
Clipboard.AsText:=MessageView.GetSelectedText;
if MessageView.ItemIndex < 0 then
exit;
Clipboard.AsText := MessageView.GetSelectedText;
end;
procedure TMessagesView.HelpMenuItemClick(Sender: TObject);
begin
ExecuteIDECommand(Self,ecContextHelp);
ExecuteIDECommand(Self, ecContextHelp);
end;
Procedure TMessagesView.MessageViewClicked(sender : TObject);
procedure TMessagesView.MessageViewClicked(Sender: TObject);
begin
if EnvironmentOptions.MsgViewDblClickJumps then exit;
if (MessageView.Items.Count > 0) and (MessageView.SelCount > 0) then Begin
If Assigned(OnSelectionChanged) then
if EnvironmentOptions.MsgViewDblClickJumps then
exit;
if (MessageView.Items.Count > 0) and (MessageView.SelCount > 0) then
if Assigned(OnSelectionChanged) then
OnSelectionChanged(self);
end;
end;
procedure TMessagesView.MessagesViewKeyDown(Sender: TObject; var Key: Word;
procedure TMessagesView.MessagesViewKeyDown(Sender: TObject; var Key: word;
Shift: TShiftState);
begin
//debugln('TMessagesView.MessagesViewKeyDown ',dbgs(Key));
ExecuteIDEShortCut(Self,Key,Shift);
ExecuteIDEShortCut(Self, Key, Shift);
end;
procedure TMessagesView.SaveAllToFileMenuItemClick(Sender: TObject);
var
SaveDialog: TSaveDialog;
AFilename: string;
AFilename: string;
begin
SaveDialog:=TSaveDialog.Create(nil);
SaveDialog := TSaveDialog.Create(nil);
try
InputHistories.ApplyFileDialogSettings(SaveDialog);
SaveDialog.Title:='Save messages to file (*.txt)';
SaveDialog.Options:=SaveDialog.Options+[ofPathMustExist];
if SaveDialog.Execute then begin
AFilename:=CleanAndExpandFilename(SaveDialog.Filename);
if ExtractFileExt(AFilename)='' then
AFilename:=AFilename+'.txt';
SaveDialog.Title := 'Save messages to file (*.txt)';
SaveDialog.Options := SaveDialog.Options + [ofPathMustExist];
if SaveDialog.Execute then
begin
AFilename := CleanAndExpandFilename(SaveDialog.Filename);
if ExtractFileExt(AFilename) = '' then
AFilename := AFilename + '.txt';
SaveMessagesToFile(AFilename);
end;
InputHistories.StoreFileDialogSettings(SaveDialog);
@ -494,68 +506,68 @@ end;
function TMessagesView.GetDirectory: string;
var
i: Integer;
i: integer;
begin
Result := '';
i:=GetSelectedLineIndex;
if (FVisibleItems.Count>i) then
i := GetSelectedLineIndex;
if (FVisibleItems.Count > i) then
Result := VisibleItems[i].Msg;
end;
function TMessagesView.GetItems(Index: integer): TMessageLine;
begin
Result:=TMessageLine(FItems[Index]);
Result := TMessageLine(FItems[Index]);
end;
Function TMessagesView.GetSelectedLineIndex : Integer;
function TMessagesView.GetSelectedLineIndex: integer;
var
I : Integer;
Begin
I: integer;
begin
Result := -1;
if (MessageView.Items.Count > 0) and (MessageView.SelCount > 0) then Begin
for i := 0 to MessageView.Items.Count-1 do
Begin
if (MessageView.Items.Count > 0) and (MessageView.SelCount > 0) then
for i := 0 to MessageView.Items.Count - 1 do
if MessageView.Selected[I] then
Begin
Result := I;
Break;
end;
end;
end;
begin
Result := I;
Break;
end;
end;
procedure TMessagesView.SetLastLineIsProgress(const AValue: boolean);
begin
if FLastLineIsProgress=AValue then exit;
if FLastLineIsProgress = AValue then
exit;
if FLastLineIsProgress then
MessageView.Items.Delete(MessageView.Items.Count-1);
FLastLineIsProgress:=AValue;
MessageView.Items.Delete(MessageView.Items.Count - 1);
FLastLineIsProgress := AValue;
end;
procedure TMessagesView.SetSelectedLineIndex(const AValue: Integer);
procedure TMessagesView.SetSelectedLineIndex(const AValue: integer);
begin
MessageView.ItemIndex:=AValue;
MessageView.TopIndex:=MessageView.ItemIndex;
MessageView.ItemIndex := AValue;
MessageView.TopIndex := MessageView.ItemIndex;
end;
{ TMessageLine }
procedure TMessageLine.SetDirectory(const AValue: string);
begin
if FDirectory=AValue then exit;
FDirectory:=AValue;
if FDirectory = AValue then
exit;
FDirectory := AValue;
end;
procedure TMessageLine.SetMsg(const AValue: string);
begin
if FMsg=AValue then exit;
FMsg:=AValue;
if FMsg = AValue then
exit;
FMsg := AValue;
end;
constructor TMessageLine.Create;
begin
FPosition:=-1;
FVisiblePosition:=-1;
FPosition := -1;
FVisiblePosition := -1;
end;
destructor TMessageLine.Destroy;
@ -565,7 +577,7 @@ begin
end;
initialization
MessagesView:=nil;
MessagesView := nil;
{$I msgview.lrs}
end.