Ejemplo n.º 1
0
        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);
                }
            }
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        /// <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();
 }
Ejemplo n.º 7
0
 public int ReleaseLineData(LINEDATA[] pLineData)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Ejemplo n.º 8
0
 public int GetLineData(int iLine, LINEDATA[] pLineData, MARKERDATA[] pMarkerData)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Ejemplo n.º 9
0
		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 );
			}
		}
Ejemplo n.º 10
0
        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);
                }
            }
        }
Ejemplo n.º 11
0
 public int GetLineData(int iLine, LINEDATA[] pLineData, MARKERDATA[] pMarkerData)
 {
     return _textBuffer.GetLineData(iLine, pLineData, pMarkerData);
 }
Ejemplo n.º 12
0
		public static int  DrawLineSet( out LINEDATA  LineData, int  Num)
		{
			return dx_DrawLineSet( out LineData , Num );
		}
Ejemplo n.º 13
0
 int IVsTextLines.IVsTextLinesReserved1(int iLine, LINEDATA[] pLineData, int fAttributes)
 {
     return VSConstants.E_NOTIMPL;
 }
Ejemplo n.º 14
0
 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();
 }
Ejemplo n.º 16
0
 public int ReleaseLineData(LINEDATA[] pLineData)
 {
     return _textBuffer.ReleaseLineData(pLineData);
 }
Ejemplo n.º 17
0
 public int IVsTextLinesReserved1(int iLine, LINEDATA[] pLineData, int fAttributes)
 {
     return _textBuffer.IVsTextLinesReserved1(iLine, pLineData, fAttributes);
 }
Ejemplo n.º 18
0
 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;
        }
Ejemplo n.º 21
0
 public int IVsTextLinesReserved1(int iLine, LINEDATA[] pLineData, int fAttributes) {
     return VSConstants.S_FALSE;
 }
Ejemplo n.º 22
0
 public int ReleaseLineData(LINEDATA[] pLineData) {
     return VSConstants.S_OK;
 }
Ejemplo n.º 23
0
 public int GetLineData(int iLine, LINEDATA[] pLineData, MARKERDATA[] pMarkerData) {
     return VSConstants.S_OK;
 }
Ejemplo n.º 24
0
		extern static int  dx_DrawLineSet_x64( out LINEDATA  LineData, int  Num);
Ejemplo n.º 25
0
 public int IVsTextLinesReserved1(int iLine, LINEDATA[] pLineData, int fAttributes)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Ejemplo n.º 26
0
        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);
        }
Ejemplo n.º 27
0
        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;
        }