To get the content of first two lines from UITextView without using next line object - iphone

I need to get the two lines of content from uitextview, but without using nextline.. I entered the text continuously on uitextview without press enter the line goes to second line automatically. when I print those text it is showing single line. But the content is two or more than two lines. How I can get that content from UITextView.

You need to count (roughly) number of characters that can be entered in a single line.
Then using modulo and division you can find number of lines the text consumed.

Related

How to remove the empty lines in an html file

In the image below there are empty lines before the head, body and closing /html tags and within the body tag I want to remove. How?
put cursor at end of line with text
press Shift-ArrowRight as many times till cursor at pos 1 selecting all newlines till next text
Ctrl+Shift+L to select all similar parts
ArrowRight
Backspace as much times as needed
Esc to leave multi cursor
According to your screenshot, you can try to reduce the line height to reduce the gaps between two successive lines.
Open Settings
Type Line height in the search bar
Specify your desired line height
And done.
Also you could try reducing your font size which would automatically decrease the line height thus reducing gaps in between successive lines.
Use \n\n* in the Find Widget (Ctrl+H) with the regex option (.*) icon enabled, replace with \n. Replace All.
or better change this setting:
// List of tags, comma separated, that should have an extra newline before them. `null` defaults to `"head, body, /html"`.
`HTML > Format: Extra Liners`
In your settings.json:
"html.format.extraLiners": "" // just leave empty
Now when you format the html file those empty lines above head/body/\html should be removed (select all and Command Palette: Format Selection).

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.

Monaco editor: Replace short text with longer text

I want to use the additionalTextEdits of the autocomplete callback to replace some text.
In some cases, I want to replace a short text with a longer text and expect everything after the short text to get pushed further back.
Example:
Original: abde
Text to insert: ABC, startColumn: 1, endColumn: 3
Expected outcome: ABCde
Actual outcome: ABde
My suspicion is that the editor sees that I want to replace two characters and therefore only takes the first two characters of my provided text.
Is there a way to tell it to replace those two characters with the provided three characters and everything afterwards gets pushed one column back?
Here is the link to the documentation of the property that I use:
https://microsoft.github.io/monaco-editor/api/interfaces/monaco.languages.CompletionItem.html#additionalTextEdits

How to set width of text marks in vega-lite / altair (text wrapping and line break) for long text

I am trying to display text over time using altair (vega-lite), which works fine using a layered chart, where one is created using the alt.Chart().mark_text() function to display the text.
The text though is multiple phrases and should be wrapped (with line breaks). How can this be done?
(I do not want to use fixed line breaks, e.g. \n, at distinct positions since the text wrapping should work with zooming too)
Not exactly what you want, but you can specify a character on which to break to a new line. When zooming, the text stays the same size, so it should always fit the view.
For example making a new line for every word:
.mark_text(lineBreak=' ')

New line on UILabel messes with the word wrapping [duplicate]

Under certain circumstances, UILabel seems to bring an extra word to new line even when there is enough space for it, for example,
If one more word is appended,
Even if I force the width of the label to become something like below, it still moves the word consists of "c"s to the next line,
I've tried twisting the configuration of the UILabel, but seems it behaves the same unless I set the line breaking mode to character wrap, below is the configuration for the above cases,
And the constraints (in the first two cases, the trailing ),
Is there any reason for this particular behaviour and can I fix this? It looks weird in this way leaving that space emptied.
this is the default behavior since iOS 11, to fix orphaned words. No way to shut it off
to fix it
use the text as attributed text
or
use UItextview and turn of the scroll, edit option
or
use the custom label here
Get each line of text in a UILabel
You should set the line break to character wrap, because the letters after the space will be recognized as a word.
Hey I know this is late but I just figured out that you can cheat the system by adding a bunch of spaces at the end of the text.
If text of UILable may be changed, then it's still possible to use quick-dirty hack with "\n" - new line symbol.
Text "Aaaaaaaaaaaaaa bbb cccccccccc\ndddddd" will force UILabel to display:
Aaaaaaaaaaaaaa bbb cccccccccc
ddddddd
In Interface Builder new line can be inputted with Ctrl + Enter
If u use wordWrap, it tries to keep words in full form, as a result of this, it goes to next line. If you use character wrap, it will break on characters, and push the chars onto next line.
For Example:-
My name is ABCXXXX and I (have space here)
love myself.
Solution:-
Use NSMutableAttributedText and write love\n. It will make the "love" be in the space myself in the next line.