private void GetLineInformation(IVsTextView pView, int iNewLine, int iLine, int iCol) { String str = ""; IVsTextLines lines; // Text of Line if (VSConstants.S_OK == pView.GetBuffer(out lines)) { // http://ankhsvn.open.collab.net/ds/viewMessage.do?dsForumId=580&viewType=browseAll&dsMessageId=349875 var data = new LINEDATA[1]; var markerData = new MARKERDATA[1]; if (VSConstants.S_OK == lines.GetLineData(iNewLine, data, markerData)) { str = Marshal.PtrToStringUni(data[0].pszText, data[0].iLength); // Clean up memory...needed? lines.ReleaseLineData(data); lines.ReleaseMarkerData(markerData); //object ppTextPoint; //lines.CreateTextPoint(iNewLine, data[0].iLength, out ppTextPoint); //var textPoint = ppTextPoint as EnvDTE.TextPoint; // See if we can get entity // ... but only if supported extension. // COM craptatic code will potentially bomb if doing something like javascript, etc. //entity = GetOrCreateCodeEntityFromActivePoint(path, doc); } } }
static string GetLine(IVsTextLines lines, int lineNr) { if (lineNr < 0) { throw new ArgumentOutOfRangeException("lineNr"); } else if (lines == null) { return(null); } int lastLine, lastIndex; if (!VSErr.Succeeded(lines.GetLastLineIndex(out lastLine, out lastIndex))) { return(null); } if (lineNr > lastLine) { return(null); } LINEDATA[] data = new LINEDATA[1]; if (!VSErr.Succeeded(lines.GetLineData(lineNr, data, null))) { return(null); } return(Marshal.PtrToStringUni(data[0].pszText, data[0].iLength)); }
public bool TryReadLine(out string line) { IVsTextLines textLines; int hr = _view.GetBuffer(out textLines); if (hr != VSConstants.S_OK || textLines == null) { line = null; return(false); } int lineCount; hr = textLines.GetLineCount(out lineCount); if (hr != VSConstants.S_OK || _lineNumber == lineCount) { line = null; return(false); } int lineNumber = _lineNumber++; hr = textLines.GetLengthOfLine(lineNumber, out _currentLineLength); if (hr != VSConstants.S_OK) { line = null; return(false); } hr = textLines.GetLineText(lineNumber, 0, lineNumber, _currentLineLength, out line); if (hr != VSConstants.S_OK) { line = null; return(false); } var lineData = new LINEDATA[1]; textLines.GetLineData(lineNumber, lineData, null); if (lineData[0].iEolType != EOLTYPE.eolNONE) { line += "\n"; } return(true); }
private String GetLineContent(IVsTextLines lines, int lineNumber) { String str = ""; var data = new LINEDATA[1]; var markerData = new MARKERDATA[1]; if (VSConstants.S_OK == lines.GetLineData(lineNumber, data, markerData)) { str = Marshal.PtrToStringUni(data[0].pszText, data[0].iLength); // Clean up memory...needed? lines.ReleaseLineData(data); lines.ReleaseMarkerData(markerData); } return(str); }
/// <summary> /// Enumerate over the lines [startIndex, endIndex) for the IVsTextLines buffer. /// </summary> /// <param name="buffer"> The buffer to enumerate. </param> /// <param name="startIndex"> The starting index, inclusive. </param> /// <param name="endIndex"> The end index, exclusive. </param> /// <returns> /// Returns an enumrator that will enumerate over the lines [startIndex, endIndex) of the buffer. /// </returns> private static IEnumerable <Tuple <int, string> > GetTextLinesEnumeratorInternal(IVsTextLines buffer, int startIndex, int endIndex) { LINEDATA[] lineData = new LINEDATA[1]; for (int i = startIndex; i < endIndex; ++i) { int hr = buffer.GetLineData(i, lineData, null); // Skip the line if there is an error. if (ErrorHandler.Failed(hr)) { continue; } string line; try { // We set an arbitrary limit on the line length that we're willing to handle. This is to avoid // loading an unreasonably long string into memory. The buffer is compressed under the covers, so it // can handle much longer strings. // If we choose to handle the case where the string is longer, we would complicate the code significantly. // Since this is an unlikely scenario to have the script tag on a line this long, we will optimize // for the standard case and error; if (lineData[0].iLength >= MaxLineLengthToConsider) { continue; } line = Marshal.PtrToStringUni(lineData[0].pszText); } finally { buffer.ReleaseLineData(lineData); } yield return(new Tuple <int, string>(i, line)); } }
public int ReleaseLineData(LINEDATA[] pLineData) { throw new NotImplementedException(); }
public int ReleaseLineData(LINEDATA[] pLineData) { throw new Exception("The method or operation is not implemented."); }
public int GetLineData(int iLine, LINEDATA[] pLineData, MARKERDATA[] pMarkerData) { throw new Exception("The method or operation is not implemented."); }
public static int DrawLineSet( out LINEDATA LineData, int Num) { if( System.IntPtr.Size == 4 ) { return dx_DrawLineSet_x86( out LineData , Num ); } else { return dx_DrawLineSet_x64( out LineData , Num ); } }
public int GetLineData(int iLine, LINEDATA[] pLineData, MARKERDATA[] pMarkerData) { return _textBuffer.GetLineData(iLine, pLineData, pMarkerData); }
public static int DrawLineSet( out LINEDATA LineData, int Num) { return dx_DrawLineSet( out LineData , Num ); }
int IVsTextLines.IVsTextLinesReserved1(int iLine, LINEDATA[] pLineData, int fAttributes) { return VSConstants.E_NOTIMPL; }
int IVsTextLines.GetLineData(int iLine, LINEDATA[] pLineData, MARKERDATA[] pMarkerData) { return VSConstants.E_NOTIMPL; }
public int IVsTextLinesReserved1(int iLine, LINEDATA[] pLineData, int fAttributes) { throw new NotImplementedException(); }
public int ReleaseLineData(LINEDATA[] pLineData) { return _textBuffer.ReleaseLineData(pLineData); }
public int IVsTextLinesReserved1(int iLine, LINEDATA[] pLineData, int fAttributes) { return _textBuffer.IVsTextLinesReserved1(iLine, pLineData, fAttributes); }
int IVsTextLines.ReleaseLineData(LINEDATA[] pLineData) { return VSConstants.E_NOTIMPL; }
public int GetLineData(int iLine, LINEDATA[] pLineData, MARKERDATA[] pMarkerData) { throw new NotImplementedException(); }
public bool TryReadLine(out string line) { IVsTextLines textLines; int hr = _view.GetBuffer(out textLines); if (hr != VSConstants.S_OK || textLines == null) { line = null; return false; } int lineCount; hr = textLines.GetLineCount(out lineCount); if (hr != VSConstants.S_OK || _lineNumber == lineCount) { line = null; return false; } int lineNumber = _lineNumber++; hr = textLines.GetLengthOfLine(lineNumber, out _currentLineLength); if(hr != VSConstants.S_OK) { line = null; return false; } hr = textLines.GetLineText(lineNumber, 0, lineNumber, _currentLineLength, out line); if (hr != VSConstants.S_OK) { line = null; return false; } LINEDATA[] lineData = new LINEDATA[1]; textLines.GetLineData(lineNumber, lineData, null); if (lineData[0].iEolType != EOLTYPE.eolNONE) { line += "\n"; } return true; }
public int IVsTextLinesReserved1(int iLine, LINEDATA[] pLineData, int fAttributes) { return VSConstants.S_FALSE; }
public int ReleaseLineData(LINEDATA[] pLineData) { return VSConstants.S_OK; }
public int GetLineData(int iLine, LINEDATA[] pLineData, MARKERDATA[] pMarkerData) { return VSConstants.S_OK; }
extern static int dx_DrawLineSet_x64( out LINEDATA LineData, int Num);
public int IVsTextLinesReserved1(int iLine, LINEDATA[] pLineData, int fAttributes) { throw new Exception("The method or operation is not implemented."); }
static string GetLine(IVsTextLines lines, int lineNr) { if (lineNr < 0) throw new ArgumentOutOfRangeException("lineNr"); else if (lines == null) return null; int lastLine, lastIndex; if (!ErrorHandler.Succeeded(lines.GetLastLineIndex(out lastLine, out lastIndex))) return null; if (lineNr > lastLine) return null; LINEDATA[] data = new LINEDATA[1]; if (!ErrorHandler.Succeeded(lines.GetLineData(lineNr, data, null))) return null; return Marshal.PtrToStringUni(data[0].pszText, data[0].iLength); }
private String GetLineContent(IVsTextLines lines, int lineNumber) { String str = ""; var data = new LINEDATA[1]; var markerData = new MARKERDATA[1]; if (VSConstants.S_OK == lines.GetLineData(lineNumber, data, markerData)) { str = Marshal.PtrToStringUni(data[0].pszText, data[0].iLength); // Clean up memory...needed? lines.ReleaseLineData(data); lines.ReleaseMarkerData(markerData); } return str; }