]> git.donarmstrong.com Git - lilypond.git/blob - lily/scm-option.cc
* Documentation/user/refman.itely: remove superfluous -'s
[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--2003  Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9 #include <stdio.h>
10
11 #include "parse-scm.hh"
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   Backwards compatibility.
39  */
40 bool lily_1_8_relative = true;
41 /*
42   crash if internally the wrong type is used for a grob property.
43  */
44 bool internal_type_checking_global_b;
45
46 LY_DEFINE (ly_option_usage, "ly:option-usage", 0, 0, 0, (SCM),
47                   "Print ly-set-option usage")
48 {  
49   printf ( _("lilypond -e EXPR means:").to_str0 ());
50   puts ("");
51   printf (_ ("  Evalute the Scheme EXPR before parsing any .ly files.").to_str0 ());
52   puts ("");
53   printf (_ ("  Multiple -e options may be given, they will be evaluated sequentially.").to_str0 ());
54   puts ("");
55   printf (_("  The function ly-set-option allows for access to some internal variables.").to_str0 ());
56   puts ("\n");
57   printf (_ ("Usage: lilypond -e \"(ly-set-option SYMBOL VAL)\"").to_str0 ());
58   puts ("\n");
59   printf (_ ("Where SYMBOL VAL pair is any of:").to_str0 ());
60   puts ("");
61   printf ( "  help ANY-SYMBOL\n"
62            "  internal-type-checking BOOLEAN\n"
63            "  midi-debug BOOLEAN\n"
64            "  parse-protect BOOLEAN\n"
65            "  testing-level INTEGER\n");
66   
67   exit (0);
68   return SCM_UNSPECIFIED;
69 }
70
71 /* Add these as well:
72
73 @item -T,--no-timestamps
74 don't timestamp the output
75
76 @item -t,--test
77 Switch on any experimental features.  Not for general public use. */
78 LY_DEFINE (ly_set_option, "ly:set-option", 2, 0, 0, (SCM var, SCM val),
79             "Set a global option value.  Supported options include\n"
80 "\n"
81 "@table @code\n"
82 "@item help\n"
83 "List all options.\n"
84 "@item midi-debug\n"
85 "If set to true, generate human readable MIDI\n"
86 "@item internal-type-checking\n"
87 "Set paranoia for property assignments\n"
88 "@item parse-protect\n"
89 "If protection is switched on, errors in inline scheme are caught in the parser. \n"
90 "If off, GUILE will halt on errors, and give a stack trace. Default is protected evaluation. \n"
91 "@item old-relative\n"
92 "Relative for simultaneous functions similar to chord syntax\n"
93 "@item new-relative\n"
94 "Relative for simultaneous functions similar to sequential music\n"
95 "@end table\n"
96 "\n"
97 "This function is useful to call from the command line: @code{lilypond -e\n"
98 "\"(ly-set-option 'midi-debug #t)\"}.\n")
99 {
100   if (var == ly_symbol2scm ("help"))
101     {
102       /* lilypond -e "(ly-set-option 'help #t)" */
103       ly_option_usage (SCM_EOL);
104     }
105   else if (var == ly_symbol2scm ("midi-debug"))
106     {
107       midi_debug_global_b = to_boolean (val);
108     }
109   else if (var == ly_symbol2scm ("testing-level"))
110     {
111      testing_level_global = gh_scm2int (val); 
112     }
113   else if (var == ly_symbol2scm ("parse-protect" ))
114     {
115       parse_protect_global = to_boolean(val);
116     }
117   else if (var == ly_symbol2scm ("internal-type-checking"))
118     {
119      internal_type_checking_global_b = to_boolean (val); 
120     }
121   else if (var == ly_symbol2scm ("old-relative"))
122     {
123       lily_1_8_relative = true;
124     }
125   else if (var == ly_symbol2scm ("new-relative"))
126     {
127       lily_1_8_relative = false;
128     }
129   else
130     {
131       warning (_("Unknown internal option!"));
132     }
133
134   return SCM_UNSPECIFIED;
135 }
136
137