当前位置: 首页>>代码示例>>C#>>正文


C# ScintillaControl.LineEndPosition方法代码示例

本文整理汇总了C#中ScintillaNet.ScintillaControl.LineEndPosition方法的典型用法代码示例。如果您正苦于以下问题:C# ScintillaControl.LineEndPosition方法的具体用法?C# ScintillaControl.LineEndPosition怎么用?C# ScintillaControl.LineEndPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ScintillaNet.ScintillaControl的用法示例。


在下文中一共展示了ScintillaControl.LineEndPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateFieldFromParameter

        private static void GenerateFieldFromParameter(ScintillaControl sci, MemberModel member, ClassModel inClass,
                    Visibility scope)
        {
            int funcBodyStart = GetBodyStart(member.LineFrom, member.LineTo, sci, false);
            int fbsLine = sci.LineFromPosition(funcBodyStart);
            int endPos = sci.LineEndPosition(member.LineTo);

            sci.SetSel(funcBodyStart, endPos);
            string body = sci.SelText;
            string trimmed = body.TrimStart();

            Match m = reSuperCall.Match(trimmed);
            if (m.Success && m.Index == 0)
            {
                funcBodyStart = GetEndOfStatement(funcBodyStart + (body.Length - trimmed.Length), endPos, sci);
            }

            funcBodyStart = GetOrSetPointOfInsertion(funcBodyStart, endPos, fbsLine, sci);

            sci.SetSel(funcBodyStart, funcBodyStart);
            sci.CurrentPos = funcBodyStart;

            bool isVararg = false;
            string paramName = contextMember.Name;
            if (paramName.StartsWithOrdinal("..."))
            {
                paramName = paramName.TrimStart(new char[] { ' ', '.' });
                isVararg = true;
            }
            string varName = paramName;
            string scopedVarName = varName;

            if ((scope & Visibility.Public) > 0)
            {
                if ((member.Flags & FlagType.Static) > 0)
                    scopedVarName = inClass.Name + "." + varName;
                else
                    scopedVarName = "this." + varName;
            }
            else
            {
                if (ASContext.CommonSettings.PrefixFields.Length > 0 && !paramName.StartsWithOrdinal(ASContext.CommonSettings.PrefixFields))
                {
                    scopedVarName = varName = ASContext.CommonSettings.PrefixFields + varName;
                }

                if (ASContext.CommonSettings.GenerateScope || ASContext.CommonSettings.PrefixFields == "")
                {
                    if ((member.Flags & FlagType.Static) > 0)
                        scopedVarName = inClass.Name + "." + varName;
                    else
                        scopedVarName = "this." + varName;
                }
            }

            string template = TemplateUtils.GetTemplate("FieldFromParameter");
            template = TemplateUtils.ReplaceTemplateVariable(template, "Name", scopedVarName);
            template = TemplateUtils.ReplaceTemplateVariable(template, "Value", paramName);
            template += "\n$(Boundary)";

            SnippetHelper.InsertSnippetText(sci, funcBodyStart, template);

            //TODO: We also need to check parent classes!!!
            MemberList classMembers = inClass.Members;
            foreach (MemberModel classMember in classMembers)
                if (classMember.Name.Equals(varName))
                {
                    ASContext.Panel.RestoreLastLookupPosition();
                    return;
                }

            MemberModel latest = GetLatestMemberForVariable(GeneratorJobType.Variable, inClass, GetDefaultVisibility(inClass), new MemberModel());
            if (latest == null) return;

            int position = FindNewVarPosition(sci, inClass, latest);
            if (position <= 0) return;
            sci.SetSel(position, position);
            sci.CurrentPos = position;

            MemberModel mem = NewMember(varName, member, FlagType.Variable, scope);
            if (isVararg) mem.Type = "Array";
            else mem.Type = contextMember.Type;

            GenerateVariable(mem, position, true);
            ASContext.Panel.RestoreLastLookupPosition();
        }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:86,代码来源:ASGenerator.cs

