Splits the content of each cell into multiple lines according to the set max column width.
968328
private function splitCellsContent()
    {
        // For each row...
        foreach ($this->data as $rowPosition => $rowContent) {
            // ... cycle each column to get its content
            foreach ($rowContent as $columnName => $cellContent) {
                // Remove extra spaces from the string
                $cellContent = $this->reduceSpaces($cellContent);

                // If we don't have a max width set for the column...
                if (false === isset($this->options['columns'][$columnName]['max_width'])) {
                    // ... simply wrap the content in an array and continue
                    $this->data[$rowPosition][$columnName] = [$cellContent];
                    goto addVerticalPadding;
                }

                // ... We have a max_width set: split the column
                $length = $this->options['columns'][$columnName]['max_width'];
                $cut    = $this->options['columns'][$columnName]['cut'];

                $wrapped = wordwrap($cellContent, $length, PHP_EOL, $cut);

                $this->data[$rowPosition][$columnName] = explode(PHP_EOL, $wrapped);

                // At the end, add the vertical padding to the cell's content
                addVerticalPadding:
                if (0 < $this->options['cells_padding'][0]) {
                    // Now add the top padding
                    for ($paddingLine = 0; $paddingLine < $this->options['cells_padding'][0]; ++$paddingLine) {
                        array_unshift($this->data[$rowPosition][$columnName], '');
                    }
                }

                if (0 < $this->options['cells_padding'][2]) {
                    // And the bottom padding
                    for ($paddingLine = 0; $paddingLine < $this->options['cells_padding'][2]; ++$paddingLine) {
                        array_push($this->data[$rowPosition][$columnName], '');
                    }
                }
            }
        }
    }
46697
def _split_tidy(self, string, maxsplit=None):
        """"""

        if maxsplit is None:
            return string.rstrip("\n").split("\t")
        else:
            return string.rstrip("\n").split("\t", maxsplit)
439903
def _format_table(fmt, headers, rows, colwidths, colaligns, is_multiline):
    """"""
    lines = []
    hidden = fmt.with_header_hide if (headers and fmt.with_header_hide) else []
    pad = fmt.padding
    headerrow = fmt.headerrow

    padded_widths = [(w + 2 * pad) for w in colwidths]
    if is_multiline:
        pad_row = lambda row, _: row  # do it later, in _append_multiline_row
        append_row = partial(_append_multiline_row, pad=pad)
    else:
        pad_row = _pad_row
        append_row = _append_basic_row

    padded_headers = pad_row(headers, pad)
    padded_rows = [pad_row(row, pad) for row in rows]

    if fmt.lineabove and "lineabove" not in hidden:
        _append_line(lines, padded_widths, colaligns, fmt.lineabove)

    if padded_headers:
        append_row(lines, padded_headers, padded_widths, colaligns, headerrow)
        if fmt.linebelowheader and "linebelowheader" not in hidden:
            _append_line(lines, padded_widths, colaligns, fmt.linebelowheader)

    if padded_rows and fmt.linebetweenrows and "linebetweenrows" not in hidden:
        # initial rows with a line below
        for row in padded_rows[:-1]:
            append_row(lines, row, padded_widths, colaligns, fmt.datarow)
            _append_line(lines, padded_widths, colaligns, fmt.linebetweenrows)
        # the last row without a line below
        append_row(lines, padded_rows[-1], padded_widths, colaligns, fmt.datarow)
    else:
        for row in padded_rows:
            append_row(lines, row, padded_widths, colaligns, fmt.datarow)

    if fmt.linebelow and "linebelow" not in hidden:
        _append_line(lines, padded_widths, colaligns, fmt.linebelow)

    return "\n".join(lines)
918270
function(text, pad) {
			var lines = this.splitByLines(text);
			var pl = pad.length;
			for (var i = 0, il = lines.length, line; i < il; i++) {
				line = lines[i];
				if (line.substr(0, pl) === pad) {
					lines[i] = line.substr(pl);
				}
			}
			
			return lines.join('\n');
		}
1078129
def split_title(title, width, title_fs):
    """"""
    titles = []
    if not title:
        return titles
    size = reverse_text_len(width, title_fs * 1.1)
    title_lines = title.split("\n")
    for title_line in title_lines:
        while len(title_line) > size:
            title_part = title_line[:size]
            i = title_part.rfind(' ')
            if i == -1:
                i = len(title_part)
            titles.append(title_part[:i])
            title_line = title_line[i:].strip()
        titles.append(title_line)
    return titles
