diff options
-rw-r--r-- | c_lhosts.go | 3 | ||||
-rw-r--r-- | i_events.go | 4 | ||||
-rw-r--r-- | i_ui.go | 22 |
3 files changed, 22 insertions, 7 deletions
diff --git a/c_lhosts.go b/c_lhosts.go index 9425231..52e2b46 100644 --- a/c_lhosts.go +++ b/c_lhosts.go @@ -124,6 +124,9 @@ func (lhost *HostList) del(id uint64) { func (lhost *HostList) sel(id uint64) *HostNode { curr := lhost.head + if curr == nil { + return nil + } for curr.next != nil && curr.ID != id { curr = curr.next } diff --git a/i_events.go b/i_events.go index 5539e59..1d977e4 100644 --- a/i_events.go +++ b/i_events.go @@ -39,7 +39,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * hardflip: src/i_events.go - * Thu Dec 21 12:03:59 2023 + * Thu Dec 21 12:49:09 2023 * Joe * * the hosts linked list @@ -107,7 +107,7 @@ func i_events(data *HardData) { ui.sel = 0 } else if event.Rune() == 'G' { ui.sel = ui.sel_max - 1 - } else if event.Rune() == 'D' { + } else if event.Rune() == 'D' && data.lhost.head != nil { ui.mode = DELETE_MODE } else if event.Key() == tcell.KeyEnter { ui.s.Fini() @@ -237,11 +237,18 @@ func i_host_panel(ui HardUI, lhost *HostList) { style, host.Folder + host.Name + spaces) host = host.next } - i_draw_text(ui.s, - 1, ui.dim[H] - 2, (ui.dim[W] / 3) - 1, ui.dim[H] - 2, - ui.def_style, - " " + strconv.Itoa(int(ui.sel + 1)) + "/" + - strconv.Itoa(int(ui.sel_max)) + " hosts ") + if ui.sel_max == 0 { + i_draw_text(ui.s, + 1, ui.dim[H] - 2, (ui.dim[W] / 3) - 1, ui.dim[H] - 2, + ui.def_style, + " " + strconv.Itoa(int(ui.sel_max)) + " hosts ") + } else { + i_draw_text(ui.s, + 1, ui.dim[H] - 2, (ui.dim[W] / 3) - 1, ui.dim[H] - 2, + ui.def_style, + " " + strconv.Itoa(int(ui.sel + 1)) + "/" + + strconv.Itoa(int(ui.sel_max)) + " hosts ") + } } func i_info_panel(ui HardUI, lhost *HostList) { @@ -455,6 +462,11 @@ func i_ui(data *HardData) { } ui.s.Show() i_events(data) + if ui.sel > ui.sel_max { + ui.sel = ui.sel_max + } else if ui.sel < 0 { + ui.sel = 0 + } if int(ui.sel) > ui.list_start + ui.dim[H] - 4 { ui.list_start = int(ui.sel + 1) - ui.dim[H] + 3 } else if int(ui.sel) < ui.list_start { |