27 #define YUILogComponent "ui"
30 #include "YUISymbols.h"
34 typedef std::deque<std::string> StringDeque;
35 typedef std::deque<std::string>::iterator StringDequeIterator;
36 typedef std::deque<std::string>::const_iterator StringDequeConstIterator;
42 YLogViewPrivate(
const std::string & label,
int visibleLines,
int maxLines )
44 , visibleLines( visibleLines )
45 , maxLines( maxLines )
62 YUI_CHECK_NEW( priv );
92 return priv->visibleLines;
99 priv->visibleLines = newVisibleLines;
106 return priv->maxLines;
113 int linesToDelete = priv->maxLines - newMaxLines;
114 priv->maxLines = newMaxLines;
116 for (
int i=0; i < linesToDelete; i++ )
117 priv->logText.pop_front();
119 if ( linesToDelete > 0 )
129 for ( StringDequeConstIterator it = priv->logText.begin();
130 it != priv->logText.end();
136 if ( ! text.empty() )
140 if ( *(text.rbegin()) ==
'\n' )
142 text.resize( text.size() - 1 );
153 if ( priv->logText.empty() )
156 return priv->logText.back();
163 std::string text = newText;
164 std::string::size_type from = 0;
165 std::string::size_type to = 0;
170 while ( to < text.size() )
173 to = text.find(
'\n', from );
174 if ( to == std::string::npos )
180 appendLine( text.substr( from, to - from ) );
183 if ( to < text.size() )
186 appendLine( text.substr( to, text.size() - to ) );
194 YLogView::appendLine(
const std::string & line )
196 priv->logText.push_back( line );
200 priv->logText.pop_front();
212 priv->logText.clear();
220 priv->logText.clear();
227 return priv->logText.size();
232 YLogView::updateDisplay()
253 propSet.
add(
YProperty( YUIProperty_Value, YStringProperty ) );
254 propSet.
add(
YProperty( YUIProperty_LastLine, YStringProperty ) );
255 propSet.
add(
YProperty( YUIProperty_VisibleLines, YIntegerProperty ) );
256 propSet.
add(
YProperty( YUIProperty_MaxLines, YIntegerProperty ) );
257 propSet.
add(
YProperty( YUIProperty_Label, YStringProperty ) );
272 else if ( propertyName == YUIProperty_VisibleLines )
setVisibleLines ( val.integerVal() );
273 else if ( propertyName == YUIProperty_MaxLines )
setMaxLines ( val.integerVal() );