1 Star 0 Fork 0

阿宇的编程之旅 / js-log-lib

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
types.ts 2.11 KB
一键复制 编辑 原始数据 按行查看 历史
import { ANSIParams } from "./static.js"
// 颜色字符串的索引
export type IColorStr = keyof typeof ANSIParams.color
// 前(后)景色可以是 RGB 对象或颜色字符串
export type IColor = IRGB | IColorStr
// 文本样式
export type ITextStyle = keyof typeof ANSIParams.textStyle
// 光标的方向
export type IDirect = keyof typeof ANSIParams.cursor.direct
// 光标操作的索引
export type ICursor = keyof Omit<typeof ANSIParams.cursor, "direct">
export type IGlobalOpts = Partial<{
text: string; // 要打印的文本
reset: boolean; // 是否在末尾重置样式
type: string; // console的类型
split: boolean; // 是否拆分显示,在node中可以在一个console.log中分开显示,比如:console.log("1","2","3")和console.log("123"),前者在字符之间会有空格,split为true表示使用前者显示,反之使用后者,在浏览器环境下只能合并显示
color: IColor[] | IColor; // 前(后)景色或其数组,方便传入多个颜色参数,但是有些控制台似乎不兼容
textStyle: ITextStyle[] | ITextStyle; // 文本样式或样式数组
cursor: ICursor; // 光标控制
move: IMoveParams; // 光标移动参数
scroll: number; // 滚动条行数
style: Partial<CSSStyleDeclaration>; // CSS样式对象,仅支持浏览器环境
}>
export type IOpts = Omit<IGlobalOpts, "type" | "split">
// 颜色模式,2:真彩色模式; 5:兼容模式; null:默认颜色模式
export type IColorMode = keyof typeof ANSIParams.colorMode
// 颜色类型,48:背景颜色,38:字体颜色
export type IColorType = keyof typeof ANSIParams.colorType
export type IRGB = {
red?: string | number
green?: string | number
blue?: string | number
type?: IColorType // 字体颜色或背景颜色
mode?: IColorMode
color?: string | number// 兼容模式下,256色调色板的颜色索引
}
export type IPosition = {
col: number | string // 列
row: number | string // 行
}
export type IMoveParams = {
direct: IDirect// 移动方向
position: IPosition | number | string// 移动到的位置,可以是坐标对象或数字
}
TypeScript
1
https://gitee.com/DieHunter/js-log-lib.git
git@gitee.com:DieHunter/js-log-lib.git
DieHunter
js-log-lib
js-log-lib
master

搜索帮助