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


C# ScintillaControl.PositionFromLine方法代码示例

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


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

示例1: AddHighlight

 /// <summary>
 /// 
 /// </summary>
 public static void AddHighlight(ScintillaControl sci, Int32 line, Int32 indicator, Int32 value)
 {
     Int32 start = sci.PositionFromLine(line);
     Int32 length = sci.LineLength(line);
     if (start < 0 || length < 1)
     {
         return;
     }
     // Remember previous EndStyled marker and restore it when we are done.
     Int32 es = sci.EndStyled;
     // Mask for style bits used for restore.
     Int32 mask = (1 << sci.StyleBits) - 1;
     Language lang = PluginBase.MainForm.SciConfig.GetLanguage(sci.ConfigurationLanguage);
     if (indicator == indicatorDebugCurrentLine)
     {
         sci.SetIndicFore(indicator, lang.editorstyle.DebugLineBack);
     }
     else if (indicator == indicatorDebugEnabledBreakpoint)
     {
         sci.SetIndicFore(indicator, lang.editorstyle.ErrorLineBack);
     }
     else if (indicator == indicatorDebugDisabledBreakpoint)
     {
         sci.SetIndicFore(indicator, lang.editorstyle.DisabledLineBack);
     }
     sci.SetIndicStyle(indicator, 7);
     sci.CurrentIndicator = indicator;
     sci.IndicatorValue = value;
     sci.IndicatorFillRange(start, length);
     sci.StartStyling(es, mask);
 }
开发者ID:thecocce,项目名称:flashdevelop,代码行数:34,代码来源:ScintillaHelper.cs

示例2: AddSquiggles

 private void AddSquiggles(ScintillaControl sci, int line, int start, int end)
 {
     if (sci == null) return;
     fileWithSquiggles = CurrentFile;
     int position = sci.PositionFromLine(line) + start;
     sci.AddHighlight(2, (int)IndicatorStyle.Squiggle, 0x000000ff, position, end - start);
 }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:7,代码来源:Context.cs

示例3: ApplyOpenParams

 /// <summary>
 /// 
 /// </summary>        
 private void ApplyOpenParams(Match openParams, ScintillaControl sci)
 {
     if (sci == null) return;
     Int32 col = 0;
     Int32 line = Math.Min(sci.LineCount - 1, Math.Max(0, Int32.Parse(openParams.Groups[1].Value) - 1));
     if (openParams.Groups.Count > 3 && openParams.Groups[3].Value.Length > 0)
     {
         col = Int32.Parse(openParams.Groups[3].Value);
     }
     Int32 position = sci.PositionFromLine(line) + col;
     sci.SetSel(position, position);
 }
开发者ID:heon21st,项目名称:flashdevelop,代码行数:15,代码来源:MainForm.cs

示例4: AddLookupPosition

 private static void AddLookupPosition(ScintillaControl sci)
 {
     if (lookupPosition >= 0 && sci != null)
     {
         int lookupLine = sci.LineFromPosition(lookupPosition);
         int lookupCol = lookupPosition - sci.PositionFromLine(lookupLine);
         // TODO: Refactor, doesn't make a lot of sense to have this feature inside the Panel
         ASContext.Panel.SetLastLookupPosition(sci.FileName, lookupLine, lookupCol);
     }
 }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:10,代码来源:ASGenerator.cs

示例5: GenerateOverride

        static public void GenerateOverride(ScintillaControl Sci, ClassModel ofClass, MemberModel member, int position)
        {
            ContextFeatures features = ASContext.Context.Features;
            List<string> typesUsed = new List<string>();
            bool isProxy = (member.Namespace == "flash_proxy");
            if (isProxy) typesUsed.Add("flash.utils.flash_proxy");
            bool isAS2Event = ASContext.Context.Settings.LanguageId == "AS2" && member.Name.StartsWithOrdinal("on");
            bool isObjectMethod = ofClass.QualifiedName == "Object";

            int line = Sci.LineFromPosition(position);
            string currentText = Sci.GetLine(line);
            int startPos = currentText.Length;
            GetStartPos(currentText, ref startPos, features.privateKey);
            GetStartPos(currentText, ref startPos, features.protectedKey);
            GetStartPos(currentText, ref startPos, features.internalKey);
            GetStartPos(currentText, ref startPos, features.publicKey);
            GetStartPos(currentText, ref startPos, features.staticKey);
            GetStartPos(currentText, ref startPos, features.overrideKey);
            startPos += Sci.PositionFromLine(line);

            FlagType flags = member.Flags;
            string acc = "";
            string decl = "";
            if (features.hasNamespaces && !string.IsNullOrEmpty(member.Namespace) && member.Namespace != "internal")
                acc = member.Namespace;
            else if ((member.Access & Visibility.Public) > 0) acc = features.publicKey;
            else if ((member.Access & Visibility.Internal) > 0) acc = features.internalKey;
            else if ((member.Access & Visibility.Protected) > 0) acc = features.protectedKey;
            else if ((member.Access & Visibility.Private) > 0 && features.methodModifierDefault != Visibility.Private) 
                acc = features.privateKey;

            bool isStatic = (flags & FlagType.Static) > 0;
            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;
                    }
                }
//.........这里部分代码省略.........
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:101,代码来源: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: FindNewVarPosition

        private static int FindNewVarPosition(ScintillaControl sci, ClassModel inClass, MemberModel latest)
        {
            firstVar = false;
            // found a var?
            if ((latest.Flags & FlagType.Variable) > 0)
                return sci.PositionFromLine(latest.LineTo + 1) - ((sci.EOLMode == 0) ? 2 : 1);

            // add as first member
            int line = 0;
            int maxLine = sci.LineCount;
            if (inClass != null)
            {
                line = inClass.LineFrom;
                maxLine = inClass.LineTo;
            }
            else if (ASContext.Context.InPrivateSection) line = ASContext.Context.CurrentModel.PrivateSectionIndex;
            else maxLine = ASContext.Context.CurrentModel.PrivateSectionIndex;
            while (line < maxLine)
            {
                string text = sci.GetLine(line++);
                if (text.IndexOf('{') >= 0)
                {
                    firstVar = true;
                    return sci.PositionFromLine(line) - ((sci.EOLMode == 0) ? 2 : 1);
                }
            }
            return -1;
        }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:28,代码来源:ASGenerator.cs

