1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-25 02:32:19 -05:00

Fixed a memory leak.

BrigthnessAdjust -> BrightnessAdjust

git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@345 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Raymond 2009-12-26 15:45:05 +00:00
parent ffcb20146b
commit fed81fb976
8 changed files with 2821 additions and 2774 deletions

View File

@ -11,22 +11,23 @@ object FunctionListFrame: TFunctionListFrame
DesignTop = 219 DesignTop = 219
object FunctionList: TTreeView object FunctionList: TTreeView
Left = 0 Left = 0
Height = 300 Height = 306
Top = 0 Top = 0
Width = 115 Width = 115
Align = alClient Align = alClient
DefaultItemHeight = 19 DefaultItemHeight = 15
ReadOnly = True ReadOnly = True
ScrollBars = ssAutoBoth ScrollBars = ssAutoBoth
TabOrder = 0 TabOrder = 0
OnDeletion = FunctionListDeletion
OnMouseDown = FunctionListMouseDown OnMouseDown = FunctionListMouseDown
OnMouseUp = FunctionListMouseUp OnMouseUp = FunctionListMouseUp
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips] Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips]
end end
object editSearchList: TEdit object editSearchList: TEdit
Left = 0 Left = 0
Height = 27 Height = 21
Top = 300 Top = 306
Width = 115 Width = 115
Align = alBottom Align = alBottom
OnChange = editSearchListChange OnChange = editSearchListChange

View File

@ -4,13 +4,13 @@ LazarusResources.Add('TFunctionListFrame','FORMDATA',[
'TPF0'#18'TFunctionListFrame'#17'FunctionListFrame'#4'Left'#2#0#6'Height'#3'G' 'TPF0'#18'TFunctionListFrame'#17'FunctionListFrame'#4'Left'#2#0#6'Height'#3'G'
+#1#3'Top'#2#0#5'Width'#2's'#5'Align'#7#6'alLeft'#12'ClientHeight'#3'G'#1#11 +#1#3'Top'#2#0#5'Width'#2's'#5'Align'#7#6'alLeft'#12'ClientHeight'#3'G'#1#11
+'ClientWidth'#2's'#8'TabOrder'#2#0#10'DesignLeft'#3#145#1#9'DesignTop'#3#219 +'ClientWidth'#2's'#8'TabOrder'#2#0#10'DesignLeft'#3#145#1#9'DesignTop'#3#219
+#0#0#9'TTreeView'#12'FunctionList'#4'Left'#2#0#6'Height'#3','#1#3'Top'#2#0#5 +#0#0#9'TTreeView'#12'FunctionList'#4'Left'#2#0#6'Height'#3'2'#1#3'Top'#2#0#5
+'Width'#2's'#5'Align'#7#8'alClient'#17'DefaultItemHeight'#2#19#8'ReadOnly'#9 +'Width'#2's'#5'Align'#7#8'alClient'#17'DefaultItemHeight'#2#15#8'ReadOnly'#9
+#10'ScrollBars'#7#10'ssAutoBoth'#8'TabOrder'#2#0#11'OnMouseDown'#7#21'Functi' +#10'ScrollBars'#7#10'ssAutoBoth'#8'TabOrder'#2#0#10'OnDeletion'#7#20'Functio'
+'onListMouseDown'#9'OnMouseUp'#7#19'FunctionListMouseUp'#7'Options'#11#17'tv' +'nListDeletion'#11'OnMouseDown'#7#21'FunctionListMouseDown'#9'OnMouseUp'#7#19
+'oAutoItemHeight'#16'tvoHideSelection'#21'tvoKeepCollapsedNodes'#11'tvoReadO' +'FunctionListMouseUp'#7'Options'#11#17'tvoAutoItemHeight'#16'tvoHideSelectio'
+'nly'#14'tvoShowButtons'#12'tvoShowLines'#11'tvoShowRoot'#11'tvoToolTips'#0#0 +'n'#21'tvoKeepCollapsedNodes'#11'tvoReadOnly'#14'tvoShowButtons'#12'tvoShowL'
+#0#5'TEdit'#14'editSearchList'#4'Left'#2#0#6'Height'#2#27#3'Top'#3','#1#5'Wi' +'ines'#11'tvoShowRoot'#11'tvoToolTips'#0#0#0#5'TEdit'#14'editSearchList'#4'L'
+'dth'#2's'#5'Align'#7#8'alBottom'#8'OnChange'#7#20'editSearchListChange'#8'T' +'eft'#2#0#6'Height'#2#21#3'Top'#3'2'#1#5'Width'#2's'#5'Align'#7#8'alBottom'#8
+'abOrder'#2#1#0#0#0 +'OnChange'#7#20'editSearchListChange'#8'TabOrder'#2#1#0#0#0
]); ]);

