18void setTextEditStyle(QTextEdit *edit, QColor fg, QColor bg, QFont font);
19void highlightBlock(QTextBlock block, QFont font, QColor foreground,
22class TransmitTextEdit :
public QTextEdit {
23 friend class PillRenderer;
24 friend class ScopedDocumentMutation;
27 explicit TransmitTextEdit(QWidget *parent);
30 static QPair<int, int> relativeTextCursorPosition(QTextCursor cursor) {
31 auto c = QTextCursor(cursor);
32 c.movePosition(QTextCursor::End);
33 int last = c.position();
35 auto cc = QTextCursor(cursor);
36 int relstart = last - qMin(cc.selectionStart(), cc.selectionEnd());
37 int relend = last - qMax(cc.selectionStart(), cc.selectionEnd());
39 return {relstart, relend};
42 int charsSent()
const {
return m_sent; }
43 void setCharsSent(
int n);
45 QString sentText()
const {
return m_textSent; }
47 QString unsentText()
const {
return toPlainText().mid(charsSent()); }
49 QString toPlainText()
const;
50 void setPlainText(
const QString &text);
51 void replaceUnsentText(
const QString &text,
bool keepCursor);
52 void replacePlainText(
const QString &text,
bool keepCursor);
56 void setFont(QFont f);
57 void setFont(QFont f, QColor fg, QColor bg);
60 bool isProtected()
const {
return m_protected; }
61 void setProtected(
bool protect);
62 bool cursorShouldBeProtected(QTextCursor c);
64 bool isEmpty()
const {
return toPlainText().isEmpty(); }
65 bool isDirty()
const {
return m_dirty; }
66 void setClean() { m_dirty =
false; }
68 PillRenderer *pillRenderer()
const {
return m_pillRenderer; }
71 void highlightCharsSent();
74 void paintEvent(QPaintEvent *event)
override;
75 bool event(QEvent *e)
override;
76 bool eventFilter(QObject * , QEvent *e)
override;
77 void keyPressEvent(QKeyEvent *e)
override;
80 void on_selectionChanged();
81 void on_textContentsChanged(
int pos,
int rem,
int add);
86 void beginInternalDocumentMutation();
87 void endInternalDocumentMutation();
88 bool isInternalDocumentMutationActive()
const;
98 PillRenderer *m_pillRenderer;
99 bool m_isHighlighting =
false;
Definition TransmitTextSourceMirror.h:8