UITextView height changes to scrollable after adding Line Break - swift

I am trying to set the height of a UITextview and all works well until I try to format the text.
An example might be "/n" or using a line break with the Swift Multiline String Literals.
After that the Textview becomes scrollable with some sort of max height value.
Does formatting the text destroy the "self.overViewTxt.contentSize.height"?
Thanks.
#IBOutlet weak var overViewTxt: UITextView!
#IBOutlet weak var overviewTxtHC: NSLayoutConstraint!
overViewTxt.text = "Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, \n sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
overviewTxtHC.constant = self.overViewTxt.contentSize.height
or
overViewTxt.text = """
Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat\n non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
"""

UITextView has a unique property of calculating height automatically. You DON'T need to take the IBOutlet of constraint or do not give any fix HEIGHT constraint, rather than you need to disable it's scrolling property and then assign any text it will be automatically became of it's size.
Note: Make sure you give proper constraints, i.e., top, bottom, leading & trailing.

Try to update frame instead of using constraint:
overViewTxt.text = "Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, \n sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
let overviewTxtHCSize = overviewTxtHC.intrinsicContentSize
overviewTxtHC.bounds.size = overviewTxtHCSize

Related

vim diff view for long lines

Is there a solution for getting a useful vim diff with very long lines? The problem I have is that for example I have one long line in one file:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
In another file I have a line very similar, but I have two changes. I capitalize ipsum to IPSUM and Duis to DUIS.
Lorem IPSUM dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. DUIS aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
The problem is that now, when I compare these two files with :diffthis, vimdiff highlights everything between IPSUM and DUIS, and this is really useless to look at. I would like to just see highlighted LOREM and DUIS and their lowercase counterparts. Here is an image of what my vimdiff view looks like. Is there a way to achieve this?
The behaviour I want is actually the default diff view in pycharm. This image is from pycharm:
I found a plugin that does what I am asking for:
https://github.com/rickhowe/diffchar.vim

Display full string in F# interactive window

If I type the following into an fsx in Visual Studio Code
let longString = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
and run F# interactive on it by highlighting and pressing Alt+Enter, the output in the interactive window is
- let longString = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepte- ur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";;
val longString : string =
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed "+[384 chars]
or as screenshot:
How can I tell the F# interactive window to display the full string? Is there a shortcut or else?
I am aware of this post, but as fas as I know this is different here because a string is not lazily-evaluated.
printfn will print it completely:
printfn "%s" longString
Alternatively, you can change the fsi object properties, for instance:
fsi.PrintWidth <- 1000;;
Also, you can use AddPrinter:
fsi.AddPrinter (fun (s:string) -> s)
Here is the documentation: https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/fsharp-interactive-options#f-interactive-structured-printing
If it is just for testing/debugging:
If you are in VSC you can run your script interactively as you mentioned. You can take advantage of that by using the interactive terminal and typing (in said interactive terminal)
longString;;
//output
val it : string =
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
This will then show the whole string and is in most cases sufficient (since you do not want to clutter your script with unnecessary outputs anyway).

In flutter development, how to print long string in visual studio code debug console?

I want to print large string in flutter but they are truncated.
Example, this is 1342 characters string:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum
dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur
adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad'); // minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum.
Only the top 1022 characters will be printed.
I try to use debugPrint and print functions but nothing.
What I can do?
That's due to VS Code truncating big strings, usually bigger than 1000 char of being printed at once.
You can try a little "hack" by splitting it into words and print each of it.
myLongString.split(' ').forEach((word) => print(" " + word));
You can also try to use the logging package, but probably it will experience the same problem when trying to print the whole string, since it is trying to stdout all at once.
you can use log(message) function.

Parse multipart/form-data cakephp 3

I'm currently trying to parse the multipart/form-data that I send through Postman plugin in Chrome. However, I get the following output:
'------WebKitFormBoundarymsXhoqlRBbTbsZFb
Content-Disposition: form-data; name="album_id"
2
------WebKitFormBoundarymsXhoqlRBbTbsZFb
Content-Disposition: form-data; name="description"
haiahaahahahdaisdhisadhisadihsdhiiahsd
------WebKitFormBoundarymsXhoqlRBbTbsZFb
Content-Disposition: form-data; name="favorite"
true
------WebKitFormBoundarymsXhoqlRBbTbsZFb
Content-Disposition: form-data; name="uploadfile"; filename="test2.txt"
Content-Type: text/plain
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
------WebKitFormBoundarymsXhoqlRBbTbsZFb
Content-Disposition: form-data; name="uploadfile"; filename="test.txt"
Content-Type: text/plain
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
------WebKitFormBoundarymsXhoqlRBbTbsZFb--
'
This output do I get when I try to debug $this->request->input(). When I try $this->request->input('json_decode') I get an empty array, so I'm assuming that the data isn't in a proper format (just a string). Before I write my own algorithm I want to be sure that I'm not reinventing the wheel with this one. I'm doing something wrong? Or if not, does there exist some Cakephp 3 function which takes care of this?
Update
I found what is wrong in my code and it seems like the routing process somehow empties the post array to early. When I try Postman with the following endpoint http://vecto.app/api/pictures $this->request->data is empty. However, when I try to access the endpoint http://vecto.app/pictures the $this->request->data is filled with the information. Does anyone know what is wrong with the following routing setup:
Router::prefix('api', function ($routes) {
$routes->extensions(['json', 'xml']);
$routes->resources('Users');
$routes->resources('Pictures');
// We connect the /register action so we can simply extend the CRUD Plugin add() method
// and benefit of already available logic like validation and response codes instead of having to reinvent the wheel.
Router::connect('/api/users/register', ['controller' => 'Users', 'action' => 'add', 'prefix' => 'api']);
$routes->fallbacks('InflectedRoute');
});
I finally found the solution which was a beforeFilter that emptied the $this->request->data array. Therefore, the input array wasn't empty but the data array was empty. This is the code that caused the problem:
public function beforeFilter(Event $event) {
if ($this->request->is('post')) {
$data = $this->request;
$this->request->data = $this->request->input(function ($data) {
return json_decode($data, true);
});
}
}

Asp classic mail function sends string with blank spaces

I am sending a mail with CDO.Message object and the mail arrives with a blank space between characters.
For example, I sent this string:
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
And arrives this:
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in volup tate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
Check the strong word for understand. Why occurre that?
My code
Set Mail= Server.CreateObject("CDO.Message")
Set MailConfig = Server.CreateObject("CDO.Configuration")
Mail.From = example#hotmail.com
Mail.Bcc = "example#hotmail.com"
Mail.Subject = "Example"
MailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = sendUsing
MailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpServer
MailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = smtpServerPort
MailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
MailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = smtpUseSSL
MailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = smtpConnectionTimeout
MailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = mailUsername
MailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = mailPassword
MailConfig.Fields.Update
Mail.Configuration = MailConfig
strBody = "the string"
Mail.HTMLBody = strBody
Mail.HTMLBodyPart.Charset = "utf-8"
Mail.send
The extra space appears every 991 characters.
I added this:
Mail.HTMLBodyPart.ContentTransferEncoding = "quoted-printable"
And has been solved.
If you don't send HTML in the email body, do not make use of Mail.HTMLBody, instead use Mail.TextBody which is the correct choice when sending pure text. Textbody preserves line breaks and other control characters which HTMLBody does not.
I have experienced similar issues in Outlook when displaying raw text sent with HTMLBody, so I believe this simple change will fix it.