This commit is contained in:
nemunaire 2021-02-13 18:34:44 +01:00
commit 2f4cc04db2
7 changed files with 30 additions and 29 deletions

View file

@ -18,7 +18,7 @@ func goLogin(stdscr *gc.Window, in chan gc.Key) (string, string, bool) {
}(username, password, validator, validator_err)
if connection(stdscr, in, validator, validator_err) {
e := <- validator_err
e := <-validator_err
return username, e.Error(), true
} else {
return goLogin(stdscr, in)

View file

@ -3,10 +3,11 @@ package main
import (
"strings"
"time"
gc "github.com/rthornton128/goncurses"
)
func login(stdscr *gc.Window, in chan gc.Key) (username , password string) {
func login(stdscr *gc.Window, in chan gc.Key) (username, password string) {
gc.Cursor(1)
stdscr.Clear()
@ -75,7 +76,7 @@ func login(stdscr *gc.Window, in chan gc.Key) (username , password string) {
login:
for {
select {
case ch := <- in:
case ch := <-in:
switch ch {
case gc.KEY_DOWN, gc.KEY_TAB:
form.Driver(gc.REQ_NEXT_FIELD)
@ -144,16 +145,16 @@ func connection(stdscr *gc.Window, in chan gc.Key, validator chan bool, validato
loginloop:
for {
select {
case ch := <- in:
case ch := <-in:
if gc.Char(ch) == gc.Char('r') {
break loginloop
}
case st := <- validator:
case st := <-validator:
if st {
canContinue = true
break loginloop
} else {
e := <- validator_err
e := <-validator_err
mainwin.ColorOn(4)
mainwin.MovePrint(4, 2, e.Error())
@ -162,19 +163,19 @@ loginloop:
mainwin.MovePrint(6, 2, " Press any key to retry ")
mainwin.Refresh()
<- in
<-in
break loginloop
}
case <- ticker.C:
case <-ticker.C:
switch rotPos += 1; rotPos {
case 0,4:
case 0, 4:
mainwin.MovePrint(4, 4, "|")
case 1,5:
case 1, 5:
mainwin.MovePrint(4, 4, "/")
case 2,6:
case 2, 6:
mainwin.MovePrint(4, 4, "-")
case 3,7:
case 3, 7:
mainwin.MovePrint(4, 4, "\\")
default:
mainwin.MovePrint(4, 4, "|")
@ -235,8 +236,8 @@ func okreboot(stdscr *gc.Window, login string, ip string) {
rebootloop:
for {
select {
case <- ticker.C:
mainwin.MovePrint(11, 3 + pos, "*")
case <-ticker.C:
mainwin.MovePrint(11, 3+pos, "*")
pos += 1
if pos > 36 {
break rebootloop