1
# ##### BEGIN GPL LICENSE BLOCK #####
3
# This program is free software; you can redistribute it and/or
4
# modify it under the terms of the GNU General Public License
5
# as published by the Free Software Foundation; either version 2
6
# of the License, or (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software Foundation,
15
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
# ##### END GPL LICENSE BLOCK #####
23
class TEXT_HT_header(bpy.types.Header):
24
bl_space_type = 'TEXT_EDITOR'
26
def draw(self, context):
29
st = context.space_data
32
row = layout.row(align=True)
35
if context.area.show_menus:
36
sub = row.row(align=True)
37
sub.menu("TEXT_MT_text")
39
sub.menu("TEXT_MT_edit")
40
sub.menu("TEXT_MT_format")
42
if text and text.modified:
45
row.operator("text.resolve_conflict", text="", icon='HELP')
47
layout.template_ID(st, "text", new="text.new", unlink="text.unlink")
49
row = layout.row(align=True)
50
row.prop(st, "line_numbers", text="")
51
row.prop(st, "word_wrap", text="")
52
row.prop(st, "syntax_highlight", text="")
56
row.operator("text.run_script")
59
row.active = text.name.endswith(".py")
60
row.prop(text, "use_module")
65
row.label(text="File: *%s (unsaved)" % text.filepath)
67
row.label(text="File: %s" % text.filepath)
69
row.label(text="Text: External" if text.library else "Text: Internal")
72
class TEXT_PT_properties(bpy.types.Panel):
73
bl_space_type = 'TEXT_EDITOR'
75
bl_label = "Properties"
77
def draw(self, context):
80
st = context.space_data
82
flow = layout.column_flow()
83
flow.prop(st, "line_numbers")
84
flow.prop(st, "word_wrap")
85
flow.prop(st, "syntax_highlight")
86
flow.prop(st, "live_edit")
88
flow = layout.column_flow()
89
flow.prop(st, "font_size")
90
flow.prop(st, "tab_width")
94
flow.prop(text, "tabs_as_spaces")
97
class TEXT_PT_find(bpy.types.Panel):
98
bl_space_type = 'TEXT_EDITOR'
102
def draw(self, context):
105
st = context.space_data
108
col = layout.column(align=True)
110
row.prop(st, "find_text", text="")
111
row.operator("text.find_set_selected", text="", icon='TEXT')
112
col.operator("text.find")
115
col = layout.column(align=True)
117
row.prop(st, "replace_text", text="")
118
row.operator("text.replace_set_selected", text="", icon='TEXT')
119
col.operator("text.replace")
122
layout.operator("text.mark_all")
126
row.prop(st, "find_wrap", text="Wrap")
127
row.prop(st, "find_all", text="All")
130
class TEXT_MT_text(bpy.types.Menu):
133
def draw(self, context):
136
st = context.space_data
140
layout.operator("text.new")
141
layout.operator("text.open")
144
layout.operator("text.reload")
147
layout.operator("text.save")
148
layout.operator("text.save_as")
151
layout.operator("text.make_internal")
154
layout.operator("text.run_script")
156
#ifndef DISABLE_PYTHON
157
# XXX if(BPY_is_pyconstraint(text))
158
# XXX uiMenuItemO(head, 0, "text.refresh_pyconstraints");
163
layout.operator("text.properties", icon='MENU_PANEL')
165
layout.menu("TEXT_MT_templates")
169
layout.operator("screen.area_dupli")
170
layout.operator("screen.screen_full_area")
173
class TEXT_MT_templates(bpy.types.Menu):
175
Creates the menu items by scanning scripts/templates
177
bl_label = "Script Templates"
179
def draw(self, context):
180
self.path_menu(bpy.utils.script_paths("templates"), "text.open", {"internal": True})
183
class TEXT_MT_edit_view(bpy.types.Menu):
186
def draw(self, context):
189
layout.operator("text.move", text="Top of File").type = 'FILE_TOP'
190
layout.operator("text.move", text="Bottom of File").type = 'FILE_BOTTOM'
193
class TEXT_MT_edit_select(bpy.types.Menu):
196
def draw(self, context):
199
layout.operator("text.select_all")
200
layout.operator("text.select_line")
203
class TEXT_MT_edit_markers(bpy.types.Menu):
206
def draw(self, context):
209
layout.operator("text.markers_clear")
210
layout.operator("text.next_marker")
211
layout.operator("text.previous_marker")
214
class TEXT_MT_format(bpy.types.Menu):
217
def draw(self, context):
220
layout.operator("text.indent")
221
layout.operator("text.unindent")
225
layout.operator("text.comment")
226
layout.operator("text.uncomment")
230
layout.operator_menu_enum("text.convert_whitespace", "type")
233
class TEXT_MT_edit_to3d(bpy.types.Menu):
234
bl_label = "Text To 3D Object"
236
def draw(self, context):
239
layout.operator("text.to_3d_object", text="One Object").split_lines = False
240
layout.operator("text.to_3d_object", text="One Object Per Line").split_lines = True
243
class TEXT_MT_edit(bpy.types.Menu):
246
def poll(self, context):
247
return (context.space_data.text)
249
def draw(self, context):
252
layout.operator("ed.undo")
253
layout.operator("ed.redo")
257
layout.operator("text.cut")
258
layout.operator("text.copy")
259
layout.operator("text.paste")
263
layout.menu("TEXT_MT_edit_view")
264
layout.menu("TEXT_MT_edit_select")
265
layout.menu("TEXT_MT_edit_markers")
269
layout.operator("text.jump")
270
layout.operator("text.properties", text="Find...")
274
layout.menu("TEXT_MT_edit_to3d")
277
class TEXT_MT_toolbox(bpy.types.Menu):
280
def draw(self, context):
282
layout.operator_context = 'INVOKE_DEFAULT'
284
layout.operator("text.cut")
285
layout.operator("text.copy")
286
layout.operator("text.paste")
290
layout.operator("text.run_script")
303
TEXT_MT_edit_markers,
309
register = bpy.types.register
315
unregister = bpy.types.unregister
319
if __name__ == "__main__":