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,
|
2010-02-12 13:34:04 +00:00
|
|
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-11-01 15:21:20 +00:00
|
|
|
#
|
|
|
|
# ##### 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)
|
2010-07-30 14:56:17 +00:00
|
|
|
sub.menu("TEXT_MT_view")
|
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
|
|
|
|
2010-08-18 07:14:10 +00:00
|
|
|
if text and text.is_modified:
|
2009-10-31 19:31:45 +00:00
|
|
|
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)
|
2010-08-11 05:21:43 +00:00
|
|
|
row.prop(st, "show_line_numbers", text="")
|
|
|
|
row.prop(st, "show_word_wrap", text="")
|
|
|
|
row.prop(st, "show_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")
|
2010-06-11 14:10:02 +00:00
|
|
|
|
|
|
|
row = layout.row()
|
|
|
|
row.active = text.name.endswith(".py")
|
2009-11-23 00:27:30 +00:00
|
|
|
row.prop(text, "use_module")
|
2009-11-22 15:15:11 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
row = layout.row()
|
2010-06-02 17:58:28 +00:00
|
|
|
if text.filepath:
|
2010-08-18 07:14:10 +00:00
|
|
|
if text.is_dirty:
|
2010-06-02 17:58:28 +00:00
|
|
|
row.label(text="File: *%s (unsaved)" % text.filepath)
|
2009-10-31 19:31:45 +00:00
|
|
|
else:
|
2010-06-02 17:58:28 +00:00
|
|
|
row.label(text="File: %s" % text.filepath)
|
2009-10-31 19:31:45 +00:00
|
|
|
else:
|
2010-06-11 14:10:02 +00:00
|
|
|
row.label(text="Text: External" if text.library else "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()
|
2010-08-11 05:21:43 +00:00
|
|
|
flow.prop(st, "show_line_numbers")
|
|
|
|
flow.prop(st, "show_word_wrap")
|
|
|
|
flow.prop(st, "show_syntax_highlight")
|
|
|
|
flow.prop(st, "show_line_highlight")
|
2010-08-17 07:49:53 +00:00
|
|
|
flow.prop(st, "use_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")
|
2010-01-20 17:41:41 +00:00
|
|
|
|
|
|
|
text = st.text
|
|
|
|
if text:
|
2010-08-17 13:14:41 +00:00
|
|
|
flow.prop(text, "use_tabs_as_spaces")
|
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()
|
2010-08-17 07:49:53 +00:00
|
|
|
row.prop(st, "use_find_wrap", text="Wrap")
|
|
|
|
row.prop(st, "use_find_all", text="All")
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2010-07-30 14:56:17 +00:00
|
|
|
class TEXT_MT_view(bpy.types.Menu):
|
|
|
|
bl_label = "View"
|
2010-09-07 15:17:42 +00:00
|
|
|
|
2010-07-30 14:56:17 +00:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2010-09-07 15:17:42 +00:00
|
|
|
|
2010-07-30 14:56:17 +00:00
|
|
|
layout.operator("text.properties", icon='MENU_PANEL')
|
2010-09-07 15:17:42 +00:00
|
|
|
|
2010-07-30 14:56:17 +00:00
|
|
|
layout.separator()
|
|
|
|
|
|
|
|
layout.operator("screen.area_dupli")
|
|
|
|
layout.operator("screen.screen_full_area")
|
2010-08-03 22:41:01 +00:00
|
|
|
|
|
|
|
layout.separator()
|
|
|
|
|
|
|
|
layout.operator("text.move", text="Top of File").type = 'FILE_TOP'
|
|
|
|
layout.operator("text.move", text="Bottom of File").type = 'FILE_BOTTOM'
|
2010-09-07 15:17:42 +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
|
|
|
|
2010-06-02 17:58:28 +00:00
|
|
|
if text.filepath:
|
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-11-23 00:27:30 +00:00
|
|
|
layout.menu("TEXT_MT_templates")
|
2009-12-04 17:54:48 +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):
|
* Multiply for panorama cameras
* Some cases of struct name being set where it shouldnt have been.
* Spelling: wich --> which
* Copy and initialize uv modifier scale, remove unneeded enum.
* Ability to pin any object into the context.
* Update uv window while transforming (useful when used with UVProject modifier)
* Patch by Wahooney, so new template's are internal text and dont get saved over
by mistake.
* Fix for https://bugzilla.redhat.com/show_bug.cgi?id=572186
Bug 572186 - [abrt] crash in blender-2.49b-5.fc12: Process
/usr/bin/blender.bin was killed by signal 6 (SIGABRT). Original fix submitted
by Jochen Schmitt.
* [#21816] bpy.data.add_image has stopped working on Windows. moved to
bpy.data.images.load(), missed this call.
(commits 27726,27825,27828,27831,27832,27833,27834,27836,27837,27838,27839,27858 by Campbell from render25 branch)
2010-03-30 12:15:16 +00:00
|
|
|
self.path_menu(bpy.utils.script_paths("templates"), "text.open", {"internal": True})
|
2009-10-29 11:26:44 +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
|
|
|
|
2010-08-09 01:37:09 +00:00
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2009-10-31 19:31:45 +00:00
|
|
|
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_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
|
|
|
|
2010-02-14 11:21:21 +00:00
|
|
|
|
2010-05-12 08:03:36 +00:00
|
|
|
class TEXT_MT_toolbox(bpy.types.Menu):
|
|
|
|
bl_label = ""
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2010-05-13 01:46:48 +00:00
|
|
|
layout.operator_context = 'INVOKE_DEFAULT'
|
2010-05-12 08:03:36 +00:00
|
|
|
|
|
|
|
layout.operator("text.cut")
|
|
|
|
layout.operator("text.copy")
|
|
|
|
layout.operator("text.paste")
|
|
|
|
|
|
|
|
layout.separator()
|
2010-05-16 12:15:04 +00:00
|
|
|
|
2010-05-12 08:03:36 +00:00
|
|
|
layout.operator("text.run_script")
|
|
|
|
|
2010-09-07 15:17:42 +00:00
|
|
|
|
2010-02-14 11:21:21 +00:00
|
|
|
def register():
|
2010-08-02 02:55:12 +00:00
|
|
|
pass
|
2010-02-14 11:21:21 +00:00
|
|
|
|
2010-02-22 23:32:58 +00:00
|
|
|
|
2010-02-14 11:21:21 +00:00
|
|
|
def unregister():
|
2010-08-02 02:55:12 +00:00
|
|
|
pass
|
2010-02-16 09:55:07 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
register()
|