How to add a force line-break in a draw2d TextFlow - swt

How do I add a forced line-break within a draw2d TextFlow figure.
I build a IFigure by adding several different objects. Amongst other things I add a FlowPage containing a TextFlow. But I could not find an option to force line-breaks at specific locations.
Figure fig = new Figure();
fig.setLayoutManager(new FreeformLayout());
FlowPage flow = new FlowPage();
flow.setSize(100,100);
TextFlow text = new textFlow("A rather long text without any line-breaks. Lorem Ipsum dolor sit amet.");
flow.add(text);
fig.add(flow);
fig.setSite(100,100);

The common LineFeed character \n solved this problem. Inserted somewhere inside the String it forces a line-break.

Related

Howto hide the text (and its lenght) that are editing?

I want write password of the root to the shell, but without move the cursor when i write it.
prompt = {"Senha de Administrador: "}; your textdefaults = {""}; your text`rowscols = [1,25];
your textsenha_root = inputdlg (prompt, "para Alterar Permissões de porta USB ", ...
your text rowscols, defaults);
I can't, for example, change the color text to the background tex, as alternative
There are several ways to hide text while editing it, depending on what you mean by "hiding" the text and the context in which you are editing the text. Here are a few options:
If you are editing text in a word processor or text editor, you can use the "hidden" text formatting feature to hide the text. This will cause the text to be invisible while you are editing, but it will be visible when the document is printed or exported.
If you are writing code and want to hide certain lines or blocks of code while you are editing, you can use a code folding feature to collapse the code so that it takes up less space in the editor.
If you are writing text on a website and want to hide it from view, you can use the "display: none" CSS style to hide the text. This will cause the text to be invisible to users, but it will still be present in the HTML code of the page.

Set custom breakpoints in long String during dynamic resize

I have a string of text that dynamically resizes. At its core its basically a Text widget in a SizedBox in a Column.
When it resizes, the words wrap to the next as you typically expect...it breaks to the next line by using the 'SPACES' between words (as opposed to breaking up words character by character).
However, an email address can be a very long string without spaces. When it no longer fits within the bounds of the box it begins to resize itself by breaking on individual characters and moving into the next line.
It's a minor issue, but not visually appealing.
How might one create breakpoints within the String to resize itself by wrapping to the next line based on custom characters? For example, in an email address I'd prefer it break on the '#' and/or '.' before resorting to breaking up the String on individual characters.

WKInterfaceLabel ignoring \n indicators

I'm getting text from the MediaWiki API, and it includes getting \n text which indicates a new line. When I set the API results as the text of a WKInterfaceLabel, the \n's disappears, but no new line is created.
Any way to fix it?
Example. From this term:
[...] forms.\n\n==Use in writing systems==\n\n===English===\nIn Modern English [[English orthography|spelling]], {{angbr|i}} represents several different sounds, either the diphthong {{IPAc-en|aɪ}} ("long" {{angbr|i}}) as in ''kite'', the short [...]
It's meant to remove the \n's and replace it with new lines. What's added to the label is this text minus the \n's, but no new lines.

How to make a very long non-stop string (without any space in it) break into many new lines when showing in HTMLPanel?

I have an HTMLPanel inside a FlowPanel which is inside a ScrollPanel like this.
<g:ScrollPanel>
<g:FlowPanel>
<g:HTMLPanel ui:field="showMessageHTMLPanel" width="600px"/>
</g:FlowPanel>
</g:ScrollPanel>
The showMessageHTMLPanel is used to hold the text that user enter a TextArea.
I want that the showMessageHTMLPanel should show exactly like how it was displayed in TextArea.
Ex,if user types in many sentences in new lines in TextArea, then the showMessageHTMLPanel should show similar like this:
This is text1
This is text2.
So here is what I did. I uses new SafeHtmlBuilder().appendEscapedLines(message).toSafeHtml().
HTML showMessageHTML = new HTML(new SafeHtmlBuilder().appendEscapedLines(message).toSafeHtml());
getView().getShowMessageHTMLPanel().add(showMessageHTML);
The result is that It breaks the lines quite OK, no problem.
However, When I type a non-stop very long string ( a String that doesn't have any space on it) into a TextArea. Ex, see this non-stop string:
"Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
As you saw, even this non-stop string has no space, but when typing in TextArea then the string will automatically fall into new lines.
Ok, now when I show that non-stop string in getView().getShowMessageHTMLPanel(), it showed the text as one straight line without any line break:
Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.
The user has to scroll the scrollbar to see the complete text. This is unacceptable since it is too hard to see the whole line. Also many urls are non-stop string without spaces. So the user may not be able to copy the url.
How to make a very long non-stop string (without any space in it) break into many new lines when showing in HTMLPanel?
Or
Do you know any other widget that can handle this?
I am sure, a simple css property should help.
word-wrap:break-word;
Detail here

Matlab text object carriage return issue + text outside graph

I'm trying to show some text on top of a plot. Using
text(13,15200,('~ 12h'),'HorizontalAlignment','right','VerticalAlignment','middle','FontSize',10,'FontAngle','italic');
I can create the text box how I want it. But a thing I didn't manage to do is to create a carriage return within that text object. Already tried to add '\r' or '\n' but the only thing I get is the display of '\r' or '\n' with out breaking the line. Any ideas?
And i now that text object are used to put text WITHIN axes. But I am still trying to find a way to put some text outside the grap. Searching stackoverflow I found this Post about using UICONTROL. It works great but when I export to EPS the text seems to be in pixel format and NOT vector - so it looks really bad. Is there another way besides using uicontrol??
Thanks a lot for help!
In text that is not interpreted, you can specify line breaks using the carriage return character, which has the ascii code 10.
text(x,y,sprintf('break after this%snew line here',char(10)));
To allow text outside axes, you need to turn off clipping for the text object
text(x,y,.....,'clipping','off')