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


C# ScintillaControl.BeginUndoAction方法代码示例

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


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

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

示例2: ReplaceMatches

 /// <summary>
 /// Replaces only the matches in the current sci control
 /// </summary>
 public static void ReplaceMatches(IList<SearchMatch> matches, ScintillaControl sci, String replacement, String src)
 {
     if (sci == null || matches == null || matches.Count == 0) return;
     sci.BeginUndoAction();
     try
     {
         for (Int32 i = 0; i < matches.Count; i++)
         {
             SelectMatch(sci, matches[i]);
             FRSearch.PadIndexes((List<SearchMatch>)matches, i, matches[i].Value, replacement);
             sci.EnsureVisible(sci.LineFromPosition(sci.MBSafePosition(matches[i].Index)));
             sci.ReplaceSel(replacement);
         }
     }
     finally
     {
         sci.EndUndoAction();
     }
 }
开发者ID:thecocce,项目名称:flashdevelop,代码行数:22,代码来源:RefactoringHelper.cs

示例3: InsertCode

        public static void InsertCode(int position, string src, ScintillaControl sci)
        {
            sci.BeginUndoAction();
            try
            {
                if (ASContext.CommonSettings.StartWithModifiers)
                    src = FixModifiersLocation(src);

                int len = SnippetHelper.InsertSnippetText(sci, position + sci.MBSafeTextLength(sci.SelText), src);
                UpdateLookupPosition(position, len);
                AddLookupPosition(sci);
            }
            finally { sci.EndUndoAction(); }
        }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:14,代码来源:ASGenerator.cs

