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


C# ScintillaControl.SetSel方法代码示例

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


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

示例1: ExecuteActionPoint

 /// <summary>
 /// Selects the text specified in the action point
 /// </summary>
 public static void ExecuteActionPoint(ActionPoint point, ScintillaControl sci)
 {
     if (point.EntryPosition != -1 && point.ExitPosition != -1)
     {
         Int32 start = sci.MBSafePosition(point.EntryPosition);
         Int32 end = sci.MBSafePosition(point.ExitPosition);
         sci.SetSel(start, end);
     }
     else if (point.EntryPosition != -1 && point.ExitPosition == -1)
     {
         Int32 start = sci.MBSafePosition(point.EntryPosition);
         sci.SetSel(start, start);
     }
 }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:17,代码来源:SnippetHelper.cs

示例2: SelectMatch

 /// <summary>
 /// Selects a search match
 /// </summary>
 public static void SelectMatch(ScintillaControl sci, SearchMatch match)
 {
     Int32 start = sci.MBSafePosition(match.Index); // wchar to byte position
     Int32 end = start + sci.MBSafeTextLength(match.Value); // wchar to byte text length
     Int32 line = sci.LineFromPosition(start);
     sci.EnsureVisible(line);
     sci.SetSel(start, end);
 }
开发者ID:ImaginationSydney,项目名称:flashdevelop,代码行数:11,代码来源:FRDialogGenerics.cs

示例3: PostProcessSnippets

 /// <summary>
 /// Processes the snippet and template arguments
 /// </summary>
 public static Int32 PostProcessSnippets(ScintillaControl sci, Int32 currentPosition)
 {
     Int32 delta = 0;
     while (sci.SelectText(BOUNDARY, 0) != -1) { sci.ReplaceSel(""); delta -= BOUNDARY.Length; }
     String text = sci.Text; // Store text temporarily
     Int32 entryPosition = sci.MBSafePosition(text.IndexOfOrdinal(ENTRYPOINT));
     Int32 exitPosition = sci.MBSafePosition(text.IndexOfOrdinal(EXITPOINT));
     if (entryPosition != -1 && exitPosition != -1)
     {
         sci.SelectText(ENTRYPOINT, 0); sci.ReplaceSel(""); delta -= ENTRYPOINT.Length;
         sci.SelectText(EXITPOINT, 0); sci.ReplaceSel(""); delta -= EXITPOINT.Length;
         sci.SetSel(entryPosition, exitPosition - ENTRYPOINT.Length);
     }
     else if (entryPosition != -1 && exitPosition == -1)
     {
         sci.SelectText(ENTRYPOINT, 0); sci.ReplaceSel(""); delta -= ENTRYPOINT.Length;
         sci.SetSel(entryPosition, entryPosition);
     }
     else sci.SetSel(currentPosition, currentPosition);
     return delta;
 }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:24,代码来源:SnippetHelper.cs

示例4: ApplyStateObject

 /// <summary>
 /// Applies the state object to a scintilla control
 /// </summary>
 private static void ApplyStateObject(ScintillaControl sci, StateObject so, Boolean restorePosition)
 {
     if (so.LineCount != sci.LineCount) return;
     sci.Refresh(); // Update the scintilla control state
     for (Int32 i = 0; i < so.FoldedLines.Count; i++)
     {
         Int32 foldedLine = so.FoldedLines[i];
         sci.ToggleFold(foldedLine);
     }
     if (so.BookmarkedLines != null)
     {
         for (Int32 i = 0; i < so.BookmarkedLines.Count; i++)
         {
             Int32 bookmarkedLine = so.BookmarkedLines[i];
             sci.MarkerAdd(bookmarkedLine, 0);
         }
         sci.Refresh(); // Update again
     }
     if (restorePosition)
     {
         sci.FirstVisibleLine = so.LineScroll;
         Int32 line = sci.LineFromPosition(so.Position);
         sci.SetSel(so.Position, so.Position);
         sci.EnsureVisible(line);
     }
 }
开发者ID:xeronith,项目名称:flashdevelop,代码行数:29,代码来源:FileStateManager.cs

示例5: MoveToPosition

 /// <summary>
 /// Move the document position
 /// </summary>
 private void MoveToPosition(ScintillaControl sci, Int32 position)
 {
     try
     {
         position = sci.MBSafePosition(position); // scintilla indexes are in 8bits
         Int32 line = sci.LineFromPosition(position);
         sci.EnsureVisible(line);
         sci.GotoPos(position);
         sci.SetSel(position, sci.LineEndPosition(line));
         sci.Focus();
     }
     catch 
     {
         String message = TextHelper.GetString("Info.InvalidItem");
         ErrorManager.ShowInfo(message);
         this.RemoveInvalidItems();
         this.RefreshProject();
     }
 }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:22,代码来源:PluginUI.cs

