Skip to content

Commit

Permalink
add Tb_key
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellwrosen committed Nov 7, 2023
1 parent d451cc1 commit 20489b4
Show file tree
Hide file tree
Showing 6 changed files with 851 additions and 14 deletions.
6 changes: 0 additions & 6 deletions termbox2-bindings-c/src/Termbox2/Bindings/C.hs
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,6 @@ module Termbox2.Bindings.C
-- ** Function types
_TB_FUNC_EXTRACT_PRE,
_TB_FUNC_EXTRACT_POST,

-- ** Buffer sizes
_TB_OPT_PRINTF_BUF,
_TB_OPT_READ_BUF,
)
where

Expand Down Expand Up @@ -349,8 +345,6 @@ import Termbox2.Bindings.C.Internal.Constants
_TB_MOD_MOTION,
_TB_MOD_SHIFT,
_TB_OK,
_TB_OPT_PRINTF_BUF,
_TB_OPT_READ_BUF,
_TB_OUTPUT_216,
_TB_OUTPUT_256,
_TB_OUTPUT_CURRENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ data {-# CTYPE "termbox2.h" "struct tb_cell" #-} Tb_cell = Tb_cell
fg :: {-# UNPACK #-} !Word64,
-- | Background attribute.
bg :: {-# UNPACK #-} !Word64,
-- | A grapheme cluster.
-- | A list of unicode code points.
ech :: {-# UNPACK #-} !(Ptr Word32),
-- | Length of @ech@; 0 means use @ch@.
nech :: {-# UNPACK #-} !CSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ module Termbox2.Bindings.C.Internal.Constants
_TB_MOD_MOTION,
_TB_MOD_SHIFT,
_TB_OK,
_TB_OPT_PRINTF_BUF,
_TB_OPT_READ_BUF,
_TB_OUTPUT_216,
_TB_OUTPUT_256,
_TB_OUTPUT_CURRENT,
Expand Down Expand Up @@ -390,10 +388,6 @@ foreign import capi "termbox2.h value TB_MOD_SHIFT" _TB_MOD_SHIFT :: Word8

foreign import capi "termbox2.h value TB_OK" _TB_OK :: CInt

foreign import capi "termbox2.h value TB_OPT_PRINTF_BUF" _TB_OPT_PRINTF_BUF :: CInt

foreign import capi "termbox2.h value TB_OPT_READ_BUF" _TB_OPT_READ_BUF :: CInt

foreign import capi "termbox2.h value TB_OUTPUT_216" _TB_OUTPUT_216 :: CInt

foreign import capi "termbox2.h value TB_OUTPUT_256" _TB_OUTPUT_256 :: CInt
Expand Down
238 changes: 237 additions & 1 deletion termbox2-bindings-hs/src/Termbox2/Bindings/Hs.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,72 @@
module Termbox2.Bindings.Hs
( -- * Types
( -- * Functions

-- ** Initialize / shutdown

-- tb_init,
-- tb_init_fd,
-- tb_init_file,
-- tb_init_rwfd,
-- tb_shutdown,

-- ** Get\/set the input\/output mode

-- tb_set_input_mode,
-- tb_set_output_mode,

-- ** Get terminal dimensions

-- tb_width,
-- tb_height,

-- ** Poll for events

-- tb_peek_event,
-- tb_poll_event,
-- tb_get_fds,

-- ** Set cell contents

-- tb_set_cell,
-- tb_set_cell_ex,
-- tb_extend_cell,
-- tb_print,
-- tb_print_ex,
-- tb_cell_buffer,

-- ** Set\/hide the cursor

-- tb_set_cursor,
-- tb_hide_cursor,

-- ** Send raw bytes

-- tb_send,

-- ** Clear and synchronize the back buffer

-- tb_clear,
-- tb_set_clear_attrs,
-- tb_present,
-- tb_invalidate,

-- ** Custom escape sequences

-- tb_set_func,

-- ** Error utils

-- tb_last_errno,
-- tb_strerror,

-- ** Query compile-time constants

-- tb_attr_width,
-- tb_has_egc,
-- tb_has_truecolor,
-- tb_version,

-- * Types
Tb_attr
( Tb_attr,
TB_BLINK,
Expand All @@ -14,7 +81,176 @@ module Termbox2.Bindings.Hs
TB_UNDERLINE,
TB_UNDERLINE_2
),
-- Tb_event (..),
Tb_key
( Tb_key,
TB_KEY_ARROW_DOWN,
TB_KEY_ARROW_LEFT,
TB_KEY_ARROW_RIGHT,
TB_KEY_ARROW_UP,
TB_KEY_BACKSPACE,
TB_KEY_BACKSPACE2,
TB_KEY_BACK_TAB,
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DEFAULT,
-- _TB_BLACK,
-- _TB_HI_BLACK,
-- _TB_BLUE,
-- _TB_CYAN,
-- _TB_GREEN,
-- _TB_MAGENTA,
-- _TB_RED,
-- _TB_WHITE,
-- _TB_YELLOW,

-- ** Attributes

-- _TB_BLINK,
-- _TB_BOLD,
-- _TB_BRIGHT,
-- _TB_DIM,
-- _TB_INVISIBLE,
-- _TB_ITALIC,
-- _TB_OVERLINE,
-- _TB_REVERSE,
-- _TB_STRIKEOUT,
-- _TB_UNDERLINE,
-- _TB_UNDERLINE_2,

-- ** Event types

-- _TB_EVENT_KEY,
-- _TB_EVENT_RESIZE,
-- _TB_EVENT_MOUSE,

-- ** Key modifiers

-- _TB_MOD_ALT,
-- _TB_MOD_CTRL,
-- _TB_MOD_MOTION,
-- _TB_MOD_SHIFT,

-- ** Input modes

-- _TB_INPUT_CURRENT,
-- _TB_INPUT_ALT,
-- _TB_INPUT_ESC,
-- _TB_INPUT_MOUSE,

-- ** Output modes

-- _TB_OUTPUT_CURRENT,
-- _TB_OUTPUT_216,
-- _TB_OUTPUT_256,
-- _TB_OUTPUT_GRAYSCALE,
-- _TB_OUTPUT_NORMAL,
-- _TB_OUTPUT_TRUECOLOR,

-- ** Result codes

-- _TB_OK,

-- *** Error codes

-- _TB_ERR,
-- _TB_ERR_CAP_COLLISION,
-- _TB_ERR_INIT_ALREADY,
-- _TB_ERR_INIT_OPEN,
-- _TB_ERR_MEM,
-- _TB_ERR_NEED_MORE,
-- _TB_ERR_NOT_INIT,
-- _TB_ERR_NO_EVENT,
-- _TB_ERR_NO_TERM,
-- _TB_ERR_OUT_OF_BOUNDS,
-- _TB_ERR_POLL,
-- _TB_ERR_READ,
-- _TB_ERR_RESIZE_IOCTL,
-- _TB_ERR_RESIZE_PIPE,
-- _TB_ERR_RESIZE_POLL,
-- _TB_ERR_RESIZE_READ,
-- _TB_ERR_RESIZE_SIGACTION,
-- _TB_ERR_RESIZE_SSCANF,
-- _TB_ERR_RESIZE_WRITE,
-- _TB_ERR_TCGETATTR,
-- _TB_ERR_TCSETATTR,
-- _TB_ERR_UNSUPPORTED_TERM,

-- ** Function types
)
where

-- _TB_FUNC_EXTRACT_PRE,
-- _TB_FUNC_EXTRACT_POST,

import Termbox2.Bindings.Hs.Internal.Attr (Tb_attr (..))
import Termbox2.Bindings.Hs.Internal.Key (Tb_key (..))
Loading

0 comments on commit 20489b4

Please sign in to comment.