Exemplo n.º 1
0
        public static string MakeString(this IEnumerable <Character> chars, Eol eol = Eol.Lf)
        {
            var sb = new StringBuilder(chars.Count());

            foreach (var c in chars)
            {
                if (c.IsNewLine)
                {
                    if (eol == Eol.CrLf)
                    {
                        sb.Append("\r\n");
                    }
                    else if (eol == Eol.Cr)
                    {
                        sb.Append('\r');
                    }
                    else
                    {
                        sb.Append('\n');
                    }
                }
                else
                {
                    sb.Append(c.Char);
                }
            }

            return(sb.ToString());
        }
Exemplo n.º 2
0
 public void InsertGroup(XElement root, string group)
 {
     if (!Initialized)
     {
         throw new Exception("Detected not yet initialized, please run Load() first.");
     }
     InsertGroup(root, group, Eol.ToEolString());
 }
Exemplo n.º 3
0
 public void RemoveNode(XElement root, string group, bool leaveBrankLine = false)
 {
     if (!Initialized)
     {
         throw new Exception("Detected not yet initialized, please run Load() first.");
     }
     RemoveGroup(root, group, Eol.ToEolString(), leaveBrankLine);
 }
Exemplo n.º 4
0
 public void InsertNode(XElement root, string group, string node, string value)
 {
     if (!Initialized)
     {
         throw new Exception("Detected not yet initialized, please run Load() first.");
     }
     InsertNode(root, group, node, value, Eol.ToEolString());
 }
Exemplo n.º 5
0
 /// <summary>
 /// Insert attribute on Node
 /// </summary>
 /// <param name="group"></param>
 /// <param name="node"></param>
 /// <param name="attributes"></param>
 /// <param name="filterElement"></param>
 public void InsertAttribute(string group, string node, CsProjAttribute[] attributes, Func <XElement, bool> filterElement, bool allowDuplicate = false)
 {
     if (!Initialized)
     {
         throw new Exception("Detected not yet initialized, please run Load() first.");
     }
     InsertAttribute(Root, group, node, attributes, Eol.ToEolString(), filterElement, allowDuplicate);
 }
Exemplo n.º 6
0
        public void SetBufferEol(Eol eol)
        {
            var buf = GetBuffer();

            if (buf != null)
            {
                buf.Eol = eol;
            }
        }
Exemplo n.º 7
0
        public static string AsString(this Eol eol)
        {
            switch (eol)
            {
            case Eol.Cr: return("\r");

            case Eol.Lf: return("\n");

            case Eol.CrLf: return("\r\n");

            default: return(Environment.NewLine);
            }
        }
Exemplo n.º 8
0
        public string GetText()
        {
            var @lock = ObtainLock();

            try
            {
                return(string.Join(Eol.AsString(), Document.Lines.Select(ln => ln.Text)));
            }
            finally
            {
                @lock.Release();
            }
        }
Exemplo n.º 9
0
        private void InitDocument(Eol eolMode = Eol.CrLf, bool useTabs = false, int tabWidth = 4, int indentWidth = 0)
        {
            // Document.h
            // These properties are stored in the document object used by Scintilla and
            // thus will have their properties reset when changing the document.

            DirectMessage(NativeMethods.SCI_SETCODEPAGE, new IntPtr(NativeMethods.SC_CP_UTF8));
            DirectMessage(NativeMethods.SCI_SETUNDOCOLLECTION, new IntPtr(1));
            DirectMessage(NativeMethods.SCI_SETEOLMODE, new IntPtr((int)eolMode));
            DirectMessage(NativeMethods.SCI_SETUSETABS, useTabs ? new IntPtr(1) : IntPtr.Zero);
            DirectMessage(NativeMethods.SCI_SETTABWIDTH, new IntPtr(tabWidth));
            DirectMessage(NativeMethods.SCI_SETINDENT, new IntPtr(indentWidth));
        }
Exemplo n.º 10
0
 /// <summary>
 /// Changes all end-of-line characters in the document to the format specified.
 /// </summary>
 /// <param name="eolMode">One of the <see cref="Eol" /> enumeration values.</param>
 public void ConvertEols(Eol eolMode)
 {
     var eol = (int)eolMode;
     DirectMessage(NativeMethods.SCI_CONVERTEOLS, new IntPtr(eol));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Changes all end-of-line characters in the document to the format specified.
 /// </summary>
 /// <param name="eolMode">One of the Eol enumeration values.</param>
 public static void ConvertEols(Eol eolMode)
 {
     var eol = (int) eolMode;
     Sci.Send(SciMsg.SCI_CONVERTEOLS, new IntPtr(eol));
 }
Exemplo n.º 12
0
        private void SetEolMode(Eol eolMode)
        {
            TextEditorForm currentTextEditorForm = this.GetCurrentTextEditorForm();

            if (currentTextEditorForm == null) {
                return;
            }

            currentTextEditorForm.Scintilla.EolMode = eolMode;
            currentTextEditorForm.Scintilla.ConvertEols(eolMode);
        }
Exemplo n.º 13
0
        private void InitDocument(Eol eolMode = Eol.CrLf, bool useTabs = false, int tabWidth = 4, int indentWidth = 0)
        {
            // Document.h
            // These properties are stored in the Scintilla document, not the control; meaning, when
            // a user changes documents these properties will change. If the user changes to a new
            // document, these properties will reset to defaults. That can cause confusion for our users
            // who would expect their tab settings, for example, to be unchanged based on which document
            // they have selected into the control. This is where we carry forward any of the user's
            // current settings -- and our default overrides -- to a new document.

            DirectMessage(NativeMethods.SCI_SETCODEPAGE, new IntPtr(NativeMethods.SC_CP_UTF8));
            DirectMessage(NativeMethods.SCI_SETUNDOCOLLECTION, new IntPtr(1));
            DirectMessage(NativeMethods.SCI_SETEOLMODE, new IntPtr((int)eolMode));
            DirectMessage(NativeMethods.SCI_SETUSETABS, useTabs ? new IntPtr(1) : IntPtr.Zero);
            DirectMessage(NativeMethods.SCI_SETTABWIDTH, new IntPtr(tabWidth));
            DirectMessage(NativeMethods.SCI_SETINDENT, new IntPtr(indentWidth));
        }