View File

@ -15,14 +15,16 @@ type
editSearchList: TEdit; editSearchList: TEdit;
FunctionList: TTreeView; FunctionList: TTreeView;
procedure editSearchListChange(Sender: TObject); procedure editSearchListChange(Sender: TObject);
procedure FunctionListDeletion(Sender: TObject; Node: TTreeNode);
procedure FunctionListMouseDown(Sender: TObject; Button: TMouseButton; procedure FunctionListMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer); Shift: TShiftState; X, Y: Integer);
procedure FunctionListMouseUp(Sender: TObject; Button: TMouseButton; procedure FunctionListMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer); Shift: TShiftState; X, Y: Integer);
procedure DockFormOnClose(Sender: TObject; var CloseAction: TCloseAction); procedure DockFormOnClose(Sender: TObject; var CloseAction: TCloseAction);
private private
procedure CreateFilterTree; FFilterTree : TTreeView;
procedure FilterTreeVis(Vis : boolean); procedure FilterTreeVis(Vis : boolean);
function GetFilterTree: TTreeView;
{ private declarations } { private declarations }
public public
DraggingNode : TTreeNode; DraggingNode : TTreeNode;
@ -32,7 +34,8 @@ type
StartWordCompletion : TPoint; StartWordCompletion : TPoint;
CompletionLine : string; CompletionLine : string;
CompletionStart : string; CompletionStart : string;
FilterTree : TTreeView; property FilterTree : TTreeView read GetFilterTree;
procedure LoadScriptTree( Script : String);
function Find(Next : boolean) : boolean; function Find(Next : boolean) : boolean;
{ public declarations } { public declarations }
end; end;
@ -49,35 +52,67 @@ begin
Find(false); Find(false);
end; end;
procedure TFunctionListFrame.FunctionListDeletion(Sender: TObject;
Node: TTreeNode);
begin
if node.data <> nil then
StrDispose(PChar(Node.Data));
end;
procedure TFunctionListFrame.DockFormOnClose(Sender: TObject; var CloseAction: TCloseAction); procedure TFunctionListFrame.DockFormOnClose(Sender: TObject; var CloseAction: TCloseAction);
begin begin
CloseAction := caHide; CloseAction := caHide;
Form1.MenuItemFunctionList.Checked := False; Form1.MenuItemFunctionList.Checked := False;
end; end;
procedure TFunctionListFrame.CreateFilterTree;
begin
if Assigned(FilterTree) then
exit;
FilterTree := TTreeView.Create(Self);
FilterTree.Parent := Self;
FilterTree.Visible := false;
FilterTree.SetBounds(FunctionList.Left,FunctionList.Top,FunctionList.Width,FunctionList.Height);
FilterTree.Align := alClient;
FilterTree.ReadOnly:= True;
FilterTree.ScrollBars:= ssAutoBoth;
FilterTree.OnMouseDown:= @FunctionListMouseDown;
FilterTree.OnMouseUp:= @FunctionListMouseUp;
end;
procedure TFunctionListFrame.FilterTreeVis(Vis: boolean); procedure TFunctionListFrame.FilterTreeVis(Vis: boolean);
begin begin
CreateFilterTree;
FunctionList.Visible:= not Vis; FunctionList.Visible:= not Vis;
FilterTree.Visible := Vis; FilterTree.Visible := Vis;
end; end;
function TFunctionListFrame.GetFilterTree: TTreeView;
begin
Result := FFilterTree;
if Assigned(Result) then
exit;
FFilterTree := TTreeView.Create(Self);
FFilterTree.Parent := Self;
FFilterTree.Visible := false;
FFilterTree.SetBounds(FunctionList.Left,FunctionList.Top,FunctionList.Width,FunctionList.Height);
FFilterTree.Align := alClient;
FFilterTree.ReadOnly:= True;
FFilterTree.ScrollBars:= ssAutoBoth;
FFilterTree.OnMouseDown:= FunctionList.OnMouseDown;
FFilterTree.OnMouseUp:= FunctionList.OnMouseUp;
FFilterTree.OnChange:= FunctionList.OnChange;
FFilterTree.OnExit := FunctionList.OnExit;
Result := FFilterTree;
//We do not want to delete the data from the FilterTree
// FilterTree.OnDeletion:= FunctionList.OnDeletion;
end;
procedure TFunctionListFrame.LoadScriptTree(Script: String);
var
I : integer;
Analyzer : TScriptAnalyzer;
tmpNode : TTreeNode;
begin
if FilterTree.Visible then
Writeln('Might get some acces violations now..');
ScriptNode.DeleteChildren;
Analyzer := TScriptAnalyzer.create;
Analyzer.ScriptToAnalyze:= Script;
Analyzer.analyze;
for i := 0 to Analyzer.MethodLen - 1 do
begin
tmpNode := FunctionList.Items.AddChild(ScriptNode,Analyzer.Methods[i].Name);
tmpNode.Data:= strnew(PChar(Analyzer.Methods[i].CreateMethodStr));
end;
ScriptNode.Expand(true);
end;
function TFunctionListFrame.Find(Next : boolean) : boolean; function TFunctionListFrame.Find(Next : boolean) : boolean;
var var
Start,Len,i,index,posi: Integer; Start,Len,i,index,posi: Integer;
@ -89,7 +124,6 @@ var
Node : TTreeNode; Node : TTreeNode;
InsertStr : string; InsertStr : string;
begin begin
CreateFilterTree;
if(editSearchList.Text = '')then if(editSearchList.Text = '')then
begin begin
editSearchList.Color := clWhite; editSearchList.Color := clWhite;
@ -101,6 +135,7 @@ begin
Form1.CurrScript.SynEdit.SelEnd:= Form1.CurrScript.SynEdit.SelStart; Form1.CurrScript.SynEdit.SelEnd:= Form1.CurrScript.SynEdit.SelStart;
end; end;
FilterTreeVis(False); FilterTreeVis(False);
ScriptNode.Expand(true);
exit; exit;
end; end;

