class RemiCharms::Window

Overview

A high-level representation of a curses window.

You can still call the lower-level bindings by using the #pointer field where necessary.

Defined in:

remicharms/window.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(width : Int, height : Int, startX : Int, startY : Int) #

Creates a new Window with the given width and height, starting at the coordinate (startX, startY).

Note that windows may not overlap.


[View source]
def self.standardWindow : Window #

Returns the stdscr in curses.


[View source]

Instance Method Detail

def attributeOff(attrs : Attribute) : Nil #

Turn off the attributes for this window without affecting any others.


[View source]
def attributeOff(*attrs : Attribute) : Nil #

Turn off the attributes for this window without affecting any others.


[View source]
def attributeOn(attrs : Attribute) : Nil #

Turn on the attributes for this window without affecting any others.


[View source]
def attributeOn(*attrs : Attribute) : Nil #

Turn on the attributes for this window without affecting any others.


[View source]
def border(topSide : Char, bottomSide : Char, leftSide : Char, rightSide : Char, upperLeft : Char, upperRight : Char, lowerLeft : Char, lowerRight : Char) : Nil #

Drawa a border around this window using the given characters. The characters must be ASCII-based.


[View source]
def border(topSide : Acs, bottomSide : Acs, leftSide : Acs, rightSide : Acs, upperLeft : Acs, upperRight : Acs, lowerLeft : Acs, lowerRight : Acs) : Nil #

Draws a border around this window using the given ACS characters.


[View source]
def border(topAndBottom : Char, leftAndRight, upperLeft : Char, upperRight : Char, lowerLeft : Char, lowerRight : Char) : Nil #

Drawa a border around this window using the given character. The same character is used for the top as the bottom, and the same for the left as the right. The characters must be ASCII-based.


[View source]
def border(topAndBottom : Acs, leftAndRight, upperLeft : Acs, upperRight : Acs, lowerLeft : Acs, lowerRight : Acs) : Nil #

Draws a border around this window using the given ACS characters. The same character is used for the top as the bottom, and the same for the left as the right.


[View source]
def border : Nil #

Draws a border around this window using the default ACS characters.


[View source]
def charAt(x : Int, y : Int) : Char #

Returns the character at the point (x, y) in this window.


[View source]
def charAt : Char #

Returns the character at the cursor in this window.


[View source]
def clear(repaint : Bool = false) : Nil #

Blank out the contents of this window. If repaint is true, then the window will be repainted entirely in the next refresh. Using this option can be more optimally performant than calling #forceRepaint manually.


[View source]
def clearAfterCursor : Nil #

Clear the rest of the window after the cursor.


[View source]
def clearLineAfterCursor : Nil #

Clear the rest of the line after the cursor.


[View source]
def cursorDown(delta : Int32 = 1) : Nil #

Moves the cursor in this window down by delta characters. A negative delta moves the cursor up instead.


[View source]
def cursorLeft(delta : Int32 = 1) : Nil #

Moves the cursor in this window left by delta characters. A negative delta moves the cursor right instead.


[View source]
def cursorPos : Tuple(Int32, Int32) #

Returns the X and Y coordinates of the cursor in this window, in that order.


[View source]
def cursorRight(delta : Int32 = 1) : Nil #

Moves the cursor in this window right by delta characters. A negative delta moves the cursor left instead.


[View source]
def cursorUp(delta : Int32 = 1) : Nil #

Moves the cursor in this window up by delta characters. A negative delta moves the cursor down instead.


[View source]
def destroy : Nil #

Destroys this window.


[View source]
def dup : Window #

Creates a copy of this window.


[View source]
def extraKeys=(value : Bool) : Nil #

Enable or disable extra keys, such as arrow and function keys, in this window.


[View source]
def finalize #

Cleans up the internal pointer if #destroy hasn't yet been called when this instance is garbage collected. If #destroy has been called, this does nothing.

See https://crystal-lang.org/reference/1.9/syntax_and_semantics/finalize.html for more details


[View source]
def forceRepaint : Nil #

Forces the entire window to be cleared and repainted on the next call to #refresh.


[View source]
def getChar(ignoreError : Bool = false) : Char | Nil #

Get a character from this window. In the event a character is not ready or could not be returned, this will raise an Error if ignoreError is false, or return nil otherwise.


