亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? csharpformattingstrategy.cs

?? SharpDevelop2.0.0 c#開發免費工具
?? CS
?? 第 1 頁 / 共 2 頁
字號:
// <file>
//     <copyright see="prj:///doc/copyright.txt"/>
//     <license see="prj:///doc/license.txt"/>
//     <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
//     <version>$Revision: 1430 $</version>
// </file>

using System;
using System.IO;
using System.Collections;
using System.Diagnostics;
using System.Drawing;
using System.Text;

using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Actions;
using ICSharpCode.TextEditor.Document;
using ICSharpCode.Core;

namespace CSharpBinding.FormattingStrategy
{
	/// <summary>
	/// This class handles the auto and smart indenting in the textbuffer while
	/// you type.
	/// </summary>
	public class CSharpFormattingStrategy : DefaultFormattingStrategy
	{
		public CSharpFormattingStrategy()
		{
		}
		
		#region SmartIndentLine
		/// <summary>
		/// Define CSharp specific smart indenting for a line :)
		/// </summary>
		protected override int SmartIndentLine(TextArea textArea, int lineNr)
		{
			if (lineNr <= 0) {
				return AutoIndentLine(textArea, lineNr);
			}
			
			string oldText = textArea.Document.GetText(textArea.Document.GetLineSegment(lineNr));
			
			DocumentAccessor acc = new DocumentAccessor(textArea.Document, lineNr, lineNr);
			
			IndentationSettings set = new IndentationSettings();
			set.IndentString = Tab.GetIndentationString(textArea.Document);
			set.LeaveEmptyLines = false;
			IndentationReformatter r = new IndentationReformatter();
			
			r.Reformat(acc, set);
			
			if (acc.ChangedLines > 0)
				textArea.Document.UndoStack.UndoLast(2);
			
			string t = acc.Text;
			if (t.Length == 0) {
				// use AutoIndentation for new lines in comments / verbatim strings.
				return AutoIndentLine(textArea, lineNr);
			} else {
				int newIndentLength = t.Length - t.TrimStart().Length;
				int oldIndentLength = oldText.Length - oldText.TrimStart().Length;
				if (oldIndentLength != newIndentLength && lineNr == textArea.Caret.Position.Y) {
					// fix cursor position if indentation was changed
					int newX = textArea.Caret.Position.X - oldIndentLength + newIndentLength;
					textArea.Caret.Position = new Point(Math.Max(newX, 0), lineNr);
				}
				return newIndentLength;
			}
		}
		
		/// <summary>
		/// This function sets the indentlevel in a range of lines.
		/// </summary>
		public override void IndentLines(TextArea textArea, int begin, int end)
		{
			if (textArea.Document.TextEditorProperties.IndentStyle != IndentStyle.Smart) {
				base.IndentLines(textArea, begin, end);
				return;
			}
			int cursorPos = textArea.Caret.Position.Y;
			int oldIndentLength = 0;
			
			if (cursorPos >= begin && cursorPos <= end)
				oldIndentLength = GetIndentation(textArea, cursorPos).Length;
			
			IndentationSettings set = new IndentationSettings();
			set.IndentString = Tab.GetIndentationString(textArea.Document);
			IndentationReformatter r = new IndentationReformatter();
			DocumentAccessor acc = new DocumentAccessor(textArea.Document, begin, end);
			r.Reformat(acc, set);
			
			if (cursorPos >= begin && cursorPos <= end) {
				int newIndentLength = GetIndentation(textArea, cursorPos).Length;
				if (oldIndentLength != newIndentLength) {
					// fix cursor position if indentation was changed
					int newX = textArea.Caret.Position.X - oldIndentLength + newIndentLength;
					textArea.Caret.Position = new Point(Math.Max(newX, 0), cursorPos);
				}
			}
			
			if (acc.ChangedLines > 0)
				textArea.Document.UndoStack.UndoLast(acc.ChangedLines);
		}
		#endregion
		
