internal TextBufferLocation(TextLine line, int index, int lineNumber, TextBuffer buffer) { this._line = line; this._columnIndex = index; this._lineIndex = lineNumber; this._buffer = buffer; }
public PlainTextViewCommandHandler(TextView view, TextBuffer buffer) { this._view = view; this._buffer = buffer; this._newLineTextList = new ArrayList(2); this._newLineTextList.Add(new char[0]); this._newLineTextList.Add(new char[0]); }
string IEventBindingService.CreateUniqueMethodName(IComponent component, EventDescriptor e) { TextBuffer buffer; ICodeBehindDocumentLanguage codeDocumentLanguage = this.GetCodeDocumentLanguage() as ICodeBehindDocumentLanguage; if (codeDocumentLanguage == null) { return string.Empty; } IMultiViewDocumentWindow documentWindow = this.GetDocumentWindow(); CodeView codeView = this.GetCodeView(documentWindow); if (codeView.Text.Length != 0) { buffer = codeView.Buffer; } else { IDocumentWithCode code = base.Component as IDocumentWithCode; buffer = new TextBuffer(code.Code.Text); } return codeDocumentLanguage.GenerateEventHandlerName(buffer, component, e); }
internal TextView(TextControl owner, TextBuffer buffer, TextManager manager) { this._textManager = manager; this._owner = owner; this._buffer = buffer; this._location = this._buffer.CreateTextBufferLocation(); this._location.LocationChanged += new EventHandler(this.OnLocationChanged); this._selectionStart = this._buffer.CreateTextBufferLocation(); this._selectionEnd = this._buffer.CreateTextBufferLocation(); this._buffer.TextBufferChanged += new TextBufferEventHandler(this.OnTextBufferChanged); base.SetStyle(ControlStyles.UserPaint, true); base.SetStyle(ControlStyles.AllPaintingInWmPaint, true); base.SetStyle(ControlStyles.Opaque, true); base.SetStyle(ControlStyles.DoubleBuffer, true); base.SetStyle(ControlStyles.ResizeRedraw, true); this._horizontalScrollBar = new HScrollBar(); this._horizontalScrollBar.Cursor = Cursors.Arrow; this._horizontalScrollBar.Scroll += new ScrollEventHandler(this.OnHorizontalScrollBarScroll); if (this._buffer.MaxLine != null) { this._viewMaxLineLength = this.GetViewIndex(this._buffer.MaxLine, this._buffer.MaxLineLength); } else { this._viewMaxLineLength = 0; } this._horizontalScrollBar.Maximum = this._viewMaxLineLength; this._verticalScrollBar = new VScrollBar(); this._verticalScrollBar.Cursor = Cursors.Arrow; this._verticalScrollBar.Scroll += new ScrollEventHandler(this.OnVerticalScrollBarScroll); this._verticalScrollBar.Maximum = this._buffer.LineCount; this.Cursor = Cursors.IBeam; this._viewTopLineNumber = 0; this._caretWidth = 2; this._insertMode = true; base.Controls.Add(this._verticalScrollBar); base.Controls.Add(this._horizontalScrollBar); this.AddCommandHandler(new PlainTextViewCommandHandler(this, this._buffer)); this.AllowDrop = true; }
string ICodeBehindDocumentLanguage.GenerateEventHandlerName(TextBuffer buffer, IComponent component, EventDescriptor eventDescriptor) { bool flag = false; if (buffer == null) { throw new ArgumentNullException("buffer"); } if (component == null) { throw new ArgumentNullException("component"); } if (component.Site == null) { throw new ArgumentException("Invalid component", "component"); } if (eventDescriptor == null) { throw new ArgumentNullException("eventDescriptor"); } string str = component.Site.Name + "_" + eventDescriptor.Name; ArrayList eventHandlers = (ArrayList) ((ICodeBehindDocumentLanguage) this).GetEventHandlers(buffer, eventDescriptor); if (eventHandlers.Count == 0) { return str; } string item = str; int num = 0; do { if (eventHandlers.Contains(item)) { num++; item = str + "_" + num; } } while (!flag); return item; }
int ICodeBehindDocumentLanguage.GenerateEventHandler(TextBuffer buffer, string methodName, EventDescriptor eventDescriptor, out bool existing) { if (buffer == null) { throw new ArgumentNullException("buffer"); } if ((methodName == null) || (methodName.Length == 0)) { throw new ArgumentNullException("methodName"); } if (eventDescriptor == null) { throw new ArgumentNullException("eventDescriptor"); } existing = false; int num = -1; string searchString = "void " + methodName; using (TextBufferSpan span = buffer.Find(searchString, true, false, false)) { if (span != null) { num = span.Start.LineIndex + 1; existing = true; return num; } string str2 = eventDescriptor.EventType.Name.Replace("EventHandler", "EventArgs"); string s = searchString + "(object sender, " + str2 + " e) {\n\n}"; TextBufferLocation location = buffer.CreateLastCharacterLocation(); if (location.Line.Length != 0) { s = "\n\n" + s; } buffer.InsertText(location, s); num = location.LineIndex - 1; location.Dispose(); } return num; }
ICollection IEventBindingService.GetCompatibleMethods(EventDescriptor e) { TextBuffer buffer; ICodeBehindDocumentLanguage codeDocumentLanguage = this.GetCodeDocumentLanguage() as ICodeBehindDocumentLanguage; if (codeDocumentLanguage == null) { return new string[0]; } IMultiViewDocumentWindow documentWindow = this.GetDocumentWindow(); CodeView codeView = this.GetCodeView(documentWindow); if (codeView.Text.Length != 0) { buffer = codeView.Buffer; } else { IDocumentWithCode component = base.Component as IDocumentWithCode; buffer = new TextBuffer(component.Code.Text); } return codeDocumentLanguage.GetEventHandlers(buffer, e); }
ICollection ICodeBehindDocumentLanguage.GetEventHandlers(TextBuffer buffer, EventDescriptor eventDescriptor) { if (buffer == null) { throw new ArgumentNullException("buffer"); } if (eventDescriptor == null) { throw new ArgumentNullException("eventDescriptor"); } ArrayList list = new ArrayList(); string str = eventDescriptor.EventType.Name.Replace("EventHandler", "EventArgs"); Regex regex = new Regex(@"void (?<handlerMethodName>[a-z_]\w*)\s*\(\s*object\s*[a-z_]\w*\s*,\s*" + str + @"\s*[a-z_]\w*\s*\)", RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase); foreach (Match match in regex.Matches(buffer.Text)) { list.Add(match.Groups["handlerMethodName"].ToString()); } return list; }
public void AddUndoUnit(TextBuffer.UndoUnit unit) { this.UndoList.Add(unit); }