Back to index

texmacs  1.0.7.15
Functions
mac_spellservice.h File Reference
#include "tree.hpp"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

string mac_spell_start (string lan)
tree mac_spell_check (string lan, string s)
void mac_spell_accept (string lan, string s)
void mac_spell_insert (string lan, string s)
void mac_spell_done (string lan)

Function Documentation

void mac_spell_accept ( string  lan,
string  s 
)

Definition at line 144 of file mac_spellservice.mm.

                                        {
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  if ((lan != current_lang) && (! mac_spelling_language (lan))) {
    // do nothing
    ;
  } else {
    [[NSSpellChecker sharedSpellChecker]  ignoreWord:to_nsstring_utf8 (s) inSpellDocumentWithTag:current_tag];
  }  
  //  ispell_send (lan, "@" * s);
  [pool release];
}

Here is the call graph for this function:

tree mac_spell_check ( string  lan,
string  s 
)

Definition at line 104 of file mac_spellservice.mm.

                                       {
  if (DEBUG_EVENTS) cout << "spell_check " << lan << " :: " << s << LF;
  tree t;
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  if ((lan != current_lang) && (! mac_spelling_language (lan))) {
      t = "Error: dictionary not available";
  } else {
    NSString *nss = to_nsstring_utf8 (s);
    NSRange r =  [[NSSpellChecker sharedSpellChecker]  
                  checkSpellingOfString: nss
                  startingAt: 0
                  language: nil
                  wrap: NO
                  inSpellDocumentWithTag: current_tag
                  wordCount: NULL];
    if (r.length == 0) 
      t = "ok";
    else {
      NSArray *arr = [[NSSpellChecker sharedSpellChecker] guessesForWord: nss];
      if ([arr count] == 0) {
        t = tree (TUPLE, "0");
      } else {
        NSEnumerator *enumerator = [arr objectEnumerator];
        NSString *sugg;
        tree a (TUPLE);
        while ((sugg = (NSString*)[enumerator nextObject])) {
          a << from_nsstring (sugg);
        }
        t= tree (TUPLE, as_string((int)[arr count]));
        t << A (a);        
      }
    }
  }
  [pool release];

  if (DEBUG_EVENTS)   cout << t << LF;     
  return t;
}

Here is the call graph for this function:

void mac_spell_done ( string  lan)

Definition at line 170 of file mac_spellservice.mm.

                            {
  (void) lan;
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  [[NSSpellChecker sharedSpellChecker] closeSpellDocumentWithTag:current_tag];
  current_tag = 0;
  [pool release];
}
void mac_spell_insert ( string  lan,
string  s 
)

Definition at line 157 of file mac_spellservice.mm.

                                        {
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  if ((lan != current_lang) && (! mac_spelling_language (lan))) {
    // do nothing
    ;
  } else {
    [[NSSpellChecker sharedSpellChecker] learnWord:to_nsstring_utf8 (s)];
  }  
  //  ispell_send (lan, "*" * s);
  [pool release];
}

Here is the call graph for this function:

Definition at line 84 of file mac_spellservice.mm.

                             {
  string r;
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  // we need to be sure that the Cocoa application infrastructure is initialized 
  // (apparently Qt does not do this properly and the NSSpellChecker instance returns null
  //  without the following instruction)
  NSApplication *NSApp=[NSApplication sharedApplication]; (void) NSApp;
  mac_init_dictionary ();
  if (mac_spelling_language (lan)) {
    // warning: we must be sure that the tag is relased by the appropriate message to sharedSpellChecker
    current_tag = [NSSpellChecker uniqueSpellDocumentTag];
    r = "ok";
  } else {
    r = "Error: no dictionary for#" * lan;
  }  
  [pool release];
  return r;
}

Here is the call graph for this function: