]> git.lyx.org Git - features.git/commitdiff
fix insertion of raw double quote, reading of Info inset, initial width of collapsed...
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 23 Jul 2001 09:11:14 +0000 (09:11 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 23 Jul 2001 09:11:14 +0000 (09:11 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2300 a592a061-630c-0410-9148-cb99ea01b6c8

38 files changed:
lib/ChangeLog
lib/bind/cua.bind
lib/bind/emacs.bind
lib/bind/sciword.bind
lib/bind/xemacs.bind
lib/ui/default.ui
src/BufferView.h
src/BufferView2.C
src/BufferView_pimpl.C
src/BufferView_pimpl.h
src/ChangeLog
src/MenuBackend.C
src/ToolbarDefaults.C
src/buffer.C
src/buffer.h
src/insets/ChangeLog
src/insets/inset.h
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/insetert.C
src/insets/insetert.h
src/insets/insetfootlike.C
src/insets/insetindex.C
src/insets/insetindex.h
src/insets/insetnote.C
src/insets/insetnote.h
src/insets/insetquotes.C
src/insets/insetspecialchar.C
src/insets/insetspecialchar.h
src/lyxfunc.C
src/lyxrc.C
src/lyxtext.h
src/mathed/ChangeLog
src/mathed/formula.C
src/mathed/formula.h
src/text.C
src/text2.C
src/trans_mgr.C

index b5cbc9bc64c2dd6b96fdf0885ce377283b466cf5..adc2ec4d6015b02bcdc300f5ba842877f19ecf4a 100644 (file)
@@ -1,3 +1,10 @@
+2001-07-22  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * ui/default.ui: 
+       * bind/cua.bind: 
+       * bind/emacs.bind: 
+       * bind/xemacs.bind: fix binding for raw double quote
+
 2001-07-22  José Matos  <jamatos@fep.up.pt>
 
        * reLyX/MakePreamble.pm (translate_preamble): add lots of options
index a25f28128b481509f17e3f4c47cbbc48b308aa27..8efd91810c4aa6cc7faf0b35b0ebb286f2d4f1bf 100644 (file)
@@ -67,7 +67,7 @@
 \bind "C-z"                    "undo"
 \bind "C-S-Z"                  "redo"
 
-\bind "S-C-quotedbl"           "quote-insert"
+\bind "~S-C-quotedbl"          "self-insert \""
 \bind "C-minus"                        "hyphenation-point-insert"
 \bind "M-S-Right"              "depth-increment"
 \bind "M-S-Left"               "depth-decrement"
index 2156723b903221ef0432483726ff3c21003c1899..5fc5be1554d53f37bc9a3d270f4facaadc464e2d 100644 (file)
@@ -42,7 +42,7 @@
 \bind "C-p"                    "up"
 
 # this is "quoted-insert" a total different meaning from "quote-insert"
-\bind "C-q"                    "quote-insert"
+\bind "C-q"                    "self-insert \""
 #bind "C-r"                    "------"
 \bind "C-s"                    "find-replace"
 \bind "M-~S-percent"           "find-replace"
@@ -66,7 +66,7 @@
 \bind "C-~S-slash"             "undo"
 \bind "C-~S-underscore"        "undo"
 
-\bind "S-C-quotedbl"           "quote-insert"
+\bind "~S-C-quotedbl"           "self-insert \""
 
 \bind "C-x a"                  "buffer-auto-save"
 #\bind "C-x b"                 "buffer-previous"
index e8314db6aa1c10e62360739287fd8daa982cab88..bbfb95e6a71736b4015f65788752a654d9391252 100644 (file)
@@ -45,7 +45,8 @@
 \bind "C-o"    "inset-toggle"
 
 # Insert a quote character. Do I need this?
-\bind "C-q"    "quote-insert"
+# Probably, since we need a way to get a raw quote
+\bind "C-q"    "self-insert \""
 
 # Sciword mnemonic.
 \bind "C-r"    "math-insert sqrt"
index 4a0a79cf49e6237151f73f8f2072b6e58b27253f..c1714331f6846b420e1952491b61d8b96c7505de 100644 (file)
@@ -43,7 +43,7 @@
 \bind "C-p"                    "up"
 
 # this is "quoted-insert" a total different meaning from "quote-insert"
-\bind "C-q"                    "quote-insert"
+\bind "C-q"                    "self-insert \""
 #bind "C-r"                    "------"
 \bind "C-s"                    "find-replace"
 \bind "M-~S-percent"           "find-replace"
@@ -69,7 +69,7 @@
 \bind "C-~S-slash"             "undo"
 \bind "C-~S-underscore"        "undo"
 
-\bind "S-C-quotedbl"           "quote-insert"
+\bind "~S-C-quotedbl"           "self-insert \""
 
 \bind "C-x a"                  "buffer-auto-save"
 # not currently supported
index 7a3e752a71bc7b00ec351349a6b5317e8a6033c1..08feb4807ade04920f7b44bb5ccd4c4f49173c0a 100644 (file)
@@ -222,7 +222,7 @@ Menuset
        Item "Linebreak|L" "break-line"
        Item "Ellipsis|i" "dots-insert"
        Item "End of Sentence|E" "end-of-sentence-period-insert"
-       Item "Ordinary Quote|Q" "quote-insert"
+       Item "Ordinary Quote|Q" "self-insert \""
        Item "Menu Separator|M" "menu-separator-insert"
     End
 
index 6a783e7c231b8f3d73e7bbc86c1ba1de9c2bf4f3..548306dbac80fb9af1fb991ec66b5ab2189f6fd9 100644 (file)
@@ -133,8 +133,6 @@ public:
        ///
        string const nextWord(float & value);
        ///
-       void insertCorrectQuote();
-       ///
        bool gotoLabel(string const & label);
        ///
        void paste();
index 2da94d1b357068697583874a94bd02cf73de28ef..6af288a3ab11ee1cdadb3942c325425156011991 100644 (file)
@@ -329,21 +329,6 @@ void BufferView::paste()
 }
 
 
-
-
-void BufferView::insertCorrectQuote()
-{
-       char c;
-
-       if (text->cursor.pos())
-               c = text->cursor.par()->getChar(text->cursor.pos() - 1);
-       else 
-               c = ' ';
-
-       insertInset(new InsetQuotes(c, buffer()->params));
-}
-
-
 /* these functions are for the spellchecker */ 
 string const BufferView::nextWord(float & value)
 {
index d0fc903f9ead00da7747b42a45dd0f552d8f60e4..5e1e36fce278639512a2030975132da000ac23dc 100644 (file)
@@ -2660,7 +2660,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                break;
 
        case LFUN_QUOTE:
-               bv_->insertCorrectQuote();
+               smartQuote();
                break;
 
        case LFUN_HTMLURL:
@@ -2671,99 +2671,60 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                        p.setCmdName("htmlurl");
                else
                        p.setCmdName("url");
-               owner_->getDialogs()->createUrl( p.getAsString() );
+               owner_->getDialogs()->createUrl(p.getAsString());
        }
        break;
        
        case LFUN_INSERT_URL:
        {
                InsetCommandParams p;
-               p.setFromString( argument );
+               p.setFromString(argument);
 
-               InsetUrl * inset = new InsetUrl( p );
+               InsetUrl * inset = new InsetUrl(p);
                if (!insertInset(inset))
                        delete inset;
                else
-                       updateInset( inset, true );
+                       updateInset(inset, true);
        }
        break;
        
        case LFUN_INSET_TEXT:
-       {
-               InsetText * new_inset = new InsetText;
-               if (insertInset(new_inset))
-                       new_inset->edit(bv_);
-               else
-                       delete new_inset;
-       }
-       break;
+               insertAndEditInset(new InsetText);
+               break;
        
        case LFUN_INSET_ERT:
-       {
-               InsetERT * new_inset = new InsetERT;
-               if (insertInset(new_inset))
-                       new_inset->edit(bv_);
-               else
-                       delete new_inset;
-       }
-       break;
+               insertAndEditInset(new InsetERT);
+               break;
        
        case LFUN_INSET_EXTERNAL:
-       {
-               InsetExternal * new_inset = new InsetExternal;
-               if (insertInset(new_inset))
-                       new_inset->edit(bv_);
-               else
-                       delete new_inset;
-       }
-       break;
+               insertAndEditInset(new InsetExternal);
+               break;
        
        case LFUN_INSET_FOOTNOTE:
-       {
-               InsetFoot * new_inset = new InsetFoot;
-               if (insertInset(new_inset))
-                       new_inset->edit(bv_);
-               else
-                       delete new_inset;
-       }
-       break;
+               insertAndEditInset(new InsetFoot);
+               break;
 
        case LFUN_INSET_MARGINAL:
-       {
-               InsetMarginal * new_inset = new InsetMarginal;
-               if (insertInset(new_inset))
-                       new_inset->edit(bv_);
-               else
-                       delete new_inset;
-       }
-       break;
+               insertAndEditInset(new InsetMarginal);
+               break;
 
        case LFUN_INSET_MINIPAGE:
-       {
-               InsetMinipage * new_inset = new InsetMinipage;
-               if (insertInset(new_inset))
-                       new_inset->edit(bv_);
-               else
-                       delete new_inset;
-       }
-       break;
+               insertAndEditInset(new InsetMinipage);
+               break;
+
+       case LFUN_INSERT_NOTE:
+               insertAndEditInset(new InsetNote);
+               break;
 
        case LFUN_INSET_FLOAT:
-       {
                // check if the float type exist
                if (floatList.typeExist(argument)) {
-                       InsetFloat * new_inset = new InsetFloat(argument);
-                       if (insertInset(new_inset))
-                               new_inset->edit(bv_);
-                       else
-                               delete new_inset;
+                       insertAndEditInset(new InsetFloat(argument));
                } else {
                        lyxerr << "Non-existant float type: "
                               << argument << endl;
                }
-               
-       }
-       break;
+               break;
 
        case LFUN_INSET_WIDE_FLOAT:
        {
@@ -2784,24 +2745,12 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        break;
 
        case LFUN_INSET_LIST:
-       {
-               InsetList * new_inset = new InsetList;
-               if (insertInset(new_inset))
-                       new_inset->edit(bv_);
-               else
-                       delete new_inset;
-       }
-       break;
+               insertAndEditInset(new InsetList);
+               break;
 
        case LFUN_INSET_THEOREM:
-       {
-               InsetTheorem * new_inset = new InsetTheorem;
-               if (insertInset(new_inset))
-                       new_inset->edit(bv_);
-               else
-                       delete new_inset;
-       }
-       break;
+               insertAndEditInset(new InsetTheorem);
+               break;
 
        case LFUN_INSET_CAPTION:
        {
@@ -3119,10 +3068,6 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        }
        break;
        
-       case LFUN_INSERT_NOTE:
-               insertNote();
-               break;
-
        case LFUN_SELFINSERT:
        {
                if (argument.empty()) break;
@@ -3145,7 +3090,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                        }
                }
                
-               bv_->beforeChange(lt);
+               beforeChange(lt);
                LyXFont const old_font(lt->real_current_font);
                
                string::const_iterator cit = argument.begin();
@@ -3284,14 +3229,31 @@ void BufferView::Pimpl::specialChar(InsetSpecialChar::Kind kind)
 }
 
 
