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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
|
# This file is part of the Frescobaldi project, http://www.frescobaldi.org/
#
# Copyright (c) 2011 - 2014 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.
"""
All completions data.
"""
import itertools
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QFont, QFontDatabase
import listmodel
import ly.words
import ly.data
import ly.pitch
from . import util
# some groups of basic lilypond commands
# markup (toplevel, book and bookpart)
markup = (
'markup',
'markuplines',
'markuplist',
'pageBreak',
'noPageBreak',
'noPageTurn',
)
# these can occur (almost) everywhere
everywhere = (
'pointAndClickOn',
'pointAndClickOff',
'include',
)
# commands that change input mode, can introduce a music expression
inputmodes = (
'chords',
'chordmode {',
'drums',
'drummode {',
'figures',
'figuremode {',
'lyrics',
'lyricmode {',
'addlyrics {',
)
# commands that only occur at the global file level
toplevel = (
'defineBarLine',
'language',
'version',
'sourcefileline',
'sourcefilename',
)
# other commands that can start a music expression
start_music = (
'repeat',
'alternative {',
'relative',
'transpose',
'partcombine',
'keepWithTag #\'',
'removeWithTag #\'',
'new',
'context',
'with',
)
# tweak commands may be assigned, in toplevel
tweaks = (
'once',
'override',
'revert',
'set',
'unset',
)
# modes book, bookpart and score
modes = (
'book {',
'bookpart {',
'score {',
)
# blocks: paper, header, layout
blocks = (
'paper {',
'header {',
'layout {',
)
# commands that are used in context definitions
cmds_context = (
'override',
'consists',
'remove',
'RemoveEmptyStaves',
'accepts',
'alias',
'defaultchild',
'denies',
'name',
)
# in \with { } a smaller set
cmds_with = cmds_context[:3]
# variables that make sense to be set at toplevel
toplevel_variables = (
'pipeSymbol',
'showFirstLength',
'showLastLength',
)
# stuff inside \score {}
score = sorted(
everywhere + inputmodes + start_music + blocks[1:] + (
'midi {',
))
# stuff inside \bookpart {}
bookpart = sorted(
everywhere + inputmodes + markup + start_music + modes[2:] + blocks
)
# stuff inside \book {}
book = sorted(
everywhere + inputmodes + markup + start_music
+ modes[1:] + blocks + (
'bookOutputName',
'bookOutputSuffix',
))
lilypond_markup = listmodel.ListModel(['\\markup'])
lilypond_markup_commands = listmodel.ListModel(
sorted(ly.words.markupcommands),
display = util.command)
lilypond_header_variables = listmodel.ListModel(
sorted(ly.words.headervariables, key=lambda i: i[:3]), edit = util.variable)
lilypond_paper_variables = listmodel.ListModel(
sorted(ly.words.papervariables), edit = util.variable)
lilypond_layout_variables = listmodel.ListModel([
'\\context {',
'\\override',
'\\set',
'\\hide',
'\\omit',
'\\accidentalStyle',
] + sorted(ly.words.layoutvariables),
edit = util.cmd_or_var)
lilypond_midi_variables = listmodel.ListModel(
['\\context {', '\\override', '\\set', '\\tempo',] +
sorted(ly.words.midivariables),
edit = util.cmd_or_var)
lilypond_contexts = listmodel.ListModel(sorted(ly.words.contexts))
lilypond_grobs = listmodel.ListModel(ly.data.grobs())
lilypond_contexts_and_grobs = listmodel.ListModel(
sorted(ly.words.contexts) + ly.data.grobs())
lilypond_context_properties = listmodel.ListModel(
ly.data.context_properties())
lilypond_contexts_and_properties = listmodel.ListModel(
sorted(ly.words.contexts) + ly.data.context_properties())
lilypond_context_contents = listmodel.ListModel(sorted(itertools.chain(
util.make_cmds(ly.words.contexts),
ly.data.context_properties(),
util.make_cmds(cmds_context),
)), edit = util.cmd_or_var)
lilypond_with_contents = listmodel.ListModel(sorted(itertools.chain(
ly.data.context_properties(),
util.make_cmds(cmds_with),
)), edit = util.cmd_or_var)
lilypond_toplevel = listmodel.ListModel(sorted(itertools.chain(util.make_cmds(
toplevel + everywhere + inputmodes + markup + start_music + tweaks
+ modes + blocks
), toplevel_variables)), edit = util.cmd_or_var)
lilypond_book = listmodel.ListModel(book, display = util.command)
lilypond_bookpart = listmodel.ListModel(bookpart, display = util.command)
lilypond_score = listmodel.ListModel(score, display = util.command)
lilypond_engravers = listmodel.ListModel(ly.data.engravers())
def lilypond_grob_properties(grob, hash_quote=True):
display = (lambda item: "#'" + item) if hash_quote else (lambda item: item)
return listmodel.ListModel(ly.data.grob_properties(grob),
display = display)
lilypond_all_grob_properties = listmodel.ListModel(ly.data.all_grob_properties(),
display = lambda item: "#'" + item)
lilypond_all_grob_properties_and_grob_names = listmodel.ListModel(
ly.data.all_grob_properties() + ly.data.grobs())
lilypond_markup_properties = listmodel.ListModel(
sorted(set(sum(map(ly.data.grob_interface_properties, (
# see lilypond docs about \markup \override
'font-interface',
'text-interface',
'instrument-specific-markup-interface',
)), []))))
lilypond_modes = listmodel.ListModel(ly.words.modes, display = util.command)
lilypond_clefs = listmodel.ListModel(ly.words.clefs_plain)
lilypond_accidental_styles = listmodel.ListModel(ly.words.accidentalstyles)
lilypond_accidental_styles_contexts = listmodel.ListModel(
ly.words.contexts + ly.words.accidentalstyles)
lilypond_repeat_types = listmodel.ListModel(ly.words.repeat_types)
music_glyphs = listmodel.ListModel(ly.data.music_glyphs())
midi_instruments = listmodel.ListModel(ly.words.midi_instruments)
language_names = listmodel.ListModel(sorted(ly.pitch.pitchInfo))
def font_names():
model = listmodel.ListModel(sorted(QFontDatabase().families()))
model.setRoleFunction(Qt.FontRole, QFont)
return model
|