fitzzftw.patch.lines.HunkHeadLine¶
---
config:
height: 300px
width: 300px
title: HunkHeadLine
---
classDiagram
PatchLine <|-- HunkHeadLine
TerminalColorMixin <|-- HunkHeadLine
Inheritage diagramm for HunkHeadLine¶
- class HunkHeadLine[source]¶
Bases:
TerminalColorMixin,PatchLineRepresents a hunk header line within a patch (starting with ‘@@ ‘).
This class specializes
PatchLineto handle coordinate metadata. It isolates the range information from optional context info (like function names) and provides parsed access to the line numbers.Public Data Attributes:
The '@@ ' prefix at the start of the line (ro).
The optional context information after the coordinates (ro).
The starting line number in the original file (ro).
The number of lines affected in the original file (ro).
The starting line number in the new file (ro).
The number of lines in the new hunk (ro).
All coordinates as a tuple: (old_start, old_len, new_start, new_len) (ro).
Inherited from
TerminalColorMixinGlobal toggle to enable or disable colorized output.
Public Methods:
__init__(raw_line)Initializes the HunkHeadLine by extracting coordinates and optional info.
__repr__()Return repr(self).
Inherited from
TerminalColorMixincolorize(text, color_key[, bold])Colorizes the text using ANSI escape sequences.
print(**kwargs)Prints the line with color mapping based on its prefix.
Private Data Attributes:
_color_map_HUNK_REInherited from
TerminalColorMixinInternal mapping of semantic names to ANSI escape sequences.
Inherited from
PatchLine_TRAIL_WS_RE_has_trailing_whitespace_content_orig_line
- _ANSI: Color = <fitzzftw.patch.static.Color object>¶
Internal mapping of semantic names to ANSI escape sequences. Can be overridden for testing purposes.
- __init__(raw_line)[source]¶
Initializes the HunkHeadLine by extracting coordinates and optional info.
- Parameters:
raw_line (str) – The complete, unmodified hunk header line.
- Raises:
ValueError – If the prefix or the coordinates are invalid.
- colorize(text, color_key, bold=False, **kwargs)¶
Colorizes the text using ANSI escape sequences.
- Parameters:
text (str) – The string to colorize.
color_key ('red' | 'green' | 'yellow' | 'cyan' | 'terminal') – The color to use (‘red’, ‘green’, ‘cyan’).
bold (bool) – Whether to make the output bold.
kwargs – Arbitrary keyword arguments forwarded to the built-in print() function. This allows for fine-grained control over the output, such as specifying a custom ‘file’ stream or changing the line termination via ‘end’ (e.g., end=”|”).
- Returns:
Colorized string or plain text if colors are disabled.
- Return type:
None
- property content: str¶
The cleaned content of the line without trailing newlines (ro).
- Returns:
A string representing the text content of the line.
- property coords: tuple[int, int, int, int]¶
All coordinates as a tuple: (old_start, old_len, new_start, new_len) (ro).
- property orig_line: str¶
The original of the line without trailing newlines (ro).
- Returns:
A string representing the text content of the line.
- print(**kwargs)¶
Prints the line with color mapping based on its prefix.
- Raises:
FtwProtocolError – If the class does not satisfy the LineLike protocol.
- Parameters:
kwargs – Passed to colorize/print (e.g., end, file).