From 1e95a0be01466d1c98644f7705c8e07e41cc645c Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Tue, 11 Aug 1998 01:45:43 +0200 Subject: [PATCH] partial: 1.0.1.jcn --- flower/international.cc | 46 ++++++ lib/include/string-storage.hh | 30 ++++ lily/include/mark-engraver.hh | 35 +++++ lily/include/staff-margin-engraver.hh | 34 +++++ lily/include/time-signature-performer.hh | 31 ++++ lily/mark-engraver.cc | 83 +++++++++++ lily/staff-margin-engraver.cc | 91 ++++++++++++ lily/time-signature-performer.cc | 56 ++++++++ stepmake/bin/table-to-html.py | 137 ++++++++++++++++++ stepmake/bin/update.py | 173 +++++++++++++++++++++++ 10 files changed, 716 insertions(+) create mode 100644 flower/international.cc create mode 100644 lib/include/string-storage.hh create mode 100644 lily/include/mark-engraver.hh create mode 100644 lily/include/staff-margin-engraver.hh create mode 100644 lily/include/time-signature-performer.hh create mode 100644 lily/mark-engraver.cc create mode 100644 lily/staff-margin-engraver.cc create mode 100644 lily/time-signature-performer.cc create mode 100644 stepmake/bin/table-to-html.py create mode 100644 stepmake/bin/update.py diff --git a/flower/international.cc b/flower/international.cc new file mode 100644 index 0000000000..029d0f0497 --- /dev/null +++ b/flower/international.cc @@ -0,0 +1,46 @@ +/* + international.cc -- implement stuff for internationalisation + + source file of the GNU LilyPond music typesetter + + (c) 1997--1998 Jan Nieuwenhuizen + + */ + +#include +#include "config.hh" +#include "string-convert.hh" +#include "international.hh" + +#if !HAVE_GETTEXT +inline char* +gettext (char const* s) +{ + return s; +} +#else +#include +#endif + +String +_ (char const *ch) +{ + return String (gettext (ch)); +} + +String +_f (char const* format, ...) +{ + va_list args; + va_start (args, format); + String str = String_convert::vform_str (gettext (format), args); + va_end (args); + return str; +} + +String +_f (char const* format, String s, String s2, String s3) +{ + return String_convert::form_str (gettext (format), s.ch_C (), s2.ch_C (), + s3.ch_C ()); +} diff --git a/lib/include/string-storage.hh b/lib/include/string-storage.hh new file mode 100644 index 0000000000..f1d526918b --- /dev/null +++ b/lib/include/string-storage.hh @@ -0,0 +1,30 @@ +/* + string-storage.hh -- declare String_storage + + source file of the GNU LilyPond music typesetter + + (c) 1998 Jan Nieuwenhuizen + + */ + +#ifndef STRING_STORAGE_HH +#define STRING_STORAGE_HH + +#include "string.hh" +#include "file-storage.hh" + +/** + Urg, let String act as file storage. + */ +class String_storage : public File_storage, protected String +{ +public: + String_storage (String s) : String (s) { } + +protected: + virtual char const* ch_C () const { return String::ch_C (); } + virtual int length_i () const { return String::length_i (); } +}; + +#endif /* STRING_STORAGE_HH */ + diff --git a/lily/include/mark-engraver.hh b/lily/include/mark-engraver.hh new file mode 100644 index 0000000000..b095669341 --- /dev/null +++ b/lily/include/mark-engraver.hh @@ -0,0 +1,35 @@ +/* + mark-engraver.hh -- declare Mark_engraver + + source file of the GNU LilyPond music typesetter + + (c) 1998 Jan Nieuwenhuizen +*/ + + +#ifndef MARK_ENGRAVER_HH +#define MARK_ENGRAVER_HH + +#include "engraver.hh" + +/** + */ +class Mark_engraver : public Engraver +{ +public: + Mark_engraver (); + + TRANSLATOR_CLONE(Mark_engraver); + DECLARE_MY_RUNTIME_TYPEINFO; + +protected: + virtual bool do_try_request (Request *req_l); + virtual void do_process_requests (); + virtual void do_pre_move_processing (); + +private: + Mark_req * mark_req_l_; + Script* script_p_; +}; + +#endif // MARK_ENGRAVER_HH diff --git a/lily/include/staff-margin-engraver.hh b/lily/include/staff-margin-engraver.hh new file mode 100644 index 0000000000..ae9d01b4c3 --- /dev/null +++ b/lily/include/staff-margin-engraver.hh @@ -0,0 +1,34 @@ +/* + staff-margin-engraver.hh -- declare Staff_margin_engraver + + source file of the GNU LilyPond music typesetter + + (c) 1998 Jan Nieuwenhuizen +*/ + + +#ifndef STAFF_MARGIN_ENGRAVER_HH +#define STAFF_MARGIN_ENGRAVER_HH + +#include "engraver.hh" + +/** + put (instrument) text to left of line + */ +class Staff_margin_engraver : public Engraver +{ +public: + TRANSLATOR_CLONE(Staff_margin_engraver); + DECLARE_MY_RUNTIME_TYPEINFO; + + Staff_margin_engraver (); + +protected: + void acknowledge_element (Score_element_info); + void do_pre_move_processing (); + +private: + Script * script_p_; +}; + +#endif // STAFF_MARGIN_ENGRAVER_HH diff --git a/lily/include/time-signature-performer.hh b/lily/include/time-signature-performer.hh new file mode 100644 index 0000000000..a40a22382f --- /dev/null +++ b/lily/include/time-signature-performer.hh @@ -0,0 +1,31 @@ +/* + time_signature-performer.hh -- declare Time_signature_performer + + source file of the GNU LilyPond music typesetter + + (c) 1997--1998 Jan Nieuwenhuizen +*/ + +#ifndef METER_PERFOMER_HH +#define METER_PERFOMER_HH + +#include "lily-proto.hh" +#include "performer.hh" + +class Time_signature_performer : public Performer { +public: + TRANSLATOR_CLONE(Time_signature_performer); + DECLARE_MY_RUNTIME_TYPEINFO; + Time_signature_performer(); + ~Time_signature_performer(); + +protected: + void do_print() const; + virtual bool do_try_request (Request* req_l); + virtual void do_process_requests(); + +private: + Time_signature_change_req* time_signature_req_l_; +}; + +#endif // METER_PERFOMER_HH diff --git a/lily/mark-engraver.cc b/lily/mark-engraver.cc new file mode 100644 index 0000000000..274911951d --- /dev/null +++ b/lily/mark-engraver.cc @@ -0,0 +1,83 @@ +/* + mark-engraver.cc -- implement Mark_engraver + + source file of the GNU LilyPond music typesetter + + (c) 1998 Jan Nieuwenhuizen +*/ + +#include "mark-engraver.hh" +#include "text-def.hh" +#include "script.hh" +#include "paper-def.hh" +#include "command-request.hh" +#include "time-description.hh" +#include "engraver-group.hh" + +IMPLEMENT_IS_TYPE_B1 (Mark_engraver, Engraver); +ADD_THIS_TRANSLATOR (Mark_engraver); + +Mark_engraver::Mark_engraver () +{ + mark_req_l_ = 0; + script_p_ = 0; +} + +bool +Mark_engraver::do_try_request (Request* r_l) +{ + Command_req* c_l = r_l->access_Command_req (); + if (!c_l || !c_l->access_Mark_req () || mark_req_l_) + return false; + + mark_req_l_ = c_l->access_Mark_req (); + + return true; +} + +void +Mark_engraver::do_process_requests () +{ + if (!mark_req_l_ || script_p_) + return; + + script_p_ = new Script; + script_p_->breakable_b_ = true; + + Text_def *td_p = new Text_def; + + td_p->text_str_ = mark_req_l_->str_; + td_p->align_dir_ = CENTER; + + td_p->style_str_ = td_p->text_str_.index_any_i ("0123456789") >= 0 + ? "mark" : "Large"; + + script_p_->dir_ = UP; + script_p_->specs_p_ = td_p->clone (); + script_p_->postbreak_only_b_ = true; + + Scalar padding = get_property ("markScriptPadding"); + if (padding.length_i() && padding.isnum_b ()) + { + script_p_->padding_f_ = Real(padding); + } + Scalar break_priority = get_property ("markBreakPriority"); + if (break_priority.length_i() && break_priority.isnum_b ()) + { + script_p_->break_priority_i_ = int(break_priority); + } + + announce_element (Score_element_info (script_p_, mark_req_l_)); +} + +void +Mark_engraver::do_pre_move_processing () +{ + if (script_p_) + { + typeset_element (script_p_); + script_p_ = 0; + mark_req_l_ = 0; + } +} + diff --git a/lily/staff-margin-engraver.cc b/lily/staff-margin-engraver.cc new file mode 100644 index 0000000000..26150a6ba0 --- /dev/null +++ b/lily/staff-margin-engraver.cc @@ -0,0 +1,91 @@ +/* + staff-margin-engraver.cc -- implement Staff_margin_engraver + + source file of the GNU LilyPond music typesetter + + (c) 1998 Jan Nieuwenhuizen +*/ + +#include "staff-margin-engraver.hh" +#include "script.hh" +#include "text-def.hh" +#include "paper-def.hh" +#include "command-request.hh" +#include "bar.hh" +#include "stem.hh" +#include "time-description.hh" + +IMPLEMENT_IS_TYPE_B1 (Staff_margin_engraver, Engraver); +ADD_THIS_TRANSLATOR (Staff_margin_engraver); + +Staff_margin_engraver::Staff_margin_engraver () +{ + script_p_ = 0; +} + + + +/* + TODO + fix alignment/support + + should be able to set whole paragraph (multiple lines, centre) to + left (right?) of staff, e.g.: + ______ + |_______ + 2 Clarinetti |________ + (Bb) |___________ + |______________ +*/ +void +Staff_margin_engraver::acknowledge_element (Score_element_info i) +{ + Item * it = i.elem_l_->access_Item (); + + if (!it + || script_p_ + || !it->is_type_b (Bar::static_name()) + || (i.origin_grav_l_arr_.size() != 1)) + return; + + String string = get_property ("instrument"); + String str = get_property ("instr"); + if (now_moment () > Moment (0)) + string = str; + + if (!string.length_i ()) + return; + + script_p_ = new Script; + script_p_->axis_ = X_AXIS; + + Text_def *td_p =new Text_def; + td_p->align_dir_ = LEFT; + td_p->text_str_ = string; + // huh? + script_p_->dir_ = RIGHT; + script_p_->specs_p_ = td_p; + script_p_->breakable_b_ = true; + + + Scalar pri = get_property ("marginBreakPriority"); + if (pri.length_i () && pri.isnum_b ()) + { + script_p_->break_priority_i_ = int (pri); + } + else + script_p_ ->break_priority_i_ = it->break_priority_i_; + + announce_element (Score_element_info (script_p_, 0)); +} + +void +Staff_margin_engraver::do_pre_move_processing () +{ + if (script_p_) + { + typeset_element (script_p_); + script_p_ =0; + } +} + diff --git a/lily/time-signature-performer.cc b/lily/time-signature-performer.cc new file mode 100644 index 0000000000..df41bf56b0 --- /dev/null +++ b/lily/time-signature-performer.cc @@ -0,0 +1,56 @@ +/* + time_signature-performer.cc -- implement Time_signature_performer + + source file of the GNU LilyPond music typesetter + + (c) 1997--1998 Jan Nieuwenhuizen +*/ + +#include "time-signature-performer.hh" +#include "command-request.hh" +#include "audio-item.hh" + +IMPLEMENT_IS_TYPE_B1(Time_signature_performer,Performer); +ADD_THIS_TRANSLATOR(Time_signature_performer); + +Time_signature_performer::Time_signature_performer() +{ + time_signature_req_l_ = 0; +} + +Time_signature_performer::~Time_signature_performer() +{ +} + +void +Time_signature_performer::do_print() const +{ +#ifndef NPRINT + if (time_signature_req_l_) + time_signature_req_l_->print(); +#endif +} + +void +Time_signature_performer::do_process_requests() +{ + if (time_signature_req_l_) + play (new Audio_time_signature (time_signature_req_l_)); + time_signature_req_l_ = 0; +} + +bool +Time_signature_performer::do_try_request (Request* req_l) +{ + if (time_signature_req_l_) + return false; + + if (req_l->access_Command_req ()) + time_signature_req_l_ = req_l->access_Command_req ()->access_Time_signature_change_req (); + + if (time_signature_req_l_) + return true; + + return false; +} + diff --git a/stepmake/bin/table-to-html.py b/stepmake/bin/table-to-html.py new file mode 100644 index 0000000000..d43590f0d7 --- /dev/null +++ b/stepmake/bin/table-to-html.py @@ -0,0 +1,137 @@ +#!@PYTHON@ + +# table-to-html.py -- convert char-separated table to html table +# +# source file of the GNU LilyPond music typesetter +# +# (c) 1998 Jan Nieuwenhuizen + +version = '0.1' +name = 'table-to-html' + +import os +import sys + +import getopt +from string import * +import regex +import regsub +import time + +def program_id (): + return name + ' version ' + version; + +def identify (): + sys.stdout.write (program_id () + '\n') + +def help (): + sys.stdout.write ("Usage: table-to-html [OPTION]... TABLE-FILE HTML-FILENAME\n" + + "Generate pretty table from char separated table\n\n" + + "Options:\n" + + " -h, --help print this help\n" + + " -p, --package=DIR specify package\n" + + " -s, --separator=SEP specify separator [:]\n" + + " -t, --latex do latex output instead\n" + ) + + sys.exit (0) + + +def header (html): + html.write ('') + +def footer (html): + html.write ('
') + +def convert_html (inname, outname, separator): + # urg, again? + from flower import * + table = File (inname) + # ugh + html = File (outname, 'w') + + header (html) + i = 0 + while not table.eof (): + line = table.readline () + i = i + 1 + if not len(line): + continue + columns = split (line, separator) + html_line = '' + join (columns, '') + '' + html.write (html_line) + if len (columns) < 7: + print inname + ': ' + str(i) + ':warning: not enough cols\n' + continue + if len (columns) > 7: + print inname + ': ' + str(i) + ':warning: too many cols\n' + continue + + table.close () + footer (html) + html.close () + +def convert_tex (inname, outname, separator): + # urg, again? + from flower import * + table = File (inname) + # ugh + html = File (outname, 'w') + + i = 0 + while not table.eof (): + line = table.readline () + i = i + 1 + if not len(line): + continue + columns = split (line, separator) + if len (columns) < 7: + print inname + ': ' + str(i) + ':warning: not enough cols\n' + continue + if len (columns) > 7: + print inname + ': ' + str(i) + ':warning: too many cols\n' + continue + + html_line = '\\tableentry{' + join (columns, '}{') + '}\n' + html.write (html_line) + table.close () + html.close () + +def main (): + identify () + (options, files) = getopt.getopt ( + sys.argv[1:], 'to:hp:s:', ['help', 'latex', 'output=', 'package=', 'separator=']) + latex = 0 + separator = ':' + output = '' + for opt in options: + o = opt[0] + a = opt[1] + if o == '--separator' or o == '-s': + separator = a + elif o== '--help' or o == '-h': + help () + elif o=='--latex' or o == '-t': + latex = 1 + elif o == '--output' or o == '-o': + output = a + elif o == '--package' or o == '-p': + topdir=a + else: + print o + raise getopt.error + + sys.path.append (topdir + '/stepmake/bin') + from packagepython import * + package = Package (topdir) + packager = Packager () + + from flower import * + + if latex: + convert_tex (files[0], output, separator) + else: + convert_html (files[0], output, separator) + +main () + diff --git a/stepmake/bin/update.py b/stepmake/bin/update.py new file mode 100644 index 0000000000..60521aeae4 --- /dev/null +++ b/stepmake/bin/update.py @@ -0,0 +1,173 @@ +#!@PYTHON@ + +# update.py -- update current source tree +# +# source file of the GNU LilyPond music typesetter +# +# (c) 1998 Jan Nieuwenhuizen + +program_name = 'update' +version = '0.1' + +import os +import sys + +sys.path.append ('@abs-step-bindir@') +sys.path.append (os.environ['HOME'] + '/usr/src/lilypond/stepmake/bin') + +import getopt +from string import * +import regex +import regsub +import time + +def program_id (): + return program_name + ' version ' + version; + +def identify (): + sys.stdout.write (program_id () + '\n') + +def help (): + sys.stdout.write ("Usage: %s [OPTION]...\n" + "Update sourcetree\n\n" + + "Options:\n" + + " -f, --file=FILE specify patch file\n" + + " -h, --help print this help\n" + + " -p, --package=DIR specify package\n" + + " -v, --version=VER specify patch version\n" + % (program_name) + ) + sys.exit (0) + +identify () +(options, files) = getopt.getopt ( + sys.argv[1:], 'f:hp:v:', ['file=', 'help', 'package=', 'version=']) +patch='' +ver='' +for opt in options: + o = opt[0] + a = opt[1] + if o == '--help' or o == '-h': + help () + elif o == '-f' or o == '--file': + patch = a + elif o == '-p' or o == '--package': + topdir = a + elif o == '-v' or o == '--version': + ver = a + else: + print o + raise getopt.error + +sys.path.append (topdir + '/stepmake/bin') +from packagepython import * +package = Package (topdir) +packager = Packager () + +from flower import * + +def read_patch_vector (patch): + vec = [] + pipe = os.popen ('gzip -dc ' + patch) + line = pipe.readline () + while line and line != '--state\n': + line = pipe.readline () + line = pipe.readline () + while line and line != '++state\n': + vec.append (line[:len (line)-1]) + line = pipe.readline () + pipe.close () + return vec + +def read_state_vector (states): + vec = [] + file = File (states) + while not file.eof (): + line = file.readline () + if line: + vec.append (line[:len (line)-1]) + return vec + +def read_relevant_state_vector (states, from_str): + vec = read_state_vector (states) + for i in range (len (vec)): + if vec[i] == from_str: + return vec[i:] + return [] + +def find_revert (states, patch): + for i in range (len (state_vector)): + for j in doubles: + if j in state_vector[:i+1]: + return state_vector[i:] + return [] + +if patch == '' and ver != '': + patch = package.patch_dir + '/' + package.name + '-%s.diff.gz' % ver +if patch == '': + if 0: + files = os.listdir (package.patch_dir) + patches = [] + for i in files: + if regex.search (package.name + '-.*.diff.gz', i) == 0: + patches.append (i) + # urg: sort + patch = package.patch_dir + '/' + patches[len (patches) -1] + else: + os.chdir (package.patch_dir) + pipe = os.popen ('/bin/ls -t1 ' + package.name + + '-*.diff.gz 2> /dev/null') + patch = pipe.readline () + patch = patch[:len (patch) -1] + pipe.close () + if not patch: + raise 'patch not found' + patch = package.patch_dir + '/' + patch + print patch + +os.chdir (package.topdir) +patch_vector = read_patch_vector (patch) +print 'patch vector: ' + str (patch_vector) +from_str = patch_vector[0] +state_vector = read_relevant_state_vector ('make/STATE-VECTOR', from_str) +print 'relevant state vector: ' + str (state_vector) + +doubles = [] +for i in patch_vector[1:]: + if i in state_vector: + doubles.append (i) +print 'doubles: ' + str (doubles) + +revert = find_revert (state_vector, patch_vector) +redo = [] +for i in revert: + redo.append (i) +revert.reverse () + +for i in doubles: + redo.remove (i) + +if revert or redo or doubles: + print 'not smart enough; please do:' + print ' * revert: ' + str (revert) + print ' * apply: ' + os.path.basename (patch) + print ' * redo: ' + str (redo) + sys.exit (1) + +status = os.system ('echo "gzip -dc %s | patch -p1 -E --force"' % patch) +if status: + raise 'apply patch failed' + +sys.stdout.write ('checking...') +rejects = my_find (['*.rej'], '.') +if len (rejects): + print 'rejects found:' + for i in rejects: + print i + sys.exit (1) +print 'ok' +sys.stdout.write ('cleaning...') +origs = my_find (['*.orig'], '.') +for i in origs: + os.remove (i) +print 'ok' -- 2.39.2