From: Jean-Philippe Bruyère Date: Mon, 21 Jul 2025 04:45:21 +0000 (+0200) Subject: wip, save commit X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=1885a774537386697e634e807be9efad45bb98b8;p=jp%2Fcrowedit.git wip, save commit --- diff --git a/CrowEdit.csproj b/CrowEdit.csproj index 9415782..c77614b 100644 --- a/CrowEdit.csproj +++ b/CrowEdit.csproj @@ -1,6 +1,6 @@  - net9 + net6 WinExe false diff --git a/CrowEditBase/CrowEditBase.csproj b/CrowEditBase/CrowEditBase.csproj index 15f76ef..4f93924 100644 --- a/CrowEditBase/CrowEditBase.csproj +++ b/CrowEditBase/CrowEditBase.csproj @@ -1,7 +1,7 @@ - net9 + net6 false diff --git a/CrowEditBase/src/Compiler/SourceDocument.cs b/CrowEditBase/src/Compiler/SourceDocument.cs index 8518ca8..8ee2e1d 100644 --- a/CrowEditBase/src/Compiler/SourceDocument.cs +++ b/CrowEditBase/src/Compiler/SourceDocument.cs @@ -128,7 +128,7 @@ namespace CrowEditBase } #endregion protected abstract SyntaxAnalyser CreateSyntaxAnalyser (); - public virtual Color GetColorForToken (Token token) + public virtual Color GetColorForToken (Token token, SyntaxNode node = null) { TokenType tokType = token.Type; if (tokType.HasFlag (TokenType.Punctuation)) diff --git a/CrowEditBase/src/CrowEditBase.cs b/CrowEditBase/src/CrowEditBase.cs index 9be1cc7..58459aa 100644 --- a/CrowEditBase/src/CrowEditBase.cs +++ b/CrowEditBase/src/CrowEditBase.cs @@ -48,6 +48,7 @@ namespace CrowEditBase public ObservableList Plugins = new ObservableList (); public ObservableList Projects = new ObservableList (); + public ObservableList KeyBindings = new ObservableList(); #region logging LogItem currentLog; diff --git a/CrowEditBase/src/Editor.cs b/CrowEditBase/src/Editor.cs index 50128da..4eebf3e 100644 --- a/CrowEditBase/src/Editor.cs +++ b/CrowEditBase/src/Editor.cs @@ -32,9 +32,9 @@ namespace CrowEditBase public Command CMDCut, CMDCopy, CMDPaste; void initCommands () { - CMDCut = new ActionCommand ("Cut", Cut, "#icons.scissors.svg", false); - CMDCopy = new ActionCommand ("Copy", Copy, "#icons.copy-file.svg", false); - CMDPaste = new ActionCommand ("Paste", Paste, "#icons.paste-on-document.svg", true); + CMDCut = new ActionCommand (this, "Cut", Cut, "#icons.scissors.svg", new KeyBinding(Key.X, Modifier.Control), false); + CMDCopy = new ActionCommand (this, "Copy", Copy, "#icons.copy-file.svg", new KeyBinding(Key.C, Modifier.Control), false); + CMDPaste = new ActionCommand (this, "Paste", Paste, "#icons.paste-on-document.svg", new KeyBinding(Key.P, Modifier.Control), true); ContextCommands = new CommandGroup (CMDCut, CMDCopy, CMDPaste); } diff --git a/CrowEditBase/src/Service.cs b/CrowEditBase/src/Service.cs index 3f042a7..80967d4 100644 --- a/CrowEditBase/src/Service.cs +++ b/CrowEditBase/src/Service.cs @@ -67,7 +67,7 @@ namespace CrowEditBase public abstract void Stop (); public abstract void Pause (); //windows having this service as datasource - public virtual string[] ServiceWindowsPath => ["#ui.winServiceConfig.crow"]; + public virtual string[] ServiceWindowsPath => new string[] {"#ui.winServiceConfig.crow"}; public virtual Document OpenDocument (string fullPath) => null; } diff --git a/CrowEditBase/src/SourceEditor.cs b/CrowEditBase/src/SourceEditor.cs index 6208f0d..a12b1c4 100644 --- a/CrowEditBase/src/SourceEditor.cs +++ b/CrowEditBase/src/SourceEditor.cs @@ -568,7 +568,7 @@ namespace CrowEditBase } } - + #region Drawing protected virtual void fillHighlight (IContext gr, int l, CharLocation selStart, CharLocation selEnd, RectangleD selRect, Color color) { if (selStart.Line == selEnd.Line) { selRect.X += selStart.VisualCharXPosition; @@ -869,6 +869,8 @@ namespace CrowEditBase } gr.Translate (ScrollX, 0); } + #endregion + protected override RectangleD? computeTextCursor (Rectangle cursor) { Rectangle cb = ClientRectangle; cursor -= new Point (ScrollX, ScrollY); diff --git a/SyntaxThemes/test.syntax b/SyntaxThemes/test.syntax new file mode 100644 index 0000000..aec7a6a --- /dev/null +++ b/SyntaxThemes/test.syntax @@ -0,0 +1,28 @@ +default = Jet;#20DADA;False;False +leftMargin = Grey;Black;True;True +Selection = White;Black;False;False +keyword = Blue;Transparent;False;False +DocumentationComment = MediumSeaGreen;Transparent;True;False +Region = DeepPink;Transparent;False;False +FoldedRegion = #FFFFF8;#35B23C;True;False +Documentation = GreenYellow;#00E800;False;False +trivia = Grey;Transparent;False;False +PreprocessorDirective = #1D1493;Transparent;False;False +PreprocessorMessage = #001493;Transparent;True;False +PredefinedType = DarkCyan;Transparent;False;False +AccessibilityModifier = RoyalBlue;Transparent;False;False +DisabledText = Grey;Transparent;False;False +identifier = Onyx;Transparent;False;False +Namespace = RoyalBlue;Transparent;True;False +NamedType = DarkGreen;Transparent;True;False +Property = Green;Transparent;True;False +Field = Black;Transparent;False;False +Method = DarkOliveGreen;Transparent;True;False +LiteralExpression = FireBrick;Transparent;False;True +error = Red;Transparent;False;False +TypeSyntax = DarkCyan;Transparent;False;False +TypeDeclaration = Lavender;Transparent;False;False +Punctuation = Black;Transparent;False;False +ContextualKeyword = DarkBlue;Transparent;True;False +InstanceExpression = Jet;Transparent;False;False +NamespaceMemberDeclaration = Jet;Transparent;False;False diff --git a/plugins/CECrowPlugin/CECrowPlugin.csproj b/plugins/CECrowPlugin/CECrowPlugin.csproj index ad99b95..6a23cfd 100644 --- a/plugins/CECrowPlugin/CECrowPlugin.csproj +++ b/plugins/CECrowPlugin/CECrowPlugin.csproj @@ -1,7 +1,7 @@ - net9 + net6 false diff --git a/plugins/CECrowPlugin/default.conf b/plugins/CECrowPlugin/default.conf index ec9ddfd..4ba1084 100644 --- a/plugins/CECrowPlugin/default.conf +++ b/plugins/CECrowPlugin/default.conf @@ -1,2 +1,2 @@ MainService=CECrowPlugin.CrowService -FileAssociations = CECrowPlugin.ImlDocument:.crow,.iml,.itmp,.template,.tmp:#ui.sourceEditor.itmp;CECrowPlugin.Style.StyleDocument:.style:#ui.sourceEditor.itmp +FileAssociations = CECrowPlugin.ImlDocument:.crow,.iml,.itmp,.template,.tmp:#CECrowPlugin.ui.IMLEditor.itmp;CECrowPlugin.Style.StyleDocument:.style:#ui.sourceEditor.itmp diff --git a/plugins/CECrowPlugin/src/CrowService.cs b/plugins/CECrowPlugin/src/CrowService.cs index b47295e..80a9865 100644 --- a/plugins/CECrowPlugin/src/CrowService.cs +++ b/plugins/CECrowPlugin/src/CrowService.cs @@ -24,8 +24,11 @@ using CERoslynPlugin; namespace CECrowPlugin { public class CrowService : Service { + CrowEditBase.LogItem logger; #region CTOR/DTOR public CrowService () : base () { + logger = App.GetLog("CrowService"); + restoreCrowAssemblies (); initCommands (); App.ValueChanged += app_ValueChanged; @@ -41,13 +44,19 @@ namespace CECrowPlugin CurrentSolution = sol; else CurrentSolution = null; + } else if (e.MemberName == "CurrentDocument") { + if (e.NewValue is Document doc) + CurrentDocument = doc; + else + CurrentDocument = null; } } - public override string[] ServiceWindowsPath => [ + public override string[] ServiceWindowsPath => new string [] { "#CECrowPlugin.ui.winConfiguration.crow", "#CECrowPlugin.ui.winGraphicTree.crow", - "#CECrowPlugin.ui.winProperties.crow" - ]; + "#CECrowPlugin.ui.winProperties.crow", + "#CECrowPlugin.ui.winCrowPreview.crow", + }; #region Commands public Command CMDStartRecording, CMDStopRecording, CMDRefresh, CMDAddEventToRecord, CMDRemoveEventToRecord; @@ -145,6 +154,7 @@ namespace CECrowPlugin } Project currentSolution; + Document currentDocument; Exception currentException; public string ErrorMessage = ""; public bool ServiceIsInError; @@ -312,8 +322,7 @@ namespace CECrowPlugin CMDRun.CanExecute = value; NotifyValueChanged(value); } - } - + } public double ZoomFactor { get => Configuration.Global.Get ("CrowPreviewZoomFactor", 1.0); set { @@ -388,19 +397,23 @@ namespace CECrowPlugin App.ForceMousePosition(); } public void UpdateRootWidget(Type widgetType, object instance) { - GraphicTree = new List([new ForeignWidgetContainer(widgetType, instance)]); + GraphicTree = new List(new ForeignWidgetContainer[] {new ForeignWidgetContainer(widgetType, instance)}); } IEnumerable getStyling () { if (App.CurrentProject is CERoslynPlugin.SolutionProject sol) { if (sol.StartupProject is CERoslynPlugin.MSBuildProject csprj) { foreach (var style in csprj.Flatten.OfType() - .Where (pin=>pin.NodeType == NodeType.EmbeddedResource && pin.FullPath.EndsWith (".style", StringComparison.OrdinalIgnoreCase))) + .Where (pin=>pin.NodeType == NodeType.EmbeddedResource && pin.FullPath.EndsWith (".style", StringComparison.OrdinalIgnoreCase))) { + logger.Add(LogType.Low, $"style found: {style.FullPath}"); yield return style.FullPath; + } foreach (var refP in csprj.ReferencedProjects) { foreach (var style in refP.Flatten.OfType() .Where (pin=>pin.NodeType == NodeType.EmbeddedResource && - pin.FullPath.EndsWith (".style", StringComparison.OrdinalIgnoreCase))) + pin.FullPath.EndsWith (".style", StringComparison.OrdinalIgnoreCase))) { + logger.Add(LogType.Low, $"style found: {style.FullPath}"); yield return style.FullPath; + } } } } @@ -624,6 +637,21 @@ namespace CECrowPlugin NotifyValueChanged (currentSolution); } } + public Document CurrentDocument { + get => currentDocument; + set { + //CERoslynPlugin.SolutionProject sol = value as CERoslynPlugin.SolutionProject; + if (currentDocument == value) + return; + currentDocument = value; + NotifyValueChanged (currentDocument); + + /*if (currentDocument is ImlDocument iml) { + LoadIML(iml.source.ToString()); + }*/ + } + } + #region Additional crow Assemblies string selectedCrowAssembly = null; @@ -1064,7 +1092,5 @@ namespace CECrowPlugin } } #endregion - - } } \ No newline at end of file diff --git a/plugins/CECrowPlugin/src/DebugInterface.cs b/plugins/CECrowPlugin/src/DebugInterface.cs index a021908..c85f0e9 100644 --- a/plugins/CECrowPlugin/src/DebugInterface.cs +++ b/plugins/CECrowPlugin/src/DebugInterface.cs @@ -154,9 +154,6 @@ namespace CECrowPlugin delCrowServiceUpdateRootWidget = (Action)Delegate.CreateDelegate(typeof(Action), crowService, t.GetMethod("UpdateRootWidget")); - - /*delCrowServiceGetScreenCoordinate = (GetScreenCoordinateDelegateType)Delegate.CreateDelegate(typeof(GetScreenCoordinateDelegateType), crowService, - t.GetMethod("getMouseScreenCoordinates", BindingFlags.Instance | BindingFlags.NonPublic));*/ delCrowServiceGetStyling = (Func>)Delegate.CreateDelegate (typeof (Func>), crowService, t.GetMethod ("getStyling", BindingFlags.Instance | BindingFlags.NonPublic)); delCrowServiceGetStreamFromPath = (Func)Delegate.CreateDelegate (typeof (Func), crowService, @@ -199,10 +196,11 @@ namespace CECrowPlugin ClearInterface(); initDictionaries(); foreach (object style in delCrowServiceGetStyling ()) { - if (style is string stylePath) + if (style is string stylePath) { LoadStyle (stylePath); - else if (style is Assembly styleAssembly) + } else if (style is Assembly styleAssembly) { loadStylingFromAssembly (styleAssembly); + } } } public void ReloadIml () { diff --git a/plugins/CECrowPlugin/src/DebugInterfaceWidget.cs b/plugins/CECrowPlugin/src/DebugInterfaceWidget.cs index 7fbaf5b..559b6c3 100644 --- a/plugins/CECrowPlugin/src/DebugInterfaceWidget.cs +++ b/plugins/CECrowPlugin/src/DebugInterfaceWidget.cs @@ -17,6 +17,7 @@ using Crow; namespace CECrowPlugin { public class DebugInterfaceWidget : Widget { + #region CTOR/DTOR public DebugInterfaceWidget () : base () { CrowIFaceService = App.GetService (); @@ -54,7 +55,9 @@ namespace CECrowPlugin if (crowIFaceService != null) crowIFaceService.ValueChanged -= service_ValueChanged; } - void service_ValueChanged(object instance, ValueChangeEventArgs e) { + #endregion + + void service_ValueChanged(object instance, ValueChangeEventArgs e) { if (e.MemberName == "CurrentWidget") { if (e.NewValue is ForeignWidgetContainer fwc) CurrentWidget = fwc; @@ -79,8 +82,8 @@ namespace CECrowPlugin CMDRefresh, //CMDZoomIn, CMDZoomOut, crowIFaceService.CMDStartRecording, crowIFaceService.CMDStopRecording, - crowIFaceService.CMDOpenConfig, - (Parent.LogicalParent as DockWindow).CMDClose + crowIFaceService.CMDOpenConfig + //(Parent.LogicalParent as DockWindow).CMDClose ); public CrowService CrowIFaceService { get => crowIFaceService; @@ -132,6 +135,7 @@ namespace CECrowPlugin RegisterForRepaint (); } } + protected void backgroundThreadFunc () { Stopwatch sw = Stopwatch.StartNew (); int refreshRate = crowIFaceService == null ? 10 : crowIFaceService.RefreshRate; @@ -164,7 +168,16 @@ namespace CECrowPlugin imlSource = tmp.ToString (); - crowIFaceService?.LoadIML (imlSource); + /*if (crowIFaceService.EncloseInTemplatedControl && !string.IsNullOrEmpty(crowIFaceService.TemplateContainerSource)) { + if (!string.IsNullOrEmpty(imlSource) && imlSource.StartsWith("'); + if (pos > 0) + src = imlSource.Substring(pos + 1); + } + string tmpCloseTag = crowIFaceService.TemplateContainerSource.Split (' ', StringSplitOptions.RemoveEmptyEntries)[0].Replace ("<","").TrimEnd('/','>'); + crowIFaceService?.LoadIML ($"{crowIFaceService.TemplateContainerSource.TrimEnd('/','>')}>"); + } else*/ + crowIFaceService?.LoadIML (imlSource); RegisterForRedraw (); } @@ -223,10 +236,10 @@ namespace CECrowPlugin if (hoverWidget != null && hoverWidget != currentWidget) { //currentWidget. RectangleD r = hoverWidget.GetScreenCoordinate() + Slot.Position + Parent.ClientRectangle.Position; - ctx.SetDash([1,3]); + ctx.SetDash(new double[] {1,3}); ctx.SetSource(Colors.Yellow); ctx.Rectangle(r, 1); - ctx.SetDash([]); + ctx.SetDash(new double[] {}); } if (currentWidget != null) { //currentWidget. diff --git a/plugins/CECrowPlugin/src/Parsing/IML/ImlDocument.cs b/plugins/CECrowPlugin/src/Parsing/IML/ImlDocument.cs index 34a684f..031f0cf 100644 --- a/plugins/CECrowPlugin/src/Parsing/IML/ImlDocument.cs +++ b/plugins/CECrowPlugin/src/Parsing/IML/ImlDocument.cs @@ -37,6 +37,36 @@ namespace CECrowPlugin }*/ } + CrowService crowService; + public CrowService CrowService { + get => crowService; + set { + if (crowService == value) + return; + crowService = value; + NotifyValueChanged (crowService); + } + } + public bool EncloseInTemplatedControl { + get => Configuration.Global.Get (nameof(EncloseInTemplatedControl), false); + set { + if (EncloseInTemplatedControl == value) + return; + Configuration.Global.Set (nameof(EncloseInTemplatedControl), value); + NotifyValueChanged (value); + + } + } + public string TemplateContainerSource { + get => Configuration.Global.Get (nameof(TemplateContainerSource), "