From 97cdc708fad73edbcbc35f0fac8d3b1843f634ee Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Wed, 21 Apr 2021 10:07:33 +1000 Subject: [PATCH] fix(developer): chiral mismatch warning is disruptive Fixes #4803. This fixes part of #4803 - namely the obtrusive warning flagging that there are mismatched modifier types in the keyboard. Instead of making the change during tab switching, it simply shows a warning message in the design view of the keyboard, which the developer can choose to ignore. This does not address the removal of comments or the switch of character formats which is part of that conversion routine. That is a more complex change to the parser. --- .../developer/TIKE/child/UfrmKeymanWizard.dfm | 81 ++++++++++++++++++- .../developer/TIKE/child/UfrmKeymanWizard.pas | 63 +++++++++------ 2 files changed, 114 insertions(+), 30 deletions(-) diff --git a/windows/src/developer/TIKE/child/UfrmKeymanWizard.dfm b/windows/src/developer/TIKE/child/UfrmKeymanWizard.dfm index b8cb54c560..dafe85fa77 100644 --- a/windows/src/developer/TIKE/child/UfrmKeymanWizard.dfm +++ b/windows/src/developer/TIKE/child/UfrmKeymanWizard.dfm @@ -198,6 +198,9 @@ inherited frmKeymanWizard: TfrmKeymanWizard object pageDetails: TTabSheet Caption = 'Details' ImageIndex = 2 + ExplicitLeft = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 object sbDetails: TScrollBox Left = 0 Top = 0 @@ -698,7 +701,7 @@ inherited frmKeymanWizard: TfrmKeymanWizard Top = 22 Width = 482 Height = 13 - Caption = + Caption = 'In Keyman 10, language metadata should now be managed in the pac' + 'kage, not the keyboard.' end @@ -721,6 +724,9 @@ inherited frmKeymanWizard: TfrmKeymanWizard object pageLayout: TTabSheet Caption = 'Layout' ImageIndex = 5 + ExplicitLeft = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 object pagesLayout: TPageControl Left = 0 Top = 0 @@ -735,6 +741,10 @@ inherited frmKeymanWizard: TfrmKeymanWizard object pageLayoutDesign: TTabSheet Caption = 'Design' ImageIndex = -1 + ExplicitLeft = 0 + ExplicitTop = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 object panLayoutSimple: TPanel Left = 0 Top = 0 @@ -953,11 +963,45 @@ inherited frmKeymanWizard: TfrmKeymanWizard TabOrder = 2 OnClick = chkLayoutDisplay102KeyClick end + object panWarnMixedShiftStates: TPanel + Left = 492 + Top = 59 + Width = 317 + Height = 54 + BevelOuter = bvLowered + Color = clCream + ParentBackground = False + TabOrder = 5 + Visible = False + object lblWarnMixedShiftStates: TLabel + Left = 8 + Top = 8 + Width = 183 + Height = 39 + Caption = + 'Warning: mixing left/right and non-specific modifiers means some' + + ' rules are not visible here' + WordWrap = True + end + object cmdFixupShiftStates: TButton + Left = 200 + Top = 16 + Width = 107 + Height = 25 + Caption = 'Fixup Shift States' + TabOrder = 0 + OnClick = cmdFixupShiftStatesClick + end + end end end object pageLayoutCode: TTabSheet Caption = 'Code' ImageIndex = -1 + ExplicitLeft = 0 + ExplicitTop = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 end end end @@ -1004,10 +1048,16 @@ inherited frmKeymanWizard: TfrmKeymanWizard object pageOnScreenKeyboard: TTabSheet Caption = 'On-Screen' ImageIndex = 7 + ExplicitLeft = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 end object pageTouchLayout: TTabSheet Caption = 'Touch Layout' ImageIndex = 16 + ExplicitLeft = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 object pagesTouchLayout: TPageControl Left = 0 Top = 0 @@ -1022,32 +1072,55 @@ inherited frmKeymanWizard: TfrmKeymanWizard object pageTouchLayoutDesign: TTabSheet Caption = 'Design' ImageIndex = -1 + ExplicitLeft = 0 + ExplicitTop = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 end object pageTouchLayoutCode: TTabSheet Caption = 'Code' ImageIndex = -1 + ExplicitLeft = 0 + ExplicitTop = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 end end end object pageIncludeCodes: TTabSheet Caption = 'Char Codes' ImageIndex = 9 + ExplicitLeft = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 end object pageKMWEmbedJS: TTabSheet Caption = 'Embedded JS' ImageIndex = 9 + ExplicitLeft = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 end object pageKMWEmbedCSS: TTabSheet Caption = 'Embedded CSS' ImageIndex = 9 + ExplicitLeft = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 end object pageKMWHelp: TTabSheet Caption = 'Embedded Help' ImageIndex = 9 + ExplicitLeft = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 end object pageCompile: TTabSheet Caption = 'Build' ImageIndex = 1 + ExplicitLeft = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 object Panel1: TPanel Left = 0 Top = 0 @@ -1063,7 +1136,7 @@ inherited frmKeymanWizard: TfrmKeymanWizard Top = 13 Width = 333 Height = 13 - Caption = + Caption = 'The keyboard must be compiled in order to distribute or install ' + 'it' end @@ -1331,7 +1404,7 @@ inherited frmKeymanWizard: TfrmKeymanWizard end object dlgBrowseBitmap: TOpenPictureDialog DefaultExt = 'ico' - Filter = + Filter = 'All supported files (*.ico, *.bmp)|*.ico;*.bmp|Icon files (*.ico' + ')|*.ico|Bitmap files (*.bmp)|*.bmp|All files (*.*)|*.*' Options = [ofHideReadOnly, ofCreatePrompt, ofEnableSizing] @@ -1341,7 +1414,7 @@ inherited frmKeymanWizard: TfrmKeymanWizard end object dlgSaveExport: TSaveDialog DefaultExt = 'kmn' - Filter = + Filter = 'Keyman 5.0 Keyboard Wizard (*.kmn)|*.kmn|Windows NT/2000/XP keyb' + 'oard (*.dll)|*.dll|Windows 95/98/Me keyboard (*.kbd)|*.kbd' Options = [ofOverwritePrompt, ofHideReadOnly, ofPathMustExist, ofEnableSizing] diff --git a/windows/src/developer/TIKE/child/UfrmKeymanWizard.pas b/windows/src/developer/TIKE/child/UfrmKeymanWizard.pas index 4b9041a29e..fae57c328b 100644 --- a/windows/src/developer/TIKE/child/UfrmKeymanWizard.pas +++ b/windows/src/developer/TIKE/child/UfrmKeymanWizard.pas @@ -273,6 +273,9 @@ type cmdAddToProject: TButton; cmdStartDebugging: TButton; cmdCompile: TButton; + panWarnMixedShiftStates: TPanel; + cmdFixupShiftStates: TButton; + lblWarnMixedShiftStates: TLabel; procedure FormCreate(Sender: TObject); procedure editNameChange(Sender: TObject); procedure editCopyrightChange(Sender: TObject); @@ -340,6 +343,7 @@ type procedure lbDebugHostsClick(Sender: TObject); procedure cmdOpenBuildFolderClick(Sender: TObject); procedure cmdOpenProjectFolderClick(Sender: TObject); + procedure cmdFixupShiftStatesClick(Sender: TObject); private frameSource: TframeTextEditor; @@ -403,10 +407,10 @@ type function SaveBitmap: Boolean; procedure LoadBitmap; - procedure MoveSourceToParser(UpdateLRShift, FixupShiftStates: Boolean); // I4137 + procedure MoveSourceToParser(UpdateLRShift: Boolean); // I4137 procedure MoveParserToSource; - procedure UpdateControls(UpdateLRShift, FixupShiftStates: Boolean); // I4137 + procedure UpdateControls(UpdateLRShift: Boolean); // I4137 procedure BitmapModifiedChanged(Sender: TObject); procedure WMUserFormShown(var Message: TMessage); message WM_USER_FORMSHOWN; @@ -1320,19 +1324,9 @@ begin end; // I2532 BEGIN - fix l/r shift transfer from source failure - if FLRShift and FAShift and FixupShiftStates then // I4137 - begin - FOldLayoutSetup := FLayoutSetup; - FLayoutSetup := True; - chkSplitCtrlAlt.Checked := True; - if Layout_FixupRules_LRShift(False) then - begin - kbdLayout.LRShift := chkSplitCtrlAlt.Checked; - FLayoutSetup := FOldLayoutSetup; - Layout_SetAllKeyDetails; - end; - end - else if (chkSplitCtrlAlt.Checked <> FLRShift) and UpdateLRShift then // I2532 + panWarnMixedShiftStates.Visible := FLRShift and FAShift; + + if (chkSplitCtrlAlt.Checked <> FLRShift) and UpdateLRShift then // I2532 begin FOldLayoutSetup := FLayoutSetup; FLayoutSetup := True; @@ -1546,7 +1540,7 @@ begin end; if not IsInParserMode then // I4557 - MoveSourceToParser(False, False); + MoveSourceToParser(False); Result := True; end; @@ -1662,6 +1656,23 @@ begin pages.ActivePage := c; end; +procedure TfrmKeymanWizard.cmdFixupShiftStatesClick(Sender: TObject); +var + FOldLayoutSetup: Boolean; +begin + FOldLayoutSetup := FLayoutSetup; + FLayoutSetup := True; + if Layout_FixupRules_LRShift(False) then + begin + chkSplitCtrlAlt.Checked := True; + kbdLayout.LRShift := True; + FLayoutSetup := FOldLayoutSetup; + Layout_SetAllKeyDetails; + end + else + FLayoutSetup := FOldLayoutSetup; +end; + procedure TfrmKeymanWizard.LoadFeature(ID: TKeyboardParser_FeatureID); begin if FKeyboardParser.Features.ContainsKey(ID) then @@ -2036,7 +2047,7 @@ begin Free; end; - UpdateControls(True, False); // I4137 + UpdateControls(True); // I4137 Layout_UpdateCharacterSet; LoadSettings; @@ -2092,7 +2103,7 @@ begin FControlDown := False; // I4680 if not IsInParserMode then // I4557 - MoveSourceToParser(True,False); + MoveSourceToParser(True); try FKeyboardParser.AddRequiredLines; @@ -2358,14 +2369,14 @@ begin // TODO: other file types end; -procedure TfrmKeymanWizard.UpdateControls(UpdateLRShift, FixupShiftStates: Boolean); // I4137 +procedure TfrmKeymanWizard.UpdateControls(UpdateLRShift: Boolean); // I4137 var i, n: Integer; nb: Integer; begin // // I4723 - removed line FLoading := True; - Layout_SetAllKeyDetails(UpdateLRShift, FixupShiftStates); // I2532 // I4137 + Layout_SetAllKeyDetails(UpdateLRShift); // I2532 // I4137 editName.Text := FKeyboardParser.GetSystemStoreValue(ssName); SetTargetsListBoxFromTargets(FKeyboardParser.GetSystemStoreValue(ssTargets)); // I4504 editMessage.Text := FKeyboardParser.GetSystemStoreValue(ssMessage); @@ -2585,13 +2596,13 @@ begin frameSource.EditorText := FKeyboardParser.KeyboardText; end; -procedure TfrmKeymanWizard.MoveSourceToParser(UpdateLRShift, FixupShiftStates: Boolean); // I4137 +procedure TfrmKeymanWizard.MoveSourceToParser(UpdateLRShift: Boolean); // I4137 begin FCurrentRule := nil; FKeyboardParser.FileName := FileName; FKeyboardParser.KeyboardText := frameSource.EditorText; ConfirmSaveOfOldEditorWindows; - UpdateControls(UpdateLRShift, FixupShiftStates); // I4137 + UpdateControls(UpdateLRShift); // I4137 end; procedure TfrmKeymanWizard.NotifyStartedWebDebug; @@ -2641,7 +2652,7 @@ begin kbdLayout.LRShift := chkSplitCtrlAlt.Checked; - Layout_SetAllKeyDetails(False, True); // I4137 + Layout_SetAllKeyDetails; Layout_FocusOutput; finally FLayoutSetup := False; @@ -2872,7 +2883,7 @@ begin begin for i := 0 to FKeyboardParser.Lines.Count - 1 do FKeyboardParser.Lines[i].ConvertToANSI; - UpdateControls(True, False); // I4137 + UpdateControls(True); // I4137 end; end; frameSource.TextFileFormat := FTextFileFormat; @@ -3098,7 +3109,7 @@ begin if not IsInParserMode then // I4557 begin - MoveSourceToParser(True, False); // I4137 + MoveSourceToParser(True); // I4137 end; for f := Low(f) to High(f) do @@ -3126,7 +3137,7 @@ begin MoveParserToSource; end else if not IsInParserMode and not FLoading then // I4557 - MoveSourceToParser(True, True); // I4137 + MoveSourceToParser(True); // I4137 end; procedure TfrmKeymanWizard.LoadOSK; // I4034