Copyright and License information Home

__ A B C D E F G H I L M P R S T U V W

### wxStyledTextCtrl - Tabs and Indentation Guides

- GetBackSpaceUnIndents
- GetHighlightGuide
- GetIndentationGuides
- GetIndentationGuides
- GetLineIndentation
- GetLineIndentPosition
- GetTabIndents
- GetTabWidth
- GetUseTabs
- SetBackSpaceUnIndents
- SetHighlightGuide
- SetIndent
- SetIndentationGuides
- SetLineIndentation
- SetTabIndents
- SetTabWidth
- SetUseTabs

Summary:

Tabs are used to add uniform spacing in a line of text; sometimes the length between tabs is variable, but in the context of the STC they are uniform. You use SetTabWidth to set the tab spacing, which defaults to 8 when a Document is created (when the STC is instantiated or you use CreateDocument).

By the way, it's important to note that the tab-related settings are maintained on a document-by-document basis. If you create a new document you need to change any tab-related settings that you want to maintain in the new document.

Very often a tab is actually implemented with a number of spaces rather than a tab character. You can choose how you want to implement a tab with SetUseTabs.

Indentation is related to tabs, but they're not exactly the same. In languages like Python (yeah!), the white space at the beginning of each line is used as part of the syntax of the language, and in most other languages programmers will use indentation to make a program easier to read.

The STC can be programmed so that it will give special handling to tab and backspace keypresses which occur when the caret is in the the leading white space of a line. This is done using SetTabIndents and SetBackSpaceUnIndents, respectively. When these special modes are active, a tab indents to the next indent position instead of inserting a tab (or group of spaces) and and backspace unindents the line instead of performing an addition. You use SetIndent to set the number of spaces comprising each indent level. You use SetLineIndentation and GetLineIndentation to deal with indentation on a line-by-line basis.

Indentation guides are thin vertical lines that appear only in whitespace areas. They appear at column intervals set by SetLineIndentation and are useful to help you line up lengthy indented sections of code. Use SetIndentationGuides to turn this mode on and off. You can use wxSTC_STYLE_INDENTGUIDE (37) to change the default foreground and background colors of these guides. See Styling.

If you're using brace highlighting with a language that uses braces as part of syntax, you can cause the indent guide for that brace level to be highlighted. Use SetHighlightGuide to activate this feature.

GetBackSpaceUnIndents()

Return the state of the backspace unindents mode. This is 1 if a backspace keypress within an indentation area will cause an unindent, or 0 if not.

top

GetHighlightGuide()

Return the highlight guide column.

top

GetIndent()

Return indentation size.

top

GetIndentationGuides()

Returns 1 if indentation guides are visible or 0 if not.

top

GetLineIndentation(line)

Retrieve an integer with the number of columns that a line specified by the integer parameter lineis indented.

top

GetLineIndentPosition(line)

Retrieve an integer with the position before the first non indentation character on a line specified by the integer parameter line.

top

GetTabIndents()

Does a tab pressed when caret is within indentation indent? Returns 1 if it will or 0 if not.

top

GetTabWidth()

Returns an integer with the visible size of a tab.

top

GetUseTabs()

Returns 1 if tabs will be used in indentation. Returns 0 if a combination of tabs and spaces is used instead.

top

SetBackSpaceUnIndents(bsUnIndents)

The integer parameter bsUnIndents controls whether a backspace pressed when caret is within indentation unindents (1) or deletes a character (0). Returns None.

top

SetHighlightGuide(column)

Use this method if you want to highlight the indentation guide at a particular column (an integer). The style wxSTC_STYLE_BRACELIGHT (34) is used to determine the colors of the highlight. When you want to turn off the highlighting you use this method again with column = 0. Returns None.

top

SetIndent(indentSize)

The integer parameter indentSize sets the number of spaces used for one level of indentation. Spaces have the width of a space character in wxSTC_STYLE_DEFAULT. Returns None.

top

SetIndentationGuides(show)

The integer parameter show will turn indentation guides on if 1 or off if 0. Returns None.

top

SetLineIndentation(line,indentSize)

Change the indentation of a line to a number of columns indentSize. line and indentSize are integers. Returns None.

top

SetTabIndents(tabIndents)

If the integer parameter tabIndents is 1, then a tab pressed when caret is within indentation indents; if tabIndents is 0 then a tab inserts a tab or spaces as set by SetUseTabs. Returns None.

top

SetTabWidth(tabWidth)

The integer parameter tabWidth sets the visible size of a tab to be a multiple of the width of a space character in wxSTC_STYLE_DEFAULT. Returns None.

top

SetUseTabs(useTabs)

Indentation will only use space characters if useTabs is 0, if useTabs is 1 it will use a combination of tabs and spaces. Returns None.

top