示例4: GenerateDelegateMethods

        public static void GenerateDelegateMethods(ScintillaControl Sci, MemberModel member,
            Dictionary<MemberModel, ClassModel> selectedMembers, ClassModel classModel, ClassModel inClass)
        {
            Sci.BeginUndoAction();
            try
            {
                string result = TemplateUtils.ReplaceTemplateVariable(
                    TemplateUtils.GetTemplate("DelegateMethodsHeader"), 
                    "Class", 
                    classModel.Type);

                int position = -1;
                ClassModel type;
                List<string> importsList = new List<string>();
                bool isStaticMember = false;

                if ((member.Flags & FlagType.Static) > 0)
                    isStaticMember = true;

                inClass.ResolveExtends();
                
                Dictionary<MemberModel, ClassModel>.KeyCollection selectedMemberKeys = selectedMembers.Keys;
                foreach (MemberModel m in selectedMemberKeys)
                {
                    MemberModel mCopy = (MemberModel) m.Clone();

                    string methodTemplate = NewLine;

                    bool overrideFound = false;
                    ClassModel baseClassType = inClass;
                    while (baseClassType != null && !baseClassType.IsVoid())
                    {
                        MemberList inClassMembers = baseClassType.Members;
                        foreach (MemberModel inClassMember in inClassMembers)
                        {
                            if ((inClassMember.Flags & FlagType.Function) > 0
                               && m.Name.Equals(inClassMember.Name))
                            {
                                mCopy.Flags |= FlagType.Override;
                                overrideFound = true;
                                break;
                            }
                        }

                        if (overrideFound)
                            break;

                        baseClassType = baseClassType.Extends;
                    }

                    if (isStaticMember && (m.Flags & FlagType.Static) == 0)
                        mCopy.Flags |= FlagType.Static;

                    if ((m.Flags & FlagType.Setter) > 0)
                    {
                        methodTemplate += TemplateUtils.GetTemplate("Setter");
                        methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Modifiers", 
                            (TemplateUtils.GetStaticExternOverride(m) + TemplateUtils.GetModifiers(m)).Trim());
                        methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Name", m.Name);
                        methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "EntryPoint", "");
                        methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Type", m.Parameters[0].Type);
                        methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Member", member.Name + "." + m.Name);
                        methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Void", ASContext.Context.Features.voidKey ?? "void");
                    }
                    else if ((m.Flags & FlagType.Getter) > 0)
                    {
                        methodTemplate += TemplateUtils.GetTemplate("Getter");
                        methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Modifiers",
                            (TemplateUtils.GetStaticExternOverride(m) + TemplateUtils.GetModifiers(m)).Trim());
                        methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Name", m.Name);
                        methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "EntryPoint", "");
                        methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Type", FormatType(m.Type));
                        methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Member", member.Name + "." + m.Name);
                    }
                    else
                    {
                        methodTemplate += TemplateUtils.GetTemplate("Function");
                        methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Body", "<<$(Return) >>$(Body)");
                        methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "EntryPoint", null);
                        methodTemplate = TemplateUtils.ToDeclarationWithModifiersString(mCopy, methodTemplate);
                        if (m.Type != null && m.Type.ToLower() != "void")
                            methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Return", "return");
                        else
                            methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Return", null);

                        // check for varargs
                        bool isVararg = false;
                        if (m.Parameters != null && m.Parameters.Count > 0)
                        {
                            MemberModel mm = m.Parameters[m.Parameters.Count - 1];
                            if (mm.Name.StartsWithOrdinal("..."))
                                isVararg = true;
                        }

                        string callMethodTemplate = TemplateUtils.GetTemplate("CallFunction");
                        if (!isVararg)
                        {
                            callMethodTemplate = TemplateUtils.ReplaceTemplateVariable(callMethodTemplate, "Name", member.Name + "." + m.Name);
                            callMethodTemplate = TemplateUtils.ReplaceTemplateVariable(callMethodTemplate, "Arguments", 
                                TemplateUtils.CallParametersString(m));
//.........这里部分代码省略.........
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:101,代码来源:ASGenerator.cs

示例5: GenerateOverride


//.........这里部分代码省略.........
            if (isStatic) acc = features.staticKey + " " + acc;

            if (!isAS2Event && !isObjectMethod)
                acc = features.overrideKey + " " + acc;

            acc = Regex.Replace(acc, "[ ]+", " ").Trim();

            if ((flags & (FlagType.Getter | FlagType.Setter)) > 0)
            {
                string type = member.Type;
                string name = member.Name;
                if (member.Parameters != null && member.Parameters.Count == 1)
                    type = member.Parameters[0].Type;
                type = FormatType(type);
                if (type == null && !features.hasInference) type = features.objectKey;

                bool genGetter = ofClass.Members.Search(name, FlagType.Getter, 0) != null;
                bool genSetter = ofClass.Members.Search(name, FlagType.Setter, 0) != null;

                if (IsHaxe)
                {
                    // property is public but not the methods
                    acc = features.overrideKey;
                }

                if (genGetter)
                {
                    string tpl = TemplateUtils.GetTemplate("OverrideGetter", "Getter");
                    tpl = TemplateUtils.ReplaceTemplateVariable(tpl, "Modifiers", acc);
                    tpl = TemplateUtils.ReplaceTemplateVariable(tpl, "Name", name);
                    tpl = TemplateUtils.ReplaceTemplateVariable(tpl, "Type", type);
                    tpl = TemplateUtils.ReplaceTemplateVariable(tpl, "Member", "super." + name);
                    decl += tpl;
                }
                if (genSetter)
                {
                    string tpl = TemplateUtils.GetTemplate("OverrideSetter", "Setter");
                    tpl = TemplateUtils.ReplaceTemplateVariable(tpl, "Modifiers", acc);
                    tpl = TemplateUtils.ReplaceTemplateVariable(tpl, "Name", name);
                    tpl = TemplateUtils.ReplaceTemplateVariable(tpl, "Type", type);
                    tpl = TemplateUtils.ReplaceTemplateVariable(tpl, "Member", "super." + name);
                    tpl = TemplateUtils.ReplaceTemplateVariable(tpl, "Void", ASContext.Context.Features.voidKey ?? "void");
                    if (decl.Length > 0)
                    {
                        tpl = "\n\n" + tpl.Replace("$(EntryPoint)", "");
                    }
                    decl += tpl;
                }
                decl = TemplateUtils.ReplaceTemplateVariable(decl, "BlankLine", "");
            }
            else
            {
                string type = FormatType(member.Type);
                //if (type == null) type = features.objectKey;
                
                decl = acc + features.functionKey + " ";
                bool noRet = type == null || type.Equals("void", StringComparison.OrdinalIgnoreCase);
                type = (noRet && type != null) ? ASContext.Context.Features.voidKey : type;
                if (!noRet)
                {
                    string qType = GetQualifiedType(type, ofClass);
                    typesUsed.Add(qType);
                    if (qType == type)
                    {
                        ClassModel rType = ASContext.Context.ResolveType(type, ofClass.InFile);
                        if (!rType.IsVoid()) type = rType.Name;
                    }
                }

                string action = (isProxy || isAS2Event) ? "" : GetSuperCall(member, typesUsed, ofClass);
                string template = TemplateUtils.GetTemplate("MethodOverride");
                
                // fix parameters if needed
                if (member.Parameters != null)
                    foreach (MemberModel para in member.Parameters)
                       if (para.Type == "any") para.Type = "*";

                template = TemplateUtils.ReplaceTemplateVariable(template, "Modifiers", acc);
                template = TemplateUtils.ReplaceTemplateVariable(template, "Name", member.Name);
                template = TemplateUtils.ReplaceTemplateVariable(template, "Arguments", TemplateUtils.ParametersString(member, true));
                template = TemplateUtils.ReplaceTemplateVariable(template, "Type", type);
                template = TemplateUtils.ReplaceTemplateVariable(template, "Method", action);
                decl = template;
            }

            Sci.BeginUndoAction();
            try
            {
                if (ASContext.Context.Settings.GenerateImports && typesUsed.Count > 0)
                {
                    int offset = AddImportsByName(typesUsed, line);
                    position += offset;
                    startPos += offset;
                }

                Sci.SetSel(startPos, position + member.Name.Length);
                InsertCode(startPos, decl, Sci);
            }
            finally { Sci.EndUndoAction(); }
        }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:101,代码来源:ASGenerator.cs

