How to Handle Text in a Prompt TextField that is too long

I am working on an action that helps the user to clean line endings of a draft.

Therefor I want the action to loop through the whole draft. At every line ending a prompt should show the text before a line ending in one text field and the text after the line ending in another text field. And the user is offered buttons to pick if the line ending actually indicates a new paragraph or not (and if not and if a hyphen is involved how to handle the latter).

The problem: The texts before and after the line endings presumably are too long to fit into the text fields. So they have to be truncated. A fixed number of characters is difficult as the font has proportional characters and so an “m” uses more space than an “i”, an “—” more than a “.”, etc. And the devices’s screen size and the user’s system wide font size setting might influence the amount of visible characters in the text field too.

So my question is if it is possible to chose which part of a too long text is visible in a text field. The second text field in my action has to show the first characters of the second line. But the first text field has to show the last characters of the first line. In short: A setting to truncate either left or right.

Bonus question: What is the difference between addTextField and addTextView, as both descriptions in the script reference say “Add a text input field to the prompt”?

Have you considered using an Advanced Preview for this sort of thing? It might give you the control you are looking for.

HTML Previews are not limited to this purpose. The content displayed can be dynamically generated, use all the tools of the browser (HTML/CSS/JavaScript), load remote content (images, scripts, stylesheets, run scripts, and even send data back to Drafts from HTML forms or other dynamic content in the page - allowing the HTML Preview step to be used to generate custom user interfaces for Drafts actions.

PS: I have been ruminating to not use a prompt with text fields at all but to loop through the draft in the editor window itself. But that would make the whole process pretty fitful. And I would not know how to keep the prompt with the option buttons (I would still work with those) from covering the part of the editor with the respective line ending.

No, I have not considered it yet but I will look into it. Thank you.

Text fields are single line text inputs. Text views are multiline (there’s even a parameter to control height). You might also consider addLabel if these fields do not need to be editable.

Thank you.

So a multiline text view field might have enough space to display the whole text line. But if not there is no setting here either to chose which end to truncate, right?

The Advanced Preview approach of @sylumer looks very interesting but I would have to learn it first while I have worked with Prompt actions already.

By the way, this is my use case: Scans from books. OCR nowadays works really well but delivers texts with lots of line endings which you sometimes cannot tell from just text wrappings. The action should make them distinguishable and make it easy to get either proper Markdown paragraph endings with additional empty lines, or spaces for ongoing paragraphs, with either preserved or removed hyphens.

Text views and labels will not truncate. Text views will be scrollable if the text exceeds the height you allow. Labels will grow to fit the text.

Ah, now I get it. I have used labels in other actions—just as labels. But not to display dynamic content. An interesting approach that I would have never thought of. Thanks again.