當前位置: 首頁>>代碼示例>>C#>>正文


C# ScintillaControl.InsertText方法代碼示例

本文整理匯總了C#中ScintillaNet.ScintillaControl.InsertText方法的典型用法代碼示例。如果您正苦於以下問題:C# ScintillaControl.InsertText方法的具體用法?C# ScintillaControl.InsertText怎麽用?C# ScintillaControl.InsertText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ScintillaNet.ScintillaControl的用法示例。


在下文中一共展示了ScintillaControl.InsertText方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TraceExpr

        private static void TraceExpr(ScintillaControl sci, string expr)
        {
            if (IsMethoDecl(sci)) SkipMethod(sci);
            else sci.LineEnd();

            sci.NewLine();
            sci.InsertText(sci.CurrentPos, String.Format("trace(\"{0} = \" + {1});", expr, SafeExpr(expr)));
            sci.LineEnd();
        }
開發者ID:elsassph,項目名稱:fdMacros,代碼行數:9,代碼來源:Trace.cs

示例2: OnCompletionInsert

        public override bool OnCompletionInsert(ScintillaControl sci, int position, string text, char trigger)
        {
            if (text == "Dictionary")
            {
                string insert = null;
                string line = sci.GetLine(sci.LineFromPosition(position));
                Match m = Regex.Match(line, @"\svar\s+(?<varname>.+)\s*:\s*Dictionary\.<(?<indextype>.+)(?=(>\s*=))");
                if (m.Success)
                {
                    insert = String.Format(".<{0}>", m.Groups["indextype"].Value);
                }
                else
                {
                    m = Regex.Match(line, @"\s*=\s*new");
                    if (m.Success)
                    {
                        ASResult result = ASComplete.GetExpressionType(sci, sci.PositionFromLine(sci.LineFromPosition(position)) + m.Index);
                        if (result != null && !result.IsNull() && result.Member != null && result.Member.Type != null)
                        {
                            m = Regex.Match(result.Member.Type, @"(?<=<).+(?=>)");
                            if (m.Success)
                            {
                                insert = String.Format(".<{0}>", m.Value);
                            }
                        }
                    }
                    if (insert == null)
                    {
                        if (trigger == '.' || trigger == '(') return true;
                        insert = ".<>";
                        sci.InsertText(position + text.Length, insert);
                        sci.CurrentPos = position + text.Length + 2;
                        sci.SetSel(sci.CurrentPos, sci.CurrentPos);
                        ASComplete.HandleAllClassesCompletion(sci, "", false, true);
                        return true;
                    }
                }
                if (insert == null) return false;
                if (trigger == '.')
                {
                    sci.InsertText(position + text.Length, insert.Substring(1));
                    sci.CurrentPos = position + text.Length;
                }
                else
                {
                    sci.InsertText(position + text.Length, insert);
                    sci.CurrentPos = position + text.Length + insert.Length;
                }
                sci.SetSel(sci.CurrentPos, sci.CurrentPos);
                return true;
            }

            return base.OnCompletionInsert(sci, position, text, trigger);
        }
開發者ID:JoeRobich,項目名稱:flashdevelop,代碼行數:54,代碼來源:Context.cs

示例3: GetOrSetPointOfInsertion

        /// <summary>
        /// Looks for the best next position to insert new code, inserting new lines if needed
        /// </summary>
        /// <param name="startPos">The position inside the Scintilla document to start looking for the insertion position</param>
        /// <param name="endPos">The end position inside the Scintilla document</param>
        /// <param name="baseLine">The line inside the document to use as the base for the indentation level and detect if the desired point
        /// matches the end line</param>
        /// <param name="sci">The ScintillaControl where our document resides</param>
        /// <returns>The insertion point position</returns>
        private static int GetOrSetPointOfInsertion(int startPos, int endPos, int baseLine, ScintillaControl sci)
        {
            char[] characterClass = { ' ', '\r', '\n', '\t' };
            int nCount = 0;
            int extraLine = 1;

            int initialLn = sci.LineFromPosition(startPos);
            int baseIndent = sci.GetLineIndentation(baseLine);

            bool found = false;
            while (startPos <= endPos)
            {
                char c = (char)sci.CharAt(startPos);
                if (Array.IndexOf(characterClass, c) == -1)
                {
                    int endLn = sci.LineFromPosition(startPos);
                    if (endLn == baseLine || endLn == initialLn)
                    {
                        sci.InsertText(startPos, sci.NewLineMarker);
                        // Do we want to set the line indentation no matter what? {\r\t\t\t\r} -> {\r\t\r}
                        // Better results in most cases, but maybe highly unwanted in others?
                        sci.SetLineIndentation(++endLn, baseIndent + sci.Indent);
                        startPos = sci.LineIndentPosition(endLn);
                    }
                    if (c == '}')
                    {
                        sci.InsertText(startPos, sci.NewLineMarker);
                        sci.SetLineIndentation(endLn + 1, baseIndent);
                        // In relation with previous comment... we'll reinden this one: {\r} -> {\r\t\r}
                        if (sci.GetLineIndentation(endLn) <= baseIndent)
                        {
                            sci.SetLineIndentation(endLn, baseIndent + sci.Indent);
                            startPos = sci.LineIndentPosition(endLn);
                        }
                    }
                    found = true;
                    break;
                }
                else if (sci.EOLMode == 1 && c == '\r' && (++nCount) > extraLine)
                {
                    found = true;
                    break;
                }
                else if (c == '\n' && (++nCount) > extraLine)
                {
                    if (sci.EOLMode != 2)
                    {
                        startPos--;
                    }
                    found = true;
                    break;
                }
                startPos++;
            }

            if (!found) startPos--;

            return startPos;
        }
開發者ID:JoeRobich,項目名稱:flashdevelop,代碼行數:68,代碼來源:ASGenerator.cs

示例4: OnChar


