wip
This commit is contained in:
Binary file not shown.
@@ -1,19 +1,19 @@
|
||||
import bpy
|
||||
from bpy.types import Operator
|
||||
from bpy.props import StringProperty
|
||||
from ..utils.constants import has_multiline_text, get_version_limits
|
||||
from ..utils.constants import has_multiline_text
|
||||
|
||||
|
||||
class TEXT_TEXTURE_OT_edit_multiline_text(Operator):
|
||||
"""Open a text editor for multiline input"""
|
||||
"""Open a text editor for single-line input"""
|
||||
bl_idname = "text_texture.edit_multiline_text"
|
||||
bl_label = "Edit Multiline Text"
|
||||
bl_description = "Open a text editor for multiline input"
|
||||
bl_label = "Edit Text"
|
||||
bl_description = "Open a text editor for single-line input"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
temp_text: StringProperty(
|
||||
name="Text",
|
||||
description="Text content being edited",
|
||||
description="Single line text only - multiline not supported",
|
||||
default="",
|
||||
maxlen=4096
|
||||
)
|
||||
@@ -27,40 +27,59 @@ class TEXT_TEXTURE_OT_edit_multiline_text(Operator):
|
||||
"""Copy current text to temp storage and open dialog"""
|
||||
props = context.scene.text_texture_props
|
||||
self.temp_text = props.text
|
||||
return context.window_manager.invoke_props_dialog(self, width=600)
|
||||
return context.window_manager.invoke_props_dialog(self, width=700)
|
||||
|
||||
def draw(self, context):
|
||||
"""Draw the dialog UI"""
|
||||
"""Draw the dialog UI with single-line input"""
|
||||
layout = self.layout
|
||||
|
||||
limits = get_version_limits()
|
||||
max_lines = limits.get("max_text_lines", 50)
|
||||
max_chars = limits.get("max_text_length", 4096)
|
||||
|
||||
current_lines = self.temp_text.count('\n') + 1 if self.temp_text else 0
|
||||
max_chars = 4096
|
||||
current_chars = len(self.temp_text)
|
||||
|
||||
# Main column
|
||||
col = layout.column()
|
||||
col.prop(self, "temp_text", text="")
|
||||
|
||||
row = layout.row()
|
||||
row.label(text=f"Lines: {current_lines}/{max_lines} | Chars: {current_chars}/{max_chars}")
|
||||
col.label(text="Edit Text (Single Line Only):", icon='EDITMODE_HLT')
|
||||
|
||||
# Make the text input larger
|
||||
text_row = col.row()
|
||||
text_row.scale_y = 2.0
|
||||
text_row.prop(self, "temp_text", text="")
|
||||
|
||||
# Warning box
|
||||
col.separator()
|
||||
info_box = col.box()
|
||||
info_box.scale_y = 0.8
|
||||
info_box.label(text="⚠️ Single Line Only:", icon='ERROR')
|
||||
row = info_box.row()
|
||||
row.label(text="• Multiline text is not supported")
|
||||
|
||||
# Statistics
|
||||
col.separator()
|
||||
stats_row = col.row()
|
||||
stats_row.label(text=f"📝 Characters: {current_chars}/{max_chars}", icon='FONT_DATA')
|
||||
|
||||
# Warnings
|
||||
if current_chars > max_chars:
|
||||
col.separator()
|
||||
warning_box = col.box()
|
||||
warning_box.alert = True
|
||||
warning_box.label(text=f"⚠ Exceeds character limit! Will be trimmed to {max_chars} chars", icon='ERROR')
|
||||
|
||||
def execute(self, context):
|
||||
"""Save temp text back to main property with limits enforced"""
|
||||
"""Save temp text back to main property - reject if contains newlines"""
|
||||
props = context.scene.text_texture_props
|
||||
|
||||
limits = get_version_limits()
|
||||
max_lines = limits.get("max_text_lines", 50)
|
||||
max_chars = limits.get("max_text_length", 4096)
|
||||
# Check for newlines and reject
|
||||
if '\n' in self.temp_text:
|
||||
self.report({'ERROR'}, "Multiline text not supported. Please use single line only.")
|
||||
return {'CANCELLED'}
|
||||
|
||||
max_chars = 4096
|
||||
|
||||
# Enforce character limit
|
||||
text = self.temp_text[:max_chars]
|
||||
|
||||
lines = text.split('\n')
|
||||
if len(lines) > max_lines:
|
||||
lines = lines[:max_lines]
|
||||
text = '\n'.join(lines)
|
||||
|
||||
props.text = text
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user