class RemiCharms::Window
- RemiCharms::Window
- Reference
- Object
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.crConstructors
-
.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). -
.standardWindow : Window
Returns the
stdscr
in curses.
Instance Method Summary
-
#attributeOff(attrs : Attribute) : Nil
Turn off the attributes for this window without affecting any others.
-
#attributeOff(*attrs : Attribute) : Nil
Turn off the attributes for this window without affecting any others.
-
#attributeOn(attrs : Attribute) : Nil
Turn on the attributes for this window without affecting any others.
-
#attributeOn(*attrs : Attribute) : Nil
Turn on the attributes for this window without affecting any others.
-
#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.
-
#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.
-
#border(topAndBottom : Char, leftAndRight, upperLeft : Char, upperRight : Char, lowerLeft : Char, lowerRight : Char) : Nil
Drawa a border around this window using the given character.
-
#border(topAndBottom : Acs, leftAndRight, upperLeft : Acs, upperRight : Acs, lowerLeft : Acs, lowerRight : Acs) : Nil
Draws a border around this window using the given ACS characters.
-
#border : Nil
Draws a border around this window using the default ACS characters.
-
#charAt(x : Int, y : Int) : Char
Returns the character at the point (x, y) in this window.
-
#charAt : Char
Returns the character at the cursor in this window.
-
#clear(repaint : Bool = false) : Nil
Blank out the contents of this window.
-
#clearAfterCursor : Nil
Clear the rest of the window after the cursor.
-
#clearLineAfterCursor : Nil
Clear the rest of the line after the cursor.
-
#cursorDown(delta : Int32 = 1) : Nil
Moves the cursor in this window down by delta characters.
-
#cursorLeft(delta : Int32 = 1) : Nil
Moves the cursor in this window left by delta characters.
-
#cursorPos : Tuple(Int32, Int32)
Returns the X and Y coordinates of the cursor in this window, in that order.
-
#cursorRight(delta : Int32 = 1) : Nil
Moves the cursor in this window right by delta characters.
-
#cursorUp(delta : Int32 = 1) : Nil
Moves the cursor in this window up by delta characters.
-
#destroy : Nil
Destroys this window.
-
#dup : Window
Creates a copy of this window.
-
#extraKeys=(value : Bool) : Nil
Enable or disable extra keys, such as arrow and function keys, in this window.
-
#finalize
Cleans up the internal pointer if
#destroy
hasn't yet been called when this instance is garbage collected. -
#forceRepaint : Nil
Forces the entire window to be cleared and repainted on the next call to
#refresh
. -
#getChar(ignoreError : Bool = false) : Char | Nil
Get a character from this window.
-
#getChar! : Char | Nil
Same as
#getChar
, but the ignoreError parameter for it is alwaystrue
. -
#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.
-
#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.
-
#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. -
#hline(ch : Char, count : Int) : Nil
Draws a horizontal line at the cursor that is count characters wide using the given character.
-
#hline(ch : Acs, count : Int) : Nil
Draws a horizontal line at the cursor that is count characters wide using the given ACS character.
-
#hline(count : Int) : Nil
Draws a horizontal line at the cursor that is count characters wide using
Acs::Hline
for the character. -
#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.
-
#insert(ch : Char) : Nil
Insert the character ch at the cursor within this window, advancing the rest of the line, without moving the cursor.
-
#lastPos?(x : Int, y : Int) : Bool
Returns
true
if the coordinate (x, y) is at the last position within this window, orfalse
otherwise. -
#moveCursor(x : Int, y : Int) : Nil
Moves the cursor in this window to the coordinates (x, y).
-
#nonBlocking=(value : Bool) : Nil
Enables or disables non-blocking mode for this window.
-
#pointer : NCurses::WindowPtr
Pointer to the underlying representation of a window pointer.
-
#refresh : Nil
Refresh the display of this window.
-
#size : Tuple(Int32, Int32)
Returns the width and height of this window, in that order.
-
#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.
-
#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.
-
#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. -
#vline(ch : Char, count : Int) : Nil
Draws a vertical line at the cursor that is count characters wide using the given character.
-
#vline(ch : Acs, count : Int) : Nil
Draws a vertical line at the cursor that is count characters wide using the given ACS character.
-
#vline(count : Int) : Nil
Draws a vertical line at the cursor that is count characters wide using
Acs::Vline
for the character. -
#withAttributes(attrs : Attribute, &) : Nil
Temporarily turns on the given attributes for this window in the block, then turns them off before returning.
-
#withRestoredCursor(&) : Nil
Records the current cursor position in this window, then yields.
-
#write(ch : Char, x : Int, y : Int) : Nil
Writes the character ch in this window at the coordinates (x, y).
-
#write(str : String, x : Int, y : Int) : Nil
Writes the string str in this window at the coordinates (x, y).
- #write(ch : Acs, x : Int, y : Int) : Nil
-
#write(ch : Char) : Nil
Writes the character ch in this window at the cursor.
-
#write(str : String) : Nil
Writes the string str in this window at the cursor.
- #write(ch : Acs) : Nil
-
#writeAtLastPos(ch : Char) : Nil
Writes ch at the last position of this window.
Constructor Detail
Creates a new Window
with the given width and height, starting at
the coordinate (startX, startY).
Note that windows may not overlap.
Instance Method Detail
Turn off the attributes for this window without affecting any others.
Turn off the attributes for this window without affecting any others.
Turn on the attributes for this window without affecting any others.
Turn on the attributes for this window without affecting any others.
Drawa a border around this window using the given characters. The characters must be ASCII-based.
Draws a border around this window using the given ACS characters.
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.
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.
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.
Moves the cursor in this window down by delta characters. A negative delta moves the cursor up instead.
Moves the cursor in this window left by delta characters. A negative delta moves the cursor right instead.
Returns the X and Y coordinates of the cursor in this window, in that order.
Moves the cursor in this window right by delta characters. A negative delta moves the cursor left instead.
Moves the cursor in this window up by delta characters. A negative delta moves the cursor down instead.
Enable or disable extra keys, such as arrow and function keys, in this window.
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
Forces the entire window to be cleared and repainted on the next call to
#refresh
.
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.
Draws a horizontal line at the coordinates that is count characters wide using the given character. The character must be ASCII-based.
Draws a horizontal line at the coordinates that is count characters wide using the given ACS character.
Draws a horizontal line at the coordinates that is count characters wide
using Acs::Hline
for the character.
Draws a horizontal line at the cursor that is count characters wide using the given character. The character must be ASCII-based.
Draws a horizontal line at the cursor that is count characters wide using the given ACS character.
Draws a horizontal line at the cursor that is count characters wide
using Acs::Hline
for the character.
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.
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.
Returns true
if the coordinate (x, y) is at the last position within
this window, or false
otherwise.
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
)."
Pointer to the underlying representation of a window pointer. You can use this in calls to the lower-level bindings.
Draws a vertical line at the coordinates that is count characters wide using the given character. The character must be ASCII-based.
Draws a vertical line at the coordinates that is count characters wide using the given ACS character.
Draws a vertical line at the coordinates that is count characters wide
using Acs::Vline
for the character.
Draws a vertical line at the cursor that is count characters wide using the given character. The character must be ASCII-based.
Draws a vertical line at the cursor that is count characters wide using the given ACS character.
Draws a vertical line at the cursor that is count characters wide
using Acs::Vline
for the character.
Temporarily turns on the given attributes for this window in the block, then turns them off before returning.
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.
Writes the character ch in this window at the coordinates (x, y).
Writes the string str in this window at the coordinates (x, y).
Writes ch at the last position of this window. This assumes the width of the window is at least 2.