1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
import bpy
class TEXT_HT_header(bpy.types.Header):
__space_type__ = "TEXT_EDITOR"
def draw(self, context):
st = context.space_data
text = st.text
layout = self.layout
layout.template_header()
if context.area.show_menus:
row = layout.row()
row.itemM("TEXT_MT_text")
if text:
row.itemM("TEXT_MT_edit")
row.itemM("TEXT_MT_format")
if text and text.modified:
row = layout.row()
# row.color(redalert)
row.itemO("text.resolve_conflict", text="", icon='ICON_HELP')
row = layout.row(align=True)
row.itemR(st, "line_numbers", text="")
row.itemR(st, "word_wrap", text="")
row.itemR(st, "syntax_highlight", text="")
layout.template_ID(st, "text", new="text.new", unlink="text.unlink")
if text:
row = layout.row()
if text.filename != "":
if text.dirty:
row.itemL(text="File: *%s (unsaved)" % text.filename)
else:
row.itemL(text="File: %s" % text.filename )
else:
if text.library:
row.itemL(text="Text: External")
else:
row.itemL(text="Text: Internal")
class TEXT_PT_properties(bpy.types.Panel):
__space_type__ = "TEXT_EDITOR"
__region_type__ = "UI"
__label__ = "Properties"
def draw(self, context):
st = context.space_data
layout = self.layout
flow = layout.column_flow()
flow.itemR(st, "line_numbers")
flow.itemR(st, "word_wrap")
flow.itemR(st, "syntax_highlight")
flow.itemR(st, "live_edit")
flow = layout.column_flow()
flow.itemR(st, "font_size")
flow.itemR(st, "tab_width")
class TEXT_PT_find(bpy.types.Panel):
__space_type__ = "TEXT_EDITOR"
__region_type__ = "UI"
__label__ = "Find"
def draw(self, context):
st = context.space_data
layout = self.layout
# find
col = layout.column(align=True)
row = col.row()
row.itemR(st, "find_text", text="")
row.itemO("text.find_set_selected", text="", icon='ICON_TEXT')
col.itemO("text.find")
# replace
col = layout.column(align=True)
row = col.row()
row.itemR(st, "replace_text", text="")
row.itemO("text.replace_set_selected", text="", icon='ICON_TEXT')
col.itemO("text.replace")
# mark
layout.itemO("text.mark_all")
# settings
row = layout.row()
row.itemR(st, "find_wrap", text="Wrap")
row.itemR(st, "find_all", text="All")
class TEXT_MT_text(bpy.types.Menu):
__space_type__ = "TEXT_EDITOR"
__label__ = "Text"
def draw(self, context):
layout = self.layout
st = context.space_data
text = st.text
layout.column()
layout.itemO("text.new")
layout.itemO("text.open")
if text:
layout.itemO("text.reload")
layout.column()
layout.itemO("text.save")
layout.itemO("text.save_as")
if text.filename != "":
layout.itemO("text.make_internal")
layout.column()
layout.itemO("text.run_script")
#ifndef DISABLE_PYTHON
# XXX if(BPY_is_pyconstraint(text))
# XXX uiMenuItemO(head, 0, "text.refresh_pyconstraints");
#endif
#ifndef DISABLE_PYTHON
# XXX layout.column()
# XXX uiDefIconTextBlockBut(block, text_template_scriptsmenu, NULL, ICON_RIGHTARROW_THIN, "Script Templates", 0, yco-=20, 120, 19, "");
# XXX uiDefIconTextBlockBut(block, text_plugin_scriptsmenu, NULL, ICON_RIGHTARROW_THIN, "Text Plugins", 0, yco-=20, 120, 19, "");
#endif
class TEXT_MT_edit_view(bpy.types.Menu):
__space_type__ = "TEXT_EDITOR"
__label__ = "View"
def draw(self, context):
layout = self.layout
layout.item_enumO("text.move", "type", 'FILE_TOP', text="Top of File")
layout.item_enumO("text.move", "type", 'FILE_BOTTOM', text="Bottom of File")
class TEXT_MT_edit_select(bpy.types.Menu):
__space_type__ = "TEXT_EDITOR"
__label__ = "Select"
def draw(self, context):
layout = self.layout
layout.itemO("text.select_all")
layout.itemO("text.select_line")
class TEXT_MT_edit_markers(bpy.types.Menu):
__space_type__ = "TEXT_EDITOR"
__label__ = "Markers"
def draw(self, context):
layout = self.layout
layout.itemO("text.markers_clear")
layout.itemO("text.next_marker")
layout.itemO("text.previous_marker")
class TEXT_MT_format(bpy.types.Menu):
__space_type__ = "TEXT_EDITOR"
__label__ = "Format"
def draw(self, context):
layout = self.layout
layout.itemO("text.indent")
layout.itemO("text.unindent")
layout.itemS()
layout.itemO("text.comment")
layout.itemO("text.uncomment")
layout.itemS()
layout.item_menu_enumO("text.convert_whitespace", "type")
class TEXT_MT_edit_to3d(bpy.types.Menu):
__space_type__ = "TEXT_EDITOR"
__label__ = "Text To 3D Object"
def draw(self, context):
layout = self.layout
layout.item_booleanO("text.to_3d_object", "split_lines", False, text="One Object");
layout.item_booleanO("text.to_3d_object", "split_lines", True, text="One Object Per Line");
class TEXT_MT_edit(bpy.types.Menu):
__space_type__ = "TEXT_EDITOR"
__label__ = "Edit"
def poll(self, context):
st = context.space_data
return st.text != None
def draw(self, context):
layout = self.layout
layout.itemO("ed.undo")
layout.itemO("ed.redo")
layout.itemS()
layout.itemO("text.cut")
layout.itemO("text.copy")
layout.itemO("text.paste")
layout.itemS()
layout.itemM("TEXT_MT_edit_view")
layout.itemM("TEXT_MT_edit_select")
layout.itemM("TEXT_MT_edit_markers")
layout.itemS()
layout.itemO("text.jump")
layout.itemO("text.properties")
layout.itemS()
layout.itemM("TEXT_MT_edit_to3d")
bpy.types.register(TEXT_HT_header)
bpy.types.register(TEXT_PT_properties)
bpy.types.register(TEXT_PT_find)
bpy.types.register(TEXT_MT_text)
bpy.types.register(TEXT_MT_format)
bpy.types.register(TEXT_MT_edit)
bpy.types.register(TEXT_MT_edit_view)
bpy.types.register(TEXT_MT_edit_select)
bpy.types.register(TEXT_MT_edit_markers)
bpy.types.register(TEXT_MT_edit_to3d)
|