diff options
| author | Joe <rbo@gmx.us> | 2024-05-16 20:20:20 +0200 | 
|---|---|---|
| committer | Joe <rbo@gmx.us> | 2024-05-16 20:20:20 +0200 | 
| commit | f7b605664109f81bbe2933907664c7a8ed83f413 (patch) | |
| tree | a298aae5b9eb4622923798345986e2a73e0b7977 | |
| parent | ok (diff) | |
| download | hardflip-f7b605664109f81bbe2933907664c7a8ed83f413.tar.gz hardflip-f7b605664109f81bbe2933907664c7a8ed83f413.tar.bz2 hardflip-f7b605664109f81bbe2933907664c7a8ed83f413.tar.xz hardflip-f7b605664109f81bbe2933907664c7a8ed83f413.tar.zst hardflip-f7b605664109f81bbe2933907664c7a8ed83f413.zip | |
coool
Diffstat (limited to '')
| -rw-r--r-- | src/c_defs.go | 66 | ||||
| -rw-r--r-- | src/c_hardflip.go | 15 | ||||
| -rw-r--r-- | src/c_init.go | 16 | ||||
| -rw-r--r-- | src/i_ui.go | 129 | 
4 files changed, 179 insertions, 47 deletions
| diff --git a/src/c_defs.go b/src/c_defs.go index a21fca8..9d542fa 100644 --- a/src/c_defs.go +++ b/src/c_defs.go @@ -110,7 +110,7 @@ const (  	BOT_STYLE  	YANK_STYLE  	MOVE_STYLE -	MAX_STYLE = MOVE_STYLE +	STYLE_MAX = MOVE_STYLE  )  const ( @@ -184,8 +184,7 @@ const (  	INSERT_EDIT  ) -var ( -	INSERT_HINTS = [INS_MAX]string{ +var INSERT_HINTS = [INS_MAX]string{  		"Select the protocol used to connect to your host",  		"IP or domain name of your host",  		"Port used for SSH (default: 22)", @@ -195,12 +194,10 @@ var (  		"Optional shell command line that will be run on your host",  		"IP or domain name of your jump host",  		"Port used for your jump SSH host (default: 22)", -		// TODO: fuck this anyway +		// NOTE: fuck this anyway  	} -) -var ( -	HELP_NORMAL_KEYS = [][2]string{ +var HELP_NORMAL_KEYS = [][2]string{  	{"<down> | j",				"Go to next item"},  	{"<up> | k",				"Go to previous item"},  	{"<pgdown> | <c-d>",		"Jump down"}, @@ -224,8 +221,7 @@ var (  	{"<c-r>",					"Reload data and configuration"},  	{"?",						"Display this help menu"},  	{"<c-c> | q",				"Quit"}, -	} -) +}  var (  	HOST_ICONS = [4]string{" ", " ", " ", " "} @@ -258,3 +254,55 @@ var DEFAULT_OPTS = HardOpts{  	"",  } +var DEFAULT_STYLE = HardStyle{ +	DefColor:	COLORS[COLOR_DEFAULT], +	DirColor:	COLORS[COLOR_BOLD_BLUE], +	BoxColor:	COLORS[COLOR_DEFAULT], +	HeadColor:	COLORS[COLOR_DEFAULT], +	ErrColor:	COLORS[COLOR_RED], +	TitleColor:	COLORS[COLOR_BOLD_BLUE], +	BotColor:	COLORS[COLOR_BLUE], +	YankColor:	COLORS[COLOR_BOLD_YELLOW], +	MoveColor:	COLORS[COLOR_BOLD_RED], +} + +const ( +	COLOR_DEFAULT = iota +    COLOR_BLACK +    COLOR_RED +    COLOR_GREEN +    COLOR_YELLOW +    COLOR_BLUE +    COLOR_MAGENTA +    COLOR_CYAN +    COLOR_WHITE +    COLOR_BOLD_BLACK +    COLOR_BOLD_RED +    COLOR_BOLD_GREEN +    COLOR_BOLD_YELLOW +    COLOR_BOLD_BLUE +    COLOR_BOLD_MAGENTA +    COLOR_BOLD_CYAN +    COLOR_BOLD_WHITE +	COLORS_MAX = COLOR_BOLD_WHITE +) + +var COLORS = [COLORS_MAX + 1]string{ +	"default", +	"black", +	"red", +	"green", +	"yellow", +	"blue", +	"magenta", +	"cyan", +	"white", +	"boldblack", +	"boldred", +	"boldgreen", +	"boldyellow", +	"boldblue", +	"boldmagenta", +	"boldcyan", +	"boldwhite", +} diff --git a/src/c_hardflip.go b/src/c_hardflip.go index 9b1b5c0..4d22149 100644 --- a/src/c_hardflip.go +++ b/src/c_hardflip.go @@ -56,17 +56,18 @@ import "os"  // the main data structure, holds up everything important  type HardData struct { -	litems  *ItemsList -	ldirs   *DirsList -	ui      HardUI -	opts    HardOpts -	folds   map[*DirsNode]*ItemsList +	litems	*ItemsList +	ldirs	*DirsList +	ui		HardUI +	opts	HardOpts +	colors	HardStyle +	folds	map[*DirsNode]*ItemsList  	data_dir string  	home_dir string  	load_err []error  	insert_err []error -	keys    [][2]string -	insert  *HostNode +	keys	[][2]string +	insert	*HostNode  	yank	*ItemsNode  } diff --git a/src/c_init.go b/src/c_init.go index 3faca8e..0bc37be 100644 --- a/src/c_init.go +++ b/src/c_init.go @@ -68,6 +68,18 @@ type HardOpts struct {  	file    string  } +type HardStyle struct { +	DefColor	string `yaml:"default"` +	DirColor	string `yaml:"dir_color"` +	BoxColor	string `yaml:"box_color"` +	HeadColor	string `yaml:"head_color"` +	ErrColor	string `yaml:"error_color"` +	TitleColor	string `yaml:"title_color"` +	BotColor	string `yaml:"bottom_color"` +	YankColor	string `yaml:"yank_color"` +	MoveColor	string `yaml:"move_color"` +} +  // this function recurses into the specified root directory in order to load  // every yaml file into memory  func c_recurse_data_dir(dir, root string, opts HardOpts, @@ -171,3 +183,7 @@ func c_get_options(dir string, load_err *[]error) HardOpts {  	return opts  } +func c_get_styles(dir string, load_err *[]error) HardStyle { +	// TODO: here +	return DEFAULT_STYLE +} diff --git a/src/i_ui.go b/src/i_ui.go index a27c602..f34d9ad 100644 --- a/src/i_ui.go +++ b/src/i_ui.go @@ -68,7 +68,7 @@ type Buffer struct {  type HardUI struct {  	s     tcell.Screen  	mode  uint8 -	style [MAX_STYLE + 1]tcell.Style +	style [STYLE_MAX + 1]tcell.Style  	dim   [2]int  	err   [2]string  	buff  Buffer @@ -691,34 +691,99 @@ func i_load_ui(data_dir string,  	return ldirs, litems, *load_err  } -func i_init_styles(ui *HardUI) { -	ui.style[DEF_STYLE] = tcell.StyleDefault. -		Background(tcell.ColorReset). -		Foreground(tcell.ColorReset) -	ui.style[DIR_STYLE] = tcell.StyleDefault. -		Background(tcell.ColorReset). -		Foreground(tcell.ColorBlue).Dim(true).Bold(true) -	ui.style[BOX_STYLE] = tcell.StyleDefault. -		Background(tcell.ColorReset). -		Foreground(tcell.ColorReset) -	ui.style[HEAD_STYLE] = tcell.StyleDefault. -		Background(tcell.ColorReset). -		Foreground(tcell.ColorReset) -	ui.style[ERR_STYLE] = tcell.StyleDefault. -		Background(tcell.ColorReset). -		Foreground(tcell.ColorRed).Dim(true) -	ui.style[TITLE_STYLE] = tcell.StyleDefault. -		Background(tcell.ColorReset). -		Foreground(tcell.ColorBlue).Dim(true).Bold(true) -	ui.style[BOT_STYLE] = tcell.StyleDefault. -		Background(tcell.ColorReset). -		Foreground(tcell.ColorBlue).Dim(true) -	ui.style[YANK_STYLE] = tcell.StyleDefault. -		Background(tcell.ColorReset). -		Foreground(tcell.ColorYellow).Dim(true).Bold(true) -	ui.style[MOVE_STYLE] = tcell.StyleDefault. -		Background(tcell.ColorReset). -		Foreground(tcell.ColorRed).Dim(true).Bold(true) +func i_init_styles(ui *HardUI, styles HardStyle) { +	for i := 0; i < STYLE_MAX + 1; i++ { +		tmp := tcell.StyleDefault.Background(tcell.ColorReset) +		curr_color := "default" +		switch i { +		case DEF_STYLE: +			curr_color = styles.DefColor +		case DIR_STYLE: +			curr_color = styles.DirColor +		case BOX_STYLE: +			curr_color = styles.BoxColor +		case HEAD_STYLE: +			curr_color = styles.HeadColor +		case ERR_STYLE: +			curr_color = styles.ErrColor +		case TITLE_STYLE: +			curr_color = styles.TitleColor +		case BOT_STYLE: +			curr_color = styles.BotColor +		case YANK_STYLE: +			curr_color = styles.YankColor +		case MOVE_STYLE: +			curr_color = styles.MoveColor +		default: +			curr_color = "default" +		} +		switch curr_color { +		case COLORS[COLOR_DEFAULT]: +			ui.style[i] = tmp.Foreground(tcell.ColorReset) +		case COLORS[COLOR_BLACK]: +			ui.style[i] = tmp.Foreground(tcell.ColorBlack).Dim(true) +		case COLORS[COLOR_RED]: +			ui.style[i] = tmp.Foreground(tcell.ColorRed).Dim(true) +		case COLORS[COLOR_GREEN]: +			ui.style[i] = tmp.Foreground(tcell.ColorGreen) +		case COLORS[COLOR_YELLOW]: +			ui.style[i] = tmp.Foreground(tcell.ColorYellow).Dim(true) +		case COLORS[COLOR_BLUE]: +			ui.style[i] = tmp.Foreground(tcell.ColorBlue).Dim(true) +		case COLORS[COLOR_MAGENTA]: +			ui.style[i] = tmp.Foreground(tcell.ColorPurple).Dim(true) +		case COLORS[COLOR_CYAN]: +			ui.style[i] = tmp.Foreground(tcell.ColorTeal) +		case COLORS[COLOR_WHITE]: +			ui.style[i] = tmp.Foreground(tcell.ColorWhite).Dim(true) +		case COLORS[COLOR_BOLD_BLACK]: +			ui.style[i] = tmp.Foreground(tcell.ColorBlack).Dim(true).Bold(true) +		case COLORS[COLOR_BOLD_RED]: +			ui.style[i] = tmp.Foreground(tcell.ColorRed).Dim(true).Bold(true) +		case COLORS[COLOR_BOLD_GREEN]: +			ui.style[i] = tmp.Foreground(tcell.ColorGreen).Dim(true).Bold(true) +		case COLORS[COLOR_BOLD_YELLOW]: +			ui.style[i] = tmp.Foreground(tcell.ColorYellow).Dim(true).Bold(true) +		case COLORS[COLOR_BOLD_BLUE]: +			ui.style[i] = tmp.Foreground(tcell.ColorBlue).Dim(true).Bold(true) +		case COLORS[COLOR_BOLD_MAGENTA]: +			ui.style[i] = tmp.Foreground(tcell.ColorPurple).Dim(true).Bold(true) +		case COLORS[COLOR_BOLD_CYAN]: +			ui.style[i] = tmp.Foreground(tcell.ColorTeal).Dim(true).Bold(true) +		case COLORS[COLOR_BOLD_WHITE]: +			ui.style[i] = tmp.Foreground(tcell.ColorWhite).Dim(true).Bold(true) +		default: +			ui.style[i] = tmp.Foreground(tcell.ColorReset) +		} +	} + +	// ui.style[DEF_STYLE] = tcell.StyleDefault. +	// 	Background(tcell.ColorReset). +	// 	Foreground(tcell.ColorReset) +	// ui.style[DIR_STYLE] = tcell.StyleDefault. +	// 	Background(tcell.ColorReset). +	// 	Foreground(tcell.ColorBlue).Dim(true).Bold(true) +	// ui.style[BOX_STYLE] = tcell.StyleDefault. +	// 	Background(tcell.ColorReset). +	// 	Foreground(tcell.ColorReset) +	// ui.style[HEAD_STYLE] = tcell.StyleDefault. +	// 	Background(tcell.ColorReset). +	// 	Foreground(tcell.ColorReset) +	// ui.style[ERR_STYLE] = tcell.StyleDefault. +	// 	Background(tcell.ColorReset). +	// 	Foreground(tcell.ColorRed).Dim(true) +	// ui.style[TITLE_STYLE] = tcell.StyleDefault. +	// 	Background(tcell.ColorReset). +	// 	Foreground(tcell.ColorBlue).Dim(true).Bold(true) +	// ui.style[BOT_STYLE] = tcell.StyleDefault. +	// 	Background(tcell.ColorReset). +	// 	Foreground(tcell.ColorBlue).Dim(true) +	// ui.style[YANK_STYLE] = tcell.StyleDefault. +	// 	Background(tcell.ColorReset). +	// 	Foreground(tcell.ColorYellow).Dim(true).Bold(true) +	// ui.style[MOVE_STYLE] = tcell.StyleDefault. +	// 	Background(tcell.ColorReset). +	// 	Foreground(tcell.ColorRed).Dim(true).Bold(true)  }  type key_event_mode_func func(*HardData, *HardUI, tcell.EventKey) bool @@ -736,8 +801,6 @@ func i_ui(data_dir string) {  	if err := ui.s.Init(); err != nil {  		c_die("view", err)  	} -	i_init_styles(&ui) -	ui.s.SetStyle(ui.style[DEF_STYLE])  	ui.dim[W], ui.dim[H], _ = term.GetSize(0)  	var load_err []error  	conf_dir  := c_get_conf_dir(&load_err) @@ -746,12 +809,16 @@ func i_ui(data_dir string) {  	} else {  		opts = c_get_options(conf_dir, &load_err)  	} +	styles := c_get_styles(conf_dir, &load_err) +	i_init_styles(&ui, styles) +	ui.s.SetStyle(ui.style[DEF_STYLE])  	ldirs, litems, load_err := i_load_ui(data_dir, opts, &ui, &load_err)  	data := HardData{  		litems,  		ldirs,  		ui,  		opts, +		styles,  		make(map[*DirsNode]*ItemsList),  		data_dir,  		home_dir, | 
