mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-07 18:52:30 +00:00
* 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:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user