Painter

public class Painter

The drawing context tracks the cursor position, and attribute in use during the View’s draw method, it enforced clipping on the view bounds.

Instances of this class are passed to a View‘s redraw method to paint

  • pos

    The current drawing column

    Declaration

    Swift

    public private(set) var pos: Point { get }
  • Undocumented

    Declaration

    Swift

    public var origin: Point
  • Undocumented

    Declaration

    Swift

    public var visible: Rect
  • The attribute used to draw

    Declaration

    Swift

    public var attribute: Attribute { get set }
  • This creates a painter, that renders into the Toplevel backing buffer

    Declaration

    Swift

    public static func createTopPainter(from top: Toplevel) -> Painter
  • Creates a new painter for the specified view, use this method when you want to create a painter to pass to the child view view, when you are in a redraw method, and you have been given the parent painter

    This creates the nested painter

    Declaration

    Swift

    public init(from view: View, parent: Painter)
  • Undocumented

    Declaration

    Swift

    public func colorNormal()
  • Undocumented

    Declaration

    Swift

    public func colorSelection()
  • Moves the drawing cursor position to the specified column and row.

    These values can be beyond the view’s frame and will be updated as print commands are done

    Declaration

    Swift

    public func goto(col: Int, row: Int)

    Parameters

    col

    the new column where the cursor will be.

    row

    the new row where the cursor will be.

  • Moves the drawing cursor position to the specified point.

    These values can be beyond the view’s frame and will be updated as print commands are done

    Declaration

    Swift

    public func go(to: Point)

    Parameters

    to

    the point that contains the new cursor position

  • Undocumented

    Declaration

    Swift

    public func add(str: String)
  • Undocumented

    Declaration

    Swift

    public func add(ch: Character)
  • Undocumented

    Declaration

    Swift

    public func add(rune: UnicodeScalar)
  • Clears the view region with the current color.

    Declaration

    Swift

    public func clear(with: Character = " ")
  • Clears the specified region in painter coordinates

    Declaration

    Swift

    public func clear(_ rect: Rect, with: Character = " ")

    Parameters

    rect

    the region to clear, the coordinates are relative to the view

  • Draws a frame on the specified region with the specified padding around the frame.

    Declaration

    Swift

    public func drawFrame(_ region: Rect, padding: Int, fill: Bool, double: Bool = false)

    Parameters

    region

    Region where the frame will be drawn.

    padding

    Padding to add on the sides

    fill

    If set to true it will clear the contents with the current color, otherwise the contents will be left untouched.

  • Utility function to draw strings that contains a hotkey using the two specified colors

    Declaration

    Swift

    public func drawHotString(text: String, hotColor: Attribute, normalColor: Attribute)

    Parameters

    text

    String to display, the underscoore before a letter flags the next letter as the hotkey.

    hotColor

    the color to use for the hotkey

    normalColor

    the color to use for the normal color

  • Utility function to draw strings that contains a hotkey using a colorscheme and the “focused” state.

    Declaration

    Swift

    public func drawHotString(text: String, focused: Bool, scheme: ColorScheme)

    Parameters

    text

    String to display, the underscoore before a letter flags the next letter as the hotkey.

    focused

    If set to true this uses the focused colors from the color scheme, otherwise the regular ones.

    scheme

    The color scheme to use

  • Undocumented

    Declaration

    Swift

    public func debug()