diff --git a/.vs/Merlin32Language/v15/.suo b/.vs/Merlin32Language/v15/.suo
new file mode 100644
index 0000000..b994e89
Binary files /dev/null and b/.vs/Merlin32Language/v15/.suo differ
diff --git a/.vs/Merlin32Language/v15/sqlite3/storage.ide b/.vs/Merlin32Language/v15/sqlite3/storage.ide
new file mode 100644
index 0000000..37059ca
Binary files /dev/null and b/.vs/Merlin32Language/v15/sqlite3/storage.ide differ
diff --git a/Backup/Coloring/Classification/ClassificationFormat.cs b/Backup/Coloring/Classification/ClassificationFormat.cs
new file mode 100644
index 0000000..2810d6e
--- /dev/null
+++ b/Backup/Coloring/Classification/ClassificationFormat.cs
@@ -0,0 +1,84 @@
+using System.ComponentModel.Composition;
+using System.Windows.Media;
+using Microsoft.VisualStudio.Text.Classification;
+using Microsoft.VisualStudio.Utilities;
+//using Microsoft.VisualStudio.Language.StandardClassification;
+
+namespace VSMerlin32.Coloring.Classification
+{
+ #region Format definition
+
+ [Export(typeof(EditorFormatDefinition))]
+ [ClassificationType(ClassificationTypeNames = Merlin32TokenHelper.Merlin32Comment)]
+ [Name("Merlin32CommentFormat")]
+ [UserVisible(false)]
+ [Order(Before = Priority.Default)]
+ internal sealed class CommentFormat : ClassificationFormatDefinition
+ {
+ public CommentFormat()
+ {
+ this.DisplayName = "This is a comment"; //human readable version of the name
+ this.ForegroundColor = Colors.Green;
+ }
+ }
+
+ [Export(typeof(EditorFormatDefinition))]
+ [ClassificationType(ClassificationTypeNames = Merlin32TokenHelper.Merlin32Opcode)]
+ [Name("Merlin32OpcodeFormat")]
+ [UserVisible(false)]
+ [Order(Before = Priority.Default)]
+ internal sealed class OpcodeFormat : ClassificationFormatDefinition
+ {
+ public OpcodeFormat()
+ {
+ this.DisplayName = "This is an opcode"; //human readable version of the name
+ this.ForegroundColor = Colors.Blue;
+ // this.IsBold = true;
+ }
+ }
+
+ [Export(typeof(EditorFormatDefinition))]
+ [ClassificationType(ClassificationTypeNames = Merlin32TokenHelper.Merlin32Directive)]
+ [Name("Merlin32DirectiveFormat")]
+ [UserVisible(false)]
+ [Order(Before = Priority.Default)]
+ internal sealed class DirectiveFormat : ClassificationFormatDefinition
+ {
+ public DirectiveFormat()
+ {
+ this.DisplayName = "This is an directive"; //human readable version of the name
+ this.ForegroundColor = Colors.DarkCyan;
+ // this.IsBold = true;
+ }
+ }
+
+ [Export(typeof(EditorFormatDefinition))]
+ [ClassificationType(ClassificationTypeNames = Merlin32TokenHelper.Merlin32DataDefine)]
+ [Name("Merlin32DataDefineFormat")]
+ [UserVisible(false)]
+ [Order(Before = Priority.Default)]
+ internal sealed class DataDefineFormat : ClassificationFormatDefinition
+ {
+ public DataDefineFormat()
+ {
+ this.DisplayName = "This is data definition"; //human readable version of the name
+ this.ForegroundColor = Colors.DarkOrchid;
+ // this.IsBold = true;
+ }
+ }
+
+ [Export(typeof(EditorFormatDefinition))]
+ [ClassificationType(ClassificationTypeNames = Merlin32TokenHelper.Merlin32Text)]
+ [Name("Merlin32TextFormat")]
+ [UserVisible(false)]
+ [Order(Before = Priority.Default)]
+ internal sealed class TextFormat : ClassificationFormatDefinition
+ {
+ public TextFormat()
+ {
+ this.DisplayName = "This is a text"; //human readable version of the name
+ this.ForegroundColor = Colors.DarkRed;
+ }
+ }
+ #endregion //Format definition
+}
diff --git a/Backup/Coloring/Classification/ClassificationType.cs b/Backup/Coloring/Classification/ClassificationType.cs
new file mode 100644
index 0000000..7a4cb7d
--- /dev/null
+++ b/Backup/Coloring/Classification/ClassificationType.cs
@@ -0,0 +1,48 @@
+using System.ComponentModel.Composition;
+using Microsoft.VisualStudio.Text.Classification;
+using Microsoft.VisualStudio.Utilities;
+
+namespace VSMerlin32.Coloring.Classification
+{
+ internal static class OrdinaryClassificationDefinition
+ {
+ #region Type definition
+
+ ///
+ /// Defines the "opcode" classification type.
+ ///
+ [Export(typeof(ClassificationTypeDefinition))]
+ [Name(Merlin32TokenHelper.Merlin32Opcode)]
+ internal static ClassificationTypeDefinition Opcode = null;
+
+ ///
+ /// Defines the "directive" classification type.
+ ///
+ [Export(typeof(ClassificationTypeDefinition))]
+ [Name(Merlin32TokenHelper.Merlin32Directive)]
+ internal static ClassificationTypeDefinition Directive = null;
+
+ ///
+ /// Defines the "datadefine" classification type.
+ ///
+ [Export(typeof(ClassificationTypeDefinition))]
+ [Name(Merlin32TokenHelper.Merlin32DataDefine)]
+ internal static ClassificationTypeDefinition Datadefine = null;
+
+ ///
+ /// Defines the "text" classification type.
+ ///
+ [Export(typeof(ClassificationTypeDefinition))]
+ [Name(Merlin32TokenHelper.Merlin32Text)]
+ internal static ClassificationTypeDefinition Text = null;
+
+ ///
+ /// Defines the "comment" classification type.
+ ///
+ [Export(typeof(ClassificationTypeDefinition))]
+ [Name(Merlin32TokenHelper.Merlin32Comment)]
+ internal static ClassificationTypeDefinition Comment = null;
+
+ #endregion
+ }
+}
diff --git a/Backup/Coloring/Classification/Merlin32sClassifier.cs b/Backup/Coloring/Classification/Merlin32sClassifier.cs
new file mode 100644
index 0000000..5cce64c
--- /dev/null
+++ b/Backup/Coloring/Classification/Merlin32sClassifier.cs
@@ -0,0 +1,75 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.Composition;
+using Microsoft.VisualStudio.Text;
+using Microsoft.VisualStudio.Text.Classification;
+using Microsoft.VisualStudio.Text.Tagging;
+using Microsoft.VisualStudio.Utilities;
+
+namespace VSMerlin32.Coloring.Classification
+{
+ [Export(typeof(ITaggerProvider))]
+ [ContentType("Merlin32")]
+ [TagType(typeof(ClassificationTag))]
+ internal sealed class Merlin32ClassifierProvider : ITaggerProvider
+ {
+ [Export]
+ [Name("Merlin32")]
+ [BaseDefinition("code")]
+ internal static ContentTypeDefinition Merlin32ContentType = null;
+
+ [Export]
+ [FileExtension(".s")]
+ [ContentType("Merlin32")]
+ internal static FileExtensionToContentTypeDefinition Merlin32FileType = null;
+
+ [Import]
+ internal IClassificationTypeRegistryService ClassificationTypeRegistry = null;
+
+ [Import]
+ internal IBufferTagAggregatorFactoryService AggregatorFactory = null;
+
+ public ITagger CreateTagger(ITextBuffer buffer) where T : ITag
+ {
+ ITagAggregator merlin32TagAggregator =
+ AggregatorFactory.CreateTagAggregator(buffer);
+
+ return new Merlin32Classifier(buffer, merlin32TagAggregator, ClassificationTypeRegistry) as ITagger;
+ }
+ }
+
+ internal sealed class Merlin32Classifier : ITagger
+ {
+ private ITextBuffer _buffer;
+ private readonly ITagAggregator _aggregator;
+ private readonly IDictionary _merlin32Types;
+
+ internal Merlin32Classifier(ITextBuffer buffer,
+ ITagAggregator merlin32TagAggregator,
+ IClassificationTypeRegistryService typeService)
+ {
+ _buffer = buffer;
+ _aggregator = merlin32TagAggregator;
+ _merlin32Types = new Dictionary();
+
+ foreach (Merlin32TokenTypes token in Enum.GetValues(typeof(Merlin32TokenTypes)))
+ _merlin32Types[token] = typeService.GetClassificationType(token.ToString());
+ }
+
+ public event EventHandler TagsChanged
+ {
+ add { }
+ remove { }
+ }
+
+ public IEnumerable> GetTags(NormalizedSnapshotSpanCollection spans)
+ {
+ foreach (var tagSpan in _aggregator.GetTags(spans))
+ {
+ var tagSpans = tagSpan.Span.GetSpans(spans[0].Snapshot);
+ yield return
+ new TagSpan(tagSpans[0], new ClassificationTag(_merlin32Types[tagSpan.Tag.Tokentype]));
+ }
+ }
+ }
+}
diff --git a/Backup/Coloring/Data/SnapshotHelper.cs b/Backup/Coloring/Data/SnapshotHelper.cs
new file mode 100644
index 0000000..e5057a3
--- /dev/null
+++ b/Backup/Coloring/Data/SnapshotHelper.cs
@@ -0,0 +1,16 @@
+using Microsoft.VisualStudio.Text;
+
+namespace VSMerlin32.Coloring.Data
+{
+ internal class SnapshotHelper
+ {
+ public SnapshotSpan Snapshot { get; private set; }
+ public Merlin32TokenTypes TokenType { get; private set; }
+
+ public SnapshotHelper(SnapshotSpan span, Merlin32TokenTypes type)
+ {
+ Snapshot = span;
+ TokenType = type;
+ }
+ }
+}
diff --git a/Backup/Coloring/Merlin32CodeHelper.cs b/Backup/Coloring/Merlin32CodeHelper.cs
new file mode 100644
index 0000000..efa0fe9
--- /dev/null
+++ b/Backup/Coloring/Merlin32CodeHelper.cs
@@ -0,0 +1,127 @@
+using System;
+using System.Collections.Generic;
+using System.Text.RegularExpressions;
+using Microsoft.VisualStudio.Text;
+using VSMerlin32.Coloring.Data;
+
+namespace VSMerlin32.Coloring
+{
+ internal class Merlin32CodeHelper
+ {
+ private static readonly string CommentRegex = @"((\u003B)|(\u002A))(.*)"; // ;
+ private static readonly string TextRegex = @"(""|')[^']*(""|')";
+ // OPCODE_REG and below are initialized dynamically below.
+ private static readonly string RegexBoilerplate = @"(\b|\s)(?<{0}>{1})(\b|\s)";
+ private static readonly string Opcode = "OPCODE";
+ private static readonly string Data = "DATA";
+ private static readonly string Directive = "DIRECTIVE";
+ private static readonly string Elup = "ELUP";
+ private static string _opcodeRegex = "";
+ private static string _directiveRegex = "";
+ private static string _dataRegex = "";
+
+ public static IEnumerable GetTokens(SnapshotSpan span)
+ {
+ string TempRegex; // temp var string
+ ITextSnapshotLine containingLine = span.Start.GetContainingLine();
+ int curLoc = containingLine.Start.Position;
+ string formattedLine = containingLine.GetText();
+
+ int commentMatch = int.MaxValue;
+ Regex reg = new Regex(CommentRegex);
+ foreach (Match match in reg.Matches(formattedLine))
+ {
+ commentMatch = match.Index < commentMatch ? match.Index : commentMatch;
+ yield return new SnapshotHelper(new SnapshotSpan(new SnapshotPoint(span.Snapshot, match.Index + curLoc), match.Length), Merlin32TokenTypes.Merlin32Comment);
+ }
+
+ reg = new Regex(TextRegex);
+ foreach (Match match in reg.Matches(formattedLine))
+ {
+ if (match.Index < commentMatch)
+ yield return new SnapshotHelper(new SnapshotSpan(new SnapshotPoint(span.Snapshot, match.Index + curLoc), match.Length), Merlin32TokenTypes.Merlin32Text);
+ }
+
+ // OG NEW
+ // OPCODES
+ TempRegex = "";
+ foreach (Merlin32Opcodes token in Enum.GetValues(typeof(Merlin32Opcodes)))
+ {
+ TempRegex += token.ToString() + ("|");
+ }
+ // we remove the last "|" added
+ TempRegex = TempRegex.Remove(TempRegex.LastIndexOf("|", StringComparison.Ordinal));
+ _opcodeRegex = string.Format(RegexBoilerplate, Opcode, TempRegex);
+
+ reg = new Regex(_opcodeRegex,RegexOptions.IgnoreCase);
+ Match opcodeMatch = reg.Match(formattedLine);
+ if (opcodeMatch.Success)
+ {
+ foreach (Capture opcode in opcodeMatch.Groups[Opcode].Captures)
+ {
+ // An opcode after within a comment doesn't get a SnapShotSpan...
+ if (opcode.Index < commentMatch)
+ yield return new SnapshotHelper(new SnapshotSpan(new SnapshotPoint(span.Snapshot, opcode.Index + curLoc), opcode.Length), Merlin32TokenTypes.Merlin32Opcode);
+ }
+ }
+
+ // OG NEW
+ // DIRECTIVES
+ TempRegex = "";
+ string elupDirective = Resources.directives.ELUP;
+ foreach (Merlin32Directives token in Enum.GetValues(typeof(Merlin32Directives)))
+ {
+ if (token.ToString() != elupDirective)
+ TempRegex += token.ToString() + ("|");
+ }
+ // we remove the last "|" added
+ TempRegex = TempRegex.Remove(TempRegex.LastIndexOf("|", StringComparison.Ordinal));
+ _directiveRegex = string.Format(RegexBoilerplate, Directive, TempRegex);
+
+ reg = new Regex(_directiveRegex, RegexOptions.IgnoreCase);
+ Match directiveMatch = reg.Match(formattedLine);
+ if (directiveMatch.Success)
+ {
+ foreach (Capture directive in directiveMatch.Groups[Directive].Captures)
+ {
+ if (directive.Index < commentMatch)
+ yield return new SnapshotHelper(new SnapshotSpan(new SnapshotPoint(span.Snapshot, directive.Index + curLoc), directive.Length), Merlin32TokenTypes.Merlin32Directive);
+ }
+ }
+
+ // We also need to check for special ELUP directive...
+ reg = new Regex(Resources.directives.ELUPRegex);
+ Match elupMatch = reg.Match(formattedLine);
+ if (elupMatch.Success)
+ {
+ foreach (Capture elup in elupMatch.Groups[Elup].Captures)
+ {
+ if (elup.Index < commentMatch)
+ yield return new SnapshotHelper(new SnapshotSpan(new SnapshotPoint(span.Snapshot, elup.Index + curLoc), elup.Length), Merlin32TokenTypes.Merlin32Directive);
+ }
+ }
+
+ // OG NEW
+ // DATADEFINES
+ TempRegex = "";
+ foreach (Merlin32DataDefines token in Enum.GetValues(typeof(Merlin32DataDefines)))
+ {
+ TempRegex += token.ToString() + ("|");
+ }
+ // we remove the last "|" added
+ TempRegex = TempRegex.Remove(TempRegex.LastIndexOf("|", StringComparison.Ordinal));
+ _dataRegex = string.Format(RegexBoilerplate, Data, TempRegex);
+
+ reg = new Regex(_dataRegex, RegexOptions.IgnoreCase);
+ Match dataMatch = reg.Match(formattedLine);
+ if (dataMatch.Success)
+ {
+ foreach (Capture data in dataMatch.Groups[Data].Captures)
+ {
+ if (data.Index < commentMatch)
+ yield return new SnapshotHelper(new SnapshotSpan(new SnapshotPoint(span.Snapshot, data.Index + curLoc), data.Length), Merlin32TokenTypes.Merlin32DataDefine);
+ }
+ }
+ }
+ }
+}
diff --git a/Backup/Coloring/Merlin32TokenTag.cs b/Backup/Coloring/Merlin32TokenTag.cs
new file mode 100644
index 0000000..08ec029
--- /dev/null
+++ b/Backup/Coloring/Merlin32TokenTag.cs
@@ -0,0 +1,77 @@
+// Copyright (c) Microsoft Corporation
+// All rights reserved
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.Composition;
+using Microsoft.VisualStudio.Text;
+using Microsoft.VisualStudio.Text.Tagging;
+using Microsoft.VisualStudio.Utilities;
+using VSMerlin32.Coloring.Data;
+
+namespace VSMerlin32.Coloring
+{
+ [Export(typeof(ITaggerProvider))]
+ [ContentType("Merlin32")]
+ [TagType(typeof(Merlin32TokenTag))]
+ internal sealed class Merlin32TokenTagProvider : ITaggerProvider
+ {
+ public ITagger CreateTagger(ITextBuffer buffer) where T : ITag
+ {
+ return new Merlin32TokenTagger(buffer) as ITagger;
+ }
+ }
+
+ public class Merlin32TokenTag : ITag
+ {
+ public Merlin32TokenTypes Tokentype { get; private set; }
+
+ public Merlin32TokenTag(Merlin32TokenTypes type)
+ {
+ this.Tokentype = type;
+ }
+ }
+
+ internal sealed class Merlin32TokenTagger : ITagger
+ {
+ private ITextBuffer _buffer;
+ private readonly IDictionary _merlin32Types;
+
+ internal Merlin32TokenTagger(ITextBuffer buffer)
+ {
+ _buffer = buffer;
+ _merlin32Types = new Dictionary();
+
+ foreach (Merlin32TokenTypes token in Enum.GetValues(typeof(Merlin32TokenTypes)))
+ _merlin32Types.Add(token.ToString(), token);
+ }
+
+ public event EventHandler TagsChanged
+ {
+ add { }
+ remove { }
+ }
+
+ // OG !!!
+ public IEnumerable> GetTags(NormalizedSnapshotSpanCollection spans)
+ {
+ foreach (SnapshotSpan curSpan in spans)
+ {
+ ITextSnapshotLine containingLine = curSpan.Start.GetContainingLine();
+ int curLoc = containingLine.Start.Position;
+
+ string formattedLine = containingLine.GetText();
+
+ foreach (SnapshotHelper item in Merlin32CodeHelper.GetTokens(curSpan))
+ {
+ if (item.Snapshot.IntersectsWith(curSpan))
+ {
+ yield return new TagSpan(item.Snapshot, new Merlin32TokenTag(item.TokenType));
+ }
+ }
+
+ //add an extra char location because of the space
+ curLoc += formattedLine.Length + 1;
+ }
+ }
+ }
+}
diff --git a/Backup/Coloring/Merlin32TokenTypes.cs b/Backup/Coloring/Merlin32TokenTypes.cs
new file mode 100644
index 0000000..b1e483d
--- /dev/null
+++ b/Backup/Coloring/Merlin32TokenTypes.cs
@@ -0,0 +1,103 @@
+using System;
+using System.Collections.Generic;
+using System.Resources;
+
+namespace VSMerlin32
+{
+ public enum Merlin32Opcodes
+ {
+ ADC, ADCL, AND, ANDL, ASL,
+ BCC, BLT, BCS, BGE, BEQ, BIT, BMI, BNE, BPL, BRA, BRK, BRL, BVC, BVS,
+ CLC, CLD, CLI, CLV, CMP, CMPL, COP, CPX, CPY,
+ DEC, DEX, DEY,
+ EOR, EORL,
+ INC, INX, INY,
+ JMP, JML, JMPL, JSR, JSL,
+ LDA, LDAL, LDX, LDY, LSR,
+ MVN, MVP,
+ NOP,
+ ORA, ORAL,
+ PEA, PEI, PER, PHA, PHB, PHD, PHK, PHP, PHX, PHY, PLA, PLB, PLD, PLP, PLX, PLY,
+ REP, ROL, ROR, RTI, RTL, RTS,
+ SBC, SBCL, SEC, SED, SEI, SEP, STA, STAL, STP, STX, STY, STZ,
+ TAX, TAY, TCD, TCS, TDC, TRB, TSB, TSC, TSX, TXA, TXS, TXY, TYA, TYX,
+ WAI, WDM,
+ XBA, XCE
+ }
+
+ public enum Merlin32Directives
+ {
+ EQU,
+ ANOP, ORG, PUT, PUTBIN, /* PUTBIN n'existe pas dans Merlin 16+ */
+ START, END,
+ DUM, DEND,
+ MX, XC, LONGA, LONGI,
+ USE, USING,
+ REL, DSK, LNK, SAV,
+ TYP,
+ IF, DO, ELSE, FIN,
+ LUP, ELUP, // --^, ignored for now (invalid enum)
+ ERR, DAT,
+ AST, CYC, EXP, LST, LSTDO, PAG, TTL, SKP, TR, KBD, PAU, SW, USR
+ }
+
+ public enum Merlin32DataDefines
+ {
+ DA, DW, DDB, DFB, DB, ADR, ADRL, HEX, DS,
+ DC, DE, /* ? */
+ ASC, DCI, INV, FLS, REV, STR, STRL,
+ CHK
+ }
+
+ class Merlin32KeywordsHelper
+ {
+ /* The regex for opcodes is now defined in Merlin32CodeHelper.cs
+ public const string strMerlin32OpcodesRegex =
+@"\b(ADC(L?)|AND(L?)|ASL|BCC|BCS|BEQ|BIT|BMI|BNE|BPL|BRA|BRK|BRL|BVC|BVS|CLC|CLD|CLI|CLV|CMP(L?)|COP|CPX|CPY|DEC|DEX|DEY|EOR(L?)|INC|INX|INY|JMP(L?)|JML|JSR|JSL|LDA(L?)|LDX|LDY|LSR|MVN|MVP|NOP|ORA(L?)|ORG|PEA|PEI|PER|PHA|PHB|PHD|PHK|PHP|PHX|PHY|PLA|PLB|PLD|PLP|PLX|PLY|REP|ROL|ROR|RTI|RTL|RTS|SBC(L?)|SEC|SED|SEI|SEP|STA(L?)|STP|STX|STY|STZ|TAX|TAY|TCD|TCS|TDC|TRB|TSB|TSC|TSX|TXA|TXS|TXY|TYA|TYX|WAI|WDM|XBA|XCE)\b";
+ */
+
+ public IDictionary _Merlin32KeywordsQuickInfo;
+
+ public Merlin32KeywordsHelper()
+ {
+ // Read the resources for opcodes, all of them...
+ ResourceSet rsOpcodes = VSMerlin32.Resources.opcodes.ResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true);
+ // Read the resources for directives too, all of them...
+ ResourceSet rsDirectives = VSMerlin32.Resources.directives.ResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true);
+ // Read the resources for datadefines too, all of them...
+ ResourceSet rsData = VSMerlin32.Resources.data.ResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true);
+
+ _Merlin32KeywordsQuickInfo = new Dictionary();
+ foreach (Merlin32Opcodes token in Enum.GetValues(typeof(Merlin32Opcodes)))
+ {
+ // _Merlin32OpcodesQuickInfo[token.ToString()] = token.ToString();
+ _Merlin32KeywordsQuickInfo[token.ToString()] = rsOpcodes.GetString(token.ToString());
+ }
+ foreach (Merlin32Directives token in Enum.GetValues(typeof(Merlin32Directives)))
+ {
+ _Merlin32KeywordsQuickInfo[token.ToString()] = rsDirectives.GetString(token.ToString());
+ }
+ foreach (Merlin32DataDefines token in Enum.GetValues(typeof(Merlin32DataDefines)))
+ {
+ _Merlin32KeywordsQuickInfo[token.ToString()] = rsData.GetString(token.ToString());
+ }
+ /*
+ _Merlin32OpcodesQuickInfo[Merlin32Opcodes.ORG.ToString()] = VSMerlin32.strings.ORG;
+ */
+ }
+ }
+
+ internal sealed class Merlin32TokenHelper
+ {
+ public const string Merlin32Opcode = "Merlin32Opcode";
+ public const string Merlin32Directive = "Merlin32Directive";
+ public const string Merlin32DataDefine = "Merlin32DataDefine";
+ public const string Merlin32Text = "Merlin32Text";
+ public const string Merlin32Comment = "Merlin32Comment";
+ }
+
+ public enum Merlin32TokenTypes
+ {
+ Merlin32Opcode, Merlin32Directive, Merlin32DataDefine, Merlin32Text, Merlin32Comment
+ }
+}
diff --git a/Backup/Intellisense/CompletionController.cs b/Backup/Intellisense/CompletionController.cs
new file mode 100644
index 0000000..24c0acf
--- /dev/null
+++ b/Backup/Intellisense/CompletionController.cs
@@ -0,0 +1,195 @@
+using System;
+using System.ComponentModel.Composition;
+using System.Runtime.InteropServices;
+using Microsoft.VisualStudio;
+using Microsoft.VisualStudio.Editor;
+using Microsoft.VisualStudio.Language.Intellisense;
+using Microsoft.VisualStudio.OLE.Interop;
+
+using Microsoft.VisualStudio.Shell;
+
+using Microsoft.VisualStudio.Text;
+using Microsoft.VisualStudio.Text.Editor;
+using Microsoft.VisualStudio.TextManager.Interop;
+using Microsoft.VisualStudio.Utilities;
+
+using Microsoft.VisualStudio.Text.Operations;
+
+namespace VSMerlin32
+{
+ #region Command Filter
+
+ [Export(typeof(IVsTextViewCreationListener))]
+ [Name("Merlin32CompletionController")]
+ [ContentType("Merlin32")]
+ [TextViewRole(PredefinedTextViewRoles.Editable)]
+ internal sealed class VsTextViewCreationListener : IVsTextViewCreationListener
+ {
+ [Import]
+ internal IVsEditorAdaptersFactoryService AdaptersFactory = null;
+ [Import]
+ internal ICompletionBroker CompletionBroker { get; set; }
+ [Import]
+ internal SVsServiceProvider ServiceProvider { get; set; }
+
+ public void VsTextViewCreated(IVsTextView textViewAdapter)
+ {
+ ITextView textView = AdaptersFactory.GetWpfTextView(textViewAdapter);
+ if (textView == null)
+ return;
+
+ Func createCommandHandler = delegate { return new CommandFilter(textViewAdapter, textView, this); };
+ textView.Properties.GetOrCreateSingletonProperty(createCommandHandler);
+ }
+ }
+
+ internal sealed class CommandFilter : IOleCommandTarget
+ {
+ private IOleCommandTarget _nextCommandHandler;
+ private ITextView _textView;
+ private VsTextViewCreationListener _provider;
+ private ICompletionSession _session;
+
+ internal CommandFilter(IVsTextView textViewAdapter, ITextView textView, VsTextViewCreationListener provider)
+ {
+ _textView = textView;
+ _provider = provider;
+
+ //add the command to the command chain
+ textViewAdapter.AddCommandFilter(this, out _nextCommandHandler);
+ }
+
+ public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
+ {
+ return _nextCommandHandler.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText);
+ }
+
+ public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
+ {
+ if (VsShellUtilities.IsInAutomationFunction(_provider.ServiceProvider))
+ {
+ return _nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
+ }
+ //make a copy of this so we can look at it after forwarding some commands
+ uint commandID = nCmdID;
+ char typedChar = char.MinValue;
+ //make sure the input is a char before getting it
+ if (pguidCmdGroup == VSConstants.VSStd2K && nCmdID == (uint)VSConstants.VSStd2KCmdID.TYPECHAR)
+ {
+ typedChar = (char)(ushort)Marshal.GetObjectForNativeVariant(pvaIn);
+ }
+
+ //check for a commit character
+ if (nCmdID == (uint)VSConstants.VSStd2KCmdID.RETURN
+ || nCmdID == (uint)VSConstants.VSStd2KCmdID.TAB
+ || char.IsWhiteSpace(typedChar)
+ || char.IsPunctuation(typedChar))
+ {
+ //check for a a selection
+ if (_session != null && !_session.IsDismissed)
+ {
+ //if the selection is fully selected, commit the current session
+ if (_session.SelectedCompletionSet.SelectionStatus.IsSelected)
+ {
+ _session.Commit();
+ //also, don't add the character to the buffer
+ return VSConstants.S_OK;
+ }
+ else
+ {
+ //if there is no selection, dismiss the session
+ _session.Dismiss();
+ }
+ }
+ }
+
+ //pass along the command so the char is added to the buffer
+ int retVal = _nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
+ bool handled = false;
+ // Test for '-' is to catch ELUP (--^)
+ if (!typedChar.Equals(char.MinValue) && ((char.IsLetterOrDigit(typedChar)) || ((typedChar == '\'') || (typedChar == '"') || (typedChar == '-'))))
+ {
+ if (_session == null || _session.IsDismissed) // If there is no active session, bring up completion
+ {
+ TriggerCompletion();
+ // No need to filter for single and double-quotes, the choice IS the characted, just doubled, and already populated in a single completionset if we're here...
+ if ((typedChar == '\'') || (typedChar == '"'))
+ {
+ // We need to save the currect caret position because we'll position it in between the single/double quotes after the commit...
+ ITextCaret caretBeforeCommit = _session.TextView.Caret;
+ _session.Commit();
+ _textView.Caret.MoveTo(caretBeforeCommit.Position.BufferPosition - 1);
+ }
+ else if (!_session.IsDismissed)
+ {
+ _session.Filter();
+ }
+ }
+ else //the completion session is already active, so just filter
+ {
+ _session.Filter();
+ }
+ handled = true;
+ }
+ else if (commandID == (uint)VSConstants.VSStd2KCmdID.BACKSPACE //redo the filter if there is a deletion
+ || commandID == (uint)VSConstants.VSStd2KCmdID.DELETE)
+ {
+ if (_session != null && !_session.IsDismissed)
+ _session.Filter();
+ handled = true;
+ }
+
+ if (handled) return VSConstants.S_OK;
+ return retVal;
+ }
+
+ private bool TriggerCompletion()
+ {
+ //the caret must be in a non-projection location
+ SnapshotPoint? caretPoint =
+ _textView.Caret.Position.Point.GetPoint(
+ textBuffer => (!textBuffer.ContentType.IsOfType("projection")), PositionAffinity.Predecessor);
+ if (!caretPoint.HasValue)
+ {
+ return false;
+ }
+
+ _session = _provider.CompletionBroker.CreateCompletionSession(_textView,
+ caretPoint.Value.Snapshot.CreateTrackingPoint(caretPoint.Value.Position, PointTrackingMode.Positive),
+ true);
+
+ // We need to check now whether we are in a comment or not, because if we are, we don't want to provide a completion list to the user
+ ITextSnapshot snapshot = caretPoint.Value.Snapshot;
+ var triggerPoint = (SnapshotPoint)_session.GetTriggerPoint(snapshot);
+ var snapshotSpan = new SnapshotSpan(triggerPoint, 0);
+ foreach (VSMerlin32.Coloring.Data.SnapshotHelper item in VSMerlin32.Coloring.Merlin32CodeHelper.GetTokens(snapshotSpan))
+ {
+ if (item.Snapshot.IntersectsWith(snapshotSpan))
+ {
+ if (item.TokenType == Merlin32TokenTypes.Merlin32Comment)
+ {
+ _session.Dismiss();
+ break;
+ }
+ }
+ }
+
+ if (!_session.IsDismissed)
+ {
+ //subscribe to the Dismissed event on the session
+ _session.Dismissed += OnSessionDismissed;
+ _session.Start();
+ }
+
+ return true;
+ }
+
+ private void OnSessionDismissed(object sender, EventArgs e)
+ {
+ _session.Dismissed -= OnSessionDismissed;
+ _session = null;
+ }
+ }
+
+ #endregion
+}
\ No newline at end of file
diff --git a/Backup/Intellisense/CompletionSource.cs b/Backup/Intellisense/CompletionSource.cs
new file mode 100644
index 0000000..800eb85
--- /dev/null
+++ b/Backup/Intellisense/CompletionSource.cs
@@ -0,0 +1,104 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.Composition;
+using Microsoft.VisualStudio.Language.Intellisense;
+using Microsoft.VisualStudio.Text;
+using Microsoft.VisualStudio.Text.Operations;
+using Microsoft.VisualStudio.Utilities;
+
+namespace VSMerlin32
+{
+ [Export(typeof(ICompletionSourceProvider))]
+ [ContentType("Merlin32")]
+ [Name("Merlin32Completion")]
+ internal class Merlin32CompletionSourceProvider : ICompletionSourceProvider
+ {
+ [Import]
+ internal ITextStructureNavigatorSelectorService NavigatorService { get; set; }
+
+ public ICompletionSource TryCreateCompletionSource(ITextBuffer textBuffer)
+ {
+ return new Merlin32CompletionSource(this, textBuffer);
+ }
+ }
+
+ internal class Merlin32CompletionSource : ICompletionSource
+ {
+ private Merlin32CompletionSourceProvider _sourceprovider;
+ private ITextBuffer _buffer;
+ private List _compList;
+ private bool _isDisposed;
+
+ public Merlin32CompletionSource(Merlin32CompletionSourceProvider sourceprovider, ITextBuffer buffer)
+ {
+ _sourceprovider = sourceprovider;
+ _buffer = buffer;
+ }
+
+ public void AugmentCompletionSession(ICompletionSession session, IList completionSets)
+ {
+ if (_isDisposed)
+ throw new ObjectDisposedException("Merlin32CompletionSource");
+
+ List strList = new List();
+ char chTyped = ((session.TextView.Caret.Position.BufferPosition) - 1).GetChar();
+ // Testing for single and double quotes because these will be autocompleted...
+ if ((chTyped == '\'') || (chTyped == '"'))
+ {
+ strList.Add(chTyped.ToString() + chTyped.ToString());
+ }
+ else
+ {
+ // If the user has been typing lowercase, we'll present a lowercase list of keywords/opcodes...
+ foreach (Merlin32Opcodes token in Enum.GetValues(typeof(Merlin32Opcodes)))
+ {
+ strList.Add(char.IsLower(chTyped)? token.ToString().ToLower() : token.ToString());
+ }
+ foreach (Merlin32Directives token in Enum.GetValues(typeof(Merlin32Directives)))
+ {
+ if ((token.ToString().ToLower() == Merlin32Directives.ELUP.ToString().ToLower()) || (token.ToString() == Merlin32Directives.ELUP.ToString()))
+ {
+ strList.Add(Resources.directives.ELUPValue);
+ }
+ else
+ {
+ strList.Add(char.IsLower(chTyped)? token.ToString().ToLower() : token.ToString());
+ }
+ }
+ foreach (Merlin32DataDefines token in Enum.GetValues(typeof(Merlin32DataDefines)))
+ {
+ strList.Add(char.IsLower(chTyped)? token.ToString().ToLower() : token.ToString());
+ }
+
+ // OG We also need to replace "ELUP" with "--^"
+ // OG 2015/10/21
+ strList.Sort();
+ // strList[strList.IndexOf(Merlin32Directives.ELUP.ToString())] = "--^";
+ // OG
+ }
+ _compList = new List();
+ foreach (string str in strList)
+ _compList.Add(new Completion(str, str, str, null, null));
+
+ completionSets.Add(new CompletionSet("All", "All", FindTokenSpanAtPosition(session), _compList, null));
+ }
+
+ private ITrackingSpan FindTokenSpanAtPosition(ICompletionSession session)
+ {
+ SnapshotPoint currentPoint = (session.TextView.Caret.Position.BufferPosition) - 1;
+ ITextStructureNavigator navigator = _sourceprovider.NavigatorService.GetTextStructureNavigator(_buffer);
+ TextExtent extent = navigator.GetExtentOfWord(currentPoint);
+ return currentPoint.Snapshot.CreateTrackingSpan(extent.Span, SpanTrackingMode.EdgeInclusive);
+ }
+
+ public void Dispose()
+ {
+ if (!_isDisposed)
+ {
+ GC.SuppressFinalize(this);
+ _isDisposed = true;
+ }
+ }
+ }
+}
+
diff --git a/Backup/Intellisense/Merlin32QuickInfoSource.cs b/Backup/Intellisense/Merlin32QuickInfoSource.cs
new file mode 100644
index 0000000..c6b8924
--- /dev/null
+++ b/Backup/Intellisense/Merlin32QuickInfoSource.cs
@@ -0,0 +1,102 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.VisualStudio.Language.Intellisense;
+using Microsoft.VisualStudio.Text;
+using Microsoft.VisualStudio.Text.Tagging;
+using System.ComponentModel.Composition;
+using Microsoft.VisualStudio.Utilities;
+using VSMerlin32.Coloring;
+
+namespace VSMerlin32
+{
+ [Export(typeof(IQuickInfoSourceProvider))]
+ [ContentType("Merlin32")]
+ [Name("Merlin32QuickInfo")]
+ class Merlin32QuickInfoSourceProvider : IQuickInfoSourceProvider
+ {
+ [Import]
+ private IBufferTagAggregatorFactoryService _aggService = null;
+
+ public IQuickInfoSource TryCreateQuickInfoSource(ITextBuffer textBuffer)
+ {
+ return new Merlin32QuickInfoSource(textBuffer, _aggService.CreateTagAggregator(textBuffer));
+ }
+ }
+
+ class Merlin32QuickInfoSource : IQuickInfoSource
+ {
+ private ITagAggregator _aggregator;
+ private ITextBuffer _buffer;
+ private Merlin32KeywordsHelper _Merlin32OpcodesHelper = new Merlin32KeywordsHelper();
+ private bool _disposed;
+
+ public Merlin32QuickInfoSource(ITextBuffer buffer, ITagAggregator aggregator)
+ {
+ _aggregator = aggregator;
+ _buffer = buffer;
+ }
+
+ public void AugmentQuickInfoSession(IQuickInfoSession session, IList