diff --git a/src/termbox/bindings.cr b/src/termbox/bindings.cr index 24aa982..cfcca99 100644 --- a/src/termbox/bindings.cr +++ b/src/termbox/bindings.cr @@ -27,18 +27,18 @@ lib TermboxBindings end # API - fun tb_init(): Int + fun tb_init(): Int32 fun tb_shutdown(): Void - fun tb_width(): Int - fun tb_height(): Int + fun tb_width(): Int32 + fun tb_height(): Int32 fun tb_clear(): Void fun tb_set_clear_attributes(fg: UInt16, bg: UInt16): Void fun tb_present(): Void - fun tb_set_cursor(x: Int, y: Int): Void - fun tb_put_cell(x: Int, y: Int, cell: Pointer(Cell)): Void - fun tb_change_cell(x: Int, y: Int, ch: UInt32, fg: UInt16, bg: UInt16): Void - fun tb_select_input_mode(mode: Int): Int - fun tb_select_output_mode(mode: Int): Int - fun tb_peek_event(event: Pointer(Event), timeout: Int): Int - fun tb_poll_event(event: Pointer(Event)): Int + fun tb_set_cursor(x: Int32, y: Int32): Void + fun tb_put_cell(x: Int32, y: Int32, cell: Pointer(Cell)): Void + fun tb_change_cell(x: Int32, y: Int32, ch: UInt32, fg: UInt16, bg: UInt16): Void + fun tb_select_input_mode(mode: Int32): Int32 + fun tb_select_output_mode(mode: Int32): Int32 + fun tb_peek_event(event: Pointer(Event), timeout: Int32): Int32 + fun tb_poll_event(event: Pointer(Event)): Int32 end diff --git a/src/termbox/border.cr b/src/termbox/border.cr index d77e24c..c13301d 100644 --- a/src/termbox/border.cr +++ b/src/termbox/border.cr @@ -18,7 +18,7 @@ module Termbox end # For special-mode borders (normal, double, solid, cloth_low, cloth_med, cloth_high, dotted) - def initialize(pivot : Position, width : Int, height : Int, mode : String) + def initialize(pivot : Position, width : Int32, height : Int32, mode : String) # Decide on border character given mode # For normal/double/char modes, just use X (no use) case mode @@ -40,17 +40,17 @@ module Termbox end # Normal mode - def initialize(pivot : Position, width : Int, height : Int) + def initialize(pivot : Position, width : Int32, height : Int32) initialize(pivot, width, height, "normal") end # Border based on a single character - def initialize(pivot : Position, width : Int, height : Int, char : Char) + def initialize(pivot : Position, width : Int32, height : Int32, char : Char) initialize(pivot, width, height, "char", char) end # Master internal constructor - private def initialize(@pivot : Position, @width : Int, @height : Int, @mode : String, @char : Char) + private def initialize(@pivot : Position, @width : Int32, @height : Int32, @mode : String, @char : Char) @foreground = COLOR_NIL @background = COLOR_NIL end diff --git a/src/termbox/cell.cr b/src/termbox/cell.cr index 3215fec..59bc815 100644 --- a/src/termbox/cell.cr +++ b/src/termbox/cell.cr @@ -6,7 +6,7 @@ module Termbox getter :position, :char, :foreground, :background # Make a cell with a specified foreground and background - def initialize(@char : Char, @position : Position, @foreground : Int, @background : Int) + def initialize(@char : Char, @position : Position, @foreground : Int32, @background : Int32) end # Make a cell with default colors @@ -15,7 +15,7 @@ module Termbox end # Make a new cell with a position transformed by x and y - def new_transform(x : Int, y : Int) + def new_transform(x : Int32, y : Int32) Cell.new(@char, @position.new_transform(x, y), @foreground, @background) end diff --git a/src/termbox/container.cr b/src/termbox/container.cr index aa0f18b..58208d2 100644 --- a/src/termbox/container.cr +++ b/src/termbox/container.cr @@ -7,7 +7,7 @@ module Termbox getter :elements # Accepts a pivot (top left position), width, and height - def initialize(@pivot : Position, @width : Int, @height : Int) + def initialize(@pivot : Position, @width : Int32, @height : Int32) @elements = [] of Element end diff --git a/src/termbox/line.cr b/src/termbox/line.cr index 925532b..e3f9fa8 100644 --- a/src/termbox/line.cr +++ b/src/termbox/line.cr @@ -4,7 +4,7 @@ module Termbox class Line < Termbox::Element getter :cell, :size, :is_vertical - def initialize(@cell : Cell, @size : Int, @is_vertical : Bool = true) + def initialize(@cell : Cell, @size : Int32, @is_vertical : Bool = true) end def render : Array(Cell) diff --git a/src/termbox/position.cr b/src/termbox/position.cr index a59561c..ea31b90 100644 --- a/src/termbox/position.cr +++ b/src/termbox/position.cr @@ -3,10 +3,10 @@ module Termbox struct Position getter :x, :y - def initialize(@x : Int, @y : Int) + def initialize(@x : Int32, @y : Int32) end - def new_transform(x : Int, y : Int) + def new_transform(x : Int32, y : Int32) Position.new(@x + x, @y + y) end end diff --git a/src/termbox/window.cr b/src/termbox/window.cr index 58f206a..e8bcf26 100644 --- a/src/termbox/window.cr +++ b/src/termbox/window.cr @@ -41,12 +41,12 @@ module Termbox end # Get width of termbox - def width : Int + def width : Int32 TermboxBindings.tb_width() end # Get height of termbox - def height : Int + def height : Int32 TermboxBindings.tb_height() end @@ -106,7 +106,7 @@ module Termbox end # Put a decomposed cell and decomposed position, bypassing @elements store - private def put_raw(x : Int, y : Int, ch : Int, foreground : Int, background : Int) : Void + private def put_raw(x : Int32, y : Int32, ch : Int32, foreground : Int32, background : Int32) : Void TermboxBindings.tb_change_cell(x, y, ch, foreground, background) end @@ -116,17 +116,17 @@ module Termbox end # Set input mode - def set_input_mode(mode : Int) : Int + def set_input_mode(mode : Int32) : Int32 TermboxBindings.tb_select_input_mode(mode) end # Set output mode - def set_output_mode(mode : Int) : Int + def set_output_mode(mode : Int32) : Int32 TermboxBindings.tb_select_output_mode(mode) end # Set primary colors - def set_primary_colors(foreground : Int, background : Int) : Void + def set_primary_colors(foreground : Int32, background : Int32) : Void @foreground = foreground @background = background TermboxBindings.tb_set_clear_attributes(foreground, background) @@ -139,7 +139,7 @@ module Termbox # Events - def peek(timeout : Int) + def peek(timeout : Int32) e = @event_master TermboxBindings.tb_peek_event(pointerof(e), timeout) e @@ -159,19 +159,19 @@ module Termbox end # Write a string horizontal starting at pivot - def write_string(pivot : Position, string : String, foreground : Int, background : Int) + def write_string(pivot : Position, string : String, foreground : Int32, background : Int32) string.each_char_with_index do |char, i| put_raw(pivot.new_transform(i, 0), char, foreground, background) end end # Decide on foreground (if nil, use default) - private def decide_foreground(color : Int) + private def decide_foreground(color : Int32) color != COLOR_NIL ? color : @foreground end # Decide on background (if nil, use default) - private def decide_background(color : Int) + private def decide_background(color : Int32) color != COLOR_NIL ? color : @background end end