本文整理汇总了C#中IVsTextBuffer类的典型用法代码示例。如果您正苦于以下问题:C# IVsTextBuffer类的具体用法?C# IVsTextBuffer怎么用?C# IVsTextBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IVsTextBuffer类属于命名空间,在下文中一共展示了IVsTextBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDataBuffer
public ITextBuffer GetDataBuffer(IVsTextBuffer bufferAdapter)
{
ITextBuffer tb = null;
_vsTextBufferAdapters.TryGetValue(bufferAdapter, out tb);
return tb;
}
示例2: VsInteractiveWindowCommandFilter
public VsInteractiveWindowCommandFilter(IVsEditorAdaptersFactoryService adapterFactory, IInteractiveWindow window, IVsTextView textViewAdapter, IVsTextBuffer bufferAdapter, IEnumerable<Lazy<IVsInteractiveWindowOleCommandTargetProvider, ContentTypeMetadata>> oleCommandTargetProviders, IContentTypeRegistryService contentTypeRegistry)
{
_window = window;
_oleCommandTargetProviders = oleCommandTargetProviders;
_contentTypeRegistry = contentTypeRegistry;
this.textViewAdapter = textViewAdapter;
// make us a code window so we'll have the same colors as a normal code window.
IVsTextEditorPropertyContainer propContainer;
ErrorHandler.ThrowOnFailure(((IVsTextEditorPropertyCategoryContainer)textViewAdapter).GetPropertyCategory(Microsoft.VisualStudio.Editor.DefGuidList.guidEditPropCategoryViewMasterSettings, out propContainer));
propContainer.SetProperty(VSEDITPROPID.VSEDITPROPID_ViewComposite_AllCodeWindowDefaults, true);
propContainer.SetProperty(VSEDITPROPID.VSEDITPROPID_ViewGlobalOpt_AutoScrollCaretOnTextEntry, true);
// editor services are initialized in textViewAdapter.Initialize - hook underneath them:
_preEditorCommandFilter = new CommandFilter(this, CommandFilterLayer.PreEditor);
ErrorHandler.ThrowOnFailure(textViewAdapter.AddCommandFilter(_preEditorCommandFilter, out _editorCommandFilter));
textViewAdapter.Initialize(
(IVsTextLines)bufferAdapter,
IntPtr.Zero,
(uint)TextViewInitFlags.VIF_HSCROLL | (uint)TextViewInitFlags.VIF_VSCROLL | (uint)TextViewInitFlags3.VIF_NO_HWND_SUPPORT,
new[] { new INITVIEW { fSelectionMargin = 0, fWidgetMargin = 0, fVirtualSpace = 0, fDragDropMove = 1 } });
// disable change tracking because everything will be changed
var textViewHost = adapterFactory.GetWpfTextViewHost(textViewAdapter);
_preLanguageCommandFilter = new CommandFilter(this, CommandFilterLayer.PreLanguage);
ErrorHandler.ThrowOnFailure(textViewAdapter.AddCommandFilter(_preLanguageCommandFilter, out _editorServicesCommandFilter));
_textViewHost = textViewHost;
}
示例3: GetNameOfLocation
public int GetNameOfLocation(IVsTextBuffer pBuffer, int iLine, int iCol, out string pbstrName, out int piLineOffset)
{
pbstrName = null;
piLineOffset = 0;
return VSConstants.E_FAIL;
//var model = _serviceProvider.GetService(typeof(SComponentModel)) as IComponentModel;
//var service = model.GetService<IVsEditorAdaptersFactoryService>();
//var buffer = service.GetDataBuffer(pBuffer);
//IAlpaProjectEntry projEntry;
//if (buffer.TryGetAlpaProjectEntry(out projEntry))
//{
// var tree = projEntry.Tree;
// var name = FindNodeInTree(tree, tree.Body as SuiteStatement, iLine);
// if (name != null)
// {
// pbstrName = projEntry.Analysis.ModuleName + "." + name;
// piLineOffset = iCol;
// }
// else
// {
// pbstrName = projEntry.Analysis.ModuleName;
// piLineOffset = iCol;
// }
// return VSConstants.S_OK;
//}
//pbstrName = "";
//piLineOffset = iCol;
//return VSConstants.S_OK;
}
示例4: PieScanner
public PieScanner(IVsTextBuffer buffer)
{
m_buffer = buffer;
grammar = new PieGrammar();
parser = new Irony.Parsing.Parser(grammar);
parser.Context.Mode = Irony.Parsing.ParseMode.VsLineScan;
}
示例5: TextStreamEventAdapter
public TextStreamEventAdapter(IVsTextBuffer buffer)
{
if (buffer == null) throw new ArgumentNullException("buffer");
var cpContainer = buffer as IConnectionPointContainer;
Guid riid = typeof(IVsTextStreamEvents).GUID;
cpContainer.FindConnectionPoint(ref riid, out _connectionPoint);
_connectionPoint.Advise(this, out _connectionCookie);
}
示例6: ValidateBreakpointLocation
public override int ValidateBreakpointLocation(IVsTextBuffer pBuffer, int iLine, int iCol, TextSpan[] pCodeSpan) {
pCodeSpan[0] = default(TextSpan);
pCodeSpan[0].iStartLine = iLine;
pCodeSpan[0].iEndLine = iLine;
// Returning E_NOTIMPL indicates that this language only supports entire-line breakpoints. Consequently,
// VS debugger will highlight the entire line when the breakpoint is active and the corresponding option
// ("Highlight entire source line for breakpoints and current statement") is set. If we returned S_OK,
// we'd have to handle this ourselves.
return VSConstants.E_NOTIMPL;
}
示例7: GetPositionsOfSpan
public static int GetPositionsOfSpan(IVsTextBuffer textStream, TextSpan ts, out int startPos, out int endPos) {
int hr;
startPos = 0;
endPos = 0;
hr = textStream.GetPositionOfLineIndex(ts.iStartLine, ts.iStartIndex, out startPos);
if (hr == VSConstants.S_OK) {
hr = textStream.GetPositionOfLineIndex(ts.iEndLine, ts.iEndIndex, out endPos);
}
return hr;
}
示例8: GetActiveView
public int GetActiveView(int fMustHaveFocus, IVsTextBuffer pBuffer, out IVsTextView ppView)
{
string fileName = ((MockTextLines)pBuffer).FileName;
if (_views.ContainsKey(fileName))
{
ppView = _views[fileName];
return VSConstants.S_OK;
}
else
{
ppView = null;
return VSConstants.E_INVALIDARG;
}
}
示例9: CreateCodeEditor
private void CreateCodeEditor()
{
Guid clsidTextBuffer = typeof(VsTextBufferClass).GUID;
Guid iidTextBuffer = VSConstants.IID_IUnknown;
TextBuffer = (IVsTextBuffer)MySqlDataProviderPackage.Instance.CreateInstance(
ref clsidTextBuffer,
ref iidTextBuffer,
typeof(object));
if (TextBuffer == null)
throw new Exception("Failed to create core editor");
// first we need to site our buffer
IObjectWithSite textBufferSite = TextBuffer as IObjectWithSite;
if (textBufferSite != null)
{
textBufferSite.SetSite(psp);
}
// then we need to tell our buffer not to attempt to autodetect the
// language settings
IVsUserData userData = TextBuffer as IVsUserData;
Guid g = EditorFactory.GuidVSBufferDetectLangSid;
int result = userData.SetData(ref g, false);
Guid clsidCodeWindow = typeof(VsCodeWindowClass).GUID;
Guid iidCodeWindow = typeof(IVsCodeWindow).GUID;
IVsCodeWindow pCodeWindow = (IVsCodeWindow)MySqlDataProviderPackage.Instance.CreateInstance(
ref clsidCodeWindow,
ref iidCodeWindow,
typeof(IVsCodeWindow));
if (pCodeWindow == null)
throw new Exception("Failed to create core editor");
// Give the text buffer to the code window.
// We are giving up ownership of the text buffer!
pCodeWindow.SetBuffer((IVsTextLines)TextBuffer);
CodeWindow = pCodeWindow;
}
示例10: IsMappedLocation
public int IsMappedLocation(IVsTextBuffer pBuffer, int iLine, int iCol) {
return VSConstants.E_FAIL;
}
示例11: GetNameOfLocation
public int GetNameOfLocation(IVsTextBuffer pBuffer, int iLine, int iCol, out string pbstrName, out int piLineOffset) {
pbstrName = null;
piLineOffset = 0;
return VSConstants.E_FAIL;
}
示例12: ValidateBreakpointLocation
public int ValidateBreakpointLocation(IVsTextBuffer pBuffer, int iLine, int iCol, TextSpan[] pCodeSpan) {
// per the docs, even if we don't intend to validate, we need to set the span info:
// http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.textmanager.interop.ivslanguagedebuginfo.validatebreakpointlocation.aspx
//
// Caution
// Even if you do not intend to support the ValidateBreakpointLocation method but your
// language does support breakpoints, you must implement this method and return a span
// that contains the specified line and column; otherwise, breakpoints cannot be set
// anywhere except line 1. You can return E_NOTIMPL to indicate that you do not otherwise
// support this method but the span must always be set.
// http://pytools.codeplex.com/workitem/787
// We were previously returning S_OK here indicating to VS that we have in fact validated
// the breakpoint. Validating breakpoints actually interacts and effectively disables
// the "Highlight entire source line for breakpoints and current statement" option as instead
// VS highlights the validated region. So we return E_NOTIMPL here to indicate that we have
// not validated the breakpoint, and then VS will happily respect the option when we're in
// design mode.
pCodeSpan[0].iStartLine = iLine;
pCodeSpan[0].iEndLine = iLine;
return VSConstants.E_NOTIMPL;
}
示例13: CreateSelectionAction
public int CreateSelectionAction(IVsTextBuffer pBuffer, out IVsTextSelectionAction ppAction)
{
throw new Exception("The method or operation is not implemented.");
}
示例14: UnregisterIndependentView
public int UnregisterIndependentView(object pUnk, IVsTextBuffer pBuffer)
{
throw new Exception("The method or operation is not implemented.");
}
示例15: GetDocumentBuffer
public Microsoft.VisualStudio.Text.ITextBuffer GetDocumentBuffer(IVsTextBuffer bufferAdapter)
{
throw new NotImplementedException();
}