]> O.S.I.I.S - jp/crowedit.git/commitdiff
update to Crow 1 with Backends
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sun, 17 Jul 2022 18:24:27 +0000 (20:24 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sun, 17 Jul 2022 18:24:27 +0000 (20:24 +0200)
22 files changed:
CrowEditBase/CrowEditBase.csproj
CrowEditBase/src/Compiler/SourceDocument.cs
CrowEditBase/src/CrowEditBase.cs
CrowEditBase/src/Editor.cs
CrowEditBase/src/LogViewerWidget.cs
CrowEditBase/src/Plugin.cs
CrowEditBase/src/SourceEditor.cs
CrowEditBase/ui/slider.tmp [new file with mode: 0644]
plugins/CECrowPlugin/default.conf
plugins/CECrowPlugin/src/CrowService.cs
plugins/CECrowPlugin/src/DbgEventWidget.cs
plugins/CECrowPlugin/src/DbgLogViewer.cs
plugins/CECrowPlugin/src/DebugInterface.cs
plugins/CECrowPlugin/src/DebugInterfaceWidget.cs
plugins/CECrowPlugin/src/ImlDocument.cs
plugins/CECrowPlugin/src/StyleDocument.cs
plugins/CERoslynPlugin/default.conf
plugins/CERoslynPlugin/src/CSTokenizer.cs
plugins/CERoslynPlugin/src/RoslynService.cs
plugins/CEXmlPlugin/src/Parsing/XmlDocument.cs
src/CrowEdit.cs
ui/EditorOptions.crow

index 26dd95805fb360cb21fef4947350d4bf0cd21c5c..d388caff01de92f91cdac25dabf3a9e62fb59d4d 100644 (file)
@@ -7,15 +7,17 @@
 
        <ItemGroup>
                <Compile Include="src\**\*.cs" />
-               <EmbeddedResource Include="ui\**\*.*" >
+               <EmbeddedResource Include="ui\**\*.*">
                        <LogicalName>ui.%(Filename)%(Extension)</LogicalName>
                </EmbeddedResource>
-               <EmbeddedResource Include="icons\**\*.*" >
+               <EmbeddedResource Include="icons\**\*.*">
                        <LogicalName>icons.%(Filename)%(Extension)</LogicalName>
                </EmbeddedResource>
        </ItemGroup>
        <ItemGroup>
                <ProjectReference Include="/mnt/devel/crow/Crow/Crow.csproj" />
-               <!--<PackageReference Include="Crow" Version="0.9.8" />-->
+               <ProjectReference Include="/mnt/devel/crow/Backends/CairoBackend/Crow.CairoBackend.csproj" />
+               <!--<PackageReference Include="Crow" Version="1.0.1-beta" />
+               <PackageReference Include="Crow.CairoBackend" Version="1.0.1-beta" />-->
        </ItemGroup>
 </Project>
index 2f092b6aa93fb95a233ddc15697d0ac2b9274d44..40b0773e27caadb0513cc99446c941504de12b8f 100644 (file)
@@ -8,6 +8,7 @@ using Crow.Text;
 using System.Diagnostics;
 using System.Collections;
 using System.Collections.Generic;
+using Drawing2D;
 
 namespace CrowEditBase
 {
@@ -143,7 +144,7 @@ namespace CrowEditBase
                        }
                }
 
