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


C# ScintillaControl.MBSafeTextLength方法代码示例

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


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

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

示例2: GetNextDocumentMatch

 /// <summary>
 /// Gets the next valid match but fixes position with selected text's length
 /// </summary>
 public static SearchMatch GetNextDocumentMatch(ScintillaControl sci, List<SearchMatch> matches, Boolean forward, Boolean fixedPosition)
 {
     SearchMatch nearestMatch = matches[0];
     Int32 currentPosition = sci.MBSafeCharPosition(sci.CurrentPos);
     if (fixedPosition) currentPosition -= sci.MBSafeTextLength(sci.SelText);
     for (Int32 i = 0; i < matches.Count; i++)
     {
         if (forward)
         {
             if (currentPosition > matches[matches.Count - 1].Index)
             {
                 return matches[0];
             }
             if (matches[i].Index >= currentPosition)
             {
                 return matches[i];
             }
         }
         else
         {
             if (sci.SelText.Length > 0 && currentPosition <= matches[0].Index + matches[0].Value.Length)
             {
                 return matches[matches.Count - 1];
             }
             if (currentPosition < matches[0].Index + matches[0].Value.Length)
             {
                 return matches[matches.Count - 1];
             }
             if (sci.SelText.Length == 0 && currentPosition == matches[i].Index + matches[i].Value.Length)
             {
                 return matches[i];
             }
             if (matches[i].Index > nearestMatch.Index && matches[i].Index + matches[i].Value.Length < currentPosition)
             {
                 nearestMatch = matches[i];
             }
         }
     }
     return nearestMatch;
 }
开发者ID:xeronith,项目名称:flashdevelop,代码行数:43,代码来源:FRDialogGenerics.cs

示例3: AddHighlights

 /// <summary>
 /// Adds highlights to the correct sci control
 /// </summary>
 private void AddHighlights(ScintillaControl sci, List<SearchMatch> matches)
 {
     ITabbedDocument doc = DocumentManager.FindDocument(sci);
     Language language = MainForm.Instance.SciConfig.GetLanguage(sci.ConfigurationLanguage);
     foreach (SearchMatch match in matches)
     {
         Int32 start = sci.MBSafePosition(match.Index);
         Int32 end = start + sci.MBSafeTextLength(match.Value);
         Int32 line = sci.LineFromPosition(start);
         Int32 position = start;
         Int32 es = sci.EndStyled;
         Int32 mask = 1 << sci.StyleBits;
         // Define indics in both controls...
         doc.SplitSci1.SetIndicStyle(0, (Int32)ScintillaNet.Enums.IndicatorStyle.RoundBox);
         doc.SplitSci1.SetIndicFore(0, language.editorstyle.HighlightBackColor);
         doc.SplitSci2.SetIndicStyle(0, (Int32)ScintillaNet.Enums.IndicatorStyle.RoundBox);
         doc.SplitSci2.SetIndicFore(0, language.editorstyle.HighlightBackColor);
         sci.StartStyling(position, mask);
         sci.SetStyling(end - start, mask);
         sci.StartStyling(es, mask - 1);
     }
 }
开发者ID:Gr33z00,项目名称:flashdevelop,代码行数:25,代码来源:QuickFind.cs

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

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

示例6: MakePrivate

        public static bool MakePrivate(ScintillaControl Sci, MemberModel member, ClassModel inClass)
        {
            ContextFeatures features = ASContext.Context.Features;
            string visibility = GetPrivateKeyword(inClass);
            if (features.publicKey == null || visibility == null) return false;
            Regex rePublic = new Regex(String.Format(@"\s*({0})\s+", features.publicKey));

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

示例7: RemoveOneLocalDeclaration

 private static bool RemoveOneLocalDeclaration(ScintillaControl sci, MemberModel contextMember)
 {
     string type = "";
     if (contextMember.Type != null && (contextMember.Flags & FlagType.Inferred) == 0)
     {
         type = FormatType(contextMember.Type);
         if (type.IndexOf('*') > 0)
             type = type.Replace("/*", @"/\*\s*").Replace("*/", @"\s*\*/");
         type = @":\s*" + type;
     }
     Regex reDecl = new Regex(String.Format(@"[\s\(]((var|const)\s+{0}\s*{1})\s*", contextMember.Name, type));
     for (int i = contextMember.LineFrom; i <= contextMember.LineTo + 10; i++)
     {
         string text = sci.GetLine(i);
         Match m = reDecl.Match(text);
         if (m.Success)
         {
             int index = sci.MBSafeTextLength(text.Substring(0, m.Groups[1].Index));
             int position = sci.PositionFromLine(i) + index;
             int len = sci.MBSafeTextLength(m.Groups[1].Value);
             sci.SetSel(position, position + len);
             if (contextMember.Type == null || (contextMember.Flags & FlagType.Inferred) != 0) sci.ReplaceSel(contextMember.Name + " ");
             else sci.ReplaceSel(contextMember.Name);
             UpdateLookupPosition(position, contextMember.Name.Length - len);
             return true;
         }
     }
     return false;
 }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:29,代码来源:ASGenerator.cs

示例8: AddHighlight

 /// <summary>
 /// Highlight a regexp match group
 /// </summary>
 /// <param name="sci"></param>
 /// <param name="matches"></param>
 private void AddHighlight(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);
     Int32 position = start;
     Int32 es = sci.EndStyled;
     Int32 mask = 1 << sci.StyleBits;
     sci.SetIndicStyle(0, (Int32)ScintillaNet.Enums.IndicatorStyle.Max);
     sci.SetIndicFore(0, 0xff0000);
     sci.StartStyling(position, mask);
     sci.SetStyling(end - start, mask);
     sci.StartStyling(es, mask - 1);
 }
开发者ID:nomilogic,项目名称:fdplugins,代码行数:19,代码来源:PluginUI.cs

示例9: DoesMatchPointToTarget

        /// <summary>
        /// Checks if a given search match actually points to the given target source
        /// </summary>
        /// <returns>True if the SearchMatch does point to the target source.</returns>
        public static bool DoesMatchPointToTarget(ScintillaControl Sci, SearchMatch match, ASResult target, DocumentHelper associatedDocumentHelper)
        {
            if (Sci == null || target == null) return false;
            FileModel targetInFile = null;

            if (target.InFile != null)
                targetInFile = target.InFile;
            else if (target.Member != null && target.InClass == null)
                targetInFile = target.Member.InFile;

            Boolean matchMember = targetInFile != null && target.Member != null;
            Boolean matchType = target.Member == null && target.IsStatic && target.Type != null;
            if (!matchMember && !matchType) return false;

            ASResult result = null;
            // get type at match position
            if (match.Index < Sci.Text.Length) // TODO: find out rare cases of incorrect index reported
            {
                result = DeclarationLookupResult(Sci, Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value));
                if (associatedDocumentHelper != null)
                {
                    // because the declaration lookup opens a document, we should register it with the document helper to be closed later
                    associatedDocumentHelper.RegisterLoadedDocument(PluginBase.MainForm.CurrentDocument);
                }
            }
            // check if the result matches the target
            if (result == null || (result.InFile == null && result.Type == null)) return false;
            if (matchMember)
            {
                if (result.Member == null) return false;

                var resultInFile = result.InClass != null ? result.InFile : result.Member.InFile;

                return resultInFile.BasePath == targetInFile.BasePath
                    && resultInFile.FileName == targetInFile.FileName
                    && result.Member.LineFrom == target.Member.LineFrom
                    && result.Member.Name == target.Member.Name;
            }
            else // type
            {
                if (result.Type == null) return false;
                if (result.Type.QualifiedName == target.Type.QualifiedName) return true;
                return false;
            }
        }
开发者ID:CamWiseOwl,项目名称:flashdevelop,代码行数:49,代码来源:RefactoringHelper.cs

示例10: IsMatchTheTarget

 /// <summary>
 /// Checks if the given match actually is the declaration.
 /// </summary>
 public static bool IsMatchTheTarget(ScintillaControl Sci, SearchMatch match, ASResult target)
 {
     if (Sci == null || target == null || target.InFile == null || target.Member == null)
     {
         return false;
     }
     String originalFile = Sci.FileName;
     // get type at match position
     ASResult declaration = DeclarationLookupResult(Sci, Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value));
     return (declaration.InFile != null && originalFile == declaration.InFile.FileName) && (Sci.CurrentPos == (Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value)));
 }
开发者ID:CamWiseOwl,项目名称:flashdevelop,代码行数:14,代码来源:RefactoringHelper.cs

示例11: MBSafeColumn

 /// <summary>
 /// Convert multibyte column to byte length
 /// </summary>
 private int MBSafeColumn(ScintillaControl sci, int line, int length)
 {
     String text = sci.GetLine(line) ?? "";
     length = Math.Min(length, text.Length);
     return sci.MBSafeTextLength(text.Substring(0, length));
 }
开发者ID:zpLin,项目名称:flashdevelop,代码行数:9,代码来源:PluginUI.cs

