aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2023-12-21 20:20:20 +0100
committerJoe <rbo@gmx.us>2023-12-21 20:20:20 +0100
commitcd5c1143d377c6238ccea57862bd20d4f997ca77 (patch)
tree925b5db30d66e3f2f20999d139302a359f38ada2
parentcool delete (diff)
downloadhardflip-cd5c1143d377c6238ccea57862bd20d4f997ca77.tar.gz
hardflip-cd5c1143d377c6238ccea57862bd20d4f997ca77.tar.bz2
hardflip-cd5c1143d377c6238ccea57862bd20d4f997ca77.tar.xz
hardflip-cd5c1143d377c6238ccea57862bd20d4f997ca77.tar.zst
hardflip-cd5c1143d377c6238ccea57862bd20d4f997ca77.zip
fixed segv
-rw-r--r--c_lhosts.go3
-rw-r--r--i_events.go4
-rw-r--r--i_ui.go22
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()
diff --git a/i_ui.go b/i_ui.go
index 515fa4d..627e646 100644
--- a/i_ui.go
+++ b/i_ui.go
@@ -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 {