"""InterestPrint 库
作者:袁窦涵
邮箱:w111251@outlook.com
各个函数用法如下:
ColorfulPrint(*text, color='white', bold=False, end='\n', sep=' '): 带颜色打印
MeowPrint(*text, meow_count=1, end='\n', sep=' ', front=True, back=True): 喵喵喵打印"""

import sys
import ctypes
from typing import Any
def ColorfulPrint(*text:Any, color:str='white', bold:bool=False, end:str='\n', sep:str=' ')->None:
    """
    带颜色打印
    :param text: 要打印的内容（可变参数）
    :param color: 字体颜色,可选:black/red/green/yellow/blue/purple/cyan/white
    :param bold: 是否加粗,默认False
    :param end: 结尾字符，默认换行
    :param sep: 多个参数的分隔符，默认空格
    """
    colors = {
        'black': 30, 'red': 31, 'green': 32, 'yellow': 33,
        'blue': 34, 'purple': 35, 'cyan': 36, 'white': 37
    }
    if color not in colors:
        raise ValueError(f"颜色必须是以下之一：{list(colors.keys())}")
    if sys.platform == 'win32':
        try:
            kernel32 = ctypes.windll.kernel32
            kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)
        except:
            print(*text, end=end, sep=sep)
            return
    style = 1 if bold else 0
    color_code = colors[color]
    ansi_prefix = f'\033[{style};{color_code}m'
    ansi_suffix = '\033[0m'
    print(f"{ansi_prefix}{sep.join(map(str, text))}{ansi_suffix}", end=end)
def MeowPrint(*text:Any, meow_count:int=1, end:str='\n', sep:str=' ', front:bool=True, back:bool=True)->None:
    """
    喵喵喵打印
    :param text: 要打印的内容（可变参数）
    :param meow_count: 猫咪表情数量,默认1
    :param end: 结尾字符,默认换行
    :param sep: 多个参数的分隔符,默认空格
    :param front: 是否在前面打印表情,默认True
    :param back: 是否打印后面打印表情,默认True
    """
    front_meow = '🐱' * meow_count if front else ''
    back_meow = '🐱' * meow_count if back else ''
    text_str = sep.join(map(str, text)) if text else ''
    print(f"{front_meow}{text_str}{back_meow}", end=end, sep=sep)
__all__ = ['ColorfulPrint', 'MeowPrint']
# 测试用例
if __name__ == '__main__':
    ColorfulPrint("这是红色加粗", color='red', bold=True)
    ColorfulPrint("这是绿色常规", color='green')
    ColorfulPrint("多参数", "测试", color='blue', sep='|')
    ColorfulPrint("黄色结尾无换行", color='yellow', end='')
    print(" → 看，没换行～")
    MeowPrint("喵喵喵", meow_count=2, front=True, back=False)
    MeowPrint("喵喵喵", meow_count=3, front=False, back=True)
    MeowPrint("喵喵喵","wfe", meow_count=4, end="mmmmm\n",sep=" ")