Added new feature: Auto Disable (disable auto-update if plugin has more than xxx lines, should prevent lags)

This commit is contained in:
Christian Hammacher 2005-11-02 15:36:24 +00:00
parent efe4b674e2
commit 6ea52a9a08
9 changed files with 68 additions and 15 deletions

View File

@ -115,7 +115,7 @@ AutoIncBuild=1
MajorVer=1
MinorVer=3
Release=0
Build=14
Build=16
Debug=0
PreRelease=0
Special=0
@ -126,7 +126,7 @@ CodePage=1252
[Version Info Keys]
CompanyName=AMX Mod X Dev Team
FileDescription=
FileVersion=1.3.0.14
FileVersion=1.3.0.16
InternalName=
LegalCopyright=
LegalTrademarks=

Binary file not shown.

Binary file not shown.

View File

@ -21,6 +21,8 @@ type
eCode: TStringList;
eAutoComplete, eCallTips, eKeywords: string;
eLastActive: Integer;
eActive: Integer;
protected
procedure Execute; override;
procedure GetCode;
@ -37,6 +39,16 @@ uses UnitfrmMain, UnitLanguages, UnitMainTools, UnitCodeUtils,
{ TCodeExplorerUpdater }
procedure TCodeExplorerUpdater.Execute;
function CheckAU: Boolean;
begin
Result := True;
if (eLastActive = eActive) and (frmSettings.chkAUDisable.Checked) then begin
if frmMain.sciEditor.Lines.Count > StrToIntDef(frmSettings.txtAUDisable.Text, 1500) then
Result := False;
end;
eLastActive := eActive;
end;
var eStr: TStringList;
begin
eCode := TStringList.Create;
@ -59,9 +71,9 @@ begin
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
if (Plugin_UpdateCodeExplorer(GetCurrLang.Name, ActiveDoc.FileName, frmMain.tsMain.Items[frmMain.tsMain.ActiveTabIndex].Caption, True)) and (frmMain.tsMain.ActiveTabIndex = 0) then begin
try
if (frmMain.tsMain.ActiveTabIndex = 0) then begin
if CheckAU then begin
if Plugin_UpdateCodeExplorer(GetCurrLang.Name, ActiveDoc.FileName, frmMain.tsMain.Items[frmMain.tsMain.ActiveTabIndex].Caption, True) then begin
// analyze code
with ParseCodePawn(eCode, ExtractFileName(ActiveDoc.FileName)) do begin
@ -114,6 +126,7 @@ end;
procedure TCodeExplorerUpdater.GetCode;
begin
eCode.Assign(frmMain.sciEditor.Lines);
eActive := ActiveDoc.Index;
end;
function GetNode(eText: string): TTreeNode;

View File

@ -631,7 +631,9 @@ begin
frmAutoIndent.chkIndentOpeningBrace.Checked := eConfig.ReadBool('Editor', 'IndentOpeningBrace', True);
frmAutoIndent.chkUnindentPressingClosingBrace.Checked := eConfig.ReadBool('Editor', 'UnindentClosingBrace', True);
frmAutoIndent.chkUnindentLine.Checked := eConfig.ReadBool('Editor', 'UnindentEmptyLine', False);
frmSettings.chkAUDisable.Checked := eConfig.ReadString('Editor', 'AutoDisable', '1500') <> '-1';
if eConfig.ReadString('Editor', 'AutoDisable', '1500') <> '-1' then
frmSettings.txtAUDisable.Text := eConfig.ReadString('Editor', 'AutoDisable', '1500');
if foldFold in frmMain.sciEditor.Folding then begin
case frmMain.sciEditor.FoldMarkerType of
sciMarkArrows: frmSettings.cboCodeFolding.ItemIndex := 0;

View File

@ -52,14 +52,14 @@ end;
function ParseCodePawn(eCode: TStringList; FileName: string; IsRecursive: Boolean = False): TPawnParseResult;
var i, k: integer;
eString, eTemp, eBackup: string;
eStr, ePreEvents: TStringList;
eStartLine, eBracesOpen: Integer;
eTimeToSleep: Integer;
eAddingEnum: Integer;
eTempResult: TPawnParseResult;
eProcedureAdded: Boolean;
eCActive: Boolean;
eString, eTemp, eBackup: string;
eStr, ePreEvents: TStringList;
eStartLine, eBracesOpen: Integer;
eTimeToSleep: Integer;
eAddingEnum: Integer;
eTempResult: TPawnParseResult;
eProcedureAdded: Boolean;
eCActive: Boolean;
begin
Result := TPawnParseResult.Create;
if not IsRecursive then

View File

@ -553,7 +553,11 @@ begin
eConfig.WriteBool('Editor', 'UnindentClosingBrace', frmAutoIndent.chkUnindentPressingClosingBrace.Checked);
eConfig.WriteBool('Editor', 'UnindentEmptyLine', frmAutoIndent.chkUnindentLine.Checked);
eConfig.WriteBool('Editor', 'Disable_AC', frmSettings.chkDisableAC.Checked);
eConfig.WriteBool('Editor', 'Disable_CT', frmSettings.chkDisableCT.Checked);
eConfig.WriteBool('Editor', 'Disable_CT', frmSettings.chkDisableCT.Checked);
if frmSettings.chkAUDisable.Checked then
eConfig.WriteString('Editor', 'AutoDisable', frmSettings.txtAUDisable.Text)
else
eConfig.WriteString('Editor', 'AutoDisable', '-1');
{ Editor }
if FileExists(sciPropertyLoader.FileName) then
sciPropertyLoader.Save;

View File

@ -61,7 +61,7 @@ object frmSettings: TfrmSettings
Top = 0
Width = 353
Height = 260
ActivePage = jspHighlighter
ActivePage = jspCTSettings
PropagateEnable = False
Align = alClient
OnChange = jplSettingsChange
@ -1670,6 +1670,31 @@ object frmSettings: TfrmSettings
TabOrder = 1
end
end
object chkAUDisable: TFlatCheckBox
Left = 8
Top = 166
Width = 297
Height = 17
Caption = 'Disable Auto-Update if plugin has more than lines'
TabOrder = 2
TabStop = True
end
object txtAUDisable: TFlatEdit
Left = 238
Top = 166
Width = 37
Height = 16
ColorFlat = clWhite
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -8
Font.Name = 'Tahoma'
Font.Style = [fsBold]
ParentFont = False
TabOrder = 3
Text = '1500'
OnExit = txtAUDisableExit
end
end
object lblCurrSetting: TLabel
Left = 0

View File

@ -193,6 +193,8 @@ type
chkMakeBaks: TFlatCheckBox;
chkDisableAC: TFlatCheckBox;
chkDisableCT: TFlatCheckBox;
chkAUDisable: TFlatCheckBox;
txtAUDisable: TFlatEdit;
procedure jplSettingsChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
@ -255,6 +257,7 @@ type
Shift: TShiftState);
procedure cboFontChange(Sender: TObject);
procedure cmdBrowseLangDirClick(Sender: TObject);
procedure txtAUDisableExit(Sender: TObject);
public
Foreground, Background: TColor;
CaretFore, CaretBack: TColor;
@ -1002,4 +1005,10 @@ begin
txtLangDir.Text := eStr;
end;
procedure TfrmSettings.txtAUDisableExit(Sender: TObject);
begin
if not IsNumeric(txtAUDisable.Text) then
txtAUDisable.Text := '1500';
end;
end.