		#region Private functions
		bool NeedCurlyBracket(string text)
		{
			int curlyCounter = 0;
			
			bool inString = false;
			bool inChar   = false;
			bool verbatim = false;
			
			bool lineComment  = false;
			bool blockComment = false;
			
			for (int i = 0; i < text.Length; ++i) {
				switch (text[i]) {
					case '\r':
					case '\n':
						lineComment = false;
						inChar = false;
						if (!verbatim) inString = false;
						break;
					case '/':
						if (blockComment) {
							Debug.Assert(i > 0);
							if (text[i - 1] == '*') {
								blockComment = false;
							}
						}
						if (!inString && !inChar && i + 1 < text.Length) {
							if (!blockComment && text[i + 1] == '/') {
								lineComment = true;
							}
							if (!lineComment && text[i + 1] == '*') {
								blockComment = true;
							}
						}
						break;
					case '"':
						if (!(inChar || lineComment || blockComment)) {
							if (inString && verbatim) {
								if (i + 1 < text.Length && text[i + 1] == '"') {
									++i; // skip escaped quote
									inString = false; // let the string go on
								} else {
									verbatim = false;
								}
							} else if (!inString && i > 0 && text[i - 1] == '@') {
								verbatim = true;
							}
							inString = !inString;
						}
						break;
					case '\'':
						if (!(inString || lineComment || blockComment)) {
							inChar = !inChar;
						}
						break;
					case '{':
						if (!(inString || inChar || lineComment || blockComment)) {
							++curlyCounter;
						}
						break;
					case '}':
						if (!(inString || inChar || lineComment || blockComment)) {
							--curlyCounter;
						}
						break;
					case '\\':
						if ((inString && !verbatim) || inChar)
							++i; // skip next character
						break;
				}
			}
			return curlyCounter > 0;
		}
		
		
		bool IsInsideStringOrComment(TextArea textArea, LineSegment curLine, int cursorOffset)
		{
			// scan cur line if it is inside a string or single line comment (//)
			bool insideString  = false;
			char stringstart = ' ';
			bool verbatim = false; // true if the current string is verbatim (@-string)
			char c = ' ';
			char lastchar;
			
			for (int i = curLine.Offset; i < cursorOffset; ++i) {
				lastchar = c;
				c = textArea.Document.GetCharAt(i);
				if (insideString) {
					if (c == stringstart) {
						if (verbatim && i + 1 < cursorOffset && textArea.Document.GetCharAt(i + 1) == '"') {
							++i; // skip escaped character
						} else {
							insideString = false;
						}
					} else if (c == '\\' && !verbatim) {
						++i; // skip escaped character
					}
				} else if (c == '/' && i + 1 < cursorOffset && textArea.Document.GetCharAt(i + 1) == '/') {
					return true;
				} else if (c == '"' || c == '\'') {
					stringstart = c;
					insideString = true;
					verbatim = (c == '"') && (lastchar == '@');
				}
			}
			
			return insideString;
		}
		
		bool IsInsideDocumentationComment(TextArea textArea, LineSegment curLine, int cursorOffset)
		{
			for (int i = curLine.Offset; i < cursorOffset; ++i) {
				char ch = textArea.Document.GetCharAt(i);
				if (ch == '"') {
					// parsing strings correctly is too complicated (see above),
					// but I don't now any case where a doc comment is after a string...
					return false;
				}
				if (ch == '/' && i + 2 < cursorOffset && textArea.Document.GetCharAt(i + 1) == '/' && textArea.Document.GetCharAt(i + 2) == '/') {
					return true;
				}
			}
			return false;
		}
		
