|
@@ -1,6 +1,7 @@
|
|
|
package main
|
|
|
|
|
|
import (
|
|
|
+ "bytes"
|
|
|
"fmt"
|
|
|
"red-green/door"
|
|
|
"strconv"
|
|
@@ -9,7 +10,7 @@ import (
|
|
|
)
|
|
|
|
|
|
func display_information(d *door.Door) {
|
|
|
- d.Write(door.Clrscr)
|
|
|
+ d.WriteS(door.Clrscr)
|
|
|
|
|
|
var headerColor string = door.ColorText("BRI CYAN")
|
|
|
var keyColor string = door.ColorText("BRI GREEN")
|
|
@@ -24,53 +25,53 @@ func display_information(d *door.Door) {
|
|
|
var header string = "DropFile: "
|
|
|
offset = strings.Repeat(" ", len(header))
|
|
|
|
|
|
- d.Write(headerColor + header)
|
|
|
- d.Write(nice_format("Comm Type", strconv.Itoa(d.Config.Comm_type)))
|
|
|
+ d.WriteA(headerColor, header)
|
|
|
+ d.WriteA(nice_format("Comm Type", strconv.Itoa(d.Config.Comm_type)))
|
|
|
|
|
|
if d.Config.BBSID != "" {
|
|
|
- d.Write(offset + nice_format("BBS Software", d.Config.BBSID))
|
|
|
+ d.WriteA(offset, nice_format("BBS Software", d.Config.BBSID))
|
|
|
}
|
|
|
- d.Write(offset + nice_format("Time Left", strconv.Itoa(d.Config.Time_left)))
|
|
|
- d.Write(offset + nice_format("Real Name", d.Config.Real_name))
|
|
|
+ d.WriteA(offset, nice_format("Time Left", strconv.Itoa(d.Config.Time_left)))
|
|
|
+ d.WriteA(offset, nice_format("Real Name", d.Config.Real_name))
|
|
|
// d.Write(nice_format("Comm Handle", strconv.Itoa(d.Config.Comm_handle)))
|
|
|
- d.Write(offset + nice_format("Handle", d.Config.Handle))
|
|
|
- d.Write(offset + nice_format("User #", strconv.Itoa(d.Config.User_number)))
|
|
|
- d.Write(offset + nice_format("Security Level", strconv.Itoa(d.Config.Security_level)))
|
|
|
- d.Write(offset + nice_format("Node #", strconv.Itoa(d.Config.Node)))
|
|
|
+ d.WriteA(offset, nice_format("Handle", d.Config.Handle))
|
|
|
+ d.WriteA(offset, nice_format("User #", strconv.Itoa(d.Config.User_number)))
|
|
|
+ d.WriteA(offset, nice_format("Security Level", strconv.Itoa(d.Config.Security_level)))
|
|
|
+ d.WriteA(offset, nice_format("Node #", strconv.Itoa(d.Config.Node)))
|
|
|
|
|
|
header = "Detected: "
|
|
|
offset = strings.Repeat(" ", len(header))
|
|
|
- d.Write(door.CRNL + headerColor + header)
|
|
|
- d.Write(nice_format("Unicode", strconv.FormatBool(door.Unicode)))
|
|
|
- d.Write(offset + nice_format("CP437", strconv.FormatBool(door.CP437)))
|
|
|
- d.Write(offset + nice_format("Full CP437", strconv.FormatBool(door.Full_CP437)))
|
|
|
- d.Write(offset + nice_format("Screen Size", fmt.Sprintf("%d X %d", door.Width, door.Height)))
|
|
|
+ d.WriteA(door.CRNL, headerColor, header)
|
|
|
+ d.WriteA(nice_format("Unicode", strconv.FormatBool(door.Unicode)))
|
|
|
+ d.WriteA(offset, nice_format("CP437", strconv.FormatBool(door.CP437)))
|
|
|
+ d.WriteA(offset, nice_format("Full CP437", strconv.FormatBool(door.Full_CP437)))
|
|
|
+ d.WriteA(offset, nice_format("Screen Size", fmt.Sprintf("%d X %d", door.Width, door.Height)))
|
|
|
var time time.Duration = d.TimeLeft()
|
|
|
- d.Write(offset + nice_format("Door Time Left", fmt.Sprintf("%d Hours, %d Minutes, %d Seconds", int(time.Hours()), int(time.Minutes())%60, int(time.Seconds())%60)))
|
|
|
+ d.WriteA(offset, nice_format("Door Time Left", fmt.Sprintf("%d Hours, %d Minutes, %d Seconds", int(time.Hours()), int(time.Minutes())%60, int(time.Seconds())%60)))
|
|
|
time = d.TimeUsed()
|
|
|
- d.Write(offset + nice_format("Door Time Used", fmt.Sprintf("%d Minutes, %d Seconds", int(time.Minutes()), int(time.Seconds())%60)))
|
|
|
+ d.WriteA(offset, nice_format("Door Time Used", fmt.Sprintf("%d Minutes, %d Seconds", int(time.Minutes()), int(time.Seconds())%60)))
|
|
|
press_a_key(d)
|
|
|
|
|
|
- d.Write(door.Clrscr + door.CRNL + door.CRNL + door.CRNL)
|
|
|
+ d.WriteA(door.Clrscr, door.CRNL, door.CRNL, door.CRNL)
|
|
|
modules := GetModules()
|
|
|
header = "Build: "
|
|
|
offset = strings.Repeat(" ", len(header))
|
|
|
- d.Write(headerColor + header)
|
|
|
+ d.WriteA(headerColor, header)
|
|
|
gover, gitver, goarch, goos := GetVersion()
|
|
|
- d.Write(nice_format("go version", gover))
|
|
|
- d.Write(offset + nice_format("git commit", gitver))
|
|
|
- d.Write(offset + nice_format("Arch", goarch))
|
|
|
- d.Write(offset + nice_format("OS", goos))
|
|
|
+ d.WriteA(nice_format("go version", gover))
|
|
|
+ d.WriteA(offset, nice_format("git commit", gitver))
|
|
|
+ d.WriteA(offset, nice_format("Arch", goarch))
|
|
|
+ d.WriteA(offset, nice_format("OS", goos))
|
|
|
for mod, version := range modules {
|
|
|
- d.Write(offset + nice_format(mod, version))
|
|
|
+ d.WriteA(offset, nice_format(mod, version))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func display_ansi(d *door.Door) {
|
|
|
var art []string = ANSIGrowl()
|
|
|
- d.Write(door.Clrscr)
|
|
|
+ d.WriteS(door.Clrscr)
|
|
|
for _, line := range art {
|
|
|
- d.Write(line + door.CRNL)
|
|
|
+ d.WriteS(line + door.CRNL)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -86,30 +87,32 @@ func input_demo(d *door.Door) {
|
|
|
|
|
|
case t := <-ticker.C:
|
|
|
const tf = "January 2, 2006 03:04:05 PM MST"
|
|
|
- output := door.SavePos + door.Goto(5, 2) + door.ColorText("BRI WHI ON CYAN") + t.Format(tf) + door.RestorePos
|
|
|
- d.Write(output)
|
|
|
+ output := door.SavePos + door.GotoS(5, 2) + door.ColorText("BRI WHI ON CYAN") + t.Format(tf) + door.RestorePos
|
|
|
+ d.WriteS(output)
|
|
|
}
|
|
|
}
|
|
|
}()
|
|
|
|
|
|
var inputColor string = door.ColorText("BRI WHI ON BLUE")
|
|
|
var inputColor2 string = door.ColorText("BRI WHI ON GREEN")
|
|
|
- var prompt door.Line = door.Line{Text: "What is YOUR Name: "}
|
|
|
+ var prompt door.Line = door.NewLine("What is YOUR Name: ")
|
|
|
prompt.RenderF = door.RenderBlueYellow
|
|
|
- d.Write(prompt.Output() + inputColor)
|
|
|
+ d.WriteA(prompt.Output(), inputColor)
|
|
|
var name string = d.Input(25)
|
|
|
- d.Write(door.Reset + door.CRNL)
|
|
|
- prompt.Text = "What is Your Quest: "
|
|
|
- d.Write(prompt.Output() + inputColor2)
|
|
|
+ d.WriteA(door.Reset, door.CRNL)
|
|
|
+ prompt.Text.Reset()
|
|
|
+ prompt.Text.WriteString("What is Your Quest:")
|
|
|
+ d.WriteA(prompt.Output(), inputColor2)
|
|
|
var quest string = d.Input(35)
|
|
|
- d.Write(door.Reset + door.CRNL)
|
|
|
- prompt.Text = "What is your Favorite CoLoR: "
|
|
|
- d.Write(prompt.Output() + inputColor)
|
|
|
+ d.WriteA(door.Reset, door.CRNL)
|
|
|
+ prompt.Text.Reset()
|
|
|
+ prompt.Text.WriteString("What is your Favorite CoLoR: ")
|
|
|
+ d.WriteA(prompt.Output(), inputColor)
|
|
|
var color string = d.Input(15)
|
|
|
- d.Write(door.Reset + door.CRNL)
|
|
|
+ d.WriteA(door.Reset, door.CRNL)
|
|
|
ticker.Stop()
|
|
|
StopIt <- true
|
|
|
- d.Write(fmt.Sprintf("You're %s on the %s quest, and fond of %s."+door.CRNL, name, quest, color))
|
|
|
+ d.WriteA(fmt.Sprintf("You're %s on the %s quest, and fond of %s."+door.CRNL, name, quest, color))
|
|
|
}
|
|
|
|
|
|
func pctUpdate(pct *int64) func() int64 {
|
|
@@ -119,7 +122,7 @@ func pctUpdate(pct *int64) func() int64 {
|
|
|
}
|
|
|
|
|
|
func progress_bars(d *door.Door) {
|
|
|
- d.Write(door.Clrscr)
|
|
|
+ d.WriteA(door.Clrscr)
|
|
|
|
|
|
var barHalf door.BarLine = door.BarLine{Line: door.Line{DefaultColor: door.ColorText("BOLD YELLOW")}, Width: 20, Style: door.HALF_STEP}
|
|
|
var barPercent door.BarLine = door.BarLine{Width: 30, Style: door.SOLID, PercentStyle: door.PERCENT_SPACE}
|
|
@@ -144,20 +147,20 @@ func progress_bars(d *door.Door) {
|
|
|
barGradient.Update()
|
|
|
}
|
|
|
|
|
|
- d.Write(door.Goto(3, 12) + "Half-Step")
|
|
|
- d.Write(door.Goto(25, 12) + "% with space and Color Range")
|
|
|
- d.Write(door.Goto(57, 12) + "Gradient")
|
|
|
- d.Write(door.HideCursor)
|
|
|
+ d.WriteA(door.Goto(3, 12), "Half-Step")
|
|
|
+ d.WriteA(door.Goto(25, 12), "% with space and Color Range")
|
|
|
+ d.WriteA(door.Goto(57, 12), "Gradient")
|
|
|
+ d.WriteA(door.HideCursor)
|
|
|
|
|
|
bar_start := door.Goto(3, 15)
|
|
|
|
|
|
for f := 0; f <= 100; f++ {
|
|
|
|
|
|
- d.Write(door.Goto(3, 10) + door.Reset + fmt.Sprintf("Value: %d", f))
|
|
|
+ d.WriteA(door.Goto(3, 10), door.Reset+fmt.Sprintf("Value: %d", f))
|
|
|
percentage = int64(f * 100)
|
|
|
|
|
|
update_bars()
|
|
|
- d.Write(bar_start + barHalf.Output() + " " + door.Reset + barPercent.Output() + door.Reset + " " + barGradient.Output())
|
|
|
+ d.WriteA(bar_start, barHalf.Output(), " ", door.Reset, barPercent.Output(), door.Reset+" ", barGradient.Output())
|
|
|
|
|
|
if d.Disconnect() {
|
|
|
// don't continue to sleep if we're disconnected
|
|
@@ -166,7 +169,7 @@ func progress_bars(d *door.Door) {
|
|
|
|
|
|
time.Sleep(time.Millisecond * 100)
|
|
|
}
|
|
|
- d.Write(door.ShowCursor)
|
|
|
+ d.WriteA(door.ShowCursor)
|
|
|
}
|
|
|
|
|
|
func width_demo(d *door.Door) {
|
|
@@ -191,7 +194,7 @@ func width_demo(d *door.Door) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- var l door.Line = door.Line{Text: line, DefaultColor: lineColor}
|
|
|
+ var l door.Line = door.Line{Text: bytes.NewBuffer([]byte(line)), DefaultColor: lineColor}
|
|
|
panel.Lines = append(panel.Lines, l)
|
|
|
}
|
|
|
var message string = fmt.Sprintf("Screen Size: %d X %d", door.Width, door.Height)
|
|
@@ -202,11 +205,11 @@ func width_demo(d *door.Door) {
|
|
|
cx = (door.Width - len(message) + 2) / 2
|
|
|
cy = (door.Height - 3) / 2
|
|
|
var alert []string = door.AlertBox(message, 1)
|
|
|
- d.Write(door.ColorText("BRI YEL ON BLUE"))
|
|
|
+ d.WriteA(door.ColorText("BRI YEL ON BLUE"))
|
|
|
for idx, ab := range alert {
|
|
|
- d.Write(door.Goto(cx, cy+idx) + ab)
|
|
|
+ d.WriteA(door.Goto(cx, cy+idx), ab)
|
|
|
}
|
|
|
- d.Write(door.Reset + panel.GotoEnd())
|
|
|
+ d.WriteA(door.Reset, panel.GotoEnd())
|
|
|
|
|
|
// Pause for key
|
|
|
d.WaitKey(door.Inactivity)
|
|
@@ -224,7 +227,7 @@ func width_demo(d *door.Door) {
|
|
|
line += background[0 : w-len(line)]
|
|
|
}
|
|
|
}
|
|
|
- var l door.Line = door.Line{Text: line, RenderF: door.RenderBlueYellow}
|
|
|
+ var l door.Line = door.Line{Text: bytes.NewBuffer([]byte(line)), RenderF: door.RenderBlueYellow}
|
|
|
panel.Lines = append(panel.Lines, l)
|
|
|
}
|
|
|
d.Write(panel.Output())
|