aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ROADMAP.md14
-rw-r--r--c_defs.go3
-rw-r--r--c_init.go3
-rw-r--r--c_litems.go22
-rw-r--r--i_events.go36
-rw-r--r--i_ui.go36
6 files changed, 49 insertions, 65 deletions
diff --git a/ROADMAP.md b/ROADMAP.md
index 1795c12..622f839 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -30,28 +30,24 @@
- [ ] theming
-## v1.0
+## v1.0 - wheelbite
- [ ] README.md
- [ ] man
- [ ] cli options
-## v1.1
+## v1.1 - 360 hard
- [ ] fuzz
-## v1.2
+## v1.2 - late flip
- [ ] vnc
-## v1.3
-
-- [ ] vnc
-
-## v1.4
+## v1.3 - ghetto bird
- [ ] sorting options
-## v1.5
+## v1.4
- [ ] ...
diff --git a/c_defs.go b/c_defs.go
index 9e70fb0..9e317e4 100644
--- a/c_defs.go
+++ b/c_defs.go
@@ -59,8 +59,7 @@ const (
)
const (
- NORMAL_KEYS_HINTS = `
-[x](a)dd/(i)nsert host -
+ NORMAL_KEYS_HINTS = `[x](a)dd/(i)nsert host -
[x](m)kdir -
[x](s)earch -
[x](?) help`
diff --git a/c_init.go b/c_init.go
index db6001f..9dbb45b 100644
--- a/c_init.go
+++ b/c_init.go
@@ -43,7 +43,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/c_init.go
- * Mon Jan 08 11:53:48 2024
+ * Mon Jan 08 13:39:08 2024
* Joe
*
* init functions
@@ -128,5 +128,6 @@ func c_load_litems(ldirs *DirsList) *ItemsList {
litems.head.prev = nil
}
litems.curr = litems.head
+ litems.draw_start = litems.head
return &litems
}
diff --git a/c_litems.go b/c_litems.go
index 24a7844..0a1acf0 100644
--- a/c_litems.go
+++ b/c_litems.go
@@ -43,7 +43,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/c_litems.go
- * Mon Jan 08 11:53:22 2024
+ * Mon Jan 08 13:36:49 2024
* Joe
*
* the dir and hosts linked list
@@ -63,6 +63,7 @@ type ItemsList struct {
head *ItemsNode
last *ItemsNode
curr *ItemsNode
+ draw_start *ItemsNode
}
// adds an item node to the list
@@ -102,32 +103,33 @@ func (item *ItemsNode) is_dir() bool {
return true
}
-func (item *ItemsNode) inc(jump int) *ItemsNode {
+func (litems *ItemsList) inc(jump int) {
+ item := litems.curr
if item == nil {
- return nil
+ return
}
if jump == 0 {
- return item
+ litems.curr = item
} else if jump == 1 {
if item.next != nil {
- return item.next
+ litems.curr = item.next
}
- return item
+ litems.curr = item
} else if jump == -1 {
if item.prev != nil {
- return item.prev
+ litems.curr = item.prev
}
- return item
+ litems.curr = item
}
new_item := item
if jump > 0 {
for i := 0; new_item.next != nil && i < jump; i++ {
new_item = new_item.next
}
- return new_item
+ litems.curr = new_item
}
for i := 0; new_item.prev != nil && i > jump; i-- {
new_item = new_item.prev
}
- return new_item
+ litems.curr = new_item
}
diff --git a/i_events.go b/i_events.go
index 8f1601b..a5eb6a8 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 11:35:21 2024
+ * Mon Jan 08 13:56:06 2024
* Joe
*
* events in the code
@@ -55,8 +55,23 @@ import (
"os"
"github.com/gdamore/tcell/v2"
+ "golang.org/x/term"
)
+func i_list_follow_cursor(litems *ItemsList, ui *HardUI) {
+ if litems.draw_start == nil {
+ return
+ }
+ for litems.draw_start.ID < litems.curr.ID - (ui.dim[H] - 4) &&
+ litems.draw_start.next != nil {
+ litems.draw_start = litems.draw_start.next
+ }
+ for litems.curr.ID < litems.draw_start.ID &&
+ litems.draw_start.prev != nil {
+ litems.draw_start = litems.draw_start.prev
+ }
+}
+
func i_reload_data(data *HardData) {
data.ldirs = c_load_data_dir(data.data_dir, data.opts)
data.litems = c_load_litems(data.ldirs)
@@ -87,6 +102,8 @@ func i_events(data *HardData) {
event := ui.s.PollEvent()
switch event := event.(type) {
case *tcell.EventResize:
+ ui.dim[W], ui.dim[H], _ = term.GetSize(0)
+ i_list_follow_cursor(data.litems, ui)
ui.s.Sync()
case *tcell.EventKey:
switch ui.mode {
@@ -97,16 +114,17 @@ func i_events(data *HardData) {
os.Exit(0)
} else if event.Rune() == 'j' ||
event.Key() == tcell.KeyDown {
- ui.inc_cursor(+1, data)
+ data.litems.inc(+1)
} else if event.Rune() == 'k' ||
- event.Key() == tcell.KeyUp {
- ui.inc_cursor(-1, data)
+ event.Key() == tcell.KeyUp {
+ data.litems.inc(-1)
} else if event.Key() == tcell.KeyCtrlD {
- ui.inc_cursor(+(ui.dim[H] / 4), data)
+ data.litems.inc(+(ui.dim[H] / 3))
} else if event.Key() == tcell.KeyCtrlU {
- ui.inc_cursor(-(ui.dim[H] / 4), data)
+ data.litems.inc(-(ui.dim[H] / 3))
} else if event.Rune() == 'g' {
data.litems.curr = data.litems.head
+ data.litems.draw_start = data.litems.head
} else if event.Rune() == 'G' {
data.litems.curr = data.litems.last
} else if event.Rune() == 'D' &&
@@ -114,7 +132,8 @@ 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 &&
+ data.litems.curr.is_dir() == false {
ui.s.Fini()
c_exec(data.litems.curr.Host)
if data.opts.Loop == false {
@@ -143,6 +162,7 @@ func i_events(data *HardData) {
i_delete_host(data)
ui.mode = NORMAL_MODE
}
- }
+ }
+ i_list_follow_cursor(data.litems, ui)
}
}
diff --git a/i_ui.go b/i_ui.go
index 5cc5e5f..f81e04c 100644
--- a/i_ui.go
+++ b/i_ui.go
@@ -55,12 +55,10 @@ import (
"strconv"
"github.com/gdamore/tcell/v2"
- "golang.org/x/term"
)
type HardUI struct {
s tcell.Screen
- list_start int
mode uint8
sel_max int
count_dirs int
@@ -71,18 +69,6 @@ type HardUI struct {
dim [2]int
}
-func (ui *HardUI) inc_cursor(n int, data *HardData) {
- if data.litems.curr == nil {
- return
- }
- data.litems.curr = data.litems.curr.inc(n)
- if data.litems.curr.ID > ui.list_start + ui.dim[H] - 4 {
- ui.list_start = (data.litems.curr.ID + 1) - (ui.dim[H] + 3)
- } else if data.litems.curr.ID < ui.list_start {
- ui.list_start = data.litems.curr.ID
- }
-}
-
func i_draw_text(s tcell.Screen,
x1, y1, x2, y2 int,
style tcell.Style, text string) {
@@ -290,7 +276,7 @@ func i_host_panel(ui HardUI, icons bool, litems *ItemsList) {
ui.dim[W] / 3, ui.dim[H] - 2,
" Hosts ", false)
line := 1
- ptr := litems.head
+ ptr := litems.draw_start
for ptr = ptr; ptr != nil && line < ui.dim[H] - 2; ptr = ptr.next {
if ptr.is_dir() == false {
i_host_panel_host(ui,
@@ -307,25 +293,6 @@ func i_host_panel(ui HardUI, icons bool, litems *ItemsList) {
}
line++
}
-
- // dirs := litems.head.Dirs
- // for host := dirs.lhost.head;
- // dirs.Folded == false && host != nil;
- // host = host.next {
- // i_host_panel_host(ui, icons, dirs.Depth, host, line)
- // line++
- // }
- // dirs = dirs.next
- // for line = line; line < ui.dim[H] - 2 && dirs != nil; dirs = dirs.next {
- // i_host_panel_dirs(ui, icons, dirs, line)
- // line++
- // for host := dirs.lhost.head;
- // dirs.Folded == false && host != nil;
- // host = host.next {
- // i_host_panel_host(ui, icons, dirs.Depth, host, line)
- // line++
- // }
- // }
if ui.sel_max != 0 {
i_draw_text(ui.s,
1, ui.dim[H] - 2, (ui.dim[W] / 3) - 1, ui.dim[H] - 2,
@@ -547,7 +514,6 @@ func i_ui(data *HardData) {
Foreground(tcell.ColorBlue).Dim(true).Bold(true)
ui.s.SetStyle(ui.def_style)
for {
- ui.dim[W], ui.dim[H], _ = term.GetSize(0)
ui.s.Clear()
i_bottom_text(*ui)
i_host_panel(data.ui, data.opts.Icon, data.litems)