MCPcopy Create free account
hub / github.com/GothenburgBitFactory/taskwarrior / render

Method render

src/columns/ColDescription.cpp:133–214  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

131
132////////////////////////////////////////////////////////////////////////////////
133void ColumnDescription::render(std::vector<std::string>& lines, Task& task, int width,
134 Color& color) {
135 std::string description = task.get(_name);
136
137 // This is a description
138 // <date> <anno>
139 // ...
140 if (_style == "default" || _style == "combined") {
141 if (task.annotation_count) {
142 for (const auto& i : task.getAnnotations()) {
143 Datetime dt(strtoll(i.first.substr(11).c_str(), nullptr, 10));
144 description += '\n' + std::string(_indent, ' ') + dt.toString(_dateformat) + ' ' + i.second;
145 }
146 }
147
148 std::vector<std::string> raw;
149 wrapText(raw, description, width, _hyphenate);
150
151 for (const auto& i : raw) renderStringLeft(lines, width, color, i);
152 }
153
154 // This is a description
155 else if (_style == "desc") {
156 std::vector<std::string> raw;
157 wrapText(raw, description, width, _hyphenate);
158
159 for (const auto& i : raw) renderStringLeft(lines, width, color, i);
160 }
161
162 // This is a description <date> <anno> ...
163 else if (_style == "oneline") {
164 if (task.annotation_count) {
165 for (const auto& i : task.getAnnotations()) {
166 Datetime dt(strtoll(i.first.substr(11).c_str(), nullptr, 10));
167 description += ' ' + dt.toString(_dateformat) + ' ' + i.second;
168 }
169 }
170
171 std::vector<std::string> raw;
172 wrapText(raw, description, width, _hyphenate);
173
174 for (const auto& i : raw) renderStringLeft(lines, width, color, i);
175 }
176
177 // This is a des...
178 else if (_style == "truncated") {
179 int len = utf8_width(description);
180 if (len > width)
181 renderStringLeft(lines, width, color, description.substr(0, width - 3) + "...");
182 else
183 renderStringLeft(lines, width, color, description);
184 }
185
186 // This is a description [2]
187 else if (_style == "count") {
188 if (task.annotation_count) description += " [" + format(task.annotation_count) + ']';
189
190 std::vector<std::string> raw;

Callers

nothing calls this directly

Calls 2

getAnnotationsMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected