gok-chunker

## gok-chunker gok-chunker |

## Synopsis

    enum                ChunkTypes;
    enum                ChunkOrder;
    gboolean            gok_chunker_chunk_all               (ChunkTypes TypeChunks,
                                                             ChunkOrder chunkOrder);
    void                gok_chunker_init_chunk              (GokChunk *pChunk);
    void                gok_chunker_delete_chunks           (GokChunk *pChunk,
                                                             gboolean bAlsoNext);
    void                gok_chunker_reset                   (void);
    void                gok_chunker_next_chunk              (void);
    void                gok_chunker_previous_chunk          (void);
    void                gok_chunker_next_key                (void);
    void                gok_chunker_previous_key            (void);
    void                gok_chunker_keyup                   (void);
    void                gok_chunker_keydown                 (void);
    void                gok_chunker_keyleft                 (void);
    void                gok_chunker_keyright                (void);
    void                gok_chunker_keyhighlight            (void);
    gboolean            gok_chunker_wraptofirstchunk        (void);
    gboolean            gok_chunker_wraptolastchunk         (void);
    gboolean            gok_chunker_wraptofirstkey          (void);
    gboolean            gok_chunker_wraptolastkey           (void);
    gboolean            gok_chunker_wraptoleft              (gint TrueFalse);
    gboolean            gok_chunker_wraptoright             (gint TrueFalse);
    void                gok_chunker_move_leftright          (gint TrueFalse);
    void                gok_chunker_move_topbottom          (gint TrueFalse);
    gint                gok_chunker_if_next_chunk           (void);
    gint                gok_chunker_if_previous_chunk       (void);
    gint                gok_chunker_if_next_key             (void);
    gint                gok_chunker_if_previous_key         (void);
    gint                gok_chunker_if_top                  (void);
    gint                gok_chunker_if_bottom               (void);
    gint                gok_chunker_if_left                 (void);
    gint                gok_chunker_if_right                (void);
    gint                gok_chunker_if_key_selected         (void);
    gboolean            gok_chunker_is_left                 (GokKey *pKey1,
                                                             GokKey *pKey2);
    gboolean            gok_chunker_is_right                (GokKey *pKey1,
                                                             GokKey *pKey2);
    gboolean            gok_chunker_is_top                  (GokKey *pKey1,
                                                             GokKey *pKey2);
    gboolean            gok_chunker_is_bottom               (GokKey *pKey1,
                                                             GokKey *pKey2);
    void                gok_chunker_counter_set             (gint CounterId,
                                                             gint CounterValue);
    void                gok_chunker_counter_increment       (gint CounterId);
    void                gok_chunker_counter_decrement       (gint CounterId);
    void                gok_chunker_state_restart           (void);
    void                gok_chunker_state_next              (void);
    void                gok_chunker_state_jump              (gchar *NameState);
    gboolean            gok_chunker_select_chunk            (void);
    void                gok_chunker_highlight_chunk         (GokChunk *pChunk);
    void                gok_chunker_unhighlight_chunk       (GokChunk *pChunk);
    void                gok_chunker_highlight_center_key    (void);
    void                gok_chunker_highlight_first_chunk   (void);
    void                gok_chunker_highlight_first_key     (void);
    gboolean            gok_chunker_insert_item_row_ltr     (GokChunk *pChunk,
                                                             GokChunkitem *pChunkitem);
    gboolean            gok_chunker_insert_item_row_rtl     (GokChunk *pChunk,
                                                             GokChunkitem *pChunkitem);
    gboolean            gok_chunker_insert_item_col_ttb     (GokChunk *pChunk,
                                                             GokChunkitem *pChunkitem);
    gboolean            gok_chunker_insert_item_col_btt     (GokChunk *pChunk,
                                                             GokChunkitem *pChunkitem);
    void                gok_chunker_dump_chunks             (void);
    void                gok_chunker_dump_chunk              (GokChunk *pChunk);
    GokChunk*           gok_chunker_chunk_group             (GokChunk *pChunk,
                                                             gint NumberGroups,
                                                             ChunkOrder Order,
                                                             gboolean bCanReorder);
    void                gok_chunker_add_chunkitem           (GokChunk *pChunk,
                                                             GokChunkitem *pChunkitem);
    gint                gok_chunker_count_chunkitems        (GokChunk *pChunk);
    GokChunk*           gok_chunker_make_2_vertical         (GokChunk *pChunk);
    GokChunk*           gok_chunker_make_2_horizontal       (GokChunk *pChunk);
    GokChunk*           gok_chunker_make_4                  (GokChunk *pChunk);
    void                gok_chunker_highlight_chunk_number  (gint Number);
    GokChunk*           gok_chunker_get_chunk               (gint Number);
    void                gok_chunker_highlight_all_keys      (void);
    void                gok_chunker_unhighlight_all_keys    (void);
    void                gok_chunker_resolve_overlap         (GokChunk *pChunk);

## Description

## Details

### enum ChunkTypes

    typedef enum {
    CHUNKER_RESET,
    CHUNKER_NOCHUNKS,
    CHUNKER_KEYS,
    CHUNKER_ROWS,
    CHUNKER_COLUMNS,
    CHUNKER_RECURSIVE,
    CHUNKER_2GROUPS,
    CHUNKER_3GROUPS,
    CHUNKER_4GROUPS,
    CHUNKER_5GROUPS,
    CHUNKER_6GROUPS
    } ChunkTypes;

### enum ChunkOrder

    typedef enum {
    CHUNKER_TOPTOBOTTOM_LEFTTORIGHT,
    CHUNKER_TOPTOBOTTOM_RIGHTTOLEFT,
    CHUNKER_BOTTOMTOTOP_LEFTTORIGHT,
    CHUNKER_BOTTOMTOTOP_RIGHTTOLEFT,
    CHUNKER_LEFTTORIGHT_TOPTOBOTTOM,
    CHUNKER_LEFTTORIGHT_BOTTOMTOTOP,
    CHUNKER_RIGHTTOLEFT_TOPTOBOTTOM,
    CHUNKER_RIGHTTOLEFT_BOTTOMTOTOP
    } ChunkOrder;

### gok_chunker_chunk_all ()

    gboolean            gok_chunker_chunk_all               (ChunkTypes TypeChunks,
                                                             ChunkOrder chunkOrder);

Breaks all the keyboards into chunks.

`TypeChunks` : | The type of chunks required e.g. rows or columns. (See the enum 'ChunkTypes' for possible values.)
`chunkOrder` : |
Returns : | TRUE if everything went OK, FALSE if there was any problem.

### gok_chunker_init_chunk ()

    void                gok_chunker_init_chunk              (GokChunk *pChunk);

Initializes a GOK chunk. This must be called after creating any chunk.

`pChunk` : | Pointer to the chunk that will be initialized.

### gok_chunker_delete_chunks ()

    void                gok_chunker_delete_chunks           (GokChunk *pChunk,
                                                             gboolean bAlsoNext);

Deletes a chunk and, optionally, any following chunks.

`pChunk` : | Pointer to the first chunk in the list of chunks that gets deleted.
`bAlsoNext` : | If TRUE then all chunks following the one given will be deleted.

### gok_chunker_reset ()

    void                gok_chunker_reset                   (void);

### gok_chunker_next_chunk ()

    void                gok_chunker_next_chunk              (void);

Highlightes the next chunk.

### gok_chunker_previous_chunk ()

    void                gok_chunker_previous_chunk          (void);

Highlightes the previous chunk.

### gok_chunker_next_key ()

    void                gok_chunker_next_key                (void);

Highlightes the next key in the chunk.

### gok_chunker_previous_key ()

    void                gok_chunker_previous_key            (void);

Highlightes the previous key in the selected chunk.

### gok_chunker_keyup ()

    void                gok_chunker_keyup                   (void);

Highlights and selects the key to the top of the currently highlighted key. This does NOT wrap to the bottom side of the keyboard (call gok_chunker_wraptobottom).

### gok_chunker_keydown ()

    void                gok_chunker_keydown                 (void);

Highlights and selects the right to the bottom of the currently highlighted key. This does NOT wrap to the top side of the keyboard (call gok_chunker_wraptotop).

### gok_chunker_keyleft ()

    void                gok_chunker_keyleft                 (void);

Highlights and selects the key to the left of the currently highlighted key. This does NOT wrap to the right side of the keyboard (call gok_chunker_wraptoright).

### gok_chunker_keyright ()

    void                gok_chunker_keyright                (void);

Highlights and selects the right to the right of the currently highlighted key. This does NOT wrap to the left side of the keyboard (call gok_chunker_wraptoleft).

### gok_chunker_keyhighlight ()

    void                gok_chunker_keyhighlight            (void);

Highlights the given key.

NOT USED (deprecate?)

### gok_chunker_wraptofirstchunk ()

    gboolean            gok_chunker_wraptofirstchunk        (void);

Highlights the first chunk in the list of chunks