View File

@ -326,6 +326,11 @@ begin
end; end;
tkProcedure, tkProcedure,
tkFunction : begin; tkFunction : begin;
if (InVarSection or (InMethod and InParams)) and ExpectingType then
begin;
//Do nothing since the this procedure/function is a var ;-)
end else
begin;
if not InMethod then if not InMethod then
InVarSection := False; InVarSection := False;
if (not InTypes) and (not InVarSection) then if (not InTypes) and (not InVarSection) then
@ -333,7 +338,7 @@ begin
WaitingForResult := LastTK = tkFunction; WaitingForResult := LastTK = tkFunction;
if Lex.TokenID <> tkIdentifier then if Lex.TokenID <> tkIdentifier then
begin; begin;
ShowMessage('No method name -> exiting'); Writeln('Analyzer: No method name -> exiting');
exit; exit;
end; end;
TempName := Lex.Token; TempName := Lex.Token;
@ -342,6 +347,7 @@ begin
InParams := True InParams := True
else if Lex.TokenID = tkPoint then else if Lex.TokenID = tkPoint then
begin; begin;
Writeln('Analyzer: In class definition?');
// FormAnalyzer.SynEdit2.Lines.add('In class definition *cough*'); // FormAnalyzer.SynEdit2.Lines.add('In class definition *cough*');
Lex.NextNoJunk; Lex.NextNoJunk;
TempName := Lex.Token; TempName := Lex.Token;
@ -350,7 +356,7 @@ begin
InParams := False; InParams := False;
end else end else
begin; begin;
ShowMessage('Your missing some stuff in the procedure declaration'); Writeln('Analyzer: You''re missing some stuff in the procedure declaration');
Exit; Exit;
end; end;
if InMethod then if InMethod then
@ -362,6 +368,7 @@ begin
end; end;
end; end;
end;
end; end;
// SynEdit2.Lines.Add(TokeToString(Lex.TokenID) + '-' + Lex.Token); // SynEdit2.Lines.Add(TokeToString(Lex.TokenID) + '-' + Lex.Token);

