From bd62ed9248a39ab22c1dcf299c93004d4398ccb9 Mon Sep 17 00:00:00 2001 From: Mikhail Tavarez Date: Fri, 21 Feb 2025 21:42:42 -0600 Subject: [PATCH] add copyable --- mojoproject.toml | 4 ++-- scripts/util.py | 2 ++ src/mist/style.mojo | 11 ++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/mojoproject.toml b/mojoproject.toml index 3ad2fdd..6acdbb8 100644 --- a/mojoproject.toml +++ b/mojoproject.toml @@ -4,7 +4,7 @@ channels = ["conda-forge", "https://conda.modular.com/max"] description = "Mist lets you safely use advanced styling options on the terminal." name = "mist" platforms = ["osx-arm64", "linux-64"] -version = "0.1.12" +version = "25.1.0" license = "MIT" license-file = "LICENSE" homepage = "https://github.com/thatstoasty/mist" @@ -19,7 +19,7 @@ build = { cmd = "python scripts/util.py build", env = { MODULAR_MOJO_IMPORT_PATH publish = { cmd = "python scripts/util.py publish", env = { PREFIX_API_KEY = "$PREFIX_API_KEY" } } [dependencies] -max = "25.1.0" +max = "==25.1.0" [feature.nightly] channels = ["conda-forge", "https://conda.modular.com/max-nightly"] diff --git a/scripts/util.py b/scripts/util.py index 8ea13db..e9754ef 100644 --- a/scripts/util.py +++ b/scripts/util.py @@ -24,6 +24,8 @@ def build_dependency_list(dependencies: dict[str, str]) -> list[str]: else: operator = version[:2] start = 2 + elif version.startswith("=="): + start = 2 deps.append(f" - {name} {operator} {version[start:]}") diff --git a/src/mist/style.mojo b/src/mist/style.mojo index 9b8b539..328cc86 100644 --- a/src/mist/style.mojo +++ b/src/mist/style.mojo @@ -97,7 +97,7 @@ trait SizedWritable(Sized, Writable): ... -struct Style(Movable, ExplicitlyCopyable, Stringable, Representable, Writable): +struct Style(Movable, Copyable, ExplicitlyCopyable, Stringable, Representable, Writable): """Style stores a list of styles to format text with. These styles are ANSI sequences which modify text (and control the terminal). In reality, these styles are turning visual terminal features on and off around the text it's styling. @@ -154,6 +154,15 @@ struct Style(Movable, ExplicitlyCopyable, Stringable, Representable, Writable): """ return Self(styles=self.styles, profile=self.profile) + fn __copyinit__(out self, other: Style): + """Constructs a Style from another Style. + + Args: + other: The Style to copy. + """ + self.styles = other.styles + self.profile = other.profile + fn __moveinit__(out self, owned other: Style): """Constructs a Style from another Style.