grepros 1.2.2
grep for ROS bag files and live topics
Loading...
Searching...
No Matches
TextWrapper Class Reference

TextWrapper that supports custom substring widths in line width calculation. More...

Public Member Functions

 __init__ (self, width=80, subsequent_indent=" ", break_long_words=True, drop_whitespace=False, max_lines=None, placeholder=" ...", custom_widths=None)
 
 reserve_width (self, reserved="")
 Decreases the configured width by given amount (number or string).
 
 strip (self, v)
 Returns string with custom substrings and whitespace stripped.
 
 strlen (self, v)
 Returns length of string, using custom substring widths.
 
 wrap (self, text)
 Returns a list of wrapped text lines, without linebreaks.
 

Public Attributes

 break_long_words
 
 custom_lens
 
 custom_rgx
 
 customs
 
 disabled
 
 drop_whitespace
 
 lencache
 
 max_lines
 
 minwidth
 
 placeholder
 
 realwidth
 
 subsequent_indent
 
 width
 

Static Public Attributes

int LENCACHEMAX = 10000
 Max length of strlen cache.
 
 SPACE_RGX = re.compile(r"([%s]+)" % re.escape("\t\n\x0b\x0c\r "))
 Regex for breaking text at whitespace.
 

Detailed Description

TextWrapper that supports custom substring widths in line width calculation.

Intended for wrapping text containing ANSI control codes. Heavily refactored from Python standard library textwrap.TextWrapper.

Definition at line 692 of file common.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ (   self,
  width = 80,
  subsequent_indent = "  ",
  break_long_words = True,
  drop_whitespace = False,
  max_lines = None,
  placeholder = " ...",
  custom_widths = None 
)
Parameters
widthdefault maximum width to wrap at, 0 disables
subsequent_indentstring prepended to all consecutive lines
break_long_wordsbreak words longer than width
drop_whitespacedrop leading and trailing whitespace from lines
max_linescount to truncate lines from
placeholderappended to last retained line when truncating
custom_widths{substring: len} to use in line width calculation

Definition at line 711 of file common.py.

Member Function Documentation

◆ reserve_width()

reserve_width (   self,
  reserved = "" 
)

Decreases the configured width by given amount (number or string).

Definition at line 752 of file common.py.

◆ strip()

strip (   self,
  v 
)

Returns string with custom substrings and whitespace stripped.

Definition at line 765 of file common.py.

◆ strlen()

strlen (   self,
  v 
)

Returns length of string, using custom substring widths.

Definition at line 758 of file common.py.

◆ wrap()

wrap (   self,
  text 
)

Returns a list of wrapped text lines, without linebreaks.

Definition at line 731 of file common.py.

Member Data Documentation

◆ break_long_words

break_long_words

Definition at line 715 of file common.py.

◆ custom_lens

custom_lens

Definition at line 722 of file common.py.

◆ custom_rgx

custom_rgx

Definition at line 723 of file common.py.

◆ customs

customs

Definition at line 721 of file common.py.

◆ disabled

disabled

Definition at line 724 of file common.py.

◆ drop_whitespace

drop_whitespace

Definition at line 716 of file common.py.

◆ lencache

lencache

Definition at line 720 of file common.py.

◆ LENCACHEMAX

int LENCACHEMAX = 10000
static

Max length of strlen cache.

Definition at line 698 of file common.py.

◆ max_lines

max_lines

Definition at line 717 of file common.py.

◆ minwidth

minwidth

Definition at line 725 of file common.py.

◆ placeholder

placeholder

Definition at line 718 of file common.py.

◆ realwidth

realwidth

Definition at line 728 of file common.py.

◆ SPACE_RGX

SPACE_RGX = re.compile(r"([%s]+)" % re.escape("\t\n\x0b\x0c\r "))
static

Regex for breaking text at whitespace.

Definition at line 695 of file common.py.

◆ subsequent_indent

subsequent_indent

Definition at line 714 of file common.py.

◆ width

width

Definition at line 713 of file common.py.


The documentation for this class was generated from the following file: