-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from JordanWelsman/develop
WIP: v0.2.0: The Color Update
- Loading branch information
Showing
7 changed files
with
153 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Import color.py, text.py, and utils.py so | ||
# module classes and functions are usable at | ||
# 'from jutl import formatting' level. | ||
from .color import * | ||
from .text import * | ||
from .utils import * | ||
|
||
# Only show functions specified in | ||
# submodule files to the outside world. | ||
__all__ = color.__all__, text.__all__, utils.__all__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# External class visibility | ||
__all__ = ['Text', 'Background'] | ||
|
||
|
||
class Text: | ||
# Text color dictionary | ||
colors = { | ||
'DEFAULT': '\033[39m', | ||
|
||
'BLACK': '\033[30m', | ||
'RED': '\033[31m', | ||
'GREEN': '\033[32m', | ||
'YELLOW': '\033[33m', | ||
'BLUE': '\033[34m', | ||
'MAGENTA': '\033[35m', | ||
'CYAN': '\033[36m', | ||
'LIGHTGRAY': '\033[37m', | ||
'DARKGRAY': '\033[90m', | ||
'LIGHTRED': '\033[91m', | ||
'LIGHTGREEN': '\033[92m', | ||
'LIGHTYELLOW': '\033[93m', | ||
'LIGHTBLUE': '\033[94m', | ||
'LIGHTMAGENTA': '\033[95m', | ||
'LIGHTCYAN': '\033[96m', | ||
'WHITE': '\033[97m' | ||
} | ||
|
||
def test() -> None: | ||
print(f"\nTesting {__name__}.Text...\n") | ||
print(f"{Text.colors['DEFAULT']}█████{Text.colors['BLACK']}█████{Text.colors['DARKGRAY']}█████{Text.colors['LIGHTGRAY']}█████{Text.colors['WHITE']}█████{Text.colors['DEFAULT']}") | ||
print(f"{Text.colors['RED']}█████{Text.colors['GREEN']}█████{Text.colors['YELLOW']}█████{Text.colors['BLUE']}█████{Text.colors['MAGENTA']}█████{Text.colors['CYAN']}█████{Text.colors['DEFAULT']}") | ||
print(f"{Text.colors['LIGHTRED']}█████{Text.colors['LIGHTGREEN']}█████{Text.colors['LIGHTYELLOW']}█████{Text.colors['LIGHTBLUE']}█████{Text.colors['LIGHTMAGENTA']}█████{Text.colors['LIGHTCYAN']}█████{Text.colors['DEFAULT']}\n") | ||
|
||
|
||
class Background: | ||
# Background color dictionary | ||
colors = { | ||
'DEFAULT': '\033[49m', | ||
|
||
'BLACK': '\033[40m', | ||
'RED': '\033[41m', | ||
'GREEN': '\033[42m', | ||
'YELLOW': '\033[43m', | ||
'BLUE': '\033[44m', | ||
'MAGENTA': '\033[45m', | ||
'CYAN': '\033[46m', | ||
'LIGHTGRAY': '\033[47m', | ||
'DARKGRAY': '\033[100m', | ||
'LIGHTRED': '\033[101m', | ||
'LIGHTGREEN': '\033[102m', | ||
'LIGHTYELLOW': '\033[103m', | ||
'LIGHTBLUE': '\033[104m', | ||
'LIGHTMAGENTA': '\033[105m', | ||
'LIGHTCYAN': '\033[106m', | ||
'WHITE': '\033[107m' | ||
} | ||
|
||
def test() -> None: | ||
print(f"\nTesting {__name__}.Background...\n") | ||
print(f"{Background.colors['DEFAULT']}|||||{Background.colors['BLACK']}|||||{Background.colors['DARKGRAY']}|||||{Background.colors['LIGHTGRAY']}|||||{Background.colors['WHITE']}|||||{Background.colors['DEFAULT']}") | ||
print(f"{Background.colors['RED']}|||||{Background.colors['GREEN']}|||||{Background.colors['YELLOW']}|||||{Background.colors['BLUE']}|||||{Background.colors['MAGENTA']}|||||{Background.colors['CYAN']}|||||{Background.colors['DEFAULT']}") | ||
print(f"{Background.colors['LIGHTRED']}|||||{Background.colors['LIGHTGREEN']}|||||{Background.colors['LIGHTYELLOW']}|||||{Background.colors['LIGHTBLUE']}|||||{Background.colors['LIGHTMAGENTA']}|||||{Background.colors['LIGHTCYAN']}|||||{Background.colors['DEFAULT']}\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# External class visibility | ||
__all__ = ['Typography', 'Reset'] | ||
|
||
|
||
class Typography: | ||
# Text typography dictionary | ||
types = { | ||
'DEFAULT': '\033[0m', | ||
|
||
'BOLD': '\033[1m', | ||
'DIM': '\033[2m', | ||
'ITALIC': '\033[3m', | ||
'UNDERLINED': '\033[4m', | ||
'BLINKING1': '\033[5m', | ||
'BLINKING2': '\033[6m', | ||
'INVERTED': '\033[7m', | ||
'HIDDEN': '\033[8m', | ||
'STRIKETHROUGH': '\033[9m' | ||
} | ||
|
||
def test() -> None: | ||
print(f"\nTesting {__name__}.Typogrddaphy...\n") | ||
print(f"{Typography.types['DEFAULT']}Default{Reset.types['ALL']}, {Typography.types['BOLD']}Bold{Reset.types['ALL']}, {Typography.types['DIM']}Dim{Reset.types['ALL']}, {Typography.types['ITALIC']}Italic{Reset.types['ALL']}, {Typography.types['UNDERLINED']}Underlined{Reset.types['ALL']},") | ||
print(f"{Typography.types['BLINKING1']}Blinking{Reset.types['ALL']}, {Typography.types['BLINKING2']}Blinking{Reset.types['ALL']}, {Typography.types['INVERTED']}Inverted{Reset.types['ALL']}, {Typography.types['HIDDEN']}Hidden{Reset.types['ALL']}, {Typography.types['STRIKETHROUGH']}Strikethrough{Reset.types['ALL']}\n") | ||
|
||
|
||
class Reset: | ||
# Reset typography dictionary | ||
types = { | ||
'ALL': '\033[0m', | ||
|
||
'BOLD': '\033[21m', | ||
'DIM': '\033[22m', | ||
'ITALIC': '\033[23m', | ||
'UNDERLINED': '\033[24m', | ||
'BLINKING1': '\033[25m', | ||
'BLINKING2': '\033[26m', | ||
'INVERTED': '\033[27m', | ||
'HIDDEN': '\033[28m', | ||
'STRIKETHROUGH': '\033[29m' | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from .color import Text, Background | ||
from .text import Typography, Reset | ||
|
||
__all__ = ['apply', 'test'] | ||
|
||
def apply(text: str, text_color: str = None, background_color: str = None, typography: str = None) -> str: | ||
formatting = "" | ||
|
||
if text_color is not None: | ||
formatting += Text.colors[text_color.upper()] if text_color.upper() in Text.colors else '' | ||
if background_color is not None: | ||
formatting += Background.colors[background_color.upper()] if background_color.upper() in Background.colors else '' | ||
if typography is not None: | ||
formatting += Typography.types[typography.upper()] if typography.upper() in Typography.types else '' | ||
return formatting + text + Reset.types['ALL'] | ||
|
||
def test(): | ||
""" | ||
Test function which executes test | ||
functions from formatting classes. | ||
""" | ||
Text.test() | ||
Background.test() | ||
Typography.test() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
# Import hello_world.py from /utilities/ so hello_world() is | ||
# usable at 'from jutils import utilities' level. | ||
from .hello_world import hello_world | ||
# Import utils.py so module | ||
# functions are usable at | ||
# 'from jutl import utilities' level. | ||
from .utils import * | ||
|
||
# Only show functions specified in | ||
# submodule files to the outside world. | ||
__all__ = utils.__all__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters