|
@@ -58,7 +58,7 @@ func about_test_door(d *door.Door) {
|
|
|
}
|
|
|
|
|
|
about.Lines = append(about.Lines,
|
|
|
- door.Line{Text: fmt.Sprintf("%*s", -W, copyright),
|
|
|
+ door.Line{Text: copyright, Width: W,
|
|
|
DefaultColor: door.ColorText("BOLD WHITE ON BLUE")})
|
|
|
for _, text := range []string{"",
|
|
|
"This door was written by Bugz.",
|
|
@@ -67,7 +67,7 @@ func about_test_door(d *door.Door) {
|
|
|
"to screen sizes, uses door32.sys, supports TheDraw Fonts",
|
|
|
"(the fonts are compiled into the door), has NoMoreSecrets",
|
|
|
"effect, and runs on Linux and Windows."} {
|
|
|
- about.Lines = append(about.Lines, door.Line{Text: fmt.Sprintf("%*s", -W, text)})
|
|
|
+ about.Lines = append(about.Lines, door.Line{Text: text, Width: W})
|
|
|
}
|
|
|
|
|
|
var better door.NoMoreSecretsConfig = door.NoMoreSecretsDefault
|
|
@@ -147,7 +147,7 @@ func MainMenu() door.Menu {
|
|
|
// Position the description panel beside the menu. m.Width + m.X + 2 (1 one to give it a space)
|
|
|
var descPanel door.Panel = door.Panel{X: menu.Width + menu.X + 2 + 1, Y: menu.Y, Width: panelWidth, Style: door.SINGLE, BorderColor: door.ColorText("WHI ON BLU")}
|
|
|
for x := 0; x < maxLines; x++ {
|
|
|
- descPanel.Lines = append(descPanel.Lines, door.Line{Text: ""})
|
|
|
+ descPanel.Lines = append(descPanel.Lines, door.Line{Text: "", Width: panelWidth})
|
|
|
}
|
|
|
|
|
|
menu.Activated = func(item int, d *door.Door) {
|
|
@@ -155,9 +155,9 @@ func MainMenu() door.Menu {
|
|
|
var lines []string = strings.Split(wordwrap.WrapString(line, uint(panelWidth)), "\n")
|
|
|
for idx, _ := range descPanel.Lines {
|
|
|
if idx >= len(lines) {
|
|
|
- descPanel.Lines[idx].Text = strings.Repeat(" ", panelWidth)
|
|
|
+ descPanel.Lines[idx].Text = ""
|
|
|
} else {
|
|
|
- descPanel.Lines[idx].Text = fmt.Sprintf("%-*s", panelWidth, lines[idx])
|
|
|
+ descPanel.Lines[idx].Text = lines[idx]
|
|
|
}
|
|
|
}
|
|
|
d.Write(door.SavePos + descPanel.Output() + door.RestorePos)
|
|
@@ -532,7 +532,6 @@ func width_demo(d *door.Door) {
|
|
|
|
|
|
func panel_demo(d *door.Door) {
|
|
|
var width int = 55
|
|
|
- var fmtStr string = "%-55s"
|
|
|
var p door.Panel = door.Panel{X: 5, Y: 5, Width: width, Style: door.DOUBLE, BorderColor: door.ColorText("CYAN ON BLUE"), Title: "[ Panel Demo ]"}
|
|
|
|
|
|
var lineColor string = door.ColorText("BRIGHT WHI ON BLUE")
|
|
@@ -541,26 +540,28 @@ func panel_demo(d *door.Door) {
|
|
|
if door.Unicode {
|
|
|
line = strings.Replace(line, "(C)", "\u00a9", -1)
|
|
|
}
|
|
|
- var l door.Line = door.Line{Text: fmt.Sprintf(fmtStr, line), DefaultColor: lineColor}
|
|
|
+ var l door.Line = door.Line{Text: line, Width: width, DefaultColor: lineColor}
|
|
|
p.Lines = append(p.Lines, l)
|
|
|
}
|
|
|
p.Lines = append(p.Lines, p.Spacer())
|
|
|
- p.Lines = append(p.Lines, door.Line{Text: fmt.Sprintf(fmtStr, "Welcome to golang!"), DefaultColor: lineColor})
|
|
|
+ p.Lines = append(p.Lines, door.Line{Text: "Welcome to golang!", Width: width, DefaultColor: lineColor})
|
|
|
|
|
|
- var single door.Panel = door.Panel{X: 6, Y: 12, Width: 10, Style: door.SINGLE, BorderColor: door.ColorText("WHITE ON BLUE"), Title: "< Single >"}
|
|
|
- single.Lines = append(single.Lines, door.Line{Text: "Example ", DefaultColor: door.ColorText("WHI ON BLACK")})
|
|
|
+ width = 10
|
|
|
+ var single door.Panel = door.Panel{X: 6, Y: 12, Width: width, Style: door.SINGLE, BorderColor: door.ColorText("WHITE ON BLUE"), Title: "< Single >"}
|
|
|
+ single.Lines = append(single.Lines, door.Line{Text: "Example", Width: width, DefaultColor: door.ColorText("WHI ON BLACK")})
|
|
|
single.Lines = append(single.Lines, single.Spacer())
|
|
|
- single.Lines = append(single.Lines, door.Line{Text: "More Text ", DefaultColor: door.ColorText("BRI GREEN ON BLACK")})
|
|
|
+ single.Lines = append(single.Lines, door.Line{Text: "More Text", Width: width, DefaultColor: door.ColorText("BRI GREEN ON BLACK")})
|
|
|
|
|
|
- var ds door.Panel = door.Panel{X: 26, Y: 12, Width: 15, Style: door.DOUBLE_SINGLE, BorderColor: door.ColorText("BRI CYAN ON GREEN"), Title: "Double", TitleOffset: 3}
|
|
|
- ds.Lines = append(ds.Lines, door.Line{Text: "Double / Single", DefaultColor: door.ColorText("BRI WHI ON GREEN")})
|
|
|
+ width = 15
|
|
|
+ var ds door.Panel = door.Panel{X: 26, Y: 12, Width: width, Style: door.DOUBLE_SINGLE, BorderColor: door.ColorText("BRI CYAN ON GREEN"), Title: "Double", TitleOffset: 3}
|
|
|
+ ds.Lines = append(ds.Lines, door.Line{Text: "Double / Single", Width: width, DefaultColor: door.ColorText("BRI WHI ON GREEN")})
|
|
|
ds.Lines = append(ds.Lines, ds.Spacer())
|
|
|
- ds.Lines = append(ds.Lines, door.Line{Text: "Some Other Text", DefaultColor: door.ColorText("BRI CYAN ON GREEN")})
|
|
|
+ ds.Lines = append(ds.Lines, door.Line{Text: "Some Other Text", Width: width, DefaultColor: door.ColorText("BRI CYAN ON GREEN")})
|
|
|
|
|
|
- var sd door.Panel = door.Panel{X: 46, Y: 12, Width: 15, Style: door.SINGLE_DOUBLE, BorderColor: door.ColorText("BRI YELL ON RED")}
|
|
|
- sd.Lines = append(sd.Lines, door.Line{Text: "Single / Double", DefaultColor: door.ColorText("BRI WHI ON RED")})
|
|
|
+ var sd door.Panel = door.Panel{X: 46, Y: 12, Width: width, Style: door.SINGLE_DOUBLE, BorderColor: door.ColorText("BRI YELL ON RED")}
|
|
|
+ sd.Lines = append(sd.Lines, door.Line{Text: "Single / Double", Width: width, DefaultColor: door.ColorText("BRI WHI ON RED")})
|
|
|
sd.Lines = append(sd.Lines, sd.Spacer())
|
|
|
- sd.Lines = append(sd.Lines, door.Line{Text: "Text Goes Here ", DefaultColor: door.ColorText("BRI GREEN ON RED")})
|
|
|
+ sd.Lines = append(sd.Lines, door.Line{Text: "Text Goes Here ", Width: width, DefaultColor: door.ColorText("BRI GREEN ON RED")})
|
|
|
|
|
|
d.Write(door.Clrscr)
|
|
|
d.Write(p.Output())
|
|
@@ -579,11 +580,12 @@ func main() {
|
|
|
|
|
|
defer func() {
|
|
|
if err := recover(); err != nil {
|
|
|
+ // This displays stack trace stderr
|
|
|
+ debug.PrintStack()
|
|
|
+ fmt.Println("ERROR:", err)
|
|
|
log.Println("FAILURE:", err)
|
|
|
// Display error to user
|
|
|
d.Write(fmt.Sprintf(door.Reset+door.CRNL+"Exception: %v"+door.CRNL, err))
|
|
|
- // This displays stack trace stderr
|
|
|
- debug.PrintStack()
|
|
|
}
|
|
|
}()
|
|
|
|