MCPcopy Create free account
hub / github.com/RobTillaart/Arduino / write

Method write

libraries/LineFormatter/LineFormatter.cpp:35–77  ·  view source on GitHub ↗

////////////////////////////////////// WRITE - the core

Source from the content-addressed store, hash-verified

33// WRITE - the core
34//
35size_t LineFormatter::write(uint8_t c)
36{
37 // handle tabs.
38 if (_tabCount && (c == '\t'))
39 {
40 write(' ');
41 for (int i = 0; i < _tabCount; i++)
42 {
43 if (_tabStop[i] > _pos + 1) // assume sorted
44 {
45 gotoPos(_tabStop[i] - 1);
46 break;
47 }
48 }
49 }
50 else
51 {
52 _stream->write(c);
53 _pos++;
54 }
55
56 // handle return
57 if (c == '\n')
58 {
59 _pos = 0;
60 _lineCount++;
61 _anl++;
62 }
63
64 // handle _maxPos if enabled (_maxPos > 0)
65 if ((_maxPos > 0) && (_pos == _maxPos))
66 {
67 write('\n'); // recursive call!
68 }
69
70 // handle autoNewLine
71 if (_autoNewLine && (_anl == _autoNewLine))
72 {
73 write('\n'); // recursive call!
74 _anl = 0;
75 }
76 return 1;
77}
78
79
80void LineFormatter::setMaxLength(uint8_t maxPos)

Callers 3

unittestFunction · 0.45
_writeRegisterMethod · 0.45
_readRegisterMethod · 0.45

Calls

no outgoing calls

Tested by 1

unittestFunction · 0.36