aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2023-12-20 20:20:20 +0100
committerJoe <rbo@gmx.us>2023-12-20 20:20:20 +0100
commitff175485ded07205da5b52919e8be04f89643a28 (patch)
treead7c4904e90165981c2e4470f3bb7ad915fecf70
parentdelete (diff)
downloadhardflip-ff175485ded07205da5b52919e8be04f89643a28.tar.gz
hardflip-ff175485ded07205da5b52919e8be04f89643a28.tar.bz2
hardflip-ff175485ded07205da5b52919e8be04f89643a28.tar.xz
hardflip-ff175485ded07205da5b52919e8be04f89643a28.tar.zst
hardflip-ff175485ded07205da5b52919e8be04f89643a28.zip
paging in progress
-rw-r--r--c_defs.go5
-rw-r--r--c_hardflip.go8
-rw-r--r--c_utils.go2
-rw-r--r--i_ui.go38
4 files changed, 33 insertions, 20 deletions
diff --git a/c_defs.go b/c_defs.go
index 1ad421a..9b6d1f5 100644
--- a/c_defs.go
+++ b/c_defs.go
@@ -39,7 +39,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/c_defs.go
- * Tue Dec 19 16:36:48 2023
+ * Wed Dec 20 12:21:38 2023
* Joe
*
* constants
@@ -54,8 +54,9 @@ const (
(q)uit -
[x](a)dd/(i)nsert host -
[x](e)dit -
-[x](D)elete -
+(D)elete -
[x](s)earch -
(c-r) reload -
[x](?) help`
+ DATA_DIR_NAME = "hardflip"
)
diff --git a/c_hardflip.go b/c_hardflip.go
index 5ad9e8e..ca231f7 100644
--- a/c_hardflip.go
+++ b/c_hardflip.go
@@ -47,7 +47,11 @@
package main
-import "github.com/gdamore/tcell/v2"
+import (
+ // "os"
+
+ "github.com/gdamore/tcell/v2"
+)
type Data struct {
lhost *HostList
@@ -55,6 +59,7 @@ type Data struct {
opts Opts
s tcell.Screen
data_dir string
+ list_start int
}
func main() {
@@ -64,6 +69,7 @@ func main() {
Opts{true, true},
nil,
data_dir,
+ 0,
}
i_ui(&data)
}
diff --git a/c_utils.go b/c_utils.go
index a2b420c..32969aa 100644
--- a/c_utils.go
+++ b/c_utils.go
@@ -70,7 +70,7 @@ func c_get_data_dir() string {
ptr = &home
*ptr += "/.local/share"
}
- *ptr += "/hardflip"
+ *ptr += "/" + DATA_DIR_NAME
if _, err := os.Stat(*ptr); os.IsNotExist(err) {
if err := os.MkdirAll(*ptr, os.ModePerm); err != nil {
c_die("could not create path " + *ptr, err)
diff --git a/i_ui.go b/i_ui.go
index 90feeea..dced789 100644
--- a/i_ui.go
+++ b/i_ui.go
@@ -39,7 +39,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/i_ui.go
- * Wed Dec 20 11:05:07 2023
+ * Wed Dec 20 13:53:02 2023
* Joe
*
* interfacing with the user
@@ -132,14 +132,17 @@ func i_draw_zhosts_box(s tcell.Screen, t [2]int, def_style tcell.Style) {
def_style, text)
}
-func i_host_panel(s tcell.Screen, t [2]int,
- def_style tcell.Style, lhost *HostList,
+func i_host_panel(data *Data, t [2]int,
+ def_style tcell.Style,
sel uint64, sel_max uint64) {
- i_draw_box(s, 0, 0,
+ i_draw_box(data.s, 0, 0,
t[W] / 3, t[H] - 2,
" Hosts ")
- host := lhost.head
- for host != nil {
+ host := data.lhost.head
+ for i := 0; i < data.list_start && host.next != nil; i++ {
+ host = host.next
+ }
+ for line := 1; line < t[H] - 2 && host != nil; line++ {
style := def_style
if sel == host.ID {
style = tcell.StyleDefault.
@@ -147,26 +150,25 @@ func i_host_panel(s tcell.Screen, t [2]int,
Foreground(tcell.ColorBlack)
}
spaces := ""
-
for i := 0; i < (t[W] / 3) - len(host.Folder + host.Name) - 2; i++ {
spaces += " "
}
if host.Type == 0 {
- i_draw_text(s,
- 1, int(host.ID) + 1, t[W] / 3, int(host.ID) + 1,
+ i_draw_text(data.s,
+ 1, line, t[W] / 3, line,
style, "  " + host.Folder + host.Name + spaces)
} else if host.Type == 1 {
- i_draw_text(s,
- 1, int(host.ID) + 1, t[W] / 3, int(host.ID) + 1,
+ i_draw_text(data.s,
+ 1, line, t[W] / 3, line,
style, "  " + host.Folder + host.Name + spaces)
}
- i_draw_text(s,
- 4, int(host.ID) + 1, t[W] / 3, int(host.ID) + 1,
+ i_draw_text(data.s,
+ 4, line, t[W] / 3, line,
style, host.Folder + host.Name + spaces)
host = host.next
}
- i_draw_text(s,
- 1, t[H] - 2, (t[W] / 3) - 1, t[H] - 1,
+ i_draw_text(data.s,
+ 1, t[H] - 2, (t[W] / 3) - 1, t[H] - 2,
def_style,
" " + strconv.Itoa(int(sel + 1)) + "/" +
strconv.Itoa(int(sel_max)) + " hosts ")
@@ -374,12 +376,16 @@ func i_ui(data *Data) {
term_size[W], term_size[H], _ = term.GetSize(0)
data.s.Clear()
i_bottom_text(data.s, term_size)
- i_host_panel(data.s, term_size, def_style, data.lhost, sel, sel_max)
+ i_host_panel(data, term_size, def_style, sel, sel_max)
i_info_panel(data.s, term_size, def_style, data.lhost, sel)
if data.lhost.head == nil {
i_draw_zhosts_box(data.s, term_size, def_style)
}
data.s.Show()
i_events(data, &sel, &sel_max, &term_size)
+ data.list_start = int(sel) - term_size[H] - 4
+ if data.list_start < 0 {
+ data.list_start = 0
+ }
}
}