代码拉取完成,页面将自动刷新
package tool
//add by stefan for linux system.
import (
"fmt"
)
/*
Foreground Background Color
30 40 black
31 41 red
32 42 green
33 43 yellow
34 44 blue
35 45 Fuchsia
36 46 cyan
37 47 white
*/
const (
LinuxForeground_Black = 0x1E
LinuxForeground_Red = 0x1F
LinuxForeground_GREEN = 0x20
LinuxForeground_YELLOW = 0x21
LinuxForeground_BLUE = 0x22
LinuxForeground_FUCHSIA = 0x23
LinuxForeground_CYAN = 0x24
LinuxForeground_WHITE = 0x25
)
const (
LinuxBackground_Black = 0x28
LinuxBackground_Red = 0x29
LinuxBackground_GREEN = 0x2a
LinuxBackground_YELLOW = 0x2b
LinuxBackground_BLUE = 0x2c
LinuxBackground_FUCHSIA = 0x2d
LinuxBackground_CYAN = 0x2e
LinuxBackground_WHITE = 0x2f
)
/*
coding meaning
0 Terminal default settings (终端默认设置)
1 Highlight (高亮显示)
4 Use underline (使用下划线)
5 flashes (闪烁)
7 Highlighted (反白显示)
8 Invisible (不可见)
*/
/*
@param 1: background color
@param 2: foreground color
@param 3: content
*/
func LinuxColorPrint(bg int, fg int, str string) {
//SGR params x1b = 033
strFmt := fmt.Sprintf("\x1b[%dm\x1b[%dm%s\x1b[0m", bg, fg, str)
fmt.Println(strFmt)
}
/*
default background color: black
@param 1: foreground color
@param 2: content
*/
func LinuxDefaultBGPrint(fg int, str string) {
strFmt := fmt.Sprintf("\x1b[40m\x1b[%dm%s\x1b[0m", fg, str)
fmt.Println(strFmt)
}
/*
default background color: black
default foreground color: white
@param 1: content
*/
func LinuxDefaultColorPrint(str string) {
strFmt := fmt.Sprintf("\x1b[m%s\x1b[0m", str)
fmt.Println(strFmt)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。