MCPcopy Create free account
hub / github.com/TeXworks/texworks / echo

Method echo

src/ui/ConsoleWidget.cpp:53–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53void 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
69void ConsoleWidget::appendOutput(QByteArray output)
70{

Callers 1

acceptInputLineMethod · 0.80

Calls 3

documentFunction · 0.85
setPositionMethod · 0.80
isValidMethod · 0.45

Tested by

no test coverage detected