		/// <summary>
		/// Gets the next member after the specified caret position.
		/// </summary>
		object GetMemberAfter(TextArea textArea, int caretLine)
		{
			string fileName = textArea.MotherTextEditorControl.FileName;
			object nextElement = null;
			if (fileName != null && fileName.Length > 0 ) {
				ParseInformation parseInfo = ParserService.ParseFile(fileName, textArea.Document.TextContent);
				if (parseInfo != null) {
					ICompilationUnit currentCompilationUnit = parseInfo.BestCompilationUnit;
					if (currentCompilationUnit != null) {
						IClass currentClass = currentCompilationUnit.GetInnermostClass(caretLine, 0);
						int nextElementLine = int.MaxValue;
						if (currentClass == null) {
							foreach (IClass c in currentCompilationUnit.Classes) {
								if (c.Region.BeginLine < nextElementLine && c.Region.BeginLine > caretLine) {
									nextElementLine = c.Region.BeginLine;
									nextElement = c;
								}
							}
						} else {
							foreach (IClass c in currentClass.InnerClasses) {
								if (c.Region.BeginLine < nextElementLine && c.Region.BeginLine > caretLine) {
									nextElementLine = c.Region.BeginLine;
									nextElement = c;
								}
							}
							foreach (IMember m in currentClass.Methods) {
								if (m.Region.BeginLine < nextElementLine && m.Region.BeginLine > caretLine) {
									nextElementLine = m.Region.BeginLine;
									nextElement = m;
								}
							}
							foreach (IMember m in currentClass.Properties) {
								if (m.Region.BeginLine < nextElementLine && m.Region.BeginLine > caretLine) {
									nextElementLine = m.Region.BeginLine;
									nextElement = m;
								}
							}
							foreach (IMember m in currentClass.Fields) {
								if (m.Region.BeginLine < nextElementLine && m.Region.BeginLine > caretLine) {
									nextElementLine = m.Region.BeginLine;
									nextElement = m;
								}
							}
							foreach (IMember m in currentClass.Events) {
								if (m.Region.BeginLine < nextElementLine && m.Region.BeginLine > caretLine) {
									nextElementLine = m.Region.BeginLine;
									nextElement = m;
								}
							}
						}
					}
				}
			}
			return nextElement;
		}
		#endregion
		
		#region FormatLine
		