示例8: GenerateFunctionJob

        private static void GenerateFunctionJob(GeneratorJobType job, ScintillaControl sci, MemberModel member,
            bool detach, ClassModel inClass)
        {
            int position = 0;
            MemberModel latest = null;
            bool isOtherClass = false;

            Visibility funcVisi = job.Equals(GeneratorJobType.FunctionPublic) ? Visibility.Public : GetDefaultVisibility(inClass);
            int wordPos = sci.WordEndPosition(sci.CurrentPos, true);
            List<FunctionParameter> functionParameters = ParseFunctionParameters(sci, wordPos);

            // evaluate, if the function should be generated in other class
            ASResult funcResult = ASComplete.GetExpressionType(sci, sci.WordEndPosition(sci.CurrentPos, true));

            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)
                {
                    if (contextOwnerResult.Member == null && contextOwnerResult.Type != null)
                    {
                        isStatic.Flags |= FlagType.Static;
                    }
                }
            }
            else if (member != null && (member.Flags & FlagType.Static) > 0)
            {
                isStatic.Flags |= FlagType.Static;
            }


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

                ASContext.MainForm.OpenEditableDocument(funcResult.RelClass.InFile.FileName, true);
                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(funcResult.RelClass.QualifiedName))
                    {
                        funcResult.RelClass = cm;
                        break;
                    }
                }
                inClass = funcResult.RelClass;

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

            string blockTmpl = null;
            if ((isStatic.Flags & FlagType.Static) > 0)
            {
                blockTmpl = TemplateUtils.GetBoundary("StaticMethods");
            }
            else if ((funcVisi & Visibility.Public) > 0)
            {
                blockTmpl = TemplateUtils.GetBoundary("PublicMethods");
            }
            else
            {
                blockTmpl = TemplateUtils.GetBoundary("PrivateMethods");
            }
            latest = TemplateUtils.GetTemplateBlockMember(sci, blockTmpl);
            if (latest == null || (!isOtherClass && member == null))
            {
                latest = GetLatestMemberForFunction(inClass, funcVisi, isStatic);

                // if we generate function in current class..
                if (!isOtherClass)
                {
                    MethodsGenerationLocations location = ASContext.CommonSettings.MethodsGenerationLocations;
                    if (member == null)
                    {
                        detach = false;
                        lookupPosition = -1;
                        position = sci.WordStartPosition(sci.CurrentPos, true);
                        sci.SetSel(position, sci.WordEndPosition(position, true));
                    }
                    else if (latest != null && location == MethodsGenerationLocations.AfterSimilarAccessorMethod)
                    {
                        position = sci.PositionFromLine(latest.LineTo + 1) - ((sci.EOLMode == 0) ? 2 : 1);
                        sci.SetSel(position, position);
                    }
                    else
                    {
                        position = sci.PositionFromLine(member.LineTo + 1) - ((sci.EOLMode == 0) ? 2 : 1);
                        sci.SetSel(position, position);
                    }
                }
//.........这里部分代码省略.........
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:101,代码来源:ASGenerator.cs

示例9: RemoveHighlight

 /// <summary>
 /// 
 /// </summary>
 public static void RemoveHighlight(ScintillaControl sci, Int32 line, Int32 indicator)
 {
     if (sci == null) return;
     Int32 start = sci.PositionFromLine(line);
     Int32 length = sci.LineLength(line);
     if (start < 0 || length < 1) return;
     Int32 es = sci.EndStyled;
     Int32 mask = (1 << sci.StyleBits) - 1;
     Language lang = PluginBase.MainForm.SciConfig.GetLanguage(sci.ConfigurationLanguage);
     if (indicator == indicatorDebugCurrentLine)
     {
         sci.SetIndicFore(indicator, lang.editorstyle.DebugLineBack);
         sci.SetIndicSetAlpha(indicator, 40); // Improve contrast
     }
     else if (indicator == indicatorDebugEnabledBreakpoint)
     {
         sci.SetIndicFore(indicator, lang.editorstyle.ErrorLineBack);
         sci.SetIndicSetAlpha(indicator, 40); // Improve contrast
     }
     else if (indicator == indicatorDebugDisabledBreakpoint)
     {
         sci.SetIndicFore(indicator, lang.editorstyle.DisabledLineBack);
         sci.SetIndicSetAlpha(indicator, 40); // Improve contrast
     }
     sci.SetIndicStyle(indicator, 7);
     sci.CurrentIndicator = indicator;
     sci.IndicatorClearRange(start, length);
     sci.StartStyling(es, mask);
 }
开发者ID:ImaginationSydney,项目名称:flashdevelop,代码行数:32,代码来源:ScintillaHelper.cs

示例10: OnChar

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

            Char c = ' ';
            DataEvent de;
            switch (value)
            {
                case 10:
                    // Shift+Enter to insert <BR/>
                    Int32 line = sci.LineFromPosition(position);
                    if (Control.ModifierKeys == Keys.Shift)
                    {
                        ctag = GetXMLContextTag(sci, position);
                        if (ctag.Tag == null || ctag.Tag.EndsWith(">"))
                        {
                            int start = sci.PositionFromLine(line)-((sci.EOLMode == 0)? 2:1);
                            sci.SetSel(start, position);
                            sci.ReplaceSel((PluginSettings.UpperCaseHtmlTags) ? "<BR/>" : "<br/>");
                            sci.SetSel(start+5, start+5);
                            return;
                        }
                    }
                    if (PluginSettings.SmartIndenter)
                    {
                        // 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

示例11: DeclarationLookupResult

 /// <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 ASResult DeclarationLookupResult(ScintillaControl Sci, int position)
 {
     if (!ASContext.Context.IsFileValid || (Sci == null)) return null;
     // get type at cursor position
     ASResult result = ASComplete.GetExpressionType(Sci, position);
     if (result.IsPackage) return result;
     // open source and show declaration
     if (!result.IsNull())
     {
         if (result.Member != null && (result.Member.Flags & FlagType.AutomaticVar) > 0) return null;
         FileModel model = result.InFile ?? ((result.Member != null && result.Member.InFile != null) ? result.Member.InFile : null) ?? ((result.Type != null) ? result.Type.InFile : null);
         if (model == null || model.FileName == "") return null;
         ClassModel inClass = result.InClass ?? result.Type;
         // for Back command
         int lookupLine = Sci.CurrentLine;
         int lookupCol = Sci.CurrentPos - Sci.PositionFromLine(lookupLine);
         ASContext.Panel.SetLastLookupPosition(ASContext.Context.CurrentFile, lookupLine, lookupCol);
         // open the file
         if (model != ASContext.Context.CurrentModel)
         {
             if (model.FileName.Length > 0 && File.Exists(model.FileName))
             {
                 ASContext.MainForm.OpenEditableDocument(model.FileName, false);
             }
             else
             {
                 ASComplete.OpenVirtualFile(model);
                 result.InFile = ASContext.Context.CurrentModel;
                 if (result.InFile == null) return null;
                 if (inClass != null)
                 {
                     inClass = result.InFile.GetClassByName(inClass.Name);
                     if (result.Member != null) result.Member = inClass.Members.Search(result.Member.Name, 0, 0);
                 }
                 else if (result.Member != null)
                 {
                     result.Member = result.InFile.Members.Search(result.Member.Name, 0, 0);
                 }
             }
         }
         if ((inClass == null || inClass.IsVoid()) && result.Member == null) return null;
         Sci = ASContext.CurSciControl;
         if (Sci == null) return null;
         int line = 0;
         string name = null;
         bool isClass = false;
         // member
         if (result.Member != null && result.Member.LineFrom > 0)
         {
             line = result.Member.LineFrom;
             name = result.Member.Name;
         }
         // class declaration
         else if (inClass.LineFrom > 0)
         {
             line = inClass.LineFrom;
             name = inClass.Name;
             isClass = true;
             // constructor
             foreach (MemberModel member in inClass.Members)
             {
                 if ((member.Flags & FlagType.Constructor) > 0)
                 {
                     line = member.LineFrom;
                     name = member.Name;
                     isClass = false;
                     break;
                 }
             }
         }
         if (line > 0) // select
         {
             if (isClass) ASComplete.LocateMember("(class|interface)", name, line);
             else ASComplete.LocateMember("(function|var|const|get|set|property|[,(])", name, line);
         }
         return result;
     }
     return null;
 }
开发者ID:CamWiseOwl,项目名称:flashdevelop,代码行数:83,代码来源:RefactoringHelper.cs

示例12: RemoveHighlight

        /// <summary>
        /// 
        /// </summary>
		static public void RemoveHighlight(ScintillaControl sci, Int32 line, Int32 indicator)
		{
			if (sci == null)
				return;

			Int32 start = sci.PositionFromLine(line);

			Int32 length = sci.LineLength(line);
			if (start < 0 || length < 1)
			{
				return;
			}

			// Remember previous EndStyled marker and restore it when we are done.
			Int32 es = sci.EndStyled;
			// Mask for style bits used for restore.
			Int32 mask = (1 << sci.StyleBits) - 1;

			if (indicator == indicatorDebugCurrentLine)
			{
				sci.SetIndicFore(indicator, DataConverter.ColorToInt32(PluginMain.settingObject.DebugLineColor));
			}
			else if (indicator == indicatorDebugEnabledBreakpoint)
			{
				sci.SetIndicFore(indicator, DataConverter.ColorToInt32(PluginMain.settingObject.BreakPointEnableLineColor));
			}
			else if (indicator == indicatorDebugDisabledBreakpoint)
			{
				sci.SetIndicFore(indicator, DataConverter.ColorToInt32(PluginMain.settingObject.BreakPointDisableLineColor));
			}
			sci.SetIndicStyle(indicator, /* (int)ScintillaNet.Enums.IndicatorStyle.RoundBox */ 7);
			sci.CurrentIndicator = indicator;
			sci.IndicatorClearRange(start, length);
			sci.StartStyling(es, mask);
		}
开发者ID:heon21st,项目名称:flashdevelop,代码行数:38,代码来源:ScintillaHelper.cs

示例13: OnChar

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

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

示例14: MakeTextFromSnippet

        public string MakeTextFromSnippet(ScintillaControl sci, AbbrevationSnippet abbrSnippet)
        {
            StringBuilder sbSnippet = new StringBuilder(abbrSnippet.Snippet);

            if (isMonitoring)
                DeactiveMonitorWords();

            if(abbrSnippet.HasImport)
            imports = new List<string>();
            if (abbrSnippet.HasEventHandler)
            eventsHandler = new List<int>();
            if (abbrSnippet.HasAfterCurrentMember)
            AfterCurrentMember = new List<string>();

            _dictCustomList = _setting.customList;

            int pos = sci.CurrentPos;
            int CodePage = sci.CodePage;

            string nl = ASCompletion.Completion.ASComplete.GetNewLineMarker(sci.EOLMode);
            int curLine = sci.LineFromPosition(pos);
            int startLine = sci.PositionFromLine(curLine);

            char ch = (char) sci.CharAt(startLine);
            string tabString = String.Empty;
            while ( Char.IsWhiteSpace( ch))
            {
                if(ch=='\n' || ch=='\r') break;
                tabString += ch;

                ch = (char)sci.CharAt(++startLine);
            }

             sbSnippet.Replace("\r","");
             sbSnippet.Replace("\n", nl + tabString);

             if (abbrSnippet.Arguments == null) return sbSnippet.ToString();

                previousLenPlace = 0;
                indexArgument = 0;
                numCursors = 0;

             MatchCollection mtc = _vocabularyArgument.regArguments.Matches(sbSnippet.ToString());
             int lenght = mtc.Count;
             Match m =null;
             Match var;

             string textClipBoard = "";
             int valueTextClipBoard = 0;

             char[] chars = null;
             int previousPos=0;
             for (int i = 0; i < lenght; i++)
             {
                  m = mtc[i];

                  /// if CodePage is 65001... pos= is position in scintilla text
                  /// and previousLen is position on abbrSnippet
                  if (indexArgument == abbrSnippet.Arguments.Length)
                  {
                      indexArgument = 0;

                          lsVar.Clear();

                  }

                  switch (abbrSnippet.Arguments[indexArgument])
                  {
                      #region Place
                      case WordTypes.place:
                          var = _vocabularyArgument.regPlace.Match(m.Value);
                          if (var.Success)
                          {
                              WordRegion wr = new WordRegion();

                              int correctPosString = m.Index - previousLenPlace;

                              int count = correctPosString - previousPos;
                              chars = new char[count];

                              sbSnippet.CopyTo(previousPos, chars, 0, count);
                              previousLenPlace += m.Length - var.Length;
                              sbSnippet.Remove(correctPosString, m.Length);
                              sbSnippet.Insert(correctPosString, var.Value);

                              previousPos = correctPosString + var.Length;

                              if (CodePage != 65001)
                              {
                                  wr.startWord = pos + chars.Length;
                                  wr.endWord = wr.startWord + var.Length;
                                  pos += chars.Length + var.Length;
                              }
                              else
                              {

                                  int strLen = Encoding.UTF8.GetByteCount(
                                      chars
                                      );
                                  int valueLen = Encoding.UTF8.GetByteCount(var.Value);
//.........这里部分代码省略.........
开发者ID:fordream,项目名称:wanghe-project,代码行数:101,代码来源:CreateWords.cs

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


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