   func tellSize() -> TellSize
 
   func draw(x: Int, y: Int, size: TellSize)
+
+  func drawBorder(x: Int, y: Int, size: TellSize) -> NCPoint
+}
+
+
+extension NCElement {
+
+  public func drawBorder(x: Int, y: Int, size: TellSize) -> NCPoint {
+    let w = size.width
+    let h = size.height
+    if w <= 0 || h <= 0 {
+      return NCPoint.far
+    }
+    var ny = y
+    var nx = x
+    var borderHeight = h
+    if borderTop {
+      var si = 0
+      var ei = w
+      if borderRight {
+        move(Int32(ny), Int32(nx + w - 1))
+        addstr("╮")
+        ei -= 1
+      }
+      move(Int32(ny), Int32(nx))
+      if borderLeft {
+        addstr("╭")
+        si += 1
+      }
+      for _ in si..<ei {
+        addstr("─")
+      }
+      ny += 1
+      borderHeight -= 1
+    }
+    if borderBottom {
+      borderHeight -= 1
+      var si = 0
+      var ei = w
+      if borderRight {
+        move(Int32(ny + borderHeight), Int32(nx + w - 1))
+        addstr("╯")
+        ei -= 1
+      }
+      move(Int32(ny + borderHeight), Int32(nx))
+      if borderLeft {
+        addstr("╰")
+        si += 1
+      }
+      for _ in si..<ei {
+        addstr("─")
+      }
+    }
+    if borderRight {
+      let ei = ny + borderHeight
+      let bx = nx + w - 1
+      for i in ny..<ei {
+        move(Int32(i), Int32(bx))
+        addstr("│")
+      }
+    }
+    if borderLeft {
+      let ei = ny + borderHeight
+      for i in ny..<ei {
+        move(Int32(i), Int32(nx))
+        addstr("│")
+      }
+      nx += 1
+    }
+    return NCPoint(x: nx, y: ny)
+  }
+
 }
 
 

        NC.pd("direct \(v)")
      }
    }
    children.append(r)
    return r
  }

  public func tellSize() -> TellSize {


public enum NCBorderType {
  case LightCurved
}


public struct NCPoint {
  public var x: Int
  public var y: Int

  static let far = NCPoint(x: -10000, y: 0)
}


