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
|
|
|
|
2011-07-26 07:39:00 +00:00
|
|
|
# <pep8-80 compliant>
|
2009-04-22 18:39:44 +00:00
|
|
|
import bpy
|
2011-08-12 06:57:00 +00:00
|
|
|
from bpy.types import Header, Menu, Panel
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class TEXT_HT_header(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:
|
2011-07-26 20:05:17 +00:00
|
|
|
row.menu("TEXT_MT_view")
|
|
|
|
row.menu("TEXT_MT_text")
|
2011-07-26 07:39:00 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
if text:
|
2011-07-26 20:05:17 +00:00
|
|
|
row.menu("TEXT_MT_edit")
|
|
|
|
row.menu("TEXT_MT_format")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2011-07-26 20:05:17 +00:00
|
|
|
row.menu("TEXT_MT_templates")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2010-08-18 07:14:10 +00:00
|
|
|
if text and text.is_modified:
|
2011-07-26 20:05:17 +00:00
|
|
|
sub = row.row()
|
|
|
|
sub.alert = True
|
|
|
|
sub.operator("text.resolve_conflict", text="", icon='HELP')
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2011-07-26 20:05:17 +00:00
|
|
|
row.template_ID(st, "text", new="text.new", unlink="text.unlink")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
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:
|
2011-09-26 15:39:15 +00:00
|
|
|
row.label(text="File" + ": *%r " %
|
|
|
|
text.filepath + "(unsaved)")
|
2009-10-31 19:31:45 +00:00
|
|
|
else:
|
2011-09-26 15:39:15 +00:00
|
|
|
row.label(text="File" + ": %r" %
|
|
|
|
text.filepath)
|
2009-10-31 19:31:45 +00:00
|
|
|
else:
|
2011-09-21 15:18:38 +00:00
|
|
|
row.label(text="Text: External"
|
2011-07-26 07:39:00 +00:00
|
|
|
if text.library
|
2011-09-21 15:18:38 +00:00
|
|
|
else "Text: Internal")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class TEXT_PT_properties(Panel):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_space_type = 'TEXT_EDITOR'
|
|
|
|
bl_region_type = 'UI'
|
2011-09-15 13:20:18 +00:00
|
|
|
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
|
|
|
|
2011-02-18 13:57:54 +00:00
|
|
|
flow.prop(st, "show_margin")
|
|
|
|
col = flow.column()
|
|
|
|
col.active = st.show_margin
|
|
|
|
col.prop(st, "margin_column")
|
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class TEXT_PT_find(Panel):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_space_type = 'TEXT_EDITOR'
|
|
|
|
bl_region_type = 'UI'
|
2011-09-15 13:20:18 +00:00
|
|
|
bl_label = "Find"
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
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
|
2011-05-07 17:52:44 +00:00
|
|
|
layout.prop(st, "use_match_case")
|
2009-10-31 19:31:45 +00:00
|
|
|
row = layout.row()
|
2011-09-21 15:18:38 +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
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class TEXT_MT_view(Menu):
|
2011-09-15 13:20:18 +00:00
|
|
|
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()
|
|
|
|
|
2011-07-26 07:39:00 +00:00
|
|
|
layout.operator("text.move",
|
2011-09-21 15:18:38 +00:00
|
|
|
text="Top of File",
|
2011-07-26 07:39:00 +00:00
|
|
|
).type = 'FILE_TOP'
|
|
|
|
layout.operator("text.move",
|
2011-09-21 15:18:38 +00:00
|
|
|
text="Bottom of File",
|
2011-07-26 07:39:00 +00:00
|
|
|
).type = 'FILE_BOTTOM'
|
2010-09-07 15:17:42 +00:00
|
|
|
|
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class TEXT_MT_text(Menu):
|
2011-09-15 13:20:18 +00:00
|
|
|
bl_label = "Text"
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
st = context.space_data
|
|
|
|
text = st.text
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class TEXT_MT_templates(Menu):
|
2011-09-15 13:20:18 +00:00
|
|
|
bl_label = "Templates"
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
def draw(self, context):
|
2011-07-26 07:39:00 +00:00
|
|
|
self.path_menu(bpy.utils.script_paths("templates"),
|
|
|
|
"text.open",
|
|
|
|
{"internal": True},
|
|
|
|
)
|
2009-10-29 11:26:44 +00:00
|
|
|
|
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class TEXT_MT_edit_select(Menu):
|
2011-09-15 13:20:18 +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
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class TEXT_MT_edit_markers(Menu):
|
2011-09-15 13:20:18 +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
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class TEXT_MT_format(Menu):
|
2011-09-15 13:20:18 +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
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class TEXT_MT_edit_to3d(Menu):
|
2011-09-15 13:20:18 +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
|
|
|
|
2011-07-26 07:39:00 +00:00
|
|
|
layout.operator("text.to_3d_object",
|
2011-09-21 15:18:38 +00:00
|
|
|
text="One Object",
|
2011-07-26 07:39:00 +00:00
|
|
|
).split_lines = False
|
|
|
|
layout.operator("text.to_3d_object",
|
2011-09-21 15:18:38 +00:00
|
|
|
text="One Object Per Line",
|
2011-07-26 07:39:00 +00:00
|
|
|
).split_lines = True
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2009-06-16 01:10:47 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class TEXT_MT_edit(Menu):
|
2011-09-15 13:20:18 +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")
|
2011-09-21 15:18:38 +00:00
|
|
|
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
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class TEXT_MT_toolbox(Menu):
|
2010-05-12 08:03:36 +00:00
|
|
|
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")
|
2011-04-04 10:13:04 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__": # only for live edit.
|
|
|
|
bpy.utils.register_module(__name__)
|