Skip to content

2.00 TextEditor

Lokasenna edited this page Jun 24, 2018 · 1 revision

Provides a multiline text editor.

  • Forces a monospace font, because it makes things way easier.
  • Supports most common commands - copy, paste, selections, navigation, tab, backtab, etc.
  • Due to Reaper limitations, tab characters are automatically replaced with four spaces.
  • Does not support word wrapping yet, unfortunately.

    A text editor

Parameters

z, x, y, w, h[, text, caption, pad]

Required

z               Element depth, used for hiding and disabling layers. 1 is the highest.
x, y            Coordinates of top-left corner
w, h            Width and height of the text editor

Optional

text            Multiline string of text
caption         Label shown to the left of the text editor
pad             Padding between the label and the text editor

Additional parameters

cap_bg          Color to be drawn underneath the label. Defaults to "wnd_bg"
bg              Editor background. Defaults to "elm_bg"
shadow          Boolean. Draw a shadow beneath the label?
color           Text color
font_a          Label font

font_b          Text font.
                *** Only monospaced fonts will work properly ***

focus           Whether the text editor is "in focus" or not, allowing users to type.
                This setting is automatically updated, so you shouldn't need to
                change it yourself in most cases.
                
undo_limit      How many undo states can be stored before the first is erased.
                Defaults to 20.

Methods

GUI.Val("my_txt")

Returns self.retval as a string.

GUI.Val("my_txt", "In a hole in the ground, there lived a Hobbit.")

Accepts a either a table or a multiline string.

:wnd_recalc()

If your script needs to resize the text editor, move it around, etc, run this afterward so it can update a few internal values.