示例2: GetBodyStart

        /// <summary>
        /// Tries to get the start position of a code block, delimited by { and }
        /// </summary>
        /// <param name="lineFrom">The line inside the Scintilla document where the owner member of the body starts</param>
        /// <param name="lineTo">The line inside the Scintilla document where the owner member of the body ends</param>
        /// <param name="sci">The Scintilla control containing the document</param>
        /// <param name="needsPointOfInsertion">If true looks for the position to add new code, inserting new lines if needed</param>
        /// <returns>The position inside the Scintilla document, or -1 if not suitable position was found</returns>
        public static int GetBodyStart(int lineFrom, int lineTo, ScintillaControl sci, bool needsPointOfInsertion)
        {
            int posStart = sci.PositionFromLine(lineFrom);
            int posEnd = sci.LineEndPosition(lineTo);

            int funcBodyStart = -1;

            int genCount = 0;
            for (int i = posStart; i <= posEnd; i++)
            {
                char c = (char)sci.CharAt(i);

                if (c == '{')
                {
                    int style = sci.BaseStyleAt(i);
                    if (ASComplete.IsCommentStyle(style) || ASComplete.IsLiteralStyle(style) || genCount > 0)
                        continue;
                    funcBodyStart = i;
                    break;
                }
                else if (c == '<')
                {
                    int style = sci.BaseStyleAt(i);
                    if (style == 10)
                        genCount++;
                }
                else if (c == '>')
                {
                    int style = sci.BaseStyleAt(i);
                    if (style == 10)
                        genCount--;
                }
            }

            if (funcBodyStart == -1)
                return -1;

            if (needsPointOfInsertion)
            {
                int ln = sci.LineFromPosition(funcBodyStart);

                funcBodyStart++;
                return GetOrSetPointOfInsertion(funcBodyStart, posEnd, ln, sci);
            }

            return funcBodyStart + 1;
        }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:55,代码来源:ASGenerator.cs

示例3: ChangeDecl

        private static void ChangeDecl(ScintillaControl sci, MemberModel memberModel, List<FunctionParameter> functionParameters)
        {
            bool paramsDiffer = false;
            if (memberModel.Parameters != null)
            {
                // check that parameters have one and the same type
                if (memberModel.Parameters.Count == functionParameters.Count)
                {
                    if (functionParameters.Count > 0)
                    {
                        List<MemberModel> parameters = memberModel.Parameters;
                        for (int i = 0; i < parameters.Count; i++)
                        {
                            MemberModel p = parameters[i];
                            if (p.Type != functionParameters[i].paramType)
                            {
                                paramsDiffer = true;
                                break;
                            }
                        }
                    }
                }
                else
                {
                    paramsDiffer = true;
                }
            }
            // check that parameters count differs
            else if (functionParameters.Count != 0)
            {
                paramsDiffer = true;
            }

            if (paramsDiffer)
            {
                int app = 0;
                List<MemberModel> newParameters = new List<MemberModel>();
                List<MemberModel> existingParameters = memberModel.Parameters;
                for (int i = 0; i < functionParameters.Count; i++)
                {
                    FunctionParameter p = functionParameters[i];
                    if (existingParameters != null
                        && existingParameters.Count > (i - app)
                        && existingParameters[i - app].Type == p.paramType)
                    {
                        newParameters.Add(existingParameters[i - app]);
                    }
                    else
                    {
                        if (existingParameters != null && existingParameters.Count < functionParameters.Count)
                        {
                            app++;
                        }
                        newParameters.Add(new MemberModel(p.paramName, p.paramType, FlagType.ParameterVar, 0));
                    }
                }
                memberModel.Parameters = newParameters;

                int posStart = sci.PositionFromLine(memberModel.LineFrom);
                int posEnd = sci.LineEndPosition(memberModel.LineTo);
                sci.SetSel(posStart, posEnd);
                string selectedText = sci.SelText;
                Regex rStart = new Regex(@"\s{1}" + memberModel.Name + @"\s*\(([^\)]*)\)(\s*:\s*([^({{|\n|\r|\s|;)]+))?");
                Match mStart = rStart.Match(selectedText);
                if (!mStart.Success)
                {
                    return;
                }

                int start = mStart.Index + posStart;
                int end = start + mStart.Length;

                sci.SetSel(start, end);

                string decl = TemplateUtils.ToDeclarationString(memberModel, TemplateUtils.GetTemplate("MethodDeclaration"));
                InsertCode(sci.CurrentPos, "$(Boundary) " + decl, sci);

                // add imports to function argument types
                if (functionParameters.Count > 0)
                {
                    List<string> l = new List<string>();
                    foreach (FunctionParameter fp in functionParameters)
                    {
                        try
                        {
                            l.Add(fp.paramQualType);
                        }
                        catch (Exception)
                        {
                        }
                    }
                    start += AddImportsByName(l, sci.LineFromPosition(end));
                }

                sci.SetSel(start, start);
            }
        }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:97,代码来源:ASGenerator.cs

示例4: AddAsParameter

        private static void AddAsParameter(ClassModel inClass, ScintillaControl sci, MemberModel member, bool detach)
        {
            if (!RemoveLocalDeclaration(sci, contextMember)) return;

            int posStart = sci.PositionFromLine(member.LineFrom);
            int posEnd = sci.LineEndPosition(member.LineTo);
            sci.SetSel(posStart, posEnd);
            string selectedText = sci.SelText;
            Regex rStart = new Regex(@"\s{1}" + member.Name + @"\s*\(([^\)]*)\)(\s*:\s*([^({{|\n|\r|\s|;)]+))?");
            Match mStart = rStart.Match(selectedText);
            if (!mStart.Success)
                return;

            int start = mStart.Index + posStart + 1;
            int end = mStart.Index + posStart + mStart.Length;

            sci.SetSel(start, end);

            MemberModel memberCopy = (MemberModel) member.Clone();

            if (memberCopy.Parameters == null)
                memberCopy.Parameters = new List<MemberModel>();

            memberCopy.Parameters.Add(contextMember);

            string template = TemplateUtils.ToDeclarationString(memberCopy, TemplateUtils.GetTemplate("MethodDeclaration"));
            InsertCode(start, template, sci);

            int currPos = sci.LineEndPosition(sci.CurrentLine);

            sci.SetSel(currPos, currPos);
            sci.CurrentPos = currPos;
        }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:33,代码来源:ASGenerator.cs

示例5: LineStartPosition

        public static Int32 LineStartPosition(ScintillaControl sci, Int32 lineIdx)
        {
            if (lineIdx == 0) return 0;

            Int32 pos = sci.LineEndPosition(lineIdx - 1) + 1;
            if (sci.EOLMode == 0) pos += 1;

            return pos;
        }
开发者ID:heon21st,项目名称:flashdevelop,代码行数:9,代码来源:PluginMain.cs

示例6: GoToLineEnd

        public static void GoToLineEnd(ScintillaControl sci, Boolean insertNewLine)
        {
            sci.GotoPos(sci.LineEndPosition(sci.LineFromPosition(sci.CurrentPos)));

            if (insertNewLine) sci.NewLine();
        }
开发者ID:heon21st,项目名称:flashdevelop,代码行数:6,代码来源:PluginMain.cs

示例7: 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

