aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--c_exec.go24
-rw-r--r--c_hardflip.go11
-rw-r--r--go.mod15
-rw-r--r--go.sum47
-rw-r--r--i_ui.go98
5 files changed, 177 insertions, 18 deletions
diff --git a/c_exec.go b/c_exec.go
index cdd23f8..b0145f6 100644
--- a/c_exec.go
+++ b/c_exec.go
@@ -39,7 +39,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/c_exec.go
- * Mon, 18 Dec 2023 13:20:08 +0100
+ * Mon, 18 Dec 2023 15:07:52 +0100
* Joe
*
* exec the command at some point
@@ -54,7 +54,7 @@ import (
"strconv"
)
-func exec_cmd(cmd_fmt []string) {
+func c_exec_cmd(cmd_fmt []string) {
cmd := exec.Command(cmd_fmt[0], cmd_fmt[1:]...)
fmt.Println(cmd_fmt)
@@ -64,7 +64,7 @@ func exec_cmd(cmd_fmt []string) {
cmd.Run()
}
-func format_ssh_jump(host *HostNode) string {
+func c_format_ssh_jump(host *HostNode) string {
jump_fmt := "-oProxyCommand=ssh"
if len(host.JumpPriv) > 0 {
jump_fmt += " -i " + host.JumpPriv
@@ -81,7 +81,7 @@ func format_ssh_jump(host *HostNode) string {
return jump_fmt
}
-func format_ssh(host *HostNode) []string {
+func c_format_ssh(host *HostNode) []string {
cmd_fmt := []string{"ssh"}
user := host.User
@@ -89,7 +89,7 @@ func format_ssh(host *HostNode) []string {
cmd_fmt = append(cmd_fmt, "-i", host.Priv)
}
if len(host.Jump) > 0 {
- cmd_fmt = append(cmd_fmt, format_ssh_jump(host))
+ cmd_fmt = append(cmd_fmt, c_format_ssh_jump(host))
}
if host.Port != 0 {
cmd_fmt = append(cmd_fmt, "-p", strconv.Itoa(int(host.Port)))
@@ -101,24 +101,24 @@ func format_ssh(host *HostNode) []string {
return cmd_fmt
}
-func format_rdp() {
+func c_format_rdp() {
}
-func format_cmd(id uint64, lhost *HostList) {
+func c_format_cmd(id uint64, lhost *HostList) {
host := lhost.head
- var cmd_fmt []string
+ // var cmd_fmt []string
host = lhost.sel(id)
if host == nil {
c_die("host id not found", nil)
}
if host.Type == 0 {
- cmd_fmt = format_ssh(host)
+ // cmd_fmt = format_ssh(host)
}
- exec_cmd(cmd_fmt)
+ // exec_cmd(cmd_fmt)
}
-func display_servers(lhost *HostList) {
+func c_display_servers(lhost *HostList) {
host := lhost.head
if lhost.head == nil {
@@ -130,5 +130,5 @@ func display_servers(lhost *HostList) {
host = host.next
}
fmt.Println()
- format_cmd(2, lhost)
+ c_format_cmd(4, lhost)
}
diff --git a/c_hardflip.go b/c_hardflip.go
index 7ce995c..ed4581a 100644
--- a/c_hardflip.go
+++ b/c_hardflip.go
@@ -39,7 +39,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/c_hardflip.go
- * Fri, 15 Dec 2023 17:53:42 +0100
+ * Mon, 18 Dec 2023 16:56:07 +0100
* Joe
*
* the main
@@ -48,9 +48,10 @@
package main
func main() {
- var data_dir string
+ // var data_dir string
- data_dir = c_get_data_dir()
- lhost := c_load_data_dir(data_dir)
- display_servers(lhost)
+ // data_dir = c_get_data_dir()
+ // lhost := c_load_data_dir(data_dir)
+ // display_servers(lhost)
+ i_ui()
}
diff --git a/go.mod b/go.mod
index e1a527a..01c0257 100644
--- a/go.mod
+++ b/go.mod
@@ -2,4 +2,17 @@ module hf
go 1.18
-require gopkg.in/yaml.v3 v3.0.1
+require (
+ github.com/gdamore/tcell/v2 v2.7.0
+ gopkg.in/yaml.v3 v3.0.1
+)
+
+require (
+ github.com/gdamore/encoding v1.0.0 // indirect
+ github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
+ github.com/mattn/go-runewidth v0.0.15 // indirect
+ github.com/rivo/uniseg v0.4.3 // indirect
+ golang.org/x/sys v0.15.0 // indirect
+ golang.org/x/term v0.15.0 // indirect
+ golang.org/x/text v0.14.0 // indirect
+)
diff --git a/go.sum b/go.sum
index a62c313..e6eab59 100644
--- a/go.sum
+++ b/go.sum
@@ -1,3 +1,50 @@
+github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
+github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
+github.com/gdamore/tcell/v2 v2.7.0 h1:I5LiGTQuwrysAt1KS9wg1yFfOI3arI3ucFrxtd/xqaA=
+github.com/gdamore/tcell/v2 v2.7.0/go.mod h1:hl/KtAANGBecfIPxk+FzKvThTqI84oplgbPEmVX60b8=
+github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
+github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
+github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
+github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
+github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
+github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw=
+github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
+github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
+golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
+golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
+golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
+golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
+golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
+golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=
+golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
+golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
+golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
+golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
+golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
diff --git a/i_ui.go b/i_ui.go
new file mode 100644
index 0000000..6bc11ff
--- /dev/null
+++ b/i_ui.go
@@ -0,0 +1,98 @@
+/*
+ * ========================
+ * ===== ===============
+ * ====== ================
+ * ====== ================
+ * ====== ==== ==== ==
+ * ====== === == = =
+ * ====== === = == =
+ * = === === = == ====
+ * = === === = == = =
+ * == ===== ==== ==
+ * ========================
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 2023 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 JOE ''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 JOE 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_hardflip.go
+ * Mon, 18 Dec 2023 16:50:31 +0100
+ * Joe
+ *
+ * interfacing with the user
+ */
+
+package main
+
+import (
+ "os"
+ "github.com/gdamore/tcell/v2"
+)
+
+func i_draw_text(s tcell.Screen, x1, y1, x2, y2 int, style tcell.Style, text string) {
+ row := y1
+ col := x1
+ for _, r := range []rune(text) {
+ s.SetContent(col, row, r, nil, style)
+ col++
+ if col >= x2 {
+ row++
+ col = x1
+ }
+ if row > y2 {
+ break
+ }
+ }
+}
+
+func i_ui() {
+ screen, err := tcell.NewScreen()
+ if err != nil {
+ c_die("view", err)
+ }
+ if err := screen.Init(); err != nil {
+ c_die("view", err)
+ }
+ def_style := tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorReset)
+ screen.SetStyle(def_style)
+ quit := func() {
+ screen.Fini()
+ os.Exit(0)
+ }
+ for {
+ i_draw_text(screen, 0, 0, 30, 0, def_style, "hey fuck you")
+ screen.Show()
+ ev := screen.PollEvent()
+ switch ev := ev.(type) {
+ case *tcell.EventResize:
+ screen.Sync()
+ case *tcell.EventKey:
+ if ev.Key() == tcell.KeyEscape || ev.Key() == tcell.KeyCtrlC {
+ quit()
+ }
+ }
+ }
+}