diff --git a/editor/studio/AMXX_Studio.dof b/editor/studio/AMXX_Studio.dof index 10d04fc7..25a8299b 100755 --- a/editor/studio/AMXX_Studio.dof +++ b/editor/studio/AMXX_Studio.dof @@ -113,9 +113,9 @@ RootDir=C:\Programme\Borland\Delphi7\Bin\ IncludeVerInfo=1 AutoIncBuild=1 MajorVer=1 -MinorVer=2 +MinorVer=3 Release=0 -Build=4 +Build=9 Debug=0 PreRelease=0 Special=0 @@ -126,7 +126,7 @@ CodePage=1252 [Version Info Keys] CompanyName=AMX Mod X Dev Team FileDescription= -FileVersion=1.2.0.4 +FileVersion=1.3.0.9 InternalName= LegalCopyright= LegalTrademarks= diff --git a/editor/studio/AMXX_Studio.dpr b/editor/studio/AMXX_Studio.dpr index 987fce27..881ee979 100755 --- a/editor/studio/AMXX_Studio.dpr +++ b/editor/studio/AMXX_Studio.dpr @@ -10,7 +10,6 @@ uses SysUtils, SciLexerMemo, JvInspector, - UnitfrmMain in 'UnitfrmMain.pas' {frmMain}, UnitMainTools in 'UnitMainTools.pas', UnitfrmSettings in 'UnitfrmSettings.pas' {frmSettings}, @@ -61,6 +60,7 @@ begin for i := 1 to ParamCount do SendStudioMsg(SCM_LOADFILE, ParamStr(i), 0); end; + SetForegroundWindow(FindWindow('TfrmMain', 'AMXX-Studio')); exit; end; Application.Initialize; @@ -70,6 +70,9 @@ begin Application.CreateForm(TfrmSettings, frmSettings); Application.OnMessage := frmMain.OnMessage; Application.OnShortCut := frmMain.OnShortCut; + frmMain.sciEditor.Lines[5] := '#define PLUGIN "' + frmSettings.txtDefaultName.Text + '"'; + frmMain.sciEditor.Lines[6] := '#define VERSION "' + frmSettings.txtDefaultVersion.Text + '"'; + frmMain.sciEditor.Lines[7] := '#define AUTHOR "' + frmSettings.txtDefaultAuthor.Text + '"'; frmMain.sciPropertyLoader.FileName := ExtractFilePath(ParamStr(0)) + 'config\Editor.sci'; if FileExists(frmMain.sciPropertyLoader.FileName) then @@ -129,7 +132,7 @@ begin ActivateProjects(0, False); // Started := True is already set here PAWNProjects.Activate(PAWNProjects.Count -1, False, False); end; - UpdateCI; + UpdateCI(frmMain.sciEditor.GetCurrentLineNumber); Application.CreateForm(TfrmSelectColor, frmSelectColor); Application.CreateForm(TfrmInfo, frmInfo); diff --git a/editor/studio/AMXX_Studio.exe b/editor/studio/AMXX_Studio.exe index 050ad7b3..d24e5f8b 100755 Binary files a/editor/studio/AMXX_Studio.exe and b/editor/studio/AMXX_Studio.exe differ diff --git a/editor/studio/AMXX_Studio.res b/editor/studio/AMXX_Studio.res index ac6ccc60..b71a3f77 100755 Binary files a/editor/studio/AMXX_Studio.res and b/editor/studio/AMXX_Studio.res differ diff --git a/editor/studio/SciLexer.dll b/editor/studio/SciLexer.dll index ba8b3265..821e41dc 100755 Binary files a/editor/studio/SciLexer.dll and b/editor/studio/SciLexer.dll differ diff --git a/editor/studio/UnitCodeExplorerUpdater.pas b/editor/studio/UnitCodeExplorerUpdater.pas index 3243a822..a3ea0a08 100755 --- a/editor/studio/UnitCodeExplorerUpdater.pas +++ b/editor/studio/UnitCodeExplorerUpdater.pas @@ -4,7 +4,7 @@ interface uses Classes, Forms, SysUtils, ComCtrls, Windows, ScintillaLanguageManager, - Dialogs, CommCtrl; + Dialogs, CommCtrl, madExcept; type TCodeExplorerUpdater = class(TThread) @@ -19,14 +19,16 @@ type eVariables: TStringList; eCode: TStringList; - - eAutoComplete, eCallTips, eKeywords: String; + + eAutoComplete, eCallTips, eKeywords: string; protected procedure Execute; override; procedure GetCode; procedure SetValuesPawn; end; +function GetNode(eText: string): TTreeNode; + implementation uses UnitfrmMain, UnitLanguages, UnitMainTools, UnitCodeUtils, @@ -85,14 +87,15 @@ begin end; end; except - // GABEN + if FindWindow(nil, 'Delphi 7') <> 0 then // This is "Debug Mode" + madExcept.HandleException; end; end; Sleep(1000); end else Sleep(50); - until (Application.Terminated); + until not Started; eCode.Free; eConstants.Free; @@ -113,13 +116,12 @@ begin eCode.Assign(frmMain.sciEditor.Lines); end; -procedure TCodeExplorerUpdater.SetValuesPawn; -function GetNode(eText: String): TTreeNode; +function GetNode(eText: string): TTreeNode; var i: integer; begin Result := nil; - for i := 0 to frmMain.trvExplorer.Items.Count -1 do begin + for i := 0 to frmMain.trvExplorer.Items.Count - 1 do begin if (frmMain.trvExplorer.Items[i].Text = eText) then begin if (frmMain.trvExplorer.Items[i].ImageIndex = 42) or (frmMain.trvExplorer.Items[i].ImageIndex = 43) then begin Result := frmMain.trvExplorer.Items[i]; @@ -129,196 +131,221 @@ begin end; end; +procedure TCodeExplorerUpdater.SetValuesPawn; var exConstants, exDefined, exIncluded, exMethods, exDefault, exEvents, - exStocks, exNatives, exForwards, exVariables, exCVars: Boolean; - i, eSelStart, eSelLength: integer; - LineMaxSubord: integer; - eStr: TStringList; - eScrollPosX, eScrollPosY: Integer; + exStocks, exNatives, exForwards, exVariables, exCVars: Boolean; + i, eSelStart, eSelLength: integer; + LineMaxSubord: integer; + eStr: TStringList; + eScrollPosX, eScrollPosY: Integer; + eTempNode: TTreeNode; + eSelected: Integer; begin + if Application.Terminated then exit; if frmMain.trvExplorer.Items.Count = 0 then exit; + if Assigned(frmMain.trvExplorer.Selected) then + eSelected := frmMain.trvExplorer.Selected.AbsoluteIndex + else + eSelected := -1; + frmMain.trvExplorer.Items.BeginUpdate; - eScrollPosX := GetScrollPos(frmMain.trvExplorer.Handle, SB_HORZ); - eScrollPosY := GetScrollPos(frmMain.trvExplorer.Handle, SB_VERT); + try + eScrollPosX := GetScrollPos(frmMain.trvExplorer.Handle, SB_HORZ); + eScrollPosY := GetScrollPos(frmMain.trvExplorer.Handle, SB_VERT); // Get Expanded-State and delete children - with GetNode('Constants') do begin - exConstants := Expanded; - DeleteChildren; - end; - with GetNode('CVars') do begin - exCVars := Expanded; - DeleteChildren; - end; - with GetNode('Defined') do begin - exDefined := Expanded; - DeleteChildren; - end; - with GetNode('Included') do begin - exIncluded := Expanded; - DeleteChildren; - end; - with GetNode('Default') do begin - exDefault := Expanded; - DeleteChildren; - end; - with GetNode('Events') do begin - exEvents := Expanded; - DeleteChildren; - end; - with GetNode('Stocks') do begin - exStocks := Expanded; - DeleteChildren; - end; - with GetNode('Methods') do begin - exMethods := Expanded; - DeleteChildren; - end; - with GetNode('Natives') do begin - exNatives := Expanded; - DeleteChildren; - end; - with GetNode('Forwards') do begin - exForwards := Expanded; - DeleteChildren; - end; - with GetNode('Variables') do begin - exVariables := Expanded; - DeleteChildren; - end; + with GetNode('Constants') do begin + exConstants := Expanded; + DeleteChildren; + end; + with GetNode('CVars') do begin + exCVars := Expanded; + DeleteChildren; + end; + with GetNode('Defined') do begin + exDefined := Expanded; + DeleteChildren; + end; + with GetNode('Included') do begin + exIncluded := Expanded; + DeleteChildren; + end; + with GetNode('Default') do begin + exDefault := Expanded; + DeleteChildren; + end; + with GetNode('Events') do begin + exEvents := Expanded; + DeleteChildren; + end; + with GetNode('Stocks') do begin + exStocks := Expanded; + DeleteChildren; + end; + with GetNode('Methods') do begin + exMethods := Expanded; + DeleteChildren; + end; + with GetNode('Natives') do begin + exNatives := Expanded; + DeleteChildren; + end; + with GetNode('Forwards') do begin + exForwards := Expanded; + DeleteChildren; + end; + with GetNode('Variables') do begin + exVariables := Expanded; + DeleteChildren; + end; // Create new children - with frmMain.trvExplorer.Items.AddChild(GetNode('Defined'), 'CVars') do begin - ImageIndex := 42; - SelectedIndex := 42; - end; - with frmMain.trvExplorer.Items.AddChild(GetNode('Methods'), 'Default') do begin - ImageIndex := 42; - SelectedIndex := 42; - end; - with frmMain.trvExplorer.Items.AddChild(GetNode('Methods'), 'Events') do begin - ImageIndex := 42; - SelectedIndex := 42; - end; - with frmMain.trvExplorer.Items.AddChild(GetNode('Methods'), 'Stocks') do begin - ImageIndex := 42; - SelectedIndex := 42; - end; + with frmMain.trvExplorer.Items.AddChild(GetNode('Defined'), 'CVars') do begin + ImageIndex := 42; + SelectedIndex := 42; + end; + with frmMain.trvExplorer.Items.AddChild(GetNode('Methods'), 'Default') do begin + ImageIndex := 42; + SelectedIndex := 42; + end; + with frmMain.trvExplorer.Items.AddChild(GetNode('Methods'), 'Events') do begin + ImageIndex := 42; + SelectedIndex := 42; + end; + with frmMain.trvExplorer.Items.AddChild(GetNode('Methods'), 'Stocks') do begin + ImageIndex := 42; + SelectedIndex := 42; + end; - for i := 0 to eConstants.Count -1 do begin - with frmMain.trvExplorer.Items.AddChildObject(GetNode('Constants'), eConstants[i], Pointer(eConstants.Objects[i])) do begin - ImageIndex := 48; - SelectedIndex := 48; + eTempNode := GetNode('Constants'); + for i := 0 to eConstants.Count - 1 do begin + with frmMain.trvExplorer.Items.AddChildObject(eTempNode, eConstants[i], Pointer(eConstants.Objects[i])) do begin + ImageIndex := 48; + SelectedIndex := 48; + end; end; - end; - for i := 0 to eDefined.Count -1 do begin - with frmMain.trvExplorer.Items.AddChildObject(GetNode('Defined'), eDefined[i], Pointer(eDefined.Objects[i])) do begin - ImageIndex := 48; - SelectedIndex := 48; + eTempNode := GetNode('Defined'); + for i := 0 to eDefined.Count - 1 do begin + with frmMain.trvExplorer.Items.AddChildObject(eTempNode, eDefined[i], Pointer(eDefined.Objects[i])) do begin + ImageIndex := 48; + SelectedIndex := 48; + end; end; - end; - for i := 0 to eCVars.Count -1 do begin - with frmMain.trvExplorer.Items.AddChildObject(GetNode('CVars'), eCVars[i], Pointer(eCVars.Objects[i])) do begin - ImageIndex := 35; - SelectedIndex := 35; + eTempNode := GetNode('CVars'); + for i := 0 to eCVars.Count - 1 do begin + with frmMain.trvExplorer.Items.AddChildObject(eTempNode, eCVars[i], Pointer(eCVars.Objects[i])) do begin + ImageIndex := 35; + SelectedIndex := 35; + end; end; - end; // Sort items - eIncluded.Sort; - eMethodsDefault.Sort; - eMethodsEvents.Sort; - eStocks.Sort; - eNatives.Sort; - eForwards.Sort; - eVariables.Sort; + eIncluded.Sort; + eMethodsDefault.Sort; + eMethodsEvents.Sort; + eStocks.Sort; + eNatives.Sort; + eForwards.Sort; + eVariables.Sort; // Add items - for i := 0 to eIncluded.Count -1 do begin - with frmMain.trvExplorer.Items.AddChildObject(GetNode('Included'), eIncluded[i], Pointer(eIncluded.Objects[i])) do begin - ImageIndex := 34; - SelectedIndex := 34; + eTempNode := GetNode('Included'); + for i := 0 to eIncluded.Count - 1 do begin + with frmMain.trvExplorer.Items.AddChildObject(eTempNode, eIncluded[i], Pointer(eIncluded.Objects[i])) do begin + ImageIndex := 34; + SelectedIndex := 34; + end; end; - end; - for i := 0 to eMethodsDefault.Count -1 do begin - with frmMain.trvExplorer.Items.AddChildObject(GetNode('Default'), eMethodsDefault[i], Pointer(eMethodsDefault.Objects[i])) do begin - ImageIndex := 12; - SelectedIndex := 12; + eTempNode := GetNode('Default'); + for i := 0 to eMethodsDefault.Count - 1 do begin + with frmMain.trvExplorer.Items.AddChildObject(eTempNode, eMethodsDefault[i], Pointer(eMethodsDefault.Objects[i])) do begin + ImageIndex := 12; + SelectedIndex := 12; + end; end; - end; - for i := 0 to eMethodsEvents.Count -1 do begin - with frmMain.trvExplorer.Items.AddChildObject(GetNode('Events'), eMethodsEvents[i], Pointer(eMethodsEvents.Objects[i])) do begin - ImageIndex := 47; - SelectedIndex := 47; + eTempNode := GetNode('Events'); + for i := 0 to eMethodsEvents.Count - 1 do begin + with frmMain.trvExplorer.Items.AddChildObject(eTempNode, eMethodsEvents[i], Pointer(eMethodsEvents.Objects[i])) do begin + ImageIndex := 47; + SelectedIndex := 47; + end; end; - end; - for i := 0 to eStocks.Count -1 do begin - with frmMain.trvExplorer.Items.AddChildObject(GetNode('Stocks'), eStocks[i], Pointer(eStocks.Objects[i])) do begin - ImageIndex := 12; - SelectedIndex := 12; + eTempNode := GetNode('Stocks'); + for i := 0 to eStocks.Count - 1 do begin + with frmMain.trvExplorer.Items.AddChildObject(eTempNode, eStocks[i], Pointer(eStocks.Objects[i])) do begin + ImageIndex := 12; + SelectedIndex := 12; + end; end; - end; - for i := 0 to eNatives.Count -1 do begin - with frmMain.trvExplorer.Items.AddChildObject(GetNode('Natives'), eNatives[i], Pointer(eNatives.Objects[i])) do begin - ImageIndex := 47; - SelectedIndex := 47; + eTempNode := GetNode('Natives'); + for i := 0 to eNatives.Count - 1 do begin + with frmMain.trvExplorer.Items.AddChildObject(eTempNode, eNatives[i], Pointer(eNatives.Objects[i])) do begin + ImageIndex := 47; + SelectedIndex := 47; + end; end; - end; - for i := 0 to eForwards.Count -1 do begin - with frmMain.trvExplorer.Items.AddChildObject(GetNode('Forwards'), eForwards[i], Pointer(eForwards.Objects[i])) do begin - ImageIndex := 47; - SelectedIndex := 47; + eTempNode := GetNode('Forwards'); + for i := 0 to eForwards.Count - 1 do begin + with frmMain.trvExplorer.Items.AddChildObject(eTempNode, eForwards[i], Pointer(eForwards.Objects[i])) do begin + ImageIndex := 47; + SelectedIndex := 47; + end; end; - end; - for i := 0 to eVariables.Count -1 do begin - with frmMain.trvExplorer.Items.AddChildObject(GetNode('Variables'), eVariables[i], Pointer(eVariables.Objects[i])) do begin - ImageIndex := 35; - SelectedIndex := 35; + eTempNode := GetNode('Variables'); + for i := 0 to eVariables.Count - 1 do begin + with frmMain.trvExplorer.Items.AddChildObject(eTempNode, eVariables[i], Pointer(eVariables.Objects[i])) do begin + ImageIndex := 35; + SelectedIndex := 35; + end; end; - end; - GetNode('Constants').Expanded := exConstants; - GetNode('Defined').Expanded := exDefined; - GetNode('CVars').Expanded := exCVars; - GetNode('Included').Expanded := exIncluded; - GetNode('Methods').Expanded := exMethods; - GetNode('Default').Expanded := exDefault; - GetNode('Events').Expanded := exEvents; - GetNode('Stocks').Expanded := exStocks; - GetNode('Natives').Expanded := exNatives; - GetNode('Forwards').Expanded := exForwards; - GetNode('Variables').Expanded := exVariables; + GetNode('Constants').Expanded := exConstants; + GetNode('Defined').Expanded := exDefined; + GetNode('CVars').Expanded := exCVars; + GetNode('Included').Expanded := exIncluded; + GetNode('Methods').Expanded := exMethods; + GetNode('Default').Expanded := exDefault; + GetNode('Events').Expanded := exEvents; + GetNode('Stocks').Expanded := exStocks; + GetNode('Natives').Expanded := exNatives; + GetNode('Forwards').Expanded := exForwards; + GetNode('Variables').Expanded := exVariables; - SetScrollPos(frmMain.trvExplorer.Handle, SB_HORZ, eScrollPosX, False); - SetScrollPos(frmMain.trvExplorer.Handle, SB_VERT, eScrollPosY, False); + SetScrollPos(frmMain.trvExplorer.Handle, SB_HORZ, eScrollPosX, False); + SetScrollPos(frmMain.trvExplorer.Handle, SB_VERT, eScrollPosY, False); + if eSelected <> -1 then + frmMain.trvExplorer.Items[eSelected].Selected := True; + except + // well, yes. + end; frmMain.trvExplorer.Items.EndUpdate; if (not frmMain.pnlLoading.Visible) and (not frmMain.sciEditor.AutoCActive) and (not frmMain.sciEditor.CallTipActive) then begin frmMain.sciAutoComplete.AStrings.Text := eAutoComplete; - for i := frmMain.sciAutoComplete.AStrings.Count -1 downto 0 do begin + for i := frmMain.sciAutoComplete.AStrings.Count - 1 downto 0 do begin if Length(Trim(frmMain.sciAutoComplete.AStrings[i])) <= 1 then frmMain.sciAutoComplete.AStrings.Delete(i); end; frmMain.sciCallTips.ApiStrings.Text := eCallTips; - for i := frmMain.sciCallTips.ApiStrings.Count -1 downto 0 do begin + for i := frmMain.sciCallTips.ApiStrings.Count - 1 downto 0 do begin if Length(Trim(frmMain.sciCallTips.ApiStrings[i])) <= 1 then frmMain.sciCallTips.ApiStrings.Delete(i); end; with TSciKeywords(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Find('Pawn').Keywords.Items[1])) do begin eStr := TStringList.Create; - for i := 0 to frmMain.sciEditor.Lines.Count -1 do begin + for i := 0 to frmMain.sciEditor.Lines.Count - 1 do begin if not frmMain.sciEditor.GetFoldExpanded(i) then eStr.Add(IntToStr(i)); end; - + Keywords.Text := eKeywords; frmMain.sciEditor.LanguageManager.Update; - for i := 0 to frmMain.sciEditor.Lines.Count -1 do begin + for i := 0 to frmMain.sciEditor.Lines.Count - 1 do begin if eStr.IndexOf(IntToStr(i)) <> -1 then begin LineMaxSubord := frmMain.sciEditor.GetLastChild(i, -1); frmMain.sciEditor.SetFoldExpanded(i, False); if LineMaxSubord > i then - frmMain.sciEditor.HideLines(i+1, LineMaxSubord); + frmMain.sciEditor.HideLines(i + 1, LineMaxSubord); end; end; @@ -330,3 +357,4 @@ begin end; end. + diff --git a/editor/studio/UnitCodeInspector.pas b/editor/studio/UnitCodeInspector.pas index 5f84dc3d..7617633b 100755 --- a/editor/studio/UnitCodeInspector.pas +++ b/editor/studio/UnitCodeInspector.pas @@ -2,7 +2,7 @@ unit UnitCodeInspector; interface -uses SysUtils, Classes, Windows, JvInspector, UnitMainTools, Contnrs; +uses SysUtils, Classes, Windows, JvInspector, UnitMainTools, Contnrs, Forms; type TSelectionTextList = class(TStringList) @@ -35,30 +35,149 @@ type TSTLWrapper = class(TObject) public STL: TSelectionTextList; - Value: String; - constructor Create(const ASTL: TSelectionTextList; const AValue: String); reintroduce; + Value: string; + constructor Create(const ASTL: TSelectionTextList; const AValue: string); reintroduce; destructor Destroy; reintroduce; end; -function AddField(eName, eCategory, eValue: String): TJvCustomInspectorItem; -function AddCombo(eName, eCategory, eValue: String; eValues: array of string): TJvCustomInspectorItem; +function AddField(eName, eCategory, eValue: string): TJvCustomInspectorItem; +function AddCombo(eName, eCategory, eValue: string; eValues: array of string): TJvCustomInspectorItem; +function FindItem(eParent: TJvCustomInspectorItem; eName: string): TJvCustomInspectorItem; +function CreateCategory(eCategory: string): TJvInspectorCustomCategoryItem; -procedure UpdateCI; -procedure UpdateCI_Pawn; +procedure UpdateCI(eLine: Integer); +procedure UpdateCI_Pawn(eLine: Integer); -var eFormatSettings: String; - eAllIncluded: TStringArray; - +procedure RebuildLine; + +var eCILine: Integer; FItems: TObjectList; STLItem: TSelectionTextList; + eStock: Boolean; implementation uses UnitfrmMain, UnitLanguages, UnitCodeUtils, UnitMenuGenerators, - UnitPlugins; + UnitPlugins, UnitCodeExplorerUpdater, UnitfrmSettings; var eBraceTexts: TStringList; +procedure HideBracesAndStrings(var eStr: string; ReplaceAll: Boolean); +begin + eStr := StringReplace(eStr, '^"', #5, [rfReplaceAll]); + while Between(eStr, '"', '"') <> '' do begin + eBraceTexts.Add('"' + Between(eStr, '"', '"') + '"'); + eStr := StringReplace(eStr, '"' + Between(eStr, '"', '"') + '"', #3 + IntToStr(eBraceTexts.Count) + #3, []); + end; + while Between(eStr, '{', '}') <> '' do begin + eBraceTexts.Add('{' + Between(eStr, '{', '}') + '}'); + eStr := StringReplace(eStr, '{' + Between(eStr, '{', '}') + '}', #1 + IntToStr(eBraceTexts.Count) + #1, []); + end; + if ReplaceAll then begin + while Between(eStr, '(', ')', True) <> '' do begin + eBraceTexts.Add('(' + Between(eStr, '(', ')', True) + ')'); + eStr := StringReplace(eStr, '(' + Between(eStr, '(', ')', True) + ')', #2 + IntToStr(eBraceTexts.Count) + #2, []); + end; + end; +end; + +function ShowBracesAndStrings(eStr: string): string; +var k: integer; +begin + while Between(eStr, #1, #1) <> '' do begin + k := StrToInt(Between(eStr, #1, #1)); + eStr := StringReplace(eStr, #1 + IntToStr(k) + #1, eBraceTexts[k - 1], []) + end; + while Between(eStr, #2, #2) <> '' do begin + k := StrToInt(Between(eStr, #2, #2)); + eStr := StringReplace(eStr, #2 + IntToStr(k) + #2, eBraceTexts[k - 1], []) + end; + while Between(eStr, #3, #3) <> '' do begin + k := StrToInt(Between(eStr, #3, #3)); + eStr := StringReplace(eStr, #3 + IntToStr(k) + #3, eBraceTexts[k - 1], []) + end; + eStr := StringReplace(eStr, #5, '^"', [rfReplaceAll]); + Result := eStr; +end; + +procedure CheckCIComment(eCurrLine: string); +begin + if (Pos('//', eCurrLine) < Pos('/*', eCurrLine)) and (Pos('//', eCurrLine) <> 0) then begin + CreateCategory('Comment'); + AddField('Line Comment', 'Comment', Trim(Copy(eCurrLine, Pos('//', eCurrLine) + 2, Length(eCurrLine)))); + end + else if (Pos('//', eCurrLine) <> 0) and (Pos('/*', eCurrLine) = 0) then begin + CreateCategory('Comment'); + AddField('Line Comment', 'Comment', Trim(Copy(eCurrLine, Pos('//', eCurrLine) + 2, Length(eCurrLine)))); + end + else if Pos('/*', eCurrLine) <> 0 then begin + CreateCategory('Comment'); + if Pos('*/', eCurrLine) = 0 then + AddField('Doc Comment', 'Comment', Trim(Copy(eCurrLine, Pos('/*', eCurrLine) + 2, Length(eCurrLine)))) + else begin + eCurrLine := Copy(eCurrLine, Pos('/*', eCurrLine) + 2, Length(eCurrLine)); + AddField('Doc Comment', 'Comment', Trim(Copy(eCurrLine, 1, Pos('*/', eCurrLine) - 2))); + end; + end; +end; + +function Assignment(eLine: string): string; +begin + Result := ''; + HideBracesAndStrings(eLine, True); + eLine := RemoveStringsAndComments(eLine, True, True); + + if Pos('=', eLine) <> 0 then + Result := '='; + if Pos('+=', eLine) <> 0 then + Result := '+='; + if Pos('-=', eLine) <> 0 then + Result := '-='; + if Pos('*=', eLine) <> 0 then + Result := '*='; + if Pos('/=', eLine) <> 0 then + Result := '/='; + if Pos('%=', eLine) <> 0 then + Result := '%='; + if Pos('>>=', eLine) <> 0 then + Result := '>>='; + if Pos('>>>=', eLine) <> 0 then + Result := '>>>='; + if Pos('<<=', eLine) <> 0 then + Result := '<<='; + if Pos('&=', eLine) <> 0 then + Result := '&='; + if Pos('|=', eLine) <> 0 then + Result := '|='; + + if (Pos(Result, Trim(eLine)) < Pos('(', Trim(eLine))) and (Result <> '') then + Result := ''; +end; + +procedure AddFunc(eValueName, eFuncCall, eParent: string); +var eStr: TStringList; + i: integer; +begin + eFuncCall := Trim(eFuncCall); + if (CountChars(eFuncCall, '(') = CountChars(eFuncCall, ')')) and (CountChars(eFuncCall, '(') = 0) then + AddField(eValueName, eParent, eFuncCall) // Simple assignment + else if (Trim(Copy(eFuncCall, 1, Pos('(', eFuncCall) - 1)) = '') or (Pos('"', eFuncCall) = 1) then + AddField(eValueName, eParent, eFuncCall) // Simple assignment + else begin // Function call + AddField(eValueName, eParent, 'Function Call').ReadOnly := True; + AddField('Function', eParent + '->' + eValueName, Trim(Copy(eFuncCall, 1, Pos('(', eFuncCall) - 1))); + + eStr := TStringList.Create; + eFuncCall := Copy(eFuncCall, Pos('(', eFuncCall) + 1, GetMatchingBrace(eFuncCall) - Pos('(', eFuncCall) - 1); + HideBracesAndStrings(eFuncCall, True); + eStr.Text := StringReplace(eFuncCall, ',', #13, [rfReplaceAll]); + for i := 0 to eStr.Count - 1 do + AddField('Param ' + IntToStr(i + 1), eParent + '->' + eValueName, Trim(ShowBracesAndStrings(eStr[i]))); + eStr.Free; + end; +end; + + { "Combobox"-Item } function TSelectionTextList.GetSelected: Integer; @@ -86,7 +205,10 @@ end; procedure TSelectionTextList.SetSelectedText(const Value: string); begin - FSelected := IndexOf(Value); + if IndexOf(Value) = -1 then + FSelected := Add(Value) + else + FSelected := IndexOf(Value); end; function TJvInspectorSelectionTextListItem.GetDisplayValue: string; @@ -106,7 +228,7 @@ end; procedure TJvInspectorSelectionTextListItem.SetFlags(const Value: TInspectorItemFlags); begin - inherited SetFlags(Value + [iifValueList]); + inherited SetFlags(Value + [iifValueList, iifAllowNonListValues]); end; constructor TStringWrapper.Create(const AValue: string); @@ -117,30 +239,21 @@ end; { Codeinspector Add Functions } -function AddCombo(eName, eCategory, eValue: String; eValues: array of string): TJvCustomInspectorItem; -var - i: integer; +function AddCombo(eName, eCategory, eValue: string; eValues: array of string): TJvCustomInspectorItem; +var i: integer; eParent: TJvCustomInspectorItem; Item: TSTLWrapper; Found: Boolean; begin - eParent := nil; - for i := 0 to frmMain.jviCode.Root.Count -1 do - begin - if (frmMain.jviCode.Root.Items[i].DisplayName = eCategory) and (frmMain.jviCode.Root.Items[i] is TJvInspectorCustomCategoryItem) then - begin - eParent := frmMain.jviCode.Root.Items[i]; - Break; - end; - end; - if eParent = nil then - begin - eParent := TJvInspectorCustomCategoryItem.Create(frmMain.jviCode.Root, nil); - eParent.DisplayName := eCategory; + eName := StringReplace(eName, '&', '&&', [rfReplaceAll]); + + eParent := FindItem(nil, eCategory); + if eParent = nil then begin + eParent := CreateCategory(eCategory); + eCategory := Copy(eCategory, Pos('->', eCategory) + 2, Length(eCategory)); end; - if eName <> '' then - begin + if eName <> '' then begin STLItem := TSelectionTextList.Create; Found := False; for i := 0 to High(eValues) do begin @@ -157,253 +270,684 @@ begin Item := TSTLWrapper.Create(STLItem, eValue); FItems.Add(Item); FItems.Add(STLItem); - + STLItem.SelectedText := Item.Value; Result := TJvInspectorVarData.New(eParent, eName, TypeInfo(TSelectionTextList), @Item.STL); - frmMain.jviCode.Root.Sort; eParent.Expanded := True; end else - begin Result := nil; - frmMain.jviCode.Root.Sort; +end; + +function AddField(eName, eCategory, eValue: string): TJvCustomInspectorItem; +var eParent: TJvCustomInspectorItem; + Item: TStringWrapper; +begin + eName := StringReplace(eName, '&', '&&', [rfReplaceAll]); + + eParent := FindItem(nil, eCategory); + if eParent = nil then begin + eParent := CreateCategory(eCategory); + eCategory := Copy(eCategory, Pos('->', eCategory) + 2, Length(eCategory)); + end; + + if eName <> '' then begin + Item := TStringWrapper.Create(eValue); + FItems.Add(Item); + Result := TJvInspectorVarData.New(eParent, eName, TypeInfo(string), @Item.Value); + Result.SortKind := iskNone; + eParent.Expanded := True; + end + else + Result := nil; +end; + +function FindItem(eParent: TJvCustomInspectorItem; eName: string): TJvCustomInspectorItem; +var i: integer; + eParentText: string; +begin + if Pos('->', eName) <> 0 then begin + eParentText := Copy(eName, 1, Pos('->', eName) - 2); + eName := Copy(eName, Pos('->', eName) + 2, Length(eName)); + end + else + eParentText := ''; + + Result := nil; + if Assigned(eParent) then begin + for i := 0 to eParent.Count - 1 do begin + if eParent.Items[i].DisplayName = eName then + Result := eParent.Items[i] + else if eParent.Items[i].Count <> 0 then + Result := FindItem(eParent.Items[i], eName); + + if Assigned(Result) then begin + if (Assigned(Result.Parent)) and (eParentText <> '') then begin + if eParentText = Result.Parent.DisplayName then + exit + else + Result := nil; + end + else + exit; + end; + end; + end + else begin + for i := 0 to frmMain.jviCode.Root.Count - 1 do begin + if frmMain.jviCode.Root.Items[i].DisplayName = eName then + Result := frmMain.jviCode.Root.Items[i] + else if frmMain.jviCode.Root.Items[i].Count <> 0 then + Result := FindItem(frmMain.jviCode.Root.Items[i], eName); + + if Assigned(Result) then begin + if (Assigned(Result.Parent)) and (eParentText <> '') then begin + if eParentText = Result.Parent.DisplayName then + exit + else + Result := nil; + end + else + exit; + end; + end; end; end; -function AddField(eName, eCategory, eValue: String): TJvCustomInspectorItem; -var - i: integer; - eParent: TJvCustomInspectorItem; - Item: TStringWrapper; +function CreateCategory(eCategory: string): TJvInspectorCustomCategoryItem; begin - eParent := nil; - for i := 0 to frmMain.jviCode.Root.Count -1 do - begin - if (frmMain.jviCode.Root.Items[i].DisplayName = eCategory) and (frmMain.jviCode.Root.Items[i] is TJvInspectorCustomCategoryItem) then - begin - eParent := frmMain.jviCode.Root.Items[i]; - Break; - end; - end; - if eParent = nil then - begin - eParent := TJvInspectorCustomCategoryItem.Create(frmMain.jviCode.Root, nil); - eParent.DisplayName := eCategory; - end; + if Pos('->', eCategory) <> 0 then + eCategory := Copy(eCategory, Pos('->', eCategory) + 2, Length(eCategory)); - if eName <> '' then - begin - Item := TStringWrapper.Create(eValue); // StringWrapper erzeugen, damit der String erhalten bleibt - FItems.Add(Item); // und das Item in die Liste eintragen, damit kein Speicherleck entsteht - Result := TJvInspectorVarData.New(eParent, eName, TypeInfo(String), @Item.Value); - frmMain.jviCode.Root.Sort; - eParent.Expanded := True; - end - else - begin - Result := nil; - frmMain.jviCode.Root.Sort; - end; + Result := TJvInspectorCustomCategoryItem(FindItem(nil, eCategory)); + if Assigned(Result) then exit; + + Result := TJvInspectorCustomCategoryItem.Create(frmMain.jviCode.Root, nil); + Result.DisplayName := eCategory; + Result.SortKind := iskNone; end; { Parse Functions } -procedure UpdateCI; +procedure UpdateCI(eLine: Integer); begin + if eCILine <> -1 then begin + eCILine := eLine; + exit; + end; + if not Plugin_UpdateCodeInspector(GetCurrLang.Name, ActiveDoc.FileName, frmMain.tsMain.Items[frmMain.tsMain.ActiveTabIndex].Caption, True) then exit; if GetCurrLang.Name = 'Pawn' then begin - UpdateCI_Pawn; + UpdateCI_Pawn(eLine); Plugin_UpdateCodeInspector(GetCurrLang.Name, ActiveDoc.FileName, frmMain.tsMain.Items[frmMain.tsMain.ActiveTabIndex].Caption, False); end; end; -procedure UpdateCI_Pawn; -procedure HideBracesAndStrings(var eStr: String); +procedure UpdateCI_Pawn(eLine: Integer); +var eCurrLine, eBackupLine: string; + i, k: integer; + eStr, eStr2: TStringList; + eVarName, eVarType, eVarValue: string; + eVarCount, eConstCount: Integer; + eFound: Boolean; begin - while Between(eStr, '{', '}') <> '' do begin - eBraceTexts.Add('{' + Between(eStr, '{', '}') + '}'); - eStr := StringReplace(eStr, '{' + Between(eStr, '{', '}') + '}', #1 + IntToStr(eBraceTexts.Count) + #1, []); - end; - while CountChars(eStr, '"') > 1 do begin - eBraceTexts.Add('"' + StringReplace(Between(eStr, '"', '"'), ':', #3, [rfReplaceAll]) + '"'); - eStr := StringReplace(eStr, '"' + Between(eStr, '"', '"') + '"', #2 + IntToStr(eBraceTexts.Count) + #2, []); - end; -end; + eBackupLine := frmMain.sciEditor.Lines[eLine]; + // Prevent parse errors + eBackupLine := StringReplace(eBackupLine, #1, '', [rfReplaceAll]); + eBackupLine := StringReplace(eBackupLine, #2, '', [rfReplaceAll]); + eBackupLine := StringReplace(eBackupLine, #3, '', [rfReplaceAll]); -function ShowBracesAndStrings(eStr: String): String; -var k: integer; -begin - while Between(eStr, #1, #1) <> '' do begin - k := StrToInt(Between(eStr, #1, #1)); - eStr := StringReplace(eStr, #1 + IntToStr(k) + #1, eBraceTexts[k -1], []); - end; - while Between(eStr, #2, #2) <> '' do begin - k := StrToInt(Between(eStr, #2, #2)); - eStr := StringReplace(eStr, #2 + IntToStr(k) + #2, eBraceTexts[k -1], []); - end; - Result := eStr; -end; - -var eCurrLine, eBackupLine: String; - i, k: integer; - eStr: TStringList; - eVars, eConsts: Integer; - eVarName, eVarType, eVarValue: String; -begin - eBackupLine := frmMain.sciEditor.Lines[frmMain.sciEditor.GetCurrentLineNumber]; eCurrLine := Trim(StringReplace(eBackupLine, #9, #32, [rfReplaceAll])); - eCurrLine := RemoveStringsAndComments(eCurrLine, False); - eAllIncluded := GetAllIncludeFiles; + eCurrLine := RemoveStringsAndComments(eCurrLine, False, True); eStr := TStringList.Create; eBraceTexts := TStringList.Create; - eVars := 0; - eConsts := 0; + frmMain.jviCode.BeginUpdate; frmMain.jviCode.Clear; + frmMain.jviCode.Root.SortKind := iskNone; FItems.Clear; + eVarCount := 0; + eConstCount := 0; + eCILine := eLine; - eFormatSettings := ''; { Constants and Variables } - if (IsAtStart('new', eCurrLine, False)) then begin // const or variable - Delete(eCurrLine, 1, 4); - - // done? okay, split all items if there are more than one; and if not, it's okay... - HideBracesAndStrings(eCurrLine); - eStr.Text := StringReplace(eCurrLine, ',', #13, [rfReplaceAll]); - - for i := 0 to eStr.Count - 1 do begin - eStr[i] := ShowBracesAndStrings(eStr[i]); - eVarType := ''; - eVarValue := ''; - - if (Trim(eStr[i]) <> '') then begin - eVarName := Trim(RemoveSemicolon(eStr[i])); - if Pos(':', eVarName) <> 0 then begin - eVarType := Trim(Copy(eVarName, 1, Pos(':', eVarName) -1)); - eVarName := Trim(Copy(eVarName, Pos(':', eVarName) +1, Length(eVarName))); - end; - - if Pos('=', eVarName) <> 0 then begin // constant - Inc(eConsts, 1); - eFormatSettings := eFormatSettings + '-Constant ' + IntToStr(eConsts) + '-'; - - eVarValue := Trim(Copy(eVarName, Pos('=', eVarName) +1, Length(eVarName))); - eVarValue := StringReplace(eVarValue, #3, ':', [rfReplaceAll]); - eVarName := Trim(Copy(eVarName, 1, Pos('=', eVarName) -1)); - - AddField(lName, 'Constant ' + IntToStr(eConsts), eVarName); - if eVarType <> '' then - AddField(lType, 'Constant ' + IntToStr(eConsts), eVarType); - if eVarValue <> '' then - AddField(lValue, 'Constant ' + IntToStr(eConsts), eVarValue); - end - else begin // variable - Inc(eVars, 1); - eFormatSettings := eFormatSettings + '-Variable ' + IntToStr(eVars) + '-'; - AddField(lName, 'Variable ' + IntToStr(eVars), eVarName); - if eVarType <> '' then - AddField(lType, 'Variable ' + IntToStr(eVars), eVarType); - end; - end; - end; - - if frmMain.jviCode.Root.Count = 1 then - frmMain.jviCode.Root.Items[0].DisplayName := Copy(frmMain.jviCode.Root.Items[0].DisplayName, 1, Length(frmMain.jviCode.Root.Items[0].DisplayName) -2); - end - { Conditions } - else if (IsAtStart('if', eCurrLine, False)) then begin - if (CountChars(eCurrLine, '(') = CountChars(eCurrLine, ')')) and (CountChars(eCurrLine, '(') <> 0) then begin - eCurrLine := Copy(eCurrLine, 1, GetMatchingBrace(eCurrLine) -1); - eCurrLine := Copy(eCurrLine, Pos('(', eCurrLine) +1, Length(eCurrLine)); - eFormatSettings := StringReplace(eBackupLine, '(' + eCurrLine + ')', #1#3#3#7, []); - HideBracesAndStrings(eCurrLine); - eStr.Text := StringReplace(eCurrLine, '||', #13, [rfReplaceAll]); - k := eStr.Count -1; // from 0 to k -> OR operators - eStr.Text := StringReplace(eStr.Text, '&&', #13, [rfReplaceAll]); - - for i := 0 to eStr.Count -1 do begin - eStr[i] := Trim(ShowBracesAndStrings(eStr[i])); - if (Pos('(', eStr[i]) = 1) and (Pos(')', eStr[i]) = Length(eStr[i])) then - eStr[i] := Copy(Copy(eStr[i], 2, Length(eStr[i])), 1, Length(eStr[i]) -1); - - if eStr.Count = 1 then - eCurrLine := 'If-Condition' - else - eCurrLine := 'If-Condition ' + IntToStr(frmMain.jviCode.Root.Count +1); - - if i <> eStr.Count -1 then begin - if i < k then - AddCombo('Operator', eCurrLine, '||', ['||', '&&']) - else - AddCombo('Operator', eCurrLine, '&&', ['||', '&&']); - end; - AddField('Condition', eCurrLine, eStr[i]); - end; - end + if (IsAtStart('new', eCurrLine, False)) or ((IsAtStart('stock', eCurrLine, False) and (CountChars(RemoveStringsAndComments(eCurrLine, True, True), '(') = 0) and (CountChars(RemoveStringsAndComments(eCurrLine, True, True), ')') = 0))) then begin + {--> Get var information } + eStock := IsAtStart('stock', eCurrLine, False); + if eStock then + eCurrLine := Trim(Copy(eCurrLine, 6, Length(eCurrLine))) else - AddField('', 'Invalid condition', ''); - end - { Defined } - else if (IsAtStart('#define', eCurrLine, False)) then begin - eCurrLine := Trim(Copy(eCurrLine, 8, Length(eCurrLine))); - HideBracesAndStrings(eCurrLine); - eCurrLine := StringReplace(eCurrLine, #9, #32, [rfReplaceAll]); - eCurrLine := ShowBracesAndStrings(eCurrLine); - AddField('Name', 'Defined', Copy(eCurrLine, 1, Pos(#32, eCurrLine) -1)); - eCurrLine := Trim(Copy(eCurrLine, Pos(#32, eCurrLine) +1, Length(eCurrLine))); - AddField('Value', 'Defined', eCurrLine); - end - { Included } - else if (IsAtStart('#include', eCurrLine, False)) then begin - eCurrLine := Trim(StringReplace(eCurrLine, #9, #32, [rfReplaceAll])); - if Between(eCurrLine, '<', '>') <> '' then begin - eCurrLine := Between(eCurrLine, '<', '>'); - eFormatSettings := StringReplace(eBackupLine, '<' + eCurrLine + '>', '<-Filename->', []); - end - else if Between(eCurrLine, '"', '"') <> '' then begin - eCurrLine := Between(eCurrLine, '"', '"'); - eFormatSettings := StringReplace(eBackupLine, '"' + eCurrLine + '"', '"-Filename-"', []); - end - else begin - eCurrLine := Copy(eCurrLine, 9, Length(eCurrLine)); - eFormatSettings := '#include -Filename-'; - end; - eCurrLine := Trim(eCurrLine); - AddCombo('File', 'Included', eCurrLine, eAllIncluded); - end - { Assignments } - else begin - if (Pos('=', eCurrLine) <> 0) then begin - eCurrLine := Trim(eCurrLine); - while Pos(eCurrLine[1], frmMain.sciEditor.WordChars + '[]') <> 0 do - Delete(eCurrLine, 1, 1); - eCurrLine := Trim(eCurrLine); - if Pos('=', eCurrLine) <= 2 then begin - while (Pos(Copy(eCurrLine, 1, 1), frmMain.sciEditor.WordChars + #32 + #9) = 0) and (Length(eCurrLine) <> 0) do begin - eFormatSettings := eFormatSettings + eCurrLine[1]; - Delete(eCurrLine, 1, 1); - end; - eCurrLine := RemoveSemicolon(Trim(eBackupLine)); - eCurrLine := StringReplace(eCurrLine, #9, #32, [rfReplaceAll]); - AddField('a', 'Assignment', Copy(eCurrLine, 1, Pos(eFormatSettings, eCurrLine) - Length(eFormatSettings))); - AddField('b', 'Assignment', Trim(Copy(eCurrLine, Pos(eFormatSettings, eCurrLine) + Length(eFormatSettings), Length(eCurrLine)))); - AddField('Operator', 'Assignment', eFormatSettings); + eCurrLine := Trim(Copy(eCurrLine, 4, Length(eCurrLine))); + + HideBracesAndStrings(eCurrLine, True); + eStr.Text := StringReplace(eCurrLine, ',', #13, [rfReplaceAll]); + eStr.Text := ShowBracesAndStrings(eStr.Text); + for i := 0 to eStr.Count - 1 do begin + if Pos('/*', eStr[i]) <> 0 then + eStr[i] := Trim(Copy(eStr[i], 1, Pos('/*', eStr[i]) - 2)); + + if Pos(':', eStr[i]) <> 0 then begin // Get type + eVarType := Trim(Copy(eStr[i], 1, Pos(':', eStr[i]) - 1)); + eStr[i] := Trim(Copy(eStr[i], Pos(':', eStr[i]) + 1, Length(eStr[i]))); end else - AddField('', 'No information available.', ''); + eVarType := ''; + + if Pos('=', eStr[i]) <> 0 then begin // Is constant? + eVarName := Trim(Copy(eStr[i], 1, Pos('=', eStr[i]) - 1)); + eVarValue := Trim(Copy(eStr[i], Pos('=', eStr[i]) + 1, Length(eStr[i]))); + + Inc(eConstCount, 1); + with CreateCategory('Constants') do begin + AddField('Constant ' + IntToStr(eConstCount), 'Constants', '').ReadOnly := True; ; + AddField('Name', 'Constant ' + IntToStr(eConstCount), eVarName); + AddField('Type', 'Constant ' + IntToStr(eConstCount), eVarType); + + AddFunc('Value', eVarValue, 'Constant ' + IntToStr(eConstCount)); + end; + end + else begin // or variable? + eVarName := Trim(eStr[i]); + eVarValue := ''; + + Inc(eVarCount, 1); + with CreateCategory('Variables') do begin + AddField('Variable ' + IntToStr(eVarCount), 'Variables', '').ReadOnly := True; ; + AddField('Name', 'Variable ' + IntToStr(eVarCount), eVarName); + AddField('Type', 'Variable ' + IntToStr(eVarCount), eVarType); + end; + end; + end; + {--> Analyze comments } + eCurrLine := Trim(StringReplace(eBackupLine, #9, #32, [rfReplaceAll])); + eCurrLine := RemoveStringsAndComments(eCurrLine, True, False); + CheckCIComment(eCurrLine); + + eBraceTexts.Free; + eStr.Free; + frmMain.jviCode.EndUpdate; + if eLine <> eCILine then + UpdateCI_Pawn(eLine) + else + eCILine := -1; + exit; + end; + { Conditions } + if (IsAtStart('if', eCurrLine)) or (IsAtStart('elseif', StringReplace(StringReplace(eCurrLine, #9, '', [rfReplaceAll]), #32, '', [rfReplaceAll]))) then begin + {--> Analyze condition } + eCurrLine := Between(eCurrLine, '(', ')', True); + if eCurrLine = '' then + AddField('', 'Invalid condition', '') + else begin + { Get condition(s) } + HideBracesAndStrings(eCurrLine, False); + eStr.Text := StringReplace(eCurrLine, '&&', #13 + #254, [rfReplaceAll]); + eStr.Text := StringReplace(eStr.Text, '||', #13 + #255, [rfReplaceAll]); + if eStr.Count > 1 then begin + for i := 1 to eStr.Count - 1 do begin + if Pos(#254, eStr[i]) = 1 then + eStr.Objects[i] := TObject(1) + else + eStr.Objects[i] := TObject(2); + eStr[i] := ShowBracesAndStrings(Copy(eStr[i], 2, Length(eStr[i]))); + end; + end; + CreateCategory('If-Condition'); + for i := 0 to eStr.Count - 1 do begin + eStr[i] := Trim(ShowBracesAndStrings(eStr[i])); + if Length(eStr[i]) >= 2 then begin + if (eStr[i] = '(') and (eStr[i][Length(eStr[i])] = ')') then + eStr[i] := Between(eStr[i], '(', ')', True); + AddField('Condition ' + IntToStr(i + 1), 'If-Condition', '').ReadOnly := True; + if i <> 0 then begin + if eStr.Objects[i] = TObject(1) then + AddCombo('Operator', 'If-Condition->Condition ' + IntToStr(i + 1), '&&', ['&&', '||']) + else + AddCombo('Operator', 'If-Condition->Condition ' + IntToStr(i + 1), '||', ['||', '&&']); + end; + AddField('Condition', 'If-Condition->Condition ' + IntToStr(i + 1), eStr[i]); + end; + end; + { Action } + eCurrLine := Trim(StringReplace(eBackupLine, #9, #32, [rfReplaceAll])); + eCurrLine := RemoveStringsAndComments(eCurrLine, False, True); + eCurrLine := Trim(Copy(eCurrLine, GetMatchingBrace(eCurrLine) + 1, Length(eCurrLine))); + if eCurrLine = '{' then + AddField('Action', 'If-Condition', 'New Code-Block').ReadOnly := True + else + AddFunc('Action', eCurrLine, 'If-Condition'); + end; + {--> Analyze comments } + eCurrLine := Trim(StringReplace(eBackupLine, #9, #32, [rfReplaceAll])); + eCurrLine := RemoveStringsAndComments(eCurrLine, True, False); + CheckCIComment(eCurrLine); + + eBraceTexts.Free; + eStr.Free; + frmMain.jviCode.EndUpdate; + if eLine <> eCILine then + UpdateCI_Pawn(eLine) + else + eCILine := -1; + exit; + end; + { Defined } + if IsAtStart('#define', eCurrLine, False) then begin + {--> Get definition } + Delete(eCurrLine, 1, 7); + if Pos(#32, eCurrLine) = 0 then + AddField('', 'Invalid Definition', '') + else begin + eCurrLine := Trim(eCurrLine); + eVarName := Copy(eCurrLine, 1, Pos(#32, eCurrLine) - 1); + eVarValue := RemoveStringsAndComments(Trim(Copy(eCurrLine, Length(eVarName) + 1, Length(eCurrLine))), False, True); + + CreateCategory('Definition'); + AddField('Name', 'Definition', eVarName); + AddField('Value', 'Definition', eVarValue); + end; + {--> Analyze comments } + eCurrLine := Trim(StringReplace(eBackupLine, #9, #32, [rfReplaceAll])); + eCurrLine := RemoveStringsAndComments(eCurrLine, True, False); + CheckCIComment(eCurrLine); + + eBraceTexts.Free; + eStr.Free; + frmMain.jviCode.EndUpdate; + if eLine <> eCILine then + UpdateCI_Pawn(eLine) + else + eCILine := -1; + exit; + end; + { Included } + if IsAtStart('#include', eCurrLine, False) then begin + {--> Get included file } + Delete(eCurrLine, 1, 8); + eCurrLine := Trim(eCurrLine); + CreateCategory('Included Header'); + if Between(eCurrLine, '<', '>') <> '' then + AddCombo('File', 'Included Header', Between(eCurrLine, '<', '>', True), GetAllIncludeFiles(eCurrLine)) + else if Between(eCurrLine, '"', '"') <> '' then + AddCombo('File', 'Included Header', Between(eCurrLine, '"', '"', True), GetAllIncludeFiles(eCurrLine)) + else + AddCombo('File', 'Included Header', eCurrLine, GetAllIncludeFiles(eCurrLine)); + {--> Analyze comments } + eCurrLine := Trim(StringReplace(eBackupLine, #9, #32, [rfReplaceAll])); + eCurrLine := RemoveStringsAndComments(eCurrLine, True, False); + CheckCIComment(eCurrLine); + + eBraceTexts.Free; + eStr.Free; + frmMain.jviCode.EndUpdate; + if eLine <> eCILine then + UpdateCI_Pawn(eLine) + else + eCILine := -1; + exit; + end; + { Return } + if Pos('return', LowerCase(Trim(eCurrLine))) = 1 then begin + {--> Get value } + eCurrLine := Trim(eCurrLine); + Delete(eCurrLine, 1, 7); + eCurrLine := Trim(eCurrLine); + CreateCategory('Return'); + AddCombo('Value', 'Return', Trim(eCurrLine), ['PLUGIN_HANDLED', 'PLUGIN_CONTINUE', 'PLUGIN_HANDLED_MAIN']); + {--> Analyze comments } + eCurrLine := Trim(StringReplace(eBackupLine, #9, #32, [rfReplaceAll])); + eCurrLine := RemoveStringsAndComments(eCurrLine, True, False); + CheckCIComment(eCurrLine); + + eBraceTexts.Free; + eStr.Free; + frmMain.jviCode.EndUpdate; + if eLine <> eCILine then + UpdateCI_Pawn(eLine) + else + eCILine := -1; + exit; + end; + { For-Loop } + if IsAtStart('for', eCurrLine) then begin + {--> Get For-Loop } + if (Between(eCurrLine, '(', ')') = '') or (CountChars(eCurrLine, ';') < 2) then + AddField('', 'Invalid For-Loop', '') + else begin + eCurrLine := Between(eCurrLine, '(', ')', True); + HideBracesAndStrings(eCurrLine, True); + eStr.Text := StringReplace(eCurrLine, ';', #13, [rfReplaceAll]); + if eStr.Count <> 3 then + AddField('Invalid For-Loop', '', '') + else begin + CreateCategory('For-Loop'); + eStr.Text := ShowBracesAndStrings(eStr.Text); + AddField('Reset', 'For-Loop', eStr[0]); + AddField('Condition', 'For-Loop', eStr[1]); + AddField('Increase', 'For-Loop', eStr[2]); + end; + + {--> Action } + eCurrLine := Trim(StringReplace(eBackupLine, #9, #32, [rfReplaceAll])); + eCurrLine := RemoveStringsAndComments(eCurrLine, False, True); + eCurrLine := Trim(Copy(eCurrLine, GetMatchingBrace(eCurrLine) + 1, Length(eCurrLine))); + if eCurrLine = '{' then + AddField('Action', 'For-Loop', 'New Code-Block').ReadOnly := True + else + AddFunc('Action', eCurrLine, 'If-Condition'); + {--> Analyze comments } + eCurrLine := Trim(StringReplace(eBackupLine, #9, #32, [rfReplaceAll])); + eCurrLine := RemoveStringsAndComments(eCurrLine, True, False); + CheckCIComment(eCurrLine); + end; + eBraceTexts.Free; + eStr.Free; + frmMain.jviCode.EndUpdate; + if eLine <> eCILine then + UpdateCI_Pawn(eLine) + else + eCILine := -1; + exit; + end; + { While-Loops } + if IsAtStart('while', eCurrLine) then begin + {--> Analyze condition } + eCurrLine := Between(eCurrLine, '(', ')', True); + if eCurrLine = '' then + AddField('', 'Invalid condition', '') + else begin + HideBracesAndStrings(eCurrLine, False); + eStr.Text := StringReplace(eCurrLine, '&&', #13 + #254, [rfReplaceAll]); + eStr.Text := StringReplace(eStr.Text, '||', #13 + #255, [rfReplaceAll]); + if eStr.Count > 1 then begin + for i := 1 to eStr.Count - 1 do begin + if Pos(#254, eStr[i]) = 1 then + eStr.Objects[i] := TObject(1) + else + eStr.Objects[i] := TObject(2); + eStr[i] := ShowBracesAndStrings(Copy(eStr[i], 2, Length(eStr[i]))); + end; + end; + CreateCategory('While-Loop'); + for i := 0 to eStr.Count - 1 do begin + eStr[i] := Trim(eStr[i]); + if Length(eStr[i]) >= 2 then begin + if (eStr[i] = '(') and (eStr[i][Length(eStr[i])] = ')') then + eStr[i] := Between(eStr[i], '(', ')', True); + AddField('Condition ' + IntToStr(i + 1), 'While-Loop', '').ReadOnly := True; + if i <> 0 then begin + if eStr.Objects[i] = TObject(1) then + AddCombo('Operator', 'While-Loop->Condition ' + IntToStr(i + 1), '&&', ['&&', '||']) + else + AddCombo('Operator', 'While-Loop->Condition ' + IntToStr(i + 1), '||', ['||', '&&']); + end; + AddField('Condition', 'While-Loop->Condition ' + IntToStr(i + 1), eStr[i]); + end; + end; + + {--> Analyze comments } + eCurrLine := Trim(StringReplace(eBackupLine, #9, #32, [rfReplaceAll])); + eCurrLine := RemoveStringsAndComments(eCurrLine, True, False); + CheckCIComment(eCurrLine); + end; + eBraceTexts.Free; + eStr.Free; + frmMain.jviCode.EndUpdate; + if eLine <> eCILine then + UpdateCI_Pawn(eLine) + else + eCILine := -1; + exit; + end; + + { Function header/call } + with GetNode('Methods') do begin + eFound := False; + for i := 0 to Item[0].Count - 1 do begin + if Integer(Item[0].Item[i].Data) = eLine then begin + eFound := True; + break; + end; + end; + if not eFound then begin + for i := 0 to Item[1].Count - 1 do begin + if Integer(Item[1].Item[i].Data) = eLine then begin + eFound := True; + break; + end; + end; + end; + if not eFound then begin + for i := 0 to Item[2].Count - 1 do begin + if Integer(Item[2].Item[i].Data) = eLine then begin + eFound := True; + break; + end; + end; + end; + end; + + if eFound then begin // Function + if Pos('(', eCurrLine) <> Pos(')', eCurrLine) then begin + CreateCategory('Function'); + eVarName := Trim(Copy(eCurrLine, 1, Pos('(', eCurrLine) - 1)); + if Pos(#32, eVarName) <> 0 then begin + eVarType := Copy(eVarName, 1, Pos(#32, eVarName) - 1); + eVarName := Copy(eVarName, Pos(#32, eVarName) + 1, Length(eVarName)); + end + else if Pos('@', eVarName) = 1 then begin + eVarType := '@'; + eVarName := Copy(eVarName, 2, Length(eVarName)); + end + else + eVarType := ''; + + AddField('Name', 'Function', Trim(eVarName)); + AddField('Type', 'Function', Trim(eVarType)); + + eCurrLine := Between(eCurrLine, '(', ')'); + HideBracesAndStrings(eCurrLine, True); + eStr.Text := StringReplace(eCurrLine, ',', #13, [rfReplaceAll]); + for i := 0 to eStr.Count - 1 do begin + if Pos(':', eStr[i]) <> 0 then begin + eVarType := Trim(Copy(eStr[i], 1, Pos(':', eStr[i]) - 1)); + eVarName := Trim(Copy(eStr[i], Pos(':', eStr[i]) + 1, Length(eStr[i]))); + end + else begin + eVarType := ''; + eVarName := Trim(eStr[i]); + end; + + eVarType := ShowBracesAndStrings(eVarType); + eVarName := ShowBracesAndStrings(eVarName); + AddField('Param ' + IntToStr(i + 1), 'Function', '').ReadOnly := True; + AddField('Name', 'Param ' + IntToStr(i + 1), eVarName); + AddField('Type', 'Param ' + IntToStr(i + 1), eVarType) + end; + {--> Action } + eCurrLine := Trim(StringReplace(eBackupLine, #9, #32, [rfReplaceAll])); + eCurrLine := RemoveStringsAndComments(eCurrLine, False, True); + eCurrLine := Trim(Copy(eCurrLine, GetMatchingBrace(eCurrLine) + 1, Length(eCurrLine))); + if eCurrLine = '{' then + AddField('Action', 'Function', 'New Code-Block').ReadOnly := True + else + AddFunc('Action', eCurrLine, 'Function'); + {--> Analyze comments } + eCurrLine := Trim(StringReplace(eBackupLine, #9, #32, [rfReplaceAll])); + eCurrLine := RemoveStringsAndComments(eCurrLine, True, False); + CheckCIComment(eCurrLine); end else - AddField('', 'No information available.', ''); + CreateCategory('Invalid Function'); + + eBraceTexts.Free; + eStr.Free; + frmMain.jviCode.EndUpdate; + if eLine <> eCILine then + UpdateCI_Pawn(eLine) + else + eCILine := -1; + exit; + end + else if (Pos('(', eCurrLine) <> Pos(')', eCurrLine)) and (Assignment(eBackupLine) = '') then begin // Function Call + eVarName := Trim(Copy(eCurrLine, 1, Pos('(', eCurrLine) - 1)); + eVarValue := ''; + with frmMain.sciCallTips.ApiStrings do begin + for i := 0 to Count - 1 do begin + if IsAtStart(eVarName, Strings[i]) then begin + eVarValue := Strings[i]; + break; + end + else + Application.ProcessMessages; + end; + end; + + eStr2 := TStringList.Create; + if eVarValue = '' then + CreateCategory('Invalid Function Call') + else begin + eVarValue := Between(eVarValue, '(', ')', True); + HideBracesAndStrings(eVarValue, True); + eStr.Text := StringReplace(eVarValue, ',', #13, [rfReplaceAll]); + + if Between(eCurrLine, '(', ')', True) = '' then + eCurrLine := Copy(eCurrLine, Pos('(', eCurrLine) + 1, Length(eCurrLine)) + else + eCurrLine := Between(eCurrLine, '(', ')', True); + HideBracesAndStrings(eCurrLine, True); + eStr2.Text := StringReplace(eCurrLine, ',', #13, [rfReplaceAll]); + + CreateCategory('Function Call'); + AddField('Function', 'Function Call', eVarName); + AddField('Params', 'Function Call', '').ReadOnly := True; + + if eStr.Count >= eStr2.Count then + k := eStr.Count + else + k := eStr2.Count; + + for i := 0 to k - 1 do begin + if (i < eStr2.Count) and (i < eStr.Count) then begin + eStr[i] := ShowBracesAndStrings(eStr[i]); + eStr2[i] := ShowBracesAndStrings(eStr2[i]); + AddField(Trim(eStr[i]), 'Params', Trim(eStr2[i])); + end + else if i < eStr.Count then begin + eStr[i] := ShowBracesAndStrings(eStr[i]); + AddField(Trim(eStr[i]), 'Params', ''); + end + else begin + eStr2[i] := ShowBracesAndStrings(eStr2[i]); + AddField('...', 'Params', Trim(eStr2[i])); + end; + end; + {--> Language Strings } + eCurrLine := Trim(StringReplace(eBackupLine, #9, #32, [rfReplaceAll])); + eCurrLine := RemoveStringsAndComments(eCurrLine, False, True); + if Pos('%L', eCurrLine) <> 0 then begin + Delete(eCurrLine, 1, Pos('%L', eCurrLine) + 1); + Delete(eCurrLine, 1, Pos('"', eCurrLine) + 1); + Delete(eCurrLine, 1, Pos(',', eCurrLine) + 1); + eVarName := Between(eCurrLine, '"', '"'); + eVarValue := ''; + eStr.Clear; + eStr2.Clear; + for i := 0 to frmMain.sciEditor.Lines.Count - 1 do begin + if IsAtStart('register_dictionary', frmMain.sciEditor.Lines[i]) then begin + eVarValue := Between(frmMain.sciEditor.Lines[i], '"', '"'); + if (eVarValue <> '') and (FileExists(frmSettings.txtLangDir.Text + eVarValue)) then begin + eStr2.LoadFromFile(frmSettings.txtLangDir.Text + eVarValue); + eStr.AddStrings(eStr2); + end; + end; + end; + + if eVarValue = '' then + CreateCategory('No dictionary registered') + else if not FileExists(frmSettings.txtLangDir.Text + eVarValue) then + CreateCategory('Invalid dictionary') + else begin + with CreateCategory('Language Strings') do begin + SortKind := iskNone; + Expanded := False; + + eVarType := ''; + eVarCount := 0; + for i := 0 to eStr.Count - 1 do begin + if Pos('[', eStr[i]) = 1 then + eVarType := Between(eStr[i], '[', ']') + else if (eVarType <> '') and (Pos(eVarName, eStr[i]) = 1) then begin + Inc(eVarCount, 1); + AddField('String ' + IntToStr(eVarCount), 'Language Strings', '').ReadOnly := True; + AddField('Language', 'String ' + IntToStr(eVarCount), eVarType).ReadOnly := True; + AddField('Value', 'String ' + IntToStr(eVarCount), Trim(Copy(eStr[i], Pos('=', eStr[i]) + 1, Length(eStr[i])))).ReadOnly := True; + end; + end; + + if Count = 0 then + DisplayName := 'No matching string found'; + end; + end; + end; + {--> Analyze comments } + eCurrLine := Trim(StringReplace(eBackupLine, #9, #32, [rfReplaceAll])); + eCurrLine := RemoveStringsAndComments(eCurrLine, True, False); + CheckCIComment(eCurrLine); + end; + + eBraceTexts.Free; + eStr.Free; + eStr2.Free; + frmMain.jviCode.EndUpdate; + if eLine <> eCILine then + UpdateCI_Pawn(eLine) + else + eCILine := -1; + exit; + end + { Assignment } + else if Assignment(eBackupLine) <> '' then begin + {--> Get values } + eVarName := Copy(eBackupLine, 1, Pos(Assignment(eBackupLine), eBackupLine) - 1); + eVarType := Copy(eBackupLine, Pos(Assignment(eBackupLine), eBackupLine) + Length(Assignment(eBackupLine)), Length(eBackupLine)); + if (Trim(eVarName) = '') or (Trim(eVarType) = '') then + CreateCategory('Invalid assignment') + else begin + CreateCategory('Assignment'); + AddField('a', 'Assignment', Trim(eVarName)); + AddFunc('b', eVarType, 'Assignment'); + AddCombo('Operator', 'Assignment', Assignment(eBackupLine), ['=', '+=', '-=', '*=', '/=', '%=', '>>=', '>>>=', '<<=', '&=', '|=']); + {--> Analyze comments } + eCurrLine := Trim(StringReplace(eBackupLine, #9, #32, [rfReplaceAll])); + eCurrLine := RemoveStringsAndComments(eCurrLine, True, False); + CheckCIComment(eCurrLine); + end; + eBraceTexts.Free; + eStr.Free; + frmMain.jviCode.EndUpdate; + if eLine <> eCILine then + UpdateCI_Pawn(eLine) + else + eCILine := -1; + exit; end; + + CreateCategory('No information available'); eBraceTexts.Free; - SetLength(eAllIncluded, 0); eStr.Free; + frmMain.jviCode.EndUpdate; + + if eLine <> eCILine then + UpdateCI_Pawn(eLine) + else + eCILine := -1; end; { TSTLWrapper } constructor TSTLWrapper.Create(const ASTL: TSelectionTextList; - const AValue: String); + const AValue: string); begin STL := ASTL; Value := AValue; @@ -422,12 +966,209 @@ begin inherited; end; +procedure RebuildLine; +function GetFunc(eItem: TJvCustomInspectorItem): String; +var i: integer; +begin + if eItem.Count = 0 then + Result := eItem.DisplayValue + else begin + Result := eItem.Items[0].DisplayValue + '('; + for i := 1 to eItem.Count -1 do begin + if i = 1 then + Result := Result + eItem.Items[i].DisplayValue + else + Result := Result + ', ' + eItem.Items[i].DisplayValue; + end; + Result := Result + ')'; + end; +end; + +function CheckItem(eItem: TJvCustomInspectorItem; eVal: Integer): Boolean; +var i: integer; +begin + Result := False; + for i := eVal to eItem.Count -1 do begin + if eItem.Items[i].DisplayValue <> '' then begin + Result := True; + exit; + end; + end; +end; + +var i, k, l, m: integer; + eLine: string; + eVarName, eVarType, eVarValue: string; +begin + eLine := GetIndents(eCILine); + + eBraceTexts := TStringList.Create; + with frmMain.jviCode.Root do begin + for i := 0 to Count - 1 do begin + { Variables and consts } + if (Items[i].DisplayName = 'Variables') or (Items[i].DisplayName = 'Constants') then begin + + if Trim(eLine) = '' then begin + if eStock then + eLine := eLine + 'stock ' + else + eLine := eLine + 'new '; + end; + + for k := 0 to Items[i].Count - 1 do begin + eVarName := ''; + eVarType := ''; + eVarValue := ''; + + for l := 0 to Items[i].Items[k].Count - 1 do begin + if Items[i].Items[k].Items[l].DisplayName = 'Name' then + eVarName := Items[i].Items[k].Items[l].DisplayValue + else if Items[i].Items[k].Items[l].DisplayName = 'Type' then + eVarType := Items[i].Items[k].Items[l].DisplayValue + else if Items[i].Items[k].Items[l].DisplayName = 'Value' then begin + if Items[i].Items[k].Items[l].ReadOnly = True then begin // Function + for m := 0 to Items[i].Items[k].Items[l].Count - 1 do begin + if Items[i].Items[k].Items[l].Items[m].DisplayName = 'Function' then + eVarValue := Items[i].Items[k].Items[l].Items[m].DisplayValue + '(' + else if m = Items[i].Items[k].Items[l].Count - 1 then + eVarValue := eVarValue + Items[i].Items[k].Items[l].Items[m].DisplayValue + else + eVarValue := eVarValue + Items[i].Items[k].Items[l].Items[m].DisplayValue + ', '; + end; + if Pos('(', eVarValue) <> 0 then + eVarValue := eVarValue + ')'; + end + else // Other value + eVarValue := Items[i].Items[k].Items[l].DisplayValue; + end; + end; + + if Trim(eLine) <> 'new' then + eLine := eLine + ', '; + + if eVarType <> '' then + eLine := eLine + eVarType + ':'; + eLine := eLine + eVarName; + if eVarValue <> '' then + eLine := eLine + ' = ' + eVarValue; + end; + end; + { Comments } + if (Items[i].DisplayName = 'Comment') then begin + if Items[i].Items[0].DisplayName = 'Line Comment' then + eLine := eLine + ' // ' + Items[i].Items[0].DisplayValue + else begin + eVarName := Copy(frmMain.sciEditor.Lines[eCILine], Pos('/*', frmMain.sciEditor.Lines[eCILine]) + 1, Length(frmMain.sciEditor.Lines[eCILine])); + if Pos('*/', eVarName) = 0 then + eLine := eLine + ' /* ' + Items[i].Items[0].DisplayValue + else + eLine := eLine + ' /* ' + Items[i].Items[0].DisplayValue + ' */'; + end; + end; + { Functions } + if Items[i].DisplayName = 'Function' then begin + if Items[i].Items[1].DisplayValue <> '' then + eLine := eLine + Items[i].Items[1].DisplayValue + #32; + eLine := eLine + Items[i].Items[0].DisplayValue + '('; + for k := 2 to Items[i].Count - 2 do begin + if Items[i].Items[k].Items[1].DisplayValue <> '' then + eLine := eLine + Items[i].Items[k].Items[1].DisplayValue + ':'; + if k = 2 then + eLine := eLine + Items[i].Items[k].Items[0].DisplayValue + else + eLine := eLine + ', ' + Items[i].Items[k].Items[0].DisplayValue; + end; + eLine := eLine + ')'; + if Items[i].Items[Items[i].Count - 1].ReadOnly then + eLine := eLine + ' {' + else + eLine := eLine + GetFunc(Items[i].Items[Items[i].Count - 1]); + end; + { Function Call } + if Items[i].DisplayName = 'Function Call' then begin + eLine := eLine + Items[i].Items[0].DisplayValue + '('; + for k := 0 to Items[i].Items[1].Count - 1 do begin + if k = 0 then + eLine := eLine + Items[i].Items[1].Items[k].DisplayValue + else if CheckItem(Items[i].Items[1], k) then + eLine := eLine + ', ' + Items[i].Items[1].Items[k].DisplayValue; + end; + eLine := eLine + ')'; + end; + { Condition } + if Items[i].DisplayName = 'If-Condition' then begin + eLine := eLine + 'if ('; + for k := 0 to Items[i].Count - 2 do begin + if k = 0 then + eLine := eLine + Items[i].Items[k].Items[0].DisplayValue + else + eLine := eLine + #32 + Items[i].Items[k].Items[0].DisplayValue + #32 + Items[i].Items[k].Items[1].DisplayValue; + end; + + if Items[i].Items[Items[i].Count - 1].ReadOnly then + eLine := eLine + ') {' + else + eLine := eLine + ') ' + GetFunc(Items[i].Items[Items[i].Count - 1]); + end; + { Defined } + if Items[i].DisplayName = 'Definition' then + eLine := eLine + '#define ' + Items[i].Items[0].DisplayValue + #32 + Items[i].Items[1].DisplayValue; + { Included Header } + if Items[i].DisplayName = 'Included Header' then begin + if Pos('<', frmMain.sciEditor.Lines[eCILine]) <> Pos('>', frmMain.sciEditor.Lines[eCILine]) then + eLine := eLine + '#include <' + Items[i].Items[0].DisplayValue + '>' + else + eLine := eLine + '#include "' + Items[i].Items[0].DisplayValue + '"'; + end; + { Return } + if Items[i].DisplayName = 'Return' then + eLine := eLine + 'return ' + Items[i].Items[0].DisplayValue; + { For-Loop } + if Items[i].DisplayName = 'For-Loop' then begin + eLine := eLine + 'for(' + Items[i].Items[0].DisplayValue + '; ' + Items[i].Items[1].DisplayValue + '; ' + Items[i].Items[2].DisplayValue; + if Items[i].Items[3].ReadOnly then + eLine := eLine + ') {' + else + eLine := eLine + ') ' + GetFunc(Items[i].Items[3]); + end; + { While-Loop } + if Items[i].DisplayName = 'While-Loop' then begin + eLine := eLine + 'while ('; + for k := 0 to Items[i].Count - 2 do begin + if k = 0 then + eLine := eLine + Items[i].Items[k].Items[0].DisplayValue + else + eLine := eLine + #32 + Items[i].Items[k].Items[0].DisplayValue + #32 + Items[i].Items[k].Items[1].DisplayValue; + end; + + if Items[i].Items[Items[i].Count - 1].ReadOnly then + eLine := eLine + ') {' + else + eLine := eLine + ') ' + Items[i].Items[Items[i].Count - 1].DisplayValue; + end; + { Assignment } + if Items[i].DisplayName = 'Assignment' then begin + eLine := eLine + Items[i].Items[0].DisplayValue; + eLine := eLine + #32 + Items[i].Items[2].DisplayValue + #32; + eLine := eLine + GetFunc(Items[i].Items[1]); + end; + end; + end; + eBraceTexts.Free; + + if Trim(eLine) <> '' then + frmMain.sciEditor.Lines[eCILine] := eLine; +// UpdateCI(eCILine); +end; + initialization -FItems := TObjectList.Create; + FItems := TObjectList.Create; + eCILine := -1; finalization -FItems.Free; + FItems.Free; end. + diff --git a/editor/studio/UnitCodeUtils.pas b/editor/studio/UnitCodeUtils.pas index f341bd7e..f67aa00b 100755 --- a/editor/studio/UnitCodeUtils.pas +++ b/editor/studio/UnitCodeUtils.pas @@ -5,6 +5,7 @@ interface uses SysUtils, Classes, Forms, Controls, Windows, ScintillaLanguageManager, RichEdit, ComCtrls, JvInspector; +function PosBack(eSubStr, eStr: String): Integer; function IsAtStart(eSubStr, eStr: String; AllowFunctions: Boolean = True): Boolean; function GetIndents(Line: Integer = -1): String; function GetStyleAt(ePos: Integer): TSciStyle; @@ -12,10 +13,10 @@ function LineFromPos(ePos: Integer): Integer; function RemoveSemicolon(eStr: String): String; procedure IndentCode; procedure UnindentCode; -function Between(eText, eFirst, eSecond: String): String; +function Between(eText, eFirst, eSecond: String; eSecondBack: Boolean = False): String; procedure Delay(eTime: Integer); function CountChars(eIn: String; eChar: Char): Integer; -function RemoveStringsAndComments(eLine: String; eRemoveStrings: Boolean): String; +function RemoveStringsAndComments(eLine: String; eRemoveStrings: Boolean; eRemoveComments: Boolean): String; function GetMatchingBrace(eString: String): Integer; function GetColoredLine(eLine: Integer): String; @@ -26,6 +27,15 @@ implementation uses UnitfrmMain, UnitMainTools, UnitLanguages, UnitfrmIRCPaster; +function PosBack(eSubStr, eStr: String): Integer; +begin + Result := 0; + if Pos(eSubStr, eStr) <> 0 then begin + while Pos(eSubStr, Copy(eStr, Result +1, Length(eStr))) <> 0 do + Inc(Result, 1); + end; +end; + function IsAtStart(eSubStr, eStr: String; AllowFunctions: Boolean = True): Boolean; begin eStr := LowerCase(Trim(StringReplace(eStr, #9, #32, [rfReplaceAll]))); @@ -70,14 +80,12 @@ begin else if eBits = 7 then eStyleNo := eStyleNo and $7f //Strip away the indicators (1 bit) else if eBits = 6 then - eStyleNo := eStyleNo and $3f; //Strip away the indicators (2 bits) + eStyleNo := eStyleNo and $3f; //Strip away the indicators (2 bits) - if eStyleNo <> 32 then begin - with frmMain.sciEditor.LanguageManager.LanguageList.Find(ActiveDoc.Highlighter).Styles do begin - for i := 0 to Count -1 do begin - if TSciStyle(Items[i]).StyleNumber = eStyleNo then - Result := TSciStyle(Items[i]); - end; + with frmMain.sciEditor.LanguageManager.LanguageList.Find(ActiveDoc.Highlighter).Styles do begin + for i := 0 to Count -1 do begin + if TSciStyle(Items[i]).StyleNumber = eStyleNo then + Result := TSciStyle(Items[i]); end; end; end; @@ -113,14 +121,14 @@ end; procedure IndentCode; var eStr: TStringList; i, k: integer; - eIdent, eTempIdent: Integer; + eIndent, eTempIndent: Integer; eString: String; begin Screen.Cursor := crHourGlass; frmMain.sciEditor.Enabled := False; eStr := TStringList.Create; - eIdent := 0; - eTempIdent := 0; + eIndent := 0; + eTempIndent := 0; Cancel := False; ShowProgress(False); @@ -134,18 +142,18 @@ begin // Remove strings and comments virtually because they could include brackets frmMain.pbLoading.Position := i; SetProgressStatus('Indenting Code...'); - eStr[i] := RemoveStringsAndComments(eStr[i], True); + eStr[i] := RemoveStringsAndComments(eStr[i], True, True); end; for i := 0 to eStr.Count -1 do begin if CountChars(eStr[i], '{') <> CountChars(eStr[i], '}') then - eIdent := eIdent - CountChars(eStr[i], '}'); + eIndent := eIndent - CountChars(eStr[i], '}'); frmMain.sciEditor.Lines[i] := TrimLeft(frmMain.sciEditor.Lines[i]); - for k := 1 to eIdent + eTempIdent do + for k := 1 to eIndent + eTempIndent do frmMain.sciEditor.Lines[i] := ' ' + frmMain.sciEditor.Lines[i]; - if eTempIdent <> 0 then - eTempIdent := eTempIdent -1; + if eTempIndent <> 0 then + eTempIndent := eTempIndent -1; if (IsAtStart('if', eStr[i], True)) and (Pos('{', eStr[i]) = 0) and (Length(eStr[i]) > 3) then begin eString := eStr[i]; @@ -153,7 +161,7 @@ begin if (eString[1] <> Trim(eString)[1]) or (eString[1] = '(') then begin eString := Trim(eString); if GetMatchingBrace(eString) = Length(eString) then - eTempIdent := eTempIdent +1; + eTempIndent := eTempIndent +1; end; end else if (IsAtStart('for', eStr[i], True)) and (Pos('{', eStr[i]) = 0) and (Length(eStr[i]) > 4) then begin @@ -162,16 +170,16 @@ begin if (eString[1] <> Trim(eString)[1]) or (eString[1] = '(') then begin eString := Trim(eString); if GetMatchingBrace(eString) = Length(eString) then - eTempIdent := eTempIdent +1; + eTempIndent := eTempIndent +1; end; end - else if (IsAtStart('else', eStr[i], False)) and (Pos('{', eStr[i]) = 0) and (Length(eStr[i]) > 5) then begin + else if (IsAtStart('else', eStr[i], False)) and (Pos('{', eStr[i]) = 0) then begin eString := eStr[i]; Delete(eString, 1, 4); if eString[1] <> Trim(eString)[1] then begin eString := Trim(eString); if GetMatchingBrace(eString) = Length(eString) then - eTempIdent := eTempIdent +1; + eTempIndent := eTempIndent +1; end; end else if (Pos('{', eStr[i]) = 0) and (Length(eStr[i]) > 6) then begin @@ -181,7 +189,7 @@ begin if (eString[1] <> Trim(eString)[1]) or (eString[1] = '(') then begin eString := Trim(eString); if GetMatchingBrace(eString) = Length(eString) then - eTempIdent := eTempIdent +1; + eTempIndent := eTempIndent +1; end; end; end; @@ -193,7 +201,7 @@ begin if eString[1] <> Trim(eString)[1] then begin eString := Trim(eString); if GetMatchingBrace(eString) = Length(eString) then - eTempIdent := eTempIdent +1; + eTempIndent := eTempIndent +1; end; end; end @@ -203,12 +211,12 @@ begin if eString[1] <> Trim(eString)[1] then begin eString := Trim(eString); if GetMatchingBrace(eString) = Length(eString) then - eTempIdent := eTempIdent +1; + eTempIndent := eTempIndent +1; end; end; if CountChars(eStr[i], '{') <> CountChars(eStr[i], '}') then - eIdent := eIdent + CountChars(eStr[i], '{'); + eIndent := eIndent + CountChars(eStr[i], '{'); frmMain.pbLoading.Position := frmMain.sciEditor.Lines.Count + i -1; SetProgressStatus('Indenting Code...'); @@ -249,18 +257,20 @@ begin Screen.Cursor := crDefault; end; -function RemoveStringsAndComments(eLine: String; eRemoveStrings: Boolean): String; +function RemoveStringsAndComments(eLine: String; eRemoveStrings: Boolean; eRemoveComments: Boolean): String; begin // Remove comments - if (Pos(GetCurrLang.CommentBoxStart, eLine) = 1) or (Pos(GetCurrLang.CommentBoxMiddle, eLine) = 1) or (Pos(GetCurrLang.CommentBoxEnd, eLine) = 1) or (Pos(GetCurrLang.CommentBlock, eLine) = 1) then - eLine := ''; - if Pos(GetCurrLang.CommentBlock, eLine) <> 0 then - eLine := Copy(eLine, 1, Pos('//', eLine) -2); - if (Pos(GetCurrLang.CommentStreamStart, eLine) < Pos(GetCurrLang.CommentStreamEnd, eLine)) and (Pos(GetCurrLang.CommentStreamStart, eLine) <> 0) then - eLine := StringReplace(eLine, GetCurrLang.CommentStreamStart + Between(eLine, GetCurrLang.CommentStreamStart, GetCurrLang.CommentStreamEnd) + GetCurrLang.CommentStreamEnd, '', [rfReplaceAll]); // maybe not the best method, but simple and quite easy + if eRemoveComments then begin + if (Pos(GetCurrLang.CommentBoxStart, eLine) = 1) or (Pos(GetCurrLang.CommentBoxMiddle, eLine) = 1) or (Pos(GetCurrLang.CommentBoxEnd, eLine) = 1) or (Pos(GetCurrLang.CommentBlock, eLine) = 1) then + eLine := ''; + if Pos(GetCurrLang.CommentBlock, eLine) <> 0 then + eLine := Copy(eLine, 1, Pos('//', eLine) -2); + if (Pos(GetCurrLang.CommentStreamStart, eLine) < Pos(GetCurrLang.CommentStreamEnd, eLine)) and (Pos(GetCurrLang.CommentStreamStart, eLine) <> 0) then + eLine := StringReplace(eLine, GetCurrLang.CommentStreamStart + Between(eLine, GetCurrLang.CommentStreamStart, GetCurrLang.CommentStreamEnd) + GetCurrLang.CommentStreamEnd, '', [rfReplaceAll]); // maybe not the best method, but simple and quite easy + end; // Remove quotes if eRemoveStrings then begin - while CountChars(eLine, '"') > 1 do + while Between(eLine, '"', '"') <> '' do eLine := StringReplace(eLine, '"' + Between(eLine, '"', '"') + '"', '', [rfReplaceAll]); end; @@ -290,17 +300,22 @@ begin end; end; -function Between(eText, eFirst, eSecond: String): String; +function Between(eText, eFirst, eSecond: String; eSecondBack: Boolean = False): String; var eTemp: String; begin - if (Pos(eFirst, eText) = 0) or (Pos(eSecond, eText) = 0) then - Result := '' - else begin - eTemp := eText; - Delete(eTemp, 1, Pos(eFirst, eText) + Length(eFirst) - 1); + Result := ''; + + if Pos(eFirst, eText) = PosBack(eSecond, eText) then exit; + if Pos(eFirst, eText) = 0 then exit; + if PosBack(eSecond, eText) < Pos(eFirst, eText) then exit; + + eTemp := eText; + Delete(eTemp, 1, Pos(eFirst, eText) + Length(eFirst) - 1); + if eSecondBack then + Delete(eTemp, PosBack(eSecond, eTemp), Length(eTemp)) + else Delete(eTemp, Pos(eSecond, eTemp), Length(eTemp)); - Result := eTemp; - end; + Result := eTemp; end; function GetMatchingBrace(eString: String): Integer; diff --git a/editor/studio/UnitCompile.pas b/editor/studio/UnitCompile.pas index 39ceb842..bc1f803e 100755 --- a/editor/studio/UnitCompile.pas +++ b/editor/studio/UnitCompile.pas @@ -81,7 +81,12 @@ begin if Pos(LowerCase(FileName), LowerCase(eLineStr)) = 1 then begin Delete(eLineStr, 1, Length(FileName)); if IsNumeric(Between(eLineStr, '(', ')')) then - eLine := StrToInt(Between(eLineStr, '(', ')')); + eLine := StrToInt(Between(eLineStr, '(', ')')) + else begin + eTemp := Between(eLineStr, '(', ')'); + eTemp := Copy(eTemp, 1, Pos(#32, eTemp) -1); + eLine := StrToInt(eTemp) + end; eTemp := Between(eLineStr, ':', ':'); diff --git a/editor/studio/UnitLanguages.pas b/editor/studio/UnitLanguages.pas index 052a760c..fa6c1e58 100755 --- a/editor/studio/UnitLanguages.pas +++ b/editor/studio/UnitLanguages.pas @@ -80,6 +80,9 @@ var lInvalidFile: String; lNoCPP: String; lInvalidChannel: String; lResetShortcuts: String; + lSelectLanguageDir: String; + lFailedCreateBak: String; + lAskRestore: String; procedure ResetToEnglish; @@ -163,6 +166,9 @@ begin lNoCPP := 'Sorry, the C++ IDE is not enabled.'; lInvalidChannel := 'Invalid channel.'; lResetShortcuts := 'Warning: The shortcut reset would immediately take affect. Reset anyway?'; + lSelectLanguageDir := 'Please select the directory of all dictionary files (default "%datadir%/lang"):'; + lFailedCreateBak := 'Error creating file backup.'; + lAskRestore := 'Do you want to restore the old file backup?'; end; end. diff --git a/editor/studio/UnitMainTools.pas b/editor/studio/UnitMainTools.pas index cb4dd48c..9a58b784 100755 --- a/editor/studio/UnitMainTools.pas +++ b/editor/studio/UnitMainTools.pas @@ -65,7 +65,7 @@ function GetCIItemByValue(eValue: String; eParent: TJvCustomInspectorItem = nil) function FindSettingsNode(eText: String; eParent: TTreeNode = nil): TTreeNode; procedure LoadPlugins; -function GetAllIncludeFiles: TStringArray; +function GetAllIncludeFiles(eMask: String): TStringArray; function GetCurrLang(FileName: String = ''): TSciLangItem; procedure FillCodeExplorer(Lang: String); function IEInstalled: Boolean; @@ -289,23 +289,36 @@ begin ePConfig.Destroy; end; -function GetAllIncludeFiles: TStringArray; +function GetAllIncludeFiles(eMask: String): TStringArray; var eSearchRec: TSearchRec; eStr: TStringList; i: integer; begin + if Between(eMask, '<', '>') <> '' then + eMask := Between(eMask, '<', '>', True) + else if Between(eMask, '"', '"') <> '' then + eMask := Between(eMask, '"', '"', True); + eStr := TStringList.Create; if GetAMXXDir(False) <> '' then begin if FindFirst(GetAMXXDir(False) + 'scripting\include\*.inc', faAnyFile, eSearchRec) = 0 then begin repeat - if (eSearchRec.Name[1] <> '.') and (eSearchRec.Attr and faDirectory <> faDirectory) then - eStr.Add(eSearchRec.Name); + if (eSearchRec.Name[1] <> '.') and (eSearchRec.Attr and faDirectory <> faDirectory) then begin + if ExtractFileExt(eMask) <> '' then + eStr.Add(eSearchRec.Name) + else + eStr.Add(ChangeFileExt(eSearchRec.Name, '')); + end; until (FindNext(eSearchRec) <> 0); end; if FindFirst(GetAMXXDir(False) + 'scripting\*.inc', faAnyFile, eSearchRec) = 0 then begin repeat - if (eSearchRec.Name[1] <> '.') and (eSearchRec.Attr and faDirectory <> faDirectory) then - eStr.Add(eSearchRec.Name); + if (eSearchRec.Name[1] <> '.') and (eSearchRec.Attr and faDirectory <> faDirectory) then begin + if ExtractFileExt(eMask) <> '' then + eStr.Add(eSearchRec.Name) + else + eStr.Add(ChangeFileExt(eSearchRec.Name, '')); + end; until (FindNext(eSearchRec) <> 0); end; end; @@ -313,8 +326,12 @@ begin if (not ActiveDoc.Untitled) then begin if FindFirst(GetAMXXDir(False) + 'scripting\include\*.inc', faAnyFile, eSearchRec) = 0 then begin repeat - if (eSearchRec.Name[1] <> '.') and (eSearchRec.Attr and faDirectory <> faDirectory) then - eStr.Add(eSearchRec.Name); + if (eSearchRec.Name[1] <> '.') and (eSearchRec.Attr and faDirectory <> faDirectory) then begin + if ExtractFileExt(eMask) <> '' then + eStr.Add(eSearchRec.Name) + else + eStr.Add(ChangeFileExt(eSearchRec.Name, '')); + end; until (FindNext(eSearchRec) <> 0); end; end; @@ -608,7 +625,9 @@ begin frmSettings.chkAutoCloseBraces.Checked := frmMain.sciEditor.AutoCloseBraces; frmSettings.chkAutoCloseQuotes.Checked := frmMain.sciEditor.AutoCloseQuotes; frmSettings.chkWordWrap.Checked := frmMain.sciEditor.WordWrap = sciWrap; - frmSettings.chkAutoIndent.Checked := eConfig.ReadBool('Editor', 'Auto-Indent', True); + frmSettings.chkMakeBaks.Checked := eConfig.ReadBool('Editor', 'MakeBaks', True); + frmSettings.chkDontLoadFilesTwice.Checked := eConfig.ReadBool('Editor', 'DontLoadFilesTwice', True); + frmSettings.chkAutoIndent.Checked := eConfig.ReadBool('Editor', 'Auto-Indent', True); frmAutoIndent.chkIndentOpeningBrace.Checked := eConfig.ReadBool('Editor', 'IndentOpeningBrace', True); frmAutoIndent.chkUnindentPressingClosingBrace.Checked := eConfig.ReadBool('Editor', 'UnindentClosingBrace', True); frmAutoIndent.chkUnindentLine.Checked := eConfig.ReadBool('Editor', 'UnindentEmptyLine', False); @@ -637,6 +656,10 @@ begin frmMain.sciEditor.AutoCloseQuotes := frmSettings.chkAutoCloseQuotes.Checked; frmMain.sciEditor.BraceHilite := frmSettings.chkHighlightBraces.Checked; frmMain.sciEditor.ClearUndoAfterSave := frmSettings.chkClearUndoAfterSave.Checked; + frmSettings.chkDisableAC.Checked := eConfig.ReadBool('Editor', 'Disable_AC', False); + frmSettings.chkDisableCT.Checked := eConfig.ReadBool('Editor', 'Disable_CT', False); + frmMain.sciAutoComplete.Disabled := frmSettings.chkDisableAC.Checked; + frmMain.sciCallTips.Disabled := frmSettings.chkDisableCT.Checked; { Shortcuts } frmSettings.lvShortcuts.Items.BeginUpdate; try @@ -711,6 +734,7 @@ begin eCPUSpeed := frmSettings.sldSpeed.Value else eCPUSpeed := 1; // otherwise the program would hang up + frmSettings.txtLangDir.Text := IncludeTrailingPathDelimiter(eConfig.ReadString('Misc', 'LangDir', '')); frmSettings.chkShowStatusbar.Checked := eConfig.ReadBool('Misc', 'ShowStatusbar', True); frmMain.sbStatus.Visible := frmSettings.chkShowStatusbar.Checked; end; @@ -811,6 +835,18 @@ begin Cancel := False; ShowProgress(True); + if (FileExists(FFileName)) and (frmSettings.chkMakeBaks.Checked) then begin + try + CopyFile(PChar(FFileName), PChar(FFileName + '.bak'), False); + SetFileAttributes(PChar(FFileName + '.bak'), faHidden); + if ActiveDoc = Self then + frmMain.mnuRestoreBackup.Enabled := True; + except + MessageBox(Application.Handle, PChar(lFailedCreateBak), PChar(Application.Title), MB_ICONERROR); + frmMain.mnuRestoreBackup.Enabled := False; + end; + end; + try AssignFile(F, FFilename); Rewrite(F); @@ -958,6 +994,7 @@ begin frmMain.sciEditor.SelLength := Document.SelLength; frmMain.sciEditor.LineScroll(0, (0 - frmMain.sciEditor.GetFirstVisibleLine) + Document.TopLine); end; + frmMain.mnuRestoreBackup.Enabled := (FileExists(Document.FileName + '.bak')) and (not Document.Untitled); Screen.Cursor := crDefault; Plugin_DocChange(Document.Index, Document.FileName, Document.Highlighter, RestoreCaret, False); end; @@ -1069,6 +1106,16 @@ begin exit; end; + if frmSettings.chkDontLoadFilesTwice.Checked then begin + for i := 0 to Count -1 do begin + if AnsiSameText(TDocument(Items[i]).FileName, AFilename) then begin + Result := i; + Activate(i, True); + exit; + end; + end; + end; + if Assigned(ActiveDoc) then begin ActiveDoc.Code := frmMain.sciEditor.Lines.Text; // saving is fast, but loading is usually slow because of code-folding... ActiveDoc.Highlighter := frmMain.sciEditor.LanguageManager.SelectedLanguage; diff --git a/editor/studio/UnitPlugins.pas b/editor/studio/UnitPlugins.pas index ca937568..6af74e8d 100755 --- a/editor/studio/UnitPlugins.pas +++ b/editor/studio/UnitPlugins.pas @@ -157,6 +157,7 @@ const SCM_SHOWPROGRESS = WM_USER + $100; SCM_PLUGIN_LOAD = WM_USER + $119; SCM_PLUGIN_UNLOAD = WM_USER + $120; SCM_SETTINGS_CREATEPAGE = WM_USER + $121; + SCM_SETTINGS_REMOVEPAGE = WM_USER + $194; SCM_CODEINSPECTOR_CLEAR = WM_USER + $122; SCM_CODEINSPECTOR_ADD = WM_USER + $123; SCM_CODEINSPECTOR_ADDCOMBO = WM_USER + $124; diff --git a/editor/studio/UnitTextAnalyze.pas b/editor/studio/UnitTextAnalyze.pas index 9ca32c21..b3c976df 100755 --- a/editor/studio/UnitTextAnalyze.pas +++ b/editor/studio/UnitTextAnalyze.pas @@ -25,8 +25,8 @@ type TPawnParseResult = class procedure DestroyResult; end; -function ParseCodePawn(eCode: TStringList; FileName: String; IsRecursive: Boolean = False): TPawnParseResult; -function UpdateIncPath(eInput: String): String; +function ParseCodePawn(eCode: TStringList; FileName: string; IsRecursive: Boolean = False): TPawnParseResult; +function UpdateIncPath(eInput: string): string; var eCPUSpeed: Integer = 1; @@ -37,7 +37,7 @@ uses UnitCodeExplorerUpdater, UnitCodeUtils, UnitfrmSettings, var eLookedUpIncluded: TStringList; -function UpdateIncPath(eInput: String): String; +function UpdateIncPath(eInput: string): string; begin eInput := StringReplace(Trim(eInput), '/', '\', [rfReplaceAll]); if FileExists(ExtractFilePath(frmSettings.txtPawnCompilerPath.Text) + eInput + '.inc') then @@ -50,15 +50,15 @@ begin Result := ''; end; -function ParseCodePawn(eCode: TStringList; FileName: String; IsRecursive: Boolean = False): TPawnParseResult; +function ParseCodePawn(eCode: TStringList; FileName: string; IsRecursive: Boolean = False): TPawnParseResult; var i, k: integer; - eString, eTemp, eBackup: string; - eStr, ePreEvents: TStringList; - eStartLine, eBracesOpen: Integer; - eTimeToSleep: Integer; - eAddingEnum: Integer; - eTempResult: TPawnParseResult; - eProcedureAdded: Boolean; + eString, eTemp, eBackup: string; + eStr, ePreEvents: TStringList; + eStartLine, eBracesOpen: Integer; + eTimeToSleep: Integer; + eAddingEnum: Integer; + eTempResult: TPawnParseResult; + eProcedureAdded: Boolean; begin Result := TPawnParseResult.Create; if not IsRecursive then @@ -74,9 +74,9 @@ begin for i := 0 to eCode.Count - 1 do begin if (Application.Terminated) or (not Started) or (frmMain.pnlLoading.Visible) or (not frmMain.trvExplorer.Visible) then exit; - eString := RemoveStringsAndComments(Trim(eCode[i]), True); + eString := RemoveStringsAndComments(Trim(eCode[i]), True, True); eBackup := Trim(eCode[i]); - + eProcedureAdded := False; Inc(eTimeToSleep, 1); @@ -86,34 +86,36 @@ begin end; { Constants and Variables } - if (IsAtStart('new', eString)) and (eBracesOpen = 0) and (not IsRecursive) then begin // const or variable - Delete(eString, 1, 4); - eString := Trim(eString); - // we don't need braces so delete them... - while (CountChars(eString, '{') <> 0) and (CountChars(eString, '}') <> 0) and (Pos('{', eString) < Pos('}', eString)) do - eString := StringReplace(eString, '{' + Between(eString, '{', '}') + '}', '', [rfReplaceAll]); - while (CountChars(eString, '[') <> 0) and (CountChars(eString, ']') <> 0) and (Pos('[', eString) < Pos(']', eString)) do - eString := StringReplace(eString, '[' + Between(eString, '[', ']') + ']', '', [rfReplaceAll]); - // done? okay, split all items if there are more than one; and if not, it's okay... - eStr.Text := StringReplace(eString, ',', #13, [rfReplaceAll]); - for k := 0 to eStr.Count - 1 do begin - if (Trim(eStr[k]) <> '') and (eStr[k] <> '}') then begin - eTemp := Trim(RemoveSemicolon(eStr[k])); + if (IsAtStart('new', eString, False)) or (IsAtStart('stock', eString, False)) then begin // const or variable + if (eBracesOpen = 0) and (not IsRecursive) and (Pos('(', eString) = Pos(')', eString)) then begin + Delete(eString, 1, Pos(#32, eString)); + eString := Trim(eString); + // we don't need braces so delete them... + while (CountChars(eString, '{') <> 0) and (CountChars(eString, '}') <> 0) and (Pos('{', eString) < Pos('}', eString)) do + eString := StringReplace(eString, '{' + Between(eString, '{', '}') + '}', '', [rfReplaceAll]); + while (CountChars(eString, '[') <> 0) and (CountChars(eString, ']') <> 0) and (Pos('[', eString) < Pos(']', eString)) do + eString := StringReplace(eString, '[' + Between(eString, '[', ']') + ']', '', [rfReplaceAll]); + // done? okay, split all items if there are more than one; and if not, it's okay... + eStr.Text := StringReplace(eString, ',', #13, [rfReplaceAll]); + for k := 0 to eStr.Count - 1 do begin + if (Trim(eStr[k]) <> '') and (eStr[k] <> '}') then begin + eTemp := Trim(RemoveSemicolon(eStr[k])); - if Pos(':', eTemp) <> 0 then - eTemp := Copy(eTemp, Pos(':', eTemp) + 1, Length(eTemp)); + if Pos(':', eTemp) <> 0 then + eTemp := Copy(eTemp, Pos(':', eTemp) + 1, Length(eTemp)); - if Pos('=', eTemp) <> 0 then begin // constant - Result.Constants.AddObject(Copy(eTemp, 1, Pos('=', eTemp) - 1), TObject(i)); - Result.AutoComplete.Add(Copy(eTemp, 1, Pos('=', eTemp) - 1)); - end - else begin // variable - Result.Variables.AddObject(eTemp, TObject(i)); - Result.AutoComplete.Add(eTemp); + if Pos('=', eTemp) <> 0 then begin // constant + Result.Constants.AddObject(Copy(eTemp, 1, Pos('=', eTemp) - 1), TObject(i)); + Result.AutoComplete.Add(Copy(eTemp, 1, Pos('=', eTemp) - 1)); + end + else begin // variable + Result.Variables.AddObject(eTemp, TObject(i)); + Result.AutoComplete.Add(eTemp); + end; end; end; + eString := RemoveStringsAndComments(Trim(eCode[i]), True, True); end; - eString := RemoveStringsAndComments(Trim(eCode[i]), True); end { Included } else if (IsAtStart('#include', eBackup)) then begin @@ -206,77 +208,89 @@ begin end; { <- Enums } end; - if (Pos('}', eString) <> 0) and (not IsAtStart('new', Trim(eCode[eStartLine]))) then begin + if (Pos('}', eString) <> 0) then begin { Enums -> } if eAddingEnum <> 0 then eAddingEnum := 0; - - { <- Enums } - if (eBracesOpen = 0) and (Length(Trim(eCode[eStartLine])) > 1) then begin - eTemp := Trim(RemoveSemicolon(Trim(eCode[eStartLine]))); - if eTemp[Length(eTemp)] = '{' then - eTemp := Trim(Copy(eTemp, 1, Length(eTemp) -1)); + { <- Enums } + if (eStartLine <> -1) then begin + if (eBracesOpen = 0) and (not IsAtStart('new', Trim(eCode[eStartLine]))) then begin + if Trim(RemoveStringsAndComments(eCode[eStartLine], True, True)) = '{' then + eStartLine := eStartLine - 1; + eTemp := Trim(RemoveSemicolon(Trim(eCode[eStartLine]))); // Analyze type - k := 0; - if IsAtStart('public', eTemp) then - k := 1 - else if IsAtStart('stock', eTemp) then - k := 2 - else if IsAtStart('native', eTemp) then - k := 3 - else if IsAtStart('forward', eTemp) then - k := 4 - else if Pos('enum', LowerCase(eTemp)) = 1 then // no method - k := 5; + k := 0; + if IsAtStart('public', eTemp) then + k := 1 + else if IsAtStart('stock', eTemp) then + k := 2 + else if IsAtStart('native', eTemp) then + k := 3 + else if IsAtStart('forward', eTemp) then + k := 4 + else if Pos('enum', LowerCase(eTemp)) = 1 then // no method + k := 5; + // Remove type - if (Pos(#32, eTemp) <> 0) and (Pos(#32, eTemp) < Pos('(', eTemp)) then - eTemp := Copy(eCode[eStartLine], Pos(#32, eCode[eStartLine]) + 1, Length(eCode[eStartLine])) - else if (Pos(#9, eTemp) <> 0) and (Pos(#9, eTemp) < Pos('(', eTemp)) then - eTemp := Copy(eTemp, Pos(#9, eTemp) + 1, Length(eTemp)); - // Remove return-type - if (Pos(':', eTemp) <> 0) and (Pos(':', eTemp) < Pos('(', eTemp)) then - Delete(eTemp, 1, Pos(':', eTemp)); - - if Pos('operator', eTemp) = 1 then - k := 6; - - if k < 5 then - Result.CallTips.Add(eTemp + '-> ' + FileName); - // Copy function-name - if Pos('(', eTemp) <> 0 then - eTemp := Copy(eTemp, 1, Pos('(', eTemp) - 1); - eTemp := Trim(eTemp); - - if k < 5 then begin - Result.AutoComplete.Add(eTemp); - Result.HighlightKeywords.Add(eTemp); - end; - - if eTemp <> '' then begin - case k of - 0: begin - if not IsRecursive then - Result.MethodsDefault.AddObject(eTemp, TObject(eStartLine)); // Default Method - end; - 1: begin - k := ePreEvents.IndexOf(eTemp); - if k <> -1 then begin - Result.Events.AddObject(eTemp, ePreEvents.Objects[k]); - ePreEvents.Delete(k); - end - else - Result.MethodsDefault.AddObject(eTemp, TObject(eStartLine)); - end; - 2: Result.Stocks.AddObject(eTemp, TObject(eStartLine)); - 3: Result.Natives.AddObject(eTemp, TObject(eStartLine)); - 4: Result.Forwards.AddObject(eTemp, TObject(eStartLine)); + if Pos('@', eTemp) = 1 then begin + eTemp := Copy(eTemp, 2, Length(eTemp)); + k := 1; + end + else begin + if (Pos(#32, eTemp) <> 0) and (Pos(#32, eTemp) < Pos('(', eTemp)) then + eTemp := Copy(eCode[eStartLine], Pos(#32, eCode[eStartLine]) + 1, Length(eCode[eStartLine])) + else if (Pos(#9, eTemp) <> 0) and (Pos(#9, eTemp) < Pos('(', eTemp)) then + eTemp := Copy(eTemp, Pos(#9, eTemp) + 1, Length(eTemp)); end; + + if eTemp[Length(eTemp)] = '{' then + eTemp := Trim(Copy(eTemp, 1, Length(eTemp) - 1)); + + // Remove return-type + if (Pos(':', eTemp) <> 0) and (Pos(':', eTemp) < Pos('(', eTemp)) then + Delete(eTemp, 1, Pos(':', eTemp)); + + if Pos('operator', eTemp) = 1 then + k := 6; + + if k < 5 then + Result.CallTips.Add(eTemp + '-> ' + FileName); + // Copy function-name + if Pos('(', eTemp) <> 0 then + eTemp := Copy(eTemp, 1, Pos('(', eTemp) - 1); + eTemp := Trim(eTemp); + + if k < 5 then begin + Result.AutoComplete.Add(eTemp); + Result.HighlightKeywords.Add(eTemp); + end; + + if eTemp <> '' then begin + case k of + 0: begin + if not IsRecursive then + Result.MethodsDefault.AddObject(eTemp, TObject(eStartLine)); // Default Method + end; + 1: begin + k := ePreEvents.IndexOf(eTemp); + if k <> -1 then begin + Result.Events.AddObject(eTemp, ePreEvents.Objects[k]); + ePreEvents.Delete(k); + end + else + Result.MethodsDefault.AddObject(eTemp, TObject(eStartLine)); + end; + 2: Result.Stocks.AddObject(eTemp, TObject(eStartLine)); + 3: Result.Natives.AddObject(eTemp, TObject(eStartLine)); + 4: Result.Forwards.AddObject(eTemp, TObject(eStartLine)); + end; + end; + eStartLine := -1; + eBracesOpen := 0; end; - eStartLine := -1; - eBracesOpen := 0; end; end else if (eAddingEnum = 2) and (Pos('enum', LowerCase(eString)) <> 1) then begin @@ -301,10 +315,11 @@ begin { Functions (2) } if (IsAtStart('forward', eString)) or (IsAtStart('public', eString)) or (IsAtStart('native', eString)) or (IsAtStart('stock', eString)) then begin - if (not eProcedureAdded) and (Pos('(', eString) <> 0) then begin - eTemp := Trim(RemoveSemicolon(eString)); + if (not eProcedureAdded) and (Pos('(', eString) <> 0) and (Pos(')', eString) <> 0) then begin + eTemp := StringReplace(Trim(eBackup), #9, #32, [rfReplaceAll]); + eTemp := Trim(RemoveSemicolon(eTemp)); if eTemp[Length(eTemp)] = '{' then - eTemp := Trim(Copy(eTemp, 1, Length(eTemp) -1)); + eTemp := Trim(Copy(eTemp, 1, Length(eTemp) - 1)); // Remove type if (Pos(#32, eTemp) <> 0) and (Pos(#32, eTemp) < Pos('(', eTemp)) then @@ -317,11 +332,11 @@ begin if (Pos('enum', eTemp) = Pos('operator', eTemp)) and (Pos('enum', eTemp) = 0) then Result.CallTips.Add(eTemp + '-> ' + FileName); - + // Copy function-name if Pos('(', eTemp) <> 0 then - eTemp := Copy(eTemp, 1, Pos('(', eTemp) - 1); - eTemp := Trim(eTemp); + eTemp := Copy(eTemp, 1, Pos('(', eTemp) - 1); + eTemp := Trim(eTemp); if (Pos('enum', eTemp) = Pos('operator', eTemp)) and (Pos('enum', eTemp) = 0) then begin Result.AutoComplete.Add(eTemp); @@ -348,7 +363,7 @@ begin Result.MethodsDefault.AddObject(eTemp, TObject(i)); end; end; - end; + end; end; ePreEvents.Free; eStr.Free; @@ -390,7 +405,7 @@ begin MethodsDefault.Free; Natives.Free; Stocks.Free; - Variables.Free; + Variables.Free; Free; end; @@ -405,3 +420,4 @@ finalization end. + diff --git a/editor/studio/UnitfrmHudMsgGenerator.pas b/editor/studio/UnitfrmHudMsgGenerator.pas index 340078bf..0b7c4bcf 100755 --- a/editor/studio/UnitfrmHudMsgGenerator.pas +++ b/editor/studio/UnitfrmHudMsgGenerator.pas @@ -178,10 +178,16 @@ procedure TfrmHudMsgGenerator.cmdSelectColorClick(Sender: TObject); begin frmSelectColor.chkDefault1.Enabled := False; frmSelectColor.chkDefault2.Enabled := False; + frmSelectColor.chkNone1.Enabled := False; + frmSelectColor.chkNone2.Enabled := False; + ShowColorDialog(CurrColor, imgColor); lblHudMsg.Font.Color := CurrColor; + frmSelectColor.chkDefault1.Enabled := True; frmSelectColor.chkDefault2.Enabled := True; + frmSelectColor.chkNone1.Enabled := True; + frmSelectColor.chkNone2.Enabled := True; end; procedure TfrmHudMsgGenerator.txtTextChange(Sender: TObject); @@ -189,7 +195,7 @@ begin if txtText.Text = '' then lblHudMsg.Caption := 'Custom Hudmessage' else - lblHudMsg.Caption := stringReplace(txtText.Text, '\n', #13, [rfReplaceAll]); + lblHudMsg.Caption := StringReplace(txtText.Text, '\n', #13, [rfReplaceAll]); if chkXCenter.Checked then CenterX; diff --git a/editor/studio/UnitfrmInfo.dfm b/editor/studio/UnitfrmInfo.dfm index 17dc5abc..c4fd6ba7 100755 Binary files a/editor/studio/UnitfrmInfo.dfm and b/editor/studio/UnitfrmInfo.dfm differ diff --git a/editor/studio/UnitfrmMain.dfm b/editor/studio/UnitfrmMain.dfm index 0a2d581c..e5f95b90 100755 --- a/editor/studio/UnitfrmMain.dfm +++ b/editor/studio/UnitfrmMain.dfm @@ -1,6 +1,6 @@ object frmMain: TfrmMain - Left = 284 - Top = 290 + Left = 257 + Top = 302 Width = 888 Height = 640 Caption = 'AMXX-Studio' @@ -455,6 +455,13 @@ object frmMain: TfrmMain OnClick = mnuPasterClick CaptionW = 'IRC Paster' end + object mnuRestoreBackup: TSpTBXItem + Enabled = False + ImageIndex = 46 + Images = ilImages + OnClick = mnuRestoreBackupClick + CaptionW = 'Restore from backup' + end object sepTools3: TSpTBXSeparatorItem end object mnuSettings: TSpTBXItem @@ -714,7 +721,7 @@ object frmMain: TfrmMain Align = alRight end object splRight: TSplitter - Left = 701 + Left = 669 Top = 23 Height = 472 Align = alRight @@ -722,7 +729,7 @@ object frmMain: TfrmMain object pnlParent: TPanel Left = 3 Top = 23 - Width = 698 + Width = 666 Height = 472 Align = alClient BevelOuter = bvNone @@ -730,7 +737,7 @@ object frmMain: TfrmMain object splOutput: TSplitter Left = 0 Top = 387 - Width = 698 + Width = 666 Height = 3 Cursor = crVSplit Align = alBottom @@ -739,7 +746,7 @@ object frmMain: TfrmMain object sciEditor: TScintilla Left = 0 Top = 0 - Width = 698 + Width = 666 Height = 387 Color = clWhite Font.Charset = DEFAULT_CHARSET @@ -818,7 +825,7 @@ object frmMain: TfrmMain WordChars = '_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' ControlCharSymbol = #0 BraceHilite = True - Folding = [foldFold, foldComment, foldPreprocessor, foldCommentPython, foldAtElse, foldHTML, foldHTMLPreProcessor] + Folding = [foldFold, foldCompact, foldComment, foldPreprocessor, foldCommentPython, foldAtElse, foldHTML, foldHTMLPreProcessor] FoldMarkerType = sciMarkBox LanguageManager.LanguageList = < item @@ -4001,7 +4008,7 @@ object frmMain: TfrmMain object lstOutput: TListBox Left = 0 Top = 390 - Width = 698 + Width = 666 Height = 82 Align = alBottom ItemHeight = 13 @@ -4062,9 +4069,9 @@ object frmMain: TfrmMain end end object tcTools: TSpTBXTabControl - Left = 704 + Left = 672 Top = 23 - Width = 173 + Width = 205 Height = 472 Align = alRight ActiveTabIndex = 0 @@ -4086,13 +4093,13 @@ object frmMain: TfrmMain object tsNotes: TSpTBXTabSheet Left = 0 Top = 0 - Width = 173 + Width = 205 Height = 449 Caption = 'Notes' ImageIndex = -1 TabItem = 'tiNotes' object imgRight4: TImage - Left = 170 + Left = 202 Top = 26 Width = 1 Height = 421 @@ -4101,14 +4108,14 @@ object frmMain: TfrmMain object imgBottom4: TImage Left = 2 Top = 447 - Width = 169 + Width = 201 Height = 2 Align = alBottom end object imgTop4: TImage Left = 2 Top = 24 - Width = 169 + Width = 201 Height = 2 Align = alTop end @@ -4122,7 +4129,7 @@ object frmMain: TfrmMain object tbxNotes: TSpTBXToolbar Left = 2 Top = 2 - Width = 169 + Width = 201 Height = 22 Align = alTop Caption = 'tbxNotes' @@ -4162,7 +4169,7 @@ object frmMain: TfrmMain object rtfNotes: TRichEdit Left = 3 Top = 26 - Width = 167 + Width = 199 Height = 421 Align = alClient TabOrder = 1 @@ -4173,7 +4180,7 @@ object frmMain: TfrmMain object tsExplorer: TSpTBXTabSheet Left = 0 Top = 0 - Width = 173 + Width = 205 Height = 449 Caption = 'Code-Tools' ImageIndex = -1 @@ -4181,7 +4188,7 @@ object frmMain: TfrmMain object spcBottom2: TImage Left = 0 Top = 447 - Width = 173 + Width = 205 Height = 2 Align = alBottom end @@ -4193,7 +4200,7 @@ object frmMain: TfrmMain Align = alLeft end object spcRight2: TImage - Left = 170 + Left = 202 Top = 0 Width = 3 Height = 447 @@ -4202,21 +4209,21 @@ object frmMain: TfrmMain object pnlDock: TSpTBXMultiDock Left = 3 Top = 0 - Width = 167 + Width = 199 Height = 447 Position = dpxClient object pnlCodeExplorer: TSpTBXDockablePanel Left = 0 Top = 0 Caption = 'Code-Explorer' - DockedWidth = 163 + DockedWidth = 195 DockPos = 0 TabOrder = 0 OnVisibleChanged = pnlCodeExplorerVisibleChanged object trvExplorer: TTreeView Left = 0 Top = 26 - Width = 163 + Width = 195 Height = 186 Align = alClient Images = ilImages @@ -4224,6 +4231,7 @@ object frmMain: TfrmMain ReadOnly = True SortType = stBoth TabOrder = 1 + OnClick = trvExplorerClick OnCollapsed = trvExplorerCollapsed OnDblClick = trvExplorerDblClick OnExpanded = trvExplorerExpanded @@ -4247,17 +4255,17 @@ object frmMain: TfrmMain Left = 0 Top = 216 Caption = 'Code-Inspector' - DockedWidth = 163 + DockedWidth = 195 DockPos = 216 TabOrder = 1 OnVisibleChanged = pnlCodeInspectorVisibleChanged object jviCode: TJvInspector Left = 0 Top = 26 - Width = 163 + Width = 195 Height = 185 Align = alClient - Divider = 80 + Divider = 110 ItemHeight = 16 Painter = JvInspectorDotNETPainter OnItemValueChanged = jviCodeItemValueChanged @@ -7564,7 +7572,7 @@ object frmMain: TfrmMain end end object JvInspectorDotNETPainter: TJvInspectorDotNETPainter - DrawNameEndEllipsis = False + DrawNameEndEllipsis = True Left = 662 Top = 36 end diff --git a/editor/studio/UnitfrmMain.pas b/editor/studio/UnitfrmMain.pas index 6c95f6b3..08c9f482 100755 --- a/editor/studio/UnitfrmMain.pas +++ b/editor/studio/UnitfrmMain.pas @@ -230,6 +230,7 @@ type sepView3: TSpTBXSeparatorItem; mnuShowCodeExplorer: TSpTBXItem; mnuShowCodeInspector: TSpTBXItem; + mnuRestoreBackup: TSpTBXItem; procedure FormConstrainedResize(Sender: TObject; var MinWidth, MinHeight, MaxWidth, MaxHeight: Integer); procedure mnuExitClick(Sender: TObject); @@ -351,8 +352,6 @@ type procedure mnuPCloseClick(Sender: TObject); procedure mnuPCloseAllFilesClick(Sender: TObject); procedure mnuTNewClick(Sender: TObject); - procedure jviCodeItemValueChanged(Sender: TObject; - Item: TJvCustomInspectorItem); procedure mnuMenuGeneratorClick(Sender: TObject); procedure JvPluginManagerPlugInError(Sender: TObject; AError: Exception); @@ -375,6 +374,10 @@ type procedure mnuShowCodeExplorerClick(Sender: TObject); procedure mnuShowCodeInspectorClick(Sender: TObject); procedure mnuConnectionGenClick(Sender: TObject); + procedure trvExplorerClick(Sender: TObject); + procedure jviCodeItemValueChanged(Sender: TObject; + Item: TJvCustomInspectorItem); + procedure mnuRestoreBackupClick(Sender: TObject); private procedure UpdateNotes; public @@ -413,7 +416,7 @@ begin pnlLoading.Left := sciEditor.Left + 3 + (sciEditor.Width div 2) - (pnlLoading.Width div 2); pnlLoading.Top := tsDocuments.Top + sciEditor.Top + ((sciEditor.Height * 5) div 6) - (pnlLoading.Height div 2); - if (Canvas.TextWidth(ActiveDoc.FileName) +10 > mnuFilename.CustomWidth) then + if (Canvas.TextWidth(ActiveDoc.FileName) + 10 > mnuFilename.CustomWidth) then mnuFilename.Caption := ExtractFileName(ActiveDoc.FileName) else mnuFilename.Caption := ActiveDoc.FileName; @@ -432,7 +435,7 @@ begin mnuCPP.Checked := Sender = mnuCPP; mnuHTML.Checked := Sender = mnuHTML; mnuOther.Checked := Sender = mnuOther; - LoadCodeSnippets((Sender As TSpTBXItem).Caption); + LoadCodeSnippets((Sender as TSpTBXItem).Caption); end; procedure TfrmMain.cpNotesChange(Sender: TObject); @@ -502,7 +505,7 @@ end; procedure TfrmMain.mnuSettingsClick(Sender: TObject); var i: integer; - eModified: Boolean; + eModified: Boolean; begin CopyFile(PChar(ExtractFilePath(ParamStr(0)) + 'config\Pawn.csl'), PChar(ExtractFilePath(ParamStr(0)) + 'config\Pawn.bak'), False); CopyFile(PChar(ExtractFilePath(ParamStr(0)) + 'config\C++.csl'), PChar(ExtractFilePath(ParamStr(0)) + 'config\C++.bak'), False); @@ -511,7 +514,7 @@ begin if frmSettings.ShowModal = mrOk then begin { Shortcuts } - for i := 0 to frmSettings.lvShortcuts.Items.Count - 1 do + for i := 0 to frmSettings.lvShortcuts.Items.Count - 1 do TSciKeyCommand(frmSettings.lvShortcuts.Items[i].Data).ShortCut := (TextToShortCut(frmSettings.lvShortcuts.Items[i].SubItems[0])); { Tools } if frmSettings.chkIndentGuides.Checked then @@ -542,10 +545,14 @@ begin sciEditor.Caret.LineBackColor := frmSettings.CaretBack; sciEditor.Caret.LineVisible := frmSettings.chkShowCaret.Checked; sciEditor.Caret.Period := StrToInt(frmSettings.txtPeriod.Text); + eConfig.WriteBool('Editor', 'MakeBaks', frmSettings.chkMakeBaks.Checked); + eConfig.WriteBool('Editor', 'DontLoadFilesTwice', frmSettings.chkDontLoadFilesTwice.Checked); eConfig.WriteBool('Editor', 'Auto-Indent', frmSettings.chkAutoIndent.Checked); eConfig.WriteBool('Editor', 'IndentOpeningBrace', frmAutoIndent.chkIndentOpeningBrace.Checked); eConfig.WriteBool('Editor', 'UnindentClosingBrace', frmAutoIndent.chkUnindentPressingClosingBrace.Checked); eConfig.WriteBool('Editor', 'UnindentEmptyLine', frmAutoIndent.chkUnindentLine.Checked); + eConfig.WriteBool('Editor', 'Disable_AC', frmSettings.chkDisableAC.Checked); + eConfig.WriteBool('Editor', 'Disable_CT', frmSettings.chkDisableCT.Checked); { Editor } if FileExists(sciPropertyLoader.FileName) then sciPropertyLoader.Save; @@ -558,8 +565,8 @@ begin eConfig.WriteString('CPP-Compiler', 'DefaultOutput', frmSettings.txtCPPOutput.Text); { HL } eConfig.WriteString('Half-Life', 'Filename', frmSettings.txtHLExec.Text); - eConfig.WriteString('Half-Life', 'Params', frmSettings.txtCustomParameters.Text); - eConfig.WriteString('Half-Life', 'AMXXListen', frmSettings.txtAMXXDir.Text); + eConfig.WriteString('Half-Life', 'Params', frmSettings.txtCustomParameters.Text); + eConfig.WriteString('Half-Life', 'AMXXListen', frmSettings.txtAMXXDir.Text); { FTP Settings } eConfig.WriteString('FTP', 'Host', frmSettings.txtHost.Text); eConfig.WriteString('FTP', 'Port', frmSettings.txtPort.Text); @@ -572,7 +579,7 @@ begin eConfig.WriteString('Proxy', 'Host', frmSettings.txtProxyHost.Text); eConfig.WriteString('Proxy', 'Port', frmSettings.txtProxyPort.Text); eConfig.WriteString('Proxy', 'Username', frmSettings.txtUsername.Text); - eConfig.WriteString('Proxy', 'Password', frmSettings.txtProxyPassword.Text); + eConfig.WriteString('Proxy', 'Password', frmSettings.txtProxyPassword.Text); { Misc } eConfig.WriteString('Misc', 'DefaultPluginName', frmSettings.txtDefaultName.Text); eConfig.WriteString('Misc', 'DefaultPluginVersion', frmSettings.txtDefaultVersion.Text); @@ -582,8 +589,9 @@ begin else if frmSettings.optConfig.Checked then eConfig.WriteInteger('Misc', 'SaveNotesTo', 1) else - eConfig.WriteInteger('Misc', 'SaveNotesTo', 3); + eConfig.WriteInteger('Misc', 'SaveNotesTo', 3); eConfig.WriteInteger('Misc', 'CPUSpeed', frmSettings.sldSpeed.Value); + eConfig.WriteString('Misc', 'LangDir', frmSettings.txtLangDir.Text); eConfig.WriteBool('Misc', 'ShowStatusbar', frmSettings.chkShowStatusbar.Checked); end else begin @@ -604,7 +612,7 @@ begin LoadCodeSnippets('HTML') else LoadCodeSnippets('Other'); - + DeleteFile(ExtractFilePath(ParamStr(0)) + 'config\Pawn.bak'); DeleteFile(ExtractFilePath(ParamStr(0)) + 'config\C++.bak'); DeleteFile(ExtractFilePath(ParamStr(0)) + 'config\Other.bak'); @@ -641,19 +649,19 @@ begin case tsMain.ActiveTabIndex of 0: begin - mnuTNew.Caption := 'New Plugin'; - end; + mnuTNew.Caption := 'New Plugin'; + end; 1: begin - mnuTNew.Caption := 'New Unit'; - sciCallTips.ApiStrings.Clear; - sciAutoComplete.AStrings.Clear; - end; + mnuTNew.Caption := 'New Unit'; + sciCallTips.ApiStrings.Clear; + sciAutoComplete.AStrings.Clear; + end; 2: begin - mnuTNew.Caption := 'New Textfile'; - sciCallTips.ApiStrings.Clear; - sciAutoComplete.AStrings.Clear; - end; - end; + mnuTNew.Caption := 'New Textfile'; + sciCallTips.ApiStrings.Clear; + sciAutoComplete.AStrings.Clear; + end; + end; ActivateProjects(ItemIndex, True); trvExplorer.Items.Clear; @@ -675,10 +683,10 @@ begin end; case tsMain.ActiveTabIndex of - 0: Collection := PawnProjects; // Pawn - 1: Collection := CPPProjects; // C++ - else Collection := OtherProjects; // Other - end; + 0: Collection := PawnProjects; // Pawn + 1: Collection := CPPProjects; // C++ + else Collection := OtherProjects; // Other + end; Collection.Activate(ItemIndex, True); end; @@ -785,7 +793,7 @@ end; procedure TfrmMain.mnuHXMLClick(Sender: TObject); begin - SelectLanguage((Sender As TSpTBXItem).Caption); + SelectLanguage((Sender as TSpTBXItem).Caption); end; procedure TfrmMain.mnuHNoneClick(Sender: TObject); @@ -794,7 +802,7 @@ begin end; procedure TfrmMain.mnuOpenClick(Sender: TObject); -var eExt: String; +var eExt: string; begin if Assigned(Sender) then begin if not odOpen.Execute then @@ -865,9 +873,9 @@ begin sciEditor.Lines.Add(#9''); sciEditor.Lines.Add(#9''); sciEditor.Lines.Add(#9#9'<-- Your text here -->'); - sciEditor.Lines.Add(#9''); + sciEditor.Lines.Add(#9''); sciEditor.Lines.Add(''); - + Plugin_CreateNewFile(NEW_OTHER_HTML, False); end; @@ -967,10 +975,10 @@ procedure TfrmMain.mnuShowCodeToolsClick(Sender: TObject); begin if not Plugin_VisibleControlChange(CTRL_CODETOOLS_MAIN, not tcTools.Visible) then exit; - tcTools.Visible := (Sender As TSpTBXItem).Checked; - splRight.Visible := (Sender As TSpTBXItem).Checked; - mnuShowCodeTools.Checked := (Sender As TSpTBXItem).Checked; - mnuShowCodeToolsWindow.Checked := (Sender As TSpTBXItem).Checked; + tcTools.Visible := (Sender as TSpTBXItem).Checked; + splRight.Visible := (Sender as TSpTBXItem).Checked; + mnuShowCodeTools.Checked := (Sender as TSpTBXItem).Checked; + mnuShowCodeToolsWindow.Checked := (Sender as TSpTBXItem).Checked; Application.ProcessMessages; Plugin_VisibleControlChange(CTRL_CODETOOLS_MAIN, tcTools.Visible); @@ -978,7 +986,7 @@ end; procedure TfrmMain.sciEditorClick(Sender: TObject); begin - mnuCaret.Caption := Format(lLnCh, [sciEditor.GetCurrentLineNumber +1, sciEditor.GetCaretInLine +1]); + mnuCaret.Caption := Format(lLnCh, [sciEditor.GetCurrentLineNumber + 1, sciEditor.GetCaretInLine + 1]); Plugin_EditorClick(False); Plugin_UpdateSel(sciEditor.SelStart, sciEditor.SelLength, sciEditor.GetFirstVisibleLine); end; @@ -987,7 +995,7 @@ procedure TfrmMain.sciEditorKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); var i: integer; begin - mnuCaret.Caption := Format(lLnCh, [sciEditor.GetCurrentLineNumber +1, sciEditor.GetCaretInLine +1]); + mnuCaret.Caption := Format(lLnCh, [sciEditor.GetCurrentLineNumber + 1, sciEditor.GetCaretInLine + 1]); Plugin_UpdateSel(sciEditor.SelStart, sciEditor.SelLength, sciEditor.GetFirstVisibleLine); if Key = 46 then begin @@ -1003,33 +1011,33 @@ begin i := sciEditor.SelLength; sciEditor.SelLength := 0; - sciEditor.SelStart := sciEditor.SelStart +i; + sciEditor.SelStart := sciEditor.SelStart + i; end; end; procedure TfrmMain.sciEditorKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); -var eStr: String; +var eStr: string; begin if not Started then exit; - mnuCaret.Caption := Format(lLnCh, [sciEditor.GetCurrentLineNumber +1, sciEditor.GetCaretInLine +1]); + mnuCaret.Caption := Format(lLnCh, [sciEditor.GetCurrentLineNumber + 1, sciEditor.GetCaretInLine + 1]); Plugin_UpdateSel(sciEditor.SelStart, sciEditor.SelLength, sciEditor.GetFirstVisibleLine); if (Key = 13) and (frmSettings.chkAutoIndent.Checked) and (Trim(sciEditor.Lines[sciEditor.GetCurrentLineNumber]) = '') then begin if (sciEditor.LanguageManager.SelectedLanguage = 'Pawn') or (sciEditor.LanguageManager.SelectedLanguage = 'C++') then begin - eStr := Trim(RemoveStringsAndComments(sciEditor.Lines[sciEditor.GetCurrentLineNumber -1], True)); + eStr := Trim(RemoveStringsAndComments(sciEditor.Lines[sciEditor.GetCurrentLineNumber - 1], True, True)); if (Copy(eStr, Length(eStr), 1) = '{') and (frmAutoIndent.chkIndentOpeningBrace.Checked) then - sciEditor.SelText := #9; + sciEditor.SelText := #9; if (eStr = '') and (frmAutoIndent.chkUnindentLine.Checked) then begin - sciEditor.Lines[sciEditor.GetCurrentLineNumber] := Copy(sciEditor.Lines[sciEditor.GetCurrentLineNumber], 1, Length(sciEditor.Lines[sciEditor.GetCurrentLineNumber]) -1); // remove last indent.. - sciEditor.SelStart := sciEditor.SelStart + Length(sciEditor.Lines[sciEditor.GetCurrentLineNumber]); // and jump to last position + sciEditor.Lines[sciEditor.GetCurrentLineNumber] := Copy(sciEditor.Lines[sciEditor.GetCurrentLineNumber], 1, Length(sciEditor.Lines[sciEditor.GetCurrentLineNumber]) - 1); // remove last indent.. + sciEditor.SelStart := sciEditor.SelStart + Length(sciEditor.Lines[sciEditor.GetCurrentLineNumber]); // and jump to last position end; end; end; Application.ProcessMessages; - UpdateCI; + UpdateCI(frmMain.sciEditor.GetCurrentLineNumber); end; procedure TfrmMain.mnuFoldAllClick(Sender: TObject); @@ -1071,8 +1079,8 @@ end; procedure TfrmMain.OnCodeSnippetClick(Sender: TObject); begin - if Plugin_CodeSnippetClick(TSpTBXItem(Sender).Caption, GetCat, GetSnippet(GetCat, (Sender As TSpTBXItem).Caption)) then - sciEditor.SelText := GetSnippet(GetCat, (Sender As TSpTBXItem).Caption); + if Plugin_CodeSnippetClick(TSpTBXItem(Sender).Caption, GetCat, GetSnippet(GetCat, (Sender as TSpTBXItem).Caption)) then + sciEditor.SelText := GetSnippet(GetCat, (Sender as TSpTBXItem).Caption); end; procedure TfrmMain.mnuCopyMessageClick(Sender: TObject); @@ -1161,7 +1169,7 @@ begin if frmSearch.ShowModal = mrOk then begin if not Plugin_Search(frmSearch.cboSearchFor.Items.Text, frmSearch.cboSearchFor.Text, False, False, frmSearch.chkCaseSensivity.Checked, frmSearch.chkWholeWordsOnly.Checked, frmSearch.chkSearchFromCaret.Checked, frmSearch.chkSelectedTextOnly.Checked, frmSearch.chkRegularExpression.Checked, frmSearch.chkForward.Checked) then exit; - + with sciSearchReplace do begin SearchBackwards := frmSearch.chkBackward.Checked; SearchCaseSensitive := frmSearch.chkCaseSensivity.Checked; @@ -1221,8 +1229,8 @@ end; procedure TfrmMain.mnuGoToLineClick(Sender: TObject); begin if frmGoToLine.ShowModal = mrOk then begin - sciEditor.GotoLineEnsureVisible(StrToInt(frmGoToLine.txtGoToLine.Text) -1); - UpdateCI; + sciEditor.GotoLineEnsureVisible(StrToInt(frmGoToLine.txtGoToLine.Text) - 1); + UpdateCI(frmMain.sciEditor.GetCurrentLineNumber); end; end; @@ -1240,22 +1248,22 @@ begin end; procedure TfrmMain.mnuSaveAllFilesClick(Sender: TObject); -var a,b: integer; - Collection: TDocCollection; +var a, b: integer; + Collection: TDocCollection; begin case tsMain.ActiveTabIndex of 0: Collection := PawnProjects; 1: Collection := CPPProjects; - else Collection := OtherProjects; + else Collection := OtherProjects; end; frmAllFilesForm.Caption := lSaveAllCaption1; frmAllFilesForm.lblCaption.Caption := lSaveAllCaption2; frmAllFilesForm.lstFiles.Clear; - for a := 0 to Collection.Count -1 do begin + for a := 0 to Collection.Count - 1 do begin if TDocument(Collection.Items[a]).Modified then - frmAllFilesForm.lstFiles.Checked[frmAllFilesForm.lstFiles.Items.AddObject(IntToStr(a +1) + ') ' + ExtractFileName(TDocument(Collection.Items[a]).FileName), TObject(a))] := True; + frmAllFilesForm.lstFiles.Checked[frmAllFilesForm.lstFiles.Items.AddObject(IntToStr(a + 1) + ') ' + ExtractFileName(TDocument(Collection.Items[a]).FileName), TObject(a))] := True; end; if frmAllFilesForm.lstFiles.Items.Count = 0 then begin @@ -1264,7 +1272,7 @@ begin end; if frmAllFilesForm.ShowModal = mrOk then begin - for a := 0 to frmAllFilesForm.lstFiles.Items.Count -1 do begin + for a := 0 to frmAllFilesForm.lstFiles.Items.Count - 1 do begin if frmAllFilesForm.lstFiles.Checked[a] then begin b := Integer(frmAllFilesForm.lstFiles.Items.Objects[a]); if TDocument(Collection.Items[b]).Untitled then begin @@ -1299,8 +1307,8 @@ begin if (Key = '}') and (frmSettings.chkAutoIndent.Checked) then begin if (Trim(sciEditor.Lines[sciEditor.GetCurrentLineNumber]) = '') and (frmAutoIndent.chkUnindentPressingClosingBrace.Checked) then begin if (sciEditor.LanguageManager.SelectedLanguage = 'Pawn') or (sciEditor.LanguageManager.SelectedLanguage = 'C++') then begin - sciEditor.Lines[sciEditor.GetCurrentLineNumber] := Copy(sciEditor.Lines[sciEditor.GetCurrentLineNumber], 1, Length(sciEditor.Lines[sciEditor.GetCurrentLineNumber]) -1); // remove last indent.. - sciEditor.SelStart := sciEditor.SelStart + Length(sciEditor.Lines[sciEditor.GetCurrentLineNumber]); // and jump to last position + sciEditor.Lines[sciEditor.GetCurrentLineNumber] := Copy(sciEditor.Lines[sciEditor.GetCurrentLineNumber], 1, Length(sciEditor.Lines[sciEditor.GetCurrentLineNumber]) - 1); // remove last indent.. + sciEditor.SelStart := sciEditor.SelStart + Length(sciEditor.Lines[sciEditor.GetCurrentLineNumber]); // and jump to last position end; end; end; @@ -1309,23 +1317,23 @@ end; procedure TfrmMain.mnuCloseAllFilesClick(Sender: TObject); var i: integer; - Collection: TDocCollection; + Collection: TDocCollection; begin case tsMain.ActiveTabIndex of 0: Collection := PawnProjects; 1: Collection := CPPProjects; - else Collection := OtherProjects; + else Collection := OtherProjects; end; frmAllFilesForm.Caption := lCloseAllCaption1; frmAllFilesForm.lblCaption.Caption := lCloseAllCaption2; frmAllFilesForm.lstFiles.Clear; - for i := 0 to Collection.Count -1 do - frmAllFilesForm.lstFiles.Checked[frmAllFilesForm.lstFiles.Items.Add(IntToStr(i +1) + ') ' + ExtractFileName(TDocument(Collection.Items[i]).FileName))] := True; + for i := 0 to Collection.Count - 1 do + frmAllFilesForm.lstFiles.Checked[frmAllFilesForm.lstFiles.Items.Add(IntToStr(i + 1) + ') ' + ExtractFileName(TDocument(Collection.Items[i]).FileName))] := True; if frmAllFilesForm.ShowModal = mrOk then begin - for i := Collection.Count -1 downto 0 do begin + for i := Collection.Count - 1 downto 0 do begin if not CloseDocument(TDocument(Collection.Items[i])) then exit; end; @@ -1344,8 +1352,8 @@ end; procedure TfrmMain.mnuPasterClick(Sender: TObject); var i: integer; - eTo, eFrom: Integer; - eLine: String; + eTo, eFrom: Integer; + eLine: string; begin if FindWindow('mirc', nil) = 0 then begin MessageBox(Handle, PChar(lNoMIRCWindowOpen), PChar(Application.Title), MB_ICONERROR); @@ -1357,12 +1365,12 @@ begin { All } if frmIRCPaster.optAll.Checked then begin eFrom := 0; - eTo := sciEditor.Lines.Count -1; + eTo := sciEditor.Lines.Count - 1; end { Special Lines } else if frmIRCPaster.optLines.Checked then begin - eFrom := StrToInt(frmIRCPaster.txtFrom.Text) -1; - eTo := StrToInt(frmIRCPaster.txtTo.Text) -1; + eFrom := StrToInt(frmIRCPaster.txtFrom.Text) - 1; + eTo := StrToInt(frmIRCPaster.txtTo.Text) - 1; end { Selected } else begin @@ -1397,7 +1405,7 @@ end; procedure TfrmMain.mnuPluginsIniEditorClick(Sender: TObject); begin frmPluginsIniEditor.txtFile.Clear; - + if FileExists(GetAMXXDir(True) + 'configs\plugins.ini') then frmPluginsIniEditor.chkEditLocal.Click else if (frmSettings.txtHost.Text <> '') and (frmPluginsIniEditor.chkEditFTP.Checked) then @@ -1430,7 +1438,7 @@ begin DeleteFile(ExtractFilePath(ParamStr(0)) + 'plugins.ini'); end else - frmPluginsIniEditor.txtFile.Lines.SaveToFile(frmPluginsIniEditor.odOpen.FileName); + frmPluginsIniEditor.txtFile.Lines.SaveToFile(frmPluginsIniEditor.odOpen.FileName); Screen.Cursor := crDefault; end; end; @@ -1449,17 +1457,17 @@ end; procedure TfrmMain.FormClose(Sender: TObject; var Action: TCloseAction); var i, k: integer; - eRoot: TTreeNode; - eItem: TDocument; - eSavedFiles: TStringList; + eRoot: TTreeNode; + eItem: TDocument; + eSavedFiles: TStringList; begin ActiveDoc.Code := sciEditor.Lines.Text; frmClose.trvFiles.Items.Clear; { Pawn Projects } eRoot := frmClose.trvFiles.Items.Add(nil, tsMain.Items[0].Caption); - for i := 0 to PawnProjects.Count -1 do begin + for i := 0 to PawnProjects.Count - 1 do begin if TDocument(PawnProjects.Items[i]).Modified then - frmClose.trvFiles.Items.AddChild(eRoot, IntToStr(i +1) + '. ' + ExtractFileName(TDocument(PawnProjects.Items[i]).FileName)); + frmClose.trvFiles.Items.AddChild(eRoot, IntToStr(i + 1) + '. ' + ExtractFileName(TDocument(PawnProjects.Items[i]).FileName)); end; if eRoot.Count = 0 then eRoot.Destroy @@ -1467,9 +1475,9 @@ begin eRoot.Expand(False); { C++ Projects } eRoot := frmClose.trvFiles.Items.Add(nil, tsMain.Items[1].Caption); - for i := 0 to CPPProjects.Count -1 do begin + for i := 0 to CPPProjects.Count - 1 do begin if TDocument(CPPProjects.Items[i]).Modified then - frmClose.trvFiles.Items.AddChild(eRoot, IntToStr(i +1) + '. ' + ExtractFileName(TDocument(CPPProjects.Items[i]).FileName)); + frmClose.trvFiles.Items.AddChild(eRoot, IntToStr(i + 1) + '. ' + ExtractFileName(TDocument(CPPProjects.Items[i]).FileName)); end; if eRoot.Count = 0 then eRoot.Destroy @@ -1477,9 +1485,9 @@ begin eRoot.Expand(False); { Other Projects } eRoot := frmClose.trvFiles.Items.Add(nil, tsMain.Items[1].Caption); - for i := 0 to OtherProjects.Count -1 do begin + for i := 0 to OtherProjects.Count - 1 do begin if TDocument(OtherProjects.Items[i]).Modified then - frmClose.trvFiles.Items.AddChild(eRoot, IntToStr(i +1) + '. ' + ExtractFileName(TDocument(OtherProjects.Items[i]).FileName)); + frmClose.trvFiles.Items.AddChild(eRoot, IntToStr(i + 1) + '. ' + ExtractFileName(TDocument(OtherProjects.Items[i]).FileName)); end; if eRoot.Count = 0 then eRoot.Destroy @@ -1488,26 +1496,26 @@ begin eSavedFiles := TStringList.Create; eSavedFiles.Clear; - for i := 0 to frmSettings.lvPlugins.Items.Count -1 do begin + for i := 0 to frmSettings.lvPlugins.Items.Count - 1 do begin if frmSettings.lvPlugins.Items[i].Data <> nil then eSavedFiles.Add('LOADED ' + frmSettings.lvPlugins.Items[i].SubItems[0]) else - eSavedFiles.Add('UNLOADED ' + frmSettings.lvPlugins.Items[i].SubItems[0]); + eSavedFiles.Add('UNLOADED ' + frmSettings.lvPlugins.Items[i].SubItems[0]); end; - eSavedFiles.SaveToFile(ExtractFilePath(ParamStr(0)) + 'config\Plugins.cfg'); + eSavedFiles.SaveToFile(ExtractFilePath(ParamStr(0)) + 'config\Plugins.cfg'); eSavedFiles.Clear; if frmClose.trvFiles.Items.Count <> 0 then begin frmClose.cmdSave.Caption := lCloseCaption; if (frmClose.ShowModal = mrOk) then begin if frmClose.cmdSave.Caption = lSaveCaption then begin - for i := 0 to frmClose.trvFiles.Items.Count -1 do begin + for i := 0 to frmClose.trvFiles.Items.Count - 1 do begin { Pawn Projects } if frmClose.trvFiles.Items[i].Text = tsMain.Items[0].Caption then begin with frmClose.trvFiles.Items[i] do begin - for k := 0 to Count -1 do begin + for k := 0 to Count - 1 do begin if frmClose.trvFiles.Checked[Item[k]] then begin - eItem := TDocument(PawnProjects.Items[StrToInt(Copy(Item[k].Text, 1, Pos('.', Item[k].Text) -1)) -1]); + eItem := TDocument(PawnProjects.Items[StrToInt(Copy(Item[k].Text, 1, Pos('.', Item[k].Text) - 1)) - 1]); // Process item here if not eItem.Untitled then eItem.Save @@ -1530,9 +1538,9 @@ begin { C++ Projects } if frmClose.trvFiles.Items[i].Text = tsMain.Items[1].Caption then begin with frmClose.trvFiles.Items[i] do begin - for k := 0 to Count -1 do begin + for k := 0 to Count - 1 do begin if frmClose.trvFiles.Checked[Item[k]] then begin - eItem := TDocument(CPPProjects.Items[StrToInt(Copy(Item[k].Text, 1, Pos('.', Item[k].Text) -1)) -1]); + eItem := TDocument(CPPProjects.Items[StrToInt(Copy(Item[k].Text, 1, Pos('.', Item[k].Text) - 1)) - 1]); // Process item here if not eItem.Untitled then eItem.Save @@ -1555,9 +1563,9 @@ begin { Other Projects } if frmClose.trvFiles.Items[i].Text = tsMain.Items[2].Caption then begin with frmClose.trvFiles.Items[i] do begin - for k := 0 to Count -1 do begin + for k := 0 to Count - 1 do begin if frmClose.trvFiles.Checked[Item[k]] then begin - eItem := TDocument(OtherProjects.Items[StrToInt(Copy(Item[k].Text, 1, Pos('.', Item[k].Text) -1)) -1]); + eItem := TDocument(OtherProjects.Items[StrToInt(Copy(Item[k].Text, 1, Pos('.', Item[k].Text) - 1)) - 1]); // Process item here if not eItem.Untitled then eItem.Save @@ -1580,34 +1588,33 @@ begin end; end; Application.Terminate; - Started := False; end else begin Action := caNone; exit; end; end - else begin + else Application.Terminate; - Started := False; - end; if eSavedFiles.Count = 0 then begin - for i := 0 to PawnProjects.Count -1 do begin + for i := 0 to PawnProjects.Count - 1 do begin if (not TDocument(PawnProjects.Items[i]).Untitled) then eSavedFiles.Add(TDocument(PawnProjects.Items[i]).FileName); end; - for i := 0 to CPPProjects.Count -1 do begin + for i := 0 to CPPProjects.Count - 1 do begin if (not TDocument(CPPProjects.Items[i]).Untitled) then eSavedFiles.Add(TDocument(CPPProjects.Items[i]).FileName); end; - for i := 0 to OtherProjects.Count -1 do begin + for i := 0 to OtherProjects.Count - 1 do begin if (not TDocument(OtherProjects.Items[i]).Untitled) then eSavedFiles.Add(TDocument(OtherProjects.Items[i]).FileName); end; end; eSavedFiles.SaveToFile(ExtractFilePath(ParamStr(0)) + 'config\Cache.cfg'); eSavedFiles.Free; + + Started := False; end; procedure TfrmMain.trvExplorerDblClick(Sender: TObject); @@ -1616,7 +1623,7 @@ begin if (trvExplorer.Selected.ImageIndex <> 42) and (trvExplorer.Selected.ImageIndex <> 43) then begin sciEditor.GotoLineEnsureVisible(Integer(trvExplorer.Selected.Data)); sciEditor.SetFocus; - UpdateCI; + UpdateCI(frmMain.sciEditor.GetCurrentLineNumber); end; end; end; @@ -1630,7 +1637,7 @@ begin mnuCompile.Visible := True; mnuRegisterPluginsIniLocal.Enabled := True; mnuRegisterPluginsIniWeb.Enabled := True; - UpdateCI; + UpdateCI(frmMain.sciEditor.GetCurrentLineNumber); end; procedure TfrmMain.tiCPPClick(Sender: TObject); @@ -1666,12 +1673,12 @@ begin end; procedure TfrmMain.mnuHudmessageClick(Sender: TObject); -function Dot(eIn: String): String; -begin - Result := StringReplace(eIn, ',', '.', [rfReplaceAll]); -end; + function Dot(eIn: string): string; + begin + Result := StringReplace(eIn, ',', '.', [rfReplaceAll]); + end; -var eStr: String; +var eStr: string; begin frmHudMsgGenerator.chkXCenter.Checked := False; frmHudMsgGenerator.chkYCenter.Checked := False; @@ -1686,7 +1693,7 @@ begin if frmHudMsgGenerator.ShowModal = mrOk then begin eStr := Format(GetIndents + 'set_hudmessage(%u, %u, %u, %s, %s, 0, 6.0, %s)', [GetRValue(frmHudMsgGenerator.CurrColor), GetGValue(frmHudMsgGenerator.CurrColor), GetBValue(frmHudMsgGenerator.CurrColor), Dot(frmHudMsgGenerator.txtXPos.Text), Dot(frmHudMsgGenerator.txtYPos.Text), Dot(frmHudMsgGenerator.txtTimeToShow.Text)]); eStr := eStr + #13#10 + GetIndents + 'show_hudmessage(id, "' + frmHudMsgGenerator.txtText.Text + '")'; - sciEditor.Lines.Insert(sciEditor.GetCurrentLineNumber, eStr); + sciEditor.Lines.Insert(sciEditor.GetCurrentLineNumber, eStr); end; end; @@ -1722,7 +1729,7 @@ end; procedure TfrmMain.lstOutputDblClick(Sender: TObject); var eLine: Integer; - eStr: String; + eStr: string; begin if not Plugin_OutputDblClick(lstOutput.ItemIndex) then exit; @@ -1750,7 +1757,7 @@ end; procedure TfrmMain.SetErrorLine(eLine: Integer); begin - eLine := eLine -1; + eLine := eLine - 1; sciEditor.SetFocus; sciEditor.SelLength := 0; sciEditor.GotoLineEnsureVisible(eLine); @@ -1775,9 +1782,9 @@ begin i := sciEditor.SelLength; sciEditor.SelLength := 0; - sciEditor.SelStart := sciEditor.SelStart +i; + sciEditor.SelStart := sciEditor.SelStart + i; end; - UpdateCI; + UpdateCI(frmMain.sciEditor.GetCurrentLineNumber); end; procedure TfrmMain.lstOutputEnter(Sender: TObject); @@ -1791,7 +1798,7 @@ begin i := sciEditor.SelLength; sciEditor.SelLength := 0; - sciEditor.SelStart := sciEditor.SelStart +i; + sciEditor.SelStart := sciEditor.SelStart + i; end; end; @@ -1814,29 +1821,29 @@ begin end; procedure TfrmMain.mnuRegisterPluginsIniLocalClick(Sender: TObject); -function RemComments(eLine: String): String; -var a, b: integer; -begin - if Length(eLine) > 0 then begin - b := 0; - for a := 1 to Length(eLine) -1 do begin - if (eLine[a] = ';') or (eLine[a] = '/') then begin - b := a; - break; + function RemComments(eLine: string): string; + var a, b: integer; + begin + if Length(eLine) > 0 then begin + b := 0; + for a := 1 to Length(eLine) - 1 do begin + if (eLine[a] = ';') or (eLine[a] = '/') then begin + b := a; + break; + end; end; - end; - if (b = 0) and (Pos(' debug', LowerCase(eLine)) <> 0) then - b := Pos(' debug', LowerCase(eLine)); - if b <> 0 then - eLine := Trim(Copy(eLine, 1, b -1)); + if (b = 0) and (Pos(' debug', LowerCase(eLine)) <> 0) then + b := Pos(' debug', LowerCase(eLine)); + if b <> 0 then + eLine := Trim(Copy(eLine, 1, b - 1)); + end; + Result := Trim(eLine); end; - Result := Trim(eLine); -end; var eStr: TStringList; - i: integer; - eFound: Boolean; + i: integer; + eFound: Boolean; begin if ActiveDoc.Untitled then begin MessageBox(Handle, PChar(lNoUntitledRegister), PChar(Application.Title), MB_ICONINFORMATION); @@ -1848,7 +1855,7 @@ begin eStr := TStringList.Create; eStr.LoadFromFile(GetAMXXDir(True) + 'configs\plugins.ini'); - for i := 0 to eStr.Count -1 do begin + for i := 0 to eStr.Count - 1 do begin if (Copy(eStr[i], 1, 1) <> ';') and (Copy(eStr[i], 1, 2) <> '//') then begin if LowerCase(RemComments(eStr[i])) = LowerCase(ChangeFileExt(ExtractFileName(ActiveDoc.FileName), '.amxx')) then begin eFound := True; @@ -1870,25 +1877,25 @@ begin end; procedure TfrmMain.mnuRegisterPluginsIniWebClick(Sender: TObject); -function RemComments(eLine: String): String; -var a, b: integer; -begin - if Length(eLine) > 0 then begin - b := 0; - for a := 1 to Length(eLine) -1 do begin - if (eLine[a] = ';') or (eLine[a] = '/') then begin - b := a; - break; + function RemComments(eLine: string): string; + var a, b: integer; + begin + if Length(eLine) > 0 then begin + b := 0; + for a := 1 to Length(eLine) - 1 do begin + if (eLine[a] = ';') or (eLine[a] = '/') then begin + b := a; + break; + end; end; + eLine := Trim(Copy(eLine, 1, b - 1)); end; - eLine := Trim(Copy(eLine, 1, b -1)); + Result := eLine; end; - Result := eLine; -end; var eStr: TStringList; - i: integer; - eFound: Boolean; + i: integer; + eFound: Boolean; begin if ActiveDoc.Untitled then begin MessageBox(Handle, PChar(lNoUntitledRegister), PChar(Application.Title), MB_ICONINFORMATION); @@ -1913,7 +1920,7 @@ begin eStr := TStringList.Create; eStr.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'plugins.ini'); - for i := 0 to eStr.Count -1 do begin + for i := 0 to eStr.Count - 1 do begin if (Copy(eStr[i], 1, 1) <> ';') and (Copy(eStr[i], 1, 2) <> '//') then begin if LowerCase(RemComments(eStr[i])) = LowerCase(ChangeFileExt(ExtractFileName(ActiveDoc.FileName), '.amxx')) then begin eFound := True; @@ -1930,19 +1937,19 @@ begin else begin eStr.Add(ChangeFileExt(ExtractFileName(ActiveDoc.FileName), '.amxx')); eStr.SaveToFile(ExtractFilePath(ParamStr(0)) + 'plugins.ini'); - Screen.Cursor := crDefault; - MessageBox(Handle, PChar(lSuccessfulRegistered), PChar(Application.Title), MB_ICONINFORMATION); end; - eStr.Destroy; + eStr.Free; try IdFTP.TransferType := ftASCII; IdFTP.Put(ExtractFilePath(ParamStr(0)) + 'plugins.ini', 'plugins.ini'); IdFTP.Disconnect; + MessageBox(Handle, PChar(lSuccessfulRegistered), PChar(Application.Title), MB_ICONINFORMATION); except Screen.Cursor := crDefault; MessageBox(Handle, PChar(lFailedUpdatePluginsIni), PChar(Application.Title), MB_ICONERROR); end; + Screen.Cursor := crDefault; end; procedure TfrmMain.sciAutoCompleteBeforeShow(Sender: TObject; @@ -1958,6 +1965,7 @@ begin if (Started) and (Assigned(GetStyleAt(sciEditor.SelStart))) then begin eCurrStyle := GetStyleAt(sciEditor.SelStart).StyleNumber; + if (ActiveDoc.Highlighter = 'Pawn') or (ActiveDoc.Highlighter = 'C++') then begin CancelDisplay := (eCurrStyle = 12) or (eCurrStyle = 1) or (eCurrStyle = 2) or (eCurrStyle = 3) or (eCurrStyle = 15); CancelDisplay := (CancelDisplay) or (Pos('#', Trim(sciEditor.Lines[sciEditor.GetCurrentLineNumber])) = 1); @@ -1968,12 +1976,12 @@ end; procedure TfrmMain.mnuMOTDGeneratorClick(Sender: TObject); var eStr: TStringList; - i: integer; + i: integer; begin if (GetCurrLang.Name = 'HTML') then begin eStr := TStringList.Create; eStr.Text := StringReplace(sciEditor.Lines.Text, #9, '', [rfReplaceAll]); - for i := 0 to eStr.Count -1 do + for i := 0 to eStr.Count - 1 do eStr[i] := '"' + eStr[i] + '\n" +'; frmMOTDGen.txtMOTD.Lines.Assign(eStr); eStr.Destroy; @@ -2016,8 +2024,8 @@ begin try case tsMain.ActiveTabIndex of 0: Collection := PawnProjects; // Pawn - 1: Collection := CPPProjects; // C++ - else Collection := OtherProjects; // Other + 1: Collection := CPPProjects; // C++ + else Collection := OtherProjects; // Other end; if tsDocuments.Items.IndexOf(SelectedTab) <> -1 then @@ -2041,87 +2049,6 @@ begin end; end; -procedure TfrmMain.jviCodeItemValueChanged(Sender: TObject; - Item: TJvCustomInspectorItem); -function FindItem(eParent: TJvCustomInspectorItem; eName: String): TJvCustomInspectorItem; -var i: integer; -begin - Result := nil; - for i := 0 to eParent.Count -1 do begin - if eParent.Items[i].DisplayName = eName then - Result := eParent.Items[i]; - end; -end; - -var eLine, eTemp: String; - i: integer; -begin - if (Assigned(Item.Parent)) then begin - // Variables and Constants - if (Pos('Constant', Item.Parent.DisplayName) = 1) or (Pos('Variable', Item.Parent.DisplayName) = 1) then begin - eLine := eFormatSettings; - for i := 0 to jviCode.Root.Count -1 do begin - eTemp := ''; - if Pos('Constant', jviCode.Root.Items[i].DisplayName) = 1 then begin - if (FindItem(jviCode.Root.Items[i], 'Name').DisplayValue <> '') then begin - eTemp := eTemp + ', '; - if Assigned(FindItem(jviCode.Root.Items[i], 'Type')) then - eTemp := eTemp + FindItem(jviCode.Root.Items[i], 'Type').DisplayValue + ':'; - eTemp := eTemp + FindItem(jviCode.Root.Items[i], 'Name').DisplayValue; - eTemp := eTemp + ' = ' + FindItem(jviCode.Root.Items[i], 'Value').DisplayValue; - end; - end - else begin - if (FindItem(jviCode.Root.Items[i], 'Name').DisplayValue <> '') then begin - eTemp := eTemp + ', '; - if Assigned(FindItem(jviCode.Root.Items[i], 'Type')) then - eTemp := eTemp + FindItem(jviCode.Root.Items[i], 'Type').DisplayValue + ':'; - eTemp := eTemp + FindItem(jviCode.Root.Items[i], 'Name').DisplayValue; - end; - end; - - if jviCode.Root.Count = 1 then - eLine := StringReplace(eLine, '-' + jviCode.Root.Items[i].DisplayName + ' 1-', eTemp, []) - else - eLine := StringReplace(eLine, '-' + jviCode.Root.Items[i].DisplayName + '-', eTemp, []); - end; - Delete(eLine, 1, 2); - eLine := GetIndents + 'new ' + eLine; - sciEditor.Lines[sciEditor.GetCurrentLineNumber] := eLine; - end - // If-Conditions - else if Pos('If-Condition', Item.Parent.DisplayName) = 1 then begin - eLine := ''; - for i := 0 to jviCode.Root.Count -1 do begin - eLine := eLine + FindItem(jviCode.Root.Items[i], 'Condition').DisplayValue; - if i <> jviCode.Root.Count -1 then - eLine := eLine + #32 + FindItem(jviCode.Root.Items[i], 'Operator').DisplayValue + #32; - end; - eLine := StringReplace(eFormatSettings, #1#3#3#7, '(' + eLine + ')', []); - sciEditor.Lines[sciEditor.GetCurrentLineNumber] := eLine; - end - // Defined - else if Item.Parent.DisplayName = 'Defined' then begin - eLine := GetIndents + '#define '; - eLine := eLine + Item.Parent.Items[0].DisplayValue; - eLine := eLine + ' ' + Item.Parent.Items[1].DisplayValue; - sciEditor.Lines[sciEditor.GetCurrentLineNumber] := eLine; - end - // Included - else if Item.Parent.DisplayName = 'Included' then begin - eLine := StringReplace(eFormatSettings, '-Filename-', Item.DisplayValue, []); - eLine := GetIndents + eLine; - sciEditor.Lines[sciEditor.GetCurrentLineNumber] := eLine; - end - // Assignment - else if Item.Parent.DisplayName = 'Assignment' then begin - eLine := GetIndents + Item.Parent.Items[0].DisplayValue; - eLine := eLine + #32 + Item.Parent.Items[2].DisplayValue + #32 + Item.Parent.Items[1].DisplayValue; - sciEditor.Lines[sciEditor.GetCurrentLineNumber] := eLine; - end; - end; -end; - procedure TfrmMain.mnuMenuGeneratorClick(Sender: TObject); begin frmMenuGenerator.ShowModal; @@ -2190,7 +2117,7 @@ end; procedure TfrmMain.OnCustomClick(Sender: TObject); begin - Plugin_CustomItemClick((Sender As TTBXCustomItem).Caption); + Plugin_CustomItemClick((Sender as TTBXCustomItem).Caption); end; procedure TfrmMain.pnlCodeInspectorVisibleChanged(Sender: TObject); @@ -2215,8 +2142,8 @@ end; procedure TfrmMain.mnuConnectionGenClick(Sender: TObject); var eIncluded: Integer; - eRegLine: Integer; - eIndents: String; + eRegLine: Integer; + eIndents: string; begin eRegLine := PluginInitLine; if (frmConnGen.ShowModal = mrOk) and (eRegLine <> -1) then begin @@ -2224,23 +2151,23 @@ begin eIncluded := GetLast('#include', True); if eIncluded = -1 then eIncluded := 0; - sciEditor.Lines.Insert(eIncluded +1, 'new sck' + frmConnGen.txtName.Text); - eRegLine := eRegLine +1; + sciEditor.Lines.Insert(eIncluded + 1, 'new sck' + frmConnGen.txtName.Text); + eRegLine := eRegLine + 1; AddIfDoesntExist('sockets'); // CVar stuff - eIndents := GetIndents(eRegLine +1); - sciEditor.Lines.Insert(eRegLine +2, eIndents + '/* Init CVars for the socket "' + frmConnGen.txtName.Text + '" */'); - sciEditor.Lines.Insert(eRegLine +3, eIndents + 'if (cvar_exists("amx_' + frmConnGen.txtName.Text + '_socket")) {'); - sciEditor.Lines.Insert(eRegLine +4, eIndents + #9 + 'sck' + frmConnGen.txtName.Text + ' = get_cvar_num("amx_' + frmConnGen.txtName.Text + '_socket")'); - sciEditor.Lines.Insert(eRegLine +5, eIndents + #9 + 'read_' + frmConnGen.txtName.Text + '()'); - sciEditor.Lines.Insert(eRegLine +6, eIndents + '}'); - sciEditor.Lines.Insert(eRegLine +7, eIndents + 'else'); - sciEditor.Lines.Insert(eRegLine +8, eIndents + #9 + 'register_cvar("amx_' + frmConnGen.txtName.Text + '_socket", "0", FCVAR_PROTECTED&FCVAR_UNLOGGED)'); - sciEditor.Lines.Insert(eRegLine +9, eIndents + '/* End */'); + eIndents := GetIndents(eRegLine + 1); + sciEditor.Lines.Insert(eRegLine + 2, eIndents + '/* Init CVars for the socket "' + frmConnGen.txtName.Text + '" */'); + sciEditor.Lines.Insert(eRegLine + 3, eIndents + 'if (cvar_exists("amx_' + frmConnGen.txtName.Text + '_socket")) {'); + sciEditor.Lines.Insert(eRegLine + 4, eIndents + #9 + 'sck' + frmConnGen.txtName.Text + ' = get_cvar_num("amx_' + frmConnGen.txtName.Text + '_socket")'); + sciEditor.Lines.Insert(eRegLine + 5, eIndents + #9 + 'read_' + frmConnGen.txtName.Text + '()'); + sciEditor.Lines.Insert(eRegLine + 6, eIndents + '}'); + sciEditor.Lines.Insert(eRegLine + 7, eIndents + 'else'); + sciEditor.Lines.Insert(eRegLine + 8, eIndents + #9 + 'register_cvar("amx_' + frmConnGen.txtName.Text + '_socket", "0", FCVAR_PROTECTED&FCVAR_UNLOGGED)'); + sciEditor.Lines.Insert(eRegLine + 9, eIndents + '/* End */'); // Functions sciEditor.Lines.Add(''); - sciEditor.Lines.Add('/* Socket ' + frmConnGen.txtName.Text + ' */'); - sciEditor.Lines.Add(''); + sciEditor.Lines.Add('/* Socket ' + frmConnGen.txtName.Text + ' */'); + sciEditor.Lines.Add(''); sciEditor.Lines.Add('public connect_' + frmConnGen.txtName.Text + '() {'); sciEditor.Lines.Add(#9 + 'new error = 0'); sciEditor.Lines.Add(#9 + 'sck' + frmConnGen.txtName.Text + ' = socket_open("' + frmConnGen.txtHost.Text + '", ' + frmConnGen.txtPort.Text + ', ' + frmConnGen.cboProtocol.Text + ', error)'); @@ -2248,7 +2175,7 @@ begin sciEditor.Lines.Add(#9 + #9 + '/* Connect successful */'); sciEditor.Lines.Add(#9 + #9 + 'read_' + frmConnGen.txtName.Text + '()'); sciEditor.Lines.Add(#9 + '}'); - sciEditor.Lines.Add(#9 + 'else {'); + sciEditor.Lines.Add(#9 + 'else {'); sciEditor.Lines.Add(#9 + #9 + 'switch (error) {'); sciEditor.Lines.Add(#9 + #9 + #9 + 'case 1: { /* Error creating socket */ }'); sciEditor.Lines.Add(#9 + #9 + #9 + 'case 2: { /* Could not resolve hostname */ }'); @@ -2297,19 +2224,45 @@ begin end; procedure TfrmMain.OnCopyData(var Msg: TWMCopyData); -var eData: String; +procedure RemoveItemFromTreeView(eCaption: String; eParent: TTreeNode = nil); +var i: integer; +begin + if Assigned(eParent) then begin + for i := 0 to eParent.Count -1 do begin + if eParent.Item[i].Text = eCaption then begin + eParent.Item[i].Free; + break; + end + else if eParent.Item[i].Count > 0 then + RemoveItemFromTreeView(eCaption, eParent.Item[i]); + end; + end + else begin + for i := 0 to frmSettings.trvSettings.Items.Count -1 do begin + if frmSettings.trvSettings.Items[i].Text = eCaption then begin + frmSettings.trvSettings.Items[i].Free; + break; + end + else if frmSettings.trvSettings.Items[i].Count > 0 then + RemoveItemFromTreeView(eCaption, frmSettings.trvSettings.Items[i]); + end; + end; +end; + +var eData: string; eIntData: Integer; eMessage: Integer; eBMP: TBitmap; - eTemp: String; + eTemp: string; eItem: TSpTBXItem; ePage: TJvStandardPage; + ePanel: TPanel; eStr: TStringList; eValues: array of string; i: integer; begin - eData := String(PChar(Msg.CopyDataStruct.lpData)); + eData := string(PChar(Msg.CopyDataStruct.lpData)); eIntData := Msg.CopyDataStruct.dwData; eMessage := Msg.From; try @@ -2318,380 +2271,397 @@ begin SCM_SHOWPROGRESS: ShowProgress(eIntData = 1); SCM_HIDEPROGRESS: HideProgress; SCM_UPDATEPROGRESS: begin - pbLoading.Position := eIntData; - SetProgressStatus(eData); - end; + pbLoading.Position := eIntData; + SetProgressStatus(eData); + end; SCM_LOADCODESNIPPETS: LoadCodeSnippets(eData); SCM_CODESNIPPETCLICK: begin - if Plugin_CodeSnippetClick(eData, GetCat, GetSnippet(GetCat, eData)) then - sciEditor.SelText := GetSnippet(GetCat, eData); - end; + if Plugin_CodeSnippetClick(eData, GetCat, GetSnippet(GetCat, eData)) then + sciEditor.SelText := GetSnippet(GetCat, eData); + end; SCM_MIRC_CMD: mIRCDDE('mIRC', 'COMMAND', eData); SCM_RELOADINI: ReloadIni; SCM_SELECTLANGUAGE: SelectLanguage(eData); SCM_LOADFILE: begin - odOpen.FileName := eData; - mnuOpenClick(nil); - end; + odOpen.FileName := eData; + mnuOpenClick(nil); + end; SCM_CURRPROJECTS: Msg.Result := tsMain.ActiveTabIndex; SCM_COMPILE: mnuDoCompile.Click; SCM_COMPILE_UPLOAD: mnuCompileAndUpload.Click; SCM_COMPILE_STARTHL: mnuCompileAndStartHL.Click; SCM_MENU_LOADIMAGE: begin - eBMP := TBitmap.Create; - eBMP.LoadFromFile(eData); - if eIntData = -1 then - Msg.Result := ilImages.Add(eBMP, nil) - else - Msg.Result := ilImages.AddMasked(eBMP, eIntData); - eBMP.Destroy; - end; + eBMP := TBitmap.Create; + eBMP.LoadFromFile(eData); + if eIntData = -1 then + Msg.Result := ilImages.Add(eBMP, nil) + else + Msg.Result := ilImages.AddMasked(eBMP, eIntData); + eBMP.Destroy; + end; SCM_MENU_ADDITEM: begin - if Pos('->', eData) <> 0 then begin - eTemp := Copy(eData, 1, Pos('->', eData) -1); - eData := Copy(eData, Pos('->', eData) +2, Length(eData)); - end - else - eTemp := ''; + if Pos('->', eData) <> 0 then begin + eTemp := Copy(eData, 1, Pos('->', eData) - 1); + eData := Copy(eData, Pos('->', eData) + 2, Length(eData)); + end + else + eTemp := ''; - eItem := TSpTBXItem.Create(tbxMenu.Items); - with eItem do begin - Caption := eData; - Images := ilImages; - ImageIndex := eIntData; - OnClick := OnCustomClick; + eItem := TSpTBXItem.Create(tbxMenu.Items); + with eItem do begin + Caption := eData; + Images := ilImages; + ImageIndex := eIntData; + OnClick := OnCustomClick; + end; + + if Assigned(GetMenuItem(eTemp)) then + GetMenuItem(eTemp).Add(eItem) + else + tbxMenu.Items.Add(eItem); end; - - if Assigned(GetMenuItem(eTemp)) then - GetMenuItem(eTemp).Add(eItem) - else - tbxMenu.Items.Add(eItem); - end; SCM_MENU_ADDSUBITEM: begin - if Pos('->', eData) <> 0 then begin - eTemp := Copy(eData, 1, Pos('->', eData) -1); - eData := Copy(eData, Pos('->', eData) +2, Length(eData)); - end - else - eTemp := ''; - - eItem := TSpTBXSubMenuItem.Create(tbxMenu.Items); - with eItem do begin - Caption := eData; - Images := ilImages; - ImageIndex := eIntData; - OnClick := OnCustomClick; + if Pos('->', eData) <> 0 then begin + eTemp := Copy(eData, 1, Pos('->', eData) - 1); + eData := Copy(eData, Pos('->', eData) + 2, Length(eData)); + end + else + eTemp := ''; + + eItem := TSpTBXSubMenuItem.Create(tbxMenu.Items); + with eItem do begin + Caption := eData; + Images := ilImages; + ImageIndex := eIntData; + OnClick := OnCustomClick; + end; + + if Assigned(GetMenuItem(eTemp)) then + GetMenuItem(eTemp).Add(eItem) + else + tbxMenu.Items.Add(eItem); end; - - if Assigned(GetMenuItem(eTemp)) then - GetMenuItem(eTemp).Add(eItem) - else - tbxMenu.Items.Add(eItem); - end; SCM_MENU_FAKECLICK: begin - if Assigned(GetMenuItem(eData)) then - GetMenuItem(eData).Click - else - Msg.Result := 0; - end; + if Assigned(GetMenuItem(eData)) then + GetMenuItem(eData).Click + else + Msg.Result := 0; + end; SCM_MENU_SHOWITEM: begin - if Assigned(GetMenuItem(eData)) then - GetMenuItem(eData).Visible := True - else - Msg.Result := 0; - end; + if Assigned(GetMenuItem(eData)) then + GetMenuItem(eData).Visible := True + else + Msg.Result := 0; + end; SCM_MENU_HIDEITEM: begin - if Assigned(GetMenuItem(eData)) then - GetMenuItem(eData).Visible := False - else - Msg.Result := 0; - end; + if Assigned(GetMenuItem(eData)) then + GetMenuItem(eData).Visible := False + else + Msg.Result := 0; + end; SCM_PLUGIN_LOAD: begin - if eData <> '' then begin - Msg.Result := 0; - for i := 0 to frmSettings.lvPlugins.Items.Count -1 do begin - if LowerCase(frmSettings.lvPlugins.Items[i].SubItems[0]) = LowerCase(eData) then begin - LoadPlugin(frmSettings.lvPlugins.Items[i]); - Msg.Result := 1; - break; + if eData <> '' then begin + Msg.Result := 0; + for i := 0 to frmSettings.lvPlugins.Items.Count - 1 do begin + if LowerCase(frmSettings.lvPlugins.Items[i].SubItems[0]) = LowerCase(eData) then begin + LoadPlugin(frmSettings.lvPlugins.Items[i]); + Msg.Result := 1; + break; + end; end; - end; - end - else - LoadPlugin(frmSettings.lvPlugins.Items[eIntData]); - end; + end + else + LoadPlugin(frmSettings.lvPlugins.Items[eIntData]); + end; SCM_PLUGIN_UNLOAD: begin - if eData <> '' then begin - Msg.Result := 0; - for i := 0 to frmSettings.lvPlugins.Items.Count -1 do begin - if LowerCase(frmSettings.lvPlugins.Items[i].SubItems[0]) = LowerCase(eData) then begin - UnloadPlugin(frmSettings.lvPlugins.Items[i]); - Msg.Result := 1; - break; + if eData <> '' then begin + Msg.Result := 0; + for i := 0 to frmSettings.lvPlugins.Items.Count - 1 do begin + if LowerCase(frmSettings.lvPlugins.Items[i].SubItems[0]) = LowerCase(eData) then begin + UnloadPlugin(frmSettings.lvPlugins.Items[i]); + Msg.Result := 1; + break; + end; end; - end; - end - else - UnloadPlugin(frmSettings.lvPlugins.Items[eIntData]); - end; + end + else + UnloadPlugin(frmSettings.lvPlugins.Items[eIntData]); + end; SCM_SETTINGS_CREATEPAGE: begin - if Pos('->', eData) <> 0 then begin - eTemp := Copy(eData, 1, Pos('->', eData) -1); - eData := Copy(eData, Pos('->', eData) +2, Length(eData)); - end - else - eTemp := ''; + if Pos('->', eData) <> 0 then begin + eTemp := Copy(eData, 1, Pos('->', eData) - 1); + eData := Copy(eData, Pos('->', eData) + 2, Length(eData)); + end + else + eTemp := ''; - ePage := TJvStandardPage.Create(frmSettings.jplSettings); - ePage.Caption := eData; - TJvPageIndexNode(frmSettings.trvSettings.Items.AddChild(FindSettingsNode(eTemp), eData)).PageIndex := ePage.PageIndex; - - Msg.Result := ePage.Handle; + ePage := TJvStandardPage.Create(frmSettings.jplSettings); + ePage.Caption := eData; + TJvPageIndexNode(frmSettings.trvSettings.Items.AddChild(FindSettingsNode(eTemp), eData)).PageIndex := ePage.PageIndex; + ePanel := TPanel.Create(ePage); + ePanel.BevelInner := bvNone; + ePanel.BevelOuter := bvNone; + ePanel.Align := alClient; + + Msg.Result := ePanel.Handle; + end; + SCM_SETTINGS_REMOVEPAGE: begin + Msg.Result := 0; + for i := 0 to frmSettings.jplSettings.PageCount -1 do begin + if TJvStandardPage(frmSettings.jplSettings.Pages[i]).Caption = eData then begin + TJvStandardPage(frmSettings.jplSettings.Pages[i]).Free; + Msg.Result := 1; + break; + end; + end; + + if Msg.Result = 1 then + RemoveItemFromTreeView(eData); end; SCM_CODEINSPECTOR_CLEAR: jviCode.Root.Clear; SCM_CODEINSPECTOR_ADD: begin - eStr := TStringList.Create; - eStr.Text := eData; - if eStr.Count = 3 then - AddField(eStr[0], eStr[1], eStr[2]) - else - Msg.Result := 0; - eStr.Destroy; - end; + eStr := TStringList.Create; + eStr.Text := eData; + if eStr.Count = 3 then + AddField(eStr[0], eStr[1], eStr[2]) + else + Msg.Result := 0; + eStr.Destroy; + end; SCM_CODEINSPECTOR_ADDCOMBO: begin - eStr := TStringList.Create; - eStr.Text := eData; - if eStr.Count > 3 then begin - SetLength(eValues, eStr.Count -2); - for i := 0 to eStr.Count -4 do - eValues[i] := eStr[i +3]; - AddCombo(eStr[0], eStr[1], eStr[2], eValues); - end - else - Msg.Result := 0; - eStr.Destroy; - end; + eStr := TStringList.Create; + eStr.Text := eData; + if eStr.Count > 3 then begin + SetLength(eValues, eStr.Count - 2); + for i := 0 to eStr.Count - 4 do + eValues[i] := eStr[i + 3]; + AddCombo(eStr[0], eStr[1], eStr[2], eValues); + end + else + Msg.Result := 0; + eStr.Destroy; + end; SCM_CODEINSPECTOR_SETVALUE: begin - eStr := TStringList.Create; - eStr.Text := eData; - if eStr.Count = 2 then begin - if Assigned(GetCIItem(eStr[0])) then - GetCIItem(eStr[0]).DisplayValue := eStr[1] + eStr := TStringList.Create; + eStr.Text := eData; + if eStr.Count = 2 then begin + if Assigned(GetCIItem(eStr[0])) then + GetCIItem(eStr[0]).DisplayValue := eStr[1] + else + Msg.Result := 0; + end else Msg.Result := 0; - end - else - Msg.Result := 0; - end; + end; SCM_CODEINSPECTOR_SETNAME: begin - eStr := TStringList.Create; - eStr.Text := eData; - if eStr.Count = 2 then begin - if Assigned(GetCIItem(eStr[0])) then - GetCIItem(eStr[0]).DisplayName := eStr[1] + eStr := TStringList.Create; + eStr.Text := eData; + if eStr.Count = 2 then begin + if Assigned(GetCIItem(eStr[0])) then + GetCIItem(eStr[0]).DisplayName := eStr[1] + else + Msg.Result := 0; + end else Msg.Result := 0; - end - else - Msg.Result := 0; - end; + end; SCM_CODEINSPECTOR_GETVALUE: begin - if Assigned(GetCIItem(eData)) then - Msg.Result := Integer(PChar(GetCIItem(eData).DisplayValue)) - else - Msg.Result := Integer(PChar('')); - end; + if Assigned(GetCIItem(eData)) then + Msg.Result := Integer(PChar(GetCIItem(eData).DisplayValue)) + else + Msg.Result := Integer(PChar('')); + end; SCM_CODEINSPECTOR_GETNAME: begin - if Assigned(GetCIItemByValue(eData)) then - Msg.Result := Integer(PChar(GetCIItemByValue(eData).DisplayName)) - else - Msg.Result := Integer(PChar('')); - end; + if Assigned(GetCIItemByValue(eData)) then + Msg.Result := Integer(PChar(GetCIItemByValue(eData).DisplayName)) + else + Msg.Result := Integer(PChar('')); + end; SCM_CODEINSPECTOR_COUNT: Msg.Result := jviCode.Root.Count; SCM_CODEINSPECTOR_BEGINUPDATE: jviCode.BeginUpdate; SCM_CODEINSPECTOR_ENDUPDATE: jviCode.EndUpdate; SCM_CODEINSPECTOR_DELETE: begin - if Assigned(GETCIItem(eData)) then - jviCode.Root.Delete(GETCIItem(eData)) - else - Msg.Result := 0; - end; - SCM_Pawn_NEWFILE: PawnProjects.Add(eData, ''); - SCM_Pawn_SAVEFILE: begin - if (eData = '') and (TDocument(PawnProjects.Items[eIntData]).Untitled) then - Msg.Result := 0 - else - PawnProjects.Save(eIntData, eData); - end; - SCM_Pawn_CLOSEFILE: PawnProjects.Close(eIntData); - SCM_Pawn_ISUNTITLED: begin - try - if TDocument(PawnProjects.Items[eIntData]).Untitled then - Msg.Result := 1 + if Assigned(GETCIItem(eData)) then + jviCode.Root.Delete(GETCIItem(eData)) else Msg.Result := 0; - except - Msg.Result := -1; end; - end; + SCM_Pawn_NEWFILE: PawnProjects.Add(eData, ''); + SCM_Pawn_SAVEFILE: begin + if (eData = '') and (TDocument(PawnProjects.Items[eIntData]).Untitled) then + Msg.Result := 0 + else + PawnProjects.Save(eIntData, eData); + end; + SCM_Pawn_CLOSEFILE: PawnProjects.Close(eIntData); + SCM_Pawn_ISUNTITLED: begin + try + if TDocument(PawnProjects.Items[eIntData]).Untitled then + Msg.Result := 1 + else + Msg.Result := 0; + except + Msg.Result := -1; + end; + end; SCM_Pawn_ACTIVATE: begin - if tsMain.ActiveTabIndex <> 0 then - ActivateProjects(0, eIntData = 1) - else - Msg.Result := 0; - end; + if tsMain.ActiveTabIndex <> 0 then + ActivateProjects(0, eIntData = 1) + else + Msg.Result := 0; + end; SCM_Pawn_ACTIVATEDOC: PawnProjects.Activate(eIntData, Pos('r', eData) <> 0, Pos('s', eData) <> 0); SCM_Pawn_GETNOTES: begin - if (tsMain.ActiveTabIndex = 0) and (tsDocuments.ActiveTabIndex = eIntData) then - Msg.Result := Integer(PChar(GetRTFText(rtfNotes))) - else - Msg.Result := Integer(PChar(TDocument(PawnProjects.Items[eIntData]).NotesText)); - end; + if (tsMain.ActiveTabIndex = 0) and (tsDocuments.ActiveTabIndex = eIntData) then + Msg.Result := Integer(PChar(GetRTFText(rtfNotes))) + else + Msg.Result := Integer(PChar(TDocument(PawnProjects.Items[eIntData]).NotesText)); + end; SCM_Pawn_SETNOTES: begin - if (tsMain.ActiveTabIndex = 0) and (tsDocuments.ActiveTabIndex = eIntData) then - SetRTFText(rtfNotes, eData) - else - TDocument(PawnProjects.Items[eIntData]).NotesText := eData; - end; + if (tsMain.ActiveTabIndex = 0) and (tsDocuments.ActiveTabIndex = eIntData) then + SetRTFText(rtfNotes, eData) + else + TDocument(PawnProjects.Items[eIntData]).NotesText := eData; + end; SCM_Pawn_GETFILENAME: Msg.Result := Integer(PChar(TDocument(PawnProjects.Items[eIntData]).FileName)); SCM_Pawn_GETTEXT: begin - if (tsMain.ActiveTabIndex = 0) and (tsDocuments.ActiveTabIndex = eIntData) then - Msg.Result := Integer(sciEditor.Lines.GetText) - else - Msg.Result := Integer(PChar(TDocument(PawnProjects.Items[eIntData]).Code)); - end; + if (tsMain.ActiveTabIndex = 0) and (tsDocuments.ActiveTabIndex = eIntData) then + Msg.Result := Integer(sciEditor.Lines.GetText) + else + Msg.Result := Integer(PChar(TDocument(PawnProjects.Items[eIntData]).Code)); + end; SCM_CPP_NEWFILE: begin - if eCPP then - CPPProjects.Add(eData) - else - Msg.Result := 0; - end; + if eCPP then + CPPProjects.Add(eData) + else + Msg.Result := 0; + end; SCM_CPP_SAVEFILE: begin - if eCPP then begin + if eCPP then begin + if (eData = '') and (TDocument(CPPProjects.Items[eIntData]).Untitled) then + Msg.Result := 0 + else + CPPProjects.Save(eIntData, eData); + end; + end; + SCM_CPP_CLOSEFILE: begin + if eCPP then + CPPProjects.Close(eIntData) + else + Msg.Result := 0; + end; + SCM_CPP_ISUNTITLED: begin + try + if TDocument(CPPProjects.Items[eIntData]).Untitled then + Msg.Result := 1 + else + Msg.Result := 0; + except + Msg.Result := -1; + end; + end; + SCM_CPP_ACTIVATE: begin + if (eCPP) and (tsMain.ActiveTabIndex <> 1) then + ActivateProjects(1, eIntData = 1) + else + Msg.Result := 0; + end; + SCM_CPP_ACTIVATEDOC: begin + if eCPP then + CPPProjects.Activate(eIntData, Pos('r', eData) <> 0, Pos('s', eData) <> 0) + else + Msg.Result := 0; + end; + SCM_CPP_ACTIVATEIDE: begin + eCPP := eIntData = 1; + if eCPP then begin + tiCPP.Enabled := True; + mnuNewHeaderCPP.Enabled := True; + mnuNewModule.Enabled := True; + mnuNewUnit.Enabled := True; + end + else begin + tiCPP.Enabled := False; + mnuNewHeaderCPP.Enabled := False; + mnuNewModule.Enabled := False; + mnuNewUnit.Enabled := False; + end; + end; + SCM_CPP_GETNOTES: begin + if (tsMain.ActiveTabIndex = 1) and (tsDocuments.ActiveTabIndex = eIntData) then + Msg.Result := Integer(PChar(GetRTFText(rtfNotes))) + else + Msg.Result := Integer(PChar(TDocument(CPPProjects.Items[eIntData]).NotesText)); + end; + SCM_CPP_SETNOTES: begin + if (tsMain.ActiveTabIndex = 1) and (tsDocuments.ActiveTabIndex = eIntData) then + SetRTFText(rtfNotes, eData) + else + TDocument(CPPProjects.Items[eIntData]).NotesText := eData; + end; + SCM_CPP_GETFILENAME: Msg.Result := Integer(PChar(TDocument(CPPProjects.Items[eIntData]).FileName)); + SCM_CPP_GETTEXT: begin + if (tsMain.ActiveTabIndex = 1) and (tsDocuments.ActiveTabIndex = eIntData) then + Msg.Result := Integer(sciEditor.Lines.GetText) + else + Msg.Result := Integer(PChar(TDocument(CPPProjects.Items[eIntData]).Code)); + end; + SCM_OTHER_NEWFILE: OtherProjects.Add(eData); + SCM_OTHER_SAVEFILE: begin if (eData = '') and (TDocument(CPPProjects.Items[eIntData]).Untitled) then Msg.Result := 0 else - CPPProjects.Save(eIntData, eData); + OtherProjects.Save(eIntData, eData); end; - end; - SCM_CPP_CLOSEFILE: begin - if eCPP then - CPPProjects.Close(eIntData) - else - Msg.Result := 0; - end; - SCM_CPP_ISUNTITLED: begin - try - if TDocument(CPPProjects.Items[eIntData]).Untitled then - Msg.Result := 1 - else - Msg.Result := 0; - except - Msg.Result := -1; - end; - end; - SCM_CPP_ACTIVATE: begin - if (eCPP) and (tsMain.ActiveTabIndex <> 1) then - ActivateProjects(1, eIntData = 1) - else - Msg.Result := 0; - end; - SCM_CPP_ACTIVATEDOC: begin - if eCPP then - CPPProjects.Activate(eIntData, Pos('r', eData) <> 0, Pos('s', eData) <> 0) - else - Msg.Result := 0; - end; - SCM_CPP_ACTIVATEIDE: begin - eCPP := eIntData = 1; - if eCPP then begin - tiCPP.Enabled := True; - mnuNewHeaderCPP.Enabled := True; - mnuNewModule.Enabled := True; - mnuNewUnit.Enabled := True; - end - else begin - tiCPP.Enabled := False; - mnuNewHeaderCPP.Enabled := False; - mnuNewModule.Enabled := False; - mnuNewUnit.Enabled := False; - end; - end; - SCM_CPP_GETNOTES: begin - if (tsMain.ActiveTabIndex = 1) and (tsDocuments.ActiveTabIndex = eIntData) then - Msg.Result := Integer(PChar(GetRTFText(rtfNotes))) - else - Msg.Result := Integer(PChar(TDocument(CPPProjects.Items[eIntData]).NotesText)); - end; - SCM_CPP_SETNOTES: begin - if (tsMain.ActiveTabIndex = 1) and (tsDocuments.ActiveTabIndex = eIntData) then - SetRTFText(rtfNotes, eData) - else - TDocument(CPPProjects.Items[eIntData]).NotesText := eData; - end; - SCM_CPP_GETFILENAME: Msg.Result := Integer(PChar(TDocument(CPPProjects.Items[eIntData]).FileName)); - SCM_CPP_GETTEXT: begin - if (tsMain.ActiveTabIndex = 1) and (tsDocuments.ActiveTabIndex = eIntData) then - Msg.Result := Integer(sciEditor.Lines.GetText) - else - Msg.Result := Integer(PChar(TDocument(CPPProjects.Items[eIntData]).Code)); - end; - SCM_OTHER_NEWFILE: OtherProjects.Add(eData); - SCM_OTHER_SAVEFILE: begin - if (eData = '') and (TDocument(CPPProjects.Items[eIntData]).Untitled) then - Msg.Result := 0 - else - OtherProjects.Save(eIntData, eData); - end; SCM_OTHER_CLOSEFILE: OtherProjects.Delete(eIntData); SCM_OTHER_ISUNTITLED: begin - try - if TDocument(OtherProjects.Items[eIntData]).Untitled then - Msg.Result := 1 + try + if TDocument(OtherProjects.Items[eIntData]).Untitled then + Msg.Result := 1 + else + Msg.Result := 0; + except + Msg.Result := -1; + end; + end; + SCM_OTHER_ACTIVATE: begin + if tsMain.ActiveTabIndex <> 2 then + ActivateProjects(2, eIntData = 1) else Msg.Result := 0; - except - Msg.Result := -1; end; - end; - SCM_OTHER_ACTIVATE: begin - if tsMain.ActiveTabIndex <> 2 then - ActivateProjects(2, eIntData = 1) - else - Msg.Result := 0; - end; SCM_OTHER_ACTIVATEDOC: OtherProjects.Activate(eIntData, Pos('r', eData) <> 0, Pos('s', eData) <> 0); SCM_OTHER_GETNOTES: begin - if (tsMain.ActiveTabIndex = 2) and (tsDocuments.ActiveTabIndex = eIntData) then - Msg.Result := Integer(PChar(GetRTFText(rtfNotes))) - else - Msg.Result := Integer(PChar(TDocument(OtherProjects.Items[eIntData]).NotesText)); - end; + if (tsMain.ActiveTabIndex = 2) and (tsDocuments.ActiveTabIndex = eIntData) then + Msg.Result := Integer(PChar(GetRTFText(rtfNotes))) + else + Msg.Result := Integer(PChar(TDocument(OtherProjects.Items[eIntData]).NotesText)); + end; SCM_OTHER_SETNOTES: begin - if (tsMain.ActiveTabIndex = 2) and (tsDocuments.ActiveTabIndex = eIntData) then - SetRTFText(rtfNotes, eData) - else - TDocument(OtherProjects.Items[eIntData]).NotesText := eData; - end; + if (tsMain.ActiveTabIndex = 2) and (tsDocuments.ActiveTabIndex = eIntData) then + SetRTFText(rtfNotes, eData) + else + TDocument(OtherProjects.Items[eIntData]).NotesText := eData; + end; SCM_OUTPUT_SHOW: begin - splOutput.Show; - lstOutput.Show; - end; + splOutput.Show; + lstOutput.Show; + end; SCM_OUTPUT_HIDE: begin - splOutput.Hide; - lstOutput.Hide; - end; + splOutput.Hide; + lstOutput.Hide; + end; SCM_OUTPUT_ADD: Msg.Result := lstOutput.Items.Add(eData); SCM_OUTPUT_CLEAR: lstOutput.Items.Clear; SCM_OUTPUT_DELETE: lstOutput.Items.Delete(eIntData); SCM_OUTPUT_GETTEXT: Msg.Result := Integer(lstOutput.Items.GetText); SCM_OUTPUT_GETITEM: begin - try - Msg.Result := Integer(PChar(lstOutput.Items[eIntData])); - except - Msg.Result := Integer(PChar('')); + try + Msg.Result := Integer(PChar(lstOutput.Items[eIntData])); + except + Msg.Result := Integer(PChar('')); + end; end; - end; SCM_OUTPUT_INDEXOF: Msg.Result := lstOutput.Items.IndexOf(eData); SCM_ACTIVE_DOCUMENT: Msg.Result := tsDocuments.ActiveTabIndex; SCM_ACTIVE_PROJECTS: Msg.Result := tsMain.ActiveTabIndex; @@ -2706,16 +2676,16 @@ begin SCM_EDITOR_SETSELSTART: sciEditor.SelStart := eIntData; SCM_EDITOR_SETSELLENGH: sciEditor.SelLength := eIntData; SCM_REMOVE_MENUITEM: begin - if Assigned(GetMenuItem(eData)) then begin - if Assigned(GetMenuItem(eData).Parent) then - GetMenuItem(eData).Parent.Remove(GetMenuItem(eData)) + if Assigned(GetMenuItem(eData)) then begin + if Assigned(GetMenuItem(eData).Parent) then + GetMenuItem(eData).Parent.Remove(GetMenuItem(eData)) + else + tbxMenu.Items.Remove(GetMenuItem(eData)); + Msg.Result := 1; + end else - tbxMenu.Items.Remove(GetMenuItem(eData)); - Msg.Result := 1; - end - else - Msg.Result := 0; - end; + Msg.Result := 0; + end; SCM_REMOVE_IMAGE: ilImages.Delete(eIntData); SCM_SETTHEME: TBXSetTheme(eData); SCM_GETTHEME: Msg.Result := Integer(PChar(TBXCurrentTheme)); @@ -2732,23 +2702,23 @@ end; procedure TfrmMain.OnShortCut(var Msg: TWMKey; var Handled: Boolean); -function TriggerMenuShortcut(eShortcut: TShortcut; Item: TTBCustomItem): Boolean; -var i: integer; -begin - Result := False; - for i := 0 to Item.Count -1 do begin - if Item.Items[i].ShortCut = eShortcut then begin - Item.Items[i].OnClick(Self); - Result := True; - exit; - end - else - TriggerMenuShortcut(eShortcut, Item.Items[i]); + function TriggerMenuShortcut(eShortcut: TShortcut; Item: TTBCustomItem): Boolean; + var i: integer; + begin + Result := False; + for i := 0 to Item.Count - 1 do begin + if Item.Items[i].ShortCut = eShortcut then begin + Item.Items[i].OnClick(Self); + Result := True; + exit; + end + else + TriggerMenuShortcut(eShortcut, Item.Items[i]); + end; end; -end; var i: integer; - eShortcut: TShortcut; + eShortcut: TShortcut; begin if not Started then exit; @@ -2774,7 +2744,7 @@ begin end; if GetActiveWindow <> frmMain.Handle then exit; - + // stop IRC Paster if escape is pressed if (Msg.CharCode = VK_ESCAPE) then begin frmMain.IRCPasterStop := True; @@ -2787,23 +2757,23 @@ begin eShortcut := Shortcut(Msg.CharCode, KeyDataToShiftState(Msg.KeyData)); // Some menu commands are suppressed by the controlchars thingy, so they will be triggered manually - for i := 0 to tbxMenu.Items.Count -1 do begin + for i := 0 to tbxMenu.Items.Count - 1 do begin if TriggerMenuShortcut(eShortcut, tbxMenu.Items[i]) then Handled := True; end; - for i := 0 to tbxToolbar.Items.Count -1 do begin + for i := 0 to tbxToolbar.Items.Count - 1 do begin if tbxToolbar.Items[i].ShortCut = eShortcut then begin Handled := True; tbxToolbar.Items[i].OnClick(Self); end; end; - for i := 0 to tbxEdit.Items.Count -1 do begin + for i := 0 to tbxEdit.Items.Count - 1 do begin if tbxEdit.Items[i].ShortCut = eShortcut then begin Handled := True; tbxEdit.Items[i].OnClick(Self); end; end; - for i := 0 to ppmEditor.Items.Count -1 do begin + for i := 0 to ppmEditor.Items.Count - 1 do begin if ppmEditor.Items[i].ShortCut = eShortcut then begin Handled := True; ppmEditor.Items[i].OnClick(Self); @@ -2856,7 +2826,7 @@ begin Handled := True; if Handled then begin - for i := 0 to frmMain.sciEditor.KeyCommands.Count -1 do begin + for i := 0 to frmMain.sciEditor.KeyCommands.Count - 1 do begin if TSciKeyCommand(frmMain.sciEditor.KeyCommands.Items[i]).ShortCut = eShortcut then Handled := False; end; @@ -2864,4 +2834,24 @@ begin end; +procedure TfrmMain.trvExplorerClick(Sender: TObject); +begin + if Assigned(trvExplorer.Selected) then + UpdateCI(Integer(trvExplorer.Selected.Data)); +end; + +procedure TfrmMain.jviCodeItemValueChanged(Sender: TObject; + Item: TJvCustomInspectorItem); +begin + if GetCurrLang.Name = 'Pawn' then + RebuildLine; +end; + +procedure TfrmMain.mnuRestoreBackupClick(Sender: TObject); +begin + if MessageBox(Handle, PChar(lAskRestore), PChar(Application.Title), MB_ICONQUESTION + MB_YESNO) = mrYes then + sciEditor.LoadFromFile(ActiveDoc.FileName + '.bak'); +end; + end. + diff --git a/editor/studio/UnitfrmMenuGenerator.dfm b/editor/studio/UnitfrmMenuGenerator.dfm index 8d701301..24b36441 100755 Binary files a/editor/studio/UnitfrmMenuGenerator.dfm and b/editor/studio/UnitfrmMenuGenerator.dfm differ diff --git a/editor/studio/UnitfrmSettings.dfm b/editor/studio/UnitfrmSettings.dfm index a2bd38f7..eae965a9 100755 --- a/editor/studio/UnitfrmSettings.dfm +++ b/editor/studio/UnitfrmSettings.dfm @@ -42,24 +42,26 @@ object frmSettings: TfrmSettings 000000FFFFFFFFFFFFFFFF040000000200000008436F6D70696C65722A000000 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF040000000000000011436F6D70696C65 722053657474696E67732C000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0500 - 0000000000001348616C662D4C696665204469726563746F727926000000FFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFF03000000000000000D436F64652D536E6970 - 706574731C0000000100000001000000FFFFFFFFFFFFFFFF0600000002000000 - 0346545021000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0600000000000000 - 0853657474696E67731E000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF070000 - 00000000000550726F787921000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF08 - 0000000000000008506C75672D496E731D000000FFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFF0900000000000000044D697363} + 0000000000001348616C662D4C696665204469726563746F7279230000000100 + 000001000000FFFFFFFFFFFFFFFF0A000000020000000A436F64652D546F6F6C + 7321000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0A00000000000000085365 + 7474696E677326000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF030000000000 + 00000D436F64652D536E6970706574731C0000000100000001000000FFFFFFFF + FFFFFFFF06000000020000000346545021000000FFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFF06000000000000000853657474696E67731E000000FFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFF07000000000000000550726F787921000000FFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFF080000000000000008506C75672D496E731D000000 + FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0900000000000000044D697363} Items.Links = { - 0D00000000000000000000000100000002000000040000000400000005000000 - 030000000600000006000000070000000800000009000000} + 0F00000000000000000000000100000002000000040000000400000005000000 + 0A0000000A000000030000000600000006000000070000000800000009000000} end object jplSettings: TJvPageList Left = 135 Top = 0 Width = 353 Height = 260 - ActivePage = jspHighlighter + ActivePage = jspTools PropagateEnable = False Align = alClient OnChange = jplSettingsChange @@ -355,35 +357,35 @@ object frmSettings: TfrmSettings Caption = 'Tools' object bvlTools1: TBevel Left = 4 - Top = 68 + Top = 90 Width = 347 Height = 3 Shape = bsTopLine end object lblCodeFolding: TLabel Left = 6 - Top = 142 + Top = 158 Width = 67 Height = 13 Caption = 'Code-Folding:' end object lblCaret: TLabel Left = 6 - Top = 76 + Top = 96 Width = 31 Height = 13 Caption = 'Caret:' end object lblAutoIndent: TLabel Left = 194 - Top = 142 + Top = 158 Width = 63 Height = 13 Caption = 'Auto-Indent:' end object chkHighlightBraces: TFlatCheckBox Left = 6 - Top = 26 + Top = 22 Width = 95 Height = 17 Caption = 'Highlight braces' @@ -392,7 +394,7 @@ object frmSettings: TfrmSettings end object chkAutoCloseBraces: TFlatCheckBox Left = 176 - Top = 4 + Top = 6 Width = 107 Height = 17 Caption = 'Auto-Close braces' @@ -401,7 +403,7 @@ object frmSettings: TfrmSettings end object chkAutoCloseQuotes: TFlatCheckBox Left = 176 - Top = 24 + Top = 22 Width = 107 Height = 17 Caption = 'Auto-Close quotes' @@ -410,7 +412,7 @@ object frmSettings: TfrmSettings end object chkClearUndoAfterSave: TFlatCheckBox Left = 6 - Top = 46 + Top = 38 Width = 125 Height = 17 Caption = 'Clear Undo after save' @@ -419,7 +421,7 @@ object frmSettings: TfrmSettings end object chkWordWrap: TFlatCheckBox Left = 176 - Top = 44 + Top = 38 Width = 173 Height = 17 Caption = 'Word-Wrap (not recommended)' @@ -428,7 +430,7 @@ object frmSettings: TfrmSettings end object pnlCodeFolding: TPanel Left = 6 - Top = 158 + Top = 174 Width = 183 Height = 49 BevelOuter = bvLowered @@ -461,7 +463,7 @@ object frmSettings: TfrmSettings end object pnlCaret: TPanel Left = 6 - Top = 92 + Top = 112 Width = 343 Height = 43 BevelOuter = bvLowered @@ -563,7 +565,7 @@ object frmSettings: TfrmSettings end object pnlAutoIndent: TPanel Left = 194 - Top = 158 + Top = 174 Width = 155 Height = 49 BevelOuter = bvLowered @@ -591,6 +593,42 @@ object frmSettings: TfrmSettings OnClick = cmdAdvancedAutoIndentClick end end + object chkDontLoadFilesTwice: TFlatCheckBox + Left = 6 + Top = 54 + Width = 157 + Height = 17 + Caption = 'Don'#39't allow to load files twice' + TabOrder = 9 + TabStop = True + end + object chkMakeBaks: TFlatCheckBox + Left = 176 + Top = 54 + Width = 151 + Height = 17 + Caption = 'Create BAK-file for each file' + TabOrder = 10 + TabStop = True + end + object chkDisableAC: TFlatCheckBox + Left = 6 + Top = 70 + Width = 127 + Height = 17 + Caption = 'Disable Auto-Complete' + TabOrder = 11 + TabStop = True + end + object chkDisableCT: TFlatCheckBox + Left = 176 + Top = 70 + Width = 97 + Height = 15 + Caption = 'Disable Call-Tips' + TabOrder = 12 + TabStop = True + end end object jspShortcuts: TJvStandardPage Left = 0 @@ -1480,7 +1518,7 @@ object frmSettings: TfrmSettings end object chkShowStatusbar: TFlatCheckBox Left = 8 - Top = 214 + Top = 146 Width = 93 Height = 17 Caption = 'Show Statusbar' @@ -1528,13 +1566,34 @@ object frmSettings: TfrmSettings TabOrder = 2 end end + end + object jspCTSettings: TJvStandardPage + Left = 0 + Top = 25 + Width = 353 + Height = 235 + Caption = 'Settings' + object lblCodeExplorer: TLabel + Left = 6 + Top = 6 + Width = 73 + Height = 13 + Caption = 'Code-Explorer:' + end + object lblCodeInspector: TLabel + Left = 6 + Top = 94 + Width = 79 + Height = 13 + Caption = 'Code-Inspector:' + end object pnlPCSpeed: TPanel - Left = 8 - Top = 146 - Width = 337 + Left = 6 + Top = 22 + Width = 341 Height = 67 BevelOuter = bvLowered - TabOrder = 3 + TabOrder = 0 object lblCPUSpeed: TLabel Left = 4 Top = 4 @@ -1550,14 +1609,14 @@ object frmSettings: TfrmSettings Caption = 'Slow' end object lblAverage: TLabel - Left = 131 + Left = 133 Top = 48 Width = 41 Height = 13 Caption = 'Average' end object lblFast: TLabel - Left = 308 + Left = 314 Top = 48 Width = 21 Height = 13 @@ -1566,7 +1625,7 @@ object frmSettings: TfrmSettings object sldSpeed: TJvxSlider Left = 4 Top = 18 - Width = 325 + Width = 331 Height = 31 Increment = 2 MinValue = 1 @@ -1575,6 +1634,42 @@ object frmSettings: TfrmSettings Value = 5 end end + object pnlCodeInspector: TPanel + Left = 6 + Top = 112 + Width = 341 + Height = 47 + BevelOuter = bvLowered + TabOrder = 1 + object lblLangDir: TLabel + Left = 4 + Top = 4 + Width = 143 + Height = 13 + Caption = 'Directory of all language files:' + end + object cmdBrowseLangDir: TFlatButton + Left = 306 + Top = 20 + Width = 29 + Height = 19 + ColorFocused = 16245198 + ColorDown = 16245198 + ColorHighLight = 8623776 + ColorShadow = 8623776 + Caption = '...' + TabOrder = 0 + OnClick = cmdBrowseLangDirClick + end + object txtLangDir: TFlatEdit + Left = 4 + Top = 20 + Width = 297 + Height = 19 + ColorFlat = clWhite + TabOrder = 1 + end + end end object lblCurrSetting: TLabel Left = 0 diff --git a/editor/studio/UnitfrmSettings.pas b/editor/studio/UnitfrmSettings.pas index 5cdb112e..960a5161 100755 --- a/editor/studio/UnitfrmSettings.pas +++ b/editor/studio/UnitfrmSettings.pas @@ -159,12 +159,6 @@ type lblProxyHost: TLabel; cboProxy: TFlatComboBox; lblProxy: TLabel; - pnlPCSpeed: TPanel; - lblCPUSpeed: TLabel; - sldSpeed: TJvxSlider; - lblSlow: TLabel; - lblAverage: TLabel; - lblFast: TLabel; jspHalfLife: TJvStandardPage; pnlHLExecutable: TPanel; lblHLExec: TLabel; @@ -182,6 +176,23 @@ type cmdBrowseAMXXDir: TFlatButton; cmdResetShortcuts: TFlatButton; txtShortcut: TFlatEdit; + jspCTSettings: TJvStandardPage; + pnlPCSpeed: TPanel; + lblCPUSpeed: TLabel; + lblSlow: TLabel; + lblAverage: TLabel; + lblFast: TLabel; + sldSpeed: TJvxSlider; + lblCodeExplorer: TLabel; + lblCodeInspector: TLabel; + pnlCodeInspector: TPanel; + cmdBrowseLangDir: TFlatButton; + txtLangDir: TFlatEdit; + lblLangDir: TLabel; + chkDontLoadFilesTwice: TFlatCheckBox; + chkMakeBaks: TFlatCheckBox; + chkDisableAC: TFlatCheckBox; + chkDisableCT: TFlatCheckBox; procedure jplSettingsChange(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); @@ -243,6 +254,7 @@ type procedure txtShortcutKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); procedure cboFontChange(Sender: TObject); + procedure cmdBrowseLangDirClick(Sender: TObject); public Foreground, Background: TColor; CaretFore, CaretBack: TColor; @@ -979,4 +991,11 @@ begin TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).FontName := cboFont.Text; end; +procedure TfrmSettings.cmdBrowseLangDirClick(Sender: TObject); +var eStr: String; +begin + if SelectDirectory(lSelectLanguageDir, ExtractFilePath(txtLangDir.Text), eStr) then + txtLangDir.Text := eStr; +end; + end. diff --git a/editor/studio/del.bat b/editor/studio/del.bat index 882b8d76..cc600433 100755 --- a/editor/studio/del.bat +++ b/editor/studio/del.bat @@ -7,6 +7,7 @@ del .\*.~dfm del .\*.~dpr del .\*.map del .\*.drc +del .\bugreport.txt del .\plugins\*.~xfm del .\plugins\*.~pas del .\plugins\*.dcu