class_docstr: A list subclass which can render to the console.
class_docstr_tok: ["A","list","subclass","which","can","render","to","the","console","."]
docstr: Justify and overflow text to a given width.
  
  Args:
      console (Console): Console instance.
      width (int): Number of cells available per line.
      justify (str, optional): Default justify method for text: "left", "center", "full" or "right". Defaults to "left".
      overflow (str, optional): Default overflow for text: "crop", "fold", or "ellipsis". Defaults to "fold".
docstr_tok: ["Justify","and","overflow","text","to","a","given","width",".","Args",":","console","(","Console",")",":","Console","instance",".","width","(","int",")",":","Number","of","cells","available","per","line",".","justify","(","str",",","optional",")",":","Default","justify","method","for","text",":","``","left","''",",","``","center","''",",","``","full","''","or","``","right","''",".","Defaults","to","``","left","''",".","overflow","(","str",",","optional",")",":","Default","overflow","for","text",":","``","crop","''",",","``","fold","''",",","or","``","ellipsis","''",".","Defaults","to","``","fold","''","."]
code: def justify(
      self,
      console: "Console",
      width: int,
      justify: "JustifyMethod" = "left",
      overflow: "OverflowMethod" = "fold",
  ) -> None:
      """Justify and overflow text to a given width.
  
      Args:
          console (Console): Console instance.
          width (int): Number of cells available per line.
          justify (str, optional): Default justify method for text: "left", "center", "full" or "right". Defaults to "left".
          overflow (str, optional): Default overflow for text: "crop", "fold", or "ellipsis". Defaults to "fold".
  
      """
      from .text import Text
  
      if justify == "left":
          for line in self._lines:
              line.truncate(width, overflow=overflow, pad=True)
      elif justify == "center":
          for line in self._lines:
              line.rstrip()
              line.truncate(width, overflow=overflow)
              line.pad_left((width - cell_len(line.plain)) // 2)
              line.pad_right(width - cell_len(line.plain))
      elif justify == "right":
          for line in self._lines:
              line.rstrip()
              line.truncate(width, overflow=overflow)
              line.pad_left(width - cell_len(line.plain))
      elif justify == "full":
          for line_index, line in enumerate(self._lines):
              if line_index == len(self._lines) - 1:
                  break
              words = line.split(" ")
              words_size = sum(cell_len(word.plain) for word in words)
              num_spaces = len(words) - 1
              spaces = [1 for _ in range(num_spaces)]
              index = 0
              if spaces:
                  while words_size + num_spaces < width:
                      spaces[len(spaces) - index - 1] += 1
                      num_spaces += 1
                      index = (index + 1) % len(spaces)
              tokens: List[Text] = []
              for index, (word, next_word) in enumerate(
                  zip_longest(words, words[1:])
              ):
                  tokens.append(word)
                  if index < len(spaces):
                      style = word.get_style_at_offset(console, -1)
                      next_style = next_word.get_style_at_offset(
                          console, 0
                      )
                      space_style = (
                          style if style == next_style else line.style
                      )
                      tokens.append(
                          Text(" " * spaces[index], style=space_style)
                      )
              self[line_index] = Text("").join(tokens)
  
imports: from itertools import zip_longest
  from typing import TYPE_CHECKING, Iterable, Iterator, List, Optional, TypeVar, Union, overload
  from .cells import cell_len
  from .measure import Measurement
label_desc: Use image node_id 13 for calling the Lines obj's underlying member method code with example usage: obj.justify(console, width, justify, overflow) without return types