Added AMXX-Studio to CVS
This commit is contained in:
parent
ac279b37e4
commit
9e035dc744
351
editor/studio/SciSearchReplace.pas
Executable file
351
editor/studio/SciSearchReplace.pas
Executable file
|
@ -0,0 +1,351 @@
|
||||||
|
//CE_Desc_Include(helpdescriptions.txt)
|
||||||
|
{$Include SciCommonDef.Inc}
|
||||||
|
unit SciSearchReplace;
|
||||||
|
{
|
||||||
|
Unit : SciSearchReplace
|
||||||
|
Purpose : Search and Replace for TScintilla based on Synedit Dialogs
|
||||||
|
Created : 20/03/2003
|
||||||
|
Original Author : Kiriakos Vlahos (kvlahos@london.edu)
|
||||||
|
History : 29/09/2004 Initial Release with Delphi Scintilla Interface Components
|
||||||
|
Changed Editor property from TScintilla to TScintillaBase class.
|
||||||
|
Wasn't any need for the extra properties to use this dialog.
|
||||||
|
hdalis (hdalis@users.sourceforge.net)
|
||||||
|
06/02/2005 Fixed a bug that caused the beginundoaction to be started,
|
||||||
|
but not finished.. i.e it treated all changes after a replace all
|
||||||
|
to belonging to the same undo operation..
|
||||||
|
hdalis (hdalis@users.sourceforge.net)
|
||||||
|
15/02/2005 Somewhat fixed a bug which caused the component to hang when
|
||||||
|
search/replace for the regular expression '$'..
|
||||||
|
it became an endless loop..
|
||||||
|
if SelWord is true, we get the word under the caret as the searchword
|
||||||
|
instead of the need to select the word first.. If there isn't a word
|
||||||
|
under the caret, uses the previous searchtext if any..
|
||||||
|
hdalis (hdalis@users.sourceforge.net)
|
||||||
|
07/29/2005 Fixed "Search from caret"-bug
|
||||||
|
}
|
||||||
|
|
||||||
|
interface
|
||||||
|
Uses
|
||||||
|
Types, Classes, Controls, Forms, SciLexer;
|
||||||
|
|
||||||
|
Type
|
||||||
|
|
||||||
|
TSciSearchReplace = class(TComponent)
|
||||||
|
private
|
||||||
|
FSearchForSelWord : boolean;
|
||||||
|
FEditor : TScintillaBase;
|
||||||
|
FSearchFromCaretInt: boolean;
|
||||||
|
FFoundText : String;
|
||||||
|
FOnTextFound : TNotifyEvent;
|
||||||
|
FOnTextNotFound : TNotifyEvent;
|
||||||
|
FOnTextReplaced : TNotifyEvent;
|
||||||
|
protected
|
||||||
|
procedure Notification(AComponent: TComponent;
|
||||||
|
Operation: TOperation); override;
|
||||||
|
public
|
||||||
|
// Search Options
|
||||||
|
SearchBackwards: boolean;
|
||||||
|
SearchCaseSensitive: boolean;
|
||||||
|
SearchSelectionOnly: boolean;
|
||||||
|
SearchWholeWords: boolean;
|
||||||
|
SearchRegex: boolean;
|
||||||
|
SearchText: string;
|
||||||
|
SearchTextHistory: string;
|
||||||
|
ReplaceText: string;
|
||||||
|
ReplaceTextHistory: string;
|
||||||
|
ReplacedCount : Integer;
|
||||||
|
|
||||||
|
property FoundText : string read fFoundText;
|
||||||
|
procedure DoSearchReplaceText(AReplace, ABackwards: boolean);
|
||||||
|
procedure ShowSearchReplaceDialog(AReplace: boolean);
|
||||||
|
constructor Create(AOwner : TComponent);override;
|
||||||
|
published
|
||||||
|
property SearchForSelWord : boolean read FSearchForSelWord write FSearchForSelWord;
|
||||||
|
property SearchFromCaret: boolean read FSearchFromCaretInt write FSearchFromCaretInt;
|
||||||
|
property Editor : TScintillaBase read FEditor write FEditor;
|
||||||
|
property OnTextFound : TNotifyEvent read FOnTextFound write FOnTextFound;
|
||||||
|
property OnTextNotFound : TNotifyEvent read FOnTextNotFound write FOnTextNotFound;
|
||||||
|
property OnTextReplaced : TNotifyEvent read FOnTextReplaced write FOnTextReplaced;
|
||||||
|
end;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
Uses
|
||||||
|
SciSearchTextDlg, SciConfirmReplaceDlg, SciReplaceTextDlg, SciSupport,sciUtils;
|
||||||
|
|
||||||
|
{ TSciSearchReplace }
|
||||||
|
constructor TSciSearchReplace.Create(AOwner : TComponent);
|
||||||
|
begin
|
||||||
|
ReplacedCount:=0;
|
||||||
|
SearchFromCaret:=True;
|
||||||
|
Inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSciSearchReplace.DoSearchReplaceText(AReplace, ABackwards: boolean);
|
||||||
|
var
|
||||||
|
Options: Integer;
|
||||||
|
StartPosition, EndPosition : Integer;
|
||||||
|
TargetStart, TargetEnd, posFind : Integer;
|
||||||
|
APos: TPoint;
|
||||||
|
EditRect: TRect;
|
||||||
|
DlgRes : Integer;
|
||||||
|
lastMatch,lenTarget,MovePastEOL : Integer;
|
||||||
|
chNext : Integer;
|
||||||
|
findLen : Integer;
|
||||||
|
LenFound, LenReplaced : Integer;
|
||||||
|
// lastMatch : Integer;
|
||||||
|
doendundo : Boolean;
|
||||||
|
begin
|
||||||
|
doendundo:=false;
|
||||||
|
if not Assigned(FEditor) then Exit;
|
||||||
|
Options := 0;
|
||||||
|
if SearchCaseSensitive then
|
||||||
|
Options := Options or SCFIND_MATCHCASE;
|
||||||
|
if SearchWholeWords then
|
||||||
|
Options := Options or SCFIND_WHOLEWORD;
|
||||||
|
if SearchRegex then
|
||||||
|
Options := Options or SCFIND_REGEXP;
|
||||||
|
if SearchText='' then Exit;
|
||||||
|
if ABackwards then
|
||||||
|
begin
|
||||||
|
if fSearchFromCaretInt and not SearchSelectionOnly then
|
||||||
|
StartPosition := FEditor.GetSelectionStart - 1
|
||||||
|
else if SearchSelectionOnly then
|
||||||
|
StartPosition := FEditor.GetSelectionEnd
|
||||||
|
else
|
||||||
|
StartPosition := FEditor.GetLength;
|
||||||
|
if SearchSelectionOnly then
|
||||||
|
EndPosition := FEditor.GetSelectionStart
|
||||||
|
else
|
||||||
|
EndPosition := 0;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
if fSearchFromCaretInt and not SearchSelectionOnly then
|
||||||
|
StartPosition := FEditor.GetSelectionEnd + 1
|
||||||
|
else if SearchSelectionOnly then
|
||||||
|
StartPosition := FEditor.GetSelectionStart
|
||||||
|
else
|
||||||
|
StartPosition := 0;
|
||||||
|
if SearchSelectionOnly then
|
||||||
|
EndPosition := FEditor.GetSelectionEnd
|
||||||
|
else
|
||||||
|
EndPosition := FEditor.GetLength;
|
||||||
|
end;
|
||||||
|
findLen:=Length(SearchText);
|
||||||
|
|
||||||
|
with FEditor do
|
||||||
|
begin
|
||||||
|
SetTargetStart(StartPosition);
|
||||||
|
SetTargetEnd(EndPosition);
|
||||||
|
SetSearchFlags(Options);
|
||||||
|
posFind := SearchInTarget(findLen, PChar(SearchText));
|
||||||
|
if (posFind < 0) then
|
||||||
|
begin
|
||||||
|
if Assigned(FOnTextNotFound) then
|
||||||
|
FOnTextNotFound(Self);
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
lastMatch:=posFind;
|
||||||
|
TargetStart := GetTargetStart;
|
||||||
|
TargetEnd := GetTargetEnd;
|
||||||
|
LenFound := TargetEnd - TargetStart;
|
||||||
|
LenReplaced := LenFound;
|
||||||
|
EnsureRangeVisible(TargetStart, TargetEnd);
|
||||||
|
SetSel(TargetStart, TargetEnd);
|
||||||
|
FFoundText := FEditor.SelText;
|
||||||
|
if Assigned(FOnTextFound) then
|
||||||
|
FOnTextFound(Self);
|
||||||
|
|
||||||
|
// Replace code
|
||||||
|
if AReplace then
|
||||||
|
begin
|
||||||
|
DlgRes := mrYes;
|
||||||
|
|
||||||
|
if ConfirmReplaceDialog = nil then
|
||||||
|
ConfirmReplaceDialog := TConfirmReplaceDialog.Create(Application);
|
||||||
|
ReplacedCount:=0;
|
||||||
|
while (posFind >= 0) and (DlgRes <> mrCancel) do
|
||||||
|
begin
|
||||||
|
lenTarget:=GetTargetEnd-GetTargetStart;
|
||||||
|
movePastEOL:=0;
|
||||||
|
if lenTarget<=0 then
|
||||||
|
begin
|
||||||
|
chNext:=GetCharAt(GetTargetEnd);
|
||||||
|
if (chNext=10) or (chNext=13) then MovePastEOL:=1;
|
||||||
|
end;
|
||||||
|
if not (DlgRes = mrYesToAll) then
|
||||||
|
begin
|
||||||
|
APos := Point(PointXFromPosition(TargetStart), PointYFromPosition(TargetStart));
|
||||||
|
APos := ClientToScreen(APos);
|
||||||
|
EditRect := FEditor.ClientRect;
|
||||||
|
EditRect.TopLeft := ClientToScreen(EditRect.TopLeft);
|
||||||
|
EditRect.BottomRight := ClientToScreen(EditRect.BottomRight);
|
||||||
|
|
||||||
|
ConfirmReplaceDialog.PrepareShow(EditRect, APos.X, APos.Y,
|
||||||
|
APos.Y + 2 * FEditor.TextHeight(LineFromPosition(TargetStart)), SearchText);
|
||||||
|
DlgRes :=ConfirmReplaceDialog.ShowModal;
|
||||||
|
if (DlgRes = mrYesToAll) and (doendundo=false) then
|
||||||
|
begin
|
||||||
|
FEditor.BeginUndoAction;
|
||||||
|
doendundo:=True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
if DlgRes in [mrYes, mrYesToAll] then
|
||||||
|
begin
|
||||||
|
// Replace
|
||||||
|
if SearchRegex then
|
||||||
|
LenReplaced := ReplaceTargetRE(Length(ReplaceText), PChar(ReplaceText))
|
||||||
|
else
|
||||||
|
LenReplaced := ReplaceTarget(Length(ReplaceText), PChar(ReplaceText));
|
||||||
|
Inc(ReplacedCount);
|
||||||
|
|
||||||
|
lastMatch:=posFind + lenReplaced + movepastEOL;
|
||||||
|
if lenTarget=0 then
|
||||||
|
lastMatch:=PositionAfter(lastMatch);
|
||||||
|
|
||||||
|
TargetEnd := TargetStart + LenReplaced -1+movePastEOL;
|
||||||
|
if Assigned(FOnTextReplaced) then FOnTextReplaced(Self);
|
||||||
|
end;
|
||||||
|
if DlgRes in [mrYes, mrNo, mrYesToAll] then
|
||||||
|
begin
|
||||||
|
// carry on
|
||||||
|
if lastMatch>=endPosition then
|
||||||
|
begin
|
||||||
|
posFind:=-1;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
if ABackwards then
|
||||||
|
begin
|
||||||
|
SetTargetStart(TargetStart - 1);
|
||||||
|
SetTargetEnd(EndPosition);
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
SetTargetStart(TargetEnd + 1);
|
||||||
|
EndPosition := EndPosition + LenReplaced - LenFound;
|
||||||
|
SetTargetEnd(EndPosition);
|
||||||
|
end;
|
||||||
|
SetTargetEnd(EndPosition);
|
||||||
|
SetSearchFlags(Options);
|
||||||
|
posFind := SearchInTarget(Length(SearchText), PChar(SearchText));
|
||||||
|
end;
|
||||||
|
if posFind >= 0 then
|
||||||
|
begin
|
||||||
|
TargetStart := GetTargetStart;
|
||||||
|
TargetEnd := GetTargetEnd;
|
||||||
|
lastMatch:=TargetStart;
|
||||||
|
LenFound := TargetEnd - TargetStart;
|
||||||
|
LenReplaced := LenFound;
|
||||||
|
EnsureRangeVisible(TargetStart, TargetEnd);
|
||||||
|
SetSel(TargetStart, TargetEnd);
|
||||||
|
end;
|
||||||
|
end else
|
||||||
|
break;
|
||||||
|
end; // While
|
||||||
|
if doendundo then
|
||||||
|
FEditor.EndUndoAction;
|
||||||
|
|
||||||
|
// Restore original selection if Searching in Selection
|
||||||
|
if SearchSelectionOnly then
|
||||||
|
begin
|
||||||
|
if ABackwards then
|
||||||
|
SetSel(EndPosition, StartPosition)
|
||||||
|
else
|
||||||
|
SetSel(StartPosition, EndPosition);
|
||||||
|
EnsureRangeVisible(GetSelectionStart, GetSelectionEnd);
|
||||||
|
end;
|
||||||
|
end; // if AReplace
|
||||||
|
end; //if (posFind < 0)
|
||||||
|
end; // with FEditor
|
||||||
|
|
||||||
|
if ConfirmReplaceDialog <> nil then
|
||||||
|
begin
|
||||||
|
ConfirmReplaceDialog.Free;
|
||||||
|
ConfirmReplaceDialog := nil;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSciSearchReplace.Notification(AComponent: TComponent;
|
||||||
|
Operation: TOperation);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
if (AComponent = FEditor) and (Operation = opRemove) then FEditor := nil;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSciSearchReplace.ShowSearchReplaceDialog(AReplace: boolean);
|
||||||
|
var
|
||||||
|
dlg: TTextSearchDialog;
|
||||||
|
SelectedText : string;
|
||||||
|
begin
|
||||||
|
if not Assigned(FEditor) then Exit;
|
||||||
|
if AReplace then
|
||||||
|
dlg := TTextReplaceDialog.Create(Self)
|
||||||
|
else
|
||||||
|
dlg := TTextSearchDialog.Create(Self);
|
||||||
|
with dlg do
|
||||||
|
try
|
||||||
|
// assign search options
|
||||||
|
SearchBackwards := Self.SearchBackwards;
|
||||||
|
SearchCaseSensitive := Self.SearchCaseSensitive;
|
||||||
|
SearchFromCursor := Self.SearchFromCaret;
|
||||||
|
SearchInSelectionOnly := Self.SearchSelectionOnly;
|
||||||
|
SelectedText := FEditor.SelText;
|
||||||
|
if (SelectedText <> '') and (Pos(#10, SelectedText) > 0) or (Pos(#13, SelectedText) > 0) then
|
||||||
|
SearchInSelectionOnly := True
|
||||||
|
else
|
||||||
|
SearchInSelectionOnly := False;
|
||||||
|
|
||||||
|
// start with last search text
|
||||||
|
|
||||||
|
if FSearchForSelWord and not SearchInSelectionOnly
|
||||||
|
then
|
||||||
|
begin
|
||||||
|
if Editor.SelectionWord(True)<>'' then
|
||||||
|
SearchText:=Editor.SelectionWord(True)
|
||||||
|
else
|
||||||
|
SearchText := Self.SearchText;
|
||||||
|
end else
|
||||||
|
SearchText := Self.SearchText;
|
||||||
|
SearchTextHistory := Self.SearchTextHistory;
|
||||||
|
if AReplace then
|
||||||
|
with dlg as TTextReplaceDialog do
|
||||||
|
begin
|
||||||
|
ReplaceText := Self.ReplaceText;
|
||||||
|
ReplaceTextHistory := Self.ReplaceTextHistory;
|
||||||
|
end;
|
||||||
|
SearchWholeWords := Self.SearchWholeWords;
|
||||||
|
if ShowModal = mrOK then
|
||||||
|
begin
|
||||||
|
Self.SearchBackwards := SearchBackwards;
|
||||||
|
Self.SearchCaseSensitive := SearchCaseSensitive;
|
||||||
|
Self.SearchFromCaret := SearchFromCursor;
|
||||||
|
Self.SearchSelectionOnly := SearchInSelectionOnly;
|
||||||
|
Self.SearchWholeWords := SearchWholeWords;
|
||||||
|
Self.SearchRegex := SearchRegularExpression;
|
||||||
|
Self.SearchText := SearchText;
|
||||||
|
Self.SearchTextHistory := SearchTextHistory;
|
||||||
|
|
||||||
|
if AReplace then
|
||||||
|
with dlg as TTextReplaceDialog do
|
||||||
|
begin
|
||||||
|
Self.ReplaceText := ReplaceText;
|
||||||
|
Self.ReplaceTextHistory := ReplaceTextHistory;
|
||||||
|
end;
|
||||||
|
fSearchFromCaretInt := Self.SearchFromCaret;
|
||||||
|
if SearchText <> '' then
|
||||||
|
begin
|
||||||
|
DoSearchReplaceText(AReplace, Self.SearchBackwards);
|
||||||
|
fSearchFromCaretInt := True;
|
||||||
|
end;
|
||||||
|
Self.SearchSelectionOnly := False;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
dlg.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
initialization
|
||||||
|
ConfirmReplaceDialog := nil;
|
||||||
|
end.
|
321
editor/studio/UnitCodeExplorerUpdater.pas
Executable file
321
editor/studio/UnitCodeExplorerUpdater.pas
Executable file
|
@ -0,0 +1,321 @@
|
||||||
|
unit UnitCodeExplorerUpdater;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, Forms, SysUtils, ComCtrls, Windows, ScintillaLanguageManager,
|
||||||
|
Dialogs, CommCtrl;
|
||||||
|
|
||||||
|
type
|
||||||
|
TCodeExplorerUpdater = class(TThread)
|
||||||
|
private
|
||||||
|
eConstants: TStringList;
|
||||||
|
eDefined: TStringList;
|
||||||
|
eCVars: TStringList;
|
||||||
|
eIncluded: TStringList;
|
||||||
|
eMethodsDefault, eMethodsEvents, eStocks: TStringList;
|
||||||
|
eNatives: TStringList;
|
||||||
|
eForwards: TStringList;
|
||||||
|
eVariables: TStringList;
|
||||||
|
|
||||||
|
eCode: TStringList;
|
||||||
|
|
||||||
|
eAutoComplete, eCallTips, eKeywords: String;
|
||||||
|
protected
|
||||||
|
procedure Execute; override;
|
||||||
|
procedure GetCode;
|
||||||
|
procedure SetValuesPAWN;
|
||||||
|
end;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses UnitfrmMain, UnitLanguages, UnitMainTools, UnitCodeUtils,
|
||||||
|
UnitTextAnalyze, UnitfrmSettings, UnitPlugins;
|
||||||
|
|
||||||
|
{ TCodeExplorerUpdater }
|
||||||
|
|
||||||
|
procedure TCodeExplorerUpdater.Execute;
|
||||||
|
var eStr: TStringList;
|
||||||
|
begin
|
||||||
|
eCode := TStringList.Create;
|
||||||
|
eConstants := TStringList.Create;
|
||||||
|
eDefined := TStringList.Create;
|
||||||
|
eCVars := TStringList.Create;
|
||||||
|
eIncluded := TStringList.Create;
|
||||||
|
eMethodsDefault := TStringList.Create;
|
||||||
|
eMethodsEvents := TStringList.Create;
|
||||||
|
eStocks := TStringList.Create;
|
||||||
|
eNatives := TStringList.Create;
|
||||||
|
eForwards := TStringList.Create;
|
||||||
|
eVariables := TStringList.Create;
|
||||||
|
eStr := TStringList.Create;
|
||||||
|
|
||||||
|
repeat
|
||||||
|
Synchronize(GetCode);
|
||||||
|
eAutoComplete := '';
|
||||||
|
eCallTips := '';
|
||||||
|
eKeywords := '';
|
||||||
|
|
||||||
|
if (not Application.Terminated) and (Started) and (not frmMain.pnlLoading.Visible) and (frmMain.trvExplorer.Visible) then begin
|
||||||
|
if Plugin_UpdateCodeExplorer(GetCurrLang.Name, ActiveDoc.FileName, frmMain.tsMain.Items[frmMain.tsMain.ActiveTabIndex].Caption, True) then begin
|
||||||
|
try
|
||||||
|
if (frmMain.tsMain.ActiveTabIndex = 0) then begin
|
||||||
|
// analyze code
|
||||||
|
with ParseCodePAWN(eCode, ExtractFileName(ActiveDoc.FileName)) do begin
|
||||||
|
eConstants.Assign(Constants);
|
||||||
|
eDefined.Assign(Defined);
|
||||||
|
eCVars.Assign(CVars);
|
||||||
|
eIncluded.Assign(Included);
|
||||||
|
eMethodsDefault.Assign(MethodsDefault);
|
||||||
|
eMethodsEvents.Assign(Events);
|
||||||
|
eStocks.Assign(Stocks);
|
||||||
|
eNatives.Assign(Natives);
|
||||||
|
eForwards.Assign(Forwards);
|
||||||
|
eVariables.Assign(Variables);
|
||||||
|
|
||||||
|
eAutoComplete := eAutoComplete + #13 + AutoComplete.Text;
|
||||||
|
eCallTips := eCallTips + #13 + CallTips.Text;
|
||||||
|
eKeywords := eKeywords + #13 + HighlightKeywords.Text;
|
||||||
|
|
||||||
|
DestroyResult;
|
||||||
|
end;
|
||||||
|
// apply changes
|
||||||
|
Synchronize(SetValuesPAWN);
|
||||||
|
end;
|
||||||
|
except
|
||||||
|
// GABEM
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Sleep(1000);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Sleep(50);
|
||||||
|
until (Application.Terminated);
|
||||||
|
|
||||||
|
eCode.Free;
|
||||||
|
eConstants.Free;
|
||||||
|
eDefined.Free;
|
||||||
|
eCVars.Free;
|
||||||
|
eIncluded.Free;
|
||||||
|
eMethodsDefault.Free;
|
||||||
|
eMethodsEvents.Free;
|
||||||
|
eStocks.Free;
|
||||||
|
eNatives.Free;
|
||||||
|
eForwards.Free;
|
||||||
|
eVariables.Free;
|
||||||
|
eStr.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCodeExplorerUpdater.GetCode;
|
||||||
|
begin
|
||||||
|
eCode.Assign(frmMain.sciEditor.Lines);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCodeExplorerUpdater.SetValuesPAWN;
|
||||||
|
function GetNode(eText: String): TTreeNode;
|
||||||
|
var i: integer;
|
||||||
|
begin
|
||||||
|
Result := nil;
|
||||||
|
|
||||||
|
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];
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var exConstants, exDefined, exIncluded, exMethods, exDefault, exEvents,
|
||||||
|
exStocks, exNatives, exForwards, exVariables, exCVars: Boolean;
|
||||||
|
i, eSelStart, eSelLength: integer;
|
||||||
|
LineMaxSubord: integer;
|
||||||
|
eStr: TStringList;
|
||||||
|
eScrollPosX, eScrollPosY: Integer;
|
||||||
|
begin
|
||||||
|
if frmMain.trvExplorer.Items.Count = 0 then exit;
|
||||||
|
|
||||||
|
frmMain.trvExplorer.Items.BeginUpdate;
|
||||||
|
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;
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
|
||||||
|
SetScrollPos(frmMain.trvExplorer.Handle, SB_HORZ, eScrollPosX, False);
|
||||||
|
SetScrollPos(frmMain.trvExplorer.Handle, SB_VERT, eScrollPosY, False);
|
||||||
|
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
|
||||||
|
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
|
||||||
|
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
|
||||||
|
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
|
||||||
|
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);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
eStr.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Plugin_UpdateCodeExplorer(GetCurrLang.Name, ActiveDoc.FileName, frmMain.tsMain.Items[frmMain.tsMain.ActiveTabIndex].Caption, False);
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
417
editor/studio/UnitCodeInspector.pas
Executable file
417
editor/studio/UnitCodeInspector.pas
Executable file
|
@ -0,0 +1,417 @@
|
||||||
|
unit UnitCodeInspector;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses SysUtils, Classes, Windows, JvInspector, UnitMainTools, Contnrs;
|
||||||
|
|
||||||
|
type
|
||||||
|
TSelectionTextList = class(TStringList)
|
||||||
|
private
|
||||||
|
FSelected: Integer;
|
||||||
|
function GetSelectedText: string;
|
||||||
|
function GetSelected: Integer;
|
||||||
|
procedure SetSelectedText(const Value: string);
|
||||||
|
procedure SetSelected(const Value: Integer);
|
||||||
|
public
|
||||||
|
property Selected: Integer read GetSelected write SetSelected;
|
||||||
|
property SelectedText: string read GetSelectedText write SetSelectedText;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TJvInspectorSelectionTextListItem = class(TJvCustomInspectorItem)
|
||||||
|
protected
|
||||||
|
function GetDisplayValue: string; override;
|
||||||
|
procedure GetValueList(const Strings: TStrings); override;
|
||||||
|
procedure SetDisplayValue(const Value: string); override;
|
||||||
|
procedure SetFlags(const Value: TInspectorItemFlags); override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TStringWrapper = class(TObject)
|
||||||
|
public
|
||||||
|
Value: string;
|
||||||
|
constructor Create(const AValue: string);
|
||||||
|
end;
|
||||||
|
|
||||||
|
TSTLWrapper = class(TObject)
|
||||||
|
public
|
||||||
|
STL: TSelectionTextList;
|
||||||
|
Value: String;
|
||||||
|
constructor Create(const ASTL: TSelectionTextList; const AValue: String);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function AddField(eName, eCategory, eValue: String): TJvCustomInspectorItem;
|
||||||
|
function AddCombo(eName, eCategory, eValue: String; eValues: array of string): TJvCustomInspectorItem;
|
||||||
|
|
||||||
|
procedure UpdateCI;
|
||||||
|
procedure UpdateCI_PAWN;
|
||||||
|
|
||||||
|
var eFormatSettings: String;
|
||||||
|
eAllIncluded: TStringArray;
|
||||||
|
|
||||||
|
FItems: TObjectList;
|
||||||
|
STLItem: TSelectionTextList;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses UnitfrmMain, UnitLanguages, UnitCodeUtils, UnitMenuGenerators,
|
||||||
|
UnitPlugins;
|
||||||
|
|
||||||
|
var eBraceTexts: TStringList;
|
||||||
|
|
||||||
|
{ "Combobox"-Item }
|
||||||
|
|
||||||
|
function TSelectionTextList.GetSelected: Integer;
|
||||||
|
begin
|
||||||
|
if FSelected < -1 then
|
||||||
|
FSelected := -1
|
||||||
|
else if FSelected >= Count then
|
||||||
|
FSelected := Count - 1;
|
||||||
|
Result := FSelected;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TSelectionTextList.GetSelectedText: string;
|
||||||
|
begin
|
||||||
|
if Selected >= 0 then
|
||||||
|
Result := Strings[Selected]
|
||||||
|
else
|
||||||
|
Result := '';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSelectionTextList.SetSelected(const Value: Integer);
|
||||||
|
begin
|
||||||
|
FSelected := Value;
|
||||||
|
GetSelected; // adjust FSelected
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSelectionTextList.SetSelectedText(const Value: string);
|
||||||
|
begin
|
||||||
|
FSelected := IndexOf(Value);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TJvInspectorSelectionTextListItem.GetDisplayValue: string;
|
||||||
|
begin
|
||||||
|
Result := TSelectionTextList(Data.AsOrdinal).SelectedText;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJvInspectorSelectionTextListItem.GetValueList(const Strings: TStrings);
|
||||||
|
begin
|
||||||
|
Strings.Assign(TSelectionTextList(Data.AsOrdinal));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJvInspectorSelectionTextListItem.SetDisplayValue(const Value: string);
|
||||||
|
begin
|
||||||
|
TSelectionTextList(Data.AsOrdinal).SelectedText := Value;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJvInspectorSelectionTextListItem.SetFlags(const Value: TInspectorItemFlags);
|
||||||
|
begin
|
||||||
|
inherited SetFlags(Value + [iifValueList]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TStringWrapper.Create(const AValue: string);
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
Value := AValue;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ Codeinspector Add Functions }
|
||||||
|
|
||||||
|
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;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if eName <> '' then
|
||||||
|
begin
|
||||||
|
STLItem := TSelectionTextList.Create;
|
||||||
|
Found := False;
|
||||||
|
for i := 0 to High(eValues) do begin
|
||||||
|
STLItem.Add(eValues[i]);
|
||||||
|
if eValues[i] = eValue then
|
||||||
|
Found := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if not Found then begin
|
||||||
|
STLItem.Add(eValue);
|
||||||
|
STLItem.Sort;
|
||||||
|
end;
|
||||||
|
|
||||||
|
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;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function AddField(eName, eCategory, eValue: String): TJvCustomInspectorItem;
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
|
eParent: TJvCustomInspectorItem;
|
||||||
|
Item: TStringWrapper;
|
||||||
|
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 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;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ Parse Functions }
|
||||||
|
|
||||||
|
procedure UpdateCI;
|
||||||
|
begin
|
||||||
|
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;
|
||||||
|
Plugin_UpdateCodeInspector(GetCurrLang.Name, ActiveDoc.FileName, frmMain.tsMain.Items[frmMain.tsMain.ActiveTabIndex].Caption, False);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure UpdateCI_PAWN;
|
||||||
|
procedure HideBracesAndStrings(var eStr: String);
|
||||||
|
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;
|
||||||
|
|
||||||
|
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;
|
||||||
|
eStr := TStringList.Create;
|
||||||
|
eBraceTexts := TStringList.Create;
|
||||||
|
eVars := 0;
|
||||||
|
eConsts := 0;
|
||||||
|
frmMain.jviCode.Clear;
|
||||||
|
FItems.Clear;
|
||||||
|
|
||||||
|
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
|
||||||
|
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);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
AddField('', 'No information available.', '');
|
||||||
|
end
|
||||||
|
else
|
||||||
|
AddField('', 'No information available.', '');
|
||||||
|
end;
|
||||||
|
eStr.Free;
|
||||||
|
eBraceTexts.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TSTLWrapper }
|
||||||
|
|
||||||
|
constructor TSTLWrapper.Create(const ASTL: TSelectionTextList;
|
||||||
|
const AValue: String);
|
||||||
|
begin
|
||||||
|
STL := ASTL;
|
||||||
|
Value := AValue;
|
||||||
|
end;
|
||||||
|
|
||||||
|
initialization
|
||||||
|
|
||||||
|
FItems := TObjectList.Create;
|
||||||
|
|
||||||
|
finalization
|
||||||
|
|
||||||
|
FItems.Free;
|
||||||
|
|
||||||
|
end.
|
92
editor/studio/UnitCodeSnippets.pas
Executable file
92
editor/studio/UnitCodeSnippets.pas
Executable file
|
@ -0,0 +1,92 @@
|
||||||
|
unit UnitCodeSnippets;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses SysUtils, Classes, Windows;
|
||||||
|
|
||||||
|
function GetSnippet(Lang, Ident: String): String;
|
||||||
|
function GetSnippetList(Lang: String): TStringList;
|
||||||
|
procedure AddSnippet(Lang, Ident, Code: String);
|
||||||
|
procedure DelSnippet(Lang, Ident: String);
|
||||||
|
procedure SetSnippet(Lang, Ident, Code: String);
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
function GetSnippet(Lang, Ident: String): String;
|
||||||
|
var eFile: TStringList;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
eFile := TStringList.Create;
|
||||||
|
eFile.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'config\' + Lang + '.csl'); // ... .csl = CodeSnippetList
|
||||||
|
for i := 0 to eFile.Count -1 do begin
|
||||||
|
if Pos(Ident + #1, eFile[i]) = 1 then begin
|
||||||
|
Result := eFile[i];
|
||||||
|
Delete(Result, 1, Length(Ident) +1);
|
||||||
|
Result := StringReplace(Result, #2, #13#10, [rfReplaceAll]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
eFile.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function GetSnippetList(Lang: String): TStringList;
|
||||||
|
var i: Integer;
|
||||||
|
begin
|
||||||
|
Result := TStringList.Create;
|
||||||
|
if FileExists(ExtractFilePath(ParamStr(0)) + 'config\' + Lang + '.csl') then begin
|
||||||
|
Result.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'config\' + Lang + '.csl'); // ... .csl = CodeSnippetList
|
||||||
|
for i := 0 to Result.Count -1 do
|
||||||
|
Result[i] := Copy(Result[i], 1, Pos(#1, Result[i]) -1);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure AddSnippet(Lang, Ident, Code: String);
|
||||||
|
var eFile: TStringList;
|
||||||
|
begin
|
||||||
|
Code := StringReplace(Code, #13#10, #2, [rfReplaceAll]);
|
||||||
|
|
||||||
|
eFile := TStringList.Create;
|
||||||
|
eFile.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'config\' + Lang + '.csl'); // ... .csl = CodeSnippetList
|
||||||
|
eFile.Add(Ident + #1 + Code);
|
||||||
|
eFile.SaveToFile(ExtractFilePath(ParamStr(0)) + 'config\' + Lang + '.csl'); // ... .csl = CodeSnippetList
|
||||||
|
eFile.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure DelSnippet(Lang, Ident: String);
|
||||||
|
var eFile: TStringList;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
eFile := TStringList.Create;
|
||||||
|
eFile.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'config\' + Lang + '.csl'); // ... .csl = CodeSnippetList
|
||||||
|
for i := eFile.Count -1 downto 0 do begin
|
||||||
|
if Pos(Ident + #1, eFile[i]) = 1 then
|
||||||
|
eFile.Delete(i);
|
||||||
|
end;
|
||||||
|
eFile.SaveToFile(ExtractFilePath(ParamStr(0)) + 'config\' + Lang + '.csl'); // ... .csl = CodeSnippetList
|
||||||
|
eFile.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure SetSnippet(Lang, Ident, Code: String);
|
||||||
|
var eFile: TStringList;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
Code := StringReplace(Code, #13#10, #2, [rfReplaceAll]);
|
||||||
|
|
||||||
|
eFile := TStringList.Create;
|
||||||
|
eFile.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'config\' + Lang + '.csl'); // ... .csl = CodeSnippetList
|
||||||
|
{ If item exists... }
|
||||||
|
for i := 0 to eFile.Count -1 do begin
|
||||||
|
if Pos(Ident + #1, eFile[i]) = 1 then begin
|
||||||
|
eFile[i] := Ident + #1 + Code;
|
||||||
|
eFile.SaveToFile(ExtractFilePath(ParamStr(0)) + 'config\' + Lang + '.csl'); // ... .csl = CodeSnippetList
|
||||||
|
eFile.Free;
|
||||||
|
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{ else... }
|
||||||
|
eFile.Add(Ident + #1 + Code);
|
||||||
|
eFile.SaveToFile(ExtractFilePath(ParamStr(0)) + 'config\' + Lang + '.csl'); // ... .csl = CodeSnippetList
|
||||||
|
eFile.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
431
editor/studio/UnitCodeUtils.pas
Executable file
431
editor/studio/UnitCodeUtils.pas
Executable file
|
@ -0,0 +1,431 @@
|
||||||
|
unit UnitCodeUtils;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses SysUtils, Classes, Forms, Controls, Windows, ScintillaLanguageManager,
|
||||||
|
RichEdit, ComCtrls, JvInspector;
|
||||||
|
|
||||||
|
function IsAtStart(eSubStr, eStr: String; AllowFunctions: Boolean = True): Boolean;
|
||||||
|
function GetIndents(Line: Integer = -1): String;
|
||||||
|
function GetStyleAt(ePos: Integer): TSciStyle;
|
||||||
|
function LineFromPos(ePos: Integer): Integer;
|
||||||
|
function RemoveSemicolon(eStr: String): String;
|
||||||
|
procedure IndentCode;
|
||||||
|
procedure UnindentCode;
|
||||||
|
function Between(eText, eFirst, eSecond: String): String;
|
||||||
|
procedure Delay(eTime: Integer);
|
||||||
|
function CountChars(eIn: String; eChar: Char): Integer;
|
||||||
|
function RemoveStringsAndComments(eLine: String; eRemoveStrings: Boolean): String;
|
||||||
|
function GetMatchingBrace(eString: String): Integer;
|
||||||
|
function GetColoredLine(eLine: Integer): String;
|
||||||
|
|
||||||
|
function GetRTFText(ARichEdit: TRichedit): string;
|
||||||
|
procedure SetRTFText(ARichEdit: TRichedit; ARTFText: String);
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses UnitfrmMain, UnitMainTools, UnitLanguages;
|
||||||
|
|
||||||
|
function IsAtStart(eSubStr, eStr: String; AllowFunctions: Boolean = True): Boolean;
|
||||||
|
begin
|
||||||
|
eStr := LowerCase(Trim(StringReplace(eStr, #9, #32, [rfReplaceAll])));
|
||||||
|
eSubStr := LowerCase(eSubStr);
|
||||||
|
if Pos(eSubStr + #32, eStr) = 1 then
|
||||||
|
Result := True
|
||||||
|
else if (Pos(eSubStr + '(', eStr) = 1) and (AllowFunctions) then
|
||||||
|
Result := True
|
||||||
|
else
|
||||||
|
Result := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function GetIndents(Line: Integer = -1): String;
|
||||||
|
var i: integer;
|
||||||
|
begin
|
||||||
|
Result := '';
|
||||||
|
if Line = -1 then
|
||||||
|
Line := frmMain.sciEditor.GetCurrentLineNumber;
|
||||||
|
|
||||||
|
if Length(frmMain.sciEditor.Lines[Line]) <> 0 then begin
|
||||||
|
for i := 1 to Length(frmMain.sciEditor.Lines[Line]) do begin
|
||||||
|
if (frmMain.sciEditor.Lines[Line][i] <> #32) and (frmMain.sciEditor.Lines[Line][i] <> #9) then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
Result := Result + frmMain.sciEditor.Lines[Line][i];
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function GetStyleAt(ePos: Integer): TSciStyle;
|
||||||
|
var eBits: Integer;
|
||||||
|
eStyleNo: Byte;
|
||||||
|
i: integer;
|
||||||
|
begin
|
||||||
|
Result := nil;
|
||||||
|
|
||||||
|
eStyleNo := Byte(frmMain.sciEditor.GetStyleAt(ePos));
|
||||||
|
eBits := frmMain.sciEditor.GetStyleBits;
|
||||||
|
|
||||||
|
if eBits = 5 then
|
||||||
|
eStyleNo := eStyleNo and $1f //Strip away the indicators (3 bits)
|
||||||
|
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)
|
||||||
|
|
||||||
|
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;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function LineFromPos(ePos: Integer): Integer;
|
||||||
|
var i: integer;
|
||||||
|
eLength: Integer;
|
||||||
|
begin
|
||||||
|
Result := -1;
|
||||||
|
eLength := 0;
|
||||||
|
|
||||||
|
for i := 0 to frmMain.sciEditor.Lines.Count -1 do begin
|
||||||
|
eLength := eLength + Length(frmMain.sciEditor.Lines[i]);
|
||||||
|
if eLength >= ePos then begin
|
||||||
|
Result := i;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function RemoveSemicolon(eStr: String): String;
|
||||||
|
begin
|
||||||
|
if Length(eStr) <> 0 then begin
|
||||||
|
if eStr[Length(eStr)] = ';' then
|
||||||
|
Result := Copy(eStr, 1, Length(eStr) -1)
|
||||||
|
else
|
||||||
|
Result := eStr;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Result := eStr;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure IndentCode;
|
||||||
|
var eStr: TStringList;
|
||||||
|
i, k: integer;
|
||||||
|
eIdent, eTempIdent: Integer;
|
||||||
|
eString: String;
|
||||||
|
begin
|
||||||
|
Screen.Cursor := crHourGlass;
|
||||||
|
frmMain.sciEditor.Enabled := False;
|
||||||
|
eStr := TStringList.Create;
|
||||||
|
eIdent := 0;
|
||||||
|
eTempIdent := 0;
|
||||||
|
|
||||||
|
ShowProgress;
|
||||||
|
frmMain.pbLoading.Max := frmMain.sciEditor.Lines.Count *2 -2;
|
||||||
|
for i := 0 to frmMain.sciEditor.Lines.Count -1 do begin
|
||||||
|
if Cancel then begin
|
||||||
|
Cancel := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
eStr.Add(TrimLeft(frmMain.sciEditor.Lines[i]));
|
||||||
|
// Remove strings and comments virtually because they could include brackets
|
||||||
|
frmMain.pbLoading.Position := i;
|
||||||
|
SetProgressStatus('Indenting Code...');
|
||||||
|
eStr[i] := RemoveStringsAndComments(eStr[i], True);
|
||||||
|
end;
|
||||||
|
|
||||||
|
for i := 0 to eStr.Count -1 do begin
|
||||||
|
if CountChars(eStr[i], '{') <> CountChars(eStr[i], '}') then
|
||||||
|
eIdent := eIdent - CountChars(eStr[i], '}');
|
||||||
|
frmMain.sciEditor.Lines[i] := TrimLeft(frmMain.sciEditor.Lines[i]);
|
||||||
|
|
||||||
|
for k := 1 to eIdent + eTempIdent do
|
||||||
|
frmMain.sciEditor.Lines[i] := ' ' + frmMain.sciEditor.Lines[i];
|
||||||
|
if eTempIdent <> 0 then
|
||||||
|
eTempIdent := eTempIdent -1;
|
||||||
|
|
||||||
|
if (IsAtStart('if', eStr[i], True)) and (Pos('{', eStr[i]) = 0) and (Length(eStr[i]) > 3) then begin
|
||||||
|
eString := eStr[i];
|
||||||
|
Delete(eString, 1, 2);
|
||||||
|
if (eString[1] <> Trim(eString)[1]) or (eString[1] = '(') then begin
|
||||||
|
eString := Trim(eString);
|
||||||
|
if GetMatchingBrace(eString) = Length(eString) then
|
||||||
|
eTempIdent := eTempIdent +1;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else if (IsAtStart('for', eStr[i], True)) and (Pos('{', eStr[i]) = 0) and (Length(eStr[i]) > 4) then begin
|
||||||
|
eString := eStr[i];
|
||||||
|
Delete(eString, 1, 3);
|
||||||
|
if (eString[1] <> Trim(eString)[1]) or (eString[1] = '(') then begin
|
||||||
|
eString := Trim(eString);
|
||||||
|
if GetMatchingBrace(eString) = Length(eString) then
|
||||||
|
eTempIdent := eTempIdent +1;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else if (IsAtStart('else', eStr[i], False)) and (Pos('{', eStr[i]) = 0) and (Length(eStr[i]) > 5) 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;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else if (Pos('{', eStr[i]) = 0) and (Length(eStr[i]) > 6) then begin
|
||||||
|
if (IsAtStart('stock', eStr[i], False)) or (IsAtStart('while', eStr[i], True)) then begin
|
||||||
|
eString := eStr[i];
|
||||||
|
Delete(eString, 1, 5);
|
||||||
|
if (eString[1] <> Trim(eString)[1]) or (eString[1] = '(') then begin
|
||||||
|
eString := Trim(eString);
|
||||||
|
if GetMatchingBrace(eString) = Length(eString) then
|
||||||
|
eTempIdent := eTempIdent +1;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if (Pos('{', eStr[i]) = 0) and (Length(eStr[i]) > 7) then begin
|
||||||
|
if (Pos('public', eStr[i]) = 1) or (Pos('native', eStr[i]) = 1) then begin
|
||||||
|
eString := eStr[i];
|
||||||
|
Delete(eString, 1, 6);
|
||||||
|
if eString[1] <> Trim(eString)[1] then begin
|
||||||
|
eString := Trim(eString);
|
||||||
|
if GetMatchingBrace(eString) = Length(eString) then
|
||||||
|
eTempIdent := eTempIdent +1;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else if (IsAtStart('forward', eStr[i], False)) and (Pos('{', eStr[i]) = 0) and (Length(eStr[i]) > 8) then begin
|
||||||
|
eString := eStr[i];
|
||||||
|
Delete(eString, 1, 7);
|
||||||
|
if eString[1] <> Trim(eString)[1] then begin
|
||||||
|
eString := Trim(eString);
|
||||||
|
if GetMatchingBrace(eString) = Length(eString) then
|
||||||
|
eTempIdent := eTempIdent +1;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if CountChars(eStr[i], '{') <> CountChars(eStr[i], '}') then
|
||||||
|
eIdent := eIdent + CountChars(eStr[i], '{');
|
||||||
|
|
||||||
|
frmMain.pbLoading.Position := frmMain.sciEditor.Lines.Count + i -1;
|
||||||
|
SetProgressStatus('Indenting Code...');
|
||||||
|
end;
|
||||||
|
|
||||||
|
ActiveDoc.Modified := True;
|
||||||
|
frmMain.mnuModified.Caption := lModified;
|
||||||
|
HideProgress;
|
||||||
|
|
||||||
|
frmMain.sciEditor.Enabled := True;
|
||||||
|
Screen.Cursor := crDefault;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure UnindentCode;
|
||||||
|
var i: integer;
|
||||||
|
begin
|
||||||
|
Screen.Cursor := crHourGlass;
|
||||||
|
frmMain.sciEditor.Enabled := False;
|
||||||
|
ShowProgress;
|
||||||
|
frmMain.pbLoading.Max := frmMain.sciEditor.Lines.Count -1;
|
||||||
|
for i := 0 to frmMain.sciEditor.Lines.Count -1 do begin
|
||||||
|
if Cancel then begin
|
||||||
|
Cancel := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
frmMain.sciEditor.Lines[i] := TrimLeft(frmMain.sciEditor.Lines[i]);
|
||||||
|
frmMain.pbLoading.Position := i;
|
||||||
|
SetProgressStatus('Unintending Code...');
|
||||||
|
end;
|
||||||
|
HideProgress;
|
||||||
|
frmMain.sciEditor.Enabled := True;
|
||||||
|
Screen.Cursor := crDefault;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function RemoveStringsAndComments(eLine: String; eRemoveStrings: 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
|
||||||
|
// Remove quotes
|
||||||
|
if eRemoveStrings then begin
|
||||||
|
while CountChars(eLine, '"') > 1 do
|
||||||
|
eLine := StringReplace(eLine, '"' + Between(eLine, '"', '"') + '"', '', [rfReplaceAll]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Result := eLine;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure Delay(eTime: Integer);
|
||||||
|
var i: integer;
|
||||||
|
begin
|
||||||
|
for i := 1 to eTime do begin
|
||||||
|
Sleep(1);
|
||||||
|
Application.ProcessMessages;
|
||||||
|
if Application.Terminated then
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function CountChars(eIn: String; eChar: Char): Integer;
|
||||||
|
var i: integer;
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
if Length(eIn) <> 0 then begin
|
||||||
|
for i := 1 to Length(eIn) do begin
|
||||||
|
if eIn[i] = eChar then
|
||||||
|
Inc(Result, 1);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Between(eText, eFirst, eSecond: String): 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);
|
||||||
|
Delete(eTemp, Pos(eSecond, eTemp), Length(eTemp));
|
||||||
|
Result := eTemp;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function GetMatchingBrace(eString: String): Integer;
|
||||||
|
var a, b,c : integer;
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
if Length(eString) < 1 then exit;
|
||||||
|
|
||||||
|
b := 0;
|
||||||
|
c := 0;
|
||||||
|
|
||||||
|
for a := 1 to Length(eString) do begin
|
||||||
|
if eString[a] = '(' then begin
|
||||||
|
b := b +1;
|
||||||
|
c := 1;
|
||||||
|
end
|
||||||
|
else if eString[a] = ')' then begin
|
||||||
|
b := b -1;
|
||||||
|
c := 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if (b = 0) and (c = 1) then begin
|
||||||
|
Result := a;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function GetColoredLine(eLine: Integer): String;
|
||||||
|
var eCurrStyle: String;
|
||||||
|
eChars: Integer;
|
||||||
|
i: integer;
|
||||||
|
begin
|
||||||
|
eChars := 0;
|
||||||
|
if eLine <> 0 then begin
|
||||||
|
for i := 0 to eLine -1 do
|
||||||
|
eChars := eChars + Length(frmMain.sciEditor.Lines[i]) + 2; // +2 for #13#10
|
||||||
|
end;
|
||||||
|
|
||||||
|
eCurrStyle := '';
|
||||||
|
Result := IntToStr(eLine +1) + '] ';
|
||||||
|
if Length(frmMain.sciEditor.Lines[eLine]) = 0 then exit;
|
||||||
|
|
||||||
|
for i := 0 to Length(frmMain.sciEditor.Lines[eLine]) -1 do begin
|
||||||
|
if eCurrStyle <> GetStyleAt(eChars + i).Name then begin
|
||||||
|
eCurrStyle := GetStyleAt(eChars + i).Name;
|
||||||
|
|
||||||
|
if (eCurrStyle = 'White Space') and (Length(Result) <> Length(IntToStr(eLine +1) + '] ')) then
|
||||||
|
Result := Result + '';
|
||||||
|
if eCurrStyle = 'Ok Braces' then
|
||||||
|
Result := Result + '02';
|
||||||
|
if eCurrStyle = 'Bad Braces' then
|
||||||
|
Result := Result + '04';
|
||||||
|
if eCurrStyle = 'White Space' then
|
||||||
|
Result := Result + '12';
|
||||||
|
if eCurrStyle = 'Comment' then
|
||||||
|
Result := Result + '07';
|
||||||
|
if eCurrStyle = 'Line Comment' then
|
||||||
|
Result := Result + '07';
|
||||||
|
if eCurrStyle = 'Doc Comment' then
|
||||||
|
Result := Result + '07';
|
||||||
|
if eCurrStyle = 'Number' then
|
||||||
|
Result := Result + '12';
|
||||||
|
if eCurrStyle = 'Keyword' then
|
||||||
|
Result := Result + '03';
|
||||||
|
if eCurrStyle = 'Double quoted string' then
|
||||||
|
Result := Result + '04';
|
||||||
|
if eCurrStyle = 'Single quoted string' then
|
||||||
|
Result := Result + '04';
|
||||||
|
if eCurrStyle = 'Symbols/UUID' then
|
||||||
|
Result := Result + '04';
|
||||||
|
if eCurrStyle = 'Preprocessor' then
|
||||||
|
Result := Result + '07';
|
||||||
|
if eCurrStyle = 'Operators' then
|
||||||
|
Result := Result + '12';
|
||||||
|
if eCurrStyle = 'Identifier' then
|
||||||
|
Result := Result + '12';
|
||||||
|
if eCurrStyle = 'Regular expressions' then
|
||||||
|
Result := Result + '10';
|
||||||
|
if eCurrStyle = 'Doc Comment Line' then
|
||||||
|
Result := Result + '07';
|
||||||
|
if eCurrStyle = 'User-defined keywords' then
|
||||||
|
Result := Result + '04';
|
||||||
|
end;
|
||||||
|
Result := Result + frmMain.sciEditor.Lines[eLine][i +1];
|
||||||
|
end;
|
||||||
|
Result := StringReplace(Result, ' ', ' ', [rfReplaceAll]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ ------------------ NOTES ------------------ }
|
||||||
|
|
||||||
|
function GetRTFText(ARichEdit: TRichedit): string;
|
||||||
|
var
|
||||||
|
ss: TStringStream;
|
||||||
|
emptystr: string;
|
||||||
|
|
||||||
|
eStr: TStringList;
|
||||||
|
i: integer;
|
||||||
|
begin
|
||||||
|
Result := '';
|
||||||
|
|
||||||
|
emptystr := '';
|
||||||
|
ss := TStringStream.Create(emptystr);
|
||||||
|
eStr := TStringList.Create;
|
||||||
|
try
|
||||||
|
ARichEdit.PlainText := False;
|
||||||
|
ARichEdit.Lines.SaveToStream(ss);
|
||||||
|
eStr.Text := StringReplace(ss.DataString, '\', '\\ ', [rfReplaceAll]);
|
||||||
|
for i := 0 to eStr.Count -1 do
|
||||||
|
Result := Result + '\n' + eStr[i];
|
||||||
|
Delete(Result, 1, 2);
|
||||||
|
finally
|
||||||
|
ss.Free;
|
||||||
|
eStr.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure SetRTFText(ARichEdit: TRichedit; ARTFText: String);
|
||||||
|
var
|
||||||
|
ss: TStringStream;
|
||||||
|
begin
|
||||||
|
ARTFText := StringReplace(ARTFText, '\n', #13#10, [rfReplaceAll]);
|
||||||
|
ARTFText := StringReplace(ARTFText, '\\ ', '\', [rfReplaceAll]);
|
||||||
|
|
||||||
|
ss := TStringStream.Create(ARTFText);
|
||||||
|
try
|
||||||
|
ARichEdit.PlainText := False;
|
||||||
|
ARichEdit.Lines.LoadFromStream(ss);
|
||||||
|
finally
|
||||||
|
ss.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
300
editor/studio/UnitCompile.pas
Executable file
300
editor/studio/UnitCompile.pas
Executable file
|
@ -0,0 +1,300 @@
|
||||||
|
unit UnitCompile;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses SysUtils, Classes, Windows, Forms, Controls, ShellAPI, Messages, IdFTP,
|
||||||
|
IdFTPCommon;
|
||||||
|
|
||||||
|
type TPAWNCompileThread = class(TThread)
|
||||||
|
protected
|
||||||
|
Stream: TStringStream;
|
||||||
|
|
||||||
|
Output: TStringList;
|
||||||
|
Finished: Boolean;
|
||||||
|
procedure Execute; override;
|
||||||
|
procedure ProcessItem(eLineStr: String);
|
||||||
|
procedure AddOutput;
|
||||||
|
procedure StartHL;
|
||||||
|
procedure Upload;
|
||||||
|
public
|
||||||
|
FileName: string;
|
||||||
|
Compiler: string;
|
||||||
|
Args: string;
|
||||||
|
Target: string;
|
||||||
|
Flags: Integer;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function DoCompilePAWN(eFlags: Integer): Boolean;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses UnitfrmSettings, UnitLanguages, UnitMainTools, UnitfrmMain,
|
||||||
|
UnitCodeUtils, UnitPlugins;
|
||||||
|
|
||||||
|
function DoCompilePAWN(eFlags: Integer): Boolean;
|
||||||
|
var eFile: string;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
if not FileExists(frmSettings.txtPAWNCompilerPath.Text) then begin
|
||||||
|
MessageBox(frmMain.Handle, PChar(lPAWNCompilerNotFound), PChar(Application.Title), MB_ICONERROR);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Screen.Cursor := crHourGlass;
|
||||||
|
if (ActiveDoc.Untitled) then
|
||||||
|
eFile := ExtractFilePath(ParamStr(0)) + 'Untitled.sma'
|
||||||
|
else
|
||||||
|
eFile := ActiveDoc.FileName;
|
||||||
|
frmMain.sciEditor.Lines.SaveToFile(eFile);
|
||||||
|
|
||||||
|
if Plugin_VisibleControlChange(CTRL_OUTPUT, True) then begin
|
||||||
|
frmMain.lstOutput.Clear;
|
||||||
|
frmMain.splOutput.Show;
|
||||||
|
frmMain.lstOutput.Show;
|
||||||
|
Plugin_VisibleControlChange(CTRL_OUTPUT, True);
|
||||||
|
end;
|
||||||
|
|
||||||
|
with TPawnCompileThread.Create(True) do begin
|
||||||
|
FileName := eFile;
|
||||||
|
Compiler := frmSettings.txtPAWNCompilerPath.Text;
|
||||||
|
if DirectoryExists(frmSettings.txtPAWNOutput.Text) then
|
||||||
|
Target := IncludeTrailingPathDelimiter(frmSettings.txtPAWNOutput.Text) + ChangeFileExt(ExtractFileName(ActiveDoc.FileName), '.amxx')
|
||||||
|
else
|
||||||
|
Target := ChangeFileExt(eFile, '.amxx');
|
||||||
|
|
||||||
|
Args := frmSettings.txtPAWNArgs.Text;
|
||||||
|
if Args <> '' then
|
||||||
|
Args := Args + #32;
|
||||||
|
Flags := eFlags;
|
||||||
|
|
||||||
|
Resume;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TPAWNCompileThread }
|
||||||
|
|
||||||
|
procedure TPAWNCompileThread.ProcessItem(eLineStr: String);
|
||||||
|
var eLine: Integer;
|
||||||
|
eTemp: String;
|
||||||
|
begin
|
||||||
|
eLine := -1;
|
||||||
|
if Pos(LowerCase(FileName), LowerCase(eLineStr)) = 1 then begin
|
||||||
|
Delete(eLineStr, 1, Length(FileName));
|
||||||
|
if IsNumeric(Between(eLineStr, '(', ')')) then
|
||||||
|
eLine := StrToInt(Between(eLineStr, '(', ')'));
|
||||||
|
|
||||||
|
eTemp := Between(eLineStr, ':', ':');
|
||||||
|
|
||||||
|
Delete(eLineStr, 1, Pos(':', eLineStr) +1);
|
||||||
|
Delete(eLineStr, 1, Pos(':', eLineStr) +1);
|
||||||
|
if eLineStr <> '' then
|
||||||
|
eLineStr[1] := UpperCase(eLineStr[1])[1];
|
||||||
|
if Pos('error', eTemp) <> 0 then
|
||||||
|
eLineStr := Format(lError, [Trim(eLineStr), eLine])
|
||||||
|
else if Pos('warning', eTemp) <> 0 then
|
||||||
|
eLineStr := Format(lWarning, [Trim(eLineStr), eLine])
|
||||||
|
else
|
||||||
|
eLineStr := Format(lOther, [Trim(eLineStr), eLine]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
if frmMain.lstOutput.ItemIndex = -1 then begin
|
||||||
|
if Pos('error', eTemp) <> 0 then begin
|
||||||
|
frmMain.lstOutput.SetFocus;
|
||||||
|
frmMain.lstOutput.ItemIndex := frmMain.lstOutput.Items.Add(eLineStr);
|
||||||
|
frmMain.SetErrorLine(eLine);
|
||||||
|
end
|
||||||
|
else if eLineStr = 'Done.' then begin
|
||||||
|
if (DirectoryExists(GetAMXXDir(True) + 'plugins\')) and (GetAMXXDir(True) <> '') then begin
|
||||||
|
if LowerCase(IncludeTrailingPathDelimiter(frmSettings.txtPAWNOutput.Text)) <> LowerCase(GetAMXXDir(True) + 'plugins\') then begin
|
||||||
|
if FileExists(GetAMXXDir(True) + 'plugins\' + ChangeFileExt(ExtractFileName(ActiveDoc.FileName), '.amxx')) then
|
||||||
|
DeleteFile(PChar(GetAMXXDir(True) + 'plugins\' + ChangeFileExt(ExtractFileName(ActiveDoc.FileName), '.amxx')));
|
||||||
|
if frmSettings.txtPAWNOutput.Text = '' then
|
||||||
|
CopyFile(PChar(ChangeFileExt(ActiveDoc.FileName, '.amxx')), PChar(GetAMXXDir(True) + 'plugins\' + ChangeFileExt(ExtractFileName(ActiveDoc.FileName), '.amxx')), False)
|
||||||
|
else
|
||||||
|
CopyFile(PChar(frmSettings.txtPAWNOutput.Text + ChangeFileExt(ExtractFileName(ActiveDoc.FileName), '.amxx')), PChar(GetAMXXDir(True) + 'plugins\' + ChangeFileExt(ExtractFileName(ActiveDoc.FileName), '.amxx')), False);
|
||||||
|
frmMain.lstOutput.Items.Add('Copied output file to: ' + GetAMXXDir(True)+ 'plugins\');
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if Flags = COMP_STARTHL then // Start HL
|
||||||
|
Synchronize(StartHL)
|
||||||
|
else if Flags = COMP_UPLOAD then
|
||||||
|
Synchronize(Upload)
|
||||||
|
else begin
|
||||||
|
frmMain.lstOutput.ItemIndex := frmMain.lstOutput.Items.Add('Done.');
|
||||||
|
frmMain.lstOutput.Perform(WM_VSCROLL, SB_BOTTOM, 0);
|
||||||
|
end;
|
||||||
|
Plugin_Compile(Flags, GetCurrLang.Name, ActiveDoc.FileName, False);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
frmMain.lstOutput.Items.Add(eLineStr);
|
||||||
|
frmMain.lstOutput.Perform(WM_VSCROLL, SB_BOTTOM, 0);
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
frmMain.lstOutput.Items.Add(eLineStr);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPAWNCompileThread.AddOutput;
|
||||||
|
var i, eIndex: integer;
|
||||||
|
begin
|
||||||
|
if Output.Count > 1 then begin
|
||||||
|
eIndex := frmMain.lstOutput.ItemIndex;
|
||||||
|
frmMain.lstOutput.Items.BeginUpdate;
|
||||||
|
frmMain.lstOutput.Items.Clear;
|
||||||
|
if Finished then begin
|
||||||
|
for i := 0 to Output.Count -1 do
|
||||||
|
ProcessItem(Output[i]);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
for i := 0 to Output.Count -2 do
|
||||||
|
ProcessItem(Output[i]);
|
||||||
|
end;
|
||||||
|
frmMain.lstOutput.Items.EndUpdate;
|
||||||
|
frmMain.lstOutput.ItemIndex := eIndex;
|
||||||
|
frmMain.Repaint;
|
||||||
|
Application.ProcessMessages;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPAWNCompileThread.Execute;
|
||||||
|
var StartupInfo: TStartupInfo;
|
||||||
|
ProcessInfo: TProcessInformation;
|
||||||
|
SecurityAttr: TSecurityAttributes;
|
||||||
|
PipeOutputRead: THandle;
|
||||||
|
PipeOutputWrite: THandle;
|
||||||
|
PipeErrorsRead: THandle;
|
||||||
|
PipeErrorsWrite: THandle;
|
||||||
|
Succeed: Boolean;
|
||||||
|
Buffer: array[0..255] of Char;
|
||||||
|
NumberOfBytesRead: DWORD;
|
||||||
|
begin
|
||||||
|
Output := TStringList.Create;
|
||||||
|
FillChar(ProcessInfo, SizeOf(TProcessInformation), 0);
|
||||||
|
FillChar(SecurityAttr, SizeOf(TSecurityAttributes), 0);
|
||||||
|
SecurityAttr.nLength := SizeOf(SecurityAttr);
|
||||||
|
SecurityAttr.bInheritHandle := True;
|
||||||
|
SecurityAttr.lpSecurityDescriptor := nil;
|
||||||
|
CreatePipe(PipeOutputRead, PipeOutputWrite, @SecurityAttr, 0);
|
||||||
|
CreatePipe(PipeErrorsRead, PipeErrorsWrite, @SecurityAttr, 0);
|
||||||
|
FillChar(StartupInfo, SizeOf(TStartupInfo), 0);
|
||||||
|
StartupInfo.cb := SizeOf(StartupInfo);
|
||||||
|
StartupInfo.hStdInput := 0;
|
||||||
|
StartupInfo.hStdOutput := PipeOutputWrite;
|
||||||
|
StartupInfo.hStdError := PipeErrorsWrite;
|
||||||
|
StartupInfo.wShowWindow := SW_HIDE;
|
||||||
|
StartupInfo.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
|
||||||
|
if CreateProcess(nil, PChar(Compiler + ' "' + FileName + '" ' + Args + '"-o' + Target + '"'), nil, nil, True, CREATE_DEFAULT_ERROR_MODE or CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo) then begin
|
||||||
|
CloseHandle(PipeOutputWrite);
|
||||||
|
CloseHandle(PipeErrorsWrite);
|
||||||
|
|
||||||
|
Stream := TStringStream.Create('');
|
||||||
|
try
|
||||||
|
Finished := False;
|
||||||
|
while True do begin
|
||||||
|
Succeed := ReadFile(PipeOutputRead, Buffer, 255, NumberOfBytesRead, nil);
|
||||||
|
if not Succeed then break;
|
||||||
|
Stream.Write(Buffer, NumberOfBytesRead);
|
||||||
|
Output.Text := Stream.DataString;
|
||||||
|
Synchronize(AddOutput);
|
||||||
|
end;
|
||||||
|
Finished := True;
|
||||||
|
Synchronize(AddOutput);
|
||||||
|
finally
|
||||||
|
Stream.Free;
|
||||||
|
end;
|
||||||
|
CloseHandle(PipeOutputRead);
|
||||||
|
try
|
||||||
|
while True do begin
|
||||||
|
Succeed := ReadFile(PipeErrorsRead, Buffer, 255, NumberOfBytesRead, nil);
|
||||||
|
if not Succeed then Break;
|
||||||
|
{ and here the errors }
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
end;
|
||||||
|
CloseHandle(PipeErrorsRead);
|
||||||
|
WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
|
||||||
|
CloseHandle(ProcessInfo.hProcess);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
CloseHandle(PipeOutputRead);
|
||||||
|
CloseHandle(PipeOutputWrite);
|
||||||
|
CloseHandle(PipeErrorsRead);
|
||||||
|
CloseHandle(PipeErrorsWrite);
|
||||||
|
end;
|
||||||
|
Screen.Cursor := crDefault;
|
||||||
|
Output.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPAWNCompileThread.StartHL;
|
||||||
|
begin
|
||||||
|
frmMain.lstOutput.ItemIndex := frmMain.lstOutput.Items.Add('Done.');
|
||||||
|
frmMain.lstOutput.Items.Add('');
|
||||||
|
frmMain.lstOutput.ItemIndex := frmMain.lstOutput.Items.Add(lStartingHalfLife);
|
||||||
|
if (FileExists(frmSettings.txtHLExec.Text)) and (frmSettings.txtHLExec.Text <> '') then begin
|
||||||
|
ShellExecute(frmMain.Handle, 'open', PChar(frmSettings.txtHLExec.Text), PChar(frmSettings.txtCustomParameters.Text), PChar(ExtractFilePath(frmSettings.txtHLExec.Text)), SW_SHOW);
|
||||||
|
frmMain.lstOutput.ItemIndex := frmMain.lstOutput.Items.Add('Done.');
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
frmMain.lstOutput.ItemIndex := frmMain.lstOutput.Items.Add(lHLNotFound);
|
||||||
|
frmMain.lstOutput.ItemIndex := frmMain.lstOutput.Items.Add(lCheckSettingsTryAgain);
|
||||||
|
MessageBeep(MB_ICONWARNING);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPAWNCompileThread.Upload;
|
||||||
|
procedure AddOutput(eItem: String);
|
||||||
|
var eAddedIndex: Integer;
|
||||||
|
begin
|
||||||
|
eAddedIndex := frmMain.lstOutput.Items.Add(eItem);
|
||||||
|
|
||||||
|
frmMain.lstOutput.ItemIndex := eAddedIndex;
|
||||||
|
repeat
|
||||||
|
Delay(50);
|
||||||
|
frmMain.lstOutput.Repaint;
|
||||||
|
until frmMain.lstOutput.ItemIndex = eAddedIndex;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
AddOutput('Done.');
|
||||||
|
if frmMain.IdFTP.Connected then
|
||||||
|
frmMain.IdFTP.Disconnect;
|
||||||
|
|
||||||
|
AddOutput('');
|
||||||
|
AddOutput(lConnecting);
|
||||||
|
|
||||||
|
if TryConnect = 0 then begin
|
||||||
|
AddOutput(lChangingDir);
|
||||||
|
|
||||||
|
try
|
||||||
|
frmMain.IdFTP.ChangeDir(frmSettings.txtDefaultDir.Text + 'plugins/');
|
||||||
|
AddOutput(lUploadingFile);
|
||||||
|
except
|
||||||
|
MessageBox(frmMain.Handle, PChar(lInvalidDirectory), PChar(Application.Title), MB_ICONERROR);
|
||||||
|
AddOutput(lUploadFailed);
|
||||||
|
|
||||||
|
if frmMain.IdFTP.Connected then
|
||||||
|
frmMain.IdFTP.Disconnect;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
try
|
||||||
|
frmMain.IdFTP.TransferType := ftBinary;
|
||||||
|
frmMain.IdFTP.Put(Target, ExtractFileName(Target));
|
||||||
|
AddOutput(lDone);
|
||||||
|
except
|
||||||
|
on E: Exception do begin
|
||||||
|
MessageBox(frmMain.Handle, PChar(lErrorUpload + #13 + E.Message), PChar(Application.Title), MB_ICONERROR);
|
||||||
|
AddOutput(lUploadFailed);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if frmMain.IdFTP.Connected then
|
||||||
|
frmMain.IdFTP.Disconnect;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
AddOutput(lUploadFailed);
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
164
editor/studio/UnitLanguages.pas
Executable file
164
editor/studio/UnitLanguages.pas
Executable file
|
@ -0,0 +1,164 @@
|
||||||
|
unit UnitLanguages;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses SysUtils, IniFiles;
|
||||||
|
|
||||||
|
var lInvalidFile: String;
|
||||||
|
lWarnHighlighterReset: String;
|
||||||
|
lHighlighterResetDone: String;
|
||||||
|
lModified: String;
|
||||||
|
lLnCh: String;
|
||||||
|
lCloseModify: String;
|
||||||
|
lSelectOutputPAWN: String;
|
||||||
|
lSelectOutputCPP: String;
|
||||||
|
lDynamic: String;
|
||||||
|
lOutputHint: String;
|
||||||
|
lAddCodeSnippetCaption: String;
|
||||||
|
lAddCodeSnippetPrompt: String;
|
||||||
|
lEmptyCodeSnippetTitle: String;
|
||||||
|
lCodeSnippetExists: String;
|
||||||
|
lEnterSearchText: String;
|
||||||
|
lPrintSelection: String;
|
||||||
|
lNoFilesToSave: String;
|
||||||
|
lSaveAllCaption1: String;
|
||||||
|
lSaveAllCaption2: String;
|
||||||
|
lCloseAllCaption1: String;
|
||||||
|
lCloseAllCaption2: String;
|
||||||
|
lNoMIRCWindowOpen: String;
|
||||||
|
lSelectChannel: String;
|
||||||
|
lSelectChannelPrompt: String;
|
||||||
|
lWarnBigPluginPaste: String;
|
||||||
|
lConnect: String;
|
||||||
|
lConnecting: String;
|
||||||
|
lDisconnect: String;
|
||||||
|
lLoginIncorrect: String;
|
||||||
|
lHostNotFound: String;
|
||||||
|
lConnectionRefused: String;
|
||||||
|
lWrongPort: String;
|
||||||
|
lScanning: String;
|
||||||
|
lFillInEachField: String;
|
||||||
|
lPastingCodeEscStop: String;
|
||||||
|
lInvalidDirectory: String;
|
||||||
|
lFailedLoadNotes: String;
|
||||||
|
lPAWNCompilerNotFound: String;
|
||||||
|
lError: String;
|
||||||
|
lWarning: String;
|
||||||
|
lOnLine: String;
|
||||||
|
lOther: String;
|
||||||
|
lStartingHalfLife: String;
|
||||||
|
lHLNotFound: String;
|
||||||
|
lCheckSettingsTryAgain: String;
|
||||||
|
lUploadingFile: String;
|
||||||
|
lErrorUpload: String;
|
||||||
|
lChangingDir: String;
|
||||||
|
lDone: String;
|
||||||
|
lUploadFailed: String;
|
||||||
|
lNoUntitledRegister: String;
|
||||||
|
lAlreadyRegistered: String;
|
||||||
|
lSuccessfulRegistered: String;
|
||||||
|
lFailedUpdatePluginsIni: String;
|
||||||
|
lInternetExplorerRequired: String;
|
||||||
|
lUseMOTDAgain: String;
|
||||||
|
lName: String;
|
||||||
|
lType: String;
|
||||||
|
lValue: String;
|
||||||
|
lVariable: String;
|
||||||
|
lAddItemCaption: String;
|
||||||
|
lAddItemPrompt: String;
|
||||||
|
lEnterTitle: String;
|
||||||
|
lAddItems: String;
|
||||||
|
lInvalidPlugin: String;
|
||||||
|
lPlayersAlreadyAdded: String;
|
||||||
|
lFailedLoadCache: String;
|
||||||
|
lAlreadyUnLoaded: String;
|
||||||
|
lAlreadyLoaded: String;
|
||||||
|
lSelectAMXXCaption: String;
|
||||||
|
lPluginError: String;
|
||||||
|
lSaveCaption: String;
|
||||||
|
lCloseCaption: String;
|
||||||
|
lNoCPP: String;
|
||||||
|
|
||||||
|
procedure ResetToEnglish;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
procedure ResetToEnglish;
|
||||||
|
begin
|
||||||
|
// Messages
|
||||||
|
lInvalidFile := 'The file couldn''t be found. Check the path and try again.';
|
||||||
|
lWarnHighlighterReset := 'Warning: All settings concerning the editor will be reset to default. Continue?';
|
||||||
|
lHighlighterResetDone := 'Reset successful. Restart AMXX-Studio and the changes will take affect.';
|
||||||
|
lModified := 'Modified';
|
||||||
|
lLnCh := 'Ln %u Ch %u';
|
||||||
|
lCloseModify := 'The file "%s" has been modified. Save it before closing?';
|
||||||
|
lSelectOutputPAWN := 'Please select the default output folder for compiled PAWN Plug-Ins:';
|
||||||
|
lSelectOutputCPP := 'Please select the default output folder for compiled C++ libraries:';
|
||||||
|
lDynamic := 'Dynamic';
|
||||||
|
lOutputHint := 'The output will be copied to the source''s directory.';
|
||||||
|
lAddCodeSnippetCaption := 'Add Code-Snippet';
|
||||||
|
lAddCodeSnippetPrompt := 'Please enter the title of the new Code-Snippet:';
|
||||||
|
lEmptyCodeSnippetTitle := 'You have to enter a title before adding a new Code-Snippet!';
|
||||||
|
lCodeSnippetExists := 'The entered Code-Snippet is already added. Please select another title.';
|
||||||
|
lEnterSearchText := 'You forgot to enter the text you want to search.';
|
||||||
|
lPrintSelection := 'Print only selection?';
|
||||||
|
lNoFilesToSave := 'There are no modified files to save!';
|
||||||
|
lSaveAllCaption1 := 'Save all files';
|
||||||
|
lSaveAllCaption2 := 'Please select all files you want to save:';
|
||||||
|
lCloseAllCaption1 := 'Close all files';
|
||||||
|
lCloseAllCaption2 := 'Please select all files you want to close:';
|
||||||
|
lNoMIRCWindowOpen := 'You have to open mIRC first to use IRC Paster!';
|
||||||
|
lSelectChannel := 'Select channel';
|
||||||
|
lSelectChannelPrompt := 'Please enter the channel the code shall be sent to:';
|
||||||
|
lWarnBigPluginPaste := 'Warning: The plugin is quite large, if you post it to a channel it MAY result in a ban. Are you sure to paste it?';
|
||||||
|
lConnect := 'Connect';
|
||||||
|
lConnecting := 'Connecting...';
|
||||||
|
lDisconnect := 'Disconnect';
|
||||||
|
lLoginIncorrect := 'Login incorrect. Check your FTP settings and try again.';
|
||||||
|
lHostNotFound := 'The entered host couldn''t be found. Check your settings and try again.';
|
||||||
|
lConnectionRefused := 'The host refused the connection. Check your port and try again.';
|
||||||
|
lWrongPort := 'The port you entered is definitely wrong. Check it and try again.';
|
||||||
|
lScanning := 'Scanning...';
|
||||||
|
lFillInEachField := 'Please fill in each field!';
|
||||||
|
lPastingCodeEscStop := 'Pasting Code, press Esc to stop...';
|
||||||
|
lInvalidDirectory := 'Could not change FTP directory. Update it and try again.';
|
||||||
|
lFailedLoadNotes := 'Failed to load the notes!';
|
||||||
|
lPAWNCompilerNotFound := 'PAWN compiler not found. Please check your settings and try again.';
|
||||||
|
lError := 'Error: %s on line %u';
|
||||||
|
lWarning := 'Warning: %s on line %u';
|
||||||
|
lOther := '%s on line %u';
|
||||||
|
lStartingHalfLife := 'Starting Half-Life...';
|
||||||
|
lHLNotFound := 'Could not find the set Half-Life executable.';
|
||||||
|
lCheckSettingsTryAgain := 'Check your settings and try again.';
|
||||||
|
lUploadingFile := 'Done, uploading file...';
|
||||||
|
lErrorUpload := 'Failed to upload the plugin:';
|
||||||
|
lChangingDir := 'Connected, changing directory...';
|
||||||
|
lDone := 'Done.';
|
||||||
|
lUploadFailed := 'Upload failed!';
|
||||||
|
lNoUntitledRegister := 'You cannot register an untitled document';
|
||||||
|
lAlreadyRegistered := 'This plugin is already registered!';
|
||||||
|
lSuccessfulRegistered := 'The plugin has been registered successfully!';
|
||||||
|
lFailedUpdatePluginsIni := 'Failed to update plugins.ini!';
|
||||||
|
lInternetExplorerRequired := 'Microsoft Internet Explorer 6.0 is required to use this function.';
|
||||||
|
lUseMOTDAgain := 'When you finished, use this function again to convert the HTML code to a PAWN string.';
|
||||||
|
lName := 'Name';
|
||||||
|
lType := 'Type';
|
||||||
|
lValue := 'Value';
|
||||||
|
lVariable := 'Variable';
|
||||||
|
lAddItemCaption := 'Add menu item';
|
||||||
|
lAddItemPrompt := 'Please enter the menu item you want to add:';
|
||||||
|
lEnterTitle := 'You forgot to enter a title!';
|
||||||
|
lAddItems := 'You forgot to add the menu items!';
|
||||||
|
lInvalidPlugin := 'Couldn''t find the register_plugin()-event. Add it and try again.';
|
||||||
|
lPlayersAlreadyAdded := 'PLAYERS item is already added!';
|
||||||
|
lFailedLoadCache := 'Failed to load file cache!';
|
||||||
|
lAlreadyUnLoaded := 'Plugin is already unloaded!';
|
||||||
|
lAlreadyLoaded := 'Plugin is already loaded!';
|
||||||
|
lSelectAMXXCaption := 'Please select the AMX Mod X directory on your listen server:';
|
||||||
|
lPluginError := 'A plugin raised this error:';
|
||||||
|
lSaveCaption := 'Save';
|
||||||
|
lCloseCaption := 'Close';
|
||||||
|
lNoCPP := 'Sorry, the C++ IDE is not enabled.';
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
1196
editor/studio/UnitMainTools.pas
Executable file
1196
editor/studio/UnitMainTools.pas
Executable file
File diff suppressed because it is too large
Load Diff
548
editor/studio/UnitMenuGenerators.pas
Executable file
548
editor/studio/UnitMenuGenerators.pas
Executable file
|
@ -0,0 +1,548 @@
|
||||||
|
unit UnitMenuGenerators;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses SysUtils, Classes, Windows, Forms, Graphics;
|
||||||
|
|
||||||
|
procedure GenerateSimpleMenu;
|
||||||
|
|
||||||
|
{ Yes, this is from AMXX-Edit v2. I'm too lazy to rewrite it... }
|
||||||
|
{ >:( }
|
||||||
|
|
||||||
|
function AddOldMenu: Boolean;
|
||||||
|
function AddOldPlayerMenu: Boolean;
|
||||||
|
function GetFirst(eStart: String; eSearchMain: Boolean): Integer;
|
||||||
|
function GetLast(eStart: String; eSearchMain: Boolean): Integer;
|
||||||
|
function GetLine(eExpression: String; eAllowFunction, eBreak: Boolean): Integer;
|
||||||
|
function AddIfDoesntExist(eInclude: String): Boolean;
|
||||||
|
function GetColoredMenu: String;
|
||||||
|
function PluginInitLine: Integer;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses UnitCodeUtils, UnitfrmMain, UnitfrmMenuGenerator, UnitLanguages;
|
||||||
|
|
||||||
|
function GetLine(eExpression: String; eAllowFunction, eBreak: Boolean): Integer;
|
||||||
|
var i: integer;
|
||||||
|
begin
|
||||||
|
Result := -1;
|
||||||
|
for i := 0 to frmMain.sciEditor.Lines.Count -1 do begin
|
||||||
|
if IsAtStart(eExpression, frmMain.sciEditor.Lines[i], eAllowFunction) then begin
|
||||||
|
Result := i;
|
||||||
|
if eBreak then
|
||||||
|
Break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure GenerateSimpleMenu;
|
||||||
|
var eRP, eVL: Integer; // RegisterPlugin, VariableLine
|
||||||
|
eStr: TStringList;
|
||||||
|
eIndents, eInternalTitle: String;
|
||||||
|
i: integer;
|
||||||
|
begin
|
||||||
|
{ Get Line Numbers }
|
||||||
|
eVL := GetLine('#define', False, False);
|
||||||
|
if eVL = -1 then
|
||||||
|
eVL := GetLine('#include', False, False);
|
||||||
|
if eVL = -1 then
|
||||||
|
eVL := 0;
|
||||||
|
|
||||||
|
eRP := PluginInitLine;
|
||||||
|
|
||||||
|
if eRP <> -1 then begin
|
||||||
|
eInternalTitle := StringReplace(frmMenuGenerator.txtNTitle.Text, #32, '', [rfReplaceAll]);
|
||||||
|
eStr := TStringList.Create;
|
||||||
|
// Register Vars
|
||||||
|
eVL := eVL +1;
|
||||||
|
eIndents := GetIndents(eVL);
|
||||||
|
eStr.Add(eIndents + 'new m' + eInternalTitle + ' // Menu');
|
||||||
|
eStr.Add(eIndents + 'new mcb' + eInternalTitle + ' // Menu Callback');
|
||||||
|
frmMain.sciEditor.Lines.Insert(eVL, eStr.Text);
|
||||||
|
|
||||||
|
|
||||||
|
// Register function
|
||||||
|
eRP := PluginInitLine;
|
||||||
|
eIndents := GetIndents(eRP);
|
||||||
|
eStr.Clear;
|
||||||
|
eStr.Add(eIndents + '/* Menu ' + frmMenuGenerator.txtNTitle.Text + ' */');
|
||||||
|
eStr.Add(eIndents + '/* Use menu_display(id, m' + eInternalTitle + ', 0) to show the menu to an user. */');
|
||||||
|
eStr.Add(eIndents + 'm' + eInternalTitle + ' = menu_create("' + frmMenuGenerator.txtNTitle.Text + '", "mh_' + eInternalTitle + '")');
|
||||||
|
eStr.Add(eIndents + 'mcb' + eInternalTitle + ' = menu_makecallback("mcb_' + eInternalTitle + '")');
|
||||||
|
for i := 0 to frmMenuGenerator.lstNMenuItems.Items.Count -1 do
|
||||||
|
eStr.Add(eIndents + 'menu_additem(m' + eInternalTitle + ', "' + frmMenuGenerator.lstNMenuItems.Items[i] + '", "ma_' + eInternalTitle + '", ' + frmMenuGenerator.cboAccess.Text + ', mcb' + eInternalTitle + ')');
|
||||||
|
eStr.Add(eIndents + '/* Menu End */');
|
||||||
|
frmMain.sciEditor.Lines.Insert(eRP, eStr.Text);
|
||||||
|
// Rest
|
||||||
|
eStr.Clear;
|
||||||
|
eStr.Add('');
|
||||||
|
eStr.Add('');
|
||||||
|
eStr.Add('/* Menu ' + frmMenuGenerator.txtNTitle.Text + ' */');
|
||||||
|
eStr.Add('');
|
||||||
|
eStr.Add('public mh_' + eInternalTitle + '(id, menu, item) {');
|
||||||
|
eStr.Add(#9 + '/* This event is called when someone presses a key on this menu */');
|
||||||
|
eStr.Add('}');
|
||||||
|
eStr.Add('');
|
||||||
|
eStr.Add('public ma_' + eInternalTitle + '(id) {');
|
||||||
|
eStr.Add(#9 + '/* This event is called when an item was selected */');
|
||||||
|
eStr.Add('}');
|
||||||
|
eStr.Add('');
|
||||||
|
eStr.Add('public mcb_' + eInternalTitle + '(id, menu, item) {');
|
||||||
|
eStr.Add(#9 + '/* This is the callback-event, here you can set items enabled or disabled. */');
|
||||||
|
eStr.Add(#9 + '/* If you want to enable an item, use: return ITEM_ENABLED */');
|
||||||
|
eStr.Add(#9 + '/* If you want to disable an item, use: return ITEM_DISABLED */');
|
||||||
|
eStr.Add('}');
|
||||||
|
eStr.Add('');
|
||||||
|
frmMain.sciEditor.Lines.AddStrings(eStr);
|
||||||
|
|
||||||
|
eStr.Free;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
MessageBox(frmMenuGenerator.Handle, PChar(lInvalidPlugin), PChar(Application.Title), MB_ICONERROR);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ Normal Menu }
|
||||||
|
|
||||||
|
function AddOldMenu: Boolean;
|
||||||
|
var eColoredMenu, DefinedKeys: String;
|
||||||
|
i: integer;
|
||||||
|
eStr: TStringList;
|
||||||
|
begin
|
||||||
|
Result := GetFirst('public Show' + frmMenuGenerator.txtMenuName.Text, True) = -1;
|
||||||
|
if not Result then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
eStr := TStringList.Create;
|
||||||
|
{ Transform text }
|
||||||
|
eColoredMenu := GetColoredMenu;
|
||||||
|
{ Add functions }
|
||||||
|
eStr.Add(Format('public Show%s(id) {', [frmMenuGenerator.txtMenuName.Text]));
|
||||||
|
eStr.Add(' show_menu(id, Keys' + frmMenuGenerator.txtMenuName.Text + ', "' + eColoredMenu + '", -1, "' + frmMenuGenerator.txtMenuName.Text + '")');
|
||||||
|
if frmMenuGenerator.chkAddComment.Checked then
|
||||||
|
eStr[eStr.Count -1] := eStr[eStr.Count -1] + ' // Display menu';
|
||||||
|
eStr.Add('}');
|
||||||
|
eStr.Add('');
|
||||||
|
eStr.Add('public Pressed' + frmMenuGenerator.txtMenuName.Text + '(id, key) {');
|
||||||
|
if frmMenuGenerator.chkAddComment.Checked then begin
|
||||||
|
eStr.Add(' /* Menu:');
|
||||||
|
for i := 0 to frmMenuGenerator.rtfMenu.Lines.Count -1 do
|
||||||
|
eStr.Add(' * ' + frmMenuGenerator.rtfMenu.Lines[i]);
|
||||||
|
eStr.Add(' */');
|
||||||
|
eStr.Add('');
|
||||||
|
end;
|
||||||
|
eStr.Add(' switch (key) {');
|
||||||
|
DefinedKeys := '';
|
||||||
|
for i := 1 to Length(frmMenuGenerator.txtKeys.Text) do begin
|
||||||
|
if frmMenuGenerator.txtKeys.Text[i] = '0' then begin
|
||||||
|
DefinedKeys := DefinedKeys + '|(1<<9)';
|
||||||
|
if frmMenuGenerator.chkAddComment.Checked then
|
||||||
|
eStr.Add(' case 9: { // 0')
|
||||||
|
else
|
||||||
|
eStr.Add(' case 9: {');
|
||||||
|
eStr.Add(' ');
|
||||||
|
eStr.Add(' }');
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
DefinedKeys := DefinedKeys + '|(1<<' + IntToStr(StrToInt(frmMenuGenerator.txtKeys.Text[i]) -1) + ')';
|
||||||
|
if frmMenuGenerator.chkAddComment.Checked then
|
||||||
|
eStr.Add(' case ' + IntToStr(StrToInt(frmMenuGenerator.txtKeys.Text[i]) -1) + ': { // ' + frmMenuGenerator.txtKeys.Text[i])
|
||||||
|
else
|
||||||
|
eStr.Add(' case ' + IntToStr(StrToInt(frmMenuGenerator.txtKeys.Text[i]) -1) + ': {');
|
||||||
|
eStr.Add(' ');
|
||||||
|
eStr.Add(' }');
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Delete(DefinedKeys, 1, 1);
|
||||||
|
if frmMenuGenerator.chkAddComment.Checked then
|
||||||
|
DefinedKeys := DefinedKeys + ' // Keys: ' + frmMenuGenerator.txtKeys.Text;
|
||||||
|
eStr.Add(' }');
|
||||||
|
eStr.Add('}');
|
||||||
|
// Insert
|
||||||
|
AddIfDoesntExist('amxmodx');
|
||||||
|
i := GetFirst('#define', True) +2;
|
||||||
|
if i = 1 then
|
||||||
|
i := GetFirst('#include', True) +2;
|
||||||
|
if i = 1 then
|
||||||
|
i := 0;
|
||||||
|
|
||||||
|
frmMain.sciEditor.Lines.Insert(i, Format('#define Keys%s %s', [frmMenuGenerator.txtMenuName.Text, DefinedKeys]));
|
||||||
|
frmMain.sciEditor.Lines.Text := frmMain.sciEditor.Lines.Text + #13 + eStr.Text;
|
||||||
|
if frmMenuGenerator.chkRegisterMenuCommand.Checked then begin
|
||||||
|
i := GetFirst('register_plugin', True) +2;
|
||||||
|
if i = 1 then
|
||||||
|
i := GetFirst('public plugin_init()', True) +2;
|
||||||
|
if i = 1 then begin
|
||||||
|
eStr.Clear;
|
||||||
|
eStr.Add('public plugin_init() {');
|
||||||
|
eStr.Add(' register_menucmd(register_menuid("' + frmMenuGenerator.txtMenuName.Text + '"), Keys' + frmMenuGenerator.txtMenuName.Text + ', "Pressed' + frmMenuGenerator.txtMenuName.Text + '")');
|
||||||
|
eStr.Add('}');
|
||||||
|
frmMain.sciEditor.Lines.Insert(GetFirst('#define', True) +2, '');
|
||||||
|
frmMain.sciEditor.Lines.Insert(GetFirst('#define', True) +3, eStr.Text);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
frmMain.sciEditor.Lines.Insert(i, ' register_menucmd(register_menuid("' + frmMenuGenerator.txtMenuName.Text + '"), Keys' + frmMenuGenerator.txtMenuName.Text + ', "Pressed' + frmMenuGenerator.txtMenuName.Text + '")');
|
||||||
|
end;
|
||||||
|
eStr.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ Player Menu }
|
||||||
|
|
||||||
|
function AddOldPlayerMenu: Boolean;
|
||||||
|
function PrepareItem(eItem: String; eDisabled: Boolean): String; // Remove colors etc.
|
||||||
|
begin
|
||||||
|
eItem := StringReplace(eItem, '\w', '', [rfReplaceAll, rfIgnoreCase]);
|
||||||
|
eItem := StringReplace(eItem, '\y', '', [rfReplaceAll, rfIgnoreCase]);
|
||||||
|
eItem := StringReplace(eItem, '\r', '', [rfReplaceAll, rfIgnoreCase]);
|
||||||
|
eItem := StringReplace(eItem, '\d', '', [rfReplaceAll, rfIgnoreCase]);
|
||||||
|
eItem := StringReplace(eItem, '%n', '%i', [rfIgnoreCase]);
|
||||||
|
eItem := StringReplace(eItem, '%v', '%s', [rfIgnoreCase]);
|
||||||
|
if eDisabled then
|
||||||
|
eItem := '\d' + eItem
|
||||||
|
else
|
||||||
|
eItem := '\w' + eItem;
|
||||||
|
Result := eItem + '^n';
|
||||||
|
end;
|
||||||
|
|
||||||
|
var i: integer;
|
||||||
|
eStr: TStringList;
|
||||||
|
ePlayersFrom, ePlayersTo: Integer; // Players
|
||||||
|
ePlayerFormat: String;
|
||||||
|
eNext, eExit: Integer; // Next and Back/Exit
|
||||||
|
eNextText, eBackText, eExitText: String;
|
||||||
|
eCurLineIndex: Integer; // Current ..
|
||||||
|
eCurLine: String; // .. line
|
||||||
|
DefinedKeys: String; // Action Keys
|
||||||
|
begin
|
||||||
|
Result := GetFirst('public Show' + frmMenuGenerator.txtMenuName.Text, True) = -1;
|
||||||
|
if not Result then begin
|
||||||
|
MessageBox(frmMenuGenerator.Handle, 'Menu already exists. Please choose another name.', 'Warning', MB_ICONWARNING);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{
|
||||||
|
Kick player
|
||||||
|
|
||||||
|
$players(1,8,%n. %v)
|
||||||
|
$next(9,9. Next)
|
||||||
|
|
||||||
|
$exitorback(0, 0. Exit, 0. Back)
|
||||||
|
}
|
||||||
|
|
||||||
|
eCurLine := frmMenuGenerator.rtfMenu.Lines[0];
|
||||||
|
eCurLineIndex := 0;
|
||||||
|
eNext := -1;
|
||||||
|
eExit := -1;
|
||||||
|
eStr := TStringList.Create;
|
||||||
|
// Prepare Values
|
||||||
|
try
|
||||||
|
{ Players }
|
||||||
|
eCurLineIndex := GetFirst('$players', False);
|
||||||
|
eCurLine := frmMenuGenerator.rtfMenu.Lines[eCurLineIndex];
|
||||||
|
ePlayersFrom := StrToInt(Between(LowerCase(Trim(eCurLine)), '$players(', ','));
|
||||||
|
ePlayersTo := StrToInt(Between(Trim(LowerCase(eCurLine)), ',', ','));
|
||||||
|
while CountChars(eCurLine, ',') > 1 do
|
||||||
|
Delete(eCurLine, 1, 1);
|
||||||
|
ePlayerFormat := Between(LowerCase(eCurLine), ',', ')');
|
||||||
|
{ Next }
|
||||||
|
if GetFirst('$next', False) <> -1 then begin
|
||||||
|
eCurLineIndex := GetFirst('$next', False);
|
||||||
|
eCurLine := frmMenuGenerator.rtfMenu.Lines[eCurLineIndex];
|
||||||
|
eNext := StrToInt(Trim(Between(eCurLine, '(', ',')));
|
||||||
|
eNextText := Between(eCurLine, ',', ')');
|
||||||
|
end;
|
||||||
|
{ Exit or Back }
|
||||||
|
if GetFirst('$exitorback', False) <> -1 then begin
|
||||||
|
eCurLineIndex := GetFirst('$exitorback', False);
|
||||||
|
eCurLine := frmMenuGenerator.rtfMenu.Lines[eCurLineIndex];
|
||||||
|
eExit := StrToInt(Trim(Between(eCurLine, '(', ',')));
|
||||||
|
eExitText := Between(eCurLine, ',', ',');
|
||||||
|
while CountChars(eCurLine, ',') > 1 do
|
||||||
|
Delete(eCurLine, 1, 1);
|
||||||
|
eBackText := Between(eCurLine, ',', ')');
|
||||||
|
end;
|
||||||
|
except
|
||||||
|
MessageBox(frmMenuGenerator.Handle, PChar(Format('Syntax error at line %s: ' + #13 + '%s', [IntToStr(eCurLineIndex +1), frmMenuGenerator.rtfMenu.Lines[eCurLineIndex]])), 'Error', MB_ICONERROR);
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
// Check Keys
|
||||||
|
{ Players }
|
||||||
|
if (ePlayersFrom < 0) or (ePlayersFrom > ePlayersTo) then begin
|
||||||
|
MessageBox(frmMenuGenerator.Handle, 'Invalid start key (players)', 'Warning', MB_ICONWARNING);
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
if (ePlayersTo < 0) or (ePlayersTo > 9) then begin
|
||||||
|
MessageBox(frmMenuGenerator.Handle, 'Invalid stop key (players)', 'Warning', MB_ICONWARNING);
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
{ Next, Exit and Custom keys}
|
||||||
|
eCurLine := '';
|
||||||
|
for i := ePlayersFrom to ePlayersTo do
|
||||||
|
eCurLine := eCurLine + IntToStr(i);
|
||||||
|
|
||||||
|
if Pos(IntToStr(eNext), eCurLine) > 0 then begin
|
||||||
|
MessageBox(frmMenuGenerator.Handle, PChar(Format('"Next" key already in use (%s). Delete it or choose another one and try again.', [IntToStr(eNext)])), 'Warning', MB_ICONWARNING);
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
if Pos(IntToStr(eExit), eCurLine) > 0 then begin
|
||||||
|
MessageBox(frmMenuGenerator.Handle, PChar(Format('"Exit" key already in use (%s). Delete it or choose another one and try again.', [IntToStr(eExit)])), 'Warning', MB_ICONWARNING);
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
eCurLine := eCurLine + IntToStr(eNext);
|
||||||
|
eCurLine := eCurLine + IntToStr(eExit);
|
||||||
|
// Insert Code
|
||||||
|
try
|
||||||
|
{ Includes }
|
||||||
|
AddIfDoesntExist('amxmodx');
|
||||||
|
AddIfDoesntExist('amxmisc');
|
||||||
|
{ Define Keys }
|
||||||
|
DefinedKeys := '';
|
||||||
|
if Length(eCurLine) <> 0 then begin
|
||||||
|
for i := 1 to Length(eCurLine) do begin
|
||||||
|
if eCurLine[i] = '0' then
|
||||||
|
DefinedKeys := DefinedKeys + '|(1<<9)'
|
||||||
|
else begin
|
||||||
|
eCurLine[i] := IntToStr(StrToInt(eCurLine[i]) -1)[1];
|
||||||
|
DefinedKeys := DefinedKeys + '|(1<<' + eCurLine[i] + ')';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Delete(DefinedKeys, 1, 1);
|
||||||
|
end;
|
||||||
|
i := GetLast('#define', True) +2;
|
||||||
|
if i = 1 then
|
||||||
|
i := GetLast('#include', True) +2;
|
||||||
|
if i = 1 then
|
||||||
|
i := 0;
|
||||||
|
frmMain.sciEditor.Lines.Insert(i, Format('#define Keys%s %s', [frmMenuGenerator.txtMenuName.Text, DefinedKeys]));
|
||||||
|
frmMain.sciEditor.Lines.Insert(i +1, 'new MenuPos' + frmMenuGenerator.txtMenuName.Text);
|
||||||
|
frmMain.sciEditor.Lines.Insert(i +2, 'new MenuPlayers' + frmMenuGenerator.txtMenuName.Text + '[32]');
|
||||||
|
{ Register }
|
||||||
|
i := GetFirst('register_plugin', True) +2;
|
||||||
|
if i = 1 then
|
||||||
|
i := GetFirst('public plugin_init()', True) +2;
|
||||||
|
if i = 1 then begin
|
||||||
|
eStr.Clear;
|
||||||
|
eStr.Add('public plugin_init() {');
|
||||||
|
eStr.Add(' register_menucmd(register_menuid("' + frmMenuGenerator.txtMenuName.Text + '"), Keys' + frmMenuGenerator.txtMenuName.Text + ', "Pressed' + frmMenuGenerator.txtMenuName.Text + '")');
|
||||||
|
eStr.Add('}');
|
||||||
|
frmMain.sciEditor.Lines.Insert(GetFirst('#define', True) +2, '');
|
||||||
|
frmMain.sciEditor.Lines.Insert(GetFirst('#define', True) +3, eStr.Text);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
frmMain.sciEditor.Lines.Insert(i, ' register_menucmd(register_menuid("' + frmMenuGenerator.txtMenuName.Text + '"), Keys' + frmMenuGenerator.txtMenuName.Text + ', "Pressed' + frmMenuGenerator.txtMenuName.Text + '")');
|
||||||
|
{ Show Menu Functions (thx to xeroblood for code example) }
|
||||||
|
eStr.Clear;
|
||||||
|
eStr.Add('public Show' + frmMenuGenerator.txtMenuName.Text + '(id) {');
|
||||||
|
eStr.Add(' ShowMenu' + frmMenuGenerator.txtMenuName.Text + '(id, MenuPos' + frmMenuGenerator.txtMenuName.Text + ' = 0)');
|
||||||
|
eStr.Add(' return PLUGIN_HANDLED');
|
||||||
|
eStr.Add('}');
|
||||||
|
eStr.Add('');
|
||||||
|
eStr.Add('public ShowMenu' + frmMenuGenerator.txtMenuName.Text + '(id, position) {');
|
||||||
|
if frmMenuGenerator.chkAddComment.Checked then
|
||||||
|
eStr.Add(' // Menu stuff //');
|
||||||
|
eStr.Add(' if (position < 0) { return 0; }');
|
||||||
|
eStr.Add(' ');
|
||||||
|
eStr.Add(' new i, k');
|
||||||
|
eStr.Add(' new MenuBody[255]');
|
||||||
|
eStr.Add(' new CurrentKey = ' + IntToStr(ePlayersFrom -1));
|
||||||
|
eStr.Add(' new Start = position * ' + IntToStr(ePlayersTo - ePlayersFrom));
|
||||||
|
eStr.Add(' new Num');
|
||||||
|
eStr.Add(' new UserName[32]');
|
||||||
|
eStr.Add(' ');
|
||||||
|
eStr.Add(' get_players(MenuPlayers' + frmMenuGenerator.txtMenuName.Text + ', Num)');
|
||||||
|
eStr.Add(' if (Start >= Num) { Start = position = MenuPos' + frmMenuGenerator.txtMenuName.Text + ' = 0; }');
|
||||||
|
eCurLine := GetColoredMenu;
|
||||||
|
eCurLine := Copy(eCurLine, 1, Pos('$players', eCurLine) -3);
|
||||||
|
Insert('\R%d/%d^n\w', eCurLine, Pos('^n', eCurLine));
|
||||||
|
eStr.Add(' new Len = format(MenuBody, 255, "' + eCurLine + '", position+1, (Num / ' + IntToStr(ePlayersTo - ePlayersFrom) + ' + ((Num % ' + IntToStr(ePlayersTo - ePlayersFrom) + ') ? 1 : 0 )) )');
|
||||||
|
eStr.Add(' new End = Start + ' + IntToStr(ePlayersTo - ePlayersFrom));
|
||||||
|
if eExit = 0 then
|
||||||
|
eStr.Add(' new Keys = (1<<9)')
|
||||||
|
else
|
||||||
|
eStr.Add(' new Keys = (1<<' + IntToStr(eExit -1) + ')');
|
||||||
|
eStr.Add(' if (End > Num) { End = Num; }');
|
||||||
|
eStr.Add(' ');
|
||||||
|
eStr.Add(' for(i=Start;i<End;i++) {');
|
||||||
|
eStr.Add(' k = MenuPlayers' + frmMenuGenerator.txtMenuName.Text + '[i]');
|
||||||
|
eStr.Add(' get_user_name(k, UserName, 31)');
|
||||||
|
// Any conditions?
|
||||||
|
// if (frmMenuGenerator.chkImmunity.Checked) and (frmMenuGenerator.chkAlive.Checked) then
|
||||||
|
// eStr.Add(' if ((get_user_flags(k) & ADMIN_IMMUNITY) || !is_user_alive(k)) {')
|
||||||
|
// else if (frmMenuGenerator.chkImmunity.Checked) then
|
||||||
|
// eStr.Add(' if (get_user_flags(k) & ADMIN_IMMUNITY) {')
|
||||||
|
// else if (frmMenuGenerator.chkAlive.Checked) then
|
||||||
|
// eStr.Add(' if (!is_user_alive(k)) {');
|
||||||
|
// if (frmMenuGenerator.chkImmunity.Checked) or (frmMenuGenerator.chkAlive.Checked) then begin
|
||||||
|
// eStr.Add(' CurrentKey++');
|
||||||
|
// eStr.Add(' Len += format(MenuBody[Len], (255-Len), "' + PrepareItem(ePlayerFormat, True) + '", CurrentKey, UserName)');
|
||||||
|
// eStr.Add(' }');
|
||||||
|
// eStr.Add(' else {');
|
||||||
|
// eStr.Add(' Keys |= (1<<CurrentKey++)');
|
||||||
|
// eStr.Add(' Len += format(MenuBody[Len], (255-Len), "' + PrepareItem(ePlayerFormat, False) + '", CurrentKey, UserName)');
|
||||||
|
// eStr.Add(' }');
|
||||||
|
// end
|
||||||
|
// else begin
|
||||||
|
eStr.Add(' Keys |= (i<<CurrentKey++)');
|
||||||
|
eStr.Add(' Len += format(MenuBody[Len], (255-Len), "' + PrepareItem(ePlayerFormat, False) + '", CurrentKey, UserName)');
|
||||||
|
// end;
|
||||||
|
eStr.Add(' }');
|
||||||
|
eStr.Add(' if (End != Num) {');
|
||||||
|
eStr.Add(' format(MenuBody[Len], (255-Len), "^n\w' + eNextText + '^n%s", position ? "\w' + eBackText + '" : "\w' + eExitText + '")');
|
||||||
|
eStr.Add(' Keys |= (1<<' + IntToStr(eNext -1) + ')');
|
||||||
|
eStr.Add(' }');
|
||||||
|
eStr.Add(' else {');
|
||||||
|
eStr.Add(' format(MenuBody[Len], (255-Len), "^n%s", position ? "\w' + eBackText + '" : "\w' + eExitText + '")');
|
||||||
|
eStr.Add(' }');
|
||||||
|
eStr.Add(' show_menu(id, Keys, MenuBody, -1)');
|
||||||
|
eStr.Add(' return 0');
|
||||||
|
eStr.Add('}');
|
||||||
|
eStr.Add('');
|
||||||
|
eStr.Add('public Pressed' + frmMenuGenerator.txtMenuName.Text + '(id, key) {');
|
||||||
|
eStr.Add(' switch (key) {');
|
||||||
|
if frmMenuGenerator.chkAddComment.Checked then begin
|
||||||
|
if eNext <> 0 then
|
||||||
|
eStr.Add(' case ' + IntToStr(eNext -1) + ': ShowMenu' + frmMenuGenerator.txtMenuName.Text + '(id, ++MenuPos' + frmMenuGenerator.txtMenuName.Text + ') // More Option')
|
||||||
|
else
|
||||||
|
eStr.Add(' case 9: ShowMenu' + frmMenuGenerator.txtMenuName.Text + '(id, ++MenuPos' + frmMenuGenerator.txtMenuName.Text + ') // More Option');
|
||||||
|
|
||||||
|
if eExit <> 0 then
|
||||||
|
eStr.Add(' case ' + IntToStr(eExit -1) + ': ShowMenu' + frmMenuGenerator.txtMenuName.Text + '(id, --MenuPos' + frmMenuGenerator.txtMenuName.Text + ') // Back Option')
|
||||||
|
else
|
||||||
|
eStr.Add(' case 9: ShowMenu' + frmMenuGenerator.txtMenuName.Text + '(id, --MenuPos' + frmMenuGenerator.txtMenuName.Text + ') // Back Option');
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
if eNext <> 0 then
|
||||||
|
eStr.Add(' case ' + IntToStr(eNext -1) + ': ShowMenu' + frmMenuGenerator.txtMenuName.Text + '(id, ++MenuPos' + frmMenuGenerator.txtMenuName.Text + ')')
|
||||||
|
else
|
||||||
|
eStr.Add(' case 9: ShowMenu' + frmMenuGenerator.txtMenuName.Text + '(id, ++MenuPos' + frmMenuGenerator.txtMenuName.Text + ')');
|
||||||
|
if eExit <> 0 then
|
||||||
|
eStr.Add(' case ' + IntToStr(eExit -1) + ': ShowMenu' + frmMenuGenerator.txtMenuName.Text + '(id, --MenuPos' + frmMenuGenerator.txtMenuName.Text + ')')
|
||||||
|
else
|
||||||
|
eStr.Add(' case 9: ShowMenu' + frmMenuGenerator.txtMenuName.Text + '(id, --MenuPos' + frmMenuGenerator.txtMenuName.Text + ')');
|
||||||
|
end;
|
||||||
|
eStr.Add(' default: {');
|
||||||
|
if frmMenuGenerator.chkAddComment.Checked then
|
||||||
|
eStr.Add(' // Get User ID and Username');
|
||||||
|
eStr.Add(' new PlayerID = MenuPlayers' + frmMenuGenerator.txtMenuName.Text + '[MenuPos' + frmMenuGenerator.txtMenuName.Text + ' * ' + IntToStr(ePlayersTo - ePlayersFrom) + ' + key]');
|
||||||
|
eStr.Add(' new UserName[32]');
|
||||||
|
eStr.Add(' get_user_name(PlayerID, UserName, 31)');
|
||||||
|
if frmMenuGenerator.chkAddComment.Checked then
|
||||||
|
eStr.Add(' // Do actions here')
|
||||||
|
else
|
||||||
|
eStr.Add(' ');
|
||||||
|
eStr.Add(' }');
|
||||||
|
eStr.Add(' }');
|
||||||
|
eStr.Add(' return PLUGIN_HANDLED');
|
||||||
|
eStr.Add('}');
|
||||||
|
frmMain.sciEditor.Lines.Text := frmMain.sciEditor.Lines.Text + #13 + eStr.Text;
|
||||||
|
except
|
||||||
|
MessageBox(frmMenuGenerator.Handle, PChar('An error occured while inserting code!'), 'Warning', MB_ICONWARNING);
|
||||||
|
end;
|
||||||
|
eStr.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ Functions }
|
||||||
|
|
||||||
|
function GetFirst(eStart: String; eSearchMain: Boolean): Integer;
|
||||||
|
var i: integer;
|
||||||
|
begin
|
||||||
|
eStart := LowerCase(Trim(eStart));
|
||||||
|
Result := -1;
|
||||||
|
if eSearchMain then begin
|
||||||
|
for i := 0 to frmMain.sciEditor.Lines.Count -1 do begin
|
||||||
|
if Pos(eStart, LowerCase(Trim(frmMain.sciEditor.Lines[i]))) = 1 then begin
|
||||||
|
Result := i;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
for i := 0 to frmMenuGenerator.rtfMenu.Lines.Count -1 do begin
|
||||||
|
if Pos(eStart, LowerCase(Trim(frmMenuGenerator.rtfMenu.Lines[i]))) = 1 then begin
|
||||||
|
Result := i;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function GetLast(eStart: String; eSearchMain: Boolean): Integer;
|
||||||
|
var i: integer;
|
||||||
|
begin
|
||||||
|
eStart := LowerCase(Trim(eStart));
|
||||||
|
Result := -1;
|
||||||
|
if eSearchMain then begin
|
||||||
|
for i := 0 to frmMain.sciEditor.Lines.Count -1 do begin
|
||||||
|
if Pos(eStart, LowerCase(Trim(frmMain.sciEditor.Lines[i]))) = 1 then
|
||||||
|
Result := i;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
for i := 0 to frmMenuGenerator.rtfMenu.Lines.Count -1 do begin
|
||||||
|
if Pos(eStart, LowerCase(Trim(frmMenuGenerator.rtfMenu.Lines[i]))) = 1 then
|
||||||
|
Result := i;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function AddIfDoesntExist(eInclude: String): Boolean;
|
||||||
|
var i: integer;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
eInclude := LowerCase(eInclude);
|
||||||
|
for i := 0 to frmMain.sciEditor.Lines.Count -1 do begin
|
||||||
|
if (Pos('<', frmMain.sciEditor.Lines[i]) <> 0) or (Pos('"', frmMain.sciEditor.Lines[i]) <> 0) then begin
|
||||||
|
if LowerCase(Between(frmMain.sciEditor.Lines[i], '<', '>')) = eInclude then
|
||||||
|
exit;
|
||||||
|
if LowerCase(Between(frmMain.sciEditor.Lines[i], '"', '"')) = eInclude then
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
i := GetLast('#include', True);
|
||||||
|
if i = -1 then
|
||||||
|
i := 0;
|
||||||
|
|
||||||
|
frmMain.sciEditor.Lines.Insert(i, '#include <' + eInclude + '>');
|
||||||
|
end;
|
||||||
|
|
||||||
|
function GetColoredMenu: String;
|
||||||
|
var i: integer;
|
||||||
|
eCurColor: TColor;
|
||||||
|
begin
|
||||||
|
eCurColor := clWhite;
|
||||||
|
Result := '';
|
||||||
|
for i := 0 to Length(frmMenuGenerator.rtfMenu.Lines.Text) -1 do begin
|
||||||
|
frmMenuGenerator.rtfMenu.SelStart := i;
|
||||||
|
if frmMenuGenerator.rtfMenu.SelAttributes.Color <> eCurColor then begin
|
||||||
|
eCurColor := frmMenuGenerator.rtfMenu.SelAttributes.Color;
|
||||||
|
case eCurColor of
|
||||||
|
clWhite : Result := Result + '\w';
|
||||||
|
clYellow: Result := Result + '\y';
|
||||||
|
clRed : Result := Result + '\r';
|
||||||
|
clGray : Result := Result + '\d';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Result := Result + frmMenuGenerator.rtfMenu.Lines.Text[i+1];
|
||||||
|
end;
|
||||||
|
frmMenuGenerator.rtfMenu.SelStart := 0;
|
||||||
|
Result := StringReplace(Result, #13, '^n', [rfReplaceAll]);
|
||||||
|
Result := StringReplace(Result, #10, '', [rfReplaceAll]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function PluginInitLine: Integer;
|
||||||
|
begin
|
||||||
|
Result := GetLine('register_concmd', True, False);
|
||||||
|
if Result = -1 then
|
||||||
|
Result := GetLine('register_clcmd', True, False);
|
||||||
|
if Result = -1 then
|
||||||
|
Result := GetLine('register_plugin', True, True);
|
||||||
|
if Result = -1 then
|
||||||
|
Result := GetLine('public plugin_init', True, True);
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
883
editor/studio/UnitPlugins.pas
Executable file
883
editor/studio/UnitPlugins.pas
Executable file
|
@ -0,0 +1,883 @@
|
||||||
|
unit UnitPlugins;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses SysUtils, Classes, Windows, Messages, Forms, ComCtrls;
|
||||||
|
|
||||||
|
type TCodeSnippetClick = function (pTitle, pCategory: PChar; pCode: PChar): Integer; cdecl;
|
||||||
|
TFileAction = function (pFilename: PChar): Integer; cdecl;
|
||||||
|
TDocChange = function (pIndex: DWord; pFilename: PChar; pHighlighter: PChar; pRestoreCaret: Boolean): Integer; cdecl;
|
||||||
|
TProjectsChange = function (pOldIndex, pNewIndex: DWord): Integer; cdecl;
|
||||||
|
TCreateNewFile = function (Item: PByte): Integer; cdecl;
|
||||||
|
TDisplaySearch = function (pSearchList: PChar; pSelected: PChar): Integer; cdecl;
|
||||||
|
TSearch = function (pExpression: PChar; pCaseSensivity, pWholeWords, pSearchFromCaret, pSelectedOnly, pRegEx, pForward: Boolean): Integer; cdecl;
|
||||||
|
TSearchReplace = function (pExpression, pReplace, pExpList, pRepList: PChar; pCaseSensivity, pWholeWords, pSearchFromCaret, pSelectedOnly, pRegEx, pForward: Boolean): Integer; cdecl;
|
||||||
|
TVisibleControlChange = function (pControl: DWord; pShow: Boolean): Integer; cdecl;
|
||||||
|
TCompile = function (pCompileType: DWord; Lang, Filename: PChar): Integer; cdecl;
|
||||||
|
TShowHelp = function (pHelpType: DWord): Integer; cdecl;
|
||||||
|
TCustomItemClick = function (pCaption: PChar): Integer; cdecl;
|
||||||
|
TThemeChanged = function (pTheme: PChar): Integer; cdecl;
|
||||||
|
|
||||||
|
TModified = function (pText: PChar): Integer; cdecl;
|
||||||
|
TKeyPress = function (var pKey: Char): Integer; cdecl;
|
||||||
|
TEditorClick = function (pDoubleClick: Boolean): Integer; cdecl;
|
||||||
|
TUpdateSel = function (pSelStart, pSelLength, pFirstVisibleLine: DWord): Integer; cdecl;
|
||||||
|
TCallTipShow = function (pList: PChar): Integer; cdecl;
|
||||||
|
TCallTipClick = function (pPosition: DWord): Integer; cdecl;
|
||||||
|
TAutoCompleteShow = function (pList: PChar): Integer; cdecl;
|
||||||
|
TAutoCompleteSelect = function (pText: PChar): Integer; cdecl;
|
||||||
|
|
||||||
|
TAppMsg = function (pHwnd: HWND; pMessage: DWord; pWParam, pLParam: Integer; pTime: DWord; pPt: TPoint): Integer; cdecl;
|
||||||
|
TUpdateCodeTools = function (pLang, pFilename, pCurrProjects: PChar): Integer; cdecl;
|
||||||
|
TOutputEvent = function (pItemIndex: Integer): Integer; cdecl;
|
||||||
|
|
||||||
|
type TIntegerArray = array of Integer;
|
||||||
|
|
||||||
|
type TLoadInfo = record
|
||||||
|
{ Plugin Values }
|
||||||
|
sPluginName: PChar;
|
||||||
|
sPluginDescription: PChar;
|
||||||
|
{ Form Handles }
|
||||||
|
hAllFilesForm: HWND;
|
||||||
|
hAutoIndent: HWND;
|
||||||
|
hClose: HWND;
|
||||||
|
hConnGen: HWND;
|
||||||
|
hGoToLine: HWND;
|
||||||
|
hHTMLPreview: HWND;
|
||||||
|
hHudMsgGenerator: HWND;
|
||||||
|
hInfo: HWND;
|
||||||
|
hMainForm: HWND;
|
||||||
|
hMenuGenerator: HWND;
|
||||||
|
hMOTDGen: HWND;
|
||||||
|
hPluginsIniEditor: HWND;
|
||||||
|
hReplace: HWND;
|
||||||
|
hSearch: HWND;
|
||||||
|
hSelectColor: HWND;
|
||||||
|
hSettings: HWND;
|
||||||
|
hSocketsTerminal: HWND;
|
||||||
|
hSplashscreen: HWND;
|
||||||
|
{ Important Control Handles }
|
||||||
|
hOutput: HWND;
|
||||||
|
hCodeExplorer: HWND;
|
||||||
|
hCodeInspector: HWND; // even if it won't be useful
|
||||||
|
hNotes: HWND;
|
||||||
|
{ Other }
|
||||||
|
pApplication: Pointer; // this is only useful for Delphi developers
|
||||||
|
end;
|
||||||
|
|
||||||
|
type PLoadInfo = ^TLoadInfo;
|
||||||
|
TLoadPlugin = procedure (var LoadInfo: PLoadInfo); cdecl;
|
||||||
|
TUnloadPlugin = procedure; cdecl;
|
||||||
|
|
||||||
|
procedure SendToMainApp(eData: String);
|
||||||
|
|
||||||
|
function LoadPlugin(ListItem: TListItem): Boolean;
|
||||||
|
procedure UnloadPlugin(ListItem: TListItem);
|
||||||
|
|
||||||
|
function Plugin_CodeSnippetClick(Title, Category: String; Code: String): Boolean;
|
||||||
|
function Plugin_FileLoad(Filename: String; Loading: Boolean): Boolean;
|
||||||
|
function Plugin_FileSave(Filename: String; Saving: Boolean): Boolean;
|
||||||
|
function Plugin_DocChange(Index: Integer; Filename, Highlighter: String; RestoreCaret, Changing: Boolean): Boolean;
|
||||||
|
function Plugin_ProjectsChange(OldIndex, NewIndex: Integer; Changing: Boolean): Boolean;
|
||||||
|
function Plugin_CreateNewFile(Item: Byte; Creating: Boolean): Boolean;
|
||||||
|
function Plugin_Search(SearchList, Selected: String; Displaying, SearchAgain: Boolean): Boolean;
|
||||||
|
function Plugin_SearchReplace(Expression, Replace, ExpList, RepList: String; CaseSensivity, WholeWords, SearchFromCaret, SelectedOnly, RegEx, Forward: Boolean): Boolean;
|
||||||
|
function Plugin_VisibleControlChange(Control: Integer; Show: Boolean): Boolean;
|
||||||
|
function Plugin_Compile(CompileType: Integer; Lang, Filename: String; Compiling: Boolean): Boolean;
|
||||||
|
function Plugin_ShowHelp(HelpType: Integer): Boolean;
|
||||||
|
function Plugin_CustomItemClick(Caption: String): Boolean;
|
||||||
|
function Plugin_ThemeChange(Theme: String): Boolean;
|
||||||
|
|
||||||
|
function Plugin_Modified(Code: PChar): Boolean;
|
||||||
|
function Plugin_KeyPress(var Key: Char): Boolean;
|
||||||
|
function Plugin_EditorClick(DoubleClick: Boolean): Boolean;
|
||||||
|
function Plugin_UpdateSel(SelStart, SelLength, FirstVisibleLine: Integer): Boolean;
|
||||||
|
function Plugin_CallTipShow(List: PChar): Boolean;
|
||||||
|
function Plugin_CallTipClick(Position: Integer): Boolean;
|
||||||
|
function Plugin_AutoCompleteShow(List: PChar): Boolean;
|
||||||
|
function Plugin_AutoCompleteSelect(Text: PChar): Boolean;
|
||||||
|
|
||||||
|
function Plugin_AppMsg(hwnd: HWND; Message: DWord; wParam, lParam: Integer; time: DWord; pt: TPoint): Boolean;
|
||||||
|
function Plugin_UpdateCodeExplorer(Lang, Filename, CurrProjects: String; Updating: Boolean): Boolean;
|
||||||
|
function Plugin_UpdateCodeInspector(Lang, Filename, CurrProjects: String; Updating: Boolean): Boolean;
|
||||||
|
function Plugin_OutputDblClick(ItemIndex: Integer): Boolean;
|
||||||
|
function Plugin_OutputPopup(ItemIndex: Integer): Boolean;
|
||||||
|
|
||||||
|
const { Return values for dlls }
|
||||||
|
PLUGIN_CONTINUE = 0; // continue...
|
||||||
|
PLUGIN_STOP = 1; // stop calling funcs and don't handle the command
|
||||||
|
PLUGIN_HANDLED = 2; // don't handle the command
|
||||||
|
{ Compile values }
|
||||||
|
COMP_DEFAULT = 0;
|
||||||
|
COMP_STARTHL = 1;
|
||||||
|
COMP_UPLOAD = 2;
|
||||||
|
{ Help values }
|
||||||
|
HELP_DEFAULT = 0;
|
||||||
|
HELP_SEARCH = 1;
|
||||||
|
HELP_FORUMS = 2;
|
||||||
|
HELP_ABOUT = 3;
|
||||||
|
{ Controls for visible state }
|
||||||
|
CTRL_OUTPUT = 0; // Output list
|
||||||
|
CTRL_CODETOOLS_MAIN = 1; // Code-Tools window
|
||||||
|
CTRL_CODETOOLS_ITEM = 2; // Code-Tools tab
|
||||||
|
CTRL_NOTES = 3; // Notes tab
|
||||||
|
{ Languages }
|
||||||
|
NEW_PAWN_PLUGIN = 0;
|
||||||
|
NEW_PAWN_EMPTYPLUGIN = 1;
|
||||||
|
NEW_PAWN_HEADER = 2;
|
||||||
|
NEW_CPP_MODULE = 3;
|
||||||
|
NEW_CPP_UNIT = 4;
|
||||||
|
NEW_CPP_HEADER = 5;
|
||||||
|
NEW_OTHER_TEXTFILE = 6;
|
||||||
|
NEW_OTHER_HTML = 7;
|
||||||
|
NEW_OTHER_SQL = 8;
|
||||||
|
NEW_OTHER_XML = 9;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses UnitfrmSettings, UnitMainTools, UnitfrmAllFilesForm,
|
||||||
|
UnitfrmAutoIndent, UnitfrmClose, UnitfrmConnGen, UnitfrmGoToLine,
|
||||||
|
UnitfrmHTMLPreview, UnitfrmHudMsgGenerator, UnitfrmInfo, UnitfrmMain,
|
||||||
|
UnitfrmMenuGenerator, UnitfrmMOTDGen, UnitfrmPluginsIniEditor,
|
||||||
|
UnitfrmReplace, UnitfrmSearch, UnitfrmSelectColor,
|
||||||
|
UnitfrmSocketsTerminal, UnitfrmSplashscreen, UnitLanguages;
|
||||||
|
|
||||||
|
function LoadPlugin(ListItem: TListItem): Boolean;
|
||||||
|
var eLoadInfo: TLoadInfo;
|
||||||
|
LoadInfo: PLoadInfo;
|
||||||
|
eHandle: Cardinal;
|
||||||
|
eFunc, eFunc2: TLoadPlugin;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
|
||||||
|
with eLoadInfo do begin
|
||||||
|
sPluginName := 'Untitled';
|
||||||
|
sPluginDescription := 'No description';
|
||||||
|
{ Handles }
|
||||||
|
hAllFilesForm := frmAllFilesForm.Handle;
|
||||||
|
hAutoIndent := frmAutoIndent.Handle;
|
||||||
|
hClose := frmClose.Handle;
|
||||||
|
hConnGen := frmConnGen.Handle;
|
||||||
|
hGoToLine := frmGoToLine.Handle;
|
||||||
|
hHTMLPreview := frmHTMLPreview.Handle;
|
||||||
|
hHudMsgGenerator := frmHudMsgGenerator.Handle;
|
||||||
|
hInfo := frmInfo.Handle;
|
||||||
|
hMainForm := frmMain.Handle;
|
||||||
|
hMenuGenerator := frmMenuGenerator.Handle;
|
||||||
|
hMOTDGen := frmMOTDGen.Handle;
|
||||||
|
hPluginsIniEditor := frmPluginsIniEditor.Handle;
|
||||||
|
hReplace := frmReplace.Handle;
|
||||||
|
hSearch := frmSearch.Handle;
|
||||||
|
hSelectColor := frmSelectColor.Handle;
|
||||||
|
hSettings := frmSettings.Handle;
|
||||||
|
hSocketsTerminal := frmSocketsTerminal.Handle;
|
||||||
|
hSplashscreen := frmSplashscreen.Handle;
|
||||||
|
{ Important Control Handles }
|
||||||
|
hOutput := frmMain.lstOutput.Handle;
|
||||||
|
hCodeExplorer := frmMain.trvExplorer.Handle;
|
||||||
|
hCodeInspector := frmMain.jviCode.Handle; // even if it won't be useful
|
||||||
|
hNotes := frmMain.rtfNotes.Handle;
|
||||||
|
{ Other }
|
||||||
|
pApplication := @Application; // this is only useful for Delphi developers
|
||||||
|
end;
|
||||||
|
|
||||||
|
eHandle := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) + 'plugins\' + ListItem.SubItems[0]));
|
||||||
|
if eHandle = 0 then exit;
|
||||||
|
@eFunc := GetProcAddress(eHandle, 'pftPluginLoad');
|
||||||
|
@eFunc2 := GetProcAddress(eHandle, 'pftPluginUnload');
|
||||||
|
|
||||||
|
if @eFunc2 <> nil then begin
|
||||||
|
if @eFunc <> nil then begin
|
||||||
|
ListItem.Data := Pointer(eHandle);
|
||||||
|
ListItem.SubItems[2] := 'Loaded';
|
||||||
|
LoadInfo := @eLoadInfo;
|
||||||
|
eFunc(LoadInfo);
|
||||||
|
ListItem.Caption := eLoadInfo.sPluginName;
|
||||||
|
ListItem.SubItems[1] := eLoadInfo.sPluginDescription;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
MessageBox(Application.Handle, PChar('Error loading plugin:' + #13 + 'pftPluginLoad function not found.'), PChar(ExtractFileName(ExtractFilePath(ParamStr(0)) + 'plugins\' + ListItem.SubItems[0])), MB_ICONERROR);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
MessageBox(Application.Handle, PChar('Error loading plugin:' + #13 + 'pftPluginUnload function not found.'), PChar(ExtractFileName(ExtractFilePath(ParamStr(0)) + 'plugins\' + ListItem.SubItems[0])), MB_ICONERROR);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure UnloadPlugin(ListItem: TListItem);
|
||||||
|
var eFunc: TUnloadPlugin;
|
||||||
|
begin
|
||||||
|
@eFunc := GetProcAddress(Cardinal(ListItem.Data), 'pftPluginUnload');
|
||||||
|
if @eFunc <> nil then
|
||||||
|
eFunc;
|
||||||
|
FreeLibrary(Cardinal(ListItem.Data));
|
||||||
|
|
||||||
|
ListItem.Data := nil;
|
||||||
|
ListItem.Caption := '-';
|
||||||
|
ListItem.SubItems[1] := '-';
|
||||||
|
ListItem.SubItems[2] := 'Unloaded';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure SendToMainApp(eData: String);
|
||||||
|
var HTargetWnd: HWND;
|
||||||
|
ACopyDataStruct: TCopyDataStruct;
|
||||||
|
begin
|
||||||
|
with ACopyDataStruct do
|
||||||
|
begin
|
||||||
|
dwData := 0;
|
||||||
|
cbData := Length(eData) + 1;
|
||||||
|
lpData := PChar(eData);
|
||||||
|
end;
|
||||||
|
|
||||||
|
HTargetWnd := FindWindow('TfrmMain', 'AMXX-Studio');
|
||||||
|
if HTargetWnd <> 0 then
|
||||||
|
SendMessage(HTargetWnd, WM_COPYDATA, 0, LongInt(@ACopyDataStruct));
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function GetDLLHandles: TIntegerArray;
|
||||||
|
var i, eCount: integer;
|
||||||
|
begin
|
||||||
|
SetLength(Result, 0);
|
||||||
|
eCount := 0;
|
||||||
|
|
||||||
|
if not Started then exit;
|
||||||
|
|
||||||
|
for i := 0 to frmSettings.lvPlugins.Items.Count -1 do begin
|
||||||
|
if frmSettings.lvPlugins.Items[i].Data <> nil then begin
|
||||||
|
SetLength(Result, eCount +1);
|
||||||
|
Result[eCount] := Cardinal(frmSettings.lvPlugins.Items[i].Data);
|
||||||
|
Inc(eCount, 1);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_CodeSnippetClick(Title, Category: String; Code: String): Boolean;
|
||||||
|
var Func: TCodeSnippetClick;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftCodeSnippetClick');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(PChar(Title), PChar(Category), PChar(Code)) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_FileLoad(Filename: String; Loading: Boolean): Boolean;
|
||||||
|
var Func: TFileAction;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
if Loading then
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftLoading')
|
||||||
|
else
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftLoaded');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(PChar(Filename)) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_FileSave(Filename: String; Saving: Boolean): Boolean;
|
||||||
|
var Func: TFileAction;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
if Saving then
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftSaving')
|
||||||
|
else
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftSaved');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(PChar(Filename)) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_DocChange(Index: Integer; Filename, Highlighter: String; RestoreCaret, Changing: Boolean): Boolean;
|
||||||
|
var Func: TDocChange;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
if Changing then
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftDocChanging')
|
||||||
|
else
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftDocChanged');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(Index, PChar(Filename), PChar(Highlighter), RestoreCaret) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_ProjectsChange(OldIndex, NewIndex: Integer; Changing: Boolean): Boolean;
|
||||||
|
var Func: TProjectsChange;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
if Changing then
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftProjectsChanging')
|
||||||
|
else
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftProjectsChanged');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(OldIndex, NewIndex) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_CreateNewFile(Item: Byte; Creating: Boolean): Boolean;
|
||||||
|
var Func: TCreateNewFile;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
if Creating then
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftCreatingNewFile')
|
||||||
|
else
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftCreatedNewFile');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(PByte(Item)) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_Search(SearchList, Selected: String; Displaying, SearchAgain: Boolean): Boolean;
|
||||||
|
var Func: TDisplaySearch;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
if Displaying then
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftDisplayingSearch')
|
||||||
|
else if SearchAgain then
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftSearchAgain')
|
||||||
|
else
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftSearch');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(PChar(SearchList), PChar(Selected)) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_SearchReplace(Expression, Replace, ExpList, RepList: String; CaseSensivity, WholeWords, SearchFromCaret, SelectedOnly, RegEx, Forward: Boolean): Boolean;
|
||||||
|
var Func: TSearchReplace;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftSearchReplace');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(PChar(Expression), PChar(Replace), PChar(ExpList), PChar(RepList), CaseSensivity, WholeWords, SearchFromCaret, SelectedOnly, RegEx, Forward) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_VisibleControlChange(Control: Integer; Show: Boolean): Boolean;
|
||||||
|
var Func: TVisibleControlChange;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftVisibleControlChange');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(Control, Show) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_Compile(CompileType: Integer; Lang, Filename: String; Compiling: Boolean): Boolean;
|
||||||
|
var Func: TCompile;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
if Compiling then
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftCompiling')
|
||||||
|
else
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftCompile');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(CompileType, PChar(Lang), PChar(Filename)) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_ShowHelp(HelpType: Integer): Boolean;
|
||||||
|
var Func: TShowHelp;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftShowHelp');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(HelpType) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_CustomItemClick(Caption: String): Boolean;
|
||||||
|
var Func: TCustomItemClick;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftCustomItemClick');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(PChar(Caption)) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_ThemeChange(Theme: String): Boolean;
|
||||||
|
var Func: TThemeChanged;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftThemeChanged');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(PChar(Theme)) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_Modified(Code: PChar): Boolean;
|
||||||
|
var Func: TModified;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftModified');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(Code) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_KeyPress(var Key: Char): Boolean;
|
||||||
|
var Func: TKeyPress;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftKeyPress');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(Key) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_EditorClick(DoubleClick: Boolean): Boolean;
|
||||||
|
var Func: TEditorClick;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
if DoubleClick then
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftDoubleClick')
|
||||||
|
else
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftClick');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(DoubleClick) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_UpdateSel(SelStart, SelLength, FirstVisibleLine: Integer): Boolean;
|
||||||
|
var Func: TUpdateSel;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftUpdateSel');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(SelStart, SelLength, FirstVisibleLine) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_CallTipShow(List: PChar): Boolean;
|
||||||
|
var Func: TCallTipShow;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftCallTipShow');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(List) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_CallTipClick(Position: Integer): Boolean;
|
||||||
|
var Func: TCallTipClick;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftCallTipClick');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(Position) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_AutoCompleteShow(List: PChar): Boolean;
|
||||||
|
var Func: TAutoCompleteShow;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftAutoCompleteShow');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(List) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_AutoCompleteSelect(Text: PChar): Boolean;
|
||||||
|
var Func: TAutoCompleteSelect;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftAutoCompleteSelect');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(Text) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_AppMsg(hwnd: HWND; Message: DWord; wParam, lParam: Integer; time: DWord; pt: TPoint): Boolean;
|
||||||
|
var Func: TAppMsg;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftMessage');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(hwnd, Message, wParam, lParam, time, pt) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_UpdateCodeExplorer(Lang, Filename, CurrProjects: String; Updating: Boolean): Boolean;
|
||||||
|
var Func: TUpdateCodeTools;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
if Updating then
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftUpdatingCodeExplorer')
|
||||||
|
else
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftUpdatedCodeExplorer');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(PChar(Lang), PChar(Filename), PChar(CurrProjects)) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_UpdateCodeInspector(Lang, Filename, CurrProjects: String; Updating: Boolean): Boolean;
|
||||||
|
var Func: TUpdateCodeTools;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
if Updating then
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftUpdatingCodeInspector')
|
||||||
|
else
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftUpdatedCodeInspector');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(PChar(Lang), PChar(Filename), PChar(CurrProjects)) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_OutputDblClick(ItemIndex: Integer): Boolean;
|
||||||
|
var Func: TOutputEvent;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftOutputDoubleClick');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(ItemIndex) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Plugin_OutputPopup(ItemIndex: Integer): Boolean;
|
||||||
|
var Func: TOutputEvent;
|
||||||
|
i: integer;
|
||||||
|
Handles: TIntegerArray;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Handles := GetDLLHandles;
|
||||||
|
for i := 0 to High(Handles) do begin
|
||||||
|
@Func := GetProcAddress(Handles[i], 'pftOutputPopup');
|
||||||
|
|
||||||
|
if @Func <> nil then begin
|
||||||
|
case Func(ItemIndex) of
|
||||||
|
PLUGIN_HANDLED: Result := False;
|
||||||
|
PLUGIN_STOP: begin
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
58
editor/studio/UnitReadThread.pas
Executable file
58
editor/studio/UnitReadThread.pas
Executable file
|
@ -0,0 +1,58 @@
|
||||||
|
unit UnitReadThread; // from AMXX-Edit v2
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, SysUtils, Graphics;
|
||||||
|
|
||||||
|
type
|
||||||
|
TReadThread = class(TThread)
|
||||||
|
public
|
||||||
|
ReadTCP: Boolean;
|
||||||
|
protected
|
||||||
|
Read: String;
|
||||||
|
procedure Execute; override;
|
||||||
|
procedure AddRead;
|
||||||
|
end;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses UnitfrmSocketsTerminal;
|
||||||
|
|
||||||
|
{ TReadThread }
|
||||||
|
|
||||||
|
procedure TReadThread.AddRead;
|
||||||
|
begin
|
||||||
|
frmSocketsTerminal.OnRead(Read);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TReadThread.Execute;
|
||||||
|
begin
|
||||||
|
if ReadTCP then begin
|
||||||
|
frmSocketsTerminal.IdTCPClient.ReadTimeout := 50;
|
||||||
|
repeat
|
||||||
|
try
|
||||||
|
Read := frmSocketsTerminal.IdTCPClient.ReadLn;
|
||||||
|
Synchronize(AddRead);
|
||||||
|
except
|
||||||
|
// nothing
|
||||||
|
end;
|
||||||
|
until (Terminated) or (not frmSocketsTerminal.IdTCPClient.Connected);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
frmSocketsTerminal.IdUDPClient.ReceiveTimeout := 50;
|
||||||
|
repeat
|
||||||
|
try
|
||||||
|
Read := frmSocketsTerminal.IdUDPClient.ReceiveString;
|
||||||
|
if Read <> '' then // if ReadTimeout then Read = ''
|
||||||
|
Synchronize(AddRead);
|
||||||
|
except
|
||||||
|
// nothing
|
||||||
|
end;
|
||||||
|
until (Terminated) or (not frmSocketsTerminal.IdUDPClient.Active);
|
||||||
|
end;
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
404
editor/studio/UnitTextAnalyze.pas
Executable file
404
editor/studio/UnitTextAnalyze.pas
Executable file
|
@ -0,0 +1,404 @@
|
||||||
|
unit UnitTextAnalyze;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses SysUtils, Classes, Windows, Forms;
|
||||||
|
|
||||||
|
type TPAWNParseResult = class
|
||||||
|
public
|
||||||
|
Constants: TStringList;
|
||||||
|
Defined: TStringList;
|
||||||
|
CVars: TStringList;
|
||||||
|
Included: TStringList;
|
||||||
|
MethodsDefault: TStringList;
|
||||||
|
Events: TStringList;
|
||||||
|
Stocks: TStringList;
|
||||||
|
Natives: TStringList;
|
||||||
|
Forwards: TStringList;
|
||||||
|
Variables: TStringList;
|
||||||
|
|
||||||
|
CallTips: TStringList;
|
||||||
|
AutoComplete: TStringList;
|
||||||
|
HighlightKeywords: TStringList;
|
||||||
|
|
||||||
|
constructor Create; reintroduce;
|
||||||
|
procedure DestroyResult;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function ParseCodePAWN(eCode: TStringList; FileName: String; IsRecursive: Boolean = False): TPAWNParseResult;
|
||||||
|
function UpdateIncPath(eInput: String): String;
|
||||||
|
|
||||||
|
var eCPUSpeed: Integer = 1;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses UnitCodeExplorerUpdater, UnitCodeUtils, UnitfrmSettings,
|
||||||
|
UnitMainTools, UnitfrmMain;
|
||||||
|
|
||||||
|
var eLookedUpIncluded: TStringList;
|
||||||
|
|
||||||
|
function UpdateIncPath(eInput: String): String;
|
||||||
|
begin
|
||||||
|
if FileExists(ExtractFilePath(frmSettings.txtPAWNCompilerPath.Text) + eInput + '.inc') then
|
||||||
|
Result := ExtractFilePath(frmSettings.txtPAWNCompilerPath.Text) + eInput + '.inc'
|
||||||
|
else if FileExists(ExtractFilePath(frmSettings.txtPAWNCompilerPath.Text) + 'include\' + eInput + '.inc') then
|
||||||
|
Result := ExtractFilePath(frmSettings.txtPAWNCompilerPath.Text) + 'include\' + eInput + '.inc'
|
||||||
|
else if (FileExists(ExtractFilePath(ActiveDoc.FileName) + eInput + '.inc')) and (not ActiveDoc.Modified) then
|
||||||
|
Result := ExtractFilePath(ActiveDoc.FileName) + eInput + '.inc'
|
||||||
|
else
|
||||||
|
Result := '';
|
||||||
|
end;
|
||||||
|
|
||||||
|
function ParseCodePAWN(eCode: TStringList; FileName: String; IsRecursive: Boolean = False): TPAWNParseResult;
|
||||||
|
var i, k: integer;
|
||||||
|
eString, eTemp: string;
|
||||||
|
eStr, ePreEvents: TStringList;
|
||||||
|
eStartLine, eBracesOpen: Integer;
|
||||||
|
eTimeToSleep: Integer;
|
||||||
|
eAddingEnum: Integer;
|
||||||
|
eTempResult: TPawnParseResult;
|
||||||
|
eProcedureAdded: Boolean;
|
||||||
|
begin
|
||||||
|
Result := TPawnParseResult.Create;
|
||||||
|
if not IsRecursive then
|
||||||
|
eLookedUpIncluded.Clear;
|
||||||
|
|
||||||
|
eStr := TStringList.Create;
|
||||||
|
ePreEvents := TStringList.Create;
|
||||||
|
eBracesOpen := 0;
|
||||||
|
eStartLine := -1;
|
||||||
|
eTimeToSleep := 0;
|
||||||
|
eAddingEnum := 0;
|
||||||
|
|
||||||
|
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);
|
||||||
|
eProcedureAdded := False;
|
||||||
|
Inc(eTimeToSleep, 1);
|
||||||
|
|
||||||
|
if eTimeToSleep = eCPUSpeed then begin
|
||||||
|
Sleep(1);
|
||||||
|
eTimeToSleep := 0;
|
||||||
|
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 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);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
eString := RemoveStringsAndComments(Trim(eCode[i]), True);
|
||||||
|
end
|
||||||
|
{ Included }
|
||||||
|
else if (IsAtStart('#include', eString)) then begin
|
||||||
|
if Between(eString, '<', '>') <> '' then begin
|
||||||
|
eString := Between(eString, '<', '>');
|
||||||
|
if ExtractFileExt(eString) <> '' then
|
||||||
|
ChangeFileExt(eString, '');
|
||||||
|
end
|
||||||
|
else if Between(eString, '"', '"') <> '' then begin
|
||||||
|
eString := Between(eString, '"', '"');
|
||||||
|
if ExtractFileExt(eString) <> '' then
|
||||||
|
ChangeFileExt(eString, '');
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
eString := Copy(eString, 9, Length(eString));
|
||||||
|
if ExtractFileExt(eString) <> '' then
|
||||||
|
ChangeFileExt(eString, '');
|
||||||
|
end;
|
||||||
|
eString := Trim(eString);
|
||||||
|
Result.Included.AddObject(eString, TObject(i));
|
||||||
|
|
||||||
|
// Recursive update
|
||||||
|
if (eLookedUpIncluded.IndexOf(eString) = -1) then begin
|
||||||
|
eLookedUpIncluded.Add(eString);
|
||||||
|
eTemp := UpdateIncPath(eString);
|
||||||
|
|
||||||
|
if (eString <> '') and (FileExists(eTemp)) then begin
|
||||||
|
// Load code and parse
|
||||||
|
try
|
||||||
|
eStr.LoadFromFile(eTemp);
|
||||||
|
if Application.Terminated then exit;
|
||||||
|
eTempResult := ParseCodePAWN(eStr, ExtractFileName(eTemp), True);
|
||||||
|
// Assign parsed values
|
||||||
|
Result.AutoComplete.AddStrings(eTempResult.AutoComplete);
|
||||||
|
Result.CallTips.AddStrings(eTempResult.CallTips);
|
||||||
|
Result.HighlightKeywords.AddStrings(eTempResult.HighlightKeywords);
|
||||||
|
// free
|
||||||
|
eTempResult.DestroyResult;
|
||||||
|
eTempResult := nil;
|
||||||
|
except
|
||||||
|
// mmmm.. burger
|
||||||
|
end;
|
||||||
|
// wait
|
||||||
|
Sleep(20);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
{ CVars }
|
||||||
|
else if (IsAtStart('register_cvar', eString)) and (not IsRecursive) then begin
|
||||||
|
if Between(eString, '"', '"') <> '' then
|
||||||
|
Result.CVars.AddObject(Between(eString, '"', '"'), TObject(i));
|
||||||
|
end
|
||||||
|
{ Defined }
|
||||||
|
else if (IsAtStart('#define', eString)) then begin
|
||||||
|
eString := Copy(eString, 8, Length(eString));
|
||||||
|
eString := Trim(eString);
|
||||||
|
Result.CallTips.Add(eString + '-> ' + FileName);
|
||||||
|
if Pos(#32, eString) <> 0 then
|
||||||
|
eString := Copy(eString, 1, Pos(#32, eString) - 1);
|
||||||
|
if Pos(' ', eString) <> 0 then
|
||||||
|
eString := Copy(eString, 1, Pos(' ', eString) - 1);
|
||||||
|
Result.Defined.AddObject(eString, TObject(i));
|
||||||
|
Result.AutoComplete.Add(eString);
|
||||||
|
end
|
||||||
|
{ Events (Part 1) }
|
||||||
|
else if (IsAtStart('register_event(', eString)) and (not IsRecursive) then begin
|
||||||
|
if CountChars(eString, '"') >= 4 then begin
|
||||||
|
eTemp := StringReplace(eString, '"' + Between(eString, '"', '"') + '"', '', []);
|
||||||
|
ePreEvents.Add(Between(eString, '"', '"'));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ Functions (1), this is adapted from AMXX-Edit v2 [see TextAnalyze.pas] }
|
||||||
|
eBracesOpen := eBracesOpen + CountChars(eString, '{');
|
||||||
|
eBracesOpen := eBracesOpen - CountChars(eString, '}');
|
||||||
|
|
||||||
|
if Pos('{', eString) <> 0 then begin
|
||||||
|
{ Enums -> }
|
||||||
|
if eAddingEnum = 1 then begin
|
||||||
|
eAddingEnum := 2;
|
||||||
|
Delete(eString, 1, Pos('{', eString) + 1);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
if eStartLine = -1 then begin
|
||||||
|
eProcedureAdded := True;
|
||||||
|
eStartLine := i;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{ <- Enums }
|
||||||
|
end;
|
||||||
|
if (Pos('}', eString) <> 0) and (not IsAtStart('new', Trim(eCode[eStartLine]))) 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));
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
// 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));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
eStartLine := -1;
|
||||||
|
eBracesOpen := 0;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else if (eAddingEnum = 2) and (Pos('enum', LowerCase(eString)) <> 1) then begin
|
||||||
|
if Pos(' ', eString) <> 0 then
|
||||||
|
eString := Copy(eString, 1, Pos(' ', eString) - 1);
|
||||||
|
if Pos(',', eString) <> 0 then
|
||||||
|
eString := Copy(eString, 1, Pos(',', eString) - 1);
|
||||||
|
if Pos(' ', eString) <> 0 then
|
||||||
|
eString := Copy(eString, 1, Pos(' ', eString) - 1);
|
||||||
|
if Pos(':', eString) <> 0 then
|
||||||
|
eString := Copy(eString, 1, Pos(':', eString) - 1);
|
||||||
|
Result.AutoComplete.Add(eString);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ Enums }
|
||||||
|
if IsAtStart('enum', eString) then begin
|
||||||
|
if Pos('{', eString) <> 0 then
|
||||||
|
eAddingEnum := 2 // Add values immediately
|
||||||
|
else
|
||||||
|
eAddingEnum := 1; // Wait for next brace and add then
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ 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 eTemp[Length(eTemp)] = '{' then
|
||||||
|
eTemp := Trim(Copy(eTemp, 1, Length(eTemp) -1));
|
||||||
|
|
||||||
|
// Remove type
|
||||||
|
if (Pos(#32, eTemp) <> 0) and (Pos(#32, eTemp) < Pos('(', eTemp)) then
|
||||||
|
eTemp := Copy(eTemp, Pos(#32, eTemp) + 1, Length(eTemp));
|
||||||
|
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('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);
|
||||||
|
|
||||||
|
if (Pos('enum', eTemp) = Pos('operator', eTemp)) and (Pos('enum', eTemp) = 0) then begin
|
||||||
|
Result.AutoComplete.Add(eTemp);
|
||||||
|
Result.HighlightKeywords.Add(eTemp);
|
||||||
|
end;
|
||||||
|
|
||||||
|
if eTemp <> '' then begin
|
||||||
|
if IsAtStart('forward', eString) then
|
||||||
|
Result.Forwards.AddObject(eString, TObject(i))
|
||||||
|
else if IsAtStart('public', eString) then 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(i));
|
||||||
|
end
|
||||||
|
else if IsAtStart('native', eString) then
|
||||||
|
Result.Natives.AddObject(eTemp, TObject(i))
|
||||||
|
else if IsAtStart('stock', eString) then
|
||||||
|
Result.Stocks.AddObject(eTemp, TObject(i))
|
||||||
|
else if (Pos('enum', eTemp) = Pos('operator', eTemp)) and (Pos('enum', eTemp) = 0) then
|
||||||
|
Result.MethodsDefault.AddObject(eTemp, TObject(i));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
ePreEvents.Free;
|
||||||
|
eStr.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TPAWNParseResult }
|
||||||
|
|
||||||
|
constructor TPAWNParseResult.Create;
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
|
||||||
|
Constants := TStringList.Create;
|
||||||
|
Defined := TStringList.Create;
|
||||||
|
CVars := TStringList.Create;
|
||||||
|
Included := TStringList.Create;
|
||||||
|
MethodsDefault := TStringList.Create;
|
||||||
|
Events := TStringList.Create;
|
||||||
|
Stocks := TStringList.Create;
|
||||||
|
Natives := TStringList.Create;
|
||||||
|
Forwards := TStringList.Create;
|
||||||
|
Variables := TStringList.Create;
|
||||||
|
|
||||||
|
CallTips := TStringList.Create;
|
||||||
|
AutoComplete := TStringList.Create;
|
||||||
|
HighlightKeywords := TStringList.Create;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPAWNParseResult.DestroyResult;
|
||||||
|
begin
|
||||||
|
Constants.Free;
|
||||||
|
Defined.Free;
|
||||||
|
CVars.Free;
|
||||||
|
Included.Free;
|
||||||
|
MethodsDefault.Free;
|
||||||
|
Events.Free;
|
||||||
|
Stocks.Free;
|
||||||
|
Natives.Free;
|
||||||
|
Forwards.Free;
|
||||||
|
Variables.Free;
|
||||||
|
|
||||||
|
CallTips.Free;
|
||||||
|
AutoComplete.Free;
|
||||||
|
HighlightKeywords.Free;
|
||||||
|
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
initialization
|
||||||
|
|
||||||
|
eLookedUpIncluded := TStringList.Create;
|
||||||
|
|
||||||
|
finalization
|
||||||
|
|
||||||
|
eLookedUpIncluded.Free;
|
||||||
|
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
BIN
editor/studio/UnitfrmAllFilesForm.dfm
Executable file
BIN
editor/studio/UnitfrmAllFilesForm.dfm
Executable file
Binary file not shown.
31
editor/studio/UnitfrmAllFilesForm.pas
Executable file
31
editor/studio/UnitfrmAllFilesForm.pas
Executable file
|
@ -0,0 +1,31 @@
|
||||||
|
unit UnitfrmAllFilesForm;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
SysUtils, Windows, Messages, Classes, Graphics, Controls,
|
||||||
|
StdCtrls, ExtCtrls, Forms, TBXDkPanels, SpTBXDkPanels, mbTBXListBox,
|
||||||
|
mbTBXCheckListBox;
|
||||||
|
|
||||||
|
type
|
||||||
|
TfrmAllFilesForm = class(TForm)
|
||||||
|
lblCaption: TLabel;
|
||||||
|
lstFiles: TmbTBXCheckListBox;
|
||||||
|
cmdOK: TSpTBXButton;
|
||||||
|
cmdCancel: TSpTBXButton;
|
||||||
|
procedure FormShow(Sender: TObject);
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
frmAllFilesForm: TfrmAllFilesForm;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{$R *.DFM}
|
||||||
|
|
||||||
|
procedure TfrmAllFilesForm.FormShow(Sender: TObject);
|
||||||
|
begin
|
||||||
|
lstFiles.SetFocus;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
BIN
editor/studio/UnitfrmAutoIndent.dfm
Executable file
BIN
editor/studio/UnitfrmAutoIndent.dfm
Executable file
Binary file not shown.
24
editor/studio/UnitfrmAutoIndent.pas
Executable file
24
editor/studio/UnitfrmAutoIndent.pas
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
unit UnitfrmAutoIndent;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
SysUtils, Windows, Messages, Classes, Graphics, Controls,
|
||||||
|
StdCtrls, ExtCtrls, Forms, TFlatCheckBoxUnit, TFlatButtonUnit;
|
||||||
|
|
||||||
|
type
|
||||||
|
TfrmAutoIndent = class(TForm)
|
||||||
|
chkUnindentPressingClosingBrace: TFlatCheckBox;
|
||||||
|
chkUnindentLine: TFlatCheckBox;
|
||||||
|
chkIndentOpeningBrace: TFlatCheckBox;
|
||||||
|
cmdClose: TFlatButton;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
frmAutoIndent: TfrmAutoIndent;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{$R *.DFM}
|
||||||
|
|
||||||
|
end.
|
BIN
editor/studio/UnitfrmClose.dfm
Executable file
BIN
editor/studio/UnitfrmClose.dfm
Executable file
Binary file not shown.
61
editor/studio/UnitfrmClose.pas
Executable file
61
editor/studio/UnitfrmClose.pas
Executable file
|
@ -0,0 +1,61 @@
|
||||||
|
unit UnitfrmClose;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
SysUtils, Windows, Messages, Classes, Graphics, Controls,
|
||||||
|
StdCtrls, ExtCtrls, Forms, CheckLst, TFlatSpeedButtonUnit, ComCtrls,
|
||||||
|
JvExComCtrls, JvComCtrls, JvCheckTreeView;
|
||||||
|
|
||||||
|
type
|
||||||
|
TfrmClose = class(TForm)
|
||||||
|
shpFiles: TShape;
|
||||||
|
cmdSave: TFlatSpeedButton;
|
||||||
|
cmdCancel: TFlatSpeedButton;
|
||||||
|
lblInfo: TLabel;
|
||||||
|
trvFiles: TJvCheckTreeView;
|
||||||
|
procedure trvFilesMouseDown(Sender: TObject; Button: TMouseButton;
|
||||||
|
Shift: TShiftState; X, Y: Integer);
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
frmClose: TfrmClose;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses UnitLanguages;
|
||||||
|
|
||||||
|
{$R *.DFM}
|
||||||
|
|
||||||
|
procedure TfrmClose.trvFilesMouseDown(Sender: TObject;
|
||||||
|
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||||
|
var eClose: Boolean;
|
||||||
|
i, k: integer;
|
||||||
|
begin
|
||||||
|
if Assigned(trvFiles.GetNodeAt(X, Y)) then begin
|
||||||
|
if not Assigned(trvFiles.GetNodeAt(X, Y).Parent) then begin
|
||||||
|
eClose := trvFiles.Checked[trvFiles.GetNodeAt(X, Y)];
|
||||||
|
with trvFiles.GetNodeAt(X, Y) do begin
|
||||||
|
for i := 0 to Count -1 do
|
||||||
|
trvFiles.Checked[Item[i]] := eClose;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
eClose := True;
|
||||||
|
for i := 0 to trvFiles.Items.Count -1 do begin
|
||||||
|
for k := 0 to trvFiles.Items[i].Count -1 do begin
|
||||||
|
if (trvFiles.Checked[trvFiles.Items[i].Item[k]]) then begin
|
||||||
|
eClose := False;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if eClose then
|
||||||
|
cmdSave.Caption := lCloseCaption
|
||||||
|
else
|
||||||
|
cmdSave.Caption := lSaveCaption;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
BIN
editor/studio/UnitfrmConnGen.dfm
Executable file
BIN
editor/studio/UnitfrmConnGen.dfm
Executable file
Binary file not shown.
40
editor/studio/UnitfrmConnGen.pas
Executable file
40
editor/studio/UnitfrmConnGen.pas
Executable file
|
@ -0,0 +1,40 @@
|
||||||
|
unit UnitfrmConnGen;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
SysUtils, Windows, Messages, Classes, Graphics, Controls,
|
||||||
|
StdCtrls, ExtCtrls, Forms, SpTBXEditors, TntStdCtrls, TBXDkPanels,
|
||||||
|
SpTBXDkPanels;
|
||||||
|
|
||||||
|
type
|
||||||
|
TfrmConnGen = class(TForm)
|
||||||
|
lblState: TLabel;
|
||||||
|
pnlSettings: TPanel;
|
||||||
|
lblHost: TLabel;
|
||||||
|
txtHost: TSpTBXEdit;
|
||||||
|
lblPort: TLabel;
|
||||||
|
txtPort: TSpTBXEdit;
|
||||||
|
lblProtocol: TLabel;
|
||||||
|
cboProtocol: TSpTBXComboBox;
|
||||||
|
cmdOK: TSpTBXButton;
|
||||||
|
cmdCancel: TSpTBXButton;
|
||||||
|
lblSocketName: TLabel;
|
||||||
|
txtName: TSpTBXEdit;
|
||||||
|
procedure txtNameKeyPress(Sender: TObject; var Key: Char);
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
frmConnGen: TfrmConnGen;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{$R *.DFM}
|
||||||
|
|
||||||
|
procedure TfrmConnGen.txtNameKeyPress(Sender: TObject; var Key: Char);
|
||||||
|
begin
|
||||||
|
if Key = #32 then
|
||||||
|
Key := #0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
BIN
editor/studio/UnitfrmGoToLine.dfm
Executable file
BIN
editor/studio/UnitfrmGoToLine.dfm
Executable file
Binary file not shown.
51
editor/studio/UnitfrmGoToLine.pas
Executable file
51
editor/studio/UnitfrmGoToLine.pas
Executable file
|
@ -0,0 +1,51 @@
|
||||||
|
unit UnitfrmGoToLine;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
SysUtils, Windows, Messages, Classes, Graphics, Controls,
|
||||||
|
StdCtrls, ExtCtrls, Forms, mbTBXEdit, mbTBXValidateEdit, TBXDkPanels,
|
||||||
|
SpTBXDkPanels, SpTBXEditors;
|
||||||
|
|
||||||
|
type
|
||||||
|
TfrmGoToLine = class(TForm)
|
||||||
|
lblCaption: TLabel;
|
||||||
|
txtGoToLine: TSpTBXEdit;
|
||||||
|
cmdOK: TSpTBXButton;
|
||||||
|
cmdCancel: TSpTBXButton;
|
||||||
|
procedure txtGoToLineChange(Sender: TObject);
|
||||||
|
procedure txtGoToLineKeyPress(Sender: TObject; var Key: Char);
|
||||||
|
procedure FormShow(Sender: TObject);
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
frmGoToLine: TfrmGoToLine;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses UnitMainTools;
|
||||||
|
|
||||||
|
{$R *.DFM}
|
||||||
|
|
||||||
|
procedure TfrmGoToLine.txtGoToLineChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if not IsNumeric(txtGoToLine.Text) then
|
||||||
|
txtGoToLine.Text := '1'
|
||||||
|
else if txtGoToLine.Text = '0' then
|
||||||
|
txtGoToLine.Text := '1';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmGoToLine.txtGoToLineKeyPress(Sender: TObject; var Key: Char);
|
||||||
|
begin
|
||||||
|
if Key = #13 then begin
|
||||||
|
cmdOK.Click;
|
||||||
|
Key := #0;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmGoToLine.FormShow(Sender: TObject);
|
||||||
|
begin
|
||||||
|
txtGoToLine.SetFocus;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
BIN
editor/studio/UnitfrmHTMLPreview.dfm
Executable file
BIN
editor/studio/UnitfrmHTMLPreview.dfm
Executable file
Binary file not shown.
73
editor/studio/UnitfrmHTMLPreview.pas
Executable file
73
editor/studio/UnitfrmHTMLPreview.pas
Executable file
|
@ -0,0 +1,73 @@
|
||||||
|
unit UnitfrmHTMLPreview;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
SysUtils, Windows, Messages, Classes, Graphics, Controls,
|
||||||
|
StdCtrls, ExtCtrls, Forms, OleCtrls, SHDocVw, ActiveX;
|
||||||
|
|
||||||
|
type
|
||||||
|
TfrmHTMLPreview = class(TForm)
|
||||||
|
wbPreview: TWebBrowser;
|
||||||
|
tmrLoad: TTimer;
|
||||||
|
procedure tmrLoadTimer(Sender: TObject);
|
||||||
|
procedure FormShow(Sender: TObject);
|
||||||
|
public
|
||||||
|
procedure LoadCode(eHTML: String);
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
frmHTMLPreview: TfrmHTMLPreview;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses UnitMainTools, UnitfrmMain;
|
||||||
|
|
||||||
|
{$R *.DFM}
|
||||||
|
|
||||||
|
{ TfrmHTMLPreview }
|
||||||
|
|
||||||
|
procedure TfrmHTMLPreview.LoadCode(eHTML: String);
|
||||||
|
var sl: TStringList;
|
||||||
|
ms: TMemoryStream;
|
||||||
|
begin
|
||||||
|
wbPreview.Navigate('about:blank');
|
||||||
|
while wbPreview.ReadyState < READYSTATE_INTERACTIVE do
|
||||||
|
Application.ProcessMessages;
|
||||||
|
|
||||||
|
if Assigned(wbPreview.Document) then
|
||||||
|
begin
|
||||||
|
sl := TStringList.Create;
|
||||||
|
try
|
||||||
|
ms := TMemoryStream.Create;
|
||||||
|
try
|
||||||
|
sl.Text := eHTML;
|
||||||
|
sl.SaveToStream(ms);
|
||||||
|
ms.Seek(0, 0);
|
||||||
|
(wbPreview.Document as IPersistStreamInit).Load(TStreamAdapter.Create(ms));
|
||||||
|
finally
|
||||||
|
ms.Free;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
sl.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmHTMLPreview.tmrLoadTimer(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if not Started then exit;
|
||||||
|
|
||||||
|
if (Visible) and (not Focused) then begin
|
||||||
|
if (LowerCase(ExtractFileExt(ActiveDoc.FileName)) = '.htm') or (LowerCase(ExtractFileExt(ActiveDoc.FileName)) = '.html') then
|
||||||
|
LoadCode(frmMain.sciEditor.Lines.Text);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmHTMLPreview.FormShow(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Left := frmMain.Left + frmMain.Width - Width - 50;
|
||||||
|
Top := frmMain.Top + 30;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
7437
editor/studio/UnitfrmHudMsgGenerator.dfm
Executable file
7437
editor/studio/UnitfrmHudMsgGenerator.dfm
Executable file
File diff suppressed because it is too large
Load Diff
273
editor/studio/UnitfrmHudMsgGenerator.pas
Executable file
273
editor/studio/UnitfrmHudMsgGenerator.pas
Executable file
|
@ -0,0 +1,273 @@
|
||||||
|
unit UnitfrmHudMsgGenerator;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||||||
|
Dialogs, TBXDkPanels, SpTBXDkPanels, ExtCtrls, StdCtrls, SpTBXEditors,
|
||||||
|
mbTBXEdit, mbTBXSpinEdit, mbTBXFloatSpinEdit, TB2Item, TBX, SpTBXItem,
|
||||||
|
TB2Dock, TB2Toolbar, ImgList, TFlatEditUnit, TFlatButtonUnit,
|
||||||
|
TFlatMemoUnit, Math, TFlatCheckBoxUnit;
|
||||||
|
|
||||||
|
type
|
||||||
|
TfrmHudMsgGenerator = class(TForm)
|
||||||
|
pnlPosition: TPanel;
|
||||||
|
lblPosition: TLabel;
|
||||||
|
lblXPos: TLabel;
|
||||||
|
lblYPos: TLabel;
|
||||||
|
pnlHudmessage: TPanel;
|
||||||
|
imgHudmessage: TImage;
|
||||||
|
pnlColor: TPanel;
|
||||||
|
lblColor: TLabel;
|
||||||
|
imgColor: TImage;
|
||||||
|
txtXPos: TFlatEdit;
|
||||||
|
txtYPos: TFlatEdit;
|
||||||
|
cmdSelectColor: TFlatButton;
|
||||||
|
cmdGenerate: TFlatButton;
|
||||||
|
cmdCancel: TFlatButton;
|
||||||
|
lblHudMsg: TLabel;
|
||||||
|
pnlText: TPanel;
|
||||||
|
txtText: TFlatEdit;
|
||||||
|
txtTimeToShow: TFlatEdit;
|
||||||
|
lblTimeToShow: TLabel;
|
||||||
|
lblText: TLabel;
|
||||||
|
lblOther: TLabel;
|
||||||
|
chkXCenter: TFlatCheckBox;
|
||||||
|
chkYCenter: TFlatCheckBox;
|
||||||
|
procedure lblHudMsgMouseDown(Sender: TObject; Button: TMouseButton;
|
||||||
|
Shift: TShiftState; X, Y: Integer);
|
||||||
|
procedure lblHudMsgMouseMove(Sender: TObject; Shift: TShiftState; X,
|
||||||
|
Y: Integer);
|
||||||
|
procedure lblHudMsgMouseUp(Sender: TObject; Button: TMouseButton;
|
||||||
|
Shift: TShiftState; X, Y: Integer);
|
||||||
|
procedure txtXPosKeyPress(Sender: TObject; var Key: Char);
|
||||||
|
procedure txtYPosKeyPress(Sender: TObject; var Key: Char);
|
||||||
|
procedure FormShow(Sender: TObject);
|
||||||
|
procedure txtTextKeyPress(Sender: TObject; var Key: Char);
|
||||||
|
procedure cmdSelectColorClick(Sender: TObject);
|
||||||
|
procedure txtTextChange(Sender: TObject);
|
||||||
|
procedure txtTimeToShowKeyPress(Sender: TObject; var Key: Char);
|
||||||
|
procedure txtTimeToShowChange(Sender: TObject);
|
||||||
|
procedure chkXCenterClick(Sender: TObject);
|
||||||
|
procedure chkYCenterClick(Sender: TObject);
|
||||||
|
procedure txtPosExit(Sender: TObject);
|
||||||
|
private
|
||||||
|
eDown: Boolean;
|
||||||
|
eStartPos: TPoint;
|
||||||
|
procedure PaintColor;
|
||||||
|
procedure CenterX;
|
||||||
|
procedure CenterY;
|
||||||
|
public
|
||||||
|
CurrColor: TColor;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
frmHudMsgGenerator: TfrmHudMsgGenerator;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses UnitfrmSelectColor, UnitMainTools;
|
||||||
|
|
||||||
|
{$R *.dfm}
|
||||||
|
|
||||||
|
procedure TfrmHudMsgGenerator.lblHudMsgMouseDown(Sender: TObject;
|
||||||
|
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||||
|
begin
|
||||||
|
eStartPos.X := X;
|
||||||
|
eStartPos.Y := Y;
|
||||||
|
eDown := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmHudMsgGenerator.lblHudMsgMouseMove(Sender: TObject;
|
||||||
|
Shift: TShiftState; X, Y: Integer);
|
||||||
|
begin
|
||||||
|
if eDown then begin
|
||||||
|
{ X Pos }
|
||||||
|
if not chkXCenter.Checked then begin
|
||||||
|
lblHudMsg.Left := lblHudMsg.Left + (X - eStartPos.X);
|
||||||
|
if lblHudMsg.Left < 0 then
|
||||||
|
lblHudMsg.Left := 0
|
||||||
|
else if lblHudMsg.Left > pnlHudmessage.Width then
|
||||||
|
lblHudMsg.Left := pnlHudmessage.Width;
|
||||||
|
txtXPos.Text := FloatToStr(RoundTo(lblHudMsg.Left / pnlHudmessage.Width, -2));
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ Y Pos }
|
||||||
|
if not chkYCenter.Checked then begin
|
||||||
|
lblHudMsg.Top := lblHudMsg.Top + (Y - eStartPos.Y);
|
||||||
|
if lblHudMsg.Top < 0 then
|
||||||
|
lblHudMsg.Top := 0
|
||||||
|
else if lblHudMsg.Top > pnlHudmessage.Height then
|
||||||
|
lblHudMsg.Top := pnlHudmessage.Height;
|
||||||
|
txtYPos.Text := FloatToStr(RoundTo(lblHudMsg.Top / pnlHudmessage.Height, -2));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmHudMsgGenerator.lblHudMsgMouseUp(Sender: TObject;
|
||||||
|
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||||
|
begin
|
||||||
|
eDown := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmHudMsgGenerator.PaintColor;
|
||||||
|
begin
|
||||||
|
imgColor.Canvas.Pen.Color := $008396A0;
|
||||||
|
imgColor.Canvas.Brush.Color := CurrColor;
|
||||||
|
imgColor.Canvas.Rectangle(0, 0, 31, 31);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmHudMsgGenerator.txtXPosKeyPress(Sender: TObject;
|
||||||
|
var Key: Char);
|
||||||
|
var eXVal: Real;
|
||||||
|
begin
|
||||||
|
if Key = '.' then
|
||||||
|
Key := ','
|
||||||
|
else if Key = #13 then begin
|
||||||
|
try
|
||||||
|
eXVal := RoundTo(StrToFloat(txtXPos.Text), -2);
|
||||||
|
txtXPos.Text := FloatToStr(eXVal);
|
||||||
|
if Pos(',', txtXPos.Text) = 0 then
|
||||||
|
txtXPos.Text := txtXPos.Text + ',0';
|
||||||
|
lblHudMsg.Left := Round(eXVal * pnlHudmessage.Width);
|
||||||
|
Key := #0;
|
||||||
|
except
|
||||||
|
txtXPos.Text := '0,00';
|
||||||
|
lblHudMsg.Left := 0;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmHudMsgGenerator.txtYPosKeyPress(Sender: TObject;
|
||||||
|
var Key: Char);
|
||||||
|
var eYVal: Real;
|
||||||
|
begin
|
||||||
|
if Key = '.' then
|
||||||
|
Key := ','
|
||||||
|
else if Key = #13 then begin
|
||||||
|
try
|
||||||
|
eYVal := RoundTo(StrToFloat(txtYPos.Text), -2);
|
||||||
|
txtYPos.Text := FloatToStr(eYVal);
|
||||||
|
if Pos(',', txtYPos.Text) = 0 then
|
||||||
|
txtYPos.Text := txtYPos.Text + ',0';
|
||||||
|
lblHudMsg.Top := Round(eYVal * pnlHudmessage.Height);
|
||||||
|
Key := #0;
|
||||||
|
except
|
||||||
|
txtYPos.Text := '0,00';
|
||||||
|
lblHudMsg.Left := 0;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmHudMsgGenerator.FormShow(Sender: TObject);
|
||||||
|
begin
|
||||||
|
CurrColor := clRed;
|
||||||
|
PaintColor;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmHudMsgGenerator.txtTextKeyPress(Sender: TObject;
|
||||||
|
var Key: Char);
|
||||||
|
begin
|
||||||
|
if Key = #13 then begin
|
||||||
|
txtText.SelText := '\n';
|
||||||
|
Key := #0;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmHudMsgGenerator.cmdSelectColorClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
frmSelectColor.chkDefault1.Enabled := False;
|
||||||
|
frmSelectColor.chkDefault2.Enabled := False;
|
||||||
|
ShowColorDialog(CurrColor, imgColor);
|
||||||
|
lblHudMsg.Font.Color := CurrColor;
|
||||||
|
frmSelectColor.chkDefault1.Enabled := True;
|
||||||
|
frmSelectColor.chkDefault2.Enabled := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmHudMsgGenerator.txtTextChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if txtText.Text = '' then
|
||||||
|
lblHudMsg.Caption := 'Custom Hudmessage'
|
||||||
|
else
|
||||||
|
lblHudMsg.Caption := stringReplace(txtText.Text, '\n', #13, [rfReplaceAll]);
|
||||||
|
|
||||||
|
if chkXCenter.Checked then
|
||||||
|
CenterX;
|
||||||
|
if chkYCenter.Checked then
|
||||||
|
CenterY;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmHudMsgGenerator.txtTimeToShowKeyPress(Sender: TObject;
|
||||||
|
var Key: Char);
|
||||||
|
begin
|
||||||
|
if Key = '.' then
|
||||||
|
Key := ',';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmHudMsgGenerator.txtTimeToShowChange(Sender: TObject);
|
||||||
|
var eVal: Real;
|
||||||
|
begin
|
||||||
|
try
|
||||||
|
eVal := Round(StrToFloat(txtTimeToShow.Text));
|
||||||
|
if eVal < 0 then begin
|
||||||
|
eVal := 0.0;
|
||||||
|
txtTimeToShow.Text := FloatToStr(eVal);
|
||||||
|
end;
|
||||||
|
except
|
||||||
|
txtTimeToShow.Text := '12,0';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmHudMsgGenerator.chkXCenterClick(Sender: TObject);
|
||||||
|
var eChar: Char;
|
||||||
|
begin
|
||||||
|
if chkXCenter.Checked then begin
|
||||||
|
txtXPos.Text := '-1,0';
|
||||||
|
CenterX;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
txtXPos.Text := '0,5';
|
||||||
|
eChar := #13;
|
||||||
|
txtXPosKeyPress(Sender, eChar);
|
||||||
|
end;
|
||||||
|
|
||||||
|
txtXPos.Enabled := not chkXCenter.Checked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmHudMsgGenerator.chkYCenterClick(Sender: TObject);
|
||||||
|
var eChar: Char;
|
||||||
|
begin
|
||||||
|
if chkYCenter.Checked then begin
|
||||||
|
txtYPos.Text := '-1,0';
|
||||||
|
CenterY;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
txtYPos.Text := '0,5';
|
||||||
|
eChar := #13;
|
||||||
|
txtYPosKeyPress(Sender, eChar);
|
||||||
|
end;
|
||||||
|
|
||||||
|
txtYPos.Enabled := not chkYCenter.Checked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmHudMsgGenerator.CenterX;
|
||||||
|
begin
|
||||||
|
lblHudMsg.Left := (pnlHudmessage.Width div 2) - (lblHudMsg.Width div 2);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmHudMsgGenerator.CenterY;
|
||||||
|
begin
|
||||||
|
lblHudMsg.Top := (pnlHudmessage.Height div 2) - (lblHudMsg.Height div 2);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmHudMsgGenerator.txtPosExit(Sender: TObject);
|
||||||
|
var eChar: Char;
|
||||||
|
begin
|
||||||
|
eChar := #13;
|
||||||
|
if Sender = txtXPos then
|
||||||
|
txtXPos.OnKeyPress(txtXPos, eChar)
|
||||||
|
else
|
||||||
|
txtYPos.OnKeyPress(txtXPos, eChar);
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
BIN
editor/studio/UnitfrmInfo.dfm
Executable file
BIN
editor/studio/UnitfrmInfo.dfm
Executable file
Binary file not shown.
56
editor/studio/UnitfrmInfo.pas
Executable file
56
editor/studio/UnitfrmInfo.pas
Executable file
|
@ -0,0 +1,56 @@
|
||||||
|
unit UnitfrmInfo;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
SysUtils, Windows, Messages, Classes, Graphics, Controls,
|
||||||
|
StdCtrls, ExtCtrls, Forms, TBXDkPanels, SpTBXDkPanels, JvExControls,
|
||||||
|
JvComponent, JvScrollText, ShellAPI, IdHTTP, jpeg, Dialogs;
|
||||||
|
|
||||||
|
type
|
||||||
|
TfrmInfo = class(TForm)
|
||||||
|
lblInfo3: TLabel;
|
||||||
|
lblInfo2: TLabel;
|
||||||
|
lblInfo1: TLabel;
|
||||||
|
imgAMXXLarge: TImage;
|
||||||
|
cmdClose: TSpTBXButton;
|
||||||
|
pnlGallery: TPanel;
|
||||||
|
Label1: TLabel;
|
||||||
|
imgGabeN: TImage;
|
||||||
|
imgBurger: TImage;
|
||||||
|
Label2: TLabel;
|
||||||
|
Label3: TLabel;
|
||||||
|
imgYams: TImage;
|
||||||
|
procedure imgGabeNDblClick(Sender: TObject);
|
||||||
|
procedure imgBurgerDblClick(Sender: TObject);
|
||||||
|
procedure imgYamsDblClick(Sender: TObject);
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
frmInfo: TfrmInfo;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{$R *.DFM}
|
||||||
|
|
||||||
|
procedure TfrmInfo.imgGabeNDblClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
ShellExecute(Handle, 'open', PChar('http://sniperbeamer.de/gallery/gaben.php'), nil, nil, SW_SHOW);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmInfo.imgBurgerDblClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
MessageBeep(MB_ICONQUESTION);
|
||||||
|
if MessageBox(Handle, 'Do you want a BIG TASTY BURGER?', 'all-in-one-messagebox', MB_ICONQUESTION + MB_YESNO) = mrYes then begin
|
||||||
|
ShellExecute(Handle, 'open', 'http://www.amxmodx.org/forums/viewtopic.php?t=14658&karma_up=8284', nil, nil, SW_SHOW);
|
||||||
|
Sleep(5000);
|
||||||
|
MessageBox(Handle, 'zomg you won''t get one. GabeN (tm) has already eaten each burger on THIS F**KIN'' BURGERLESS WORLD >_< :( Sorry.', 'all-in-one-messagebox', MB_ICONERROR);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmInfo.imgYamsDblClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
MessageBox(Handle, 'myam(s) myam(s), myam(s)...', 'all-in-one-messagebox', MB_ICONINFORMATION);
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
BIN
editor/studio/UnitfrmMOTDGen.dfm
Executable file
BIN
editor/studio/UnitfrmMOTDGen.dfm
Executable file
Binary file not shown.
30
editor/studio/UnitfrmMOTDGen.pas
Executable file
30
editor/studio/UnitfrmMOTDGen.pas
Executable file
|
@ -0,0 +1,30 @@
|
||||||
|
unit UnitfrmMOTDGen;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
SysUtils, Windows, Messages, Classes, Graphics, Controls,
|
||||||
|
StdCtrls, ExtCtrls, Forms, mxFlatControls, TBXDkPanels, SpTBXDkPanels;
|
||||||
|
|
||||||
|
type
|
||||||
|
TfrmMOTDGen = class(TForm)
|
||||||
|
txtMOTD: TmxFlatMemo;
|
||||||
|
cmdClose: TSpTBXButton;
|
||||||
|
cmdCopy: TSpTBXButton;
|
||||||
|
procedure cmdCopyClick(Sender: TObject);
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
frmMOTDGen: TfrmMOTDGen;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{$R *.DFM}
|
||||||
|
|
||||||
|
procedure TfrmMOTDGen.cmdCopyClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
txtMOTD.CopyToClipboard;
|
||||||
|
txtMOTD.CopyToClipboard;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
7741
editor/studio/UnitfrmMain.dfm
Executable file
7741
editor/studio/UnitfrmMain.dfm
Executable file
File diff suppressed because it is too large
Load Diff
2652
editor/studio/UnitfrmMain.pas
Executable file
2652
editor/studio/UnitfrmMain.pas
Executable file
File diff suppressed because it is too large
Load Diff
BIN
editor/studio/UnitfrmMenuGenerator.dfm
Executable file
BIN
editor/studio/UnitfrmMenuGenerator.dfm
Executable file
Binary file not shown.
295
editor/studio/UnitfrmMenuGenerator.pas
Executable file
295
editor/studio/UnitfrmMenuGenerator.pas
Executable file
|
@ -0,0 +1,295 @@
|
||||||
|
unit UnitfrmMenuGenerator;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
SysUtils, Windows, Messages, Classes, Graphics, Controls,
|
||||||
|
StdCtrls, ExtCtrls, Forms, TBXDkPanels, SpTBXDkPanels, JvExControls,
|
||||||
|
JvComponent, JvPageList, TFlatRadioButtonUnit, TFlatMemoUnit,
|
||||||
|
TFlatEditUnit, TB2Dock, TB2Toolbar, TBX, SpTBXItem, ImgList, TB2Item,
|
||||||
|
Dialogs, TFlatComboBoxUnit, ComCtrls, ClipBrd, TFlatCheckBoxUnit;
|
||||||
|
|
||||||
|
type
|
||||||
|
TfrmMenuGenerator = class(TForm)
|
||||||
|
jplMain: TJvPageList;
|
||||||
|
jspSelectType: TJvStandardPage;
|
||||||
|
pnlSelectType: TPanel;
|
||||||
|
lblSelectInfo: TLabel;
|
||||||
|
optSimpleOldMenu: TSpTBXRadioButton;
|
||||||
|
optPlayerMenu: TSpTBXRadioButton;
|
||||||
|
optSimpleMenu: TSpTBXRadioButton;
|
||||||
|
cmdCancel: TSpTBXButton;
|
||||||
|
cmdNext: TSpTBXButton;
|
||||||
|
jspOldMenuAdd1: TJvStandardPage;
|
||||||
|
optOldPlayerMenu: TSpTBXRadioButton;
|
||||||
|
jspNewMenuAdd: TJvStandardPage;
|
||||||
|
ilImages: TImageList;
|
||||||
|
pnlBack: TPanel;
|
||||||
|
pnlMenu: TPanel;
|
||||||
|
tbxMenuItems: TSpTBXToolbar;
|
||||||
|
mnuAdd: TSpTBXItem;
|
||||||
|
mnuRemove: TSpTBXItem;
|
||||||
|
sepItems: TSpTBXSeparatorItem;
|
||||||
|
mnuUp: TSpTBXItem;
|
||||||
|
mnuMoveDown: TSpTBXItem;
|
||||||
|
lstNMenuItems: TListBox;
|
||||||
|
txtNTitle: TFlatEdit;
|
||||||
|
lblNTitle: TLabel;
|
||||||
|
lblMenuNItemsCaption: TLabel;
|
||||||
|
cmdNCreate: TSpTBXButton;
|
||||||
|
cmdBack: TSpTBXButton;
|
||||||
|
pnlAccess: TPanel;
|
||||||
|
lblAccess: TLabel;
|
||||||
|
cboAccess: TFlatComboBox;
|
||||||
|
lblState: TLabel;
|
||||||
|
tbxColors: TSpTBXToolbar;
|
||||||
|
mnuYellow: TSpTBXItem;
|
||||||
|
mnuWhite: TSpTBXItem;
|
||||||
|
mnuRed: TSpTBXItem;
|
||||||
|
mnuGray: TSpTBXItem;
|
||||||
|
pnlControls: TPanel;
|
||||||
|
rtfMenu: TRichEdit;
|
||||||
|
sepColors: TSpTBXSeparatorItem;
|
||||||
|
mnuCopy: TSpTBXItem;
|
||||||
|
cmdOldNext1: TSpTBXButton;
|
||||||
|
cmdOldBack1: TSpTBXButton;
|
||||||
|
lblHelp: TLabel;
|
||||||
|
jspOldMenuAdd2: TJvStandardPage;
|
||||||
|
Panel1: TPanel;
|
||||||
|
txtKeys: TFlatEdit;
|
||||||
|
lblKeys: TLabel;
|
||||||
|
txtMenuName: TFlatEdit;
|
||||||
|
lblName: TLabel;
|
||||||
|
chkAddComment: TFlatCheckBox;
|
||||||
|
chkRegisterMenuCommand: TFlatCheckBox;
|
||||||
|
chkUseTime: TFlatCheckBox;
|
||||||
|
txtTime: TFlatEdit;
|
||||||
|
Label1: TLabel;
|
||||||
|
cmdOldNext2: TSpTBXButton;
|
||||||
|
cmdOldBack2: TSpTBXButton;
|
||||||
|
procedure mnuAddClick(Sender: TObject);
|
||||||
|
procedure mnuRemoveClick(Sender: TObject);
|
||||||
|
procedure mnuUpClick(Sender: TObject);
|
||||||
|
procedure mnuMoveDownClick(Sender: TObject);
|
||||||
|
procedure cmdNCreateClick(Sender: TObject);
|
||||||
|
procedure cmdBackClick(Sender: TObject);
|
||||||
|
procedure cmdNextClick(Sender: TObject);
|
||||||
|
procedure lblHelpMouseEnter(Sender: TObject);
|
||||||
|
procedure lblHelpMouseLeave(Sender: TObject);
|
||||||
|
procedure mnuYellowClick(Sender: TObject);
|
||||||
|
procedure mnuWhiteClick(Sender: TObject);
|
||||||
|
procedure mnuRedClick(Sender: TObject);
|
||||||
|
procedure mnuGrayClick(Sender: TObject);
|
||||||
|
procedure rtfMenuMouseUp(Sender: TObject; Button: TMouseButton;
|
||||||
|
Shift: TShiftState; X, Y: Integer);
|
||||||
|
procedure rtfMenuKeyUp(Sender: TObject; var Key: Word;
|
||||||
|
Shift: TShiftState);
|
||||||
|
procedure cmdOldNext1Click(Sender: TObject);
|
||||||
|
procedure mnuCopyClick(Sender: TObject);
|
||||||
|
procedure cmdOldNext2Click(Sender: TObject);
|
||||||
|
procedure lblHelpClick(Sender: TObject);
|
||||||
|
private
|
||||||
|
procedure UpdateColor;
|
||||||
|
procedure UpdateMenu(Sender: TObject);
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
frmMenuGenerator: TfrmMenuGenerator;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses UnitLanguages, UnitMenuGenerators, UnitCodeUtils, UnitMainTools;
|
||||||
|
|
||||||
|
{$R *.DFM}
|
||||||
|
|
||||||
|
procedure TfrmMenuGenerator.mnuAddClick(Sender: TObject);
|
||||||
|
var eStr: String;
|
||||||
|
begin
|
||||||
|
if InputQuery(lAddItemCaption, lAddItemPrompt, eStr) then begin
|
||||||
|
if (optPlayerMenu.Checked) and (UpperCase(eStr) = 'PLAYERS') then begin
|
||||||
|
eStr := 'PLAYERS';
|
||||||
|
if lstNMenuItems.Items.IndexOf('PLAYERS') <> -1 then begin
|
||||||
|
MessageBox(Handle, PChar(lPlayersAlreadyAdded), PChar(Application.Title), MB_ICONERROR);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
lstNMenuItems.ItemIndex := lstNMenuItems.Items.Add(eStr);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMenuGenerator.mnuRemoveClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if lstNMenuItems.ItemIndex <> -1 then
|
||||||
|
lstNMenuItems.DeleteSelected;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMenuGenerator.mnuUpClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if lstNMenuItems.ItemIndex > 0 then
|
||||||
|
lstNMenuItems.Items.Exchange(lstNMenuItems.ItemIndex, lstNMenuItems.ItemIndex -1);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMenuGenerator.mnuMoveDownClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if (lstNMenuItems.ItemIndex <> -1) and (lstNMenuItems.ItemIndex <> lstNMenuItems.Items.Count -1) then
|
||||||
|
lstNMenuItems.Items.Exchange(lstNMenuItems.ItemIndex, lstNMenuItems.ItemIndex +1);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMenuGenerator.cmdNCreateClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if txtNTitle.Text = '' then
|
||||||
|
MessageBox(Handle, PChar(lEnterTitle), PChar(Application.Title), MB_ICONERROR)
|
||||||
|
else if lstNMenuItems.Items.Count = 0 then
|
||||||
|
MessageBox(Handle, PChar(lAddItems), PChar(Application.Title), MB_ICONERROR)
|
||||||
|
else if self.optSimpleMenu.Checked then begin
|
||||||
|
GenerateSimpleMenu;
|
||||||
|
ModalResult := mrOk;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMenuGenerator.cmdBackClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
jplMain.ActivePageIndex := 0;
|
||||||
|
lblState.Caption := 'Menu Generator';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMenuGenerator.cmdNextClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
// New style
|
||||||
|
if optSimpleMenu.Checked then begin
|
||||||
|
jplMain.ActivePageIndex := 1;
|
||||||
|
lblState.Caption := 'Create a simple menu';
|
||||||
|
end;
|
||||||
|
// Old style
|
||||||
|
if optSimpleOldMenu.Checked then begin
|
||||||
|
jplMain.ActivePageIndex := 2;
|
||||||
|
lblState.Caption := 'Create a simple menu';
|
||||||
|
lblHelp.Hide;
|
||||||
|
end;
|
||||||
|
if optOldPlayerMenu.Checked then begin
|
||||||
|
jplMain.ActivePageIndex := 2;
|
||||||
|
lblState.Caption := 'Create a player menu';
|
||||||
|
lblHelp.Show;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMenuGenerator.lblHelpMouseEnter(Sender: TObject);
|
||||||
|
begin
|
||||||
|
lblHelp.Font.Color := clHotLight;
|
||||||
|
lblHelp.Font.Style := [fsUnderline];
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMenuGenerator.lblHelpMouseLeave(Sender: TObject);
|
||||||
|
begin
|
||||||
|
lblHelp.Font.Color := clWindowText;
|
||||||
|
lblHelp.Font.Style := [];
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMenuGenerator.mnuYellowClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
rtfMenu.SelAttributes.Color := clYellow;
|
||||||
|
UpdateMenu(Sender);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMenuGenerator.mnuWhiteClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
rtfMenu.SelAttributes.Color := clWhite;
|
||||||
|
UpdateMenu(Sender);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMenuGenerator.mnuRedClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
rtfMenu.SelAttributes.Color := clRed;
|
||||||
|
UpdateMenu(Sender);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMenuGenerator.mnuGrayClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
rtfMenu.SelAttributes.Color := clGray;
|
||||||
|
UpdateMenu(Sender);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMenuGenerator.UpdateColor;
|
||||||
|
begin
|
||||||
|
case rtfMenu.SelAttributes.Color of
|
||||||
|
clYellow: mnuYellow.Checked := True;
|
||||||
|
clWhite: mnuWhite.Checked := True;
|
||||||
|
clRed: mnuRed.Checked := True;
|
||||||
|
clGray: mnuGray.Checked := True;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMenuGenerator.UpdateMenu(Sender: TObject);
|
||||||
|
begin
|
||||||
|
mnuYellow.Checked := Sender = mnuYellow;
|
||||||
|
mnuWhite.Checked := Sender = mnuWhite;
|
||||||
|
mnuRed.Checked := Sender = mnuRed;
|
||||||
|
mnuGray.Checked := Sender = mnuGray;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMenuGenerator.rtfMenuMouseUp(Sender: TObject;
|
||||||
|
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||||
|
begin
|
||||||
|
UpdateColor;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMenuGenerator.rtfMenuKeyUp(Sender: TObject; var Key: Word;
|
||||||
|
Shift: TShiftState);
|
||||||
|
begin
|
||||||
|
UpdateColor;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMenuGenerator.cmdOldNext1Click(Sender: TObject);
|
||||||
|
var i: integer;
|
||||||
|
begin
|
||||||
|
if Trim(rtfMenu.Text) = '' then begin
|
||||||
|
MessageBox(Handle, 'The menu is empty!', PChar(Application.Title), MB_ICONERROR);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
txtKeys.Clear;
|
||||||
|
for i := 0 to rtfMenu.Lines.Count -1 do begin
|
||||||
|
if IsNumeric(Copy(rtfMenu.Lines[i], 1, 1)) then
|
||||||
|
txtKeys.Text := txtKeys.Text + rtfMenu.Lines[i][1];
|
||||||
|
end;
|
||||||
|
jplMain.ActivePageIndex := 3;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMenuGenerator.mnuCopyClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Clipboard.SetTextBuf(PChar(GetColoredMenu));
|
||||||
|
MessageBox(Handle, 'Okay, menu copied to clipboard.', PChar(Application.Title), MB_ICONINFORMATION);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMenuGenerator.cmdOldNext2Click(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if optSimpleOldMenu.Checked then
|
||||||
|
AddOldMenu
|
||||||
|
else
|
||||||
|
AddOldPlayerMenu;
|
||||||
|
ModalResult := mrOk;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMenuGenerator.lblHelpClick(Sender: TObject);
|
||||||
|
var eMsg: String;
|
||||||
|
begin
|
||||||
|
eMsg := '1. Choose a menu title (e.g. Kick player)' + #13;
|
||||||
|
eMsg := eMsg + '2. Set dynamic players with $players in this format:' + #13;
|
||||||
|
eMsg := eMsg + ' $players(StartKey, StopKey, Caption)' + #13;
|
||||||
|
eMsg := eMsg + ' Variables in caption are: %n (Key) and %v(Player)' + #13;
|
||||||
|
eMsg := eMsg + '3. Set Next and Back keys using $next(Key, Caption)' + #13;
|
||||||
|
eMsg := eMsg + ' and $exitorback(Key, ExitCaption, BackCaption)' + #13;
|
||||||
|
eMsg := eMsg + #13;
|
||||||
|
eMsg := eMsg + 'Show example?';
|
||||||
|
|
||||||
|
if MessageBox(Handle, PChar(eMsg), PChar(Application.Title), MB_ICONQUESTION + MB_YESNO) = mrYes then begin
|
||||||
|
rtfMenu.Clear;
|
||||||
|
rtfMenu.SelAttributes.Color := clYellow;
|
||||||
|
rtfMenu.SelText := 'Kick player' + #13 + #13;
|
||||||
|
rtfMenu.SelStart := Length(rtfMenu.Lines.Text);
|
||||||
|
rtfMenu.SelAttributes.Color := clWhite;
|
||||||
|
rtfMenu.SelText := '$players(1,8,%n. %v)' + #13 + '$next(9,9. Next)' + '$exitorback(0,0. Exit,0. Back)';
|
||||||
|
rtfMenu.SelStart := 0;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
BIN
editor/studio/UnitfrmPluginsIniEditor.dfm
Executable file
BIN
editor/studio/UnitfrmPluginsIniEditor.dfm
Executable file
Binary file not shown.
160
editor/studio/UnitfrmPluginsIniEditor.pas
Executable file
160
editor/studio/UnitfrmPluginsIniEditor.pas
Executable file
|
@ -0,0 +1,160 @@
|
||||||
|
unit UnitfrmPluginsIniEditor;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
SysUtils, Windows, Messages, Classes, Graphics, Controls,
|
||||||
|
StdCtrls, ExtCtrls, Forms, TBXDkPanels, SpTBXDkPanels, mbTBXMemo, Dialogs,
|
||||||
|
IdFTPCommon;
|
||||||
|
|
||||||
|
type
|
||||||
|
TfrmPluginsIniEditor = class(TForm)
|
||||||
|
txtFile: TmbTBXMemo;
|
||||||
|
cmdOK: TSpTBXButton;
|
||||||
|
cmdCancel: TSpTBXButton;
|
||||||
|
pnlEditType: TPanel;
|
||||||
|
chkEditFTP: TSpTBXCheckBox;
|
||||||
|
chkEditLocal: TSpTBXCheckBox;
|
||||||
|
cmdRemove: TSpTBXButton;
|
||||||
|
odOpen: TOpenDialog;
|
||||||
|
procedure chkEditFTPClick(Sender: TObject);
|
||||||
|
procedure chkEditLocalClick(Sender: TObject);
|
||||||
|
procedure cmdRemoveClick(Sender: TObject);
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
frmPluginsIniEditor: TfrmPluginsIniEditor;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses UnitfrmMain, UnitfrmSettings, UnitMainTools, UnitLanguages;
|
||||||
|
|
||||||
|
{$R *.DFM}
|
||||||
|
|
||||||
|
procedure TfrmPluginsIniEditor.chkEditFTPClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if Screen.Cursor = crHourGlass then exit;
|
||||||
|
|
||||||
|
Screen.Cursor := crHourGlass;
|
||||||
|
|
||||||
|
if not frmMain.IdFTP.Connected then begin
|
||||||
|
if TryConnect <> 0 then begin
|
||||||
|
cmdRemove.Enabled := False;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
try
|
||||||
|
frmMain.IdFTP.ChangeDir(frmSettings.txtDefaultDir.Text + 'configs/');
|
||||||
|
except
|
||||||
|
frmMain.IdFTP.Disconnect;
|
||||||
|
MessageBox(Application.Handle, PChar(lInvalidDirectory), PChar(Application.Title), MB_ICONERROR);
|
||||||
|
chkEditFTP.Checked := False;
|
||||||
|
chkEditLocal.Checked := True;
|
||||||
|
cmdRemove.Enabled := False;
|
||||||
|
Screen.Cursor := crDefault;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
frmMain.IdFTP.TransferType := ftASCII;
|
||||||
|
frmMain.IdFTP.Get('plugins.ini', ExtractFilePath(ParamStr(0)) + 'plugins.ini', True);
|
||||||
|
frmPluginsIniEditor.txtFile.Lines.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'plugins.ini');
|
||||||
|
DeleteFile(PChar(ExtractFilePath(ParamStr(0)) + 'plugins.ini'));
|
||||||
|
|
||||||
|
chkEditFTP.Checked := True;
|
||||||
|
chkEditLocal.Checked := False;
|
||||||
|
cmdRemove.Enabled := True;
|
||||||
|
Screen.Cursor := crDefault;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmPluginsIniEditor.chkEditLocalClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if Screen.Cursor = crHourGlass then exit;
|
||||||
|
|
||||||
|
Screen.Cursor := crHourGlass;
|
||||||
|
if not FileExists(GetAMXXDir(True) + 'configs\plugins.ini') then begin
|
||||||
|
if odOpen.Execute then begin
|
||||||
|
txtFile.Lines.LoadFromFile(odOpen.FileName);
|
||||||
|
cmdRemove.Enabled := Pos('amxmodx', LowerCase(odOpen.FileName)) <> 0;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
cmdRemove.Enabled := False;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
txtFile.Lines.LoadFromFile(GetAMXXDir(True) + 'configs\plugins.ini');
|
||||||
|
odOpen.FileName := GetAMXXDir(True) + 'configs\plugins.ini';
|
||||||
|
cmdRemove.Enabled := True;
|
||||||
|
end;
|
||||||
|
chkEditFTP.Checked := False;
|
||||||
|
chkEditLocal.Checked := True;
|
||||||
|
Screen.Cursor := crDefault;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmPluginsIniEditor.cmdRemoveClick(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;
|
||||||
|
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));
|
||||||
|
end;
|
||||||
|
Result := Trim(eLine);
|
||||||
|
end;
|
||||||
|
|
||||||
|
var eStr: TStringList;
|
||||||
|
a,b: integer;
|
||||||
|
eFound: Boolean;
|
||||||
|
begin
|
||||||
|
Screen.Cursor := crHourGlass;
|
||||||
|
if chkEditFTP.Checked then begin
|
||||||
|
if not frmMain.IdFTP.Connected then begin
|
||||||
|
if TryConnect <> 0 then begin
|
||||||
|
Screen.Cursor := crDefault;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
eStr := TStringList.Create;
|
||||||
|
try
|
||||||
|
frmMain.IdFTP.ChangeDir(frmSettings.txtDefaultDir.Text + 'plugins/');
|
||||||
|
frmMain.IdFTP.List(eStr, '', False);
|
||||||
|
for a := txtFile.Lines.Count -1 downto 0 do begin
|
||||||
|
if (Copy(txtFile.Lines[a], 1, 1) <> ';') and (Copy(txtFile.Lines[a], 1, 1) <> '/') and (Trim(txtFile.Lines[a]) <> '') then begin
|
||||||
|
eFound := False;
|
||||||
|
for b := 0 to eStr.Count -1 do begin
|
||||||
|
if RemComments(txtFile.Lines[a]) = eStr[b] then
|
||||||
|
eFound := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if not eFound then
|
||||||
|
txtFile.Lines.Delete(a);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
except
|
||||||
|
MessageBox(Application.Handle, PChar(lInvalidDirectory), PChar(Application.Title), MB_ICONERROR);
|
||||||
|
end;
|
||||||
|
|
||||||
|
eStr.Free;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
for a := txtFile.Lines.Count -1 downto 0 do begin
|
||||||
|
if (Copy(txtFile.Lines[a], 1, 1) <> ';') and (Copy(txtFile.Lines[a], 1, 1) <> '/') then begin
|
||||||
|
if (not FileExists(Copy(ExtractFilePath(odOpen.FileName), 1, Length(ExtractFilePath(odOpen.FileName)) -8) + 'plugins\' + RemComments(txtFile.Lines[a]))) and (Trim(txtFile.Lines[a]) <> '') then
|
||||||
|
txtFile.Lines.Delete(a);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Screen.Cursor := crDefault;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
BIN
editor/studio/UnitfrmReplace.dfm
Executable file
BIN
editor/studio/UnitfrmReplace.dfm
Executable file
Binary file not shown.
78
editor/studio/UnitfrmReplace.pas
Executable file
78
editor/studio/UnitfrmReplace.pas
Executable file
|
@ -0,0 +1,78 @@
|
||||||
|
unit UnitfrmReplace;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
SysUtils, Windows, Messages, Classes, Graphics, Controls,
|
||||||
|
StdCtrls, ExtCtrls, Forms, TntStdCtrls, SpTBXEditors, SpTBXDkPanels,
|
||||||
|
TBXDkPanels;
|
||||||
|
|
||||||
|
type
|
||||||
|
TfrmReplace = class(TForm)
|
||||||
|
lblSearchFor: TLabel;
|
||||||
|
cboSearchFor: TSpTBXComboBox;
|
||||||
|
lblReplaceWith: TLabel;
|
||||||
|
cboReplaceWith: TSpTBXComboBox;
|
||||||
|
pnlOptions: TSpTBXGroupBox;
|
||||||
|
chkCaseSensivity: TSpTBXCheckBox;
|
||||||
|
chkWholeWordsOnly: TSpTBXCheckBox;
|
||||||
|
chkSearchFromCaret: TSpTBXCheckBox;
|
||||||
|
chkSelectedTextOnly: TSpTBXCheckBox;
|
||||||
|
chkRegularExpression: TSpTBXCheckBox;
|
||||||
|
pnlDirection: TSpTBXGroupBox;
|
||||||
|
chkForward: TSpTBXCheckBox;
|
||||||
|
chkBackward: TSpTBXCheckBox;
|
||||||
|
cmdOK: TSpTBXButton;
|
||||||
|
cmdCancel: TSpTBXButton;
|
||||||
|
bvlReplaceAll: TBevel;
|
||||||
|
chkReplaceAll: TSpTBXCheckBox;
|
||||||
|
procedure FormCreate(Sender: TObject);
|
||||||
|
procedure OnDirectionChange(Sender: TObject);
|
||||||
|
procedure cmdOKClick(Sender: TObject);
|
||||||
|
procedure FormShow(Sender: TObject);
|
||||||
|
public
|
||||||
|
eChange: Boolean;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
frmReplace: TfrmReplace;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses UnitLanguages;
|
||||||
|
|
||||||
|
{$R *.DFM}
|
||||||
|
|
||||||
|
procedure TfrmReplace.FormCreate(Sender: TObject);
|
||||||
|
begin
|
||||||
|
eChange := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmReplace.OnDirectionChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if not eChange then exit;
|
||||||
|
eChange := False;
|
||||||
|
chkForward.Checked := Sender = chkForward;
|
||||||
|
chkBackward.Checked := Sender = chkBackward;
|
||||||
|
eChange := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmReplace.cmdOKClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if cboSearchFor.Text = '' then
|
||||||
|
MessageBox(Handle, PChar(lEnterSearchText), PChar(Application.Title), MB_ICONERROR)
|
||||||
|
else begin
|
||||||
|
if cboSearchFor.Items.IndexOf(cboSearchFor.Text) = -1 then
|
||||||
|
cboSearchFor.Items.Add(cboSearchFor.Text);
|
||||||
|
if (cboReplaceWith.Text <> '') and (cboReplaceWith.Items.IndexOf(cboReplaceWith.Text) = -1) then
|
||||||
|
cboReplaceWith.Items.Add(cboReplaceWith.Text);
|
||||||
|
ModalResult := mrOK;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmReplace.FormShow(Sender: TObject);
|
||||||
|
begin
|
||||||
|
cboSearchFor.SetFocus;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
BIN
editor/studio/UnitfrmSearch.dfm
Executable file
BIN
editor/studio/UnitfrmSearch.dfm
Executable file
Binary file not shown.
81
editor/studio/UnitfrmSearch.pas
Executable file
81
editor/studio/UnitfrmSearch.pas
Executable file
|
@ -0,0 +1,81 @@
|
||||||
|
unit UnitfrmSearch;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
SysUtils, Windows, Messages, Classes, Graphics, Controls,
|
||||||
|
StdCtrls, ExtCtrls, Forms, TntStdCtrls, SpTBXEditors, SpTBXDkPanels,
|
||||||
|
TBXDkPanels, Dialogs;
|
||||||
|
|
||||||
|
type
|
||||||
|
TfrmSearch = class(TForm)
|
||||||
|
pnlOptions: TSpTBXGroupBox;
|
||||||
|
lblSearchFor: TLabel;
|
||||||
|
cboSearchFor: TSpTBXComboBox;
|
||||||
|
pnlDirection: TSpTBXGroupBox;
|
||||||
|
chkCaseSensivity: TSpTBXCheckBox;
|
||||||
|
chkWholeWordsOnly: TSpTBXCheckBox;
|
||||||
|
chkSearchFromCaret: TSpTBXCheckBox;
|
||||||
|
chkSelectedTextOnly: TSpTBXCheckBox;
|
||||||
|
chkRegularExpression: TSpTBXCheckBox;
|
||||||
|
cmdOK: TSpTBXButton;
|
||||||
|
cmdCancel: TSpTBXButton;
|
||||||
|
chkForward: TSpTBXCheckBox;
|
||||||
|
chkBackward: TSpTBXCheckBox;
|
||||||
|
procedure FormCreate(Sender: TObject);
|
||||||
|
procedure OnDirectionClick(Sender: TObject);
|
||||||
|
procedure cmdOKClick(Sender: TObject);
|
||||||
|
procedure cboSearchForKeyPress(Sender: TObject; var Key: Char);
|
||||||
|
procedure FormShow(Sender: TObject);
|
||||||
|
public
|
||||||
|
eChange: Boolean;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
frmSearch: TfrmSearch;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses UnitLanguages, UnitPlugins;
|
||||||
|
|
||||||
|
{$R *.DFM}
|
||||||
|
|
||||||
|
procedure TfrmSearch.FormCreate(Sender: TObject);
|
||||||
|
begin
|
||||||
|
eChange := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSearch.OnDirectionClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if not eChange then exit;
|
||||||
|
eChange := False;
|
||||||
|
chkForward.Checked := Sender = chkForward;
|
||||||
|
chkBackward.Checked := Sender = chkBackward;
|
||||||
|
eChange := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSearch.cmdOKClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if cboSearchFor.Text = '' then
|
||||||
|
MessageBox(Handle, PChar(lEnterSearchText), PChar(Application.Title), MB_ICONERROR)
|
||||||
|
else begin
|
||||||
|
if cboSearchFor.Items.IndexOf(cboSearchFor.Text) = -1 then
|
||||||
|
cboSearchFor.Items.Add(cboSearchFor.Text);
|
||||||
|
ModalResult := mrOK;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSearch.cboSearchForKeyPress(Sender: TObject; var Key: Char);
|
||||||
|
begin
|
||||||
|
if Key = #13 then begin
|
||||||
|
cmdOk.Click;
|
||||||
|
Key := #0;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSearch.FormShow(Sender: TObject);
|
||||||
|
begin
|
||||||
|
cboSearchFor.SetFocus;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
BIN
editor/studio/UnitfrmSelectColor.dfm
Executable file
BIN
editor/studio/UnitfrmSelectColor.dfm
Executable file
Binary file not shown.
265
editor/studio/UnitfrmSelectColor.pas
Executable file
265
editor/studio/UnitfrmSelectColor.pas
Executable file
|
@ -0,0 +1,265 @@
|
||||||
|
unit UnitfrmSelectColor; // adapted from OfficeMoreColorsDialog
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||||||
|
ComCtrls, HexaColorPicker, HSLColorPicker, StdCtrls, ExtCtrls, RGBHSLUtils,
|
||||||
|
mbXPSpinEdit, mbColorPreview, mbXPSizeGrip, StrUtils, HTMLColors;
|
||||||
|
|
||||||
|
type
|
||||||
|
TfrmSelectColor = class(TForm)
|
||||||
|
Pages: TPageControl;
|
||||||
|
Standard: TTabSheet;
|
||||||
|
Custom: TTabSheet;
|
||||||
|
Hexa: THexaColorPicker;
|
||||||
|
HSL: THSLColorPicker;
|
||||||
|
lblColor2: TLabel;
|
||||||
|
lblColor1: TLabel;
|
||||||
|
lblColorModel: TLabel;
|
||||||
|
ColorModel: TComboBox;
|
||||||
|
LRed: TLabel;
|
||||||
|
LGreen: TLabel;
|
||||||
|
LBlue: TLabel;
|
||||||
|
lblNew: TLabel;
|
||||||
|
lblCurrent: TLabel;
|
||||||
|
cmdOK: TButton;
|
||||||
|
cmdCancel: TButton;
|
||||||
|
ERed: TmbXPSpinEdit;
|
||||||
|
EGreen: TmbXPSpinEdit;
|
||||||
|
EBlue: TmbXPSpinEdit;
|
||||||
|
NewSwatch: TmbColorPreview;
|
||||||
|
OldSwatch: TmbColorPreview;
|
||||||
|
chkDefault1: TCheckBox;
|
||||||
|
bvlSpace1: TBevel;
|
||||||
|
bvlSpace2: TBevel;
|
||||||
|
chkDefault2: TCheckBox;
|
||||||
|
procedure ColorModelChange(Sender: TObject);
|
||||||
|
procedure HSLChange(Sender: TObject);
|
||||||
|
procedure ERedChange(Sender: TObject);
|
||||||
|
procedure EGreenChange(Sender: TObject);
|
||||||
|
procedure EBlueChange(Sender: TObject);
|
||||||
|
procedure FormKeyDown(Sender: TObject; var Key: Word;
|
||||||
|
Shift: TShiftState);
|
||||||
|
procedure HexaChange(Sender: TObject);
|
||||||
|
procedure NewSwatchColorChange(Sender: TObject);
|
||||||
|
procedure OldSwatchColorChange(Sender: TObject);
|
||||||
|
function GetHint(c: TColor): string;
|
||||||
|
procedure SetAllToSel(c: TColor);
|
||||||
|
procedure PagesChange(Sender: TObject);
|
||||||
|
procedure chkDefault2Click(Sender: TObject);
|
||||||
|
protected
|
||||||
|
procedure CreateParams(var Params: TCreateParams); override;
|
||||||
|
procedure CreateWnd; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
frmSelectColor: TfrmSelectColor;
|
||||||
|
h, s, l: integer;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{$R *.dfm}
|
||||||
|
|
||||||
|
procedure TfrmSelectColor.CreateParams(var Params: TCreateParams);
|
||||||
|
begin
|
||||||
|
inherited CreateParams(Params);
|
||||||
|
Params.Style := WS_CAPTION or WS_SYSMENU;
|
||||||
|
Params.ExStyle := WS_EX_DLGMODALFRAME or WS_EX_WINDOWEDGE;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSelectColor.CreateWnd;
|
||||||
|
begin
|
||||||
|
inherited CreateWnd;
|
||||||
|
SendMessage(Self.Handle, WM_SETICON, 1, 0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSelectColor.ColorModelChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
case ColorModel.ItemIndex of
|
||||||
|
0:
|
||||||
|
begin
|
||||||
|
LRed.Caption := '&Red:';
|
||||||
|
LGreen.Caption := '&Green:';
|
||||||
|
LBlue.Caption := '&Blue:';
|
||||||
|
ERed.MaxValue := 255;
|
||||||
|
EGreen.MaxValue := 255;
|
||||||
|
EBlue.MaxValue := 255;
|
||||||
|
ERed.Value := GetRValue(NewSwatch.Color);
|
||||||
|
EGreen.Value := GetGValue(NewSwatch.Color);
|
||||||
|
EBlue.Value := GetBValue(NewSwatch.Color);
|
||||||
|
end;
|
||||||
|
1:
|
||||||
|
begin
|
||||||
|
LRed.Caption := 'H&ue:';
|
||||||
|
LGreen.Caption := '&Sat:';
|
||||||
|
LBlue.Caption := '&Lum:';
|
||||||
|
ERed.MaxValue := 238;
|
||||||
|
EGreen.MaxValue := 240;
|
||||||
|
EBlue.MaxValue := 240;
|
||||||
|
RGBtoHSLRange(NewSwatch.Color, h, s, l);
|
||||||
|
ERed.Value := h;
|
||||||
|
EGreen.Value := s;
|
||||||
|
EBlue.Value := l;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSelectColor.HSLChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if HSL.Manual then
|
||||||
|
case ColorModel.ItemIndex of
|
||||||
|
0:
|
||||||
|
begin
|
||||||
|
ERed.Value := HSL.RValue;
|
||||||
|
EGreen.Value := HSL.GValue;
|
||||||
|
EBlue.Value := HSL.BValue;
|
||||||
|
NewSwatch.Color := HSL.SelectedColor;
|
||||||
|
end;
|
||||||
|
1:
|
||||||
|
begin
|
||||||
|
ERed.Value := HSL.HValue;
|
||||||
|
EGreen.Value := HSL.SValue;
|
||||||
|
EBlue.Value := HSL.LValue;
|
||||||
|
NewSwatch.Color := HSL.SelectedColor;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSelectColor.ERedChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if (ERed.Text <> '') and ERed.Focused then
|
||||||
|
case ColorModel.ItemIndex of
|
||||||
|
0:
|
||||||
|
begin
|
||||||
|
HSL.RValue := ERed.Value;
|
||||||
|
NewSwatch.Color := RGB(ERed.Value, EGreen.Value, EBlue.Value);
|
||||||
|
end;
|
||||||
|
1:
|
||||||
|
begin
|
||||||
|
HSL.HValue := ERed.Value;
|
||||||
|
NewSwatch.Color := HSLRangeToRGB(ERed.Value, EGreen.Value, EBlue.Value);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSelectColor.EGreenChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if (EGreen.Text <> '') and EGreen.Focused then
|
||||||
|
case ColorModel.ItemIndex of
|
||||||
|
0:
|
||||||
|
begin
|
||||||
|
HSL.GValue := EGreen.Value;
|
||||||
|
NewSwatch.Color := RGB(ERed.Value, EGreen.Value, EBlue.Value);
|
||||||
|
end;
|
||||||
|
1:
|
||||||
|
begin
|
||||||
|
HSL.SValue := EGreen.Value;
|
||||||
|
NewSwatch.Color := HSLRangeToRGB(ERed.Value, EGreen.Value, EBlue.Value);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSelectColor.EBlueChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if (EBlue.Text <> '') and EBlue.Focused then
|
||||||
|
case ColorModel.ItemIndex of
|
||||||
|
0:
|
||||||
|
begin
|
||||||
|
HSL.BValue := EBlue.Value;
|
||||||
|
NewSwatch.Color := RGB(ERed.Value, EGreen.Value, EBlue.Value);
|
||||||
|
end;
|
||||||
|
1:
|
||||||
|
begin
|
||||||
|
HSL.LValue := EBlue.Value;
|
||||||
|
NewSwatch.Color := HSLRangeToRGB(ERed.Value, EGreen.Value, EBlue.Value);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSelectColor.FormKeyDown(Sender: TObject; var Key: Word;
|
||||||
|
Shift: TShiftState);
|
||||||
|
begin
|
||||||
|
case Key of
|
||||||
|
VK_RETURN: ModalResult := mrOK;
|
||||||
|
VK_ESCAPE: ModalResult := mrCancel;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSelectColor.HexaChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
NewSwatch.Color := Hexa.SelectedColor;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TfrmSelectColor.GetHint(c: TColor): string;
|
||||||
|
begin
|
||||||
|
Result := Format('RGB(%u, %u, %u)'#13'Hex: %s', [GetRValue(c), GetGValue(c), GetBValue(c), ColorToHex(c)]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSelectColor.NewSwatchColorChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
NewSwatch.Hint := GetHint(NewSwatch.Color);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSelectColor.OldSwatchColorChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
OldSwatch.Hint := GetHint(OldSwatch.Color);
|
||||||
|
SetAllToSel(OldSwatch.Color);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSelectColor.SetAllToSel(c: TColor);
|
||||||
|
begin
|
||||||
|
case Pages.ActivePageIndex of
|
||||||
|
// Standard Page
|
||||||
|
0: Hexa.SelectedColor := c;
|
||||||
|
// Custom Page
|
||||||
|
1:
|
||||||
|
begin
|
||||||
|
HSL.SelectedColor := c;
|
||||||
|
case ColorModel.ItemIndex of
|
||||||
|
0:
|
||||||
|
begin
|
||||||
|
ERed.Value := GetRValue(c);
|
||||||
|
EGreen.Value := GetGValue(c);
|
||||||
|
EBlue.Value := GetBValue(c);
|
||||||
|
end;
|
||||||
|
1:
|
||||||
|
begin
|
||||||
|
RGBtoHSLRange(c, h, s, l);
|
||||||
|
ERed.Value := h;
|
||||||
|
EGreen.Value := s;
|
||||||
|
EBlue.Value := l;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
NewSwatch.Color := c;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSelectColor.PagesChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
SetAllToSel(NewSwatch.Color);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSelectColor.chkDefault2Click(Sender: TObject);
|
||||||
|
begin
|
||||||
|
chkDefault1.Checked := (Sender As TCheckBox).Checked;
|
||||||
|
chkDefault2.Checked := (Sender As TCheckBox).Checked;
|
||||||
|
|
||||||
|
lblColor1.Enabled := not (Sender As TCheckBox).Checked;
|
||||||
|
bvlSpace1.Enabled := not (Sender As TCheckBox).Checked;
|
||||||
|
Hexa.Enabled := not (Sender As TCheckBox).Checked;
|
||||||
|
lblColor2.Enabled := not (Sender As TCheckBox).Checked;
|
||||||
|
lblColorModel.Enabled := not (Sender As TCheckBox).Checked;
|
||||||
|
LRed.Enabled := not (Sender As TCheckBox).Checked;
|
||||||
|
LGreen.Enabled := not (Sender As TCheckBox).Checked;
|
||||||
|
LBlue.Enabled := not (Sender As TCheckBox).Checked;
|
||||||
|
bvlSpace2.Enabled := not (Sender As TCheckBox).Checked;
|
||||||
|
HSL.Enabled := not (Sender As TCheckBox).Checked;
|
||||||
|
ColorModel.Enabled := not (Sender As TCheckBox).Checked;
|
||||||
|
ERed.Enabled := not (Sender As TCheckBox).Checked;
|
||||||
|
EGreen.Enabled := not (Sender As TCheckBox).Checked;
|
||||||
|
EBlue.Enabled := not (Sender As TCheckBox).Checked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
1806
editor/studio/UnitfrmSettings.dfm
Executable file
1806
editor/studio/UnitfrmSettings.dfm
Executable file
File diff suppressed because it is too large
Load Diff
949
editor/studio/UnitfrmSettings.pas
Executable file
949
editor/studio/UnitfrmSettings.pas
Executable file
|
@ -0,0 +1,949 @@
|
||||||
|
unit UnitfrmSettings;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
SysUtils, Windows, Messages, Classes, Graphics, Controls,
|
||||||
|
StdCtrls, ExtCtrls, Forms, JvExControls, JvComponent, JvPageList,
|
||||||
|
ComCtrls, JvExComCtrls, JvPageListTreeView, TBXDkPanels, SpTBXDkPanels,
|
||||||
|
SpTBXEditors, IniFiles, TFlatButtonUnit, TFlatEditUnit, TFlatCheckBoxUnit,
|
||||||
|
TFlatListBoxUnit, TFlatComboBoxUnit, mbXPFontCombo, ScintillaLanguageManager,
|
||||||
|
SciKeyBindings, menus, TFlatTabControlUnit, TFlatMemoUnit,
|
||||||
|
TFlatRadioButtonUnit, sciLexer, sciLexerMod, sciLexerMemo, Dialogs,
|
||||||
|
FileCtrl, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
|
||||||
|
IdFTP, IdException, ImgList, JvxSlider;
|
||||||
|
|
||||||
|
type
|
||||||
|
TfrmSettings = class(TForm)
|
||||||
|
trvSettings: TJvSettingsTreeView;
|
||||||
|
jplSettings: TJvPageList;
|
||||||
|
jspHighlighter: TJvStandardPage;
|
||||||
|
jspTools: TJvStandardPage;
|
||||||
|
jspShortcuts: TJvStandardPage;
|
||||||
|
jspCompiler: TJvStandardPage;
|
||||||
|
jspFTP: TJvStandardPage;
|
||||||
|
jspPlugIns: TJvStandardPage;
|
||||||
|
jspMisc: TJvStandardPage;
|
||||||
|
jspCodeSnippets: TJvStandardPage;
|
||||||
|
lblCurrSetting: TLabel;
|
||||||
|
pnlControls: TPanel;
|
||||||
|
bvlControls: TBevel;
|
||||||
|
cmdOK: TFlatButton;
|
||||||
|
cmdCancel: TFlatButton;
|
||||||
|
lblStyles: TLabel;
|
||||||
|
cboLanguage: TFlatComboBox;
|
||||||
|
lblLanguage: TLabel;
|
||||||
|
pnlHighlighter: TPanel;
|
||||||
|
lblProperties: TLabel;
|
||||||
|
cboFont: TmbXPFontCombo;
|
||||||
|
lblFont: TLabel;
|
||||||
|
chkBold: TFlatCheckBox;
|
||||||
|
chkItalic: TFlatCheckBox;
|
||||||
|
chkUnderlined: TFlatCheckBox;
|
||||||
|
chkVisible: TFlatCheckBox;
|
||||||
|
pnlColors: TPanel;
|
||||||
|
cmdSelectBackground: TFlatButton;
|
||||||
|
imgBackground: TImage;
|
||||||
|
lblBackground: TLabel;
|
||||||
|
cmdSelectForeground: TFlatButton;
|
||||||
|
imgForeground: TImage;
|
||||||
|
lblForeground: TLabel;
|
||||||
|
lblFontSize: TLabel;
|
||||||
|
txtFontSize: TFlatEdit;
|
||||||
|
chkUseDefaultFont: TFlatCheckBox;
|
||||||
|
cmdReset: TFlatButton;
|
||||||
|
pnlDefaultNewPluginValues: TPanel;
|
||||||
|
lblDefaultInfo: TLabel;
|
||||||
|
lblDefaultAuthor: TLabel;
|
||||||
|
txtDefaultAuthor: TFlatEdit;
|
||||||
|
lblDefaultVersion: TLabel;
|
||||||
|
lblDefaultName: TLabel;
|
||||||
|
txtDefaultName: TFlatEdit;
|
||||||
|
txtDefaultVersion: TFlatEdit;
|
||||||
|
shpStyles: TShape;
|
||||||
|
lstStyles: TListBox;
|
||||||
|
chkHighlightBraces: TFlatCheckBox;
|
||||||
|
chkAutoCloseBraces: TFlatCheckBox;
|
||||||
|
chkAutoCloseQuotes: TFlatCheckBox;
|
||||||
|
chkClearUndoAfterSave: TFlatCheckBox;
|
||||||
|
bvlTools1: TBevel;
|
||||||
|
chkWordWrap: TFlatCheckBox;
|
||||||
|
lblCodeFolding: TLabel;
|
||||||
|
pnlCodeFolding: TPanel;
|
||||||
|
cboCodeFolding: TFlatComboBox;
|
||||||
|
lblCodeFoldingStyle: TLabel;
|
||||||
|
lvShortcuts: TListView;
|
||||||
|
hkShortcut: THotKey;
|
||||||
|
cmdApply: TFlatButton;
|
||||||
|
shpShortcuts: TShape;
|
||||||
|
ftcCodeSnippets: TFlatTabControl;
|
||||||
|
shpCodeSnippets: TShape;
|
||||||
|
shpCodeSnippet: TShape;
|
||||||
|
lstCodeSnippets: TListBox;
|
||||||
|
txtCodeSnippet: TMemo;
|
||||||
|
cmdCSAdd: TFlatButton;
|
||||||
|
cmdCSRemove: TFlatButton;
|
||||||
|
chkShowStatusbar: TFlatCheckBox;
|
||||||
|
lblCaret: TLabel;
|
||||||
|
pnlCaret: TPanel;
|
||||||
|
cmdSelectCaretFore: TFlatButton;
|
||||||
|
imgCaretFore: TImage;
|
||||||
|
lblSelectCaretFore: TLabel;
|
||||||
|
cmdSelectCaretBack: TFlatButton;
|
||||||
|
imgCaretBack: TImage;
|
||||||
|
lblSelectCaretBack: TLabel;
|
||||||
|
bvlCaret1: TBevel;
|
||||||
|
chkShowCaret: TFlatCheckBox;
|
||||||
|
lblCaretPeriod: TLabel;
|
||||||
|
txtPeriod: TFlatEdit;
|
||||||
|
pnlNotes: TPanel;
|
||||||
|
lblSaveNotesTo: TLabel;
|
||||||
|
optFileComment: TFlatRadioButton;
|
||||||
|
optConfig: TFlatRadioButton;
|
||||||
|
shpPlugins: TShape;
|
||||||
|
lvPlugins: TListView;
|
||||||
|
cmdReload: TFlatButton;
|
||||||
|
cmdLoad: TFlatButton;
|
||||||
|
cmdUnload: TFlatButton;
|
||||||
|
cmdRemove: TFlatButton;
|
||||||
|
chkRestoreCaret: TFlatCheckBox;
|
||||||
|
txtLines: TFlatEdit;
|
||||||
|
bvlCaret2: TBevel;
|
||||||
|
optDontSave: TFlatRadioButton;
|
||||||
|
lblPAWN: TLabel;
|
||||||
|
pnlSMALLCompiler: TPanel;
|
||||||
|
lblCPPCompiler: TLabel;
|
||||||
|
pnlCPPCompiler: TPanel;
|
||||||
|
lblPAWNCompilerPath: TLabel;
|
||||||
|
txtPAWNCompilerPath: TFlatEdit;
|
||||||
|
cmdBrowsePAWNCompiler: TFlatButton;
|
||||||
|
txtCPPCompilerPath: TFlatEdit;
|
||||||
|
lblCPPCompilerPath: TLabel;
|
||||||
|
cmdBrowseCPPCompiler: TFlatButton;
|
||||||
|
lblCPPHint: TLabel;
|
||||||
|
lblCPPCompilerArgs: TLabel;
|
||||||
|
txtCPPCompilerArguments: TFlatEdit;
|
||||||
|
txtCPPOutput: TFlatEdit;
|
||||||
|
lblCPPOutput: TLabel;
|
||||||
|
txtPAWNOutput: TFlatEdit;
|
||||||
|
txtPAWNArgs: TFlatEdit;
|
||||||
|
lblPAWNArgs: TLabel;
|
||||||
|
lblSPAWNOutput: TLabel;
|
||||||
|
cmdBrowseOutputPAWN: TFlatButton;
|
||||||
|
cmdBrowseOutputCPP: TFlatButton;
|
||||||
|
pnlFTPData: TPanel;
|
||||||
|
lblFTPData: TLabel;
|
||||||
|
chkPassive: TFlatCheckBox;
|
||||||
|
txtHost: TFlatEdit;
|
||||||
|
lblHost: TLabel;
|
||||||
|
txtPort: TFlatEdit;
|
||||||
|
txtUsername: TFlatEdit;
|
||||||
|
txtPassword: TFlatEdit;
|
||||||
|
lblPassword: TLabel;
|
||||||
|
lblUsername: TLabel;
|
||||||
|
lblPort: TLabel;
|
||||||
|
pnlDefaultPath: TPanel;
|
||||||
|
pnlDirectory: TPanel;
|
||||||
|
trvDirectories: TTreeView;
|
||||||
|
txtDefaultDir: TFlatEdit;
|
||||||
|
cmdConnect: TFlatButton;
|
||||||
|
lblDefaultDir: TLabel;
|
||||||
|
lblDefaultDirectory: TLabel;
|
||||||
|
odBrowse: TOpenDialog;
|
||||||
|
ilImages: TImageList;
|
||||||
|
jspProxy: TJvStandardPage;
|
||||||
|
pnlProxy: TPanel;
|
||||||
|
txtProxyPassword: TFlatEdit;
|
||||||
|
txtProxyUsername: TFlatEdit;
|
||||||
|
lblProxyPassword: TLabel;
|
||||||
|
lblProxyUsername: TLabel;
|
||||||
|
txtProxyHost: TFlatEdit;
|
||||||
|
txtProxyPort: TFlatEdit;
|
||||||
|
lblProxyPort: TLabel;
|
||||||
|
lblProxyHost: TLabel;
|
||||||
|
cboProxy: TFlatComboBox;
|
||||||
|
lblProxy: TLabel;
|
||||||
|
pnlPCSpeed: TPanel;
|
||||||
|
lblCPUSpeed: TLabel;
|
||||||
|
sldSpeed: TJvxSlider;
|
||||||
|
lblSlow: TLabel;
|
||||||
|
lblAverage: TLabel;
|
||||||
|
lblFast: TLabel;
|
||||||
|
jspHalfLife: TJvStandardPage;
|
||||||
|
pnlHLExecutable: TPanel;
|
||||||
|
lblHLExec: TLabel;
|
||||||
|
txtHLExec: TFlatEdit;
|
||||||
|
cmdBrowseHL: TFlatButton;
|
||||||
|
lblCustomParameters: TLabel;
|
||||||
|
txtCustomParameters: TFlatEdit;
|
||||||
|
chkIndentGuides: TFlatCheckBox;
|
||||||
|
lblAutoIndent: TLabel;
|
||||||
|
pnlAutoIndent: TPanel;
|
||||||
|
chkAutoIndent: TFlatCheckBox;
|
||||||
|
cmdAdvancedAutoIndent: TFlatButton;
|
||||||
|
txtAMXXDir: TFlatEdit;
|
||||||
|
lblAMXXDir: TLabel;
|
||||||
|
cmdBrowseAMXXDir: TFlatButton;
|
||||||
|
procedure jplSettingsChange(Sender: TObject);
|
||||||
|
procedure txtLinesChange(Sender: TObject);
|
||||||
|
procedure FormCreate(Sender: TObject);
|
||||||
|
procedure FormDestroy(Sender: TObject);
|
||||||
|
procedure FormShow(Sender: TObject);
|
||||||
|
procedure chkRestoreCaretClick(Sender: TObject);
|
||||||
|
procedure txtFontSizeChange(Sender: TObject);
|
||||||
|
procedure cboLanguageChange(Sender: TObject);
|
||||||
|
procedure chkUseDefaultFontClick(Sender: TObject);
|
||||||
|
procedure cboFontChange(Sender: TObject);
|
||||||
|
procedure chkBoldClick(Sender: TObject);
|
||||||
|
procedure chkItalicClick(Sender: TObject);
|
||||||
|
procedure chkUnderlinedClick(Sender: TObject);
|
||||||
|
procedure chkVisibleClick(Sender: TObject);
|
||||||
|
procedure cmdResetClick(Sender: TObject);
|
||||||
|
procedure lstStylesClick(Sender: TObject);
|
||||||
|
procedure lvShortcutsClick(Sender: TObject);
|
||||||
|
procedure trvSettingsChanging(Sender: TObject; Node: TTreeNode;
|
||||||
|
var AllowChange: Boolean);
|
||||||
|
procedure txtPeriodChange(Sender: TObject);
|
||||||
|
procedure txtPortChange(Sender: TObject);
|
||||||
|
procedure lvShortcutsSelectItem(Sender: TObject; Item: TListItem;
|
||||||
|
Selected: Boolean);
|
||||||
|
procedure cmdApplyClick(Sender: TObject);
|
||||||
|
procedure cmdSelectForegroundClick(Sender: TObject);
|
||||||
|
procedure cmdSelectBackgroundClick(Sender: TObject);
|
||||||
|
procedure cmdSelectCaretForeClick(Sender: TObject);
|
||||||
|
procedure cmdSelectCaretBackClick(Sender: TObject);
|
||||||
|
procedure cmdBrowsePAWNCompilerClick(Sender: TObject);
|
||||||
|
procedure cmdBrowseCPPCompilerClick(Sender: TObject);
|
||||||
|
procedure cmdBrowseOutputPAWNClick(Sender: TObject);
|
||||||
|
procedure cmdBrowseOutputCPPClick(Sender: TObject);
|
||||||
|
procedure txtPAWNOutputExit(Sender: TObject);
|
||||||
|
procedure txtCPPOutputChange(Sender: TObject);
|
||||||
|
procedure cmdCSAddClick(Sender: TObject);
|
||||||
|
procedure cmdCSRemoveClick(Sender: TObject);
|
||||||
|
procedure lstCodeSnippetsClick(Sender: TObject);
|
||||||
|
procedure ftcCodeSnippetsTabChanged(Sender: TObject);
|
||||||
|
procedure txtCodeSnippetKeyUp(Sender: TObject; var Key: Word;
|
||||||
|
Shift: TShiftState);
|
||||||
|
procedure cmdConnectClick(Sender: TObject);
|
||||||
|
procedure trvDirectoriesExpanded(Sender: TObject; Node: TTreeNode);
|
||||||
|
procedure trvDirectoriesChange(Sender: TObject; Node: TTreeNode);
|
||||||
|
procedure trvDirectoriesExpanding(Sender: TObject; Node: TTreeNode;
|
||||||
|
var AllowExpansion: Boolean);
|
||||||
|
procedure trvDirectoriesCollapsing(Sender: TObject; Node: TTreeNode;
|
||||||
|
var AllowCollapse: Boolean);
|
||||||
|
procedure cboProxyChange(Sender: TObject);
|
||||||
|
procedure txtProxyPortChange(Sender: TObject);
|
||||||
|
procedure jplSettingsChanging(Sender: TObject; PageIndex: Integer;
|
||||||
|
var AllowChange: Boolean);
|
||||||
|
procedure txtProxyHostChange(Sender: TObject);
|
||||||
|
procedure cmdBrowseHLClick(Sender: TObject);
|
||||||
|
procedure cmdAdvancedAutoIndentClick(Sender: TObject);
|
||||||
|
procedure cmdReloadClick(Sender: TObject);
|
||||||
|
procedure cmdUnloadClick(Sender: TObject);
|
||||||
|
procedure cmdLoadClick(Sender: TObject);
|
||||||
|
procedure cmdRemoveClick(Sender: TObject);
|
||||||
|
procedure cmdBrowseAMXXDirClick(Sender: TObject);
|
||||||
|
public
|
||||||
|
Foreground, Background: TColor;
|
||||||
|
CaretFore, CaretBack: TColor;
|
||||||
|
procedure UpdateItemIndex;
|
||||||
|
procedure PaintForeground(eColor: TColor);
|
||||||
|
procedure PaintBackground(eColor: TColor);
|
||||||
|
procedure PaintCaretFore(eColor: TColor);
|
||||||
|
procedure PaintCaretBack(eColor: TColor);
|
||||||
|
procedure EnableControls(eEnable: Boolean); // For Proxy
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
frmSettings: TfrmSettings;
|
||||||
|
eConfig: TIniFile;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses UnitMainTools, UnitfrmMain, UnitfrmSelectColor, UnitLanguages,
|
||||||
|
UnitCodeSnippets, UnitfrmAutoIndent, UnitPlugins;
|
||||||
|
|
||||||
|
{$R *.DFM}
|
||||||
|
|
||||||
|
procedure TfrmSettings.jplSettingsChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if not Started then exit;
|
||||||
|
|
||||||
|
if Assigned(trvSettings.Selected.Parent) then
|
||||||
|
lblCurrSetting.Caption := trvSettings.Selected.Parent.Text + ' - ' + (jplSettings.ActivePage as TJvStandardPage).Caption
|
||||||
|
else
|
||||||
|
lblCurrSetting.Caption := (jplSettings.ActivePage as TJvStandardPage).Caption;
|
||||||
|
|
||||||
|
txtPAWNOutputExit(Sender);
|
||||||
|
txtCPPOutputChange(Sender);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.txtLinesChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if not IsNumeric(txtLines.Text) then
|
||||||
|
txtLines.Text := '600';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.FormCreate(Sender: TObject);
|
||||||
|
begin
|
||||||
|
eConfig := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'config\Settings.ini');
|
||||||
|
ReloadIni;
|
||||||
|
case eConfig.ReadInteger('Misc', 'WindowState', 0) of
|
||||||
|
0: frmMain.WindowState := wsNormal;
|
||||||
|
1: frmMain.WindowState := wsMaximized;
|
||||||
|
2: frmMain.WindowState := wsMinimized;
|
||||||
|
end;
|
||||||
|
|
||||||
|
PaintForeground(clBlack);
|
||||||
|
PaintBackground(clBlack);
|
||||||
|
PaintCaretFore(clBlack);
|
||||||
|
PaintCaretBack(clBlack);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.FormDestroy(Sender: TObject);
|
||||||
|
begin
|
||||||
|
case frmMain.WindowState of
|
||||||
|
wsNormal : eConfig.WriteInteger('Misc', 'WindowState', 0);
|
||||||
|
wsMaximized: eConfig.WriteInteger('Misc', 'WindowState', 1);
|
||||||
|
else eConfig.WriteInteger('Misc', 'WindowState', 2);
|
||||||
|
end;
|
||||||
|
|
||||||
|
if frmMain.IdFTP.Connected then
|
||||||
|
frmMain.IdFTP.Disconnect;
|
||||||
|
|
||||||
|
eConfig.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.FormShow(Sender: TObject);
|
||||||
|
var i: integer;
|
||||||
|
begin
|
||||||
|
txtLines.Enabled := chkRestoreCaret.Checked;
|
||||||
|
cboLanguage.OnChange(Self);
|
||||||
|
for i := 0 to trvSettings.Items.Count -1 do
|
||||||
|
trvSettings.Items[i].Expand(True);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.chkRestoreCaretClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
txtLines.Enabled := chkRestoreCaret.Checked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.txtFontSizeChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if not IsNumeric(txtFontSize.Text) then begin
|
||||||
|
txtFontSize.Text := '0';
|
||||||
|
TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).FontSize := 0;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).FontSize := StrToInt(txtFontSize.Text);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ For Highlighter Section }
|
||||||
|
|
||||||
|
procedure TfrmSettings.PaintBackground(eColor: TColor);
|
||||||
|
begin
|
||||||
|
imgBackground.Canvas.Pen.Color := $008396A0;
|
||||||
|
imgBackground.Canvas.Brush.Color := eColor;
|
||||||
|
imgBackground.Canvas.Rectangle(0, 0, 19, 19);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.PaintForeground(eColor: TColor);
|
||||||
|
begin
|
||||||
|
imgForeground.Canvas.Pen.Color := $008396A0;
|
||||||
|
imgForeground.Canvas.Brush.Color := eColor;
|
||||||
|
imgForeground.Canvas.Rectangle(0, 0, 19, 19);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cboLanguageChange(Sender: TObject);
|
||||||
|
var i: integer;
|
||||||
|
begin
|
||||||
|
lstStyles.Items.Clear;
|
||||||
|
for i := 0 to TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Count -1 do
|
||||||
|
lstStyles.Items.Add(TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[i]).Name);
|
||||||
|
|
||||||
|
if lstStyles.Items.Count > 0 then
|
||||||
|
lstStyles.ItemIndex := 0;
|
||||||
|
cboFont.Enabled := lstStyles.Items.Count <> 0;
|
||||||
|
chkUseDefaultFont.Enabled := lstStyles.Items.Count <> 0;
|
||||||
|
chkBold.Enabled := lstStyles.Items.Count <> 0;
|
||||||
|
chkItalic.Enabled := lstStyles.Items.Count <> 0;
|
||||||
|
chkUnderlined.Enabled := lstStyles.Items.Count <> 0;
|
||||||
|
chkVisible.Enabled := lstStyles.Items.Count <> 0;
|
||||||
|
cmdSelectForeground.Enabled := lstStyles.Items.Count <> 0;
|
||||||
|
cmdSelectBackground.Enabled := lstStyles.Items.Count <> 0;
|
||||||
|
|
||||||
|
UpdateItemIndex;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.chkUseDefaultFontClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
cboFont.Enabled := not chkUseDefaultFont.Checked;
|
||||||
|
if chkUseDefaultFont.Checked then
|
||||||
|
TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).FontName := ''
|
||||||
|
else
|
||||||
|
TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).FontName := cboFont.Selected;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cboFontChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if (not chkUseDefaultFont.Checked) then
|
||||||
|
TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).FontName := cboFont.Selected;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.chkBoldClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if chkBold.Checked then
|
||||||
|
TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).FontStyles := TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).FontStyles + [fsBold]
|
||||||
|
else
|
||||||
|
TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).FontStyles := TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).FontStyles - [fsBold];
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.chkItalicClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if chkItalic.Checked then
|
||||||
|
TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).FontStyles := TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).FontStyles + [fsItalic]
|
||||||
|
else
|
||||||
|
TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).FontStyles := TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).FontStyles - [fsItalic];
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.chkUnderlinedClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if chkUnderlined.Checked then
|
||||||
|
TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).FontStyles := TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).FontStyles + [fsUnderline]
|
||||||
|
else
|
||||||
|
TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).FontStyles := TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).FontStyles - [fsUnderline];
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.chkVisibleClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).Visible := chkVisible.Checked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cmdResetClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if MessageBox(Handle, PChar(lWarnHighlighterReset), 'AMXX-Studio', MB_ICONWARNING + MB_YESNO) = mrYes then begin
|
||||||
|
DeleteFile(PChar(ExtractFilePath(ParamStr(0)) + 'config\Editor.sci'));
|
||||||
|
cmdReset.Enabled := False;
|
||||||
|
cboLanguage.Enabled := False;
|
||||||
|
lstStyles.Enabled := False;
|
||||||
|
lblFont.Enabled := False;
|
||||||
|
cboFont.Enabled := False;
|
||||||
|
chkUseDefaultFont.Enabled := False;
|
||||||
|
chkBold.Enabled := False;
|
||||||
|
chkItalic.Enabled := False;
|
||||||
|
chkUnderlined.Enabled := False;
|
||||||
|
chkVisible.Enabled := False;
|
||||||
|
lblFontSize.Enabled := False;
|
||||||
|
txtFontSize.Enabled := False;
|
||||||
|
lblForeground.Enabled := False;
|
||||||
|
cmdSelectForeground.Enabled := False;
|
||||||
|
lblBackground.Enabled := False;
|
||||||
|
cmdSelectBackground.Enabled := False;
|
||||||
|
MessageBox(Handle, PChar(lHighlighterResetDone), 'AMXX-Studio', MB_ICONINFORMATION);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.UpdateItemIndex;
|
||||||
|
begin
|
||||||
|
lblFont.Enabled := lstStyles.ItemIndex <> -1;
|
||||||
|
cboFont.Enabled := lstStyles.ItemIndex <> -1;
|
||||||
|
chkUseDefaultFont.Enabled := lstStyles.ItemIndex <> -1;
|
||||||
|
chkBold.Enabled := lstStyles.ItemIndex <> -1;
|
||||||
|
chkItalic.Enabled := lstStyles.ItemIndex <> -1;
|
||||||
|
chkUnderlined.Enabled := lstStyles.ItemIndex <> -1;
|
||||||
|
chkVisible.Enabled := lstStyles.ItemIndex <> -1;
|
||||||
|
lblFontSize.Enabled := lstStyles.ItemIndex <> -1;
|
||||||
|
txtFontSize.Enabled := lstStyles.ItemIndex <> -1;
|
||||||
|
lblForeground.Enabled := lstStyles.ItemIndex <> -1;
|
||||||
|
cmdSelectForeground.Enabled := lstStyles.ItemIndex <> -1;
|
||||||
|
lblBackground.Enabled := lstStyles.ItemIndex <> -1;
|
||||||
|
cmdSelectBackground.Enabled := lstStyles.ItemIndex <> -1;
|
||||||
|
|
||||||
|
if lstStyles.ItemIndex <> -1 then begin
|
||||||
|
with TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]) do begin
|
||||||
|
chkUseDefaultFont.Checked := FontName = '';
|
||||||
|
if FontName <> '' then
|
||||||
|
cboFont.Selected := FontName;
|
||||||
|
cboFont.Enabled := FontName <> '';
|
||||||
|
chkBold.Checked := fsBold in FontStyles;
|
||||||
|
chkItalic.Checked := fsItalic in FontStyles;
|
||||||
|
chkUnderlined.Checked := fsUnderline in FontStyles;
|
||||||
|
chkVisible.Checked := Visible;
|
||||||
|
txtFontSize.Text := IntToStr(TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).FontSize);
|
||||||
|
|
||||||
|
PaintForeground(ForeColor);
|
||||||
|
PaintBackground(BackColor);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.lstStylesClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
UpdateItemIndex;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.lvShortcutsClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
cmdApply.Enabled := Assigned(lvShortcuts.Selected);
|
||||||
|
hkShortcut.Enabled := cmdApply.Enabled;
|
||||||
|
if cmdApply.Enabled then
|
||||||
|
hkShortcut.HotKey := TextToShortCut(lvShortcuts.Selected.Subitems[0]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.trvSettingsChanging(Sender: TObject;
|
||||||
|
Node: TTreeNode; var AllowChange: Boolean);
|
||||||
|
begin
|
||||||
|
if (not Started) then exit;
|
||||||
|
|
||||||
|
if (Assigned(Node.Parent)) and (not cmdReset.Enabled) then
|
||||||
|
AllowChange := Node.Parent.Index <> 0
|
||||||
|
else
|
||||||
|
AllowChange := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.txtPeriodChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if not IsNumeric(txtPeriod.Text) then
|
||||||
|
txtPeriod.Text := '1024';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.txtPortChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if not IsNumeric(txtPort.Text) then
|
||||||
|
txtPort.Text := '21';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.PaintCaretBack(eColor: TColor);
|
||||||
|
begin
|
||||||
|
imgCaretBack.Canvas.Pen.Color := $008396A0;
|
||||||
|
imgCaretBack.Canvas.Brush.Color := eColor;
|
||||||
|
imgCaretBack.Canvas.Rectangle(0, 0, 19, 19);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.PaintCaretFore(eColor: TColor);
|
||||||
|
begin
|
||||||
|
imgCaretFore.Canvas.Pen.Color := $008396A0;
|
||||||
|
imgCaretFore.Canvas.Brush.Color := eColor;
|
||||||
|
imgCaretFore.Canvas.Rectangle(0, 0, 19, 19);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.lvShortcutsSelectItem(Sender: TObject;
|
||||||
|
Item: TListItem; Selected: Boolean);
|
||||||
|
begin
|
||||||
|
lvShortcuts.OnClick(Sender);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cmdApplyClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if Assigned(lvShortcuts.Selected) then
|
||||||
|
lvShortcuts.Selected.SubItems[0] := ShortcutToText(hkShortcut.HotKey);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cmdSelectForegroundClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if ShowColorDialog(Foreground, imgForeground) then
|
||||||
|
TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).ForeColor := Foreground;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cmdSelectBackgroundClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if ShowColorDialog(Background, imgBackground) then
|
||||||
|
TSciStyle(TSciLangItem(frmMain.sciEditor.LanguageManager.LanguageList.Items[cboLanguage.ItemIndex]).Styles.Items[lstStyles.ItemIndex]).BackColor := Background;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cmdSelectCaretForeClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
ShowColorDialog(CaretFore, imgCaretFore);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cmdSelectCaretBackClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
ShowColorDialog(CaretBack, imgCaretBack);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cmdBrowsePAWNCompilerClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if odBrowse.Execute then
|
||||||
|
txtPAWNCompilerPath.Text := odBrowse.FileName;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cmdBrowseCPPCompilerClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if odBrowse.Execute then
|
||||||
|
txtCPPCompilerPath.Text := odBrowse.FileName;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cmdBrowseOutputPAWNClick(Sender: TObject);
|
||||||
|
var eDir: String;
|
||||||
|
begin
|
||||||
|
if SelectDirectory(lSelectOutputPAWN, txtPAWNOutput.Text, eDir) then
|
||||||
|
txtPAWNOutput.Text := eDir;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cmdBrowseOutputCPPClick(Sender: TObject);
|
||||||
|
var eDir: String;
|
||||||
|
begin
|
||||||
|
if SelectDirectory(lSelectOutputCPP, txtCPPOutput.Text, eDir) then
|
||||||
|
txtCPPOutput.Text := eDir;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.txtPAWNOutputExit(Sender: TObject);
|
||||||
|
var eHDC: HDC;
|
||||||
|
eCanvas: TCanvas;
|
||||||
|
begin
|
||||||
|
if (txtPAWNOutput.Text = '') and (not txtPAWNOutput.Focused) then begin
|
||||||
|
eHDC := GetDC(txtPAWNOutput.Handle);
|
||||||
|
eCanvas := TCanvas.Create;
|
||||||
|
eCanvas.Handle := eHDC;
|
||||||
|
eCanvas.Font.Name := 'Tahoma';
|
||||||
|
eCanvas.Font.Color := clBtnShadow;
|
||||||
|
eCanvas.Font.Size := 7;
|
||||||
|
eCanvas.TextOut(1, 1, lDynamic);
|
||||||
|
eCanvas.Free;
|
||||||
|
txtPAWNOutput.Hint := lOutputHint;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
txtPAWNOutput.Hint := '';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.txtCPPOutputChange(Sender: TObject);
|
||||||
|
var eHDC: HDC;
|
||||||
|
eCanvas: TCanvas;
|
||||||
|
begin
|
||||||
|
if (txtCPPOutput.Text = '') and (not txtCPPOutput.Focused) then begin
|
||||||
|
eHDC := GetDC(txtCPPOutput.Handle);
|
||||||
|
eCanvas := TCanvas.Create;
|
||||||
|
eCanvas.Handle := eHDC;
|
||||||
|
eCanvas.Font.Name := 'Tahoma';
|
||||||
|
eCanvas.Font.Color := clBtnShadow;
|
||||||
|
eCanvas.Font.Size := 7;
|
||||||
|
eCanvas.TextOut(1, 1, lDynamic);
|
||||||
|
eCanvas.Free;
|
||||||
|
txtCPPOutput.Hint := lOutputHint;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
txtCPPOutput.Hint := '';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cmdCSAddClick(Sender: TObject);
|
||||||
|
var eStr: String;
|
||||||
|
begin
|
||||||
|
if InputQuery(lAddCodeSnippetCaption, lAddCodeSnippetPrompt, eStr) then begin
|
||||||
|
eStr := StringReplace(eStr, '=', '', [rfReplaceAll]);
|
||||||
|
if eStr = '' then begin
|
||||||
|
MessageBox(Handle, PChar(lEmptyCodeSnippetTitle), PChar(Application.Title), MB_ICONWARNING);
|
||||||
|
cmdCSAdd.Click;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
if lstCodeSnippets.Items.IndexOf(eStr) = -1 then begin
|
||||||
|
lstCodeSnippets.ItemIndex := lstCodeSnippets.Items.Add(eStr);
|
||||||
|
AddSnippet(ftcCodeSnippets.Tabs[ftcCodeSnippets.ActiveTab], eStr, '');
|
||||||
|
txtCodeSnippet.Enabled := True;
|
||||||
|
lstCodeSnippetsClick(Sender);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
MessageBox(Handle, PChar(lCodeSnippetExists), PChar(Application.Title), MB_ICONWARNING);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cmdCSRemoveClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if lstCodeSnippets.ItemIndex <> -1 then begin
|
||||||
|
DelSnippet(ftcCodeSnippets.Tabs[ftcCodeSnippets.ActiveTab], lstCodeSnippets.Items[lstCodeSnippets.ItemIndex]);
|
||||||
|
lstCodeSnippets.Items.Delete(lstCodeSnippets.ItemIndex);
|
||||||
|
if lstCodeSnippets.Items.Count > 0 then
|
||||||
|
lstCodeSnippets.ItemIndex := 0
|
||||||
|
else
|
||||||
|
txtCodeSnippet.Clear;
|
||||||
|
lstCodeSnippetsClick(Sender);
|
||||||
|
end;
|
||||||
|
cmdCSRemove.Enabled := lstCodeSnippets.ItemIndex <> -1;
|
||||||
|
txtCodeSnippet.Enabled := lstCodeSnippets.Items.Count > 0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.lstCodeSnippetsClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
cmdCSRemove.Enabled := lstCodeSnippets.ItemIndex <> -1;
|
||||||
|
if cmdCSRemove.Enabled then
|
||||||
|
txtCodeSnippet.Lines.Text := GetSnippet(ftcCodeSnippets.Tabs[ftcCodeSnippets.ActiveTab], lstCodeSnippets.Items[lstCodeSnippets.ItemIndex]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.ftcCodeSnippetsTabChanged(Sender: TObject);
|
||||||
|
begin
|
||||||
|
lstCodeSnippets.Items.Text := GetSnippetList(ftcCodeSnippets.Tabs[ftcCodeSnippets.ActiveTab]).Text;
|
||||||
|
if lstCodeSnippets.Items.Count > 0 then
|
||||||
|
lstCodeSnippets.ItemIndex := 0
|
||||||
|
else
|
||||||
|
txtCodeSnippet.Clear;
|
||||||
|
lstCodeSnippetsClick(Sender);
|
||||||
|
txtCodeSnippet.Enabled := lstCodeSnippets.Items.Count > 0;
|
||||||
|
cmdCSRemove.Enabled := lstCodeSnippets.ItemIndex <> -1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.txtCodeSnippetKeyUp(Sender: TObject; var Key: Word;
|
||||||
|
Shift: TShiftState);
|
||||||
|
begin
|
||||||
|
SetSnippet(ftcCodeSnippets.Tabs[ftcCodeSnippets.ActiveTab], lstCodeSnippets.Items[lstCodeSnippets.ItemIndex], txtCodeSnippet.Lines.Text);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cmdConnectClick(Sender: TObject);
|
||||||
|
var i: integer;
|
||||||
|
eStr: TStringList;
|
||||||
|
CurNode: TTreeNode;
|
||||||
|
begin
|
||||||
|
{ The following functions are copied from my installer }
|
||||||
|
|
||||||
|
if (Trim(txtHost.Text) = '') or (Trim(txtUsername.Text) = '') or (Trim(txtPassword.Text) = '') then
|
||||||
|
MessageBox(Handle, PChar(lFillInEachField), PChar(Application.Title), MB_ICONWARNING)
|
||||||
|
else if cmdConnect.Caption = lConnect then begin
|
||||||
|
// ... design stuff ...
|
||||||
|
Screen.Cursor := crHourGlass;
|
||||||
|
cmdConnect.Enabled := False;
|
||||||
|
txtHost.Enabled := False;
|
||||||
|
txtPort.Enabled := False;
|
||||||
|
txtUsername.Enabled := False;
|
||||||
|
txtPassword.Enabled := False;
|
||||||
|
chkPassive.Enabled := False;
|
||||||
|
cmdConnect.Caption := lConnecting;
|
||||||
|
// ... disconnect if already connected ...
|
||||||
|
if frmMain.IdFTP.Connected then
|
||||||
|
frmMain.IdFTP.Disconnect;
|
||||||
|
// ... set values, connect and check errors etc ...
|
||||||
|
i := TryConnect;
|
||||||
|
case i of
|
||||||
|
1: begin
|
||||||
|
txtUsername.SetFocus;
|
||||||
|
txtUsername.SelectAll;
|
||||||
|
end;
|
||||||
|
2: begin
|
||||||
|
txtHost.SetFocus;
|
||||||
|
txtHost.SelectAll;
|
||||||
|
end;
|
||||||
|
3, 4: begin
|
||||||
|
txtPort.SetFocus;
|
||||||
|
txtPort.SelectAll;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if i <> 0 then begin
|
||||||
|
// reset button properties
|
||||||
|
cmdConnect.Enabled := True;
|
||||||
|
txtHost.Enabled := True;
|
||||||
|
txtPort.Enabled := True;
|
||||||
|
txtUsername.Enabled := True;
|
||||||
|
txtPassword.Enabled := True;
|
||||||
|
chkPassive.Enabled := True;
|
||||||
|
cmdConnect.Caption := lConnect;
|
||||||
|
Screen.Cursor := crDefault;
|
||||||
|
// ... connect failed, leave procedure ...
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
// ... connect successful, change captions ...
|
||||||
|
trvDirectories.Enabled := True;
|
||||||
|
cmdConnect.Enabled := True;
|
||||||
|
cmdConnect.Caption := lDisconnect;
|
||||||
|
// ... scan for initial directory ...
|
||||||
|
eStr := TStringList.Create;
|
||||||
|
eStr.Text := StringReplace(frmMain.IdFTP.RetrieveCurrentDir, '/', #13, [rfReplaceAll]);
|
||||||
|
for i := eStr.Count -1 downto 0 do begin
|
||||||
|
if eStr[i] = '' then
|
||||||
|
eStr.Delete(i);
|
||||||
|
end;
|
||||||
|
|
||||||
|
CurNode := nil;
|
||||||
|
if eStr.Count <> 0 then begin
|
||||||
|
for i := 0 to eStr.Count -1 do
|
||||||
|
CurNode := trvDirectories.Items.AddChild(CurNode, eStr[i]);
|
||||||
|
end;
|
||||||
|
if trvDirectories.Items.Count <> 0 then
|
||||||
|
trvDirectories.Items.Item[0].Expand(True);
|
||||||
|
eStr.Free;
|
||||||
|
|
||||||
|
// ... scan for directories ...
|
||||||
|
with GetAllDirs do begin
|
||||||
|
for i := 0 to Count -1 do
|
||||||
|
trvDirectories.Items.AddChild(trvDirectories.Items.AddChild(CurNode, Strings[i]), 'Scanning...');
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if Assigned(CurNode) then
|
||||||
|
CurNode.Expand(False);
|
||||||
|
Screen.Cursor := crDefault;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
Screen.Cursor := crHourGlass;
|
||||||
|
frmMain.IdFTP.Quit;
|
||||||
|
trvDirectories.Items.Clear;
|
||||||
|
cmdConnect.Enabled := True;
|
||||||
|
trvSettings.Enabled := True;
|
||||||
|
txtHost.Enabled := True;
|
||||||
|
txtPort.Enabled := True;
|
||||||
|
txtUsername.Enabled := True;
|
||||||
|
txtPassword.Enabled := True;
|
||||||
|
chkPassive.Enabled := True;
|
||||||
|
cmdConnect.Caption := lConnect;
|
||||||
|
Screen.Cursor := crDefault;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.trvDirectoriesExpanded(Sender: TObject;
|
||||||
|
Node: TTreeNode);
|
||||||
|
var ePath: String;
|
||||||
|
CurNode: TTreeNode;
|
||||||
|
i: integer;
|
||||||
|
begin
|
||||||
|
if Node.Item[0].Text = lScanning then begin // no directories have been added yet
|
||||||
|
Screen.Cursor := crHourGlass;
|
||||||
|
// get complete path
|
||||||
|
ePath := '/';
|
||||||
|
CurNode := Node;
|
||||||
|
repeat
|
||||||
|
ePath := '/' + CurNode.Text + ePath;
|
||||||
|
CurNode := CurNode.Parent;
|
||||||
|
until (not Assigned(CurNode));
|
||||||
|
// change dir and add directories in it
|
||||||
|
try
|
||||||
|
Repaint;
|
||||||
|
frmMain.IdFTP.ChangeDir(ePath);
|
||||||
|
with GetAllDirs do begin
|
||||||
|
Node.Item[0].Free;
|
||||||
|
for i := 0 to Count -1 do begin
|
||||||
|
trvDirectories.Items.AddChild(trvDirectories.Items.AddChild(Node, Strings[i]), lScanning);
|
||||||
|
end;
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
Application.ProcessMessages;
|
||||||
|
end;
|
||||||
|
Screen.Cursor := crDefault;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.trvDirectoriesChange(Sender: TObject;
|
||||||
|
Node: TTreeNode);
|
||||||
|
var ePath: String;
|
||||||
|
CurNode: TTreeNode;
|
||||||
|
begin
|
||||||
|
if Screen.Cursor <> crDefault then exit; // on disconnect this event is also raised
|
||||||
|
|
||||||
|
// get complete path
|
||||||
|
ePath := '/';
|
||||||
|
CurNode := Node;
|
||||||
|
repeat
|
||||||
|
ePath := '/' + CurNode.Text + ePath;
|
||||||
|
CurNode := CurNode.Parent;
|
||||||
|
until (not Assigned(CurNode));
|
||||||
|
// change path
|
||||||
|
txtDefaultDir.Text := ePath;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.trvDirectoriesExpanding(Sender: TObject;
|
||||||
|
Node: TTreeNode; var AllowExpansion: Boolean);
|
||||||
|
begin
|
||||||
|
Node.ImageIndex := 1;
|
||||||
|
Node.SelectedIndex := 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.trvDirectoriesCollapsing(Sender: TObject;
|
||||||
|
Node: TTreeNode; var AllowCollapse: Boolean);
|
||||||
|
begin
|
||||||
|
Node.ImageIndex := 0;
|
||||||
|
Node.SelectedIndex := 0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cboProxyChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
EnableControls(cboProxy.ItemIndex <> 0); // 0 = None
|
||||||
|
SetProxySettings;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.EnableControls(eEnable: Boolean);
|
||||||
|
begin
|
||||||
|
lblProxyHost.Enabled := eEnable;
|
||||||
|
lblProxyPassword.Enabled := eEnable;
|
||||||
|
lblProxyPort.Enabled := eEnable;
|
||||||
|
lblProxyUsername.Enabled := eEnable;
|
||||||
|
txtProxyHost.Enabled := eEnable;
|
||||||
|
txtProxyPort.Enabled := eEnable;
|
||||||
|
txtProxyUsername.Enabled := eEnable;
|
||||||
|
txtProxyPassword.Enabled := eEnable;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.txtProxyPortChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if not IsNumeric(txtProxyPort.Text) then
|
||||||
|
txtProxyPort.Text := '8080';
|
||||||
|
SetProxySettings;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.jplSettingsChanging(Sender: TObject;
|
||||||
|
PageIndex: Integer; var AllowChange: Boolean);
|
||||||
|
begin
|
||||||
|
if (frmMain.IdFTP.Connected) and (jplSettings.Pages[PageIndex] = jspProxy) then
|
||||||
|
AllowChange := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.txtProxyHostChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
SetProxySettings;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cmdBrowseHLClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if odBrowse.Execute then
|
||||||
|
txtHLExec.Text := odBrowse.FileName;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cmdAdvancedAutoIndentClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
frmAutoIndent.ShowModal;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cmdReloadClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if Assigned(lvPlugins.Selected) then begin
|
||||||
|
if lvPlugins.Selected.SubItems[2] = 'Loaded' then
|
||||||
|
cmdUnload.Click;
|
||||||
|
cmdLoad.Click;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cmdUnloadClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if Assigned(lvPlugins.Selected) then begin
|
||||||
|
if lvPlugins.Selected.SubItems[2] = 'Unloaded' then
|
||||||
|
MessageBox(Handle, PChar(lAlreadyUnLoaded), PChar(Application.Title), MB_ICONERROR)
|
||||||
|
else
|
||||||
|
UnloadPlugin(lvPlugins.Selected);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cmdLoadClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if Assigned(lvPlugins.Selected) then begin
|
||||||
|
if lvPlugins.Selected.SubItems[2] = 'Loaded' then
|
||||||
|
MessageBox(Handle, PChar(lAlreadyLoaded), PChar(Application.Title), MB_ICONERROR)
|
||||||
|
else
|
||||||
|
LoadPlugin(lvPlugins.Selected);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cmdRemoveClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if Assigned(lvPlugins.Selected) then begin
|
||||||
|
if lvPlugins.Selected.SubItems[2] = 'Loaded' then
|
||||||
|
cmdUnload.Click;
|
||||||
|
DeleteFile(PChar(ExtractFilePath(ParamStr(0)) + 'plugins\' + lvPlugins.Selected.SubItems[0]));
|
||||||
|
lvPlugins.DeleteSelected;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSettings.cmdBrowseAMXXDirClick(Sender: TObject);
|
||||||
|
var eStr: String;
|
||||||
|
begin
|
||||||
|
if SelectDirectory(lSelectAMXXCaption, ExtractFilePath(txtHLExec.Text), eStr) then
|
||||||
|
txtAMXXDir.Text := eStr;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
189
editor/studio/UnitfrmSocketsTerminal.dfm
Executable file
189
editor/studio/UnitfrmSocketsTerminal.dfm
Executable file
|
@ -0,0 +1,189 @@
|
||||||
|
object frmSocketsTerminal: TfrmSocketsTerminal
|
||||||
|
Left = 584
|
||||||
|
Top = 418
|
||||||
|
ActiveControl = rtfEnter
|
||||||
|
BorderStyle = bsDialog
|
||||||
|
Caption = 'Socket Terminal'
|
||||||
|
ClientHeight = 230
|
||||||
|
ClientWidth = 369
|
||||||
|
Color = clBtnFace
|
||||||
|
Font.Charset = DEFAULT_CHARSET
|
||||||
|
Font.Color = clWindowText
|
||||||
|
Font.Height = -11
|
||||||
|
Font.Name = 'Tahoma'
|
||||||
|
Font.Style = []
|
||||||
|
FormStyle = fsStayOnTop
|
||||||
|
OldCreateOrder = False
|
||||||
|
Position = poMainFormCenter
|
||||||
|
OnClose = FormClose
|
||||||
|
PixelsPerInch = 96
|
||||||
|
TextHeight = 13
|
||||||
|
object pnlSettings: TPanel
|
||||||
|
Left = 0
|
||||||
|
Top = 141
|
||||||
|
Width = 369
|
||||||
|
Height = 89
|
||||||
|
Align = alBottom
|
||||||
|
BevelOuter = bvNone
|
||||||
|
TabOrder = 2
|
||||||
|
object lblStatusCaption: TLabel
|
||||||
|
Left = 2
|
||||||
|
Top = 72
|
||||||
|
Width = 35
|
||||||
|
Height = 13
|
||||||
|
Caption = 'Status:'
|
||||||
|
Font.Charset = DEFAULT_CHARSET
|
||||||
|
Font.Color = clWindowText
|
||||||
|
Font.Height = -11
|
||||||
|
Font.Name = 'Tahoma'
|
||||||
|
Font.Style = []
|
||||||
|
ParentFont = False
|
||||||
|
end
|
||||||
|
object lblStatus: TLabel
|
||||||
|
Left = 40
|
||||||
|
Top = 72
|
||||||
|
Width = 69
|
||||||
|
Height = 13
|
||||||
|
Caption = 'not connected'
|
||||||
|
Font.Charset = DEFAULT_CHARSET
|
||||||
|
Font.Color = clRed
|
||||||
|
Font.Height = -11
|
||||||
|
Font.Name = 'Tahoma'
|
||||||
|
Font.Style = []
|
||||||
|
ParentFont = False
|
||||||
|
end
|
||||||
|
object lblSettings: TLabel
|
||||||
|
Left = 4
|
||||||
|
Top = 6
|
||||||
|
Width = 43
|
||||||
|
Height = 13
|
||||||
|
Caption = 'Settings:'
|
||||||
|
end
|
||||||
|
object pnlSettings2: TPanel
|
||||||
|
Left = 4
|
||||||
|
Top = 24
|
||||||
|
Width = 361
|
||||||
|
Height = 41
|
||||||
|
BevelOuter = bvLowered
|
||||||
|
TabOrder = 0
|
||||||
|
object lblHost: TLabel
|
||||||
|
Left = 4
|
||||||
|
Top = 3
|
||||||
|
Width = 26
|
||||||
|
Height = 13
|
||||||
|
Caption = 'Host:'
|
||||||
|
end
|
||||||
|
object lblPort: TLabel
|
||||||
|
Left = 184
|
||||||
|
Top = 3
|
||||||
|
Width = 24
|
||||||
|
Height = 13
|
||||||
|
Caption = 'Port:'
|
||||||
|
end
|
||||||
|
object txtHost: TFlatEdit
|
||||||
|
Left = 4
|
||||||
|
Top = 17
|
||||||
|
Width = 173
|
||||||
|
Height = 19
|
||||||
|
ColorFlat = clWhite
|
||||||
|
TabOrder = 0
|
||||||
|
end
|
||||||
|
object txtPort: TFlatEdit
|
||||||
|
Left = 184
|
||||||
|
Top = 17
|
||||||
|
Width = 39
|
||||||
|
Height = 19
|
||||||
|
ColorFlat = clWhite
|
||||||
|
TabOrder = 1
|
||||||
|
Text = '1'
|
||||||
|
OnChange = txtPortChange
|
||||||
|
end
|
||||||
|
object optUDP: TFlatRadioButton
|
||||||
|
Left = 230
|
||||||
|
Top = 20
|
||||||
|
Width = 39
|
||||||
|
Height = 17
|
||||||
|
Caption = 'UDP'
|
||||||
|
TabOrder = 3
|
||||||
|
OnClick = optTCPClick
|
||||||
|
end
|
||||||
|
object optTCP: TFlatRadioButton
|
||||||
|
Left = 230
|
||||||
|
Top = 4
|
||||||
|
Width = 35
|
||||||
|
Height = 15
|
||||||
|
Caption = 'TCP'
|
||||||
|
Checked = True
|
||||||
|
TabOrder = 2
|
||||||
|
TabStop = True
|
||||||
|
OnClick = optTCPClick
|
||||||
|
end
|
||||||
|
object cmdConnect: TFlatButton
|
||||||
|
Left = 278
|
||||||
|
Top = 10
|
||||||
|
Width = 77
|
||||||
|
Height = 21
|
||||||
|
ColorHighLight = 8623776
|
||||||
|
ColorShadow = 8623776
|
||||||
|
Caption = 'Connect'
|
||||||
|
TabOrder = 4
|
||||||
|
OnClick = cmdConnectClick
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
object rtfEnter: TRichEdit
|
||||||
|
Left = 0
|
||||||
|
Top = 121
|
||||||
|
Width = 369
|
||||||
|
Height = 20
|
||||||
|
Align = alBottom
|
||||||
|
TabOrder = 1
|
||||||
|
WantReturns = False
|
||||||
|
OnKeyPress = rtfEnterKeyPress
|
||||||
|
end
|
||||||
|
object rtfReceived: TRichEdit
|
||||||
|
Left = 0
|
||||||
|
Top = 0
|
||||||
|
Width = 369
|
||||||
|
Height = 121
|
||||||
|
Align = alClient
|
||||||
|
ScrollBars = ssVertical
|
||||||
|
TabOrder = 0
|
||||||
|
end
|
||||||
|
object IdTCPClient: TIdTCPClient
|
||||||
|
MaxLineAction = maSplit
|
||||||
|
OnDisconnected = IdTCPClientDisconnected
|
||||||
|
OnConnected = IdTCPClientConnected
|
||||||
|
Port = 0
|
||||||
|
Left = 4
|
||||||
|
Top = 4
|
||||||
|
end
|
||||||
|
object IdUDPClient: TIdUDPClient
|
||||||
|
OnStatus = IdUDPClientStatus
|
||||||
|
Port = 0
|
||||||
|
Left = 4
|
||||||
|
Top = 34
|
||||||
|
end
|
||||||
|
object alCopyPaste: TActionList
|
||||||
|
Left = 4
|
||||||
|
Top = 64
|
||||||
|
object acCopy: TAction
|
||||||
|
Caption = 'Copy'
|
||||||
|
ShortCut = 16451
|
||||||
|
OnExecute = acCopyExecute
|
||||||
|
end
|
||||||
|
object acPaste: TAction
|
||||||
|
Caption = 'Paste'
|
||||||
|
ShortCut = 16470
|
||||||
|
OnExecute = acPasteExecute
|
||||||
|
end
|
||||||
|
object acUndo: TAction
|
||||||
|
Caption = 'Undo'
|
||||||
|
OnExecute = acUndoExecute
|
||||||
|
end
|
||||||
|
object acSelectAll: TAction
|
||||||
|
Caption = 'Select all'
|
||||||
|
OnExecute = acSelectAllExecute
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
259
editor/studio/UnitfrmSocketsTerminal.pas
Executable file
259
editor/studio/UnitfrmSocketsTerminal.pas
Executable file
|
@ -0,0 +1,259 @@
|
||||||
|
unit UnitfrmSocketsTerminal; // the "old" dialog from AMXX-Edit v2
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||||||
|
Dialogs, ExtCtrls, StdCtrls, ComCtrls, TFlatEditUnit,
|
||||||
|
TFlatRadioButtonUnit, TFlatButtonUnit, IdUDPBase, IdUDPClient,
|
||||||
|
IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, UnitReadThread,
|
||||||
|
ActnList;
|
||||||
|
|
||||||
|
type
|
||||||
|
TfrmSocketsTerminal = class(TForm)
|
||||||
|
pnlSettings: TPanel;
|
||||||
|
rtfEnter: TRichEdit;
|
||||||
|
rtfReceived: TRichEdit;
|
||||||
|
lblStatusCaption: TLabel;
|
||||||
|
lblStatus: TLabel;
|
||||||
|
lblSettings: TLabel;
|
||||||
|
pnlSettings2: TPanel;
|
||||||
|
lblHost: TLabel;
|
||||||
|
txtHost: TFlatEdit;
|
||||||
|
txtPort: TFlatEdit;
|
||||||
|
lblPort: TLabel;
|
||||||
|
optUDP: TFlatRadioButton;
|
||||||
|
optTCP: TFlatRadioButton;
|
||||||
|
cmdConnect: TFlatButton;
|
||||||
|
IdTCPClient: TIdTCPClient;
|
||||||
|
IdUDPClient: TIdUDPClient;
|
||||||
|
alCopyPaste: TActionList;
|
||||||
|
acCopy: TAction;
|
||||||
|
acPaste: TAction;
|
||||||
|
acUndo: TAction;
|
||||||
|
acSelectAll: TAction;
|
||||||
|
procedure txtPortChange(Sender: TObject);
|
||||||
|
procedure cmdConnectClick(Sender: TObject);
|
||||||
|
procedure optTCPClick(Sender: TObject);
|
||||||
|
procedure IdTCPClientConnected(Sender: TObject);
|
||||||
|
procedure IdTCPClientDisconnected(Sender: TObject);
|
||||||
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||||||
|
procedure rtfEnterKeyPress(Sender: TObject; var Key: Char);
|
||||||
|
procedure IdUDPClientStatus(ASender: TObject; const AStatus: TIdStatus;
|
||||||
|
const AStatusText: String);
|
||||||
|
procedure acCopyExecute(Sender: TObject);
|
||||||
|
procedure acPasteExecute(Sender: TObject);
|
||||||
|
procedure acUndoExecute(Sender: TObject);
|
||||||
|
procedure acSelectAllExecute(Sender: TObject);
|
||||||
|
private
|
||||||
|
ReadThread: TReadThread;
|
||||||
|
public
|
||||||
|
procedure Append(eText: String; eColor: TColor = clBlack);
|
||||||
|
procedure SetStatus(eStatus: String; eColor: TColor);
|
||||||
|
procedure OnRead(eRead: String);
|
||||||
|
procedure EnableControls(eValue: Boolean);
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
frmSocketsTerminal: TfrmSocketsTerminal;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{$R *.dfm}
|
||||||
|
|
||||||
|
procedure TfrmSocketsTerminal.Append(eText: String; eColor: TColor);
|
||||||
|
begin
|
||||||
|
eText := Format('[%s] %s', [TimeToStr(Time), eText]);
|
||||||
|
rtfReceived.SelStart := Length(rtfReceived.Lines.Text);
|
||||||
|
rtfReceived.SelAttributes.Color := eColor;
|
||||||
|
rtfReceived.SelText := eText + #13#10;
|
||||||
|
rtfReceived.Perform(WM_VSCROLL, SB_BOTTOM, 0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSocketsTerminal.OnRead(eRead: String);
|
||||||
|
begin
|
||||||
|
Append(eRead, clWindowText);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSocketsTerminal.SetStatus(eStatus: String; eColor: TColor);
|
||||||
|
begin
|
||||||
|
lblStatus.Caption := eStatus;
|
||||||
|
lblStatus.Font.Color := eColor;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSocketsTerminal.txtPortChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
try
|
||||||
|
StrToInt(txtPort.Text);
|
||||||
|
except
|
||||||
|
txtPort.Text := '1';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSocketsTerminal.cmdConnectClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if Tag = 0 then begin
|
||||||
|
if optTCP.Checked then begin
|
||||||
|
IdTCPClient.Host := txtHost.Text;
|
||||||
|
IdTCPClient.Port := StrToInt(txtPort.Text);
|
||||||
|
EnableControls(False);
|
||||||
|
Append('Connecting to ' + txtHost.Text + ':' + txtPort.Text + '...', clHighlight);
|
||||||
|
try
|
||||||
|
IdTCPClient.Connect;
|
||||||
|
ReadThread := TReadThread.Create(True);
|
||||||
|
ReadThread.ReadTCP := True;
|
||||||
|
ReadThread.Resume;
|
||||||
|
except
|
||||||
|
on E: Exception do begin
|
||||||
|
MessageBox(Handle, PChar('Couldn''t connect to server:' + #13 + E.Message), 'Warning', MB_ICONWARNING);
|
||||||
|
EnableControls(True);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
IdUDPClient.Host := txtHost.Text;
|
||||||
|
IdUDPClient.Port := StrToInt(txtPort.Text);
|
||||||
|
EnableControls(False);
|
||||||
|
try
|
||||||
|
IdUDPClient.Active := True;
|
||||||
|
ReadThread := TReadThread.Create(True);
|
||||||
|
ReadThread.ReadTCP := False;
|
||||||
|
ReadThread.Resume;
|
||||||
|
SetStatus('socket active', clGreen);
|
||||||
|
Append('Opened socket to ' + txtHost.Text + ':' + txtPort.Text + '!', clGreen);
|
||||||
|
except
|
||||||
|
on E: Exception do begin
|
||||||
|
MessageBox(Handle, PChar('Couldn''t activate socket:' + #13 + E.Message), 'Warning', MB_ICONWARNING);
|
||||||
|
EnableControls(True);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
if optTCP.Checked then begin
|
||||||
|
Screen.Cursor := crHourGlass;
|
||||||
|
IdTCPClient.Disconnect;
|
||||||
|
ReadThread.Terminate;
|
||||||
|
while Tag <> 0 do begin
|
||||||
|
Sleep(5);
|
||||||
|
Application.ProcessMessages;
|
||||||
|
end;
|
||||||
|
Screen.Cursor := crDefault;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
Screen.Cursor := crHourGlass;
|
||||||
|
IdUDPClient.Active := False;
|
||||||
|
ReadThread.Terminate;
|
||||||
|
EnableControls(True);
|
||||||
|
SetStatus('socket inactive', clRed);
|
||||||
|
Append('Closed socket to ' + txtHost.Text + ':' + txtPort.Text + '!', clRed);
|
||||||
|
Screen.Cursor := crDefault;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSocketsTerminal.optTCPClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if optTCP.Checked then begin
|
||||||
|
if not IdTCPClient.Connected then
|
||||||
|
SetStatus('not connected', clRed);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
if not IdUDPClient.Active then
|
||||||
|
SetStatus('socket inactive', clRed);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSocketsTerminal.EnableControls(eValue: Boolean);
|
||||||
|
begin
|
||||||
|
txtHost.Enabled := eValue;
|
||||||
|
txtPort.Enabled := eValue;
|
||||||
|
lblHost.Enabled := eValue;
|
||||||
|
lblPort.Enabled := eValue;
|
||||||
|
optTCP.Enabled := eValue;
|
||||||
|
optUDP.Enabled := eValue;
|
||||||
|
if eValue then begin
|
||||||
|
cmdConnect.Caption := 'Connect';
|
||||||
|
Tag := 0;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
cmdConnect.Caption := 'Disconnect';
|
||||||
|
Tag := 1;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSocketsTerminal.IdTCPClientConnected(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Append('Established connection to ' + txtHost.Text + ':' + txtPort.Text, clGreen);
|
||||||
|
SetStatus('connected', clGreen);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSocketsTerminal.IdTCPClientDisconnected(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Append('Disconnected from ' + txtHost.Text + ':' + txtPort.Text, clMaroon);
|
||||||
|
EnableControls(True);
|
||||||
|
SetStatus('not connected', clRed);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSocketsTerminal.FormClose(Sender: TObject;
|
||||||
|
var Action: TCloseAction);
|
||||||
|
begin
|
||||||
|
if Tag = 1 then
|
||||||
|
cmdConnect.Click;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSocketsTerminal.rtfEnterKeyPress(Sender: TObject;
|
||||||
|
var Key: Char);
|
||||||
|
begin
|
||||||
|
if Tag = 1 then begin
|
||||||
|
if (Key = #13) and (rtfEnter.Text <> '') then begin
|
||||||
|
if IdTCPClient.Connected then
|
||||||
|
IdTCPClient.WriteLn(rtfEnter.Text)
|
||||||
|
else
|
||||||
|
IdUDPClient.Send(rtfEnter.Text);
|
||||||
|
Append(rtfEnter.Text, clNavy);
|
||||||
|
rtfEnter.Clear;
|
||||||
|
Key := #0;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSocketsTerminal.IdUDPClientStatus(ASender: TObject;
|
||||||
|
const AStatus: TIdStatus; const AStatusText: String);
|
||||||
|
begin
|
||||||
|
Append(AStatusText, clGray);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSocketsTerminal.acCopyExecute(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if (ActiveControl is TRichEdit) then
|
||||||
|
TRichEdit(ActiveControl).CopyToClipboard;
|
||||||
|
if (ActiveControl is TFlatEdit) then
|
||||||
|
TFlatEdit(ActiveControl).CopyToClipboard;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSocketsTerminal.acPasteExecute(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if (ActiveControl is TRichEdit) then
|
||||||
|
TRichEdit(ActiveControl).PasteFromClipboard;
|
||||||
|
if (ActiveControl is TFlatEdit) then
|
||||||
|
TFlatEdit(ActiveControl).PasteFromClipboard;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSocketsTerminal.acUndoExecute(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if (ActiveControl is TRichEdit) then
|
||||||
|
TRichEdit(ActiveControl).Undo;
|
||||||
|
if (ActiveControl is TFlatEdit) then
|
||||||
|
TFlatEdit(ActiveControl).Undo;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSocketsTerminal.acSelectAllExecute(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if (ActiveControl is TRichEdit) then
|
||||||
|
TRichEdit(ActiveControl).SelectAll;
|
||||||
|
if (ActiveControl is TFlatEdit) then
|
||||||
|
TFlatEdit(ActiveControl).SelectAll;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
BIN
editor/studio/UnitfrmSplashscreen.dfm
Executable file
BIN
editor/studio/UnitfrmSplashscreen.dfm
Executable file
Binary file not shown.
173
editor/studio/UnitfrmSplashscreen.pas
Executable file
173
editor/studio/UnitfrmSplashscreen.pas
Executable file
|
@ -0,0 +1,173 @@
|
||||||
|
unit UnitfrmSplashscreen;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
SysUtils, Windows, Messages, Classes, Graphics, Controls,
|
||||||
|
StdCtrls, ExtCtrls, Forms, SciLexerMemo, JvInspector,
|
||||||
|
UnitfrmMain, UnitfrmSettings, UnitfrmSelectColor, UnitfrmSearch,
|
||||||
|
UnitfrmReplace, UnitfrmAllFilesForm, UnitfrmGoToLine,
|
||||||
|
UnitfrmPluginsIniEditor, UnitfrmSocketsTerminal, UnitfrmInfo, TBX,
|
||||||
|
TB2Item, SpTBXItem, Dialogs;
|
||||||
|
|
||||||
|
type
|
||||||
|
TfrmSplashscreen = class(TForm)
|
||||||
|
imgSplashscreen: TImage;
|
||||||
|
lblStudio: TLabel;
|
||||||
|
tmrHide: TTimer;
|
||||||
|
procedure FormShow(Sender: TObject);
|
||||||
|
procedure tmrHideTimer(Sender: TObject);
|
||||||
|
public
|
||||||
|
procedure OnMessage(var Msg: TMsg; var Handled: Boolean);
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
frmSplashscreen: TfrmSplashscreen;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses UnitCodeExplorerUpdater, UnitCodeSnippets, UnitCodeUtils,
|
||||||
|
UnitLanguages, UnitMainTools, UnitReadThread, UnitfrmHudMsgGenerator,
|
||||||
|
UnitfrmAutoIndent, UnitfrmHTMLPreview, UnitCodeInspector, UnitPlugins,
|
||||||
|
UnitfrmMenuGenerator, UnitfrmMOTDGen, UnitfrmClose, UnitfrmConnGen;
|
||||||
|
|
||||||
|
|
||||||
|
{$R *.DFM}
|
||||||
|
|
||||||
|
procedure TfrmSplashscreen.FormShow(Sender: TObject);
|
||||||
|
var eCache: TStringList;
|
||||||
|
i: integer;
|
||||||
|
eExt: String;
|
||||||
|
begin
|
||||||
|
Application.ProcessMessages;
|
||||||
|
Repaint;
|
||||||
|
Application.CreateForm(TfrmMain, frmMain);
|
||||||
|
Application.ProcessMessages;
|
||||||
|
Repaint;
|
||||||
|
Application.CreateForm(TfrmAutoIndent, frmAutoIndent);
|
||||||
|
Application.ProcessMessages;
|
||||||
|
Repaint;
|
||||||
|
Application.CreateForm(TfrmSettings, frmSettings);
|
||||||
|
Application.ProcessMessages;
|
||||||
|
Repaint;
|
||||||
|
Application.CreateForm(TfrmSelectColor, frmSelectColor);
|
||||||
|
Application.ProcessMessages;
|
||||||
|
Repaint;
|
||||||
|
Application.CreateForm(TfrmInfo, frmInfo);
|
||||||
|
Application.ProcessMessages;
|
||||||
|
Repaint;
|
||||||
|
Application.CreateForm(TfrmSearch, frmSearch);
|
||||||
|
Application.ProcessMessages;
|
||||||
|
Repaint;
|
||||||
|
Application.CreateForm(TfrmReplace, frmReplace);
|
||||||
|
Application.ProcessMessages;
|
||||||
|
Repaint;
|
||||||
|
Application.CreateForm(TfrmAllFilesForm, frmAllFilesForm);
|
||||||
|
Application.ProcessMessages;
|
||||||
|
Repaint;
|
||||||
|
Application.CreateForm(TfrmGoToLine, frmGoToLine);
|
||||||
|
Application.ProcessMessages;
|
||||||
|
Repaint;
|
||||||
|
Application.CreateForm(TfrmPluginsIniEditor, frmPluginsIniEditor);
|
||||||
|
Application.ProcessMessages;
|
||||||
|
Repaint;
|
||||||
|
Application.CreateForm(TfrmSocketsTerminal, frmSocketsTerminal);
|
||||||
|
Application.ProcessMessages;
|
||||||
|
Repaint;
|
||||||
|
Application.CreateForm(TfrmHudMsgGenerator, frmHudMsgGenerator);
|
||||||
|
Application.ProcessMessages;
|
||||||
|
Repaint;
|
||||||
|
Application.CreateForm(TfrmMenuGenerator, frmMenuGenerator);
|
||||||
|
Application.ProcessMessages;
|
||||||
|
Repaint;
|
||||||
|
Application.CreateForm(TfrmMOTDGen, frmMOTDGen);
|
||||||
|
Application.ProcessMessages;
|
||||||
|
Repaint;
|
||||||
|
Application.CreateForm(TfrmClose, frmClose);
|
||||||
|
Application.ProcessMessages;
|
||||||
|
Repaint;
|
||||||
|
Application.CreateForm(TfrmConnGen, frmConnGen);
|
||||||
|
Application.ProcessMessages;
|
||||||
|
Repaint;
|
||||||
|
|
||||||
|
if IEInstalled then begin
|
||||||
|
Application.CreateForm(TfrmHTMLPreview, frmHTMLPreview);
|
||||||
|
Application.ProcessMessages;
|
||||||
|
Repaint;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
frmMain.mnuMOTDGenerator.Enabled := False;
|
||||||
|
|
||||||
|
Application.OnMessage := OnMessage;
|
||||||
|
|
||||||
|
with frmMain do begin
|
||||||
|
sciPropertyLoader.FileName := ExtractFilePath(ParamStr(0)) + 'config\Editor.sci';
|
||||||
|
if FileExists(sciPropertyLoader.FileName) then
|
||||||
|
sciPropertyLoader.Load
|
||||||
|
else
|
||||||
|
sciPropertyLoader.Save; // create new if it doesnt exist...
|
||||||
|
|
||||||
|
sciEditor.Gutter1.Width := 40;
|
||||||
|
sciEditor.Gutter1.MarginType := gutLineNumber;
|
||||||
|
LoadCodeSnippets('Pawn');
|
||||||
|
ResetToEnglish;
|
||||||
|
TJvCustomInspectorData.ItemRegister.Add(TJvInspectorTypeInfoRegItem.Create(TJvInspectorSelectionTextListItem, TypeInfo(TSelectionTextList)));
|
||||||
|
|
||||||
|
eCache := TStringList.Create;
|
||||||
|
if FileExists(ExtractFilePath(ParamStr(0)) + 'config\Cache.cfg') then
|
||||||
|
eCache.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'config\Cache.cfg');
|
||||||
|
for i := 1 to ParamCount do begin
|
||||||
|
if eCache.IndexOf(ParamStr(i)) = -1 then
|
||||||
|
eCache.Add(ParamStr(i));
|
||||||
|
end;
|
||||||
|
|
||||||
|
for i := 0 to eCache.Count -1 do begin
|
||||||
|
if FileExists(eCache[i]) then begin
|
||||||
|
eExt := ExtractFileExt(eCache[i]);
|
||||||
|
eExt := LowerCase(eExt);
|
||||||
|
if (eExt = '.sma') or (eExt = '.inc') then // PAWN files
|
||||||
|
PAWNProjects.Open(eCache[i])
|
||||||
|
else if (eExt = '.cpp') or (eExt = '.h') then // C++ files
|
||||||
|
CPPProjects.Open(eCache[i])
|
||||||
|
else if (eExt = '.htm') or (eExt = '.html') then // HTML files
|
||||||
|
OtherProjects.Open(eCache[i], 'HTML')
|
||||||
|
else if (eExt = '.sql') then // SQL databases
|
||||||
|
OtherProjects.Open(eCache[i], 'SQL')
|
||||||
|
else if (eExt = '.xml') then // XML files
|
||||||
|
OtherProjects.Open(eCache[i], 'XML')
|
||||||
|
else // Other files and/or Textfiles
|
||||||
|
OtherProjects.Open(eCache[i], 'null');
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
eCache.Free;
|
||||||
|
|
||||||
|
if PAWNProjects.Count > 1 then
|
||||||
|
PAWNProjects.Close(0);
|
||||||
|
if CPPProjects.Count > 1 then
|
||||||
|
CPPProjects.Close(0);
|
||||||
|
if OtherProjects.Count > 1 then
|
||||||
|
OtherProjects.Close(0);
|
||||||
|
|
||||||
|
ActivateProjects(0, False); // Started := True is already set here
|
||||||
|
PAWNProjects.Activate(PAWNProjects.Count -1, False, False);
|
||||||
|
UpdateCI;
|
||||||
|
LoadPlugins;
|
||||||
|
end;
|
||||||
|
|
||||||
|
tmrHide.Enabled := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSplashscreen.OnMessage(var Msg: TMsg; var Handled: Boolean);
|
||||||
|
begin
|
||||||
|
Handled := not Plugin_AppMsg(Msg.hwnd, Msg.message, Msg.wParam, Msg.lParam, Msg.time, Msg.pt);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmSplashscreen.tmrHideTimer(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Hide;
|
||||||
|
frmMain.Show;
|
||||||
|
|
||||||
|
tmrHide.Enabled := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
198
editor/studio/UnitfrmTextAnalyze.~pa
Executable file
198
editor/studio/UnitfrmTextAnalyze.~pa
Executable file
|
@ -0,0 +1,198 @@
|
||||||
|
unit UnitfrmTextAnalyze;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses SysUtils, Classes;
|
||||||
|
|
||||||
|
type TPAWNParseResult = class
|
||||||
|
public
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function ParseCodePAWN(eCode: TStringList): TPAWNParseResult;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
function ParseCodePAWN(eCode: TStringList): TPAWNParseResult;
|
||||||
|
var i, k: integer;
|
||||||
|
eTrimmed, eLowered, eNoComments: String;
|
||||||
|
eStr, ePreEvents: TStringList;
|
||||||
|
eStartLine, eBracesOpen: Integer;
|
||||||
|
eTemp: String;
|
||||||
|
begin
|
||||||
|
Synchronize(GetCodeAndPos);
|
||||||
|
eConstants.Clear;
|
||||||
|
eDefined.Clear;
|
||||||
|
eCVars.Clear;
|
||||||
|
eIncluded.Clear;
|
||||||
|
eMethodsDefault.Clear;
|
||||||
|
eMethodsEvents.Clear;
|
||||||
|
eStocks.Clear;
|
||||||
|
eNatives.Clear;
|
||||||
|
eForwards.Clear;
|
||||||
|
eVariables.Clear;
|
||||||
|
ePreEvents.Clear;
|
||||||
|
eBracesOpen := 0;
|
||||||
|
eCurrLine := 0;
|
||||||
|
eStartLine := -1;
|
||||||
|
for i := 0 to eCode.Count -1 do begin
|
||||||
|
eTrimmed := Trim(eCode[i]);
|
||||||
|
eLowered := LowerCase(eTrimmed);
|
||||||
|
eNoComments := RemoveStringsAndComments(eTrimmed);
|
||||||
|
|
||||||
|
{ Constants and Variables }
|
||||||
|
if (Pos('new ', eLowered) = 1) and (eBracesOpen = 0) then begin // const or variable
|
||||||
|
Delete(eTrimmed, 1, 4);
|
||||||
|
eLowered := Trim(eTrimmed);
|
||||||
|
// we don't need braces so delete them...
|
||||||
|
while (CountChars(eTrimmed, '{') = CountChars(eTrimmed, '}')) and (CountChars(eTrimmed, '{') <> 0) and (Pos('{', eTrimmed) < Pos('}', eTrimmed)) do
|
||||||
|
eTrimmed := StringReplace(eTrimmed, '{' + Between(eTrimmed, '{', '}') + '}', '', [rfReplaceAll]);
|
||||||
|
while (CountChars(eTrimmed, '[') = CountChars(eTrimmed, ']')) and (CountChars(eTrimmed, '[') <> 0) and (Pos('[', eTrimmed) < Pos(']', eTrimmed)) do
|
||||||
|
eTrimmed := StringReplace(eTrimmed, '[' + Between(eTrimmed, '[', ']') + ']', '', [rfReplaceAll]);
|
||||||
|
// done? okay, split all items if there are more than one; and if not, it's okay...
|
||||||
|
eStr.Text := StringReplace(eTrimmed, ',', #13, [rfReplaceAll]);
|
||||||
|
for k := 0 to eStr.Count -1 do begin
|
||||||
|
if Trim(eStr[k]) <> '' then begin
|
||||||
|
if Pos(':', eStr[k]) <> 0 then
|
||||||
|
eStr[k] := Copy(eStr[k], Pos(':', eStr[k]) +1, Length(eStr[k]));
|
||||||
|
eStr[k] := Trim(RemoveSemicolon(eStr[k]));
|
||||||
|
if Pos('=', eStr[k]) <> 0 then // constant
|
||||||
|
eConstants.AddObject(Copy(eStr[k], 1, Pos('=', eStr[k]) -1), TObject(i))
|
||||||
|
else
|
||||||
|
eVariables.AddObject(eStr[k], TObject(i));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
{ Included }
|
||||||
|
else if Pos('#include ', eLowered) = 1 then begin
|
||||||
|
if Between(eTrimmed, '<', '>') <> '' then begin
|
||||||
|
eTrimmed := Between(eTrimmed, '<', '>');
|
||||||
|
if ExtractFileExt(eTrimmed) <> '' then
|
||||||
|
ChangeFileExt(eTrimmed, '');
|
||||||
|
end
|
||||||
|
else if Between(eTrimmed, '"', '"') <> '' then begin
|
||||||
|
eTrimmed := Between(eTrimmed, '"', '"');
|
||||||
|
if ExtractFileExt(eTrimmed) <> '' then
|
||||||
|
ChangeFileExt(eTrimmed, '');
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
eTrimmed := Copy(eTrimmed, 9, Length(eTrimmed));
|
||||||
|
if ExtractFileExt(eTrimmed) <> '' then
|
||||||
|
ChangeFileExt(eTrimmed, '');
|
||||||
|
end;
|
||||||
|
eTrimmed := Trim(eTrimmed);
|
||||||
|
eIncluded.AddObject(eTrimmed, TObject(i));
|
||||||
|
end
|
||||||
|
{ CVars }
|
||||||
|
else if Pos('register_cvar(', eLowered) = 1 then begin
|
||||||
|
if Between(eTrimmed, '"', '"') <> '' then
|
||||||
|
eCVars.AddObject(Between(eTrimmed, '"', '"'), TObject(i));
|
||||||
|
end
|
||||||
|
{ Defined }
|
||||||
|
else if Pos('#define ', eLowered) = 1 then begin
|
||||||
|
eTrimmed := Copy(eTrimmed, 8, Length(eTrimmed));
|
||||||
|
eTrimmed := Trim(eTrimmed);
|
||||||
|
if Pos(#32, eTrimmed) <> 0 then
|
||||||
|
eTrimmed := Copy(eTrimmed, 1, Pos(#32, eTrimmed) -1);
|
||||||
|
eDefined.AddObject(eTrimmed, TObject(i));
|
||||||
|
end
|
||||||
|
{ Events (Part 1) }
|
||||||
|
else if Pos('register_event(', eLowered) = 1 then begin
|
||||||
|
if CountChars(eLowered, '"') >= 4 then
|
||||||
|
ePreEvents.Add(Between(eTrimmed, '"', '"'));
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ Functions, this is adapted from AMXX-Edit v2 [see TextAnalyze.pas] }
|
||||||
|
if Pos('{', eNoComments) <> 0 then begin
|
||||||
|
if eStartLine = -1 then
|
||||||
|
eStartLine := i;
|
||||||
|
Inc(eBracesOpen, CountChars(eTrimmed, '{'));
|
||||||
|
end;
|
||||||
|
if Pos('}', eNoComments) <> 0 then begin
|
||||||
|
Inc(eBracesOpen, -CountChars(eTrimmed, '}'));
|
||||||
|
if (eBracesOpen = 0) then begin
|
||||||
|
eTemp := Trim(StringReplace(eCode[eStartLine], '{', '', [rfReplaceAll]));
|
||||||
|
// Analyze type
|
||||||
|
k := 0;
|
||||||
|
if Pos('public ', LowerCase(eTemp)) = 1 then
|
||||||
|
k := 1
|
||||||
|
else if Pos('stock ', LowerCase(eTemp)) = 1 then
|
||||||
|
k := 2
|
||||||
|
else if Pos('native ', LowerCase(eTemp)) = 1 then
|
||||||
|
k := 3
|
||||||
|
else if Pos('forward ', LowerCase(eTemp)) = 1 then
|
||||||
|
k := 4;
|
||||||
|
// 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]));
|
||||||
|
// Copy function-name
|
||||||
|
if Pos('(', eTemp) <> 0 then
|
||||||
|
eTemp := Copy(eTemp, 1, Pos('(', eTemp) -1);
|
||||||
|
// Remove return-type
|
||||||
|
if Pos(':', eTemp) <> 0 then
|
||||||
|
Delete(eTemp, 1, Pos(':', eTemp));
|
||||||
|
eTemp := Trim(eTemp);
|
||||||
|
|
||||||
|
if eTemp <> '' then begin
|
||||||
|
case k of
|
||||||
|
0: eMethodsDefault.AddObject(eTemp, TObject(i)); // Default Method
|
||||||
|
1: begin
|
||||||
|
k := ePreEvents.IndexOf(eTemp);
|
||||||
|
if k <> -1 then begin
|
||||||
|
eMethodsEvents.AddObject(eTemp, ePreEvents.Objects[k]);
|
||||||
|
ePreEvents.Delete(k);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
eMethodsDefault.AddObject(eTemp, TObject(i));
|
||||||
|
end;
|
||||||
|
2: eStocks.AddObject(eTemp, TObject(i));
|
||||||
|
3: eNatives.AddObject(eTemp, TObject(i));
|
||||||
|
4: eForwards.AddObject(eTemp, TObject(i));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
eStartLine := -1;
|
||||||
|
eBracesOpen := -2;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if (Pos('forward ', eLowered) = 1) or (Pos('public ', eLowered) = 1) or (Pos('native ', eLowered) = 1) or (Pos('stock ', eLowered) = 1) then begin
|
||||||
|
eBracesOpen := 0;
|
||||||
|
if ((Pos('{', eLowered) = 0)) or (Pos('{', eLowered) <> 0) and (Pos('}', eLowered) <> 0) then begin
|
||||||
|
eTemp := eTrimmed;
|
||||||
|
// Remove type
|
||||||
|
if (Pos(#32, eTemp) <> 0) and (Pos(#32, eTemp) < Pos('(', eTemp)) then
|
||||||
|
eTemp := Copy(eTemp, Pos(#32, eTemp) +1, Length(eTemp));
|
||||||
|
// Copy function-name
|
||||||
|
if Pos('(', eTemp) <> 0 then
|
||||||
|
eTemp := Copy(eTemp, 1, Pos('(', eTemp) -1);
|
||||||
|
// Remove return-type
|
||||||
|
if Pos(':', eTemp) <> 0 then
|
||||||
|
Delete(eTemp, 1, Pos(':', eTemp));
|
||||||
|
eTemp := Trim(eTemp);
|
||||||
|
|
||||||
|
if eTemp <> '' then begin
|
||||||
|
if Pos('forward', eLowered) = 1 then
|
||||||
|
eForwards.AddObject(eTrimmed, TObject(i))
|
||||||
|
else if Pos('public', eLowered) = 1 then begin
|
||||||
|
k := ePreEvents.IndexOf(eTemp);
|
||||||
|
if k <> -1 then begin
|
||||||
|
eMethodsEvents.AddObject(eTemp, ePreEvents.Objects[k]);
|
||||||
|
ePreEvents.Delete(k);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
eMethodsDefault.Add(eTemp);
|
||||||
|
end
|
||||||
|
else if Pos('native', eLowered) = 1 then
|
||||||
|
eNatives.AddObject(eTemp, TObject(i))
|
||||||
|
else if Pos('stock', eLowered) = 1 then
|
||||||
|
eStocks.AddObject(eTemp, TObject(i))
|
||||||
|
else
|
||||||
|
eMethodsDefault.AddObject(eTemp, TObject(i));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Sleep(5);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user