* Starting work on ElementText for displaying generic information.

* If a storage error was thrown from make_directory in
EntryList::open, it would try to erase a FileMeta that wasn't inserted.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@753 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-08-09 19:55:34 +00:00
parent ba28df3ff2
commit ca58b43d8b
17 changed files with 360 additions and 67 deletions
+21 -14
View File
@@ -36,21 +36,12 @@
#include "config.h"
#include <cstring>
#include "text_element_string.h"
namespace display {
char*
TextElementString::print(char* first, const char* last, Canvas::attributes_list* attributes, void* object) {
size_t length = std::min<size_t>(last - first, m_string.size());
if (length == 0)
return first;
std::memcpy(first, m_string.c_str(), length);
TextElementStringBase::print(char* first, const 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);
@@ -65,17 +56,33 @@ TextElementString::print(char* first, const char* last, Canvas::attributes_list*
else if (current.colors() != base.colors())
current.set_position(first);
first = copy_string(first, last, object);
if (current.position() != NULL) {
attributes->push_back(current);
attributes->push_back(Attributes(first + length, base.attributes(), base.colors()));
attributes->push_back(Attributes(first, base.attributes(), base.colors()));
}
return first;
}
char*
TextElementString::copy_string(char* first, const char* last, void* object) {
extent_type length = std::min<extent_type>(last - first, m_string.size());
if (length == 0)
return first;
std::memcpy(first, m_string.c_str(), std::min<extent_type>(length, last - first));
return first + length;
}
TextElementString::extent_type
TextElementString::max_length() {
return m_string.size();
char*
TextElementCString::copy_string(char* first, const char* last, void* object) {
std::memcpy(first, m_string, std::min<extent_type>(m_length, last - first));
return first + m_length;
}
}