How to append text to QPlainTextEdit without adding newline, and keep scroll at the bottom?

I’ll just quote what I found here: http://www.jcjc-dev.com/2013/03/qt-48-appending-text-to-qtextedit.html We just need to move the cursor to the end of the contents in the QTextEdit and use insertPlainText. In my code, it looks like this: myTextEdit->moveCursor (QTextCursor::End); myTextEdit->insertPlainText (myString); myTextEdit->moveCursor (QTextCursor::End); As simple as that. If your application needs to keep the cursor where it was … Read more

Removing a newline character at the end of a file

A simpler solution than the accepted one: truncate -s -1 <<file>> From the truncate man page (man truncate): -s, –size=SIZE set or adjust the file size by SIZE SIZE may also be prefixed by one of the following modifying characters: ‘+’ extend by, ‘-‘ reduce by, ‘<‘ at most, ‘>’ at least, “https://stackoverflow.com/” round down … Read more

Newline in Haskell String?

To create a string containing a newline, just write “\n”. If you run your program on Windows, it will automatically be converted to “\r\n”. Note that calling show on it will escape the newline (or any other meta-characters), so don’t do foo ++ (show “\n”) or foo ++ (show ‘\n’) – just use foo ++ … Read more

Rails 3: How to display properly text from “textarea”?

Rails got a helper method out of the box, so you dont have to write your own method. From the documentation: simple_format(text, html_options={}, options={}) my_text = “Here is some basic text…\n…with a line break.” simple_format(my_text) # => “<p>Here is some basic text…\n<br />…with a line break.</p>” more_text = “We want to put a paragraph…\n\n…right there.” … Read more