Add message option to make the filter persistent - close #162

This commit is contained in:
Basile Burg 2017-07-10 11:12:05 +02:00
parent 09fa996fd7
commit efcba233a6
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
3 changed files with 19 additions and 5 deletions

View File

@ -36,6 +36,7 @@ This value and several other options can be changed in the options.
![](img/options_messages.png) ![](img/options_messages.png)
- **alwaysFilter**: Sets if the custom filter (text filed at the top right) is maintained or if it's reset when new messages are emitted.
- **autoDemangle**: Automatically filters the new messages with [ddemangle](https://github.com/dlang/tools#d-tools). Note that Coedit uses the tool as a daemon so it's perfectly normal that it remains in the task list when the IDE runs. - **autoDemangle**: Automatically filters the new messages with [ddemangle](https://github.com/dlang/tools#d-tools). Note that Coedit uses the tool as a daemon so it's perfectly normal that it remains in the task list when the IDE runs.
- **autoSelect**: Defines if the widget change dynamically the message categories. - **autoSelect**: Defines if the widget change dynamically the message categories.
This is a recommended setting because if a run-time error happens, it will be immediately displayed. This is a recommended setting because if a run-time error happens, it will be immediately displayed.

View File

@ -25,7 +25,6 @@ inherited CEMessagesWidget: TCEMessagesWidget
Width = 840 Width = 840
Align = alClient Align = alClient
BorderSpacing.Around = 2 BorderSpacing.Around = 2
DefaultItemHeight = 16
HideSelection = False HideSelection = False
Images = imgList Images = imgList
MultiSelect = True MultiSelect = True
@ -153,7 +152,6 @@ inherited CEMessagesWidget: TCEMessagesWidget
MaxLength = 0 MaxLength = 0
TabOrder = 0 TabOrder = 0
OnButtonClick = TreeFilterEdit1ButtonClick OnButtonClick = TreeFilterEdit1ButtonClick
FilteredTreeview = List
end end
object btnClearCat: TSpeedButton[12] object btnClearCat: TSpeedButton[12]
Left = 1 Left = 1

View File

@ -31,10 +31,12 @@ type
fAutoSelect: boolean; fAutoSelect: boolean;
fSingleClick: boolean; fSingleClick: boolean;
fAutoDemangle: boolean; fAutoDemangle: boolean;
fAlwaysFilter: boolean;
fFont: TFont; fFont: TFont;
fMsgColors: array[TCEAppMessageKind] of TColor; fMsgColors: array[TCEAppMessageKind] of TColor;
procedure setFont(value: TFont); procedure setFont(value: TFont);
published published
property alwaysFilter: boolean read fAlwaysFilter write fAlwaysFilter;
property fastDisplay: boolean read fFastDisplay write fFastDisplay; property fastDisplay: boolean read fFastDisplay write fFastDisplay;
property maxMessageCount: integer read fMaxCount write fMaxCount; property maxMessageCount: integer read fMaxCount write fMaxCount;
property autoSelect: boolean read fAutoSelect write fAutoSelect; property autoSelect: boolean read fAutoSelect write fAutoSelect;
@ -93,6 +95,7 @@ type
fActSelAll: TAction; fActSelAll: TAction;
fActDemangle: TAction; fActDemangle: TAction;
fMaxMessCnt: Integer; fMaxMessCnt: Integer;
fAlwaysFilter: boolean;
fProj: ICECommonProject; fProj: ICECommonProject;
fDoc: TCESynMemo; fDoc: TCESynMemo;
fCtxt: TCEAppMessageCtxt; fCtxt: TCEAppMessageCtxt;
@ -289,6 +292,7 @@ begin
fSingleClick := opts.fSingleClick; fSingleClick := opts.fSingleClick;
fFastDisplay := opts.fFastDisplay; fFastDisplay := opts.fFastDisplay;
fMsgColors := opts.fMsgColors; fMsgColors := opts.fMsgColors;
fAlwaysFilter := opts.fAlwaysFilter;
fFont.EndUpdate; fFont.EndUpdate;
end end
else if source is TCEMessagesWidget then else if source is TCEMessagesWidget then
@ -301,6 +305,7 @@ begin
fFastDisplay := widg.fastDisplay; fFastDisplay := widg.fastDisplay;
fMsgColors := widg.fMsgColors; fMsgColors := widg.fMsgColors;
fAutoDemangle:= widg.fAutoDemangle; fAutoDemangle:= widg.fAutoDemangle;
fAlwaysFilter:=widg.fAlwaysFilter;
end end
else inherited; else inherited;
end; end;
@ -319,6 +324,7 @@ begin
widg.fastDisplay:= fFastDisplay; widg.fastDisplay:= fFastDisplay;
widg.fMsgColors := fMsgColors; widg.fMsgColors := fMsgColors;
widg.fAutoDemangle:=fAutoDemangle; widg.fAutoDemangle:=fAutoDemangle;
widg.fAlwaysFilter:=fAlwaysFilter;
if fFastDisplay then if fFastDisplay then
widg.updaterByLoopInterval:= 70 widg.updaterByLoopInterval:= 70
else else
@ -825,6 +831,8 @@ var
msg: string; msg: string;
begin begin
showWidget; showWidget;
if not fAlwaysFilter then
TreeFilterEdit1.Filter:='';
case fAutoDemangle of case fAutoDemangle of
false: msg := value; false: msg := value;
true: msg := demangle(value); true: msg := demangle(value);
@ -866,6 +874,10 @@ begin
TTreeHack(list).scrolledLeft := 0; TTreeHack(list).scrolledLeft := 0;
List.Update; List.Update;
filterMessages(fCtxt); filterMessages(fCtxt);
end
else if fAlwaysFilter and fFiltering then
begin
filterMessages(fCtxt);
end; end;
end; end;
@ -897,6 +909,7 @@ begin
if (TObject(data) = fDoc) and (fDoc.isNotNil) then if (TObject(data) = fDoc) and (fDoc.isNotNil) then
fEditorMessagePos[fDoc.fileName] := -1; fEditorMessagePos[fDoc.fileName] := -1;
list.BeginUpdate; list.BeginUpdate;
TreeFilterEdit1.Filter := '';
for i := List.Items.Count-1 downto 0 do for i := List.Items.Count-1 downto 0 do
begin begin
msgdt := PMessageData(List.Items[i].Data); msgdt := PMessageData(List.Items[i].Data);
@ -990,6 +1003,7 @@ procedure TCEMessagesWidget.filterMessages(aCtxt: TCEAppMessageCtxt);
var var
itm: TTreeNode; itm: TTreeNode;
i: integer; i: integer;
f: boolean;
begin begin
if updating then if updating then
exit; exit;
@ -997,10 +1011,11 @@ begin
for i := 0 to List.Items.Count-1 do for i := 0 to List.Items.Count-1 do
begin begin
itm := List.Items.Item[i]; itm := List.Items.Item[i];
if not fFiltering then if fFiltering then
itm.Visible := itemShouldBeVisible(itm, aCtxt) itm.Visible := itemShouldBeVisible(itm, aCtxt) and
itm.Text.Contains(TreeFilterEdit1.Filter)
else else
itm.Visible := itm.Visible and itemShouldBeVisible(itm, aCtxt); itm.Visible:= itemShouldBeVisible(itm, aCtxt);
itm.Selected := false; itm.Selected := false;
end; end;
list.EndUpdate; list.EndUpdate;