From e8d0210da04e28f9e08d572d5ea9bfa579ef5e41 Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Thu, 31 Jan 2019 09:25:11 -0600 Subject: [PATCH] [Developer] Cleanup and address review comments --- .../developer/TIKE/compile/CompileKeymanWeb.pas | 17 ++++++++--------- .../TIKE/main/KeymanDeveloperOptions.pas | 6 ++++++ .../src/global/delphi/general/RegistryKeys.pas | 3 +++ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/windows/src/developer/TIKE/compile/CompileKeymanWeb.pas b/windows/src/developer/TIKE/compile/CompileKeymanWeb.pas index 4c94f1534d..113a8531a5 100644 --- a/windows/src/developer/TIKE/compile/CompileKeymanWeb.pas +++ b/windows/src/developer/TIKE/compile/CompileKeymanWeb.pas @@ -211,7 +211,8 @@ type FTabStop: string; // I3681 fMnemonic: Boolean; FCompilerWarningsAsErrors: Boolean; - FTouchLayoutFont: string; // I4872 + FTouchLayoutFont: string; + FFix183_LadderLength: Integer; // I4872 function JavaScript_String(ch: DWord): string; // I2242 @@ -266,6 +267,7 @@ uses CompileErrorCodes, JsonUtil, + KeymanDeveloperOptions, KeyboardParser, Keyman.System.KeyboardUtils, KeymanWebKeyCodes, @@ -379,6 +381,7 @@ end; constructor TCompileKeymanWeb.Create; begin FillChar(fk, sizeof(fk), 0); + FFix183_LadderLength := FKeymanDeveloperOptions.Fix183_LadderLength; // How frequently to break ladders end; destructor TCompileKeymanWeb.Destroy; @@ -711,9 +714,6 @@ begin // We know the rules are sorted by key code. // First pass, break the grouping down by key code. -// Result := Result + FTabstop+FTabstop; // I3681 -// if HasRules then Result := Result + 'else '; -// HasRules := True; if fgp.fUsingKeys then begin Result := Result + Format('%s%sif(k.KKM(e,%s,%s)) {%s', @@ -733,14 +733,13 @@ begin LocalCounter := 0; while (j < Integer(fgp.cxKeyArray)) and (fkp2.Key = fkp.Key) and (fkp2.ShiftFlags = fkp.ShiftFlags) do begin - //writeln(Format('%d of %d [%d]', [j, fgp.cxKeyArray, fkp.Line])); - if not RuleIsExcludedByPlatform(fkp) then begin processed_rule[j] := True; Result := Result + JavaScript_Rule(FTabStop + FTabStop + FTabStop, IfThen(LocalHasRules, 'else ', ''), fgp, fkp); Inc(LocalCounter); - if (LocalCounter mod 100) = 0 then + + if (FFix183_LadderLength <> 0) and ((LocalCounter mod FFix183_LadderLength) = 0) then begin // Break if/else ladders Result := Result + Format('%sif(m) {}%s', [FTabStop + FTabStop + FTabStop, nl]); @@ -756,7 +755,7 @@ begin end else begin - //TODO + // TODO: context character level switches instead of full context comparisons Result := Result + JavaScript_Rule(FTabStop + FTabStop + FTabStop, IfThen(HasRules, 'else ', ''), fgp, fkp); HasRules := True; Inc(Counter); @@ -764,7 +763,7 @@ begin Inc(j); end; - if (Counter mod 100) = 0 then + if (FFix183_LadderLength <> 0) and ((Counter mod FFix183_LadderLength) = 0) then begin // Break if/else ladders // We need to only match if no previous line is matched (i.e. m is false) diff --git a/windows/src/developer/TIKE/main/KeymanDeveloperOptions.pas b/windows/src/developer/TIKE/main/KeymanDeveloperOptions.pas index f5c9fcfc78..237b40033b 100644 --- a/windows/src/developer/TIKE/main/KeymanDeveloperOptions.pas +++ b/windows/src/developer/TIKE/main/KeymanDeveloperOptions.pas @@ -59,6 +59,7 @@ type FOpenKeyboardFilesInSourceView: Boolean; // I4751 FDisplayTheme: string; FEditorTheme: string; + FFix183_LadderLength: Integer; procedure CloseRegistry; procedure OpenRegistry; function regReadString(const nm, def: string): string; @@ -83,6 +84,7 @@ type property CharMapAutoLookup: Boolean read FCharMapAutoLookup write FCharMapAutoLookup; property CharMapDisableDatabaseLookups: Boolean read FCharMapDisableDatabaseLookups write FCharMapDisableDatabaseLookups; + property Fix183_LadderLength: Integer read FFix183_LadderLength write FFix183_LadderLength; property DebuggerBreakWhenExitingLine: Boolean read FDebuggerBreakWhenExitingLine write FDebuggerBreakWhenExitingLine; property DebuggerSingleStepAfterBreak: Boolean read FDebuggerSingleStepAfterBreak write FDebuggerSingleStepAfterBreak; property DebuggerShowStoreOffset: Boolean read FDebuggerShowStoreOffset write FDebuggerShowStoreOffset; @@ -196,6 +198,8 @@ begin FExternalEditorPath := regReadString(SRegValue_IDEOptExternalEditorPath, ''); FSMTPServer := regReadString(SRegValue_IDEOptSMTPServer, ''); // I4506 FTestEmailAddresses := regReadString(SRegValue_IDEOptTestEmailAddresses, ''); // I4506 + + FFix183_LadderLength := regReadInt(SRegValue_IDEOpt_WebLadderLength, CRegValue_IDEOpt_WebLadderLength_Default); finally CloseRegistry; end; @@ -233,6 +237,8 @@ begin regWriteString(SRegValue_IDEOptExternalEditorPath, FExternalEditorPath); regWriteString(SRegValue_IDEOptSMTPServer, FSMTPServer); // I4506 regWriteString(SRegValue_IDEOptTestEmailAddresses, FTestEmailAddresses); // I4506 + + regWriteInt(SRegValue_IDEOpt_WebLadderLength, FFix183_LadderLength); finally CloseRegistry; end; diff --git a/windows/src/global/delphi/general/RegistryKeys.pas b/windows/src/global/delphi/general/RegistryKeys.pas index 1b51a67f66..d1bf0c393a 100644 --- a/windows/src/global/delphi/general/RegistryKeys.pas +++ b/windows/src/global/delphi/general/RegistryKeys.pas @@ -394,6 +394,9 @@ const SRegValue_IDEOptSMTPServer = 'smtp server'; // CU // I4506 SRegValue_IDEOptTestEmailAddresses = 'test email addresses'; // CU // I4506 + SRegValue_IDEOpt_WebLadderLength = 'web ladder length'; // CU + CRegValue_IDEOpt_WebLadderLength_Default = 100; + { SRegKey_KCT values } // SRegValue_KCTTemplatePath = 'template path'; // LM