6663b6c9
adorian
projet complet av...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#include <escher/buffer_text_view.h>
#include <string.h>
#include <assert.h>
BufferTextView::BufferTextView(KDText::FontSize size, float horizontalAlignment, float verticalAlignment,
KDColor textColor, KDColor backgroundColor) :
TextView(size, horizontalAlignment, verticalAlignment, textColor, backgroundColor),
m_buffer()
{
}
const char * BufferTextView::text() const {
return m_buffer;
}
void BufferTextView::setText(const char * text) {
assert(strlen(text) < sizeof(m_buffer));
strlcpy(m_buffer, text, sizeof(m_buffer));
markRectAsDirty(bounds());
}
void BufferTextView::appendText(const char * text) {
size_t previousTextLength = strlen(m_buffer);
size_t argTextLength = strlen(text);
if (previousTextLength + argTextLength + 1 < k_maxNumberOfChar) {
strlcpy(&m_buffer[previousTextLength], text, argTextLength + 1);
}
}
|