@@ -163,6 +163,16 @@ namespace samilton {
163163
164164 friend std::ostream &operator <<(std::ostream &stream, ConsoleTable &table);
165165 private:
166+ void _fillStreamByChar (std::ostream &stream, const char &fillChar, const size_t &lenght) {
167+ if (lenght > 0 )
168+ stream << std::setfill (fillChar) << std::setw (lenght);
169+ }
170+
171+ void _fillStreamByChar (std::ostream &stream, const char &fillChar, const char &endChar, const size_t &lenght) {
172+ if (lenght > 0 )
173+ stream << std::setfill (fillChar) << std::setw (lenght) << endChar;
174+ }
175+
166176 std::map<size_t , ConsoleRow*> _tableData;
167177 Alignment _alignment;
168178 size_t _leftIndent, _rightIndent;
@@ -203,11 +213,12 @@ namespace samilton {
203213 const char centreSeparation = 206 ;
204214
205215 if (table._alignment != ConsoleTable::Alignment::centre) {
206- stream << std::right << topLeft << std::setfill (topDownSimple) << std::setw (columnWidth[0 ] + 1 );
216+ stream << std::right << topLeft;
217+ table._fillStreamByChar (stream, topDownSimple, columnWidth[0 ] + 1 + table._leftIndent + table._rightIndent );
207218
208219 if (column != 1 ) {
209220 for (size_t i = 1 ; i < column; i++) {
210- stream << topSeparation << std::setw (columnWidth[i] + 1 );
221+ stream << topSeparation << std::setw (columnWidth[i] + 1 + table. _leftIndent + table. _rightIndent );
211222 }
212223 }
213224 stream << topRight << std::endl;
@@ -220,30 +231,44 @@ namespace samilton {
220231
221232 for (size_t j = 0 ; j < column; j++) {
222233 if (table._tableData [i] != nullptr && table._tableData [i]->_rowData [j] != nullptr ) {
223- stream << leftRightSimple << std::setfill (' ' ) << std::setw (columnWidth[j]) << table._tableData [i]->_rowData [j]->_str ;
234+ stream << leftRightSimple;
235+ table._fillStreamByChar (stream, ' ' , ' ' , table._leftIndent );
236+
237+ table._fillStreamByChar (stream, ' ' , columnWidth[j]);
238+ stream << table._tableData [i]->_rowData [j]->_str ;
239+
240+ table._fillStreamByChar (stream, ' ' , ' ' , table._rightIndent );
224241 }
225242 else {
226- stream << leftRightSimple << std::setfill (' ' ) << std::setw (columnWidth[j]) << ' ' ;
243+ stream << leftRightSimple;
244+ table._fillStreamByChar (stream, ' ' , ' ' , table._leftIndent );
245+
246+ table._fillStreamByChar (stream, ' ' , columnWidth[j]);
247+ stream << ' ' ;
248+
249+ table._fillStreamByChar (stream, ' ' , ' ' , table._rightIndent );
227250 }
228251 }
229252 stream << std::right << leftRightSimple << std::endl;
230253
231254 if (i == row - 1 ) {
232- stream << downLeft << std::setfill (topDownSimple) << std::setw (columnWidth[0 ] + 1 );
255+ stream << downLeft;
256+ table._fillStreamByChar (stream, topDownSimple, columnWidth[0 ] + 1 + table._leftIndent + table._rightIndent );
233257
234258 if (column != 1 ) {
235259 for (size_t j = 1 ; j < column; j++) {
236- stream << downSeparation << std::setw (columnWidth[j] + 1 );
260+ stream << downSeparation << std::setw (columnWidth[j] + 1 + table. _leftIndent + table. _rightIndent );
237261 }
238262 }
239263 stream << downRight << std::endl;
240264 }
241265 else {
242- stream << leftSeparation << std::setfill (topDownSimple) << std::setw (columnWidth[0 ] + 1 );
266+ stream << leftSeparation;
267+ table._fillStreamByChar (stream, topDownSimple, columnWidth[0 ] + 1 + table._leftIndent + table._rightIndent );
243268
244269 if (column != 1 ) {
245270 for (size_t j = 1 ; j < column; j++) {
246- stream << centreSeparation << std::setw (columnWidth[j] + 1 );
271+ stream << centreSeparation << std::setw (columnWidth[j] + 1 + table. _leftIndent + table. _rightIndent );
247272 }
248273 }
249274 stream << rightSeparation << std::endl;
0 commit comments