Partager via


IVsContainedLanguageHost.GetLineIndent Method

Provides information on the base indent level and indent settings.

Namespace:  Microsoft.VisualStudio.TextManager.Interop
Assembly:  Microsoft.VisualStudio.TextManager.Interop.8.0 (in Microsoft.VisualStudio.TextManager.Interop.8.0.dll)

Syntax

'Declaration
Function GetLineIndent ( _
    lLineNumber As Integer, _
    <OutAttribute> ByRef pbstrIndentString As String, _
    <OutAttribute> ByRef plParentIndentLevel As Integer, _
    <OutAttribute> ByRef plIndentSize As Integer, _
    <OutAttribute> ByRef pfTabs As Integer, _
    <OutAttribute> ByRef plTabSize As Integer _
) As Integer
int GetLineIndent(
    int lLineNumber,
    out string pbstrIndentString,
    out int plParentIndentLevel,
    out int plIndentSize,
    out int pfTabs,
    out int plTabSize
)
int GetLineIndent(
    [InAttribute] int lLineNumber, 
    [OutAttribute] String^% pbstrIndentString, 
    [OutAttribute] int% plParentIndentLevel, 
    [OutAttribute] int% plIndentSize, 
    [OutAttribute] int% pfTabs, 
    [OutAttribute] int% plTabSize
)
abstract GetLineIndent : 
        lLineNumber:int * 
        pbstrIndentString:string byref * 
        plParentIndentLevel:int byref * 
        plIndentSize:int byref * 
        pfTabs:int byref * 
        plTabSize:int byref -> int
function GetLineIndent(
    lLineNumber : int, 
    pbstrIndentString : String, 
    plParentIndentLevel : int, 
    plIndentSize : int, 
    pfTabs : int, 
    plTabSize : int
) : int

Parameters

  • lLineNumber
    Type: System.Int32

    [in] The line number for the line of text in question. This is the line number in the secondary buffer (that is, it is typically relative to the first line of code).

  • pbstrIndentString
    Type: System.String%

    [out] Returns the exact indent string. This string is to be inserted at the beginning of each line that is reformatted and represents the base level of indentation. See Remarks for more information.

  • plParentIndentLevel
    Type: System.Int32%

    [out] Returns the indent level in spaces. This value should be ignored if the pbstrIndentString parameter returns a non-empty string.

  • plIndentSize
    Type: System.Int32%

    [out] Size of the indent.

  • pfTabs
    Type: System.Int32%

    [out] Returns nonzero (TRUE) if tabs are to be used for line indents; otherwise, returns zero (FALSE), use spaces instead.

  • plTabSize
    Type: System.Int32%

    [out] Size of the tab indent, if present. If the pfTabs parameter returns zero (FALSE), this value is unspecified.

Return Value

Type: System.Int32
If successful, returns S_OK; otherwise, returns an error code.

Remarks

COM Signature

From singlefileeditor.idl:

HRESULT GetLineIndent(
   [in]  long  lLineNumber,
   [out] BSTR* pbstrIndentString,
   [out] long* plParentIndentLevel,
   [out] long* plIndentSize,
   [out] BOOL* pfTabs,
   [out] long* plTabSize
);

This method is called by a contained language performing any kind of reformatting where the indent level must be known. The base indent level is the indent level of the containing (parent) block:

<html>
  <script language="vb" runat="server">
        Sub TestSub()
            Dim x as String
        End Sub
  </script>
</html>

In this example, the base indent is the indent of the <script> tag, which is two spaces here.

If the editor decides to derive the indent from the source itself, the pbstrIndentString parameter provides the exact indent string (in the above example, this would a string containing two spaces) then the plParentIndentLevel parameter has no meaning and should be ignored. If the editor is not able to derive the indent from the source, the editor returns a null string in the pbstrIndentString parameter. In that case, the contained language should use the value in the plParentIndentLevel parameter.

.NET Framework Security

See Also

Reference

IVsContainedLanguageHost Interface

Microsoft.VisualStudio.TextManager.Interop Namespace