Module Text :: Class Text
[hide private]
[frames] | no frames]

Class Text

source code

The Text object

This object gives access to Texts in Blender.

Instance Methods [hide private]
string
getName()
Get the name of this Text object.
source code
 
setName(name)
Set the name of this Text object.
source code
string
getFilename()
Get the filename of the file loaded into this Text object.
source code
int
getNLines()
Get the number of lines in this Text buffer.
source code
 
clear()
Clear this Text object: its buffer becomes empty.
source code
 
reset()
Reset the read IO pointer to the start of the buffer.
source code
string
readline()
Reads a line of text from the buffer from the current IO pointer position to the end of the line.
source code
 
set(attribute, value)
Set this Text's attributes.
source code
 
write(data)
Append a string to this Text buffer.
source code
 
insert(data)
Inserts a string into this Text buffer at the cursor.
source code
list of strings
asLines(start=0, end=-1)
Retrieve the contents of this Text buffer as a list of strings between the start and end lines specified.
source code
(int, int)
getCursorPos()
Retrieve the position of the cursor in this Text buffer.
source code
 
setCursorPos(row, col)
Set the position of the cursor in this Text buffer.
source code
(int, int)
getSelectPos()
Retrieve the position of the selection cursor in this Text buffer.
source code
 
setSelectPos(row, col)
Set the position of the selection cursor in this Text buffer.
source code
 
suggest(list, prefix='')
Suggest a list of names.
source code
 
showDocs(docs)
Displays a word-wrapped message box containing the specified documentation when this Text object is visible.
source code
Instance Variables [hide private]
bool fakeUser
When set to True, this datablock wont be removed, even if nothing is using it.
  filename
The filename of the file loaded into this Text.
string or None lib
path to the blend file this datablock is stored in (readonly).
  mode
The follow_mode flag: if 1 it is 'on'; if 0, 'off'.
string name
unique name within each blend file.
  nlines
The number of lines in this Text.
IDGroup properties
Returns an IDGroup reference to this datablocks's ID Properties.
bool tag
A temporary tag that to flag data as being used within a loop.
int users
The number of users this datablock has.
Method Details [hide private]

setName(name)

source code 

Set the name of this Text object.

Parameters:
  • name (string) - The new name.

readline()

source code 

Reads a line of text from the buffer from the current IO pointer position to the end of the line. If the text has changed since the last read, reset() *must* be called.

Returns: string

set(attribute, value)

source code 

Set this Text's attributes.

Parameters:
  • attribute (string) - The attribute to change: currently, 'follow_cursor' is the only one available. It can be turned 'on' with value = 1 and 'off' with value = 0.
  • value (int) - The new attribute value.

write(data)

source code 

Append a string to this Text buffer.

Parameters:
  • data (string) - The string to append to the text buffer.

insert(data)

source code 

Inserts a string into this Text buffer at the cursor.

Parameters:
  • data (string) - The string to insert into the text buffer.

asLines(start=0, end=-1)

source code 

Retrieve the contents of this Text buffer as a list of strings between the start and end lines specified. If end < 0 all lines from start will be included.

Parameters:
  • start (int) - Optional index of first line of the span to return @type end int
  • end - Optional index of the line to which the span is taken or -1 to include all lines from start
Returns: list of strings
A list of strings, one for each line in the buffer between start and end.

getCursorPos()

source code 

Retrieve the position of the cursor in this Text buffer.

Returns: (int, int)
A pair (row, col) indexing the line and character of the cursor.

setCursorPos(row, col)

source code 

Set the position of the cursor in this Text buffer. Any selection will be cleared. Use setSelectPos to extend a selection from the point specified here.

Parameters:
  • row (int) - The index of the line in which to position the cursor.
  • col (int) - The index of the character within the line to position the cursor.

getSelectPos()

source code 

Retrieve the position of the selection cursor in this Text buffer.

Returns: (int, int)
A pair (row, col) indexing the line and character of the selection cursor.

setSelectPos(row, col)

source code 

Set the position of the selection cursor in this Text buffer. This method should be called after setCursorPos to extend the selection to the specified point.

Parameters:
  • row (int) - The index of the line in which to position the cursor.
  • col (int) - The index of the character within the line to position the cursor.

suggest(list, prefix='')

source code 

Suggest a list of names. If list is a list of tuples (name, type) the list will be formatted to syntax-highlight each entry type. Types must be strings in the list ['m', 'f', 'v', 'k', '?']. It is recommended that the list be sorted, case-insensitively by name.

Parameters:
  • list (list of tuples or strings) - List of pair-tuples of the form (name, type) where name is the suggested name and type is one of 'm' (module or class), 'f' (function or method), 'v' (variable), 'k' (keyword), '?' (other). Lists of plain strings are also accepted where the type is always '?'.
  • prefix (string) - The optional prefix used to limit what is suggested from the list. This is usually whatever precedes the cursor so that backspace will update it.

showDocs(docs)

source code 

Displays a word-wrapped message box containing the specified documentation when this Text object is visible.

Parameters:
  • docs (string) - The documentation string to display.

Instance Variable Details [hide private]

fakeUser

When set to True, this datablock wont be removed, even if nothing is using it. All data has this disabled by default except for Actions.
Type:
bool

lib

path to the blend file this datablock is stored in (readonly).

lib will be None unless you are using external blend files with (File, Append/Link)

Note: the path may be relative, to get the full path use Blender.sys.expandpath

Type:
string or None

name

unique name within each blend file.

The name is case sensitive and 21 characters maximum length.

Note: a blend file may have naming collisions when external library data is used, be sure to check the value of lib.

Note: Setting a value longer then 21 characters will be shortened

Type:
string

tag

A temporary tag that to flag data as being used within a loop. always set all tags to True or False before using since blender uses this flag for its own internal operations.
Type:
bool

users

The number of users this datablock has. (readonly) Zero user datablocks are de-allocated after reloading and saving.
Type:
int