"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/System/Language/language.cpp" between
TeXmacs-1.99.8-src.tar.gz and TeXmacs-1.99.9-src.tar.gz

About: GNU TeXmacs is a what-you-see-is-what-you-get scientific text editor, which was both inspired by TeX and GNU Emacs.

language.cpp  (TeXmacs-1.99.8-src):language.cpp  (TeXmacs-1.99.9-src)
skipping to change at line 15 skipping to change at line 15
******************************************************************************* *******************************************************************************
* This software falls under the GNU general public license version 3 or later. * This software falls under the GNU general public license version 3 or later.
* It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
* in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>. * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
******************************************************************************/ ******************************************************************************/
#include "impl_language.hpp" #include "impl_language.hpp"
#include "packrat.hpp" #include "packrat.hpp"
#include "analyze.hpp" #include "analyze.hpp"
#include "hyphenate.hpp" #include "hyphenate.hpp"
#include "iterator.hpp"
#include "universal.hpp"
RESOURCE_CODE(language); RESOURCE_CODE(language);
text_property_rep global_tpr; text_property_rep global_tpr;
text_property_rep tp_normal_rep text_property_rep tp_normal_rep
(TP_NORMAL); (TP_NORMAL);
text_property_rep tp_hyph_rep text_property_rep tp_hyph_rep
(TP_HYPH, SPC_NONE, SPC_NONE, 0, 0); (TP_HYPH, SPC_NONE, SPC_NONE, 0, 0);
text_property_rep tp_thin_space_rep text_property_rep tp_thin_space_rep
skipping to change at line 360 skipping to change at line 362
language language
ad_hoc_language (language base, tree hyphs) { ad_hoc_language (language base, tree hyphs) {
static hashmap<tree,int> abbrevs; static hashmap<tree,int> abbrevs;
if (!abbrevs->contains (hyphs)) if (!abbrevs->contains (hyphs))
abbrevs (hyphs)= N (abbrevs); abbrevs (hyphs)= N (abbrevs);
string name= base->res_name * "-" * as_string (abbrevs [hyphs]); string name= base->res_name * "-" * as_string (abbrevs [hyphs]);
if (language::instances -> contains (name)) return language (name); if (language::instances -> contains (name)) return language (name);
return tm_new<ad_hoc_language_rep> (name, base, hyphs); return tm_new<ad_hoc_language_rep> (name, base, hyphs);
} }
/******************************************************************************
* Interface with spell engines and cache
******************************************************************************/
#ifdef MACOSX_EXTENSIONS
#include "MacOS/mac_spellservice.h"
#define ispell_start mac_spell_start
#define ispell_check mac_spell_check
#define ispell_accept mac_spell_accept
#define ispell_insert mac_spell_insert
#define ispell_done mac_spell_done
#else
#include "Ispell/ispell.hpp"
#endif
static bool spell_active= false;
static hashmap<string,bool> spell_busy (false);
static hashmap<string,int > spell_cache (0);
static hashmap<string,bool> spell_temp (false);
void
spell_start () {
spell_active= true;
}
void
spell_done () {
spell_active= false;
hashmap<string,bool> h= copy (spell_busy);
for (iterator<string> it= iterate (h); it->busy (); )
spell_done (it->next ());
}
string
spell_start (string lan) {
if (spell_busy->contains (lan)) return "ok";
spell_busy (lan)= true;
return ispell_start (lan);
}
void
spell_done (string lan) {
if (spell_active) return;
spell_busy->reset (lan);
ispell_done (lan);
hashmap<string,bool> aux (false);
for (iterator<string> it= iterate (spell_temp); it->busy (); ) {
string key= it->next ();
if (starts (key, lan * ":")) aux (key)= true;
}
for (iterator<string> it= iterate (aux); it->busy (); ) {
string key= it->next ();
spell_cache->reset (key);
spell_temp ->reset (key);
}
}
tree
spell_check (string lan, string s) {
if (spell_busy->contains (lan)) {
if (lan == "verbatim") return "ok";
string f= uni_Locase_all (s);
if (f == s) {
tree r= ispell_check (lan, s);
return r;
}
else {
string l= uni_locase_all (s);
tree r= ispell_check (lan, l);
if (s == uni_upcase_all (s) && is_tuple (r))
for (int i=1; i<N(r); i++)
if (is_atomic (r[i]))
r[i]= uni_upcase_all (r[i]->label);
return r;
}
}
else {
spell_start (lan);
tree r= spell_check (lan, s);
spell_done (lan);
return r;
}
}
bool
check_word (string lan, string s) {
string key= lan * ":" * s;
string f= uni_Locase_all (s);
string l= uni_locase_first (f);
if (s != l && s != f) key= lan * ":" * l;
int val= spell_cache[key];
if (val == 0) {
tree t= spell_check (lan, s);
if (t == "ok") val= 1;
else val= -1;
spell_cache (key)= val;
}
return val == 1;
}
void
spell_accept (string lan, string s, bool permanent) {
string f= uni_Locase_all (s);
string l= uni_locase_first (f);
if (s != f) s= l;
string key= lan * ":" * s;
spell_cache (key) = 1;
if (!permanent) spell_temp (key)= 1;
ispell_accept (lan, s);
}
void
spell_insert (string lan, string s) {
string f= uni_Locase_all (s);
string l= uni_locase_first (f);
if (s != f) s= l;
string key= lan * ":" * s;
spell_cache (key) = 1;
ispell_insert (lan, s);
}
 End of changes. 2 change blocks. 
0 lines changed or deleted 2 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)