home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / lyx-0.13.2.tar.gz / lyx-0.13.2.tar / lyx-0.13.2 / src / lyxrc.C < prev    next >
C/C++ Source or Header  |  1998-04-23  |  21KB  |  802 lines

  1. /* This file is part of
  2. * ======================================================
  3. *           LyX, The Document Processor
  4. *      
  5. *        Copyright (C) 1995 Matthias Ettrich
  6. *           Copyright (C) 1995-1998 The LyX Team.
  7. *
  8. *======================================================*/
  9.  
  10. #include <config.h>
  11.  
  12. #ifdef __GNUG__
  13. #pragma implementation "lyxrc.h"
  14. #endif
  15.  
  16. #include "error.h"
  17.  
  18. #include "lyxrc.h"
  19. #include "LyXAction.h"
  20. #include "lyxserver.h"
  21. #include "lyx_main.h"
  22. #include "intl.h"
  23. #include "tex-strings.h"
  24. #include "path.h"
  25. #include "filetools.h"
  26. #include "lyxtext.h"
  27.  
  28. //     $Id: lyxrc.C,v 1.1.1.1 1998/04/23 16:02:51 larsbj Exp $    
  29.  
  30. #if !defined(lint) && !defined(WITH_WARNINGS)
  31. static char vcid[] = "$Id: lyxrc.C,v 1.1.1.1 1998/04/23 16:02:51 larsbj Exp $";
  32. #endif /* lint */
  33.  
  34. // this is crappy... why are those colors command line arguments and
  35. // not in lyxrc?? (Matthias) 
  36. // Because nobody put them there. (Asger)
  37. extern LString background_color;
  38. extern char selection_color[];
  39. extern bool cursor_follows_scrollbar;
  40. extern kb_keymap *toplevel_keymap;
  41. extern LyXAction lyxaction;
  42.  
  43. enum _LyXRCTags {
  44.     RC_BEGINTOOLBAR=1,
  45.     RC_FONT_ENCODING,
  46.     RC_PRINTER,
  47.     RC_PRINT_COMMAND,
  48.     RC_PRINTEVENPAGEFLAG,
  49.     RC_PRINTODDPAGEFLAG,
  50.     RC_PRINTREVERSEFLAG,
  51.     RC_PRINTLANDSCAPEFLAG,
  52.     RC_PRINTTOPRINTER,
  53.     RC_PRINT_ADAPTOUTPUT,
  54.     RC_PRINTTOFILE,
  55.     RC_PRINTFILEEXTENSION,
  56.     RC_PRINTEXSTRAOPTIONS,
  57.     RC_PRINTSPOOL_COMMAND,
  58.     RC_PRINTSPOOL_PRINTERPREFIX,
  59.     RC_CUSTOM_EXPORT_COMMAND,
  60.     RC_CUSTOM_EXPORT_FORMAT,
  61.     RC_LATEX_COMMAND,
  62.     RC_SCREEN_DPI,
  63.     RC_SCREEN_ZOOM,
  64.     RC_SCREEN_FONT_SIZES,
  65.     RC_SCREEN_FONT_ROMAN,
  66.     RC_SCREEN_FONT_SANS,
  67.     RC_SCREEN_FONT_TYPEWRITER,
  68.     RC_SCREEN_FONT_MENU,
  69.     RC_SCREEN_FONT_POPUP,
  70.     RC_SCREEN_FONT_ENCODING,
  71.     RC_AUTOSAVE,
  72.     RC_SGML_EXTRA_OPTIONS,
  73.     RC_DOCUMENTPATH,
  74.     RC_TEMPLATEPATH,
  75.     RC_TEMPDIRPATH,
  76.     RC_USETEMPDIR,
  77.     RC_LASTFILES,
  78.     RC_AUTOREGIONDELETE,
  79.     RC_BIND,
  80.     RC_SERVERPIPE,
  81.     RC_NOMENUACCELERATORS,
  82.     RC_INPUT,
  83.     RC_BINDFILE,
  84.     RC_KBMAP,
  85.     RC_KBMAP_PRIMARY,
  86.     RC_KBMAP_SECONDARY,
  87.     RC_SELECTION_COLOR,
  88.     RC_BACKGROUND_COLOR,
  89.     RC_FAX_COMMAND,
  90.     RC_PHONEBOOK,
  91.     RC_FAXPROGRAM,
  92.     RC_ASCIIROFF_COMMAND,
  93.     RC_ASCII_LINELEN,
  94.     RC_NUMLASTFILES,
  95.     RC_CHECKLASTFILES,
  96.     RC_VIEWDVI_COMMAND,
  97.     RC_DEFAULT_PAPERSIZE,
  98.     RC_PS_COMMAND,
  99.     RC_VIEWPS_COMMAND,
  100.     RC_VIEWPSPIC_COMMAND,
  101.     RC_ACCEPT_COMPOUND,
  102.     RC_USE_INP_ENC,
  103.     RC_USE_ALT_LANG,
  104.     RC_USE_PERS_DICT,
  105.     RC_USE_ESC_CHARS,
  106.     RC_SCREEN_FONT_SCALABLE,
  107.     RC_ALT_LANG,
  108.     RC_PERS_DICT,
  109.     RC_ESC_CHARS,
  110.     RC_CHKTEX_COMMAND,
  111.     RC_CURSOR_FOLLOWS_SCROLLBAR,
  112.     RC_EXIT_CONFIRMATION,
  113.     RC_DISPLAY_SHORTCUTS,
  114.     RC_LAST    
  115. };
  116.  
  117. static keyword_item lyxrcTags[] = {
  118.     { "\\accept_compound", RC_ACCEPT_COMPOUND },
  119.     { "\\alternate_language", RC_ALT_LANG },
  120.     { "\\ascii_linelen", RC_ASCII_LINELEN },
  121.     { "\\ascii_roff_command", RC_ASCIIROFF_COMMAND },
  122.     { "\\auto_region_delete", RC_AUTOREGIONDELETE },
  123.     { "\\autosave", RC_AUTOSAVE },
  124.     { "\\background_color", RC_BACKGROUND_COLOR },
  125.     { "\\begin_toolbar", RC_BEGINTOOLBAR },
  126.     { "\\bind", RC_BIND },
  127.     { "\\bind_file", RC_BINDFILE },
  128.     { "\\check_lastfiles", RC_CHECKLASTFILES },
  129.     { "\\chktex_command", RC_CHKTEX_COMMAND },
  130.     { "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
  131.     { "\\custom_export_command", RC_CUSTOM_EXPORT_COMMAND },
  132.     { "\\custom_export_format", RC_CUSTOM_EXPORT_FORMAT },
  133.     { "\\default_papersize", RC_DEFAULT_PAPERSIZE },
  134.     { "\\display_shortcuts", RC_DISPLAY_SHORTCUTS },
  135.     { "\\document_path", RC_DOCUMENTPATH },
  136.     { "\\escape_chars", RC_ESC_CHARS },
  137.     { "\\exit_confirmation", RC_EXIT_CONFIRMATION },
  138.     { "\\fax_command", RC_FAX_COMMAND },
  139.     { "\\fax_program", RC_FAXPROGRAM },
  140.     { "\\font_encoding", RC_FONT_ENCODING },
  141.     { "\\input", RC_INPUT },
  142.     { "\\kbmap", RC_KBMAP },
  143.     { "\\kbmap_primary", RC_KBMAP_PRIMARY },
  144.     { "\\kbmap_secondary", RC_KBMAP_SECONDARY },
  145.     { "\\lastfiles", RC_LASTFILES },
  146.     { "\\latex_command", RC_LATEX_COMMAND },
  147.     { "\\num_lastfiles", RC_NUMLASTFILES },
  148.     { "\\personal_dictionary", RC_PERS_DICT },
  149.     { "\\phone_book", RC_PHONEBOOK },
  150.     { "\\print_adapt_output", RC_PRINT_ADAPTOUTPUT },
  151.     { "\\print_command", RC_PRINT_COMMAND },
  152.     { "\\print_evenpage_flag", RC_PRINTEVENPAGEFLAG },
  153.     { "\\print_extra_options", RC_PRINTEXSTRAOPTIONS },
  154.     { "\\print_file_extension", RC_PRINTFILEEXTENSION },
  155.     { "\\print_landscape_flag", RC_PRINTLANDSCAPEFLAG },
  156.     { "\\print_oddpage_flag", RC_PRINTODDPAGEFLAG },
  157.     { "\\print_reverse_flag", RC_PRINTREVERSEFLAG },
  158.     { "\\print_spool_command", RC_PRINTSPOOL_COMMAND },
  159.     { "\\print_spool_printerprefix", RC_PRINTSPOOL_PRINTERPREFIX },
  160.     { "\\print_to_file", RC_PRINTTOFILE },
  161.     { "\\print_to_printer", RC_PRINTTOPRINTER },
  162.     { "\\printer", RC_PRINTER },
  163.     { "\\ps_command", RC_PS_COMMAND },
  164.     { "\\screen_dpi", RC_SCREEN_DPI },
  165.     { "\\screen_font_encoding", RC_SCREEN_FONT_ENCODING },
  166.     { "\\screen_font_menu", RC_SCREEN_FONT_MENU },
  167.     { "\\screen_font_popup", RC_SCREEN_FONT_POPUP },
  168.     { "\\screen_font_roman", RC_SCREEN_FONT_ROMAN },
  169.     { "\\screen_font_sans", RC_SCREEN_FONT_SANS },
  170.     { "\\screen_font_scalable", RC_SCREEN_FONT_SCALABLE },
  171.     { "\\screen_font_sizes", RC_SCREEN_FONT_SIZES },
  172.     { "\\screen_font_typewriter", RC_SCREEN_FONT_TYPEWRITER },
  173.     { "\\screen_zoom", RC_SCREEN_ZOOM },
  174.     { "\\selection_color", RC_SELECTION_COLOR },
  175.     { "\\serverpipe", RC_SERVERPIPE },
  176.     { "\\sgml_extra_options", RC_SGML_EXTRA_OPTIONS },
  177.     { "\\tempdir_path", RC_TEMPDIRPATH },
  178.     { "\\template_path", RC_TEMPLATEPATH },
  179.     { "\\use_alt_language", RC_USE_ALT_LANG },
  180.     { "\\use_escape_chars", RC_USE_ESC_CHARS },
  181.     { "\\use_input_encoding", RC_USE_INP_ENC },
  182.     { "\\use_personal_dictionary", RC_USE_PERS_DICT },
  183.     { "\\use_tempdir", RC_USETEMPDIR },
  184.     { "\\view_dvi_command", RC_VIEWDVI_COMMAND },
  185.     { "\\view_ps_command", RC_VIEWPS_COMMAND },
  186.     { "\\view_pspic_command", RC_VIEWPSPIC_COMMAND }
  187. };
  188.  
  189. /* Let the range depend of the size of lyxrcTags.  Alejandro 240596 */
  190. static const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
  191.  
  192. // Should this be moved inside LyXAction? 
  193. static inline
  194. int bindKey(char const* seq, int action)
  195.     return toplevel_keymap->bind(seq, action); 
  196. }
  197.  
  198.  
  199. LyXRC::LyXRC()
  200. {
  201.     // Get printer from the environment. If fail, use default "",
  202.     // assuming that everything is set up correctly.
  203.     printer = getenv("PRINTER");
  204.     print_command = "dvips";
  205.     print_evenpage_flag = "-B";
  206.     print_oddpage_flag = "-A";
  207.     print_reverse_flag = "-r";
  208.     print_landscape_flag = "-t landscape";
  209.     print_to_printer = "-P";
  210.     print_to_file = "-o";
  211.     print_file_extension = ".ps";
  212.     document_path = getEnvPath("HOME");
  213.     tempdir_path = "/tmp";
  214.     use_tempdir = true;
  215.     latex_command = "latex";
  216.     ps_command = "gs";
  217.     view_ps_command = "ghostview -swap";
  218.     view_pspic_command = "ghostview";
  219.     view_dvi_command = "xdvi";
  220.     default_papersize = PAPER_USLETTER;
  221.     custom_export_format = "ps";
  222.     chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
  223.     fontenc = "default";
  224.     dpi = 75;
  225.     // Because a screen typically is wider than a piece of paper:
  226.     zoom = 150;
  227.     // Default LaTeX font size:
  228.     font_sizes[LyXFont::SIZE_TINY] = 5.0;
  229.     font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
  230.     font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
  231.     font_sizes[LyXFont::SIZE_SMALL] = 9.0;
  232.     font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
  233.     font_sizes[LyXFont::SIZE_LARGE] = 12.0;
  234.     font_sizes[LyXFont::SIZE_LARGER] = 14.4;
  235.     font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
  236.     font_sizes[LyXFont::SIZE_HUGE] = 20.74;
  237.     font_sizes[LyXFont::SIZE_HUGER] = 24.88;
  238.     use_scalable_fonts = true;
  239.     roman_font_name = "-*-times";
  240.     sans_font_name = "-*-helvetica";
  241.     typewriter_font_name = "-*-courier";
  242.     menu_font_name = "-*-helvetica-bold-r";
  243.     popup_font_name = "-*-helvetica-medium-r";
  244.     font_norm = "iso8859-1";
  245.     autosave = 300;
  246.     auto_region_delete = true;
  247.     ascii_linelen = 75;
  248.     num_lastfiles = 4;
  249.     check_lastfiles = true;
  250.     exit_confirmation = true;
  251.     display_shortcuts = true;
  252.     // Spellchecker settings:
  253.     isp_accept_compound = true;
  254.     isp_use_input_encoding = false;
  255.     isp_use_alt_lang = false;
  256.     isp_use_pers_dict = false;
  257.     isp_use_esc_chars = false;
  258.     use_kbmap = false;
  259.     defaultKeyBindings();
  260. }
  261.  
  262.  
  263. LyXRC::~LyXRC()
  264. {
  265. }
  266.  
  267.  
  268. int LyXRC::Read(LString const &filename)
  269. {
  270.     LyXLex lexrc(lyxrcTags, lyxrcCount);
  271.     if (lyxerr.debugging(Error::PARSER))
  272.         lexrc.printTable();
  273.     
  274.     lexrc.setFile(filename);
  275.     if (!lexrc.IsOK()) return -2;
  276.  
  277.     lyxerr.debug("Reading `" + filename + "'...", Error::INIT);
  278.     
  279.     while (lexrc.IsOK()) {
  280.  
  281.         switch(lexrc.lex()) {
  282.         case LyXLex::LEX_FEOF:
  283.             break;
  284.         case RC_INPUT: // Include file
  285.                 if (lexrc.next()) {
  286.                     LString tmp = LibFileSearch(LString(),
  287.                                 lexrc.GetString()); 
  288.                 if (Read(tmp)) {
  289.                     lexrc.printError("Error reading incl"
  290.                              "uded file: "+tmp);
  291.                 }
  292.             }
  293.             break;
  294.         case RC_BINDFILE:                     // RVDK_PATCH_5
  295.             if (lexrc.next()) {
  296.                 LString tmp2 = lexrc.GetString();
  297.                 lyxerr.debug("BF: "+ tmp2, Error::LYXRC);
  298.                     LString tmp = LibFileSearch("bind",
  299.                         tmp2,"bind");
  300.                 lyxerr.debug("Reading bindfile:"
  301.                           + tmp, Error::LYXRC); 
  302.                 if (Read(tmp)) {
  303.                     lexrc.printError("Error reading bind"
  304.                              "file: " + tmp);
  305.                 }
  306.             }
  307.             break;
  308.  
  309.         case RC_BEGINTOOLBAR:
  310.             // this toolbar should be changed to be a completely
  311.             // non gui toolbar. (Lgb)
  312.             toolbarBackend.read(lexrc);
  313.             break;
  314.             
  315.         case RC_KBMAP:
  316.             if (lexrc.next())
  317.                 use_kbmap = lexrc.GetBool();
  318.             break;
  319.  
  320.         case RC_EXIT_CONFIRMATION:
  321.             if (lexrc.next())
  322.                 exit_confirmation = lexrc.GetBool();
  323.             break;
  324.  
  325.         case RC_DISPLAY_SHORTCUTS:
  326.             if (lexrc.next())
  327.                 display_shortcuts = lexrc.GetBool();
  328.             break;
  329.  
  330.         case RC_KBMAP_PRIMARY:
  331.             if (lexrc.next())
  332.                 primary_kbmap = lexrc.GetString();
  333.             break;
  334.  
  335.         case RC_KBMAP_SECONDARY:
  336.             if (lexrc.next())
  337.                 secondary_kbmap = lexrc.GetString();
  338.             break;
  339.               
  340.         case RC_FONT_ENCODING:
  341.             if (lexrc.next())
  342.                 fontenc = lexrc.GetString();
  343.             break;
  344.             
  345.         case RC_PRINTER:
  346.             if (lexrc.next())
  347.                 printer = lexrc.GetString();
  348.             break;
  349.             
  350.         case RC_PRINT_COMMAND:
  351.             if (lexrc.next())
  352.                 print_command = lexrc.GetString();
  353.             break;
  354.             
  355.         case RC_PRINTEVENPAGEFLAG:
  356.             if (lexrc.next())
  357.                 print_evenpage_flag = lexrc.GetString();
  358.             break;
  359.             
  360.         case RC_PRINTODDPAGEFLAG:
  361.             if (lexrc.next())
  362.                 print_oddpage_flag = lexrc.GetString();
  363.             break;
  364.             
  365.         case RC_PRINTREVERSEFLAG:
  366.             if (lexrc.next())
  367.                 print_reverse_flag = lexrc.GetString();
  368.             break;
  369.             
  370.         case RC_PRINTLANDSCAPEFLAG:
  371.             if (lexrc.next())
  372.                 print_landscape_flag = lexrc.GetString();
  373.             break;
  374.             
  375.         case RC_PRINTTOPRINTER:
  376.             if (lexrc.next())
  377.                 print_to_printer = lexrc.GetString();
  378.             break;
  379.             
  380.         case RC_PRINT_ADAPTOUTPUT:
  381.             if (lexrc.next())
  382.                 print_adapt_output = lexrc.GetBool();
  383.             break;
  384.             
  385.         case RC_PRINTTOFILE:
  386.             if (lexrc.next())
  387.                 print_to_file = lexrc.GetString();
  388.             break;
  389.             
  390.         case RC_PRINTFILEEXTENSION:
  391.             if (lexrc.next())
  392.                 print_file_extension = lexrc.GetString();
  393.             break;
  394.             
  395.         case RC_PRINTEXSTRAOPTIONS:
  396.             if (lexrc.EatLine())
  397.                 print_extra_options = lexrc.GetString();
  398.             break;
  399.             
  400.         case RC_PRINTSPOOL_COMMAND:
  401.             if (lexrc.next())
  402.                 print_spool_command = lexrc.GetString();
  403.             break;
  404.             
  405.         case RC_PRINTSPOOL_PRINTERPREFIX:
  406.             if (lexrc.next())
  407.                 print_spool_printerprefix = lexrc.GetString();
  408.             break;
  409.             
  410.         case RC_CUSTOM_EXPORT_COMMAND:
  411.             if (lexrc.next())
  412.                 custom_export_command = lexrc.GetString();
  413.             break;
  414.  
  415.         case RC_CUSTOM_EXPORT_FORMAT:
  416.             if (lexrc.next())
  417.                 custom_export_format = lexrc.GetString();
  418.             break;
  419.             
  420.         case RC_LATEX_COMMAND:
  421.             if (lexrc.next())
  422.                 latex_command = lexrc.GetString();
  423.             break;
  424.  
  425.         case RC_DEFAULT_PAPERSIZE:
  426.                         if (lexrc.next()) {
  427.                     LString size = lexrc.GetString();
  428.                 size.lowercase();
  429.                 if (size == "usletter")
  430.                         default_papersize = PAPER_USLETTER;
  431.                 else if (size == "legal")
  432.                         default_papersize = PAPER_LEGALPAPER;
  433.                 else if (size == "executive")
  434.                         default_papersize = PAPER_EXECUTIVEPAPER;
  435.                 else if (size == "a3")
  436.                         default_papersize = PAPER_A3PAPER;
  437.                 else if (size == "a4")
  438.                         default_papersize = PAPER_A4PAPER;
  439.                 else if (size == "a5")
  440.                         default_papersize = PAPER_A5PAPER;
  441.                 else if (size == "b5")
  442.                         default_papersize = PAPER_B5PAPER;
  443.             }
  444.             break;
  445.         case RC_VIEWDVI_COMMAND:
  446.             if (lexrc.next())
  447.                 view_dvi_command = lexrc.GetString();
  448.             break;
  449.  
  450.         case RC_PS_COMMAND:
  451.             if (lexrc.next())
  452.                 ps_command = lexrc.GetString();
  453.             break;
  454.  
  455.         case RC_VIEWPS_COMMAND:
  456.             if (lexrc.next())
  457.                 view_ps_command = lexrc.GetString();
  458.             break;
  459.  
  460.         case RC_VIEWPSPIC_COMMAND:
  461.             if (lexrc.next())
  462.                 view_pspic_command = lexrc.GetString();
  463.             break;
  464.  
  465.         case RC_CHKTEX_COMMAND:
  466.             if (lexrc.next())
  467.                 chktex_command = lexrc.GetString();
  468.             break;
  469.  
  470.         case RC_SCREEN_DPI:
  471.             if (lexrc.next())
  472.                 dpi = lexrc.GetInteger();
  473.             break;
  474.  
  475.         case RC_SCREEN_ZOOM:
  476.             if (lexrc.next())
  477.                 zoom = lexrc.GetInteger();
  478.             break;
  479.  
  480.         case RC_SCREEN_FONT_SIZES:
  481.             if (lexrc.next())
  482.                 font_sizes[LyXFont::SIZE_TINY] =
  483.                     lexrc.GetFloat();
  484.             if (lexrc.next())
  485.                 font_sizes[LyXFont::SIZE_SCRIPT] =
  486.                     lexrc.GetFloat();
  487.             if (lexrc.next())
  488.                 font_sizes[LyXFont::SIZE_FOOTNOTE] =
  489.                     lexrc.GetFloat();
  490.             if (lexrc.next())
  491.                 font_sizes[LyXFont::SIZE_SMALL] =
  492.                     lexrc.GetFloat();
  493.             if (lexrc.next())
  494.                 font_sizes[LyXFont::SIZE_NORMAL] =
  495.                     lexrc.GetFloat();
  496.             if (lexrc.next())
  497.                 font_sizes[LyXFont::SIZE_LARGE] =
  498.                     lexrc.GetFloat();
  499.             if (lexrc.next())
  500.                 font_sizes[LyXFont::SIZE_LARGER] =
  501.                     lexrc.GetFloat();
  502.             if (lexrc.next())
  503.                 font_sizes[LyXFont::SIZE_LARGEST] =
  504.                     lexrc.GetFloat();
  505.             if (lexrc.next())
  506.                 font_sizes[LyXFont::SIZE_HUGE] =
  507.                     lexrc.GetFloat();
  508.             if (lexrc.next())
  509.                 font_sizes[LyXFont::SIZE_HUGER] =
  510.                     lexrc.GetFloat();
  511.             break;
  512.  
  513.                 case RC_SCREEN_FONT_SCALABLE:
  514.                         if (lexrc.next())
  515.                                 use_scalable_fonts = lexrc.GetBool();
  516.             break;
  517.  
  518.         case RC_AUTOSAVE:
  519.             if (lexrc.next())
  520.                 autosave = lexrc.GetInteger();
  521.             break;
  522.             
  523.         case RC_SGML_EXTRA_OPTIONS:
  524.             if (lexrc.next())
  525.                 sgml_extra_options = lexrc.GetString();
  526.             break;
  527.  
  528.         case RC_DOCUMENTPATH:
  529.             if (lexrc.next()) {
  530.                 document_path = ExpandPath(lexrc.GetString());
  531.             }
  532.             break;
  533.  
  534.         case RC_TEMPLATEPATH:
  535.             if (lexrc.next())
  536.                 template_path = ExpandPath(lexrc.GetString());
  537.             break;
  538.  
  539.         case RC_TEMPDIRPATH:
  540.             if (lexrc.next())
  541.                 tempdir_path = ExpandPath(lexrc.GetString());
  542.             break;
  543.             
  544.         case RC_USETEMPDIR:
  545.             if (lexrc.next())
  546.                 use_tempdir = lexrc.GetBool();
  547.             break;
  548.  
  549.         case RC_LASTFILES:
  550.             if (lexrc.next())
  551.                 lastfiles = ExpandPath(lexrc.GetString());
  552.             break;
  553.  
  554.                 case RC_NUMLASTFILES:
  555.                         if (lexrc.next())
  556.                                 num_lastfiles = lexrc.GetInteger();
  557.             break;
  558.  
  559.                 case RC_CHECKLASTFILES:
  560.                         if (lexrc.next())
  561.                                 check_lastfiles = lexrc.GetBool();
  562.             break;
  563.  
  564.         case RC_SCREEN_FONT_ROMAN:
  565.             if (lexrc.next())
  566.                 roman_font_name = lexrc.GetString();
  567.             break;
  568.  
  569.         case RC_SCREEN_FONT_SANS:
  570.             if (lexrc.next())
  571.                 sans_font_name = lexrc.GetString();
  572.             break;
  573.  
  574.         case RC_SCREEN_FONT_TYPEWRITER:
  575.             if (lexrc.next())
  576.                 typewriter_font_name = lexrc.GetString();
  577.             break;
  578.             
  579.         case RC_SCREEN_FONT_MENU:
  580.             if (lexrc.next())
  581.                 menu_font_name = lexrc.GetString();
  582.             break;
  583.             
  584.         case RC_SCREEN_FONT_POPUP:
  585.             if (lexrc.next())
  586.                 popup_font_name = lexrc.GetString();
  587.             break;
  588.             
  589.         case RC_SCREEN_FONT_ENCODING:
  590.             if (lexrc.next())
  591.                 font_norm = lexrc.GetString();
  592.             break;
  593.             
  594.         case RC_AUTOREGIONDELETE:
  595.             // Auto region delete defaults to true
  596.                 if (lexrc.next())
  597.                     auto_region_delete = lexrc.GetBool();
  598.             break;
  599.             
  600.         case RC_BIND:
  601.         {
  602.             // !!!chb, dynamic key binding...
  603.             int action, res=0;
  604.             LString seq, cmd;
  605.  
  606.             if (lexrc.lex()==LyXLex::LEX_DATA)  {
  607.                 seq = lexrc.GetString();
  608.             } else {
  609.                 lexrc.printError("Bad key sequence: `$$Token'");
  610.                 break;
  611.             }
  612.  
  613.             if (lexrc.lex()==LyXLex::LEX_DATA) {
  614.                 cmd = lexrc.GetString();
  615.             } else {
  616.                 lexrc.printError("Bad command: `$$Token'");
  617.                 break;
  618.             }
  619.  
  620.             if ((action = lyxaction.LookupFunc(cmd.c_str()))>=0) {
  621.                 if (lyxerr.debugging(Error::KEY)) {
  622.                     lyxerr.print("RC_BIND: Sequence `"
  623.                               + seq + "' Command `"
  624.                               + cmd + "' Action `"
  625.                               + (int) action + '\'');
  626.                 }
  627.                 res = bindKey(seq.c_str(), action);
  628.                 if (res != 0) {
  629.                     lexrc.printError(
  630.                           "Invalid key sequence `"
  631.                           + seq + '\''); 
  632.                 }
  633.             } else {// cmd is the last token read.
  634.                 lexrc.printError(
  635.                         "Unknown LyX function `$$Token'");
  636.             }
  637.             break;
  638.         }
  639.         case RC_SERVERPIPE:
  640.             if (lexrc.next())
  641.                 lyxpipes = ExpandPath(lexrc.GetString());
  642.             break;
  643.             
  644.         case RC_CURSOR_FOLLOWS_SCROLLBAR:
  645.             if (lexrc.next())
  646.                 cursor_follows_scrollbar = lexrc.GetBool();
  647.             break;
  648.         case RC_BACKGROUND_COLOR:
  649.             if (lexrc.next())
  650.                 background_color = lexrc.GetString();
  651.             break;
  652.         case RC_SELECTION_COLOR:
  653.             if (lexrc.next())
  654.                 strncpy(selection_color,
  655.                     lexrc.GetString().c_str(),31);
  656.             break;
  657.         case RC_FAX_COMMAND:
  658.              if (lexrc.next())
  659.                  fax_command = lexrc.GetString();
  660.             break;
  661.         case RC_FAXPROGRAM:
  662.             if (lexrc.next())
  663.                 fax_program = lexrc.GetString();
  664.             break;
  665.         case RC_PHONEBOOK:
  666.             if (lexrc.next()) {
  667.                 LString s = lexrc.GetString();
  668.                 if (AbsolutePath(s))
  669.                     phone_book = s;
  670.                 else
  671.                                     phone_book = user_lyxdir + s;
  672.             }
  673.              break;
  674.         case RC_ASCIIROFF_COMMAND:
  675.              if (lexrc.next())
  676.                             ascii_roff_command = lexrc.GetString();
  677.             break;
  678.         case RC_ASCII_LINELEN:
  679.             if (lexrc.next())
  680.                             ascii_linelen = lexrc.GetInteger();
  681.             break;
  682.         // Spellchecker settings:
  683.         case RC_ACCEPT_COMPOUND:
  684.             if (lexrc.next())
  685.                 isp_accept_compound = lexrc.GetBool();
  686.             break;
  687.         case RC_USE_INP_ENC:
  688.             if (lexrc.next())
  689.                 isp_use_input_encoding = lexrc.GetBool();
  690.             break;
  691.         case RC_USE_ALT_LANG:
  692.             if (lexrc.next())
  693.                 isp_use_alt_lang = lexrc.GetBool();
  694.             break;
  695.         case RC_USE_PERS_DICT:
  696.             if (lexrc.next())
  697.                 isp_use_pers_dict = lexrc.GetBool();
  698.             break;
  699.         case RC_USE_ESC_CHARS:
  700.             if (lexrc.next())
  701.                 isp_use_esc_chars = lexrc.GetBool();
  702.             break;
  703.         case RC_ALT_LANG:
  704.             if (lexrc.next())
  705.                 isp_alt_lang = lexrc.GetString();
  706.             break;
  707.         case RC_PERS_DICT:
  708.             if (lexrc.next())
  709.                 isp_pers_dict = lexrc.GetString();
  710.             break;
  711.         case RC_ESC_CHARS:
  712.             if (lexrc.next())
  713.                 isp_esc_chars = lexrc.GetString();
  714.             break;
  715.  
  716.         default:
  717.             lexrc.printError("Unknown tag `$$Token'");
  718.             break;
  719.         }
  720.     }
  721.  
  722.     return 0;
  723. }
  724.  
  725.  
  726. void LyXRC::Print()
  727. {
  728.     lyxerr.print("The current internal LyXRC:");
  729. }
  730.  
  731.  
  732. /// define the default key bindings for LyX.
  733. void LyXRC::defaultKeyBindings()
  734. {
  735.     bindKey("Right",   LFUN_RIGHT);
  736.     bindKey("Left",    LFUN_LEFT);
  737.     bindKey("Up",      LFUN_UP);
  738.     bindKey("Down",    LFUN_DOWN);
  739.  
  740.     bindKey("Tab",  LFUN_TAB);
  741.  
  742.     bindKey("Home",    LFUN_HOME);
  743.     bindKey("End",     LFUN_END);
  744.     bindKey("Prior",   LFUN_PRIOR);
  745.     bindKey("Next",    LFUN_NEXT);
  746.  
  747.     bindKey("Return",  LFUN_BREAKPARAGRAPH);
  748.     bindKey("~C-~S-~M-nobreakspace", LFUN_PROTECTEDSPACE);
  749.  
  750.     bindKey("Delete",  LFUN_DELETE);
  751.     bindKey("BackSpace",    LFUN_BACKSPACE);
  752.     // bindKeyings for transparent handling of deadkeys
  753.     // The keysyms are gotten from XFree86 X11R6
  754.     bindKey("~C-~S-~M-dead_acute",           LFUN_ACUTE);
  755.     bindKey("~C-~S-~M-dead_breve",           LFUN_BREVE);
  756.     bindKey("~C-~S-~M-dead_caron",           LFUN_CARON);
  757.     bindKey("~C-~S-~M-dead_cedilla",         LFUN_CEDILLA);
  758.     bindKey("~C-~S-~M-dead_abovering",          LFUN_CIRCLE);
  759.     bindKey("~C-~S-~M-dead_circumflex",      LFUN_CIRCUMFLEX);
  760.     bindKey("~C-~S-~M-dead_abovedot",             LFUN_DOT);
  761.     bindKey("~C-~S-~M-dead_grave",           LFUN_GRAVE);
  762.     bindKey("~C-~S-~M-dead_doubleacute",     LFUN_HUNG_UMLAUT);
  763.     bindKey("~C-~S-~M-dead_macron",          LFUN_MACRON);
  764.     // nothing with this name
  765.     // bindKey("~C-~S-~M-dead_special_caron",   LFUN_SPECIAL_CARON);
  766.     bindKey("~C-~S-~M-dead_tilde",           LFUN_TILDE);
  767.     bindKey("~C-~S-~M-dead_diaeresis",       LFUN_UMLAUT);
  768.     // nothing with this name either...
  769.     //bindKey("~C-~S-~M-dead_underbar",        LFUN_UNDERBAR);
  770.     bindKey("~C-~S-~M-dead_belowdot",        LFUN_UNDERDOT);
  771.     bindKey("~C-~S-~M-dead_tie",             LFUN_TIE);
  772.     bindKey("~C-~S-~M-dead_ogonek",           LFUN_OGONEK);
  773.  
  774.     // bindings to utilize the use of the numeric keypad
  775.     // e.g. Num Lock set
  776.     bindKey("KP_0",        LFUN_SELFINSERT);
  777.     bindKey("KP_Decimal",  LFUN_SELFINSERT);
  778.     bindKey("KP_Enter",    LFUN_SELFINSERT);
  779.     bindKey("KP_1",        LFUN_SELFINSERT);
  780.     bindKey("KP_2",        LFUN_SELFINSERT);
  781.     bindKey("KP_3",        LFUN_SELFINSERT);
  782.     bindKey("KP_4",        LFUN_SELFINSERT);
  783.     bindKey("KP_5",        LFUN_SELFINSERT);
  784.     bindKey("KP_6",        LFUN_SELFINSERT);
  785.     bindKey("KP_Add",      LFUN_SELFINSERT);
  786.     bindKey("KP_7",        LFUN_SELFINSERT);
  787.     bindKey("KP_8",        LFUN_SELFINSERT);
  788.     bindKey("KP_9",        LFUN_SELFINSERT);
  789.     bindKey("KP_Divide",   LFUN_SELFINSERT);
  790.     bindKey("KP_Multiply", LFUN_SELFINSERT);
  791.     bindKey("KP_Subtract", LFUN_SELFINSERT);
  792.     
  793.     /* Most self-insert keys are handled in the 'default:' section of
  794.      * WorkAreaKeyPress - so we don't have to define them all.
  795.      * However keys explicit decleared as self-insert are
  796.      * handled seperatly (LFUN_SELFINSERT.) Lgb. */
  797.  
  798.         bindKey("C-Tab",  LFUN_TABINSERT);  // ale970515
  799. }
  800.