Back to index

im-sdk  12.3.91
Classes | Typedefs | Functions
lookupbuf.h File Reference
#include "utfchar.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _LookupBufferStruct
struct  _LookupBufferPage

Typedefs

typedef struct _LookupBufferStruct
typedef struct _LookupBufferPage

Functions

LookupBufferStruct * hangul_lookupbuf_new (int n_candidates, int count_per_page, UTFCHAR **string_list)
Bool hangul_lookupbuf_free (LookupBufferStruct *lub)
LookupBufferPage * hangul_lookupbuf_get_current_page (LookupBufferStruct *lub)
int hangul_lookupbuf_get_current_selection_index (LookupBufferStruct *lub)
void hangul_lookupbuf_get_current_page_candidates (LookupBufferStruct *lub, int *n_candidates_return, int *n_current_candidate, UTFCHAR ***candidates_list_return)
UTFCHARhangul_lookupbuf_get_candidate_string (LookupBufferStruct *lub, int i)
void hangul_lookupbuf_next_page (LookupBufferStruct *lub)
void hangul_lookupbuf_previous_page (LookupBufferStruct *lub)
int hangul_lookupbuf_get_count_of_candidates_in_current_page (LookupBufferStruct *lub)
void hangul_lookupbuf_next_candidate (LookupBufferStruct *lub)

Class Documentation

struct _LookupBufferStruct

Definition at line 8 of file lookupbuf.h.

Class Members
int n_candidates
int n_items_per_page
LookupBufferPage * p_current_page
LookupBufferPage * page_list
struct _LookupBufferPage

Definition at line 14 of file lookupbuf.h.

Collaboration diagram for _LookupBufferPage:
Class Members
int i_candidate
int n_strings
struct _LookupBufferPage * next
struct _LookupBufferPage * prev
UTFCHAR ** string_list

Typedef Documentation

typedef struct _LookupBufferPage

Definition at line 6 of file lookupbuf.h.

typedef struct _LookupBufferStruct

Definition at line 5 of file lookupbuf.h.


Function Documentation

Bool hangul_lookupbuf_free ( LookupBufferStruct *  lub)

Definition at line 76 of file lookupbuf.c.

{
  LookupBufferPage *p, *pnext;
  
  if (lub == NULL){
    fprintf (stderr, "hangul_lookupbuf_free error: lub is already NULL\n");
    return True;
  }
  p = lub->page_list;
  while (p){
    pnext = p->next;
    hangul_lookupbuf_page_free (p);
    p = pnext;
  }
  return True;
}

Here is the call graph for this function:

Here is the caller graph for this function:

UTFCHAR* hangul_lookupbuf_get_candidate_string ( LookupBufferStruct *  lub,
int  i 
)

Definition at line 186 of file lookupbuf.c.

{
  UTFCHAR *str_return;
  LookupBufferPage *page;
  assert (lub != NULL);
  if (lub == NULL){
    fprintf (stderr, "hangul_lookupbuf_get_candidate_string error :"
            "lub is null \n");
    return NULL;
  }
  page = lub->p_current_page;
  if (!page){
    fprintf (stderr, "hangul_lookupbuf_get_candidate_string error :"
            "lub->p_current_page is null \n");
    return NULL;
  }
  str_return = hangul_lookupbuf_page_get_candidate_string (page, i);
  return str_return;
} 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 270 of file lookupbuf.c.

{
  LookupBufferPage *page;
  assert (lub != NULL);
  if (lub == NULL){
    fprintf (stderr,
            "hangul_lookupbuf_get_count_of_candidates_in_current_page error :"
            "lub is NULL\n");
    return -1;
  }
  page = lub->p_current_page;
  if (page == NULL){
    fprintf (stderr, 
            "hangul_lookupbuf_get_count_of_candidates_in_current_page error :"
            "lub->p_current_page is NULL\n");
    return -1;    
  }
  return page->n_strings;
}

Here is the caller graph for this function:

LookupBufferPage* hangul_lookupbuf_get_current_page ( LookupBufferStruct *  lub)

Definition at line 94 of file lookupbuf.c.

{
  assert (lub != NULL);
  if (lub == NULL){
    fprintf (stderr, "hangul_lookupbuf_get_current_page error :"
            "lub is null\n");
    return NULL;
  }
  if (!lub->p_current_page){
    if (lub->page_list)
      lub->p_current_page = lub->page_list;
    else
      return NULL;
  }
  return lub->p_current_page;
}
void hangul_lookupbuf_get_current_page_candidates ( LookupBufferStruct *  lub,
int *  n_candidates_return,
int *  n_current_candidate,
UTFCHAR ***  candidates_list_return 
)

Definition at line 129 of file lookupbuf.c.

