Updated Function list -> now filters..

Still have to clean up the code!

Oh to insert some text after Ctrl+Space'ing press Space,Comma,dot,bracketOpen,BracketClose..

git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@343 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Raymond 2009-12-26 12:44:40 +00:00
parent 6e5fc0cd1d
commit ebbd4dcb5c
6 changed files with 3091 additions and 2996 deletions

View File

@ -6,3 +6,4 @@ crosshair: http://led24.de/iconset/ or http://led24.de/ would be appreciated. Fo
Delete: http://www.oxygen-icons.org/ licensed under GPL Delete: http://www.oxygen-icons.org/ licensed under GPL
close:http://titancreations.org/ close:http://titancreations.org/
search: http://wefunction.com/2008/07/function-free-icon-set

BIN
Images/search.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 446 B

View File

@ -21,6 +21,8 @@ type
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;
procedure FilterTreeVis(Vis : boolean);
{ private declarations } { private declarations }
public public
DraggingNode : TTreeNode; DraggingNode : TTreeNode;
@ -30,6 +32,7 @@ type
StartWordCompletion : TPoint; StartWordCompletion : TPoint;
CompletionLine : string; CompletionLine : string;
CompletionStart : string; CompletionStart : string;
FilterTree : TTreeView;
function Find(Next : boolean) : boolean; function Find(Next : boolean) : boolean;
{ public declarations } { public declarations }
end; end;
@ -52,13 +55,41 @@ begin
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);
begin
CreateFilterTree;
FunctionList.Visible:= not Vis;
FilterTree.Visible := Vis;
end;
function TFunctionListFrame.Find(Next : boolean) : boolean; function TFunctionListFrame.Find(Next : boolean) : boolean;
var var
Start,i,index,posi: Integer; Start,Len,i,index,posi: Integer;
FoundFunction : boolean; FoundFunction : boolean;
LastSection : string;
str : string; str : string;
RootNode : TTreeNode;
NormalNode : TTreeNode;
Node : TTreeNode; Node : TTreeNode;
InsertStr : string;
begin begin
CreateFilterTree;
if(editSearchList.Text = '')then if(editSearchList.Text = '')then
begin begin
editSearchList.Color := clWhite; editSearchList.Color := clWhite;
@ -69,52 +100,108 @@ begin
Form1.CurrScript.SynEdit.LogicalCaretXY:= point(CompletionCaret.x,CompletionCaret.y); Form1.CurrScript.SynEdit.LogicalCaretXY:= point(CompletionCaret.x,CompletionCaret.y);
Form1.CurrScript.SynEdit.SelEnd:= Form1.CurrScript.SynEdit.SelStart; Form1.CurrScript.SynEdit.SelEnd:= Form1.CurrScript.SynEdit.SelStart;
end; end;
FilterTreeVis(False);
exit; exit;
end; end;
//We only have to search the next item in our filter tree.. Fu-king easy!
if next then
begin;
if FilterTree.Visible = false then
begin;
Writeln('ERROR: You cannot search next, since the Tree isnt generated yet');
Find(false);
exit;
end;
if FilterTree.Selected <> nil then
Start := FilterTree.Selected.AbsoluteIndex + 1
else
Start := 0;
Len := FilterTree.Items.Count;
for i := start to start + len - 1 do
if FilterTree.Items[i mod len].Level = 1 then
begin
FilterTree.Items[i mod len].Selected:= true;
InsertStr := FilterTree.Items[i mod len].Text;
Result := true;
break;
end;
end else
begin
FilterTree.Items.Clear;
FoundFunction := False; FoundFunction := False;
if FunctionList.Selected <> nil then if FunctionList.Selected <> nil then
begin Start := FunctionList.Selected.AbsoluteIndex
Start := FunctionList.Selected.AbsoluteIndex; else
if(next)then
inc(Start);
end else
Start := 0; Start := 0;
Len := FunctionList.Items.Count;
LastSection := '';
for i := start to start + FunctionList.Items.Count - 1 do for i := start to start + FunctionList.Items.Count - 1 do
if(FunctionList.Items[i mod FunctionList.Items.Count].Level = 1)then begin;
if(pos(lowercase(editSearchList.Text), lowercase(FunctionList.Items[i mod FunctionList.Items.Count].Text)) > 0)then Node := FunctionList.Items[i mod FunctionList.Items.Count];
if(Node.Level = 1)then
if(pos(lowercase(editSearchList.Text), lowercase(Node.Text)) > 0)then
begin
if not FoundFunction then
begin begin
FoundFunction := True; FoundFunction := True;
index := i mod FunctionList.Items.Count; index := i mod FunctionList.Items.Count;
break; InsertStr:= node.Text;
end;
if LastSection <> Node.Parent.Text then //We enter a new section, add it to the filter tree!
RootNode := FilterTree.Items.AddChild(nil,Node.Parent.Text);
FilterTree.Items.AddChild(RootNode,Node.Text).Data := Node.Data;
LastSection:= RootNode.Text;
// break;
end;
end; end;
Result := FoundFunction; Result := FoundFunction;
if Result then if Result then
begin; begin;
FilterTreeVis(True);
FilterTree.FullExpand;
FilterTree.Items[1].Selected:= True;
Writeln(FunctionList.Items[Index].Text); Writeln(FunctionList.Items[Index].Text);
FunctionList.FullCollapse; FunctionList.FullCollapse;
FunctionList.Items[Index].Selected := true; FunctionList.Items[Index].Selected := true;
FunctionList.Items[index].ExpandParents; FunctionList.Items[index].ExpandParents;
editSearchList.Color := clWhite; editSearchList.Color := clWhite;
end else
begin
FilterTreeVis(false);
editSearchList.Color := 6711039;
if InCodeCompletion then if InCodeCompletion then
Form1.CurrScript.SynEdit.Lines[CompletionCaret.y - 1] := CompletionStart;
end;
end;
if result and InCodeCompletion then
begin; begin;
str := format(CompletionLine, [FunctionList.items[index].text]); str := format(CompletionLine, [InsertStr]);
with Form1.CurrScript.SynEdit do with Form1.CurrScript.SynEdit do
begin; begin;
Lines[CompletionCaret.y - 1] := str; Lines[CompletionCaret.y - 1] := str;
LogicalCaretXY:= StartWordCompletion; LogicalCaretXY:= StartWordCompletion;
i := SelStart; i := SelStart;
posi := pos(lowercase(editSearchList.text), lowercase(FunctionList.items[index].text)); posi := pos(lowercase(editSearchList.text), lowercase(InsertStr)) + length(editSearchList.text) - 1; //underline the rest of the word
SelStart := i + length(editSearchList.Text) + posi - 1; if Posi = Length(InsertStr) then //Special occasions
SelEnd := i + Length(str); begin;
if Length(editSearchList.Text) <> Posi then //We found the last part of the text -> for exmaple when you Search for bitmap, you can find LoadBitmap -> We underline 'Load'
begin;
SelStart := i;
SelEnd := i + pos(lowercase(editSearchList.text), lowercase(InsertStr)) -1;
Exit;
end; end;
//We searched for the whole text -> for example LoadBitmap, and we found LoadBitmap -> Underline the whole text
Posi := 0;
end;
//Underline the rest of the word
SelStart := i + posi;
SelEnd := SelStart + Length(InsertStr) - posi;
end; end;
end else
begin
editSearchList.Color := 6711039;
if InCodeCompletion then
Form1.CurrScript.SynEdit.Lines[CompletionCaret.y - 1] := CompletionStart;
end; end;
end; end;
@ -128,7 +215,9 @@ begin
Writeln('Not yet implemented'); Writeln('Not yet implemented');
exit; exit;
end; end;
N := Self.FunctionList.GetNodeAt(x, y); if not (Sender is TTreeView) then
exit;
N := TTreeView(Sender).GetNodeAt(x, y);
if(N = nil)then if(N = nil)then
begin begin
Self.DragKind := dkDock; Self.DragKind := dkDock;

View File

@ -1,11 +1,11 @@
object Form1: TForm1 object Form1: TForm1
Left = 473 Left = 243
Height = 557 Height = 557
Top = 246 Top = 302
Width = 734 Width = 734
ActiveControl = ScriptPanel ActiveControl = ScriptPanel
Caption = 'THA FUKING MUFASA' Caption = 'THA FUKING MUFASA'
ClientHeight = 532 ClientHeight = 537
ClientWidth = 734 ClientWidth = 734
KeyPreview = True KeyPreview = True
Menu = MainMenu1 Menu = MainMenu1
@ -166,8 +166,8 @@ object Form1: TForm1
end end
object StatusBar: TStatusBar object StatusBar: TStatusBar
Left = 0 Left = 0
Height = 21 Height = 23
Top = 511 Top = 514
Width = 734 Width = 734
Panels = < Panels = <
item item
@ -185,7 +185,7 @@ object Form1: TForm1
object PanelMemo: TPanel object PanelMemo: TPanel
Left = 0 Left = 0
Height = 154 Height = 154
Top = 357 Top = 360
Width = 734 Width = 734
Align = alBottom Align = alBottom
ClientHeight = 154 ClientHeight = 154
@ -205,19 +205,19 @@ object Form1: TForm1
Cursor = crVSplit Cursor = crVSplit
Left = 0 Left = 0
Height = 5 Height = 5
Top = 352 Top = 355
Width = 734 Width = 734
Align = alBottom Align = alBottom
ResizeAnchor = akBottom ResizeAnchor = akBottom
end end
object ScriptPanel: TPanel object ScriptPanel: TPanel
Left = 0 Left = 0
Height = 328 Height = 331
Top = 24 Top = 24
Width = 734 Width = 734
Align = alClient Align = alClient
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 328 ClientHeight = 331
ClientWidth = 734 ClientWidth = 734
DockSite = True DockSite = True
TabOrder = 4 TabOrder = 4
@ -225,7 +225,7 @@ object Form1: TForm1
OnDockOver = ScriptPanelDockOver OnDockOver = ScriptPanelDockOver
object PageControl1: TPageControl object PageControl1: TPageControl
Left = 150 Left = 150
Height = 293 Height = 296
Top = 0 Top = 0
Width = 584 Width = 584
Align = alClient Align = alClient
@ -244,7 +244,7 @@ object Form1: TForm1
object SearchPanel: TPanel object SearchPanel: TPanel
Left = 0 Left = 0
Height = 35 Height = 35
Top = 293 Top = 296
Width = 734 Width = 734
Align = alBottom Align = alBottom
BevelOuter = bvSpace BevelOuter = bvSpace
@ -340,7 +340,7 @@ object Form1: TForm1
end end
object LabeledEditSearch: TLabeledEdit object LabeledEditSearch: TLabeledEdit
Left = 104 Left = 104
Height = 27 Height = 21
Top = 6 Top = 6
Width = 174 Width = 174
EditLabel.AnchorSideLeft.Control = LabeledEditSearch EditLabel.AnchorSideLeft.Control = LabeledEditSearch
@ -348,10 +348,10 @@ object Form1: TForm1
EditLabel.AnchorSideTop.Side = asrCenter EditLabel.AnchorSideTop.Side = asrCenter
EditLabel.AnchorSideRight.Control = LabeledEditSearch EditLabel.AnchorSideRight.Control = LabeledEditSearch
EditLabel.AnchorSideBottom.Control = LabeledEditSearch EditLabel.AnchorSideBottom.Control = LabeledEditSearch
EditLabel.Left = 65 EditLabel.Left = 73
EditLabel.Height = 18 EditLabel.Height = 14
EditLabel.Top = 10 EditLabel.Top = 9
EditLabel.Width = 36 EditLabel.Width = 28
EditLabel.Caption = 'Find: ' EditLabel.Caption = 'Find: '
EditLabel.ParentColor = False EditLabel.ParentColor = False
LabelPosition = lpLeft LabelPosition = lpLeft
@ -364,9 +364,9 @@ object Form1: TForm1
end end
object CheckBoxMatchCase: TCheckBox object CheckBoxMatchCase: TCheckBox
Left = 320 Left = 320
Height = 22 Height = 17
Top = 7 Top = 7
Width = 98 Width = 72
Caption = 'Match case' Caption = 'Match case'
OnClick = CheckBoxMatchCaseClick OnClick = CheckBoxMatchCaseClick
TabOrder = 1 TabOrder = 1
@ -374,27 +374,27 @@ object Form1: TForm1
end end
object Splitter1: TSplitter object Splitter1: TSplitter
Left = 145 Left = 145
Height = 293 Height = 296
Top = 0 Top = 0
Width = 5 Width = 5
OnCanResize = Splitter1CanResize OnCanResize = Splitter1CanResize
Visible = False Visible = False
end end
inline frmFunctionList: TFunctionListFrame inline frmFunctionList: TFunctionListFrame
Height = 293 Height = 296
Width = 145 Width = 145
ClientHeight = 293 ClientHeight = 296
ClientWidth = 145 ClientWidth = 145
TabOrder = 3 TabOrder = 3
Visible = False Visible = False
inherited FunctionList: TTreeView inherited FunctionList: TTreeView
Height = 266 Height = 275
Width = 145 Width = 145
OnChange = FunctionListChange OnChange = FunctionListChange
OnExit = FunctionListExit OnExit = FunctionListExit
end end
inherited editSearchList: TEdit inherited editSearchList: TEdit
Top = 266 Top = 275
Width = 145 Width = 145
OnExit = editSearchListExit OnExit = editSearchListExit
OnKeyPress = editSearchListKeyPress OnKeyPress = editSearchListKeyPress
@ -1039,7 +1039,6 @@ object Form1: TForm1
00008C8C8C308C8C8CAF8C8C8CFF8C8C8CFF8C8C8CFF8C8C8CEF8C8C8C9F8C8C 00008C8C8C308C8C8CAF8C8C8CFF8C8C8CFF8C8C8CFF8C8C8CEF8C8C8C9F8C8C
8C10000000000000000000000000000000000000000000000000 8C10000000000000000000000000000000000000000000000000
} }
ImageIndex = 26
OnClick = ActionFindstartExecute OnClick = ActionFindstartExecute
end end
object MenuItemFindNext: TMenuItem object MenuItemFindNext: TMenuItem
@ -2480,6 +2479,7 @@ object Form1: TForm1
end end
object ActionFindStart: TAction object ActionFindStart: TAction
Caption = '&Find ...' Caption = '&Find ...'
ImageIndex = 26
OnExecute = ActionFindstartExecute OnExecute = ActionFindstartExecute
ShortCut = 16454 ShortCut = 16454
end end