		bool NeedEndregion(IDocument document)
		{
			int regions = 0;
			int endregions = 0;
			foreach (LineSegment line in document.LineSegmentCollection) {
				string text = document.GetText(line).Trim();
				if (text.StartsWith("#region")) {
					++regions;
				} else if (text.StartsWith("#endregion")) {
					++endregions;
				}
			}
			return regions > endregions;
		}
		public override int FormatLine(TextArea textArea, int lineNr, int cursorOffset, char ch) // used for comment tag formater/inserter
		{
			LineSegment curLine   = textArea.Document.GetLineSegment(lineNr);
			LineSegment lineAbove = lineNr > 0 ? textArea.Document.GetLineSegment(lineNr - 1) : null;
			
			//// local string for curLine segment
			string curLineText="";
			if (ch == '/') {
				curLineText   = textArea.Document.GetText(curLine);
				string lineAboveText = lineAbove == null ? "" : textArea.Document.GetText(lineAbove);
				if (curLineText != null && curLineText.EndsWith("///") && (lineAboveText == null || !lineAboveText.Trim().StartsWith("///"))) {
					string indentation = base.GetIndentation(textArea, lineNr);
					object member = GetMemberAfter(textArea, lineNr);
					if (member != null) {
						StringBuilder sb = new StringBuilder();
						sb.Append(" <summary>\n");
						sb.Append(indentation);
						sb.Append("/// \n");
						sb.Append(indentation);
						sb.Append("/// </summary>");
						
						if (member is IMethod) {
							IMethod method = (IMethod)member;
							if (method.Parameters != null && method.Parameters.Count > 0) {
								for (int i = 0; i < method.Parameters.Count; ++i) {
									sb.Append("\n");
									sb.Append(indentation);
									sb.Append("/// <param name=\"");
									sb.Append(method.Parameters[i].Name);
									sb.Append("\"></param>");
								}
							}
							if (method.ReturnType != null && !method.IsConstructor && method.ReturnType.FullyQualifiedName != "System.Void") {
								sb.Append("\n");
								sb.Append(indentation);
								sb.Append("/// <returns></returns>");
							}
						}
						textArea.Document.Insert(cursorOffset, sb.ToString());
						
						textArea.Refresh();
						textArea.Caret.Position = textArea.Document.OffsetToPosition(cursorOffset + indentation.Length + "/// ".Length + " <summary>\n".Length);
						return 0;
					}
				}
				return 0;
			}
			
			if (ch != '\n' && ch != '>') {
				if (IsInsideStringOrComment(textArea, curLine, cursorOffset)) {
					return 0;
				}
			}
			switch (ch) {
				case '>':
					if (IsInsideDocumentationComment(textArea, curLine, cursorOffset)) {
						curLineText  = textArea.Document.GetText(curLine);
						int column = textArea.Caret.Offset - curLine.Offset;
						int index = Math.Min(column - 1, curLineText.Length - 1);
						
						while (index >= 0 && curLineText[index] != '<') {
							--index;
							if(curLineText[index] == '/')
								return 0; // the tag was an end tag or already
						}
						
						if (index > 0) {
							StringBuilder commentBuilder = new StringBuilder("");
							for (int i = index; i < curLineText.Length && i < column && !Char.IsWhiteSpace(curLineText[i]); ++i) {
								commentBuilder.Append(curLineText[ i]);
							}
							string tag = commentBuilder.ToString().Trim();
							if (!tag.EndsWith(">")) {
								tag += ">";
							}
							if (!tag.StartsWith("/")) {
								textArea.Document.Insert(textArea.Caret.Offset, "</" + tag.Substring(1));
							}
						}
					}
					break;
				case ':':
				case ')':
				case ']':
					

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美丝袜第三区| 7777女厕盗摄久久久| 国产乱子伦视频一区二区三区| 日韩激情视频网站| 婷婷开心激情综合| 亚洲综合激情另类小说区| 亚洲美女一区二区三区| 亚洲精品欧美激情| 午夜久久福利影院| 日本欧美大码aⅴ在线播放| 天涯成人国产亚洲精品一区av| 亚洲大片一区二区三区| 日韩精品欧美精品| 久久99深爱久久99精品| 国产成人综合网| 成人自拍视频在线观看| 91麻豆6部合集magnet| 在线观看国产精品网站| 宅男噜噜噜66一区二区66| 日韩欧美成人一区| 国产精品拍天天在线| 亚洲乱码国产乱码精品精98午夜 | 精品免费日韩av| 久久久亚洲精品石原莉奈| 国产精品视频在线看| 一二三四社区欧美黄| 久久不见久久见免费视频7| 国产成人小视频| 91久久国产综合久久| 欧美va亚洲va| 亚洲四区在线观看| 奇米综合一区二区三区精品视频| 国产精品69毛片高清亚洲| 91蝌蚪porny九色| 欧美一区二区三区四区视频| 国产精品欧美一区喷水| 日韩1区2区日韩1区2区| 丁香六月久久综合狠狠色| 欧美在线观看视频在线| 日韩限制级电影在线观看| 中文字幕日本不卡| 麻豆精品国产91久久久久久| 91小视频免费看| 欧美一区二区日韩一区二区| 中文字幕一区三区| 美女任你摸久久| 在线观看日韩av先锋影音电影院| 国产亚洲精品aa| 日韩国产在线一| 色哟哟一区二区| 久久一区二区视频| 日本美女一区二区| 欧美中文字幕不卡| 亚洲丝袜精品丝袜在线| 国产精品一区在线| 国产欧美一区二区三区在线看蜜臀| 久久综合色之久久综合| 婷婷综合五月天| 成人午夜视频网站| 精品福利在线导航| 日韩av电影免费观看高清完整版| 91女神在线视频| 国产精品久久国产精麻豆99网站| 久久99精品一区二区三区三区| 欧美私人免费视频| 亚洲精品国产无套在线观| 成人深夜福利app| 久久一区二区三区国产精品| 久久超级碰视频| 日韩久久久久久| 久久99精品久久久| 欧美不卡视频一区| 美女mm1313爽爽久久久蜜臀| 欧美岛国在线观看| 美日韩一级片在线观看| 日韩色在线观看| 日本视频在线一区| 日韩欧美你懂的| 九色综合狠狠综合久久| 日韩欧美一级在线播放| 久久成人精品无人区| 久久天天做天天爱综合色| 久久国产免费看| 久久婷婷色综合| 成人av在线播放网址| 亚洲三级在线看| 色婷婷综合五月| 亚洲成人一区二区在线观看| 91精品国产麻豆国产自产在线 | 精品免费视频.| 国内成人自拍视频| 久久综合久久久久88| 成人免费av网站| 一个色妞综合视频在线观看| 91精品国产丝袜白色高跟鞋| 青娱乐精品视频在线| 久久久久久97三级| av电影在线观看完整版一区二区| 亚洲制服丝袜在线| 日韩丝袜美女视频| 香蕉久久夜色精品国产使用方法| 亚洲午夜一区二区| 欧美一区二区三区日韩视频| 蜜桃精品视频在线观看| 国产人成一区二区三区影院| 色就色 综合激情| 性久久久久久久久| 国产欧美一区二区精品秋霞影院 | 91猫先生在线| 亚洲线精品一区二区三区八戒| 日韩欧美黄色影院| 91看片淫黄大片一级在线观看| 日韩精品乱码av一区二区| 久久影院午夜片一区| 欧美最新大片在线看| 国产乱码精品一区二区三区忘忧草| 国产精品污污网站在线观看| 欧美另类变人与禽xxxxx| 国产成人免费视频网站高清观看视频| 自拍偷拍亚洲综合| 精品国产乱码久久| 欧美性猛交xxxx黑人交| 成人免费看的视频| 精品一区二区免费在线观看| 一区二区三区视频在线看| 久久网站热最新地址| 91精品久久久久久久91蜜桃| zzijzzij亚洲日本少妇熟睡| 日韩精品视频网站| 亚洲一区二区三区自拍| 国产精品久久久久久久午夜片| 欧美一区二区观看视频| 欧美伊人精品成人久久综合97| 成人免费毛片高清视频| 黄页视频在线91| 天天影视涩香欲综合网| 亚洲精品乱码久久久久久黑人| 久久欧美中文字幕| 精品日韩欧美在线| 日韩一区二区视频| 欧美老人xxxx18| 91色porny在线视频| 粉嫩久久99精品久久久久久夜| 免费亚洲电影在线| 日本少妇一区二区| 日本在线播放一区二区三区| 亚洲成av人影院| 亚洲小说欧美激情另类| 亚洲综合一二区| 亚洲永久精品大片| 亚洲免费av高清| 一区二区三区久久久| 亚洲精品一卡二卡| 亚洲高清三级视频| 亚州成人在线电影| 日产国产欧美视频一区精品| 免费观看久久久4p| 国产乱码一区二区三区| 国产精品99久久久久久似苏梦涵| 国产精品资源网站| 国产a精品视频| 成人免费高清视频在线观看| av网站免费线看精品| 91蝌蚪porny九色| 欧美日韩精品三区| 精品电影一区二区三区| 国产日韩欧美不卡在线| 亚洲欧美自拍偷拍| 亚洲最大色网站| 麻豆91精品视频| 高清av一区二区| 色欧美乱欧美15图片| 欧美军同video69gay| 欧美mv日韩mv国产网站app| 久久精品在线观看| 亚洲精品国产无套在线观| 日本不卡123| av电影在线观看一区| 欧美日韩亚洲综合一区 | 成人禁用看黄a在线| av在线不卡免费看| 欧美无砖砖区免费| 久久综合久久99| 亚洲精品视频一区二区| 蜜桃视频在线一区| av资源站一区| 91精品国产91综合久久蜜臀| 国产日本亚洲高清| 亚洲无人区一区| 国产一区二三区| 欧美日韩亚洲丝袜制服| 国产女同性恋一区二区| 亚洲成人资源在线| 成人精品在线视频观看| 91麻豆精品久久久久蜜臀| 国产精品美日韩| 久久99国产精品免费| 在线欧美日韩国产| 国产精品少妇自拍| 国产综合成人久久大片91|