-               public virtual Crow.Color GetColorForToken (TokenType tokType) {
+               public virtual Color GetColorForToken (TokenType tokType) {
                        if (tokType.HasFlag (TokenType.Punctuation))
                                return Colors.DarkGrey;
                        if (tokType.HasFlag (TokenType.Trivia))
index a8caa2bf1a1444727e9cd1529957871705cd7af3..d18e5a5aef67ea2efa041f1f6fa7397dc1b66e5e 100644 (file)
@@ -10,6 +10,7 @@ using System.Runtime.CompilerServices;
 using System.Collections.Generic;
 using System.Runtime.Loader;
 using System.Text;
+using Drawing2D;
 
 namespace CrowEditBase
 {
@@ -58,7 +59,7 @@ namespace CrowEditBase
 
 
                public static CrowEditBase App;
-               public CrowEditBase (int width, int height) : base (width, height) {
+               public CrowEditBase (int width, int height) : base (width, height, true) {
                        App = this;
                }
 
@@ -352,6 +353,24 @@ namespace CrowEditBase
 
 
 #region main options
+               public int CrowUpdateInterval {
+                       get => Crow.Interface.UPDATE_INTERVAL;
+                       set {
+                               if (Crow.Interface.UPDATE_INTERVAL == value)
+                                       return;
+                               Crow.Interface.UPDATE_INTERVAL = value;
+                               NotifyValueChanged (Crow.Interface.UPDATE_INTERVAL);
+                       }
+               }
+               public int CrowPollingInterval {
+                       get => Crow.Interface.POLLING_INTERVAL;
+                       set {
+                               if (Crow.Interface.POLLING_INTERVAL == value)
+                                       return;
+                               Crow.Interface.POLLING_INTERVAL = value;
+                               NotifyValueChanged (Crow.Interface.POLLING_INTERVAL);
+                       }
+               }
                public virtual Color MarginBackground {
                        get => Configuration.Global.Get<Color> ("MarginBackground", Colors.Onyx);
                        set {
index b1ca5680e1c4978c65bd4555f14d91a2d086948a..f00adfbf4edc5cbf3002081103dece7b1387667c 100644 (file)
@@ -6,7 +6,7 @@ using System;
 using Glfw;
 using Crow.Text;
 using System.Collections.Generic;
-using Crow.Drawing;
+using Drawing2D;
 using System.Linq;
 using CrowEditBase;
 using System.Threading;
@@ -268,7 +268,7 @@ namespace Crow
                /// </summary>
                protected virtual int visualLineCount => document.LinesCount;
 
-               protected virtual void measureTextBounds (Context gr) {
+               protected virtual void measureTextBounds (IContext gr) {
                        fe = gr.FontExtents;
                        te = new TextExtents ();
 
@@ -301,7 +301,7 @@ namespace Crow
                                document.ExitReadLock ();
                        }
                }
-               protected virtual void drawContent (Context gr) {
+               protected virtual void drawContent (IContext gr) {
                        gr.Translate (-ScrollX, -ScrollY);
 
                        Rectangle cb = ClientRectangle;
@@ -358,7 +358,7 @@ namespace Crow
                                                                if (bytes.Length < size)
                                                                        bytes = size > 512 ? new byte[size] : stackalloc byte[size];
 
-                                                               encodedBytes = Crow.Text.Encoding.ToUtf8 (document.GetText (l), bytes);
+                                                               encodedBytes = document.GetText (l).ToUtf8 (bytes);
                                                                bytes[encodedBytes++] = 0;
 
                                                                if (l.LengthInPixel < 0) {
@@ -442,21 +442,23 @@ namespace Crow
                        NotifyValueChanged("VisibleLines", visibleLines);
                        NotifyValueChanged("HoverLine", hoverLine);
                        hoverLoc = new CharLocation (hoverLine, -1, mouseLocalPos.X + ScrollX);
-                       using (Context gr = new Context (IFace.surf)) {
-                               setFontForContext (gr);
+                       using (IContext gr = IFace.Backend.CreateContext (IFace.MainSurface)) {
+                               gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+                               gr.SetFontSize (Font.Size);
                                updateLocation (gr, ClientRectangle.Width, ref hoverLoc);
                        }
                }
                protected virtual bool cancelLinePrint (double lineHeght, double y, int clientHeight) => false;
                RectangleD? textCursor = null;
 
-               public virtual bool DrawCursor (Context ctx, out Rectangle rect) {
+               public virtual bool DrawCursor (IContext ctx, out Rectangle rect) {
                        if (CurrentLoc == null) {
                                rect = default;
                                return false;
                        }
                        if (!CurrentLoc.Value.HasVisualX) {
-                               setFontForContext (ctx);
+                               ctx.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+                               ctx.SetFontSize (Font.Size);
 
                                if (currentLoc?.Column < 0) {
                                        updateLocation (ctx, ClientRectangle.Width, ref currentLoc);
@@ -486,7 +488,7 @@ namespace Crow
                        return true;
                }
 
-               protected void updateLocation (Context gr, int clientWidth, ref CharLocation? location) {
+               protected void updateLocation (IContext gr, int clientWidth, ref CharLocation? location) {
                        if (location == null)
                                return;
                        CharLocation loc = location.Value;
@@ -512,7 +514,7 @@ namespace Crow
                                Span<byte> bytes = stackalloc byte[5];//utf8 single char buffer + '\0'
 
                                for (int i = 0; i < ls.Length; i++) {
-                                       int encodedBytes = Crow.Text.Encoding.ToUtf8 (curLine.Slice (i, 1), bytes);
+                                       int encodedBytes = curLine.Slice (i, 1).ToUtf8 (bytes);
                                        bytes[encodedBytes] = 0;
 
                                        gr.TextExtents (bytes, out te);
@@ -563,8 +565,9 @@ namespace Crow
                        DbgLogger.StartEvent(DbgEvtType.GOMeasure, this, lt);
                        try {
                                if (!textMeasureIsUpToDate) {
-                                       using (Context gr = new Context (IFace.surf)) {
-                                               setFontForContext (gr);
+                                       using (IContext gr = IFace.Backend.CreateContext (IFace.MainSurface)) {
+                                               gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+                                               gr.SetFontSize (Font.Size);
                                                measureTextBounds (gr);
                                        }
                                }
@@ -573,15 +576,16 @@ namespace Crow
                                DbgLogger.EndEvent(DbgEvtType.GOMeasure);
                        }
                }
-               public override void Paint (Context ctx) {
+               public override void Paint (IContext ctx) {
                        base.Paint (ctx);
                        IFace.forceTextCursor = true;
                }
-               protected override void onDraw (Context gr)
+               protected override void onDraw (IContext gr)
                {
                        //base.onDraw (gr);
 
-                       setFontForContext (gr);
+                       gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+                       gr.SetFontSize (Font.Size);
 
                        if (!textMeasureIsUpToDate) {
                                measureTextBounds (gr);
index e7d1d74267dab29de17d082dd40292be34d95f84..c63d67e0882e6334cb3a24a57ddbd5bc247659a4 100644 (file)
@@ -6,7 +6,7 @@ using System;
 using System.Xml.Serialization;
 using System.ComponentModel;
 using System.Collections;
-using Crow.Drawing;
+using Drawing2D;
 using System.Threading.Tasks;
 using System.Linq;
 
@@ -254,15 +254,10 @@ namespace Crow
                        base.OnLayoutChanges (layoutType);
 
                        if (layoutType == LayoutingType.Height) {
-                               using (ImageSurface img = new ImageSurface (Format.Argb32, 10, 10)) {
-                                       using (Context gr = new Context (img)) {
-                                               //Cairo.FontFace cf = gr.GetContextFontFace ();
-
-                                               gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
-                                               gr.SetFontSize (Font.Size);
-
-                                               fe = gr.FontExtents;
-                                       }
+                               using (IContext gr = IFace.Backend.CreateContext (IFace.MainSurface)) {
+                                       gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+                                       gr.SetFontSize (Font.Size);
+                                       fe = gr.FontExtents;
                                }
                                if (updateFilteredLinesRequest)
                                        updateFilteredLines ();
@@ -270,7 +265,7 @@ namespace Crow
                                MaxScrollY = filteredLines == null ? 0 : filteredLines.Length - visibleLines;
                        }
                }
-               protected override void onDraw (Context gr)
+               protected override void onDraw (IContext gr)
                {
                        base.onDraw (gr);
 
index e681c801ab43c5de87b70129369d630df999f43a..55950bddc4af8321ac817b7337c790ce700443bd 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2021-2021  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2021-2022  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
 //
 // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 
@@ -18,6 +18,7 @@ namespace CrowEditBase
                string FullPath;
                bool isLoaded;
                PluginsLoadContext loadContext;
+               Type serviceClass;
 
                public Assembly Load (AssemblyName assemblyName)
                        => loadContext.LoadFromAssemblyName (assemblyName);
@@ -68,6 +69,11 @@ namespace CrowEditBase
                        string defaultConfigName = loadContext.MainAssembly.GetManifestResourceNames ().FirstOrDefault(c=>c.EndsWith ("default.conf"));
                        if (!string.IsNullOrEmpty (defaultConfigName)) {
                                Configuration config = new Configuration (loadContext.MainAssembly.GetManifestResourceStream (defaultConfigName));
+                               string mainService = config.Get<string> ("MainService");
+                               if (!string.IsNullOrEmpty (mainService)) {
+                                       serviceClass = loadContext.MainAssembly.GetType (mainService);
+                                       App.GetService (serviceClass)?.Start();
+                               }
                                string fileAssociations = config.Get<string> ("FileAssociations");
                                if (!string.IsNullOrEmpty (fileAssociations)) {
                                        try
@@ -95,6 +101,9 @@ namespace CrowEditBase
                        if (!isLoaded)
                                return;
 
+                       if (serviceClass != null)
+                               App.GetService (serviceClass)?.Stop();
+
                        App.RemoveCrowAssembly (loadContext.MainAssembly);
 
                        IsLoaded = false;
index 281a7cd72c53317dcc968c3dbe13002c951a8a83..94b200bc0288c7b55ddb0d9da3d353668c4d5848 100644 (file)
@@ -5,7 +5,7 @@
 using System;
 using Glfw;
 using Crow.Text;
-using Crow.Drawing;
+using Drawing2D;
 using System.Collections;
 using CrowEditBase;
 using static CrowEditBase.CrowEditBase;
@@ -186,8 +186,10 @@ namespace Crow
                                updateMargin ();
 
                                if (!textMeasureIsUpToDate) {
-                                       using (Context gr = new Context (IFace.surf)) {
-                                               setFontForContext (gr);
+                                       using (IContext gr = IFace.Backend.CreateContext (IFace.MainSurface)) {
+                                               gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+                                               gr.SetFontSize (Font.Size);
+
                                                measureTextBounds (gr);
                                        }
                                }
@@ -258,8 +260,9 @@ namespace Crow
                                return;
                        }
                        hoverLoc = new CharLocation (hoverLine, -1, mouseLocalPos.X + ScrollX - leftMargin);
-                       using (Context gr = new Context (IFace.surf)) {
-                               setFontForContext (gr);
+                       using (IContext gr = IFace.Backend.CreateContext (IFace.MainSurface)) {
+                               gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+                               gr.SetFontSize (Font.Size);
                                updateLocation (gr, ClientRectangle.Width, ref hoverLoc);
                        }
 #if DEBUG_NODES
@@ -473,7 +476,7 @@ namespace Crow
                }
 
 
-               protected virtual void fillHighlight (Context gr, int l, CharLocation selStart, CharLocation selEnd, RectangleD selRect, Color color) {
+               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;
                                selRect.Width = selEnd.VisualCharXPosition - selStart.VisualCharXPosition;
@@ -495,7 +498,7 @@ namespace Crow
 
                        gr.Operator = Operator.Over;
                }
-               protected override void drawContent (Context gr) {
+               protected override void drawContent (IContext gr) {
                        if (!(Document is SourceDocument doc)) {
                                base.drawContent (gr);
                                return;
@@ -642,7 +645,7 @@ namespace Crow
                                                if (bytes.Length < size)
                                                        bytes = size > 512 ? new byte[size] : stackalloc byte[size];
 
-                                               int encodedBytes = Crow.Text.Encoding.ToUtf8 (buff, bytes);
+                                               int encodedBytes = buff.ToUtf8 (bytes);
 
                                                if (encodedBytes > 0) {
                                                        bytes[encodedBytes++] = 0;
diff --git a/CrowEditBase/ui/slider.tmp b/CrowEditBase/ui/slider.tmp
new file mode 100644 (file)
index 0000000..d60e66c
--- /dev/null
@@ -0,0 +1,11 @@
+<VerticalStack Background="{./Background}" Margin="5">
+       <Label Text="{./Caption}"/>
+       <Group Height="20">
+               <Gauge Height="50%" Foreground="${ControlHighlight}" Background="Onyx" Value="{./Value}" Maximum="{./Maximum}" Minimum="{Minimum}" Orientation="{./Orientation}"/>
+               <Border Name="Cursor" Background="White" BorderWidth="2" Foreground="Grey"
+                               MouseEnter="{Foreground=${ControlHighlight}}"
+                               MouseLeave="{Foreground=Grey}" >
+                       <Label Text="{./Value}" Foreground="Black"/>
+               </Border>
+       </Group>
+</VerticalStack>
index 87b623e4a18b206fc5118dfbb37c80be393d5303..8a67d5201a4de5d453c4f3872a19d4538c8bbfcd 100644 (file)
@@ -1 +1,2 @@
+MainService=Crow.CrowService
 FileAssociations = CECrowPlugin.ImlDocument:.crow,.iml,.itmp,.template,.tmp:#ui.sourceEditor.itmp;CECrowPlugin.Style.StyleDocument:.style:#ui.sourceEditor.itmp
index 3d93ee3bc6f1d7e62eafd6faf1883dde18a0074e..62b275381c9d37b4357b910da5aa8d81c5d02123 100644 (file)
@@ -7,7 +7,6 @@ using Glfw;
 using System.Reflection;
 using System.Runtime.Loader;
 using System.IO;
-using Crow.Drawing;
 using System.Diagnostics;
 using System.Collections.Generic;
 using Crow.DebugLogger;
@@ -18,6 +17,7 @@ using Crow.Text;
 using System.Runtime.InteropServices;
 using System.Runtime.CompilerServices;
 using static CrowEditBase.CrowEditBase;
+using Drawing2D;
 
 namespace Crow
 {
@@ -93,10 +93,12 @@ namespace Crow
                        }
                );
 
+               public ActionCommand CMDViewPreview;
+
                void initCommands ()
                {
-                       App.ViewCommands.Add (
-                               new ActionCommand("Crow Preview", () => App.LoadWindow ("#CECrowPlugin.ui.winCrowPreview.crow", App)));
+                       CMDViewPreview = new ActionCommand("Crow Preview", () => App.LoadWindow ("#CECrowPlugin.ui.winCrowPreview.crow", App));
+
                        CMDRefresh = new ActionCommand ("Refresh", refresh, "#icons.refresh.svg", IsRunning);
                        CMDStartRecording = new ActionCommand ("Start Recording", () => Recording = true, "#icons.circle.svg", false);
                        CMDStopRecording = new ActionCommand ("Stop Recording", stopRecording, "#icons.circle-red.svg", false);
@@ -129,14 +131,14 @@ namespace Crow
                FieldInfo fiDbgIFace_IsDirty;
                Action delResetDebugger;
                Action<object, string> delSaveDebugLog;
-               Func<IntPtr> delGetSurfacePointer;
+               Func<ISurface> delGetMainSurface;
                Action<string> delSetSource;
                Action delReloadIml;
                Func<double> delGetZoomFactor;
                Action<double> delSetZoomFactor;
 
 
-               FieldInfo fiDbg_IncludeEvents, fiDbg_DiscardEvents, fiDbg_ConsoleOutput, fiDbgIFace_MaxLayoutingTries, fiDbgIFace_MaxDiscardCount;
+               FieldInfo fiDbg_IncludeEvents, fiDbg_DiscardEvents, fiDbg_ConsoleOutput, fiDbgIFace_MaxLayoutingTries, fiDbgIFace_MaxDiscardCount, fiDbgIFace_Terminate;
                #endregion
 
                bool recording, debugLogIsEnabled;
@@ -293,7 +295,7 @@ namespace Crow
                        foreach (string assemblyPath in crowAssemblies)
                                additionalResolvePath.Add (System.IO.Path.GetDirectoryName(assemblyPath));
 
-                       crowLoadCtx?.Unload();
+                       //crowLoadCtx?.Unload();
                        crowLoadCtx = new AssemblyLoadContext("CrowDebuggerLoadContext");
                        crowLoadCtx.Resolving += (context, assemblyName) => {
                                foreach (string path in additionalResolvePath) {
@@ -343,17 +345,18 @@ namespace Crow
                                                                                        dbgIFace, dbgIfaceType.GetMethod("OnKeyPress"));
 
 
-                               delGetSurfacePointer = (Func<IntPtr>)Delegate.CreateDelegate(typeof(Func<IntPtr>),
-                                                                                       dbgIFace, dbgIfaceType.GetProperty("SurfacePointer").GetGetMethod());
+                               delGetMainSurface = (Func<ISurface>)Delegate.CreateDelegate(typeof(Func<ISurface>),
+                                                                                       dbgIFace, dbgIfaceType.GetProperty("MainSurface").GetGetMethod());
                                delSetSource = (Action<string>)Delegate.CreateDelegate(typeof(Action<string>),
                                                                                        dbgIFace, dbgIfaceType.GetProperty("Source").GetSetMethod());
                                delReloadIml = (Action)Delegate.CreateDelegate(typeof(Action), dbgIFace, dbgIfaceType.GetMethod("ReloadIml"));
 
-                               delGetZoomFactor = (Func<double>)Delegate.CreateDelegate(typeof(Func<double>),
+                               /*delGetZoomFactor = (Func<double>)Delegate.CreateDelegate(typeof(Func<double>),
                                                                                        dbgIFace, dbgIfaceType.GetProperty("ZoomFactor").GetGetMethod());
                                delSetZoomFactor = (Action<double>)Delegate.CreateDelegate(typeof(Action<double>),
-                                                                                       dbgIFace, dbgIfaceType.GetProperty("ZoomFactor").GetSetMethod());
+                                                                                       dbgIFace, dbgIfaceType.GetProperty("ZoomFactor").GetSetMethod());*/
 
+                               fiDbgIFace_Terminate = dbgIfaceType.GetField("Terminate");
                                fiDbgIFace_IsDirty = dbgIfaceType.GetField("IsDirty");
                                fiDbgIFace_MaxLayoutingTries = dbgIfaceType.GetField("MaxLayoutingTries", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
                                fiDbgIFace_MaxDiscardCount = dbgIfaceType.GetField("MaxDiscardCount", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
@@ -364,7 +367,7 @@ namespace Crow
                                delResetDebugger = (Action)Delegate.CreateDelegate(typeof(Action), null, debuggerType.GetMethod("Reset"));
                                /*delSaveDebugLog = (Action<object, string>)Delegate.CreateDelegate(typeof(Action<object, string>),
                                                                                        null, debuggerType.GetMethod("Save", new Type[] {dbgIfaceType, typeof(string)}));*/
-                               HasVkvgBackend = (bool)dbgIfaceType.GetField ("HaveVkvgBackend", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).GetValue (null);
+                               //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);
 
@@ -373,12 +376,18 @@ namespace Crow
 
                                CurrentState = Status.Running;
 
+                               App.ViewCommands.Add (CMDViewPreview);
+
                                updateCrowDebuggerState();
 
-                               delSetZoomFactor (ZoomFactor);
+                               //delSetZoomFactor (ZoomFactor);
                }
                public override void Stop()
                {
+                       if (CurrentState == Status.Running)
+                               fiDbgIFace_Terminate.SetValue (dbgIFace, true);
+                       App.ViewCommands.Remove (CMDViewPreview);
+
                        Recording = false;
                        DebugLogIsEnabled = false;
                        crowLoadCtx = null;
@@ -540,7 +549,7 @@ namespace Crow
                        }
                }
                #endregion
-               public IntPtr SurfacePointer => IsRunning ? delGetSurfacePointer() : IntPtr.Zero;
+               public ISurface MainSurface => IsRunning ? delGetMainSurface() : null;
                public void Resize (int width, int height) {
                        if (IsRunning)
                                delResize (width, height);
index 5960a8c18950dd3c6c9d584509a50508c30e54cf..c29edfe0eb8804e97f900933791682dbd1d03f88 100644 (file)
@@ -4,7 +4,7 @@
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
-using Crow.Drawing;
+using Drawing2D;
 using Crow.DebugLogger;
 
 namespace Crow
@@ -85,7 +85,7 @@ namespace Crow
                        base.OnLayoutChanges (layoutType);
                }
 
-               protected override void onDraw (Context gr)
+               protected override void onDraw (IContext gr)
                {
                        lock (dataMutex) {
 
@@ -109,7 +109,7 @@ namespace Crow
                                drawEvent (gr, cb.Height, Event);
                        }
                }
-               void drawEvent (Context ctx, int h, DbgEvent dbge)
+               void drawEvent (IContext ctx, int h, DbgEvent dbge)
                {
                        double w = Math.Max(dbge.Duration * pixelPerTick, 2.0);
                        double x = (dbge.begin - Event.begin) * pixelPerTick;
index fd0f18eb0858a253e7b0cab329fb119795355401..5df0be2ddb905f3c9e95e598854e8cfe79bf5e6a 100644 (file)
@@ -8,7 +8,7 @@ using System.ComponentModel;
 using System.IO;
 using System.Linq;
 using System.Threading.Tasks;
-using Crow.Drawing;
+using Drawing2D;
 using Crow.DebugLogger;
 using System.Diagnostics;
 
@@ -176,7 +176,7 @@ namespace Crow
                        get { return base.Font; }
                        set {
                                base.Font = value;
-                               using (Context gr = new Context (IFace.surf)) {
+                               using (IContext gr = IFace.Backend.CreateContext (IFace.MainSurface)) {
                                        gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
                                        gr.SetFontSize (Font.Size);
 
@@ -198,7 +198,7 @@ namespace Crow
                                w -= rightDiff;
                        return new RectangleD(x, penY, w, fe.Height);
                }
-               void drawEvents (Context ctx, IList<DbgEvent> evts)
+               void drawEvents (IContext ctx, IList<DbgEvent> evts)
                {
                        if (evts == null || evts.Count == 0)
                                return;
@@ -245,11 +245,12 @@ namespace Crow
                }
 
                DbgEvtType currentFilter;
-               protected override void onDraw (Context gr)
+               protected override void onDraw (IContext gr)
                {
                        base.onDraw (gr);
 
-                       setFontForContext (gr);
+                       gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+                       gr.SetFontSize (Font.Size);
 
                        if (widgets == null)
                                return;
@@ -268,7 +269,7 @@ namespace Crow
 
                                penY += fe.Height;
 
-                               gr.SetSource (Crow.Colors.Jet);
+                               gr.SetSource (Colors.Jet);
                                gr.MoveTo (cb.X, penY - 0.5);
                                gr.LineTo (cb.Right, penY - 0.5);
                                gr.Stroke ();
@@ -276,7 +277,7 @@ namespace Crow
                                double penX = 5.0 * g.xLevel + cb.Left;
 
                                if (g.xLevel == 0)
-                                       gr.SetSource (Crow.Colors.LightSalmon);
+                                       gr.SetSource (Colors.LightSalmon);
                                else if (currentLine == g.listIndex)
                                        gr.SetSource(Colors.RoyalBlue);
                                else
@@ -294,7 +295,7 @@ namespace Crow
 
                        gr.MoveTo (leftMargin + cb.Left, cb.Top);
                        gr.LineTo (leftMargin + cb.Left, cb.Bottom);
-                       gr.SetSource (Crow.Colors.Grey);
+                       gr.SetSource (Colors.Grey);
 
                        penY = topMargin + ClientRectangle.Top;
 
@@ -329,7 +330,7 @@ namespace Crow
 
                }
                string ticksToMS(long ticks) => Math.Round ((double)ticks / Stopwatch.Frequency * 1000.0, 2).ToString();
-               public override void Paint (Context ctx)
+               public override void Paint (IContext ctx)
                {
                        base.Paint (ctx);
 
@@ -362,7 +363,8 @@ namespace Crow
                                }
                        }
 
-                       setFontForContext (ctx);
+                       ctx.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+                       ctx.SetFontSize (Font.Size);
 
                        string str = ticksToMS(hoverTick);
 
@@ -586,11 +588,12 @@ namespace Crow
                        if (widgets == null)
                                return;
 
-                       using (Context gr = new Context (IFace.surf)) {
+                       using (IContext gr = IFace.Backend.CreateContext (IFace.MainSurface)) {
+                               gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+                               gr.SetFontSize (Font.Size);
+                               
                                double maxNameWidth = 0.0;
 
-                               setFontForContext (gr);
-
                                foreach (DbgWidgetRecord o in widgets) {
                                        double nameWidth = gr.TextExtents (o.name).Width + 5.0 * o.xLevel;
                                        if (nameWidth > maxNameWidth)
index b5c78f406d6e6f3a16aee38ec317de9305ec149e..8f5d8d34d1bcb71d416e69c91cc0e97904db73ab 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2021  Bruyère Jean-Philippe <jp_bruyere@hotmail.com>
+// Copyright (c) 2021-2022  Bruyère Jean-Philippe <jp_bruyere@hotmail.com>
 //
 // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 
@@ -9,7 +9,7 @@ using System.Reflection;
 using System.Threading;
 using System.Linq;
 using Crow;
-using Crow.Drawing;
+using Drawing2D;
 using IML = Crow.IML;
 
 namespace CECrowPlugin
@@ -20,21 +20,28 @@ namespace CECrowPlugin
                }
                public DebugInterface (IntPtr hWin) : base (100, 100, hWin)
                {
-                       SolidBackground = false;
-                       initBackend (true);
-
                        clientRectangle = new Rectangle (0, 0, 100, 100);
-                       CreateMainSurface (ref clientRectangle);
                }
-
+               protected override void initBackend()
+               {
+                       if (!tryFindBackendType (out Type backendType))
+                               throw new Exception ("No backend found.");
+                       backend = (CrowBackend)Activator.CreateInstance (backendType, new object[] {clientRectangle.Width, clientRectangle.Height});
+                       //hWin = backend.hWin;
+                       ownWindow = false;
+                       clipping = Backend.CreateRegion ();
+               }
                public override void Run()
                {
-                       Init();
+                       initBackend ();
 
                        Thread t = new Thread (interfaceThread) {
                                IsBackground = true
                        };
                        t.Start ();
+
+                       Init();
+
                }
                public bool Terminate;
                string source;
@@ -66,8 +73,6 @@ namespace CECrowPlugin
                                                Console.WriteLine ($"[DebugIFace] trying to exit ClippingMutex on error");
                                                Monitor.Exit (ClippingMutex);
                                        }
-
-
                                        /*while (Monitor.IsEntered(LayoutMutex))
                                                Monitor.Exit (LayoutMutex);
                                        while (Monitor.IsEntered(UpdateMutex))
@@ -85,12 +90,7 @@ namespace CECrowPlugin
 
                                Thread.Sleep (UPDATE_INTERVAL);
                        }
-               }
-               public new IntPtr SurfacePointer {
-                       get {
-                               lock(UpdateMutex)
-                                       return surf.Handle;
-                       }
+                       Dispose();
                }
                public void RegisterDebugInterfaceCallback (object crowService){
                        Type t = crowService.GetType();
@@ -152,10 +152,9 @@ namespace CECrowPlugin
                        Source = src;
                }
                public void Resize (int width, int height) {
-                       if (!HaveVkvgBackend)
-                               ProcessResize (new Rectangle(0,0,width, height));
+                       ProcessResize (new Rectangle(0, 0, width, height));
                }
-               public override void ProcessResize(Rectangle bounds) {
+               /*public override void ProcessResize(Rectangle bounds) {
                        lock (UpdateMutex) {
                                clientRectangle = bounds.Size;
 
@@ -166,7 +165,7 @@ namespace CECrowPlugin
 
                                RegisterClip (clientRectangle);
                        }
-               }
+               }*/
                public override void ForceMousePosition()
                {
                        delCrowServiceGetScreenCoordinate(out int x, out int y);
index 13a5dcfae580a5b9bf0399a4bd480faa9232e1fe..849f72ed0cd358e9e92af71d9331b5491b2309dc 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2013-2019  Bruyère Jean-Philippe <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022  Bruyère Jean-Philippe <jp_bruyere@hotmail.com>
 //
 // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 
@@ -7,7 +7,7 @@ using Glfw;
 using System.Reflection;
 using System.Runtime.Loader;
 using System.IO;
-using Crow.Drawing;
+using Drawing2D;
 using System.Diagnostics;
 using System.Collections.Generic;
 using Crow.DebugLogger;
@@ -137,7 +137,7 @@ namespace Crow
                        (Parent.LogicalParent as DockWindow).CMDClose
                );
 
-               protected override void onDraw(Context gr)
+               protected override void onDraw(IContext gr)
                {
                        Console.WriteLine("onDraw");
                        gr.SetSource(Colors.RoyalBlue);
@@ -156,23 +156,23 @@ namespace Crow
                public override void onMouseUp(object sender, MouseButtonEventArgs e) => crowIFaceService?.onMouseUp(e);
                public override void onMouseWheel(object sender, MouseWheelEventArgs e) => crowIFaceService?.onMouseWheel(e);
 
+               public override void Paint(IContext ctx)
+               {
+                       base.Paint(ctx);
+               }
                protected override void RecreateCache()
                {
-                       bmp?.Dispose ();
+                       //bmp?.Dispose ();
 
                        if (crowIFaceService != null && crowIFaceService.IsRunning) {
                                crowIFaceService.Resize (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);
+                               bmp = crowIFaceService.MainSurface;
                        } else
                                base.RecreateCache ();
 
                        IsDirty = false;
                }
-               protected override void UpdateCache(Context ctx)
+               protected override void UpdateCache(IContext ctx)
                {
                        if (bmp != null) {
                                paintCache (ctx, Slot + Parent.ClientRectangle.Position);
index 49a4f99d020ee52560e7cbbd0f9f760b9d13c5db..a5d30f6ba118a001368c9c7c92575528f3d12277 100644 (file)
@@ -17,6 +17,7 @@ using static CrowEditBase.CrowEditBase;
 using CrowEdit.Xml;
 
 using AttributeSyntax = CrowEdit.Xml.AttributeSyntax;
+using Drawing2D;
 
 namespace CECrowPlugin
 {
index d6e751a7c438406ae2b6a987c883e57f38a91528..215d7647f87bc3e44f14fadcc76edc784315545c 100644 (file)
@@ -7,6 +7,7 @@ using Crow;
 using System.Collections;
 using CrowEditBase;
 using static CrowEditBase.CrowEditBase;
+using Drawing2D;
 
 namespace CECrowPlugin.Style
 {
index 8fb7123b2429cd99ef7f27be8ff8e3a71c153e53..cd4b1a1668c3a6873dbe317ae810078a82fef457 100644 (file)
@@ -1 +1,2 @@
+MainService=CERoslynPlugin.RoslynService
 FileAssociations=CERoslynPlugin.CSDocument:.cs;CERoslynPlugin.SolutionProject:.sln
\ No newline at end of file
index e34f23e598dbff57f85b25c7bfe3730ea6c13371..68b386da3e0b32fdf6c74d26366c6dfeaf5f7720 100644 (file)
@@ -37,11 +37,11 @@ namespace CERoslynPlugin
                                                reader.Read();
                                                if (reader.IsNextCharIn ('\xA', '\x85'))
                                                        reader.Read();
-                                               addTok (ref reader, TokenType.LineBreak);                                                                                                               
+                                               addTok (ref reader, TokenType.LineBreak);
                                                break;
                                        case '\x20':
                                        case '\x9':
-                                               char c = reader.Read();                                                                 
+                                               char c = reader.Read();
                                                while (reader.TryPeak (c))
                                                        reader.Read();
                                                addTok (ref reader, c == '\x20' ? TokenType.WhiteSpace : TokenType.Tabulation);
@@ -56,7 +56,7 @@ namespace CERoslynPlugin
                                switch (reader.Peak) {
                                        case '\x20':
                                        case '\x9':
-                                               char c = reader.Read();                                                                 
+                                               char c = reader.Read();
                                                while (reader.TryPeak (c))
                                                        reader.Read();
                                                addTok (ref reader, c == '\x20' ? TokenType.WhiteSpace : TokenType.Tabulation);
@@ -70,7 +70,7 @@ namespace CERoslynPlugin
                public override Token[] Tokenize(string source)
                {
                        SpanCharReader reader = new SpanCharReader(source);
-                       
+
                        startOfTok = 0;
                        //curState = States.Init;
                        Toks = new List<Token>(100);
@@ -101,7 +101,7 @@ namespace CERoslynPlugin
                        Toks = new List<Token>(100);
                }
                public override void Visit (SyntaxNode node)
-               {                       
+               {
                        base.Visit (node);
                }
                public override void VisitToken (SyntaxToken token)
index f2a67281215c42862e58d85112144ae59e6838a4..4a74b0843b5acba1c8b67a78ece5fd2300a6386c 100644 (file)
@@ -61,15 +61,19 @@ namespace CERoslynPlugin
                        AssemblyLoadContext pluginCtx = AssemblyLoadContext.GetLoadContext (Assembly.GetExecutingAssembly());
                        pluginCtx.Resolving += msbuildResolve;
 
-                       foreach (string dll in Directory.GetFiles (MSBuildRoot, "*.dll"))
-                               pluginCtx.LoadFromAssemblyPath (dll);
+                       foreach (string dll in Directory.GetFiles (MSBuildRoot, "*.dll")) {
+                               try {
+                                       pluginCtx.LoadFromAssemblyPath (dll);
+                               } catch (Exception ex) {
+                                       App.Log(LogType.Error, $"[RoslynService]{ex}");
+                               }
+                       }
                        string capath = Path.Combine (MSBuildRoot, "Roslyn", "bincore");
                        foreach (string dll in Directory.GetFiles (capath, "*.dll")) {
                                try     {
                                        pluginCtx.LoadFromAssemblyPath (dll);
-                               }
-                               catch (Exception ex) {
-                                       Console.WriteLine ($"[RoslynService]{ex}");
+                               } catch (Exception ex) {
+                                       App.Log(LogType.Error, $"[RoslynService]{ex}");
                                }
 
                        }
@@ -80,7 +84,7 @@ namespace CERoslynPlugin
                        if (!File.Exists (assemblyPath))
                                return null;
                        Assembly a = context.LoadFromAssemblyPath (assemblyPath);
-                       Console.WriteLine ($"[MSBuildResolve]{a},{a.CodeBase}");
+                       App.Log (LogType.Message, $"[MSBuildResolve]{a},{a.CodeBase}");
                        return a;
                }
 
index edb10d3eab6743e2fe43c5a73354aa2171f13f8e..791813662ad1ef8ad21455b0bf47fb6226c573f9 100644 (file)
@@ -2,17 +2,10 @@
 //
 // 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 Drawing2D;
 
 namespace CrowEdit.Xml
 {
index 17556c71ba7f055be9c9ac544640de2b5b907aeb..19c133cb2ed9032ca87a215f1c65df72180de05e 100644 (file)
@@ -12,6 +12,7 @@ using System.Runtime.InteropServices;
 using CrowEditBase;
 using System.Linq;
 using System.Text;
+using Drawing2D;
 
 namespace CrowEdit
 {
@@ -62,6 +63,8 @@ namespace CrowEdit
                protected override void OnInitialized () {
                        base.OnInitialized ();
 
+                       initCommands ();
+
                        loadPlugins ();
 
                        SetWindowIcon ("#Crow.Icons.crow.png");
@@ -69,8 +72,6 @@ namespace CrowEdit
                        if (CurrentDir == null)
                                CurrentDir = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
 
-                       initCommands ();
-
                        Widget w = Load ("#CrowEdit.ui.main.crow");
                        w.DataSource = this;
 
index dc0183c85ed765411bf25567cbd75df6484bd549..b2e4096f5bfcc504273da1f43aba68cfad63dc4b 100644 (file)
@@ -5,5 +5,11 @@
                <CheckBox Caption="Reopen last file" IsChecked="{²ReopenLastFile}"/>
                <CheckBox Caption="Indent With Space" IsChecked="{²IndentWithSpace}"/>
                <Spinner Caption="Tabulation Size" Value="{²TabulationSize}"/>
+               <Slider Template="#ui.slider.tmp" Height="Fit" Background="0.1,0.1,0.2,0.8"
+                               Minimum="1" Maximum="50" SmallIncrement="1" LargeIncrement="10"
+                               Caption="Crow Update Interval (ms)" Value="{²CrowUpdateInterval}" />
+               <Slider Template="#ui.slider.tmp" Height="Fit" Background="0.1,0.1,0.2,0.8"
+                               Minimum="1" Maximum="50" SmallIncrement="1" LargeIncrement="10"
+                               Caption="GLFW polling Interval (ms)" Value="{²CrowPollingInterval}" />
        </VerticalStack>
 </Window>
\ No newline at end of file