示例8: GenerateFieldFromParameter

        private static void GenerateFieldFromParameter(ScintillaControl Sci, MemberModel member, ClassModel inClass,
                    Visibility scope)
        {
            int funcBodyStart = GetBodyStart(member.LineFrom, member.LineTo, Sci);

            Sci.SetSel(funcBodyStart, Sci.LineEndPosition(member.LineTo));
            string body = Sci.SelText;
            string trimmed = body.TrimStart();

            Regex re = new Regex("^super\\s*[\\(|\\.]");
            Match m = re.Match(trimmed);
            if (m.Success)
            {
                if (m.Index == 0)
                {
                    int p = funcBodyStart + (body.Length - trimmed.Length);
                    int l = Sci.LineFromPosition(p);
                    p = Sci.PositionFromLine(l + 1);
                    funcBodyStart = GetBodyStart(member.LineFrom, member.LineTo, Sci, p);
                }
            }

            Sci.SetSel(funcBodyStart, funcBodyStart);
            Sci.CurrentPos = funcBodyStart;

            bool isVararg = false;
            string paramName = contextMember.Name;
            if (paramName.StartsWith("..."))
            {
                paramName = paramName.TrimStart(new char[] { ' ', '.' });
                isVararg = true;
            }
            string varName = paramName;
            string scopedVarName = varName;

            if ((scope & Visibility.Public) > 0)
            {
                if ((member.Flags & FlagType.Static) > 0)
                    scopedVarName = inClass.Name + "." + varName;
                else
                    scopedVarName = "this." + varName;
            }
            else
            {
                if (ASContext.CommonSettings.PrefixFields.Length > 0 && !paramName.StartsWith(ASContext.CommonSettings.PrefixFields))
                {
                    scopedVarName = varName = ASContext.CommonSettings.PrefixFields + varName;
                }

                if (ASContext.CommonSettings.GenerateScope || ASContext.CommonSettings.PrefixFields == "")
                {
                    if ((member.Flags & FlagType.Static) > 0)
                        scopedVarName = inClass.Name + "." + varName;
                    else
                        scopedVarName = "this." + varName;
                }
            }

            

            string template = TemplateUtils.GetTemplate("FieldFromParameter");
            template = TemplateUtils.ReplaceTemplateVariable(template, "Name", scopedVarName);
            template = TemplateUtils.ReplaceTemplateVariable(template, "Value", paramName);
            template += "\n$(Boundary)";

            SnippetHelper.InsertSnippetText(Sci, funcBodyStart, template);

            MemberList classMembers = inClass.Members;
            foreach (MemberModel classMember in classMembers)
                if (classMember.Name.Equals(varName))
                    return;

            MemberModel latest = GetLatestMemberForVariable(GeneratorJobType.Variable, inClass, GetDefaultVisibility(), new MemberModel());
            if (latest == null) return;

            int position = FindNewVarPosition(Sci, inClass, latest);
            if (position <= 0) return;
            Sci.SetSel(position, position);
            Sci.CurrentPos = position;

            MemberModel mem = NewMember(varName, member, FlagType.Variable, scope);
            if (isVararg) mem.Type = "Array";
            else mem.Type = contextMember.Type;

            GenerateVariable(mem, position, true);
            ASContext.Panel.RestoreLastLookupPosition();
        }
开发者ID:ImaginationSydney,项目名称:flashdevelop,代码行数:87,代码来源:ASGenerator.cs

示例9: ToggleBlockOnCurrentLine

 private void ToggleBlockOnCurrentLine(ScintillaControl sci)
 {
     Int32 selStart = sci.SelectionStart;
     Int32 indentPos = sci.LineIndentPosition(sci.CurrentLine);
     Int32 lineEndPos = sci.LineEndPosition(sci.CurrentLine);
     bool afterBlockStart = sci.CurrentPos > indentPos;
     bool afterBlockEnd = sci.CurrentPos >= lineEndPos;
     sci.SelectionStart = indentPos;
     sci.SelectionEnd = lineEndPos;
     bool ? added = CommentSelection();
     if (added == null) return;
     int factor = (bool)added ? 1 : -1;
     String commentEnd = ScintillaManager.GetCommentEnd(sci.ConfigurationLanguage);
     String commentStart = ScintillaManager.GetCommentStart(sci.ConfigurationLanguage);
     // preserve cursor pos
     if (afterBlockStart) selStart += commentStart.Length * factor;
     if (afterBlockEnd) selStart += commentEnd.Length * factor;
     sci.SetSel(selStart, selStart);
 }
开发者ID:xeronith,项目名称:flashdevelop,代码行数:19,代码来源:MainForm.cs

