diff options
author | joe <rbo@gmx.us> | 2025-08-26 19:24:18 +0200 |
---|---|---|
committer | joe <rbo@gmx.us> | 2025-08-26 19:24:18 +0200 |
commit | 93aed08e521c7d96d3c53f207fb650b449cdb12c (patch) | |
tree | d3bf429138004692a36a4a47df137093f1393fc2 | |
parent | fixed (diff) | |
download | hardflip-93aed08e521c7d96d3c53f207fb650b449cdb12c.tar.gz hardflip-93aed08e521c7d96d3c53f207fb650b449cdb12c.tar.bz2 hardflip-93aed08e521c7d96d3c53f207fb650b449cdb12c.tar.xz hardflip-93aed08e521c7d96d3c53f207fb650b449cdb12c.tar.zst hardflip-93aed08e521c7d96d3c53f207fb650b449cdb12c.zip |
fixed all errs and some other things
-rw-r--r-- | src/c_exec.go | 13 | ||||
-rw-r--r-- | src/c_ldirs.go | 80 | ||||
-rw-r--r-- | src/c_lhosts.go | 18 | ||||
-rw-r--r-- | src/c_litems.go | 38 | ||||
-rw-r--r-- | src/c_parse.go | 2 | ||||
-rw-r--r-- | src/e_events.go | 9 | ||||
-rw-r--r-- | src/e_keys.go | 3 | ||||
-rw-r--r-- | src/i_insert.go | 11 | ||||
-rw-r--r-- | src/i_ui.go | 12 |
9 files changed, 92 insertions, 94 deletions
diff --git a/src/c_exec.go b/src/c_exec.go index aa297ea..6d42b29 100644 --- a/src/c_exec.go +++ b/src/c_exec.go @@ -43,7 +43,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * hardflip: src/c_exec.go - * Tue Apr 23 17:47:58 2024 + * Tue, 26 Aug 2025 19:17:04 +0200 * Joe * * exec the command at some point @@ -104,7 +104,10 @@ func c_format_ssh(host *HostNode, pass string) ([]string, []string) { cmd_fmt = append(cmd_fmt, "sshpass", "-p", pass) } - cmd_fmt = append(cmd_fmt, "ssh", "-F", "none") + cmd_fmt = append(cmd_fmt, "ssh", "-F", "none", + "-o", "StrictHostKeyChecking=no", + "-o", "UserKnownHostsFile=/dev/null", + "-o", "LogLevel=ERROR") if len(host.Priv) > 0 { cmd_fmt = append(cmd_fmt, "-i", host.Priv) } @@ -157,13 +160,13 @@ func c_format_rdp(host *HostNode, pass string) ([]string, []string) { cmd_fmt = append(cmd_fmt, "/drive:" + share + "," + path) } } - if host.Quality == 0 { + switch host.Quality { + case 0: cmd_fmt = append(cmd_fmt, "-aero", "-menu-anims", "-window-drag", "-wallpaper", "-decorations", "-fonts", "-themes", "/bpp:8", "/compression-level:2") - } else if host.Quality == 1 { - } else if host.Quality == 2 { + case 2: cmd_fmt = append(cmd_fmt, "+aero", "+menu-anims", "+window-drag", "+decorations", "+fonts", "+themes", "/gfx:RFX", "/rfx", "/gdi:hw", diff --git a/src/c_ldirs.go b/src/c_ldirs.go index ce9c424..0d73354 100644 --- a/src/c_ldirs.go +++ b/src/c_ldirs.go @@ -77,35 +77,35 @@ func (ldirs *DirsList) add_back(node *DirsNode) { } // removes a dir node from the list -func (ldirs *DirsList) del(dir *DirsNode) { - if ldirs.head == nil { - return - } - if ldirs.head == dir { - ldirs.head = ldirs.head.next - if ldirs.head == nil { - ldirs.last = nil - return - } - return - } - if ldirs.last == dir { - ptr := ldirs.head - for ptr.next != nil { - ptr = ptr.next - } - ldirs.last = ptr - ldirs.last.next = nil - return - } - ptr := ldirs.head - for ptr.next != nil && ptr.next != dir { - ptr = ptr.next - } - if ptr.next == dir { - ptr.next = ptr.next.next - } -} +// func (ldirs *DirsList) del(dir *DirsNode) { +// if ldirs.head == nil { +// return +// } +// if ldirs.head == dir { +// ldirs.head = ldirs.head.next +// if ldirs.head == nil { +// ldirs.last = nil +// return +// } +// return +// } +// if ldirs.last == dir { +// ptr := ldirs.head +// for ptr.next != nil { +// ptr = ptr.next +// } +// ldirs.last = ptr +// ldirs.last.next = nil +// return +// } +// ptr := ldirs.head +// for ptr.next != nil && ptr.next != dir { +// ptr = ptr.next +// } +// if ptr.next == dir { +// ptr.next = ptr.next.next +// } +// } // returns a string with the full path of the dir func (dir *DirsNode) path() string { @@ -122,14 +122,14 @@ func (dir *DirsNode) path() string { return path } -func (ldirs *DirsList) prev(dir *DirsNode) *DirsNode { - if ldirs.head == dir { - return dir - } - for ptr := ldirs.head; ptr != nil; ptr = ptr.next { - if ptr.next == dir { - return ptr - } - } - return nil -} +// func (ldirs *DirsList) prev(dir *DirsNode) *DirsNode { +// if ldirs.head == dir { +// return dir +// } +// for ptr := ldirs.head; ptr != nil; ptr = ptr.next { +// if ptr.next == dir { +// return ptr +// } +// } +// return nil +// } diff --git a/src/c_lhosts.go b/src/c_lhosts.go index 41964bd..e2fbd90 100644 --- a/src/c_lhosts.go +++ b/src/c_lhosts.go @@ -153,12 +153,12 @@ func (lhost *HostList) del(host *HostNode) { } } -func (lhost *HostList) count() int { - curr := lhost.head - var count int - - for count = 0; curr != nil; count++ { - curr = curr.next - } - return count -} +// func (lhost *HostList) count() int { +// curr := lhost.head +// var count int +// +// for count = 0; curr != nil; count++ { +// curr = curr.next +// } +// return count +// } diff --git a/src/c_litems.go b/src/c_litems.go index 14afbf2..7b04880 100644 --- a/src/c_litems.go +++ b/src/c_litems.go @@ -83,25 +83,25 @@ func (litems *ItemsList) add_back(node *ItemsNode) { } // replaces an item -func (litems *ItemsList) overwrite(node *ItemsNode) { - if litems.head == nil || litems.curr == nil { - litems.add_back(node) - return - } - curr := litems.curr - node.prev = curr.prev - node.next = curr.next - if node.next != nil { - curr.next.prev = node - } - if litems.last == curr { - litems.last = node - } - if curr.prev != nil { - curr.prev.next = node - } - litems.curr = node -} +// func (litems *ItemsList) overwrite(node *ItemsNode) { +// if litems.head == nil || litems.curr == nil { +// litems.add_back(node) +// return +// } +// curr := litems.curr +// node.prev = curr.prev +// node.next = curr.next +// if node.next != nil { +// curr.next.prev = node +// } +// if litems.last == curr { +// litems.last = node +// } +// if curr.prev != nil { +// curr.prev.next = node +// } +// litems.curr = node +// } // adds an item node to the list after the current selected item func (litems *ItemsList) add_after(node *ItemsNode) { diff --git a/src/c_parse.go b/src/c_parse.go index 2c8cddd..5f788e9 100644 --- a/src/c_parse.go +++ b/src/c_parse.go @@ -90,7 +90,7 @@ func c_read_yaml_file(file string) (*HostNode, error) { return nil, err } if err := yaml.Unmarshal(yaml_file, &host); err != nil { - err = errors.New(fmt.Sprintf("%s: %v", file, err)) + err = fmt.Errorf("%s: %v", file, err) return nil, err } if len(host.Name) == 0 { diff --git a/src/e_events.go b/src/e_events.go index 2889053..87a55f3 100644 --- a/src/e_events.go +++ b/src/e_events.go @@ -43,7 +43,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * hardflip: src/e_events.go - * Thu Apr 11 16:00:44 2024 + * Tue, 26 Aug 2025 19:02:24 +0200 * Joe * * events in the code @@ -52,6 +52,7 @@ package main import ( + "maps" "os" "github.com/gdamore/tcell/v2" @@ -98,7 +99,7 @@ func e_unfold_dir(data *HardData, item *ItemsNode) { return } // single empty dir - if start == item && end == end { // HACK: i forgot why end == end + if start == item { e_set_unfold(data, item) return } @@ -545,9 +546,7 @@ func e_deep_copy_host(base *HostNode) HostNode { new_host = *base if base.Drive != nil { new_host.Drive = make(map[string]string, len(base.Drive)) - for k, v := range base.Drive { - new_host.Drive[k] = v - } + maps.Copy(new_host.Drive, base.Drive) } if base.Shell != nil { new_host.Shell = make([]string, len(base.Shell)) diff --git a/src/e_keys.go b/src/e_keys.go index cc77ee3..4fb0acc 100644 --- a/src/e_keys.go +++ b/src/e_keys.go @@ -349,8 +349,7 @@ func e_mkdir_events(data *HardData, ui *HardUI, event tcell.EventKey) bool { func e_insert_events(data *HardData, ui *HardUI, event tcell.EventKey) bool { if data.insert == nil { if event.Key() == tcell.KeyEscape || - event.Key() == tcell.KeyCtrlC || - event.Rune() == 'q' { + event.Key() == tcell.KeyCtrlC { ui.s.HideCursor() ui.mode = NORMAL_MODE ui.insert_sel = 0 diff --git a/src/i_insert.go b/src/i_insert.go index 79d46e6..a147cb3 100644 --- a/src/i_insert.go +++ b/src/i_insert.go @@ -211,9 +211,10 @@ func i_insert_check_ok(data *HardData, in *HostNode) { if len(in.Host) == 0 { if (in.Protocol == PROTOCOL_RDP && len(in.RDPFile) > 0) == false { text := "no host" - if in.Protocol == PROTOCOL_CMD { + switch in.Protocol { + case PROTOCOL_CMD: text = "no command" - } else if in.Protocol == PROTOCOL_OS { + case PROTOCOL_OS: text = "no endpoint" } data.insert_err = append(data.insert_err, errors.New(text)) @@ -326,7 +327,7 @@ func i_draw_text_box(ui *HardUI, line int, dim Quad, label, content string, tbox_style = tbox_style.Foreground(tcell.ColorRed) } spaces := "" - for i := 0; i < tbox_size; i++ { + for range tbox_size { spaces += " " } i_draw_text(ui.s, ui.dim[W] / 2, line, dim.R, line, @@ -348,11 +349,11 @@ func i_draw_ok_butt(ui *HardUI, dim Quad, line, id, selected int) { style = style.Reverse(true).Dim(false) } buff := "[" - for i := 0; i < butt_size / 2 - len(txt); i++ { + for range butt_size / 2 - len(txt) { buff += " " } buff += txt - for i := 0; i < butt_size / 2 - len(txt); i++ { + for range butt_size / 2 - len(txt) { buff += " " } buff += "]" diff --git a/src/i_ui.go b/src/i_ui.go index f32b214..653f333 100644 --- a/src/i_ui.go +++ b/src/i_ui.go @@ -43,7 +43,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * hardflip: src/i_ui.go - * Tue, 26 Aug 2025 18:48:33 +0200 + * Tue, 26 Aug 2025 18:55:49 +0200 * Joe * * interfacing with the user @@ -580,9 +580,7 @@ func i_draw_insert_err_msg(ui HardUI, insert_err []error) { i_draw_msg(ui.s, lines, ui.style[BOX_STYLE], ui.dim, " Errors ") left, right := 1, ui.dim[W] - 1 line := ui.dim[H] - 2 - 1 - len(insert_err) - if line < 0 { - line = 0 - } + line = max(line, 0) for _, err := range insert_err { line += 1 err_str := fmt.Sprintf("%v", err) @@ -596,9 +594,7 @@ func i_draw_load_error_msg(ui HardUI, load_err []error) { i_draw_msg(ui.s, lines, ui.style[BOX_STYLE], ui.dim, " Load time errors ") left, right := 1, ui.dim[W] - 1 line := ui.dim[H] - 2 - 1 - len(load_err) - if line < 0 { - line = 0 - } + line = max(line, 0) for _, err := range load_err { line += 1 err_str := fmt.Sprintf("%v", err) @@ -715,7 +711,7 @@ func i_load_ui(data_dir string, } func i_init_styles(ui *HardUI, styles HardStyle) { - for i := 0; i < STYLE_MAX + 1; i++ { + for i := range STYLE_MAX + 1 { tmp := tcell.StyleDefault.Background(tcell.ColorReset) curr_color := "default" switch i { |