mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-07 18:52:30 +00:00
* Cleanup of TextElement.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@838 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -41,21 +41,27 @@
|
||||
|
||||
namespace display {
|
||||
|
||||
// Should be in text_element.cc.
|
||||
void
|
||||
TextElement::push_attribute(Canvas::attributes_list* attributes, Attributes value) {
|
||||
Attributes base = attributes->back();
|
||||
|
||||
if (value.colors() == Attributes::color_invalid)
|
||||
value.set_colors(base.colors());
|
||||
|
||||
if (value.attributes() == Attributes::a_invalid)
|
||||
value.set_attributes(base.attributes());
|
||||
|
||||
if (base.position() == value.position())
|
||||
attributes->back() = value;
|
||||
else if (base.colors() != value.colors() || base.attributes() != value.attributes())
|
||||
attributes->push_back(value);
|
||||
}
|
||||
|
||||
char*
|
||||
TextElementValueBase::print(char* first, char* last, Canvas::attributes_list* attributes, void* object) {
|
||||
// Move this stuff into a function in TextElement.
|
||||
Attributes base = attributes->back();
|
||||
Attributes current(NULL, m_attributes, Attributes::color_invalid);
|
||||
|
||||
if (current.attributes() == Attributes::a_invalid)
|
||||
current.set_attributes(base.attributes());
|
||||
else if (current.attributes() != base.attributes())
|
||||
current.set_position(first);
|
||||
|
||||
if (current.colors() == Attributes::color_invalid)
|
||||
current.set_colors(base.colors());
|
||||
else if (current.colors() != base.colors())
|
||||
current.set_position(first);
|
||||
Attributes baseAttribute = attributes->back();
|
||||
push_attribute(attributes, Attributes(first, m_attributes, Attributes::color_invalid));
|
||||
|
||||
int64_t val = value(object);
|
||||
|
||||
@@ -119,10 +125,7 @@ TextElementValueBase::print(char* first, char* last, Canvas::attributes_list* at
|
||||
first += std::max(snprintf(first, last - first + 1, "%lld", val), 0);
|
||||
}
|
||||
|
||||
if (current.position() != NULL) {
|
||||
attributes->push_back(current);
|
||||
attributes->push_back(Attributes(first, base.attributes(), base.colors()));
|
||||
}
|
||||
push_attribute(attributes, Attributes(first, baseAttribute));
|
||||
|
||||
return first;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user