示例6: GenerateImplementation


//.........这里部分代码省略.........

            iType.ResolveExtends(); // resolve inheritance chain
            while (!iType.IsVoid() && iType.QualifiedName != "Object")
            {
                foreach (MemberModel method in iType.Members)
                {
                    if ((method.Flags & flags) == 0
                        || method.Name == iType.Name)
                        continue;

                    // check if method exists
                    ASComplete.FindMember(method.Name, inClass, result, method.Flags, 0);
                    if (!result.IsNull()) continue;

                    string decl;
                    if ((method.Flags & FlagType.Getter) > 0)
                    {
                        if (isHaxe)
                        {
                            decl = TemplateUtils.ToDeclarationWithModifiersString(method, TemplateUtils.GetTemplate("Property"));

                            string templateName = null;
                            string metadata = null;
                            if (method.Parameters[0].Name == "get")
                            {
                                if (method.Parameters[1].Name == "set")
                                {
                                    templateName = "GetterSetter";
                                    metadata = "@:isVar";
                                }
                                else
                                    templateName = "Getter";
                            }
                            else if (method.Parameters[1].Name == "set")
                            {
                                templateName = "Setter";
                            }

                            decl = TemplateUtils.ReplaceTemplateVariable(decl, "MetaData", metadata);

                            if (templateName != null)
                            {
                                var accessor = NewLine + TemplateUtils.ToDeclarationString(method, TemplateUtils.GetTemplate(templateName));
                                accessor = TemplateUtils.ReplaceTemplateVariable(accessor, "Modifiers", null);
                                accessor = TemplateUtils.ReplaceTemplateVariable(accessor, "Member", method.Name);
                                decl += accessor;
                            }
                        }
                        else
                            decl = TemplateUtils.ToDeclarationWithModifiersString(method, TemplateUtils.GetTemplate("Getter"));
                    }
                    else if ((method.Flags & FlagType.Setter) > 0)
                        decl = TemplateUtils.ToDeclarationWithModifiersString(method, TemplateUtils.GetTemplate("Setter"));
                    else if ((method.Flags & FlagType.Function) > 0)
                        decl = TemplateUtils.ToDeclarationWithModifiersString(method, TemplateUtils.GetTemplate("Function"));
                    else
                        decl = NewLine + TemplateUtils.ToDeclarationWithModifiersString(method, TemplateUtils.GetTemplate("Variable"));
                    decl = TemplateUtils.ReplaceTemplateVariable(decl, "Member", "_" + method.Name);
                    decl = TemplateUtils.ReplaceTemplateVariable(decl, "Void", features.voidKey);
                    decl = TemplateUtils.ReplaceTemplateVariable(decl, "Body", null);
                    decl = TemplateUtils.ReplaceTemplateVariable(decl, "BlankLine", NewLine);

                    if (!entry)
                    {
                        decl = TemplateUtils.ReplaceTemplateVariable(decl, "EntryPoint", null);
                    }

                    decl += NewLine;

                    entry = false;

                    sb.Append(decl);
                    canGenerate = true;

                    AddTypeOnce(typesUsed, GetQualifiedType(method.Type, iType));

                    if (method.Parameters != null && method.Parameters.Count > 0)
                        foreach (MemberModel param in method.Parameters)
                            AddTypeOnce(typesUsed, GetQualifiedType(param.Type, iType));
                }
                // interface inheritance
                iType = iType.Extends;
            }
            if (!canGenerate)
                return;

            sci.BeginUndoAction();
            try
            {
                int position = sci.CurrentPos;
                if (ASContext.Context.Settings.GenerateImports && typesUsed.Count > 0)
                {
                    int offset = AddImportsByName(typesUsed, sci.LineFromPosition(position));
                    position += offset;
                    sci.SetSel(position, position);
                }
                InsertCode(position, sb.ToString(), sci);
            }
            finally { sci.EndUndoAction(); }
        }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:101,代码来源:ASGenerator.cs

