Browse Source

Clear panel.

Steve Thielemann 2 years ago
parent
commit
1c0734ace0
1 changed files with 26 additions and 0 deletions
  1. 26 0
      door/panel.go

+ 26 - 0
door/panel.go

@@ -44,6 +44,32 @@ func (p *Panel) Range(withBorder bool) (sx, sy, ex, ey int) {
 	return
 }
 
+// Clear out the panel
+func (p *Panel) Clear() string {
+	var style int = int(p.Style)
+	var output string
+	var row int = p.Y
+	var blank string
+
+	if style > 0 {
+		blank = strings.Repeat(" ", p.Width+2)
+		output += Goto(p.X, row) + blank
+		row++
+	} else {
+		blank = strings.Repeat(" ", p.Width)
+	}
+
+	for _ = range p.Lines {
+		output += Goto(p.X, row) + blank
+		row++
+	}
+
+	if style > 0 {
+		output += Goto(p.X, row) + blank
+	}
+	return output
+}
+
 // Output the panel
 func (p *Panel) Output() string {
 	var style int = int(p.Style)