2009-11-01 15:21:20 +00:00
|
|
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
2009-11-03 07:23:02 +00:00
|
|
|
#
|
2009-11-01 15:21:20 +00:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2009-11-03 07:23:02 +00:00
|
|
|
#
|
2009-11-01 15:21:20 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software Foundation,
|
|
|
|
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
#
|
|
|
|
# ##### END GPL LICENSE BLOCK #####
|
2009-10-31 20:16:59 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
# <pep8 compliant>
|
2009-04-22 18:39:44 +00:00
|
|
|
import bpy
|
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2009-04-22 18:39:44 +00:00
|
|
|
class TEXT_HT_header(bpy.types.Header):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_space_type = 'TEXT_EDITOR'
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
st = context.space_data
|
|
|
|
text = st.text
|
|
|
|
|
|
|
|
row = layout.row(align=True)
|
|
|
|
row.template_header()
|
|
|
|
|
|
|
|
if context.area.show_menus:
|
|
|
|
sub = row.row(align=True)
|
2009-11-23 00:27:30 +00:00
|
|
|
sub.menu("TEXT_MT_text")
|
2009-10-31 19:31:45 +00:00
|
|
|
if text:
|
2009-11-23 00:27:30 +00:00
|
|
|
sub.menu("TEXT_MT_edit")
|
|
|
|
sub.menu("TEXT_MT_format")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
if text and text.modified:
|
|
|
|
row = layout.row()
|
|
|
|
# row.color(redalert)
|
2009-12-10 10:23:53 +00:00
|
|
|
row.operator("text.resolve_conflict", text="", icon='HELP')
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
layout.template_ID(st, "text", new="text.new", unlink="text.unlink")
|
|
|
|
|
|
|
|
row = layout.row(align=True)
|
2009-11-23 00:27:30 +00:00
|
|
|
row.prop(st, "line_numbers", text="")
|
|
|
|
row.prop(st, "word_wrap", text="")
|
|
|
|
row.prop(st, "syntax_highlight", text="")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
if text:
|
2009-11-22 15:15:11 +00:00
|
|
|
row = layout.row()
|
2009-11-23 00:27:30 +00:00
|
|
|
row.operator("text.run_script")
|
|
|
|
row.prop(text, "use_module")
|
2009-11-22 15:15:11 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
row = layout.row()
|
|
|
|
if text.filename != "":
|
|
|
|
if text.dirty:
|
2009-11-23 00:27:30 +00:00
|
|
|
row.label(text="File: *%s (unsaved)" % text.filename)
|
2009-10-31 19:31:45 +00:00
|
|
|
else:
|
2009-11-23 00:27:30 +00:00
|
|
|
row.label(text="File: %s" % text.filename)
|
2009-10-31 19:31:45 +00:00
|
|
|
else:
|
|
|
|
if text.library:
|
2009-11-23 00:27:30 +00:00
|
|
|
row.label(text="Text: External")
|
2009-10-31 19:31:45 +00:00
|
|
|
else:
|
2009-11-23 00:27:30 +00:00
|
|
|
row.label(text="Text: Internal")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2009-04-22 18:39:44 +00:00
|
|
|
class TEXT_PT_properties(bpy.types.Panel):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_space_type = 'TEXT_EDITOR'
|
|
|
|
bl_region_type = 'UI'
|
|
|
|
bl_label = "Properties"
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
st = context.space_data
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
flow = layout.column_flow()
|
2009-11-23 00:27:30 +00:00
|
|
|
flow.prop(st, "line_numbers")
|
|
|
|
flow.prop(st, "word_wrap")
|
|
|
|
flow.prop(st, "syntax_highlight")
|
|
|
|
flow.prop(st, "live_edit")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
flow = layout.column_flow()
|
2009-11-23 00:27:30 +00:00
|
|
|
flow.prop(st, "font_size")
|
|
|
|
flow.prop(st, "tab_width")
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2009-04-22 18:39:44 +00:00
|
|
|
class TEXT_PT_find(bpy.types.Panel):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_space_type = 'TEXT_EDITOR'
|
|
|
|
bl_region_type = 'UI'
|
|
|
|
bl_label = "Find"
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
st = context.space_data
|
|
|
|
|
|
|
|
# find
|
|
|
|
col = layout.column(align=True)
|
|
|
|
row = col.row()
|
2009-11-23 00:27:30 +00:00
|
|
|
row.prop(st, "find_text", text="")
|
2009-12-10 10:23:53 +00:00
|
|
|
row.operator("text.find_set_selected", text="", icon='TEXT')
|
2009-11-23 00:27:30 +00:00
|
|
|
col.operator("text.find")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
# replace
|
|
|
|
col = layout.column(align=True)
|
|
|
|
row = col.row()
|
2009-11-23 00:27:30 +00:00
|
|
|
row.prop(st, "replace_text", text="")
|
2009-12-10 10:23:53 +00:00
|
|
|
row.operator("text.replace_set_selected", text="", icon='TEXT')
|
2009-11-23 00:27:30 +00:00
|
|
|
col.operator("text.replace")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
# mark
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.operator("text.mark_all")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
# settings
|
|
|
|
row = layout.row()
|
2009-11-23 00:27:30 +00:00
|
|
|
row.prop(st, "find_wrap", text="Wrap")
|
|
|
|
row.prop(st, "find_all", text="All")
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2009-04-22 18:39:44 +00:00
|
|
|
class TEXT_MT_text(bpy.types.Menu):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_label = "Text"
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
st = context.space_data
|
|
|
|
text = st.text
|
|
|
|
|
|
|
|
layout.column()
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.operator("text.new")
|
|
|
|
layout.operator("text.open")
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
if text:
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.operator("text.reload")
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
layout.column()
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.operator("text.save")
|
|
|
|
layout.operator("text.save_as")
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
if text.filename != "":
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.operator("text.make_internal")
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
layout.column()
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.operator("text.run_script")
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
#ifndef DISABLE_PYTHON
|
|
|
|
# XXX if(BPY_is_pyconstraint(text))
|
|
|
|
# XXX uiMenuItemO(head, 0, "text.refresh_pyconstraints");
|
|
|
|
#endif
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.separator()
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-12-10 10:23:53 +00:00
|
|
|
layout.operator("text.properties", icon='MENU_PANEL')
|
2009-08-19 00:55:30 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.menu("TEXT_MT_templates")
|
2009-12-04 17:54:48 +00:00
|
|
|
|
2009-12-03 16:28:50 +00:00
|
|
|
layout.separator()
|
2009-12-04 17:54:48 +00:00
|
|
|
|
2009-12-03 16:28:50 +00:00
|
|
|
layout.operator("screen.area_dupli")
|
|
|
|
layout.operator("screen.screen_full_area")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2009-10-29 11:26:44 +00:00
|
|
|
|
|
|
|
class TEXT_MT_templates(bpy.types.Menu):
|
2009-10-31 19:31:45 +00:00
|
|
|
'''
|
|
|
|
Creates the menu items by scanning scripts/templates
|
|
|
|
'''
|
|
|
|
bl_label = "Script Templates"
|
|
|
|
|
|
|
|
def draw(self, context):
|
2009-11-22 11:23:19 +00:00
|
|
|
self.path_menu(bpy.utils.script_paths("templates"), "text.open")
|
2009-10-29 11:26:44 +00:00
|
|
|
|
|
|
|
|
2009-06-16 01:10:47 +00:00
|
|
|
class TEXT_MT_edit_view(bpy.types.Menu):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_label = "View"
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-11-23 11:43:38 +00:00
|
|
|
layout.operator("text.move", text="Top of File").type = 'FILE_TOP'
|
|
|
|
layout.operator("text.move", text="Bottom of File").type = 'FILE_BOTTOM'
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2009-06-16 01:10:47 +00:00
|
|
|
class TEXT_MT_edit_select(bpy.types.Menu):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_label = "Select"
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.operator("text.select_all")
|
|
|
|
layout.operator("text.select_line")
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2009-06-16 01:10:47 +00:00
|
|
|
class TEXT_MT_edit_markers(bpy.types.Menu):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_label = "Markers"
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.operator("text.markers_clear")
|
|
|
|
layout.operator("text.next_marker")
|
|
|
|
layout.operator("text.previous_marker")
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2009-06-16 01:10:47 +00:00
|
|
|
class TEXT_MT_format(bpy.types.Menu):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_label = "Format"
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.operator("text.indent")
|
|
|
|
layout.operator("text.unindent")
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.separator()
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.operator("text.comment")
|
|
|
|
layout.operator("text.uncomment")
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.separator()
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.operator_menu_enum("text.convert_whitespace", "type")
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2009-06-16 01:10:47 +00:00
|
|
|
class TEXT_MT_edit_to3d(bpy.types.Menu):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_label = "Text To 3D Object"
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-11-23 11:43:38 +00:00
|
|
|
layout.operator("text.to_3d_object", text="One Object").split_lines = False
|
|
|
|
layout.operator("text.to_3d_object", text="One Object Per Line").split_lines = True
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2009-06-16 01:10:47 +00:00
|
|
|
|
|
|
|
class TEXT_MT_edit(bpy.types.Menu):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_label = "Edit"
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
def poll(self, context):
|
|
|
|
return (context.space_data.text)
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.operator("ed.undo")
|
|
|
|
layout.operator("ed.redo")
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.separator()
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.operator("text.cut")
|
|
|
|
layout.operator("text.copy")
|
|
|
|
layout.operator("text.paste")
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.separator()
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.menu("TEXT_MT_edit_view")
|
|
|
|
layout.menu("TEXT_MT_edit_select")
|
|
|
|
layout.menu("TEXT_MT_edit_markers")
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.separator()
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.operator("text.jump")
|
|
|
|
layout.operator("text.properties", text="Find...")
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.separator()
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.menu("TEXT_MT_edit_to3d")
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2009-04-22 18:39:44 +00:00
|
|
|
bpy.types.register(TEXT_HT_header)
|
|
|
|
bpy.types.register(TEXT_PT_properties)
|
|
|
|
bpy.types.register(TEXT_PT_find)
|
|
|
|
bpy.types.register(TEXT_MT_text)
|
2009-10-29 11:26:44 +00:00
|
|
|
bpy.types.register(TEXT_MT_templates)
|
2009-06-16 01:10:47 +00:00
|
|
|
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)
|