diff options
Diffstat (limited to '')
-rw-r--r-- | c_litems.go | 14 | ||||
-rw-r--r-- | i_events.go | 15 | ||||
-rw-r--r-- | i_ui.go | 13 |
3 files changed, 22 insertions, 20 deletions
diff --git a/c_litems.go b/c_litems.go index 68d7137..63338bd 100644 --- a/c_litems.go +++ b/c_litems.go @@ -109,18 +109,24 @@ func (item *ItemsNode) inc(jump int) *ItemsNode { if jump == 0 { return item } else if jump == 1 { - return item.next + if item.next != nil { + return item.next + } + return item } else if jump == -1 { - return item.prev + if item.prev != nil { + return item.prev + } + return item } new_item := item if jump > 0 { - for i := 0; new_item != nil && i < jump; i++ { + for i := 0; new_item.next != nil && i < jump; i++ { new_item = new_item.next } return new_item } - for i := 0; new_item != nil && i > jump; i-- { + for i := 0; new_item.prev != nil && i > jump; i-- { new_item = new_item.prev } return new_item diff --git a/i_events.go b/i_events.go index 9d86366..b710317 100644 --- a/i_events.go +++ b/i_events.go @@ -43,7 +43,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * hardflip: src/i_events.go - * Wed Dec 27 17:56:44 2023 + * Mon Jan 08 11:35:21 2024 * Joe * * events in the code @@ -60,9 +60,8 @@ import ( func i_reload_data(data *HardData) { data.ldirs = c_load_data_dir(data.data_dir, data.opts) data.litems = c_load_litems(data.ldirs) - data.ui.sel_max, - data.ui.count_dirs, - data.ui.count_hosts = i_get_sel_max(data.ldirs) + data.ui.sel_max, data.ui.count_dirs, data.ui.count_hosts = + i_get_sel_max(data.ldirs) } func i_delete_host(data *HardData) { @@ -98,14 +97,10 @@ func i_events(data *HardData) { os.Exit(0) } else if event.Rune() == 'j' || event.Key() == tcell.KeyDown { - if ui.sel_id < ui.sel_max - 1 { - ui.inc_sel(1, data) - } + ui.inc_sel(1, data) } else if event.Rune() == 'k' || event.Key() == tcell.KeyUp { - if ui.sel_id > 0 { - ui.inc_sel(-1, data) - } + ui.inc_sel(-1, data) } else if event.Rune() == 'g' { // TODO: litems.curr ui.sel_id = 0 @@ -43,7 +43,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * hardflip: src/i_ui.go - * Fri Jan 05 16:59:59 2024 + * Mon Jan 08 11:37:32 2024 * Joe * * interfacing with the user @@ -79,7 +79,7 @@ func (ui *HardUI) inc_sel(n int, data *HardData) { return } if ui.sel_id + n < 1 || - ui.sel_id + n >= ui.sel_max { + ui.sel_id + n > ui.sel_max { n = 0 } data.litems.curr = data.litems.curr.inc(n) @@ -334,17 +334,17 @@ func i_host_panel(ui HardUI, icons bool, litems *ItemsList) { // line++ // } // } - if ui.sel_max == 0 { + 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 ") + " " + strconv.Itoa(litems.curr.ID) + "/" + + strconv.Itoa(int(ui.sel_max)) + " items ") } 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_id + 1)) + "/" + - strconv.Itoa(int(ui.sel_max)) + " hosts ") + " 0 hosts ") } } @@ -524,6 +524,7 @@ func i_info_panel(ui HardUI, lhost *HostList) { func i_get_sel_max(ldirs *DirsList) (int, int, int) { count_dirs, count_hosts := ldirs.count() + count_dirs -= 1 return count_dirs + count_hosts, count_dirs, count_hosts } |