| 51 | } |
| 52 | |
| 53 | void ConsoleWidget::echo(const QString &str, const QColor foregroundColor /* = {} */) |
| 54 | { |
| 55 | QTextCursor curs(document()); |
| 56 | using pos_type = decltype(curs.position()); |
| 57 | curs.setPosition(static_cast<pos_type>(toPlainText().length())); |
| 58 | setTextCursor(curs); |
| 59 | QTextCharFormat inputFormat(currentCharFormat()); |
| 60 | if (foregroundColor.isValid()) { |
| 61 | inputFormat.setForeground(QBrush(foregroundColor)); |
| 62 | } |
| 63 | insertPlainText(str); |
| 64 | curs.movePosition(QTextCursor::PreviousCharacter); |
| 65 | curs.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor, static_cast<pos_type>(str.length() - 1)); |
| 66 | curs.setCharFormat(inputFormat); |
| 67 | } |
| 68 | |
| 69 | void ConsoleWidget::appendOutput(QByteArray output) |
| 70 | { |
no test coverage detected