MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / insertAttributedText

Method insertAttributedText

Source/UIComponents/CtrlrTextEditor.cpp:40–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40void CtrlrTextEditor::insertAttributedText (const AttributedString &text)
41{
42 if (!getText().endsWithChar('\n'))
43 {
44 setCaretPosition (getText().length());
45 insertTextAtCaret ("\n");
46 }
47
48 Range<int> lastRange, currentRange;
49
50 currentRange = text.getAttribute(0).range;
51
52 for (int i=0; i<text.getNumAttributes(); i++)
53 {
54 const AttributedString::Attribute a = text.getAttribute(i);
55
56 if (currentRange != a.range)
57 {
58 insertTextAtCaret (text.getText().substring (currentRange.getStart(), currentRange.getEnd()));
59 }
60
61 currentRange = a.range;
62
63 setFont (a.font);
64 setColour (TextEditor::textColourId, a.colour);
65 }
66
67 insertTextAtCaret (text.getText().substring (currentRange.getStart(), currentRange.getEnd()));
68}
69
70const String CtrlrTextEditor::getLineAtPosition(const int index)
71{

Callers 1

insertOutputMethod · 0.80

Calls 11

endsWithCharMethod · 0.80
getAttributeMethod · 0.80
getNumAttributesMethod · 0.80
getTextFunction · 0.50
setFontFunction · 0.50
setColourFunction · 0.50
lengthMethod · 0.45
substringMethod · 0.45
getTextMethod · 0.45
getStartMethod · 0.45
getEndMethod · 0.45

Tested by

no test coverage detected