//.........這裏部分代碼省略.........
                                        }
                                    }
                                    if (tmpTags.Count > 0)
                                        indent = sci.GetLineIndentation(sci.LineFromPosition(tmpTags.Pop().Position));
                                    else if (tmpTag.Name != null)
                                    {
                                        subIndent = true;
                                        checkStart = "</" + tmpTag.Name;
                                        indent = sci.GetLineIndentation(sci.LineFromPosition(tmpTag.Position));
                                    }
                                    else
                                    {
                                        indent = sci.GetLineIndentation(sci.LineFromPosition(tmpTag.Position));
                                    }
                                }
                            }
                            else if (ctag.Name != null)
                            {
                                // Indentation. Some IDEs use the tag position, VS uses the tag start line indentation. 
                                indent = sci.GetLineIndentation(sci.LineFromPosition(ctag.Position));
                                checkStart = "</" + ctag.Name;
                                if (ctag.Name.ToLower() == "script" || ctag.Name.ToLower() == "style") 
                                    subIndent = false;
                            }
                            try
                            {
                                sci.BeginUndoAction();
                                if (checkStart != null)
                                {
                                    text = sci.GetLine(line).TrimStart();
                                    if (text.StartsWith(checkStart))
                                    {
                                        sci.SetLineIndentation(line, indent);
                                        sci.InsertText(sci.PositionFromLine(line), LineEndDetector.GetNewLineMarker(sci.EOLMode));
                                    }
                                }
                                // Indent the code
                                if (subIndent) indent += sci.Indent;
                                sci.SetLineIndentation(line, indent);
                                position = sci.LineIndentPosition(line);
                                sci.SetSel(position, position);
                            }
                            finally { sci.EndUndoAction(); }
                            return;
                        }
                        else if (!text.EndsWith(">"))
                        {
                            ctag = GetXMLContextTag(sci, sci.CurrentPos);
                            if (ctag.Tag == null || ctag.Name == null) return;
                            // We're inside a tag. Visual Studio indents with regards to the first line, other IDEs indent using the indentation of the last line with text.
                            int indent;
                            string tag = (ctag.Tag.IndexOf('\r') > 0 || ctag.Tag.IndexOf('\n') > 0) ? ctag.Tag.Substring(0, ctag.Tag.IndexOfAny(new[] {'\r', '\n'})).TrimEnd() : ctag.Tag.TrimEnd();
                            if (tag.EndsWith("\""))
                            {
                                int i;
                                int l = tag.Length;
                                for (i = ctag.Name.Length + 1; i < l; i++)
                                {
                                    if (!char.IsWhiteSpace(tag[i]))
                                        break;
                                }
                                indent = sci.Column(ctag.Position) + sci.MBSafePosition(i);
                            }
                            else
                            {
                                indent = sci.GetLineIndentation(sci.LineFromPosition(ctag.Position)) + sci.Indent;
開發者ID:ImaginationSydney,項目名稱:flashdevelop,代碼行數:67,代碼來源:XMLComplete.cs

示例5: AutoCloseBrace

        /// <summary>
        /// Add closing brace to a code block.
        /// If enabled, move the starting brace to a new line.
        /// </summary>
        /// <param name="Sci"></param>
        /// <param name="txt"></param>
        /// <param name="line"></param>
        public static void AutoCloseBrace(ScintillaControl Sci, int line)
        {
            // find matching brace
            int bracePos = Sci.LineEndPosition(line - 1) - 1;
            while ((bracePos > 0) && (Sci.CharAt(bracePos) != '{')) bracePos--;
            if (bracePos == 0 || Sci.BaseStyleAt(bracePos) != 5) return;
            int match = Sci.SafeBraceMatch(bracePos);
            int start = line;
            int indent = Sci.GetLineIndentation(start - 1);
            if (match > 0)
            {
                int endIndent = Sci.GetLineIndentation(Sci.LineFromPosition(match));
                if (endIndent + Sci.TabWidth > indent)
                    return;
            }

            // find where to include the closing brace
            int startIndent = indent;
            int count = Sci.LineCount;
            int lastLine = line;
            int position;
            string txt = Sci.GetLine(line).Trim();
            line++;
            int eolMode = Sci.EOLMode;
            string NL = LineEndDetector.GetNewLineMarker(eolMode);

            if (txt.Length > 0 && ")]};,".IndexOf(txt[0]) >= 0)
            {
                Sci.BeginUndoAction();
                try
                {
                    position = Sci.CurrentPos;
                    Sci.InsertText(position, NL + "}");
                    Sci.SetLineIndentation(line, startIndent);
                }
                finally
                {
                    Sci.EndUndoAction();
                }
                return;
            }
            else
            {
                while (line < count - 1)
                {
                    txt = Sci.GetLine(line).TrimEnd();
                    if (txt.Length != 0)
                    {
                        indent = Sci.GetLineIndentation(line);
                        if (indent <= startIndent) break;
                        lastLine = line;
                    }
                    else break;
                    line++;
                }
            }
            if (line >= count - 1) lastLine = start;

            // insert closing brace
            Sci.BeginUndoAction();
            try
            {
                position = Sci.LineEndPosition(lastLine);
                Sci.InsertText(position, NL + "}");
                Sci.SetLineIndentation(lastLine + 1, startIndent);
            }
            finally
            {
                Sci.EndUndoAction();
            }
        }
開發者ID:ImaginationSydney,項目名稱:flashdevelop,代碼行數:78,代碼來源:Completion.cs

示例6: OnInsert

 internal void OnInsert(ScintillaControl sci, int position, string text, char trigger, ICompletionListItem item)
 {
     if (!(item is CompletionItem)) return;
     CompletionItem it = item as CompletionItem;
     if (trigger == ':')
     {
         lastColonInsert = position + text.Length + 1;
     }
     else if (it.Kind == ItemKind.Property && !settings.DisableInsertColon)
     {
         int pos = position + text.Length;
         char c = (char)sci.CharAt(pos);
         if (c != ':') sci.InsertText(pos, ":");
         sci.SetSel(pos + 1, pos + 1);
         lastColonInsert = pos + 1;
     }
     else lastColonInsert = -1;
 }
開發者ID:ImaginationSydney,項目名稱:flashdevelop,代碼行數:18,代碼來源:Completion.cs

示例7: CompletionList_OnInsert

        void CompletionList_OnInsert(ScintillaControl sender, int position, string text, char trigger, ICompletionListItem item)
        {
            if (trigger == '(' || trigger == '.') return;
            if (!(item is MemberItem)) return; // Generate Event
              //      if (item is EventItem) return;
             currentData = (DataEvent)currentNotifyEvent;
             Hashtable table = currentData.Data as Hashtable;
             if (table==null) return;

            ASResult res = (table)["context"] as ASResult;

            if (res == null) return;

            MemberModel member = res.Member;
            int posAdd = 0;

                    if (member != null)
                    {
                        if ((member.Flags & FlagType.Function) == 0) { return; }

                            int pos = sender.CurrentPos;
                            int insertPos = pos;
                            if (((member.Flags & FlagType.Constructor) > 0))
                            {

                                if (!thereIsNewWord(sender))
                                {
                                    sender.GotoPos(pos);
                                    return;
                                }
                            }

                          //  sender.ReplaceSel
                                bool hasParameters = false;

                                char lastChar=' ';
                                posAdd = SearchNextNewLineWithoutChar(sender, position, text, ref lastChar);

                                if (lastChar == '(')
                                {
                                    return;
                                }

                            // Search if is a parameter of a function
                                if (lastChar == ',' || lastChar == ')')
                                {
                                    if (IsFunctionParameter(sender, position - 1))
                                    {
                                        return;
                                    };
                                }

                                sender.BeginUndoAction();

                                if (posAdd > 0)
                                {
                                    sender.InsertText(pos, "();");
                                    posAdd = 1;

                                }
                                else
                                    sender.InsertText(pos, "()");

                                pos++;

                                if (!(trigger == '[' || trigger == '"'))
                                {
                                    if (member.Parameters != null)
                                    {
                                        if (member.Parameters.Count == 0)
                                        {
                                            pos += 1 + posAdd;

                                        }
                                        else
                                        {
                                            hasParameters = true;
                                        }

                                    }
                                    else
                                    {
                                        pos += 1 + posAdd;
                                    }

                                }

                                sender.GotoPos(pos);

                                if (hasParameters)
                                {
                                    if (abbreviations != null &&  member.Parameters[0].Value == null && member.Parameters[0].Name != "...rest")
                                    {

                                       // string str = res.Member.ToString();
                                        TextParameters tp = new TextParameters(res.Member);

                                        if (member.Name.EndsWith("EventListener"))
                                        {
                                            if (text.EndsWith("Event"))
//.........這裏部分代碼省略.........
開發者ID:fordream,項目名稱:wanghe-project,代碼行數:101,代碼來源:AutoClose.cs

示例8: SciInsertAndSelect

        private static void SciInsertAndSelect(ScintillaControl sci, string text)
        {
            if (text.Length == 0) return;
            if (sci.SelText.Length == 0)
            {
                sci.InsertText(sci.CurrentPos, text);
                sci.CurrentPos += text.Length;
            }
            else
                sci.ReplaceSel(text);

            sci.SetSel(sci.CurrentPos - text.Length , sci.CurrentPos);
        }
開發者ID:fordream,項目名稱:wanghe-project,代碼行數:13,代碼來源:frmMonitor.cs

示例9: TraceMethod

        private static void TraceMethod(ScintillaControl sci, string name)
        {
            SkipMethod(sci);

            sci.NewLine();
            sci.InsertText(sci.CurrentPos, String.Format("trace(\"{0}()\");", name));
            sci.LineEnd();
        }
開發者ID:elsassph,項目名稱:fdMacros,代碼行數:8,代碼來源:Trace.cs

示例10: OnChar

        /// <summary>
        /// Handles the incoming character
        /// </summary> 
		public static void OnChar(ScintillaControl sci, Int32 value)
		{
            if (cType == XMLType.Invalid || (sci.ConfigurationLanguage != "xml" && sci.ConfigurationLanguage != "html")) 
                return;
			XMLContextTag ctag;
			Int32 position = sci.CurrentPos;
            if (sci.BaseStyleAt(position) == 6 && value != '"')
                return; // in XML attribute

			Char c = ' ';
            DataEvent de;
			switch (value)
			{
				case 10:
                    // Shift+Enter to insert <BR/>
                    Int32 line = sci.LineFromPosition(position);
					if (Control.ModifierKeys == Keys.Shift)
					{
						ctag = GetXMLContextTag(sci, position);
						if (ctag.Tag == null || ctag.Tag.EndsWith(">"))
						{
							int start = sci.PositionFromLine(line)-((sci.EOLMode == 0)? 2:1);
							sci.SetSel(start, position);
                            sci.ReplaceSel((PluginSettings.UpperCaseHtmlTags) ? "<BR/>" : "<br/>");
							sci.SetSel(start+5, start+5);
							return;
						}
					}
                    if (PluginSettings.SmartIndenter)
					{
                        // Get last non-empty line
						String text = "";
                        Int32 line2 = line - 1;
						while (line2 >= 0 && text.Length == 0)
						{
							text = sci.GetLine(line2).TrimEnd();
							line2--;
						}
						if ((text.EndsWith(">") && !text.EndsWith("?>") && !text.EndsWith("%>") && !closingTag.IsMatch(text)) || text.EndsWith("<!--") || text.EndsWith("<![CDATA["))
						{
                            // Get the previous tag
                            do
                            {
								position--;
								c = (Char)sci.CharAt(position);
							}
							while (position > 0 && c != '>');
							ctag = GetXMLContextTag(sci, c == '>' ? position + 1 : position);
							if ((Char)sci.CharAt(position-1) == '/') return;
                            // Insert blank line if we pressed Enter between a tag & it's closing tag
                            Int32 indent = sci.GetLineIndentation(line2 + 1);
							String checkStart = null;
                            bool subIndent = true;
							if (text.EndsWith("<!--")) { checkStart = "-->"; subIndent = false; }
                            else if (text.EndsWith("<![CDATA[")) { checkStart = "]]>"; subIndent = false; }
                            else if (ctag.Closed) subIndent = false;
                            else if (ctag.Name != null)
                            {
                                checkStart = "</" + ctag.Name;
                                if (ctag.Name.ToLower() == "script" || ctag.Name.ToLower() == "style") 
                                    subIndent = false;
                                if (ctag.Tag.IndexOf('\r') > 0 || ctag.Tag.IndexOf('\n') > 0)
                                    subIndent = false;
                            }
							if (checkStart != null)
							{
								text = sci.GetLine(line).TrimStart();
								if (text.StartsWith(checkStart))
								{
									sci.SetLineIndentation(line, indent);
									sci.InsertText(sci.PositionFromLine(line), LineEndDetector.GetNewLineMarker(sci.EOLMode));
								}
							}
                            // Indent the code
                            if (subIndent) indent += sci.Indent;
                            sci.SetLineIndentation(line, indent);
							position = sci.LineIndentPosition(line);
							sci.SetSel(position, position);
							return;
						}
					}
					break;
					
				case '<':
				case '/':
					if (value == '/')
					{
						if ((position < 2) || ((Char)sci.CharAt(position-2) != '<')) return;
                        ctag = new XMLContextTag();
                        ctag.Closing = true;
					}
					else 
					{
						ctag = GetXMLContextTag(sci, position);
						if (ctag.Tag != null) return;
					}
                    // Allow another plugin to handle this
//.........這裏部分代碼省略.........
開發者ID:heon21st,項目名稱:flashdevelop,代碼行數:101,代碼來源:XMLComplete.cs

示例11: InsertSnippetText

 /// <summary>
 /// Inserts the specified snippet to the document
 /// </summary>
 public static Int32 InsertSnippetText(ScintillaControl sci, Int32 currentPosition, String snippet)
 {
     sci.BeginUndoAction();
     try
     {
         Int32 newIndent; 
         String text = snippet;
         if (sci.SelTextSize > 0)
             currentPosition -= sci.MBSafeTextLength(sci.SelText);
         Int32 line = sci.LineFromPosition(currentPosition);
         Int32 indent = sci.GetLineIndentation(line);
         sci.ReplaceSel("");
         
         Int32 lineMarker = LineEndDetector.DetectNewLineMarker(text, sci.EOLMode);
         String newline = LineEndDetector.GetNewLineMarker(lineMarker);
         if (newline != "\n") text = text.Replace(newline, "\n");
         newline = LineEndDetector.GetNewLineMarker((Int32)PluginBase.MainForm.Settings.EOLMode);
         text = PluginBase.MainForm.ProcessArgString(text).Replace(newline, "\n");
         newline = LineEndDetector.GetNewLineMarker(sci.EOLMode);
         String[] splitted = text.Trim().Split('\n');
         for (Int32 j = 0; j < splitted.Length; j++)
         {
             if (j != splitted.Length - 1) sci.InsertText(sci.CurrentPos, splitted[j] + newline);
             else sci.InsertText(sci.CurrentPos, splitted[j]);
             sci.CurrentPos += sci.MBSafeTextLength(splitted[j]) + newline.Length;
             if (j > 0)
             {
                 line = sci.LineFromPosition(sci.CurrentPos - newline.Length);
                 newIndent = sci.GetLineIndentation(line) + indent;
                 sci.SetLineIndentation(line, newIndent);
             }
         }
         Int32 length = sci.CurrentPos - currentPosition - newline.Length;
         Int32 delta = PostProcessSnippets(sci, currentPosition);
         return length + delta;
     }
     finally
     {
         sci.EndUndoAction();
     }
 }
開發者ID:JoeRobich,項目名稱:flashdevelop,代碼行數:44,代碼來源:SnippetHelper.cs

示例12: OnChar

		static public void OnChar(ScintillaControl sci, int value)
		{
			if (cType == XMLType.Invalid)
				return;
			
			XMLContextTag ctag;
			int position = sci.CurrentPos;
			char c = ' ';
			switch (value)
			{
				case 10:
					int line = sci.LineFromPosition(position);
					
					// Shift+Enter to insert <BR/>
					if (Control.ModifierKeys == Keys.Shift)
					{
						ctag = GetXMLContextTag(sci, position);
						if (ctag.Tag == null || ctag.Tag.EndsWith(">"))
						{
							int start = sci.PositionFromLine(line)-((sci.EOLMode == 0)? 2:1);
							sci.SetSel(start, position);
							sci.ReplaceSel((lowerCaseHtmlTags)?"<br/>":"<BR/>");
							sci.SetSel(start+5, start+5);
							return;
						}
					}
					if (autoIndent)
					{
						// get last non-empty line
						string text = "";
						int line2 = line-1;
						while (line2 >= 0 && text.Length == 0)
						{
							text = sci.GetLine(line2).TrimEnd();
							line2--;
						}
						
						if ((text.EndsWith(">") && !text.EndsWith("?>") && !text.EndsWith("%>") && !re_closingTag.IsMatch(text)) 
						    || text.EndsWith("<!--") || text.EndsWith("<![CDATA["))
						{
							// get the previous tag
							do {
								position--;
								c = (char)sci.CharAt(position);
							}
							while (position > 0 && c != '>');
							ctag = GetXMLContextTag(sci, position);
							
							if ((char)sci.CharAt(position-1) == '/')
								return;
							
							// insert blank line if we pressed Enter between a tag & it's closing tag
							int indent = sci.GetLineIndentation(line2+1);
							string checkStart = null;
							if (text.EndsWith("<!--")) checkStart = "-->";
							else if (text.EndsWith("<![CDATA[")) checkStart = "]]>";
							else if (ctag.Name != null) checkStart = "</"+ctag.Name;
							if (checkStart != null)
							{
								text = sci.GetLine(line).TrimStart();
								if (text.StartsWith(checkStart))
								{
									sci.SetLineIndentation(line, indent);
									sci.InsertText(sci.PositionFromLine(line), mainForm.GetNewLineMarker(sci.EOLMode));
								}
							}
							
							// indent
							sci.SetLineIndentation(line, indent+sci.Indent);
							position = sci.LineIndentPosition(line);
							sci.SetSel(position, position);
							return;
						}
					}
					break;
					
				case '<':
				case '/':
					if (value == '/')
					{
						if ((position < 2) || ((char)sci.CharAt(position-2) != '<'))
							return;
					}
					else 
					{
						ctag = GetXMLContextTag(sci, position);
						if (ctag.Tag != null)
							return;
					}
					// new tag
					if (enableHtmlCompletion && cType == XMLType.Known)
					{
						ArrayList items = new ArrayList();
						string previous = null;
						foreach(HTMLTag tag in knownTags) 
						if (tag.Name != previous) {
							items.Add( new HtmlTagItem(tag.Name, tag.Tag) );
							previous = tag.Name;
						}
						CompletionList.Show(items, true);
//.........這裏部分代碼省略.........
開發者ID:heon21st,項目名稱:flashdevelop,代碼行數:101,代碼來源:XMLComplete.cs

示例13: GetBodyStart

        public static int GetBodyStart(int lineFrom, int lineTo, ScintillaControl Sci, int pos)
        {
            int posStart = Sci.PositionFromLine(lineFrom);
            int posEnd = Sci.LineEndPosition(lineTo);

            Sci.SetSel(posStart, posEnd);

            List<char> characterClass = new List<char>(new char[] { ' ', '\r', '\n', '\t' });
            string currentMethodBody = Sci.SelText;
            int nCount = 0;
            int funcBodyStart = pos;
            int extraLine = 0;
            if (pos == -1)
            {
                funcBodyStart = posStart + currentMethodBody.IndexOf('{');
                extraLine = 1;
            }
            while (funcBodyStart <= posEnd)
            {
                char c = (char)Sci.CharAt(++funcBodyStart);
                if (c == '}')
                {
                    int ln = Sci.LineFromPosition(funcBodyStart);
                    int indent = Sci.GetLineIndentation(ln);
                    if (lineFrom == lineTo || lineFrom == ln)
                    {
                        Sci.InsertText(funcBodyStart, Sci.NewLineMarker);
                        Sci.SetLineIndentation(ln + 1, indent);
                        ln++;
                    }
                    Sci.SetLineIndentation(ln, indent + Sci.Indent);
                    Sci.InsertText(funcBodyStart, Sci.NewLineMarker);
                    Sci.SetLineIndentation(ln + 1, indent);
                    Sci.SetLineIndentation(ln, indent + Sci.Indent);
                    funcBodyStart = Sci.LineEndPosition(ln);
                    break;
                }
                else if (!characterClass.Contains(c))
                {
                    break;
                }
                else if (Sci.EOLMode == 1 && c == '\r' && (++nCount) > extraLine)
                {
                    break;
                }
                else if (c == '\n' && (++nCount) > extraLine)
                {
                    if (Sci.EOLMode != 2)
                    {
                        funcBodyStart--;
                    }
                    break;
                }
            }
            return funcBodyStart;
        }
開發者ID:ImaginationSydney,項目名稱:flashdevelop,代碼行數:56,代碼來源:ASGenerator.cs


注:本文中的ScintillaNet.ScintillaControl.InsertText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。