Skip to content

Terminal Interface

Aaron Santos edited this page Apr 25, 2016 · 5 revisions

Methods

Terminal interface

;; Methods suffixed with ! indicate a change of state within the terminal. refresh! and destroy! are not transaction-safe and must not be called from within a transaction.
(defprotocol Terminal
  ;; Returns the arguments passed to create-terminal."
  (args [this] )

  ;; Change the [x y] position of a layer group. `x` and `y` are measured in pixels from the upper left corner of the screen.
  (alter-group-pos! [this group-id pos-fn])

  ;; Changes the font for a layer group. `font-fn` is a function that takes one argument: one of :linux :macosx or :windows, and returns a font.
  (alter-group-font! [this group-id font-fn])

  ;; Add characters to the back buffer
  ; Layer id  must match one of the layers specified in `create-terminal`s `group-map` parameter
  ; Characters is a vector of maps each with these keys
  ; {:c \a             ; The character to place
  ;  :fg [255 255 255] ; [red green blue] foreground color. (0-255)
  ;  :bg [0 0 0]       ; [red green blue] background color. (0-255)
  ;  :x  0             ; column to place the character
  ;  :y  0             ; row to place the character
  ; The terminal coordinate system is layed out like this
  ; (0, 0)          (cols, 0)
  ;  +---------------+
  ;  |               |
  ;  |               |
  ;  |               |
  ;  +---------------+
  ; (0, rows)          (cols, rows)
  (put-chars! [this layer-id characters])

  ;; Changes the foreground color of a character in a layer.
  (set-fg! [this layer-id x y fg])

  ;; Changes the background color of a character in a layer.
  (set-bg! [this layer-id x y bg])

  ;; Changes the value of a uniform variable in the post-processing shader.
  (assoc-shader-param! [this k v])

  ;; Returns a clojure.core.async publication partitioned into these topics: :keypress :mouse-down :mouse-up :click :mouse-leave :mouse-enter :close.
  (pub [this])

  ;; Uses group and layer information to draw to the screen.
  (refresh! [this])

  ;; Clears all layers or just a specific layer.
  (clear! [this]
          [this layer-id])

  ;; Changes the terminal to fullscreen mode if v is a value returned by fullscreen-sizes. If false is supplied the terminal will revert to windowed mode.
  (fullscreen! [this v] "")

  ;; Returns a list of fullscreen values.
  (fullscreen-sizes [this])

  ;; Overrides the forecround color of a character.
  (set-fx-fg! [this layer-id x y fg])

  ;; Overrides the background color of a character.
  (set-fx-bg! [this layer-id x y bg])

  ;; Overrides the character on a layer.
  (set-fx-char! [this layer-id x y c])

  ;; Clears all of the fx overrides or just those for a layer.
  (clear-fx! [this]
             [this layer-id])

  ;; Stops the terminal, and closes the window.
  ;; Sends a :close event to the terminal's event subscribers.
  (destroy! [this] ""))
Clone this wiki locally