diff options
-rw-r--r-- | c_ldirs.go | 11 | ||||
-rw-r--r-- | c_lhosts.go | 47 | ||||
-rw-r--r-- | i_events.go | 13 | ||||
-rw-r--r-- | i_ui.go | 11 |
4 files changed, 55 insertions, 27 deletions
@@ -43,7 +43,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * hardflip: src/c_ldirs.go - * Mon Jan 08 17:44:15 2024 + * Tue Jan 09 12:06:44 2024 * Joe * * the directories linked list @@ -116,3 +116,12 @@ func (dir *DirsNode) count_hosts() int { } return dir.lhost.last.ID + 1 } + +func (dir *DirsNode) folded_parents() bool { + for ptr := dir.Parent; ptr.Parent != nil; ptr = ptr.Parent { + if ptr.Folded == true { + return true + } + } + return false +} diff --git a/c_lhosts.go b/c_lhosts.go index 4041279..80fbdbc 100644 --- a/c_lhosts.go +++ b/c_lhosts.go @@ -43,7 +43,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * hardflip: src/c_lhosts.go - * Tue Jan 09 11:16:59 2024 + * Tue Jan 09 12:07:53 2024 * Joe * * the hosts linked list @@ -54,28 +54,28 @@ package main // 0: ssh // 1: rdp type HostNode struct { - ID int - Protocol int8 `yaml:"type"` - Name string `yaml:"name"` - Host string `yaml:"host"` - Port uint16 `yaml:"port"` - User string `yaml:"user"` - Pass string `yaml:"pass"` - Priv string `yaml:"priv"` - Jump string `yaml:"jump"` + ID int + Protocol int8 `yaml:"type"` + Name string `yaml:"name"` + Host string `yaml:"host"` + Port uint16 `yaml:"port"` + User string `yaml:"user"` + Pass string `yaml:"pass"` + Priv string `yaml:"priv"` + Jump string `yaml:"jump"` JumpPort uint16 `yaml:"jump_port"` JumpUser string `yaml:"jump_user"` JumpPass string `yaml:"jump_pass"` JumpPriv string `yaml:"jump_priv"` - Quality uint8 `yaml:"quality"` - Domain string `yaml:"domain"` - Width uint16 `yaml:"width"` - Height uint16 `yaml:"height"` - Dynamic bool `yaml:"dynamic"` - Note string `yaml:"note"` - Filename string - Parent *DirsNode - next *HostNode + Quality uint8 `yaml:"quality"` + Domain string `yaml:"domain"` + Width uint16 `yaml:"width"` + Height uint16 `yaml:"height"` + Dynamic bool `yaml:"dynamic"` + Note string `yaml:"note"` + Filename string + Parent *DirsNode + next *HostNode } type HostList struct { @@ -166,3 +166,12 @@ func (host *HostNode) protocol_str() string { default: return "" } } + +func (host *HostNode) folded_parents() bool { + for ptr := host.Parent; ptr.Parent != nil; ptr = ptr.Parent { + if ptr.Folded == true { + return true + } + } + return false +} diff --git a/i_events.go b/i_events.go index 4ea2a1a..9989d2a 100644 --- a/i_events.go +++ b/i_events.go @@ -43,7 +43,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * hardflip: src/i_events.go - * Mon Jan 08 16:40:17 2024 + * Tue Jan 09 12:00:50 2024 * Joe * * events in the code @@ -146,8 +146,9 @@ func i_events(data *HardData) { ui.sel_max != 0 { ui.mode = DELETE_MODE } else if event.Key() == tcell.KeyEnter { - if data.litems.curr != nil && - data.litems.curr.is_dir() == false { + if data.litems.curr == nil { + return + } else if data.litems.curr.is_dir() == false { ui.s.Fini() c_exec(data.litems.curr.Host) if data.opts.Loop == false { @@ -161,6 +162,12 @@ func i_events(data *HardData) { } ui.s.SetStyle(ui.def_style) } + } else { + if data.litems.curr.Dirs.Folded == false { + data.litems.curr.Dirs.Folded = true + } else { + data.litems.curr.Dirs.Folded = false + } } } if event.Key() == tcell.KeyCtrlR { @@ -43,7 +43,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * hardflip: src/i_ui.go - * Tue Jan 09 11:49:48 2024 + * Tue Jan 09 12:00:46 2024 * Joe * * interfacing with the user @@ -283,20 +283,23 @@ func i_host_panel(ui HardUI, icons bool, litems *ItemsList) { line := 1 ptr := litems.draw_start for ptr = ptr; ptr != nil && line < ui.dim[H] - 2; ptr = ptr.next { - if ptr.is_dir() == false { + if ptr.is_dir() == false && + ptr.Host.folded_parents() == false && + ptr.Host != nil { i_host_panel_host(ui, icons, ptr.Host.Parent.Depth, ptr.Host, litems.curr.Host, line) - } else { + line++ + } else if ptr.Dirs != nil && ptr.Dirs.folded_parents() == false { i_host_panel_dirs(ui, icons, ptr.Dirs, litems.curr.Dirs, line) + line++ } - line++ } if ui.sel_max != 0 { i_draw_text(ui.s, |