aboutsummaryrefslogtreecommitdiffstats
path: root/i_ui.go
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-01-19 20:20:20 +0100
committerJoe <rbo@gmx.us>2024-01-19 20:20:20 +0100
commitea264b98265452a3979ed8727dd14ce23b3ae51b (patch)
tree8c2fd5aba9cad799e1ea9ec5560329d456caa9bb /i_ui.go
parentfix this some day (diff)
downloadhardflip-ea264b98265452a3979ed8727dd14ce23b3ae51b.tar.gz
hardflip-ea264b98265452a3979ed8727dd14ce23b3ae51b.tar.bz2
hardflip-ea264b98265452a3979ed8727dd14ce23b3ae51b.tar.xz
hardflip-ea264b98265452a3979ed8727dd14ce23b3ae51b.tar.zst
hardflip-ea264b98265452a3979ed8727dd14ce23b3ae51b.zip
refac
Diffstat (limited to '')
-rw-r--r--i_ui.go384
1 files changed, 0 insertions, 384 deletions
diff --git a/i_ui.go b/i_ui.go
index e3f4637..f6681cb 100644
--- a/i_ui.go
+++ b/i_ui.go
@@ -228,390 +228,6 @@ func i_draw_delete_box(ui HardUI, item *ItemsNode) {
ui.def_style, "o]")
}
-func i_host_panel_dirs(ui HardUI, icons bool, dir_icon uint8,
- dir *DirsNode, curr *DirsNode, line int) {
- style := ui.dir_style
- if dir == curr {
- style = style.Reverse(true)
- }
- text := ""
- for i := 0; i < int(dir.Depth) - 2; i++ {
- text += " "
- }
- if icons == true {
- text += DIRS_ICONS[dir_icon]
- }
- text += dir.Name
- spaces := ""
- for i := 0; i < (ui.dim[W] / 3) - len(text) + 1; i++ {
- spaces += " "
- }
- text += spaces
- i_draw_text(ui.s,
- 1, line, ui.dim[W] / 3, line,
- style, text)
-}
-
-func i_host_panel_host(ui HardUI, icons bool,
- depth uint16, host *HostNode, curr *HostNode, line int) {
- style := ui.def_style
- if host == curr {
- style = style.Reverse(true)
- }
- text := ""
- for i := 0; i < int(depth + 1) - 2; i++ {
- text += " "
- }
- if icons == true {
- text += HOST_ICONS[int(host.Protocol)]
- }
- text += host.Name
- spaces := ""
- for i := 0; i < (ui.dim[W] / 3) - len(text) + 1; i++ {
- spaces += " "
- }
- text += spaces
- i_draw_text(ui.s,
- 1, line, ui.dim[W] / 3, line,
- style, text)
-}
-
-func i_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)
- line := 1
- if litems.head == nil {
- return
- }
- for ptr := litems.draw; ptr != nil && line < ui.dim[H] - 2; ptr = ptr.next {
- if ptr.is_dir() == false && ptr.Host != nil {
- i_host_panel_host(ui,
- icons,
- ptr.Host.Parent.Depth,
- ptr.Host,
- litems.curr.Host,
- line)
- line++
- } else if ptr.Dirs != nil {
- var dir_icon uint8
- if data.folds[ptr.Dirs] != nil {
- dir_icon = 1
- }
- i_host_panel_dirs(ui, icons, dir_icon,
- ptr.Dirs,
- litems.curr.Dirs,
- line)
- line++
- }
- }
-}
-
-func i_info_panel_dirs(ui HardUI, dir *DirsNode) {
- line := 2
- if 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, "Name: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line,
- ui.def_style, dir.Name)
- 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, "Type: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line,
- ui.def_style, "Directory")
- if line += 2; 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, "Path: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line,
- ui.def_style, dir.path())
-}
-
-func i_info_panel_host(ui HardUI, host *HostNode) {
- host_type := host.protocol_str()
- line := 2
- if line > ui.dim[H] - 3 {
- return
- }
- // name, type
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line,
- ui.title_style, "Name: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line,
- ui.def_style, host.Name)
- 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, "Type: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line,
- ui.def_style, host_type)
- if line += 2; line > ui.dim[H] - 3 {
- return
- }
- if line > ui.dim[H] - 3 {
- return
- }
- // host, port
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line,
- ui.title_style, "Host: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line,
- ui.def_style, host.Host)
- 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: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line,
- ui.def_style, strconv.Itoa(int(host.Port)))
- if line += 1; line > ui.dim[H] - 3 {
- return
- }
- // RDP shit
- if host.Protocol == 1 {
- if len(host.Domain) > 0 {
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line,
- ui.title_style, "Domain: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 12, line, ui.dim[W] - 2, line,
- ui.def_style, host.Domain)
- if line += 1; line > ui.dim[H] - 3 {
- return
- }
- }
- }
- if line += 1; line > ui.dim[H] - 3 {
- return
- }
- // user infos
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line,
- ui.title_style, "User: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line,
- ui.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) + 4, line, ui.dim[W] - 2, line,
- ui.title_style, "Pass: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line,
- ui.def_style, "***")
- if line += 1; line > ui.dim[H] - 3 {
- return
- }
- }
- if host.Protocol == 0 && len(host.Priv) > 0 {
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line,
- ui.title_style, "Privkey: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 13, line, ui.dim[W] - 2, line,
- ui.def_style, host.Priv)
- if line += 1; line > ui.dim[H] - 3 {
- return
- }
- }
- if line += 1; line > ui.dim[H] - 3 {
- return
- }
- // jump
- if host.Protocol == 0 && len(host.Jump) > 0 {
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line,
- ui.title_style, "Jump settings: ")
- if line += 1; line > ui.dim[H] - 3 {
- return
- }
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 5, line, ui.dim[W] - 2, line,
- ui.title_style, "Host: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 11, line, ui.dim[W] - 2, line,
- ui.def_style, host.Jump)
- if line += 1; line > ui.dim[H] - 3 {
- return
- }
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 5, line, ui.dim[W] - 2, line,
- ui.title_style, "Port: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 11, line, ui.dim[W] - 2, line,
- ui.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) + 5, line, ui.dim[W] - 2, line,
- ui.title_style, "User: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 11, line, ui.dim[W] - 2, line,
- ui.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) + 5, line, ui.dim[W] - 2, line,
- ui.title_style, "Pass: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 11, line, ui.dim[W] - 2, line,
- ui.def_style, "***")
- if line += 1; line > ui.dim[H] - 3 {
- return
- }
- }
- if host.Protocol == 0 && len(host.JumpPriv) > 0 {
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 5, line, ui.dim[W] - 2, line,
- ui.title_style, "Privkey: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 14, line, ui.dim[W] - 2, line,
- ui.def_style, host.JumpPriv)
- if line += 1; line > ui.dim[H] - 3 {
- return
- }
- }
- if line += 1; line > ui.dim[H] - 3 {
- return
- }
- }
- // RDP shit
- if host.Protocol == 1 {
- qual := [3]string{"Low", "Medium", "High"}
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line,
- ui.title_style, "Screen size: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 17, line, ui.dim[W] - 2, line,
- ui.def_style,
- strconv.Itoa(int(host.Width)) + "x" +
- strconv.Itoa(int(host.Height)))
- 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, "Dynamic window: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 20, line, ui.dim[W] - 2, line,
- ui.def_style, strconv.FormatBool(host.Dynamic))
- 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, "Quality: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 13, line, ui.dim[W] - 2, line,
- ui.def_style, qual[host.Quality])
- line += 1
- if line += 1; line > ui.dim[H] - 3 {
- return
- }
- }
- // note
- if len(host.Note) > 0 {
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line,
- ui.title_style, "Note: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line,
- ui.def_style, host.Note)
- if line += 1; line > ui.dim[H] - 3 {
- return
- }
- }
-}
-
-func i_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.s.SetContent(ui.dim[W] / 3, ui.dim[H] - 2,
- tcell.RuneBTee, nil, ui.def_style)
- // number display
- if litems.head != nil {
- text := " " + strconv.Itoa(litems.curr.ID) + " of " +
- strconv.Itoa(int(litems.last.ID)) + " "
- if percent == true {
- text += "- " +
- strconv.Itoa(litems.curr.ID * 100 / litems.last.ID) + "% "
- }
- i_draw_text(ui.s,
- (ui.dim[W] - 1) - len(text) - 1,
- ui.dim[H] - 2,
- (ui.dim[W] - 1) - 1,
- ui.dim[H] - 2,
- ui.def_style,
- text)
- } else {
- text := " 0 hosts "
- i_draw_text(ui.s,
- (ui.dim[W] - 1) - len(text) - 1,
- ui.dim[H] - 2,
- (ui.dim[W] - 1) - 1,
- ui.dim[H] - 2,
- ui.def_style,
- text)
- }
- // panel
- if litems.head == nil {
- return
- } else if litems.curr.is_dir() == true {
- i_info_panel_dirs(ui, litems.curr.Dirs)
- } else {
- i_info_panel_host(ui, litems.curr.Host)
- }
-}
-
-func i_scrollhint(ui HardUI, litems *ItemsList) {
- if litems.head == nil {
- return
- }
- h := ui.dim[H] - 4
- max := litems.last.ID
- if max <= h {
- return
- }
- draw_id := litems.draw.ID
- if draw_id > 1 {
- ui.s.SetContent(0, 1,
- '▲',
- nil, ui.def_style)
- }
- if max - draw_id > h {
- ui.s.SetContent(0, ui.dim[H] - 3,
- '▼',
- nil, ui.def_style)
- return
- }
-}
-
// HACK: fuck global vars but do we have the choice really
var g_load_count int = -1