Skip to content

Commit

Permalink
fix background
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Mar 31, 2020
1 parent 3509614 commit e5c300d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.8.8] - 2020-03-31

### Fixed

- Fixed background in Syntax

## [0.8.7] - 2020-03-31

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "rich"
homepage = "https://github.com/willmcgugan/rich"
documentation = "https://rich.readthedocs.io/en/latest/"
version = "0.8.7"
version = "0.8.8"
description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal"
authors = ["Will McGugan <[email protected]>"]
license = "MIT"
Expand Down
11 changes: 9 additions & 2 deletions rich/syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,12 @@ def __console__(self, console: Console, options: ConsoleOptions) -> RenderResult
line, render_options, style=background_style
)
else:
wrapped_lines = [list(line.render(console, render_options, end=""))]
segments = list(line.render(console, end=""))
wrapped_lines = [
Segment.adjust_line_length(
segments, render_options.max_width, style=background_style
)
]
for first, wrapped_line in loop_first(wrapped_lines):
if first:
line_column = str(line_no).rjust(numbers_column_width - 2) + " "
Expand All @@ -289,5 +294,7 @@ def __console__(self, console: Console, options: ConsoleOptions) -> RenderResult

console = Console()

syntax = Syntax.from_path(sys.argv[1], line_numbers=True, word_wrap=True)
syntax = Syntax.from_path(
sys.argv[1], line_numbers=True, word_wrap=False, theme="default"
)
console.print(syntax)
12 changes: 5 additions & 7 deletions rich/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def __console__(
tab_size=tab_size,
)
all_lines = Text("\n").join(lines)
yield from all_lines.render(console, options, end=self.end)
yield from all_lines.render(console, end=self.end)

def __measure__(self, console: "Console", max_width: int) -> Measurement:
text = self.text
Expand All @@ -339,14 +339,12 @@ def __measure__(self, console: "Console", max_width: int) -> Measurement:
min_text_width = max(cell_len(word) for word in text.split())
return Measurement(min_text_width, max_text_width)

def render(
self, console: "Console", options: "ConsoleOptions", end: str = None
) -> Iterable["Segment"]:
"""Render the rich text to the console.
def render(self, console: "Console", end: str = None) -> Iterable["Segment"]:
"""Render the text as Segments.
Args:
console (Console): Console instance.
options (ConsoleOptions): Console options.
console (Console): Console instance.
end (Optional[str], optional): Optional end character.
Returns:
Iterable[Segment]: Result of render that may be written to the console.
Expand Down

0 comments on commit e5c300d

Please sign in to comment.