Returns : | TRUE if successful, FALSE if not.

### gok_chunker_wraptolastchunk ()

    gboolean            gok_chunker_wraptolastchunk         (void);

Highlights the last chunk in the list of chunks

Returns : | TRUE if successful, FALSE if not.

### gok_chunker_wraptofirstkey ()

    gboolean            gok_chunker_wraptofirstkey          (void);

Highlights the first key in the list of keys.

Returns : | TRUE if successful, FALSE if not.

### gok_chunker_wraptolastkey ()

    gboolean            gok_chunker_wraptolastkey           (void);

Highlights the last key in the list of keys.

Returns : | TRUE if successful, FALSE if not.

### gok_chunker_wraptoleft ()

    gboolean            gok_chunker_wraptoleft              (gint TrueFalse);

Highlights the leftmost key that is on the same row as the currently selected key.

`TrueFalse` : | unused.
Returns : | TRUE if successful, FALSE if not.

### gok_chunker_wraptoright ()

    gboolean            gok_chunker_wraptoright             (gint TrueFalse);

Highlights the rightmost key that is on the same row as the currently selected key.

`TrueFalse` : | unused
Returns : | TRUE if successful, FALSE if not.

### gok_chunker_move_leftright ()

    void                gok_chunker_move_leftright          (gint TrueFalse);

Not implemented yet.

`TrueFalse` : | unused

### gok_chunker_move_topbottom ()

    void                gok_chunker_move_topbottom          (gint TrueFalse);

Not implemented yet.

`TrueFalse` : | unused

### gok_chunker_if_next_chunk ()

    gint                gok_chunker_if_next_chunk           (void);

Tests if there is another chunk after the current chunk.

Returns : | TRUE if there is a next chunk, FALSE if not.

### gok_chunker_if_previous_chunk ()

    gint                gok_chunker_if_previous_chunk       (void);

Tests if there is another chunk before the current chunk.

Returns : | TRUE if there is a previous chunk, FALSE if not.

### gok_chunker_if_next_key ()

    gint                gok_chunker_if_next_key             (void);

Tests if there is another key after the current key.

Returns : | TRUE if there is a next key, FALSE if not.

### gok_chunker_if_previous_key ()

    gint                gok_chunker_if_previous_key         (void);

Tests if there is another key before the current key.

Returns : | TRUE if there is a key chunk, FALSE if not.

### gok_chunker_if_top ()

    gint                gok_chunker_if_top                  (void);

Tests if there is a key to the top of the currently highlighted key.

Returns : | TRUE if there is a key to the top, FALSE if not.

### gok_chunker_if_bottom ()

    gint                gok_chunker_if_bottom               (void);

Tests if there is a key to the bottom of the currently highlighted key.

Returns : | TRUE if there is a key to the bottom, FALSE if not.

### gok_chunker_if_left ()

    gint                gok_chunker_if_left                 (void);

Tests if there is a key to the left of the currently highlighted key.

Returns : | TRUE if there is a key to the left, FALSE if not.

### gok_chunker_if_right ()

    gint                gok_chunker_if_right                (void);

Tests if there is a key to the right of the currently highlighted key.

Returns : | TRUE if there is a key to the right, FALSE if not.

### gok_chunker_if_key_selected ()

    gint                gok_chunker_if_key_selected         (void);

Returns : | Alwasy 0.

### gok_chunker_is_left ()

    gboolean            gok_chunker_is_left                 (GokKey *pKey1,
                                                             GokKey *pKey2);

Tests if a key is left of another key. This does NOT test if the keys are on the same row. This should be called when traversing a row from right to left.

`pKey1` : | Key you want to test.
`pKey2` : | Key you want to compare against.
Returns : | TRUE if pKey1 is left of pKey2, FALSE if pKey2 is left of pKey1.

### gok_chunker_is_right ()

    gboolean            gok_chunker_is_right                (GokKey *pKey1,
                                                             GokKey *pKey2);

Tests if a key is right of another key. This does NOT test if the keys are on the same row. This should be called when traversing a row from left to right.

`pKey1` : | Key you want to test.
`pKey2` : | Key you want to compare against.
Returns : | TRUE if pKey1 is right of pKey2, FALSE if pKey2 is left of pKey1.

### gok_chunker_is_top ()

    gboolean            gok_chunker_is_top                  (GokKey *pKey1,
                                                             GokKey *pKey2);

Tests if a key is top of another key. This does NOT test if the keys are on the same column. This should be called when traversing a column from bottom to top.