示例10: Execute

        public void Execute()
        {
            Sci = PluginBase.MainForm.CurrentDocument.SciControl;
            Sci.BeginUndoAction();
            try
            {
                IASContext context = ASContext.Context;
                Int32 pos = Sci.CurrentPos;

                string expression = Sci.SelText.Trim(new char[] { '=', ' ', '\t', '\n', '\r', ';', '.' });
                expression = expression.TrimEnd(new char[] { '(', '[', '{', '<' });
                expression = expression.TrimStart(new char[] { ')', ']', '}', '>' });

                cFile = ASContext.Context.CurrentModel;
                ASFileParser parser = new ASFileParser();
                parser.ParseSrc(cFile, Sci.Text);

                MemberModel current = cFile.Context.CurrentMember;
               
                string characterClass = ScintillaControl.Configuration.GetLanguage(Sci.ConfigurationLanguage).characterclass.Characters;

                int funcBodyStart = ASGenerator.GetBodyStart(current.LineFrom, current.LineTo, Sci);
                Sci.SetSel(funcBodyStart, Sci.LineEndPosition(current.LineTo));
                string currentMethodBody = Sci.SelText;

                bool isExprInSingleQuotes = (expression.StartsWith("'") && expression.EndsWith("'"));
                bool isExprInDoubleQuotes = (expression.StartsWith("\"") && expression.EndsWith("\""));
                int stylemask = (1 << Sci.StyleBits) - 1;
                int lastPos = -1;
                char prevOrNextChar;
                Sci.Colourise(0, -1);
                while (true)
                {
                    lastPos = currentMethodBody.IndexOf(expression, lastPos + 1);
                    if (lastPos > -1)
                    {
                        if (lastPos > 0)
                        {
                            prevOrNextChar = currentMethodBody[lastPos - 1];
                            if (characterClass.IndexOf(prevOrNextChar) > -1)
                            {
                                continue;
                            }
                        }
                        if (lastPos + expression.Length < currentMethodBody.Length)
                        {
                            prevOrNextChar = currentMethodBody[lastPos + expression.Length];
                            if (characterClass.IndexOf(prevOrNextChar) > -1)
                            {
                                continue;
                            }
                        }

                        int style = Sci.StyleAt(funcBodyStart + lastPos) & stylemask;
                        if (ASComplete.IsCommentStyle(style))
                        {
                            continue;
                        }
                        else if ((isExprInDoubleQuotes && currentMethodBody[lastPos] == '"' && currentMethodBody[lastPos + expression.Length - 1] == '"')
                            || (isExprInSingleQuotes && currentMethodBody[lastPos] == '\'' && currentMethodBody[lastPos + expression.Length - 1] == '\''))
                        {
                            
                        }
                        else if (!ASComplete.IsTextStyle(style))
                        {
                            continue;
                        }

                        Sci.SetSel(funcBodyStart + lastPos, funcBodyStart + lastPos + expression.Length);
                        Sci.ReplaceSel(NewName);
                        currentMethodBody = currentMethodBody.Substring(0, lastPos) + NewName + currentMethodBody.Substring(lastPos + expression.Length);
                        lastPos += NewName.Length;
                    }
                    else
                    {
                        break;
                    }
                }

                Sci.CurrentPos = funcBodyStart;
                Sci.SetSel(Sci.CurrentPos, Sci.CurrentPos);

                string snippet = "var " + NewName + ":$(EntryPoint) = " + expression + ";\n$(Boundary)";
                SnippetHelper.InsertSnippetText(Sci, Sci.CurrentPos, snippet);
            }
            finally
            {
                Sci.EndUndoAction();
            }
        }
开发者ID:heon21st,项目名称:flashdevelop,代码行数:90,代码来源:ExtractLocalVariableCommand.cs

示例11: OnScintillaControlUpdateControl

 /// <summary>
 /// Refreshes the statusbar display and updates the important edit buttons
 /// </summary>
 public void OnScintillaControlUpdateControl(ScintillaControl sci)
 {
     if (this.InvokeRequired)
     {
         this.BeginInvoke((MethodInvoker)delegate { this.OnScintillaControlUpdateControl(sci); });
         return;
     }
     ITabbedDocument document = DocumentManager.FindDocument(sci);
     if (sci != null && document != null && document.IsEditable)
     {
         String statusText = " " + TextHelper.GetString("Info.StatusText");
         String line = sci.CurrentLine + 1 + " / " + sci.LineCount;
         String column = sci.Column(sci.CurrentPos) + 1 + " / " + (sci.Column(sci.LineEndPosition(sci.CurrentLine)) + 1);
         var oldOS = this.OSVersion.Major < 6; // Vista is 6.0 and ok...
         String file = oldOS ? PathHelper.GetCompactPath(sci.FileName) : sci.FileName;
         String eol = (sci.EOLMode == 0) ? "CR+LF" : ((sci.EOLMode == 1) ? "CR" : "LF");
         String encoding = ButtonManager.GetActiveEncodingName();
         this.toolStripStatusLabel.Text = String.Format(statusText, line, column, eol, encoding, file);
     }
     else this.toolStripStatusLabel.Text = " ";
     this.OnUpdateMainFormDialogTitle();
     ButtonManager.UpdateFlaggedButtons();
     NotifyEvent ne = new NotifyEvent(EventType.UIRefresh);
     EventManager.DispatchEvent(this, ne);
 }