示例6: GenerateDelegateMethods


//.........这里部分代码省略.........
                        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));
                            callMethodTemplate += ";";
                        }
                        else 
                        {
                            List<MemberModel> pseudoParamsList = new List<MemberModel>();
                            pseudoParamsList.Add(new MemberModel("null", null, FlagType.ParameterVar, 0));
                            pseudoParamsList.Add(new MemberModel("[$(Subarguments)].concat($(Lastsubargument))", null, FlagType.ParameterVar, 0));
                            MemberModel pseudoParamsOwner = new MemberModel();
                            pseudoParamsOwner.Parameters = pseudoParamsList;

                            callMethodTemplate = TemplateUtils.ReplaceTemplateVariable(callMethodTemplate, "Name",
                                member.Name + "." + m.Name + ".apply");
                            callMethodTemplate = TemplateUtils.ReplaceTemplateVariable(callMethodTemplate, "Arguments",
                                TemplateUtils.CallParametersString(pseudoParamsOwner));
                            callMethodTemplate += ";";

                            List<MemberModel> arrayParamsList = new List<MemberModel>();
                            for (int i = 0; i < m.Parameters.Count - 1; i++)
                            {
                                MemberModel param = m.Parameters[i];
                                arrayParamsList.Add(param);
                            }

                            pseudoParamsOwner.Parameters = arrayParamsList;

                            callMethodTemplate = TemplateUtils.ReplaceTemplateVariable(callMethodTemplate, "Subarguments",
                                TemplateUtils.CallParametersString(pseudoParamsOwner));

                            callMethodTemplate = TemplateUtils.ReplaceTemplateVariable(callMethodTemplate, "Lastsubargument", 
                                m.Parameters[m.Parameters.Count - 1].Name.TrimStart(new char[] { '.', ' '}));
                        }

                        methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Body", callMethodTemplate);
                    }
                    methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "BlankLine", NewLine);
                    result += methodTemplate;

                    if (m.Parameters != null)
                    {
                        for (int i = 0; i < m.Parameters.Count; i++)
                        {
                            MemberModel param = m.Parameters[i];
                            if (param.Type != null)
                            {
                                type = ASContext.Context.ResolveType(param.Type, selectedMembers[m].InFile);
                                importsList.Add(type.QualifiedName);
                            }
                        }
                    }

                    if (position < 0)
                    {
                        MemberModel latest = GetLatestMemberForFunction(inClass, mCopy.Access, mCopy);
                        if (latest == null)
                        {
                            position = Sci.WordStartPosition(Sci.CurrentPos, true);
                            Sci.SetSel(position, Sci.WordEndPosition(position, true));
                        }
                        else
                        {
                            position = Sci.PositionFromLine(latest.LineTo + 1) - ((Sci.EOLMode == 0) ? 2 : 1);
                            Sci.SetSel(position, position);
                        }
                    }
                    else
                    {
                        position = Sci.CurrentPos;
                    }

                    if (m.Type != null)
                    {
                        type = ASContext.Context.ResolveType(m.Type, selectedMembers[m].InFile);
                        importsList.Add(type.QualifiedName);
                    }
                }

                if (importsList.Count > 0 && position > -1)
                {
                    int o = AddImportsByName(importsList, Sci.LineFromPosition(position));
                    position += o;
                    Sci.SetSel(position, position);
                }

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

示例7: RenameMember

        public static bool RenameMember(ScintillaControl Sci, MemberModel member, string newName)
        {
            ContextFeatures features = ASContext.Context.Features;
            string kind = features.varKey;

            if ((member.Flags & FlagType.Getter) > 0)
                kind = features.getKey;
            else if ((member.Flags & FlagType.Setter) > 0)
                kind = features.setKey;
            else if (member.Flags == FlagType.Function)
                kind = features.functionKey;

            Regex reMember = new Regex(String.Format(@"{0}\s+({1})[\s:]", kind, member.Name));

            string line;
            Match m;
            int index, position;
            for (int i = member.LineFrom; i <= member.LineTo; i++)
            {
                line = Sci.GetLine(i);
                m = reMember.Match(line);
                if (m.Success)
                {
                    index = Sci.MBSafeTextLength(line.Substring(0, m.Groups[1].Index));
                    position = Sci.PositionFromLine(i) + index;
                    Sci.SetSel(position, position + member.Name.Length);
                    Sci.ReplaceSel(newName);
                    UpdateLookupPosition(position, 1);
                    return true;
                }
            }
            return false;
        }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:33,代码来源:ASGenerator.cs

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

