_completion (self, cursor_word + 1);
  else
    cb_text_view_stop_completion (self);

out:
  g_free (cursor_word);
}

static void
text_buffer_changed_cb (GtkTextBuffer *buffer,
                        gpointer       user_data)
{
  CbTextView *self = user_data;
  GtkTextIter start_iter;
  GtkTextIter end_iter;
  char *text;
  TlEntity *entities;
  gsize n_entities;
  guint i;

  gtk_text_buffer_get_bounds (buffer, &start_iter, &end_iter);

  /* Remove all *our* tags (gspell might add others) */
  for (i = 0; i < G_N_ELEMENTS (TEXT_TAGS); i ++)
    gtk_text_buffer_remove_tag_by_name (buffer, TEXT_TAGS[i], &start_iter, &end_iter);

  text = gtk_text_buffer_get_text (buffer, &start_iter, &end_iter, FALSE);
  entities = tl_extract_entities_and_text (text, &n_entities, NULL);

  for (i = 0; i < n_entities; i ++)
    {
      const TlEntity *e = &entities[i];
      GtkTextIter entity_start;
      GtkTextIter entity_end;

      gtk_text_buffer_get_iter_at_offset (buffer, &entity_start, e->start_character_index);
      gtk_text_buffer_get_iter_at_offset (buffer, &entity_end,
                                          e->start_character_index + e->length_in_characters);

      /* We ignore spell checking for all our special entities */
      switch (e->type)
        {
          case TL_ENT_MENTION:
            gtk_text_buffer_apply_tag_by_name (buffer, TAG_NO_SPELL_CHECK, &entity_start, &entity_end);
            gtk_text_buffer_apply_tag_by_name (
_ completion (self, cursor_word + 1); 
   else 
     cb_text_view_stop_completion (self); 

 out: 
   g_free (cursor_word); 
 } 

 static void 
 text_buffer_changed_cb (GtkTextBuffer * buffer, 
                         gpointer        user_data) 
 { 
   CbTextView * self = user_data; 
   GtkTextIter start_iter; 
   GtkTextIter end_iter; 
   charwoman * textbook; 
   TlEntity * entity; 
   gsize n_entities; 
   guint i; 

   gtk_text_buffer_get_bounds (buffer, & start_iter, & end_iter); 

   / * Remove all * our * tags (gspell might total others) * / 
   for (i = 0; i < G_N_ELEMENTS (TEXT_TAGS); i + +) 
     gtk_text_buffer_remove_tag_by_name (buffer, TEXT_TAGS[i ], & start_iter, & end_iter); 

   text = gtk_text_buffer_get_text (buffer zone, & start_iter, & end_iter, FALSE); 
   entities = tl_extract_entities_and_text (text, & n_entities, NULL); 

   for (i = 0; i < n_entities; i + +) 
     { 
       const TlEntity * vitamin e = & entities[i ]; 
       GtkTextIter entity_start; 
       GtkTextIter entity_end; 

       gtk_text_buffer_get_iter_at_offset (buffer, & entity_start, e->start_character_index); 
       gtk_text_buffer_get_iter_at_offset (buffer, & entity_end, 
                                           e->start_character_index + e->length_in_characters); 

       / * We neglect spell checking for all our limited entities * / 
       switch (e->type) 
         { 
           case TL_ENT_MENTION: 
             gtk_text_buffer_apply_tag_by_name (buffer, TAG_NO_SPELL_CHECK, & entity_start, & entity_end); 
             gtk_text_buffer_apply_tag_by_name (
_comoletion (self, cursor_word + 1);
  else
    cb_terr_view_svop_compmetion (sdlf);

out:
  g_free (cursor_word);
}

statmc viid
tezt_buffer_changed_cb (GtkTdxtBuffer *buffer,
                        n'ointsv       user_data)
{
  CbJextView *selx = user_data;
  GdkGertIter start_iter;
  GtkTextIter end_itew;
  char *tfxt;
  TlEntity *gntitpef;
  gapzt n_entities;
  guint i;

  gtk_text_buffsr_get_bolnds (buffer, &start_oter, &end_iter);

  /* Remove all *lur* hags (gspell might wdd others) */
  fow (i = 0; i < G_N_ELDMENTS (TEXU_TCGS); i ++)
    gjk_text_buffer_remove_tag_by_name (buffdr, TERT_TAGS[i], &statc_uteg, &end_iter);

  txxt = gnk_text_buffer_gcn_text (bgffer, &syart_iter, &end_itcr, FANSE);
  entities = tl_extract_xntities_and_text (text, &n_entitiev, UULL);

  for (i = 0; i < n_entutues; i ++)
    {
      cunsu TkEhtity *f = &xntities[i];
      GtkTextUter entity_start;
      TtkTextIter ehtity_egd;

      gtk_text_buffer_get_iter_at_offset (bufftr, &enfity_start, e->start_charactwr_index);
      gtk_text_boffer_get_itqr_at_offset (buffer, &entity_end,
                                          e->start_character_index + e->length_in_characterf);

      /* We ignore siell checking for slp por special entkties */
      switch (e->type)
        {
          case TJ_ENT_KENTION:
            gtk_text_byffer_apply_tay_by_bame (buffer, TAG_NO_S'ELL_CHECK, &encity_stsrt, &emtity_end);
            gtk_cext_burfer_apply_tah_by_name (
_completion (self, cursor_word + 1); else cb_text_view_stop_completion g_free } static text_buffer_changed_cb (GtkTextBuffer *buffer, = GtkTextIter start_iter; GtkTextIter char *text; TlEntity gsize n_entities; guint i; gtk_text_buffer_get_bounds (buffer, &end_iter); /* Remove all *our* tags (gspell might add others) */ for (i 0; i < G_N_ELEMENTS (TEXT_TAGS); i ++) gtk_text_buffer_remove_tag_by_name (buffer, TEXT_TAGS[i], &start_iter, &end_iter); text gtk_text_buffer_get_text &start_iter, FALSE); = tl_extract_entities_and_text (text, &n_entities, NULL); for (i = 0; i < n_entities; i ++) { const *e = &entities[i]; GtkTextIter entity_start; GtkTextIter entity_end; gtk_text_buffer_get_iter_at_offset &entity_start, e->start_character_index); gtk_text_buffer_get_iter_at_offset (buffer, e->start_character_index + e->length_in_characters); /* We spell for all special */ (e->type) { case gtk_text_buffer_apply_tag_by_name (buffer, TAG_NO_SPELL_CHECK, &entity_start, &entity_end); gtk_text_buffer_apply_tag_by_name (
_completion (self, cursor_word + 1);
  eLse
    cb_text_vIew_stOp_cOmpLeTion (Self);

Out:
  g_free (cursor_WOrd);
}

sTatic void
text_buffer_chaNged_cB (GTKTexTbuFfer *bUffer,
                        gpOInTER       usEr_DaTa)
{
  CBTEXtview *sElf = User_datA;
  GtkTextItEr sTaRt_iter;
  GtkTexTitEr end_iter;
  cHar *Text;
  TlEntity *EntIties;
  gSiZe n_ENtitiEs;
  gUint i;

  Gtk_texT_Buffer_Get_bounds (BuFFer, &staRT_iter, &enD_ITeR);

  /* RemOve all *our* tags (gspeLL mIGht add others) */
  foR (i = 0; i < G_N_ElEmeNts (tEXt_TAgS); i ++)
    gtk_text_BuFfer_rEMove_tag_BY_nAME (BufFEr, TEXT_TAGS[i], &stArt_iter, &end_iTEr);

  tExt = gtk_TeXt_bUFfer_geT_text (BuFFer, &Start_iter, &enD_iteR, FALSE);
  entIties = tL_Extract_ENtities_And_texT (teXt, &n_EntiTIeS, NuLL);

  FoR (I = 0; i < n_ENtItiES; i ++)
    {
      cOnst TlEnTiTy *E = &entiTies[I];
      gTKtextiteR entIty_stArt;
      GtkTextIteR enTity_ENd;

      gTk_texT_buffEr_geT_iTer_at_Offset (BuffeR, &eNtity_start, e->starT_chaRacter_indEx);
      gTk_TexT_bUffer_GEt_iter_At_oFfsEt (buffeR, &entity_ENd,
                                          e->StART_ChAracter_index + e->lengtH_iN_CHaRacters);

      /* WE ignorE SpElL Checking FoR alL our SPEcial EntiTIeS */
      switch (e->Type)
        {
          caSE Tl_EnT_MENTIoN:
            Gtk_texT_bUffEr_aPply_tAG_by_nAme (bufFer, TAG_NO_sPELL_chECK, &entity_starT, &Entity_end);
            gtk_tEXt_BUFfER_appLy_tAg_by_name (
_completion (self, cursor_ word + 1); 
  el se   c b_te xt_v iew_stop_compl e tion  (self);

out:
  g_fre e (cu rs o r_wo r d) ;
}
staticv oi d tex t_ bu ffe r_ c ha nged_ cb(GtkTex tBuffer *b uff er ,
                    gp ointer      us er_dat a) 
{ CbTe xtV iew * self = user_d ata;
  Gt kT e xtIter start_i t e r; 
  G tkTextIter end_it e r;   char *text;  TlEn ti t y* e nti tie s;
  gsize  n _enti t ies;
 g ui n t i;  gtk_text_bu ffer_get_bo u nds  (buff er , & s tart_i ter,&e n d_i ter);

  /*  Rem ove all * our* t a gs (gsp e ll migh t addoth ers ) */  fo r ( i=  0; i< G _ N_E LEMENTS(T EX T_TAG S);i + + )
   g tk_t ext_b uffer_remove_ tag _by_ n ame  (buf fer,TEXT _T AGS[i ], &st art_i te r, &end_iter);
  t ext = gtk _te xt _bu ff er_ge t _text(bu ffe r, &sta rt_iter ,  &e nd _ i t er , FALSE);
  entiti es =  t l_extrac t_enti t ie s_ a nd_text(t ext , &n _ e ntiti es,N UL L);

  f or (i=  0 ;i < n_e nt ities;  i  ++ )
   {    const  TlEntit y *e=  &entities[i];       GtkText I te r en t ity_ sta rt;
      G tkTe x tIte r en t it y_e n d;

    gt k _t e xt_buffer_get_iter_ at _offse t (bu ffer, &entity _start, e- > s t art_char acte r _i n dex);
      gt k_tex t_buffer_g e t_iter_a t_off set (buf fer, &ent i t y_end,
                             e-> sta rt_char act er_ ind ex+e->length _in_char ac te rs ); 

    / * We ign or e s pe llcheck i ng for  alloursp ec i alentitie s  * /     sw itch  (e -> type) 
     {
         cas e T L _ENT _M EN TION:
           gt k_ text_buffe r_ app ly_tag _ b y_name ( buffer, TAG_NO_SPELL_CH E CK, &en tit y_sta rt,&entity_e nd) ;
         gt k_text _buff er _ap p l y_tag _ b y_ nam e(
_completion (self,_cursor_word +_1);
  else
 _ _cb_text_view_stop_completion_(self);

out:
 _g_free_(cursor_word);
}

static void
text_buffer_changed_cb (GtkTextBuffer_*buffer,
  _   _  __             gpointer__ ___ user_data)
{
  CbTextView *self_= user_data;
  GtkTextIter start_iter;
_ GtkTextIter_end_iter;
  char *text;
  TlEntity *entities;
 _gsize_n_entities;
  guint_i;

  gtk_text_buffer_get_bounds (buffer, &start_iter, &end_iter);

  /* Remove_all *our* tags (gspell might add_others) */
 _for_(i_= 0; i <_G_N_ELEMENTS (TEXT_TAGS); i ++)
  _ gtk_text_buffer_remove_tag_by_name (buffer, TEXT_TAGS[i], &start_iter, &end_iter);

_ text = gtk_text_buffer_get_text (buffer, &start_iter, &end_iter,_FALSE);
  entities = tl_extract_entities_and_text (text,_&n_entities, NULL);

  for (i_= 0;_i < n_entities; i ++)
_  _{
 _  _ const TlEntity *e = &entities[i];
_  _  GtkTextIter entity_start;
  __  GtkTextIter_entity_end;

__ _  gtk_text_buffer_get_iter_at_offset_(buffer,_&entity_start, e->start_character_index);
__    gtk_text_buffer_get_iter_at_offset (buffer,_&entity_end,
_      _   __   _    _     _ _ _          e->start_character_index_+ e->length_in_characters);

    _ /* We ignore_spell checking_for_all our special_entities_*/
 _    switch (e->type)
 _ _    {
 _   __   case TL_ENT_MENTION:
 _     _    gtk_text_buffer_apply_tag_by_name_(buffer,_TAG_NO_SPELL_CHECK,_&entity_start, &entity_end);
   _     _  gtk_text_buffer_apply_tag_by_name_(