开发者ID:xeronith,项目名称:flashdevelop,代码行数:28,代码来源:MainForm.cs

示例12: GenerateExtractVariable

        public static void GenerateExtractVariable(ScintillaControl sci, string newName)
        {
            string expression = sci.SelText.Trim(new char[] { '=', ' ', '\t', '\n', '\r', ';', '.' });
            expression = expression.TrimEnd(new char[] { '(', '[', '{', '<' });
            expression = expression.TrimStart(new char[] { ')', ']', '}', '>' });

            var cFile = ASContext.Context.CurrentModel;
            ASFileParser parser = new ASFileParser();
            parser.ParseSrc(cFile, sci.Text);

            MemberModel current = cFile.Context.CurrentMember;

            string characterClass = ScintillaControl.Configuration.GetLanguage(sci.ConfigurationLanguage).characterclass.Characters;

            int funcBodyStart = GetBodyStart(current.LineFrom, current.LineTo, sci);
            sci.SetSel(funcBodyStart, sci.LineEndPosition(current.LineTo));
            string currentMethodBody = sci.SelText;
            var insertPosition = funcBodyStart + currentMethodBody.IndexOfOrdinal(expression);
            var line = sci.LineFromPosition(insertPosition);
            insertPosition = sci.LineIndentPosition(line);

            int lastPos = -1;
            sci.Colourise(0, -1);
            while (true)
            {
                lastPos = currentMethodBody.IndexOfOrdinal(expression, lastPos + 1);
                if (lastPos > -1)
                {
                    char prevOrNextChar;
                    if (lastPos > 0)
                    {
                        prevOrNextChar = currentMethodBody[lastPos - 1];
                        if (characterClass.IndexOf(prevOrNextChar) > -1)
                        {
                            continue;
                        }
                    }
                    if (lastPos + expression.Length < currentMethodBody.Length)
                    {
                        prevOrNextChar = currentMethodBody[lastPos + expression.Length];
                        if (characterClass.IndexOf(prevOrNextChar) > -1)
                        {
                            continue;
                        }
                    }

                    var pos = funcBodyStart + lastPos;
                    int style = sci.BaseStyleAt(pos);
                    if (ASComplete.IsCommentStyle(style)) continue;
                    sci.SetSel(pos, pos + expression.Length);
                    sci.ReplaceSel(newName);
                    currentMethodBody = currentMethodBody.Substring(0, lastPos) + newName + currentMethodBody.Substring(lastPos + expression.Length);
                    lastPos += newName.Length;
                }
                else
                {
                    break;
                }
            }

            sci.CurrentPos = insertPosition;
            sci.SetSel(sci.CurrentPos, sci.CurrentPos);
            MemberModel m = new MemberModel(newName, "", FlagType.LocalVar, 0);
            m.Value = expression;

            string snippet = TemplateUtils.GetTemplate("Variable");
            snippet = TemplateUtils.ReplaceTemplateVariable(snippet, "Modifiers", null);
            snippet = TemplateUtils.ToDeclarationString(m, snippet);
            snippet += NewLine + "$(Boundary)";
            SnippetHelper.InsertSnippetText(sci, sci.CurrentPos, snippet);
        }
开发者ID:xeronith,项目名称:flashdevelop,代码行数:71,代码来源:ASGenerator.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