View File

@ -1,7 +1,7 @@
object Form1: TForm1 object Form1: TForm1
Left = 243 Left = 273
Height = 557 Height = 557
Top = 302 Top = 233
Width = 734 Width = 734
ActiveControl = ScriptPanel ActiveControl = ScriptPanel
Caption = 'THA FUKING MUFASA' Caption = 'THA FUKING MUFASA'
@ -391,6 +391,8 @@ object Form1: TForm1
Height = 275 Height = 275
Width = 145 Width = 145
OnChange = FunctionListChange OnChange = FunctionListChange
OnDeletion = nil
OnEnter = FunctionListEnter
OnExit = FunctionListExit OnExit = FunctionListExit
end end
inherited editSearchList: TEdit inherited editSearchList: TEdit

File diff suppressed because it is too large Load Diff

View File

@ -214,6 +214,7 @@ type
procedure editSearchListExit(Sender: TObject); procedure editSearchListExit(Sender: TObject);
procedure editSearchListKeyPress(Sender: TObject; var Key: char); procedure editSearchListKeyPress(Sender: TObject; var Key: char);
procedure FunctionListChange(Sender: TObject; Node: TTreeNode); procedure FunctionListChange(Sender: TObject; Node: TTreeNode);
procedure FunctionListEnter(Sender: TObject);
procedure FunctionListExit(Sender: TObject); procedure FunctionListExit(Sender: TObject);
procedure MenuItemColourHistoryClick(Sender: TObject); procedure MenuItemColourHistoryClick(Sender: TObject);
procedure dlgReplaceFind(Sender: TObject); procedure dlgReplaceFind(Sender: TObject);
@ -1008,8 +1009,17 @@ end;
procedure TForm1.FunctionListChange(Sender: TObject; Node: TTreeNode); procedure TForm1.FunctionListChange(Sender: TObject; Node: TTreeNode);
begin begin
if node = nil then
exit;
if Node.Level > 0 then if Node.Level > 0 then
StatusBar.Panels[2].Text := PChar(Node.Data); StatusBar.Panels[2].Text := PChar(Node.Data);
if Node.level = 0 then
StatusBar.Panels[2].Text := 'Section: ' + Node.Text;
end;
procedure TForm1.FunctionListEnter(Sender: TObject);
begin
frmFunctionList.LoadScriptTree(CurrScript.SynEdit.Text);
end; end;
procedure TForm1.FunctionListExit(Sender: TObject); procedure TForm1.FunctionListExit(Sender: TObject);
@ -1245,6 +1255,7 @@ begin
Tree.Items.Clear; Tree.Items.Clear;
Sections := TStringList.Create; Sections := TStringList.Create;
LastSection := ''; LastSection := '';
frmFunctionList.ScriptNode := Tree.Items.Add(nil,'Script');
for i := 0 to high(Methods) do for i := 0 to high(Methods) do
begin; begin;
if Methods[i].Section <> LastSection then if Methods[i].Section <> LastSection then
@ -1262,7 +1273,7 @@ begin
Temp2Node := Tree.Items.AddChild(Tempnode,GetMethodName(Methods[i].FuncDecl,false)); Temp2Node := Tree.Items.AddChild(Tempnode,GetMethodName(Methods[i].FuncDecl,false));
Temp2Node.Data:= strnew(PChar(Methods[i].FuncDecl)); Temp2Node.Data:= strnew(PChar(Methods[i].FuncDecl));
end; end;
frmFunctionList.ScriptNode := Tree.Items.Add(nil,'Script'); frmFunctionList.LoadScriptTree(CurrScript.SynEdit.Text);
end; end;
procedure TForm1.MenuItemHideClick(Sender: TObject); procedure TForm1.MenuItemHideClick(Sender: TObject);
@ -1462,17 +1473,7 @@ begin
if editSearchList.CanFocus then if editSearchList.CanFocus then
editSearchList.SetFocus; editSearchList.SetFocus;
//Lets load up this Script tree! //Lets load up this Script tree!
Tree := frmFunctionList.FunctionList; frmFunctionList.LoadScriptTree(CurrScript.SynEdit.text);
Node := frmFunctionList.ScriptNode;
Node.DeleteChildren;
Analyzer := TScriptAnalyzer.create;
Analyzer.ScriptToAnalyze:= CurrScript.SynEdit.Lines.Text;
Analyzer.analyze;
for i := 0 to Analyzer.MethodLen - 1 do
begin
tmpNode := Tree.Items.AddChild(Node,Analyzer.Methods[i].Name);
tmpNode.Data:= PChar(Analyzer.Methods[i].CreateMethodStr);
end;
end else begin end else begin
if(frmFunctionList.Parent is TPanel)then if(frmFunctionList.Parent is TPanel)then
frmFunctionList.Hide frmFunctionList.Hide

View File

@ -805,7 +805,7 @@ begin
end; end;
end; end;
function BrigthnessAdjust(Col: byte; br : integer): byte;inline; function BrightnessAdjust(Col: byte; br : integer): byte;inline;
var var
temp : integer; temp : integer;
begin; begin;
@ -824,9 +824,9 @@ begin
Ptr := Self.FData; Ptr := Self.FData;
for i := (h*w-1) downto 0 do for i := (h*w-1) downto 0 do
begin; begin;
Ptr^.r := BrigthnessAdjust(Ptr^.r,br); Ptr^.r := BrightnessAdjust(Ptr^.r,br);
Ptr^.g := BrigthnessAdjust(Ptr^.g,br); Ptr^.g := BrightnessAdjust(Ptr^.g,br);
Ptr^.b := BrigthnessAdjust(Ptr^.b,br); Ptr^.b := BrightnessAdjust(Ptr^.b,br);
inc(ptr); inc(ptr);
end; end;
end; end;
@ -841,9 +841,9 @@ begin
PtrNew := TargetBitmap.FData; PtrNew := TargetBitmap.FData;
for i := (h*w-1) downto 0 do for i := (h*w-1) downto 0 do
begin; begin;
PtrNew^.r := BrigthnessAdjust(PtrOld^.r,br); PtrNew^.r := BrightnessAdjust(PtrOld^.r,br);
PtrNew^.g := BrigthnessAdjust(PtrOld^.g,br); PtrNew^.g := BrightnessAdjust(PtrOld^.g,br);
PtrNew^.b := BrigthnessAdjust(PtrOld^.b,br); PtrNew^.b := BrightnessAdjust(PtrOld^.b,br);
inc(ptrOld); inc(ptrOld);
inc(PtrNew); inc(PtrNew);
end; end;