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