diff options
Diffstat (limited to '')
-rw-r--r-- | src/c_defs.go | 10 | ||||
-rw-r--r-- | src/i_events.go | 5 | ||||
-rw-r--r-- | src/i_host.go | 6 | ||||
-rw-r--r-- | src/i_info.go | 92 | ||||
-rw-r--r-- | src/i_ui.go | 122 |
5 files changed, 127 insertions, 108 deletions
diff --git a/src/c_defs.go b/src/c_defs.go index 4145613..c248466 100644 --- a/src/c_defs.go +++ b/src/c_defs.go @@ -78,6 +78,16 @@ const ( ERROR_MODE = 3 ) +const ( + DEF_STYLE = 0 + DIR_STYLE = 1 + BOX_STYLE = 2 + HEAD_STYLE = 3 + ERR_STYLE = 4 + TITLE_STYLE = 5 + SEL_STYLE = 6 +) + var ( HOST_ICONS = [2]string{" ", " "} DIRS_ICONS = [2]string{" ", " "} diff --git a/src/i_events.go b/src/i_events.go index 526b4a4..4e3baae 100644 --- a/src/i_events.go +++ b/src/i_events.go @@ -305,7 +305,7 @@ func i_events(data *HardData) { if err := ui.s.Init(); err != nil { c_die("view", err) } - ui.s.SetStyle(ui.def_style) + ui.s.SetStyle(ui.style[DEF_STYLE]) } } else if data.litems.curr.Dirs != nil && data.folds[data.litems.curr.Dirs] == nil { @@ -341,7 +341,8 @@ func i_events(data *HardData) { } } case ERROR_MODE: - if event.Key() == tcell.KeyEnter { + if event.Rune() == 'q' || + event.Key() == tcell.KeyEnter { ui.mode = NORMAL_MODE } } diff --git a/src/i_host.go b/src/i_host.go index 0ff0eb2..5d74234 100644 --- a/src/i_host.go +++ b/src/i_host.go @@ -53,7 +53,7 @@ package main func i_host_panel_dirs(ui HardUI, icons bool, dir_icon uint8, dir *DirsNode, curr *DirsNode, line int) { - style := ui.dir_style + style := ui.style[DIR_STYLE] if dir == curr { style = style.Reverse(true) } @@ -77,7 +77,7 @@ func i_host_panel_dirs(ui HardUI, icons bool, dir_icon uint8, func i_host_panel_host(ui HardUI, icons bool, depth uint16, host *HostNode, curr *HostNode, line int) { - style := ui.def_style + style := ui.style[DEF_STYLE] if host == curr { style = style.Reverse(true) } @@ -102,7 +102,7 @@ func i_host_panel_host(ui HardUI, icons bool, func i_draw_host_panel(ui HardUI, icons bool, litems *ItemsList, data *HardData) { i_draw_box(ui.s, 0, 0, ui.dim[W] / 3, ui.dim[H] - 2, - " Hosts ", false) + ui.style[BOX_STYLE], ui.style[HEAD_STYLE], " Hosts ", false) line := 1 if litems == nil || litems.head == nil { return diff --git a/src/i_info.go b/src/i_info.go index 271f1d0..21bc670 100644 --- a/src/i_info.go +++ b/src/i_info.go @@ -65,28 +65,28 @@ func i_info_panel_dirs(ui HardUI, dir *DirsNode) { i_draw_text(ui.s, (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line, - ui.title_style, "Name: ") + ui.style[TITLE_STYLE], "Name: ") i_draw_text(ui.s, (ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line, - ui.def_style, dir.Name) + ui.style[DEF_STYLE], dir.Name) if line += 1; line > ui.dim[H] - 3 { return } i_draw_text(ui.s, (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line, - ui.title_style, "Type: ") + ui.style[TITLE_STYLE], "Type: ") i_draw_text(ui.s, (ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line, - ui.def_style, "Directory") + ui.style[DEF_STYLE], "Directory") if line += 2; line > ui.dim[H] - 3 { return } i_draw_text(ui.s, (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line, - ui.title_style, "Path: ") + ui.style[TITLE_STYLE], "Path: ") i_draw_text(ui.s, (ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line, - ui.def_style, dir.path()) + ui.style[DEF_STYLE], dir.path()[1:]) } func i_info_panel_host(ui HardUI, host *HostNode) { @@ -98,19 +98,19 @@ func i_info_panel_host(ui HardUI, host *HostNode) { // name, type i_draw_text(ui.s, (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line, - ui.title_style, "Name: ") + ui.style[TITLE_STYLE], "Name: ") i_draw_text(ui.s, (ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line, - ui.def_style, host.Name) + ui.style[DEF_STYLE], host.Name) if line += 1; line > ui.dim[H] - 3 { return } i_draw_text(ui.s, (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line, - ui.title_style, "Type: ") + ui.style[TITLE_STYLE], "Type: ") i_draw_text(ui.s, (ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line, - ui.def_style, host_type) + ui.style[DEF_STYLE], host_type) if line += 2; line > ui.dim[H] - 3 { return } @@ -120,19 +120,19 @@ func i_info_panel_host(ui HardUI, host *HostNode) { // host, port i_draw_text(ui.s, (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line, - ui.title_style, "Host: ") + ui.style[TITLE_STYLE], "Host: ") i_draw_text(ui.s, (ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line, - ui.def_style, host.Host) + ui.style[DEF_STYLE], host.Host) if line += 1; line > ui.dim[H] - 3 { return } i_draw_text(ui.s, (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line, - ui.title_style, "Port: ") + ui.style[TITLE_STYLE], "Port: ") i_draw_text(ui.s, (ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line, - ui.def_style, strconv.Itoa(int(host.Port))) + ui.style[DEF_STYLE], strconv.Itoa(int(host.Port))) if line += 1; line > ui.dim[H] - 3 { return } @@ -141,10 +141,10 @@ func i_info_panel_host(ui HardUI, host *HostNode) { if len(host.Domain) > 0 { i_draw_text(ui.s, (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line, - ui.title_style, "Domain: ") + ui.style[TITLE_STYLE], "Domain: ") i_draw_text(ui.s, (ui.dim[W] / 3) + 11, line, ui.dim[W] - 2, line, - ui.def_style, host.Domain) + ui.style[DEF_STYLE], host.Domain) if line += 1; line > ui.dim[H] - 3 { return } @@ -156,20 +156,20 @@ func i_info_panel_host(ui HardUI, host *HostNode) { // user infos i_draw_text(ui.s, (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line, - ui.title_style, "User: ") + ui.style[TITLE_STYLE], "User: ") i_draw_text(ui.s, (ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line, - ui.def_style, host.User) + ui.style[DEF_STYLE], host.User) if line += 1; line > ui.dim[H] - 3 { return } if len(host.Pass) > 0 { i_draw_text(ui.s, (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line, - ui.title_style, "Pass: ") + ui.style[TITLE_STYLE], "Pass: ") i_draw_text(ui.s, (ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line, - ui.def_style, "***") + ui.style[DEF_STYLE], "***") if line += 1; line > ui.dim[H] - 3 { return } @@ -177,10 +177,10 @@ func i_info_panel_host(ui HardUI, host *HostNode) { if host.Protocol == 0 && len(host.Priv) > 0 { i_draw_text(ui.s, (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line, - ui.title_style, "Privkey: ") + ui.style[TITLE_STYLE], "Privkey: ") i_draw_text(ui.s, (ui.dim[W] / 3) + 12, line, ui.dim[W] - 2, line, - ui.def_style, host.Priv) + ui.style[DEF_STYLE], host.Priv) if line += 1; line > ui.dim[H] - 3 { return } @@ -192,44 +192,44 @@ func i_info_panel_host(ui HardUI, host *HostNode) { if host.Protocol == 0 && len(host.Jump) > 0 { i_draw_text(ui.s, (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line, - ui.title_style, "Jump settings: ") + ui.style[TITLE_STYLE], "Jump settings: ") if line += 1; line > ui.dim[H] - 3 { return } i_draw_text(ui.s, (ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line, - ui.title_style, "Host: ") + ui.style[TITLE_STYLE], "Host: ") i_draw_text(ui.s, (ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line, - ui.def_style, host.Jump) + ui.style[DEF_STYLE], host.Jump) if line += 1; line > ui.dim[H] - 3 { return } i_draw_text(ui.s, (ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line, - ui.title_style, "Port: ") + ui.style[TITLE_STYLE], "Port: ") i_draw_text(ui.s, (ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line, - ui.def_style, strconv.Itoa(int(host.JumpPort))) + ui.style[DEF_STYLE], strconv.Itoa(int(host.JumpPort))) if line += 1; line > ui.dim[H] - 3 { return } i_draw_text(ui.s, (ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line, - ui.title_style, "User: ") + ui.style[TITLE_STYLE], "User: ") i_draw_text(ui.s, (ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line, - ui.def_style, host.JumpUser) + ui.style[DEF_STYLE], host.JumpUser) if line += 1; line > ui.dim[H] - 3 { return } if len(host.JumpPass) > 0 { i_draw_text(ui.s, (ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line, - ui.title_style, "Pass: ") + ui.style[TITLE_STYLE], "Pass: ") i_draw_text(ui.s, (ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line, - ui.def_style, "***") + ui.style[DEF_STYLE], "***") if line += 1; line > ui.dim[H] - 3 { return } @@ -237,10 +237,10 @@ func i_info_panel_host(ui HardUI, host *HostNode) { if host.Protocol == 0 && len(host.JumpPriv) > 0 { i_draw_text(ui.s, (ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line, - ui.title_style, "Privkey: ") + ui.style[TITLE_STYLE], "Privkey: ") i_draw_text(ui.s, (ui.dim[W] / 3) + 13, line, ui.dim[W] - 2, line, - ui.def_style, host.JumpPriv) + ui.style[DEF_STYLE], host.JumpPriv) if line += 1; line > ui.dim[H] - 3 { return } @@ -254,10 +254,10 @@ func i_info_panel_host(ui HardUI, host *HostNode) { qual := [3]string{"Low", "Medium", "High"} i_draw_text(ui.s, (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line, - ui.title_style, "Screen size: ") + ui.style[TITLE_STYLE], "Screen size: ") i_draw_text(ui.s, (ui.dim[W] / 3) + 16, line, ui.dim[W] - 2, line, - ui.def_style, + ui.style[DEF_STYLE], strconv.Itoa(int(host.Width)) + "x" + strconv.Itoa(int(host.Height))) if line += 1; line > ui.dim[H] - 3 { @@ -265,19 +265,19 @@ func i_info_panel_host(ui HardUI, host *HostNode) { } i_draw_text(ui.s, (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line, - ui.title_style, "Dynamic window: ") + ui.style[TITLE_STYLE], "Dynamic window: ") i_draw_text(ui.s, (ui.dim[W] / 3) + 19, line, ui.dim[W] - 2, line, - ui.def_style, strconv.FormatBool(host.Dynamic)) + ui.style[DEF_STYLE], strconv.FormatBool(host.Dynamic)) if line += 1; line > ui.dim[H] - 3 { return } i_draw_text(ui.s, (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line, - ui.title_style, "Quality: ") + ui.style[TITLE_STYLE], "Quality: ") i_draw_text(ui.s, (ui.dim[W] / 3) + 12, line, ui.dim[W] - 2, line, - ui.def_style, qual[host.Quality]) + ui.style[DEF_STYLE], qual[host.Quality]) line += 1 if line += 1; line > ui.dim[H] - 3 { return @@ -287,10 +287,10 @@ func i_info_panel_host(ui HardUI, host *HostNode) { if len(host.Note) > 0 { i_draw_text(ui.s, (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line, - ui.title_style, "Note: ") + ui.style[TITLE_STYLE], "Note: ") i_draw_text(ui.s, (ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line, - ui.def_style, host.Note) + ui.style[DEF_STYLE], host.Note) if line += 1; line > ui.dim[H] - 3 { return } @@ -300,10 +300,10 @@ func i_info_panel_host(ui HardUI, host *HostNode) { func i_draw_info_panel(ui HardUI, percent bool, litems *ItemsList) { i_draw_box(ui.s, (ui.dim[W] / 3), 0, ui.dim[W] - 1, ui.dim[H] - 2, - " Infos ", false) - ui.s.SetContent(ui.dim[W] / 3, 0, tcell.RuneTTee, nil, ui.def_style) + ui.style[BOX_STYLE], ui.style[HEAD_STYLE], " Infos ", false) + ui.s.SetContent(ui.dim[W] / 3, 0, tcell.RuneTTee, nil, ui.style[BOX_STYLE]) ui.s.SetContent(ui.dim[W] / 3, ui.dim[H] - 2, - tcell.RuneBTee, nil, ui.def_style) + tcell.RuneBTee, nil, ui.style[BOX_STYLE]) if litems == nil { return } @@ -320,7 +320,7 @@ func i_draw_info_panel(ui HardUI, percent bool, litems *ItemsList) { ui.dim[H] - 2, (ui.dim[W] - 1) - 1, ui.dim[H] - 2, - ui.def_style, + ui.style[DEF_STYLE], text) } else { text := " 0 hosts " @@ -329,7 +329,7 @@ func i_draw_info_panel(ui HardUI, percent bool, litems *ItemsList) { ui.dim[H] - 2, (ui.dim[W] - 1) - 1, ui.dim[H] - 2, - ui.def_style, + ui.style[DEF_STYLE], text) } // panel diff --git a/src/i_ui.go b/src/i_ui.go index 05e5141..1c7f710 100644 --- a/src/i_ui.go +++ b/src/i_ui.go @@ -60,13 +60,11 @@ import ( ) type HardUI struct { - s tcell.Screen - mode uint8 - def_style tcell.Style - dir_style tcell.Style - title_style tcell.Style - dim [2]int - err [2]string + s tcell.Screen + mode uint8 + style [7]tcell.Style + dim [2]int + err [2]string } func i_left_right(text_len int, ui *HardUI) (int, int) { @@ -99,10 +97,8 @@ func i_draw_text(s tcell.Screen, } } -func i_draw_box(s tcell.Screen, x1, y1, x2, y2 int, title string, fill bool) { - style := tcell.StyleDefault. - Background(tcell.ColorReset). - Foreground(tcell.ColorReset) +func i_draw_box(s tcell.Screen, x1, y1, x2, y2 int, + box_style, head_style tcell.Style, title string, fill bool) { if y2 < y1 { y1, y2 = y2, y1 @@ -112,34 +108,32 @@ func i_draw_box(s tcell.Screen, x1, y1, x2, y2 int, title string, fill bool) { } // Draw borders for col := x1; col <= x2; col++ { - s.SetContent(col, y1, tcell.RuneHLine, nil, style) - s.SetContent(col, y2, tcell.RuneHLine, nil, style) + s.SetContent(col, y1, tcell.RuneHLine, nil, box_style) + s.SetContent(col, y2, tcell.RuneHLine, nil, box_style) } for row := y1 + 1; row < y2; row++ { - s.SetContent(x1, row, tcell.RuneVLine, nil, style) - s.SetContent(x2, row, tcell.RuneVLine, nil, style) + s.SetContent(x1, row, tcell.RuneVLine, nil, box_style) + s.SetContent(x2, row, tcell.RuneVLine, nil, box_style) } // Only draw corners if necessary if y1 != y2 && x1 != x2 { - s.SetContent(x1, y1, tcell.RuneULCorner, nil, style) - s.SetContent(x2, y1, tcell.RuneURCorner, nil, style) - s.SetContent(x1, y2, tcell.RuneLLCorner, nil, style) - s.SetContent(x2, y2, tcell.RuneLRCorner, nil, style) + s.SetContent(x1, y1, tcell.RuneULCorner, nil, box_style) + s.SetContent(x2, y1, tcell.RuneURCorner, nil, box_style) + s.SetContent(x1, y2, tcell.RuneLLCorner, nil, box_style) + s.SetContent(x2, y2, tcell.RuneLRCorner, nil, box_style) } if fill == true { for y := y1 + 1; y < y2; y++ { for x := x1 + 1; x < x2; x++ { - s.SetContent(x, y, ' ', nil, style) + s.SetContent(x, y, ' ', nil, box_style) } } } - i_draw_text(s, x1 + 1, y1, x2 - 1, y1, style, title) + i_draw_text(s, x1 + 1, y1, x2 - 1, y1, head_style, title) } -func i_draw_msg(s tcell.Screen, lines int, dim [2]int, title string) { - style := tcell.StyleDefault. - Background(tcell.ColorReset). - Foreground(tcell.ColorReset) +func i_draw_msg(s tcell.Screen, lines int, box_style tcell.Style, + dim [2]int, title string) { lines += 1 if lines < 0 { @@ -149,27 +143,28 @@ func i_draw_msg(s tcell.Screen, lines int, dim [2]int, title string) { lines = dim[H] - 2 } for row := dim[H] - 2 - lines; row < dim[H] - 2; row++ { - s.SetContent(0, row, tcell.RuneVLine, nil, style) - s.SetContent(dim[W] - 1, row, tcell.RuneVLine, nil, style) + s.SetContent(0, row, tcell.RuneVLine, nil, box_style) + s.SetContent(dim[W] - 1, row, tcell.RuneVLine, nil, box_style) } for col := 1; col < dim[W] - 1; col++ { - s.SetContent(col, dim[H] - 2 - lines, tcell.RuneHLine, nil, style) - s.SetContent(col, dim[H] - 2, tcell.RuneHLine, nil, style) + s.SetContent(col, dim[H] - 2 - lines, tcell.RuneHLine, nil, box_style) + s.SetContent(col, dim[H] - 2, tcell.RuneHLine, nil, box_style) } - s.SetContent(0, dim[H] - 2 - lines, tcell.RuneULCorner, nil, style) - s.SetContent(dim[W] - 1, dim[H] - 2 - lines, tcell.RuneURCorner, nil, style) - s.SetContent(0, dim[H] - 2, tcell.RuneLLCorner, nil, style) - s.SetContent(dim[W] - 1, dim[H] - 2, tcell.RuneLRCorner, nil, style) - // s.SetContent(dim[W] / 3, dim[H] - 2 - lines, tcell.RuneBTee, nil, style) - // s.SetContent(0, dim[H] - 2 - lines, tcell.RuneLTee, nil, style) - // s.SetContent(dim[W] - 1, dim[H] - 2 - lines, tcell.RuneRTee, nil, style) + s.SetContent(0, dim[H] - 2 - lines, tcell.RuneULCorner, nil, box_style) + s.SetContent(dim[W] - 1, dim[H] - 2 - lines, tcell.RuneURCorner, nil, + box_style) + s.SetContent(0, dim[H] - 2, tcell.RuneLLCorner, nil, box_style) + s.SetContent(dim[W] - 1, dim[H] - 2, tcell.RuneLRCorner, nil, box_style) + // s.SetContent(dim[W] / 3, dim[H] - 2 - lines, tcell.RuneBTee, nil, ) + // s.SetContent(0, dim[H] - 2 - lines, tcell.RuneLTee, nil, ) + // s.SetContent(dim[W] - 1, dim[H] - 2 - lines, tcell.RuneRTee, nil, ) for y := dim[H] - 2 - lines + 1; y < dim[H] - 2; y++ { for x := 1; x < dim[W] - 1; x++ { - s.SetContent(x, y, ' ', nil, style) + s.SetContent(x, y, ' ', nil, box_style) } } i_draw_text(s, 1, dim[H] - 2 - lines, len(title) + 2, dim[H] - 2 - lines, - style, title) + box_style, title) } func i_draw_bottom_text(ui HardUI) { @@ -187,18 +182,18 @@ func i_draw_bottom_text(ui HardUI) { } i_draw_text(ui.s, 0, ui.dim[H] - 1, ui.dim[W], ui.dim[H] - 1, - ui.def_style.Dim(true), text) + ui.style[DEF_STYLE].Dim(true), text) i_draw_text(ui.s, ui.dim[W] - 5, ui.dim[H] - 1, ui.dim[W], ui.dim[H] - 1, - ui.def_style.Dim(true), " " + VERSION) + ui.style[DEF_STYLE].Dim(true), " " + VERSION) } func i_draw_zhosts_box(ui HardUI) { - i_draw_msg(ui.s, 1, ui.dim, " No hosts ") + i_draw_msg(ui.s, 1, ui.style[BOX_STYLE], ui.dim, " No hosts ") text := "Hosts list empty. Add hosts/folders by pressing (a/m)" left, right := i_left_right(len(text), &ui) i_draw_text(ui.s, left, ui.dim[H] - 2 - 1, right, ui.dim[H] - 2 - 1, - ui.def_style, text) + ui.style[DEF_STYLE], text) } func i_draw_delete_msg(ui HardUI, item *ItemsNode) { @@ -214,15 +209,15 @@ func i_draw_delete_msg(ui HardUI, item *ItemsNode) { file = host.Parent.path() + host.Filename } file = file[1:] - i_draw_msg(ui.s, 2, ui.dim, " Delete ") + i_draw_msg(ui.s, 2, ui.style[BOX_STYLE], ui.dim, " Delete ") left, right := i_left_right(len(text), &ui) line := ui.dim[H] - 2 - 2 - i_draw_text(ui.s, left, line, right, line, ui.def_style, text) + i_draw_text(ui.s, left, line, right, line, ui.style[DEF_STYLE], text) left, right = i_left_right(len(file), &ui) line += 1 i_draw_text(ui.s, left, line, right, line, - ui.def_style.Bold(true), file) + ui.style[DEF_STYLE].Bold(true), file) } func i_draw_error_msg(ui HardUI) { @@ -230,18 +225,19 @@ func i_draw_error_msg(ui HardUI) { if len(ui.err[ERROR_ERR]) == 0 { lines = 1 } - i_draw_msg(ui.s, lines, ui.dim, " Delete ") + i_draw_msg(ui.s, lines, ui.style[BOX_STYLE], ui.dim, " Delete ") left, right := i_left_right(len(ui.err[ERROR_MSG]), &ui) line := ui.dim[H] - 2 - 2 if len(ui.err[ERROR_ERR]) == 0 { line += 1 } - i_draw_text(ui.s, left, line, right, line, ui.def_style, ui.err[ERROR_MSG]) + i_draw_text(ui.s, left, line, right, line, + ui.style[ERR_STYLE], ui.err[ERROR_MSG]) if len(ui.err[ERROR_ERR]) > 0 { left, right = i_left_right(len(ui.err[ERROR_ERR]), &ui) line += 1 i_draw_text(ui.s, left, line, right, line, - ui.def_style, ui.err[ERROR_ERR]) + ui.style[ERR_STYLE], ui.err[ERROR_ERR]) } } @@ -258,12 +254,12 @@ func i_draw_scrollhint(ui HardUI, litems *ItemsList) { if draw_id > 1 { ui.s.SetContent(0, 1, '▲', - nil, ui.def_style) + nil, ui.style[DEF_STYLE]) } if last - draw_id > h { ui.s.SetContent(0, ui.dim[H] - 3, '▼', - nil, ui.def_style) + nil, ui.style[DEF_STYLE]) return } } @@ -279,14 +275,14 @@ func i_draw_load_ui(ui *HardUI) { ui.s.Clear() i_draw_host_panel(*ui, false, nil, nil) i_draw_info_panel(*ui, false, nil) - i_draw_msg(ui.s, 1, ui.dim, " Loading ") + i_draw_msg(ui.s, 1, ui.style[BOX_STYLE], ui.dim, " Loading ") text := "Loading " + strconv.Itoa(g_load_count) + " hosts" left, right := i_left_right(len(text), ui) i_draw_text(ui.s, - left, ui.dim[H] - 2 - 1, right, ui.dim[H] - 2 - 1, ui.def_style, text) + left, ui.dim[H] - 2 - 1, right, ui.dim[H] - 2 - 1, ui.style[DEF_STYLE], text) i_draw_text(ui.s, ui.dim[W] - 5, ui.dim[H] - 1, ui.dim[W], ui.dim[H] - 1, - ui.def_style.Dim(true), " " + VERSION) + ui.style[DEF_STYLE].Dim(true), " " + VERSION) ui.s.Show() event := ui.s.PollEvent() ui.s.PostEvent(event) @@ -324,16 +320,28 @@ func i_ui(data_dir string, opts HardOpts) { if err := ui.s.Init(); err != nil { c_die("view", err) } - ui.def_style = tcell.StyleDefault. + ui.style[DEF_STYLE] = tcell.StyleDefault. Background(tcell.ColorReset). Foreground(tcell.ColorReset) - ui.dir_style = tcell.StyleDefault. + ui.style[DIR_STYLE] = tcell.StyleDefault. + Background(tcell.ColorReset). + Foreground(tcell.ColorBlue).Dim(true).Bold(true) + ui.style[BOX_STYLE] = tcell.StyleDefault. + Background(tcell.ColorReset). + Foreground(tcell.ColorReset) + ui.style[HEAD_STYLE] = tcell.StyleDefault. + Background(tcell.ColorReset). + Foreground(tcell.ColorReset) + ui.style[ERR_STYLE] = tcell.StyleDefault. + Background(tcell.ColorReset). + Foreground(tcell.ColorRed).Dim(true) + ui.style[TITLE_STYLE] = tcell.StyleDefault. Background(tcell.ColorReset). Foreground(tcell.ColorBlue).Dim(true).Bold(true) - ui.title_style = tcell.StyleDefault. + ui.style[SEL_STYLE] = tcell.StyleDefault. Background(tcell.ColorReset). Foreground(tcell.ColorBlue).Dim(true).Bold(true) - ui.s.SetStyle(ui.def_style) + ui.s.SetStyle(ui.style[DEF_STYLE]) ui.dim[W], ui.dim[H], _ = term.GetSize(0) ldirs, litems := i_load_ui(data_dir, opts, &ui) data := HardData{ |