MCPcopy Create free account
hub / github.com/crawl/crawl / chop

Method chop

crawl-ref/source/format.cc:432–455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430}
431
432formatted_string formatted_string::chop(int length, bool pad) const
433{
434 formatted_string result;
435 for (const fs_op& op : ops)
436 {
437 if (op.type == FSOP_TEXT)
438 {
439 result.ops.push_back(op);
440 string& new_string = result.ops[result.ops.size()-1].text;
441 int w = strwidth(new_string);
442 if (w > length)
443 new_string = chop_string(new_string, length, false);
444 length -= w;
445 if (length <= 0)
446 break;
447 }
448 else
449 result.ops.push_back(op);
450 }
451 if (pad && length > 0)
452 result += string(length, ' ');
453
454 return result;
455}
456
457formatted_string formatted_string::chop_bytes(int length) const
458{

Callers 6

do_layoutMethod · 0.80
_renderMethod · 0.80
pack_buffersMethod · 0.80
_print_stats_qvFunction · 0.80
wrap_text_to_sizeMethod · 0.80
_renderMethod · 0.80

Calls 4

strwidthFunction · 0.85
chop_stringFunction · 0.85
push_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected