Partager via


IVsContainedLanguageHost.GetLineIndent Method

Definition

Provides information on the base indent level and indent settings.

public:
 int GetLineIndent(int lLineNumber, [Runtime::InteropServices::Out] System::String ^ % pbstrIndentString, [Runtime::InteropServices::Out] int % plParentIndentLevel, [Runtime::InteropServices::Out] int % plIndentSize, [Runtime::InteropServices::Out] int % pfTabs, [Runtime::InteropServices::Out] int % plTabSize);
int GetLineIndent(int lLineNumber, [Runtime::InteropServices::Out] std::wstring const & & pbstrIndentString, [Runtime::InteropServices::Out] int & plParentIndentLevel, [Runtime::InteropServices::Out] int & plIndentSize, [Runtime::InteropServices::Out] int & pfTabs, [Runtime::InteropServices::Out] int & plTabSize);
public int GetLineIndent (int lLineNumber, out string pbstrIndentString, out int plParentIndentLevel, out int plIndentSize, out int pfTabs, out int plTabSize);
abstract member GetLineIndent : int * string * int * int * int * int -> int
Public Function GetLineIndent (lLineNumber As Integer, ByRef pbstrIndentString As String, ByRef plParentIndentLevel As Integer, ByRef plIndentSize As Integer, ByRef pfTabs As Integer, ByRef plTabSize As Integer) As Integer

Parameters

lLineNumber
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
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
Int32

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

plIndentSize
Int32

[out] Size of the indent.

pfTabs
Int32

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

plTabSize
Int32

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

Returns

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.

Applies to