-void BufferView::Pimpl::insertNote()
+void BufferView::Pimpl::smartQuote()
 {
-       Inset * inset = new InsetNote;
-       insertInset(inset);
-       inset->edit(bv_);
+       char c;
+       LyXText * lt = bv_->getLyXText();
+
+       if (lt->cursor.pos())
+               c = lt->cursor.par()->getChar(lt->cursor.pos() - 1);
+       else 
+               c = ' ';
+
+       hideCursor();
+       if (!insertInset(new InsetQuotes(c, bv_->buffer()->params)))
+               Dispatch(LFUN_SELFINSERT, "\"");
 }
 
 
+void BufferView::Pimpl::insertAndEditInset(Inset * inset)
+{
+       if (insertInset(inset))
+               inset->edit(bv_);
+       else
+               delete inset;
+}
+
 // Open and lock an updatable inset
 bool BufferView::Pimpl::open_new_inset(UpdatableInset * new_inset, bool behind)
 {
index f4b9162a10079f503fd58432c861b7486e43fa9b..d5c9bb86e44181268693c312566e54f906647f7b 100644 (file)
@@ -139,7 +139,9 @@ private:
        ///
        void hfill();
        ///
-       void insertNote();
+       void smartQuote();
+       ///
+       void insertAndEditInset(Inset *);
        ///
        void gotoInset(std::vector<Inset::Code> const & codes,
                       bool same_content);
index 147d69111066241cb4f2950660dc4862f7d5ccc0..9a0aa0fb80f3f48a87cd8bdc5e539a04084a2eea 100644 (file)
@@ -1,3 +1,38 @@
+2001-07-22  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * ToolbarDefaults.C (read): 
+       * MenuBackend.C (read): allow escaping in all strings
+
+       * BufferView_pimpl.C (insertAndEditInset): new method.
+       (Dispatch): use insertAndEditInset whenever appropriate.
+
+       * BufferView_pimpl.C (insertNote): removed
+
+       * BufferView_pimpl.C (smartQuote): new method, moved from
+       BufferView; if an insetquote cannot be inserted, insert a '"'
+       character instead.
+
+       * BufferView2.C: remove insertCorrectQuote();
+
+       * lyxfunc.C (getStatus): Add support for all remaingin
+       inset-insert lfuns.
+
+       * trans_mgr.C (insertVerbatim): do not treat '"' specially.
+
+       * lyxrc.C (read): in RC_BIND, allow escaped sequences in the
+       command (necessary to pass " as parameter of self-insert.
+
+       * text.C (selectWordWhenUnderCursor):
+       (selectWord): add word_location parameter
+       (selectWordWhenUnderCursor): same + remove special code for word
+       boundary.
+       (selectNextWord): use kind() to guess type of insetspecialchar,
+       not latex().
+       
+       * buffer.C (insertStringAsLines): new method, extracted from LyXText.
+       (insertErtContents): create ert insets as collapsed.
+       (readInset): better compatibility code for Info inset.
+
 2001-07-20  Juergen Vigna  <jug@sad.it>
 
        * lyxfunc.C (dispatch): use always LyXFind now!
index 166c0076bf5d441e1ce7145ea7685708d69a573e..98f15391751897a431146c7f011da9dcbf444bf2 100644 (file)
@@ -135,9 +135,9 @@ Menu & Menu::read(LyXLex & lex)
                        optional = true;
                        // fallback to md_item
                case md_item: {
-                       lex.next();
+                       lex.next(true);
                        string const name = _(lex.GetString());
-                       lex.next();
+                       lex.next(true);
                        string const command = lex.GetString();
                        add(MenuItem(MenuItem::Command, name, 
                                     command, optional));
@@ -186,9 +186,9 @@ Menu & Menu::read(LyXLex & lex)
                        break;
                        
                case md_submenu: {
-                       lex.next();
+                       lex.next(true);
                        string mlabel = _(lex.GetString());
-                       lex.next();
+                       lex.next(true);
                        string mname = lex.GetString();
                        add(MenuItem(MenuItem::Submenu, mlabel, mname));
                        break;
@@ -438,7 +438,7 @@ void MenuBackend::read(LyXLex & lex)
                        menubar = true;
                        // fallback to md_menu
                case md_menu: {
-                       lex.next();
+                       lex.next(true);
                        string name = lex.GetString();
                        if (hasMenu(name)) {
                                if (getMenu(name).menubar() == menubar) {
index a51b9ff984daf43b4642ec5981a11148ec181154..390dabb43cbf66ead2fbed8fbc7f0e30b7c16f2f 100644 (file)
@@ -114,7 +114,7 @@ void ToolbarDefaults::read(LyXLex & lex)
        while (lex.IsOK() && !quit) {
                switch (lex.lex()) {
                case TO_ADD:
-                       if (lex.next()) {
+                       if (lex.next(true)) {
                                func = lex.GetString();
                                lyxerr[Debug::PARSER]
                                        << "Toolbar::read TO_ADD func: `"
index cc41db67b76ff59d9fb66c7c1d8af32d4fd3870d..da8410f78d52b028c6f56301604409154a761d54 100644 (file)
@@ -79,6 +79,7 @@
 #include "insets/insettheorem.h"
 #include "insets/insetcaption.h"
 #include "insets/insetfloatlist.h"
+#include "support/textutils.h"
 #include "support/filetools.h"
 #include "support/path.h"
 #include "support/os.h"
@@ -388,7 +389,7 @@ void Buffer::insertErtContents(Paragraph * par, int & pos,
        if (!ert_comp.contents.empty()) {
                lyxerr[Debug::INSETS] << "ERT contents:\n"
                       << ert_comp.contents << endl;
-               Inset * inset = new InsetERT(ert_comp.contents);
+               Inset * inset = new InsetERT(ert_comp.contents, true);
                par->insertInset(pos++, inset, font);
                ert_comp.contents.erase();
        }
@@ -1314,6 +1315,59 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
        return the_end_read;
 }
 
+// needed to insert the selection
+void Buffer::insertStringAsLines(Paragraph *& par, Paragraph::size_type & pos,
+                                LyXFont const & font, 
+                                string const & str) const
+{
+       LyXLayout const & layout = textclasslist.Style(params.textclass, 
+                                                    par->getLayout());
+       // insert the string, don't insert doublespace
+       bool space_inserted = true;
+       for(string::const_iterator cit = str.begin(); 
+           cit != str.end(); ++cit) {
+               if (*cit == '\n') {
+                       if (par->size() || layout.keepempty) { 
+                               par->breakParagraph(params, pos, 
+                                                   layout.isEnvironment());
+                               par = par->next();
+                               pos = 0;
+                               space_inserted = true;
+                       } else {
+                               continue;
+                       }
+                       // do not insert consecutive spaces if !free_spacing
+               } else if ((*cit == ' ' || *cit == '\t')
+                          && space_inserted && !layout.free_spacing) {
+                       continue;
+               } else if (*cit == '\t') {
+                       if (!layout.free_spacing) {
+                               // tabs are like spaces here
+                               par->insertChar(pos, ' ', font);
+                               ++pos;
+                               space_inserted = true;
+                       } else {
+                               const Paragraph::value_type nb = 8 - pos % 8;
+                               for (Paragraph::size_type a = 0; 
+                                    a < nb ; ++a) {
+                                       par->insertChar(pos, ' ', font);
+                                       ++pos;
+                               }
+                               space_inserted = true;
+                       }
+               } else if (!IsPrintable(*cit)) {
+                       // Ignore unprintables
+                       continue;
+               } else {
+                       // just insert the character
+                       par->insertChar(pos, *cit, font);
+                       ++pos;
+                       space_inserted = (*cit == ' ');
+               }
+
+       }       
+}
+
 
 void Buffer::readInset(LyXLex & lex, Paragraph *& par,
                       int & pos, LyXFont & font)
@@ -1378,6 +1432,7 @@ void Buffer::readInset(LyXLex & lex, Paragraph *& par,
                        inset = new InsetParent(inscmd, *this);
                }
        } else {
+               bool alreadyread = false;
                if (tmptok == "Quotes") {
                        inset = new InsetQuotes;
                } else if (tmptok == "External") {
@@ -1388,8 +1443,12 @@ void Buffer::readInset(LyXLex & lex, Paragraph *& par,
                        inset = new InsetFormula;
                } else if (tmptok == "Figure") {
                        inset = new InsetFig(100, 100, *this);
-               } else if (tmptok == "Info" // backwards compatibility
-                          || tmptok == "Note") {
+               } else if (tmptok == "Info") {// backwards compatibility
+                       inset = new InsetNote(this,
+                                             lex.getLongString("\\end_inset"),
+                                             true);
+                       alreadyread = true;
+               } else if (tmptok == "Note") {
                        inset = new InsetNote;
                } else if (tmptok == "Include") {
                        InsetCommandParams p( "Include" );
@@ -1422,7 +1481,7 @@ void Buffer::readInset(LyXLex & lex, Paragraph *& par,
                        inset = new InsetFloatList;
                }
                
-               if (inset) inset->read(this, lex);
+               if (inset && !alreadyread) inset->read(this, lex);
        }
        
        if (inset) {
index dedb17f273e22aae87cb9c14ff921af56a322edf..94b5297b8191705b59010d7f710efb5ca892d789 100644 (file)
@@ -125,6 +125,9 @@ public:
                                        Paragraph::depth_type & depth, 
                                        LyXFont &);
        ///
+       void insertStringAsLines(Paragraph *&, Paragraph::size_type &,
+                                LyXFont const &, string const &) const;
+       ///
        void insertErtContents(Paragraph * par, int & pos,
                               LyXFont const & font,
                               bool set_inactive = true);
index 06f058404b5da631a57f77da1d76efbd407ecd22..8f3241584074b82519fc93462b4940fbba14d98e 100644 (file)
@@ -1,3 +1,34 @@
+2001-07-22  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * insetcollapsable.h: make WidthCollapsed mutable.
+
+       * insetindex.C (lyxCode): InsetIndex returns INDEX_CODE,
+       InsetPrintIndex returns INDEX_PRINT_CODE.
+
+       * inset.h: add INDEX_PRINT_CODE
+
+       * insetcollapsable.C (draw): init widthCollapsed if necessary
+       (width): ditto.
+
+       * insetquotes.C (width): use the local language, not the document
+       language.
+       (draw): ditto.
+       (dispString): add additional spacing for all french languages,
+       like fr_CA.
+       (validate): make it work when there is no default language
+
+       * insetspecialchar.h: rename kind to kind_; add kind() accessor.
+
+       * insetnote.C (init): new method, called by the constructors
+       (InsetNote): new constructor with contents passed as a string
+
+2001-07-21  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * insetfootlike.C (insetAllowed): disallow float in footlike.
+
+       * insetert.C (InsetERT): add collapsed argument to the constrctor
+       with contents.
+
 2001-07-20  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * insetindex.h: shut off warning
index b095fab7e64a7ea53e13c92cd2da4b335d7fd219..c309e60a531920097aa39104cb3f69353b0d46c2 100644 (file)
@@ -106,7 +106,9 @@ public:
                ///
                CITE_CODE,
                ///
-               FLOAT_LIST_CODE
+               FLOAT_LIST_CODE,
+               ///
+               INDEX_PRINT_CODE
        };
 
        ///
index b99efbb55cb38cd6290c2e0db28e4aa019442bde..5d6739fbcf57fda2ed5940257b093a3b7d0135f5 100644 (file)
@@ -32,20 +32,18 @@ using std::endl;
 using std::max;
 
 
-InsetCollapsable::InsetCollapsable()
-       : UpdatableInset()
+InsetCollapsable::InsetCollapsable(bool collapsed)
+       : UpdatableInset(), collapsed_(collapsed), 
+       button_length(0), button_top_y(0), button_bottom_y(0),
+       label("Label"), autocollapse(true), 
+       widthCollapsed(0), oldWidth(0), need_update(FULL)
+
 {
        inset.setOwner(this);
-       collapsed_ = false;
-       label = "Label";
-       autocollapse = true;
        inset.setAutoBreakRows(true);
        inset.setDrawFrame(0, InsetText::ALWAYS);
        inset.setFrameColor(0, LColor::collapsableframe);
-       button_length = button_top_y = button_bottom_y = 0;
        setInsetName("Collapsable");
-       widthCollapsed = oldWidth = 0;
-       need_update = FULL;
 }
 
 
@@ -138,6 +136,9 @@ int InsetCollapsable::descent(BufferView * bv, LyXFont const & font) const
 
 int InsetCollapsable::width(BufferView * bv, LyXFont const & font) const
 {
+       if (!widthCollapsed)
+               widthCollapsed = width_collapsed(bv->painter(), font);
+
        if (collapsed_) 
                return widthCollapsed;
 
@@ -164,6 +165,9 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
 
        Painter & pain = bv->painter();
 
+       if (!widthCollapsed)
+               widthCollapsed = width_collapsed(pain, f);
+
        button_length = widthCollapsed;
        button_top_y = -ascent(bv, f);
        button_bottom_y = -ascent(bv, f) + ascent_collapsed(pain,f) +
index e672030953e266d19271e696aed98c4c80c68dee..05dfb96f48d7ba2018995de909d79b5b7dcf8eac 100644 (file)
@@ -27,7 +27,7 @@ class LyXText;
 class Paragraph;
 class LyXCursor;
 
-/** A colapsable text inset
+/** A collapsable text inset
   
 */
 class InsetCollapsable : public UpdatableInset {
@@ -41,8 +41,8 @@ public:
        static int const TEXT_TO_TOP_OFFSET = 2;
        ///
        static int const TEXT_TO_BOTTOM_OFFSET = 2;
-       ///
-       InsetCollapsable();
+       /// inset is initially collapsed if bool = true
+       InsetCollapsable(bool = false);
        ///
        void read(Buffer const *, LyXLex &);
        ///
@@ -219,7 +219,7 @@ private:
        ///
        bool autocollapse;
        ///
-       int widthCollapsed;
+       mutable int widthCollapsed;
        ///
        mutable int oldWidth;
        ///
index d6c4542ae0452e952dd275672fab216bc850d5be..14bdf5e3f7a9a370b953df4e3e81e6056ca76834 100644 (file)
@@ -37,7 +37,8 @@ InsetERT::InsetERT() : InsetCollapsable()
 }
 
 
-InsetERT::InsetERT(string const & contents)
+InsetERT::InsetERT(string const & contents, bool collapsed)
+       : InsetCollapsable(collapsed)
 {
        setLabel(_("666"));
        LyXFont font(LyXFont::ALL_SANE);
index 9533e8eee03841eec25c2dcbdced13b678206937..f6a0ebde9dddf787521fa951ac496cce7985b67a 100644 (file)
@@ -30,7 +30,7 @@ public:
        ///
        InsetERT();
        ///
-       InsetERT(string const & contents);
+       InsetERT(string const & contents, bool collapsed);
        ///
        virtual void write(Buffer const * buf, std::ostream & os) const;
        ///
index 75dd3ad5816a80593c1d1ecda4f33a5515bd2541..e58ae00e72f8661edf52e04988e3171e4e48af43 100644 (file)
@@ -42,7 +42,8 @@ void InsetFootlike::write(Buffer const * buf, std::ostream & os) const
 
 bool InsetFootlike::insetAllowed(Inset::Code code) const
 {
-       if ((code == Inset::FOOT_CODE) || (code == Inset::MARGIN_CODE))
+       if ((code == Inset::FOOT_CODE) || (code == Inset::MARGIN_CODE)
+           || (code ==Inset::FLOAT_CODE))
                return false;
        return InsetCollapsable::insetAllowed(code);
 }
index eccde8d07c1c9bf1f8e6549dfdfa0a6e7ab4dbc5..87b3cfaa19570aa5152d1e862fe2f20e6680dee8 100644 (file)
@@ -34,6 +34,12 @@ void InsetIndex::edit(BufferView * bv, bool)
 }
 
 
+Inset::Code InsetIndex::lyxCode() const
+{
+       return Inset::INDEX_CODE;
+}
+
+
 InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p, bool)
        : InsetCommand(p)
 {}
@@ -52,5 +58,5 @@ void InsetPrintIndex::validate(LaTeXFeatures & features) const
 
 Inset::Code InsetPrintIndex::lyxCode() const
 {
-       return Inset::INDEX_CODE;
+       return Inset::INDEX_PRINT_CODE;
 }
index 0479937a8ec4aa3ca7b8efe9f3a8cd276486de2e..051d78cd3f7d8f4cc2230d236d8d99768d9a0339 100644 (file)
@@ -38,6 +38,8 @@ public:
        void edit(BufferView *, int, int, unsigned int);
        ///
        void edit(BufferView * bv, bool front = true);
+       ///
+       Inset::Code lyxCode() const;
 };
 
 
index 4463747b7d2814dcdd9768a2203311f5f2dbce0f..89ac827f58894c444184b46fff04918511356376 100644 (file)
@@ -17,6 +17,7 @@
 #include "insetnote.h"
 #include "gettext.h"
 #include "lyxfont.h"
+#include "buffer.h"
 #include "BufferView.h"
 #include "lyxtext.h"
 #include "insets/insettext.h"
 
 using std::ostream;
 
-InsetNote::InsetNote()
-       : InsetCollapsable()
+void InsetNote::init()
 {
        LyXFont font(LyXFont::ALL_SANE);
        font.decSize();
        font.setColor(LColor::note);
        setLabelFont(font);
-       setAutoCollapse(true);
+       setAutoCollapse(false);
 
        setLabel(_("note"));
        setInsetName("Note");
 }
 
+InsetNote::InsetNote()
+       : InsetCollapsable()
+{
+       init();
+}
+
+InsetNote::InsetNote(Buffer const * buf, string const & contents, 
+                    bool collapsed)
+       : InsetCollapsable(collapsed)
+{
+       init();
+
+       Paragraph * par = inset.paragraph();
+       Paragraph::size_type pos = 0;
+       buf->insertStringAsLines(par, pos, labelfont, contents);
+}
 
 Inset * InsetNote::clone(Buffer const &, bool same_id) const
 {
index 5ac501f8452edec4f91821c1c08526e5f599f528..a23fbdb2191a29a2fc09719c23ae6cb9f4280b99 100644 (file)
 */
 class InsetNote : public InsetCollapsable {
 public:
-       ///
+       /// 
        InsetNote();
+       /// constructor with initial contents
+       InsetNote(Buffer const *, string const & contents, bool collapsed);
        ///
        virtual Inset * clone(Buffer const &, bool) const;
        ///
@@ -36,6 +38,10 @@ public:
        ///
        virtual int latex(Buffer const *, std::ostream &, bool, bool) const
                { return 0; }
+private:
+       /// used by the constructors
+       void init();
+
 };
 
 #endif
index 695187a4945b94bf99cf013fd01c2022dea77689..ecb30cb1433a4d808061ab5390cebab972b196e1 100644 (file)
@@ -145,7 +145,7 @@ void InsetQuotes::parseString(string const & s)
 }
 
 
-string const InsetQuotes::dispString(Language const * doclang) const
+string const InsetQuotes::dispString(Language const * loclang) const
 {
        string disp;
        disp += quote_char[quote_index[side_][language_]];
@@ -160,7 +160,7 @@ string const InsetQuotes::dispString(Language const * doclang) const
                        disp = '»';
 
        // in french, spaces are added inside double quotes
-       if (times_ == DoubleQ && doclang->code() == "fr") {
+       if (times_ == DoubleQ && prefixIs(loclang->code(), "fr")) {
                if (side_ == LeftQ)
                        disp += " ";
                else
@@ -183,9 +183,9 @@ int InsetQuotes::descent(BufferView *, LyXFont const & font) const
 }
 
 
-int InsetQuotes::width(BufferView * bv, LyXFont const & font) const
+int InsetQuotes::width(BufferView *, LyXFont const & font) const
 {
-       string text = dispString(bv->buffer()->getLanguage());
+       string const text = dispString(font.language());
        int w = 0;
 
        for (string::size_type i = 0; i < text.length(); ++i) {
@@ -215,7 +215,7 @@ LyXFont const InsetQuotes::convertFont(LyXFont const & f) const
 void InsetQuotes::draw(BufferView * bv, LyXFont const & font,
                       int baseline, float & x, bool) const
 {
-       string text = dispString(bv->buffer()->getLanguage());
+       string const text = dispString(font.language());
 
        bv->painter().text(int(x), baseline, text, font);
        x += width(bv, font);
@@ -237,10 +237,8 @@ void InsetQuotes::read(Buffer const *, LyXLex & lex)
        lex.nextToken();
        parseString(lex.GetString());
        lex.next();
-       string tmp(lex.GetString());
-       if (tmp != "\\end_inset")
-               lyxerr << "LyX Warning: Missing \\end_inset "
-                       "in InsetQuotes::Read." << endl;
+       if (lex.GetString() != "\\end_inset")
+               lex.printError("Missing \\end_inset at this point");
 }
 
 
@@ -249,8 +247,11 @@ extern bool use_babel;
 int InsetQuotes::latex(Buffer const * buf, ostream & os,
                       bool /*fragile*/, bool) const
 {
+#ifdef WITH_WARNINGS
+#warning How do we get the local language here??
+#endif
        string const doclang = buf->getLanguage()->babel();
-       int quoteind = quote_index[side_][language_];
+       const int quoteind = quote_index[side_][language_];
        string qstr;
        
        if (language_ == FrenchQ && times_ == DoubleQ) {
@@ -258,7 +259,7 @@ int InsetQuotes::latex(Buffer const * buf, ostream & os,
                        if (side_ == LeftQ) 
                                qstr = "\\og "; //the spaces are important here
                        else 
-                               qstr = " \\fg "; //and here
+                               qstr = " \\fg{}"; //and here
                } else if (doclang == "french") {
                        if (side_ == LeftQ) 
                                qstr = "<< "; //the spaces are important here
@@ -321,7 +322,11 @@ void InsetQuotes::validate(LaTeXFeatures & features) const
 {
        char type = quote_char[quote_index[side_][language_]];
 
+#ifdef DO_USE_DEFAULT_LANGUAGE
        if (features.bufferParams().language->lang() == "default" 
+#else
+       if (!use_babel
+#endif
            && lyxrc.fontenc != "T1") {
                if (times_ == SingleQ) 
                        switch (type) {
index 7979f1ff8f83490cabf8401ddb6729b79f84bdd7..fd4181bc6c0048be6af520602f974cd536aa37a1 100644 (file)
@@ -24,10 +24,15 @@ using std::ostream;
 using std::max;
 
 InsetSpecialChar::InsetSpecialChar(Kind k)
-       : kind(k)
+       : kind_(k)
 {}
 
 
+InsetSpecialChar::Kind InsetSpecialChar::kind() const
+{
+       return kind_;
+}
+
 int InsetSpecialChar::ascent(BufferView *, LyXFont const & font) const
 {
        return lyxfont::maxAscent(font);
@@ -42,7 +47,7 @@ int InsetSpecialChar::descent(BufferView *, LyXFont const & font) const
 
 int InsetSpecialChar::width(BufferView *, LyXFont const & font) const
 {
-       switch (kind) {
+       switch (kind_) {
        case HYPHENATION:
        {
                int w = lyxfont::width('-', font);
@@ -82,7 +87,7 @@ void InsetSpecialChar::draw(BufferView * bv, LyXFont const & f,
        Painter & pain = bv->painter();
        LyXFont font(f);
 
-       switch (kind) {
+       switch (kind_) {
        case HYPHENATION:
        {
                font.setColor(LColor::special);
@@ -158,7 +163,7 @@ void InsetSpecialChar::draw(BufferView * bv, LyXFont const & f,
 void InsetSpecialChar::write(Buffer const *, ostream & os) const
 {
        string command;
-       switch (kind) {
+       switch (kind_) {
        case HYPHENATION:       
                command = "\\-";        
                break;
@@ -190,18 +195,18 @@ void InsetSpecialChar::read(Buffer const *, LyXLex & lex)
        string const command = lex.GetString();
 
        if (command == "\\-")
-               kind = HYPHENATION;
+               kind_ = HYPHENATION;
        else if (command == "\\textcompwordmark{}")
-               kind = LIGATURE_BREAK;
+               kind_ = LIGATURE_BREAK;
        else if (command == "\\@.")
-               kind = END_OF_SENTENCE;
+               kind_ = END_OF_SENTENCE;
        else if (command == "\\ldots{}")
-               kind = LDOTS;
+               kind_ = LDOTS;
        else if (command == "\\menuseparator")
-               kind = MENU_SEPARATOR;
+               kind_ = MENU_SEPARATOR;
        else if (command == "\\protected_separator"
                 || command == "~")
-               kind = PROTECTED_SEPARATOR;
+               kind_ = PROTECTED_SEPARATOR;
        else
                lex.printError("InsetSpecialChar: Unknown kind: `$$Token'");
 }
@@ -210,7 +215,7 @@ void InsetSpecialChar::read(Buffer const *, LyXLex & lex)
 int InsetSpecialChar::latex(Buffer const *, ostream & os, bool /*fragile*/,
                            bool free_space) const
 {
-       switch (kind) {
+       switch (kind_) {
        case HYPHENATION:         
                os << "\\-";    
                break;
@@ -236,7 +241,7 @@ int InsetSpecialChar::latex(Buffer const *, ostream & os, bool /*fragile*/,
 
 int InsetSpecialChar::ascii(Buffer const *, ostream & os, int) const
 {
-       switch (kind) {
+       switch (kind_) {
        case HYPHENATION:
        case LIGATURE_BREAK:
                break;
@@ -271,13 +276,13 @@ int InsetSpecialChar::docBook(Buffer const * buf, ostream & os) const
 
 Inset * InsetSpecialChar::clone(Buffer const &, bool) const
 {
-       return new InsetSpecialChar(kind);
+       return new InsetSpecialChar(kind_);
 }
 
 
 void InsetSpecialChar::validate(LaTeXFeatures & features) const
 {
-       if (kind == MENU_SEPARATOR) {
+       if (kind_ == MENU_SEPARATOR) {
                features.lyxarrow = true;
        }
 }
index 507f42cb8f92da360a6ed2629fd8269dfca6f7c6..20ff5b3360e00ea0f2f8919463e75cc36ca16c8d 100644 (file)
@@ -46,6 +46,8 @@ public:
        explicit
        InsetSpecialChar(Kind k);
        ///
+       Kind kind() const;
+       ///
        int ascent(BufferView *, LyXFont const &) const;
        ///
        int descent(BufferView *, LyXFont const &) const;
@@ -82,7 +84,7 @@ public:
        void validate(LaTeXFeatures &) const;
 private:
        /// And which kind is this?
-       Kind kind;
+       Kind kind_;
 };
 
 #endif
index 2d706ca101659a6dd497426450fd3f5aa0a3d67f..860b6958bca394340912fb1dfb0beaa81d9a84de 100644 (file)
@@ -600,12 +600,14 @@ func_status::value_type LyXFunc::getStatus(int ac,
        case LFUN_INSET_ERT:
                code = Inset::ERT_CODE;         
                break;
+       case LFUN_FIGURE:
        case LFUN_INSET_GRAPHICS:
                code = Inset::GRAPHICS_CODE;
                break;
        case LFUN_INSET_FOOTNOTE:
                code = Inset::FOOT_CODE;
                break;
+       case LFUN_DIALOG_TABULAR_INSERT:
        case LFUN_INSET_TABULAR:
                code = Inset::TABULAR_CODE;
                break;
@@ -622,6 +624,9 @@ func_status::value_type LyXFunc::getStatus(int ac,
        case LFUN_INSET_WIDE_FLOAT:
                code = Inset::FLOAT_CODE;
                break;
+       case LFUN_FLOAT_LIST:
+               code = Inset::FLOAT_LIST_CODE;
+               break;
 #if 0
        case LFUN_INSET_LIST:
                code = Inset::LIST_CODE;
@@ -642,6 +647,7 @@ func_status::value_type LyXFunc::getStatus(int ac,
        case LFUN_REF_INSERT:
                code = Inset::REF_CODE;
                break;
+       case LFUN_CITATION_CREATE:
        case LFUN_CITATION_INSERT:
                code = Inset::CITE_CODE;
                break;
@@ -650,22 +656,40 @@ func_status::value_type LyXFunc::getStatus(int ac,
                break;
        case LFUN_INDEX_INSERT:
        case LFUN_INDEX_INSERT_LAST:
+       case LFUN_INDEX_CREATE:
                code = Inset::INDEX_CODE;
                break;
-#if 0
+       case LFUN_INDEX_PRINT:
+               code = Inset::INDEX_PRINT_CODE;
+               break;
        case LFUN_CHILD_INSERT:
-               code = Inset::CHILD_CODE;
+               code = Inset::INCLUDE_CODE;
                break;
-#endif
        case LFUN_TOC_INSERT:
                code = Inset::TOC_CODE;
                break;
        case LFUN_PARENTINSERT:
                code = Inset::PARENT_CODE;
                break;
+       case LFUN_HTMLURL:
+       case LFUN_URL:
        case LFUN_INSERT_URL:
                code = Inset::URL_CODE;
                break;
+       case LFUN_QUOTE:
+               // always allow this, since we will inset a raw quote
+               // if an inset is not allowed.
+               break;
+       case LFUN_HYPHENATION:
+       case LFUN_LIGATURE_BREAK:
+       case LFUN_HFILL:
+       case LFUN_MENU_SEPARATOR:
+       case LFUN_LDOTS:
+       case LFUN_END_OF_SENTENCE:
+       case LFUN_PROTECTEDSPACE:
+       case LFUN_BREAKLINE:
+               code = Inset::SPECIALCHAR_CODE;
+               break;
        default:
                break;
        }
index bc3b7d302ebf40235cff681c85ce36216d338e4b..ebaa3dccf3dfe36e048595cc36ea24f6e7748e38 100644 (file)
@@ -698,17 +698,17 @@ int LyXRC::read(string const & filename)
                        int action, res = 0;
                        string seq, cmd;
                        
-                       if (lexrc.lex() == LyXLex::LEX_DATA)  {
+                       if (lexrc.next()) {
                                seq = lexrc.GetString();
                        } else {
-                               lexrc.printError("Bad key sequence: `$$Token'");
+                               lexrc.printError("RC_BIND: Missing key sequence");
                                break;
                        }
                        
-                       if (lexrc.lex() == LyXLex::LEX_DATA) {
+                       if (lexrc.next(true)) {
                                cmd = lexrc.GetString();
                        } else {
-                               lexrc.printError("Bad command: `$$Token'");
+                               lexrc.printError("RC_BIND: missing command");
                                break;
                        }
                        
index e6d29ca8f430c534b8e3505b892033e86ef3ee26..87d6b78c4b69127129341faf36ee4f9ce8bfca03 100644 (file)
@@ -268,9 +268,10 @@ public:
        string const selectionAsString(Buffer const *) const;
        
        /// select the word we need depending on word_location
-       void getWord(LyXCursor & from, LyXCursor & to, word_location) const;
+       void getWord(LyXCursor & from, LyXCursor & to, 
+                    word_location const) const;
        /// just selects the word the cursor is in
-       void selectWord(BufferView *);
+       void selectWord(BufferView *, word_location const = WHOLE_WORD);
        /// returns the inset at cursor (if it exists), 0 otherwise
        Inset * getInset() const;
 
@@ -351,7 +352,8 @@ public:
        ///
        void deleteLineForward(BufferView *);
        ///
-       bool selectWordWhenUnderCursor(BufferView *);
+       bool selectWordWhenUnderCursor(BufferView *, 
+                                      word_location const = WHOLE_WORD);
        ///
        enum TextCase {
                ///
index 5f6719d1f929f8ce5b559a1cb572c3fafc63e822..3d1d4944002fdc790d1ece70f89c2a3e08b5c0d7 100644 (file)
@@ -1,3 +1,7 @@
+2001-07-22  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * formula.C (insetAllowed): allow insertion of label
+
 2001-07-20 André Pönitz  <poenitz@htwm.de>
 
        * math_macrotable.C: support for \land and \vee
index ffa4eaecb3b78a423dc44b4cbc79f11e0e7a0423..31af423668c2985d0b523bb75415fee006172d9f 100644 (file)
@@ -325,6 +325,11 @@ void InsetFormula::validate(LaTeXFeatures & features) const
        par()->Validate(features);
 }
 
+bool InsetFormula::insetAllowed(Inset::Code code) const
+{
+       return code == Inset::LABEL_CODE; 
+}
+
 
 int InsetFormula::ascent(BufferView *, LyXFont const &) const
 {
index 41f8bca78601985f930ee4c1344f25c9f4f9171d..b98c7ef8dc08649933c1c6cb03e24c32f7275c5a 100644 (file)
@@ -67,6 +67,8 @@ public:
        ///
        Inset::Code lyxCode() const;
        ///
+       bool insetAllowed(Inset::Code code) const;
+       ///
        virtual RESULT localDispatch(BufferView *, kb_action, string const &);
        ///
        std::vector<string> const getLabelList() const;
index 7e69df5421bac2e69f88ab65e1b86253d5dff002..01349da75ca65ec2f6c54a2c97f44d8db960c684 100644 (file)
@@ -19,6 +19,7 @@
 #include "support/textutils.h"
 #include "insets/insetbib.h"
 #include "insets/insettext.h"
+#include "insets/insetspecialchar.h"
 #include "lyx_gui_misc.h"
 #include "gettext.h"
 #include "bufferparams.h"
@@ -2157,10 +2158,10 @@ void LyXText::cursorLeftOneWord(LyXCursor  & cur)  const
        }
 }
 
-/* -------> Select current word. This depends on behaviour of CursorLeftOneWord(), so it is
-                       patched as well. */
-
-void LyXText::getWord(LyXCursor & from, LyXCursor & to, word_location loc) const
+/* -------> Select current word. This depends on behaviour of
+CursorLeftOneWord(), so it is patched as well. */
+void LyXText::getWord(LyXCursor & from, LyXCursor & to, 
+                     word_location const loc) const
 {
        // first put the cursor where we wana start to select the word
        from = cursor;
@@ -2188,11 +2189,11 @@ void LyXText::getWord(LyXCursor & from, LyXCursor & to, word_location loc) const
 }
 
 
-void LyXText::selectWord(BufferView * bview) 
+void LyXText::selectWord(BufferView * bview, word_location const loc
 {
        LyXCursor from;
        LyXCursor to;
-       getWord(from, to, WHOLE_WORD);
+       getWord(from, to, loc);
        if (cursor != from)
                setCursor(bview, from.par(), from.pos());
        selection.cursor = cursor;
@@ -2202,17 +2203,21 @@ void LyXText::selectWord(BufferView * bview)
 
 /* -------> Select the word currently under the cursor when:
                        1: no selection is currently set,
-                       2: the cursor is not at the borders of the word. */
+       [disabled]      2: the cursor is not at the borders of the word. */
 
-bool LyXText::selectWordWhenUnderCursor(BufferView * bview) 
+bool LyXText::selectWordWhenUnderCursor(BufferView * bview, 
+                                       word_location const loc) 
 {
-       if (!selection.set() &&
-           cursor.pos() > 0 && cursor.pos() < cursor.par()->size()
+       if (!selection.set() 
+#if 0
+           && cursor.pos() > 0 && cursor.pos() < cursor.par()->size()
            && !cursor.par()->isSeparator(cursor.pos())
            && !cursor.par()->isKomma(cursor.pos())
            && !cursor.par()->isSeparator(cursor.pos() -1)
-           && !cursor.par()->isKomma(cursor.pos() -1)) {
-               selectWord(bview);
+           && !cursor.par()->isKomma(cursor.pos() -1)
+#endif
+           ) {
+               selectWord(bview, loc);
                return true;
        }
        return false;
@@ -2291,17 +2296,18 @@ string const LyXText::selectNextWord(BufferView * bview,
        // Start the selection from here
        selection.cursor = cursor;
        
-       ostringstream latex;
+       Inset * inset;
 
        // and find the end of the word 
        // (optional hyphens are part of a word)
        while (cursor.pos() < cursor.par()->size()
               && (cursor.par()->isLetter(cursor.pos())) 
-                  || (cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET
-                      && cursor.par()->getInset(cursor.pos()) != 0
-                      && cursor.par()->getInset(cursor.pos())->latex(bview->buffer(), latex, false, false) == 0
-                      && latex.str() == "\\-"
-                          ))
+              // assignment is intentional here
+              || ((inset = getInset())
+                  && inset->lyxCode() == Inset::SPECIALCHAR_CODE
+                  && static_cast<InsetSpecialChar *>(inset)->kind()
+                       == InsetSpecialChar::HYPHENATION
+                  ))
                cursor.pos(cursor.pos() + 1);
 
        // Finally, we copy the word to a string and return it
@@ -2329,16 +2335,17 @@ void LyXText::selectSelectedWord(BufferView * bview)
        
        // set the sel cursor
        selection.cursor = cursor;
-       ostringstream latex;
+       Inset * inset;
        
        // now find the end of the word
        while (cursor.pos() < cursor.par()->size()
               && (cursor.par()->isLetter(cursor.pos())
-                  || (cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET
-                      && cursor.par()->getInset(cursor.pos()) != 0
-                      && cursor.par()->getInset(cursor.pos())->latex(bview->buffer(), latex, false, false) == 0
-                      && latex.str() == "\\-"
-                          )))
+                  // assignment is intentional here
+                  || ((inset = getInset())
+                      && inset->lyxCode() == Inset::SPECIALCHAR_CODE
+                      && static_cast<InsetSpecialChar *>(inset)->kind()
+                               == InsetSpecialChar::HYPHENATION
+                      )))
                cursor.pos(cursor.pos() + 1);
        
        setCursor(bview, cursor.par(), cursor.pos());
index 33bd234118688bd174b894735bc2e98bcefc6f9f..2e1972b8422d1c11df86b84e6c631754cd39498d 100644 (file)
@@ -1785,65 +1785,10 @@ void LyXText::insertStringAsLines(BufferView * bview, string const & str)
        
        setCursorParUndo(bview);
        
-       bool isEnvironment =
-               textclasslist.Style(bview->buffer()->params.textclass, 
-                                   cursor.par()->getLayout()).isEnvironment();
-       bool free_spacing =
-               textclasslist.Style(bview->buffer()->params.textclass, 
-                                   cursor.par()->getLayout()).free_spacing;
-       bool keepempty =
-               textclasslist.Style(bview->buffer()->params.textclass, 
-                                   cursor.par()->getLayout()).keepempty;
-
        // only to be sure, should not be neccessary
        clearSelection(bview);
        
-       // insert the string, don't insert doublespace
-       bool space_inserted = true;
-       for(string::const_iterator cit = str.begin(); 
-           cit != str.end(); ++cit) {
-               if (*cit == '\n') {
-                       if (par->size() || keepempty) { 
-                               par->breakParagraph(bview->buffer()->params, 
-                                                   pos, isEnvironment);
-                               par = par->next();
-                               pos = 0;
-                               space_inserted = true;
-                       } else {
-                               continue;
-                       }
-                       // do not insert consecutive spaces if !free_spacing
-               } else if ((*cit == ' ' || *cit == '\t')
-                          && space_inserted && !free_spacing) {
-                       continue;
-               } else if (*cit == '\t') {
-                       if (!free_spacing) {
-                               // tabs are like spaces here
-                               par->insertChar(pos, ' ', 
-                                               current_font);
-                               ++pos;
-                               space_inserted = true;
-                       } else {
-                               const Paragraph::value_type nb = 8 - pos % 8;
-                               for (Paragraph::size_type a = 0; 
-                                    a < nb ; ++a) {
-                                       par->insertChar(pos, ' ', 
-                                                       current_font);
-                                       ++pos;
-                               }
-                               space_inserted = true;
-                       }
-               } else if (!IsPrintable(*cit)) {
-                       // Ignore unprintables
-                       continue;
-               } else {
-                       // just insert the character
-                       par->insertChar(pos, *cit, current_font);
-                       ++pos;
-                       space_inserted = (*cit == ' ');
-               }
-
-       }       
+       bview->buffer()->insertStringAsLines(par, pos, current_font, str);
 
        redoParagraphs(bview, cursor, endpar);
        setCursor(bview, cursor.par(), cursor.pos());
index 3c5a6904d93011bebd40a32042d3eb7a9009fafd..547452a0780a8afbbc2fd7ee971754cd5e275b45 100644 (file)
@@ -15,7 +15,6 @@
 #include "buffer.h"
 #include "lyxrc.h"
 #include "support/lstrings.h"
-#include "language.h"
 
 using std::endl;
 using std::pair;
@@ -372,16 +371,7 @@ void TransManager::insertVerbatim(string const & str, LyXText * text)
        string::size_type const l = str.length();
        
        for (string::size_type i = 0; i < l; ++i) {
-               if (str[i] == '\"'
-#ifndef NO_LATEX
-                   && text->getFont(current_view->buffer(),text->cursor.par(),
-                                    text->cursor.pos()).latex() == LyXFont::OFF
-#endif
-                   && text->getFont(current_view->buffer(),text->cursor.par(),
-                                    text->cursor.pos()).language()->lang() != "hebrew")
-                       current_view->insertCorrectQuote();
-               else
-                       text->insertChar(current_view, str[i]);
+               text->insertChar(current_view, str[i]);
        }
 }
 
@@ -390,7 +380,7 @@ void TransManager::insert(string const & str, LyXText * text)
 {
        // Go through the character encoding only if the current 
        // encoding (chset_->name()) matches the current font_norm
-       // (lyrxc->font_norm
+       // (lyrxc->font_norm)
        
        // Is false to speak about "only if" the current encoding will
        // almost always be equal to font_norm.