Send text padded and wrapped to the user's screen width.
182356
def send_wrapped(self, text):
        
        lines = word_wrap(text, self.columns)
        for line in lines:
            self.send_cc(line + '\n')
529024
def wrap(text, width, *args, **kwargs):
    

    return sum([textwrap.wrap(line, width, *args, **kwargs)
                if line else [''] for line in text.splitlines()], [])
222371
def wrap(self, availWidth, availHeight):
        

        # memorize available space
        self.avWidth = availWidth
        self.avHeight = availHeight

        logger.debug("*** wrap (%f, %f)", availWidth, availHeight)

        if not self.text:
            logger.debug("*** wrap (%f, %f) needed", 0, 0)
            return 0, 0

        # Split lines
        width = availWidth
        self.splitIndex = self.text.splitIntoLines(width, availHeight)

        self.width, self.height = availWidth, self.text.height

        logger.debug("*** wrap (%f, %f) needed, splitIndex %r", self.width, self.height, self.splitIndex)

        return self.width, self.height
561089
def pad_char(text: str, width: int, char: str = '\n') -> str:
    """"""
    dis = width - len(text)
    if dis < 0:
        raise ValueError
    if dis > 0:
        text += char * dis
    return text
924888
def format_fullwidth(self, value):
        
        assert isinstance(value, VTMLBuffer)
        pad = self.colspec[0]['padding']
        fmt = self.make_formatter(self.width - pad, pad,
                                  self.table.title_align)
        return VTMLBuffer('\n').join(fmt(value))
407283
def word_wrap(self, text, width=1023):
        
        substrings = []

        string = text
        while len(string) > width:
            index = width - 1
            while not string[index].isspace():
                index = index - 1

            line = string[0:index]
            substrings.append(line)

            string = string[index + 1:]

        substrings.append(string)

        return substrings
511034
def hint_width(self):
        """"""
        return sum((len(self.style.delimiter),
                    self.wide,
                    len(self.style.delimiter),
                    len(u' '),
                    UCS_PRINTLEN + 2,
                    len(u' '),
                    self.style.name_len,))
351429
def _pad(string, size):
    
    strlen = len(string)
    if strlen == size:
        return string
    if strlen < size:
        return _padding[0:size-strlen] + string
    return string[-size:]
802637
def format(self, text, width=78, indent=4):
        """"""
        return textwrap.fill(
            text,
            width=width,
            initial_indent=' ' * indent,
            subsequent_indent=' ' * indent,
        )
908227
def write_screen(self, font, color, screen_pos, text, align="left",
                   valign="top"):
    """"""
    pos = point.Point(*screen_pos) * point.Point(0.75, 1) * font.get_linesize()
    text_surf = font.render(str(text), True, color)
    rect = text_surf.get_rect()
    if pos.x >= 0:
      setattr(rect, align, pos.x)
    else:
      setattr(rect, align, self.surf.get_width() + pos.x)
    if pos.y >= 0:
      setattr(rect, valign, pos.y)
    else:
      setattr(rect, valign, self.surf.get_height() + pos.y)
    self.surf.blit(text_surf, rect)
44517
def text_width(string, font_name, font_size):
    """"""
    return stringWidth(string, fontName=font_name, fontSize=font_size)
684565
def _configure_formatting(self):
        '''
        
        '''
        self.format_strings(self.DEFAULT_FORMAT, self.DEFAULT_FORMAT)

        if self.fit_to_screen:
            try:
                import fcntl
                import struct
                import termios

                # Get the terminal window width
                hw = struct.unpack('hh', fcntl.ioctl(1, termios.TIOCGWINSZ, '1234'))
                self.SCREEN_WIDTH = self.HEADER_WIDTH = hw[1]
            except KeyboardInterrupt as e:
                raise e
            except Exception:
                pass
492351
def wrap (text, width, **kwargs):
    """"""
    if width <= 0 or not text:
        return text
    ret = []
    for para in get_paragraphs(text):
        text = " ".join(para.strip().split())
        ret.extend(textwrap.wrap(text, width, **kwargs))
    return os.linesep.join(ret)
1193929
def min_width(string, cols, padding=' '):
    """"""

    is_color = isinstance(string, ColoredString)

    stack = tsplit(str(string), NEWLINES)

    for i, substring in enumerate(stack):
        _sub = clean(substring).ljust((cols + 0), padding)
        if is_color:
            _sub = (_sub.replace(clean(substring), substring))
        stack[i] = _sub
        
    return '\n'.join(stack)
831448
def wrap_text(paragraph, line_count, min_char_per_line=0):
	""""""
	one_string = strip_all_white_space(paragraph)
	if min_char_per_line:
		lines = wrap(one_string, width=min_char_per_line)
		try:
			return lines[:line_count]
		except IndexError:
			return lines
	else:
		return wrap(one_string, len(one_string)/line_count)
591669
def _set_padding(self, attr, value):
        """"""
        if not value:
            setattr(self, attr, "")
        else:
            value = str(value)
            if not value.isspace():
                raise ValueError("padding must be entirely whitespace")
            setattr(self, attr, value)
650183
function createPadding (width) {
  var result = ''
  var string = ' '
  var n = width
  do {
    if (n % 2) {
      result += string;
    }
    n = Math.floor(n / 2);
    string += string;
  } while (n);

  return result;
}