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

@ -5,4 +5,5 @@ pickcolor: From the Crystal Clear Project (http://www.everaldo.com/crystal/) lic
crosshair: http://led24.de/iconset/ or http://led24.de/ would be appreciated. Follow us on twitter http://twitter.com/gasyoun or email leds24@gmail.com 512 icons 20/05/2009
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);
procedure DockFormOnClose(Sender: TObject; var CloseAction: TCloseAction);
private
procedure CreateFilterTree;
procedure FilterTreeVis(Vis : boolean);
{ private declarations }
public
DraggingNode : TTreeNode;
@ -30,6 +32,7 @@ type
StartWordCompletion : TPoint;
CompletionLine : string;
CompletionStart : string;
FilterTree : TTreeView;
function Find(Next : boolean) : boolean;
{ public declarations }
end;
@ -52,13 +55,41 @@ begin
Form1.MenuItemFunctionList.Checked := False;
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;
var
Start,i,index,posi: Integer;
Start,Len,i,index,posi: Integer;
FoundFunction : boolean;
LastSection : string;
str : string;
RootNode : TTreeNode;
NormalNode : TTreeNode;
Node : TTreeNode;
InsertStr : string;
begin
CreateFilterTree;
if(editSearchList.Text = '')then
begin
editSearchList.Color := clWhite;
@ -69,53 +100,109 @@ begin
Form1.CurrScript.SynEdit.LogicalCaretXY:= point(CompletionCaret.x,CompletionCaret.y);
Form1.CurrScript.SynEdit.SelEnd:= Form1.CurrScript.SynEdit.SelStart;
end;
FilterTreeVis(False);
exit;
end;
FoundFunction := False;
if FunctionList.Selected <> nil then
begin
Start := FunctionList.Selected.AbsoluteIndex;
if(next)then
inc(Start);
end else
Start := 0;
for i := start to start + FunctionList.Items.Count - 1 do
if(FunctionList.Items[i mod FunctionList.Items.Count].Level = 1)then
if(pos(lowercase(editSearchList.Text), lowercase(FunctionList.Items[i mod FunctionList.Items.Count].Text)) > 0)then
//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
FoundFunction := True;
index := i mod FunctionList.Items.Count;
FilterTree.Items[i mod len].Selected:= true;
InsertStr := FilterTree.Items[i mod len].Text;
Result := true;
break;
end;
Result := FoundFunction;
if Result then
begin;
Writeln(FunctionList.Items[Index].Text);
FunctionList.FullCollapse;
FunctionList.Items[Index].Selected := true;
FunctionList.Items[index].ExpandParents;
editSearchList.Color := clWhite;
if InCodeCompletion then
end else
begin
FilterTree.Items.Clear;
FoundFunction := False;
if FunctionList.Selected <> nil then
Start := FunctionList.Selected.AbsoluteIndex
else
Start := 0;
Len := FunctionList.Items.Count;
LastSection := '';
for i := start to start + FunctionList.Items.Count - 1 do
begin;
str := format(CompletionLine, [FunctionList.items[index].text]);
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
FoundFunction := True;
index := i mod FunctionList.Items.Count;
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;
Result := FoundFunction;
if Result then
begin;
FilterTreeVis(True);
FilterTree.FullExpand;
FilterTree.Items[1].Selected:= True;
Writeln(FunctionList.Items[Index].Text);
FunctionList.FullCollapse;
FunctionList.Items[Index].Selected := true;
FunctionList.Items[index].ExpandParents;
editSearchList.Color := clWhite;
end else
begin
FilterTreeVis(false);
editSearchList.Color := 6711039;
if InCodeCompletion then
Form1.CurrScript.SynEdit.Lines[CompletionCaret.y - 1] := CompletionStart;
end;
end;
if result and InCodeCompletion then
begin;
str := format(CompletionLine, [InsertStr]);
with Form1.CurrScript.SynEdit do
begin;
Lines[CompletionCaret.y - 1] := str;
LogicalCaretXY:= StartWordCompletion;
i := SelStart;
posi := pos(lowercase(editSearchList.text), lowercase(FunctionList.items[index].text));
SelStart := i + length(editSearchList.Text) + posi - 1;
SelEnd := i + Length(str);
posi := pos(lowercase(editSearchList.text), lowercase(InsertStr)) + length(editSearchList.text) - 1; //underline the rest of the word
if Posi = Length(InsertStr) then //Special occasions
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;
//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;
procedure TFunctionListFrame.FunctionListMouseDown(Sender: TObject;
@ -128,7 +215,9 @@ begin
Writeln('Not yet implemented');
exit;
end;
N := Self.FunctionList.GetNodeAt(x, y);
if not (Sender is TTreeView) then
exit;
N := TTreeView(Sender).GetNodeAt(x, y);
if(N = nil)then
begin
Self.DragKind := dkDock;

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -979,25 +979,30 @@ begin
begin;
key := #0;
frmFunctionList.Find(True);
end;
if key = #32 then//space lets do this!
end else
if frmFunctionList.InCodeCompletion then
begin;
key := #0;
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
key := #0;
CurrScript.SynEdit.Lines[frmFunctionList.CompletionCaret.y - 1] := frmFunctionList.CompletionStart;
frmFunctionList.editSearchList.OnExit(sender);
CurrScript.SynEdit.LogicalCaretXY:= point(frmFunctionList.CompletionCaret.x,frmFunctionList.CompletionCaret.y);
CurrScript.SynEdit.SelEnd:= CurrScript.SynEdit.SelStart;
CurrScript.SynEdit.SetFocus;
if key = #27 then//esc -> C'est error!
begin
key := #0;
CurrScript.SynEdit.Lines[frmFunctionList.CompletionCaret.y - 1] := frmFunctionList.CompletionStart;
frmFunctionList.editSearchList.OnExit(sender);
CurrScript.SynEdit.LogicalCaretXY:= point(frmFunctionList.CompletionCaret.x,frmFunctionList.CompletionCaret.y);
CurrScript.SynEdit.SelEnd:= CurrScript.SynEdit.SelStart;
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;