`pKey1` : | Key you want to test.
`pKey2` : | Key you want to compare against.
Returns : | TRUE if pKey1 is higher than pKey2, FALSE if pKey2 is higher than pKey1.

### gok_chunker_is_bottom ()

    gboolean            gok_chunker_is_bottom               (GokKey *pKey1,
                                                             GokKey *pKey2);

Tests if a key is bottom of another key. This does NOT test if the keys are on the same column. This should be called when traversing a column from top to bottom.

`pKey1` : | Key you want to test.
`pKey2` : | Key you want to compare against.
Returns : | TRUE if pKey1 is bottom of pKey2, FALSE if pKey2 is bottom of pKey1.

### gok_chunker_counter_set ()

    void                gok_chunker_counter_set             (gint CounterId,
                                                             gint CounterValue);

`CounterId` : | Counter you want to set.
`CounterValue` : | Value you want the counter set to.

### gok_chunker_counter_increment ()

    void                gok_chunker_counter_increment       (gint CounterId);

`CounterId` : | Counter you want to increment.

### gok_chunker_counter_decrement ()

    void                gok_chunker_counter_decrement       (gint CounterId);

`CounterId` : | Counter you want to decrement.

### gok_chunker_state_restart ()

    void                gok_chunker_state_restart           (void);

Move to the first state.

### gok_chunker_state_next ()

    void                gok_chunker_state_next              (void);

Move to the next state. Move to the first state if at the last state.

### gok_chunker_state_jump ()

    void                gok_chunker_state_jump              (gchar *NameState);

Change state to the given state.

`NameState` : | Name of the state you want to jump to.

### gok_chunker_select_chunk ()

    gboolean            gok_chunker_select_chunk            (void);

Sets the current chunk as the selected chunk.

Returns : | The number of keys in the selected chunk.

### gok_chunker_highlight_chunk ()

    void                gok_chunker_highlight_chunk         (GokChunk *pChunk);

Highlightes the given chunk. Updates m_pChunkHighlighted with the chunk given.

`pChunk` : | Pointer to the chunk that will be highlighted.

### gok_chunker_unhighlight_chunk ()

    void                gok_chunker_unhighlight_chunk       (GokChunk *pChunk);

Unhighlightes the given chunk. Updates m_pChunkHighlighted.

`pChunk` : | Pointer to the chunk that will be unhighlighed (made normal).

### gok_chunker_highlight_center_key ()

    void                gok_chunker_highlight_center_key    (void);

Highlightes the center key on the current keyboard.

### gok_chunker_highlight_first_chunk ()

    void                gok_chunker_highlight_first_chunk   (void);

Highlightes the first chunk on the current keyboard. Updates m_pChunkHighlighted.

### gok_chunker_highlight_first_key ()

    void                gok_chunker_highlight_first_key     (void);

Highlightes the first key in the selected chunk. Updates m_pChunkitemHighlighted.

### gok_chunker_insert_item_row_ltr ()

    gboolean            gok_chunker_insert_item_row_ltr     (GokChunk *pChunk,
                                                             GokChunkitem *pChunkitem);

Adds a chunkitem (key) to a chunk (row). The new chunkitem will be added in the sequence left to right (the leftmost key is the first key in the sequence).

`pChunk` : | Pointer to the first chunk that will contain the new chunkitem.
`pChunkitem` : | Pointer to the chunkitem that gets added to the chunk.
Returns : | TRUE if the chunkitem was added to the chunk, FALSE if not.

### gok_chunker_insert_item_row_rtl ()

    gboolean            gok_chunker_insert_item_row_rtl     (GokChunk *pChunk,
                                                             GokChunkitem *pChunkitem);

Adds a chunkitem (key) to a chunk (row). The new chunkitem will be added in the sequence right to left (the rightmost key is the first key in the sequence).

`pChunk` : | Pointer to the first chunk that will contain the new chunkitem.
`pChunkitem` : | Pointer to the chunkitem that gets added to the chunk.
Returns : | TRUE if the chunkitem was added to the chunk, FALSE if not.

### gok_chunker_insert_item_col_ttb ()

    gboolean            gok_chunker_insert_item_col_ttb     (GokChunk *pChunk,
                                                             GokChunkitem *pChunkitem);

Adds a chunkitem (key) to a chunk (column). The new chunkitem will be added in the sequence top to bottom (the topmost key is the first key in the sequence).

`pChunk` : | Pointer to the first chunk that will contain the new chunkitem.
`pChunkitem` : | Pointer to the chunkitem that gets added to the chunk.
Returns : | TRUE if the chunkitem was added to the chunk, FALSE if not.