示例14: GenerateExtractVariable

        public static void GenerateExtractVariable(ScintillaControl Sci, string NewName)
        {
            FileModel cFile;

            string expression = Sci.SelText.Trim(new char[] { '=', ' ', '\t', '\n', '\r', ';', '.' });
            expression = expression.TrimEnd(new char[] { '(', '[', '{', '<' });
            expression = expression.TrimStart(new char[] { ')', ']', '}', '>' });

            cFile = ASContext.Context.CurrentModel;
            ASFileParser parser = new ASFileParser();
            parser.ParseSrc(cFile, Sci.Text);

            MemberModel current = cFile.Context.CurrentMember;

            string characterClass = ScintillaControl.Configuration.GetLanguage(Sci.ConfigurationLanguage).characterclass.Characters;

            int funcBodyStart = GetBodyStart(current.LineFrom, current.LineTo, Sci);
            Sci.SetSel(funcBodyStart, Sci.LineEndPosition(current.LineTo));
            string currentMethodBody = Sci.SelText;

            bool isExprInSingleQuotes = (expression.StartsWith('\'') && expression.EndsWith('\''));
            bool isExprInDoubleQuotes = (expression.StartsWith('\"') && expression.EndsWith('\"'));
            int stylemask = (1 << Sci.StyleBits) - 1;
            int lastPos = -1;
            char prevOrNextChar;
            Sci.Colourise(0, -1);
            while (true)
            {
                lastPos = currentMethodBody.IndexOfOrdinal(expression, lastPos + 1);
                if (lastPos > -1)
                {
                    if (lastPos > 0)
                    {
                        prevOrNextChar = currentMethodBody[lastPos - 1];
                        if (characterClass.IndexOf(prevOrNextChar) > -1)
                        {
                            continue;
                        }
                    }
                    if (lastPos + expression.Length < currentMethodBody.Length)
                    {
                        prevOrNextChar = currentMethodBody[lastPos + expression.Length];
                        if (characterClass.IndexOf(prevOrNextChar) > -1)
                        {
                            continue;
                        }
                    }

                    int style = Sci.StyleAt(funcBodyStart + lastPos) & stylemask;
                    if (ASComplete.IsCommentStyle(style))
                    {
                        continue;
                    }
                    else if ((isExprInDoubleQuotes && currentMethodBody[lastPos] == '"' && currentMethodBody[lastPos + expression.Length - 1] == '"')
                        || (isExprInSingleQuotes && currentMethodBody[lastPos] == '\'' && currentMethodBody[lastPos + expression.Length - 1] == '\''))
                    {

                    }
                    else if (!ASComplete.IsTextStyle(style))
                    {
                        continue;
                    }

                    Sci.SetSel(funcBodyStart + lastPos, funcBodyStart + lastPos + expression.Length);
                    Sci.ReplaceSel(NewName);
                    currentMethodBody = currentMethodBody.Substring(0, lastPos) + NewName + currentMethodBody.Substring(lastPos + expression.Length);
                    lastPos += NewName.Length;
                }
                else
                {
                    break;
                }
            }

            Sci.CurrentPos = funcBodyStart;
            Sci.SetSel(Sci.CurrentPos, Sci.CurrentPos);

            MemberModel m = new MemberModel(NewName, "", FlagType.LocalVar, 0);
            m.Value = expression;

            string snippet = TemplateUtils.GetTemplate("Variable");
            snippet = TemplateUtils.ReplaceTemplateVariable(snippet, "Modifiers", null);
            snippet = TemplateUtils.ToDeclarationString(m, snippet);
            snippet += NewLine + "$(Boundary)";
            SnippetHelper.InsertSnippetText(Sci, Sci.CurrentPos, snippet);
        }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:86,代码来源:ASGenerator.cs