4765
def width_aware_splitlines(self, columns):
        # type: (int) -> Iterator[FmtStr]
        
        if columns < 2:
            raise ValueError("Column width %s is too narrow." % columns)
        if wcswidth(self.s) == -1:
            raise ValueError('bad values for width aware slicing')
        return self._width_aware_splitlines(columns)
388464
def pad(lines, delim):
	
	"""
	Populates text into chunks. If the delim was & then
	['12 & 344', '344 & 8', '8 & 88'] would be stored in chunks as
	[['12', '344', '8'], ['344', '8', '88']]
	"""
	chunks = []
	for i in range(len(lines)):
		line = lines[i]
		sections = line.split(delim)
		for j in range(len(sections)):
			if len(chunks) <= j:
				chunks.append([])
			chunks[j].append(sections[j])

	"""
	Calculates & Stores the max length of chunks
	"""
	max_lengths = []
	for i in range(len(chunks)):
		_max = max([len(j) for j in chunks[i]])
		max_lengths.append(_max)

	"""
	Pads the children of chunks according to the chunk's max length" \
	"""
	for i in range(len(chunks)):
		for j in range(len(chunks[i])):
			chunks[i][j] += (max_lengths[i] - len(chunks[i][j])) * ' '
	new_lines = ['' for i in range(len(lines))]

	for i in range(len(chunks)):
		for j in range(len(chunks[i])):
			new_lines[j] += chunks[i][j]
	return new_lines
741998
private String getRowLineBuf(int colCount, List<Integer> colMaxLenList, String[][] data) {

    StringBuilder rowBuilder = new StringBuilder();
    int colWidth = 0;

    for (int i = 0; i < colCount; i++) {

      colWidth = colMaxLenList.get(i) + 3;

      for (int j = 0; j < colWidth; j++) {
        if (j == 0) {
          rowBuilder.append("+");
        } else if ((i + 1 == colCount && j + 1 == colWidth)) {//for last column close the border
          rowBuilder.append("-+");
        } else {
          rowBuilder.append("-");
        }
      }
    }

    return rowBuilder.append("\n").toString();
  }
1114763
private void splitOn(String... columnNames) {

        List<Column<?>> columns = getSourceTable().columns(columnNames);
        int byteSize = getByteSize(columns);

        byte[] currentKey = null;
        String currentStringKey = null;
        TableSlice view;

        Selection selection = new BitmapBackedSelection();

        for (int row = 0; row < getSourceTable().rowCount(); row++) {

            ByteBuffer byteBuffer = ByteBuffer.allocate(byteSize);
            String newStringKey = "";

            for (int col = 0; col < columnNames.length; col++) {
                if (col > 0) {
                    newStringKey = newStringKey + SPLIT_STRING;
                }

                Column<?> c = getSourceTable().column(columnNames[col]);
                String groupKey = getSourceTable().getUnformatted(row, getSourceTable().columnIndex(c));
                newStringKey = newStringKey + groupKey;
                byteBuffer.put(c.asBytes(row));
            }
            byte[] newKey = byteBuffer.array();
            if (row == 0) {
                currentKey = newKey;
                currentStringKey = newStringKey;
            }
            if (!Arrays.equals(newKey, currentKey)) {
                currentKey = newKey;
                view = new TableSlice(getSourceTable(), selection);
                view.setName(currentStringKey);
                currentStringKey = newStringKey;
                addSlice(view);
                selection = new BitmapBackedSelection();
                selection.add(row);
            } else {
                selection.add(row);
            }
        }
        if (!selection.isEmpty()) {
            view = new TableSlice(getSourceTable(), selection);
            view.setName(currentStringKey);
            addSlice(view);
        }
    }
1319523
function () {
		var self = this,
			options = this.options,
			csv = options.csv,
			columns = this.columns,
			startRow = options.startRow || 0,
			endRow = options.endRow || Number.MAX_VALUE,
			startColumn = options.startColumn || 0,
			endColumn = options.endColumn || Number.MAX_VALUE,
			lines,
			activeRowNo = 0;
			
		if (csv) {
			
			lines = csv
				.replace(/\r\n/g, "\n") // Unix
				.replace(/\r/g, "\n") // Mac
				.split(options.lineDelimiter || "\n");
			
			each(lines, function (line, rowNo) {
				var trimmed = self.trim(line),
					isComment = trimmed.indexOf('#') === 0,
					isBlank = trimmed === '',
					items;
				
				if (rowNo >= startRow && rowNo <= endRow && !isComment && !isBlank) {
					items = line.split(options.itemDelimiter || ',');
					each(items, function (item, colNo) {
						if (colNo >= startColumn && colNo <= endColumn) {
							if (!columns[colNo - startColumn]) {
								columns[colNo - startColumn] = [];					
							}
							
							columns[colNo - startColumn][activeRowNo] = item;
						}
					});
					activeRowNo += 1;
				}
			});

			this.dataFound();
		}
	}
1296033
function fullWidth(text, param) {
    let cols = process.stdout.columns;
    let lines = text.split('\n');

    for (i = 0; i < lines.length; i++) {
        let size = cols;
        if (i === 0) size = size - 15;
        if ((lines[i].indexOf('%') > 0) && (param !== undefined)) size = size - param.length + 2;
        while (lines[i].length < size) {
            lines[i] = lines[i] + ' ';
        }
    }
    text = lines.join('\n');

    return text;
}
703921
def _wrap_content(content, width):
        
        data = []
        if isinstance(content, list):
            data += content
        else:
            data.append(content)

        lines = []
        for d in data:
            l = textwrap.wrap(d, width)
            lines += l
        return lines
704459
def _format_multirow(self, row, ilevels, i, rows):
        
        """
        for j in range(ilevels):
            if row[j].strip():
                nrow = 1
                for r in rows[i + 1:]:
                    if not r[j].strip():
                        nrow += 1
                    else:
                        break
                if nrow > 1:
                    # overwrite non-multirow entry
                    row[j] = '\\multirow{{{nrow:d}}}{{*}}{{{row:s}}}'.format(
                        nrow=nrow, row=row[j].strip())
                    # save when to end the current block with \cline
                    self.clinebuf.append([i + nrow - 1, j + 1])
        return row
730664
public function write() {
        // Determine the width of the last column.
        $columnWidths = array_sum($this->columnWidths);
        $totalWidth = $this->indent + $columnWidths + $this->padding * (count($this->columnWidths) - 1);

        $lastWidth = end($this->columnWidths) + $this->maxWidth - $totalWidth;
        $lastWidth = max($lastWidth, 10); // min width of 10
        $this->columnWidths[count($this->columnWidths) - 1] = $lastWidth;

        // Loop through each row and write it.
        foreach ($this->rows as $row) {
            $rowLines = [];
            $lineCount = 0;

            // Split the cells into lines.
            foreach ($row as $i => $cell) {
                list($text,) = $cell;
                $width = $this->columnWidths[$i];

                $lines = Cli::breakLines($text, $width, $i < count($this->columnWidths) - 1);
                $rowLines[] = $lines;
                $lineCount = max($lineCount, count($lines));
            }

            // Write all of the lines.
            for ($i = 0; $i < $lineCount; $i++) {
                foreach ($rowLines as $j => $lines) {
                    $padding = $j === 0 ? $this->indent : $this->padding;

                    if (isset($lines[$i])) {
                        if ($this->formatOutput) {
                            if(isset($row[$j])) {
                                $wrap = $row[$j][1];
                            } else {
                                // if we're out of array, use the latest wraps
                                $wrap = $row[count($row)-1][1];
                            }

                            echo str_repeat(' ', $padding).$wrap[0].$lines[$i].$wrap[1];
                        } else {
                            echo str_repeat(' ', $padding).$lines[$i];
                        }
                    } elseif ($j < count($this->columnWidths) - 1) {
                        // This is an empty line. Write the spaces.
                        echo str_repeat(' ', $padding + $this->columnWidths[$j]);
                    }
                }
                echo PHP_EOL;
            }
        }
    }
283549
def _split_vlines_hlines(lines):
    """"""
    vlines, hlines = [], []
    for line in lines:
        (vlines if line.x1 - line.x0 < 0.1 else hlines).append(line)
    return vlines, hlines
446387
def _pys2col_widths(self, line):
        """"""

        # Split with maxsplit 3
        split_line = self._split_tidy(line)
        key = col, tab = self._get_key(*split_line[:2])
        width = float(split_line[2])

        shape = self.code_array.shape

        try:
            if col < shape[1] and tab < shape[2]:
                self.code_array.col_widths[key] = width

        except ValueError:
            pass
817437
def getcells(self, line):
        '''
        '''
        for boundary in self.boundaries:
            cell = line.lstrip()[boundary].strip()
            if cell:
                for cell in re.split('\s{3,}', cell):
                    yield cell
            else:
                yield None