]> git.donarmstrong.com Git - lilypond.git/blob - lily/scm-option.cc
``slikken kreng''
[lilypond.git] / lily / scm-option.cc
1 /*   
2   scm-option.cc --  implement option setting from Scheme
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 2001--2002  Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #include <iostream>
11
12 #include "string.hh"
13 #include "lily-guile.hh"
14 #include "scm-option.hh"
15 #include "warn.hh"
16
17 /*
18   This interface to option setting is meant for setting options are
19   useful to a limited audience. The reason for this interface is that
20   making command line options clutters up the command-line option name
21   space.
22
23
24   preferably, also dont use TESTING_LEVEL_GLOBAL, since it defeats
25   another purpose of this very versatile interface, which is to
26   support multiple debug/testing options concurrently.
27   
28  */
29
30
31 /* Write midi as formatted ascii stream? */
32 bool midi_debug_global_b;
33
34 /* General purpose testing flag */
35 int testing_level_global;
36
37 /*
38   crash if internally the wrong type is used for a grob property.
39  */
40 bool internal_type_checking_global_b;
41
42 /*
43
44 add these as well:
45
46 @item -T,--no-timestamps
47 don't timestamp the output
48
49 @item -t,--test
50 Switch on any experimental features.  Not for general public use.
51
52  */
53
54 LY_DEFINE(set_lily_option,"set-lily-option", 2, 0, 0,  (SCM var, SCM val),
55           "Set a global option for the program. Supported options  include
56
57
58 @table @code
59 @item help
60 List all options.
61 @item midi-debug
62 If set to true, generate human  readable MIDI
63 @item internal-type-checking
64 Set paranoia for property assignments 
65 @end table
66
67 This function is useful to call from the command line: @code{lilypond -e
68 \"(set-lily-option 'midi-debug #t)\"}.
69 ")
70 {
71   /*
72     Scheme option usage:
73     lilypond -e "(set-lily-option 'help 0)"
74    */
75   if (var == ly_symbol2scm ("help"))
76     {
77       std::cout << _("lilypond -e EXPR means
78
79 evalute EXPR as Scheme after init.scm has been read.  In particular,
80 the function set-lily-option allows for access to some internal
81 variables. Usage:
82
83   (set-lily-option SYMBOL VAL)
84
85 possible options for SYMBOL are :
86 ").to_str0 ()<< std::endl;
87       
88       std::cout << "  help (any-symbol)"<< std::endl; 
89       std::cout << "  internal-type-checking (boolean)"<< std::endl; 
90       std::cout << "  midi-debug (boolean)"<< std::endl; 
91       std::cout << "  testing-level (int)"<< std::endl; 
92
93       exit (0);
94     }
95   else if (var == ly_symbol2scm ("midi-debug"))
96     {
97       midi_debug_global_b = to_boolean (val);
98     }
99   else if (var == ly_symbol2scm ("testing-level"))
100     {
101      testing_level_global = gh_scm2int (val); 
102     }
103   else if (var == ly_symbol2scm ("internal-type-checking"))
104     {
105      internal_type_checking_global_b = to_boolean (val); 
106     }
107   else if (var == ly_symbol2scm ("find-old-relative"))
108     {
109       /*
110         Seems to have been broken for some time!
111         
112         @item  -Q,--find-old-relative
113         show all changes needed to convert a file to  relative octave syntax.
114
115
116         
117       */
118
119       ;
120     }
121   else
122     {
123       warning (_("Unknown internal option!"));
124     }
125   
126
127   return SCM_UNSPECIFIED;
128 }
129
130
131
132