rename color constants
This commit is contained in:
@@ -17,17 +17,17 @@ func NewBlogHandler(token string) *BlogHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *BlogHandler) Handle(s *engine.Session) {
|
func (h *BlogHandler) Handle(s *engine.Session) {
|
||||||
renderWikiList(s, h.repo, "blog", "Blog Posts", engine.BL)
|
renderWikiList(s, h.repo, "blog", "Blog Posts", engine.COLOR_BLUE)
|
||||||
}
|
}
|
||||||
|
|
||||||
// renderWikiList is a helper used by wiki-based handlers
|
// renderWikiList is a helper used by wiki-based handlers
|
||||||
func renderWikiList(s *engine.Session, repo *wikiRepository, tag, title, color string) {
|
func renderWikiList(s *engine.Session, repo *wikiRepository, tag, title, color string) {
|
||||||
s.Printer.BoxHeader(title, color)
|
s.Printer.BoxHeader(title, color)
|
||||||
s.Printer.Send(fmt.Sprintf(" %s%s%s\r\n", engine.GY, s.Lang["WikiLoading"], engine.R))
|
s.Printer.Send(fmt.Sprintf(" %s%s%s\r\n", engine.COLOR_GRAY, s.Lang["WikiLoading"], engine.COLOR_RESET))
|
||||||
|
|
||||||
pages, err := repo.fetchList(tag)
|
pages, err := repo.fetchList(tag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.Printer.Send(fmt.Sprintf("\r\n%s%s: %v%s\r\n", engine.RD, s.Lang["WikiConnError"], err, engine.R))
|
s.Printer.Send(fmt.Sprintf("\r\n%s%s: %v%s\r\n", engine.COLOR_RED, s.Lang["WikiConnError"], err, engine.COLOR_RESET))
|
||||||
s.Printer.Pause(s.Lang)
|
s.Printer.Pause(s.Lang)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ func renderWikiList(s *engine.Session, repo *wikiRepository, tag, title, color s
|
|||||||
s.Printer.Send("\r\033[A\033[2K")
|
s.Printer.Send("\r\033[A\033[2K")
|
||||||
|
|
||||||
if len(pages) == 0 {
|
if len(pages) == 0 {
|
||||||
s.Printer.Send(fmt.Sprintf(" %s%s%s\r\n", engine.GY, fmt.Sprintf(s.Lang["WikiNoResults"], tag), engine.R))
|
s.Printer.Send(fmt.Sprintf(" %s%s%s\r\n", engine.COLOR_GRAY, fmt.Sprintf(s.Lang["WikiNoResults"], tag), engine.COLOR_RESET))
|
||||||
s.Printer.Pause(s.Lang)
|
s.Printer.Pause(s.Lang)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -61,15 +61,15 @@ func renderWikiList(s *engine.Session, repo *wikiRepository, tag, title, color s
|
|||||||
if len(desc) > 60 {
|
if len(desc) > 60 {
|
||||||
desc = desc[:60]
|
desc = desc[:60]
|
||||||
}
|
}
|
||||||
s.Printer.Send(fmt.Sprintf(" %s%2d%s %s%s%s\r\n", color, i+1, engine.R, engine.WH, titleP, engine.R))
|
s.Printer.Send(fmt.Sprintf(" %s%2d%s %s%s%s\r\n", color, i+1, engine.COLOR_RESET, engine.COLOR_WHITE, titleP, engine.COLOR_RESET))
|
||||||
if desc != "" {
|
if desc != "" {
|
||||||
s.Printer.Send(fmt.Sprintf(" %s%s %s%s%s\r\n", engine.GY, date, engine.DIM, desc, engine.R))
|
s.Printer.Send(fmt.Sprintf(" %s%s %s%s%s\r\n", engine.COLOR_GRAY, date, engine.COLOR_DIM, desc, engine.COLOR_RESET))
|
||||||
} else {
|
} else {
|
||||||
s.Printer.Send(fmt.Sprintf(" %s%s%s\r\n", engine.GY, date, engine.R))
|
s.Printer.Send(fmt.Sprintf(" %s%s%s\r\n", engine.COLOR_GRAY, date, engine.COLOR_RESET))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s.Printer.Send(fmt.Sprintf("\r\n%s%s%s ", engine.GY, s.Lang["WikiEnterNum"], engine.R))
|
s.Printer.Send(fmt.Sprintf("\r\n%s%s%s ", engine.COLOR_GRAY, s.Lang["WikiEnterNum"], engine.COLOR_RESET))
|
||||||
choice, _ := s.Printer.ReadLine()
|
choice, _ := s.Printer.ReadLine()
|
||||||
choice = strings.TrimSpace(choice)
|
choice = strings.TrimSpace(choice)
|
||||||
idx, err := strconv.Atoi(choice)
|
idx, err := strconv.Atoi(choice)
|
||||||
@@ -78,10 +78,10 @@ func renderWikiList(s *engine.Session, repo *wikiRepository, tag, title, color s
|
|||||||
}
|
}
|
||||||
|
|
||||||
page := pages[idx-1]
|
page := pages[idx-1]
|
||||||
s.Printer.Send(fmt.Sprintf("\r\n%s%s%s", engine.GY, s.Lang["WikiFetchContent"], engine.R))
|
s.Printer.Send(fmt.Sprintf("\r\n%s%s%s", engine.COLOR_GRAY, s.Lang["WikiFetchContent"], engine.COLOR_RESET))
|
||||||
pageContent, err := repo.fetchContent(page.ID)
|
pageContent, err := repo.fetchContent(page.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.Printer.Send(fmt.Sprintf("\r\n%sHiba: %v%s\r\n", engine.RD, err, engine.R))
|
s.Printer.Send(fmt.Sprintf("\r\n%sHiba: %v%s\r\n", engine.COLOR_RED, err, engine.COLOR_RESET))
|
||||||
s.Printer.Pause(s.Lang)
|
s.Printer.Pause(s.Lang)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -90,10 +90,10 @@ func renderWikiList(s *engine.Session, repo *wikiRepository, tag, title, color s
|
|||||||
s.Printer.Send("\r\n")
|
s.Printer.Send("\r\n")
|
||||||
s.Printer.HR("═", color)
|
s.Printer.HR("═", color)
|
||||||
s.Printer.Send("\r\n")
|
s.Printer.Send("\r\n")
|
||||||
s.Printer.Send(fmt.Sprintf(" %s%s%s%s\r\n", engine.WH, engine.B, page.Title, engine.R))
|
s.Printer.Send(fmt.Sprintf(" %s%s%s%s\r\n", engine.COLOR_WHITE, engine.COLOR_BOLD, page.Title, engine.COLOR_RESET))
|
||||||
url := fmt.Sprintf("%s/%s/%s", WikiJSBaseURL, page.Locale, page.Path)
|
url := fmt.Sprintf("%s/%s/%s", WikiJSBaseURL, page.Locale, page.Path)
|
||||||
s.Printer.Send(fmt.Sprintf(" %s%s %s%s%s\r\n", engine.GY, s.Printer.FmtDate(page.CreatedAt), engine.DIM, url, engine.R))
|
s.Printer.Send(fmt.Sprintf(" %s%s %s%s%s\r\n", engine.COLOR_GRAY, s.Printer.FmtDate(page.CreatedAt), engine.COLOR_DIM, url, engine.COLOR_RESET))
|
||||||
s.Printer.HR("─", engine.GY)
|
s.Printer.HR("─", engine.COLOR_GRAY)
|
||||||
s.Printer.Send("\r\n\r\n")
|
s.Printer.Send("\r\n\r\n")
|
||||||
|
|
||||||
body := s.Printer.Wrapped(pageContent, 2, 5000)
|
body := s.Printer.Wrapped(pageContent, 2, 5000)
|
||||||
@@ -102,7 +102,7 @@ func renderWikiList(s *engine.Session, repo *wikiRepository, tag, title, color s
|
|||||||
}
|
}
|
||||||
|
|
||||||
s.Printer.Send("\r\n")
|
s.Printer.Send("\r\n")
|
||||||
s.Printer.HR("─", engine.GY)
|
s.Printer.HR("─", engine.COLOR_GRAY)
|
||||||
s.Printer.Send("\r\n")
|
s.Printer.Send("\r\n")
|
||||||
s.Printer.Pause(s.Lang)
|
s.Printer.Pause(s.Lang)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ func NewCatalogHandler() *CatalogHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *CatalogHandler) Handle(s *engine.Session) {
|
func (h *CatalogHandler) Handle(s *engine.Session) {
|
||||||
s.Printer.BoxHeader(s.Lang["CatTitle"], engine.YL)
|
s.Printer.BoxHeader(s.Lang["CatTitle"], engine.COLOR_YELLOW)
|
||||||
s.Printer.Send(fmt.Sprintf(" %s%s%s\r\n", engine.GY, s.Lang["WikiLoading"], engine.R))
|
s.Printer.Send(fmt.Sprintf(" %s%s%s\r\n", engine.COLOR_GRAY, s.Lang["WikiLoading"], engine.COLOR_RESET))
|
||||||
|
|
||||||
softwares, err := h.repo.fetchGames()
|
softwares, err := h.repo.fetchGames()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.Printer.Send(fmt.Sprintf("\r\n%s%s: %v%s\r\n", engine.RD, s.Lang["WikiConnError"], err, engine.R))
|
s.Printer.Send(fmt.Sprintf("\r\n%s%s: %v%s\r\n", engine.COLOR_RED, s.Lang["WikiConnError"], err, engine.COLOR_RESET))
|
||||||
s.Printer.Pause(s.Lang)
|
s.Printer.Pause(s.Lang)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,7 @@ func (h *CatalogHandler) Handle(s *engine.Session) {
|
|||||||
s.Printer.Send("\r\033[A\033[2K")
|
s.Printer.Send("\r\033[A\033[2K")
|
||||||
|
|
||||||
if len(softwares) == 0 {
|
if len(softwares) == 0 {
|
||||||
s.Printer.Send(fmt.Sprintf(" %s%s%s\r\n", engine.GY, s.Lang["CatNoGames"], engine.R))
|
s.Printer.Send(fmt.Sprintf(" %s%s%s\r\n", engine.COLOR_GRAY, s.Lang["CatNoGames"], engine.COLOR_RESET))
|
||||||
s.Printer.Pause(s.Lang)
|
s.Printer.Pause(s.Lang)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -40,32 +40,32 @@ func (h *CatalogHandler) Handle(s *engine.Session) {
|
|||||||
sw := entry.Software
|
sw := entry.Software
|
||||||
lr := entry.LatestRelease
|
lr := entry.LatestRelease
|
||||||
|
|
||||||
s.Printer.Send(fmt.Sprintf("\r\n %s%s%s\r\n", engine.YL, strings.Repeat("─", engine.W-4), engine.R))
|
s.Printer.Send(fmt.Sprintf("\r\n %s%s%s\r\n", engine.COLOR_YELLOW, strings.Repeat("─", engine.W-4), engine.COLOR_RESET))
|
||||||
s.Printer.Send(fmt.Sprintf(" %s%2d.%s %s%s%s%s %s[%s] by %s%s\r\n",
|
s.Printer.Send(fmt.Sprintf(" %s%2d.%s %s%s%s%s %s[%s] by %s%s\r\n",
|
||||||
engine.YL, i+1, engine.R,
|
engine.COLOR_YELLOW, i+1, engine.COLOR_RESET,
|
||||||
engine.WH, engine.B, sw.Title, engine.R,
|
engine.COLOR_WHITE, engine.COLOR_BOLD, sw.Title, engine.COLOR_RESET,
|
||||||
engine.GY, sw.Platform, sw.Author, engine.R))
|
engine.COLOR_GREEN, sw.Platform, sw.Author, engine.COLOR_RESET))
|
||||||
|
|
||||||
if sw.Desc != "" {
|
if sw.Desc != "" {
|
||||||
wrappedDesc := s.Printer.Wrapped(sw.Desc, 7, 1000)
|
wrappedDesc := s.Printer.Wrapped(sw.Desc, 7, 1000)
|
||||||
for _, line := range strings.Split(wrappedDesc, "\r\n") {
|
for _, line := range strings.Split(wrappedDesc, "\r\n") {
|
||||||
s.Printer.Send(fmt.Sprintf("%s%s\r\n", engine.GY, line))
|
s.Printer.Send(fmt.Sprintf("%s%s\r\n", engine.COLOR_GRAY, line))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if lr != nil {
|
if lr != nil {
|
||||||
badges := []string{}
|
badges := []string{}
|
||||||
if lr.HTMLFolderPath != "" {
|
if lr.HTMLFolderPath != "" {
|
||||||
badges = append(badges, fmt.Sprintf("%s[▶ Play]%s", engine.GR, engine.R))
|
badges = append(badges, fmt.Sprintf("%s[▶ Play]%s", engine.COLOR_GREEN, engine.COLOR_RESET))
|
||||||
}
|
}
|
||||||
if lr.CartridgePath != "" {
|
if lr.CartridgePath != "" {
|
||||||
badges = append(badges, fmt.Sprintf("%s[⬇ Download]%s", engine.BL, engine.R))
|
badges = append(badges, fmt.Sprintf("%s[⬇ Download]%s", engine.COLOR_BLUE, engine.COLOR_RESET))
|
||||||
}
|
}
|
||||||
if lr.SourcePath != "" {
|
if lr.SourcePath != "" {
|
||||||
badges = append(badges, fmt.Sprintf("%s[Source]%s", engine.MG, engine.R))
|
badges = append(badges, fmt.Sprintf("%s[Source]%s", engine.COLOR_MAGENTA, engine.COLOR_RESET))
|
||||||
}
|
}
|
||||||
if lr.DocsFolderPath != "" {
|
if lr.DocsFolderPath != "" {
|
||||||
badges = append(badges, fmt.Sprintf("%s[Docs]%s", engine.YL, engine.R))
|
badges = append(badges, fmt.Sprintf("%s[Docs]%s", engine.COLOR_YELLOW, engine.COLOR_RESET))
|
||||||
}
|
}
|
||||||
|
|
||||||
badgeStr := "–"
|
badgeStr := "–"
|
||||||
@@ -73,19 +73,19 @@ func (h *CatalogHandler) Handle(s *engine.Session) {
|
|||||||
badgeStr = strings.Join(badges, " ")
|
badgeStr = strings.Join(badges, " ")
|
||||||
}
|
}
|
||||||
s.Printer.Send(fmt.Sprintf(" %s%s: v%s%s %s\r\n",
|
s.Printer.Send(fmt.Sprintf(" %s%s: v%s%s %s\r\n",
|
||||||
engine.GY, s.Lang["CatLatest"], lr.Version, engine.R, badgeStr))
|
engine.COLOR_GRAY, s.Lang["CatLatest"], lr.Version, engine.COLOR_RESET, badgeStr))
|
||||||
|
|
||||||
if lr.HTMLFolderPath != "" {
|
if lr.HTMLFolderPath != "" {
|
||||||
url := base + lr.HTMLFolderPath
|
url := base + lr.HTMLFolderPath
|
||||||
s.Printer.Send(fmt.Sprintf(" %s▶ %s%s\r\n", engine.DIM, url, engine.R))
|
s.Printer.Send(fmt.Sprintf(" %s▶ %s%s\r\n", engine.COLOR_DIM, url, engine.COLOR_RESET))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.Printer.Send(fmt.Sprintf(" %s%s%s\r\n",
|
s.Printer.Send(fmt.Sprintf(" %s%s%s\r\n",
|
||||||
engine.GY, fmt.Sprintf(s.Lang["CatVersions"], len(entry.Releases)), engine.R))
|
engine.COLOR_GRAY, fmt.Sprintf(s.Lang["CatVersions"], len(entry.Releases)), engine.COLOR_RESET))
|
||||||
}
|
}
|
||||||
|
|
||||||
s.Printer.HR("─", engine.YL)
|
s.Printer.HR("─", engine.COLOR_YELLOW)
|
||||||
s.Printer.Send("\r\n")
|
s.Printer.Send("\r\n")
|
||||||
s.Printer.Send(fmt.Sprintf(" %s%s: %s%s\r\n", engine.GY, s.Lang["CatFull"], base, engine.R))
|
s.Printer.Send(fmt.Sprintf(" %s%s: %s%s\r\n", engine.COLOR_GREEN, s.Lang["CatFull"], base, engine.COLOR_RESET))
|
||||||
s.Printer.Pause(s.Lang)
|
s.Printer.Pause(s.Lang)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,5 @@ func NewHowToHandler(token string) *HowToHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *HowToHandler) Handle(s *engine.Session) {
|
func (h *HowToHandler) Handle(s *engine.Session) {
|
||||||
renderWikiList(s, h.repo, "howto", "HowTo Guides", engine.MG)
|
renderWikiList(s, h.repo, "howto", "HowTo Guides", engine.COLOR_MAGENTA)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ func NewMessageBoardIndexHandler(board *MessageBoard) *MessageBoardIndexHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *MessageBoardIndexHandler) Handle(s *engine.Session) {
|
func (h *MessageBoardIndexHandler) Handle(s *engine.Session) {
|
||||||
s.Printer.BoxHeader(s.Lang["MsgBoardTitle"], engine.GR)
|
s.Printer.BoxHeader(s.Lang["MsgBoardTitle"], engine.COLOR_GRAY)
|
||||||
|
|
||||||
h.board.mu.Lock()
|
h.board.mu.Lock()
|
||||||
snap := make([]message, len(h.board.messages))
|
snap := make([]message, len(h.board.messages))
|
||||||
@@ -23,7 +23,7 @@ func (h *MessageBoardIndexHandler) Handle(s *engine.Session) {
|
|||||||
h.board.mu.Unlock()
|
h.board.mu.Unlock()
|
||||||
|
|
||||||
if len(snap) == 0 {
|
if len(snap) == 0 {
|
||||||
s.Printer.Send(fmt.Sprintf(" %s%s%s\r\n", engine.GY, s.Lang["MsgNoMessages"], engine.R))
|
s.Printer.Send(fmt.Sprintf(" %s%s%s\r\n", engine.COLOR_GRAY, s.Lang["MsgNoMessages"], engine.COLOR_RESET))
|
||||||
} else {
|
} else {
|
||||||
start := 0
|
start := 0
|
||||||
if len(snap) > 30 {
|
if len(snap) > 30 {
|
||||||
@@ -31,9 +31,9 @@ func (h *MessageBoardIndexHandler) Handle(s *engine.Session) {
|
|||||||
}
|
}
|
||||||
for i, msg := range snap[start:] {
|
for i, msg := range snap[start:] {
|
||||||
s.Printer.Send(fmt.Sprintf(" %s%02d%s %s%s%s %s%s:%s %s\r\n",
|
s.Printer.Send(fmt.Sprintf(" %s%02d%s %s%s%s %s%s:%s %s\r\n",
|
||||||
engine.GR, i+1, engine.R,
|
engine.COLOR_GRAY, i+1, engine.COLOR_RESET,
|
||||||
engine.GY, msg.Timestamp, engine.R,
|
engine.COLOR_GRAY, msg.Timestamp, engine.COLOR_RESET,
|
||||||
engine.WH, msg.User, engine.R, msg.Text))
|
engine.COLOR_WHITE, msg.User, engine.COLOR_RESET, msg.Text))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.Printer.Pause(s.Lang)
|
s.Printer.Pause(s.Lang)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ func NewMessageBoardNewHandler(board *MessageBoard) *MessageBoardNewHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *MessageBoardNewHandler) Handle(s *engine.Session) {
|
func (h *MessageBoardNewHandler) Handle(s *engine.Session) {
|
||||||
s.Printer.Send(fmt.Sprintf("\r\n%s%s%s ", engine.WH, s.Lang["MsgEnterText"], engine.R))
|
s.Printer.Send(fmt.Sprintf("\r\n%s%s%s ", engine.COLOR_WHITE, s.Lang["MsgEnterText"], engine.COLOR_RESET))
|
||||||
msgText, _ := s.Printer.ReadLine()
|
msgText, _ := s.Printer.ReadLine()
|
||||||
msgText = strings.TrimSpace(msgText)
|
msgText = strings.TrimSpace(msgText)
|
||||||
if msgText != "" {
|
if msgText != "" {
|
||||||
@@ -30,9 +30,9 @@ func (h *MessageBoardNewHandler) Handle(s *engine.Session) {
|
|||||||
h.board.messages = append(h.board.messages, msg)
|
h.board.messages = append(h.board.messages, msg)
|
||||||
h.board.mu.Unlock()
|
h.board.mu.Unlock()
|
||||||
h.board.append(msg)
|
h.board.append(msg)
|
||||||
s.Printer.Send(fmt.Sprintf("\r\n%s%s%s\r\n", engine.GR, s.Lang["MsgSent"], engine.R))
|
s.Printer.Send(fmt.Sprintf("\r\n%s%s%s\r\n", engine.COLOR_GREEN, s.Lang["MsgSent"], engine.COLOR_RESET))
|
||||||
} else {
|
} else {
|
||||||
s.Printer.Send(fmt.Sprintf("\r\n%s%s%s\r\n", engine.GY, s.Lang["MsgEmpty"], engine.R))
|
s.Printer.Send(fmt.Sprintf("\r\n%s%s%s\r\n", engine.COLOR_GRAY, s.Lang["MsgEmpty"], engine.COLOR_RESET))
|
||||||
}
|
}
|
||||||
s.Printer.Pause(s.Lang)
|
s.Printer.Pause(s.Lang)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ func NewOnlineHandler() *OnlineHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *OnlineHandler) Handle(s *engine.Session) {
|
func (h *OnlineHandler) Handle(s *engine.Session) {
|
||||||
s.Printer.BoxHeader(s.Lang["OnlineTitle"], engine.CY)
|
s.Printer.BoxHeader(s.Lang["OnlineTitle"], engine.COLOR_YELLOW)
|
||||||
|
|
||||||
snap := s.State.Snapshot()
|
snap := s.State.Snapshot()
|
||||||
keys := make([]string, 0, len(snap))
|
keys := make([]string, 0, len(snap))
|
||||||
@@ -27,12 +27,12 @@ func (h *OnlineHandler) Handle(s *engine.Session) {
|
|||||||
user := snap[addr]
|
user := snap[addr]
|
||||||
marker := ""
|
marker := ""
|
||||||
if addr == s.Addr {
|
if addr == s.Addr {
|
||||||
marker = fmt.Sprintf(" %s%s%s", engine.GR, s.Lang["OnlineYou"], engine.R)
|
marker = fmt.Sprintf(" %s%s%s", engine.COLOR_GREEN, s.Lang["OnlineYou"], engine.COLOR_RESET)
|
||||||
}
|
}
|
||||||
s.Printer.Send(fmt.Sprintf(" %s•%s %s%s%s%s\r\n", engine.CY, engine.R, engine.WH, user, engine.R, marker))
|
s.Printer.Send(fmt.Sprintf(" %s•%s %s%s%s%s\r\n", engine.COLOR_YELLOW, engine.COLOR_RESET, engine.COLOR_WHITE, user, engine.COLOR_RESET, marker))
|
||||||
}
|
}
|
||||||
|
|
||||||
s.Printer.Send(fmt.Sprintf("\r\n %s%s\r\n", engine.GY,
|
s.Printer.Send(fmt.Sprintf("\r\n %s%s\r\n", engine.COLOR_GRAY,
|
||||||
fmt.Sprintf(s.Lang["OnlineTotal"], engine.WH, len(snap), engine.GY, engine.R)))
|
fmt.Sprintf(s.Lang["OnlineTotal"], engine.COLOR_WHITE, len(snap), engine.COLOR_GRAY, engine.COLOR_RESET)))
|
||||||
s.Printer.Pause(s.Lang)
|
s.Printer.Pause(s.Lang)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ func NewSysinfoHandler(board *MessageBoard) *SysinfoHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *SysinfoHandler) Handle(s *engine.Session) {
|
func (h *SysinfoHandler) Handle(s *engine.Session) {
|
||||||
s.Printer.BoxHeader(s.Lang["SysTitle"], engine.GY)
|
s.Printer.BoxHeader(s.Lang["SysTitle"], engine.COLOR_GRAY)
|
||||||
|
|
||||||
s.Printer.Send(fmt.Sprintf(" %s%-15s%s %d\r\n", engine.GY, s.Lang["SysUsers"], engine.WH, s.State.UserCount()))
|
s.Printer.Send(fmt.Sprintf(" %s%-15s%s %d\r\n", engine.COLOR_GRAY, s.Lang["SysUsers"], engine.COLOR_RESET, s.State.UserCount()))
|
||||||
s.Printer.Send(fmt.Sprintf(" %s%-15s%s %d\r\n", engine.GY, s.Lang["SysMessages"], engine.WH, h.board.Count()))
|
s.Printer.Send(fmt.Sprintf(" %s%-15s%s %d\r\n", engine.COLOR_GRAY, s.Lang["SysMessages"], engine.COLOR_RESET, h.board.Count()))
|
||||||
s.Printer.Send(fmt.Sprintf(" %s%-15s%s %s\r\n", engine.GY, s.Lang["SysOS"], engine.WH, runtime.GOOS))
|
s.Printer.Send(fmt.Sprintf(" %s%-15s%s %s\r\n", engine.COLOR_GRAY, s.Lang["SysOS"], engine.COLOR_RESET, runtime.GOOS))
|
||||||
s.Printer.Send(fmt.Sprintf(" %s%-15s%s %s\r\n", engine.GY, s.Lang["SysArch"], engine.WH, runtime.GOARCH))
|
s.Printer.Send(fmt.Sprintf(" %s%-15s%s %s\r\n", engine.COLOR_GRAY, s.Lang["SysArch"], engine.COLOR_RESET, runtime.GOARCH))
|
||||||
|
|
||||||
s.Printer.Pause(s.Lang)
|
s.Printer.Pause(s.Lang)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,26 +53,26 @@ func (m *Menu) Dispatch(s *Session, key string) {
|
|||||||
// Render returns the rendered menu string
|
// Render returns the rendered menu string
|
||||||
func (m *Menu) Render(p *Printer, lang T, username string) string {
|
func (m *Menu) Render(p *Printer, lang T, username string) string {
|
||||||
headerLine := strings.Repeat("═", W)
|
headerLine := strings.Repeat("═", W)
|
||||||
l1 := p.PadLine(fmt.Sprintf(" %s%s%s %s@%s%s", YL, m.title, R, GY, username, R), W)
|
l1 := p.PadLine(fmt.Sprintf(" %s%s%s %s@%s%s", COLOR_YELLOW, m.title, COLOR_RESET, COLOR_GRAY, username, COLOR_RESET), W)
|
||||||
|
|
||||||
var rows []string
|
var rows []string
|
||||||
for i := 0; i < len(m.items); i += 2 {
|
for i := 0; i < len(m.items); i += 2 {
|
||||||
if i+1 < len(m.items) {
|
if i+1 < len(m.items) {
|
||||||
left := p.PadLine(fmt.Sprintf(" %s[%s]%s %s", m.items[i].Color, m.items[i].Key, R, m.items[i].Label), W/2)
|
left := p.PadLine(fmt.Sprintf(" %s[%s]%s %s", m.items[i].Color, m.items[i].Key, COLOR_RESET, m.items[i].Label), W/2)
|
||||||
right := p.PadLine(fmt.Sprintf(" %s[%s]%s %s", m.items[i+1].Color, m.items[i+1].Key, R, m.items[i+1].Label), W/2)
|
right := p.PadLine(fmt.Sprintf(" %s[%s]%s %s", m.items[i+1].Color, m.items[i+1].Key, COLOR_RESET, m.items[i+1].Label), W/2)
|
||||||
rows = append(rows, left+right)
|
rows = append(rows, left+right)
|
||||||
} else {
|
} else {
|
||||||
rows = append(rows, p.PadLine(fmt.Sprintf(" %s[%s]%s %s", m.items[i].Color, m.items[i].Key, R, m.items[i].Label), W))
|
rows = append(rows, p.PadLine(fmt.Sprintf(" %s[%s]%s %s", m.items[i].Color, m.items[i].Key, COLOR_RESET, m.items[i].Label), W))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var sb strings.Builder
|
var sb strings.Builder
|
||||||
sb.WriteString(fmt.Sprintf("\n%s╔%s╗%s\n", WH, headerLine, R))
|
sb.WriteString(fmt.Sprintf("\n%s╔%s╗%s\n", COLOR_WHITE, headerLine, COLOR_RESET))
|
||||||
sb.WriteString(fmt.Sprintf("%s║%s%s║%s\n", WH, l1, WH, R))
|
sb.WriteString(fmt.Sprintf("%s║%s%s║%s\n", COLOR_WHITE, l1, COLOR_WHITE, COLOR_RESET))
|
||||||
sb.WriteString(fmt.Sprintf("%s╠%s╣%s\n", WH, headerLine, R))
|
sb.WriteString(fmt.Sprintf("%s╠%s╣%s\n", COLOR_WHITE, headerLine, COLOR_RESET))
|
||||||
for _, row := range rows {
|
for _, row := range rows {
|
||||||
sb.WriteString(fmt.Sprintf("%s║%s%s║%s\n", WH, row, WH, R))
|
sb.WriteString(fmt.Sprintf("%s║%s%s║%s\n", COLOR_WHITE, row, COLOR_WHITE, COLOR_RESET))
|
||||||
}
|
}
|
||||||
sb.WriteString(fmt.Sprintf("%s╚%s╝%s\n%s", WH, headerLine, R, lang["Choice"]))
|
sb.WriteString(fmt.Sprintf("%s╚%s╝%s\n%s", COLOR_WHITE, headerLine, COLOR_RESET, lang["Choice"]))
|
||||||
return sb.String()
|
return sb.String()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,17 +12,17 @@ import (
|
|||||||
|
|
||||||
// ANSI color codes
|
// ANSI color codes
|
||||||
const (
|
const (
|
||||||
R = "\033[0m"
|
COLOR_RESET = "\033[0m"
|
||||||
B = "\033[1m"
|
COLOR_BOLD = "\033[1m"
|
||||||
DIM = "\033[2m"
|
COLOR_DIM = "\033[2m"
|
||||||
CY = "\033[1;36m"
|
COLOR_CYAN = "\033[1;36m"
|
||||||
YL = "\033[1;33m"
|
COLOR_YELLOW = "\033[1;33m"
|
||||||
GR = "\033[1;32m"
|
COLOR_GREEN = "\033[1;32m"
|
||||||
RD = "\033[1;31m"
|
COLOR_RED = "\033[1;31m"
|
||||||
MG = "\033[1;35m"
|
COLOR_MAGENTA = "\033[1;35m"
|
||||||
WH = "\033[1;37m"
|
COLOR_WHITE = "\033[1;37m"
|
||||||
BL = "\033[1;34m"
|
COLOR_BLUE = "\033[1;34m"
|
||||||
GY = "\033[0;37m"
|
COLOR_GRAY = "\033[0;37m"
|
||||||
)
|
)
|
||||||
|
|
||||||
// W is the default terminal width
|
// W is the default terminal width
|
||||||
@@ -94,7 +94,7 @@ func (p *Printer) ReadLine() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Printer) Pause(lang T) {
|
func (p *Printer) Pause(lang T) {
|
||||||
p.Send(fmt.Sprintf("\r\n%s [ %s ]%s ", GY, lang["Pause"], R))
|
p.Send(fmt.Sprintf("\r\n%s [ %s ]%s ", COLOR_GRAY, lang["Pause"], COLOR_RESET))
|
||||||
p.ReadLine()
|
p.ReadLine()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,14 +122,14 @@ func (p *Printer) BoxHeader(title string, color string) {
|
|||||||
inner := strings.Repeat(" ", padding) + title + strings.Repeat(" ", W-2-titleLen-padding)
|
inner := strings.Repeat(" ", padding) + title + strings.Repeat(" ", W-2-titleLen-padding)
|
||||||
p.Send(fmt.Sprintf(
|
p.Send(fmt.Sprintf(
|
||||||
"\n%s%s%s\n%s║%s %s%s%s %s║%s\n%s%s%s\n",
|
"\n%s%s%s\n%s║%s %s%s%s %s║%s\n%s%s%s\n",
|
||||||
color, line, R,
|
color, line, COLOR_RESET,
|
||||||
color, R, B, inner, R, color, R,
|
color, COLOR_RESET, COLOR_BOLD, inner, COLOR_RESET, color, COLOR_RESET,
|
||||||
color, line, R,
|
color, line, COLOR_RESET,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Printer) HR(char string, color string) {
|
func (p *Printer) HR(char string, color string) {
|
||||||
p.Send(fmt.Sprintf("%s%s%s", color, strings.Repeat(char, W), R))
|
p.Send(fmt.Sprintf("%s%s%s", color, strings.Repeat(char, W), COLOR_RESET))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Printer) FmtDate(s string) string {
|
func (p *Printer) FmtDate(s string) string {
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ func (b *BBS) handleClient(conn net.Conn) {
|
|||||||
// Telnet negotiation (IAC WILL ECHO, IAC WILL SGA, IAC WONT LINEMODE)
|
// Telnet negotiation (IAC WILL ECHO, IAC WILL SGA, IAC WONT LINEMODE)
|
||||||
printer.Send("\xff\xfb\x01\xff\xfb\x03\xff\xfe\x22")
|
printer.Send("\xff\xfb\x01\xff\xfb\x03\xff\xfe\x22")
|
||||||
|
|
||||||
printer.Send(CY + b.config.Banner + R)
|
printer.Send(COLOR_CYAN + b.config.Banner + COLOR_RESET)
|
||||||
printer.Send(fmt.Sprintf("\n%s%s%s ", WH, lang["AskName"], R))
|
printer.Send(fmt.Sprintf("\n%s%s%s ", COLOR_WHITE, lang["AskName"], COLOR_RESET))
|
||||||
|
|
||||||
username, err := printer.ReadLine()
|
username, err := printer.ReadLine()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -98,7 +98,7 @@ func (b *BBS) handleClient(conn net.Conn) {
|
|||||||
b.state.Mu.Unlock()
|
b.state.Mu.Unlock()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
printer.Send(fmt.Sprintf("\r\n%s%s%s\r\n", GR, fmt.Sprintf(lang["Greeting"], WH, username, GR), R))
|
printer.Send(fmt.Sprintf("\r\n%s%s%s\r\n", COLOR_GREEN, fmt.Sprintf(lang["Greeting"], COLOR_WHITE, username, COLOR_GREEN), COLOR_RESET))
|
||||||
|
|
||||||
session := &Session{
|
session := &Session{
|
||||||
State: b.state,
|
State: b.state,
|
||||||
@@ -118,6 +118,6 @@ func (b *BBS) handleClient(conn net.Conn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if session.Quit {
|
if session.Quit {
|
||||||
printer.Send(fmt.Sprintf("\r\n%s%s%s\r\n\r\n", RD, fmt.Sprintf(lang["Goodbye"], username), R))
|
printer.Send(fmt.Sprintf("\r\n%s%s%s\r\n\r\n", COLOR_RED, fmt.Sprintf(lang["Goodbye"], username), COLOR_RESET))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
16
main.go
16
main.go
@@ -60,14 +60,14 @@ func main() {
|
|||||||
|
|
||||||
bbs.Menu(func(m *engine.Menu) {
|
bbs.Menu(func(m *engine.Menu) {
|
||||||
m.Title("MAIN MENU")
|
m.Title("MAIN MENU")
|
||||||
m.Item("1", "Message Board", engine.GR, messageBoardIndexHandler.Handle)
|
m.Item("1", "Message Board", engine.COLOR_GREEN, messageBoardIndexHandler.Handle)
|
||||||
m.Item("N", "New Message", engine.WH, messageBoardNewHandler.Handle)
|
m.Item("N", "New Message", engine.COLOR_WHITE, messageBoardNewHandler.Handle)
|
||||||
m.Item("2", "Blog Posts", engine.BL, blogHandler.Handle)
|
m.Item("2", "Blog Posts", engine.COLOR_BLUE, blogHandler.Handle)
|
||||||
m.Item("3", "HowTo Guides", engine.MG, howtoHandler.Handle)
|
m.Item("3", "HowTo Guides", engine.COLOR_MAGENTA, howtoHandler.Handle)
|
||||||
m.Item("4", "Game Catalog", engine.YL, catalogHandler.Handle)
|
m.Item("4", "Game Catalog", engine.COLOR_YELLOW, catalogHandler.Handle)
|
||||||
m.Item("5", "Online Users", engine.CY, onlineHandler.Handle)
|
m.Item("5", "Online Users", engine.COLOR_CYAN, onlineHandler.Handle)
|
||||||
m.Item("6", "System Info", engine.GY, sysinfoHandler.Handle)
|
m.Item("6", "System Info", engine.COLOR_GRAY, sysinfoHandler.Handle)
|
||||||
m.Item("Q", "Exit", engine.RD, engine.Exit)
|
m.Item("Q", "Exit", engine.COLOR_RED, engine.Exit)
|
||||||
})
|
})
|
||||||
|
|
||||||
bbs.Start()
|
bbs.Start()
|
||||||
|
|||||||
Reference in New Issue
Block a user