Text wrapping

Without text wrapping a line could grow longer and longer, eventually falling off the screen. Text wrapping automatically breaks the line, such that everything fits in the viewable window. Notice however that wrapped lines don’t increment the line number, and that’s great! Imagine the mess if your text editor starts playing around with line numbers, just because your display isn’t that wide…

Wrap mode

Text wrapping comes in many flavours. You can set the mode with the function

  • WrapNone
  • WrapWord

  • WrapCharacter

  • WrapWhitespace


Wrap visual flags

Text wrapping can be visualized in QScintilla:
setWrapVisualFlags(endFlag, startFlag, indent)
Let’s take a look at the parameters:

  • endFlag
    • WrapFlagNone
      self.__editor.setWrapVisualFlags(endFlag=QsciScintilla.WrapFlagNone, …)

    • WrapFlagByText
      self.__editor.setWrapVisualFlags(endFlag=QsciScintilla.WrapFlagByText, …)

    • WrapFlagByBorder
      self.__editor.setWrapVisualFlags(endFlag=QsciScintilla.WrapFlagByBorder, …)

    • WrapFlagInMargin
      self.__editor.setWrapVisualFlags(endFlag=QsciScintilla.WrapFlagInMargin, …)

  • startFlag
    • WrapFlagNone
      self.__editor.setWrapVisualFlags(startFlag=QsciScintilla.WrapFlagNone, …)

    • WrapFlagByText or WrapFlagByBorder
      self.__editor.setWrapVisualFlags(startFlag=QsciScintilla.WrapFlagByText, …)

    • WrapFlagInMargin
      self.__editor.setWrapVisualFlags(startFlag=QsciScintilla.WrapFlagInMargin, …)

      Note that this value has the same effect when applied on parameter ‘endFlag’.
  • indent
    This parameter sets the number of spaces each wrapped line gets indented by. It has to be an integer value. Its effect can only be seen if the indent mode is set to ‘fixed’ (see next paragraph).

Wrap indent mode

The wrapped line can have an indentation – if you want to.

  • WrapIndentFixed

    Please don’t forget to set the fixed value of the wrap-indentation. See the ‘indent’ parameter from previous paragraph.
  • WrapIndentSame

    The new line is indented the same as the original line.
  • WrapIndentIndented

    The new line is indented the same as the original line PLUS one more indentation level. The indentation level is defined by the setTabWidth function (see chapter about Indentation options).