示例15: PositionInfos

        public PositionInfos(ScintillaControl sci, Int32 position, String argString)
        {
            // Variables
            String[] vars = argString.Split('¤');
            this.ArgCurWord = vars[0];
            this.ArgPackageName = vars[1];
            this.ArgClassName = vars[2];
            this.ArgClassType = vars[3];
            this.ArgMemberName = vars[4];
            this.ArgMemberType = vars[5];

            // Selection
            Int32 ss = sci.SelectionStart;
            Int32 se = sci.SelectionEnd;
            if (se != ss)
            {
                this.SelectionStart = ss;
                this.SelectionEnd = se;
                this.HasSelection = true;
                if (sci.LineFromPosition(ss) != sci.LineFromPosition(se))
                    this.SelectionIsMultiline = true;
                else SelectedText = sci.SelText;
            }

            // Current
            this.CurrentPosition = position;
            this.CurrentCharCode = sci.CharAt(position);
            this.CurrentIsWhiteChar = (HelpTools.IsWhiteChar(this.CurrentCharCode));
            this.CurrentIsDotChar = (this.CurrentCharCode == 46);
            this.CurrentIsActionScriptChar = HelpTools.IsActionScriptChar(this.CurrentCharCode);
            this.CurrentIsWordChar = HelpTools.IsWordChar((byte)this.CurrentCharCode);
            Int32 s = sci.StyleAt(position);
            this.CurrentIsInsideComment = (s == 1 || s == 2 || s == 3 || s == 17);

            // Next
            Int32 np = sci.PositionAfter(position);
            if (np != position)
                this.NextPosition = np;
            else
                this.CaretIsAtEndOfDocument = true;

            // Word
            this.CodePage = sci.CodePage; // (UTF-8|Big Endian|Little Endian : 65001) (8 Bits|UTF-7 : 0)
            
            if (this.CurrentIsInsideComment == false && this.SelectionIsMultiline == false)
            {
                Int32 wsp = sci.WordStartPosition(position, true);
                // Attention (WordEndPosition n'est pas estimé comme par defaut)
                Int32 wep = sci.PositionBefore(sci.WordEndPosition(position, true));

                if (this.CodePage != 65001)
                {
                    wsp = HelpTools.GetWordStartPositionByWordChar(sci, position);
                    // Attention (WordEndPosition n'est pas estimé comme par defaut)
                    wep = sci.PositionBefore(HelpTools.GetWordEndPositionByWordChar(sci, position));
                }

                this.WordStartPosition = wsp;
                this.WordEndPosition = wep;

                if (this.CodePage == 65001)
                    this.WordFromPosition = this.ArgCurWord;
                else
                    this.WordFromPosition = HelpTools.GetText(sci, wsp, sci.PositionAfter(wep));

                if (position > wep)
                    this.CaretIsAfterLastLetter = true;
            }
            
            // Previous
            if (this.CurrentPosition > 0)
            {
                this.PreviousPosition = sci.PositionBefore(position);
                this.PreviousCharCode = sci.CharAt(this.PreviousPosition);
                this.PreviousIsWhiteChar = HelpTools.IsWhiteChar(this.PreviousCharCode);
                this.PreviousIsDotChar = (this.PreviousCharCode == 46);
                this.PreviousIsActionScriptChar = HelpTools.IsActionScriptChar(this.PreviousCharCode);
            }

            // Line
            this.CurrentLineIdx = sci.LineFromPosition(position);
            if (this.CurrentPosition > 0)
                this.PreviousLineIdx = sci.LineFromPosition(this.PreviousPosition);

            this.LineIdxMax = sci.LineCount - 1;
            this.LineStartPosition = HelpTools.LineStartPosition(sci, this.CurrentLineIdx);
            this.LineEndPosition = sci.LineEndPosition(this.CurrentLineIdx);
            this.NewLineMarker = LineEndDetector.GetNewLineMarker(sci.EOLMode);

            // Previous / Next
            if (this.WordStartPosition != -1)
            {
                this.PreviousNonWhiteCharPosition = HelpTools.PreviousNonWhiteCharPosition(sci, this.WordStartPosition);
                this.PreviousWordIsFunction = (sci.GetWordFromPosition(this.PreviousNonWhiteCharPosition) == "function");
                this.NextNonWhiteCharPosition = HelpTools.NextNonWhiteCharPosition(sci, this.WordEndPosition);
            }

            // Function
            if (this.PreviousWordIsFunction)
            {
//.........这里部分代码省略.........
开发者ID:heon21st,项目名称:flashdevelop,代码行数:101,代码来源:PluginMain.cs


注:本文中的ScintillaNet.ScintillaControl.LineEndPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。