File: debug-layout-options.ly

package info (click to toggle)
frescobaldi 3.0.0%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 14,884 kB
  • sloc: python: 37,968; sh: 180; makefile: 69
file content (105 lines) | stat: -rw-r--r-- 4,319 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
% This file is part of the Frescobaldi project, http://www.frescobaldi.org/
%
% Copyright (c) 2011 - 2012 by Wilbert Berendsen
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
% See http://www.gnu.org/licenses/ for more information.

%{
  This file is included (through -dinclude-settings)
  by Frescobaldi's Preview compilation mode.
  It checks for the presence of certain command line options
  (which are also inserted by the Preview mode)
  to switch some layout debugging features on or off.
  This design has been chosen to simplify a future
  integration of the functionality into LilyPond proper.
  Then the following code has to be run inside LilyPond
  when a -ddebug-layout command line option is present.

  For an inclusion in LilyPond the strategy has to be modified:
  Currently all options have to be explicitly activated.
  This is because we have the checkbox UI in Frescobaldi.
  When implemented as LilyPond command line option we will
  define a default set of options that is activated by
  -ddebug-layout, while some additional options can be
  activated and the default options be deactivated with
  command line options or #(ly:set-option ...) commands.
%}


\include "./lilypond-version-predicates.ily"

debugLayoutOptions =
#(define-void-function (parser location)()
   (let*
    ((lily-version-new (lilypond-greater-than? '(2 19 21)))
     (cond-inc
      ;; conditionally choose the syntax to include a file
      ;; based on the current LilyPond version
      (lambda (filename)
        (if lily-version-new
            (ly:parser-include-string (format "\\include \"./~a\"" filename))
            (ly:parser-include-string parser (format "\\include \"./~a\"" filename))))))
    ;; include the optional custom file first.
    ;; This way it can for example define configuration variables.
    (if (ly:get-option 'debug-custom-file)
        ;; Add a custom file for debugging layout
        (cond-inc (ly:get-option 'debug-custom-file)))
    ;; include preview options depending on the
    ;; presence or absence of command line switches
    (if (ly:get-option 'debug-control-points)
        ;; display control points
        (cond-inc "display-control-points.ily"))
    (if (ly:get-option 'debug-voices)
        ;; color \voiceXXX music
        (cond-inc "color-voices.ily"))
    (if (ly:get-option 'debug-directions)
        ;; color grobs switched with \xxxUp or \xxxDown
        (cond-inc "color-directions.ily"))
    (if (ly:get-option 'debug-grob-anchors)
        ;; Add a dot for the anchor of each grob
        (cond-inc "display-grob-anchors.ily"))
    (if (ly:get-option 'debug-grob-names)
        ;; Add a dot for the anchor of each grob
        (cond-inc "display-grob-names.ily"))
    (if (ly:get-option 'debug-paper-columns)
        ;; Add a dot for the anchor of each grob
        (cond-inc "info-paper-columns.ily"))
    (if (ly:get-option 'debug-display-skylines)
        ;; display skylines
        ;; -> this is very intrusive, so handle with care!
        ;; should be switched off by default
        (ly:set-option 'debug-skylines #t))
    ;; the option should be named debug-skylines,
    ;; this name clash has to be resolved!
    (if (ly:get-option 'debug-annotate-spacing)
        ;; Add a dot for the anchor of each grob
        (cond-inc "annotate-spacing.ily"))))

\debugLayoutOptions

%{
  The following code should later be included in LilyPond's
  initialisation phase, at a point
  when any (ly:set-option ...) commands in the input file(s) have
  been already parsed.

#(if (ly:get-option 'debug-layout)
     ;; check for additional command line options
     #{
       \debugLayoutOptions
     #})

%}