MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / write

Method write

common/script/scriptconsole.cpp:97–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97void ScriptConsole::write(const char* data, size_t len)
98{
99 if (data == nullptr || len == 0) {
100 return;
101 }
102
103 std::lock_guard<std::mutex> lock(mMutex);
104 for (size_t i = 0; i < len; i++) {
105 const char c = data[i];
106 if (c == '\n') {
107 // Close the row. An empty run of newlines still produces blank
108 // rows, which is what a script printing "\n\n" means to see.
109 if (!mOpen) {
110 appendChar(' ');
111 mLines.back().clear();
112 }
113 mOpen = false;
114 }
115 else if (c == '\t') {
116 const size_t col = (mOpen && !mLines.empty()) ? mLines.back().size() : 0;
117 for (size_t pad = TAB_WIDTH - (col % TAB_WIDTH); pad > 0; pad--) {
118 appendChar(' ');
119 }
120 }
121 else if (c == '\r' || (unsigned char)c < 0x20 || c == 0x7F) {
122 continue; // control characters have no cell in the pane
123 }
124 else {
125 appendChar(c);
126 }
127 }
128 mGen++;
129}
130
131void ScriptConsole::log(const std::string& text)
132{

Callers 2

ckpt_console_writeFunction · 0.45
consoleStreamWriteFunction · 0.45

Calls 4

backMethod · 0.80
clearMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected