]> git.lyx.org Git - lyx.git/blobdiff - src/intl.C
citation patch from Angus
[lyx.git] / src / intl.C
index eebc879f390c03aa9e04f27248228f06c83a3252..faaa79910bdc046a2e8f0a6453dbd9452c5424d3 100644 (file)
@@ -4,7 +4,7 @@
  *           LyX, The Document Processor
  *      
  *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-1999 The LyX Team.
+ *           Copyright 1995-2000 The LyX Team.
  *
  * ====================================================== */
 
 #include "lyxrc.h"
 #include "trans_mgr.h"
 #include "support/lstrings.h"
+#include "language.h"
 
-extern LyXRC * lyxrc;
+using std::endl;
 
 // a wrapper around the callback static member.
 extern "C" void C_Intl_DispatchCallback(FL_OBJECT * ob, long code);
 
 
 Intl::Intl()
-       : prim_lang(lyxrc->primary_kbmap), 
-       sec_lang(lyxrc->secondary_kbmap),
+       : prim_lang(lyxrc.primary_kbmap), 
+       sec_lang(lyxrc.secondary_kbmap),
        trans(new TransManager)
 {
-       keymapon = lyxrc->use_kbmap;
+       keymapon = lyxrc.use_kbmap;
        chsetcode = 0;
        primarykeymap = false;
        curkeymap = 0;
@@ -66,9 +67,9 @@ int Intl::SetSecondary(string const & lang)
 
 void Intl::update()
 {
-       int off, prim, sec;
-       
-       off = prim = sec = 0;
+       int off = 0;
+       int prim = 0;
+       int sec = 0;
        
        if (!keymapon) {
                off = 1;
@@ -130,9 +131,6 @@ void Intl::KeyMapPrim()
 
        /* read text from choice */
        int i = Language->get();
-       
-       if (lyxerr.debugging(Debug::KBMAP))
-               lyxerr << "Table: " << tex_babel[i-1] << endl;
 
        string p;
        if (i == otherkeymap)
@@ -164,9 +162,6 @@ void Intl::KeyMapSec()
 
        /* read text from choice */
        int i = Language2->get();
-       
-       if (lyxerr.debugging(Debug::KBMAP))
-               lyxerr << "Table: " << tex_babel[i-1] << endl;
 
        string p;
        if (i == otherkeymap)
@@ -219,11 +214,13 @@ void Intl::DispatchCallback(FL_OBJECT * ob, long code)
        if (itl!= 0) itl->Keymap(code);
 }
 
+
 extern "C" void C_Intl_DispatchCallback(FL_OBJECT * ob, long code)
 {
        Intl::DispatchCallback(ob, code);
 }
 
+
 void Intl::InitKeyMapper(bool on)
        /* initialize key mapper */
 {
@@ -270,7 +267,7 @@ void Intl::InitKeyMapper(bool on)
 
        fl_hide_object(fd_form_keymap->KeymapErr);
        fl_hide_object(fd_form_keymap->ChsetErr);
-       fl_set_input(fd_form_keymap->Charset, lyxrc->font_norm.c_str());
+       fl_set_input(fd_form_keymap->Charset, lyxrc.font_norm.c_str());
 
        // Adds two comboxes to the keyboard map
        fl_addto_form(fd_form_keymap->KeyMap);
@@ -278,20 +275,20 @@ void Intl::InitKeyMapper(bool on)
        Language2->add(120, 110, 160, 30, 300); // Secondary
        fl_end_form();
 
-       int n = 0;
+       int n = 1;
+       // Default is not in the language map
+       Language->addto("default");
+       Language2->addto("default");
+       for (Languages::const_iterator cit = languages.begin();
+            cit != languages.end(); ++cit) {
+               Language->addto((*cit).second.lang().c_str());
+               Language2->addto((*cit).second.lang().c_str());
+               ++n;
+       }
 
-       while (true)
-               if (!strlen(tex_babel[n]))
-                       break;
-               else {
-                       Language->addto(tex_babel[n]);
-                       Language2->addto(tex_babel[n]);
-                       n++;
-               }
-       
        Language->addto(_("other..."));
        Language2->addto(_("other..."));
-       otherkeymap = n+1;
+       otherkeymap = n + 1;
        if (!Language->select_text(prim_lang.c_str())) {
                Language->select(n+1);
                fl_set_input(fd_form_keymap->OtherKeymap, prim_lang.c_str());
@@ -300,7 +297,7 @@ void Intl::InitKeyMapper(bool on)
                trans->SetPrimary(prim_lang);
 
        if (!Language2->select_text(sec_lang.c_str())) {
-               Language2->select(n+1);
+               Language2->select(n + 1);
                fl_set_input(fd_form_keymap->OtherKeymap2, sec_lang.c_str());
        }
        else
@@ -310,7 +307,7 @@ void Intl::InitKeyMapper(bool on)
        if (keymapon)
                Keymap(23); // turn primary on
 
-       trans->setCharset(lyxrc->font_norm.c_str());
+       trans->setCharset(lyxrc.font_norm.c_str());
 }
 
 
@@ -319,6 +316,9 @@ void Intl::Keymap(long code)
        if (lyxerr.debugging(Debug::KBMAP))
                lyxerr << "KeyMap callback: " << code << endl;
 
+       // Did you wonder if it is possible to write spagetti code with
+       // other constructs thatn goto's? Well here we have a nice small
+       // spagetti example using a switch... (Lgb)
        switch (code) {
        case 0:
                /* cancel/hide */