MCPcopy Create free account
hub / github.com/JacquesLucke/code_autocomplete / TextEditorInfo

Class TextEditorInfo

text_editor_utils.py:3–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1import bpy
2
3class TextEditorInfo:
4 def __init__(self):
5 context = bpy.context
6
7 space = context.space_data
8 region = context.region
9
10
11 text_block = space.text
12
13 self.visible_lines = space.visible_lines
14 self.top_line_index = space.top
15 self.text_block = text_block
16 self.line_index = text_block.current_line_index
17 self.character_index = text_block.current_character
18
19 self.width = region.width
20 self.height = region.height
21
22 self.line_height = self.height / self.visible_lines
23 self.character_width = self.line_height * 0.436
24
25 self.visible_line_index = self.line_index - self.top_line_index
26
27 self.cursor_position = (
28 self.character_width * self.character_index,
29 self.height - self.line_height * self.visible_line_index - self.line_height / 2 )
30
31 self.scale = self.line_height / 20
32
33def active_text_block_exists():
34 return getattr(bpy.context.space_data, "text", None) is not None

Callers 1

drawMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected