Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add copyable #23

Merged
merged 1 commit into from
Feb 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mojoproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"]
Expand Down
2 changes: 2 additions & 0 deletions scripts/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:]}")

Expand Down
11 changes: 10 additions & 1 deletion src/mist/style.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.

Expand Down