From 132c46940b0cfdd309da4a6e2c85ceee271d1029 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Tue, 4 Feb 2020 18:26:53 +0000 Subject: [PATCH] new release --- CHANGELOG.md | 2 ++ examples/table.html | 26 -------------------------- pyproject.toml | 14 +++++++++++++- rich/color.py | 2 ++ rich/console.py | 4 ++-- rich/pretty.py | 1 + rich/segment.py | 4 ++-- rich/text.py | 2 -- 8 files changed, 22 insertions(+), 33 deletions(-) delete mode 100644 examples/table.html diff --git a/CHANGELOG.md b/CHANGELOG.md index 71188343..fe807e30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed Windows color support +- Fixed line width on windows issue (https://github.com/willmcgugan/rich/issues/7) +- Fixed Pretty print on Windows ## [0.3.2] - 2020-01-26 diff --git a/examples/table.html b/examples/table.html deleted file mode 100644 index 0417a52a..00000000 --- a/examples/table.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - -
                           Star Wars Movies                           
-┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓
-┃     Released  Title                                  Box Office ┃
-┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩
-│ Dec 20, 2019  Star Wars: The Rise of Skywalker     $952,110,690 │
-│ May 25, 2018  Solo: A Star Wars Story              $393,151,347 │
-│ Dec 15, 2017  Star Wars Ep. V111: The Last Jedi  $1,332,539,889 │
-│ Dec 16, 2016  Rouge One: A Star Wars Story       $1,332,439,889 │
-└──────────────┴───────────────────────────────────┴────────────────┘
-
-
- - diff --git a/pyproject.toml b/pyproject.toml index a8520015..7e55f6d9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,11 +2,23 @@ name = "rich" homepage = "https://github.com/willmcgugan/rich" documentation = "https://rich.readthedocs.io/en/latest/" -version = "0.3.2" +version = "0.3.3" description = "Render rich text, tables, syntax highlighting, markdown and more to the terminal" authors = ["Will McGugan "] license = "MIT" readme = "README.md" +classifiers = [ + "Development Status :: 3 - Alpha", + "Environment :: Console", + "Intended Audience :: Developers", + "Operating System :: Microsoft :: Windows", + "Operating System :: MacOS", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", +] + [tool.poetry.dependencies] python = "^3.6" diff --git a/rich/color.py b/rich/color.py index 86e5f2f5..a870252b 100644 --- a/rich/color.py +++ b/rich/color.py @@ -398,6 +398,8 @@ class Color(NamedTuple): def downgrade(self, system: ColorSystem) -> "Color": """Downgrade a color system to a system with fewer colors.""" + if self.type == ColorType.DEFAULT or self.type == system: + return self # Convert to 8-bit color from truecolor color if system == ColorSystem.EIGHT_BIT and self.system == ColorSystem.TRUECOLOR: assert self.triplet is not None diff --git a/rich/console.py b/rich/console.py index e37386f0..0e578b20 100644 --- a/rich/console.py +++ b/rich/console.py @@ -316,8 +316,8 @@ class Console: return ConsoleDimensions(self._width, self._height) width, height = shutil.get_terminal_size() - if WINDOWS: - width -= 1 + # Fixes Issue with Windows console (https://github.com/willmcgugan/rich/issues/7) + width -= 1 return ConsoleDimensions( width if self._width is None else self._width, height if self._height is None else self._height, diff --git a/rich/pretty.py b/rich/pretty.py index 3185d0c6..e5f36c91 100644 --- a/rich/pretty.py +++ b/rich/pretty.py @@ -19,6 +19,7 @@ class Pretty: self, console: "Console", options: "ConsoleOptions" ) -> "RenderResult": pretty_str = pformat(self._object, width=options.max_width) + pretty_str = pretty_str.replace("\r", "") pretty_text = self.highlighter(pretty_str) yield pretty_text diff --git a/rich/segment.py b/rich/segment.py index e6d41579..d2a80fea 100644 --- a/rich/segment.py +++ b/rich/segment.py @@ -88,7 +88,7 @@ class Segment(NamedTuple): """ line_length = sum(len(text) for text, _style in line) if line_length < length: - return line[:] + [Segment(" " * (length - line_length), style)] + return line + [Segment(" " * (length - line_length), style)] elif line_length > length: line_length = 0 new_line: List[Segment] = [] @@ -103,7 +103,7 @@ class Segment(NamedTuple): append(Segment(text[: length - line_length], style)) break return new_line - return line + return line[:] @classmethod def get_line_length(cls, line: List["Segment"]) -> int: diff --git a/rich/text.py b/rich/text.py index 009fda6a..7cacf4bd 100644 --- a/rich/text.py +++ b/rich/text.py @@ -480,8 +480,6 @@ class Text: break span = new_span line_index += 1 - # if line_index >= len(line_ranges): - # break line_start, line_end = line_ranges[line_index] return new_lines