From: Luca Padovani Date: Thu, 20 Mar 2003 16:15:12 +0000 (+0000) Subject: * added default dictionary/stylesheet paths X-Git-Tag: before_refactoring~102 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=84877da90dd68c88915b5ee54d31e9849f340eac;p=helm.git * added default dictionary/stylesheet paths * small fix in configure.ac --- diff --git a/helm/DEVEL/mathml_editor/configure.ac b/helm/DEVEL/mathml_editor/configure.ac index 20227a54d..f39a5f93f 100644 --- a/helm/DEVEL/mathml_editor/configure.ac +++ b/helm/DEVEL/mathml_editor/configure.ac @@ -35,7 +35,7 @@ AC_ARG_WITH(gmetadom-prefix, GMETADOM_PREFIX=$withval ) -AC_CONFIG_HEADERS([config.h]) +dnl AC_CONFIG_HEADERS([config.h]) AM_CONFIG_HEADER(config.h) AH_TOP([ @@ -249,6 +249,7 @@ AC_SUBST(OCAML_INCLUDE_DIR) AC_CONFIG_FILES([ Makefile src/Makefile + src/config.dirs test/Makefile textomml/Makefile textomml/config.dirs diff --git a/helm/DEVEL/mathml_editor/ocaml/c_mathml_editor.cc b/helm/DEVEL/mathml_editor/ocaml/c_mathml_editor.cc index 73bc4abb7..f610a7ff5 100644 --- a/helm/DEVEL/mathml_editor/ocaml/c_mathml_editor.cc +++ b/helm/DEVEL/mathml_editor/ocaml/c_mathml_editor.cc @@ -96,6 +96,24 @@ Editor::~Editor() delete logger; } +extern "C" const char* +c_mathml_editor_get_default_dictionary_path() +{ + return TDictionary::getDefaultDictionaryPath().c_str(); +} + +extern "C" const char* +c_mathml_editor_get_default_mathml_stylesheet_path() +{ + return AMathMLFactory::getDefaultMathMLStylesheetPath().c_str(); +} + +extern "C" const char* +c_mathml_editor_get_default_tex_stylesheet_path() +{ + return AMathMLFactory::getDefaultTeXStylesheetPath().c_str(); +} + extern "C" Editor* c_mathml_editor_new(GdomeDocument* dictionary, GdomeDocument* tml_mml, diff --git a/helm/DEVEL/mathml_editor/ocaml/c_mathml_editor.h b/helm/DEVEL/mathml_editor/ocaml/c_mathml_editor.h index 63796bcd8..6c8a5f5cb 100644 --- a/helm/DEVEL/mathml_editor/ocaml/c_mathml_editor.h +++ b/helm/DEVEL/mathml_editor/ocaml/c_mathml_editor.h @@ -30,6 +30,9 @@ typedef struct Editor Editor; +const char* c_mathml_editor_get_default_dictionary_path(void); +const char* c_mathml_editor_get_default_mathml_stylesheet_path(void); +const char* c_mathml_editor_get_default_tex_stylesheet_path(void); Editor* c_mathml_editor_new(GdomeDocument*, GdomeDocument*, GdomeDocument*, void (*)(int, const char*, void*), void*); void c_mathml_editor_destroy(Editor*); int c_mathml_editor_freeze(Editor*); diff --git a/helm/DEVEL/mathml_editor/ocaml/i_mathml_editor.ml b/helm/DEVEL/mathml_editor/ocaml/i_mathml_editor.ml index 229478101..25171b8bb 100644 --- a/helm/DEVEL/mathml_editor/ocaml/i_mathml_editor.ml +++ b/helm/DEVEL/mathml_editor/ocaml/i_mathml_editor.ml @@ -25,6 +25,15 @@ type t +external get_default_dictionary_path : unit -> string + = "ml_mathml_editor_get_default_dictionary_path" + +external get_default_mathml_stylesheet_path : unit -> string + = "ml_mathml_editor_get_default_mathml_stylesheet_path" + +external get_default_tex_stylesheet_path : unit -> string + = "ml_mathml_editor_get_default_tex_stylesheet_path" + external create : dictionary:[> `Document] GdomeT.t -> mml: [> `Document] GdomeT.t -> diff --git a/helm/DEVEL/mathml_editor/ocaml/mathml_editor.ml b/helm/DEVEL/mathml_editor/ocaml/mathml_editor.ml index 06372e8e4..472760184 100644 --- a/helm/DEVEL/mathml_editor/ocaml/mathml_editor.ml +++ b/helm/DEVEL/mathml_editor/ocaml/mathml_editor.ml @@ -23,6 +23,15 @@ * or send an email to *) +let default_dictionary_path = I_mathml_editor.get_default_dictionary_path () +;; + +let default_mathml_stylesheet_path = I_mathml_editor.get_default_mathml_stylesheet_path () +;; + +let default_tex_stylesheet_path = I_mathml_editor.get_default_tex_stylesheet_path () +;; + let create ~dictionary ~mml ~tml ~log = I_mathml_editor.create dictionary#as_Document mml#as_Document tml#as_Document log ;; diff --git a/helm/DEVEL/mathml_editor/ocaml/ml_mathml_editor.c b/helm/DEVEL/mathml_editor/ocaml/ml_mathml_editor.c index 9b78aeb41..4f84fffe3 100644 --- a/helm/DEVEL/mathml_editor/ocaml/ml_mathml_editor.c +++ b/helm/DEVEL/mathml_editor/ocaml/ml_mathml_editor.c @@ -58,7 +58,7 @@ ml_mathml_editor_finalize(value v) free(editor); } -void +static void ml_mathml_editor_log_callback(int level, const char* msg, void* user_data) { ml_Editor* ml_editor = (ml_Editor*) user_data; @@ -66,6 +66,27 @@ ml_mathml_editor_log_callback(int level, const char* msg, void* user_data) callback2(ml_editor->callback, Val_int(level), copy_string(msg)); } +value +ml_mathml_editor_get_default_dictionary_path(value unit) +{ + CAMLparam1(unit); + CAMLreturn(copy_string(c_mathml_editor_get_default_dictionary_path())); +} + +value +ml_mathml_editor_get_default_mathml_stylesheet_path(value unit) +{ + CAMLparam1(unit); + CAMLreturn(copy_string(c_mathml_editor_get_default_mathml_stylesheet_path())); +} + +value +ml_mathml_editor_get_default_tex_stylesheet_path(value unit) +{ + CAMLparam1(unit); + CAMLreturn(copy_string(c_mathml_editor_get_default_tex_stylesheet_path())); +} + value ml_mathml_editor_new(value dictionary, value tml_mml, diff --git a/helm/DEVEL/mathml_editor/src/AMathMLFactory.cc b/helm/DEVEL/mathml_editor/src/AMathMLFactory.cc new file mode 100644 index 000000000..8f8b21ce6 --- /dev/null +++ b/helm/DEVEL/mathml_editor/src/AMathMLFactory.cc @@ -0,0 +1,42 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#include + +#include "config.dirs" +#include "AMathMLFactory.hh" + +std::string +AMathMLFactory::getDefaultMathMLStylesheetPath() +{ + return PKGDATADIR"tml-mmlp.xsl"; +} + +std::string +AMathMLFactory::getDefaultTeXStylesheetPath() +{ + return PKGDATADIR"tml-tex.xsl"; +} + diff --git a/helm/DEVEL/mathml_editor/src/AMathMLFactory.hh b/helm/DEVEL/mathml_editor/src/AMathMLFactory.hh index b91d240d4..f53b56408 100644 --- a/helm/DEVEL/mathml_editor/src/AMathMLFactory.hh +++ b/helm/DEVEL/mathml_editor/src/AMathMLFactory.hh @@ -34,6 +34,9 @@ public: AMathMLFactory(class ALogger& l) : logger(l) { }; virtual ~AMathMLFactory() { }; + static std::string getDefaultMathMLStylesheetPath(void); + static std::string getDefaultTeXStylesheetPath(void); + virtual void documentModified(class TDocument&) = 0; virtual DOM::Document document(void) const = 0; diff --git a/helm/DEVEL/mathml_editor/src/ILPushLexer.cc b/helm/DEVEL/mathml_editor/src/ILPushLexer.cc index 8a2777fef..b82b52e5c 100644 --- a/helm/DEVEL/mathml_editor/src/ILPushLexer.cc +++ b/helm/DEVEL/mathml_editor/src/ILPushLexer.cc @@ -24,7 +24,7 @@ ILPushLexer::complete() if (!complete_list.size()) { // no matching macro - logger.warning("wrong prefix: nothing to complete"); + logger.warning("no known macro with `" + buffer + "' prefix"); } else if (complete_list.size() == 1) { @@ -34,7 +34,13 @@ ILPushLexer::complete() else { // we have more than one matching macro - logger.warning("prefix not sufficient"); + logger.warning("ambiguous prefix `" + buffer + "'"); + for (std::list::const_iterator p = complete_list.begin(); + p != complete_list.end(); + p++) + { + logger.info("Candidate: " + *p); + } buffer = new_buffer; } diff --git a/helm/DEVEL/mathml_editor/src/Makefile.am b/helm/DEVEL/mathml_editor/src/Makefile.am index 439f23e52..f1c14e5f0 100644 --- a/helm/DEVEL/mathml_editor/src/Makefile.am +++ b/helm/DEVEL/mathml_editor/src/Makefile.am @@ -16,6 +16,7 @@ libeditex_la_SOURCES = \ LPushLexer.cc \ APushParser.cc \ TPushParser.cc \ + AMathMLFactory.cc \ CMathMLFactoryXSLT.cc \ CMathMLFactoryXSLTDiff.cc \ TDictionary.cc \ diff --git a/helm/DEVEL/mathml_editor/src/TDictionary.cc b/helm/DEVEL/mathml_editor/src/TDictionary.cc index c1aae5cc1..2359b69cb 100644 --- a/helm/DEVEL/mathml_editor/src/TDictionary.cc +++ b/helm/DEVEL/mathml_editor/src/TDictionary.cc @@ -26,6 +26,7 @@ #include #include "dom.hh" +#include "config.dirs" #include "TDictionary.hh" #include "TTokenizer.hh" #include "CLoggerConsole.hh" @@ -48,6 +49,12 @@ getURIName(const std::string& uri) else return uri; } +std::string +TDictionary::getDefaultDictionaryPath() +{ + return PKGDATADIR"/dictionary-tex.xml"; +} + void TDictionary::load(const std::string& uri) { diff --git a/helm/DEVEL/mathml_editor/src/TDictionary.hh b/helm/DEVEL/mathml_editor/src/TDictionary.hh index 43c2e51af..8807f8377 100644 --- a/helm/DEVEL/mathml_editor/src/TDictionary.hh +++ b/helm/DEVEL/mathml_editor/src/TDictionary.hh @@ -84,6 +84,8 @@ public: unsigned table : 1; }; + static std::string getDefaultDictionaryPath(void); + void load(const std::string&); void load(const std::string&, const std::string&); void load(const DOM::Document&, const std::string& = ""); diff --git a/helm/DEVEL/mathml_editor/src/config.dirs.in b/helm/DEVEL/mathml_editor/src/config.dirs.in new file mode 100644 index 000000000..1ce2d0a5e --- /dev/null +++ b/helm/DEVEL/mathml_editor/src/config.dirs.in @@ -0,0 +1,3 @@ + +#define PKGDATADIR "@prefix@/share/@PACKAGE@" + diff --git a/helm/DEVEL/mathml_editor/test/editor.cc b/helm/DEVEL/mathml_editor/test/editor.cc index 6f9175f94..37b84866c 100644 --- a/helm/DEVEL/mathml_editor/test/editor.cc +++ b/helm/DEVEL/mathml_editor/test/editor.cc @@ -162,7 +162,7 @@ main(int argc, char* argv[]) DOM::Document texStyleDoc = di.createDocumentFromURI("./xsl/tml-texid.xsl"); DOMX::XSLTStylesheet texStyle(texStyleDoc); - CMathMLFactoryXSLT factory(logger, mmlStyle); + CMathMLFactoryXSLTDiff factory(logger, mmlStyle); TPushParser parser(logger, factory, dictionary); ILPushLexer lexer(logger, parser, dictionary);