@@ -113,28 +113,12 @@ I POP DS
113
113
*(uchar *)dest++ = *s++;
114
114
115
115
#else
116
- return moveStrEx (indent, std::string_view {(const char *) source, count}, attr);
117
- #if 0
118
- TScreenCell *dest = &data[indent];
119
- TScreenCell *limit = &data[dataLength];
120
- uchar *s = (uchar *) source;
121
- if (attr)
122
- for (; dest < limit && count; --count, ++s, ++dest)
123
- {
124
- TScreenCell c {};
125
- c.Char = (uchar) *s;
126
- c.Attr = (uchar) attr;
127
- *dest = c;
128
- }
129
- else
130
- while (dest < limit && count--)
131
- *dest++ = TScreenCell::fromPair(*s++);
132
- #endif
116
+ return moveStr (indent, std::string_view {(const char *) source, count}, attr);
133
117
#endif
134
118
}
135
119
136
120
#ifndef __BORLANDC__
137
- void TDrawBuffer::moveBufEx (ushort indent, TScreenCell *source, ushort attr, ushort count)
121
+ void TDrawBuffer::moveBuf (ushort indent, TScreenCell *source, ushort attr, ushort count)
138
122
{
139
123
TScreenCell *dest = &data[indent];
140
124
TScreenCell *limit = &data[dataLength];
@@ -317,35 +301,12 @@ I POP DS
317
301
}
318
302
}
319
303
#else
320
- return moveCStrEx (indent, str, attrs);
321
- #if 0
322
- TScreenCell *dest = &data[indent];
323
- TScreenCell *limit = &data[dataLength];
324
- uchar c;
325
- int toggle = 1;
326
- uchar curAttr = ((uchar *)&attrs)[0];
327
-
328
- for (; dest < limit && (c = *str); ++str)
329
- {
330
- if (c == '~')
331
- {
332
- curAttr = ((uchar *) &attrs)[toggle];
333
- toggle = 1 - toggle;
334
- }
335
- else
336
- {
337
- TScreenCell cell {};
338
- cell.Char = (uchar) c;
339
- cell.Attr = (uchar) curAttr;
340
- *dest++ = cell;
341
- }
342
- }
343
- #endif
304
+ return moveCStr (indent, std::string_view {str}, attrs);
344
305
#endif
345
306
}
346
307
347
308
#ifndef __BORLANDC__
348
- void TDrawBuffer::moveCStrEx ( ushort indent, std::string_view str, ushort attrs )
309
+ void TDrawBuffer::moveCStr ( ushort indent, std::string_view str, ushort attrs )
349
310
{
350
311
size_t i = indent, j = 0 ;
351
312
int toggle = 1 ;
@@ -434,34 +395,12 @@ I POP DS
434
395
while (dest < limit && *str)
435
396
*(uchar *)dest++ = *str++;
436
397
#else
437
- return moveStrEx (indent, str, attr);
438
- #if 0
439
- TScreenCell *dest = &data[indent];
440
- TScreenCell *limit = &data[dataLength];
441
- uchar c;
442
-
443
- if (attr)
444
- for (; dest < limit && (c = *str); ++str, ++dest)
445
- {
446
- TScreenCell cell {};
447
- cell.Char = (uchar) c;
448
- cell.Attr = (uchar) attr;
449
- *dest = cell;
450
- }
451
- else
452
- while (dest < limit && *str)
453
- {
454
- auto cell = dest->Cell;
455
- cell.Char = (uchar) *str++;
456
- cell.extraWidth = 0;
457
- *dest++ = cell;;
458
- }
459
- #endif
398
+ return moveStr (indent, std::string_view {str}, attr);
460
399
#endif
461
400
}
462
401
463
402
#ifndef __BORLANDC__
464
- void TDrawBuffer::moveStrEx ( ushort indent, std::string_view str, ushort attr )
403
+ void TDrawBuffer::moveStr ( ushort indent, std::string_view str, ushort attr )
465
404
{
466
405
size_t i = indent, j = 0 ;
467
406
@@ -477,6 +416,59 @@ void TDrawBuffer::moveStrEx( ushort indent, std::string_view str, ushort attr )
477
416
}
478
417
#endif
479
418
419
+ /* ------------------------------------------------------------------------*/
420
+ /* */
421
+ /* TDrawBuffer::moveStr (2) */
422
+ /* */
423
+ /* arguments: */
424
+ /* */
425
+ /* indent - character position within the buffer where the data */
426
+ /* is to go */
427
+ /* */
428
+ /* str - pointer to a 0-terminated string of characters to */
429
+ /* be moved into the buffer */
430
+ /* */
431
+ /* attr - text attribute to be put into the buffer with each */
432
+ /* character in the string. */
433
+ /* */
434
+ /* width - number of display columns to be copied from str. */
435
+ /* */
436
+ /* begin - initial display column in str where to start counting. */
437
+ /* */
438
+ /* ------------------------------------------------------------------------*/
439
+
440
+ void TDrawBuffer::moveStr ( ushort indent, const char _FAR *str, ushort attr, ushort width, ushort begin )
441
+ {
442
+ #ifdef __BORLANDC__
443
+ int len = 0 ;
444
+ while (str[len] && len < int (begin + width))
445
+ ++len;
446
+ len -= begin;
447
+ if (len > 0 )
448
+ moveBuf (indent, str + begin, attr, min (width, len));
449
+ #else
450
+ moveStr (indent, std::string {str}, attr, width, begin);
451
+ #endif
452
+ }
453
+
454
+ #ifndef __BORLANDC__
455
+ void TDrawBuffer::moveStr ( ushort indent, std::string_view str, ushort attr, ushort width, ushort begin )
456
+ {
457
+ size_t s = 0 , remainder = 0 ;
458
+ utf8wseek (str, s, remainder , begin);
459
+ if (remainder )
460
+ moveChar (indent, ' ' , attr, remainder );
461
+ size_t d = indent + remainder ;
462
+ size_t limit = std::min (dataLength, d + width);
463
+ while (d < limit && s < str.size ())
464
+ {
465
+ if (attr)
466
+ data[d].Attr = (uchar) attr;
467
+ utf8read (&data[d], dataLength - d, d, {&str[s], str.size () - s}, s);
468
+ }
469
+ }
470
+ #endif
471
+
480
472
#ifdef __FLAT__
481
473
TDrawBuffer::TDrawBuffer () {
482
474
// This makes it possible to create TDrawBuffers for big screen widths.
0 commit comments