Tabs and Indentation Guides =========================== Indentation (the white space at the start of a line) is often used by programmers to clarify program structure and in some languages, for example Python, it may be part of the language syntax. Tabs are normally used in editors to insert a tab character or to pad text with spaces up to the next tab. Scintilla can be set to treat tab and backspace in the white space at the start of a line in a special way: inserting a tab indents the line to the next indent position rather than just inserting a tab at the current character position and backspace unindents the line rather than deleting a character. Scintilla can also display indentation guides (vertical lines) to help you to generate code. .. method:: gtkscintilla.Scintilla.set_tab_width(widthInChars) .. method:: gtkscintilla.Scintilla.get_tab_width() Sets the size of a tab as a multiple of the size of a space character in STYLE_DEFAULT. The default tab width is 8 characters. There are no limits on tab sizes, but values less than 1 or large values may have undesirable effects. .. method:: gtkscintilla.Scintilla.set_use_tabs(useTabs) .. method:: gtkscintilla.Scintilla.get_use_tabs() determines whether indentation should be created out of a mixture of tabs and spaces or be based purely on spaces. Set useTabs to False to create all tabs and indents out of spaces. The default is True. You can use :meth:`~gtkscintilla.Scintilla.get_column` to get the column of a position taking the width of a tab into account. .. method:: gtkscintilla.Scintilla.set_indent(widthInChars) .. method:: gtkscintilla.Scintilla.get_indent() sets the size of indentation in terms of the width of a space in STYLE_DEFAULT. If you set a width of 0, the indent size is the same as the tab size. There are no limits on indent sizes, but values less than 0 or large values may have undesirable effects. .. method:: gtkscintilla.Scintilla.set_tab_indents(tabIndents) .. method:: gtkscintilla.Scintilla.set_tab_indents() .. method:: gtkscintilla.Scintilla.set_backspace_unindents(bsUnIndents) .. method:: gtkscintilla.Scintilla.set_backspace_unindents() Inside indentation white space, the tab and backspace keys can be made to indent and unindent rather than insert a tab character or delete a character with the :meth:`~gtkscintilla.Scintilla.set_tab_indents` and :meth:`~gtkscintilla.Scintilla.set_backspace_unindents` functions. .. method:: gtkscintilla.Scintilla.set_line_indentation(line, indentation) .. method:: gtkscintilla.Scintilla.set_line_indentation(line) The amount of indentation on a line can be discovered and set with :meth:`~gtkscintilla.Scintilla.set_line_indentation` and :meth:`~gtkscintilla.Scintilla.set_line_indentation` . The indentation is measured in character columns, which correspond to the width of space characters. .. method:: gtkscintilla.Scintilla.get_line_indent_position(line) This returns the position at the end of indentation of a line. .. method:: gtkscintilla.Scintilla.set_indentation_guides(indentView) .. method:: gtkscintilla.Scintilla.set_indentation_guides() Indentation guides are dotted vertical lines that appear within indentation white space every indent size columns. They make it easy to see which constructs line up especially when they extend over multiple pages. Style STYLE_INDENTGUIDE (37) is used to specify the foreground and background colour of the indentation guides. There are 4 indentation guide views. SC_IV_NONE turns the feature off but the other 3 states determine how far the guides appear on empty lines. +---------------------+---------------------------------------------------------+ | SC_IV_NONE | No indentation guides are shown. | +---------------------+---------------------------------------------------------+ | SC_IV_REAL | Indentation guides are shown inside real indentation | | | white space. | +---------------------+---------------------------------------------------------+ | SC_IV_LOOKFORWARD | Indentation guides are shown beyond the actual | | | indentation up to the level of the next non-empty | | | line. If the previous non-empty line was a fold header | | | then indentation guides are shown for one more level of | | | indent than that line. This setting is good for Python. | +---------------------+---------------------------------------------------------+ | SC_IV_LOOKBOTH | Indentation guides are shown beyond the actual | | | indentation up to the level of the next non-empty line | | | or previous non-empty line whichever is the greater. | | | This setting is good for most languages. | +---------------------+---------------------------------------------------------+ .. method:: gtkscintilla.Scintilla.set_highlight_guide(column) .. method:: gtkscintilla.Scintilla.set_highlight_guide() When brace highlighting occurs, the indentation guide corresponding to the braces may be highlighted with the brace highlighting style, STYLE_BRACELIGHT (34). Set column to 0 to cancel this highlight.