mirror of https://github.com/mgba-emu/mgba.git
Qt: handle newlines in TextBuffer print()
This commit is contained in:
parent
a114207828
commit
b272968969
|
@ -51,8 +51,7 @@ void ScriptingTextBuffer::setBufferName(const QString& name) {
|
||||||
|
|
||||||
void ScriptingTextBuffer::print(const QString& text) {
|
void ScriptingTextBuffer::print(const QString& text) {
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
QString split(text);
|
for (QString split : text.split('\n')) {
|
||||||
m_shim.cursor.beginEditBlock();
|
|
||||||
while (m_shim.cursor.positionInBlock() + split.length() > m_dims.width()) {
|
while (m_shim.cursor.positionInBlock() + split.length() > m_dims.width()) {
|
||||||
int cut = m_dims.width() - m_shim.cursor.positionInBlock();
|
int cut = m_dims.width() - m_shim.cursor.positionInBlock();
|
||||||
if (!m_shim.cursor.atBlockEnd()) {
|
if (!m_shim.cursor.atBlockEnd()) {
|
||||||
|
@ -70,7 +69,7 @@ void ScriptingTextBuffer::print(const QString& text) {
|
||||||
m_shim.cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, split.length());
|
m_shim.cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, split.length());
|
||||||
}
|
}
|
||||||
m_shim.cursor.insertText(split);
|
m_shim.cursor.insertText(split);
|
||||||
m_shim.cursor.endEditBlock();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptingTextBuffer::clear() {
|
void ScriptingTextBuffer::clear() {
|
||||||
|
|
Loading…
Reference in New Issue