### gok_chunker_insert_item_col_btt ()

    gboolean            gok_chunker_insert_item_col_btt     (GokChunk *pChunk,
                                                             GokChunkitem *pChunkitem);

Adds a chunkitem (key) to a chunk (column). The new chunkitem will be added in the sequence bottom to top (the bottommost key is the first key in the sequence).

`pChunk` : | Pointer to the first chunk that will contain the new chunkitem.
`pChunkitem` : | Pointer to the chunkitem that gets added to the chunk.
Returns : | TRUE if the chunkitem was added to the chunk, FALSE if not.

### gok_chunker_dump_chunks ()

    void                gok_chunker_dump_chunks             (void);

Diagnostic function that prints all the chunks to stdout.

### gok_chunker_dump_chunk ()

    void                gok_chunker_dump_chunk              (GokChunk *pChunk);

Diagnostic function that prints the chunk to stdout.

`pChunk` : | Pointer to the chunk that gets the dump.

### gok_chunker_chunk_group ()

    GokChunk*           gok_chunker_chunk_group             (GokChunk *pChunk,
                                                             gint NumberGroups,
                                                             ChunkOrder Order,
                                                             gboolean bCanReorder);

Breaks the given list of chunks into 2 or more groups.

`pChunk` : | Pointer to the list of chunks that will be broken into groups.
`NumberGroups` : | Number of groups the chunks should be broken into.
`Order` : | The order in which the chunks should be created. (see enum ChunkOrder)
`bCanReorder` : | TRUE if the chunks can be reordered.
Returns : | A pointer to the first chunk in the list of chunks. Returns NULL if the given chunk can't be divided into chunks.

### gok_chunker_add_chunkitem ()

    void                gok_chunker_add_chunkitem           (GokChunk *pChunk,
                                                             GokChunkitem *pChunkitem);

Adds a chunkitem (key) to a chunk (group). The new chunkitem will be added as the last chunkitem in the list.

`pChunk` : | Pointer to the chunk that will contain the new chunkitem.
`pChunkitem` : | Pointer to the chunkitem that gets added to the chunk.

### gok_chunker_count_chunkitems ()

    gint                gok_chunker_count_chunkitems        (GokChunk *pChunk);

Counts the number of items in the given chunk.

`pChunk` : | Pointer to the Chunk that will be counted.
Returns : | The number of items in the chunk.

### gok_chunker_make_2_vertical ()

    GokChunk*           gok_chunker_make_2_vertical         (GokChunk *pChunk);

Creates 2 chunks that split the given chunk vertically.

`pChunk` : | Pointer to the chunk that will be split.
Returns : | A pointer to the first chunk, NULL if it couldn't be created.

### gok_chunker_make_2_horizontal ()

    GokChunk*           gok_chunker_make_2_horizontal       (GokChunk *pChunk);

Create 2 chunks that split the given chunk horizontally.

`pChunk` : | Pointer to the chunks that will be split.
Returns : | A pointer to the first chunk, NULL if none could be created.

### gok_chunker_make_4 ()

    GokChunk*           gok_chunker_make_4                  (GokChunk *pChunk);

Create 4 chunks from the given chunk. The 4 chunks are ordered like: 1 2 3 4

`pChunk` : | Pointer to the first in a list of chunks that will be split.
Returns : | A pointer to the first chunk, NULL if none could be created.

### gok_chunker_highlight_chunk_number ()

    void                gok_chunker_highlight_chunk_number  (gint Number);

Highlight the chunk identified by a number.

`Number` : | Id number of the chunk you want highlighted.

### gok_chunker_get_chunk ()

    GokChunk*           gok_chunker_get_chunk               (gint Number);

Finds a child chunk of the currently highlighted chunk.

`Number` : | Number of the chunk you are looking for.
Returns : | A pointer to the chunk, NULL if not found.

### gok_chunker_highlight_all_keys ()

    void                gok_chunker_highlight_all_keys      (void);

Highlightes all keys on the current keyboard.

### gok_chunker_unhighlight_all_keys ()

    void                gok_chunker_unhighlight_all_keys    (void);

Unhighlightes all keys on the current keyboard.

### gok_chunker_resolve_overlap ()

    void                gok_chunker_resolve_overlap         (GokChunk *pChunk);

If one of the chunks has more than one item, move an item to another chunk.

`pChunk` : | Pointer to the list of chunke sthat need to be resolved.