diff --git a/common/web/types/src/kpj/keyman-developer-project.ts b/common/web/types/src/kpj/keyman-developer-project.ts index 27ea6ddf16e..a53cbca20e9 100644 --- a/common/web/types/src/kpj/keyman-developer-project.ts +++ b/common/web/types/src/kpj/keyman-developer-project.ts @@ -37,7 +37,7 @@ export class KeymanDeveloperProject { for(let filename of files) { let fullPath = this.callbacks.path.join(sourcePath, filename); if(KeymanFileTypes.filenameIs(filename, KeymanFileTypes.Source.LdmlKeyboard)) { - if(!this.callbacks.fs.readFileSync(fullPath, 'utf-8').match(/ldmlKeyboard\.dtd/)) { + if(!this.callbacks.fs.readFileSync(fullPath, 'utf-8').match(/ldmlKeyboard3\.dtd/)) { // Skip this .xml because we assume it isn't really a keyboard .xml continue; } diff --git a/common/web/types/test/fixtures/invalid-conforms-to.xml b/common/web/types/test/fixtures/invalid-conforms-to.xml index 01e463d817e..de19c3a3bf0 100644 --- a/common/web/types/test/fixtures/invalid-conforms-to.xml +++ b/common/web/types/test/fixtures/invalid-conforms-to.xml @@ -1,7 +1,7 @@ diff --git a/developer/src/tike/actions/dmActionsDebugger.dfm b/developer/src/tike/actions/dmActionsDebugger.dfm new file mode 100644 index 00000000000..98dc623b72d --- /dev/null +++ b/developer/src/tike/actions/dmActionsDebugger.dfm @@ -0,0 +1,149 @@ +object modActionsDebugger: TmodActionsDebugger + OldCreateOrder = False + Height = 333 + Width = 408 + object actionsDebug: TActionList + Images = frmKeymanDeveloper.lstImages + Left = 60 + Top = 88 + object actDebugStartDebugger: TAction + Category = 'Debug Control' + Caption = '&Start Debugging' + ImageIndex = 44 + ShortCut = 116 + OnExecute = actDebugStartDebuggerExecute + OnUpdate = actDebugStartDebuggerUpdate + end + object actDebugStopDebugger: TAction + Category = 'Debug Control' + Caption = 'Stop Debugger' + ImageIndex = 45 + ShortCut = 8308 + OnExecute = actDebugStopDebuggerExecute + OnUpdate = actDebugStopDebuggerUpdate + end + object actDebugSetClearBreakpoint: TAction + Category = 'Debug Control' + Caption = 'Set/Clear &Breakpoint' + ImageIndex = 43 + ShortCut = 120 + OnExecute = actDebugSetClearBreakpointExecute + OnUpdate = actDebugSetClearBreakpointUpdate + end + object actDebugSingleStepMode: TAction + Category = 'Debug Action' + Caption = 'Single Step &Mode' + ImageIndex = 46 + OnExecute = actDebugSingleStepModeExecute + OnUpdate = actDebugSingleStepModeUpdate + end + object actDebugStepForward: TAction + Category = 'Debug Action' + Caption = 'Step &Forward' + ImageIndex = 47 + OnExecute = actDebugStepForwardExecute + OnUpdate = actDebugStepForwardUpdate + end + object actDebugRun: TAction + Category = 'Debug Action' + Caption = '&Run' + ImageIndex = 48 + OnExecute = actDebugRunExecute + OnUpdate = actDebugRunUpdate + end + object actDebugSelectSystemKeyboard: TAction + Category = 'Debug Control' + Caption = 'Select System &Keyboard...' + ImageIndex = 49 + Visible = False + OnExecute = actDebugSelectSystemKeyboardExecute + OnUpdate = actDebugSelectSystemKeyboardUpdate + end + object actDebugANSITestMode: TAction + Category = 'Debug Control' + Caption = '&ANSI Test Mode' + end + object actDebugViewElements: TAction + Category = 'Debug Control' + Caption = '&Elements' + ImageIndex = 50 + OnExecute = actDebugViewElementsExecute + OnUpdate = actDebugViewElementsUpdate + end + object actDebugViewCallStack: TAction + Category = 'Debug Control' + Caption = '&Call Stack' + ImageIndex = 51 + OnExecute = actDebugViewCallStackExecute + OnUpdate = actDebugViewCallStackUpdate + end + object actDebugViewDeadkeys: TAction + Category = 'Debug Control' + Caption = '&Deadkeys' + ImageIndex = 52 + OnExecute = actDebugViewDeadkeysExecute + OnUpdate = actDebugViewDeadkeysUpdate + end + object actDebugViewRegressionTesting: TAction + Category = 'Debug Control' + Caption = '&Regression Testing' + OnExecute = actDebugViewRegressionTestingExecute + OnUpdate = actDebugViewRegressionTestingUpdate + end + object actDebugTestMode: TAction + Category = 'Debug Control' + Caption = '&Test Mode' + GroupIndex = 1 + OnExecute = actDebugTestModeExecute + OnUpdate = actDebugTestModeUpdate + end + object actDebugDebuggerMode: TAction + Category = 'Debug Control' + Caption = '&Debugger Mode' + GroupIndex = 2 + OnExecute = actDebugDebuggerModeExecute + OnUpdate = actDebugDebuggerModeUpdate + end + object actDebugPause: TAction + Category = 'Debug Action' + Caption = '&Pause' + ImageIndex = 57 + OnExecute = actDebugPauseExecute + OnUpdate = actDebugPauseUpdate + end + object actDebugViewFont: TAction + Category = 'Debug Control' + Caption = '&Font...' + OnExecute = actDebugViewFontExecute + OnUpdate = actDebugViewFontUpdate + end + object actDebugViewDefaultFont: TAction + Category = 'Debug Control' + Caption = 'Use Editor &Character Font' + OnExecute = actDebugViewDefaultFontExecute + OnUpdate = actDebugViewDefaultFontUpdate + end + object actDebugViewState: TAction + Category = 'Debug Control' + Caption = '&State' + OnExecute = actDebugViewStateExecute + OnUpdate = actDebugViewStateUpdate + end + object actDebugSwitchToDebuggerWindow: TAction + Category = 'Debug Control' + Caption = 'Switch to debugger' + ShortCut = 117 + OnExecute = actDebugSwitchToDebuggerWindowExecute + OnUpdate = actDebugSwitchToDebuggerWindowUpdate + end + end + object dlgFont: TFontDialog + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + Left = 256 + Top = 73 + end +end diff --git a/developer/src/tike/actions/dmActionsDebugger.pas b/developer/src/tike/actions/dmActionsDebugger.pas new file mode 100644 index 00000000000..bd0b3730ec4 --- /dev/null +++ b/developer/src/tike/actions/dmActionsDebugger.pas @@ -0,0 +1,428 @@ +(* + Name: dmActionsKeyboardEditor + Copyright: Copyright (C) SIL International. + Documentation: + Description: + Create Date: 23 Aug 2006 + + Modified Date: 4 May 2015 + Authors: mcdurdin + Related Files: + Dependencies: + + Bugs: + Todo: + Notes: + History: 23 Aug 2006 - mcdurdin - Initial version + 14 Sep 2006 - mcdurdin - Add debugger actions + 28 Sep 2006 - mcdurdin - Added Test Keyboard menu item + 06 Oct 2006 - mcdurdin - Add Test Keyman Web keyboard + 04 Dec 2006 - mcdurdin - Implement all debug actions + 04 Dec 2006 - mcdurdin - Localize + 04 Dec 2006 - mcdurdin - Add keyboard upload + 22 Jan 2007 - mcdurdin - Reset debugger before compiling + 23 Aug 2007 - mcdurdin - I962 - Fix crash when uploading a keyboard and pressing Cancel + 12 Oct 2007 - mcdurdin - I654 - handle error when installing or uninstalling an invalid keyboard file + 16 Jan 2009 - mcdurdin - Add keyboard font helper command (incomplete) + 26 Jul 2010 - mcdurdin - I2468 - KeymanWeb Pack elimination, part of standard build + 17 Dec 2010 - mcdurdin - I2595 - Remove GnuGetText + 18 May 2012 - mcdurdin - I3306 - V9.0 - Remove TntControls + Win9x support + 18 May 2012 - mcdurdin - I3323 - V9.0 - Change from Plus-MemoU to Plus-Memo + 04 Dec 2013 - mcdurdin - I3655 - V9.0 - Keyboard debugger does not appear to function in 9.0.419.0 + 21 Feb 2014 - mcdurdin - I4057 - V9.0 - Keyman Developer Keyboard Font dialog helpful to reduce font confusion + 04 Nov 2014 - mcdurdin - I4504 - V9.0 - Consolidate the compile action into single command + 04 May 2015 - mcdurdin - I4686 - V9.0 - Refactor compile into project file action + 04 May 2015 - mcdurdin - I4687 - V9.0 - Split project UI actions into separate classes + +*) +unit dmActionsDebugger; // I3306 // I3323 + +interface + +uses + SysUtils, + Classes, + ActnList, + UfrmSelectSystemKeyboard, + ImgList, + Controls, + Dialogs, + System.Actions; + +type + TmodActionsDebugger = class(TDataModule) + actionsDebug: TActionList; + actDebugStartDebugger: TAction; + actDebugSetClearBreakpoint: TAction; + actDebugStopDebugger: TAction; + actDebugSingleStepMode: TAction; + actDebugStepForward: TAction; + actDebugRun: TAction; + actDebugSelectSystemKeyboard: TAction; + actDebugANSITestMode: TAction; + actDebugViewElements: TAction; + actDebugViewCallStack: TAction; + actDebugViewDeadkeys: TAction; + actDebugViewRegressionTesting: TAction; + actDebugTestMode: TAction; + actDebugDebuggerMode: TAction; + actDebugPause: TAction; + actDebugViewFont: TAction; + actDebugViewDefaultFont: TAction; + dlgFont: TFontDialog; + actDebugViewState: TAction; + actDebugSwitchToDebuggerWindow: TAction; + procedure actionsKeyboardEditorUpdate(Action: TBasicAction; + var Handled: Boolean); + procedure actDebugViewElementsExecute(Sender: TObject); + procedure actDebugSetClearBreakpointExecute(Sender: TObject); + procedure actDebugSetClearBreakpointUpdate(Sender: TObject); + procedure actDebugStartDebuggerExecute(Sender: TObject); + procedure actDebugStartDebuggerUpdate(Sender: TObject); + procedure actDebugStopDebuggerExecute(Sender: TObject); + procedure actDebugStopDebuggerUpdate(Sender: TObject); + procedure actDebugSingleStepModeUpdate(Sender: TObject); + procedure actDebugSingleStepModeExecute(Sender: TObject); + procedure actDebugStepForwardUpdate(Sender: TObject); + procedure actDebugStepForwardExecute(Sender: TObject); + procedure actDebugRunUpdate(Sender: TObject); + procedure actDebugRunExecute(Sender: TObject); + procedure actDebugSelectSystemKeyboardExecute(Sender: TObject); + procedure actDebugDebuggerModeExecute(Sender: TObject); + procedure actDebugTestModeExecute(Sender: TObject); + procedure actDebugTestModeUpdate(Sender: TObject); + procedure actDebugDebuggerModeUpdate(Sender: TObject); + procedure actDebugPauseUpdate(Sender: TObject); + procedure actDebugPauseExecute(Sender: TObject); + procedure actDebugSelectSystemKeyboardUpdate(Sender: TObject); + procedure actDebugViewDefaultFontExecute(Sender: TObject); + procedure actDebugViewDefaultFontUpdate(Sender: TObject); + procedure actDebugViewFontExecute(Sender: TObject); + procedure actDebugViewFontUpdate(Sender: TObject); + procedure actDebugViewCallStackExecute(Sender: TObject); + procedure actDebugViewDeadkeysExecute(Sender: TObject); + procedure actDebugViewRegressionTestingExecute(Sender: TObject); + procedure actDebugViewElementsUpdate(Sender: TObject); + procedure actDebugViewCallStackUpdate(Sender: TObject); + procedure actDebugViewDeadkeysUpdate(Sender: TObject); + procedure actDebugViewRegressionTestingUpdate(Sender: TObject); + procedure actDebugViewStateExecute(Sender: TObject); + procedure actDebugViewStateUpdate(Sender: TObject); + procedure actDebugSwitchToDebuggerWindowUpdate(Sender: TObject); + procedure actDebugSwitchToDebuggerWindowExecute(Sender: TObject); + private + function IsDebuggerVisible: Boolean; + function IsDebuggerInTestMode: Boolean; + { Private declarations } + public + { Public declarations } + procedure SelectDebugSystemKeyboard(k: TSystemKeyboardItem); + end; + +var + modActionsDebugger: TmodActionsDebugger; + +implementation + +uses + Vcl.Forms, + Vcl.Menus, + System.Win.ComObj, + Winapi.Windows, + + KMDActions, + KMDActionInterfaces, + Keyman.System.Debug.DebugUIStatus, + Keyman.Developer.System.Project.kmnProjectFile, + Keyman.Developer.UI.Project.kmnProjectFileUI, + UfrmKeymanWizard, + UfrmDebug, + UfrmDebugStatus, + UfrmMain; + +{$R *.dfm} + +function ActiveKmnKeyboardEditor: TfrmKeymanWizard; +begin + if Assigned(frmKeymanDeveloper.ActiveChild) and (frmKeymanDeveloper.ActiveChild is TfrmKeymanWizard) + then Result := frmKeymanDeveloper.ActiveChild as TfrmKeymanWizard + else Result := nil; +end; + +function ActiveKmnKeyboardProjectFile: TkmnProjectFile; +begin + Result := ActiveKmnKeyboardEditor.ProjectFile as TkmnProjectFile; +end; + +function ActiveMemo: IKMDTextEditorActions; +begin + Result := GetTextEditorController(Screen.ActiveControl); +end; + +procedure TmodActionsDebugger.actionsKeyboardEditorUpdate(Action: TBasicAction; var Handled: Boolean); +begin + with Action as TAction do + begin + if not Assigned(Action.OnUpdate) then + begin + Enabled := ActiveKmnKeyboardEditor <> nil; + if not Enabled then Handled := True; + end; + end; +end; + +{ ---- Debug Menu ---- } + +procedure TmodActionsDebugger.actDebugDebuggerModeExecute(Sender: TObject); +begin + if ActiveKmnKeyboardEditor.DebugForm.UIStatus = duiTest then + ActiveKmnKeyboardEditor.DebugForm.UIStatus := duiReadyForInput; +end; + +procedure TmodActionsDebugger.actDebugDebuggerModeUpdate(Sender: TObject); +begin + actDebugDebuggerMode.Checked := (ActiveKmnKeyboardEditor <> nil) and (ActiveKmnKeyboardEditor.DebugForm.UIStatus <> duiTest); +end; + +procedure TmodActionsDebugger.actDebugPauseExecute(Sender: TObject); +begin + if ActiveKmnKeyboardEditor.DebugForm.UIStatus = duiPaused + then ActiveKmnKeyboardEditor.DebugForm.Unpause + else ActiveKmnKeyboardEditor.DebugForm.Pause; +end; + +procedure TmodActionsDebugger.actDebugPauseUpdate(Sender: TObject); +begin + actDebugPause.Enabled := + (ActiveKmnKeyboardEditor <> nil) and + IsDebuggerVisible and + not IsDebuggerInTestMode and + (ActiveKmnKeyboardEditor.DebugForm.UIStatus in [duiPaused, duiFocusedForInput, duiReadyForInput]); + + if actDebugPause.Enabled + then actDebugPause.Checked := ActiveKmnKeyboardEditor.DebugForm.UIStatus = duiPaused + else actDebugPause.Checked := False; +end; + +procedure TmodActionsDebugger.actDebugRunExecute(Sender: TObject); +begin + ActiveKmnKeyboardEditor.DebugForm.Run; +end; + +procedure TmodActionsDebugger.actDebugRunUpdate(Sender: TObject); +begin + actDebugRun.Enabled := IsDebuggerVisible and not IsDebuggerInTestMode and + (ActiveKmnKeyboardEditor.DebugForm.UIStatus = duiDebugging); +end; + +procedure TmodActionsDebugger.actDebugSelectSystemKeyboardExecute(Sender: TObject); +var + FKeyboardID: string; +begin + if SelectSystemKeyboard(frmKeymanDeveloper, FKeyboardID) then + begin + // TODO: this is disabled? + //ActiveKmnKeyboardEditor.DebugForm.SetSystemKeyboardID(FKeyboardID); // I3655 + end; +end; + +procedure TmodActionsDebugger.actDebugSelectSystemKeyboardUpdate(Sender: TObject); +begin + actDebugSelectSystemKeyboard.Enabled := IsDebuggerVisible; +end; + +procedure TmodActionsDebugger.actDebugSetClearBreakpointExecute(Sender: TObject); +begin + if ActiveKmnKeyboardEditor.DebugForm.IsBreakPointLine(ActiveMemo.SelectedRow) + then ActiveKmnKeyboardEditor.DebugForm.ClearBreakpoint(ActiveMemo.SelectedRow) + else ActiveKmnKeyboardEditor.DebugForm.SetBreakpoint(ActiveMemo.SelectedRow); +end; + +procedure TmodActionsDebugger.actDebugSetClearBreakpointUpdate(Sender: TObject); +begin + if (ActiveKmnKeyboardEditor <> nil) and (ActiveMemo <> nil) and Assigned(ActiveKmnKeyboardEditor.DebugForm) then + begin + actDebugSetClearBreakpoint.Enabled := True; + actDebugSetClearBreakpoint.Visible := True; + if ActiveKmnKeyboardEditor.DebugForm.IsBreakPointLine(ActiveMemo.SelectedRow) + then actDebugSetClearBreakpoint.Caption := 'Clear &Breakpoint' + else actDebugSetClearBreakpoint.Caption := 'Set &Breakpoint'; + end + else + begin + actDebugSetClearBreakpoint.Enabled := False; + actDebugSetClearBreakpoint.Visible := False; + end; +end; + +procedure TmodActionsDebugger.actDebugSingleStepModeExecute( + Sender: TObject); +begin + ActiveKmnKeyboardEditor.DebugForm.SingleStepMode := not ActiveKmnKeyboardEditor.DebugForm.SingleStepMode; +end; + +procedure TmodActionsDebugger.actDebugSingleStepModeUpdate(Sender: TObject); +begin + actDebugSingleStepMode.Enabled := IsDebuggerVisible and not IsDebuggerInTestMode; + if actDebugSingleStepMode.Enabled + then actDebugSingleStepMode.Checked := ActiveKmnKeyboardEditor.DebugForm.SingleStepMode + else actDebugSingleStepMode.Checked := False; +end; + +procedure TmodActionsDebugger.actDebugStartDebuggerExecute(Sender: TObject); +begin + ActiveKmnKeyboardEditor.StartDebugging; +end; + +procedure TmodActionsDebugger.actDebugStartDebuggerUpdate(Sender: TObject); +begin + actDebugStartDebugger.Enabled := (ActiveKmnKeyboardEditor <> nil) and not ActiveKmnKeyboardEditor.IsDebugVisible; +end; + +procedure TmodActionsDebugger.actDebugStepForwardExecute(Sender: TObject); +begin + ActiveKmnKeyboardEditor.DebugForm.StepForward; +end; + +procedure TmodActionsDebugger.actDebugStepForwardUpdate(Sender: TObject); +begin + actDebugStepForward.Enabled := IsDebuggerVisible and not IsDebuggerInTestMode and + (ActiveKmnKeyboardEditor.DebugForm.UIStatus = duiDebugging); +end; + +procedure TmodActionsDebugger.actDebugStopDebuggerExecute( + Sender: TObject); +begin + ActiveKmnKeyboardEditor.StopDebugging; +end; + +procedure TmodActionsDebugger.actDebugStopDebuggerUpdate(Sender: TObject); +begin + actDebugStopDebugger.Enabled := (ActiveKmnKeyboardEditor <> nil) and ActiveKmnKeyboardEditor.IsDebugVisible; +end; + +procedure TmodActionsDebugger.actDebugSwitchToDebuggerWindowExecute( + Sender: TObject); +begin + ActiveKmnKeyboardEditor.DebugForm.SetFocus; +end; + +procedure TmodActionsDebugger.actDebugSwitchToDebuggerWindowUpdate( + Sender: TObject); +begin + actDebugSwitchToDebuggerWindow.Enabled := (ActiveKmnKeyboardEditor <> nil) and ActiveKmnKeyboardEditor.IsDebugVisible and + ((Screen.ActiveControl = nil) or (Screen.ActiveControl.Owner <> ActiveKmnKeyboardEditor.DebugForm)); +end; + +procedure TmodActionsDebugger.actDebugTestModeExecute(Sender: TObject); +begin + ActiveKmnKeyboardEditor.DebugForm.UIStatus := duiTest; +end; + +procedure TmodActionsDebugger.actDebugTestModeUpdate(Sender: TObject); +begin + actDebugTestMode.Enabled := (ActiveKmnKeyboardEditor <> nil); + actDebugTestMode.Checked := actDebugTestMode.Enabled and (ActiveKmnKeyboardEditor.DebugForm.UIStatus = duiTest); +end; + +procedure TmodActionsDebugger.actDebugViewCallStackExecute(Sender: TObject); +begin + ActiveKmnKeyboardEditor.DebugStatusForm.Visible := True; + ActiveKmnKeyboardEditor.DebugStatusForm.pagesDebug.ActivePage := ActiveKmnKeyboardEditor.DebugStatusForm.tabDebugCallStack; +end; + +procedure TmodActionsDebugger.actDebugViewCallStackUpdate( + Sender: TObject); +begin + actDebugViewCallStack.Enabled := (ActiveKmnKeyboardEditor <> nil) and ActiveKmnKeyboardEditor.IsDebugVisible; +end; + +procedure TmodActionsDebugger.actDebugViewDeadkeysExecute(Sender: TObject); +begin + ActiveKmnKeyboardEditor.DebugStatusForm.Visible := True; + ActiveKmnKeyboardEditor.DebugStatusForm.pagesDebug.ActivePage := ActiveKmnKeyboardEditor.DebugStatusForm.tabDebugDeadkeys; +end; + +procedure TmodActionsDebugger.actDebugViewDeadkeysUpdate(Sender: TObject); +begin + actDebugViewDeadkeys.Enabled := (ActiveKmnKeyboardEditor <> nil) and ActiveKmnKeyboardEditor.IsDebugVisible; +end; + +procedure TmodActionsDebugger.actDebugViewDefaultFontExecute(Sender: TObject); +begin + ActiveKmnKeyboardEditor.DebugForm.UpdateFont(nil); +end; + +procedure TmodActionsDebugger.actDebugViewDefaultFontUpdate(Sender: TObject); +begin + actDebugViewDefaultFont.Enabled := IsDebuggerVisible; + actDebugViewDefaultFont.Checked := actDebugViewDefaultFont.Enabled and + ActiveKmnKeyboardEditor.DebugForm.DefaultFont; +end; + +procedure TmodActionsDebugger.actDebugViewFontExecute(Sender: TObject); +begin + dlgFont.Font := ActiveKmnKeyboardEditor.DebugForm.memo.Font; + if dlgFont.Execute then + ActiveKmnKeyboardEditor.DebugForm.UpdateFont(dlgFont.Font); +end; + +procedure TmodActionsDebugger.actDebugViewFontUpdate(Sender: TObject); +begin + actDebugViewFont.Enabled := IsDebuggerVisible; + actDebugViewFont.Checked := actDebugViewFont.Enabled and not ActiveKmnKeyboardEditor.DebugForm.DefaultFont; +end; + +procedure TmodActionsDebugger.actDebugViewRegressionTestingExecute(Sender: TObject); +begin + ActiveKmnKeyboardEditor.DebugStatusForm.Visible := True; + ActiveKmnKeyboardEditor.DebugStatusForm.pagesDebug.ActivePage := ActiveKmnKeyboardEditor.DebugStatusForm.tabDebugRegressionTesting; +end; + +procedure TmodActionsDebugger.actDebugViewRegressionTestingUpdate(Sender: TObject); +begin + actDebugViewRegressionTesting.Enabled := (ActiveKmnKeyboardEditor <> nil) and ActiveKmnKeyboardEditor.IsDebugVisible; +end; + +procedure TmodActionsDebugger.actDebugViewStateExecute(Sender: TObject); +begin + ActiveKmnKeyboardEditor.DebugStatusForm.Visible := True; + ActiveKmnKeyboardEditor.DebugStatusForm.pagesDebug.ActivePage := ActiveKmnKeyboardEditor.DebugStatusForm.tabDebugKey; +end; + +procedure TmodActionsDebugger.actDebugViewStateUpdate(Sender: TObject); +begin + actDebugViewState.Enabled := (ActiveKmnKeyboardEditor <> nil) and ActiveKmnKeyboardEditor.IsDebugVisible; +end; + +procedure TmodActionsDebugger.actDebugViewElementsExecute(Sender: TObject); +begin + ActiveKmnKeyboardEditor.DebugStatusForm.Visible := True; + ActiveKmnKeyboardEditor.DebugStatusForm.pagesDebug.ActivePage := ActiveKmnKeyboardEditor.DebugStatusForm.tabDebugStores; +end; + +procedure TmodActionsDebugger.actDebugViewElementsUpdate(Sender: TObject); +begin + actDebugViewElements.Enabled := (ActiveKmnKeyboardEditor <> nil) and ActiveKmnKeyboardEditor.IsDebugVisible; +end; + +{ ---- Keyboard Menu ---- } + +function TmodActionsDebugger.IsDebuggerInTestMode: Boolean; +begin + Result := (ActiveKmnKeyboardEditor <> nil) and (ActiveKmnKeyboardEditor.DebugForm.UIStatus = duiTest); +end; + +function TmodActionsDebugger.IsDebuggerVisible: Boolean; +begin + Result := (ActiveKmnKeyboardEditor <> nil) and ActiveKmnKeyboardEditor.IsDebugVisible; +end; + +procedure TmodActionsDebugger.SelectDebugSystemKeyboard(k: TSystemKeyboardItem); +begin +//TODO: #1225, #1074 (note both menu item and toolbar combo are hidden while this is not working) +// if IsDebuggerVisible then // I3655 +// ActiveKmnKeyboardEditor.DebugForm.SetSystemKeyboardID(k.KeyboardID); +end; + +end. diff --git a/developer/src/tike/actions/dmActionsKeyboardEditor.dfm b/developer/src/tike/actions/dmActionsKeyboardEditor.dfm index 3a2c010099c..be0f4097d5a 100644 --- a/developer/src/tike/actions/dmActionsKeyboardEditor.dfm +++ b/developer/src/tike/actions/dmActionsKeyboardEditor.dfm @@ -4,7 +4,6 @@ object modActionsKeyboardEditor: TmodActionsKeyboardEditor Width = 408 object actionsKeyboardEditor: TActionList Images = frmKeymanDeveloper.lstImages - OnUpdate = actionsKeyboardEditorUpdate Left = 60 Top = 24 object actKeyboardCompile: TAction @@ -27,176 +26,38 @@ object modActionsKeyboardEditor: TmodActionsKeyboardEditor ImageIndex = 41 ShortCut = 16504 OnExecute = actKeyboardInstallExecute + OnUpdate = actKeyboardInstallUpdate end object actKeyboardUninstall: TAction Category = 'Keyboard' Caption = '&Uninstall...' ImageIndex = 42 OnExecute = actKeyboardUninstallExecute + OnUpdate = actKeyboardUninstallUpdate end object actKeyboardTest: TAction Category = 'Keyboard' Caption = '&Test Keyboard' OnExecute = actKeyboardTestExecute + OnUpdate = actKeyboardTestUpdate end object actKeyboardTestKeymanWeb: TAction Category = 'Keyboard' Caption = 'Test &Keyboard on web' OnExecute = actKeyboardTestKeymanWebExecute + OnUpdate = actKeyboardTestKeymanWebUpdate end object actKeyboardFontHelper: TAction Category = 'Keyboard' Caption = 'Font &Helper...' OnExecute = actKeyboardFontHelperExecute + OnUpdate = actKeyboardFontHelperUpdate end object actKeyboardFonts: TAction Category = 'Keyboard' Caption = '&Fonts...' OnExecute = actKeyboardFontsExecute + OnUpdate = actKeyboardFontsUpdate end end - object actionsDebug: TActionList - Images = frmKeymanDeveloper.lstImages - Left = 60 - Top = 88 - object actDebugStartDebugger: TAction - Category = 'Debug Control' - Caption = '&Start Debugging' - ImageIndex = 44 - ShortCut = 116 - OnExecute = actDebugStartDebuggerExecute - OnUpdate = actDebugStartDebuggerUpdate - end - object actDebugStopDebugger: TAction - Category = 'Debug Control' - Caption = 'Stop Debugger' - ImageIndex = 45 - ShortCut = 8308 - OnExecute = actDebugStopDebuggerExecute - OnUpdate = actDebugStopDebuggerUpdate - end - object actDebugSetClearBreakpoint: TAction - Category = 'Debug Control' - Caption = 'Set/Clear &Breakpoint' - ImageIndex = 43 - ShortCut = 120 - OnExecute = actDebugSetClearBreakpointExecute - OnUpdate = actDebugSetClearBreakpointUpdate - end - object actDebugSingleStepMode: TAction - Category = 'Debug Action' - Caption = 'Single Step &Mode' - ImageIndex = 46 - OnExecute = actDebugSingleStepModeExecute - OnUpdate = actDebugSingleStepModeUpdate - end - object actDebugStepForward: TAction - Category = 'Debug Action' - Caption = 'Step &Forward' - ImageIndex = 47 - OnExecute = actDebugStepForwardExecute - OnUpdate = actDebugStepForwardUpdate - end - object actDebugRun: TAction - Category = 'Debug Action' - Caption = '&Run' - ImageIndex = 48 - OnExecute = actDebugRunExecute - OnUpdate = actDebugRunUpdate - end - object actDebugSelectSystemKeyboard: TAction - Category = 'Debug Control' - Caption = 'Select System &Keyboard...' - ImageIndex = 49 - Visible = False - OnExecute = actDebugSelectSystemKeyboardExecute - OnUpdate = actDebugSelectSystemKeyboardUpdate - end - object actDebugANSITestMode: TAction - Category = 'Debug Control' - Caption = '&ANSI Test Mode' - end - object actDebugViewElements: TAction - Category = 'Debug Control' - Caption = '&Elements' - ImageIndex = 50 - OnExecute = actDebugViewElementsExecute - OnUpdate = actDebugViewElementsUpdate - end - object actDebugViewCallStack: TAction - Category = 'Debug Control' - Caption = '&Call Stack' - ImageIndex = 51 - OnExecute = actDebugViewCallStackExecute - OnUpdate = actDebugViewCallStackUpdate - end - object actDebugViewDeadkeys: TAction - Category = 'Debug Control' - Caption = '&Deadkeys' - ImageIndex = 52 - OnExecute = actDebugViewDeadkeysExecute - OnUpdate = actDebugViewDeadkeysUpdate - end - object actDebugViewRegressionTesting: TAction - Category = 'Debug Control' - Caption = '&Regression Testing' - OnExecute = actDebugViewRegressionTestingExecute - OnUpdate = actDebugViewRegressionTestingUpdate - end - object actDebugTestMode: TAction - Category = 'Debug Control' - Caption = '&Test Mode' - GroupIndex = 1 - OnExecute = actDebugTestModeExecute - OnUpdate = actDebugTestModeUpdate - end - object actDebugDebuggerMode: TAction - Category = 'Debug Control' - Caption = '&Debugger Mode' - GroupIndex = 2 - OnExecute = actDebugDebuggerModeExecute - OnUpdate = actDebugDebuggerModeUpdate - end - object actDebugPause: TAction - Category = 'Debug Action' - Caption = '&Pause' - ImageIndex = 57 - OnExecute = actDebugPauseExecute - OnUpdate = actDebugPauseUpdate - end - object actDebugViewFont: TAction - Category = 'Debug Control' - Caption = '&Font...' - OnExecute = actDebugViewFontExecute - OnUpdate = actDebugViewFontUpdate - end - object actDebugViewDefaultFont: TAction - Category = 'Debug Control' - Caption = 'Use Editor &Character Font' - OnExecute = actDebugViewDefaultFontExecute - OnUpdate = actDebugViewDefaultFontUpdate - end - object actDebugViewState: TAction - Category = 'Debug Control' - Caption = '&State' - OnExecute = actDebugViewStateExecute - OnUpdate = actDebugViewStateUpdate - end - object actDebugSwitchToDebuggerWindow: TAction - Category = 'Debug Control' - Caption = 'Switch to debugger' - ShortCut = 117 - OnExecute = actDebugSwitchToDebuggerWindowExecute - OnUpdate = actDebugSwitchToDebuggerWindowUpdate - end - end - object dlgFont: TFontDialog - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'MS Sans Serif' - Font.Style = [] - Left = 256 - Top = 73 - end end diff --git a/developer/src/tike/actions/dmActionsKeyboardEditor.pas b/developer/src/tike/actions/dmActionsKeyboardEditor.pas index 4f6434d6937..33bcc399a95 100644 --- a/developer/src/tike/actions/dmActionsKeyboardEditor.pas +++ b/developer/src/tike/actions/dmActionsKeyboardEditor.pas @@ -40,8 +40,14 @@ interface uses - SysUtils, Classes, ActnList, - UfrmSelectSystemKeyboard, ImgList, Controls, Dialogs, System.Actions; + SysUtils, + Classes, + ActnList, + UfrmSelectSystemKeyboard, + ImgList, + Controls, + Dialogs, + System.Actions; type TmodActionsKeyboardEditor = class(TDataModule) @@ -50,86 +56,26 @@ TmodActionsKeyboardEditor = class(TDataModule) actKeyboardIncludeDebugInformation: TAction; actKeyboardInstall: TAction; actKeyboardUninstall: TAction; - actionsDebug: TActionList; - actDebugStartDebugger: TAction; - actDebugSetClearBreakpoint: TAction; - actDebugStopDebugger: TAction; - actDebugSingleStepMode: TAction; - actDebugStepForward: TAction; - actDebugRun: TAction; - actDebugSelectSystemKeyboard: TAction; - actDebugANSITestMode: TAction; - actDebugViewElements: TAction; - actDebugViewCallStack: TAction; - actDebugViewDeadkeys: TAction; - actDebugViewRegressionTesting: TAction; - actDebugTestMode: TAction; - actDebugDebuggerMode: TAction; - actDebugPause: TAction; - actDebugViewFont: TAction; - actDebugViewDefaultFont: TAction; - dlgFont: TFontDialog; actKeyboardTest: TAction; actKeyboardTestKeymanWeb: TAction; - actDebugViewState: TAction; actKeyboardFontHelper: TAction; actKeyboardFonts: TAction; - actDebugSwitchToDebuggerWindow: TAction; procedure actKeyboardCompileExecute(Sender: TObject); - procedure actionsKeyboardEditorUpdate(Action: TBasicAction; - var Handled: Boolean); procedure actKeyboardIncludeDebugInformationExecute(Sender: TObject); - procedure actDebugViewElementsExecute(Sender: TObject); - procedure actDebugSetClearBreakpointExecute(Sender: TObject); - procedure actDebugSetClearBreakpointUpdate(Sender: TObject); - procedure actDebugStartDebuggerExecute(Sender: TObject); - procedure actDebugStartDebuggerUpdate(Sender: TObject); - procedure actDebugStopDebuggerExecute(Sender: TObject); - procedure actDebugStopDebuggerUpdate(Sender: TObject); procedure actKeyboardInstallExecute(Sender: TObject); procedure actKeyboardUninstallExecute(Sender: TObject); procedure actKeyboardIncludeDebugInformationUpdate(Sender: TObject); - procedure actDebugSingleStepModeUpdate(Sender: TObject); - procedure actDebugSingleStepModeExecute(Sender: TObject); - procedure actDebugStepForwardUpdate(Sender: TObject); - procedure actDebugStepForwardExecute(Sender: TObject); - procedure actDebugRunUpdate(Sender: TObject); - procedure actDebugRunExecute(Sender: TObject); - procedure actDebugSelectSystemKeyboardExecute(Sender: TObject); - procedure actDebugDebuggerModeExecute(Sender: TObject); - procedure actDebugTestModeExecute(Sender: TObject); - procedure actDebugTestModeUpdate(Sender: TObject); - procedure actDebugDebuggerModeUpdate(Sender: TObject); - procedure actDebugPauseUpdate(Sender: TObject); - procedure actDebugPauseExecute(Sender: TObject); - procedure actDebugSelectSystemKeyboardUpdate(Sender: TObject); - procedure actDebugViewDefaultFontExecute(Sender: TObject); - procedure actDebugViewDefaultFontUpdate(Sender: TObject); - procedure actDebugViewFontExecute(Sender: TObject); - procedure actDebugViewFontUpdate(Sender: TObject); procedure actKeyboardTestExecute(Sender: TObject); procedure actKeyboardTestKeymanWebExecute(Sender: TObject); - procedure actDebugViewCallStackExecute(Sender: TObject); - procedure actDebugViewDeadkeysExecute(Sender: TObject); - procedure actDebugViewRegressionTestingExecute(Sender: TObject); - procedure actDebugViewElementsUpdate(Sender: TObject); - procedure actDebugViewCallStackUpdate(Sender: TObject); - procedure actDebugViewDeadkeysUpdate(Sender: TObject); - procedure actDebugViewRegressionTestingUpdate(Sender: TObject); - procedure actDebugViewStateExecute(Sender: TObject); - procedure actDebugViewStateUpdate(Sender: TObject); procedure actKeyboardFontHelperExecute(Sender: TObject); procedure actKeyboardFontsExecute(Sender: TObject); procedure actKeyboardCompileUpdate(Sender: TObject); - procedure actDebugSwitchToDebuggerWindowUpdate(Sender: TObject); - procedure actDebugSwitchToDebuggerWindowExecute(Sender: TObject); - private - function IsDebuggerVisible: Boolean; - function IsDebuggerInTestMode: Boolean; - { Private declarations } - public - { Public declarations } - procedure SelectDebugSystemKeyboard(k: TSystemKeyboardItem); + procedure actKeyboardInstallUpdate(Sender: TObject); + procedure actKeyboardUninstallUpdate(Sender: TObject); + procedure actKeyboardTestUpdate(Sender: TObject); + procedure actKeyboardTestKeymanWebUpdate(Sender: TObject); + procedure actKeyboardFontHelperUpdate(Sender: TObject); + procedure actKeyboardFontsUpdate(Sender: TObject); end; var @@ -153,10 +99,10 @@ implementation Keyman.Developer.System.Project.ProjectFile, Keyman.Developer.UI.Project.ProjectFileUI, Keyman.Developer.UI.Project.UfrmProject, + Keyman.Developer.UI.UfrmLdmlKeyboardEditor, + Keyman.Developer.System.Project.xmlLdmlProjectFile, UframeTextEditor, UfrmKeymanWizard, - UfrmDebug, - UfrmDebugStatus, UfrmMessages, UfrmMain, UfrmPackageEditor, @@ -164,7 +110,14 @@ implementation {$R *.dfm} -function ActiveEditor: TfrmKeymanWizard; +function ActiveLdmlKeyboardEditor: TfrmLdmlKeyboardEditor; +begin + if Assigned(frmKeymanDeveloper.ActiveChild) and (frmKeymanDeveloper.ActiveChild is TfrmLdmlKeyboardEditor) + then Result := frmKeymanDeveloper.ActiveChild as TfrmLdmlKeyboardEditor + else Result := nil; +end; + +function ActiveKmnKeyboardEditor: TfrmKeymanWizard; begin if Assigned(frmKeymanDeveloper.ActiveChild) and (frmKeymanDeveloper.ActiveChild is TfrmKeymanWizard) then Result := frmKeymanDeveloper.ActiveChild as TfrmKeymanWizard @@ -178,363 +131,189 @@ function ActivePackageEditor: TfrmPackageEditor; else Result := nil; end; -function ActiveProjectFile: TkmnProjectFile; -begin - Result := ActiveEditor.ProjectFile as TkmnProjectFile; -end; - -function ActivePackageProjectFile: TkpsProjectFile; -begin - Result := ActivePackageEditor.ProjectFile as TkpsProjectFile; -end; - -function ActiveMemo: IKMDTextEditorActions; +function ActiveLdmlKeyboardProjectFile: TxmlLdmlProjectFile; begin - Result := GetTextEditorController(Screen.ActiveControl); + if ActiveLdmlKeyboardEditor = nil + then Result := nil + else Result := ActiveLdmlKeyboardEditor.ProjectFile as TxmlLdmlProjectFile; end; -procedure TmodActionsKeyboardEditor.actionsKeyboardEditorUpdate(Action: TBasicAction; var Handled: Boolean); +function ActiveKmnKeyboardProjectFile: TkmnProjectFile; begin - with Action as TAction do - begin - if not Assigned(Action.OnUpdate) then - begin - Enabled := ActiveEditor <> nil; - if not Enabled then Handled := True; - end; - end; + if ActiveKmnKeyboardEditor = nil + then Result := nil + else Result := ActiveKmnKeyboardEditor.ProjectFile as TkmnProjectFile; end; -{ ---- Debug Menu ---- } - -procedure TmodActionsKeyboardEditor.actDebugDebuggerModeExecute(Sender: TObject); +function ActivePackageProjectFile: TkpsProjectFile; begin - if ActiveEditor.DebugForm.UIStatus = duiTest then - ActiveEditor.DebugForm.UIStatus := duiReadyForInput; + if ActivePackageEditor = nil + then Result := nil + else Result := ActivePackageEditor.ProjectFile as TkpsProjectFile; end; -procedure TmodActionsKeyboardEditor.actDebugDebuggerModeUpdate(Sender: TObject); +function ActiveProjectFileUI: TProjectFileUI; begin - actDebugDebuggerMode.Checked := (ActiveEditor <> nil) and (ActiveEditor.DebugForm.UIStatus <> duiTest); + if ActiveKmnKeyboardProjectFile <> nil then + Result := ActiveKmnKeyboardProjectFile.UI as TProjectFileUI + else if ActiveLdmlKeyboardProjectFile <> nil then + Result := ActiveLdmlKeyboardProjectFile.UI as TProjectFileUI + else if ActivePackageProjectFile <> nil then + Result := ActivePackageProjectFile.UI as TProjectFileUI + else + Result := nil; end; -procedure TmodActionsKeyboardEditor.actDebugPauseExecute(Sender: TObject); -begin - if ActiveEditor.DebugForm.UIStatus = duiPaused - then ActiveEditor.DebugForm.Unpause - else ActiveEditor.DebugForm.Pause; -end; +{ ---- Keyboard Menu ---- } -procedure TmodActionsKeyboardEditor.actDebugPauseUpdate(Sender: TObject); +procedure TmodActionsKeyboardEditor.actKeyboardCompileUpdate(Sender: TObject); begin - actDebugPause.Enabled := - (ActiveEditor <> nil) and - IsDebuggerVisible and - not IsDebuggerInTestMode and - (ActiveEditor.DebugForm.UIStatus in [duiPaused, duiFocusedForInput, duiReadyForInput]); - - if actDebugPause.Enabled - then actDebugPause.Checked := ActiveEditor.DebugForm.UIStatus = duiPaused - else actDebugPause.Checked := False; -end; + // TODO: Split Keyboard menu and package editor functions + actKeyboardCompile.Enabled := + (ActiveKmnKeyboardEditor <> nil) or + (ActiveLdmlKeyboardEditor <> nil) or + (ActivePackageEditor <> nil) or + ((frmKeymanDeveloper.ActiveChild is TfrmProject) and (FGlobalProject <> nil)); -procedure TmodActionsKeyboardEditor.actDebugRunExecute(Sender: TObject); -begin - ActiveEditor.DebugForm.Run; -end; + if actKeyboardCompile.Enabled + then actKeyboardCompile.ShortCut := Vcl.Menus.Shortcut(VK_F7, []) + else actKeyboardCompile.ShortCut := scNone; -procedure TmodActionsKeyboardEditor.actDebugRunUpdate(Sender: TObject); -begin - actDebugRun.Enabled := IsDebuggerVisible and not IsDebuggerInTestMode and - (ActiveEditor.DebugForm.UIStatus = duiDebugging); + // This is a little side-effecty + frmKeymanDeveloper.mnuKeyboard.Visible := True; + frmKeymanDeveloper.mnuDebug.Visible := ActiveKmnKeyboardEditor <> nil; end; -procedure TmodActionsKeyboardEditor.actDebugSelectSystemKeyboardExecute(Sender: TObject); +procedure TmodActionsKeyboardEditor.actKeyboardCompileExecute(Sender: TObject); // I4504 var - FKeyboardID: string; + DebugReset: Boolean; begin - if SelectSystemKeyboard(frmKeymanDeveloper, FKeyboardID) then - begin - //ActiveEditor.DebugForm.SetSystemKeyboardID(FKeyboardID); // I3655 - end; -end; + DebugReset := False; -procedure TmodActionsKeyboardEditor.actDebugSelectSystemKeyboardUpdate(Sender: TObject); -begin - actDebugSelectSystemKeyboard.Enabled := IsDebuggerVisible; -end; + frmMessages.Clear; // I4686 -procedure TmodActionsKeyboardEditor.actDebugSetClearBreakpointExecute(Sender: TObject); -begin - if ActiveEditor.DebugForm.IsBreakPointLine(ActiveMemo.SelectedRow) - then ActiveEditor.DebugForm.ClearBreakpoint(ActiveMemo.SelectedRow) - else ActiveEditor.DebugForm.SetBreakpoint(ActiveMemo.SelectedRow); -end; + if ActiveKmnKeyboardEditor <> nil then + begin + if not ActiveKmnKeyboardEditor.PrepareForBuild(DebugReset) then + Exit; -procedure TmodActionsKeyboardEditor.actDebugSetClearBreakpointUpdate(Sender: TObject); -begin - if (ActiveEditor <> nil) and (ActiveMemo <> nil) and Assigned(ActiveEditor.DebugForm) then + if ActiveProjectFileUI.DoAction(pfaCompile, False) and DebugReset then // I4686 + ActiveKmnKeyboardEditor.StartDebugging; + end + else if ActiveLdmlKeyboardEditor <> nil then begin - actDebugSetClearBreakpoint.Enabled := True; - actDebugSetClearBreakpoint.Visible := True; - if ActiveEditor.DebugForm.IsBreakPointLine(ActiveMemo.SelectedRow) - then actDebugSetClearBreakpoint.Caption := 'Clear &Breakpoint' - else actDebugSetClearBreakpoint.Caption := 'Set &Breakpoint'; + ActiveProjectFileUI.DoAction(pfaCompile, False); end - else + else if ActivePackageEditor <> nil then + begin + ActiveProjectFileUI.DoAction(pfaCompile, False); + end + else if frmKeymanDeveloper.ActiveChild is TfrmProject then begin - actDebugSetClearBreakpoint.Enabled := False; - actDebugSetClearBreakpoint.Visible := False; + (frmKeymanDeveloper.ActiveChild as TfrmProject).CompileAll; end; end; -procedure TmodActionsKeyboardEditor.actDebugSingleStepModeExecute( - Sender: TObject); -begin - ActiveEditor.DebugForm.SingleStepMode := not ActiveEditor.DebugForm.SingleStepMode; -end; - -procedure TmodActionsKeyboardEditor.actDebugSingleStepModeUpdate(Sender: TObject); -begin - actDebugSingleStepMode.Enabled := IsDebuggerVisible and not IsDebuggerInTestMode; - if actDebugSingleStepMode.Enabled - then actDebugSingleStepMode.Checked := ActiveEditor.DebugForm.SingleStepMode - else actDebugSingleStepMode.Checked := False; -end; - -procedure TmodActionsKeyboardEditor.actDebugStartDebuggerExecute(Sender: TObject); -begin - ActiveEditor.StartDebugging; -end; - -procedure TmodActionsKeyboardEditor.actDebugStartDebuggerUpdate(Sender: TObject); -begin - actDebugStartDebugger.Enabled := (ActiveEditor <> nil) and not ActiveEditor.IsDebugVisible; -end; - -procedure TmodActionsKeyboardEditor.actDebugStepForwardExecute(Sender: TObject); -begin - ActiveEditor.DebugForm.StepForward; -end; - -procedure TmodActionsKeyboardEditor.actDebugStepForwardUpdate(Sender: TObject); -begin - actDebugStepForward.Enabled := IsDebuggerVisible and not IsDebuggerInTestMode and - (ActiveEditor.DebugForm.UIStatus = duiDebugging); -end; +//------------------------------------------------------------------------------ -procedure TmodActionsKeyboardEditor.actDebugStopDebuggerExecute( +procedure TmodActionsKeyboardEditor.actKeyboardFontHelperUpdate( Sender: TObject); begin - ActiveEditor.StopDebugging; -end; - -procedure TmodActionsKeyboardEditor.actDebugStopDebuggerUpdate(Sender: TObject); -begin - actDebugStopDebugger.Enabled := (ActiveEditor <> nil) and ActiveEditor.IsDebugVisible; + actKeyboardFontHelper.Enabled := (ActiveKmnKeyboardProjectFile <> nil); end; -procedure TmodActionsKeyboardEditor.actDebugSwitchToDebuggerWindowExecute( +procedure TmodActionsKeyboardEditor.actKeyboardFontHelperExecute( Sender: TObject); begin - ActiveEditor.DebugForm.SetFocus; + ActiveProjectFileUI.DoAction(pfaFontHelper, False) // I4687 end; -procedure TmodActionsKeyboardEditor.actDebugSwitchToDebuggerWindowUpdate( - Sender: TObject); -begin - actDebugSwitchToDebuggerWindow.Enabled := (ActiveEditor <> nil) and ActiveEditor.IsDebugVisible and - ((Screen.ActiveControl = nil) or (Screen.ActiveControl.Owner <> ActiveEditor.DebugForm)); -end; +//------------------------------------------------------------------------------ -procedure TmodActionsKeyboardEditor.actDebugTestModeExecute(Sender: TObject); +procedure TmodActionsKeyboardEditor.actKeyboardFontsUpdate(Sender: TObject); begin - ActiveEditor.DebugForm.UIStatus := duiTest; + actKeyboardFonts.Enabled := (ActiveKmnKeyboardProjectFile <> nil); end; -procedure TmodActionsKeyboardEditor.actDebugTestModeUpdate(Sender: TObject); +procedure TmodActionsKeyboardEditor.actKeyboardFontsExecute(Sender: TObject); // I4057 begin - actDebugTestMode.Enabled := (ActiveEditor <> nil); - actDebugTestMode.Checked := actDebugTestMode.Enabled and (ActiveEditor.DebugForm.UIStatus = duiTest); + ActiveProjectFileUI.DoAction(pfaFontDialog, False); // I4687 end; -procedure TmodActionsKeyboardEditor.actDebugViewCallStackExecute(Sender: TObject); -begin - ActiveEditor.DebugStatusForm.Visible := True; - ActiveEditor.DebugStatusForm.pagesDebug.ActivePage := ActiveEditor.DebugStatusForm.tabDebugCallStack; -end; +//------------------------------------------------------------------------------ -procedure TmodActionsKeyboardEditor.actDebugViewCallStackUpdate( +procedure TmodActionsKeyboardEditor.actKeyboardIncludeDebugInformationUpdate( Sender: TObject); begin - actDebugViewCallStack.Enabled := (ActiveEditor <> nil) and ActiveEditor.IsDebugVisible; -end; - -procedure TmodActionsKeyboardEditor.actDebugViewDeadkeysExecute(Sender: TObject); -begin - ActiveEditor.DebugStatusForm.Visible := True; - ActiveEditor.DebugStatusForm.pagesDebug.ActivePage := ActiveEditor.DebugStatusForm.tabDebugDeadkeys; -end; - -procedure TmodActionsKeyboardEditor.actDebugViewDeadkeysUpdate(Sender: TObject); -begin - actDebugViewDeadkeys.Enabled := (ActiveEditor <> nil) and ActiveEditor.IsDebugVisible; -end; - -procedure TmodActionsKeyboardEditor.actDebugViewDefaultFontExecute(Sender: TObject); -begin - ActiveEditor.DebugForm.UpdateFont(nil); -end; - -procedure TmodActionsKeyboardEditor.actDebugViewDefaultFontUpdate(Sender: TObject); -begin - actDebugViewDefaultFont.Enabled := IsDebuggerVisible; - actDebugViewDefaultFont.Checked := actDebugViewDefaultFont.Enabled and - ActiveEditor.DebugForm.DefaultFont; -end; - -procedure TmodActionsKeyboardEditor.actDebugViewFontExecute(Sender: TObject); -begin - dlgFont.Font := ActiveEditor.DebugForm.memo.Font; - if dlgFont.Execute then - ActiveEditor.DebugForm.UpdateFont(dlgFont.Font); + actKeyboardIncludeDebugInformation.Enabled := ActiveKmnKeyboardEditor <> nil; + if (ActiveKmnKeyboardEditor <> nil) and (ActiveKmnKeyboardProjectFile <> nil) + then actKeyboardIncludeDebugInformation.Checked := (ActiveProjectFileUI as TkmnProjectFileUI).Debug // I4687 + else actKeyboardIncludeDebugInformation.Checked := False; end; -procedure TmodActionsKeyboardEditor.actDebugViewFontUpdate(Sender: TObject); +procedure TmodActionsKeyboardEditor.actKeyboardIncludeDebugInformationExecute(Sender: TObject); begin - actDebugViewFont.Enabled := IsDebuggerVisible; - actDebugViewFont.Checked := actDebugViewFont.Enabled and not ActiveEditor.DebugForm.DefaultFont; + (ActiveProjectFileUI as TkmnProjectFileUI).Debug := not (ActiveProjectFileUI as TkmnProjectFileUI).Debug; // I4687 end; -procedure TmodActionsKeyboardEditor.actDebugViewRegressionTestingExecute(Sender: TObject); -begin - ActiveEditor.DebugStatusForm.Visible := True; - ActiveEditor.DebugStatusForm.pagesDebug.ActivePage := ActiveEditor.DebugStatusForm.tabDebugRegressionTesting; -end; +//------------------------------------------------------------------------------ -procedure TmodActionsKeyboardEditor.actDebugViewRegressionTestingUpdate(Sender: TObject); +procedure TmodActionsKeyboardEditor.actKeyboardInstallUpdate(Sender: TObject); begin - actDebugViewRegressionTesting.Enabled := (ActiveEditor <> nil) and ActiveEditor.IsDebugVisible; + actKeyboardInstall.Enabled := ActiveProjectFileUI <> nil; end; -procedure TmodActionsKeyboardEditor.actDebugViewStateExecute(Sender: TObject); -begin - ActiveEditor.DebugStatusForm.Visible := True; - ActiveEditor.DebugStatusForm.pagesDebug.ActivePage := ActiveEditor.DebugStatusForm.tabDebugKey; -end; - -procedure TmodActionsKeyboardEditor.actDebugViewStateUpdate(Sender: TObject); +procedure TmodActionsKeyboardEditor.actKeyboardInstallExecute(Sender: TObject); begin - actDebugViewState.Enabled := (ActiveEditor <> nil) and ActiveEditor.IsDebugVisible; + try + ActiveProjectFileUI.DoAction(pfaInstall, False); // I4687 + except + on E:EOleException do // I654 + begin + ShowMessage(E.Message); + end; + end; end; -procedure TmodActionsKeyboardEditor.actDebugViewElementsExecute(Sender: TObject); -begin - ActiveEditor.DebugStatusForm.Visible := True; - ActiveEditor.DebugStatusForm.pagesDebug.ActivePage := ActiveEditor.DebugStatusForm.tabDebugStores; -end; +//------------------------------------------------------------------------------ -procedure TmodActionsKeyboardEditor.actDebugViewElementsUpdate(Sender: TObject); +procedure TmodActionsKeyboardEditor.actKeyboardTestUpdate(Sender: TObject); begin - actDebugViewElements.Enabled := (ActiveEditor <> nil) and ActiveEditor.IsDebugVisible; + actKeyboardTest.Enabled := (ActiveKmnKeyboardEditor <> nil); + // TODO: test xml keyboards in editor end; -{ ---- Keyboard Menu ---- } - -procedure TmodActionsKeyboardEditor.actKeyboardCompileExecute(Sender: TObject); // I4504 -var - DebugReset: Boolean; +procedure TmodActionsKeyboardEditor.actKeyboardTestExecute(Sender: TObject); begin - DebugReset := False; - - frmMessages.Clear; // I4686 - - if ActiveEditor <> nil then - begin - if not ActiveEditor.PrepareForBuild(DebugReset) then - Exit; - - if (ActiveProjectFile.UI as TProjectFileUI).DoAction(pfaCompile, False) and DebugReset then // I4686 - ActiveEditor.StartDebugging; - end - else if ActivePackageEditor <> nil then - begin - (ActivePackageProjectFile.UI as TProjectFileUI).DoAction(pfaCompile, False); - end - else if frmKeymanDeveloper.ActiveChild is TfrmProject then - (frmKeymanDeveloper.ActiveChild as TfrmProject).CompileAll; + ActiveKmnKeyboardEditor.DebugForm.UIStatus := duiTest; + ActiveKmnKeyboardEditor.StartDebugging(True); end; -procedure TmodActionsKeyboardEditor.actKeyboardCompileUpdate(Sender: TObject); -begin - // TODO: Split Keyboard menu and package editor functions - actKeyboardCompile.Enabled := - (ActiveEditor <> nil) or - (ActivePackageEditor <> nil) or - ((frmKeymanDeveloper.ActiveChild is TfrmProject) and (FGlobalProject <> nil)); - - if actKeyboardCompile.Enabled - then actKeyboardCompile.ShortCut := Vcl.Menus.Shortcut(VK_F7, []) - else actKeyboardCompile.ShortCut := scNone; - - frmKeymanDeveloper.mnuKeyboard.Visible := True; - frmKeymanDeveloper.mnuDebug.Visible := ActiveEditor <> nil; -end; +//------------------------------------------------------------------------------ -procedure TmodActionsKeyboardEditor.actKeyboardFontHelperExecute( +procedure TmodActionsKeyboardEditor.actKeyboardTestKeymanWebUpdate( Sender: TObject); begin - (ActiveProjectFile.UI as TProjectFileUI).DoAction(pfaFontHelper, False) // I4687 + actKeyboardTestKeymanWeb.Enabled := (ActiveKmnKeyboardEditor <> nil); end; -procedure TmodActionsKeyboardEditor.actKeyboardFontsExecute(Sender: TObject); // I4057 -begin - (ActiveProjectFile.UI as TProjectFileUI).DoAction(pfaFontDialog, False); // I4687 -end; - -procedure TmodActionsKeyboardEditor.actKeyboardIncludeDebugInformationExecute(Sender: TObject); -begin - (ActiveProjectFile.UI as TkmnProjectFileUI).Debug := not (ActiveProjectFile.UI as TkmnProjectFileUI).Debug; // I4687 -end; - -procedure TmodActionsKeyboardEditor.actKeyboardIncludeDebugInformationUpdate( +procedure TmodActionsKeyboardEditor.actKeyboardTestKeymanWebExecute( Sender: TObject); begin - actKeyboardIncludeDebugInformation.Enabled := ActiveEditor <> nil; - if (ActiveEditor <> nil) and (ActiveProjectFile <> nil) - then actKeyboardIncludeDebugInformation.Checked := (ActiveProjectFile.UI as TkmnProjectFileUI).Debug // I4687 - else actKeyboardIncludeDebugInformation.Checked := False; -end; - -procedure TmodActionsKeyboardEditor.actKeyboardInstallExecute(Sender: TObject); -begin - try - (ActiveProjectFile.UI as TProjectFileUI).DoAction(pfaInstall, False); // I4687 - //WideShowMessage('Keyboard installed successfully.'); - except - on E:EOleException do // I654 - begin - ShowMessage(E.Message); - end; - end; + ActiveProjectFileUI.DoAction(pfaTestKeymanWeb, False); // I4687 end; -procedure TmodActionsKeyboardEditor.actKeyboardTestExecute(Sender: TObject); -begin - ActiveEditor.DebugForm.UIStatus := duiTest; - ActiveEditor.StartDebugging(True); -end; +//------------------------------------------------------------------------------ -procedure TmodActionsKeyboardEditor.actKeyboardTestKeymanWebExecute( - Sender: TObject); +procedure TmodActionsKeyboardEditor.actKeyboardUninstallUpdate(Sender: TObject); begin - (ActiveProjectFile.UI as TProjectFileUI).DoAction(pfaTestKeymanWeb, False); // I4687 + actKeyboardUninstall.Enabled := ActiveProjectFileUI <> nil; end; procedure TmodActionsKeyboardEditor.actKeyboardUninstallExecute(Sender: TObject); begin try - if (ActiveProjectFile.UI as TProjectFileUI).DoAction(pfaUninstall, False) + if ActiveProjectFileUI.DoAction(pfaUninstall, False) then ShowMessage('Keyboard uninstalled successfully.') else ShowMessage('Failed to uninstall keyboard.'); except @@ -545,21 +324,4 @@ procedure TmodActionsKeyboardEditor.actKeyboardUninstallExecute(Sender: TObject) end; end; -function TmodActionsKeyboardEditor.IsDebuggerInTestMode: Boolean; -begin - Result := (ActiveEditor <> nil) and (ActiveEditor.DebugForm.UIStatus = duiTest); -end; - -function TmodActionsKeyboardEditor.IsDebuggerVisible: Boolean; -begin - Result := (ActiveEditor <> nil) and ActiveEditor.IsDebugVisible; -end; - -procedure TmodActionsKeyboardEditor.SelectDebugSystemKeyboard(k: TSystemKeyboardItem); -begin -//TODO: #1225, #1074 (note both menu item and toolbar combo are hidden while this is not working) -// if IsDebuggerVisible then // I3655 -// ActiveEditor.DebugForm.SetSystemKeyboardID(k.KeyboardID); -end; - end. diff --git a/developer/src/tike/child/Keyman.Developer.UI.UfrmLdmlKeyboardEditor.dfm b/developer/src/tike/child/Keyman.Developer.UI.UfrmLdmlKeyboardEditor.dfm new file mode 100644 index 00000000000..9420597382e --- /dev/null +++ b/developer/src/tike/child/Keyman.Developer.UI.UfrmLdmlKeyboardEditor.dfm @@ -0,0 +1,12 @@ +inherited frmLdmlKeyboardEditor: TfrmLdmlKeyboardEditor + Left = 0 + Top = 0 + Caption = 'frmLdmlKeyboardEditor' + ClientHeight = 247 + ClientWidth = 480 + Font.Name = 'Tahoma' + ExplicitWidth = 480 + ExplicitHeight = 247 + PixelsPerInch = 96 + TextHeight = 13 +end diff --git a/developer/src/tike/child/Keyman.Developer.UI.UfrmLdmlKeyboardEditor.pas b/developer/src/tike/child/Keyman.Developer.UI.UfrmLdmlKeyboardEditor.pas new file mode 100644 index 00000000000..e000dabbbac --- /dev/null +++ b/developer/src/tike/child/Keyman.Developer.UI.UfrmLdmlKeyboardEditor.pas @@ -0,0 +1,33 @@ +unit Keyman.Developer.UI.UfrmLdmlKeyboardEditor; + +interface + +uses + System.Classes, + System.ImageList, + System.SysUtils, + System.Variants, + Vcl.Controls, + Vcl.Dialogs, + Vcl.Forms, + Vcl.Graphics, + Vcl.ImgList, + Winapi.Messages, + Winapi.Windows, + + MenuImgList, + UfrmEditor; + +type + TfrmLdmlKeyboardEditor = class(TfrmEditor) + private + { Private declarations } + public + { Public declarations } + end; + +implementation + +{$R *.dfm} + +end. diff --git a/developer/src/tike/child/UfrmDebug.dfm b/developer/src/tike/child/UfrmDebug.dfm index 1d8bca104b9..362488d5f33 100644 --- a/developer/src/tike/child/UfrmDebug.dfm +++ b/developer/src/tike/child/UfrmDebug.dfm @@ -67,10 +67,10 @@ inherited frmDebug: TfrmDebug Left = 228 Top = 73 object mnuPopupFont: TMenuItem - Action = modActionsKeyboardEditor.actDebugViewFont + Action = modActionsDebugger.actDebugViewFont end object mnuPopupResetToQuotedFont: TMenuItem - Action = modActionsKeyboardEditor.actDebugViewDefaultFont + Action = modActionsDebugger.actDebugViewDefaultFont end object N1: TMenuItem Caption = '-' diff --git a/developer/src/tike/child/UfrmDebug.pas b/developer/src/tike/child/UfrmDebug.pas index c6a04b45017..1d271e62a05 100644 --- a/developer/src/tike/child/UfrmDebug.pas +++ b/developer/src/tike/child/UfrmDebug.pas @@ -207,7 +207,7 @@ implementation Keyman.Developer.System.HelpTopics, ActiveX, - dmActionsKeyboardEditor, + dmActionsDebugger, dmActionsMain, Glossary, Keyman.Developer.System.Project.ProjectLog, @@ -1386,7 +1386,7 @@ procedure TfrmDebug.UpdateCharacterGrid; // I4808 procedure TfrmDebug.cmdStopClick(Sender: TObject); begin - modActionsKeyboardEditor.actDebugStopDebugger.Execute; + modActionsDebugger.actDebugStopDebugger.Execute; end; { TDebugBreakpoint } diff --git a/developer/src/tike/child/UfrmKeymanWizard.dfm b/developer/src/tike/child/UfrmKeymanWizard.dfm index 13d710fed6e..e3e6dcffc89 100644 --- a/developer/src/tike/child/UfrmKeymanWizard.dfm +++ b/developer/src/tike/child/UfrmKeymanWizard.dfm @@ -1338,7 +1338,7 @@ inherited frmKeymanWizard: TfrmKeymanWizard Top = 33 Width = 137 Height = 25 - Action = modActionsKeyboardEditor.actDebugStartDebugger + Action = modActionsDebugger.actDebugStartDebugger TabOrder = 1 end object cmdCompile: TButton diff --git a/developer/src/tike/child/UfrmKeymanWizard.pas b/developer/src/tike/child/UfrmKeymanWizard.pas index 9d511388d66..a4a276e145d 100644 --- a/developer/src/tike/child/UfrmKeymanWizard.pas +++ b/developer/src/tike/child/UfrmKeymanWizard.pas @@ -132,6 +132,7 @@ interface UframeTextEditor, UfrmDebug, ExtShiftState, ImgList, MenuImgList, KeyboardParser, TextFileFormat, dmActionsKeyboardEditor, + dmActionsDebugger, VisualKeyboard, UframeOnScreenKeyboardEditor, KeymanDeveloperUtils, OnScreenKeyboard, KMDActionInterfaces, diff --git a/developer/src/tike/http/Keyman.Developer.System.HttpServer.App.pas b/developer/src/tike/http/Keyman.Developer.System.HttpServer.App.pas index eef85cd3af7..1af9aafb976 100644 --- a/developer/src/tike/http/Keyman.Developer.System.HttpServer.App.pas +++ b/developer/src/tike/http/Keyman.Developer.System.HttpServer.App.pas @@ -104,7 +104,7 @@ procedure TAppHttpResponder.RespondProject(doc: string; AContext: TIdContext; path := CrackUTF8ZeroExtendedString(ARequestInfo.CommandType, ARequestInfo.Params.Values['path']); - if (Path <> '') and (not FileExists(path) or not SameText(ExtractFileExt(path), Ext_ProjectSource)) then + if (Path <> '') and (not DirectoryExists(ExtractFileDir(path)) or not SameText(ExtractFileExt(path), Ext_ProjectSource)) then begin AResponseInfo.ResponseNo := 404; AResponseInfo.ResponseText := 'Project file '+path+' does not exist.'; @@ -191,7 +191,7 @@ procedure TAppHttpResponder.RespondProject(doc: string; AContext: TIdContext; // Saving state - if (Path <> '') and (not FileExists(path) or not SameText(ExtractFileExt(path), Ext_ProjectSource)) then + if (Path <> '') and (not DirectoryExists(ExtractFileDir(path)) or not SameText(ExtractFileExt(path), Ext_ProjectSource)) then begin AResponseInfo.ResponseNo := 404; AResponseInfo.ResponseText := 'Project file '+path+' does not exist.'; diff --git a/developer/src/tike/main/UfrmMain.dfm b/developer/src/tike/main/UfrmMain.dfm index 69e5beca174..311c1fd67d5 100644 --- a/developer/src/tike/main/UfrmMain.dfm +++ b/developer/src/tike/main/UfrmMain.dfm @@ -75,7 +75,7 @@ inherited frmKeymanDeveloper: TfrmKeymanDeveloper Top = 0 Width = 82 Height = 22 - Action = modActionsKeyboardEditor.actDebugTestMode + Action = modActionsDebugger.actDebugTestMode AllowAllUp = True GroupIndex = 1 end @@ -84,7 +84,7 @@ inherited frmKeymanDeveloper: TfrmKeymanDeveloper Top = 0 Width = 98 Height = 22 - Action = modActionsKeyboardEditor.actDebugDebuggerMode + Action = modActionsDebugger.actDebugDebuggerMode AllowAllUp = True GroupIndex = 2 end @@ -120,7 +120,7 @@ inherited frmKeymanDeveloper: TfrmKeymanDeveloper object ToolButton21: TToolButton Left = 8 Top = 0 - Action = modActionsKeyboardEditor.actDebugStopDebugger + Action = modActionsDebugger.actDebugStopDebugger end object ToolButton23: TToolButton Left = 31 @@ -133,7 +133,7 @@ inherited frmKeymanDeveloper: TfrmKeymanDeveloper object ToolButton22: TToolButton Left = 39 Top = 0 - Action = modActionsKeyboardEditor.actDebugSingleStepMode + Action = modActionsDebugger.actDebugSingleStepMode end object ToolButton24: TToolButton Left = 62 @@ -146,17 +146,17 @@ inherited frmKeymanDeveloper: TfrmKeymanDeveloper object ToolButton25: TToolButton Left = 70 Top = 0 - Action = modActionsKeyboardEditor.actDebugStepForward + Action = modActionsDebugger.actDebugStepForward end object ToolButton26: TToolButton Left = 93 Top = 0 - Action = modActionsKeyboardEditor.actDebugRun + Action = modActionsDebugger.actDebugRun end object ToolButton27: TToolButton Left = 116 Top = 0 - Action = modActionsKeyboardEditor.actDebugPause + Action = modActionsDebugger.actDebugPause end object ToolButton28: TToolButton Left = 139 @@ -169,7 +169,7 @@ inherited frmKeymanDeveloper: TfrmKeymanDeveloper object ToolButton29: TToolButton Left = 147 Top = 0 - Action = modActionsKeyboardEditor.actDebugSetClearBreakpoint + Action = modActionsDebugger.actDebugSetClearBreakpoint end end end @@ -3014,40 +3014,40 @@ inherited frmKeymanDeveloper: TfrmKeymanDeveloper object mnuDebug: TMenuItem Caption = '&Debug' object SetBreakpoint1: TMenuItem - Action = modActionsKeyboardEditor.actDebugSetClearBreakpoint + Action = modActionsDebugger.actDebugSetClearBreakpoint end object N32: TMenuItem Caption = '-' end object StartDebugging1: TMenuItem - Action = modActionsKeyboardEditor.actDebugStartDebugger + Action = modActionsDebugger.actDebugStartDebugger end object StopDebugger1: TMenuItem - Action = modActionsKeyboardEditor.actDebugStopDebugger + Action = modActionsDebugger.actDebugStopDebugger end object N33: TMenuItem Caption = '-' end object ANSITestMode1: TMenuItem - Action = modActionsKeyboardEditor.actDebugANSITestMode + Action = modActionsDebugger.actDebugANSITestMode end object N34: TMenuItem Caption = '-' end object SingleStepMode1: TMenuItem - Action = modActionsKeyboardEditor.actDebugSingleStepMode + Action = modActionsDebugger.actDebugSingleStepMode end object N35: TMenuItem Caption = '-' end object StepForward1: TMenuItem - Action = modActionsKeyboardEditor.actDebugStepForward + Action = modActionsDebugger.actDebugStepForward end object Run1: TMenuItem - Action = modActionsKeyboardEditor.actDebugRun + Action = modActionsDebugger.actDebugRun end object Pause1: TMenuItem - Action = modActionsKeyboardEditor.actDebugPause + Action = modActionsDebugger.actDebugPause end object N36: TMenuItem Caption = '-' @@ -3055,35 +3055,35 @@ inherited frmKeymanDeveloper: TfrmKeymanDeveloper object View2: TMenuItem Caption = '&View' object State1: TMenuItem - Action = modActionsKeyboardEditor.actDebugViewState + Action = modActionsDebugger.actDebugViewState end object Elements1: TMenuItem - Action = modActionsKeyboardEditor.actDebugViewElements + Action = modActionsDebugger.actDebugViewElements end object CallStack1: TMenuItem - Action = modActionsKeyboardEditor.actDebugViewCallStack + Action = modActionsDebugger.actDebugViewCallStack end object Deadkeys1: TMenuItem - Action = modActionsKeyboardEditor.actDebugViewDeadkeys + Action = modActionsDebugger.actDebugViewDeadkeys end object RegressionTesting1: TMenuItem - Action = modActionsKeyboardEditor.actDebugViewRegressionTesting + Action = modActionsDebugger.actDebugViewRegressionTesting end object N38: TMenuItem Caption = '-' end object Font1: TMenuItem - Action = modActionsKeyboardEditor.actDebugViewFont + Action = modActionsDebugger.actDebugViewFont end object UseEditorCharacterFont1: TMenuItem - Action = modActionsKeyboardEditor.actDebugViewDefaultFont + Action = modActionsDebugger.actDebugViewDefaultFont end end object N37: TMenuItem Caption = '-' end object SelectSystemKeyboard1: TMenuItem - Action = modActionsKeyboardEditor.actDebugSelectSystemKeyboard + Action = modActionsDebugger.actDebugSelectSystemKeyboard end end object mnuTools: TMenuItem diff --git a/developer/src/tike/main/UfrmMain.pas b/developer/src/tike/main/UfrmMain.pas index a84d386a079..67dd1d0d888 100644 --- a/developer/src/tike/main/UfrmMain.pas +++ b/developer/src/tike/main/UfrmMain.pas @@ -88,22 +88,52 @@ interface uses System.UITypes, - Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, - ComCtrls, ImgList, Menus, StdCtrls, ExtCtrls, ToolWin, Buttons, - KeymanDeveloperUtils, UfrmMDIChild, UfrmMDIEditor, + Windows, + Messages, + SysUtils, + Classes, + Graphics, + Controls, + Forms, + ComCtrls, + ImgList, + Menus, + StdCtrls, + ExtCtrls, + ToolWin, + Buttons, + KeymanDeveloperUtils, + UfrmMDIChild, + UfrmMDIEditor, MenuImgList, Keyman.Developer.System.Project.Project, - Keyman.Developer.UI.Project.UfrmProject, CharacterMapSettings, + Keyman.Developer.UI.Project.UfrmProject, + CharacterMapSettings, mrulist, UfrmUnicodeDataStatus, CharacterDragObject, Keyman.Developer.UI.dmActionsModelEditor, - dmActionsMain, UnicodeData, UserMessages, webhelp, - dmActionsKeyboardEditor, Dialogs, UfrmTike, AppEvnts, + UnicodeData, + UserMessages, + webhelp, + dmActionsDebugger, + dmActionsKeyboardEditor, + dmActionsMain, + Dialogs, + UfrmTike, + AppEvnts, DropTarget, - System.ImageList, Winapi.ActiveX, CloseButtonPageControl, JvComponentBase, - JvDockControlForm, JvDockTree, JvDockVIDStyle, JvDockVSNetStyle, - JvAppRegistryStorage, Vcl.ActnMan, Vcl.ActnCtrls; + System.ImageList, + Winapi.ActiveX, + CloseButtonPageControl, + JvComponentBase, + JvDockControlForm, + JvDockTree, + JvDockVIDStyle, + JvDockVSNetStyle, + JvAppRegistryStorage, + Vcl.ActnMan, + Vcl.ActnCtrls; type TfrmKeymanDeveloper = class(TTikeForm, IUnicodeDataUIManager, IDragDrop) @@ -449,8 +479,10 @@ implementation Keyman.Developer.System.Project.ProjectFileType, Keyman.Developer.System.Project.WelcomeRenderer, Keyman.Developer.System.Project.ProjectLog, + Keyman.Developer.System.Project.XmlLdmlProjectFile, Keyman.Developer.UI.Project.ProjectFileUI, Keyman.Developer.UI.Project.ProjectUI, + Keyman.Developer.UI.UfrmLdmlKeyboardEditor, Keyman.Developer.UI.UfrmWordlistEditor, Keyman.Developer.UI.UfrmModelEditor, TextFileFormat, @@ -511,6 +543,7 @@ procedure TfrmKeymanDeveloper.FormCreate(Sender: TObject); modActionsTextEditor := TmodActionsTextEditor.Create(Self); modActionsKeyboardEditor := TmodActionsKeyboardEditor.Create(Self); + modActionsDebugger := TmodActionsDebugger.Create(Self); modActionsMain := TmodActionsMain.Create(Self); modActionsModelEditor := TmodActionsModelEditor.Create(Self); @@ -1022,7 +1055,7 @@ procedure TfrmKeymanDeveloper.cbDebugSystemKeyboardItemClick(Sender: TObject); begin if cbDebugSystemKeyboard.ItemIndex < 0 then cbDebugSystemKeyboard.ItemIndex := 0; - modActionsKeyboardEditor.SelectDebugSystemKeyboard(cbDebugSystemKeyboard.Items.Objects[cbDebugSystemKeyboard.ItemIndex] as TSystemKeyboardItem); + modActionsDebugger.SelectDebugSystemKeyboard(cbDebugSystemKeyboard.Items.Objects[cbDebugSystemKeyboard.ItemIndex] as TSystemKeyboardItem); //actDebugSystemKeyboard end; @@ -1169,6 +1202,8 @@ function TfrmKeymanDeveloper.OpenFile(FFileName: string; FCloseNewFile: Boolean) else if ext = '.kvks' then Result := OpenKVKEditor(FFileName) else if ext = '.bmp' then Result := OpenEditor(FFileName, TfrmBitmapEditor) else if ext = '.tsv' then Result := OpenTSVEditor(FFileName) + else if (ext = '.xml') and TxmlLdmlProjectFile.IsFileTypeSupported(FFileName) then + Result := OpenEditor(FFileName, TfrmLdmlKeyboardEditor) else if FileHasModelTsExt(FFileName) then Result := OpenModelEditor(FFileName) else Result := OpenEditor(FFileName, TfrmEditor); diff --git a/developer/src/tike/project/Keyman.Developer.System.Project.ProjectFile.pas b/developer/src/tike/project/Keyman.Developer.System.Project.ProjectFile.pas index 46ebcdc47d0..f7c032ec977 100644 --- a/developer/src/tike/project/Keyman.Developer.System.Project.ProjectFile.pas +++ b/developer/src/tike/project/Keyman.Developer.System.Project.ProjectFile.pas @@ -265,9 +265,12 @@ TProjectFile = class constructor Create(AProject: TProject; AFileName: string; AParent: TProjectFile); virtual; destructor Destroy; override; - procedure Load(node: IXMLNode; LoadState: Boolean); virtual; // I4698 + function IsCompilable: Boolean; virtual; + class function IsFileTypeSupported(const Filename: string): Boolean; virtual; + + procedure Load(node: IXMLNode); virtual; // I4698 procedure LoadState(node: IXMLNode); virtual; // I4698 - procedure Save(node: IXMLNode; SaveState: Boolean); virtual; // I4698 + procedure Save(node: IXMLNode); virtual; // I4698 procedure SaveState(node: IXMLNode); virtual; // I4698 procedure AddFreeNotification(AClient: IProjectFileFreeNotification); @@ -571,7 +574,20 @@ function TProjectFile.GetOwnerProject: TProject; end; end; -procedure TProjectFile.Load(node: IXMLNode; LoadState: Boolean); // I4698 +function TProjectFile.IsCompilable: Boolean; +begin + Result := False; +end; + +class function TProjectFile.IsFileTypeSupported( + const Filename: string): Boolean; +begin + // assumes that if we are registered for the file type extension, then we can + // handle the file. For example, .xml LDML keyboards + Result := True; +end; + +procedure TProjectFile.Load(node: IXMLNode); // I4698 var i: Integer; begin @@ -579,17 +595,6 @@ procedure TProjectFile.Load(node: IXMLNode; LoadState: Boolean); // I4698 FID := CleanID(VarToWideStr(node.ChildValues['ID'])); if node.ChildNodes.IndexOf('ParentFileID') >= 0 then FParentFileID := CleanID(VarToWideStr(node.ChildValues['ParentFileID'])); - - if LoadState then - begin - FIDEState.Clear; - if node.ChildNodes.IndexOf('IDEState') >= 0 then - begin - node := node.ChildNodes.Nodes['IDEState']; - for i := 0 to node.ChildNodes.Count - 1 do - FIDEState[node.ChildNodes[i].NodeName] := node.ChildNodes[i].NodeValue; - end; - end; end; procedure TProjectFile.LoadState(node: IXMLNode); // I4698 @@ -616,7 +621,7 @@ procedure TProjectFile.RemoveFreeNotification( FNotifiers.Remove(AClient); end; -procedure TProjectFile.Save(node: IXMLNode; SaveState: Boolean); // I4698 +procedure TProjectFile.Save(node: IXMLNode); // I4698 var I: Integer; begin @@ -627,21 +632,6 @@ procedure TProjectFile.Save(node: IXMLNode; SaveState: Boolean); // I4698 node.AddChild('FileType').NodeValue := ExtractFileExt(FFileName);; if Assigned(FParent) then node.AddChild('ParentFileID').NodeValue := FParent.ID; - - if SaveState then - begin - node.AddChild('FullPath').NodeValue := FFileName; - - if FIDEState.Count > 0 then - begin - node := node.AddChild('IDEState'); - for I := 0 to FIDEState.Count - 1 do - begin - with node.AddChild(TProjectFileState(FIDEState.Get(I)).Name) do - NodeValue := TProjectFileState(FIDEState.Get(I)).Value; - end; - end; - end; end; procedure TProjectFile.SaveState(node: IXMLNode); // I4698 @@ -995,7 +985,7 @@ procedure TProject.PopulateFolder(const path: string); function IsLMDLKeyboardFile(filename: string): Boolean; if EndsText('.xml', filename) then begin - Result := Pos('ldmlKeyboard.dtd', ReadUtf8FileText(ff)) > 0; + Result := Pos('ldmlKeyboard3.dtd', ReadUtf8FileText(ff)) > 0; end else Result := False; diff --git a/developer/src/tike/project/Keyman.Developer.System.Project.ProjectFileType.pas b/developer/src/tike/project/Keyman.Developer.System.Project.ProjectFileType.pas index 819a5491d52..c0633dc34e5 100644 --- a/developer/src/tike/project/Keyman.Developer.System.Project.ProjectFileType.pas +++ b/developer/src/tike/project/Keyman.Developer.System.Project.ProjectFileType.pas @@ -97,7 +97,8 @@ function CreateProjectFile(AProject: TProject; AFileName: string; AParent: TProj ni := -1; for i := 0 to FRegisteredFileTypes.Count - 1 do if FRegisteredFileTypes[i].Extension = '*' then ni := i - else if FRegisteredFileTypes[i].Extension = Ext then + else if (FRegisteredFileTypes[i].Extension = Ext) and + FRegisteredFileTypes[i].ProjectFileClass.IsFileTypeSupported(AFileName) then begin Result := FRegisteredFileTypes[i].ProjectFileClass.Create(AProject, AFileName, AParent); diff --git a/developer/src/tike/project/Keyman.Developer.System.Project.ProjectLoader.pas b/developer/src/tike/project/Keyman.Developer.System.Project.ProjectLoader.pas index c5b74a49fec..8fcc34ac2be 100644 --- a/developer/src/tike/project/Keyman.Developer.System.Project.ProjectLoader.pas +++ b/developer/src/tike/project/Keyman.Developer.System.Project.ProjectLoader.pas @@ -100,6 +100,7 @@ procedure TProjectLoader.LoadProjectFromFile; doc: IXMLDocument; node, root: IXMLNode; pf: TProjectFile; + hasUserState: Boolean; begin try doc := LoadXMLDocument(FFileName); @@ -108,6 +109,8 @@ procedure TProjectLoader.LoadProjectFromFile; raise EProjectLoader.Create('Error loading project file: '+E.Message); end; + hasUserState := FileExists(ChangeFileExt(FFileName, Ext_ProjectSourceUser)); + root := doc.DocumentElement; if root.NodeName <> 'KeymanDeveloperProject' then raise EProjectLoader.Create('Not a Keyman Developer project file'); @@ -164,7 +167,9 @@ procedure TProjectLoader.LoadProjectFromFile; begin // I1152 - Avoid crashes when .kpj file is invalid pf := CreateProjectFile(FProject, ExpandFileNameClean(FFileName, node.ChildValues['Filepath']), nil); - pf.Load(node, True); + pf.Load(node); + if not hasUserState then + pf.LoadState(node); end; end; end; @@ -181,7 +186,9 @@ procedure TProjectLoader.LoadProjectFromFile; n := FProject.Files.IndexOfID(node.ChildValues['ParentFileID']); if n < 0 then Continue; pf := CreateProjectFile(FProject, ExpandFileNameClean(FFileName, node.ChildValues['Filepath']), FProject.Files[n]); - pf.Load(node, True); + pf.Load(node); + if not hasUserState then + pf.LoadState(node); end; end; diff --git a/developer/src/tike/project/Keyman.Developer.System.Project.ProjectSaver.pas b/developer/src/tike/project/Keyman.Developer.System.Project.ProjectSaver.pas index ba5f5def502..17fb306c559 100644 --- a/developer/src/tike/project/Keyman.Developer.System.Project.ProjectSaver.pas +++ b/developer/src/tike/project/Keyman.Developer.System.Project.ProjectSaver.pas @@ -86,7 +86,7 @@ procedure TProjectSaver.Execute; // I4698 node, root: IXMLNode; defopts: TProjectOptionsRecord; begin - if FProject.IsDefaultProject(pv20) then + if FProject.IsDefaultProject(pv20) and (FFileName <> '') then begin if FileExists(FFileName) then System.SysUtils.DeleteFile(FFileName); @@ -136,7 +136,7 @@ procedure TProjectSaver.Execute; // I4698 begin node := root.AddChild('Files'); for i := 0 to FProject.Files.Count - 1 do - FProject.Files[i].Save(node.AddChild('File'), False); + FProject.Files[i].Save(node.AddChild('File')); end; if FFileName <> '' then diff --git a/developer/src/tike/project/Keyman.Developer.System.Project.kmnProjectFile.pas b/developer/src/tike/project/Keyman.Developer.System.Project.kmnProjectFile.pas index db149fe8166..55ef1992a59 100644 --- a/developer/src/tike/project/Keyman.Developer.System.Project.kmnProjectFile.pas +++ b/developer/src/tike/project/Keyman.Developer.System.Project.kmnProjectFile.pas @@ -1,18 +1,18 @@ (* Name: Keyman.Developer.System.Project.kmnProjectFile Copyright: Copyright (C) SIL International. - Documentation: - Description: + Documentation: + Description: Create Date: 1 Aug 2006 Modified Date: 24 Aug 2015 Authors: mcdurdin - Related Files: - Dependencies: + Related Files: + Dependencies: - Bugs: - Todo: - Notes: + Bugs: + Todo: + Notes: History: 01 Aug 2006 - mcdurdin - Add loading and saving from XML 23 Aug 2006 - mcdurdin - Add CompileKeyboardToWeb function 28 Sep 2006 - mcdurdin - Editions @@ -47,7 +47,7 @@ 03 Aug 2015 - mcdurdin - I4823 - Note in compile log if symbols are included in build 24 Aug 2015 - mcdurdin - I4865 - Add treat hints and warnings as errors into project 24 Aug 2015 - mcdurdin - I4866 - Add warn on deprecated features to project and compile - + *) unit Keyman.Developer.System.Project.kmnProjectFile; // I3306 // I4687 // I4688 // I4692 @@ -73,7 +73,6 @@ TkmnProjectFile = class(TOpenableProjectFile) FHeader_Copyright: WideString; FTargets: TKeymanTargets; FKVKFileName: string; - FWarnAsError: Boolean; // I4706 function GetOutputFilename: string; function GetTargetFilename: string; @@ -85,13 +84,13 @@ TkmnProjectFile = class(TOpenableProjectFile) property KVKFileName: string read FKVKFileName; property IsDebug: Boolean read FDebug; public - procedure Load(node: IXMLNode; LoadState: Boolean); override; // I4698 - procedure Save(node: IXMLNode; SaveState: Boolean); override; // I4698 + function IsCompilable: Boolean; override; + procedure Load(node: IXMLNode); override; // I4698 + procedure Save(node: IXMLNode); override; // I4698 procedure LoadState(node: IXMLNode); override; // I4698 procedure SaveState(node: IXMLNode); override; // I4698 property Debug: Boolean read FDebug write FDebug; - property WarnAsError: Boolean read FWarnAsError write FWarnAsError; // I4706 property OutputFilename: string read GetOutputFilename; property TargetFilename: string read GetTargetFilename; @@ -119,15 +118,13 @@ implementation - TkmnProjectFile - -------------------------------------------------------------------------------} -procedure TkmnProjectFile.Save(node: IXMLNode; SaveState: Boolean); // I4698 +procedure TkmnProjectFile.Save(node: IXMLNode); // I4698 begin - inherited Save(node, SaveState); // I4698 + inherited Save(node); // I4698 node := node.AddChild('Details'); if FHeader_Name <> '' then node.AddChild('Name').NodeValue := FHeader_Name; if FHeader_Copyright <> '' then node.AddChild('Copyright').NodeValue := FHeader_Copyright; if FHeader_Message <> '' then node.AddChild('Message').NodeValue := FHeader_Message; - - if SaveState then node.AddChild('Debug').NodeValue := FDebug; // I4698 end; procedure TkmnProjectFile.SaveState(node: IXMLNode); // I4698 @@ -136,22 +133,15 @@ procedure TkmnProjectFile.SaveState(node: IXMLNode); // I4698 node.AddChild('Debug').NodeValue := FDebug; end; -procedure TkmnProjectFile.Load(node: IXMLNode; LoadState: Boolean); // I4698 +procedure TkmnProjectFile.Load(node: IXMLNode); // I4698 begin - inherited Load(node, LoadState); + inherited Load(node); if node.ChildNodes.IndexOf('Details') < 0 then Exit; node := node.ChildNodes['Details']; if node.ChildNodes.IndexOf('Name') >= 0 then FHeader_Name := VarToWideStr(node.ChildValues['Name']); if node.ChildNodes.IndexOf('Copyright') >= 0 then FHeader_Copyright := VarToWideStr(node.ChildValues['Copyright']); if node.ChildNodes.IndexOf('Message') >= 0 then FHeader_Message := VarToWideStr(node.ChildValues['Message']); - - if LoadState then - try - if node.ChildNodes.IndexOf('Debug') >= 0 then FDebug := node.ChildValues['Debug']; - except - FDebug := False; - end; end; procedure TkmnProjectFile.LoadState(node: IXMLNode); // I4698 @@ -181,6 +171,11 @@ function TkmnProjectFile.GetTargetFilename: string; Result := OwnerProject.GetTargetFilename(OutputFileName, FileName, FTempFileVersion); end; +function TkmnProjectFile.IsCompilable: Boolean; +begin + Result := True; +end; + procedure TkmnProjectFile.GetFileParameters; var j: Integer; diff --git a/developer/src/tike/project/Keyman.Developer.System.Project.kpsProjectFile.pas b/developer/src/tike/project/Keyman.Developer.System.Project.kpsProjectFile.pas index 8c3ec46f8a0..cbba63398df 100644 --- a/developer/src/tike/project/Keyman.Developer.System.Project.kpsProjectFile.pas +++ b/developer/src/tike/project/Keyman.Developer.System.Project.kpsProjectFile.pas @@ -1,18 +1,18 @@ (* Name: Keyman.Developer.System.Project.kpsProjectFile Copyright: Copyright (C) SIL International. - Documentation: - Description: + Documentation: + Description: Create Date: 20 Jun 2006 Modified Date: 6 Jun 2015 Authors: mcdurdin - Related Files: - Dependencies: + Related Files: + Dependencies: - Bugs: - Todo: - Notes: + Bugs: + Todo: + Notes: History: 20 Jun 2006 - mcdurdin - Initial version 01 Aug 2006 - mcdurdin - Add loading and saving from XML 23 Aug 2006 - mcdurdin - Refactor to use actions @@ -54,7 +54,6 @@ TkpsProjectFile = class(TOpenableProjectFile) FHeader_Copyright: string; FHeader_Version: string; FMSIFileName: WideString; - FWarnAsError: Boolean; // I4706 function GetOutputFilename: string; function GetTargetFilename: string; function GetTargetInstallerFilename: string; @@ -62,10 +61,9 @@ TkpsProjectFile = class(TOpenableProjectFile) function GetRelativeOrder: Integer; override; procedure GetFileParameters; override; public - procedure Load(node: IXMLNode; LoadState: Boolean); override; // I4698 - procedure Save(node: IXMLNode; SaveState: Boolean); override; // I4698 - - property WarnAsError: Boolean read FWarnAsError write FWarnAsError; // I4706 + function IsCompilable: Boolean; override; + procedure Load(node: IXMLNode); override; // I4698 + procedure Save(node: IXMLNode); override; // I4698 property OutputFilename: string read GetOutputFilename; property TargetFilename: string read GetTargetFilename; @@ -163,9 +161,14 @@ function TkpsProjectFile.GetTargetInstallerFilename: string; Result := OwnerProject.GetTargetFilename(ChangeFileExt(ExtractFileName(FMSIFileName),'') + '-' + ChangeFileExt(ExtractFileName(OutputFilename), '') + '.exe', Filename, FileVersion); end; -procedure TkpsProjectFile.Load(node: IXMLNode; LoadState: Boolean); // I4698 +function TkpsProjectFile.IsCompilable: Boolean; +begin + Result := True; +end; + +procedure TkpsProjectFile.Load(node: IXMLNode); // I4698 begin - inherited Load(node, LoadState); + inherited Load(node); if node.ChildNodes.IndexOf('Details') < 0 then Exit; node := node.ChildNodes['Details']; @@ -174,9 +177,9 @@ procedure TkpsProjectFile.Load(node: IXMLNode; LoadState: Boolean); // I4698 if node.ChildNodes.IndexOf('Version') >= 0 then FHeader_Version := VarToWideStr(node.ChildValues['Version']); end; -procedure TkpsProjectFile.Save(node: IXMLNode; SaveState: Boolean); // I4698 +procedure TkpsProjectFile.Save(node: IXMLNode); // I4698 begin - inherited Save(node, SaveState); + inherited Save(node); node := node.AddChild('Details'); if FHeader_Name <> '' then node.AddChild('Name').NodeValue := FHeader_Name; if FHeader_Copyright <> '' then node.AddChild('Copyright').NodeValue := FHeader_Copyright; diff --git a/developer/src/tike/project/Keyman.Developer.System.Project.modelTsProjectFile.pas b/developer/src/tike/project/Keyman.Developer.System.Project.modelTsProjectFile.pas index d04488df532..464409df518 100644 --- a/developer/src/tike/project/Keyman.Developer.System.Project.modelTsProjectFile.pas +++ b/developer/src/tike/project/Keyman.Developer.System.Project.modelTsProjectFile.pas @@ -34,7 +34,6 @@ TmodelTsProjectFile = class; TmodelTsProjectFile = class(TOpenableProjectFile) private FDebug: Boolean; - FWarnAsError: Boolean; FTestKeyboard: string; // I4706 function GetTargetFilename: string; @@ -44,16 +43,13 @@ TmodelTsProjectFile = class(TOpenableProjectFile) property IsDebug: Boolean read FDebug; public - procedure Load(node: IXMLNode; LoadState: Boolean); override; // I4698 - procedure Save(node: IXMLNode; SaveState: Boolean); override; // I4698 + function IsCompilable: Boolean; override; procedure LoadState(node: IXMLNode); override; // I4698 procedure SaveState(node: IXMLNode); override; // I4698 property Debug: Boolean read FDebug write FDebug; property TestKeyboard: string read FTestKeyboard write FTestKeyboard; - property WarnAsError: Boolean read FWarnAsError write FWarnAsError; // I4706 - property TargetFilename: string read GetTargetFilename; end; @@ -70,13 +66,6 @@ implementation - TmodelTsProjectFile - -------------------------------------------------------------------------------} -procedure TmodelTsProjectFile.Save(node: IXMLNode; SaveState: Boolean); // I4698 -begin - inherited Save(node, SaveState); // I4698 - if SaveState then - Self.SaveState(node); // I4698 -end; - procedure TmodelTsProjectFile.SaveState(node: IXMLNode); // I4698 begin inherited SaveState(node); @@ -84,14 +73,6 @@ procedure TmodelTsProjectFile.SaveState(node: IXMLNode); // I4698 node.AddChild('TestKeyboard').NodeValue := FTestKeyboard; end; -procedure TmodelTsProjectFile.Load(node: IXMLNode; LoadState: Boolean); // I4698 -begin - inherited Load(node, LoadState); - - if LoadState then - Self.LoadState(node); -end; - procedure TmodelTsProjectFile.LoadState(node: IXMLNode); // I4698 begin inherited LoadState(node); @@ -126,6 +107,11 @@ function TmodelTsProjectFile.GetTargetFilename: string; Result := OwnerProject.GetTargetFilename(OutputFileName, FileName, FTempFileVersion); end; +function TmodelTsProjectFile.IsCompilable: Boolean; +begin + Result := True; +end; + procedure TmodelTsProjectFile.GetFileParameters; begin SetFileVersion('1.0'); // I4701 diff --git a/developer/src/tike/project/Keyman.Developer.System.Project.modelTsProjectFileAction.pas b/developer/src/tike/project/Keyman.Developer.System.Project.modelTsProjectFileAction.pas index 834045aa177..1015c455a0f 100644 --- a/developer/src/tike/project/Keyman.Developer.System.Project.modelTsProjectFileAction.pas +++ b/developer/src/tike/project/Keyman.Developer.System.Project.modelTsProjectFileAction.pas @@ -64,7 +64,7 @@ function TmodelTsProjectFileAction.CompileModel: Boolean; ForceDirectories(ExtractFileDir(TargetFileName)); Result := CompileModelFile(Self, FileName, TargetFileName, IsDebug); - if HasCompileWarning and (WarnAsError or OwnerProject.Options.CompilerWarningsAsErrors) then Result := False; // I4706 + if HasCompileWarning and OwnerProject.Options.CompilerWarningsAsErrors then Result := False; // I4706 if Result then Log(plsSuccess, Format('''%s'' was compiled successfully to ''%s''.', [FileName, TargetFileName]), 0, 0) // I4504 diff --git a/developer/src/tike/project/Keyman.Developer.System.Project.xmlLdmlProjectFile.pas b/developer/src/tike/project/Keyman.Developer.System.Project.xmlLdmlProjectFile.pas new file mode 100644 index 00000000000..a5a678c6b96 --- /dev/null +++ b/developer/src/tike/project/Keyman.Developer.System.Project.xmlLdmlProjectFile.pas @@ -0,0 +1,184 @@ +{ + * Keyman is copyright (C) SIL International. MIT License. + * + * xmlLdmlProjectFile: LDML keyboard files +} +unit Keyman.Developer.System.Project.xmlLdmlProjectFile; + +interface + +uses + System.SysUtils, + Xml.XMLIntf, + + Keyman.Developer.System.Project.ProjectFile, + Keyman.Developer.System.Project.ProjectFiles, + Keyman.Developer.System.Project.ProjectFileType, + UKeymanTargets; + +type + TxmlLdmlProjectFile = class; + + TxmlLdmlProjectFile = class(TOpenableProjectFile) + private + FDebug: Boolean; + FHeader_Name: WideString; + FTargets: TKeymanTargets; + FKVKFileName: string; + + function GetOutputFilename: string; + function GetTargetFilename: string; + function GetJSTargetFilename: string; + protected + function GetRelativeOrder: Integer; override; + procedure GetFileParameters; override; + + property KVKFileName: string read FKVKFileName; + property IsDebug: Boolean read FDebug; + public + class function IsFileTypeSupported(const Filename: string): Boolean; override; + function IsCompilable: Boolean; override; + procedure Load(node: IXMLNode); override; // I4698 + procedure Save(node: IXMLNode); override; // I4698 + procedure LoadState(node: IXMLNode); override; // I4698 + procedure SaveState(node: IXMLNode); override; // I4698 + + property Debug: Boolean read FDebug write FDebug; + + property OutputFilename: string read GetOutputFilename; + property TargetFilename: string read GetTargetFilename; + property JSTargetFilename: string read GetJSTargetFilename; + property Header_Name: WideString read FHeader_Name; + property Targets: TKeymanTargets read FTargets; + end; + +implementation + +uses + System.Classes, + System.Variants, + Winapi.Windows, + + KeyboardParser, + kmxfileconsts, + KeyboardFonts, + Keyman.System.KeyboardUtils, + utilsystem; + +{------------------------------------------------------------------------------- + - TxmlLdmlProjectFile - + -------------------------------------------------------------------------------} + +function TxmlLdmlProjectFile.IsCompilable: Boolean; +begin + Result := True; +end; + +class function TxmlLdmlProjectFile.IsFileTypeSupported(const Filename: string): Boolean; +var + ss: TStringStream; +begin + // Look for DTD in plain text as an adequate heuristic + ss := TStringStream.Create('', TEncoding.UTF8); + try + ss.LoadFromFile(Filename); + Result := ss.DataString.IndexOf('ldmlKeyboard3.dtd') > 0; + finally + ss.Free; + end; +end; + +procedure TxmlLdmlProjectFile.Save(node: IXMLNode); // I4698 +begin + inherited Save(node); // I4698 + node := node.AddChild('Details'); + if FHeader_Name <> '' then node.AddChild('Name').NodeValue := FHeader_Name; +end; + +procedure TxmlLdmlProjectFile.SaveState(node: IXMLNode); // I4698 +begin + inherited SaveState(node); + node.AddChild('Debug').NodeValue := FDebug; +end; + +procedure TxmlLdmlProjectFile.Load(node: IXMLNode); // I4698 +begin + inherited Load(node); + + if node.ChildNodes.IndexOf('Details') < 0 then Exit; + node := node.ChildNodes['Details']; + if node.ChildNodes.IndexOf('Name') >= 0 then FHeader_Name := VarToWideStr(node.ChildValues['Name']); +end; + +procedure TxmlLdmlProjectFile.LoadState(node: IXMLNode); // I4698 +begin + inherited LoadState(node); + try + if node.ChildNodes.IndexOf('Debug') >= 0 then FDebug := node.ChildValues['Debug']; + except + FDebug := False; + end; +end; + +function TxmlLdmlProjectFile.GetRelativeOrder: Integer; +begin + Result := 20; +end; + +function TxmlLdmlProjectFile.GetTargetFilename: string; +var + FTempFileVersion: string; +begin + // https://github.com/keymanapp/keyman/issues/631 + // This appears to be a Delphi compiler bug (RSP-20457) + // Workaround is to make a copy of the parameter locally + // which fixes the reference counting. + FTempFileVersion := FileVersion; + Result := OwnerProject.GetTargetFilename(OutputFileName, FileName, FTempFileVersion); +end; + +procedure TxmlLdmlProjectFile.GetFileParameters; +var + j: Integer; + value: WideString; + FVersion: string; // I4701 +begin + FHeader_Name := ''; + FKVKFileName := ''; + SetFileVersion('1.0'); // I4701 + FTargets := AllKeymanTargets; + + if not FileExists(FileName) then Exit; + + // TODO: Load from XML? +end; + +function TxmlLdmlProjectFile.GetJSTargetFilename: string; +begin + if FTargets = [] then + GetFileParameters; + + // There is no JS target if no target is specified + if FTargets * KMWKeymanTargets = [] then + Exit(''); + + Result := OwnerProject.GetTargetFilename(TKeyboardUtils.GetKeymanWebCompiledFileName(FileName), FileName, FileVersion); +end; + +function TxmlLdmlProjectFile.GetOutputFilename: string; +begin + if FTargets = [] then + GetFileParameters; + + // If no target is specified, we'll fall back to .kmx + // so we always have at least one target filename + if (FTargets <> []) and (FTargets * KMXKeymanTargets = []) then + Exit(''); + Result := ChangeFileExt(FileName, '.kmx'); +end; + + +initialization + RegisterProjectFileType('.xml', TxmlLdmlProjectFile); +end. + diff --git a/developer/src/tike/project/Keyman.Developer.System.Project.xmlLdmlProjectFileAction.pas b/developer/src/tike/project/Keyman.Developer.System.Project.xmlLdmlProjectFileAction.pas new file mode 100644 index 00000000000..36c9c85f7cb --- /dev/null +++ b/developer/src/tike/project/Keyman.Developer.System.Project.xmlLdmlProjectFileAction.pas @@ -0,0 +1,93 @@ +{ + * Keyman is copyright (C) SIL International. MIT License. + * + * xmlLdmlProjectFileAction: actions for LDML keyboard files +} +unit Keyman.Developer.System.Project.xmlLdmlProjectFileAction; + +interface + +uses + System.SysUtils, + + Keyman.Developer.System.Project.xmlLdmlProjectFile, + Keyman.Developer.System.Project.ProjectFile, + Keyman.Developer.System.Project.ProjectFiles, + Keyman.Developer.System.Project.ProjectFileType, + UKeymanTargets; + +type + TxmlLdmlProjectFileAction = class(TxmlLdmlProjectFile) + private + procedure CheckFilenameConventions; + public + function CompileKeyboard: Boolean; + function Clean: Boolean; + end; + +implementation + +uses + System.Classes, + System.StrUtils, + System.Variants, + Winapi.Windows, + + Keyman.Developer.System.Project.ProjectLog, + Keyman.System.KeyboardUtils, + Keyman.Developer.System.KmcWrapper; + +function TxmlLdmlProjectFileAction.Clean: Boolean; +var + FJS: string; +begin + CleanFile(OutputFileName); + + if Targets * KMXKeymanTargets <> [] then + CleanFile(ExtractFilePath(FileName) + ExtractFileName(ChangeFileExt(KVKFileName, '.kvk')), True); + + if Targets * KMWKeymanTargets <> [] then + begin + FJS := TKeyboardUtils.GetKeymanWebCompiledFileName(FileName); + CleanFile(FJS); // keyboard.js + end; + + Result := True; +end; + +procedure TxmlLdmlProjectFileAction.CheckFilenameConventions; +begin + if not OwnerProject.Options.CheckFilenameConventions then + Exit; + + if not TKeyboardUtils.DoesKeyboardFilenameFollowConventions(FileName) then + begin + HasCompileWarning := True; + Log(plsWarning, Format(TKeyboardUtils.SKeyboardNameDoesNotFollowConventions_Message, [ExtractFileName(FileName)]), CERR_WARNING, 0); + end; + + if KVKFileName <> '' then + begin + if not TKeyboardUtils.DoesKeyboardFilenameFollowConventions(KVKFileName) then + begin + HasCompileWarning := True; + Log(plsWarning, Format(TKeyboardUtils.SKeyboardNameDoesNotFollowConventions_Message, [ExtractFileName(KVKFileName)]), CERR_WARNING, 0); + end; + end; +end; + +function TxmlLdmlProjectFileAction.CompileKeyboard: Boolean; +var + w: TKmcWrapper; +begin + w := TKmcWrapper.Create; + try + Result := w.Compile(Self, FileName, TargetFilename, Debug); + finally + w.Free; + end; +end; + +initialization + RegisterProjectFileType('.xml', TxmlLdmlProjectFileAction); +end. diff --git a/developer/src/tike/project/Keyman.Developer.UI.Project.UfrmProject.pas b/developer/src/tike/project/Keyman.Developer.UI.Project.UfrmProject.pas index 6fcefc44368..be3a502b306 100644 --- a/developer/src/tike/project/Keyman.Developer.UI.Project.UfrmProject.pas +++ b/developer/src/tike/project/Keyman.Developer.UI.Project.UfrmProject.pas @@ -287,8 +287,8 @@ procedure TfrmProject.CompileAll; ClearMessages; for i := 0 to FGlobalProject.Files.Count - 1 do begin - if (FGlobalProject.Files[i] is TkmnProjectFile) or - (FGlobalProject.Files[i] is TmodelTsProjectFile) then + if FGlobalProject.Files[i].IsCompilable and + not (FGlobalProject.Files[i] is TkpsProjectFile) then begin if not (FGlobalProject.Files[i].UI as TProjectFileUI).DoAction(pfaCompile, False) then Exit; // I4687 end; diff --git a/developer/src/tike/project/Keyman.Developer.UI.Project.xmlLdmlProjectFileUI.pas b/developer/src/tike/project/Keyman.Developer.UI.Project.xmlLdmlProjectFileUI.pas new file mode 100644 index 00000000000..793c12dff6d --- /dev/null +++ b/developer/src/tike/project/Keyman.Developer.UI.Project.xmlLdmlProjectFileUI.pas @@ -0,0 +1,285 @@ +{ + * Keyman is copyright (C) SIL International. MIT License. + * + * xmlLdmlProjectFileUI: User Interface connections for LDML keyboard files +} +unit Keyman.Developer.UI.Project.xmlLdmlProjectFileUI; + +interface + +uses + System.UITypes, + Menus, + Keyman.Developer.UI.Project.ProjectFilesUI, + Keyman.Developer.UI.Project.ProjectFileUI, + Keyman.Developer.UI.Project.ProjectUIFileType, + UfrmMessages, + Keyman.Developer.System.Project.xmlLdmlProjectFile, + Keyman.Developer.System.Project.xmlLdmlProjectFileAction; + +type + TxmlLdmlProjectFileUI = class(TOpenableProjectFileUI) + private + function TestKeymanWeb(FSilent: Boolean): Boolean; + function DebugKeyboard(FSilent: Boolean): Boolean; + function InstallKeyboard: Boolean; + function UninstallKeyboard: Boolean; + function GetProjectFile: TxmlLdmlProjectFileAction; + + function GetDebug: Boolean; + procedure SetDebug(const Value: Boolean); + function CompileKeyboard(FSilent: Boolean): Boolean; + function TestKeyboardState(FCompiledName: string; FSilent: Boolean): Boolean; + public + function DoAction(action: TProjectFileAction; FSilent: Boolean): Boolean; override; + property Debug: Boolean read GetDebug write SetDebug; + property ProjectFile: TxmlLdmlProjectFileAction read GetProjectFile; + end; + +implementation + +uses + Winapi.Windows, + System.Classes, + System.StrUtils, + System.SysUtils, + System.Variants, + Vcl.Dialogs, + Vcl.Graphics, + Vcl.Controls, + dmActionsMain, + + Keyman.Developer.UI.UfrmMessageDlgWithSave, + UfrmMain, + Keyman.Developer.UI.UfrmLdmlKeyboardEditor, + UfrmMDIEditor, + UKeymanTargets, + UmodWebHttpServer, + Keyman.Developer.System.ServerAPI, + Keyman.Developer.UI.ServerUI, + KeyboardFonts, + KeymanDeveloperUtils, + KeymanDeveloperOptions, + utilsystem; + +function TxmlLdmlProjectFileUI.DoAction(action: TProjectFileAction; FSilent: Boolean): Boolean; +begin + case action of + pfaCompile: Result := CompileKeyboard(FSilent); + pfaTestKeymanWeb: Result := TestKeymanWeb(FSilent); + pfaInstall: Result := InstallKeyboard; + pfaUninstall: Result := UninstallKeyboard; +// pfaDebug: Result := DebugKeyboard(FSilent); + pfaClean: Result := ProjectFile.Clean; + else + Result := False; + end; +end; + +function TxmlLdmlProjectFileUI.CompileKeyboard(FSilent: Boolean): Boolean; +var + FSave: Boolean; +begin + Result := False; + + if ProjectFile.Modified then + begin + if not FSilent then + begin + if not FKeymanDeveloperOptions.AutoSaveBeforeCompiling then + begin + if TfrmMessageDlgWithSave.Execute( + 'The keyboard file has been modified. You must save before compiling.'+#13#10#13#10+ + 'Save the keyboard and continue?', + 'Always save automatically before compiling', + '', True, FSave) in [mrNo, mrCancel] then + Exit(False); + if FSave then + begin + FKeymanDeveloperOptions.AutoSaveBeforeCompiling := True; + FKeymanDeveloperOptions.Write; + end; + end; + + if not modActionsMain.actFileSave.Execute then Exit; + end + else + Exit; + end; + + if not FSilent then + frmMessages.DoShowForm; + + Result := + ProjectFile.CompileKeyboard; + + if Result and + TServerDebugAPI.Running and + TServerDebugAPI.IsKeyboardRegistered(ProjectFile.TargetFileName) and + (ProjectFile.Targets * KMWKeymanTargets <> []) then + TestKeymanWeb(True); +end; + +function TxmlLdmlProjectFileUI.GetDebug: Boolean; +begin + Result := ProjectFile.Debug; +end; + +function TxmlLdmlProjectFileUI.GetProjectFile: TxmlLdmlProjectFileAction; +begin + Result := FOwner as TxmlLdmlProjectFileAction; +end; + +procedure TxmlLdmlProjectFileUI.SetDebug(const Value: Boolean); +begin + ProjectFile.Debug := Value; +end; + +function TxmlLdmlProjectFileUI.TestKeymanWeb(FSilent: Boolean): Boolean; // I4409 +(*var + FCompiledName: string; + editor: TfrmTikeEditor; + wizard: TfrmEditor; + i: TKeyboardFont; + j: TKeyboardFont; + Found: Boolean; + + function IsStandardFont(const FontName: string): Boolean; // I4448 + const + StandardFontNames: array[0..9] of string = ( + 'Arial', 'Calibri', 'Consolas', 'Courier New', 'Lucida Console', 'Lucida Sans Unicode', 'Segoe UI', 'Tahoma', 'Times New Roman', 'Verdana' + ); + begin + Result := AnsiIndexText(FontName, StandardFontNames) >= 0; + end; + + procedure RegisterFont(const fontname: string); + var + strm: TMemoryStream; + begin + if (fontname <> '') and not IsStandardFont(fontname) then + begin + strm := TMemoryStream.Create; + try + if TFontLoadUtil.LoadFontData(fontname, strm) and + TServerDebugAPI.Running then + TServerDebugAPI.RegisterFont(strm, fontname); + finally + strm.Free; + end; + end; + end; +begin + editor := frmKeymanDeveloper.FindEditorByFileName(ProjectFile.FileName); // I4021 + if not Assigned(editor) or not (editor is TfrmKeymanWizard) then + Exit(False); + wizard := editor as TfrmKeymanWizard; + + if ProjectFile.Targets * KMWKeymanTargets = [] then + Exit(False); + + FCompiledName := ProjectFile.JSTargetFilename; + if FCompiledName = '' then + Exit(False); + + if not TestKeyboardState(FCompiledName, FSilent) then + Exit(False); + + // We register all fonts that are used by the layout, + // but just once for each reference! + for i := kfontChar to kfontTouchLayoutDesktop do + begin + Found := False; + for j := kfontChar to TKeyboardFont(Ord(i)-1) do + if Wizard.FontInfo[j].Name = Wizard.FontInfo[i].Name then + begin + Found := True; + Break; + end; + if not Found then + RegisterFont(Wizard.FontInfo[i].Name); + end; + + if TServerUI.VerifyServerRunning then + begin + TServerDebugAPI.RegisterKeyboard( + FCompiledName, + ProjectFile.FileVersion, + // We only need to specify the char + osk fonts here + // as the others are referenced in the touch layout definition directly + Wizard.FontInfo[kfontChar].Name, + Wizard.FontInfo[kfontOSK].Name + ); + + wizard.NotifyStartedWebDebug; // I4021 + end; +*) +begin + Result := True; +end; + +function TxmlLdmlProjectFileUI.InstallKeyboard: Boolean; +var + FCompiledName: string; +begin + Result := False; + FCompiledName := ProjectFile.TargetFilename; + if not TestKeyboardState(FCompiledName, False) then Exit; + KeymanDeveloperUtils.InstallKeyboard(FCompiledName, True); + Result := True; +end; + +function TxmlLdmlProjectFileUI.UninstallKeyboard: Boolean; +begin + Result := KeymanDeveloperUtils.UninstallKeyboard(ChangeFileExt(ExtractFileName(ProjectFile.FileName), '')); +end; + +function TxmlLdmlProjectFileUI.DebugKeyboard(FSilent: Boolean): Boolean; +var + editor: TfrmLdmlKeyboardEditor; +begin + editor := frmKeymanDeveloper.OpenEditor(ProjectFile.FileName, TfrmLdmlKeyboardEditor) as TfrmLdmlKeyboardEditor; +// editor.StartDebugging; + Result := True; +end; + +function TxmlLdmlProjectFileUI.TestKeyboardState(FCompiledName: string; FSilent: Boolean): Boolean; +var + ftxml, ftkmx: TDateTime; +begin + Result := False; + + if not FileExists(FCompiledName) then + if FSilent then + begin + if not CompileKeyboard(FSilent) then Exit; + end + else + case MessageDlg('You need to compile the keyboard before you can continue. Compile now?', + mtConfirmation, mbOkCancel, 0) of + mrOk: if not CompileKeyboard(FSilent) then Exit; + mrCancel: Exit; + end; + + FileAge(ProjectFile.FileName, ftxml); + FileAge(FCompiledName, ftkmx); + + if ProjectFile.Modified or (ftxml > ftkmx) then + if FSilent then + begin + if not CompileKeyboard(FSilent) then Exit; + end + else + case MessageDlg('The source file has changed. Recompile before continuing?', + mtConfirmation, mbYesNoCancel, 0) of + mrYes: if not CompileKeyboard(FSilent) then Exit; + mrNo: ; + mrCancel: Exit; + end; + + Result := True; +end; + +initialization + RegisterProjectFileUIType(TxmlLdmlProjectFileAction, TxmlLdmlProjectFileUI); +end. diff --git a/developer/src/tike/tike.dpr b/developer/src/tike/tike.dpr index 72fd1523d22..ac6ad94a5f8 100644 --- a/developer/src/tike/tike.dpr +++ b/developer/src/tike/tike.dpr @@ -151,7 +151,7 @@ uses ErrorControlledRegistry in '..\..\..\common\windows\delphi\vcl\ErrorControlledRegistry.pas', UframeBitmapEditor in 'main\UframeBitmapEditor.pas' {frameBitmapEditor: TFrame}, UfrmMessages in 'main\UfrmMessages.pas' {frmMessages}, - dmActionsKeyboardEditor in 'actions\dmActionsKeyboardEditor.pas' {modActionsKeyboardEditor: TDataModule}, + dmActionsDebugger in 'actions\dmActionsDebugger.pas' {modActionsDebugger: TDataModule}, dmActionsMain in 'actions\dmActionsMain.pas' {modActionsMain: TDataModule}, dmActionsTextEditor in 'actions\dmActionsTextEditor.pas' {modActionsTextEditor: TDataModule}, UfrmCharacterMapNew in '..\..\..\common\windows\delphi\charmap\UfrmCharacterMapNew.pas' {frmCharacterMapNew}, @@ -282,7 +282,12 @@ uses Keyman.Developer.UI.UfrmEditRelatedPackage in 'dialogs\relatedPackages\Keyman.Developer.UI.UfrmEditRelatedPackage.pas' {frmEditRelatedPackage}, Keyman.Developer.UI.UfrmEditPackageWebFonts in 'dialogs\packageWebFonts\Keyman.Developer.UI.UfrmEditPackageWebFonts.pas' {frmEditPackageWebFonts}, Keyman.Developer.System.KmcWrapper in 'compile\Keyman.Developer.System.KmcWrapper.pas', - Keyman.Developer.UI.Project.UpgradeProject in 'project\Keyman.Developer.UI.Project.UpgradeProject.pas'; + Keyman.Developer.UI.Project.UpgradeProject in 'project\Keyman.Developer.UI.Project.UpgradeProject.pas', + Keyman.Developer.System.Project.xmlLdmlProjectFile in 'project\Keyman.Developer.System.Project.xmlLdmlProjectFile.pas', + Keyman.Developer.System.Project.xmlLdmlProjectFileAction in 'project\Keyman.Developer.System.Project.xmlLdmlProjectFileAction.pas', + Keyman.Developer.UI.Project.xmlLdmlProjectFileUI in 'project\Keyman.Developer.UI.Project.xmlLdmlProjectFileUI.pas', + Keyman.Developer.UI.UfrmLdmlKeyboardEditor in 'child\Keyman.Developer.UI.UfrmLdmlKeyboardEditor.pas' {frmLdmlKeyboardEditor}, + dmActionsKeyboardEditor in 'actions\dmActionsKeyboardEditor.pas' {modActionsKeyboardEditor: TDataModule}; {$R *.RES} {$R ICONS.RES} diff --git a/developer/src/tike/tike.dproj b/developer/src/tike/tike.dproj index 7f50777db96..397140f1652 100644 --- a/developer/src/tike/tike.dproj +++ b/developer/src/tike/tike.dproj @@ -345,8 +345,8 @@
frmMessages
- -
modActionsKeyboardEditor
+ +
modActionsDebugger
TDataModule
@@ -560,6 +560,18 @@ + + + + +
frmLdmlKeyboardEditor
+ dfm +
+ +
modActionsKeyboardEditor
+ dfm + TDataModule +
Cfg_2 diff --git a/resources/standards-data/ldml-keyboards/readme.md b/resources/standards-data/ldml-keyboards/readme.md index 66f54789c08..373c7c07451 100644 --- a/resources/standards-data/ldml-keyboards/readme.md +++ b/resources/standards-data/ldml-keyboards/readme.md @@ -9,8 +9,8 @@ That will very roughly correspond to