示例12: AddHighlights

        /// <summary>
        /// Adds highlights to the correct sci control
        /// </summary>
        private void AddHighlights(ScintillaControl sci, List<SearchMatch> matches)
        {
            if (matches == null)
            {
                return;
            }

            foreach (SearchMatch match in matches)
            {
                Int32 start = sci.MBSafePosition(match.Index);
                Int32 end = start + sci.MBSafeTextLength(match.Value);
                Int32 line = sci.LineFromPosition(start);
                Int32 position = start;
                Int32 es = sci.EndStyled;
                Int32 mask = 1 << sci.StyleBits;

                sci.SetIndicStyle(0, (Int32)ScintillaNet.Enums.IndicatorStyle.RoundBox);
                sci.SetIndicFore(0, DataConverter.ColorToInt32(this.settingObject.highlightColor));
                sci.StartStyling(position, mask);
                sci.SetStyling(end - start, mask);
                sci.StartStyling(es, mask - 1);

                if (this.settingObject.addLineMarker)
                {
                    sci.MarkerAdd(line, 2);
                    sci.MarkerSetBack(2, DataConverter.ColorToInt32(this.settingObject.highlightColor));
                }
            }
        }
开发者ID:fordream,项目名称:wanghe-project,代码行数:32,代码来源:PluginMain.cs

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

示例14: AddHighlights

 /// <summary>
 /// Adds highlights to the correct sci control
 /// </summary>
 private void AddHighlights(ScintillaControl sci, List<SearchMatch> matches)
 {
     if (matches == null) return;
     int style = (int)settings.HighlightStyle;
     int color = DataConverter.ColorToInt32(settings.HighlightColor);
     if (settings.HighlightUnderCursorEnabled && prevResult != null)
     {
         if (prevResult.IsPackage) color = DataConverter.ColorToInt32(settings.PackageColor);
         else
         {
             FlagType flags;
             if (prevResult.Type != null && prevResult.Member == null)
             {
                 flags = prevResult.Type.Flags;
                 if ((flags & FlagType.Abstract) > 0) color = DataConverter.ColorToInt32(settings.AbstractColor);
                 else if ((flags & FlagType.TypeDef) > 0) color = DataConverter.ColorToInt32(settings.TypeDefColor);
                 else if ((flags & FlagType.Enum) > 0) color = DataConverter.ColorToInt32(settings.EnumColor);
                 else if ((flags & FlagType.Class) > 0) color = DataConverter.ColorToInt32(settings.ClassColor);
             }
             else if (prevResult.Member != null)
             {
                 flags = prevResult.Member.Flags;
                 if ((flags & FlagType.Constant) > 0) color = DataConverter.ColorToInt32(settings.ConstantColor);
                 else if ((flags & FlagType.ParameterVar) > 0) color = DataConverter.ColorToInt32(settings.MemberFunctionColor);
                 else if ((flags & FlagType.LocalVar) > 0) color = DataConverter.ColorToInt32(settings.LocalVariableColor);
                 else if ((flags & FlagType.Static) == 0)
                 {
                     if ((flags & FlagType.Variable) > 0) color = DataConverter.ColorToInt32(settings.VariableColor);
                     else if ((flags & (FlagType.Setter | FlagType.Getter)) > 0) color = DataConverter.ColorToInt32(settings.AccessorColor);
                     else if ((flags & FlagType.Function) > 0) color = DataConverter.ColorToInt32(settings.MethodColor);
                 }
                 else
                 {
                     if ((flags & FlagType.Variable) > 0) color = DataConverter.ColorToInt32(settings.StaticVariableColor);
                     else if ((flags & (FlagType.Setter | FlagType.Getter)) > 0) color = DataConverter.ColorToInt32(settings.StaticAccessorColor);
                     else if ((flags & FlagType.Function) > 0) color = DataConverter.ColorToInt32(settings.StaticMethodColor);
                 }
             }
         }
     }
     int es = sci.EndStyled;
     int mask = 1 << sci.StyleBits;
     bool addLineMarker = settings.AddLineMarker;
     foreach (SearchMatch match in matches)
     {
         int start = sci.MBSafePosition(match.Index);
         int end = start + sci.MBSafeTextLength(match.Value);
         int line = sci.LineFromPosition(start);
         int position = start;
         sci.SetIndicStyle(0, style);
         sci.SetIndicFore(0, color);
         sci.StartStyling(position, mask);
         sci.SetStyling(end - start, mask);
         sci.StartStyling(es, mask - 1);
         if (addLineMarker)
         {
             sci.MarkerAdd(line, MARKER_NUMBER);
             sci.MarkerSetBack(MARKER_NUMBER, color);
         }
     }
     prevPos = sci.CurrentPos;
 }