示例7: GenerateProperty

        private static void GenerateProperty(GeneratorJobType job, MemberModel member, ClassModel inClass, ScintillaControl sci)
        {
            MemberModel latest;
            string name = GetPropertyNameFor(member);
            PropertiesGenerationLocations location = ASContext.CommonSettings.PropertiesGenerationLocation;

            latest = TemplateUtils.GetTemplateBlockMember(sci, TemplateUtils.GetBoundary("AccessorsMethods"));
            if (latest != null)
            {
                location = PropertiesGenerationLocations.AfterLastPropertyDeclaration;
            }
            else
            {
                if (location == PropertiesGenerationLocations.AfterLastPropertyDeclaration)
                {
                    if (IsHaxe) latest = FindLatest(FlagType.Function, 0, inClass, false, false);
                    else latest = FindLatest(FlagType.Getter | FlagType.Setter, 0, inClass, false, false);
                }
                else latest = member;
            }
            if (latest == null) return;

            sci.BeginUndoAction();
            try
            {
                if (IsHaxe)
                {
                    if (name == null) name = member.Name;
                    string args = "(default, default)";
                    if (job == GeneratorJobType.GetterSetter) args = "(get, set)";
                    else if (job == GeneratorJobType.Getter) args = "(get, null)";
                    else if (job == GeneratorJobType.Setter) args = "(default, set)";
                    MakeHaxeProperty(sci, member, args);
                }
                else
                {
                    if ((member.Access & Visibility.Public) > 0) // hide member
                    {
                        MakePrivate(sci, member, inClass);
                    }
                    if (name == null) // rename var with starting underscore
                    {
                        name = member.Name;
                        string newName = GetNewPropertyNameFor(member);
                        if (RenameMember(sci, member, newName)) member.Name = newName;
                    }
                }

                int atLine = latest.LineTo + 1;
                if (location == PropertiesGenerationLocations.BeforeVariableDeclaration)
                    atLine = latest.LineTo;
                int position = sci.PositionFromLine(atLine) - ((sci.EOLMode == 0) ? 2 : 1);

                if (job == GeneratorJobType.GetterSetter)
                {
                    sci.SetSel(position, position);
                    GenerateGetterSetter(name, member, position);
                }
                else
                {
                    if (job != GeneratorJobType.Getter)
                    {
                        sci.SetSel(position, position);
                        GenerateSetter(name, member, position);
                    }
                    if (job != GeneratorJobType.Setter)
                    {
                        sci.SetSel(position, position);
                        GenerateGetter(name, member, position);
                    }
                }
            }
            finally
            {
                sci.EndUndoAction();
            }
        }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:77,代码来源:ASGenerator.cs

