|
@@ -60,6 +60,7 @@ func MainMenu() door.Menu {
|
|
|
m.AddSelection("M", "Menu Demo")
|
|
|
m.AddSelection("P", "Progress Bars Demo")
|
|
|
m.AddSelection("S", "Show Panel")
|
|
|
+ m.AddSelection("W", "Screen Width")
|
|
|
|
|
|
m.AddSelection("Q", "Quit")
|
|
|
return m
|
|
@@ -342,6 +343,63 @@ func progress_bars(d *door.Door) {
|
|
|
d.Write(door.ShowCursor)
|
|
|
}
|
|
|
|
|
|
+func width_demo(d *door.Door) {
|
|
|
+ w := door.Width
|
|
|
+ panel := door.Panel{X: 1, Y: 1, Width: w}
|
|
|
+ lineColor := door.ColorText("WHI")
|
|
|
+ var line string
|
|
|
+
|
|
|
+ for y := 1; y <= door.Height; y++ {
|
|
|
+ if y%10 == 0 {
|
|
|
+ line = strings.Repeat("1234567890", w/10)
|
|
|
+ for x := len(line); x < w; x++ {
|
|
|
+ line += strconv.Itoa(x % 10)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ line = ""
|
|
|
+ for x := 1; x < w; x++ {
|
|
|
+ if x%10 == 0 {
|
|
|
+ line += strconv.Itoa(y % 10)
|
|
|
+ } else {
|
|
|
+ line += " "
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ l := door.Line{Text: line, DefaultColor: lineColor}
|
|
|
+ panel.Lines = append(panel.Lines, l)
|
|
|
+ }
|
|
|
+ message := fmt.Sprintf("Screen Size: %d X %d", door.Width, door.Height)
|
|
|
+ alert := door.AlertBox(message, 1)
|
|
|
+ d.Write(panel.Output())
|
|
|
+ cx := (door.Width - len(message) + 2) / 2
|
|
|
+ cy := (door.Height - 3) / 2
|
|
|
+ d.Write(door.ColorText("BRI YEL ON BLUE"))
|
|
|
+ for idx, ab := range alert {
|
|
|
+ d.Write(door.Goto(cx, cy+idx) + ab)
|
|
|
+ }
|
|
|
+ d.Write(door.Reset + panel.GotoEnd())
|
|
|
+ _ = d.Key()
|
|
|
+
|
|
|
+ panel.Lines = make([]door.Line, 0)
|
|
|
+ background := "BUGZ Test Door in GO "
|
|
|
+ bl := len(background)
|
|
|
+ for y := 1; y <= door.Height; y++ {
|
|
|
+ offset := (y - 1) % bl
|
|
|
+ line = background[offset:]
|
|
|
+ for len(line) < w {
|
|
|
+ if len(line)+bl <= w {
|
|
|
+ line += background
|
|
|
+ } else {
|
|
|
+ line += background[0 : w-len(line)]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ l := door.Line{Text: line, RenderF: door.RenderBlueYellow}
|
|
|
+ panel.Lines = append(panel.Lines, l)
|
|
|
+ }
|
|
|
+ d.Write(panel.Output())
|
|
|
+ _ = d.Key()
|
|
|
+}
|
|
|
+
|
|
|
func panel_demo(d *door.Door) {
|
|
|
width := 55
|
|
|
fmtStr := "%-55s"
|
|
@@ -451,6 +509,8 @@ func main() {
|
|
|
case 'S':
|
|
|
panel_demo(&d)
|
|
|
press_a_key(&d)
|
|
|
+ case 'W':
|
|
|
+ width_demo(&d)
|
|
|
case 'Q':
|
|
|
choice = -1
|
|
|
break
|