Skip to content

Commit

Permalink
sort by description case sensitive/insensitive toggle (ctrl down)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheat-engine committed Aug 10, 2021
1 parent 181a2ec commit b53a503
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions Cheat Engine/addresslist.pas
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ TAddresslist=class(TPanel)
function activecompare(_a: TTreenode; _b: TTreenode): integer;
procedure sortByActive;
function descriptioncompare(_a: TTreenode; _b: TTreenode): integer;
function descriptioncomparecasesensitive(_a: TTreenode; _b: TTreenode): integer;
procedure sortByDescription;
function addresscompare(_a: TTreenode; _b: TTreenode): integer;
procedure sortByAddress;
Expand Down Expand Up @@ -1558,7 +1559,7 @@ procedure TAddresslist.sortByActive;
activesortdirection:=not activesortdirection;
end;

function TAddresslist.descriptioncompare(_a: TTreenode; _b: TTreenode): integer;
function TAddresslist.descriptioncomparecasesensitive(_a: TTreenode; _b: TTreenode): integer;
var
a,b: TMemoryRecord;
begin
Expand All @@ -1576,13 +1577,36 @@ function TAddresslist.descriptioncompare(_a: TTreenode; _b: TTreenode): integer;
result:=-result;
end;

function TAddresslist.descriptioncompare(_a: TTreenode; _b: TTreenode): integer;
var
a,b: TMemoryRecord;
begin
if sortlevel0only and (_a.level<>0) and (_b.level<>0) then exit(0);

a:=TMemoryRecord(_a.data);
b:=TMemoryRecord(_b.data);
result:=0; //equal
if uppercase(b.description)>uppercase(a.description) then
result:=1;
if uppercase(b.description)<uppercase(a.description) then
result:=-1;

if not descriptionsortdirection then
result:=-result;
end;

procedure TAddresslist.sortByDescription;
var n: TTreenode;
begin
if count=0 then exit;

if treeview.Selected<>nil then n:=treeview.Selected else n:=treeview.Items[0];
sort(n, descriptioncompare, descriptionsortdirection);

if ssCtrl in GetKeyShiftState then
sort(n, descriptioncomparecasesensitive, descriptionsortdirection)
else
sort(n, descriptioncompare, descriptionsortdirection);

descriptionsortdirection:=not descriptionsortdirection;
end;

Expand Down

0 comments on commit b53a503

Please sign in to comment.