aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/c_debug.go (renamed from src/c_lfuzz.go)89
-rw-r--r--src/c_hardflip.go2
-rw-r--r--src/c_release.go60
-rw-r--r--src/e_keys.go54
-rw-r--r--src/i_host.go63
-rw-r--r--src/i_info.go2
-rw-r--r--src/i_ui.go29
7 files changed, 160 insertions, 139 deletions
diff --git a/src/c_lfuzz.go b/src/c_debug.go
index 419a5f4..286e1ef 100644
--- a/src/c_lfuzz.go
+++ b/src/c_debug.go
@@ -1,3 +1,5 @@
+// +build debug
+
/*
* ========================
* ===== ===============
@@ -42,86 +44,31 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * hardflip: src/c_lfuzz.go
- * Thu, 17 Oct 2024 13:22:18 +0200
+ * hardflip: src/c_debug.go
+ * Wed Mar 27 13:48:53 2024
* Joe
*
- * fuzz hard
+ * debug shit
*/
package main
-type FuzzNode struct {
- ptr *ItemsNode
- name string
- prev *FuzzNode
- next *FuzzNode
-}
+import (
+ "log"
+ "os"
+)
-type FuzzList struct {
- head *FuzzNode
- last *FuzzNode
- curr *FuzzNode
- draw *FuzzNode
-}
+var logger *log.Logger
-// adds a fuzz node to the list
-func (lfuzz *FuzzList) add_back(node *ItemsNode) {
- name := ""
- if node.is_dir() == false {
- name = node.Host.Name
- } else {
- name = node.Dirs.Name
+func init_logger() {
+ log_file, err := os.OpenFile("/tmp/hflog", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
+ if err != nil {
+ log.Fatal(err)
}
- fuzz_node := &FuzzNode{
- node,
- name,
- nil,
- nil,
- }
- if lfuzz.head == nil {
- lfuzz.head = fuzz_node
- lfuzz.last = lfuzz.head
- lfuzz.curr = lfuzz.head
- lfuzz.draw = lfuzz.head
- return
- }
- last := lfuzz.last
- fuzz_node.prev = last
- last.next = fuzz_node
- lfuzz.last = last.next
+ logger = log.New(log_file, "", log.LstdFlags)
+ logger.Println("program start")
}
-// removes n fuzz node from the list
-func (lfuzz *FuzzList) del(item *FuzzNode) {
- if lfuzz.head == nil {
- return
- }
- if lfuzz.head == item {
- lfuzz.head = lfuzz.head.next
- if lfuzz.head == nil {
- lfuzz.last, lfuzz.curr, lfuzz.draw = nil, nil, nil
- return
- }
- lfuzz.head.prev = nil
- lfuzz.curr, lfuzz.draw = lfuzz.head, lfuzz.head
- return
- }
- if lfuzz.last == item {
- lfuzz.last = lfuzz.last.prev
- lfuzz.last.next = nil
- lfuzz.curr = lfuzz.last
- if lfuzz.draw == item {
- lfuzz.draw = lfuzz.last
- }
- return
- }
- ptr := lfuzz.head
- for ptr.next != nil && ptr.next != item {
- ptr = ptr.next
- }
- if ptr.next == item {
- ptr.next = ptr.next.next
- ptr.next.prev = ptr
- }
+func write_log(msg any) {
+ logger.Println(msg)
}
diff --git a/src/c_hardflip.go b/src/c_hardflip.go
index 02aadee..d2e4c12 100644
--- a/src/c_hardflip.go
+++ b/src/c_hardflip.go
@@ -68,10 +68,10 @@ type HardData struct {
keys [][2]string
insert *HostNode
yank *ItemsNode
- lfuzz *FuzzList
}
func main() {
+ init_logger()
if len(os.Args) > 1 {
c_cli_opts(os.Args[1])
}
diff --git a/src/c_release.go b/src/c_release.go
new file mode 100644
index 0000000..a4646c4
--- /dev/null
+++ b/src/c_release.go
@@ -0,0 +1,60 @@
+// +build !debug
+
+/*
+ * ========================
+ * ===== ===============
+ * ====== ================
+ * ====== ================
+ * ====== ==== ==== ==
+ * ====== === == = =
+ * ====== === = == =
+ * = === === = == ====
+ * = === === = == = =
+ * == ===== ==== ==
+ * ========================
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 2023-2024, Joe
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the organization nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ''AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * hardflip: src/c_release.go
+ * Wed Mar 27 13:48:53 2024
+ * Joe
+ *
+ * debug shit
+ */
+
+package main
+
+func init_logger() {
+}
+
+func write_log(msg any) {
+}
diff --git a/src/e_keys.go b/src/e_keys.go
index 29c789f..ce378eb 100644
--- a/src/e_keys.go
+++ b/src/e_keys.go
@@ -62,6 +62,7 @@ import (
func e_normal_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
if event.Key() == tcell.KeyCtrlC ||
event.Rune() == 'q' {
+ write_log("exit")
ui.s.Fini()
os.Exit(0)
} else if event.Rune() == 'j' ||
@@ -261,7 +262,6 @@ func e_normal_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
} else if (event.Rune() == '/' ||
event.Key() == tcell.KeyCtrlF) &&
data.litems.curr != nil {
- e_create_fuzz_list(data)
ui.mode = FUZZ_MODE
} else if event.Rune() == '?' {
ui.mode = HELP_MODE
@@ -921,49 +921,33 @@ func e_fuzz_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
ui.s.HideCursor()
ui.mode = NORMAL_MODE
ui.buff.empty()
- data.lfuzz = nil
return true
} else if event.Key() == tcell.KeyEnter {
// TODO: select fuzzed item
ui.s.HideCursor()
ui.mode = NORMAL_MODE
ui.buff.empty()
- data.lfuzz = nil
} else {
e_readline(event, &ui.buff, ui, data.home_dir)
- e_update_lfuzz(ui.buff, data.lfuzz)
}
- // TODO: here
return false
}
-func e_create_fuzz_list(data *HardData) {
- if data.litems.head == nil {
- return
- }
- for ptr := data.litems.head; ptr != nil; ptr = ptr.next {
- data.lfuzz.add_back(ptr)
- }
-}
-
-func e_update_lfuzz(buff Buffer, lfuzz *FuzzList) {
- if lfuzz.head == nil {
- return
- }
- for ptr := lfuzz.head; ptr != nil; ptr = ptr.next {
- var name_runes []rune
- name_runes = []rune(ptr.name)
- var end_runes []rune
- for _, buff_ptr := range buff.data {
- for _, name_ptr := range name_runes {
- if buff_ptr == name_ptr {
- end_runes = append(end_runes, buff_ptr)
- continue
- }
- }
- }
- if len(end_runes) == 0 {
- lfuzz.del(ptr)
- }
- }
-}
+// func e_update_lfuzz(buff Buffer) {
+// for ptr := lfuzz.head; ptr != nil; ptr = ptr.next {
+// var name_runes []rune
+// name_runes = []rune(ptr.name)
+// var end_runes []rune
+// for _, buff_ptr := range buff.data {
+// for _, name_ptr := range name_runes {
+// if buff_ptr == name_ptr {
+// end_runes = append(end_runes, buff_ptr)
+// continue
+// }
+// }
+// }
+// if len(end_runes) == 0 {
+// lfuzz.del(ptr)
+// }
+// }
+// }
diff --git a/src/i_host.go b/src/i_host.go
index b048d4d..92ec32f 100644
--- a/src/i_host.go
+++ b/src/i_host.go
@@ -110,6 +110,8 @@ func i_host_panel_host(ui HardUI, icons bool,
func i_draw_host_panel(ui HardUI, icons bool,
litems *ItemsList, data *HardData) {
+ if ui.mode == FUZZ_MODE {
+ }
i_draw_box(ui.s, 0, 0,
ui.dim[W] / 3, ui.dim[H] - 2,
ui.style[BOX_STYLE], ui.style[HEAD_STYLE], " Hosts ", false)
@@ -117,12 +119,15 @@ func i_draw_host_panel(ui HardUI, icons bool,
if litems == nil || litems.head == nil {
return
}
- if ui.mode == FUZZ_MODE && data.lfuzz != nil {
- i_draw_host_panel_fuzzy(ui, icons, data.lfuzz, data)
- // TODO: draw fuzz list
- return
- }
+ // if ui.mode == FUZZ_MODE && data.lfuzz != nil {
+ // i_draw_host_panel_fuzzy(ui, icons, data.lfuzz, data)
+ // // TODO: draw fuzz list
+ // return
+ // }
for ptr := litems.draw; ptr != nil && line < ui.dim[H] - 2; ptr = ptr.next {
+ if ui.mode == FUZZ_MODE && i_fuzz_check(ptr, &ui) == false {
+ continue
+ }
if ptr.is_dir() == false && ptr.Host != nil {
i_host_panel_host(ui,
icons,
@@ -147,34 +152,30 @@ func i_draw_host_panel(ui HardUI, icons bool,
}
}
-func i_draw_host_panel_fuzzy(ui HardUI, icons bool,
- lfuzz *FuzzList, data *HardData) {
- line := 1
- if lfuzz == nil || lfuzz.head == nil {
- return
+func i_fuzz_check(ptr *ItemsNode, ui *HardUI) bool {
+ name := ""
+ var name_runes []rune
+ var end_runes []rune
+
+ if len(ui.buff.data) == 0 {
+ return true
}
- // TODO: find a way
- for ptr := lfuzz.draw; ptr != nil && line < ui.dim[H] - 2; ptr = ptr.next {
- if ptr.is_dir() == false && ptr.Host != nil {
- i_host_panel_host(ui,
- icons,
- 0,
- ptr.Host,
- lfuzz.curr.Host,
- data.yank,
- line)
- line++
- } else if ptr.Dirs != nil {
- var dir_icon uint8
- if data.folds[ptr.Dirs] != nil {
- dir_icon = 1
+ if ptr.is_dir() == false && ptr.Host != nil {
+ name = ptr.Host.Name
+ } else if ptr.Dirs != nil {
+ name = ptr.Dirs.Name
+ }
+ name_runes = []rune(name)
+ for _, buff_ptr := range ui.buff.data {
+ for _, name_ptr := range name_runes {
+ if buff_ptr == name_ptr {
+ end_runes = append(end_runes, buff_ptr)
}
- i_host_panel_dirs(ui, icons, dir_icon,
- 0,
- ptr.Dirs,
- lfuzz.curr.Dirs,
- line)
- line++
}
+ if len(end_runes) == 0 {
+ return false
+ }
+ // TODO: here
}
+ return true
}
diff --git a/src/i_info.go b/src/i_info.go
index 4802feb..e2aaba4 100644
--- a/src/i_info.go
+++ b/src/i_info.go
@@ -467,6 +467,8 @@ func i_info_note(ui HardUI, host *HostNode, line int) {
func i_draw_info_panel(ui HardUI, percent bool, litems *ItemsList) {
type info_func func(HardUI, *HostNode, int) int
+ if ui.mode == FUZZ_MODE {
+ }
i_draw_box(ui.s, (ui.dim[W] / 3), 0,
ui.dim[W] - 1, ui.dim[H] - 2,
ui.style[BOX_STYLE], ui.style[HEAD_STYLE], " Infos ", false)
diff --git a/src/i_ui.go b/src/i_ui.go
index 209156d..486cc29 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -205,6 +205,33 @@ func i_draw_msg(s tcell.Screen, lines int, box_style tcell.Style,
box_style, title)
}
+func i_set_box_style(ui *HardUI) {
+ tmp := tcell.StyleDefault.Background(tcell.ColorReset)
+
+ switch ui.mode {
+ case NORMAL_MODE,
+ LOAD_MODE,
+ WELCOME_MODE,
+ HELP_MODE:
+ // FIX: with custom config for default ayayaya
+ ui.style[BOX_STYLE] = tmp.Foreground(tcell.ColorReset)
+ ui.style[HEAD_STYLE] = tmp.Foreground(tcell.ColorReset)
+ case DELETE_MODE,
+ ERROR_MODE:
+ ui.style[BOX_STYLE] = tmp.Foreground(tcell.ColorRed).Dim(true)
+ ui.style[HEAD_STYLE] = tmp.Foreground(tcell.ColorRed).Dim(true)
+ case MKDIR_MODE,
+ INSERT_NAME_MODE,
+ INSERT_MODE,
+ RENAME_MODE:
+ ui.style[BOX_STYLE] = tmp.Foreground(tcell.ColorBlue).Dim(true)
+ ui.style[HEAD_STYLE] = tmp.Foreground(tcell.ColorBlue).Dim(true)
+ case FUZZ_MODE:
+ ui.style[BOX_STYLE] = tmp.Foreground(tcell.ColorPurple)
+ ui.style[HEAD_STYLE] = tmp.Foreground(tcell.ColorPurple)
+ }
+}
+
func i_draw_bottom_text(ui HardUI, insert *HostNode, insert_err []error) {
text := ""
@@ -815,7 +842,6 @@ func i_ui(data_dir string) {
[][2]string{},
nil,
nil,
- nil,
}
if data.opts.GPG == DEFAULT_OPTS.GPG && data.litems.head == nil {
data.ui.mode = WELCOME_MODE
@@ -836,6 +862,7 @@ func i_ui(data_dir string) {
}
for {
data.ui.s.Clear()
+ i_set_box_style(&data.ui)
i_draw_bottom_text(data.ui, data.insert, data.insert_err)
i_draw_host_panel(data.ui, data.opts.Icon, data.litems, &data)
i_draw_info_panel(data.ui, data.opts.Perc, data.litems)