From 4d3288c95b580560b4707e163a0e60609e287758 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Mon, 24 Jul 2000 21:49:58 +0000 Subject: [PATCH] more NEW_INSETS changes, define NEW_MANUBAR as default some other changes, read ChangeLog git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@915 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 69 +++++ acinclude.m4 | 155 ++++++++---- config/lyxinclude.m4 | 174 ++++++++----- configure.in | 1 + lib/lyxrc.example | 13 +- src/BufferView2.C | 13 +- src/CutAndPaste.C | 84 ++++++- src/LyXAction.C | 42 ++-- src/LyXView.h | 2 +- src/MenuBackend.C | 82 +++--- src/MenuBackend.h | 72 +++--- src/TableLayout.C | 2 + src/ToolbarDefaults.C | 13 + src/Variables.h | 2 +- src/buffer.C | 175 ++++++++++++- src/buffer.h | 5 +- src/commandtags.h | 69 ++--- src/encoding.C | 61 +++++ src/encoding.h | 40 --- src/insets/insettabular.C | 10 +- src/insets/insettext.C | 78 ++++-- src/layout.h | 4 +- src/lyx_cb.C | 9 + src/lyx_main.C | 15 +- src/lyx_main.h | 6 +- src/lyxfunc.C | 2 +- src/lyxlex_pimpl.C | 12 +- src/lyxparagraph.h | 23 +- src/lyxrc.C | 515 ++++++++++++++++++++++---------------- src/menus.C | 43 +++- src/paragraph.C | 335 +++++++++++++++---------- src/support/lstrings.C | 22 +- src/text.C | 76 +++++- src/text2.C | 176 ++++++------- 34 files changed, 1603 insertions(+), 797 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4a3bb9348c..fb7bd09db3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,72 @@ +2000-07-25 Lars Gullik Bjønnes + + * src/support/lstrings.C (prefixIs): rewrite so that gcc bastring + can be used. + (suffixIs): ditto + + * src/paragraph.C (GetChar): remove non-const version + + * src/lyxlex_pimpl.C (compare_tags): rewritten to suit cvs gcc 2.96 + (search_kw): use it. + + * src/lyx_main.C (init): if "preferences" exist, read that instead + of "lyxrc". + (ReadRcFile): return bool if the file could be read ok. + (ReadUIFile): add a check to see if lex file is set ok. + + * src/lyx_cb.C (InsertAsciiFile): rewrite a bit so that gcc + bastring can be used instead of lyxstring (still uses the old code + if std::string is good enough or if lyxstring is used.) + + * src/encoding.C: make the arrays static, move ininle functions + here + * src/encoding.h: from here. + + * src/buffer.C: have last_isnet_read as a file scope variable for now. + (parseSingleLyXformat2Token): move inset parsing to separate method + (readInset): new private method + + * src/Variables.h: remove virtual from get(). + + * src/ToolbarDefaults.C: include lyxparagraph.h temporary to get + access to NEW_INSETS and NEW_TABULAR + + * src/MenuBackend.h: remove superfluous forward declaration of + MenuItem. Add documentations tags "///", remove empty MenuItem + destructor, remove private default contructor. + + * src/MenuBackend.C (MenuItem): remove unneeded copy contructor + (add): return *this + (read): more string mlabel and mname to where they are used + (read): remove unused variables mlabel and mname + (defaults): unconditional clear, make menusetup take advantage of + add returning Menu &. + + * src/LyXView.h: define NEW_MENUBAR as default + + * src/LyXAction.C: include lyxparagraph.h temporary to get access + to NEW_INSETS and NEW_TABULAR. + (init): commetn out some funcs that is obsolete when NEW_INSETS is + defined. Change some of the "xxxx-inset-insert" functions names to + "xxxx-insert". + + * several files: more enahncements to NEW_INSETS and the resulting + LyXParagraph code. + + * lib/lyxrc.example (\date_insert_format): move to misc section + + * config/lyxinclude.m4 (LYX_CXX_STL_STRING): allow to use the gcc + bastring and use AC_CACHE_CHECK. + (LYX_CXX_GOOD_STD_STRING): new check. Checks if the std::string of + the system have the newest methods. uses AC_CACHE_CHECK + (LYX_CXX_MUTABLE): use AC_CACHE_CHECK + (LYX_CXX_PARTIAL): use AC_CACHE_CHECK + (LYX_CXX_NAMESPACES): use AC_CACHE_CHECK + + * configure.in: add LYX_CXX_GOOD_STD_STRING + + * acinclude.m4: recreated + 2000-07-24 Amir Karger * README: add Hebrew, Arabic kmaps diff --git a/acinclude.m4 b/acinclude.m4 index 6b5a3602ca..ca5db23548 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -333,38 +333,84 @@ fi]) dnl Usage: LYX_CXX_STL_STRING : checks whether the C++ compiler -dnl has a working stl string container, the check is really stupid -dnl and could need some improvement. +dnl has a std::string that is usable for LyX. LyX does not require this +dnl std::string to be standard. AC_DEFUN(LYX_CXX_STL_STRING,[ AC_REQUIRE([LYX_PROG_CXX]) AC_MSG_CHECKING(whether the included std::string should be used) AC_ARG_WITH(included-string, [ --with-included-string use LyX string class instead of STL string], - [with_included_string=$withval], - [AC_TRY_COMPILE([ + [lyx_cv_with_included_string=$withval], + [AC_CACHE_CHECK([],lyx_cv_with_included_string, + [AC_TRY_COMPILE([ #include using std::string; ],[ + // LyX has reduced its requirements on the basic_string + // implementation so that the basic_string supplied + // with gcc is usable. In particular this means that + // lyx does not use std::string::clear and not the + // strncmp version of std::string::compare. This is mainly + // done so that LyX can use precompiled C++ libraries that + // already uses the systems basic_string, e.g. gtk-- string a("hello there"); a.erase(); a = "hey"; - char s[] = "y"; - int t = a.compare(a.length() - 1, 1, s); + //char s[] = "y"; + //int t = a.compare(a.length() - 1, 1, s); a.erase(); ],[ - with_included_string=no + lyx_cv_with_included_string=no ],[ - with_included_string=yes - + lyx_cv_with_included_string=yes + ]) ]) ]) - if test x$with_included_string = xyes ; then + if test x$lyx_cv_with_included_string = xyes ; then AC_DEFINE(USE_INCLUDED_STRING, 1, [Define to use the lyxstring class bundled with LyX.]) lyx_flags="$lyx_flags included-string" fi - AM_CONDITIONAL(USE_LYXSTRING, test x$with_included_string = xyes) - AC_MSG_RESULT([$with_included_string]) + AM_CONDITIONAL(USE_LYXSTRING, test x$lyx_cv_with_included_string = xyes) +dnl AC_MSG_RESULT([$with_included_string]) +]) + + +dnl Usage: LYX_CXX_GOOD_STD_STRING : checks whether the C++ compiler +dnl has a std::string that is close to the standard. So close that +dnl methods not found in "unstandard" std::strings are present here. +AC_DEFUN(LYX_CXX_GOOD_STD_STRING,[ + AC_REQUIRE([LYX_PROG_CXX]) +dnl AC_MSG_CHECKING(whether the systems std::string is really good) + AC_CACHE_CHECK([whether the systems std::string is really good], + [lyx_cv_std_string_good], + [AC_TRY_COMPILE([ + #include + using std::string; + ],[ + // From a std::string that is supposed to be close to the + // standard we require at least three things: + // - clear() and erase() + // - the strncmp of compare() + // - push_back() + string a("hello there"); + a.erase(); + a = "hey"; + char s[] = "y"; + int t = a.compare(a.length() - 1, 1, s); + a.push_back('g'); + a.clear(); + ],[ + lyx_cv_std_string_good=yes + ],[ + lyx_cv_std_string_good=no + + ]) + ]) + if test x$lyx_cv_std_string_good = xyes ; then + AC_DEFINE(STD_STRING_IS_GOOD, 1, + [Define is the systems std::string is really good.]) + fi ]) @@ -379,49 +425,56 @@ AC_DEFUN(LYX_REGEX,[ dnl LYX_CXX_MUTABLE AC_DEFUN(LYX_CXX_MUTABLE, [ -AC_REQUIRE([LYX_PROG_CXX]) -AC_MSG_CHECKING(if C++ compiler supports mutable) -AC_TRY_COMPILE( -[ -class k { - mutable char *c; -public: - void foo() const { c=0; } -}; -],[ -],[ - ac_mutable=yes - AC_DEFINE(HAVE_MUTABLE, 1, - [Defined if you compiler supports 'mutable'.]) -],[ - ac_mutable=no -]) -AC_MSG_RESULT([$ac_mutable]) + AC_REQUIRE([LYX_PROG_CXX]) +dnl AC_MSG_CHECKING(if C++ compiler supports mutable) + AC_CACHE_CHECK([if C++ compiler supports mutable], + lyx_cv_cxx_mutable,[ + AC_TRY_COMPILE( + [ + class k { + mutable char *c; + public: + void foo() const { c=0; } + }; + ],[ + ],[ + lyx_cv_cxx_mutable=yes + ],[ + lyx_cv_cxx_mutable=no + ]) + ]) + if test $lyx_cv_cxx_mutable = yes ; then + AC_DEFINE(HAVE_MUTABLE, 1, + [Defined if your compiler suports 'mutable'.]) + fi ]) dnl LYX_CXX_PARTIAL AC_DEFUN(LYX_CXX_PARTIAL, [ -AC_REQUIRE([LYX_PROG_CXX]) -AC_MSG_CHECKING(if C++ compiler supports partial specialization) -AC_TRY_COMPILE( -[ -template -class k { -public: -}; -template class k { }; -],[ - k b; - k a; -],[ - ac_partial_specialization=yes - AC_DEFINE(HAVE_PARTIAL_SPECIALIZATION, 1, - [Defined if your compiler supports partial specialization.]) -],[ - ac_partial_specialization=no -]) -AC_MSG_RESULT([$ac_partial_specialization]) + AC_REQUIRE([LYX_PROG_CXX]) + AC_CACHE_CHECK([if C++ compiler supports partial specialization], + [lyx_cv_cxx_partial_specialization], + [AC_TRY_COMPILE( + [ + template + class k { + public: + }; + template class k { }; + ],[ + k b; + k a; + ],[ + lyx_cv_cxx_partial_specialization=yes + ],[ + lyx_cv_cxx_partial_specialization=no + ]) + ]) + if test x$lyx_cv_cxx_partial_specialization = xyes ; then + AC_DEFINE(HAVE_PARTIAL_SPECIALIZATION, 1, + [Defined if your compiler supports partial specialization.]) + fi ]) @@ -440,7 +493,7 @@ AC_CACHE_CHECK(for correct namespaces support,lyx_cv_cxx_namespace, return 0; ],lyx_cv_cxx_namespace=yes,lyx_cv_cxx_namespace=no) ]) -if test $lyx_cv_cxx_namespace = yes ; then +if test x$lyx_cv_cxx_namespace = xyes ; then AC_DEFINE(CXX_WORKING_NAMESPACES, 1, [Define if your C++ compiler has correct support for namespaces]) fi]) diff --git a/config/lyxinclude.m4 b/config/lyxinclude.m4 index 92a81bb29d..904faff771 100644 --- a/config/lyxinclude.m4 +++ b/config/lyxinclude.m4 @@ -333,38 +333,83 @@ fi]) dnl Usage: LYX_CXX_STL_STRING : checks whether the C++ compiler -dnl has a working stl string container, the check is really stupid -dnl and could need some improvement. +dnl has a std::string that is usable for LyX. LyX does not require this +dnl std::string to be standard. AC_DEFUN(LYX_CXX_STL_STRING,[ AC_REQUIRE([LYX_PROG_CXX]) AC_MSG_CHECKING(whether the included std::string should be used) AC_ARG_WITH(included-string, [ --with-included-string use LyX string class instead of STL string], - [with_included_string=$withval], - [AC_TRY_COMPILE([ + [lyx_cv_with_included_string=$withval], + [AC_CACHE_CHECK([],lyx_cv_with_included_string, + [AC_TRY_COMPILE([ #include using std::string; ],[ + // LyX has reduced its requirements on the basic_string + // implementation so that the basic_string supplied + // with gcc is usable. In particular this means that + // lyx does not use std::string::clear and not the + // strncmp version of std::string::compare. This is mainly + // done so that LyX can use precompiled C++ libraries that + // already uses the systems basic_string, e.g. gtk-- string a("hello there"); a.erase(); a = "hey"; - char s[] = "y"; - int t = a.compare(a.length() - 1, 1, s); + //char s[] = "y"; + //int t = a.compare(a.length() - 1, 1, s); a.erase(); ],[ - with_included_string=no + lyx_cv_with_included_string=no ],[ - with_included_string=yes - + lyx_cv_with_included_string=yes + ]) ]) ]) - if test x$with_included_string = xyes ; then + if test x$lyx_cv_with_included_string = xyes ; then AC_DEFINE(USE_INCLUDED_STRING, 1, [Define to use the lyxstring class bundled with LyX.]) lyx_flags="$lyx_flags included-string" fi - AM_CONDITIONAL(USE_LYXSTRING, test x$with_included_string = xyes) - AC_MSG_RESULT([$with_included_string]) + AM_CONDITIONAL(USE_LYXSTRING, test x$lyx_cv_with_included_string = xyes) +dnl AC_MSG_RESULT([$with_included_string]) +]) + + +dnl Usage: LYX_CXX_GOOD_STD_STRING : checks whether the C++ compiler +dnl has a std::string that is close to the standard. So close that +dnl methods not found in "unstandard" std::strings are present here. +AC_DEFUN(LYX_CXX_GOOD_STD_STRING,[ + AC_REQUIRE([LYX_PROG_CXX]) + AC_CACHE_CHECK([whether the systems std::string is really good], + [lyx_cv_std_string_good], + [AC_TRY_COMPILE([ + #include + using std::string; + ],[ + // From a std::string that is supposed to be close to the + // standard we require at least three things: + // - clear() and erase() + // - the strncmp of compare() + // - push_back() + string a("hello there"); + a.erase(); + a = "hey"; + char s[] = "y"; + int t = a.compare(a.length() - 1, 1, s); + a.push_back('g'); + a.clear(); + ],[ + lyx_cv_std_string_good=yes + ],[ + lyx_cv_std_string_good=no + + ]) + ]) + if test x$lyx_cv_std_string_good = xyes ; then + AC_DEFINE(STD_STRING_IS_GOOD, 1, + [Define is the systems std::string is really good.]) + fi ]) @@ -379,49 +424,55 @@ AC_DEFUN(LYX_REGEX,[ dnl LYX_CXX_MUTABLE AC_DEFUN(LYX_CXX_MUTABLE, [ -AC_REQUIRE([LYX_PROG_CXX]) -AC_MSG_CHECKING(if C++ compiler supports mutable) -AC_TRY_COMPILE( -[ -class k { - mutable char *c; -public: - void foo() const { c=0; } -}; -],[ -],[ - ac_mutable=yes - AC_DEFINE(HAVE_MUTABLE, 1, - [Defined if you compiler supports 'mutable'.]) -],[ - ac_mutable=no -]) -AC_MSG_RESULT([$ac_mutable]) + AC_REQUIRE([LYX_PROG_CXX]) + AC_CACHE_CHECK([if C++ compiler supports mutable], + lyx_cv_cxx_mutable,[ + AC_TRY_COMPILE( + [ + class k { + mutable char *c; + public: + void foo() const { c=0; } + }; + ],[ + ],[ + lyx_cv_cxx_mutable=yes + ],[ + lyx_cv_cxx_mutable=no + ]) + ]) + if test $lyx_cv_cxx_mutable = yes ; then + AC_DEFINE(HAVE_MUTABLE, 1, + [Defined if your compiler suports 'mutable'.]) + fi ]) dnl LYX_CXX_PARTIAL AC_DEFUN(LYX_CXX_PARTIAL, [ -AC_REQUIRE([LYX_PROG_CXX]) -AC_MSG_CHECKING(if C++ compiler supports partial specialization) -AC_TRY_COMPILE( -[ -template -class k { -public: -}; -template class k { }; -],[ - k b; - k a; -],[ - ac_partial_specialization=yes - AC_DEFINE(HAVE_PARTIAL_SPECIALIZATION, 1, - [Defined if your compiler supports partial specialization.]) -],[ - ac_partial_specialization=no -]) -AC_MSG_RESULT([$ac_partial_specialization]) + AC_REQUIRE([LYX_PROG_CXX]) + AC_CACHE_CHECK([if C++ compiler supports partial specialization], + [lyx_cv_cxx_partial_specialization], + [AC_TRY_COMPILE( + [ + template + class k { + public: + }; + template class k { }; + ],[ + k b; + k a; + ],[ + lyx_cv_cxx_partial_specialization=yes + ],[ + lyx_cv_cxx_partial_specialization=no + ]) + ]) + if test x$lyx_cv_cxx_partial_specialization = xyes ; then + AC_DEFINE(HAVE_PARTIAL_SPECIALIZATION, 1, + [Defined if your compiler supports partial specialization.]) + fi ]) @@ -430,20 +481,21 @@ dnl has a correct namespace handling and define CXX_WORKING_NAMESPACES dnl if true. This macro does not do a thourough test, but it should be dnl good enough to suit our needs. AC_DEFUN(LYX_CXX_NAMESPACES,[ -AC_CACHE_CHECK(for correct namespaces support,lyx_cv_cxx_namespace, - [AC_TRY_COMPILE([ - namespace foo { - int bar; - } -],[ + AC_CACHE_CHECK(for correct namespaces support,lyx_cv_cxx_namespace, + [AC_TRY_COMPILE([ + namespace foo { + int bar; + } + ],[ foo::bar = 0; return 0; -],lyx_cv_cxx_namespace=yes,lyx_cv_cxx_namespace=no) + ],lyx_cv_cxx_namespace=yes,lyx_cv_cxx_namespace=no) + ]) + if test x$lyx_cv_cxx_namespace = xyes ; then + AC_DEFINE(CXX_WORKING_NAMESPACES, 1, + [Define if your C++ compiler has correct support for namespaces]) + fi ]) -if test $lyx_cv_cxx_namespace = yes ; then - AC_DEFINE(CXX_WORKING_NAMESPACES, 1, - [Define if your C++ compiler has correct support for namespaces]) -fi]) dnl Usage: LYX_CXX_CHEADERS : checks whether the C++ compiler diff --git a/configure.in b/configure.in index e9bdc94887..92d552f288 100644 --- a/configure.in +++ b/configure.in @@ -77,6 +77,7 @@ dnl we do not use stl stack, or at least not on gcc 2.7, which was the dnl cause for this test. dnl LYX_CXX_STL_STACK LYX_CXX_STL_STRING +LYX_CXX_GOOD_STD_STRING LYX_CXX_NAMESPACES LYX_CXX_CHEADERS LYX_STD_COUNT diff --git a/lib/lyxrc.example b/lib/lyxrc.example index a9e9f51161..b106329706 100644 --- a/lib/lyxrc.example +++ b/lib/lyxrc.example @@ -193,6 +193,13 @@ # this line: #\relyx_command "none" +# Default format string for the date-insert command +# +# This accepts the normal strftime formats; see man strftime for full +# details of the format. +# +#\date_insert_format "%A, %e. %B %Y" + # # SCREEN & FONTS SECTION ################################################# # @@ -572,12 +579,6 @@ # does not work with all dictionaries, so this is disabled by default. #\use_input_encoding true -# Default format string for the date-insert command -# -# This accepts the normal strftime formats; see man strftime for full -# details of the format. -# -#\date_insert_format "%A, %e. %B %Y" # # LANGUAGE SUPPORT SECTION #################################################### diff --git a/src/BufferView2.C b/src/BufferView2.C index 723381e34c..c8675a0a1c 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -809,10 +809,16 @@ void BufferView::lockedInsetStoreUndo(Undo::undo_kind kind) if (kind == Undo::EDIT) // in this case insets would not be stored! kind = Undo::FINISH; text->SetUndo(buffer(), kind, +#ifndef NEW_INSETS text->cursor.par()-> ParFromPos(text->cursor.pos())->previous, text->cursor.par()-> - ParFromPos(text->cursor.pos())->next); + ParFromPos(text->cursor.pos())->next +#else + text->cursor.par()->previous, + text->cursor.par()->next +#endif + ); } @@ -870,8 +876,13 @@ bool BufferView::ChangeRefs(string const & from, string const & to) LyXParagraph * par = buffer()->paragraph; LyXCursor cursor = text->cursor; LyXCursor tmpcursor = cursor; +#ifndef NEW_INSETS cursor.par(tmpcursor.par()->ParFromPos(tmpcursor.pos())); cursor.pos(tmpcursor.par()->PositionInParFromPos(tmpcursor.pos())); +#else + cursor.par(tmpcursor.par()); + cursor.pos(tmpcursor.pos()); +#endif while (par) { bool flag2 = false; diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 73c4823755..0987745ca1 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -78,8 +78,14 @@ bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar, textclass = tc; - if (!(*endpar) || (startpar->ParFromPos(start) == - (*endpar)->ParFromPos(end))) { + if (!(*endpar) || +#ifndef NEW_INSETS + (startpar->ParFromPos(start) == + (*endpar)->ParFromPos(end)) +#else + (startpar == (*endpar)) +#endif + ) { // only within one paragraph buf = new LyXParagraph; LyXParagraph::size_type i = start; @@ -112,14 +118,24 @@ bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar, start); // store the selection +#ifndef NEW_INSETS buf = startpar->ParFromPos(start)->next; +#else + buf = startpar->next; +#endif buf->previous = 0; (*endpar)->previous->next = 0; // cut the selection +#ifndef NEW_INSETS startpar->ParFromPos(start)->next = (*endpar); (*endpar)->previous = startpar->ParFromPos(start); +#else + startpar->next = (*endpar); + + (*endpar)->previous = startpar; +#endif #ifndef NEW_INSETS // care about footnotes @@ -144,7 +160,11 @@ bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar, if (startpar->HasSameLayout(startpar->Next()) || #endif !startpar->Next()->Last()) { +#ifndef NEW_INSETS startpar->ParFromPos(start)->PasteParagraph(current_view->buffer()->params); +#else + startpar->PasteParagraph(current_view->buffer()->params); +#endif (*endpar) = startpar; // this because endpar gets deleted here! } } @@ -162,8 +182,14 @@ bool CutAndPaste::copySelection(LyXParagraph * startpar, LyXParagraph * endpar, textclass = tc; - if (!(endpar) || (startpar->ParFromPos(start) == - (endpar)->ParFromPos(end))) { + if (!(endpar) || +#ifndef NEW_INSETS + (startpar->ParFromPos(start) == + (endpar)->ParFromPos(end)) +#else + (startpar == endpar) +#endif + ) { // only within one paragraph buf = new LyXParagraph; LyXParagraph::size_type i = start; @@ -176,11 +202,20 @@ bool CutAndPaste::copySelection(LyXParagraph * startpar, LyXParagraph * endpar, } else { // copy more than one paragraph // clone the paragraphs within the selection - LyXParagraph *tmppar = startpar->ParFromPos(start); +#ifndef NEW_INSETS + LyXParagraph * tmppar = startpar->ParFromPos(start); +#else + LyXParagraph * tmppar = startpar; +#endif buf = tmppar->Clone(); - LyXParagraph *tmppar2 = buf; + LyXParagraph * tmppar2 = buf; - while (tmppar != endpar->ParFromPos(end) + while ( +#ifndef NEW_INSETS + tmppar != endpar->ParFromPos(end) +#else + tmppar != endpar +#endif && tmppar->next) { tmppar = tmppar->next; tmppar2->next = tmppar->Clone(); @@ -201,13 +236,20 @@ bool CutAndPaste::copySelection(LyXParagraph * startpar, LyXParagraph * endpar, #endif // the buf paragraph is too big +#ifndef NEW_INSETS LyXParagraph::size_type tmpi2 = startpar->PositionInParFromPos(start); +#else + LyXParagraph::size_type tmpi2 = start; +#endif for (; tmpi2; --tmpi2) buf->Erase(0); // now tmppar 2 is too big, delete all after end - +#ifndef NEW_INSETS tmpi2 = endpar->PositionInParFromPos(end); +#else + tmpi2 = end; +#endif while (tmppar2->size() > tmpi2) { tmppar2->Erase(tmppar2->size() - 1); } @@ -339,6 +381,7 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar, } // set the end for redoing later +#ifndef NEW_INSETS *endpar = (*par)->ParFromPos(pos)->next->Next(); // paste it! @@ -354,13 +397,28 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar, lastbuffer = *par; (*par)->ParFromPos(pos)->PasteParagraph(current_view->buffer()->params); +#else + *endpar = (*par)->next->Next(); + + // paste it! + lastbuffer->next = (*par)->next; + (*par)->next->previous = lastbuffer; + + (*par)->next = buf; + buf->previous = (*par); + if ((*par)->Next() == lastbuffer) + lastbuffer = *par; + + (*par)->PasteParagraph(current_view->buffer()->params); +#endif // store the new cursor position *par = lastbuffer; pos = lastbuffer->Last(); // maybe some pasting if (lastbuffer->Next() && paste_the_end) { +#ifndef NEW_INSETS if (lastbuffer->Next()->HasSameLayout(lastbuffer)) { lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params); } else if (!lastbuffer->Next()->Last()) { @@ -369,6 +427,16 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar, } else if (!lastbuffer->Last()) { lastbuffer->MakeSameLayout(lastbuffer->next); lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params); +#else + if (lastbuffer->Next()->HasSameLayout(lastbuffer)) { + lastbuffer->PasteParagraph(current_view->buffer()->params); + } else if (!lastbuffer->Next()->Last()) { + lastbuffer->Next()->MakeSameLayout(lastbuffer); + lastbuffer->PasteParagraph(current_view->buffer()->params); + } else if (!lastbuffer->Last()) { + lastbuffer->MakeSameLayout(lastbuffer->next); + lastbuffer->PasteParagraph(current_view->buffer()->params); +#endif } else lastbuffer->Next()->StripLeadingSpaces(tc); } diff --git a/src/LyXAction.C b/src/LyXAction.C index ef71ce489e..f9380b4ece 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -18,6 +18,10 @@ #include "debug.h" #include "gettext.h" #include "support/lstrings.h" +#if 1 +// only to get access to NEW_INSETS and NEW_TABULAR +#include "lyxparagraph.h" +#endif using std::ostream; using std::endl; @@ -123,7 +127,9 @@ void LyXAction::init() N_("Select to end of document"), ReadOnly }, { LFUN_EXPORT, "buffer-export", N_("Export to"), ReadOnly }, { LFUN_FAX, "buffer-fax", N_("Fax"), ReadOnly }, +#ifndef NEW_INSETS { LFUN_INSERTFOOTNOTE, "buffer-float-insert", "", Noop }, +#endif { LFUN_IMPORT, "buffer-import", N_("Import document"), NoBuffer }, { LFUN_BUFFERBULLETSSELECT, "buffer-itemize-bullets-select", @@ -187,12 +193,12 @@ void LyXAction::init() { LFUN_GOTOERROR, "error-next", N_("Go to next error"), Noop }, { LFUN_REMOVEERRORS, "error-remove-all", N_("Remove all error boxes"), ReadOnly }, - { LFUN_INSET_ERT, "ert-inset-insert", + { LFUN_INSET_ERT, "ert-insert", N_("Insert a new ERT Inset"), Noop }, - { LFUN_INSET_EXTERNAL, "external-inset-insert", + { LFUN_INSET_EXTERNAL, "external-insert", N_("Insert a new external inset"), Noop }, { LFUN_FIGURE, "figure-insert", N_("Insert Figure"), Noop }, - { LFUN_INSERT_GRAPHICS, "graphics-insert", + { LFUN_INSET_GRAPHICS, "graphics-insert", N_("Insert Graphics"), Noop }, { LFUN_FILE_INSERT, "file-insert", "", Noop }, { LFUN_FILE_INSERT_ASCII, "file-insert-ascii", "", Noop }, @@ -216,11 +222,14 @@ void LyXAction::init() ReadOnly }, { LFUN_UNDERLINE, "font-underline", N_("Toggle font underline"), Noop }, +#ifndef NEW_INSETS { LFUN_FOOTMELT, "footnote-insert", N_("Insert Footnote"), Noop }, - { LFUN_INSET_FOOTNOTE, "footnote-inset-insert", +#else + { LFUN_INSET_FOOTNOTE, "footnote-insert", N_("Insert Footnote"), Noop }, - { LFUN_INSET_MARGINAL, "marginalnote-inset-insert", +#endif + { LFUN_INSET_MARGINAL, "marginalnote-insert", N_("Insert Marginalnote"), Noop }, { LFUN_RIGHTSEL, "forward-select", N_("Select next char"), ReadOnly }, @@ -293,8 +302,10 @@ void LyXAction::init() { LFUN_LOTVIEW, "lot-view", N_("View list of tables"), ReadOnly }, { LFUN_QUIT, "lyx-quit", N_("Exit"), NoBuffer }, +#ifndef NEW_INSETS { LFUN_MARGINMELT, "marginpar-insert", N_("Insert Margin note"), Noop }, +#endif { LFUN_MARK_OFF, "mark-off", "", ReadOnly }, { LFUN_MARK_ON, "mark-on", "", ReadOnly }, { LFUN_SETMARK, "mark-toggle", "", ReadOnly }, @@ -330,7 +341,7 @@ void LyXAction::init() { LFUN_PARENTINSERT, "parent-insert", "", Noop }, { LFUN_PASTE, "paste", N_("Paste") , Noop }, { LFUN_SAVEPREFERENCES, "preferences-save", - "Save Preferences", NoBuffer }, + N_("Save Preferences"), NoBuffer }, { LFUN_PASTESELECTION, "primary-selection-paste", "", Noop }, { LFUN_PROTECTEDSPACE, "protected-space-insert", N_("Insert protected space"), Noop }, @@ -364,11 +375,13 @@ void LyXAction::init() { LFUN_SHIFT_TAB, "tab-backward", "", Noop }, { LFUN_TAB, "tab-forward", "", Noop }, { LFUN_TABINSERT, "tab-insert", "", Noop }, +#ifndef NEW_TABULAR { LFUN_TABLE, "table-insert", N_("Insert Table"), Noop }, - { LFUN_INSET_TABULAR, "tabular-inset-insert", +#endif + { LFUN_INSET_TABULAR, "tabular-insert", N_("Insert a new Tabular Inset"), Noop }, { LFUN_TEX, "tex-mode", N_("Toggle TeX style"), Noop }, - { LFUN_INSET_TEXT, "text-inset-insert", + { LFUN_INSET_TEXT, "text-insert", N_("Insert a new Text Inset"), Noop }, { LFUN_TOC_INSERT, "toc-insert", N_("Insert table of contents"), Noop }, @@ -405,11 +418,11 @@ void LyXAction::init() { LFUN_DATE_INSERT, "date-insert", "", Noop }, { LFUN_PARAGRAPH_SPACING, "paragraph-spacing", "", Noop }, { LFUN_SET_COLOR, "set-color", "", Noop }, - { LFUN_INSET_MINIPAGE, "minipage-inset-insert", "", Noop }, - { LFUN_INSET_FLOAT, "float-inset-insert", "", Noop }, - { LFUN_INSET_LIST, "list-inset-insert", "", Noop }, - { LFUN_INSET_THEOREM, "theorem-inset-insert", "", Noop }, - { LFUN_INSET_CAPTION, "caption-inset-insert", "", Noop }, + { LFUN_INSET_MINIPAGE, "minipage-insert", "", Noop }, + { LFUN_INSET_FLOAT, "float-insert", "", Noop }, + { LFUN_INSET_LIST, "list-insert", "", Noop }, + { LFUN_INSET_THEOREM, "theorem-insert", "", Noop }, + { LFUN_INSET_CAPTION, "caption-insert", "", Noop }, { LFUN_NOACTION, "", "", Noop } }; @@ -639,7 +652,8 @@ bool LyXAction::funcHasFlag(kb_action action, return (*ici).second.attrib & flag; } else { // it really should exist, but... - lyxerr << "No info about kb_action: " << action << '\n'; + lyxerr << "LyXAction::funcHasFlag: " + "No info about kb_action: " << action << '\n'; return false; } diff --git a/src/LyXView.h b/src/LyXView.h index e09d69b7fc..b4a23c4b32 100644 --- a/src/LyXView.h +++ b/src/LyXView.h @@ -21,7 +21,7 @@ #include "Timeout.h" // uncomment this line to try out the new menus -//#define NEW_MENUBAR +#define NEW_MENUBAR 1 class LyXFunc; class Toolbar; diff --git a/src/MenuBackend.C b/src/MenuBackend.C index c95866a0d6..a35d9f40d1 100644 --- a/src/MenuBackend.C +++ b/src/MenuBackend.C @@ -26,13 +26,9 @@ using std::endl; // This is the global menu definition MenuBackend menubackend; -MenuItem::MenuItem(MenuItem const & m) - : kind_(m.kind_), label_(m.label_), action_(m.action_), submenu_(m.submenu_) -{} - MenuItem::MenuItem(Kind kind, string const & label, string const & command) - : kind_(kind), label_(label) + : kind_(kind), label_(label) { switch(kind) { case Separator: @@ -53,9 +49,11 @@ MenuItem::MenuItem(Kind kind, string const & label, string const & command) } } -void Menu::add(MenuItem const & i) + +Menu & Menu::add(MenuItem const & i) { items_.push_back(i); + return *this; } @@ -84,7 +82,6 @@ void Menu::read(LyXLex & lex) if (lyxerr.debugging(Debug::PARSER)) lex.printTable(lyxerr); - string mlabel, mname; bool quit = false; while (lex.IsOK() && !quit) { @@ -108,9 +105,9 @@ void Menu::read(LyXLex & lex) break; case md_submenu: { lex.next(); - mlabel = lex.GetString(); + string mlabel = lex.GetString(); lex.next(); - mname = lex.GetString(); + string mname = lex.GetString(); add(MenuItem(MenuItem::Submenu, mlabel, mname)); break; } @@ -136,7 +133,7 @@ void MenuBackend::read(LyXLex & lex) md_last }; - struct keyword_item menutags[md_last-1] = { + struct keyword_item menutags[md_last - 1] = { { "end", md_endmenuset }, { "menu", md_menu }, { "menubar", md_menubar } @@ -151,7 +148,6 @@ void MenuBackend::read(LyXLex & lex) if (lyxerr.debugging(Debug::PARSER)) lex.printTable(lyxerr); - string mlabel, mname; bool quit = false; while (lex.IsOK() && !quit) { @@ -184,43 +180,38 @@ void MenuBackend::read(LyXLex & lex) lex.popTable(); } + void MenuBackend::defaults() { - if (menulist_.size() > 0) - menulist_.clear(); + menulist_.clear(); lyxerr[Debug::GUI] << "MenuBackend::defaults: using default values" << endl; Menu file("file"); - file.add(MenuItem(MenuItem::Command, - "New...|N", "buffer-new")); - file.add(MenuItem(MenuItem::Command, - "Open...|O", "buffer-open")); - file.add(MenuItem(MenuItem::Submenu, - "Import|I", "import")); - file.add(MenuItem(MenuItem::Command, - "Quit|Q", "lyx-quit")); - file.add(MenuItem(MenuItem::Separator)); - file.add(MenuItem(MenuItem::Lastfiles)); + file + .add(MenuItem(MenuItem::Command, "New...|N", "buffer-new")) + .add(MenuItem(MenuItem::Command, "Open...|O", "buffer-open")) + .add(MenuItem(MenuItem::Submenu, "Import|I", "import")) + .add(MenuItem(MenuItem::Command, "Quit|Q", "lyx-quit")) + .add(MenuItem(MenuItem::Separator)) + .add(MenuItem(MenuItem::Lastfiles)); add(file); Menu import("import"); - import.add(MenuItem(MenuItem::Command, - "LaTeX...|L", "buffer-import latex")); - import.add(MenuItem(MenuItem::Command, - "LinuxDoc...|L", "buffer-import linuxdoc")); + import + .add(MenuItem(MenuItem::Command, + "LaTeX...|L", "buffer-import latex")) + .add(MenuItem(MenuItem::Command, + "LinuxDoc...|L", "buffer-import linuxdoc")); add(import); Menu edit("edit"); - edit.add(MenuItem(MenuItem::Command, - "Cut", "cut")); - edit.add(MenuItem(MenuItem::Command, - "Copy", "copy")); - edit.add(MenuItem(MenuItem::Command, - "Paste", "paste")); - edit.add(MenuItem(MenuItem::Command, - "Emphasize", "font-emph")); + edit + .add(MenuItem(MenuItem::Command, "Cut", "cut")) + .add(MenuItem(MenuItem::Command, "Copy", "copy")) + .add(MenuItem(MenuItem::Command, "Paste", "paste")) + .add(MenuItem(MenuItem::Command, "Emphasize", "font-emph")); add(edit); Menu documents("documents"); @@ -228,15 +219,15 @@ void MenuBackend::defaults() add(documents); Menu main("main", true); - main.add(MenuItem(MenuItem::Submenu, "File|F", "file")); - main.add(MenuItem(MenuItem::Submenu, "Edit|E", "edit")); - main.add(MenuItem(MenuItem::Submenu, - "Documents|D", "documents")); + main + .add(MenuItem(MenuItem::Submenu, "File|F", "file")) + .add(MenuItem(MenuItem::Submenu, "Edit|E", "edit")) + .add(MenuItem(MenuItem::Submenu, + "Documents|D", "documents")); add(main); Menu main_nobuffer("main_nobuffer", true); - main_nobuffer.add(MenuItem(MenuItem::Submenu, - "File|F", "file")); + main_nobuffer.add(MenuItem(MenuItem::Submenu, "File|F", "file")); add(main_nobuffer); if (lyxerr.debugging(Debug::GUI)) { @@ -248,12 +239,14 @@ void MenuBackend::defaults() } } -void MenuBackend::add(Menu const &menu) + +void MenuBackend::add(Menu const & menu) { menulist_.push_back(menu); } -bool MenuBackend::hasMenu(string const &name) const + +bool MenuBackend::hasMenu(string const & name) const { for (const_iterator cit = begin(); cit != end(); ++cit) { if ((*cit).name() == name) @@ -262,7 +255,8 @@ bool MenuBackend::hasMenu(string const &name) const return false; } -Menu const & MenuBackend::getMenu(string const &name) const + +Menu const & MenuBackend::getMenu(string const & name) const { for (const_iterator cit = begin(); cit != end(); ++cit) { if ((*cit).name() == name) diff --git a/src/MenuBackend.h b/src/MenuBackend.h index 4a1d16bf7f..62d6a54f53 100644 --- a/src/MenuBackend.h +++ b/src/MenuBackend.h @@ -3,8 +3,8 @@ * * LyX, The Document Processor * -* Copyright (C) 1995 Matthias Ettrich -* Copyright (C) 1995-1999 The LyX Team. +* Copyright 1995 Matthias Ettrich +* Copyright 1995-2000 The LyX Team. * * This file is Copyright 1999 * Jean-Marc Lasgouttes @@ -23,64 +23,67 @@ #include class LyXLex; -class MenuItem; +/// class MenuItem { public: - // The type of elements that can be in a menu - enum Kind { - Command, - Submenu, - Separator, - Lastfiles, // This is the list of last opened file, - // typically for the File menu. - Documents // This is the list of opened Documents, - // typically for the Documents menu. + /// The type of elements that can be in a menu + enum Kind { + /// + Command, + /// + Submenu, + /// + Separator, + /** This is the list of last opened file, + typically for the File menu. */ + Lastfiles, + /** This is the list of opened Documents, + typically for the Documents menu. */ + Documents }; - // Create a copy of a given MenuItem - MenuItem(MenuItem const &); - // Create a Command type MenuItem + /// Create a Command type MenuItem MenuItem(Kind kind_, string const & label_ = string(), string const & command_ = string()); - // - ~MenuItem() {} - - // The label of a given menuitem + /// The label of a given menuitem string const & label() const { return label_; } - // The kind of entry + /// The kind of entry Kind kind() const { return kind_; } - // the action (if relevant) + /// the action (if relevant) int action() const { return action_; } - // the description of the submenu (if relevant) + /// the description of the submenu (if relevant) string const & submenu() const { return submenu_; } - private: + /// Kind kind_; + /// string label_; + /// int action_; + /// string submenu_; - MenuItem() {} }; +/// class Menu { public: - // + /// typedef std::vector ItemList; - // + /// typedef ItemList::const_iterator const_iterator; - // + /// explicit Menu(string const & name, bool mb = false) : menubar_(mb), name_(name) {} - // - void add(MenuItem const &); - // + /// + Menu & add(MenuItem const &); + /// void read(LyXLex &); - // + /// bool menubar() const { return menubar_; } - // + /// string const & name() const { return name_; } - // + /// bool empty() const { return items_.empty(); } /// const_iterator begin() const { @@ -90,7 +93,6 @@ public: const_iterator end() const { return items_.end(); } - private: /// ItemList items_; @@ -102,6 +104,7 @@ private: }; +/// class MenuBackend { public: /// @@ -133,6 +136,7 @@ private: MenuList menulist_; }; +/// extern MenuBackend menubackend; #endif /* MENUBACKEND_H */ diff --git a/src/TableLayout.C b/src/TableLayout.C index 67487f1bf9..06f3f138fc 100644 --- a/src/TableLayout.C +++ b/src/TableLayout.C @@ -22,6 +22,7 @@ extern FD_form_table_options * fd_form_table_options; extern FD_form_table_extra * fd_form_table_extra; extern BufferView * current_view; +#ifndef NEW_TABULAR static int Confirmed = false; static int ActCell; @@ -33,6 +34,7 @@ static int ActCell; // in 1.1 anyway) static int extra_col_cursor_x; // need no y's, one-line input fields static int extra_multicol_cursor_x; +#endif // Joacim diff --git a/src/ToolbarDefaults.C b/src/ToolbarDefaults.C index 75bdaef029..e2f04188a2 100644 --- a/src/ToolbarDefaults.C +++ b/src/ToolbarDefaults.C @@ -20,6 +20,10 @@ #include "lyxlex.h" #include "debug.h" #include "lyxlex.h" +#if 1 +// only until we don't need access tot he NEW_INSETS or NEW_TABULAR anymore +#include "lyxparagraph.h" +#endif using std::endl; @@ -56,8 +60,13 @@ void ToolbarDefaults::init() add(LFUN_FREE); add(SEPARATOR); +#ifndef NEW_INSETS add(LFUN_FOOTMELT); add(LFUN_MARGINMELT); +#else + add(LFUN_INSET_FOOTNOTE); + add(LFUN_INSET_MARGINAL); +#endif add(LFUN_DEPTH); add(SEPARATOR); @@ -66,7 +75,11 @@ void ToolbarDefaults::init() add(SEPARATOR); add(LFUN_FIGURE); +#ifndef NEW_TABULAR add(LFUN_TABLE); +#else + add(LFUN_INSET_TABULAR); +#endif //add(LFUN_MELT); } diff --git a/src/Variables.h b/src/Variables.h index 617a740785..45747927c1 100644 --- a/src/Variables.h +++ b/src/Variables.h @@ -26,7 +26,7 @@ public: /// void set(string const &, string const &); /// - virtual string get(string const &) const; + string get(string const &) const; /// bool isset(string const & var) const; /// diff --git a/src/buffer.C b/src/buffer.C index 4b82b72104..365f198701 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -306,6 +306,10 @@ bool Buffer::readLyXformat2(LyXLex & lex, LyXParagraph * par) } +// We'll remove this later. (Lgb) +static string last_inset_read; + + bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, LyXParagraph *& return_par, @@ -318,8 +322,6 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, ) { bool the_end_read = false; - // We'll remove this later. (Lgb) - static string last_inset_read; if (token[0] != '\\') { for (string::const_iterator cit = token.begin(); @@ -850,6 +852,9 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, // But insets should read it, it is a part of // the inset isn't it? Lgb. } else if (token == "\\begin_inset") { +#if 1 + readInset(lex, par, pos, font); +#else // Should be moved out into its own function/method. (Lgb) lex.next(); string tmptok = lex.GetString(); @@ -993,6 +998,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, ++pos; } } +#endif } else if (token == "\\SpecialChar") { LyXLayout const & layout = textclasslist.Style(params.textclass, @@ -1073,6 +1079,164 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, return the_end_read; } + +void Buffer::readInset(LyXLex & lex, LyXParagraph *& par, + int & pos, LyXFont & font) +{ + // consistency check + if (lex.GetString() != "\\begin_inset") { + lyxerr << "Buffer::readInset: Consistency check failed." + << endl; + } + + lex.next(); + string tmptok = lex.GetString(); + last_inset_read = tmptok; + // test the different insets + if (tmptok == "Quotes") { + Inset * inset = new InsetQuotes; + inset->Read(this, lex); + par->InsertInset(pos, inset, font); + ++pos; + } else if (tmptok == "External") { + Inset * inset = new InsetExternal; + inset->Read(this, lex); + par->InsertInset(pos, inset, font); + ++pos; + } else if (tmptok == "FormulaMacro") { + Inset * inset = new InsetFormulaMacro; + inset->Read(this, lex); + par->InsertInset(pos, inset, font); + ++pos; + } else if (tmptok == "Formula") { + Inset * inset = new InsetFormula; + inset->Read(this, lex); + par->InsertInset(pos, inset, font); + ++pos; + } else if (tmptok == "Figure") { + Inset * inset = new InsetFig(100, 100, this); + inset->Read(this, lex); + par->InsertInset(pos, inset, font); + ++pos; + } else if (tmptok == "Info") { + Inset * inset = new InsetInfo; + inset->Read(this, lex); + par->InsertInset(pos, inset, font); + ++pos; + } else if (tmptok == "Include") { + Inset * inset = new InsetInclude(string(), this); + inset->Read(this, lex); + par->InsertInset(pos, inset, font); + ++pos; + } else if (tmptok == "ERT") { + Inset * inset = new InsetERT; + inset->Read(this, lex); + par->InsertInset(pos, inset, font); + ++pos; + } else if (tmptok == "Tabular") { + Inset * inset = new InsetTabular(this); + inset->Read(this, lex); + par->InsertInset(pos, inset, font); + ++pos; + } else if (tmptok == "Text") { + Inset * inset = new InsetText; + inset->Read(this, lex); + par->InsertInset(pos, inset, font); + ++pos; + } else if (tmptok == "Foot") { + Inset * inset = new InsetFoot; + inset->Read(this, lex); + par->InsertInset(pos, inset, font); + ++pos; + } else if (tmptok == "Marginal") { + Inset * inset = new InsetMarginal; + inset->Read(this, lex); + par->InsertInset(pos, inset, font); + ++pos; + } else if (tmptok == "Minipage") { + Inset * inset = new InsetMinipage; + inset->Read(this, lex); + par->InsertInset(pos, inset, font); + ++pos; + } else if (tmptok == "Float") { + lex.next(); + string tmptok = lex.GetString(); + Inset * inset = new InsetFloat(tmptok); + inset->Read(this, lex); + par->InsertInset(pos, inset, font); + ++pos; + } else if (tmptok == "List") { + Inset * inset = new InsetList; + inset->Read(this, lex); + par->InsertInset(pos, inset, font); + ++pos; + } else if (tmptok == "Theorem") { + Inset * inset = new InsetList; + inset->Read(this, lex); + par->InsertInset(pos, inset, font); + ++pos; + } else if (tmptok == "Caption") { + Inset * inset = new InsetCaption; + inset->Read(this, lex); + par->InsertInset(pos, inset, font); + ++pos; + } else if (tmptok == "GRAPHICS") { + Inset * inset = new InsetGraphics; + //inset->Read(this, lex); + par->InsertInset(pos, inset, font); + } else if (tmptok == "LatexCommand") { + InsetCommand inscmd; + inscmd.Read(this, lex); + Inset * inset = 0; + if (inscmd.getCmdName() == "cite") { + inset = new InsetCitation(inscmd.getContents(), + inscmd.getOptions()); + } else if (inscmd.getCmdName() == "bibitem") { + lex.printError("Wrong place for bibitem"); + inset = inscmd.Clone(); + } else if (inscmd.getCmdName() == "BibTeX") { + inset = new InsetBibtex(inscmd.getContents(), + inscmd.getOptions(), this); + } else if (inscmd.getCmdName() == "index") { + inset = new InsetIndex(inscmd.getContents()); + } else if (inscmd.getCmdName() == "include") { + inset = new InsetInclude(inscmd.getContents(), this); + } else if (inscmd.getCmdName() == "label") { + inset = new InsetLabel(inscmd.getCommand()); + } else if (inscmd.getCmdName() == "url" + || inscmd.getCmdName() == "htmlurl") { + inset = new InsetUrl(inscmd.getCommand()); + } else if (inscmd.getCmdName() == "ref" + || inscmd.getCmdName() == "pageref" + || inscmd.getCmdName() == "vref" + || inscmd.getCmdName() == "vpageref" + || inscmd.getCmdName() == "prettyref") { + if (!inscmd.getOptions().empty() + || !inscmd.getContents().empty()) { + inset = new InsetRef(inscmd, this); + } + } else if (inscmd.getCmdName() == "tableofcontents") { + inset = new InsetTOC(this); + } else if (inscmd.getCmdName() == "listoffigures") { + inset = new InsetLOF(this); + } else if (inscmd.getCmdName() == "listofalgorithms") { + inset = new InsetLOA(this); + } else if (inscmd.getCmdName() == "listoftables") { + inset = new InsetLOT(this); + } else if (inscmd.getCmdName() == "printindex") { + inset = new InsetPrintIndex(this); + } else if (inscmd.getCmdName() == "lyxparent") { + inset = new InsetParent(inscmd.getContents(), this); + } + + if (inset) { + par->InsertInset(pos, inset, font); + ++pos; + } + } +} + + bool Buffer::readFile(LyXLex & lex, LyXParagraph * par) { string token; @@ -2175,8 +2339,11 @@ void Buffer::latexParagraphs(ostream & ofs, LyXParagraph * par, ftcount = -1; if (layout.isEnvironment() || par->pextra_type != LyXParagraph::PEXTRA_NONE) { - par = par->TeXEnvironment(this, params, ofs, texrow, - ftnote, ft_texrow, ftcount); + par = par->TeXEnvironment(this, params, ofs, texrow +#ifndef NEW_INSETS + ,ftnote, ft_texrow, ftcount +#endif + ); } else { par = par->TeXOnePar(this, params, ofs, texrow, false #ifndef NEW_INSETS diff --git a/src/buffer.h b/src/buffer.h index 1d5609a86e..9e78027cfc 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -138,7 +138,10 @@ public: LyXParagraph::footnote_kind & #endif ); - +private: + // Parse a single inset. + void readInset(LyXLex &, LyXParagraph *& par, int & pos, LyXFont &); +public: /** Save file Takes care of auto-save files and backup file if requested. Returns true if the save is successful, false otherwise. diff --git a/src/commandtags.h b/src/commandtags.h index 32016ba11e..13732893b2 100644 --- a/src/commandtags.h +++ b/src/commandtags.h @@ -13,6 +13,8 @@ #include /** These are all the lyxfunctions (as enums). + Please add new functions at the end of the enum, right + before LFUN_LASTACTION. */ enum kb_action { LFUN_UNKNOWN_ACTION = -1, @@ -26,7 +28,7 @@ enum kb_action { LFUN_MENUPRINT, LFUN_MENUSENDTO, LFUN_RUNLATEX, - LFUN_BUILDPROG, + LFUN_BUILDPROG, // 10 LFUN_TOCVIEW, LFUN_PREVIEW, LFUN_PREVIEWPS, @@ -36,7 +38,7 @@ enum kb_action { LFUN_QUIT, LFUN_AUTOSAVE, LFUN_UNDO, - LFUN_REDO, + LFUN_REDO, // 20 LFUN_MENUSEARCH, LFUN_PASTE, LFUN_PASTESELECTION, @@ -46,18 +48,17 @@ enum kb_action { LFUN_GOTONOTE, LFUN_OPENSTUFF, LFUN_HYPHENATION, - LFUN_HFILL, + LFUN_HFILL, // 30 LFUN_DEPTH, LFUN_FREE, LFUN_TEX, - LFUN_FOOTMELT, - LFUN_MARGINMELT, - LFUN_SWITCHBUFFER, + LFUN_FOOTMELT, // schedule for deletion + LFUN_MARGINMELT, // schedule for deletion LFUN_EMPH, LFUN_BOLD, LFUN_ROMAN, LFUN_NOUN, - LFUN_RIGHT, + LFUN_RIGHT, // 40 LFUN_LEFT, LFUN_UP, LFUN_DOWN, @@ -67,7 +68,7 @@ enum kb_action { LFUN_END, LFUN_TAB, LFUN_SHIFT_TAB, // Jug 20000522 - LFUN_WORDRIGHT, + LFUN_WORDRIGHT, // 50 LFUN_WORDLEFT, LFUN_BEGINNINGBUF, LFUN_ENDBUF, @@ -77,7 +78,7 @@ enum kb_action { LFUN_DOWNSEL, LFUN_PRIORSEL, LFUN_NEXTSEL, - LFUN_HOMESEL, + LFUN_HOMESEL, // 60 LFUN_ENDSEL, LFUN_WORDRIGHTSEL, LFUN_WORDLEFTSEL, @@ -87,7 +88,7 @@ enum kb_action { LFUN_SETMARK, LFUN_DELETE, LFUN_BACKSPACE, - LFUN_BREAKLINE, + LFUN_BREAKLINE, // 70 LFUN_BREAKPARAGRAPH, LFUN_BREAKPARAGRAPHKEEPLAYOUT, LFUN_QUOTE, @@ -97,7 +98,7 @@ enum kb_action { LFUN_TILDE, LFUN_CEDILLA, LFUN_MACRON, - LFUN_UNDERBAR, + LFUN_UNDERBAR, // 80 LFUN_UNDERDOT, LFUN_CIRCLE, LFUN_TIE, @@ -107,7 +108,7 @@ enum kb_action { LFUN_HUNG_UMLAUT, LFUN_UMLAUT, LFUN_DOT, - LFUN_OGONEK, + LFUN_OGONEK, // 90 LFUN_VECTOR, // Alejandro 040696 LFUN_SELFINSERT, LFUN_GETBUFNAME, @@ -117,7 +118,7 @@ enum kb_action { LFUN_LINEATCURSOR, LFUN_GETLAYOUT, LFUN_GETFONT, - LFUN_GETLATEX, + LFUN_GETLATEX, // 100 LFUN_GETNAME, LFUN_NOTIFY, LFUN_GOTOFILEROW, // Edmar 12/23/98 @@ -127,7 +128,7 @@ enum kb_action { LFUN_KMAP_SEC, LFUN_KMAP_TOGGLE, LFUN_INSERT_MATH, - LFUN_INSERT_MATRIX, + LFUN_INSERT_MATRIX, // 110 LFUN_GREEK, LFUN_MATH_LIMITS, LFUN_GREEK_TOGGLE, @@ -137,17 +138,17 @@ enum kb_action { LFUN_MATH_NUMBER, // Alejandro 040696 LFUN_MATH_NONUMBER, // Alejandro 180696 LFUN_MATH_SIZE, // Alejandro 150896 - LFUN_MATH_MACRO, // ale970510 + LFUN_MATH_MACRO, // 120 // ale970510 LFUN_MATH_MACROARG, // ale970510 LFUN_FIGURE, - LFUN_TABLE, + LFUN_TABLE, // schedule for deletion LFUN_MELT, LFUN_DELETE_WORD_FORWARD, LFUN_DELETE_WORD_BACKWARD, LFUN_DELETE_LINE_FORWARD, LFUN_MARK_OFF, LFUN_MARK_ON, - LFUN_LAYOUT, + LFUN_LAYOUT, // 130 LFUN_LAYOUTNO, // Lgb 97-06-10 LFUN_LAYOUT_CHARACTER, LFUN_LAYOUT_PARAGRAPH, @@ -157,7 +158,7 @@ enum kb_action { LFUN_LAYOUT_QUOTES, LFUN_LAYOUT_PREAMBLE, LFUN_LAYOUT_SAVE_DEFAULT, - LFUN_DROP_LAYOUTS_CHOICE, + LFUN_DROP_LAYOUTS_CHOICE, // 140 LFUN_CODE, LFUN_SANS, LFUN_DEFAULT, @@ -167,7 +168,7 @@ enum kb_action { LFUN_UPCASE_WORD, LFUN_LOWCASE_WORD, LFUN_CAPITALIZE_WORD, - LFUN_INSERT_LABEL, + LFUN_INSERT_LABEL, // 150 LFUN_INSERT_REF, LFUN_PUSH_TOOLBAR, LFUN_ADD_TO_TOOLBAR, @@ -177,7 +178,7 @@ enum kb_action { LFUN_SPELLCHECK, // RVDK_PATCH_5 LFUN_CANCEL, // RVDK_PATCH_5 LFUN_META_FAKE, // RVDK_PATCH_5 - LFUN_EXEC_COMMAND, + LFUN_EXEC_COMMAND, // 160 LFUN_FILE_INSERT, LFUN_FILE_INSERT_ASCII, // CFO-G 1997-11-19 LFUN_FILE_NEW, @@ -187,7 +188,7 @@ enum kb_action { LFUN_DOWN_PARAGRAPH, // Asger 1996-10-01 LFUN_DOWN_PARAGRAPHSEL, // Asger 1996-10-01 LFUN_BREAKPARAGRAPH_SKIP, - LFUN_BACKSPACE_SKIP, + LFUN_BACKSPACE_SKIP, // 170 LFUN_DELETE_SKIP, LFUN_MENUNEWTMPLT, // Asger 1997-02-02 LFUN_RUNDVIPS, // Asger 1997-02-02 @@ -197,7 +198,7 @@ enum kb_action { LFUN_INSERT_CITATION, // AAS 97-02-23 LFUN_INSERT_BIBTEX, // AAS 97-02-23 LFUN_INDEX_INSERT, // Lgb 97-02-27 - LFUN_INDEX_INSERT_LAST, // Reh 98-09-17 + LFUN_INDEX_INSERT_LAST, // 180 // Reh 98-09-17 LFUN_INDEX_PRINT, // Lgb 97-02-27 LFUN_APROPOS, // Asger 1997-02-27 LFUN_LATEX_LOG, // Lgb 97-04-05 @@ -207,7 +208,7 @@ enum kb_action { LFUN_CHILDINSERT, // Ale 970521 LFUN_CHILDOPEN, // Ale 970528 LFUN_TOC_INSERT, // Lgb 97-05-27 - LFUN_LOA_INSERT, // Bernhard 97-08-07 + LFUN_LOA_INSERT, // 190 // Bernhard 97-08-07 LFUN_LOF_INSERT, // Lgb 97-05-27 LFUN_LOT_INSERT, // Lgb 97-05-27 LFUN_READ_ONLY_TOGGLE, // Lgb 97-05-27 @@ -217,7 +218,7 @@ enum kb_action { LFUN_GETTIP, // Ale 970603 LFUN_VC_REGISTER, // Lgb 97-07-01 LFUN_VC_CHECKIN, // Lgb 97-07-01 - LFUN_VC_CHECKOUT, // Lgb 97-07-01 + LFUN_VC_CHECKOUT, // 200 // Lgb 97-07-01 LFUN_VC_REVERT, // Lgb 97-07-01 LFUN_VC_UNDO, // Lgb 97-07-01 LFUN_VC_HISTORY, // Lgb 97-07-01 @@ -227,8 +228,8 @@ enum kb_action { LFUN_REFGOTO, // Ale 970806 LFUN_REFBACK, // Ale 970806 LFUN_PARENTINSERT, // Ale 970813 - LFUN_REMOVEERRORS, // Asger 970906 - LFUN_LDOTS, // Asger 970929 + LFUN_REMOVEERRORS, // 210 // Asger 970906 + LFUN_LDOTS, // Asger 970929 LFUN_END_OF_SENTENCE, // Asger 970929 LFUN_RUNCHKTEX, // Asger 971030 LFUN_BUFFERBULLETSSELECT, // ARRae 971018 @@ -237,8 +238,8 @@ enum kb_action { LFUN_URL, // CFO-G 971121 LFUN_WORDFINDFORWARD, // Etienne 980216 LFUN_WORDFINDBACKWARD, // Etienne 980220 - LFUN_APPENDIX, // ettrich 980505 - LFUN_IMPORT, // Asger 980724 + LFUN_APPENDIX, // 220 // ettrich 980505 + LFUN_IMPORT, // Asger 980724 LFUN_MENU_SEPARATOR, // Asger 990220 LFUN_SEQUENCE, // Andre' 991111 LFUN_SAVEPREFERENCES, // Lgb 991127 @@ -250,8 +251,8 @@ enum kb_action { LFUN_LANGUAGE, // Dekel 20000203 LFUN_INSET_TEXT, // Jug 20000214 LFUN_INSET_ERT, // Jug 20000218 - LFUN_INSERT_GRAPHICS, // Lgb 20000226 - LFUN_INSET_FOOTNOTE, // Jug 20000307 + LFUN_INSET_GRAPHICS, // 230 // Lgb 20000226 + LFUN_INSET_FOOTNOTE, // Jug 20000307 LFUN_PARAGRAPH_SPACING, // Lgb 20000411 LFUN_INSET_TABULAR, // Jug 20000412 LFUN_LOFVIEW, // Dekel 20000519 @@ -260,14 +261,20 @@ enum kb_action { LFUN_SET_COLOR, // SLior 20000611 LFUN_INSET_EXTERNAL, // Alstrup 20000609 LFUN_INSET_MARGINAL, // Lgb 20000626 - LFUN_INSET_MINIPAGE, // Lgb 20000627 + LFUN_INSET_MINIPAGE, // 240 // Lgb 20000627 LFUN_INSET_FLOAT, // Lgb 20000627 LFUN_INSET_LIST, // Lgb 20000627 LFUN_INSET_THEOREM, // Lgb 20000630 LFUN_CREATE_CITATION, // Angus 20000705 LFUN_INSET_CAPTION, // Lgb 20000718 + LFUN_SWITCHBUFFER, // and where is this comming from? LFUN_LASTACTION /* this marks the end of the table */ }; std::ostream & operator<<(std::ostream &, kb_action); #endif + + + + + diff --git a/src/encoding.C b/src/encoding.C index b41bde6c2c..1c7066a772 100644 --- a/src/encoding.C +++ b/src/encoding.C @@ -16,6 +16,7 @@ #include "encoding.h" +static Uchar tab_iso8859_1[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, @@ -35,6 +36,8 @@ Uchar tab_iso8859_1[256] = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff }; + +static Uchar tab_iso8859_2[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, @@ -60,6 +63,8 @@ Uchar tab_iso8859_2[256] = { 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9 }; + +static Uchar tab_iso8859_3[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, @@ -85,6 +90,8 @@ Uchar tab_iso8859_3[256] = { 0x011d, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x016d, 0x015d, 0x02d9, }; + +static Uchar tab_iso8859_4[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, @@ -110,6 +117,8 @@ Uchar tab_iso8859_4[256] = { 0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x0169, 0x016b, 0x02d9 }; + +static Uchar tab_iso8859_6_16[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, @@ -141,6 +150,8 @@ Uchar tab_iso8859_6_16[256] = { 0xfe8b, 0xfe8a, 0xfef6, 0xfefa, 0xfef8, 0xfefc, 0x00fe, 0x00ff }; + +static Uchar tab_iso8859_7[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, @@ -166,6 +177,8 @@ Uchar tab_iso8859_7[256] = { 0x03c8, 0x03c9, 0x03ca, 0x03cb, 0x03cc, 0x03cd, 0x03ce, 0xffff }; + +static Uchar tab_iso8859_9[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, @@ -191,6 +204,8 @@ Uchar tab_iso8859_9[256] = { 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0131, 0x015f, 0x00ff, }; + +static Uchar tab_cp1255[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, @@ -216,6 +231,8 @@ Uchar tab_cp1255[256] = { 0x05e8, 0x05e9, 0x05ea, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; + +static Uchar tab_koi8[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, @@ -243,6 +260,9 @@ Uchar tab_koi8[256] = { 0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a }; + +#ifdef USE_UNICODE_FOR_SYMBOLS +static Uchar tab_symbol[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, @@ -293,7 +313,10 @@ Uchar tab_symbol[256] = { 0xffff, 0x232a, 0x222b, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x2309, 0xffff, 0x230b, 0xffff, 0xffff, 0xffff, 0xffff }; +#endif + +static unsigned char arabic_table2[63][4] = { {0x41, 0x41, 0x41, 0x41}, // 0xc1 = hamza {0x42, 0xa1, 0x42, 0x42}, // 0xc2 = ligature madda on alef @@ -363,6 +386,8 @@ unsigned char arabic_table2[63][4] = { {0,0,0,0}, // 0xff }; + +static unsigned char arabic_table[63][2] = { {0xc1, 0xc1}, // 0xc1 = hamza {0xc2, 0xc2}, // 0xc2 = ligature madda on alef @@ -448,3 +473,39 @@ Encoding symbol_encoding("",tab_symbol); #else Encoding symbol_encoding("",tab_iso8859_1); #endif + + +bool Encoding::IsComposeChar_hebrew(unsigned char c) +{ + return c <= 0xd2 && c >= 0xc0 && + c != 0xce && c != 0xd0; +} + + +bool Encoding::IsComposeChar_arabic(unsigned char c) +{ + return c >= 0xeb && c <= 0xf2; +} + + +static +unsigned char const arabic_start = 0xc1; + + +bool Encoding::is_arabic(unsigned char c) +{ + return c >= arabic_start && arabic_table[c-arabic_start][0]; +} + + +unsigned char Encoding::TransformChar(unsigned char c, + Encoding::Letter_Form form) +{ + if (!is_arabic(c)) + return c; + + if (lyxrc.font_norm == "iso10646-1") + return arabic_table2[c-arabic_start][form]; + else + return arabic_table[c-arabic_start][form >> 1]; +} diff --git a/src/encoding.h b/src/encoding.h index d4c1670933..5b4d661749 100644 --- a/src/encoding.h +++ b/src/encoding.h @@ -72,44 +72,4 @@ extern Encoding cp1255; extern Encoding koi8; extern Encoding symbol_encoding; -inline -bool Encoding::IsComposeChar_hebrew(unsigned char c) -{ - return c <= 0xd2 && c >= 0xc0 && - c != 0xce && c != 0xd0; -} - - -inline -bool Encoding::IsComposeChar_arabic(unsigned char c) -{ - return c >= 0xeb && c <= 0xf2; -} - - -extern unsigned char arabic_table[][2]; -extern unsigned char arabic_table2[][4]; -unsigned char const arabic_start = 0xc1; - - -inline -bool Encoding::is_arabic(unsigned char c) -{ - return c >= arabic_start && arabic_table[c-arabic_start][0]; -} - - -inline -unsigned char Encoding::TransformChar(unsigned char c, Encoding::Letter_Form form) -{ - if (!is_arabic(c)) - return c; - - if (lyxrc.font_norm == "iso10646-1") - return arabic_table2[c-arabic_start][form]; - else - return arabic_table[c-arabic_start][form >> 1]; -} - - #endif diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 8192b6b12d..1c17492e2b 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -1095,9 +1095,15 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val) sel_col_start = sel_col_end = tabular->column_of_cell(actcell); sel_row_start = sel_row_end = tabular->row_of_cell(actcell); } - bv->text->SetUndo(bv->buffer(), Undo::FINISH, + bv->text->SetUndo(bv->buffer(), Undo::FINISH, +#ifndef NEW_INSETS bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous, - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next); + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next +#else + bv->text->cursor.par()->previous, + bv->text->cursor.par()->next +#endif + ); int row = tabular->row_of_cell(actcell); int column = tabular->column_of_cell(actcell); diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 855fb2c061..13a75c012c 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -305,20 +305,20 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, y += baseline - row->ascent_of_text() + 1; if (cleared || !locked || (need_update == FULL)) { while (row != 0) { - TEXT(bv)->GetVisibleRow(bv, y, x, row, y, cleared); + TEXT(bv)->GetVisibleRow(bv, y, int(x), row, y, cleared); y += row->height(); row = row->next(); } } else if (need_update == SELECTION) { - bv->screen()->ToggleToggle(TEXT(bv), y, x); + bv->screen()->ToggleToggle(TEXT(bv), y, int(x)); } else { locked = false; if (need_update == CURSOR) { - bv->screen()->ToggleSelection(TEXT(bv), true, y, x); + bv->screen()->ToggleSelection(TEXT(bv), true, y, int(x)); TEXT(bv)->ClearSelection(); TEXT(bv)->sel_cursor = TEXT(bv)->cursor; } - bv->screen()->Update(TEXT(bv), y, x); + bv->screen()->Update(TEXT(bv), y, int(x)); locked = true; } TEXT(bv)->refresh_y = 0; @@ -707,9 +707,15 @@ InsetText::LocalDispatch(BufferView * bv, * "auto_region_delete", which defaults to * true (on). */ - bv->text->SetUndo(bv->buffer(), Undo::INSERT, + bv->text->SetUndo(bv->buffer(), Undo::INSERT, +#ifndef NEW_INSETS bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous, - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next); + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next +#else + bv->text->cursor.par()->previous, + bv->text->cursor.par()->next +#endif + ); if (lyxrc.auto_region_delete) { if (TEXT(bv)->selection){ TEXT(bv)->CutSelection(bv, false); @@ -777,23 +783,41 @@ InsetText::LocalDispatch(BufferView * bv, UpdateLocal(bv, CURSOR, false); break; case LFUN_BACKSPACE: - bv->text->SetUndo(bv->buffer(), Undo::DELETE, + bv->text->SetUndo(bv->buffer(), Undo::DELETE, +#ifndef NEW_INSETS bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous, - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next); + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next +#else + bv->text->cursor.par()->previous, + bv->text->cursor.par()->next +#endif + ); TEXT(bv)->Backspace(bv); UpdateLocal(bv, CURSOR_PAR, true); break; case LFUN_DELETE: - bv->text->SetUndo(bv->buffer(), Undo::DELETE, + bv->text->SetUndo(bv->buffer(), Undo::DELETE, +#ifndef NEW_INSETS bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous, - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next); + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next +#else + bv->text->cursor.par()->previous, + bv->text->cursor.par()->next +#endif + ); TEXT(bv)->Delete(bv); UpdateLocal(bv, CURSOR_PAR, true); break; case LFUN_CUT: - bv->text->SetUndo(bv->buffer(), Undo::DELETE, + bv->text->SetUndo(bv->buffer(), Undo::DELETE, +#ifndef NEW_INSETS bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous, - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next); + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next +#else + bv->text->cursor.par()->previous, + bv->text->cursor.par()->next +#endif + ); TEXT(bv)->CutSelection(bv); UpdateLocal(bv, CURSOR_PAR, true); break; @@ -813,9 +837,15 @@ InsetText::LocalDispatch(BufferView * bv, break; } } - bv->text->SetUndo(bv->buffer(), Undo::INSERT, + bv->text->SetUndo(bv->buffer(), Undo::INSERT, +#ifndef NEW_INSETS bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous, - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next); + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next +#else + bv->text->cursor.par()->previous, + bv->text->cursor.par()->next +#endif + ); TEXT(bv)->PasteSelection(bv); UpdateLocal(bv, CURSOR_PAR, true); break; @@ -828,9 +858,15 @@ InsetText::LocalDispatch(BufferView * bv, case LFUN_BREAKLINE: if (!autoBreakRows) return DISPATCHED; - bv->text->SetUndo(bv->buffer(), Undo::INSERT, + bv->text->SetUndo(bv->buffer(), Undo::INSERT, +#ifndef NEW_INSETS bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous, - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next); + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next +#else + bv->text->cursor.par()->previous, + bv->text->cursor.par()->next +#endif + ); TEXT(bv)->InsertChar(bv, LyXParagraph::META_NEWLINE); UpdateLocal(bv, CURSOR_PAR, true); break; @@ -1079,9 +1115,15 @@ bool InsetText::InsertInset(BufferView * bv, Inset * inset) return the_locking_inset->InsertInset(bv, inset); return false; } - bv->text->SetUndo(bv->buffer(), Undo::INSERT, + bv->text->SetUndo(bv->buffer(), Undo::INSERT, +#ifndef NEW_INSETS bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous, - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next); + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next +#else + bv->text->cursor.par()->previous, + bv->text->cursor.par()->next +#endif + ); if (inset->Editable() == Inset::IS_EDITABLE) { UpdatableInset * i = static_cast(inset); i->setOwner(static_cast(this)); diff --git a/src/layout.h b/src/layout.h index 779cfa1624..641aad24c5 100644 --- a/src/layout.h +++ b/src/layout.h @@ -22,7 +22,6 @@ #include "lyxfont.h" #include "Spacing.h" - /// Reads the style files extern void LyXSetStyle(); @@ -33,11 +32,14 @@ enum { // no good name for this /// LYX_LAYOUT_DEFAULT = 99 }; + + // Could this cause confusion that both DUMMY_LAYOUT and LAYOUT_DEFAULT has // the same value? (Lgb) /// #define LYX_DUMMY_LAYOUT 99 + /// The different output types enum OutputType { /// diff --git a/src/lyx_cb.C b/src/lyx_cb.C index dc9b4debaf..021af5c074 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -1102,10 +1102,19 @@ void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph) ifs.unsetf(ios::skipws); istream_iterator ii(ifs); istream_iterator end; +#if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD) + // We use this until the compilers get better... + vector tmp; + copy(ii, end, back_inserter(tmp)); + string tmpstr(tmp.begin(), tmp.end()); +#else + // This is what we want to use and what we will use once the + // compilers get good enough. //string tmpstr(ii, end); // yet a reason for using std::string // alternate approach to get the file into a string: string tmpstr; copy(ii, end, back_inserter(tmpstr)); +#endif // insert the string current_view->hideCursor(); diff --git a/src/lyx_main.C b/src/lyx_main.C index 48d0072268..d17f1946d3 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -403,7 +403,10 @@ void LyX::init(int */*argc*/, char **argv, bool gui) // ReadRcFile("lyxrc.defaults"); - ReadRcFile("lyxrc"); + // If there is a preferences file we read that instead + // of the old lyxrc file. + if (!ReadRcFile("preferences")) + ReadRcFile("lyxrc"); // Ensure that we have really read a bind file, so that LyX is // usable. @@ -566,7 +569,7 @@ void LyX::queryUserLyXDir(bool explicit_userdir) // Read the rc file `name' -void LyX::ReadRcFile(string const & name) +bool LyX::ReadRcFile(string const & name) { lyxerr[Debug::INIT] << "About to read " << name << "..." << endl; @@ -578,9 +581,12 @@ void LyX::ReadRcFile(string const & name) WriteAlert(_("LyX Warning!"), _("Error while reading ")+lyxrc_path+".", _("Using built-in defaults.")); + return false; } + return true; } else lyxerr[Debug::INIT] << "Could not find " << name << endl; + return false; } @@ -611,6 +617,11 @@ void LyX::ReadUIFile(string const & name) << " in " << ui_path << endl; LyXLex lex(uitags, ui_last - 1); lex.setFile(ui_path); + if (!lex.IsOK()) { + lyxerr << "Unable to set LyXLeX for ui file: " << ui_path + << endl; + } + if (lyxerr.debugging(Debug::PARSER)) lex.printTable(lyxerr); diff --git a/src/lyx_main.h b/src/lyx_main.h index 7279b087d3..ef58c2bcf1 100644 --- a/src/lyx_main.h +++ b/src/lyx_main.h @@ -85,8 +85,10 @@ private: void deadKeyBindings(kb_keymap * kbmap); /// void queryUserLyXDir(bool explicit_userdir); - /// - void ReadRcFile(string const & name); + /** Search for and read the LyXRC file name, return + true if successfull. + */ + bool ReadRcFile(string const & name); /// Read the ui file `name' void ReadUIFile(string const & name); /// diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 0e6564e9a3..83b46b6008 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -898,7 +898,7 @@ string LyXFunc::Dispatch(int ac, Figure(); break; - case LFUN_INSERT_GRAPHICS: + case LFUN_INSET_GRAPHICS: { Inset * new_inset = new InsetGraphics; if (!owner->view()->insertInset(new_inset)) diff --git a/src/lyxlex_pimpl.C b/src/lyxlex_pimpl.C index 4068b7eb2a..f12f119e46 100644 --- a/src/lyxlex_pimpl.C +++ b/src/lyxlex_pimpl.C @@ -19,12 +19,7 @@ using std::lower_bound; // namespace { struct compare_tags { - // used by lower_bound - inline - int operator()(keyword_item const & a, char const * const tag) const { - return compare_no_case(a.tag, tag) < 0; - } - // used by sorted and sort + // used by lower_bound, sort and sorted inline int operator()(keyword_item const & a, keyword_item const & b) const { return compare_no_case(a.tag, b.tag) < 0; @@ -345,12 +340,13 @@ bool LyXLex::Pimpl::next(bool esc /* = false */) } } - /// + int LyXLex::Pimpl::search_kw(char const * const tag) const { + keyword_item search_tag = { tag, 0 }; keyword_item * res = lower_bound(table, table + no_items, - tag, compare_tags()); + search_tag, compare_tags()); if (res != table + no_items && !compare_no_case(res->tag, tag)) return res->code; diff --git a/src/lyxparagraph.h b/src/lyxparagraph.h index dd84cf2210..dcccb3cd75 100644 --- a/src/lyxparagraph.h +++ b/src/lyxparagraph.h @@ -188,9 +188,12 @@ public: /// LyXParagraph * TeXEnvironment(Buffer const *, BufferParams const &, - std::ostream &, TexRow & texrow, - std::ostream & foot, TexRow & foot_texrow, - int & foot_count); + std::ostream &, TexRow & texrow +#ifndef NEW_INSETS + ,std::ostream & foot, TexRow & foot_texrow, + int & foot_count +#endif + ); /// LyXParagraph * Clone() const; @@ -369,12 +372,11 @@ public: LyXParagraph * FirstPhysicalPar(); /// LyXParagraph const * FirstPhysicalPar() const; -#endif - /// returns the physical paragraph LyXParagraph * ParFromPos(size_type pos); /// returns the position in the physical par int PositionInParFromPos(size_type pos) const; +#endif /// for the environments LyXParagraph * DepthHook(int depth); @@ -429,8 +431,6 @@ public: */ LyXFont getFont(BufferParams const &, size_type pos) const; /// - value_type GetChar(size_type pos); - /// value_type GetChar(size_type pos) const; /// The position must already exist. void SetChar(size_type pos, value_type c) { @@ -619,9 +619,12 @@ private: InsetList insetlist; /// LyXParagraph * TeXDeeper(Buffer const *, BufferParams const &, - std::ostream &, TexRow & texrow, - std::ostream & foot, TexRow & foot_texrow, - int & foot_count); + std::ostream &, TexRow & texrow +#ifndef NEW_INSETS + ,std::ostream & foot, TexRow & foot_texrow, + int & foot_count +#endif + ); #ifndef NEW_INSETS /// LyXParagraph * TeXFootnote(Buffer const *, BufferParams const &, diff --git a/src/lyxrc.C b/src/lyxrc.C index 03e8331c4d..d3132a33ca 100644 --- a/src/lyxrc.C +++ b/src/lyxrc.C @@ -467,11 +467,6 @@ int LyXRC::read(string const & filename) } break; - case RC_KBMAP: - if (lexrc.next()) - use_kbmap = lexrc.GetBool(); - break; - case RC_EXIT_CONFIRMATION: if (lexrc.next()) exit_confirmation = lexrc.GetBool(); @@ -482,22 +477,35 @@ int LyXRC::read(string const & filename) display_shortcuts = lexrc.GetBool(); break; + case RC_KBMAP: + if (lexrc.next()) + use_kbmap = lexrc.GetBool(); + break; + case RC_KBMAP_PRIMARY: - if (lexrc.next()) - if (!LibFileSearch("kbd", lexrc.GetString(), - "kmap").empty()) - primary_kbmap = lexrc.GetString(); + if (lexrc.next()) { + string kmap(lexrc.GetString()); + if (kmap.empty()) { + // nothing + } else if (!LibFileSearch("kbd", kmap, + "kmap").empty()) + primary_kbmap = kmap; else lexrc.printError("LyX: Keymap `$$Token' not found"); + } break; case RC_KBMAP_SECONDARY: - if (lexrc.next()) - if (!LibFileSearch("kbd", lexrc.GetString(), - "kmap").empty()) - secondary_kbmap = lexrc.GetString(); + if (lexrc.next()) { + string kmap(lexrc.GetString()); + if (kmap.empty()) { + // nothing + } else if (!LibFileSearch("kbd", kmap, + "kmap").empty()) + secondary_kbmap = kmap; else lexrc.printError("LyX: Keymap `$$Token' not found"); + } break; case RC_FONT_ENCODING: @@ -1122,14 +1130,12 @@ void LyXRC::output(ostream & os) const << "### LyX, The Document Processor\n" << "###\n" << "### Copyright 1995 Matthias Ettrich\n" - << "### Copyright 1995-1998 The LyX Team.\n" + << "### Copyright 1995-2000 The LyX Team.\n" << "###\n" << "### ========================================================\n" << "\n" << "# This file is written by LyX, if you want to make your own\n" << "# modifications you should do them from inside LyX and save\n" - << "# your preferences, or you can also make your modifications\n" - << "# to lyxrc by hand. It is not advisable to edit this file.\n" << "\n"; // Why the switch you might ask. It is a trick to ensure that all @@ -1145,134 +1151,51 @@ void LyXRC::output(ostream & os) const case RC_BIND: // bindings is not written to the preferences file. case RC_BINDFILE: + os << "\\bind_file " << bind_file << "\n"; + + // + // Misc Section + // + os << "\n#\n" + << "# MISC SECTION ######################################\n" + << "#\n\n"; + + case RC_SHOW_BANNER: + os << "# Set to false to inhibit the startup banner.\n" + << "\\show_banner " << tostr(show_banner) << "\n"; + // bind files are not done here. case RC_UIFILE: os << "\\ui_file \"" << ui_file << "\"\n"; - //case RC_SET_COLOR: - // color bindings not written to preference file. - // And we want to be warned about that. (Lgb) - case RC_FONT_ENCODING: - os << "\\font_encoding \"" << fontenc << "\"\n"; - case RC_PRINTER: - os << "\\printer \"" << printer << "\"\n"; - case RC_PRINT_COMMAND: - os << "\\print_command \"" << print_command << "\"\n"; - case RC_PRINTEVENPAGEFLAG: - os << "\\print_evenpage_flag \"" << print_evenpage_flag - << "\"\n"; - case RC_PRINTODDPAGEFLAG: - os << "\\print_oddpage_flag \"" << print_oddpage_flag - << "\"\n"; - case RC_PRINTPAGERANGEFLAG: - os << "\\print_pagerange_flag \"" << print_pagerange_flag - << "\"\n"; - case RC_PRINTCOPIESFLAG: - os << "\\print_copies_flag \"" << print_copies_flag << "\"\n"; - case RC_PRINTCOLLCOPIESFLAG: - os << "\\print_collcopies_flag \"" << print_collcopies_flag - << "\"\n"; - case RC_PRINTREVERSEFLAG: - os << "\\print_reverse_flag \"" << print_reverse_flag - << "\"\n"; - case RC_PRINTLANDSCAPEFLAG: - os << "\\print_landscape_flag \"" << print_landscape_flag - << "\"\n"; - case RC_PRINTTOPRINTER: - os << "\\print_to_printer \"" << print_to_printer << "\"\n"; - case RC_PRINT_ADAPTOUTPUT: - os << "\\print_adapt_output " << tostr(print_adapt_output) - << "\n"; - case RC_PRINTTOFILE: - os << "\\print_to_file \"" << print_to_file << "\"\n"; - case RC_PRINTFILEEXTENSION: - os << "\\print_file_extension \"" << print_file_extension - << "\"\n"; - case RC_PRINTEXSTRAOPTIONS: - os << "\\print_extra_options \"" << print_extra_options - << "\"\n"; - case RC_PRINTSPOOL_COMMAND: - os << "\\print_spool_command \"" << print_spool_command - << "\"\n"; - case RC_PRINTSPOOL_PRINTERPREFIX: - os << "\\print_spool_printerprefix \"" - << print_spool_printerprefix << "\"\n"; - case RC_PRINTPAPERDIMENSIONFLAG: - os << "\\print_paper_dimension_flag \"" - << print_paper_dimension_flag << "\"\n"; - case RC_PRINTPAPERFLAG: - os << "\\print_paper_flag \"" << print_paper_flag << "\"\n"; - case RC_CUSTOM_EXPORT_COMMAND: - os << "\\custom_export_command \"" << custom_export_command - << "\"\n"; - case RC_CUSTOM_EXPORT_FORMAT: - os << "\\custom_export_format \"" << custom_export_format - << "\"\n"; - case RC_PDF_MODE: - os << "\\pdf_mode " << tostr(pdf_mode) << "\n"; - case RC_LATEX_COMMAND: - os << "\\latex_command \"" << latex_command << "\"\n"; - case RC_PDFLATEX_COMMAND: - os << "\\pdflatex_command \"" << pdflatex_command << "\"\n"; - case RC_PDF_TO_PS_COMMAND: - os << "\\pdf_to_ps_command \"" << pdf_to_ps_command << "\"\n"; - case RC_DVI_TO_PS_COMMAND: - os << "\\dvi_to_ps_command \"" << dvi_to_ps_command << "\"\n"; - case RC_LITERATE_COMMAND: - os << "\\literate_command \"" << literate_command << "\"\n"; - case RC_LITERATE_EXTENSION: - os << "\\literate_extension \"" << literate_extension - << "\"\n"; - case RC_LITERATE_ERROR_FILTER: - os << "\\literate_error_filter \"" << literate_error_filter - << "\"\n"; - case RC_BUILD_COMMAND: - os << "\\build_command \"" << build_command << "\"\n"; - case RC_BUILD_ERROR_FILTER: - os << "\\build_error_filter \"" << build_error_filter - << "\"\n"; - case RC_SCREEN_DPI: - os << "\\screen_dpi " << dpi << "\n"; - case RC_SCREEN_ZOOM: - os << "\\screen_zoom " << zoom << "\n"; - case RC_WHEEL_JUMP: - os << "\\wheel_jump " << wheel_jump << "\n"; - case RC_SCREEN_FONT_SIZES: - os.setf(ios::fixed); - os.precision(2); - os << "\\screen_font_sizes"; - os << " " << font_sizes[LyXFont::SIZE_TINY]; - os << " " << font_sizes[LyXFont::SIZE_SCRIPT]; - os << " " << font_sizes[LyXFont::SIZE_FOOTNOTE]; - os << " " << font_sizes[LyXFont::SIZE_SMALL]; - os << " " << font_sizes[LyXFont::SIZE_NORMAL]; - os << " " << font_sizes[LyXFont::SIZE_LARGE]; - os << " " << font_sizes[LyXFont::SIZE_LARGER]; - os << " " << font_sizes[LyXFont::SIZE_LARGEST]; - os << " " << font_sizes[LyXFont::SIZE_HUGE]; - os << " " << font_sizes[LyXFont::SIZE_HUGER]; - os << "\n"; - case RC_OVERRIDE_X_DEADKEYS: - os << "\\override_x_deadkeys " - << override_x_deadkeys << "\n"; case RC_AUTOREGIONDELETE: - os << "\\auto_region_delete " << tostr(auto_region_delete) + os << "# Set to false to inhibit automatic replacement of\n" + << "# the current selection.\n" + << "\\auto_region_delete " << tostr(auto_region_delete) << "\n"; case RC_AUTOSAVE: - os << "\\autosave " << autosave << "\n"; + os << "# The time interval between auto-saves in seconds.\n" + << "\\autosave " << autosave << "\n"; case RC_EXIT_CONFIRMATION: - os << "\\exit_confirmation " << tostr(exit_confirmation) + os << "# Ask for confirmation before exit if there are\n" + << "# unsaved changed documents.\n" + << "\\exit_confirmation " << tostr(exit_confirmation) << "\n"; case RC_DISPLAY_SHORTCUTS: - os << "\\display_shortcuts " << tostr(display_shortcuts) + os << "# Display name of the last command executed, with a\n" + << "# list of short-cuts in the minibuffer.\n" + << "\\display_shortcuts " << tostr(display_shortcuts) << "\n"; case RC_VIEWDVI_COMMAND: - os << "\\view_dvi_command \"" << view_dvi_command << "\"\n"; + os << "# Program used to view dvi files.\n" + << "\\view_dvi_command \"" << view_dvi_command << "\"\n"; case RC_VIEWDVI_PAPEROPTION: - os << "\\view_dvi_paper_option \"" << view_dvi_paper_option << "\"\n"; - case RC_VIEWPDF_COMMAND: - os << "\\view_pdf_command \"" << view_pdf_command << "\"\n"; + os << "# Options used to specify paper size to the\n" + << "# view_dvi_command\n" + << "\\view_dvi_paper_option \"" + << view_dvi_paper_option << "\"\n"; case RC_DEFAULT_PAPERSIZE: - os << "\\default_papersize \""; + os << "# The default papersize to use.\n" + << "\\default_papersize \""; switch (default_papersize) { case BufferParams::PAPER_USLETTER: os << "usletter"; break; @@ -1291,13 +1214,20 @@ void LyXRC::output(ostream & os) const case BufferParams::PAPER_DEFAULT: break; } os << "\"\n"; + case RC_VIEWPDF_COMMAND: + os << "# Command used to view PDF files.\n" + << "\\view_pdf_command \"" << view_pdf_command << "\"\n"; case RC_VIEWPS_COMMAND: - os << "\\view_ps_command \"" << view_ps_command << "\"\n"; + os << "# Command used to view PostScript files.\n" + << "\\view_ps_command \"" << view_ps_command << "\"\n"; case RC_VIEWPSPIC_COMMAND: - os << "\\view_pspic_command \"" << view_pspic_command + os << "# Command used to view full screen included PS\n" + << "# pictures.\n" + << "\\view_pspic_command \"" << view_pspic_command << "\"\n"; case RC_PS_COMMAND: - os << "\\ps_command \"" << ps_command << "\"\n"; + os << "# Program used for interpreting postscript.\n" + << "\\ps_command \"" << ps_command << "\"\n"; case RC_CHKTEX_COMMAND: os << "\\chktex_command \"" << chktex_command << "\"\n"; case RC_HTML_COMMAND: @@ -1312,20 +1242,24 @@ void LyXRC::output(ostream & os) const os << "\\serverpipe \"" << lyxpipes << "\"\n"; case RC_RELYX_COMMAND: os << "\\relyx_command \"" << relyx_command << "\"\n"; - case RC_DOCUMENTPATH: - os << "\\document_path \"" << document_path << "\"\n"; - case RC_TEMPLATEPATH: - os << "\\template_path \"" << template_path << "\"\n"; - case RC_TEMPDIRPATH: - os << "\\tempdir_path \"" << tempdir_path << "\"\n"; - case RC_USETEMPDIR: - os << "\\use_tempdir " << tostr(use_tempdir) << "\n"; - case RC_LASTFILES: - os << "\\lastfiles \"" << lastfiles << "\"\n"; - case RC_NUMLASTFILES: - os << "\\num_lastfiles " << num_lastfiles << "\n"; - case RC_CHECKLASTFILES: - os << "\\check_lastfiles " << tostr(check_lastfiles) << "\n"; + case RC_DATE_INSERT_FORMAT: + os << "\\date_insert_format \"" << date_insert_format + << "\"\n"; + + + os << "\n#\n" + << "# SCREEN & FONTS SECTION ############################\n" + << "#\n\n"; + + case RC_SCREEN_DPI: + os << "\\screen_dpi " << dpi << "\n"; + case RC_SCREEN_ZOOM: + os << "\\screen_zoom " << zoom << "\n"; + case RC_WHEEL_JUMP: + os << "\\wheel_jump " << wheel_jump << "\n"; + case RC_CURSOR_FOLLOWS_SCROLLBAR: + os << "\\cursor_follows_scrollbar " + << tostr(cursor_follows_scrollbar) << "\n"; case RC_SCREEN_FONT_ROMAN: os << "\\screen_font_roman \"" << roman_font_name << "\"\n"; case RC_SCREEN_FONT_SANS: @@ -1333,67 +1267,216 @@ void LyXRC::output(ostream & os) const case RC_SCREEN_FONT_TYPEWRITER: os << "\\screen_font_typewriter \"" << typewriter_font_name << "\"\n"; - case RC_SCREEN_FONT_MENU: - os << "\\screen_font_menu \"" << menu_font_name << "\"\n"; - case RC_SCREEN_FONT_POPUP: - os << "\\screen_font_popup \"" << popup_font_name << "\"\n"; - case RC_SCREEN_FONT_ENCODING: - os << "\\screen_font_encoding \"" << font_norm << "\"\n"; - case RC_SCREEN_FONT_ENCODING_MENU: - os << "\\screen_font_encoding_menu \"" << font_norm_menu - << "\"\n"; case RC_SCREEN_FONT_SCALABLE: os << "\\screen_font_scalable " << tostr(use_scalable_fonts) << "\n"; - case RC_CURSOR_FOLLOWS_SCROLLBAR: - os << "\\cursor_follows_scrollbar " - << tostr(cursor_follows_scrollbar) << "\n"; + case RC_SCREEN_FONT_ENCODING: + os << "\\screen_font_encoding \"" << font_norm << "\"\n"; + case RC_SCREEN_FONT_POPUP: + os << "\\screen_font_popup \"" << popup_font_name << "\"\n"; + case RC_SCREEN_FONT_MENU: + os << "\\screen_font_menu \"" << menu_font_name << "\"\n"; + case RC_SCREEN_FONT_SIZES: + os.setf(ios::fixed); + os.precision(2); + os << "\\screen_font_sizes"; + os << " " << font_sizes[LyXFont::SIZE_TINY]; + os << " " << font_sizes[LyXFont::SIZE_SCRIPT]; + os << " " << font_sizes[LyXFont::SIZE_FOOTNOTE]; + os << " " << font_sizes[LyXFont::SIZE_SMALL]; + os << " " << font_sizes[LyXFont::SIZE_NORMAL]; + os << " " << font_sizes[LyXFont::SIZE_LARGE]; + os << " " << font_sizes[LyXFont::SIZE_LARGER]; + os << " " << font_sizes[LyXFont::SIZE_LARGEST]; + os << " " << font_sizes[LyXFont::SIZE_HUGE]; + os << " " << font_sizes[LyXFont::SIZE_HUGER]; + os << "\n"; + //case RC_SET_COLOR: + // color bindings not written to preference file. + // And we want to be warned about that. (Lgb) + + os << "\n#\n" + << "# PRINTER SECTION ###################################\n" + << "#\n\n"; + + case RC_PRINTER: + os << "\\printer \"" << printer << "\"\n"; + case RC_PRINT_ADAPTOUTPUT: + os << "\\print_adapt_output " << tostr(print_adapt_output) + << "\n"; + case RC_PRINT_COMMAND: + os << "\\print_command \"" << print_command << "\"\n"; + case RC_PRINTEXSTRAOPTIONS: + os << "\\print_extra_options \"" << print_extra_options + << "\"\n"; + case RC_PRINTSPOOL_COMMAND: + os << "\\print_spool_command \"" << print_spool_command + << "\"\n"; + case RC_PRINTSPOOL_PRINTERPREFIX: + os << "\\print_spool_printerprefix \"" + << print_spool_printerprefix << "\"\n"; + case RC_PRINTEVENPAGEFLAG: + os << "\\print_evenpage_flag \"" << print_evenpage_flag + << "\"\n"; + case RC_PRINTODDPAGEFLAG: + os << "\\print_oddpage_flag \"" << print_oddpage_flag + << "\"\n"; + case RC_PRINTREVERSEFLAG: + os << "\\print_reverse_flag \"" << print_reverse_flag + << "\"\n"; + case RC_PRINTLANDSCAPEFLAG: + os << "\\print_landscape_flag \"" << print_landscape_flag + << "\"\n"; + case RC_PRINTPAGERANGEFLAG: + os << "\\print_pagerange_flag \"" << print_pagerange_flag + << "\"\n"; + case RC_PRINTCOPIESFLAG: + os << "\\print_copies_flag \"" << print_copies_flag << "\"\n"; + case RC_PRINTCOLLCOPIESFLAG: + os << "\\print_collcopies_flag \"" << print_collcopies_flag + << "\"\n"; + case RC_PRINTPAPERFLAG: + os << "\\print_paper_flag \"" << print_paper_flag << "\"\n"; + case RC_PRINTPAPERDIMENSIONFLAG: + os << "\\print_paper_dimension_flag \"" + << print_paper_dimension_flag << "\"\n"; + case RC_PRINTTOPRINTER: + os << "\\print_to_printer \"" << print_to_printer << "\"\n"; + case RC_PRINTTOFILE: + os << "\\print_to_file \"" << print_to_file << "\"\n"; + case RC_PRINTFILEEXTENSION: + os << "\\print_file_extension \"" << print_file_extension + << "\"\n"; + + os << "\n#\n" + << "# EXPORT SECTION ####################################\n" + << "#\n\n"; + + case RC_CUSTOM_EXPORT_COMMAND: + os << "\\custom_export_command \"" << custom_export_command + << "\"\n"; + case RC_CUSTOM_EXPORT_FORMAT: + os << "\\custom_export_format \"" << custom_export_format + << "\"\n"; + + os << "\n#\n" + << "# TEX SECTION #######################################\n" + << "#\n\n"; + + case RC_LATEX_COMMAND: + os << "\\latex_command \"" << latex_command << "\"\n"; + case RC_PDFLATEX_COMMAND: + os << "\\pdflatex_command \"" << pdflatex_command << "\"\n"; + case RC_PDF_MODE: + os << "\\pdf_mode " << tostr(pdf_mode) << "\n"; + case RC_FONT_ENCODING: + os << "\\font_encoding \"" << fontenc << "\"\n"; + + os << "\n#\n" + << "# LINUXDOC SECTION ##################################\n" + << "#\n\n"; + + case RC_LINUXDOC_TO_LATEX_COMMAND: + os << "\\linuxdoc_to_latex_command \"" << linuxdoc_to_latex_command + << "\"\n"; + case RC_LINUXDOC_TO_HTML_COMMAND: + os << "\\linuxdoc_to_html_command \"" << linuxdoc_to_html_command + << "\"\n"; + case RC_LINUXDOC_TO_LYX_COMMAND: + os << "\\linuxdoc_to_lyx_command \"" << linuxdoc_to_lyx_command + << "\"\n"; + + os << "\n#\n" + << "# DOCBOOK SECTION ###################################\n" + << "#\n\n"; + + case RC_DOCBOOK_TO_DVI_COMMAND: + os << "\\docbook_to_dvi_command \"" << docbook_to_dvi_command + << "\"\n"; + case RC_DOCBOOK_TO_HTML_COMMAND: + os << "\\docbook_to_html_command \"" << docbook_to_html_command + << "\"\n"; + case RC_DOCBOOK_TO_PDF_COMMAND: + os << "\\docbook_to_pdf_command \"" << docbook_to_pdf_command + << "\"\n"; + + os << "\n#\n" + << "# FILE SECTION ######################################\n" + << "#\n\n"; + + case RC_DOCUMENTPATH: + os << "\\document_path \"" << document_path << "\"\n"; + case RC_LASTFILES: + os << "\\lastfiles \"" << lastfiles << "\"\n"; + case RC_NUMLASTFILES: + os << "\\num_lastfiles " << num_lastfiles << "\n"; + case RC_CHECKLASTFILES: + os << "\\check_lastfiles " << tostr(check_lastfiles) << "\n"; + case RC_TEMPLATEPATH: + os << "\\template_path \"" << template_path << "\"\n"; + case RC_TEMPDIRPATH: + os << "\\tempdir_path \"" << tempdir_path << "\"\n"; + case RC_USETEMPDIR: + os << "\\use_tempdir " << tostr(use_tempdir) << "\n"; + case RC_ASCII_LINELEN: + os << "\\ascii_linelen " << ascii_linelen << "\n"; + case RC_MAKE_BACKUP: + os << "\\make_backup " << tostr(make_backup) << "\n"; + case RC_BACKUPDIR_PATH: + os << "\\backupdir_path \"" << backupdir_path << "\"\n"; + + os << "\n#\n" + << "# FAX SECTION #######################################\n" + << "#\n\n"; + case RC_FAX_COMMAND: os << "\\fax_command \"" << fax_command << "\"\n"; - case RC_FAXPROGRAM: - os << "\\fax_program \"" << fax_program << "\"\n"; case RC_PHONEBOOK: os << "\\phone_book \"" << phone_book << "\"\n"; + case RC_FAXPROGRAM: + os << "\\fax_program \"" << fax_program << "\"\n"; + + os << "\n#\n" + << "# ASCII EXPORT SECTION ##############################\n" + << "#\n\n"; + case RC_ASCIIROFF_COMMAND: os << "\\ascii_roff_command \"" << ascii_roff_command << "\"\n"; - case RC_ASCII_LINELEN: - os << "\\ascii_linelen " << ascii_linelen << "\n"; + + os << "\n#\n" + << "# SPELLCHECKER SECTION ##############################\n" + << "#\n\n"; + case RC_SPELL_COMMAND: os << "\\spell_command \"" << isp_command << "\"\n"; case RC_ACCEPT_COMPOUND: os << "\\accept_compound " << tostr(isp_accept_compound) << "\n"; - case RC_USE_INP_ENC: - os << "\\use_input_encoding " << tostr(isp_use_input_encoding) - << "\n"; case RC_USE_ALT_LANG: os << "\\use_alt_language " << tostr(isp_use_alt_lang) << "\n"; - case RC_USE_PERS_DICT: - os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict) - << "\n"; + case RC_ALT_LANG: + os << "\\alternate_language \"" << isp_alt_lang << "\"\n"; case RC_USE_ESC_CHARS: os << "\\use_escape_chars " << tostr(isp_use_esc_chars) << "\n"; - case RC_ALT_LANG: - os << "\\alternate_language \"" << isp_alt_lang << "\"\n"; - case RC_PERS_DICT: - os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n"; case RC_ESC_CHARS: os << "\\escape_chars \"" << isp_esc_chars << "\"\n"; + case RC_USE_PERS_DICT: + os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict) + << "\n"; + case RC_PERS_DICT: + os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n"; + case RC_USE_INP_ENC: + os << "\\use_input_encoding " << tostr(isp_use_input_encoding) + << "\n"; + + os << "\n#\n" + << "# LANGUAGE SUPPORT SECTION ##########################\n" + << "#\n\n"; + case RC_RTL_SUPPORT: os << "\\rtl " << tostr(rtl_support) << "\n"; - case RC_AUTO_NUMBER: - os << "\\auto_number " << tostr(auto_number) << "\n"; - case RC_MARK_FOREIGN_LANGUAGE: - os << "\\mark_foreign_language " << - tostr(mark_foreign_language) << "\n"; - case RC_LANGUAGE_AUTO_BEGIN: - os << "\\language_auto_begin " - << tostr(language_auto_begin) << "\n"; - case RC_LANGUAGE_AUTO_END: - os << "\\language_auto_end " - << tostr(language_auto_end) << "\n"; case RC_LANGUAGE_PACKAGE: os << "\\language_package \"" << language_package << "\"\n"; case RC_LANGUAGE_COMMAND_BEGIN: @@ -1402,35 +1485,47 @@ void LyXRC::output(ostream & os) const case RC_LANGUAGE_COMMAND_END: os << "\\language_command_end \"" << language_command_end << "\"\n"; - case RC_MAKE_BACKUP: - os << "\\make_backup " << tostr(make_backup) << "\n"; - case RC_BACKUPDIR_PATH: - os << "\\backupdir_path \"" << backupdir_path << "\"\n"; - case RC_DATE_INSERT_FORMAT: - os << "\\date_insert_format \"" << date_insert_format - << "\"\n"; - case RC_SHOW_BANNER: - os << "\\show_banner " << tostr(show_banner) << "\n"; - case RC_USE_GUI: - os << "\\use_gui " << tostr(show_banner) << "\n"; - case RC_LINUXDOC_TO_LYX_COMMAND: - os << "\\linuxdoc_to_lyx_command \"" << linuxdoc_to_lyx_command - << "\"\n"; - case RC_LINUXDOC_TO_HTML_COMMAND: - os << "\\linuxdoc_to_html_command \"" << linuxdoc_to_html_command - << "\"\n"; - case RC_LINUXDOC_TO_LATEX_COMMAND: - os << "\\linuxdoc_to_latex_command \"" << linuxdoc_to_latex_command + case RC_LANGUAGE_AUTO_BEGIN: + os << "\\language_auto_begin " + << tostr(language_auto_begin) << "\n"; + case RC_LANGUAGE_AUTO_END: + os << "\\language_auto_end " + << tostr(language_auto_end) << "\n"; + case RC_MARK_FOREIGN_LANGUAGE: + os << "\\mark_foreign_language " << + tostr(mark_foreign_language) << "\n"; + + os << "\n#\n" + << "# 2nd MISC SUPPORT SECTION ##########################\n" + << "#\n\n"; + + case RC_PDF_TO_PS_COMMAND: + os << "\\pdf_to_ps_command \"" << pdf_to_ps_command << "\"\n"; + case RC_DVI_TO_PS_COMMAND: + os << "\\dvi_to_ps_command \"" << dvi_to_ps_command << "\"\n"; + case RC_LITERATE_COMMAND: + os << "\\literate_command \"" << literate_command << "\"\n"; + case RC_LITERATE_EXTENSION: + os << "\\literate_extension \"" << literate_extension << "\"\n"; - case RC_DOCBOOK_TO_DVI_COMMAND: - os << "\\docbook_to_dvi_command \"" << docbook_to_dvi_command + case RC_LITERATE_ERROR_FILTER: + os << "\\literate_error_filter \"" << literate_error_filter << "\"\n"; - case RC_DOCBOOK_TO_HTML_COMMAND: - os << "\\docbook_to_html_command \"" << docbook_to_html_command + case RC_BUILD_COMMAND: + os << "\\build_command \"" << build_command << "\"\n"; + case RC_BUILD_ERROR_FILTER: + os << "\\build_error_filter \"" << build_error_filter << "\"\n"; - case RC_DOCBOOK_TO_PDF_COMMAND: - os << "\\docbook_to_pdf_command \"" << docbook_to_pdf_command + case RC_OVERRIDE_X_DEADKEYS: + os << "\\override_x_deadkeys " + << tostr(override_x_deadkeys) << "\n"; + case RC_SCREEN_FONT_ENCODING_MENU: + os << "\\screen_font_encoding_menu \"" << font_norm_menu << "\"\n"; + case RC_AUTO_NUMBER: + os << "\\auto_number " << tostr(auto_number) << "\n"; + case RC_USE_GUI: + os << "\\use_gui " << tostr(use_gui) << "\n"; } os.flush(); } diff --git a/src/menus.C b/src/menus.C index 2e249d0927..523cfe3c63 100644 --- a/src/menus.C +++ b/src/menus.C @@ -1827,27 +1827,62 @@ void Menus::ShowInsertMenu(FL_OBJECT * ob, long) case 6: tmpfunc->Dispatch(LFUN_INSET_EXTERNAL); break; - case 7: tmpfunc->Dispatch(LFUN_FOOTMELT); break - ; - case 8: tmpfunc->Dispatch(LFUN_MARGINMELT); break; + case 7: +#ifndef NEW_INSETS + tmpfunc->Dispatch(LFUN_FOOTMELT); break; +#else + tmpfunc->Dispatch(LFUN_INSET_FOOTNOTE); + break; +#endif + case 8: +#ifndef NEW_INSETS + tmpfunc->Dispatch(LFUN_MARGINMELT); break; +#else + tmpfunc->Dispatch(LFUN_INSET_MARGINAL); + break; +#endif case 9: // Float sub-menu case 71: +#ifndef NEW_INSETS tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "figure"); break; +#else + tmpfunc->Dispatch(LFUN_INSET_FLOAT, "figure"); + break; +#endif case 72: +#ifndef NEW_INSETS tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "table"); break; +#else + tmpfunc->Dispatch(LFUN_INSET_FLOAT, "table"); + break; +#endif case 73: +#ifndef NEW_INSETS tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "wide-fig"); break; +#else + tmpfunc->Dispatch(LFUN_INSET_FLOAT, "figure"); + break; +#endif case 74: +#ifndef NEW_INSETS tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "wide-tab"); break; +#else + tmpfunc->Dispatch(LFUN_INSET_FLOAT, "table"); + break; +#endif case 75: +#ifndef NEW_INSETS tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "algorithm"); break; - +#else + tmpfunc->Dispatch(LFUN_INSET_FLOAT, "algorithm"); + break; +#endif case 10: // Table/List submenu break; case 21: tmpfunc->Dispatch(LFUN_TOC_INSERT); break; diff --git a/src/paragraph.C b/src/paragraph.C index 7e9e13dc72..3f94aeb4fa 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -551,19 +551,23 @@ LyXParagraph::~LyXParagraph() void LyXParagraph::Erase(LyXParagraph::size_type pos) { +#ifndef NEW_INSETS // > because last is the next unused position, and you can // use it if you want if (pos > size()) { -#ifndef NEW_INSETS if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) NextAfterFootnote()->Erase(pos - text.size() - 1); else -#endif lyxerr.debug() << "ERROR (LyXParagraph::Erase): " "position does not exist." << endl; return; } +#else + Assert(pos < size()); +#endif +#ifndef NEW_INSETS if (pos < size()) { // last is free for insertation, but should be empty +#endif // if it is an inset, delete the inset entry if (text[pos] == LyXParagraph::META_INSET) { // find the entry @@ -615,10 +619,12 @@ void LyXParagraph::Erase(LyXParagraph::size_type pos) search_inset, matchIT()); it != insetlist.end(); ++it) --(*it).pos; +#ifndef NEW_INSETS } else { lyxerr << "ERROR (LyXParagraph::Erase): " "can't erase non-existant char." << endl; } +#endif } @@ -634,20 +640,22 @@ void LyXParagraph::InsertChar(LyXParagraph::size_type pos, LyXParagraph::value_type c, LyXFont const & font) { +#ifndef NEW_INSETS // > because last is the next unused position, and you can // use it if you want if (pos > size()) { -#ifndef NEW_INSETS if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) NextAfterFootnote()->InsertChar(pos - text.size() - 1, c); else -#endif lyxerr.debug() << "ERROR (LyXParagraph::InsertChar): " "position does not exist." << endl; return; } +#else + Assert(pos <= size()); +#endif text.insert(text.begin() + pos, c); // Update the font table. FontTable search_font(pos, LyXFont()); @@ -682,21 +690,23 @@ void LyXParagraph::InsertInset(LyXParagraph::size_type pos, { Assert(inset); +#ifndef NEW_INSETS // > because last is the next unused position, and you can // use it if you want if (pos > size()) { -#ifndef NEW_INSETS if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) NextAfterFootnote() ->InsertInset(pos - text.size() - 1, inset, font); else -#endif lyxerr << "ERROR (LyXParagraph::InsertInset): " "position does not exist: " << pos << endl; return; } +#else + Assert(pos <= size()); +#endif InsertChar(pos, META_INSET, font); Assert(text[pos] == META_INSET); @@ -728,20 +738,22 @@ bool LyXParagraph::InsertInsetAllowed(Inset * inset) Inset * LyXParagraph::GetInset(LyXParagraph::size_type pos) { - if (pos >= size()) { #ifndef NEW_INSETS + if (pos >= size()) { if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) return NextAfterFootnote() ->GetInset(pos - text.size() - 1); else -#endif lyxerr << "ERROR (LyXParagraph::GetInset): " "position does not exist: " << pos << endl; return 0; } +#else + Assert(pos < size()); +#endif // Find the inset. InsetTable search_inset(pos, 0); InsetList::iterator it = lower_bound(insetlist.begin(), @@ -765,20 +777,22 @@ Inset * LyXParagraph::GetInset(LyXParagraph::size_type pos) Inset const * LyXParagraph::GetInset(LyXParagraph::size_type pos) const { - if (pos >= size()) { #ifndef NEW_INSETS + if (pos >= size()) { if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) return NextAfterFootnote() ->GetInset(pos - text.size() - 1); else -#endif lyxerr << "ERROR (LyXParagraph::GetInset): " "position does not exist: " << pos << endl; return 0; } +#else + Assert(pos < size()); +#endif // Find the inset. InsetTable search_inset(pos, 0); InsetList::const_iterator cit = lower_bound(insetlist.begin(), @@ -804,25 +818,31 @@ Inset const * LyXParagraph::GetInset(LyXParagraph::size_type pos) const LyXFont LyXParagraph::GetFontSettings(BufferParams const & bparams, LyXParagraph::size_type pos) const { +#ifdef NEW_INSETS + Assert(pos <= size()); +#endif +#ifndef NEW_INSETS if (pos < size()) { +#endif FontTable search_font(pos, LyXFont()); FontList::const_iterator cit = lower_bound(fontlist.begin(), fontlist.end(), search_font, matchFT()); if (cit != fontlist.end()) return (*cit).font; +#ifndef NEW_INSETS } +#endif +#ifndef NEW_INSETS // > because last is the next unused position, and you can // use it if you want else if (pos > size()) { -#ifndef NEW_INSETS if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) return NextAfterFootnote() ->GetFontSettings(bparams, pos - text.size() - 1); else -#endif // Why is it an error to ask for the font of a // position that does not exist? Would it be // enough for this to be enabled on debug? @@ -832,12 +852,19 @@ LyXFont LyXParagraph::GetFontSettings(BufferParams const & bparams, "position does not exist. " << pos << " (" << static_cast(pos) << ")" << endl; - } else if (pos > 0) { + } + else if (pos > 0) { + return GetFontSettings(bparams, pos - 1); + } +#else + if (pos == size() && size()) return GetFontSettings(bparams, pos - 1); - } else // pos = size() = 0 - return LyXFont(LyXFont::ALL_INHERIT, getParLanguage(bparams)); +#endif + //else + // pos = size() = 0 + return LyXFont(LyXFont::ALL_INHERIT, getParLanguage(bparams)); - return LyXFont(LyXFont::ALL_INHERIT); + //return LyXFont(LyXFont::ALL_INHERIT); } // Gets uninstantiated font setting at position 0 @@ -942,83 +969,30 @@ LyXParagraph::HighestFontInRange(LyXParagraph::size_type startpos, LyXParagraph::value_type -LyXParagraph::GetChar(LyXParagraph::size_type pos) +LyXParagraph::GetChar(LyXParagraph::size_type pos) const { - Assert(pos >= 0); - - if (pos < size()) { - return text[pos]; - } - // > because last is the next unused position, and you can - // use it if you want - else if (pos > size()) { #ifndef NEW_INSETS - if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE) - return NextAfterFootnote() - ->GetChar(pos - text.size() - 1); - else -#endif - { - lyxerr << "ERROR (LyXParagraph::GetChar): " - "position does not exist." - << pos << " (" << static_cast(pos) - << ")\n"; - // Assert(false); // This triggers sometimes... - // Why? - } - - return '\0'; - } - -#ifndef NEW_INSETS - else { - // We should have a footnote environment. - if (!next || next->footnoteflag == LyXParagraph::NO_FOOTNOTE) { - // Notice that LyX does request the - // last char from time to time. (Asger) - //lyxerr << "ERROR (LyXParagraph::GetChar): " - // "expected footnote." << endl; - return '\0'; - } - switch (next->footnotekind) { - case LyXParagraph::FOOTNOTE: - return LyXParagraph::META_FOOTNOTE; - case LyXParagraph::MARGIN: - return LyXParagraph::META_MARGIN; - case LyXParagraph::FIG: - case LyXParagraph::WIDE_FIG: - return LyXParagraph::META_FIG; - case LyXParagraph::TAB: - case LyXParagraph::WIDE_TAB: - return LyXParagraph::META_TAB; - case LyXParagraph::ALGORITHM: - return LyXParagraph::META_ALGORITHM; - } - return '\0'; // to shut up gcc - } + Assert(pos >= 0); #else - return '\0'; // to shut up gcc + Assert(pos <= size()); + if (!size() || pos == size()) return '\0'; #endif -} - - -LyXParagraph::value_type -LyXParagraph::GetChar(LyXParagraph::size_type pos) const -{ - Assert(pos >= 0); +#ifndef NEW_INSETS if (pos < size()) { +#endif return text[pos]; +#ifndef NEW_INSETS } +#endif +#ifndef NEW_INSETS // > because last is the next unused position, and you can // use it if you want else if (pos > size()) { -#ifndef NEW_INSETS if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE) return NextAfterFootnote() ->GetChar(pos - text.size() - 1); else -#endif { lyxerr << "ERROR (LyXParagraph::GetChar const): " "position does not exist." @@ -1027,9 +1001,7 @@ LyXParagraph::GetChar(LyXParagraph::size_type pos) const Assert(false); } return '\0'; - } -#ifndef NEW_INSETS - else { + } else { // We should have a footnote environment. if (!next || next->footnoteflag == LyXParagraph::NO_FOOTNOTE) { // Notice that LyX does request the @@ -1054,9 +1026,6 @@ LyXParagraph::GetChar(LyXParagraph::size_type pos) const } return '\0'; // to shut up gcc } -#else - return '\0'; // to shut up gcc - #endif } @@ -1064,7 +1033,7 @@ LyXParagraph::GetChar(LyXParagraph::size_type pos) const // return an string of the current word, and the end of the word in lastpos. string LyXParagraph::GetWord(LyXParagraph::size_type & lastpos) const { - Assert(lastpos>=0); + Assert(lastpos >= 0); // the current word is defined as starting at the first character // from the immediate left of lastpospos which meets the definition @@ -1107,7 +1076,10 @@ string LyXParagraph::GetWord(LyXParagraph::size_type & lastpos) const } - + +#ifdef NEW_INSETS +#warning Remember to get rid of this one. (Lgb) +#endif LyXParagraph::size_type LyXParagraph::Last() const { #ifndef NEW_INSETS @@ -1121,38 +1093,37 @@ LyXParagraph::size_type LyXParagraph::Last() const } +#ifndef NEW_INSETS LyXParagraph * LyXParagraph::ParFromPos(LyXParagraph::size_type pos) { // > because last is the next unused position, and you can // use it if you want if (pos > size()) { -#ifndef NEW_INSETS if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) return NextAfterFootnote() ->ParFromPos(pos - text.size() - 1); else -#endif lyxerr << "ERROR (LyXParagraph::ParFromPos): " "position does not exist." << endl; return this; } else return this; } +#endif +#ifndef NEW_INSETS int LyXParagraph::PositionInParFromPos(LyXParagraph::size_type pos) const { // > because last is the next unused position, and you can // use it if you want if (pos > size()) { -#ifndef NEW_INSETS if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) return NextAfterFootnote() ->PositionInParFromPos(pos - text.size() - 1); else -#endif lyxerr << "ERROR (LyXParagraph::PositionInParFromPos): " "position does not exist." << endl; @@ -1161,26 +1132,29 @@ int LyXParagraph::PositionInParFromPos(LyXParagraph::size_type pos) const else return pos; } +#endif void LyXParagraph::SetFont(LyXParagraph::size_type pos, LyXFont const & font) { +#ifndef NEW_INSETS // > because last is the next unused position, and you can // use it if you want if (pos > size()) { -#ifndef NEW_INSETS if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) { NextAfterFootnote()->SetFont(pos - text.size() - 1, font); } else -#endif lyxerr << "ERROR (LyXParagraph::SetFont): " "position does not exist." << endl; return; } +#else + Assert(pos <= size()); +#endif // First, reduce font against layout/label font // Update: The SetCharFont() routine in text2.C already @@ -1438,16 +1412,21 @@ void LyXParagraph::BreakParagraph(BufferParams const & bparams, LyXParagraph::size_type pos, int flag) { - size_type i, j, pos_end, pos_first; + size_type i; + size_type j; // create a new paragraph - LyXParagraph * par = ParFromPos(pos); #ifndef NEW_INSETS + size_type pos_end; + size_type pos_first; + LyXParagraph * par = ParFromPos(pos); LyXParagraph * firstpar = FirstPhysicalPar(); -#else - LyXParagraph * firstpar = this; -#endif LyXParagraph * tmp = new LyXParagraph(par); +#else + //LyXParagraph * par = this; + //LyXParagraph * firstpar = this; + LyXParagraph * tmp = new LyXParagraph(this); +#endif #ifndef NEW_INSETS tmp->footnoteflag = footnoteflag; @@ -1455,13 +1434,21 @@ void LyXParagraph::BreakParagraph(BufferParams const & bparams, #endif // this is an idea for a more userfriendly layout handling, I will // see what the users say - + +#ifndef NEW_INSETS // layout stays the same with latex-environments if (flag) { tmp->SetOnlyLayout(bparams, firstpar->layout); tmp->SetLabelWidthString(firstpar->labelwidthstring); } - +#else + // layout stays the same with latex-environments + if (flag) { + tmp->SetOnlyLayout(bparams, layout); + tmp->SetLabelWidthString(labelwidthstring); + } +#endif +#ifndef NEW_INSETS if (Last() > pos || !Last() || flag == 2) { tmp->SetOnlyLayout(bparams, firstpar->layout); tmp->align = firstpar->align; @@ -1476,15 +1463,31 @@ void LyXParagraph::BreakParagraph(BufferParams const & bparams, tmp->depth = firstpar->depth; tmp->noindent = firstpar->noindent; - +#else + if (Last() > pos || !Last() || flag == 2) { + tmp->SetOnlyLayout(bparams, layout); + tmp->align = align; + tmp->SetLabelWidthString(labelwidthstring); + + tmp->line_bottom = line_bottom; + line_bottom = false; + tmp->pagebreak_bottom = pagebreak_bottom; + pagebreak_bottom = false; + tmp->added_space_bottom = added_space_bottom; + added_space_bottom = VSpace(VSpace::NONE); + + tmp->depth = depth; + tmp->noindent = noindent; +#endif // copy everything behind the break-position // to the new paragraph +#ifndef NEW_INSETS pos_first = 0; while (ParFromPos(pos_first) != par) ++pos_first; - pos_end = pos_first + par->text.size() - 1; + for (i = j = pos; i <= pos_end; ++i) { par->CutIntoMinibuffer(bparams, i - pos_first); if (tmp->InsertFromMinibuffer(j - pos)) @@ -1495,8 +1498,23 @@ void LyXParagraph::BreakParagraph(BufferParams const & bparams, par->Erase(i - pos_first); par->text.resize(par->text.size()); +#else + size_type pos_end = text.size() - 1; + + for (i = j = pos; i <= pos_end; ++i) { + CutIntoMinibuffer(bparams, i); + if (tmp->InsertFromMinibuffer(j - pos)) + ++j; + } + tmp->fitToSize(); + for (i = pos_end; i >= pos; --i) + Erase(i); + + fitToSize(); +#endif } +#ifndef NEW_INSETS // just an idea of me if (!pos) { tmp->line_top = firstpar->line_top; @@ -1511,6 +1529,22 @@ void LyXParagraph::BreakParagraph(BufferParams const & bparams, firstpar->depth = tmp->depth; } } +#else + // just an idea of me + if (!pos) { + tmp->line_top = line_top; + tmp->pagebreak_top = pagebreak_top; + tmp->added_space_top = added_space_top; + tmp->bibkey = bibkey; + Clear(); + // layout stays the same with latex-environments + if (flag) { + SetOnlyLayout(bparams, tmp->layout); + SetLabelWidthString(tmp->labelwidthstring); + depth = tmp->depth; + } + } +#endif } @@ -1672,6 +1706,7 @@ bool LyXParagraph::HasSameLayout(LyXParagraph const * par) const void LyXParagraph::BreakParagraphConservative(BufferParams const & bparams, LyXParagraph::size_type pos) { +#ifndef NEW_INSETS // create a new paragraph LyXParagraph * par = ParFromPos(pos); @@ -1701,24 +1736,57 @@ void LyXParagraph::BreakParagraphConservative(BufferParams const & bparams, par->text.resize(par->text.size()); } +#else + // create a new paragraph + LyXParagraph * tmp = new LyXParagraph(this); + tmp->MakeSameLayout(this); + + // When can pos > Last()? + // I guess pos == Last() is possible. + if (Last() > pos) { + // copy everything behind the break-position to the new + // paragraph + size_type pos_end = text.size() - 1; + + size_type i, j; + for (i = j = pos; i <= pos_end; ++i) { + CutIntoMinibuffer(bparams, i); + if (tmp->InsertFromMinibuffer(j - pos)) + ++j; + } + + tmp->fitToSize(); + + for (size_type i = pos_end; i >= pos; --i) + Erase(i); + + fitToSize(); + } +#endif } // Be carefull, this does not make any check at all. +// This method has wrong name, it combined this par with the next par. +// In that sense it is the reverse of break paragraph. (Lgb) void LyXParagraph::PasteParagraph(BufferParams const & bparams) { // copy the next paragraph to this one LyXParagraph * the_next = Next(); #ifndef NEW_INSETS LyXParagraph * firstpar = FirstPhysicalPar(); -#else - LyXParagraph * firstpar = this; #endif // first the DTP-stuff +#ifndef NEW_INSETS firstpar->line_bottom = the_next->line_bottom; firstpar->added_space_bottom = the_next->added_space_bottom; firstpar->pagebreak_bottom = the_next->pagebreak_bottom; +#else + line_bottom = the_next->line_bottom; + added_space_bottom = the_next->added_space_bottom; + pagebreak_bottom = the_next->pagebreak_bottom; +#endif size_type pos_end = the_next->text.size() - 1; size_type pos_insert = Last(); @@ -2165,15 +2233,6 @@ LyXParagraph::InsetIterator(LyXParagraph::size_type pos) int LyXParagraph::GetPositionOfInset(Inset * inset) const { // Find the entry. - // We could use lower_bound here too, we just need to add - // the approp. operator() to matchIT (and change the name - // of that struct). Code would then be: - // InsetList::const_iterator cit = lower_bound(insetlist.begin(), - // insetlist.end(), - // inset, matchIT()); - // if ((*cit).inset == inset) { - // return (*cit).pos; - // } for (InsetList::const_iterator cit = insetlist.begin(); cit != insetlist.end(); ++cit) { if ((*cit).inset == inset) { @@ -3705,10 +3764,13 @@ void LyXParagraph::SimpleTeXSpecialChars(Buffer const * buf, LyXParagraph * LyXParagraph::TeXDeeper(Buffer const * buf, BufferParams const & bparams, - ostream & os, TexRow & texrow, - ostream & foot, + ostream & os, TexRow & texrow +#ifndef NEW_INSETS + ,ostream & foot, TexRow & foot_texrow, - int & foot_count) + int & foot_count +#endif + ) { lyxerr[Debug::LATEX] << "TeXDeeper... " << this << endl; LyXParagraph * par = this; @@ -3727,9 +3789,12 @@ LyXParagraph * LyXParagraph::TeXDeeper(Buffer const * buf, par->layout).isEnvironment() || par->pextra_type != PEXTRA_NONE) { par = par->TeXEnvironment(buf, bparams, - os, texrow, - foot, foot_texrow, - foot_count); + os, texrow +#ifndef NEW_INSETS + ,foot, foot_texrow, + foot_count +#endif + ); } else { par = par->TeXOnePar(buf, bparams, os, texrow, false @@ -3749,13 +3814,18 @@ LyXParagraph * LyXParagraph::TeXDeeper(Buffer const * buf, LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, BufferParams const & bparams, - ostream & os, TexRow & texrow, - ostream & foot, + ostream & os, TexRow & texrow +#ifndef NEW_INSETS + ,ostream & foot, TexRow & foot_texrow, - int & foot_count) + int & foot_count +#endif + ) { bool eindent_open = false; +#ifndef NEW_INSETS bool foot_this_level = false; +#endif // flags when footnotetext should be appended to file. static bool minipage_open = false; static int minipage_open_depth = 0; @@ -3933,8 +4003,11 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, os << '\n'; texrow.newline(); } - par = par->TeXDeeper(buf, bparams, os, texrow, - foot, foot_texrow, foot_count); + par = par->TeXDeeper(buf, bparams, os, texrow +#ifndef NEW_INSETS + ,foot, foot_texrow, foot_count +#endif + ); } if (par && par->layout == layout && par->depth == depth && (par->pextra_type == PEXTRA_MINIPAGE) && !minipage_open) { @@ -3998,6 +4071,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, if (style.isEnvironment()) { os << "\\end{" << style.latexname() << '}'; +#ifndef NEW_INSETS // maybe this should go after the minipage closes? if (foot_this_level) { if (foot_count >= 1) { @@ -4013,6 +4087,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, foot_count = 0; } } +#endif } if (minipage_open && (minipage_open_depth == depth) && (!par || par->pextra_start_minipage || @@ -4337,9 +4412,8 @@ void LyXParagraph::SetPExtraType(BufferParams const & bparams, if (textclasslist.Style(bparams.textclass, layout).isEnvironment()) { - LyXParagraph - * par = this, - * ppar = par; + LyXParagraph * par = this; + LyXParagraph * ppar = par; while (par && (par->layout == layout) && (par->depth == depth)) { @@ -4394,9 +4468,8 @@ void LyXParagraph::UnsetPExtraType(BufferParams const & bparams) if (textclasslist.Style(bparams.textclass, layout).isEnvironment()) { - LyXParagraph - * par = this, - * ppar = par; + LyXParagraph * par = this; + LyXParagraph * ppar = par; while (par && (par->layout == layout) && (par->depth == depth)) { @@ -4494,9 +4567,7 @@ bool LyXParagraph::IsLetter(LyXParagraph::size_type pos) const return false; // We want to pass the ' and escape chars to ispell string extra = lyxrc.isp_esc_chars + '\''; - char ch[2]; - ch[0] = c; - ch[1] = 0; + char ch[2] = { c, 0 }; return contains(extra, ch); } diff --git a/src/support/lstrings.C b/src/support/lstrings.C index e0096dda2f..f5908b2eaa 100644 --- a/src/support/lstrings.C +++ b/src/support/lstrings.C @@ -204,8 +204,18 @@ bool prefixIs(string const & a, char const * pre) unsigned int l = strlen(pre); if (l > a.length() || a.empty()) return false; - else + else { +#if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD) + // Delete this code when the compilers get a bit better. + return ::strncmp(a.c_str(), pre, l) == 0; +#else + // This is the code that we really want to use + // but until gcc ships with a basic_string that + // implements std::string correctly we have to + // use the code above. return a.compare(0, l, pre, l) == 0; +#endif + } } @@ -222,7 +232,17 @@ bool suffixIs(string const & a, char const * suf) if (suflen > a.length()) return false; else { +#if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD) + // Delete this code when the compilers get a bit better. + string tmp(a, a.length() - suflen); + return ::strncmp(tmp.c_str(), suf, suflen) == 0; +#else + // This is the code that we really want to use + // but until gcc ships with a basic_string that + // implements std::string correctly we have to + // use the code above. return a.compare(a.length() - suflen, suflen, suf) == 0; +#endif } } diff --git a/src/text.C b/src/text.C index 974e68c841..3008be0676 100644 --- a/src/text.C +++ b/src/text.C @@ -1628,7 +1628,12 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const } /* is it a bottom line? */ - if (row_ptr->par()->ParFromPos(RowLast(row_ptr) + 1) == par + if ( +#ifndef NEW_INSETS + row_ptr->par()->ParFromPos(RowLast(row_ptr) + 1) == par +#else + row_ptr->par() == par +#endif && (!row_ptr->next() || row_ptr->next()->par() != row_ptr->par())) { /* the paper margins */ @@ -1701,7 +1706,7 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const height += row_ptr->height(); float x, dummy; PrepareToPrint(bview, row_ptr, x, dummy, dummy, dummy, false); - row_ptr->width(maxwidth+x); + row_ptr->width(int(maxwidth + x)); if (inset_owner) { Row * r = firstrow; width = max(0,workWidth(bview)); @@ -1859,9 +1864,15 @@ void LyXText::BreakParagraph(BufferView * bview, char keep_layout) layout.labeltype!= LABEL_SENSITIVE) return; - SetUndo(bview->buffer(), Undo::INSERT, + SetUndo(bview->buffer(), Undo::INSERT, +#ifndef NEW_INSETS cursor.par()->ParFromPos(cursor.pos())->previous, - cursor.par()->ParFromPos(cursor.pos())->next); + cursor.par()->ParFromPos(cursor.pos())->next +#else + cursor.par()->previous, + cursor.par()->next +#endif + ); #ifndef NEW_TABULAR /* table stuff -- begin */ @@ -2709,9 +2720,15 @@ void LyXText::RedoParagraph(BufferView * bview) const * same Paragraph one to the right and make a rebreak */ void LyXText::InsertChar(BufferView * bview, char c) { - SetUndo(bview->buffer(), Undo::INSERT, + SetUndo(bview->buffer(), Undo::INSERT, +#ifndef NEW_INSETS cursor.par()->ParFromPos(cursor.pos())->previous, - cursor.par()->ParFromPos(cursor.pos())->next); + cursor.par()->ParFromPos(cursor.pos())->next +#else + cursor.par()->previous, + cursor.par()->next +#endif + ); // When the free-spacing option is set for the current layout, // disable the double-space checking @@ -3432,12 +3449,20 @@ void LyXText::DeleteLineForward(BufferView * bview) // version did. (JMarc) void LyXText::ChangeWordCase(BufferView * bview, LyXText::TextCase action) { +#ifndef NEW_INSETS LyXParagraph * tmppar = cursor.par()->ParFromPos(cursor.pos()); +#else + LyXParagraph * tmppar = cursor.par(); +#endif SetUndo(bview->buffer(),Undo::FINISH, tmppar->previous, tmppar->next); +#ifndef NEW_INSETS LyXParagraph::size_type tmppos = cursor.par()->PositionInParFromPos(cursor.pos()); +#else + LyXParagraph::size_type tmppos = cursor.pos(); +#endif while (tmppos < tmppar->size()) { unsigned char c = tmppar->GetChar(tmppos); if (IsKommaChar(c) || IsLineSeparatorChar(c)) @@ -3493,9 +3518,15 @@ void LyXText::Delete(BufferView * bview) if (old_cursor.par() != cursor.par() || old_cursor.pos() != cursor.pos()) { LyXCursor tmpcursor = cursor; cursor = old_cursor; // to make sure undo gets the right cursor position - SetUndo(bview->buffer(), Undo::DELETE, + SetUndo(bview->buffer(), Undo::DELETE, +#ifndef NEW_INSETS cursor.par()->ParFromPos(cursor.pos())->previous, - cursor.par()->ParFromPos(cursor.pos())->next); + cursor.par()->ParFromPos(cursor.pos())->next +#else + cursor.par()->previous, + cursor.par()->next +#endif + ); cursor = tmpcursor; Backspace(bview); } @@ -3573,12 +3604,20 @@ void LyXText::Backspace(BufferView * bview) return; } } - + +#ifndef NEW_INSETS if (cursor.par()->ParFromPos(cursor.pos())->previous){ SetUndo(bview->buffer(), Undo::DELETE, cursor.par()->ParFromPos(cursor.pos())->previous->previous, cursor.par()->ParFromPos(cursor.pos())->next); } +#else + if (cursor.par()->previous) { + SetUndo(bview->buffer(), Undo::DELETE, + cursor.par()->previous->previous, + cursor.par()->next); + } +#endif LyXParagraph * tmppar = cursor.par(); Row * tmprow = cursor.row(); @@ -3651,9 +3690,15 @@ void LyXText::Backspace(BufferView * bview) } else { /* this is the code for a normal backspace, not pasting * any paragraphs */ - SetUndo(bview->buffer(), Undo::DELETE, + SetUndo(bview->buffer(), Undo::DELETE, +#ifndef NEW_INSETS cursor.par()->ParFromPos(cursor.pos())->previous, - cursor.par()->ParFromPos(cursor.pos())->next); + cursor.par()->ParFromPos(cursor.pos())->next +#else + cursor.par()->previous, + cursor.par()->next +#endif + ); // We used to do CursorLeftIntern() here, but it is // not a good idea since it triggers the auto-delete // mechanism. So we do a CursorLeftIntern()-lite, @@ -4459,8 +4504,13 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, #else LyXParagraph * par = row_ptr->par(); #endif - if ((row_ptr->par()->ParFromPos(last + 1) == par) && - (!row_ptr->next() || (row_ptr->next()->par() != row_ptr->par()))) + if ( +#ifndef NEW_INSETS + (row_ptr->par()->ParFromPos(last + 1) == par) +#else + (row_ptr->par() == par) +#endif + && (!row_ptr->next() || (row_ptr->next()->par() != row_ptr->par()))) { /* think about the margins */ if (!row_ptr->next() && bv_owner) diff --git a/src/text2.C b/src/text2.C index 89a5f8a948..deda64412f 100644 --- a/src/text2.C +++ b/src/text2.C @@ -559,7 +559,11 @@ LyXParagraph * LyXText::SetLayout(BufferView * bview, } SetUndo(bview->buffer(), Undo::EDIT, - sstart_cur.par()->ParFromPos(sstart_cur.pos())->previous, +#ifndef NEW_INSETS + sstart_cur.par()->ParFromPos(sstart_cur.pos())->previous, +#else + sstart_cur.par()->previous, +#endif undoendpar); /* ok we have a selection. This is always between sstart_cur @@ -628,80 +632,6 @@ void LyXText::SetLayout(BufferView * bview, LyXTextClass::size_type layout) { LyXCursor tmpcursor = cursor; /* store the current cursor */ -// #ifdef USE_OLD_SET_LAYOUT -// // if there is no selection just set the layout -// // of the current paragraph */ -// if (!selection) { -// sel_start_cursor = cursor; // dummy selection -// sel_end_cursor = cursor; -// } - -// LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->Next(); -// LyXParagraph * undoendpar = endpar; - -// if (endpar && endpar->GetDepth()) { -// while (endpar && endpar->GetDepth()) { -// endpar = endpar->LastPhysicalPar()->Next(); -// undoendpar = endpar; -// } -// } -// else if (endpar) { -// endpar = endpar->Next(); // because of parindents etc. -// } - -// SetUndo(Undo::EDIT, -// sel_start_cursor.par()->ParFromPos(sel_start_cursor.pos())->previous, -// undoendpar); - -// /* ok we have a selection. This is always between sel_start_cursor -// * and sel_end cursor */ -// cursor = sel_start_cursor; - -// LyXLayout const & lyxlayout = -// textclasslist.Style(bview->buffer()->params.textclass, layout); - -// while (cursor.par() != sel_end_cursor.par()) { -// if (cursor.par()->footnoteflag == -// sel_start_cursor.par()->footnoteflag) { -// cursor.par()->SetLayout(layout); -// MakeFontEntriesLayoutSpecific(cursor.par()); -// LyXParagraph* fppar = cursor.par()->FirstPhysicalPar(); -// fppar->added_space_top = lyxlayout.fill_top ? -// VSpace(VSpace::VFILL) : VSpace(VSpace::NONE); -// fppar->added_space_bottom = lyxlayout.fill_bottom ? -// VSpace(VSpace::VFILL) : VSpace(VSpace::NONE); -// if (lyxlayout.margintype == MARGIN_MANUAL) -// cursor.par()->SetLabelWidthString(lyxlayout.labelstring()); -// if (lyxlayout.labeltype != LABEL_BIBLIO -// && fppar->bibkey) { -// delete fppar->bibkey; -// fppar->bibkey = 0; -// } -// } -// cursor.par() = cursor.par()->Next(); -// } -// if (cursor.par()->footnoteflag == -// sel_start_cursor.par()->footnoteflag) { -// cursor.par()->SetLayout(layout); -// MakeFontEntriesLayoutSpecific(cursor.par()); -// #ifndef NEW_INSETS -// LyXParagraph* fppar = cursor.par()->FirstPhysicalPar(); -// #else -// LyXParagraph* fppar = cursor.par(); -// #endif -// fppar->added_space_top = lyxlayout.fill_top ? -// VSpace(VSpace::VFILL) : VSpace(VSpace::NONE); -// fppar->added_space_bottom = lyxlayout.fill_bottom ? -// VSpace(VSpace::VFILL) : VSpace(VSpace::NONE); -// if (lyxlayout.margintype == MARGIN_MANUAL) -// cursor.par()->SetLabelWidthString(lyxlayout.labelstring()); -// if (lyxlayout.labeltype != LABEL_BIBLIO -// && fppar->bibkey) { -// delete fppar->bibkey; -// fppar->bibkey = 0; -// } -// } -// #else // if there is no selection just set the layout // of the current paragraph */ if (!selection) { @@ -711,7 +641,6 @@ void LyXText::SetLayout(BufferView * bview, LyXTextClass::size_type layout) LyXParagraph * endpar = SetLayout(bview, cursor, sel_start_cursor, sel_end_cursor, layout); -//#endif RedoParagraphs(bview, sel_start_cursor, endpar); // we have to reset the selection, because the @@ -761,9 +690,13 @@ void LyXText::IncDepth(BufferView * bview) endpar = endpar->Next(); // because of parindents etc. } - SetUndo(bview->buffer(), Undo::EDIT, + SetUndo(bview->buffer(), Undo::EDIT, +#ifndef NEW_INSETS sel_start_cursor - .par()->ParFromPos(sel_start_cursor.pos())->previous, + .par()->ParFromPos(sel_start_cursor.pos())->previous, +#else + sel_start_cursor.par()->previous, +#endif undoendpar); LyXCursor tmpcursor = cursor; // store the current cursor @@ -873,9 +806,13 @@ void LyXText::DecDepth(BufferView * bview) endpar = endpar->Next(); // because of parindents etc. } - SetUndo(bview->buffer(), Undo::EDIT, + SetUndo(bview->buffer(), Undo::EDIT, +#ifndef NEW_INSETS sel_start_cursor - .par()->ParFromPos(sel_start_cursor.pos())->previous, + .par()->ParFromPos(sel_start_cursor.pos())->previous, +#else + sel_start_cursor.par()->previous, +#endif undoendpar); LyXCursor tmpcursor = cursor; // store the current cursor @@ -945,9 +882,15 @@ void LyXText::SetFont(BufferView * bview, LyXFont const & font, bool toggleall) // ok we have a selection. This is always between sel_start_cursor // and sel_end cursor - SetUndo(bview->buffer(), Undo::EDIT, + SetUndo(bview->buffer(), Undo::EDIT, +#ifndef NEW_INSETS sel_start_cursor.par()->ParFromPos(sel_start_cursor.pos())->previous, - sel_end_cursor.par()->ParFromPos(sel_end_cursor.pos())->next); + sel_end_cursor.par()->ParFromPos(sel_end_cursor.pos())->next +#else + sel_start_cursor.par()->previous, + sel_end_cursor.par()->next +#endif + ); cursor = sel_start_cursor; while (cursor.par() != sel_end_cursor.par() || ( @@ -1520,9 +1463,13 @@ void LyXText::SetParagraph(BufferView * bview, endpar = endpar->Next(); // because of parindents etc. } - SetUndo(bview->buffer(), Undo::EDIT, + SetUndo(bview->buffer(), Undo::EDIT, +#ifndef NEW_INSETS sel_start_cursor - .par()->ParFromPos(sel_start_cursor.pos())->previous, + .par()->ParFromPos(sel_start_cursor.pos())->previous, +#else + sel_start_cursor.par()->previous, +#endif undoendpar); @@ -1619,9 +1566,13 @@ void LyXText::SetParagraphExtraOpt(BufferView * bview, int type, endpar = endpar->Next(); // because of parindents etc. } - SetUndo(bview->buffer(), Undo::EDIT, + SetUndo(bview->buffer(), Undo::EDIT, +#ifndef NEW_INSETS sel_start_cursor - .par()->ParFromPos(sel_start_cursor.pos())->previous, + .par()->ParFromPos(sel_start_cursor.pos())->previous, +#else + sel_start_cursor.par()->previous, +#endif undoendpar); tmppar = sel_end_cursor.par(); @@ -2203,9 +2154,15 @@ void LyXText::InsertInset(BufferView * bview, Inset * inset) { if (!cursor.par()->InsertInsetAllowed(inset)) return; - SetUndo(bview->buffer(), Undo::INSERT, + SetUndo(bview->buffer(), Undo::INSERT, +#ifndef NEW_INSETS cursor.par()->ParFromPos(cursor.pos())->previous, - cursor.par()->ParFromPos(cursor.pos())->next); + cursor.par()->ParFromPos(cursor.pos())->next +#else + cursor.par()->previous, + cursor.par()->next +#endif + ); cursor.par()->InsertInset(cursor.pos(), inset); InsertChar(bview, LyXParagraph::META_INSET); /* just to rebreak and refresh correctly. * The character will not be inserted a @@ -2293,16 +2250,26 @@ void LyXText::CutSelection(BufferView * bview, bool doclear) endpar = endpar->Next(); // because of parindents etc. } - SetUndo(bview->buffer(), Undo::DELETE, sel_start_cursor + SetUndo(bview->buffer(), Undo::DELETE, +#ifndef NEW_INSETS + sel_start_cursor .par()->ParFromPos(sel_start_cursor.pos())->previous, +#else + sel_start_cursor.par()->previous, +#endif undoendpar); CutAndPaste cap; // there are two cases: cut only within one paragraph or // more than one paragraph +#ifndef NEW_INSETS if (sel_start_cursor.par()->ParFromPos(sel_start_cursor.pos()) - == sel_end_cursor.par()->ParFromPos(sel_end_cursor.pos())) { + == sel_end_cursor.par()->ParFromPos(sel_end_cursor.pos())) +#else + if (sel_start_cursor.par() == sel_end_cursor.par()) +#endif + { // only within one paragraph endpar = sel_start_cursor.par(); int pos = sel_end_cursor.pos(); @@ -2411,9 +2378,15 @@ void LyXText::PasteSelection(BufferView * bview) if (!cap.checkPastePossible(cursor.par(), cursor.pos())) return; - SetUndo(bview->buffer(), Undo::INSERT, + SetUndo(bview->buffer(), Undo::INSERT, +#ifndef NEW_INSETS cursor.par()->ParFromPos(cursor.pos())->previous, - cursor.par()->ParFromPos(cursor.pos())->next); + cursor.par()->ParFromPos(cursor.pos())->next +#else + cursor.par()->previous, + cursor.par()->next +#endif + ); LyXParagraph * endpar; LyXParagraph * actpar = cursor.par(); @@ -2899,13 +2872,13 @@ void LyXText::SetCursor(BufferView * bview, LyXParagraph * par, void LyXText::SetCursor(BufferView *bview, LyXCursor & cur, LyXParagraph * par, LyXParagraph::size_type pos, bool boundary) const { +#ifndef NEW_INSETS // correct the cursor position if impossible if (pos > par->Last()){ LyXParagraph * tmppar = par->ParFromPos(pos); pos = par->PositionInParFromPos(pos); par = tmppar; } -#ifndef NEW_INSETS if (par->IsDummy() && par->previous && par->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) { while (par->previous && @@ -3758,9 +3731,14 @@ Undo * LyXText::CreateUndo(Buffer * buf, Undo::undo_kind kind, tmppar2->next = 0; } else undopar = 0; // nothing to replace (undo of delete maybe) - + +#ifndef NEW_INSETS int cursor_par = cursor.par()->ParFromPos(cursor.pos())->id(); int cursor_pos = cursor.par()->PositionInParFromPos(cursor.pos()); +#else + int cursor_par = cursor.par()->id(); + int cursor_pos = cursor.pos(); +#endif Undo * undo = new Undo(kind, before_number, behind_number, @@ -3776,9 +3754,15 @@ void LyXText::SetCursorParUndo(Buffer * buf) { if (inset_owner) return; - SetUndo(buf, Undo::FINISH, + SetUndo(buf, Undo::FINISH, +#ifndef NEW_INSETS cursor.par()->ParFromPos(cursor.pos())->previous, - cursor.par()->ParFromPos(cursor.pos())->next); + cursor.par()->ParFromPos(cursor.pos())->next +#else + cursor.par()->previous, + cursor.par()->next +#endif + ); } -- 2.39.5