3
$\begingroup$

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"]]

Blockquote

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

Blockquote

$\endgroup$
  • 3
    $\begingroup$ Don't understand 2), but is BaseStyle -> LineBreakWithin -> False the answer for 1)? $\endgroup$ – Kuba May 10 '17 at 18:11
  • $\begingroup$ @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! $\endgroup$ – Stitch May 10 '17 at 18:13
4
$\begingroup$

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.

enter image description here

$\endgroup$
  • 1
    $\begingroup$ 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. $\endgroup$ – Alexey Popkov May 11 '17 at 0:36
  • 1
    $\begingroup$ @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. $\endgroup$ – Stitch May 11 '17 at 0:54
  • $\begingroup$ @Stitch Yeah, Pane in this respect is still painful. :( Probably worth reporting as it doesn't look as expected behavior. $\endgroup$ – Alexey Popkov May 11 '17 at 1:06
2
$\begingroup$

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
 ]

Blockquote

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.