{
  int i;
  LookupBufferPage *p_page;
  
  assert (lub != NULL);
  if (lub == NULL){
    fprintf (stderr, "hangul_lookupbuf_get_current_page error :"
            "lub is null\n");
    return;
  }
  if (!lub->p_current_page){
    if (lub->page_list)
      lub->p_current_page = lub->page_list;
    else {
      *n_candidates_return = 0;
      *n_current_candidate = -1;
      *candidates_list_return = NULL;
      return ;
    }
  }
  p_page = lub->p_current_page;

  *n_candidates_return = p_page->n_strings;
  *n_current_candidate = p_page->i_candidate;
  *candidates_list_return = (UTFCHAR **) calloc (*n_candidates_return,
                                           sizeof (UTFCHAR *));
  for (i = 0 ; i < *n_candidates_return; i++)
    (*candidates_list_return)[i] = _utfchar_dup (p_page->string_list[i]);
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int hangul_lookupbuf_get_current_selection_index ( LookupBufferStruct *  lub)

Definition at line 112 of file lookupbuf.c.

{
  int i;
  assert (lub != NULL);
  if (lub == NULL){
    fprintf (stderr, "hangul_lookupbuf_get_current_selection_index error :"
            "lub is null\n");
    return -1;
  }
  if (!lub->p_current_page)
    return -1;

  i = hangul_lookupbuf_page_get_current_selection_index (lub->p_current_page);
  return i;
}

Here is the call graph for this function:

Here is the caller graph for this function:

LookupBufferStruct* hangul_lookupbuf_new ( int  n_candidates,
int  count_per_page,
UTFCHAR **  string_list 
)

Definition at line 20 of file lookupbuf.c.

{
  LookupBufferStruct *lub = NULL;
  LookupBufferPage *lup = NULL;
  
  int i;
  int n_pages;
  int n_last_page_size = 0;
  
  assert (n_candidates > 0);
  assert (string_list != NULL);

  if ((n_candidates <= 0) || (string_list == NULL)){
    fprintf (stderr, "hangul_lookupbuf_new error: "
            "n_candidates or string_list is not valid\n");
    return NULL;
  }

  lub = (LookupBufferStruct *) calloc (1, sizeof (LookupBufferStruct));

  lub->n_candidates = n_candidates;
  lub->n_items_per_page = count_per_page;
  lub->p_current_page = NULL;
  lub->page_list = NULL;

  n_last_page_size = n_candidates % lub->n_items_per_page;
  if (!n_last_page_size)
    n_pages = n_candidates / lub->n_items_per_page;
  else
    n_pages = n_candidates / lub->n_items_per_page +1;

  for (i = 0 ; i < n_pages; i++){
    if ( i < n_pages - 1){
       lup =
         hangul_lookupbuf_page_new (lub->n_items_per_page,
                                 string_list + (i * count_per_page));
    } else {
      if (n_last_page_size){
       lup =
         hangul_lookupbuf_page_new ( n_last_page_size,
                                  string_list + (i * count_per_page));
      } else {
       lup =
         hangul_lookupbuf_page_new (lub->n_items_per_page,
                                 string_list + (i *count_per_page));
      }
    }
    hangul_lookupbuf_append_page (lub, lup);
    lup = NULL;
  }
  lub->p_current_page = lub->page_list;
  hangul_lookupbuf_page_set_focus (lub->p_current_page);
  return lub;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void hangul_lookupbuf_next_candidate ( LookupBufferStruct *  lub)

Definition at line 327 of file lookupbuf.c.

{
  Bool move_to_next_page = False;
  LookupBufferPage *p;

  assert (lub != NULL);
  if (lub == NULL){
    fprintf (stderr, "hangul_lookupbuf_next_candidate error :"
            "lub is NULL\n");
    return;
  }

  if (!lub->p_current_page){
    if (!lub->page_list){
      fprintf (stderr, "hangul_lookupbuf_next_candidate error :"
              "fatal error, not lookup page\n");
      return;
    }
    lub->p_current_page = lub->page_list;
  } 

  p = lub->p_current_page;
  
  hangul_lookupbuf_page_next_candidate (p, &move_to_next_page);
  if (move_to_next_page){
    hangul_lookupbuf_page_unset_focus (lub->p_current_page);
    if (p->next)
      lub->p_current_page = p->next;
    else
      lub->p_current_page = lub->page_list;
    hangul_lookupbuf_page_set_focus (lub->p_current_page);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void hangul_lookupbuf_next_page ( LookupBufferStruct *  lub)

Definition at line 207 of file lookupbuf.c.

{
  assert (lub != NULL);
  if (lub == NULL){
    fprintf (stderr, "hangul_lookupbuf_next_page error: "
            "lub is NULL\n");
    return;
  }
  
  if (!lub->p_current_page){
    lub->p_current_page = lub->page_list;
    hangul_lookupbuf_page_set_focus (lub->p_current_page);
  } else {
    if (lub->p_current_page->next){
      hangul_lookupbuf_page_unset_focus (lub->p_current_page);
      lub->p_current_page = lub->p_current_page->next;
      hangul_lookupbuf_page_set_focus (lub->p_current_page);
    }
    else {
      hangul_lookupbuf_page_unset_focus (lub->p_current_page);
      lub->p_current_page = lub->page_list;
      hangul_lookupbuf_page_set_focus (lub->p_current_page);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void hangul_lookupbuf_previous_page ( LookupBufferStruct *  lub)

Definition at line 235 of file lookupbuf.c.

{
  assert (lub != NULL);
  if (lub == NULL){
    fprintf (stderr, "hangul_lookupbuf_next_page error: "
            "lub is NULL\n");
    return;
  }
  
  if (!lub->p_current_page){
    lub->p_current_page = lub->page_list;
    hangul_lookupbuf_page_set_focus (lub->p_current_page);
  } else {
    if (lub->p_current_page->prev){
      hangul_lookupbuf_page_unset_focus (lub->p_current_page);
      lub->p_current_page = lub->p_current_page->prev;
      hangul_lookupbuf_page_set_focus (lub->p_current_page);
    } else {
      /* This is not efficient... */
      LookupBufferPage *p = lub->page_list;
      LookupBufferPage *tail = NULL;
      hangul_lookupbuf_page_unset_focus (lub->p_current_page);
      while (p){
       tail = p;
       p = p->next;
      }
      p = tail;
      /* p is the last page */
      lub->p_current_page = p;
      hangul_lookupbuf_page_set_focus (lub->p_current_page);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function: