]> git.donarmstrong.com Git - lilypond.git/blob - lily/scm-option.cc
iostream fixes
[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 /*
42
43 add these as well:
44
45 @item -T,--no-timestamps
46 don't timestamp the output
47
48 @item -t,--test
49 Switch on any experimental features.  Not for general public use.
50
51  */
52
53 LY_DEFINE(set_lily_option,"set-lily-option", 2, 0, 0,  (SCM var, SCM val),
54           "Set a global option for the program. Supported options  include
55
56
57 @table @code
58 @item help
59 List all options.
60 @item midi-debug
61 If set to true, generate human  readable MIDI
62 @item internal-type-checking
63 Set paranoia for property assignments 
64 @end table
65
66 This function is useful to call from the command line: @code{lilypond -e
67 \"(set-lily-option 'midi-debug #t)\"}.
68 ")
69 {
70   /*
71     Scheme option usage:
72     lilypond -e "(set-lily-option 'help 0)"
73    */
74   if (var == ly_symbol2scm ("help"))
75     {
76       printf ( _("lilypond -e EXPR means
77
78 evalute EXPR as Scheme after init.scm has been read.  In particular,
79 the function set-lily-option allows for access to some internal
80 variables. Usage:
81
82   (set-lily-option SYMBOL VAL)
83
84 possible options for SYMBOL are :
85 ").to_str0 ());
86       printf ( "  help (any-symbol)\n"
87                "  internal-type-checking (boolean)\n"
88                "  midi-debug (boolean)\n"
89                "  testing-level (int)\n");
90                
91       exit (0);
92     }
93   else if (var == ly_symbol2scm ("midi-debug"))
94     {
95       midi_debug_global_b = to_boolean (val);
96     }
97   else if (var == ly_symbol2scm ("testing-level"))
98     {
99      testing_level_global = gh_scm2int (val); 
100     }
101   else if (var == ly_symbol2scm ("internal-type-checking"))
102     {
103      internal_type_checking_global_b = to_boolean (val); 
104     }
105   else if (var == ly_symbol2scm ("find-old-relative"))
106     {
107       /*
108         Seems to have been broken for some time!
109         
110         @item  -Q,--find-old-relative
111         show all changes needed to convert a file to  relative octave syntax.
112
113
114         
115       */
116
117       ;
118     }
119   else
120     {
121       warning (_("Unknown internal option!"));
122     }
123   
124
125   return SCM_UNSPECIFIED;
126 }
127
128
129
130