MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / processText

Method processText

app/src/UI/Widgets/Terminal.cpp:1363–1422  ·  view source on GitHub ↗

* @brief Processes a single character in the context of normal text input. */

Source from the content-addressed store, hash-verified

1361 * @brief Processes a single character in the context of normal text input.
1362 */
1363void Widgets::Terminal::processText(const QChar& byte, QString& text)
1364{
1365 const ushort code = byte.unicode();
1366 const bool vt = vt100emulation();
1367
1368 if (code == '\n') {
1369 appendString(text);
1370 text.clear();
1371 setCursorPosition(0, m_cursorPosition.y() + 1);
1372 return;
1373 }
1374
1375 if (!vt) {
1376 if (byte.isPrint())
1377 text.append(byte);
1378
1379 return;
1380 }
1381
1382 switch (code) {
1383 case 0x1b:
1384 appendString(text);
1385 text.clear();
1386 m_state = Escape;
1387 return;
1388 case '\r':
1389 appendString(text);
1390 text.clear();
1391 setCursorPosition(0, m_cursorPosition.y());
1392 return;
1393 case '\b':
1394 if (m_cursorPosition.x() == 0)
1395 return;
1396
1397 appendString(text);
1398 text.clear();
1399 setCursorPosition(m_cursorPosition.x() - 1, m_cursorPosition.y());
1400 return;
1401 case 0x7F:
1402 appendString(text);
1403 text.clear();
1404 removeStringFromCursor(RightDirection, 1);
1405 return;
1406 case '\t': {
1407 appendString(text);
1408 text.clear();
1409 const int nextTab = (m_cursorPosition.x() / 8 + 1) * 8;
1410 const int spaces = nextTab - m_cursorPosition.x();
1411 text.fill(' ', spaces);
1412 appendString(text);
1413 text.clear();
1414 return;
1415 }
1416 default:
1417 break;
1418 }
1419
1420 if (byte.isPrint())

Callers

nothing calls this directly

Calls 4

xMethod · 0.80
clearMethod · 0.45
appendMethod · 0.45
fillMethod · 0.45

Tested by

no test coverage detected