File diff suppressed because it is too large Load Diff

View File

@ -979,18 +979,10 @@ begin
begin; begin;
key := #0; key := #0;
frmFunctionList.Find(True); frmFunctionList.Find(True);
end; end else
if key = #32 then//space lets do this! if frmFunctionList.InCodeCompletion then
begin; begin;
key := #0; if key = #27 then//esc -> C'est error!
linetext := CurrScript.SynEdit.Lines[frmFunctionList.CompletionCaret.y - 1];
frmFunctionList.editSearchList.OnExit(sender);
while (frmFunctionList.CompletionCaret.x <= length(linetext)) and (linetext[frmFunctionList.CompletionCaret.x] in ['a'..'z','A'..'Z','0'..'9','_']) do
inc(frmFunctionList.CompletionCaret.x);
CurrScript.SynEdit.LogicalCaretXY:= frmFunctionList.CompletionCaret;
CurrScript.SynEdit.SetFocus;
end;
if key = #27 then//esc
begin begin
key := #0; key := #0;
CurrScript.SynEdit.Lines[frmFunctionList.CompletionCaret.y - 1] := frmFunctionList.CompletionStart; CurrScript.SynEdit.Lines[frmFunctionList.CompletionCaret.y - 1] := frmFunctionList.CompletionStart;
@ -998,6 +990,19 @@ begin
CurrScript.SynEdit.LogicalCaretXY:= point(frmFunctionList.CompletionCaret.x,frmFunctionList.CompletionCaret.y); CurrScript.SynEdit.LogicalCaretXY:= point(frmFunctionList.CompletionCaret.x,frmFunctionList.CompletionCaret.y);
CurrScript.SynEdit.SelEnd:= CurrScript.SynEdit.SelStart; CurrScript.SynEdit.SelEnd:= CurrScript.SynEdit.SelStart;
CurrScript.SynEdit.SetFocus; CurrScript.SynEdit.SetFocus;
end else
if key in [' ',',','.','(',')'] then //on on these chars we will insert the function!
begin;
linetext := CurrScript.SynEdit.Lines[frmFunctionList.CompletionCaret.y - 1];
frmFunctionList.editSearchList.OnExit(sender);
while (frmFunctionList.CompletionCaret.x <= length(linetext)) and (linetext[frmFunctionList.CompletionCaret.x] in ['a'..'z','A'..'Z','0'..'9','_']) do
inc(frmFunctionList.CompletionCaret.x);
CurrScript.SynEdit.LogicalCaretXY:= frmFunctionList.CompletionCaret;
CurrScript.SynEdit.SelStart:= CurrScript.SynEdit.SelEnd;
CurrScript.SynEdit.ExecuteCommand(ecChar,key,nil);
CurrScript.SynEdit.SetFocus;
key := #0;
end;
end; end;
end; end;