示例9: GenerateExtractMethod

        public static void GenerateExtractMethod(ScintillaControl Sci, string NewName)
        {
            FileModel cFile;
            IASContext context = ASContext.Context;

            string selection = Sci.SelText;
            if (string.IsNullOrEmpty(selection))
            {
                return;
            }

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

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

            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;
            string template = TemplateUtils.GetTemplate("CallFunction");
            template = TemplateUtils.ReplaceTemplateVariable(template, "Name", NewName);
            template = TemplateUtils.ReplaceTemplateVariable(template, "Arguments", "");

            InsertCode(Sci.CurrentPos, template + ";", Sci);

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

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

            lookupPosition = Sci.CurrentPos;
            AddLookupPosition();

            MemberModel latest = TemplateUtils.GetTemplateBlockMember(Sci, TemplateUtils.GetBoundary("PrivateMethods"));

            if (latest == null)
                latest = GetLatestMemberForFunction(found.inClass, GetDefaultVisibility(found.inClass), found.member);

            if (latest == null)
                latest = found.member;

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

            FlagType flags = FlagType.Function;
            if ((found.member.Flags & FlagType.Static) > 0)
            {
                flags |= FlagType.Static;
            }

            MemberModel m = new MemberModel(NewName, context.Features.voidKey, flags, GetDefaultVisibility(found.inClass));

            template = NewLine + TemplateUtils.GetTemplate("Function");
            template = TemplateUtils.ToDeclarationWithModifiersString(m, template);
            template = TemplateUtils.ReplaceTemplateVariable(template, "Body", selText);
            template = TemplateUtils.ReplaceTemplateVariable(template, "BlankLine", NewLine);
            InsertCode(position, template, Sci);
        }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:79,代码来源:ASGenerator.cs

示例10: AssignStatementToVar

        private static void AssignStatementToVar(ClassModel inClass, ScintillaControl sci, MemberModel member)
        {
            int lineNum = sci.CurrentLine;
            string line = sci.GetLine(lineNum);
            StatementReturnType returnType = GetStatementReturnType(sci, inClass, line, sci.PositionFromLine(lineNum));

            if (returnType == null) return;
            
            string type = null;
            string varname = null;
            ASResult resolve = returnType.resolve;
            string word = returnType.word;

            if (resolve != null && !resolve.IsNull())
            {
                if (resolve.Member != null && resolve.Member.Type != null)
                {
                    type = resolve.Member.Type;
                }
                else if (resolve.Type != null && resolve.Type.Name != null)
                {
                    type = resolve.Type.QualifiedName;
                }

                if (resolve.Member != null && resolve.Member.Name != null)
                {
                    varname = GuessVarName(resolve.Member.Name, type);
                }
            }

            if (!string.IsNullOrEmpty(word) && Char.IsDigit(word[0])) word = null;

            if (!string.IsNullOrEmpty(word) && (string.IsNullOrEmpty(type) || Regex.IsMatch(type, "(<[^]]+>)")))
                word = null;

            if (!string.IsNullOrEmpty(type) && type.Equals("void", StringComparison.OrdinalIgnoreCase))
                type = null;

            if (varname == null) varname = GuessVarName(word, type);

            if (varname != null && varname == word)
                varname = varname.Length == 1 ? varname + "1" : varname[0] + "";

            string cleanType = null;
            if (type != null) cleanType = FormatType(GetShortType(type));
            
            string template = TemplateUtils.GetTemplate("AssignVariable");
            template = TemplateUtils.ReplaceTemplateVariable(template, "Name", varname);
            template = TemplateUtils.ReplaceTemplateVariable(template, "Type", cleanType);

            int indent = sci.GetLineIndentation(lineNum);
            int pos = sci.PositionFromLine(lineNum) + indent / sci.Indent;

            sci.CurrentPos = pos;
            sci.SetSel(pos, pos);
            InsertCode(pos, template, sci);

            if (type != null)
            {
                ClassModel inClassForImport = null;
                if (resolve.InClass != null)
                {
                    inClassForImport = resolve.InClass;
                }
                else if (resolve.RelClass != null)
                {
                    inClassForImport = resolve.RelClass;
                }
                else 
                {
                    inClassForImport = inClass;
                }
                List<string> l = new List<string>();
                l.Add(GetQualifiedType(type, inClassForImport));
                pos += AddImportsByName(l, sci.LineFromPosition(pos));
            }
        }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:77,代码来源:ASGenerator.cs

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

