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


C# ScintillaNet.SafeBraceMatch方法代码示例

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


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

示例1: HandleStructureCompletion

		static private bool HandleStructureCompletion(ScintillaNet.ScintillaControl Sci)
		{
			try
			{
				int position = Sci.CurrentPos;
				int line = Sci.LineFromPosition(position);
				if (line == 0) 
					return false;
				string txt = Sci.GetLine(line-1);
				int style = Sci.BaseStyleAt(position);
				int eolMode = Sci.EOLMode;
				// box comments
				if (IsCommentStyle(style) && (Sci.BaseStyleAt(position+1) == style))
				{
					txt = txt.Trim();
					if (txt.StartsWith("/*") || txt.StartsWith("*"))
					{
						Sci.ReplaceSel("* ");
						position = Sci.LineIndentPosition(line)+2;
						Sci.SetSel(position,position);
						return true;
					}
				}
				// braces
				else if (txt.TrimEnd().EndsWith("{") && (line > 1))
				{
					// find matching brace
					int bracePos = Sci.LineEndPosition(line-1)-1;
					while ((bracePos > 0) && (Sci.CharAt(bracePos) != '{')) bracePos--;
					if (bracePos == 0 || Sci.BaseStyleAt(bracePos) != 10) return true;
					int match = Sci.SafeBraceMatch(bracePos);
					DebugConsole.Trace("match "+bracePos+" "+match);
					int start = line;
					int indent = Sci.GetLineIndentation(start-1);
					if (match > 0)
					{
						int endIndent = Sci.GetLineIndentation(Sci.LineFromPosition(match));
						if (endIndent+Sci.TabWidth > indent) 
							return false;
				 	}
					// find where to include the closing brace
					int startIndent = indent;
					int newIndent = indent+Sci.TabWidth;
					int count = Sci.LineCount;
					int lastLine = line;
					line++;
					while (line < count-1)
					{
						txt = Sci.GetLine(line).TrimEnd();
						if (txt.Length != 0) {
							indent = Sci.GetLineIndentation(line);
							DebugConsole.Trace("indent "+(line+1)+" "+indent+" : "+txt);
							if (indent <= startIndent) break;
							lastLine = line;
						}
						else break;
						line++;
					}
					if (line >= count-1) lastLine = start;
					
					// insert closing brace
					DebugConsole.Trace("Insert at "+position);
					position = Sci.LineEndPosition(lastLine);
					Sci.InsertText(position, ASContext.MainForm.GetNewLineMarker(eolMode)+"}");
					Sci.SetLineIndentation(lastLine+1, startIndent);
					return false;
				}
			}
			catch (Exception ex)
			{
				ErrorHandler.ShowError(ex.Message, ex);
			}
			return false;
		}
开发者ID:heon21st,项目名称:flashdevelop,代码行数:74,代码来源:ASComplete.cs


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