Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
AAriam committed Sep 11, 2024
1 parent b659f77 commit 4283a0d
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 182 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ namespaces = true

# ----------------------------------------- Project Metadata -------------------------------------
[project]
version = "0.0.0.dev7"
version = "0.0.0.dev8"
name = "ANSI-SGR"
requires-python = ">=3.10"
dependencies = [
"PyProtocol",
"wcwidth",
]
2 changes: 1 addition & 1 deletion src/ansi_sgr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
color_code,
)

from ansi_sgr import element
from ansi_sgr import element, protocol
6 changes: 3 additions & 3 deletions src/ansi_sgr/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def code_block(
char_top_right: Stringable | None = "┓",
char_bottom_left: Stringable | None = "┗",
char_bottom_right: Stringable | None = "┛",
line_width: int = 70,
line_width: int = 50,
):
title = str(title)
code = str(code)
Expand Down Expand Up @@ -156,7 +156,7 @@ def admonition(
char_top_right: Stringable | None = "┓",
char_bottom_left: Stringable | None = "┗",
char_bottom_right: Stringable | None = "┛",
line_width: int = 70,
line_width: int = 50,
):
title = str(title)
if emoji:
Expand Down Expand Up @@ -217,7 +217,7 @@ def block(
margin_bottom: int | None = None,
margin_left: int | None = 1,
margin_right: int | None = 1,
line_width: int = 70,
line_width: int = 50,
align: Literal["left", "right", "center"] = "left",
):
if margin_left is None:
Expand Down
110 changes: 110 additions & 0 deletions src/ansi_sgr/protocol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
from __future__ import annotations as _annotations

from typing import TYPE_CHECKING as _TYPE_CHECKING
from dataclasses import dataclass as _dataclass, asdict as _asdict

if _TYPE_CHECKING:
from typing import Literal
from pyprotocol import Stringable


@_dataclass
class ANSICodeBlockStyle:
emoji: Stringable | None = "💻"
title_styles: int | str | list[int | str] = "bold"
title_color: int | str | tuple = (255, 255, 255)
title_bg_color: int | str | tuple = (70, 0, 0)
title_margin_top: int | None = None
title_margin_bottom: int | None = None
title_align: Literal["left", "right", "center"] = "left"
code_margin_top: int | None = 1
code_margin_bottom: int | None = 1
line_num_styles: int | str | list[int | str] = "bold"
line_num_color: int | str | tuple = (255, 255, 255)
line_num_bg_color: int | str | tuple = (30, 30, 30)
line_styles: int | str | list[int | str] = None
line_color: int | str | tuple = (255, 255, 255)
line_bg_color: int | str | tuple = (100, 0, 0)
margin_left: int | None = 1
margin_right: int | None = 1
char_top: Stringable | None = ""
char_bottom: Stringable | None = "━"
char_left: Stringable | None = "┃"
char_right: Stringable | None = "┃"
char_top_left: Stringable | None = "┏"
char_top_right: Stringable | None = "┓"
char_bottom_left: Stringable | None = "┗"
char_bottom_right: Stringable | None = "┛"
line_width: int = 50

@property
def dict(self) -> dict:
return _asdict(self)


@_dataclass
class ANSIAdmonitionStyle:
emoji: Stringable | None = None
title_styles: int | str | list[int | str] = "bold"
title_color: int | str | tuple = (255, 255, 255)
title_bg_color: int | str | tuple = (70, 0, 0)
title_margin_top: int | None = None
title_margin_bottom: int | None = None
title_align: Literal["left", "right", "center"] = "left"
text_styles: int | str | list[int | str] = None
text_color: int | str | tuple = None
text_bg_color: int | str | tuple = None
text_margin_top: int | None = 1
text_margin_bottom: int | None = 1
text_align: Literal["left", "right", "center"] = "left"
margin_left: int | None = 1
margin_right: int | None = 1
char_top: Stringable | None = None
char_bottom: Stringable | None = "━"
char_left: Stringable | None = "┃"
char_right: Stringable | None = "┃"
char_top_left: Stringable | None = "┏"
char_top_right: Stringable | None = "┓"
char_bottom_left: Stringable | None = "┗"
char_bottom_right: Stringable | None = "┛"
line_width: int = 50

@property
def dict(self) -> dict:
return _asdict(self)


@_dataclass
class ANSIBlockStyle:
text_styles: int | str | list[int | str] | None = None
text_color: int | str | tuple[int, int, int] | None = None
bg_color: int | str | tuple[int, int, int] = None
char_top: str | None = None
char_bottom: str | None = None
char_left: str | None = None
char_right: str | None = None
margin_top: int | None = None
margin_bottom: int | None = None
margin_left: int | None = None
margin_right: int | None = None
line_width: int = 50

@property
def dict(self) -> dict:
return _asdict(self)


@_dataclass
class ANSIInlineStyle:
text_styles: int | str | list[int | str] | None = None
text_color: int | str | tuple[int, int, int] | None = None
bg_color: int | str | tuple[int, int, int] = None
char_left: str | None = None
char_right: str | None = None
margin_left: int | None = None
margin_right: int | None = None

@property
def dict(self) -> dict:
return _asdict(self)

177 changes: 0 additions & 177 deletions src/ansi_sgr/wrap.py

This file was deleted.

0 comments on commit 4283a0d

Please sign in to comment.