diff options
Diffstat (limited to '')
| -rw-r--r-- | src/c_defs.go | 6 | ||||
| -rw-r--r-- | src/c_init.go | 4 | ||||
| -rw-r--r-- | src/i_events.go | 12 | ||||
| -rw-r--r-- | src/i_ui.go | 37 | 
4 files changed, 42 insertions, 17 deletions
| diff --git a/src/c_defs.go b/src/c_defs.go index 6cb8e05..a096e52 100644 --- a/src/c_defs.go +++ b/src/c_defs.go @@ -65,10 +65,8 @@ const (  !s: search -  [C-r]: reload  !?: help` -	DELETE_KEYS_HINTS = `q: quit - -y: yes - -n: no` -	ERROR_KEYS_HINTS = "[Enter] Ok" +	ERROR_KEYS_HINTS = "[Enter]: Ok" +	CONFIRM_KEYS_HINTS = `y/n: yes - no`  )  const ( diff --git a/src/c_init.go b/src/c_init.go index a9da6c5..beeb80d 100644 --- a/src/c_init.go +++ b/src/c_init.go @@ -85,7 +85,7 @@ func c_recurse_data_dir(dir, root string, opts HardOpts,  		nil,  	}  	ldirs.add_back(&dir_node) -	i_draw_load_ui(ui) +	i_draw_load_ui(ui, opts)  	for _, file := range files {  		filename := file.Name()  		if file.IsDir() == true { @@ -103,7 +103,7 @@ func c_recurse_data_dir(dir, root string, opts HardOpts,  				}  				dir_node.lhost.add_back(host_node)  			} -			i_draw_load_ui(ui) +			i_draw_load_ui(ui, opts)  		}  	}  } diff --git a/src/i_events.go b/src/i_events.go index 4a82404..38d0643 100644 --- a/src/i_events.go +++ b/src/i_events.go @@ -53,7 +53,6 @@ package main  import (  	"os" -	"fmt"  	"github.com/gdamore/tcell/v2"  	"golang.org/x/term" @@ -297,7 +296,8 @@ func i_events(data *HardData) {  					  event.Key() == tcell.KeyEnd {  				data.litems.curr = data.litems.last  			} else if event.Rune() == 'D' && -					  data.ldirs.head != nil { +					  data.litems.head != nil && +					  data.litems.curr != nil {  				ui.mode = DELETE_MODE  			} else if event.Rune() == 'l' ||  					  event.Key() == tcell.KeyEnter { @@ -330,7 +330,6 @@ func i_events(data *HardData) {  		case DELETE_MODE:  			if event.Key() == tcell.KeyEscape ||  			   event.Key() == tcell.KeyCtrlC || -			   event.Rune() == 'q' ||  			   event.Rune() == 'n' {  				ui.mode = NORMAL_MODE  			} else if event.Key() == tcell.KeyEnter || @@ -357,9 +356,14 @@ func i_events(data *HardData) {  					break  				} else {  					data.opts.GPG = data.keys[event.Rune() - 48 - 1][0] +					ui.s.HideCursor()  				}  			} else { -				// TODO: confirm +				if event.Rune() == 'y' { +					ui.mode = NORMAL_MODE +				} else if event.Rune() == 'n' { +					data.opts.GPG = "" +				}  			}  		}	 diff --git a/src/i_ui.go b/src/i_ui.go index b0cea23..97921e0 100644 --- a/src/i_ui.go +++ b/src/i_ui.go @@ -166,19 +166,24 @@ func i_draw_msg(s tcell.Screen, lines int, box_style tcell.Style,  		box_style, title)  } -func i_draw_bottom_text(ui HardUI) { +func i_draw_bottom_text(ui HardUI, opts HardOpts) {  	text := ""  	switch ui.mode {  	case NORMAL_MODE:  		text = NORMAL_KEYS_HINTS  	case DELETE_MODE: -		text = DELETE_KEYS_HINTS +		text = CONFIRM_KEYS_HINTS  	case LOAD_MODE:  		text = "Loading..."  	case ERROR_MODE:  		text = ERROR_KEYS_HINTS  	case WELCOME_MODE: +		if len(opts.GPG) > 0 { +			text = CONFIRM_KEYS_HINTS +		} else { +			text = "" +		}  	default:  		text = ""  	} @@ -275,7 +280,7 @@ func i_prompt_gpg(ui HardUI, keys [][2]string) {  	if lines == 1 {  		lines = 2  	} -	i_draw_msg(ui.s, lines, ui.style[STYLE_DEF], ui.dim, " GnuPG keys ") +	i_draw_msg(ui.s, lines, ui.style[STYLE_BOX], ui.dim, " GnuPG keys ")  	for k, v := range keys {  		text := ""  		if v[0] != "plain" { @@ -299,6 +304,25 @@ func i_prompt_gpg(ui HardUI, keys [][2]string) {  	ui.s.ShowCursor(6 + len(ui.buff), ui.dim[H] - 1)  } +func i_prompt_confirm_gpg(ui HardUI, opts HardOpts) { +	if opts.GPG == "plain" { +		i_draw_msg(ui.s, 1, ui.style[STYLE_BOX], ui.dim, " Confirm plaintext ") +		text := "Really use plaintext to store passwords?" +		l, r := i_left_right(len(text), &ui) +		i_draw_text(ui.s, l, ui.dim[H] - 3, r, ui.dim[H] - 3, +			ui.style[STYLE_DEF], text) +		return +	} +	i_draw_msg(ui.s, 2, ui.style[STYLE_BOX], ui.dim, " Confirm GnuPG key ") +	text := "Really use this gpg key?" +	l, r := i_left_right(len(text), &ui) +	i_draw_text(ui.s, l, ui.dim[H] - 4, r, ui.dim[H] - 4, +		ui.style[STYLE_DEF], text) +	l, r = i_left_right(len(opts.GPG), &ui) +	i_draw_text(ui.s, l, ui.dim[H] - 3, r, ui.dim[H] - 3, +		ui.style[STYLE_DEF], opts.GPG) +} +  func i_draw_zhosts_box(ui HardUI) {  	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)" @@ -396,7 +420,7 @@ func i_draw_scrollhint(ui HardUI, litems *ItemsList) {  var g_load_count int = -1 -func i_draw_load_ui(ui *HardUI) { +func i_draw_load_ui(ui *HardUI, opts HardOpts) {  	g_load_count += 1  	if g_load_count % 1000 != 0 {  		return @@ -409,7 +433,7 @@ func i_draw_load_ui(ui *HardUI) {  	}  	i_draw_text(ui.s, 1, ui.dim[H] - 1, ui.dim[W], ui.dim[H] - 1,  		ui.style[STYLE_BOT], text) -	i_draw_bottom_text(*ui) +	i_draw_bottom_text(*ui, opts)  	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) @@ -507,7 +531,7 @@ func i_ui(data_dir string) {  	}  	for {  		data.ui.s.Clear() -		i_draw_bottom_text(data.ui) +		i_draw_bottom_text(data.ui, data.opts)  		i_draw_host_panel(data.ui, data.opts.Icon, data.litems, &data)  		i_draw_info_panel(data.ui, data.opts.Perc, data.litems)  		i_draw_scrollhint(data.ui, data.litems) @@ -520,7 +544,6 @@ func i_ui(data_dir string) {  				i_prompt_gpg(data.ui, data.keys)  			} else {  				i_prompt_confirm_gpg(data.ui, data.opts) -				// TODO: here  			}  		} else if data.litems.head == nil {  			i_draw_zhosts_box(data.ui) | 
