</ItemGroup>
<ItemGroup>
<ProjectReference Include="/mnt/devel/crow/Crow/Crow.csproj" />
- <!--<PackageReference Include="Crow" Version="0.9.7-beta" />-->
+ <!--<PackageReference Include="Crow" Version="0.9.8" />-->
</ItemGroup>
</Project>
public event EventHandler<TextChangeEventArgs> TextChanged;
public void OnTextChanged(object sender, TextChangeEventArgs e)
{
- if (disableTextChangedEvent)
- return;
TextChanged.Raise (this, e);
}
- protected void backgroundThreadFunc () {
+ protected virtual void backgroundThreadFunc () {
while (true) {
if (Document != null && document.TryGetState (this, out List<TextChange> changes)) {
disableTextChangedEvent = true;
protected virtual void update (TextChange change) {
- OnTextChanged (this, new TextChangeEventArgs (change));
+ if (!disableTextChangedEvent)
+ OnTextChanged (this, new TextChangeEventArgs (change));
selectionStart = null;
CurrentLoc = document.GetLocation (change.Start + change.ChangedText.Length);
{
public class SourceEditor : Editor {
object TokenMutex = new object();
+ /*protected override void backgroundThreadFunc () {
+ while (true) {
+ if (Document != null && Document.TryGetState (this, out List<TextChange> changes)) {
+ disableTextChangedEvent = true;
+ disableSuggestions = true;
+ foreach (TextChange tc in changes)
+ update (tc);
+ disableTextChangedEvent = false;
+ disableSuggestions = false;
+ }
+ System.Threading.Thread.Sleep (200);
+ }
+ }*/
+
SyntaxNode currentNode;
#if DEBUG_NODE
SyntaxNode _hoverNode;
if (Document is SourceDocument srcdoc)
srcdoc.updateCurrentTokAndNode (CurrentLoc.Value);
- if (!disableSuggestions && HasFocus)
+ if (!disableSuggestions &&!disableTextChangedEvent && HasFocus)
tryGetSuggestions ();
RegisterForGraphicUpdate();
-FileAssociations = CECrowPlugin.ImlDocument:.crow,.iml,.itmp,.template,.tmp:#ui.sourceEditor.itmp;CECrowPlugin.StyleDocument:.style:#ui.sourceEditor.itmp
+FileAssociations = CECrowPlugin.ImlDocument:.crow,.iml,.itmp,.template,.tmp:#ui.sourceEditor.itmp;CECrowPlugin.Style.StyleDocument:.style:#ui.sourceEditor.itmp
=> App.TryGetPlugin ("CERoslynPlugin", out Plugin roslynPlugin) ?
roslynPlugin.Load (assemblyName) : null;*/
- static IntPtr resolveUnmanaged(Assembly assembly, String libraryName)
+ /*static IntPtr resolveUnmanaged(Assembly assembly, String libraryName)
{
switch (libraryName)
}
Console.WriteLine($"[UNRESOLVE] {assembly} {libraryName}");
return IntPtr.Zero;
- }
+ }*/
- void updateCrowApp () {
+ /*void updateCrowApp () {
if (App.CurrentProject is CERoslynPlugin.SolutionProject sol) {
if (sol.StartupProject is CERoslynPlugin.MSBuildProject csprj) {
}
- }
+ }*/
#region Commands
public Command CMDStartRecording, CMDStopRecording, CMDRefresh;
public Command CMDGotoParentEvent, CMDEventHistoryForward, CMDEventHistoryBackward;
foreach (string assemblyPath in crowAssemblies)
additionalResolvePath.Add (System.IO.Path.GetDirectoryName(assemblyPath));
+ crowLoadCtx?.Unload();
crowLoadCtx = new AssemblyLoadContext("CrowDebuggerLoadContext");
- crowLoadCtx.ResolvingUnmanagedDll += resolveUnmanaged;
crowLoadCtx.Resolving += (context, assemblyName) => {
foreach (string path in additionalResolvePath) {
string assemblyPath = System.IO.Path.Combine (path, assemblyName.Name + ".dll");
}
return null;
};
- //crowLoadCtx.Resolving += (ctx,name) => AssemblyLoadContext.Default.LoadFromAssemblyName (name);
//using (crowLoadCtx.EnterContextualReflection()) {
crowAssembly = crowLoadCtx.LoadFromAssemblyPath (CrowDbgAssemblyLocation);
public Project ActiveSolution {
get => activeSolution;
set {
- CERoslynPlugin.SolutionProject sol = value as CERoslynPlugin.SolutionProject;
- if (activeSolution == sol)
+ //CERoslynPlugin.SolutionProject sol = value as CERoslynPlugin.SolutionProject;
+ if (activeSolution == value)
return;
- activeSolution = sol;
+ activeSolution = value;
NotifyValueChanged (activeSolution);
}
}
using System.IO;
using System.Reflection;
using System.Threading;
+using System.Linq;
using Crow;
using Crow.Drawing;
using IML = Crow.IML;
public override Type GetWidgetTypeFromName (string typeName){
if (knownCrowWidgetTypes.ContainsKey (typeName))
return knownCrowWidgetTypes [typeName];
- foreach (Assembly a in System.Runtime.Loader.AssemblyLoadContext.GetLoadContext (Assembly.GetExecutingAssembly ()).Assemblies) {
- foreach (Type expT in a.GetExportedTypes ()) {
- if (expT.Name != typeName)
- continue;
- knownCrowWidgetTypes.Add (typeName, expT);
- return expT;
+ System.Runtime.Loader.AssemblyLoadContext dbgLoadCtx =
+ System.Runtime.Loader.AssemblyLoadContext.All.FirstOrDefault (ctx=>ctx.Name == "CrowDebuggerLoadContext");
+ foreach (Assembly a in dbgLoadCtx.Assemblies) {
+ try {
+ foreach (Type expT in a.GetExportedTypes ()) {
+ if (expT.Name != typeName)
+ continue;
+ knownCrowWidgetTypes.Add (typeName, expT);
+ return expT;
+ }
+ } catch (Exception ex) {
+ Console.WriteLine ($"[CECrowPlugin]Error: GetWidgetTypeFromName failed for {typeName} in {a}.\n{ex}");
}
}
return null;
using static CrowEditBase.CrowEditBase;
using CrowEdit.Xml;
-using CERoslynPlugin;
using AttributeSyntax = CrowEdit.Xml.AttributeSyntax;
using System;
-namespace CECrowPlugin
+namespace CECrowPlugin.Style
{
[Flags]
public enum StyleTokenType {
using System.Globalization;
using Crow.Coding;
-namespace CECrowPlugin {
+namespace CECrowPlugin.Style {
public class StyleTokenizer : Tokenizer {
enum States {
classNames, members, value, endOfStatement
}
return false;
}
+ bool replacePreviousNonTriviaTokType (StyleTokenType expectedType, StyleTokenType newType) {
+ int tk = Toks.Count - 2;
+ if (tk < 0)
+ return false;
+ while (tk > 0 && Toks[tk].Type.HasFlag(StyleTokenType.Trivia))
+ tk --;
+ if ((StyleTokenType)Toks[tk].Type == expectedType) {
+ Token tok = Toks[tk];
+ tok.Type = (TokenType)newType;
+ Toks[tk] = tok;
+ return true;
+ }
+ return false;
+ }
public override Token[] Tokenize (string source) {
SpanCharReader reader = initParsing (source);
} else if (reader.TryPeak ('*')) {
reader.Advance ();
addTok (ref reader, StyleTokenType.BlockCommentStart);
- if (reader.TryReadUntil ("*/")) {
- addTok (ref reader, StyleTokenType.BlockComment);
- reader.Advance (2);
- addTok (ref reader, StyleTokenType.BlockCommentEnd);
+ while (!reader.EndOfSpan) {
+ if (reader.Eol()) {
+ addTok (ref reader, StyleTokenType.BlockComment);
+ reader.ReadEol();
+ addTok (ref reader, StyleTokenType.LineBreak);
+ continue;
+ }
+ if (reader.TryPeak ("*/")) {
+ addTok (ref reader, StyleTokenType.BlockComment);
+ reader.Advance (2);
+ addTok (ref reader, StyleTokenType.BlockCommentEnd);
+ break;
+ } else
+ reader.Read ();
}
}
break;
using System.Linq;
using CrowEditBase;
-namespace CECrowPlugin
+namespace CECrowPlugin.Style
{
+ public static class Extensions {
+ public static StyleTokenType GetTokenType (this Token tok) {
+ return (StyleTokenType)tok.Type;
+ }
+ public static void SetTokenType (this Token tok, StyleTokenType type) {
+ tok.Type = (TokenType)type;
+ }
+ }
public class StyleSyntaxAnalyser : SyntaxAnalyser {
- public override SyntaxNode Root => CurrentNode;
+ public override SyntaxNode Root => currentNode;
public StyleSyntaxAnalyser (StyleDocument source) : base (source) {
this.source = source;
}
- SyntaxNode CurrentNode;
- Token previousTok;
- IEnumerator<Token> iter;
- int currentLine;
public override void Process () {
StyleDocument doc = source as StyleDocument;
Exceptions = new List<SyntaxException> ();
- CurrentNode = new StyleRootSyntax (doc);
- previousTok = default;
- iter = doc.Tokens.AsEnumerable().GetEnumerator ();
+ currentNode = new StyleRootSyntax (doc);
currentLine = 0;
+ Span<Token> toks = source.Tokens;
+ tokIdx = 0;
+
+ int firstNameIdx = -1;
- bool notEndOfSource = iter.MoveNext ();
- while (notEndOfSource) {
- if (iter.Current.Type == TokenType.LineBreak)
+ while (tokIdx < toks.Length) {
+ Token curTok = toks[tokIdx];
+ if (curTok.Type == TokenType.LineBreak)
currentLine++;
- else if (!iter.Current.Type.HasFlag (TokenType.Trivia)) {
- }
+ else if (!curTok.Type.HasFlag (TokenType.Trivia)) {
+ /*if (currentNode is StyleRootSyntax root) {
+ if (firstNameIdx < 0) {
+ if (curTok.GetTokenType() == StyleTokenType.Name) {
+ firstNameIdx = tokIdx;
+ } else {
+ Exceptions.Add (new SyntaxException ("Unexpected Token", curTok));
+ }
+
+ }
- previousTok = iter.Current;
- notEndOfSource = iter.MoveNext ();
+ }*/
+ }
+ tokIdx++;
}
while (currentNode.Parent != null) {
if (!currentNode.LastTokenOffset.HasValue)
using CrowEditBase;
-namespace CECrowPlugin
+namespace CECrowPlugin.Style
{
public class StyleRootSyntax : SyntaxRootNode {
: base (source) {
}
}
-
+ public class ConstantDefinitionSyntax : SyntaxNode {
+ internal int? name, equal, valueOpen, valueClose;
+ public override bool IsComplete => base.IsComplete & name.HasValue & equal.HasValue &
+ valueOpen.HasValue & valueClose.HasValue;
+ public ConstantDefinitionSyntax (int startLine, int tokenBase)
+ : base (startLine, tokenBase) {
+ }
+ }
public class AttributeSyntax : SyntaxNode {
public Token? NameToken { get; internal set; }
public Token? EqualToken { get; internal set; }
// Copyright (c) 2013-2021 Bruyère Jean-Philippe <jp_bruyere@hotmail.com>
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
-
+using System;
using Crow.Text;
using Crow;
using System.Collections;
using CrowEditBase;
using static CrowEditBase.CrowEditBase;
-namespace CECrowPlugin
+namespace CECrowPlugin.Style
{
public class StyleDocument : SourceDocument {
protected override SyntaxAnalyser CreateSyntaxAnalyser() => new StyleSyntaxAnalyser (this);
public override IList GetSuggestions (CharLocation loc) {
- /*currentToken = FindTokenIncludingPosition (pos);
- currentNode = FindNodeIncludingPosition (pos);*/
+ Console.ForegroundColor = ConsoleColor.DarkYellow;
+ Console.WriteLine ($"Tok: {this.CurrentTokenString} {((StyleTokenType)CurrentToken.Type).ToString()}");
+ Console.ResetColor();
return null;
}
public override bool TryGetCompletionForCurrentToken(object suggestion, out TextChange change, out TextSpan? newSelection)
public long ToInt => major << 62 + minor << 60 + revision;
public override string ToString () => $"{major}.{minor}.{revision}";
}
+
+
}
}
\ No newline at end of file
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<EnableDefaultItems>false</EnableDefaultItems>
</PropertyGroup>
-
+
<ItemGroup>
<Compile Include="src\**\*.cs" />
<EmbeddedResource Include="default.conf" />
{
public class CrowEdit : CrowEditBase.CrowEditBase
{
-#if NETCOREAPP
- static IntPtr resolveUnmanaged(Assembly assembly, String libraryName)
- {
-
- switch (libraryName)
- {
- case "glfw3":
- return NativeLibrary.Load("glfw", assembly, null);
- case "rsvg-2.40":
- return NativeLibrary.Load("rsvg-2", assembly, null);
- }
- Console.WriteLine($"[UNRESOLVE] {assembly} {libraryName}");
- return IntPtr.Zero;
- }
-
static Assembly last_chance_resolve (System.Runtime.Loader.AssemblyLoadContext context, AssemblyName assemblyName)
{
foreach (Plugin plugin in App.Plugins) {
}
static CrowEdit()
{
- System.Runtime.Loader.AssemblyLoadContext.GetLoadContext(Assembly.GetExecutingAssembly()).ResolvingUnmanagedDll += resolveUnmanaged;
System.Runtime.Loader.AssemblyLoadContext.GetLoadContext(Assembly.GetExecutingAssembly()).Resolving += last_chance_resolve;
}
-#endif
+
static void Main ()
{
/*DbgLogger.IncludedEvents.AddRange ( new DbgEvtType[] {
OpenedDocuments.Add (doc);
CurrentDocument = doc;
} catch (Exception ex) {
- System.Diagnostics.Debug.WriteLine ($"[openOrCreateFile]{ex}");
+ MessageBox.ShowModal (this, MessageBox.Type.Alert, $"Unable to open {filePath}.\n{ex.Message}");
+ Console.ForegroundColor = ConsoleColor.Red;
+ Console.WriteLine (ex);
+ Console.ResetColor();
}
return doc;
}
CurrentDocument = doc;
}
void tv_projects_SelectedItemChanged (object sender, SelectionChangeEventArgs e) {
- if (e.NewValue is Project prj) {
+ /*if (e.NewValue is Project prj) {
CurrentProject = prj;
- }
+ }*/
/*if (e.NewValue is IFileNode fi) {
if (string.IsNullOrEmpty (fi.FullPath) || ! File.Exists (fi.FullPath))
return;
</ListBox>
<Splitter/>
<TreeView IsRoot="true" Name="lbCtxs" Data="{AllLoadContexts}" UseLoadingThread = 'false' >
- <ItemTemplate DataType="System.Reflection">
+ <ItemTemplate DataType="System.Reflection.Assembly">
<ListItem CornerRadius="2" Margin="0" Height="Fit" Width="Stretched"
Selected="{Background=${ControlHighlight}}"
Unselected="{Background=Transparent}">
<HorizontalStack>
<!--<Image Margin="1" Width="14" Height="14" Path="#Crow.Icons.file.svg"/>-->
- <Label Text="{}" Width="Stretched"/>
+ <Label Text="{}" Width="Stretched" Tooltip="{Location}"/>
</HorizontalStack>
</ListItem>
</ItemTemplate>
</HorizontalStack>
</ItemTemplate>
</ListBox>-->
-
<TreeView Name="treeview" IsRoot="true" RootDataLevel="true" Data="{Projects}" Background="Onyx"
SelectedItemChanged="tv_projects_SelectedItemChanged" >
<ItemTemplate DataType="default" >