aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/c_defs.go39
-rw-r--r--src/c_exec.go2
-rw-r--r--src/c_hardflip.go1
-rw-r--r--src/c_init.go20
-rw-r--r--src/c_parse.go11
-rw-r--r--src/c_utils.go41
-rw-r--r--src/i_host.go6
-rw-r--r--src/i_info.go92
-rw-r--r--src/i_ui.go50
9 files changed, 173 insertions, 89 deletions
diff --git a/src/c_defs.go b/src/c_defs.go
index 2662009..da3ab77 100644
--- a/src/c_defs.go
+++ b/src/c_defs.go
@@ -43,7 +43,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/c_defs.go
- * Wed Jan 10 17:11:42 2024
+ * Wed Jan 31 16:40:52 2024
* Joe
*
* constants
@@ -52,12 +52,10 @@
package main
const (
- W = 0
- H = 1
- ERROR_MSG = 0
- ERROR_ERR = 1
- DATA_DIR_NAME = "hardflip"
- VERSION = "v0.2"
+ CONF_FILE_NAME = "hf.yml"
+ CONF_DIR_NAME = "hf"
+ DATA_DIR_NAME = "hf"
+ VERSION = "v0.2"
)
const (
@@ -79,16 +77,29 @@ const (
)
const (
- DEF_STYLE = 0
- DIR_STYLE = 1
- BOX_STYLE = 2
- HEAD_STYLE = 3
- ERR_STYLE = 4
- TITLE_STYLE = 5
- BOT_STYLE = 6
+ W = 0
+ H = 1
+ ERROR_MSG = 0
+ ERROR_ERR = 1
+ STYLE_DEF = 0
+ STYLE_DIR = 1
+ STYLE_BOX = 2
+ STYLE_HEAD = 3
+ STYLE_ERR = 4
+ STYLE_TITLE = 5
+ STYLE_BOT = 6
)
var (
HOST_ICONS = [2]string{" ", " "}
DIRS_ICONS = [2]string{" ", " "}
)
+
+var DEFAULT_OPS = HardOpts{
+ true,
+ true,
+ "",
+ false,
+ "",
+}
+
diff --git a/src/c_exec.go b/src/c_exec.go
index c1dd6aa..7bfcbc9 100644
--- a/src/c_exec.go
+++ b/src/c_exec.go
@@ -196,6 +196,6 @@ func c_exec(host *HostNode, opts HardOpts, ui *HardUI) {
if err := ui.s.Init(); err != nil {
c_die("view", err)
}
- ui.s.SetStyle(ui.style[DEF_STYLE])
+ ui.s.SetStyle(ui.style[STYLE_DEF])
}
}
diff --git a/src/c_hardflip.go b/src/c_hardflip.go
index 1075f19..e4eec84 100644
--- a/src/c_hardflip.go
+++ b/src/c_hardflip.go
@@ -63,6 +63,7 @@ type HardData struct {
}
func main() {
+ c_get_options(c_get_conf_dir(nil))
data_dir := c_get_data_dir(nil)
opts := HardOpts{
true,
diff --git a/src/c_init.go b/src/c_init.go
index f89ce47..e377053 100644
--- a/src/c_init.go
+++ b/src/c_init.go
@@ -138,3 +138,23 @@ func c_load_litems(ldirs *DirsList) *ItemsList {
litems.draw = litems.head
return &litems
}
+
+func c_write_options(dir string) {
+ // TODO: this
+}
+
+func c_get_options(dir string) HardOpts {
+ opts := HardOpts{}
+ file := dir + "/" + CONF_FILE_NAME
+
+ if _, err := os.Stat(file); os.IsNotExist(err) {
+ c_write_options(file)
+ return DEFAULT_OPS
+ }
+ opts, err := c_parse_opts(file)
+ if err != nil {
+ // TODO: this
+ }
+ return opts
+}
+
diff --git a/src/c_parse.go b/src/c_parse.go
index faa8223..53249cf 100644
--- a/src/c_parse.go
+++ b/src/c_parse.go
@@ -58,6 +58,17 @@ import (
"gopkg.in/yaml.v3"
)
+func c_parse_opts(file string) (HardOpts, error) {
+ var opts HardOpts
+
+ yaml_file, err := os.ReadFile(file)
+ if err != nil {
+ return opts, err
+ }
+ err = yaml.Unmarshal(yaml_file, opts)
+ return opts, err
+}
+
func c_read_yaml_file(file string, ui *HardUI) (*HostNode, error) {
var host HostNode
yaml_file, err := os.ReadFile(file)
diff --git a/src/c_utils.go b/src/c_utils.go
index 01c8665..7ec70c0 100644
--- a/src/c_utils.go
+++ b/src/c_utils.go
@@ -60,11 +60,52 @@ import (
// this function will go get the data folder and try to create it if it does
// not exist
+// the first path being checked is $XDG_CONFIG_HOME then $HOME/.config
+// it returns the full data directory path
+func c_get_conf_dir(ui *HardUI) string {
+ var ptr string
+ var home string
+
+ if home = os.Getenv("HOME"); len(home) == 0 {
+ if ui == nil {
+ c_die("env variable HOME not defined", nil)
+ }
+ c_error_mode("env variable HOME not defined", nil, ui)
+ return ""
+ }
+ xdg_home := os.Getenv("XDG_CONFIG_HOME")
+
+ if len(xdg_home) > 0 {
+ ptr = xdg_home
+ } else {
+ ptr = home + "/.config"
+ }
+ ptr += "/" + CONF_DIR_NAME
+ if _, err := os.Stat(ptr); os.IsNotExist(err) {
+ if err := os.MkdirAll(ptr, os.ModePerm); err != nil {
+ if ui == nil {
+ c_die("could not create path " + ptr, err)
+ }
+ c_error_mode("could not create path" + ptr, err, ui)
+ }
+ } else if err != nil {
+ if ui == nil {
+ c_die("could read path " + ptr, err)
+ }
+ c_error_mode("could read path" + ptr, err, ui)
+ return ""
+ }
+ return ptr
+}
+
+// this function will go get the data folder and try to create it if it does
+// not exist
// the first path being checked is $XDG_DATA_HOME then $HOME/.local/share
// it returns the full data directory path
func c_get_data_dir(ui *HardUI) string {
var ptr string
var home string
+
if home = os.Getenv("HOME"); len(home) == 0 {
if ui == nil {
c_die("env variable HOME not defined", nil)
diff --git a/src/i_host.go b/src/i_host.go
index 76334e1..9afb352 100644
--- a/src/i_host.go
+++ b/src/i_host.go
@@ -53,7 +53,7 @@ package main
func i_host_panel_dirs(ui HardUI, icons bool, dir_icon uint8,
dir *DirsNode, curr *DirsNode, line int) {
- style := ui.style[DIR_STYLE]
+ style := ui.style[STYLE_DIR]
if dir == curr {
// style = style.Background(tcell.ColorBlack)
style = style.Reverse(true)
@@ -78,7 +78,7 @@ func i_host_panel_dirs(ui HardUI, icons bool, dir_icon uint8,
func i_host_panel_host(ui HardUI, icons bool,
depth uint16, host *HostNode, curr *HostNode, line int) {
- style := ui.style[DEF_STYLE]
+ style := ui.style[STYLE_DEF]
if host == curr {
// style = style.Background(tcell.ColorBlack)
style = style.Reverse(true)
@@ -105,7 +105,7 @@ func i_draw_host_panel(ui HardUI, icons bool,
litems *ItemsList, data *HardData) {
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)
+ ui.style[STYLE_BOX], ui.style[STYLE_HEAD], " Hosts ", false)
line := 1
if litems == nil || litems.head == nil {
return
diff --git a/src/i_info.go b/src/i_info.go
index 21bc670..41acce7 100644
--- a/src/i_info.go
+++ b/src/i_info.go
@@ -65,28 +65,28 @@ func i_info_panel_dirs(ui HardUI, dir *DirsNode) {
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[TITLE_STYLE], "Name: ")
+ ui.style[STYLE_TITLE], "Name: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[DEF_STYLE], dir.Name)
+ ui.style[STYLE_DEF], dir.Name)
if line += 1; line > ui.dim[H] - 3 {
return
}
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[TITLE_STYLE], "Type: ")
+ ui.style[STYLE_TITLE], "Type: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[DEF_STYLE], "Directory")
+ ui.style[STYLE_DEF], "Directory")
if line += 2; line > ui.dim[H] - 3 {
return
}
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[TITLE_STYLE], "Path: ")
+ ui.style[STYLE_TITLE], "Path: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[DEF_STYLE], dir.path()[1:])
+ ui.style[STYLE_DEF], dir.path()[1:])
}
func i_info_panel_host(ui HardUI, host *HostNode) {
@@ -98,19 +98,19 @@ func i_info_panel_host(ui HardUI, host *HostNode) {
// name, type
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[TITLE_STYLE], "Name: ")
+ ui.style[STYLE_TITLE], "Name: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[DEF_STYLE], host.Name)
+ ui.style[STYLE_DEF], host.Name)
if line += 1; line > ui.dim[H] - 3 {
return
}
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[TITLE_STYLE], "Type: ")
+ ui.style[STYLE_TITLE], "Type: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[DEF_STYLE], host_type)
+ ui.style[STYLE_DEF], host_type)
if line += 2; line > ui.dim[H] - 3 {
return
}
@@ -120,19 +120,19 @@ func i_info_panel_host(ui HardUI, host *HostNode) {
// host, port
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[TITLE_STYLE], "Host: ")
+ ui.style[STYLE_TITLE], "Host: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[DEF_STYLE], host.Host)
+ ui.style[STYLE_DEF], host.Host)
if line += 1; line > ui.dim[H] - 3 {
return
}
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[TITLE_STYLE], "Port: ")
+ ui.style[STYLE_TITLE], "Port: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[DEF_STYLE], strconv.Itoa(int(host.Port)))
+ ui.style[STYLE_DEF], strconv.Itoa(int(host.Port)))
if line += 1; line > ui.dim[H] - 3 {
return
}
@@ -141,10 +141,10 @@ func i_info_panel_host(ui HardUI, host *HostNode) {
if len(host.Domain) > 0 {
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[TITLE_STYLE], "Domain: ")
+ ui.style[STYLE_TITLE], "Domain: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 11, line, ui.dim[W] - 2, line,
- ui.style[DEF_STYLE], host.Domain)
+ ui.style[STYLE_DEF], host.Domain)
if line += 1; line > ui.dim[H] - 3 {
return
}
@@ -156,20 +156,20 @@ func i_info_panel_host(ui HardUI, host *HostNode) {
// user infos
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[TITLE_STYLE], "User: ")
+ ui.style[STYLE_TITLE], "User: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[DEF_STYLE], host.User)
+ ui.style[STYLE_DEF], host.User)
if line += 1; line > ui.dim[H] - 3 {
return
}
if len(host.Pass) > 0 {
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[TITLE_STYLE], "Pass: ")
+ ui.style[STYLE_TITLE], "Pass: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[DEF_STYLE], "***")
+ ui.style[STYLE_DEF], "***")
if line += 1; line > ui.dim[H] - 3 {
return
}
@@ -177,10 +177,10 @@ func i_info_panel_host(ui HardUI, host *HostNode) {
if host.Protocol == 0 && len(host.Priv) > 0 {
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[TITLE_STYLE], "Privkey: ")
+ ui.style[STYLE_TITLE], "Privkey: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 12, line, ui.dim[W] - 2, line,
- ui.style[DEF_STYLE], host.Priv)
+ ui.style[STYLE_DEF], host.Priv)
if line += 1; line > ui.dim[H] - 3 {
return
}
@@ -192,44 +192,44 @@ func i_info_panel_host(ui HardUI, host *HostNode) {
if host.Protocol == 0 && len(host.Jump) > 0 {
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[TITLE_STYLE], "Jump settings: ")
+ ui.style[STYLE_TITLE], "Jump settings: ")
if line += 1; line > ui.dim[H] - 3 {
return
}
i_draw_text(ui.s,
(ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line,
- ui.style[TITLE_STYLE], "Host: ")
+ ui.style[STYLE_TITLE], "Host: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line,
- ui.style[DEF_STYLE], host.Jump)
+ ui.style[STYLE_DEF], host.Jump)
if line += 1; line > ui.dim[H] - 3 {
return
}
i_draw_text(ui.s,
(ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line,
- ui.style[TITLE_STYLE], "Port: ")
+ ui.style[STYLE_TITLE], "Port: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line,
- ui.style[DEF_STYLE], strconv.Itoa(int(host.JumpPort)))
+ ui.style[STYLE_DEF], strconv.Itoa(int(host.JumpPort)))
if line += 1; line > ui.dim[H] - 3 {
return
}
i_draw_text(ui.s,
(ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line,
- ui.style[TITLE_STYLE], "User: ")
+ ui.style[STYLE_TITLE], "User: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line,
- ui.style[DEF_STYLE], host.JumpUser)
+ ui.style[STYLE_DEF], host.JumpUser)
if line += 1; line > ui.dim[H] - 3 {
return
}
if len(host.JumpPass) > 0 {
i_draw_text(ui.s,
(ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line,
- ui.style[TITLE_STYLE], "Pass: ")
+ ui.style[STYLE_TITLE], "Pass: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line,
- ui.style[DEF_STYLE], "***")
+ ui.style[STYLE_DEF], "***")
if line += 1; line > ui.dim[H] - 3 {
return
}
@@ -237,10 +237,10 @@ func i_info_panel_host(ui HardUI, host *HostNode) {
if host.Protocol == 0 && len(host.JumpPriv) > 0 {
i_draw_text(ui.s,
(ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line,
- ui.style[TITLE_STYLE], "Privkey: ")
+ ui.style[STYLE_TITLE], "Privkey: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 13, line, ui.dim[W] - 2, line,
- ui.style[DEF_STYLE], host.JumpPriv)
+ ui.style[STYLE_DEF], host.JumpPriv)
if line += 1; line > ui.dim[H] - 3 {
return
}
@@ -254,10 +254,10 @@ func i_info_panel_host(ui HardUI, host *HostNode) {
qual := [3]string{"Low", "Medium", "High"}
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[TITLE_STYLE], "Screen size: ")
+ ui.style[STYLE_TITLE], "Screen size: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 16, line, ui.dim[W] - 2, line,
- ui.style[DEF_STYLE],
+ ui.style[STYLE_DEF],
strconv.Itoa(int(host.Width)) + "x" +
strconv.Itoa(int(host.Height)))
if line += 1; line > ui.dim[H] - 3 {
@@ -265,19 +265,19 @@ func i_info_panel_host(ui HardUI, host *HostNode) {
}
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[TITLE_STYLE], "Dynamic window: ")
+ ui.style[STYLE_TITLE], "Dynamic window: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 19, line, ui.dim[W] - 2, line,
- ui.style[DEF_STYLE], strconv.FormatBool(host.Dynamic))
+ ui.style[STYLE_DEF], strconv.FormatBool(host.Dynamic))
if line += 1; line > ui.dim[H] - 3 {
return
}
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[TITLE_STYLE], "Quality: ")
+ ui.style[STYLE_TITLE], "Quality: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 12, line, ui.dim[W] - 2, line,
- ui.style[DEF_STYLE], qual[host.Quality])
+ ui.style[STYLE_DEF], qual[host.Quality])
line += 1
if line += 1; line > ui.dim[H] - 3 {
return
@@ -287,10 +287,10 @@ func i_info_panel_host(ui HardUI, host *HostNode) {
if len(host.Note) > 0 {
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[TITLE_STYLE], "Note: ")
+ ui.style[STYLE_TITLE], "Note: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[DEF_STYLE], host.Note)
+ ui.style[STYLE_DEF], host.Note)
if line += 1; line > ui.dim[H] - 3 {
return
}
@@ -300,10 +300,10 @@ func i_info_panel_host(ui HardUI, host *HostNode) {
func i_draw_info_panel(ui HardUI, percent bool, litems *ItemsList) {
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)
- ui.s.SetContent(ui.dim[W] / 3, 0, tcell.RuneTTee, nil, ui.style[BOX_STYLE])
+ ui.style[STYLE_BOX], ui.style[STYLE_HEAD], " Infos ", false)
+ ui.s.SetContent(ui.dim[W] / 3, 0, tcell.RuneTTee, nil, ui.style[STYLE_BOX])
ui.s.SetContent(ui.dim[W] / 3, ui.dim[H] - 2,
- tcell.RuneBTee, nil, ui.style[BOX_STYLE])
+ tcell.RuneBTee, nil, ui.style[STYLE_BOX])
if litems == nil {
return
}
@@ -320,7 +320,7 @@ func i_draw_info_panel(ui HardUI, percent bool, litems *ItemsList) {
ui.dim[H] - 2,
(ui.dim[W] - 1) - 1,
ui.dim[H] - 2,
- ui.style[DEF_STYLE],
+ ui.style[STYLE_DEF],
text)
} else {
text := " 0 hosts "
@@ -329,7 +329,7 @@ func i_draw_info_panel(ui HardUI, percent bool, litems *ItemsList) {
ui.dim[H] - 2,
(ui.dim[W] - 1) - 1,
ui.dim[H] - 2,
- ui.style[DEF_STYLE],
+ ui.style[STYLE_DEF],
text)
}
// panel
diff --git a/src/i_ui.go b/src/i_ui.go
index b7b83a9..69563e0 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -180,18 +180,18 @@ func i_draw_bottom_text(ui HardUI) {
}
i_draw_text(ui.s,
1, ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
- ui.style[BOT_STYLE], text)
+ ui.style[STYLE_BOT], text)
i_draw_text(ui.s,
ui.dim[W] - len(VERSION) - 2, ui.dim[H] - 1,
- ui.dim[W] - 1, ui.dim[H] - 1, ui.style[BOT_STYLE], " " + VERSION)
+ ui.dim[W] - 1, ui.dim[H] - 1, ui.style[STYLE_BOT], " " + VERSION)
}
func i_draw_zhosts_box(ui HardUI) {
- i_draw_msg(ui.s, 1, ui.style[BOX_STYLE], ui.dim, " No hosts ")
+ i_draw_msg(ui.s, 1, ui.style[STYLE_BOX], ui.dim, " No hosts ")
text := "Hosts list empty. Add hosts/folders by pressing (a/m)"
left, right := i_left_right(len(text), &ui)
i_draw_text(ui.s, left, ui.dim[H] - 2 - 1, right, ui.dim[H] - 2 - 1,
- ui.style[DEF_STYLE], text)
+ ui.style[STYLE_DEF], text)
}
func i_draw_delete_msg(ui HardUI, item *ItemsNode) {
@@ -207,20 +207,20 @@ func i_draw_delete_msg(ui HardUI, item *ItemsNode) {
file = host.Parent.path() + host.Filename
}
file = file[1:]
- i_draw_msg(ui.s, 2, ui.style[BOX_STYLE], ui.dim, " Delete ")
+ i_draw_msg(ui.s, 2, ui.style[STYLE_BOX], ui.dim, " Delete ")
left, right := i_left_right(len(text), &ui)
line := ui.dim[H] - 2 - 2
- i_draw_text(ui.s, left, line, right, line, ui.style[DEF_STYLE], text)
+ i_draw_text(ui.s, left, line, right, line, ui.style[STYLE_DEF], text)
left, right = i_left_right(len(file), &ui)
line += 1
i_draw_text(ui.s,
left, line, right, line,
- ui.style[DEF_STYLE].Bold(true), file)
+ ui.style[STYLE_DEF].Bold(true), file)
}
func i_draw_load_error_msg(ui HardUI, load_err []error) {
lines := len(load_err)
- i_draw_msg(ui.s, lines, ui.style[BOX_STYLE], ui.dim, " Load time errors ")
+ i_draw_msg(ui.s, lines, ui.style[STYLE_BOX], ui.dim, " Load time errors ")
left, right := 1, ui.dim[W] - 1
line := ui.dim[H] - 2 - 1 - len(load_err)
if line < 0 {
@@ -230,7 +230,7 @@ func i_draw_load_error_msg(ui HardUI, load_err []error) {
line += 1
err_str := fmt.Sprintf("%v", err)
i_draw_text(ui.s, left, line, right, line,
- ui.style[ERR_STYLE], err_str)
+ ui.style[STYLE_ERR], err_str)
}
}
@@ -243,18 +243,18 @@ func i_draw_error_msg(ui HardUI, load_err []error) {
if len(ui.err[ERROR_ERR]) == 0 {
lines = 1
}
- i_draw_msg(ui.s, lines, ui.style[BOX_STYLE], ui.dim, " Error ")
+ i_draw_msg(ui.s, lines, ui.style[STYLE_BOX], ui.dim, " Error ")
left, right := 1, ui.dim[W] - 2
line := ui.dim[H] - 2 - 2
if len(ui.err[ERROR_ERR]) == 0 {
line += 1
}
i_draw_text(ui.s, left, line, right, line,
- ui.style[ERR_STYLE], ui.err[ERROR_MSG])
+ ui.style[STYLE_ERR], ui.err[ERROR_MSG])
if len(ui.err[ERROR_ERR]) > 0 {
line += 1
i_draw_text(ui.s, left, line, right, line,
- ui.style[ERR_STYLE], ui.err[ERROR_ERR])
+ ui.style[STYLE_ERR], ui.err[ERROR_ERR])
}
}
@@ -271,12 +271,12 @@ func i_draw_scrollhint(ui HardUI, litems *ItemsList) {
if draw_id > 1 {
ui.s.SetContent(0, 1,
'▲',
- nil, ui.style[BOX_STYLE])
+ nil, ui.style[STYLE_BOX])
}
if last - draw_id > h {
ui.s.SetContent(0, ui.dim[H] - 3,
'▼',
- nil, ui.style[BOX_STYLE])
+ nil, ui.style[STYLE_BOX])
return
}
}
@@ -295,14 +295,14 @@ func i_draw_load_ui(ui *HardUI) {
text += " "
}
i_draw_text(ui.s, 1, ui.dim[H] - 1, ui.dim[W], ui.dim[H] - 1,
- ui.style[BOT_STYLE], text)
+ ui.style[STYLE_BOT], text)
i_draw_bottom_text(*ui)
- i_draw_msg(ui.s, 1, ui.style[BOX_STYLE], ui.dim, " Loading ")
+ i_draw_msg(ui.s, 1, ui.style[STYLE_BOX], ui.dim, " Loading ")
text = "Loading " + strconv.Itoa(g_load_count) + " hosts"
left, right := i_left_right(len(text), ui)
i_draw_text(ui.s,
left, ui.dim[H] - 2 - 1, right, ui.dim[H] - 2 - 1,
- ui.style[DEF_STYLE], text)
+ ui.style[STYLE_DEF], text)
ui.s.Show()
ui.s.PostEvent(nil)
event := ui.s.PollEvent()
@@ -345,28 +345,28 @@ func i_ui(data_dir string, opts HardOpts) {
if err := ui.s.Init(); err != nil {
c_die("view", err)
}
- ui.style[DEF_STYLE] = tcell.StyleDefault.
+ ui.style[STYLE_DEF] = tcell.StyleDefault.
Background(tcell.ColorReset).
Foreground(tcell.ColorReset)
- ui.style[DIR_STYLE] = tcell.StyleDefault.
+ ui.style[STYLE_DIR] = tcell.StyleDefault.
Background(tcell.ColorReset).
Foreground(tcell.ColorBlue).Dim(true).Bold(true)
- ui.style[BOX_STYLE] = tcell.StyleDefault.
+ ui.style[STYLE_BOX] = tcell.StyleDefault.
Background(tcell.ColorReset).
Foreground(tcell.ColorReset)
- ui.style[HEAD_STYLE] = tcell.StyleDefault.
+ ui.style[STYLE_HEAD] = tcell.StyleDefault.
Background(tcell.ColorReset).
Foreground(tcell.ColorReset)
- ui.style[ERR_STYLE] = tcell.StyleDefault.
+ ui.style[STYLE_ERR] = tcell.StyleDefault.
Background(tcell.ColorReset).
Foreground(tcell.ColorRed).Dim(true)
- ui.style[TITLE_STYLE] = tcell.StyleDefault.
+ ui.style[STYLE_TITLE] = tcell.StyleDefault.
Background(tcell.ColorReset).
Foreground(tcell.ColorBlue).Dim(true).Bold(true)
- ui.style[BOT_STYLE] = tcell.StyleDefault.
+ ui.style[STYLE_BOT] = tcell.StyleDefault.
Background(tcell.ColorReset).
Foreground(tcell.ColorBlue).Dim(true)
- ui.s.SetStyle(ui.style[DEF_STYLE])
+ ui.s.SetStyle(ui.style[STYLE_DEF])
ui.dim[W], ui.dim[H], _ = term.GetSize(0)
ldirs, litems, load_err := i_load_ui(data_dir, opts, &ui)
data := HardData{