
Pastes the clipboard text into text edit.ĭeletes the selected text and copies it to the clipboard. The list of key bindings which are implemented for editing:ĭeletes the character to the left of the cursor.ĭeletes the character to the right of the cursor. In addition it provides methods for undo and redo. QTextDocument emits a textChanged() signal if the text changes and it also provides a isModified() function which will return true if the text has been modified since it was either loaded or since the last call to setModified with false as argument. You can also set your own document object using setDocument(). QPlainTextEdit holds a QTextDocument object which can be retrieved using the document() method. The entire text can be selected using selectAll(). The selection can be copied to the clipboard with copy(), or cut to the clipboard with cut(). If you want to set a selection in QPlainTextEdit just create one on a QTextCursor object and then make that cursor the visible cursor using setCursor(). You can retrieve the object that corresponds with the user-visible cursor using the textCursor() method. Selection of text is handled by the QTextCursor class, which provides functionality for creating selections, retrieving the text contents or deleting selections. While QPlainTextEdit does not support complex rich text rendering with tables and floats, it does support limited paragraph-based formatting that you may need in a log viewer.Īll the information about using QPlainTextEdit as a display widget also applies here. Text can be formatted in a limited way, either using a syntax highlighter (see below), or by appending html-formatted text with appendHtml(). The scrolling can be reduced with the centerOnScroll() property, making the log viewer even faster. The combination of setMaximumBlockCount() and appendPlainText() turns QPlainTextEdit into an efficient viewer for log text. If you want to limit the total number of paragraphs in a QPlainTextEdit, as it is for example useful in a log viewer, then you can use the maximumBlockCount property. The find() function can be used to find and select a given string within the text. If you use word wrap to the widget’s width WidgetWidth, you can specify whether to break on whitespace or anywhere with setWordWrapMode(). The setLineWrapMode() function is used to specify the kind of line wrap you want, WidgetWidth or NoWrap if you don’t want any wrapping. īy default, the text edit wraps words at whitespace to fit within the text edit widget. Text can be inserted using the QTextCursor class or using the convenience functions insertPlainText(), appendPlainText() or paste(). The text is set or replaced using setPlainText() which deletes the existing text and replaces it with the text passed to setPlainText().
#Plain text editor full#
(this is a simple example that can be solved by input rules, but there can be something more complex like user pastes content that completes the formatting to text already in the document)ĭoes view.updateState avoid the flickering? If not, I need to either find/make a syntax highlighter that gives me transactions instead of full ASTs or diff the intermediate AST to create a transaction that I can then dispatch w/ prosemirror.Def find (exp)ĭef moveCursor (operation) User types *, finishing *x => syntax highlighter runs, realizes this text now needs to be bold, gives me a new intermediate AST for document => I use this AST to create a new doc state w/ (or something similar) => I call view.updateState
#Plain text editor update#
Transaction is about to be dispatched => syntax highlighter runs, and creates a new AST with where highlights should be => AST gets converted to a new document state by me => I need to use view.updateState(newState) to update the state to the one the AST returned by me.
