@@ -63,14 +63,15 @@ struct TrivialLineBuffer
63
63
64
64
ColumnCount usedColumns {};
65
65
crispy::BufferFragment<char > text {};
66
-
66
+ std::vector< bool > tabstops = std::vector< bool >(displayWidth.value, false );
67
67
void reset (GraphicsAttributes attributes) noexcept
68
68
{
69
69
textAttributes = attributes;
70
70
fillAttributes = attributes;
71
71
hyperlink = {};
72
72
usedColumns = {};
73
73
text.reset ();
74
+ tabstops.clear ();
74
75
}
75
76
};
76
77
@@ -233,6 +234,15 @@ class Line
233
234
return inflatedBuffer ().at (unbox<size_t >(column)).empty ();
234
235
}
235
236
237
+ [[nodiscard]] bool hasTabstop (ColumnOffset column) const noexcept
238
+ {
239
+ Require (ColumnOffset (0 ) <= column);
240
+ Require (column <= ColumnOffset::cast_from (size ()));
241
+ if (isInflatedBuffer ())
242
+ return cells ()[column.as <size_t >()].isTab ();
243
+ return trivialBuffer ().tabstops [column.as <size_t >()];
244
+ }
245
+
236
246
[[nodiscard]] uint8_t cellWidthAt (ColumnOffset column) const noexcept
237
247
{
238
248
#if 0 // TODO: This optimization - but only when we return actual widths and not always 1.
@@ -257,6 +267,8 @@ class Line
257
267
[[nodiscard]] bool wrappable () const noexcept { return isFlagEnabled (LineFlags::Wrappable); }
258
268
void setWrappable (bool enable) { setFlag (LineFlags::Wrappable, enable); }
259
269
270
+ void setTab (ColumnOffset start, ColumnCount n, bool tab);
271
+
260
272
[[nodiscard]] LineFlags wrappableFlag () const noexcept
261
273
{
262
274
return wrappable () ? LineFlags::Wrappable : LineFlags::None;
@@ -315,7 +327,18 @@ class Line
315
327
return !std::holds_alternative<TrivialBuffer>(storage_);
316
328
}
317
329
318
- void setBuffer (Storage buffer) noexcept { storage_ = std::move (buffer); }
330
+ void setBuffer (Storage buffer) noexcept
331
+ {
332
+ if (isTrivialBuffer ())
333
+ std::get<TrivialBuffer>(buffer).tabstops = std::move (trivialBuffer ().tabstops );
334
+ else
335
+ {
336
+ size_t cellNr = 0 ;
337
+ for (auto const & cell: cells ())
338
+ std::get<TrivialBuffer>(buffer).tabstops [cellNr++] = cell.isTab ();
339
+ }
340
+ storage_ = std::move (buffer);
341
+ }
319
342
320
343
// Tests if the given text can be matched in this line at the exact given start column.
321
344
[[nodiscard]] bool matchTextAt (std::u32string_view text, ColumnOffset startColumn) const noexcept
0 commit comments