示例#1
0
 public RenderOpts(SelectionState selectionState, Selection selection, CellAssignments[,] assignments, SchemeNode hoveredNode)
 {
     SelectionState = selectionState;
     Selection      = selection;
     Assignments    = assignments;
     HoveredNode    = hoveredNode;
 }
        void ModifyButtonClick(object sender, EventArgs ev)
        {
            if (userList.SelectedIndex == -1)
            {
                return;
            }

            XmlTextReader reader = new XmlTextReader(userList.SelectedValue.ToString());
            SchemeNode    node   = CreateSchemeNode(reader, true);

            using (EditHighlightingDialog dlg = new EditHighlightingDialog(node))
            {
                DialogResult res = dlg.ShowDialog();

                if (res == DialogResult.OK)
                {
                    using (StreamWriter sw = new StreamWriter(userList.SelectedValue.ToString(), false))
                    {
                        sw.WriteLine(node.ToXml().Replace("\n", "\r\n"));
                    }
                }

                try
                {
                    node.Remove();
                }
                catch {}
            }
        }
        public override void LoadSettings()
        {
            SchemeNode node = (SchemeNode)parentNode;

            nameBox.Text = node.Name;
            extBox.Text  = String.Join(";", node.Extensions);
        }
        public override void StoreSettings()
        {
            SchemeNode node = (SchemeNode)parentNode;

            node.Name       = nameBox.Text;
            node.Extensions = extBox.Text.Split(';');
        }
 public SchemeOptionPanel(SchemeNode parent) : base(parent)
 {
     SetupFromXmlFile(System.IO.Path.Combine(PropertyService.DataDirectory,
                                             @"resources\panels\HighlightingEditor\Scheme.xfrm"));
     nameBox = (TextBox)ControlDictionary["nameBox"];
     extBox  = (TextBox)ControlDictionary["extBox"];
 }
示例#6
0
        void CopyButtonClick(object sender, EventArgs ev)
        {
            if (builtinList.SelectedIndex == -1)
            {
                return;
            }

            try {
                HighlightItem item = (HighlightItem)builtinList.SelectedItem;

                string filename = item.FileName;
                if (filename == null)
                {
                    filename = item.SyntaxMode.FileName;
                }

                string newname = Path.GetFileName(filename);
                newname = Path.Combine(PropertyService.ConfigDirectory, "modes" +
                                       Path.DirectorySeparatorChar + newname);

                using (StreamWriter fs = File.CreateText(newname)) {
                    fs.Write(item.Node.Content);
                }

                SchemeNode newNode = LoadFile(new XmlTextReader(newname), true, Path.GetFileNameWithoutExtension(newname));
                if (newNode == null)
                {
                    throw new Exception();
                }

                userList.Items.Add(new HighlightItem(null, newname, newNode));
            } catch (Exception e) {
                MessageService.ShowError(e, "${res:Dialog.Options.TextEditorOptions.EditHighlighting.CopyError}");
            }
            BuiltinListSelectedIndexChanged(this, EventArgs.Empty);
        }
示例#7
0
 public static IEnumerable <(QualifiedName prefix, ISchemeEntry entry)> GetAllChildrenAndSelf(this SchemeNode node) =>
示例#8
0
 public HighlightItem(SyntaxMode mode, string filename, SchemeNode Node)
 {
     syntaxMode = mode;
     fileName   = filename;
     node       = Node;
 }
示例#9
0
        void FillLists()
        {
            builtinList.Items.Clear();
            userList.Items.Clear();

            string uPath = Path.Combine(PropertyService.ConfigDirectory, "modes");

            List <string> uCol;

            if (Directory.Exists(uPath))
            {
                uCol = FileUtility.SearchDirectory(uPath, "*.xshd", true);
            }
            else
            {
                Directory.CreateDirectory(uPath);
                uCol = new List <string>();
            }

            foreach (string str in uCol)
            {
                SchemeNode node = LoadFile(new XmlTextReader(str), true, Path.GetFileNameWithoutExtension(str));
                if (node == null)
                {
                    continue;
                }
                userList.Items.Add(new HighlightItem(null, str, node));
            }

            ISyntaxModeFileProvider modeProvider;

            modeProvider = new ResourceSyntaxModeProvider();

            foreach (SyntaxMode mode in modeProvider.SyntaxModes)
            {
                SchemeNode node = LoadFile(modeProvider.GetSyntaxModeFile(mode), false, mode.Name);
                if (node == null)
                {
                    continue;
                }
                builtinList.Items.Add(new HighlightItem(mode, null, node));
            }

            modeProvider = new ICSharpCode.SharpDevelop.DefaultEditor.Codons.AddInTreeSyntaxModeProvider();

            foreach (SyntaxMode mode in modeProvider.SyntaxModes)
            {
                SchemeNode node = LoadFile(modeProvider.GetSyntaxModeFile(mode), false, mode.Name);
                if (node == null)
                {
                    continue;
                }
                builtinList.Items.Add(new HighlightItem(mode, null, node));
            }

            if (builtinList.Items.Count > 0)
            {
                builtinList.SelectedIndex = 0;
            }

            if (userList.Items.Count > 0)
            {
                userList.SelectedIndex = 0;
            }
        }
 public static IEnumerable <Payload> GetOriginalPayload(this SchemeNode node) =>
 node.GetAllChildren().OfType <SchemeLeaf>().Select(l => l.OriginalEntry);
示例#11
0
 public NodeState(SchemeNode node, bool isHigh)
 {
     Node   = node;
     IsHigh = isHigh;
 }
示例#12
0
 public IEnumerable <(QualifiedName prefix, IFormatter formatter)> Build(SchemeNode node) =>