示例12: GetText

 public static String GetText(ScintillaControl sci, Int32 startPosition, Int32 endPosition)
 {
     Int32 curPos = sci.CurrentPos;
     Int32 selStart = sci.SelectionStart;
     Int32 selEnd = sci.SelectionEnd;
     Int32 firstLine = sci.FirstVisibleLine;
     sci.SetSel(startPosition, endPosition);
     String text = sci.SelText;
     sci.GotoPos(curPos);
     sci.SetSel(selStart, selEnd);
     Int32 actualFirstLine = sci.FirstVisibleLine;
     if (actualFirstLine != firstLine)
     {
         sci.LineScroll(0, firstLine - actualFirstLine);
     }
     return text;
 }
开发者ID:heon21st,项目名称:flashdevelop,代码行数:17,代码来源:PluginMain.cs

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

示例14: 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)
                    {
                        // There is no standard for XML formatting, although most IDEs have similarities. We are mostly going with Visual Studio style with slight differences.
                        // 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("%>")) || 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);
                            // Line indentation.
                            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 || ctag.Closing)
                            {
                                //Closed tag. Look for the nearest open and not closed tag for proper indentation
                                subIndent = false;
                                if (ctag.Name != null)
                                {
                                    var tmpTags = new Stack<XMLContextTag>();
                                    var tmpTag = ctag;

                                    if (!tmpTag.Closed) tmpTags.Push(tmpTag);
                                    while (tmpTag.Position != 0)
                                    {
                                        tmpTag = GetXMLContextTag(sci, tmpTag.Position);
                                        if (tmpTag.Tag != null && tmpTag.Name != null)
                                        {
                                            if (tmpTag.Closed) 
                                                continue;
                                            else if (tmpTag.Closing)
                                            {
                                                tmpTags.Push(tmpTag);
                                            }
                                            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));
//.........这里部分代码省略.........
开发者ID:ImaginationSydney,项目名称:flashdevelop,代码行数:101,代码来源:XMLComplete.cs

示例15: OnCharAdded

        internal void OnCharAdded(ScintillaControl sci, int position, int value)
        {
            if (!enabled) return;

            bool autoInsert = false;

            char c = (char)value;
            if (wordChars.IndexOf(c) < 0)
            {
                if (c == ':')
                {
                    if (lastColonInsert == position - 1)
                    {
                        sci.DeleteBack();
                        lastColonInsert = -1;
                        return;
                    }
                }
                else if (c == ';')
                {
                    char c2 = (char)sci.CharAt(position);
                    if (c2 == ';')
                    {
                        sci.DeleteBack();
                        sci.SetSel(position, position);
                        return;
                    }
                }
                else if (c == '\n' && !settings.DisableAutoCloseBraces)
                {
                    int line = sci.LineFromPosition(position);
                    string text = sci.GetLine(line - 1).TrimEnd();
                    if (text.EndsWith("{")) AutoCloseBrace(sci, line);
                }
                else if (c == '\t') // TODO get tab notification!
                {
                    position--;
                    autoInsert = true;
                }
                else return;
            }

            var context = GetContext(sci, position);
            var mode = CompleteMode.None;

            if (context.InComments) return;
            else if (context.InBlock)
            {
                if (context.Word == "-") mode = CompleteMode.Prefix;
                else if (context.Word.Length >= 2 || (char)value == '-')
                    mode = CompleteMode.Attribute;
            }
            else if (context.InValue)
            {
                if (features.Mode != "CSS" && c == features.Trigger)
                {
                    context.Word = context.Word.Substring(1);
                    context.Position++;
                    mode = CompleteMode.Variable;
                }
                else if (context.Word.Length == 1 && "abcdefghijklmnopqrstuvwxyz".IndexOf(context.Word[0]) >= 0)
                    mode = CompleteMode.Value;
            }
            else if (c == ':' && !context.IsVar) mode = CompleteMode.Pseudo;

            HandleCompletion(mode, context, autoInsert, true);
        }
开发者ID:ImaginationSydney,项目名称:flashdevelop,代码行数:67,代码来源:Completion.cs


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