示例8: ReplaceText

        /// <summary>
        /// 
        /// </summary> 
        public static bool ReplaceText(ScintillaControl sci, String tail, char trigger)
        {
            sci.BeginUndoAction();
            try
            {
                String triggers = PluginBase.Settings.InsertionTriggers ?? "";
                if (triggers.Length > 0 && Regex.Unescape(triggers).IndexOf(trigger) < 0) return false;

                ICompletionListItem item = null;
                if (completionList.SelectedIndex >= 0)
                {
                    item = completionList.Items[completionList.SelectedIndex] as ICompletionListItem;
                }
                Hide();
                if (item != null)
                {
                    String replace = item.Value;
                    if (replace != null)
                    {
                        sci.SetSel(startPos, sci.CurrentPos);
                        if (word != null && tail.Length > 0)
                        {
                            if (replace.StartsWith(word, StringComparison.OrdinalIgnoreCase) && replace.IndexOfOrdinal(tail) >= word.Length)
                            {
                                replace = replace.Substring(0, replace.IndexOfOrdinal(tail));
                            }
                        }
                        sci.ReplaceSel(replace);
                        if (OnInsert != null) OnInsert(sci, startPos, replace, trigger, item);
                        if (tail.Length > 0) sci.ReplaceSel(tail);
                    }
                    return true;
                }
                return false;
            }
            finally
            {
                sci.EndUndoAction();
            }
        }
开发者ID:xeronith,项目名称:flashdevelop,代码行数:43,代码来源:CompletionList.cs

示例9: OnChar


//.........这里部分代码省略.........
                                            else
                                            {
                                                if (tmpTags.Count > 0 && tmpTags.Peek().Name == tmpTag.Name)
                                                    tmpTags.Pop();
                                                else
                                                    break;
                                            }
                                        }
                                    }
                                    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]))
开发者ID:ImaginationSydney,项目名称:flashdevelop,代码行数:67,代码来源:XMLComplete.cs

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

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

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

示例13: Execute

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

                string selection = Sci.SelText;
                if (selection == null || selection.Length == 0)
                {
                    return;
                }

                if (selection.TrimStart().Length == 0)
                {
                    return;
                }

                Sci.SetSel(Sci.SelectionStart + selection.Length - selection.TrimStart().Length,
                    Sci.SelectionEnd);
                Sci.CurrentPos = Sci.SelectionEnd;

                Int32 pos = Sci.CurrentPos;

                int lineStart = Sci.LineFromPosition(Sci.SelectionStart);
                int lineEnd = Sci.LineFromPosition(Sci.SelectionEnd);
                int firstLineIndent = Sci.GetLineIndentation(lineStart);
                int entryPointIndent = Sci.Indent;

                for (int i = lineStart; i <= lineEnd; i++)
                {
                    int indent = Sci.GetLineIndentation(i);
                    if (i > lineStart)
                    {
                        Sci.SetLineIndentation(i, indent - firstLineIndent + entryPointIndent);
                    }
                }

                string selText = Sci.SelText;
                Sci.ReplaceSel(NewName + "();");

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

                bool isAs3 = cFile.Context.Settings.LanguageId == "AS3";

                FoundDeclaration found = GetDeclarationAtLine(Sci, lineStart);
                if (found == null || found.member == null)
                {
                    return;
                }

                int position = Sci.PositionFromLine(found.member.LineTo + 1) - ((Sci.EOLMode == 0) ? 2 : 1);
                Sci.SetSel(position, position);

                StringBuilder sb = new StringBuilder();
                sb.Append("$(Boundary)\n\n");
                if ((found.member.Flags & FlagType.Static) > 0)
                {
                    sb.Append("static ");
                }
                sb.Append(ASGenerator.GetPrivateKeyword());
                sb.Append(" function ");
                sb.Append(NewName);
                sb.Append("():");
                sb.Append(isAs3 ? "void " : "Void ");
                sb.Append("$(CSLB){\n\t");
                sb.Append(selText);
                sb.Append("$(EntryPoint)");
                sb.Append("\n}\n$(Boundary)");

                ASGenerator.InsertCode(position, sb.ToString());
            }
            finally
            {
                Sci.EndUndoAction();
            }
        }
