private void SetCurrentMethod(ProcListItem item) { editor.Focus(); editor.ScrollToLine(item.StartLine); editor.TextArea.Caret.Line = item.StartLine; editor.TextArea.Caret.Column = 0; }
public IEnumerable<NewFolding> CreateNewFoldings(ITextSource document) { List<NewFolding> newFoldings = new List<NewFolding>(); _procList = new List<ProcListItem>(); int startPos = 0; int len = document.TextLength; int currentStart = 0; bool MethodIsOpen = false; string MethodName =""; string EndToken = null; int PreCommentStart = -1; //var Reader = document.CreateReader(); string FullText = document.Text; int DocLine = 0; int MethodStart = 0; const string kProcStart = "ПРОЦЕДУРА"; const string kProcEnd = "КОНЕЦПРОЦЕДУРЫ"; const string kFuncStart = "ФУНКЦИЯ"; const string kFuncEnd = "КОНЕЦФУНКЦИИ"; char[] trimArr = new char[]{' ','\t'}; do { int prev_start = startPos; string lineText = ReadLine(FullText, ref startPos); DocLine++; if (lineText == null) { break; } TextFragment tf = new TextFragment(); tf.offset = prev_start; tf.len = lineText.Length; //startPos += lineText.Length + 2; if (!MethodIsOpen) { bool CommentBreak = false; if (lineText.StartsWith("//")) { if (PreCommentStart < 0) { PreCommentStart = tf.offset + tf.len; } } else { CommentBreak = true; } if (LineIsKeyword(lineText.TrimStart(trimArr), kProcStart)) { MethodIsOpen = true; MethodName = ScanForParamList(FullText, prev_start+kProcStart.Length); EndToken = kProcEnd; MethodStart = DocLine; } else if(LineIsKeyword(lineText.TrimStart(trimArr), kFuncStart)) { MethodIsOpen = true; MethodName = ScanForParamList(FullText, prev_start + kFuncStart.Length); EndToken = kFuncEnd; MethodStart = DocLine; } if (MethodIsOpen) { currentStart = tf.offset + tf.len; if (PreCommentStart >= 0) { var Folding = new NewFolding(PreCommentStart, tf.offset-1); newFoldings.Add(Folding); PreCommentStart = -1; } } else if(CommentBreak) { PreCommentStart = -1; } } else if (LineIsKeyword(lineText.TrimStart(trimArr), EndToken)) { var Folding = new NewFolding(currentStart, tf.offset + tf.len); newFoldings.Add(Folding); if (MethodName != "") { ProcListItem pli = new ProcListItem(); pli.Name = MethodName; pli.StartLine = MethodStart; pli.EndLine = DocLine; pli.ListIndex = _procList.Count; _procList.Add(pli); MethodName = ""; } MethodIsOpen = false; } } while (true); return newFoldings; }
public IEnumerable <NewFolding> CreateNewFoldings(ITextSource document) { List <NewFolding> newFoldings = new List <NewFolding>(); _procList = new List <ProcListItem>(); int startPos = 0; int len = document.TextLength; int currentStart = 0; bool MethodIsOpen = false; string MethodName = ""; string EndToken = null; int PreCommentStart = -1; //var Reader = document.CreateReader(); string FullText = document.Text; int DocLine = 0; int MethodStart = 0; const string kProcStart = "ПРОЦЕДУРА"; const string kProcEnd = "КОНЕЦПРОЦЕДУРЫ"; const string kFuncStart = "ФУНКЦИЯ"; const string kFuncEnd = "КОНЕЦФУНКЦИИ"; char[] trimArr = new char[] { ' ', '\t' }; do { int prev_start = startPos; string lineText = ReadLine(FullText, ref startPos); DocLine++; if (lineText == null) { break; } TextFragment tf = new TextFragment(); tf.offset = prev_start; tf.len = lineText.Length; //startPos += lineText.Length + 2; if (!MethodIsOpen) { bool CommentBreak = false; if (lineText.StartsWith("//")) { if (PreCommentStart < 0) { PreCommentStart = tf.offset + tf.len; } } else { CommentBreak = true; } if (LineIsKeyword(lineText.TrimStart(trimArr), kProcStart)) { MethodIsOpen = true; MethodName = ScanForParamList(FullText, prev_start + kProcStart.Length); EndToken = kProcEnd; MethodStart = DocLine; } else if (LineIsKeyword(lineText.TrimStart(trimArr), kFuncStart)) { MethodIsOpen = true; MethodName = ScanForParamList(FullText, prev_start + kFuncStart.Length); EndToken = kFuncEnd; MethodStart = DocLine; } if (MethodIsOpen) { currentStart = tf.offset + tf.len; if (PreCommentStart >= 0) { var Folding = new NewFolding(PreCommentStart, tf.offset - 1); newFoldings.Add(Folding); PreCommentStart = -1; } } else if (CommentBreak) { PreCommentStart = -1; } } else if (LineIsKeyword(lineText.TrimStart(trimArr), EndToken)) { var Folding = new NewFolding(currentStart, tf.offset + tf.len); newFoldings.Add(Folding); if (MethodName != "") { ProcListItem pli = new ProcListItem(); pli.Name = MethodName; pli.StartLine = MethodStart; pli.EndLine = DocLine; pli.ListIndex = _procList.Count; _procList.Add(pli); MethodName = ""; } MethodIsOpen = false; } }while (true); return(newFoldings); }
private void PerformSelection(ProcListItem src) { SelectedItem = src; DialogResult = true; Close(); }