[View source]
def getChar! : Char | Nil #

Same as #getChar, but the ignoreError parameter for it is always true.


[View source]
def hline(ch : Char, x : Int, y : Int, count : Int) : Nil #

Draws a horizontal line at the coordinates that is count characters wide using the given character. The character must be ASCII-based.


[View source]
def hline(ch : Acs, x : Int, y : Int, count : Int) : Nil #

Draws a horizontal line at the coordinates that is count characters wide using the given ACS character.


[View source]
def hline(x : Int, y : Int, count : Int) : Nil #

Draws a horizontal line at the coordinates that is count characters wide using Acs::Hline for the character.


[View source]
def hline(ch : Char, count : Int) : Nil #

Draws a horizontal line at the cursor that is count characters wide using the given character. The character must be ASCII-based.


[View source]
def hline(ch : Acs, count : Int) : Nil #

Draws a horizontal line at the cursor that is count characters wide using the given ACS character.


[View source]
def hline(count : Int) : Nil #

Draws a horizontal line at the cursor that is count characters wide using Acs::Hline for the character.


[View source]
def insert(ch : Char, x : Int, y : Int) : Nil #

Insert the character ch at the coordinates (x, y) within this window, advancing the rest of the line, without moving the cursor. This is akin to pressing the 'insert' key and typing a character.


[View source]
def insert(ch : Char) : Nil #

Insert the character ch at the cursor within this window, advancing the rest of the line, without moving the cursor. This is akin to pressing the 'insert' key and typing a character.


[View source]
def lastPos?(x : Int, y : Int) : Bool #

Returns true if the coordinate (x, y) is at the last position within this window, or false otherwise.


[View source]
def moveCursor(x : Int, y : Int) : Nil #

Moves the cursor in this window to the coordinates (x, y).


[View source]
def nonBlocking=(value : Bool) : Nil #

Enables or disables non-blocking mode for this window. When enabled, this will cause character input functions to not block and error (or return nil)."


[View source]
def pointer : NCurses::WindowPtr #

Pointer to the underlying representation of a window pointer. You can use this in calls to the lower-level bindings.


[View source]
def refresh : Nil #

Refresh the display of this window.


[View source]
def size : Tuple(Int32, Int32) #

Returns the width and height of this window, in that order.


[View source]
def vline(ch : Char, x : Int, y : Int, count : Int) : Nil #

Draws a vertical line at the coordinates that is count characters wide using the given character. The character must be ASCII-based.


[View source]
def vline(ch : Acs, x : Int, y : Int, count : Int) : Nil #

Draws a vertical line at the coordinates that is count characters wide using the given ACS character.


[View source]
def vline(x : Int, y : Int, count : Int) : Nil #

Draws a vertical line at the coordinates that is count characters wide using Acs::Vline for the character.


[View source]
def vline(ch : Char, count : Int) : Nil #

Draws a vertical line at the cursor that is count characters wide using the given character. The character must be ASCII-based.


[View source]
def vline(ch : Acs, count : Int) : Nil #

Draws a vertical line at the cursor that is count characters wide using the given ACS character.


[View source]
def vline(count : Int) : Nil #

Draws a vertical line at the cursor that is count characters wide using Acs::Vline for the character.


[View source]
def withAttributes(attrs : Attribute, &) : Nil #

Temporarily turns on the given attributes for this window in the block, then turns them off before returning.


[View source]
def withRestoredCursor(&) : Nil #

Records the current cursor position in this window, then yields. This will then ensure that the cursor is restored to its original position before calling this function.


[View source]
def write(ch : Char, x : Int, y : Int) : Nil #

Writes the character ch in this window at the coordinates (x, y).


[View source]
def write(str : String, x : Int, y : Int) : Nil #

Writes the string str in this window at the coordinates (x, y).


[View source]
def write(ch : Acs, x : Int, y : Int) : Nil #

[View source]
def write(ch : Char) : Nil #

Writes the character ch in this window at the cursor.


[View source]
def write(str : String) : Nil #

Writes the string str in this window at the cursor.


[View source]
def write(ch : Acs) : Nil #

[View source]
def writeAtLastPos(ch : Char) : Nil #

Writes ch at the last position of this window. This assumes the width of the window is at least 2.


[View source]