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


C# IVsTextView.GetBuffer方法代码示例

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


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

示例1: TextView

        public TextView(IVsTextView view)
        {
            if (view == null) throw new ArgumentNullException("view");

            try
            {
                _view = view;
                _buffer = view.GetBuffer();

                _viewEvents = new TextViewEventAdapter(view);
                _textStreamEvents = new TextStreamEventAdapter(Buffer);

                _viewEvents.ScrollChanged += ScrollChangedHandler;
                _viewEvents.GotFocus += new EventHandler<ViewFocusEventArgs>(GotFocusHandler);

                _screenUpdater = new ScreenUpdateManager(this);

                CreateWindow();

                selectionSearcher = new MarkSearcher(-1, this);
                freezer1 = new MarkSearcher(1, this);
                freezer2 = new MarkSearcher(2, this);
                freezer3 = new MarkSearcher(3, this);

                freezers = new List<MarkSearcher>();
                freezers.Add(freezer1);
                freezers.Add(freezer2);
                freezers.Add(freezer3);
            }
            catch (Exception ex)
            {
                Log.Error("Failed to create TextView", ex);
            }
        }
开发者ID:hxhlb,项目名称:wordlight,代码行数:34,代码来源:TextView.cs

示例2: OnUnregisterView

        public void OnUnregisterView(IVsTextView pView)
        {
            // It's interesting to us when a document is closed because we need this
            // information to keep track when a document is opened. Furthermore we
            // have to free all text markers.
            IVsTextLines textLines;
            ErrorHandler.ThrowOnFailure(pView.GetBuffer(out textLines));
            if (textLines == null)
                return;

            // Decrement the stored view count. This is a little bit special as we use
            // IVsTextLines instances as keys in our dictionary. That means that we
            // have to remove the whole entry from the dictionary when the counter drops
            // to zero to prevent memory leaks.
            int documentViewCount;

            if (!documentViewCounts.TryGetValue(textLines, out documentViewCount)) return;

            if (documentViewCount > 1)
            {
                // There are several open views for the same document. In this case
                // we only have to decrement the view count.
                documentViewCounts[textLines] = documentViewCount - 1;
            }
            else
            {
                // When we reach this branch the last view of a document has been
                // closed. That means we have to free the whole IVsTextLines reference
                // by removing it from the dictionary.
                documentViewCounts.Remove(textLines);

                // Notify the CloneDetectiveManager of this event.
                JiraEditorLinkManager.OnDocumentClosed(textLines);
            }
        }
开发者ID:spncrgr,项目名称:connector-idea,代码行数:35,代码来源:TextManagerEventSink.cs

示例3: VsTextViewCreated

        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            var view = textViewAdapter.ToITextView();
            var filePath = textViewAdapter.GetFilePath();

            var project = ProjectInfo.FindProject(filePath);
            if (project == null)
                return;

            var engine = project.Engine;
            if (engine.IsExtensionRegistered(Path.GetExtension(filePath))
                || engine.HasSourceChangedSubscribers(Location.GetFileIndex(filePath)))
            {
                //Trace.WriteLine("Opened: " + filePath);

                IVsTextLines vsTextLines = textViewAdapter.GetBuffer();
                var langSrv = NemerlePackage.GetGlobalService(typeof(NemerleLanguageService)) as NemerleLanguageService;
                if (langSrv == null)
                    return;
                var source = (NemerleSource)langSrv.GetOrCreateSource(vsTextLines);
              source.AddRef();
                project.AddEditableSource(source);

                if (!Utils.IsNemerleFileExtension(filePath))
                    view.TextBuffer.Changed += TextBuffer_Changed;
                view.Closed += view_Closed;
            }
        }
开发者ID:vestild,项目名称:nemerle,代码行数:28,代码来源:NemerleTextViewCreationListener.cs

示例4: GetTokenAtIndex

			/// <summary>
			/// Gets the specific token that resides at the given index.
			/// </summary>
			/// <param name="index">The index of the token to get.</param>
			/// <param name="view">The IVsTextView of the lines of source to parse.</param>
			/// <param name="service">The language service.</param>
			/// <returns>The <see cref="T:Microsoft.VisualStudio.Package.TokenInfo"/> at the index.</returns>
			public static FactTokenInfo GetTokenAtIndex(int index, IVsTextView view, FactEditorLanguageService service)
			{
				IVsTextLines lines;

				ErrorHandler.ThrowOnFailure(view.GetBuffer(out lines));

				return GetTokenAtIndex(index, lines, service);
			}
