From e491e3f8b15523b9cb17ed1c3960a6250fd33390 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Tue, 24 Aug 2021 16:55:11 +0200 Subject: [PATCH] rename crowdebuglog to crowPlugin --- CrowEdit.csproj | 12 +- CrowEdit.sln | 12 +- CrowEdit.style | 4 +- CrowEditBase/CrowEditBase.csproj | 6 +- CrowEditBase/icons/log.svg | 1 + CrowEditBase/icons/plugins.svg | 6 + CrowEditBase/icons/services.svg | 9 ++ CrowEditBase/src/CrowEditBase.cs | 18 ++- CrowEditBase/src/Editor.cs | 2 +- CrowEditBase/src/IFileNode.cs | 2 +- CrowEditBase/src/LogViewerWidget.cs | 8 +- CrowEditBase/src/Project.cs | 24 ++- CrowEditBase/src/SourceEditor.cs | 8 +- CrowEditBase/src/VirtualNode.cs | 6 + CrowEditBase/ui/TreeExpandable.template | 2 +- .../CECrowPlugin.csproj} | 6 +- plugins/CECrowPlugin/default.conf | 1 + .../src/CrowService.cs | 46 ++++-- .../src/DbgEventWidget.cs | 2 +- .../src/DbgLogViewer.cs | 12 +- .../src/DebugInterface.cs | 26 +-- .../src/DebugInterfaceWidget.cs | 32 ++-- plugins/CECrowPlugin/src/ImlDocument.cs | 152 ++++++++++++++++++ .../ui/Button.template | 0 .../ui/CheckBox2.imlt | 0 .../ui/DbgEventTreeItems.itemp | 4 +- .../ui/DbgEventView.template | 4 +- .../ui/DbgEvtTooltip.crow | 0 .../ui/DbgWidgetEventListItems.itemp | 0 .../ui/DebugLog.crow | 16 +- .../ui/EnumSelector.template | 0 .../ui/WidgetRecord.itemp | 0 .../ui/dbg.style | 4 +- .../ui/focused.crow | 0 .../ui/main.crow | 0 .../ui/winConfiguration.crow | 14 +- .../ui/winCrowPreview.crow | 0 .../ui/winDebugLog.crow | 16 +- .../ui/winLogGraph.crow | 2 +- .../ui/winLogNavigation.crow | 4 +- .../CENetcoreDbgPlugin.csproj | 2 +- .../src/NetcoreDbgService.cs | 11 ++ .../ui/winConfiguration.crow | 10 -- plugins/CERoslynPlugin/CERoslynPlugin.csproj | 2 +- plugins/CERoslynPlugin/src/CSDocument.cs | 2 +- plugins/CERoslynPlugin/src/MSBuildProject.cs | 20 ++- .../src/ProjectTree/ProjectItemNodes.cs | 3 + plugins/CERoslynPlugin/src/RoslynService.cs | 51 ++++-- plugins/CERoslynPlugin/src/SolutionProject.cs | 12 +- .../CERoslynPlugin/ui/winConfiguration.crow | 25 ++- plugins/CEXmlPlugin/default.conf | 2 +- .../CEXmlPlugin/src/ImlParsing/XmlDocument.cs | 113 +------------ src/CrowEdit.cs | 46 +++--- ui/MenuButton.template | 4 +- ui/main.crow | 2 +- ui/windows/winProjects.crow | 20 ++- 56 files changed, 500 insertions(+), 286 deletions(-) create mode 100644 CrowEditBase/icons/log.svg create mode 100644 CrowEditBase/icons/plugins.svg create mode 100644 CrowEditBase/icons/services.svg rename plugins/{CECrowDebugLog/CECrowDebugLog.csproj => CECrowPlugin/CECrowPlugin.csproj} (55%) create mode 100644 plugins/CECrowPlugin/default.conf rename plugins/{CECrowDebugLog => CECrowPlugin}/src/CrowService.cs (92%) rename plugins/{CECrowDebugLog => CECrowPlugin}/src/DbgEventWidget.cs (99%) rename plugins/{CECrowDebugLog => CECrowPlugin}/src/DbgLogViewer.cs (98%) rename plugins/{CECrowDebugLog => CECrowPlugin}/src/DebugInterface.cs (90%) rename plugins/{CECrowDebugLog => CECrowPlugin}/src/DebugInterfaceWidget.cs (88%) create mode 100644 plugins/CECrowPlugin/src/ImlDocument.cs rename plugins/{CECrowDebugLog => CECrowPlugin}/ui/Button.template (100%) rename plugins/{CECrowDebugLog => CECrowPlugin}/ui/CheckBox2.imlt (100%) rename plugins/{CECrowDebugLog => CECrowPlugin}/ui/DbgEventTreeItems.itemp (92%) rename plugins/{CECrowDebugLog => CECrowPlugin}/ui/DbgEventView.template (96%) rename plugins/{CECrowDebugLog => CECrowPlugin}/ui/DbgEvtTooltip.crow (100%) rename plugins/{CECrowDebugLog => CECrowPlugin}/ui/DbgWidgetEventListItems.itemp (100%) rename plugins/{CECrowDebugLog => CECrowPlugin}/ui/DebugLog.crow (88%) rename plugins/{CECrowDebugLog => CECrowPlugin}/ui/EnumSelector.template (100%) rename plugins/{CECrowDebugLog => CECrowPlugin}/ui/WidgetRecord.itemp (100%) rename plugins/{CECrowDebugLog => CECrowPlugin}/ui/dbg.style (85%) rename plugins/{CECrowDebugLog => CECrowPlugin}/ui/focused.crow (100%) rename plugins/{CECrowDebugLog => CECrowPlugin}/ui/main.crow (100%) rename plugins/{CECrowDebugLog => CECrowPlugin}/ui/winConfiguration.crow (85%) rename plugins/{CECrowDebugLog => CECrowPlugin}/ui/winCrowPreview.crow (100%) rename plugins/{CECrowDebugLog => CECrowPlugin}/ui/winDebugLog.crow (89%) rename plugins/{CECrowDebugLog => CECrowPlugin}/ui/winLogGraph.crow (94%) rename plugins/{CECrowDebugLog => CECrowPlugin}/ui/winLogNavigation.crow (89%) diff --git a/CrowEdit.csproj b/CrowEdit.csproj index 75e0b06..b97f8bd 100644 --- a/CrowEdit.csproj +++ b/CrowEdit.csproj @@ -1,6 +1,6 @@  - netcoreapp5 + netcoreapp3.1 WinExe false @@ -13,8 +13,11 @@ + - + + false @@ -26,8 +29,5 @@ false - - - - \ No newline at end of file + diff --git a/CrowEdit.sln b/CrowEdit.sln index 3608c07..7f96d42 100644 --- a/CrowEdit.sln +++ b/CrowEdit.sln @@ -15,7 +15,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CrowEditBase", "CrowEditBas EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{386C459C-4849-40C3-9D5A-4A8802A5A848}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CECrowDebugLog", "plugins\CECrowDebugLog\CECrowDebugLog.csproj", "{1095C2F1-802F-4DE1-8035-EE0AAC4A5E35}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CECrowPlugin", "plugins\CECrowPlugin\CECrowPlugin.csproj", "{1095C2F1-802F-4DE1-8035-EE0AAC4A5E35}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CENetcoreDbgPlugin", "plugins\CENetcoreDbgPlugin\CENetcoreDbgPlugin.csproj", "{14E49365-6E22-4A27-B0E5-C6BBB347A85C}" EndProject @@ -23,7 +23,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CERoslynPlugin", "plugins\C EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CEXmlPlugin", "plugins\CEXmlPlugin\CEXmlPlugin.csproj", "{196D847E-D051-429B-892F-C405F036B8C2}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Crow", "..\CrowIDE\Crow\Crow\Crow.csproj", "{D0487872-E5A5-424A-AB18-3B2F258D51D5}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Crow", "..\crow\Crow\Crow.csproj", "{5D8999F6-80D8-44CA-93F2-E18C9E44640C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -55,10 +55,10 @@ Global {196D847E-D051-429B-892F-C405F036B8C2}.Debug|Any CPU.Build.0 = Debug|Any CPU {196D847E-D051-429B-892F-C405F036B8C2}.Release|Any CPU.ActiveCfg = Release|Any CPU {196D847E-D051-429B-892F-C405F036B8C2}.Release|Any CPU.Build.0 = Release|Any CPU - {D0487872-E5A5-424A-AB18-3B2F258D51D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D0487872-E5A5-424A-AB18-3B2F258D51D5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D0487872-E5A5-424A-AB18-3B2F258D51D5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D0487872-E5A5-424A-AB18-3B2F258D51D5}.Release|Any CPU.Build.0 = Release|Any CPU + {5D8999F6-80D8-44CA-93F2-E18C9E44640C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5D8999F6-80D8-44CA-93F2-E18C9E44640C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5D8999F6-80D8-44CA-93F2-E18C9E44640C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5D8999F6-80D8-44CA-93F2-E18C9E44640C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/CrowEdit.style b/CrowEdit.style index ad8f71a..5bfdb06 100644 --- a/CrowEdit.style +++ b/CrowEdit.style @@ -4,7 +4,7 @@ InactiveTabBackground = "DarkGrey"; SelectedTabBackground = "Onyx"; InactiveTabForeground = "Grey"; SelectedTabForeground = "White"; -MenuIconSize = "14"; +MenuIconSize = "16"; ControlHighlight = "RoyalBlue"; @@ -31,7 +31,7 @@ MenuItem { } MenuIcon { - Margin = "2"; + Margin = "1"; Width = "${MenuIconSize}"; Height = "${MenuIconSize}"; } diff --git a/CrowEditBase/CrowEditBase.csproj b/CrowEditBase/CrowEditBase.csproj index 5308721..b255137 100644 --- a/CrowEditBase/CrowEditBase.csproj +++ b/CrowEditBase/CrowEditBase.csproj @@ -13,7 +13,7 @@ - - + + - \ No newline at end of file + diff --git a/CrowEditBase/icons/log.svg b/CrowEditBase/icons/log.svg new file mode 100644 index 0000000..0f8a358 --- /dev/null +++ b/CrowEditBase/icons/log.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/CrowEditBase/icons/plugins.svg b/CrowEditBase/icons/plugins.svg new file mode 100644 index 0000000..14ea6f3 --- /dev/null +++ b/CrowEditBase/icons/plugins.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/CrowEditBase/icons/services.svg b/CrowEditBase/icons/services.svg new file mode 100644 index 0000000..c1a14e7 --- /dev/null +++ b/CrowEditBase/icons/services.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/CrowEditBase/src/CrowEditBase.cs b/CrowEditBase/src/CrowEditBase.cs index c232988..e823f40 100644 --- a/CrowEditBase/src/CrowEditBase.cs +++ b/CrowEditBase/src/CrowEditBase.cs @@ -56,7 +56,7 @@ namespace CrowEditBase Document currentDocument; Editor currentEditor; Project currentProject; - public CommandGroup FileCommands, EditCommands; + public CommandGroup CommandsRoot, FileCommands, EditCommands, ViewCommands; public ObservableList OpenedDocuments = new ObservableList (); public ObservableList Services = new ObservableList (); public ObservableList Plugins = new ObservableList (); @@ -81,6 +81,22 @@ namespace CrowEditBase plugin = Plugins.FirstOrDefault (p=>p.Name == pluginName); return plugin != null; } + //TODO:flattened project + public IEnumerable FlattenProjects { + get { + foreach (var node in Projects.SelectMany (child => child.Flatten)) + yield return node; + } + } + public bool TryGetProject (string projectFullPath, out T proj) where T : Project { + proj = FlattenProjects.FirstOrDefault (p=>p.FullPath == projectFullPath) as T; + return proj != null; + } + public bool TryGetProject (string projectFullPath, out Project proj) { + proj = FlattenProjects.FirstOrDefault (p=>p.FullPath == projectFullPath); + return proj != null; + } + public Document CurrentDocument { get => currentDocument; set { diff --git a/CrowEditBase/src/Editor.cs b/CrowEditBase/src/Editor.cs index d9e803f..a0ad516 100644 --- a/CrowEditBase/src/Editor.cs +++ b/CrowEditBase/src/Editor.cs @@ -6,7 +6,7 @@ using System; using Glfw; using Crow.Text; using System.Collections.Generic; -using Crow.Cairo; +using Crow.Drawing; using System.Threading.Tasks; using System.Linq; using System.Diagnostics.CodeAnalysis; diff --git a/CrowEditBase/src/IFileNode.cs b/CrowEditBase/src/IFileNode.cs index 9f3077a..93a7121 100644 --- a/CrowEditBase/src/IFileNode.cs +++ b/CrowEditBase/src/IFileNode.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Jean-Philippe Bruyère +// Copyright (c) 2021 Jean-Philippe Bruyère // // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) using System; diff --git a/CrowEditBase/src/LogViewerWidget.cs b/CrowEditBase/src/LogViewerWidget.cs index f9bd3a5..ee2f4a1 100644 --- a/CrowEditBase/src/LogViewerWidget.cs +++ b/CrowEditBase/src/LogViewerWidget.cs @@ -6,10 +6,14 @@ using System; using System.Xml.Serialization; using System.ComponentModel; using System.Collections; -using Crow.Cairo; +using Crow.Drawing; namespace Crow { + public enum LogLevel + { + Minimal, Normal, Full, Debug + } public enum LogType { Low, Normal, @@ -107,7 +111,7 @@ namespace Crow MaxScrollY = lines == null ? 0 : lines.Count - visibleLines; } } - protected override void onDraw (Cairo.Context gr) + protected override void onDraw (Context gr) { base.onDraw (gr); diff --git a/CrowEditBase/src/Project.cs b/CrowEditBase/src/Project.cs index 4c001ad..82c1e67 100644 --- a/CrowEditBase/src/Project.cs +++ b/CrowEditBase/src/Project.cs @@ -21,6 +21,15 @@ namespace CrowEditBase public Project Parent => parent; public IList SubProjects => subProjects; + public IEnumerable Flatten { + get { + yield return this; + if (subProjects != null) { + foreach (var node in subProjects?.SelectMany (child => child.Flatten)) + yield return node; + } + } + } public bool HasChildren => subProjects?.Count > 0; public string FullPath { get ; private set; } @@ -44,18 +53,27 @@ namespace CrowEditBase initCommands (); FullPath = fullPath; } - public Command CMDLoad, CMDUnload, CMDReload; + public Command CMDLoad, CMDUnload, CMDReload, CMDClose; public virtual CommandGroup Commands => new CommandGroup ( - CMDLoad, CMDUnload, CMDReload); + CMDLoad, CMDUnload, CMDReload, CMDClose); void initCommands () { CMDLoad = new Command ("Load", Load, "#icons.reply.svg", false); CMDUnload = new Command ("Unload", Unload, "#icons.share-arrow.svg", false); CMDReload = new Command ("Reload", () => { Unload(); Load();}, "#icons.refresh.svg", false); + CMDClose = new Command ("Close", Close, "#icons.share-arrow.svg", true); } public abstract void Load (); - public abstract void Unload (); + public virtual void Unload () { + IsLoaded = false; + } + public virtual void Close () { + if (App.CurrentProject == this) + App.CurrentProject = null; + App.Projects.Remove (this); + IsLoaded = false; + } public virtual string Icon => "#icons.question.svg"; } } \ No newline at end of file diff --git a/CrowEditBase/src/SourceEditor.cs b/CrowEditBase/src/SourceEditor.cs index 382a8d5..37358b6 100644 --- a/CrowEditBase/src/SourceEditor.cs +++ b/CrowEditBase/src/SourceEditor.cs @@ -6,7 +6,7 @@ using System; using Glfw; using Crow.Text; using System.Collections.Generic; -using Crow.Cairo; +using Crow.Drawing; using System.Threading.Tasks; using System.Linq; using System.Diagnostics.CodeAnalysis; @@ -65,7 +65,7 @@ namespace Crow lock (IFace.UpdateMutex) { if (overlay == null) { overlay = IFace.LoadIMLFragment(@" - + - + @@ -83,7 +83,7 @@ namespace Crow - + diff --git a/CrowEditBase/src/VirtualNode.cs b/CrowEditBase/src/VirtualNode.cs index e1d773d..7da4991 100644 --- a/CrowEditBase/src/VirtualNode.cs +++ b/CrowEditBase/src/VirtualNode.cs @@ -22,6 +22,12 @@ namespace CrowEditBase public override string Caption => caption; public override NodeType NodeType => nodeType; + + public override CommandGroup Commands { + get { + return null; + } + } } } diff --git a/CrowEditBase/ui/TreeExpandable.template b/CrowEditBase/ui/TreeExpandable.template index 94641ae..8838166 100644 --- a/CrowEditBase/ui/TreeExpandable.template +++ b/CrowEditBase/ui/TreeExpandable.template @@ -1,5 +1,5 @@  - + diff --git a/plugins/CECrowDebugLog/CECrowDebugLog.csproj b/plugins/CECrowPlugin/CECrowPlugin.csproj similarity index 55% rename from plugins/CECrowDebugLog/CECrowDebugLog.csproj rename to plugins/CECrowPlugin/CECrowPlugin.csproj index a20d97d..f982122 100644 --- a/plugins/CECrowDebugLog/CECrowDebugLog.csproj +++ b/plugins/CECrowPlugin/CECrowPlugin.csproj @@ -1,15 +1,17 @@ - netcoreapp5 + netcoreapp3.1 false + - + + diff --git a/plugins/CECrowPlugin/default.conf b/plugins/CECrowPlugin/default.conf new file mode 100644 index 0000000..69586b6 --- /dev/null +++ b/plugins/CECrowPlugin/default.conf @@ -0,0 +1 @@ +FileAssociations=CECrowPlugin.ImlDocument:.crow,.iml,.itmp,.template \ No newline at end of file diff --git a/plugins/CECrowDebugLog/src/CrowService.cs b/plugins/CECrowPlugin/src/CrowService.cs similarity index 92% rename from plugins/CECrowDebugLog/src/CrowService.cs rename to plugins/CECrowPlugin/src/CrowService.cs index 06cd564..615435d 100644 --- a/plugins/CECrowDebugLog/src/CrowService.cs +++ b/plugins/CECrowPlugin/src/CrowService.cs @@ -7,7 +7,7 @@ using Glfw; using System.Reflection; using System.Runtime.Loader; using System.IO; -using Crow.Cairo; +using Crow.Drawing; using System.Diagnostics; using System.Collections.Generic; using Crow.DebugLogger; @@ -17,9 +17,8 @@ using System.Threading; using Crow.Text; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; -using System.Runtime.Loader; - using static CrowEditBase.CrowEditBase; + namespace Crow { public class CrowService : Service { @@ -30,12 +29,12 @@ namespace Crow //resolve other plugins dependencies //AssemblyLoadContext.GetLoadContext (Assembly.GetExecutingAssembly ()).Resolving += resolvePluginRefs; - if (CrowEditBase.CrowEditBase.App.TryGetWindow ("#CECrowDebugLog.ui.winLogGraph.crow", out Window win)) + if (CrowEditBase.CrowEditBase.App.TryGetWindow ("#CECrowPlugin.ui.winLogGraph.crow", out Window win)) win.DataSource = this; } - Assembly resolvePluginRefs (AssemblyLoadContext ctx, AssemblyName assemblyName) + /*Assembly resolvePluginRefs (AssemblyLoadContext ctx, AssemblyName assemblyName) => App.TryGetPlugin ("CERoslynPlugin", out Plugin roslynPlugin) ? - roslynPlugin.Load (assemblyName) : null; + roslynPlugin.Load (assemblyName) : null;*/ static IntPtr resolveUnmanaged(Assembly assembly, String libraryName) { @@ -57,7 +56,8 @@ namespace Crow Console.WriteLine (project.Name); }else if (App.CurrentProject is CERoslynPlugin.MSBuildProject csprj){ CERoslynPlugin.MSBuildProject project = App.CurrentProject as CERoslynPlugin.MSBuildProject; - Console.WriteLine (project.Name); + Console.WriteLine ($"{project.Name}: {project.IsCrowProject}"); + } @@ -71,6 +71,8 @@ namespace Crow CMDGotoParentEvent, CMDEventHistoryBackward, CMDEventHistoryForward); void initCommands () { + App.ViewCommands.Add ( + new Command("Crow Preview", () => App.LoadWindow ("#CECrowPlugin.ui.winCrowPreview.crow", App))); CMDRefresh = new Command ("Refresh", refresh, "#icons.refresh.svg", IsRunning); CMDStartRecording = new Command ("Start Recording", () => Recording = true, "#icons.circle.svg", false); CMDStopRecording = new Command ("Stop Recording", stopRecording, "#icons.circle-red.svg", false); @@ -119,6 +121,7 @@ namespace Crow bool recording, debugLogIsEnabled; DbgEvtType recordedEvents = DbgEvtType.Widget, discardedEvents; + public bool HasVkvgBackend { get; private set; } public int RefreshRate { get => Configuration.Global.Get ("RefreshRate", 10); set { @@ -129,7 +132,7 @@ namespace Crow } } public int MaxLayoutingTries { - get => Configuration.Global.Get ("MaxLayoutingTries", 3); + get => Configuration.Global.Get ("MaxLayoutingTries", 30); set { if (MaxLayoutingTries == value) return; @@ -167,7 +170,7 @@ namespace Crow Configuration.Global.Set ("CrowDbgAssemblyLocation", value); NotifyValueChanged(value); } - } + } public bool DebugLogIsEnabled { get => debugLogIsEnabled; set { @@ -252,6 +255,11 @@ namespace Crow crowLoadCtx = new AssemblyLoadContext("CrowDebuggerLoadContext"); crowLoadCtx.ResolvingUnmanagedDll += resolveUnmanaged; + crowLoadCtx.Resolving += (context, assemblyName) => { + return crowLoadCtx.LoadFromAssemblyPath ( + System.IO.Path.Combine ( + System.IO.Path.GetDirectoryName(CrowDbgAssemblyLocation), assemblyName.Name + ".dll")); + }; //crowLoadCtx.Resolving += (ctx,name) => AssemblyLoadContext.Default.LoadFromAssemblyName (name); //using (crowLoadCtx.EnterContextualReflection()) { @@ -261,7 +269,7 @@ namespace Crow Type debuggerType = crowAssembly.GetType("Crow.DbgLogger"); DebugLogIsEnabled = (bool)debuggerType.GetField("IsEnabled").GetValue(null); - dbgIfaceType = thisAssembly.GetType("CECrowDebugLog.DebugInterface"); + dbgIfaceType = thisAssembly.GetType("CECrowPlugin.DebugInterface"); dbgIFace = Activator.CreateInstance (dbgIfaceType, new object[] {CrowEditBase.CrowEditBase.App.WindowHandle}); @@ -305,7 +313,7 @@ namespace Crow delResetDebugger = (Action)Delegate.CreateDelegate(typeof(Action), null, debuggerType.GetMethod("Reset")); /*delSaveDebugLog = (Action)Delegate.CreateDelegate(typeof(Action), null, debuggerType.GetMethod("Save", new Type[] {dbgIfaceType, typeof(string)}));*/ - + HasVkvgBackend = (bool)dbgIfaceType.GetField ("HaveVkvgBackend", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).GetValue (null); dbgIfaceType.GetMethod("RegisterDebugInterfaceCallback").Invoke (dbgIFace, new object[] {this} ); dbgIfaceType.GetMethod("Run").Invoke (dbgIFace, null); @@ -327,8 +335,16 @@ namespace Crow { CurrentState = Status.Paused; } - public override string ConfigurationWindowPath => "#CECrowDebugLog.ui.winConfiguration.crow"; - + public override string ConfigurationWindowPath => "#CECrowPlugin.ui.winConfiguration.crow"; + public Command CMDOptions_SelectCrowDbgAssemblyLocation => new Command ("...", + () => { + FileDialog dlg = App.LoadIMLFragment (@" + "); + dlg.OkClicked += (sender, e) => CrowDbgAssemblyLocation = (sender as FileDialog).SelectedFileFullPath; + dlg.DataSource = this; + } + ); protected override void onStateChange(Status previousState, Status newState) { base.onStateChange(previousState, newState); @@ -426,8 +442,6 @@ namespace Crow } } } - - public IntPtr SurfacePointer => IsRunning ? delGetSurfacePointer() : IntPtr.Zero; public void Resize (int width, int height) { if (IsRunning) @@ -470,7 +484,7 @@ namespace Crow return; Recording = false; getLog (); - CrowEditBase.CrowEditBase.App.LoadWindow ("#CECrowDebugLog.ui.winDebugLog.crow", this); + CrowEditBase.CrowEditBase.App.LoadWindow ("#CECrowPlugin.ui.winDebugLog.crow", this); } int firstWidgetIndexToGet = 0; public object LogMutex = new object (); diff --git a/plugins/CECrowDebugLog/src/DbgEventWidget.cs b/plugins/CECrowPlugin/src/DbgEventWidget.cs similarity index 99% rename from plugins/CECrowDebugLog/src/DbgEventWidget.cs rename to plugins/CECrowPlugin/src/DbgEventWidget.cs index b075b4c..5960a8c 100644 --- a/plugins/CECrowDebugLog/src/DbgEventWidget.cs +++ b/plugins/CECrowPlugin/src/DbgEventWidget.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using Crow.Cairo; +using Crow.Drawing; using Crow.DebugLogger; namespace Crow diff --git a/plugins/CECrowDebugLog/src/DbgLogViewer.cs b/plugins/CECrowPlugin/src/DbgLogViewer.cs similarity index 98% rename from plugins/CECrowDebugLog/src/DbgLogViewer.cs rename to plugins/CECrowPlugin/src/DbgLogViewer.cs index cef4082..67ca7cc 100644 --- a/plugins/CECrowDebugLog/src/DbgLogViewer.cs +++ b/plugins/CECrowPlugin/src/DbgLogViewer.cs @@ -8,7 +8,7 @@ using System.ComponentModel; using System.IO; using System.Linq; using System.Threading.Tasks; -using Crow.Cairo; +using Crow.Drawing; using Crow.DebugLogger; using System.Diagnostics; @@ -245,7 +245,7 @@ namespace Crow } DbgEvtType currentFilter; - protected override void onDraw (Cairo.Context gr) + protected override void onDraw (Context gr) { base.onDraw (gr); @@ -329,7 +329,7 @@ namespace Crow } string ticksToMS(long ticks) => Math.Round ((double)ticks / Stopwatch.Frequency * 1000.0, 2).ToString(); - public override void Paint (Cairo.Context ctx) + public override void Paint (Context ctx) { base.Paint (ctx); @@ -369,7 +369,7 @@ namespace Crow ctx.MoveTo (ctxR.X - ctx.TextExtents (str).Width / 2, ctxR.Y + fe.Height); ctx.ShowText (str); - ctx.Operator = Cairo.Operator.Add; + ctx.Operator = Operator.Add; if (hoverLine >= 0) { double y = fe.Height * (hoverLine - ScrollY) + topMargin + cb.Top; @@ -396,7 +396,7 @@ namespace Crow } if (selStart < 0 || selEnd < 0) { - ctx.Operator = Cairo.Operator.Over; + ctx.Operator = Operator.Over; return; } double selStartX = (double)(selStart - ScrollX - minTicks) * xScale + leftMargin + cb.Left; @@ -415,7 +415,7 @@ namespace Crow ctx.SetSource (0.0,0.2,0.8,0.15); //ctx.SetSource (Colors.Jet); ctx.Fill(); - ctx.Operator = Cairo.Operator.Over; + ctx.Operator = Operator.Over; str = $"{ticksToMS(Math.Abs (selEnd - selStart))} (ms)"; diff --git a/plugins/CECrowDebugLog/src/DebugInterface.cs b/plugins/CECrowPlugin/src/DebugInterface.cs similarity index 90% rename from plugins/CECrowDebugLog/src/DebugInterface.cs rename to plugins/CECrowPlugin/src/DebugInterface.cs index 0ee8177..ec3bed9 100644 --- a/plugins/CECrowDebugLog/src/DebugInterface.cs +++ b/plugins/CECrowPlugin/src/DebugInterface.cs @@ -6,23 +6,24 @@ using System; using System.Threading; using Crow; -using Crow.Cairo; +using Crow.Drawing; using IML = Crow.IML; -namespace CECrowDebugLog +namespace CECrowPlugin { public class DebugInterface : Interface { static DebugInterface() { DbgLogger.IncludeEvents = DbgEvtType.None; DbgLogger.DiscardEvents = DbgEvtType.None; DbgLogger.ConsoleOutput = false; - Interface.MaxLayoutingTries = 3; - Interface.MaxDiscardCount = 25; } public DebugInterface (IntPtr hWin) : base (100, 100, hWin) { SolidBackground = false; - surf = new ImageSurface (Format.Argb32, 100, 100); + initBackend (true); + + clientRectangle = new Rectangle (0, 0, 100, 100); + CreateMainSurface (ref clientRectangle); } public override void Run() @@ -130,16 +131,21 @@ namespace CECrowDebugLog Source = src; } public void Resize (int width, int height) { - + if (!HaveVkvgBackend) + ProcessResize (new Rectangle(0,0,width, height)); + } + public override void ProcessResize(Rectangle bounds) { lock (UpdateMutex) { - clientRectangle = new Rectangle (0, 0, width, height); - surf?.Dispose(); - surf = new ImageSurface (Format.Argb32, width, height); + clientRectangle = bounds.Size; + + CreateMainSurface (ref clientRectangle); + foreach (Widget g in GraphicTree) g.RegisterForLayouting (LayoutingType.All); + RegisterClip (clientRectangle); } - } + } /*public override void ForceMousePosition() { Point p = (Point)delGetScreenCoordinate(); diff --git a/plugins/CECrowDebugLog/src/DebugInterfaceWidget.cs b/plugins/CECrowPlugin/src/DebugInterfaceWidget.cs similarity index 88% rename from plugins/CECrowDebugLog/src/DebugInterfaceWidget.cs rename to plugins/CECrowPlugin/src/DebugInterfaceWidget.cs index 9926fa9..738b549 100644 --- a/plugins/CECrowDebugLog/src/DebugInterfaceWidget.cs +++ b/plugins/CECrowPlugin/src/DebugInterfaceWidget.cs @@ -7,7 +7,7 @@ using Glfw; using System.Reflection; using System.Runtime.Loader; using System.IO; -using Crow.Cairo; +using Crow.Drawing; using System.Diagnostics; using System.Collections.Generic; using Crow.DebugLogger; @@ -18,6 +18,7 @@ using Crow.Text; using System.Runtime.InteropServices; using static CrowEditBase.CrowEditBase; +using CECrowPlugin; namespace Crow { @@ -70,20 +71,22 @@ namespace Crow } string imlSource; - TextDocument document; + ImlDocument document; public TextDocument Document { get => document; set { if (document == value) return; - - document?.UnregisterClient (this); - imlSource = ""; - document = value; - document?.RegisterClient (this); - - NotifyValueChangedAuto (document); - RegisterForGraphicUpdate (); + + if (value is ImlDocument imlDoc) { + document?.UnregisterClient (this); + imlSource = ""; + document = imlDoc; + document?.RegisterClient (this); + + NotifyValueChangedAuto (document); + RegisterForGraphicUpdate (); + } } } @@ -136,9 +139,12 @@ namespace Crow if (crowIFaceService != null && crowIFaceService.IsRunning) { crowIFaceService.Resize (Slot.Width, Slot.Height); - bmp = Crow.Cairo.Surface.Lookup (crowIFaceService.SurfacePointer, false); - } else - bmp = IFace.surf.CreateSimilar (Content.ColorAlpha, Slot.Width, Slot.Height); + if (crowIFaceService.HasVkvgBackend) + bmp = IFace.CreateSurfaceForData (crowIFaceService.SurfacePointer, Slot.Width, Slot.Height); + else + bmp = IFace.CreateSurface (crowIFaceService.SurfacePointer); + bmp = Crow.Drawing.Surface.Lookup (crowIFaceService.SurfacePointer, false); + } IsDirty = false; } diff --git a/plugins/CECrowPlugin/src/ImlDocument.cs b/plugins/CECrowPlugin/src/ImlDocument.cs new file mode 100644 index 0000000..0b6aef1 --- /dev/null +++ b/plugins/CECrowPlugin/src/ImlDocument.cs @@ -0,0 +1,152 @@ +// Copyright (c) 2013-2021 Bruyère Jean-Philippe +// +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + +using System; +using System.Linq; +using Crow.Text; +using System.Collections.Generic; +using System.Diagnostics; +using Crow; +using IML = Crow.IML; +using System.Collections; +using System.Reflection; +using CrowEditBase; +using static CrowEditBase.CrowEditBase; + +using CrowEdit.Xml; + +namespace CECrowPlugin +{ + public class ImlDocument : XmlDocument { + + public ImlDocument (string fullPath) : base (fullPath) { + App.GetService ()?.Start (); + } + + string[] allWidgetNames = typeof (Widget).Assembly.GetExportedTypes ().Where(t=>typeof(Widget).IsAssignableFrom (t)) + .Select (s => s.Name).ToArray (); + + + IEnumerable getAllCrowTypeMembers (string crowTypeName) { + Type crowType = IML.Instantiator.GetWidgetTypeFromName (crowTypeName); + return crowType.GetMembers (BindingFlags.Public | BindingFlags.Instance). + Where (m=>((m is PropertyInfo pi && pi.CanWrite) || (m is EventInfo)) && + m.GetCustomAttribute() == null); + } + MemberInfo getCrowTypeMember (string crowTypeName, string memberName) { + Type crowType = IML.Instantiator.GetWidgetTypeFromName (crowTypeName); + return crowType.GetMember (memberName, BindingFlags.Public | BindingFlags.Instance).FirstOrDefault (); + } + public override IList GetSuggestions (int pos) { + base.GetSuggestions (pos); +#if DEBUG + Console.WriteLine ($"Current Token: {currentToken} Current Node: {currentNode}"); +#endif + + if (currentToken.GetTokenType() == XmlTokenType.ElementOpen) + return new List (allWidgetNames); + if (currentToken.GetTokenType() == XmlTokenType.ElementName) + return allWidgetNames.Where (s => s.StartsWith (currentToken.AsString (Source), StringComparison.OrdinalIgnoreCase)).ToList (); + if (currentNode is AttributeSyntax attribNode) { + if (currentNode.Parent is ElementTagSyntax eltTag) { + if (eltTag.NameToken.HasValue) { + if (currentToken.GetTokenType() == XmlTokenType.AttributeName) { + return getAllCrowTypeMembers (eltTag.NameToken.Value.AsString (Source)) + .Where (s => s.Name.StartsWith (currentToken.AsString (Source), StringComparison.OrdinalIgnoreCase)).ToList (); + } else if (attribNode.NameToken.HasValue) { + if (currentToken.GetTokenType() == XmlTokenType.AttributeValue) { + MemberInfo mi = getCrowTypeMember ( + eltTag.NameToken.Value.AsString (Source), attribNode.NameToken.Value.AsString (Source)); + if (mi is PropertyInfo pi) { + if (pi.Name == "Style") + return App.Styling.Keys + .Where (s => s.StartsWith (currentToken.AsString (Source), StringComparison.OrdinalIgnoreCase)).ToList (); + if (pi.PropertyType.IsEnum) + return Enum.GetNames (pi.PropertyType) + .Where (s => s.StartsWith (currentToken.AsString (Source), StringComparison.OrdinalIgnoreCase)).ToList (); + if (pi.PropertyType == typeof(bool)) + return (new string[] {"true", "false"}). + Where (s => s.StartsWith (currentToken.AsString (Source), StringComparison.OrdinalIgnoreCase)).ToList (); + if (pi.PropertyType == typeof (Measure)) + return (new string[] {"Stretched", "Fit"}). + Where (s => s.StartsWith (currentToken.AsString (Source), StringComparison.OrdinalIgnoreCase)).ToList (); + if (pi.PropertyType == typeof (Fill)) + return EnumsNET.Enums.GetValues () + .Where (s => s.ToString().StartsWith (currentToken.AsString (Source), StringComparison.OrdinalIgnoreCase)).ToList (); + } + } else if (currentToken.GetTokenType() == XmlTokenType.AttributeValueOpen) { + MemberInfo mi = getCrowTypeMember ( + eltTag.NameToken.Value.AsString (Source), attribNode.NameToken.Value.AsString (Source)); + if (mi is PropertyInfo pi) { + if (pi.Name == "Style") + return App.Styling.Keys.ToList (); + if (pi.PropertyType.IsEnum) + return Enum.GetNames (pi.PropertyType).ToList (); + if (pi.PropertyType == typeof(bool)) + return new List (new string[] {"true", "false"}); + if (pi.PropertyType == typeof (Fill)) + return EnumsNET.Enums.GetValues ().ToList (); + if (pi.PropertyType == typeof (Measure)) + return new List (new string[] {"Stretched", "Fit"}); + } + } + } + } + } + } else if (currentToken.GetTokenType() != XmlTokenType.AttributeValueClose && + currentToken.GetTokenType() != XmlTokenType.EmptyElementClosing && + currentToken.GetTokenType() != XmlTokenType.ClosingSign && + currentNode is ElementStartTagSyntax eltStartTag) { + if (currentToken.GetTokenType() == XmlTokenType.AttributeName) + return getAllCrowTypeMembers (eltStartTag.NameToken.Value.AsString (Source)) + .Where (s => s.Name.StartsWith (currentToken.AsString (Source), StringComparison.OrdinalIgnoreCase)).ToList (); + //else if (currentToken.Type == TokenType.ElementName) + // Suggestions = getAllCrowTypeMembers (eltStartTag.NameToken.Value.AsString (Source)).ToList (); + } else { + /*SyntaxNode curNode = source.FindNodeIncludingPosition (pos); + Console.WriteLine ($"Current Node: {curNode}"); + if (curNode is ElementStartTagSyntax eltStartTag && + (currentToken.Type != TokenType.ClosingSign && currentToken.Type != TokenType.EmptyElementClosing && currentToken.Type != TokenType.Unknown)) { + Suggestions = getAllCrowTypeMembers (eltStartTag.NameToken.Value.AsString (Source)).ToList (); + } else*/ + + } + return null; + } + public override TextChange? GetCompletionForCurrentToken (object suggestion, out TextSpan? newSelection) { + newSelection = null; + + string selectedSugg = suggestion is MemberInfo mi ? + mi.Name : suggestion?.ToString (); + if (selectedSugg == null) + return null; + + if (currentToken.GetTokenType() == XmlTokenType.ElementOpen || + currentToken.GetTokenType() == XmlTokenType.WhiteSpace || + currentToken.GetTokenType() == XmlTokenType.AttributeValueOpen) + return new TextChange (currentToken.End, 0, selectedSugg); + + if (currentToken.GetTokenType() == XmlTokenType.AttributeName && currentNode is AttributeSyntax attrib) { + if (attrib.ValueToken.HasValue) { + TextChange tc = new TextChange (currentToken.Start, currentToken.Length, selectedSugg); + newSelection = new TextSpan( + attrib.ValueToken.Value.Start + tc.CharDiff + 1, + attrib.ValueToken.Value.End + tc.CharDiff - 1 + ); + return tc; + } else { + newSelection = TextSpan.FromStartAndLength (currentToken.Start + selectedSugg.Length + 2); + return new TextChange (currentToken.Start, currentToken.Length, selectedSugg + "=\"\""); + } + } + + return new TextChange (currentToken.Start, currentToken.Length, selectedSugg); + } + + public override Color GetColorForToken(TokenType tokType) + { + return base.GetColorForToken (tokType); + } + } +} \ No newline at end of file diff --git a/plugins/CECrowDebugLog/ui/Button.template b/plugins/CECrowPlugin/ui/Button.template similarity index 100% rename from plugins/CECrowDebugLog/ui/Button.template rename to plugins/CECrowPlugin/ui/Button.template diff --git a/plugins/CECrowDebugLog/ui/CheckBox2.imlt b/plugins/CECrowPlugin/ui/CheckBox2.imlt similarity index 100% rename from plugins/CECrowDebugLog/ui/CheckBox2.imlt rename to plugins/CECrowPlugin/ui/CheckBox2.imlt diff --git a/plugins/CECrowDebugLog/ui/DbgEventTreeItems.itemp b/plugins/CECrowPlugin/ui/DbgEventTreeItems.itemp similarity index 92% rename from plugins/CECrowDebugLog/ui/DbgEventTreeItems.itemp rename to plugins/CECrowPlugin/ui/DbgEventTreeItems.itemp index aeee763..135b13c 100644 --- a/plugins/CECrowDebugLog/ui/DbgEventTreeItems.itemp +++ b/plugins/CECrowPlugin/ui/DbgEventTreeItems.itemp @@ -20,7 +20,7 @@ MouseLeave="{Background=Transparent}"/> @@ -55,7 +55,7 @@