Skip to content

Commit

Permalink
Added basic incremental search
Browse files Browse the repository at this point in the history
  • Loading branch information
CWBudde committed Feb 26, 2019
1 parent a58a4aa commit 58dc82f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
17 changes: 10 additions & 7 deletions Source/MainForm.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,19 @@ object FormMain: TFormMain
Header.AutoSizeIndex = 0
Header.Options = [hoColumnResize, hoDrag]
Images = ImageListResources
IncrementalSearch = isAll
PopupMenu = PopupMenuResources
ProportionalColumnSizes = False
StateImages = ImageListResources
TabOrder = 2
TreeOptions.MiscOptions = [toAcceptOLEDrop, toEditable, toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning]
TreeOptions.SelectionOptions = [toRightClickSelect, toCenterScrollIntoView]
OnCompareNodes = vstResourcesCompareNodes
OnEditing = vstResourcesEditing
OnFocusChanged = vstResourcesFocusChanged
OnGetText = vstResourcesGetText
OnGetImageIndex = vstResourcesGetImageIndex
OnIncrementalSearch = vstResourcesIncrementalSearch
OnInitChildren = vstResourcesInitChildren
OnInitNode = vstResourcesInitNode
OnNewText = vstResourcesNewText
Expand Down Expand Up @@ -339,7 +342,7 @@ object FormMain: TFormMain
Left = 256
Top = 118
Bitmap = {
494C010112009000900010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
494C010112009800980010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000005000000001002000000000000050
0000000000000000000000000000000000000000000000000000000000000000
000000000000E6CEC300E3CDC300DFCBC200DBC7BE00DCC4B900E5C9BB000000
Expand Down Expand Up @@ -1205,7 +1208,7 @@ object FormMain: TFormMain
Filter = 'X Files (*.x)|*.x|Y Files (*.y)|*.y'
Options = [ofOverwritePrompt, ofHideReadOnly, ofPathMustExist, ofEnableSizing]
Left = 224
Top = 208
Top = 224
end
object PrintDialog: TPrintDialog
Left = 280
Expand Down Expand Up @@ -1243,7 +1246,7 @@ object FormMain: TFormMain
Left = 224
Top = 177
Bitmap = {
494C01010E009000900010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
494C01010E009800980010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000004000000001002000000000000040
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
Expand Down Expand Up @@ -1827,13 +1830,13 @@ object FormMain: TFormMain
object ApplicationEvents: TApplicationEvents
OnHelp = ApplicationEventsHelp
OnMessage = ApplicationEventsMessage
Left = 252
Top = 206
Left = 324
Top = 230
end
object OpenDialogAllFiles: TOpenDialog
Filter = 'Any File (*.*)|*.*'
Options = [ofHideReadOnly, ofFileMustExist, ofEnableSizing]
Left = 284
Top = 214
Left = 276
Top = 222
end
end
26 changes: 24 additions & 2 deletions Source/MainForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ TFormMain = class(TForm)
procedure vstResourcesGetImageIndex(Sender: TBaseVirtualTree;
Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
var Ghosted: Boolean; var ImageIndex: TImageIndex);
procedure vstResourcesCompareNodes(Sender: TBaseVirtualTree; Node1,
Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
procedure vstResourcesIncrementalSearch(Sender: TBaseVirtualTree;
Node: PVirtualNode; const SearchText: string; var Result: Integer);
private
FResourceModule: TResourceModule;
FUndo, FRedo: string;
Expand Down Expand Up @@ -1896,7 +1900,7 @@ procedure TFormMain.vstResourcesGetImageIndex(Sender: TBaseVirtualTree;
var
Details: TResourceDetails;
begin
if Kind = ikOverlay then
if Kind in [ikOverlay, ikState] then
Exit;

Details := GetNodeResourceDetails(Node);
Expand All @@ -1906,7 +1910,7 @@ procedure TFormMain.vstResourcesGetImageIndex(Sender: TBaseVirtualTree;
if vsExpanded in Node^.States then
ImageIndex := imgOpenFolder
else
ImageIndex := imgClosedFolder
ImageIndex := imgClosedFolder;
end;

procedure TFormMain.vstResourcesGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;
Expand All @@ -1918,6 +1922,15 @@ procedure TFormMain.vstResourcesGetText(Sender: TBaseVirtualTree; Node: PVirtual
CellText := elem.DisplayName
end;

procedure TFormMain.vstResourcesIncrementalSearch(Sender: TBaseVirtualTree;
Node: PVirtualNode; const SearchText: string; var Result: Integer);
var
elem: TResExamElement;
begin
if GetNodeElement(Node, elem) then
Result := CompareText(SearchText, elem.DisplayName);
end;

procedure TFormMain.vstResourcesInitChildren(Sender: TBaseVirtualTree;
Node: PVirtualNode; var ChildCount: Cardinal);
var
Expand Down Expand Up @@ -1948,6 +1961,15 @@ procedure TFormMain.vstResourcesInitNode(Sender: TBaseVirtualTree; ParentNode,
end
end;

procedure TFormMain.vstResourcesCompareNodes(Sender: TBaseVirtualTree; Node1,
Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
var
Elem1, Elem2: TResExamElement;
begin
if GetNodeElement(Node1, Elem1) and GetNodeElement(Node2, Elem2) then
Result := CompareText(Elem1.DisplayName, Elem2.DisplayName);
end;

procedure TFormMain.vstResourcesEditing(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; var Allowed: Boolean);
begin
Expand Down

0 comments on commit 58dc82f

Please sign in to comment.