# Prevent string from splitting

I have two elements of a grid:

Framed[Pane["this is a very long string", {130, 20},
ImageSizeAction -> "Clip"]]
Framed[Pane["thisisaverylongstring", {130, 20},
ImageSizeAction -> "Clip"]]


Two questions:

1) How can I prevent the first string from being split at word boundaries?

2) Can I display instead the ends of strings, clipped from the left? Such that we have "..isaverylongstring" instead of "thisisaverylongs..." like

• Don't understand 2), but is BaseStyle -> LineBreakWithin -> False the answer for 1)? – Kuba May 10 '17 at 18:11
• @Kuba Apologies for not being clear. I mean like "..ylongstring" instead of "thisisaverylong..." I will edit the question. Thank you for 1) -- this is exactly what I need! – Stitch May 10 '17 at 18:13

The statement

Framed[Pane["thisisaverylongstring", {130, 20}, ScrollPosition -> {130, 20}]]


generates a pane in which the initial position is the bottom line, thereby showing the end of the multi-line string. Even specifying the "Clip" option, I find that the panes are scrollable.

• Addition of BaseStyle -> LineBreakWithin -> False makes this perfect solution. Note that ScrollPosition -> 100 is sufficient, the number just should be sufficiently large. Checked with version 11.1.1 on Windows 7 x64. – Alexey Popkov May 11 '17 at 0:36
• @AlexeyPopkov You are right. Almost. If the string fits the box (it is shorter and doesn't need to be clipped), the content is empty somehow... Try to increase the width to 200 or shorten the string. – Stitch May 11 '17 at 0:54
• @Stitch Yeah, Pane in this respect is still painful. :( Probably worth reporting as it doesn't look as expected behavior. – Alexey Popkov May 11 '17 at 1:06

If we use Text's ability to align the string and convert it to Graphis, then combined with Kuba's suggestion in the comments above, we can do it:

Framed@Pane[
Graphics@Style[Text["thisisaverylongstring", {0, 0}, {1, 0}],20],
{130, 30}, Alignment -> {Left, Center},
BaseStyle -> LineBreakWithin -> False
]

Framed@Pane[
Graphics@Style[Text["thisisaverylongstring", {0, 0}, {-1, 0}], 20],
{130, 30}, Alignment -> {Left, Center},
BaseStyle -> LineBreakWithin -> False
]


Doesn't look like an ideal solution, but at least it works.