开发者ID:cjheath,项目名称:NORMA,代码行数:15,代码来源:FactEditorTokenHelper.cs

示例5: GetTokens

			/// <summary>
			/// Gets a list of tokens from the IVsTextView.
			/// </summary>
			/// <param name="view">The IVsTextLines of the lines of source to parse.</param>
			/// <param name="service">The language service.</param>
			/// <returns>A list of tokens.</returns>
			public static List<FactTokenInfo> GetTokens(IVsTextView view, FactEditorLanguageService service)
			{
				IVsTextLines lines;

				ErrorHandler.ThrowOnFailure(view.GetBuffer(out lines));

				return GetTokens(lines, service);
			}
开发者ID:cjheath,项目名称:NORMA,代码行数:14,代码来源:FactEditorTokenHelper.cs

示例6: DataTipTextViewFilter

        public DataTipTextViewFilter(System.IServiceProvider serviceProvider, IVsTextView vsTextView) {
            _debugger = (IVsDebugger)NodejsPackage.GetGlobalService(typeof(IVsDebugger));
            vsTextView.GetBuffer(out _vsTextLines);

            var editorAdaptersFactory = serviceProvider.GetComponentModel().GetService<IVsEditorAdaptersFactoryService>();
            _wpfTextView = editorAdaptersFactory.GetWpfTextView(vsTextView);

            ErrorHandler.ThrowOnFailure(vsTextView.AddCommandFilter(this, out _next));
        }
开发者ID:munyirik,项目名称:nodejstools,代码行数:9,代码来源:DataTipTextViewFilter.cs

示例7: VsTextViewCreated

        public void VsTextViewCreated(IVsTextView vsTextView)
        {
            if (vsTextView == null)
            {
                throw new ArgumentNullException(nameof(vsTextView));
            }

            IVsTextLines textLines;
            if (ErrorHandler.Failed(vsTextView.GetBuffer(out textLines)))
            {
                return;
            }

            IVsUserData userData = textLines as IVsUserData;
            if (userData == null)
            {
                return;
            }

            object monikerObj;
            Guid monikerGuid = typeof(IVsUserData).GUID;
            if (ErrorHandler.Failed(userData.GetData(ref monikerGuid, out monikerObj)))
            {
                return;
            }

            string filePath = monikerObj as string;
            uint itemId;
            uint docCookie;
            IVsHierarchy hierarchy;

            _rdt.Value.FindDocument(filePath, out hierarchy, out itemId, out docCookie);

            AbstractProject project = GetXamlProject(hierarchy);
            if (project == null)
            {
                project = new XamlProject(hierarchy, _serviceProvider, _vsWorkspace);
                _vsWorkspace.ProjectTracker.AddProject(project);
            }

            IVisualStudioHostDocument vsDocument = project.GetCurrentDocumentFromPath(filePath);
            if (vsDocument == null)
            {
                if (!TryCreateXamlDocument(project, filePath, out vsDocument))
                {
                    return;
                }

                project.AddDocument(vsDocument, isCurrentContext: true, hookupHandlers: true);
            }

            AttachRunningDocTableEvents();

            var wpfTextView = _editorAdaptersFactory.GetWpfTextView(vsTextView);
            var target = new XamlOleCommandTarget(wpfTextView, CommandHandlerServiceFactory, _editorAdaptersFactory, _serviceProvider);
            target.AttachToVsTextView();
        }
开发者ID:natidea,项目名称:roslyn,代码行数:57,代码来源:XamlTextViewCreationListener.cs

示例8: TextViewFilter

        public TextViewFilter(IServiceProvider serviceProvider, IVsTextView vsTextView) {
            var compModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
            _vsEditorAdaptersFactoryService = compModel.GetService<IVsEditorAdaptersFactoryService>();
            _debugger = (IVsDebugger)serviceProvider.GetService(typeof(IVsDebugger));

            vsTextView.GetBuffer(out _vsTextLines);
            _wpfTextView = _vsEditorAdaptersFactoryService.GetWpfTextView(vsTextView);

            ErrorHandler.ThrowOnFailure(vsTextView.AddCommandFilter(this, out _next));
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:10,代码来源:TextViewFilter.cs

示例9: DataTipTextViewFilter

        private DataTipTextViewFilter(IWpfTextView textView, IVsEditorAdaptersFactoryService adapterService, IVsDebugger debugger) {
            Trace.Assert(textView.TextBuffer.ContentType.IsOfType(RContentTypeDefinition.ContentType));

            _textView = textView;
            _debugger = debugger;

            _vsTextView = adapterService.GetViewAdapter(textView);
            _vsTextView.AddCommandFilter(this, out _nextTarget);
            _vsTextView.GetBuffer(out _vsTextLines);

            textView.Properties.AddProperty(typeof(DataTipTextViewFilter), this);
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:12,代码来源:DataTipTextViewFilter.cs

示例10: OnTypeChar

        public void OnTypeChar(IVsTextView pView, string ch)
        {
            if (ch == "{")
            {
                // add a closing "}" if it makes a complete expression or condition where one doesn't exist otherwise

                _TextSpan selection;
                pView.GetSelectionSpan(out selection);

                IVsTextLines buffer;
                pView.GetBuffer(out buffer);

                string before;
                buffer.GetLineText(0, 0, selection.iStartLine, selection.iStartIndex, out before);

                int iLastLine, iLastColumn;
                buffer.GetLastLineIndex(out iLastLine, out iLastColumn);

                string after;
                buffer.GetLineText(selection.iEndLine, selection.iEndIndex, iLastLine, iLastColumn, out after);

                var existingResult = _grammar.Nodes(new Position(new SourceContext(before + ch + after)));
                var expressionHits = existingResult.Rest.GetPaint()
                    .OfType<Paint<Node>>()
                    .Where(p => p.Begin.Offset <= before.Length && before.Length <= p.End.Offset && (p.Value is ExpressionNode || p.Value is ConditionNode));

                // if a node exists normally, do nothing
                if (expressionHits.Count() != 0)
                    return;

                var withCloseResult = _grammar.Nodes(new Position(new SourceContext(before + ch + "}" + after)));
                var withCloseHits = withCloseResult.Rest.GetPaint()
                    .OfType<Paint<Node>>()
                    .Where(p => p.Begin.Offset <= before.Length && before.Length <= p.End.Offset && (p.Value is ExpressionNode || p.Value is ConditionNode));

                // if a close brace doesn't cause a node to exist, do nothing
                if (withCloseHits.Count() == 0)
                    return;

                // add a closing } after the selection, then set the selection back to what it was
                int iAnchorLine, iAnchorCol, iEndLine, iEndCol;
                pView.GetSelection(out iAnchorLine, out iAnchorCol, out iEndLine, out iEndCol);
                _TextSpan inserted;
                buffer.ReplaceLines(selection.iEndLine, selection.iEndIndex, selection.iEndLine, selection.iEndIndex, "}", 1, out inserted);
                pView.SetSelection(iAnchorLine, iAnchorCol, iEndLine, iEndCol);
            }
        }
开发者ID:dtabuenc,项目名称:spark,代码行数:47,代码来源:SourceSupervisor.cs

示例11: VsTextViewCreated

        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            var view = textViewAdapter.ToITextView();
            var filePath = textViewAdapter.GetFilePath();

            var project = GetProjectInfo(filePath);
            if (project == null)
                return;

            //Trace.WriteLine("Opened: " + filePath);

            IVsTextLines vsTextLines = textViewAdapter.GetBuffer();
            var langSrv = NemerlePackage.GetGlobalService(typeof(NemerleLanguageService)) as NemerleLanguageService;
            if (langSrv == null)
                return;
            var source = (NemerleSource)langSrv.GetOrCreateSource(vsTextLines);
            project.AddEditableSource(source);

            view.TextBuffer.Changed += TextBuffer_Changed;
            view.Closed             += view_Closed;
        }
开发者ID:mwatts,项目名称:nemerle,代码行数:21,代码来源:NemerleTextViewCreationListener.cs

示例12: OnRegisterView

        public void OnRegisterView(IVsTextView pView)
        {
            // We have to keep track of the number of views that are currently open per
            // document. That way we can discover when a document is opened and insert
            // our custom text markers.
            IVsTextLines textLines;
            ErrorHandler.ThrowOnFailure(pView.GetBuffer(out textLines));
            if (textLines == null)
                return;

            // Increment the stored view count.
            int documentViewCount;
            documentViewCounts.TryGetValue(textLines, out documentViewCount);
            documentViewCounts[textLines] = documentViewCount + 1;

            // If this view belongs to a document that had no views before the document
            // has been opened. It's time to notify the JiraEditorLinkManager about it.
            // However there is a problem: The text buffer represented by textLines has
            // not been initialized yet, i.e. the file name is not set and the file
            // content is not loaded yet. So we need to subscribe to the text buffer to
            // get notified when the file load procedure completed.
            if (documentViewCount != 0) return;

            TextBufferDataEventSink textBufferDataEventSink = new TextBufferDataEventSink();
            IConnectionPoint connectionPoint;
            uint cookie;

            IConnectionPointContainer textBufferData = (IConnectionPointContainer)textLines;
            Guid interfaceGuid = typeof(IVsTextBufferDataEvents).GUID;
            textBufferData.FindConnectionPoint(ref interfaceGuid, out connectionPoint);
            connectionPoint.Advise(textBufferDataEventSink, out cookie);

            textBufferDataEventSink.TextLines = textLines;
            textBufferDataEventSink.ConnectionPoint = connectionPoint;
            textBufferDataEventSink.Cookie = cookie;
        }
开发者ID:spncrgr,项目名称:connector-idea,代码行数:36,代码来源:TextManagerEventSink.cs

示例13: EditBufferToInitialize

        // When the dialog is first instantiated, the IVsTextView it contains may 
        // not have been initialized, which will prevent us from using an 
        // EditorAdaptersFactoryService to get the ITextView. If we edit the IVsTextView,
        // it will initialize and we can proceed.
        private static void EditBufferToInitialize(IVsTextView adapter)
        {
            if (adapter == null)
            {
                return;
            }

            var newText = "";
            var newTextPtr = Marshal.StringToHGlobalAuto(newText);

            IVsTextLines lines;
            Marshal.ThrowExceptionForHR(adapter.GetBuffer(out lines));

            int piLIne, piLineIndex;
            Marshal.ThrowExceptionForHR(lines.GetLastLineIndex(out piLIne, out piLineIndex));

            int piLineLength;
            Marshal.ThrowExceptionForHR(lines.GetLengthOfLine(piLineIndex, out piLineLength));

            Microsoft.VisualStudio.TextManager.Interop.TextSpan[] changes = default(Microsoft.VisualStudio.TextManager.Interop.TextSpan[]);

            piLineLength = piLineLength > 0 ? piLineLength - 1 : 0;

            Marshal.ThrowExceptionForHR(lines.ReplaceLines(0, 0, piLineIndex, piLineLength, newTextPtr, newText.Length, changes));
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:29,代码来源:PreviewEngine.cs

示例14: HandleTextViewChange

        protected void HandleTextViewChange(IVsTextView textView)
        {
            IVsTextLines buffer;
            Guid bufEventGuid = typeof(IVsTextLinesEvents).GUID;
            IConnectionPointContainer container;
            IConnectionPoint cpoint;
            if (_textView != null)
            {
                _textView.GetBuffer(out buffer);
                container = buffer as IConnectionPointContainer;
                container.FindConnectionPoint(ref bufEventGuid, out cpoint);
                cpoint.Unadvise(activeCodeFileCookie);
            }
            _textView = textView;
            if (_textView != null)
            {
                _textView.GetBuffer(out buffer);
                container = buffer as IConnectionPointContainer;
                container.FindConnectionPoint(ref bufEventGuid, out cpoint);
                cpoint.Advise(this, out activeCodeFileCookie);

            }
        }
开发者ID:jijo-paulose,项目名称:bistro-framework,代码行数:23,代码来源:FileManager.cs

示例15: ScrollToEnd

 /// <include file='doc\LanguageService.uex' path='docs/doc[@for="LanguageService.ScrollToEnd2"]/*' />
 public void ScrollToEnd(IVsTextView view) {
     IVsTextLines buffer;
     NativeMethods.ThrowOnFailure(view.GetBuffer(out buffer));
     int lines;
     NativeMethods.ThrowOnFailure(buffer.GetLineCount(out lines));
     int lineHeight;
     NativeMethods.ThrowOnFailure(view.GetLineHeight(out lineHeight));
     Microsoft.VisualStudio.NativeMethods.RECT bounds = new Microsoft.VisualStudio.NativeMethods.RECT();
     NativeMethods.GetClientRect(view.GetWindowHandle(), ref bounds);
     int visibleLines = ((bounds.bottom - bounds.top) / lineHeight) - 1;
     int top = Math.Max(0, lines - visibleLines + 4);
     NativeMethods.ThrowOnFailure(view.SetTopLine(top));
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:14,代码来源:LanguageService.cs


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