开发者ID:heon21st,项目名称:flashdevelop,代码行数:80,代码来源:ExtractMethodCommand.cs

示例14: ProcessAbbrevation

        private bool ProcessAbbrevation(ScintillaControl sci)
        {
            //if (_settings.abbrevationDictList == null)
            //{
            //    System.Windows.Forms.MessageBox.Show("Insert abbreviations before!!");
            //    return false;
            //}

            int start =0;
            int end = 0;

            string left = GetWordFromPosition(sci, ref start, ref end);

            if (left != null)
            {
                String ext = System.IO.Path.GetExtension(ASContext.Context.CurrentFile).ToLower(); ;
               dictAbbreviations = null;

                if (!settings.abbrevationDictList.TryGetValue(ext, out dictAbbreviations))
                {
                    dictAbbreviations = settings.abbrevationDictList[".other"];
                }

                AbbrevationSnippet abbrevationSnippet;
                if (dictAbbreviations.TryGetValue(left , out abbrevationSnippet))
                {

                    sci.GotoPos(start);
                    sci.BeginUndoAction();

                    CreateWords cwNew;
                    // c'è una abbreviazione lo creo

                    if (currentCreateWords != null)
                        cw_MonitorOnWordsDeactive(currentCreateWords);

                    cwNew = CreateNewWords();

                    string elaborateText = cwNew.MakeTextFromSnippet(sci, abbrevationSnippet);

                    sci.SetSel(start, end);
                    sci.ReplaceSel(elaborateText);

                    if (abbrevationSnippet.Arguments == null)
                    {
                        cwNew.MonitorOnWordsActive -= new OnMonitorActiveEventHanlder(cw_MonitorOnWordsActive);
                        cwNew.MonitorOnWordsDeactive -= new OnMonitorActiveEventHanlder(cw_MonitorOnWordsDeactive);
                        sci.EndUndoAction();
                        return true;
                    }

                    DoBeforeMonitor();
                    // nessuna activazione quindi nessun monitor
                    if (!currentCreateWords.TryActivateMonitor())
                    {
                        cwNew.MonitorOnWordsActive -= new OnMonitorActiveEventHanlder(cw_MonitorOnWordsActive);
                        cwNew.MonitorOnWordsDeactive -= new OnMonitorActiveEventHanlder(cw_MonitorOnWordsDeactive);
                    }
                    else
                    {
                        currentCreateWords = cwNew;
                    }

                    sci.EndUndoAction();

                    return true;
                }

            }

            //non ha trovato nessuna parola

            if (isCursor)
            {
                isCursor = false;
                ShowListAbbrevations();
                return false;
            }

            if (MonitorWordsActive && currentSci.Focused)
                currentCreateWords.MoveNextWord();
            else
                ShowListAbbrevations();

            return false;
        }
开发者ID:fordream,项目名称:wanghe-project,代码行数:86,代码来源:Abbreviation.cs


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