开发者ID:nujond,项目名称:fd-highlight-selected-plugin,代码行数:65,代码来源:PluginMain.cs

示例15: GenerateVariableJob

        private static void GenerateVariableJob(GeneratorJobType job, ScintillaControl sci, MemberModel member, bool detach, ClassModel inClass)
        {
            var position = 0;
            bool isOtherClass = false;
            Visibility visibility = job.Equals(GeneratorJobType.Variable) ? GetDefaultVisibility(inClass) : Visibility.Public;
            FlagType kind = job.Equals(GeneratorJobType.Constant) ? FlagType.Constant : FlagType.Variable;
            // evaluate, if the variable (or constant) should be generated in other class
            ASResult varResult = ASComplete.GetExpressionType(sci, sci.WordEndPosition(sci.CurrentPos, true));
            var memberIsStatic = member != null && (member.Flags & FlagType.Static) > 0;
            var dot = ASContext.Context.Features.dot;
            if (ASContext.CommonSettings.GenerateScope && !varResult.Context.Value.Contains(dot))
            {
                position = sci.CurrentPos;
                var start = sci.WordStartPosition(position, true);
                var length = sci.MBSafeTextLength(contextToken);
                sci.SetSel(start, start + length);
                var scope = memberIsStatic ? inClass.QualifiedName : "this";
                var text = scope + dot + contextToken;
                sci.ReplaceSel(text);
                UpdateLookupPosition(position, text.Length - length);
            }
            int contextOwnerPos = GetContextOwnerEndPos(sci, sci.WordStartPosition(sci.CurrentPos, true));
            MemberModel isStatic = new MemberModel();
            if (contextOwnerPos != -1)
            {
                ASResult contextOwnerResult = ASComplete.GetExpressionType(sci, contextOwnerPos);
                if (contextOwnerResult != null
                    && (contextOwnerResult.Member == null || (contextOwnerResult.Member.Flags & FlagType.Constructor) > 0)
                    && contextOwnerResult.Type != null)
                {
                    isStatic.Flags |= FlagType.Static;
                }
            }
            else if (memberIsStatic)
            {
                isStatic.Flags |= FlagType.Static;
            }

            ASResult returnType = null;
            int lineNum = sci.CurrentLine;
            string line = sci.GetLine(lineNum);

            Match m = Regex.Match(line, "\\b" + Regex.Escape(contextToken) + "\\(");
            if (m.Success)
            {
                returnType = new ASResult();
                returnType.Type = ASContext.Context.ResolveType("Function", null);
            }
            else
            {
                m = Regex.Match(line, @"=\s*[^;\n\r}}]+");
                if (m.Success)
                {
                    int posLineStart = sci.PositionFromLine(lineNum);
                    if (posLineStart + m.Index >= sci.CurrentPos)
                    {
                        line = line.Substring(m.Index);
                        StatementReturnType rType = GetStatementReturnType(sci, inClass, line, posLineStart + m.Index);
                        if (rType != null)
                        {
                            returnType = rType.resolve;
                        }
                    }
                }
            }

            if (varResult.RelClass != null && !varResult.RelClass.IsVoid() && !varResult.RelClass.Equals(inClass))
            {
                AddLookupPosition();
                lookupPosition = -1;

                ASContext.MainForm.OpenEditableDocument(varResult.RelClass.InFile.FileName, false);
                sci = ASContext.CurSciControl;
                isOtherClass = true;

                FileModel fileModel = new FileModel();
                fileModel.Context = ASContext.Context;
                ASFileParser parser = new ASFileParser();
                parser.ParseSrc(fileModel, sci.Text);

                foreach (ClassModel cm in fileModel.Classes)
                {
                    if (cm.QualifiedName.Equals(varResult.RelClass.QualifiedName))
                    {
                        varResult.RelClass = cm;
                        break;
                    }
                }
                inClass = varResult.RelClass;

                ASContext.Context.UpdateContext(inClass.LineFrom);
            }

            var latest = GetLatestMemberForVariable(job, inClass, visibility, isStatic);

            // if we generate variable in current class..
            if (!isOtherClass && member == null)
            {
                detach = false;
                lookupPosition = -1;
//.........这里部分代码省略.........
开发者ID:xeronith,项目名称:flashdevelop,代码行数:101,代码来源:ASGenerator.cs


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