From: Angus Leeming Date: Thu, 22 May 2003 10:40:57 +0000 (+0000) Subject: (Juergen) the new space inset. X-Git-Tag: 1.6.10~16791 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=b3608133b0ee897c4e9ccccc9cd17a742d97e556;hp=021369da29024b9709c310538216ce60f8247eb9;p=lyx.git (Juergen) the new space inset. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6998 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/development/FORMAT b/development/FORMAT index c3dfe51b5a..de524ff42f 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -1,6 +1,13 @@ LyX file-format changes ----------------------- +2003-05-20 Jürgen Spitzmüller + + * Added new space insets: + \SpecialChar ~ is now \InsetSpace ~ + ERT: "\ " could be converted to InsetSpace \ + ERT: "\," could be converted to InsetSpace \, + 2003-03-12 John Levon * Added \\end_header to signify the end of the header in a diff --git a/lib/ChangeLog b/lib/ChangeLog index 893288f889..ae820bdb7b 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,15 @@ +2003-05-21 José Matos + + * lyx2lyx/lyxconvert_221.py: convert \SpecialChar ~ + +2003-05-20 Jürgen Spitzmüller + + * bind/cua.bind: + * bind/emacs.bind: + * bind/yemacs.bind: + * bind/latinkeys.bind: + * ui/stdmenus.ui: new space insets + 2003-05-20 John Levon * ui/stdtoolbars.ui: s/Paragraph Style/Paragraph Settings/ diff --git a/lib/bind/cua.bind b/lib/bind/cua.bind index 847245a886..b6d018a083 100644 --- a/lib/bind/cua.bind +++ b/lib/bind/cua.bind @@ -164,7 +164,9 @@ \bind "M-Return" "break-paragraph-keep-layout" \bind "C-Return" "break-line" \bind "C-k" "line-delete-forward" -\bind "C-space" "protected-space-insert" +\bind "C-space" "space-insert protected" +\bind "C-M-space" "space-insert normal" +\bind "S-C-space" "space-insert thin" \bind "C-period" "end-of-sentence-period-insert" \bind "M-period" "dots-insert" \bind "Escape" "cancel" diff --git a/lib/bind/emacs.bind b/lib/bind/emacs.bind index 204c065e93..7468f00af9 100644 --- a/lib/bind/emacs.bind +++ b/lib/bind/emacs.bind @@ -190,7 +190,9 @@ \bind "M-Return" "break-paragraph-keep-layout" \bind "C-Return" "break-line" \bind "C-S-L" "ligature-break-insert" -\bind "C-space" "protected-space-insert" +\bind "C-space" "space-insert protected" +\bind "C-M-space" "space-insert normal" +\bind "S-C-space" "space-insert thin" \bind "C-period" "end-of-sentence-period-insert" \bind "M-period" "dots-insert" \bind "M-w" "copy" diff --git a/lib/bind/latinkeys.bind b/lib/bind/latinkeys.bind index 80675afa7d..e1e3739651 100644 --- a/lib/bind/latinkeys.bind +++ b/lib/bind/latinkeys.bind @@ -116,7 +116,7 @@ \bind "braceright" "self-insert" \bind "asciitilde" "self-insert" -\bind "nobreakspace" "protected-space-insert" +\bind "nobreakspace" "space-insert protected" \bind "exclamdown" "self-insert" \bind "cent" "self-insert" \bind "sterling" "self-insert" diff --git a/lib/bind/xemacs.bind b/lib/bind/xemacs.bind index 838fbb3663..ffc41f0115 100644 --- a/lib/bind/xemacs.bind +++ b/lib/bind/xemacs.bind @@ -198,7 +198,9 @@ \bind "M-Return" "break-paragraph-keep-layout" \bind "C-Return" "break-line" \bind "C-S-L" "ligature-break-insert" -\bind "C-space" "protected-space-insert" +\bind "C-space" "space-insert protected" +\bind "C-M-space" "space-insert normal" +\bind "S-C-space" "space-insert thin" \bind "C-period" "end-of-sentence-period-insert" \bind "M-period" "dots-insert" \bind "M-w" "copy" diff --git a/lib/lyx2lyx/lyxconvert_221.py b/lib/lyx2lyx/lyxconvert_221.py index ad7ea1d406..02d9e17f64 100644 --- a/lib/lyx2lyx/lyxconvert_221.py +++ b/lib/lyx2lyx/lyxconvert_221.py @@ -15,11 +15,18 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +import string + def add_end(header): header.append("\\end_header"); +def convert_spaces(lines): + for i in range(len(lines)): + lines[i] = string.replace(lines[i],"\\SpecialChar ~","\\InsetSpace ~") + def convert(header, body): add_end(header) + convert_spaces(body) if __name__ == "__main__": pass diff --git a/lib/ui/stdmenus.ui b/lib/ui/stdmenus.ui index 1054a0db8e..4b1b353768 100644 --- a/lib/ui/stdmenus.ui +++ b/lib/ui/stdmenus.ui @@ -243,7 +243,9 @@ Menuset Item "Horizontal Fill|H" "hfill-insert" Item "Hyphenation Point|P" "hyphenation-point-insert" Item "Ligature Break|k" "ligature-break-insert" - Item "Protected Blank|B" "protected-space-insert" + Item "Protected Space|r" "space-insert protected" + Item "Force normal Space|n" "space-insert normal" + Item "Thin Space|T" "space-insert thin" Item "Linebreak|L" "break-line" Item "Ellipsis|i" "dots-insert" Item "End of Sentence|E" "end-of-sentence-period-insert" diff --git a/lib/ui/stdtoolbars.ui b/lib/ui/stdtoolbars.ui index 18b7ae688e..2539f13b39 100644 --- a/lib/ui/stdtoolbars.ui +++ b/lib/ui/stdtoolbars.ui @@ -61,7 +61,7 @@ Toolbar "Standard" "on,top" Item "Insert table" "tabular-insert 4 4" End -Toolbar "Extra" "off,top" +Toolbar "Extra" "on,top" Item "Numbered list" "layout Enumerate" Item "Itemized list" "layout Itemize" Item "List" "layout List" @@ -90,7 +90,7 @@ Toolbar "Extra" "off,top" Item "Thesaurus" "thesaurus-entry" End -Toolbar "Table" "off,bottom" +Toolbar "Table" "table,bottom" Item "Add row" "tabular-feature append-row" Item "Add column" "tabular-feature append-column" Item "Delete row" "tabular-feature delete-row" @@ -115,7 +115,7 @@ Toolbar "Table" "off,bottom" Item "Set multi-column" "tabular-feature multicolumn" End -Toolbar "Math" "off,bottom" +Toolbar "Math" "math,bottom" Item "Show math panel" "math-panel" Item "Set display mode" "math-display" Item "Subscript" "math-subscript" @@ -139,6 +139,6 @@ Toolbar "Math" "off,bottom" Item "Delete column" "tabular-feature delete-column" End -Toolbar "Command Buffer" "off,bottom" +Toolbar "Command Buffer" "on,bottom" Minibuffer End diff --git a/src/ChangeLog b/src/ChangeLog index dc95b4fada..314498edae 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2003-05-20 Jürgen Spitzmüller + + * LyXAction.C: new lfun space-insert, kill protected-space-insert + * lfuns.h: new LFUN_SPACE + * lyxfunc.C: protected space has a new lfun + * paragraph_funcs.C: read new space insets + * text3.C: + * factory.C: handle new space insets 2003-05-22 André Pönitz diff --git a/src/LyXAction.C b/src/LyXAction.C index de47ef4085..9f955102b9 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -242,7 +242,6 @@ void LyXAction::init() { LFUN_DIALOG_PREFERENCES, "dialog-preferences", NoBuffer }, { LFUN_SAVEPREFERENCES, "preferences-save", NoBuffer }, { LFUN_PASTESELECTION, "primary-selection-paste", Noop }, - { LFUN_PROTECTEDSPACE, "protected-space-insert", Noop }, { LFUN_QUOTE, "quote-insert", Noop }, { LFUN_RECONFIGURE, "reconfigure", NoBuffer }, { LFUN_REDO, "redo", Noop }, @@ -256,6 +255,7 @@ void LyXAction::init() { LFUN_PRIORSEL, "screen-up-select", ReadOnly }, { LFUN_SCROLL_INSET, "inset-scroll", ReadOnly }, { LFUN_SELFINSERT, "self-insert", Noop }, + { LFUN_SPACE_INSERT, "space-insert", Noop }, { LFUN_CHARATCURSOR, "server-char-after", ReadOnly }, { LFUN_GETFONT, "server-get-font", ReadOnly }, { LFUN_GETLAYOUT, "server-get-layout", ReadOnly }, diff --git a/src/factory.C b/src/factory.C index 0e88c5f7a8..4c335b06f7 100644 --- a/src/factory.C +++ b/src/factory.C @@ -40,6 +40,7 @@ #include "insets/insetoptarg.h" #include "insets/insetparent.h" #include "insets/insetref.h" +#include "insets/insetspace.h" #include "insets/insettabular.h" #include "insets/insettext.h" #include "insets/insettoc.h" @@ -245,6 +246,31 @@ Inset * createInset(FuncRequest const & cmd) return new InsetUrl(icp); } } + + case LFUN_SPACE_INSERT: { + string const name = cmd.argument; + if (name == "normal") + return new InsetSpace(InsetSpace::NORMAL); + else if (name == "protected") + return new InsetSpace(InsetSpace::PROTECTED); + else if (name == "thin") + return new InsetSpace(InsetSpace::THIN); + else if (name == "quad") + return new InsetSpace(InsetSpace::QUAD); + else if (name == "qquad") + return new InsetSpace(InsetSpace::QQUAD); + else if (name == "enspace") + return new InsetSpace(InsetSpace::ENSPACE); + else if (name == "enskip") + return new InsetSpace(InsetSpace::ENSKIP); + else if (name == "negthinspace") + return new InsetSpace(InsetSpace::NEGTHIN); + else if (name.empty()) + lyxerr << "LyX function 'space' needs an argument." << endl; + else + lyxerr << "Wrong argument for LyX function 'space'." << endl; + } + break; default: @@ -337,6 +363,8 @@ Inset * readInset(LyXLex & lex, Buffer const & buf) inset = new InsetEnvironment(buf.params, lex.getString()); } else if (tmptok == "ERT") { inset = new InsetERT(buf.params); + } else if (tmptok == "InsetSpace") { + inset = new InsetSpace; } else if (tmptok == "Tabular") { inset = new InsetTabular(buf); } else if (tmptok == "Text") { diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 3ca4cff9b5..d6ac8879c9 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,9 @@ +2003-05-20 Jürgen Spitzmüller + + * insetspace.[Ch]: added (new space insets) + * Makefile.am: + * inset.h: handle new space insets + 2003-05-21 Lars Gullik Bjønnes * insetfloat.C (addToToc): adjust diff --git a/src/insets/Makefile.am b/src/insets/Makefile.am index ff82b7183b..23e0bdf6ac 100644 --- a/src/insets/Makefile.am +++ b/src/insets/Makefile.am @@ -85,6 +85,8 @@ libinsets_la_SOURCES = \ insetquotes.h \ insetref.C \ insetref.h \ + insetspace.C \ + insetspace.h \ insetspecialchar.C \ insetspecialchar.h \ insettabular.C \ diff --git a/src/insets/inset.h b/src/insets/inset.h index 32843b5e30..ecb2a06820 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -102,6 +102,8 @@ public: /// MINIPAGE_CODE, /// + SPACE_CODE, + /// SPECIALCHAR_CODE, // 25 /// TABULAR_CODE, diff --git a/src/insets/insetspace.C b/src/insets/insetspace.C new file mode 100644 index 0000000000..d4abadea67 --- /dev/null +++ b/src/insets/insetspace.C @@ -0,0 +1,276 @@ +/** + * \file insetspace.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Asger Alstrup Nielsen + * \author Jean-Marc Lasgouttes + * \author Lars Gullik Bjønnes + * \author Juergen Spitzmueller + * + * Full author contact details are available in file CREDITS + */ + +#include + +#include "insetspace.h" + +#include "debug.h" +#include "dimension.h" +#include "LaTeXFeatures.h" +#include "BufferView.h" +#include "frontends/Painter.h" +#include "frontends/font_metrics.h" +#include "lyxlex.h" +#include "lyxfont.h" + +using std::ostream; +using std::max; + + +InsetSpace::InsetSpace(Kind k) + : kind_(k) +{} + + +InsetSpace::Kind InsetSpace::kind() const +{ + return kind_; +} + + +void InsetSpace::dimension(BufferView *, LyXFont const & font, + Dimension & dim) const +{ + dim.a = font_metrics::maxAscent(font); + dim.d = font_metrics::maxDescent(font); + + switch (kind_) { + case THIN: + case NEGTHIN: + dim.w = font_metrics::width("x", font) / 3; + break; + case PROTECTED: + case NORMAL: + dim.w = font_metrics::width("x", font); + break; + case QUAD: + dim.w = 20; + break; + case QQUAD: + dim.w = 40; + break; + case ENSPACE: + case ENSKIP: + dim.w = 10; + break; + } +} + + +void InsetSpace::draw(BufferView * bv, LyXFont const & f, + int baseline, float & x) const +{ + Painter & pain = bv->painter(); + LyXFont font(f); + + float w = width(bv, font); + int h = font_metrics::ascent('x', font); + int xp[4], yp[4]; + + xp[0] = int(x); yp[0] = baseline - max(h / 4, 1); + if (kind_ == NORMAL) { + xp[1] = int(x); yp[1] = baseline; + xp[2] = int(x + w); yp[2] = baseline; + } else { + xp[1] = int(x); yp[1] = baseline + max(h / 4, 1); + xp[2] = int(x + w); yp[2] = baseline + max(h / 4, 1); + } + xp[3] = int(x + w); yp[3] = baseline - max(h / 4, 1); + + if (kind_ == PROTECTED || kind_ == ENSPACE || kind_ == NEGTHIN) + pain.lines(xp, yp, 4, LColor::latex); + else + pain.lines(xp, yp, 4, LColor::special); + x += w; +} + + +void InsetSpace::write(Buffer const *, ostream & os) const +{ + string command; + switch (kind_) { + case NORMAL: + command = "\\space"; + break; + case PROTECTED: + command = "~"; + break; + case THIN: + command = "\\,"; + break; + case QUAD: + command = "\\quad{}"; + break; + case QQUAD: + command = "\\qquad{}"; + break; + case ENSPACE: + command = "\\enspace{}"; + break; + case ENSKIP: + command = "\\enskip{}"; + break; + case NEGTHIN: + command = "\\negthinspace{}"; + break; + } + os << "\\InsetSpace " << command << "\n"; +} + + +// This function will not be necessary when lyx3 +void InsetSpace::read(Buffer const *, LyXLex & lex) +{ + lex.nextToken(); + string const command = lex.getString(); + + if (command == "\\space") + kind_ = NORMAL; + else if (command == "~") + kind_ = PROTECTED; + else if (command == "\\,") + kind_ = THIN; + else if (command == "\\quad{}") + kind_ = QUAD; + else if (command == "\\qquad{}") + kind_ = QQUAD; + else if (command == "\\enspace{}") + kind_ = ENSPACE; + else if (command == "\\enskip{}") + kind_ = ENSKIP; + else if (command == "\\negthinspace{}") + kind_ = NEGTHIN; + else + lex.printError("InsetSpace: Unknown kind: `$$Token'"); +} + + +int InsetSpace::latex(Buffer const *, ostream & os, bool /*fragile*/, + bool free_space) const +{ + switch (kind_) { + case NORMAL: + os << (free_space ? " " : "\\ "); + break; + case PROTECTED: + os << (free_space ? ' ' : '~'); + break; + case THIN: + os << (free_space ? " " : "\\,"); + break; + case QUAD: + os << (free_space ? " " : "\\quad{}"); + break; + case QQUAD: + os << (free_space ? " " : "\\qquad{}"); + break; + case ENSPACE: + os << (free_space ? " " : "\\enspace{}"); + break; + case ENSKIP: + os << (free_space ? " " : "\\enskip{}"); + break; + case NEGTHIN: + os << (free_space ? " " : "\\negthinspace{}"); + break; + } + return 0; +} + + +int InsetSpace::ascii(Buffer const *, ostream & os, int) const +{ + switch (kind_) { + case NORMAL: + case PROTECTED: + case THIN: + case QUAD: + case QQUAD: + case ENSPACE: + case ENSKIP: + case NEGTHIN: + os << ' '; + break; + } + return 0; +} + + +int InsetSpace::linuxdoc(Buffer const *, ostream & os) const +{ + switch (kind_) { + // fixme: correct? + case NORMAL: + case QUAD: + case QQUAD: + case ENSKIP: + os << " "; + break; + case PROTECTED: + case ENSPACE: + case THIN: + case NEGTHIN: + os << " "; + break; + } + return 0; +} + + +int InsetSpace::docbook(Buffer const *, ostream & os, bool) const +{ + switch (kind_) { + // fixme: correct? + case NORMAL: + case QUAD: + case QQUAD: + case ENSKIP: + os << " "; + break; + case PROTECTED: + case ENSPACE: + case THIN: + case NEGTHIN: + os << " "; + break; + } + return 0; +} + + +Inset * InsetSpace::clone(Buffer const &, bool) const +{ + return new InsetSpace(kind_); +} + + +bool InsetSpace::isChar() const +{ + return true; +} + +bool InsetSpace::isLetter() const +{ + return false; +} + +bool InsetSpace::isSpace() const +{ + return true; +} + +bool InsetSpace::isLineSeparator() const +{ + return false; +} diff --git a/src/insets/insetspace.h b/src/insets/insetspace.h new file mode 100644 index 0000000000..0425c7548e --- /dev/null +++ b/src/insets/insetspace.h @@ -0,0 +1,93 @@ +// -*- C++ -*- +/** + * \file InsetSpace.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Asger Alstrup Nielsen + * \author Jean-Marc Lasgouttes + * \author Lars Gullik Bjønnes + * \author Juergen Spitzmueller + * + * Full author contact details are available in file CREDITS + */ + +#ifndef INSET_SPACE_H +#define INSET_SPACE_H + + +#include "inset.h" +#include "LString.h" + +struct LaTeXFeatures; + +/// Used to insert different kinds of spaces +class InsetSpace : public Inset { +public: + + /// The different kinds of spaces we support + enum Kind { + /// Normal space ('\ ') + NORMAL, + /// Protected (no break) space ('~') + PROTECTED, + /// Thin space ('\,') + THIN, + /// \quad (1em) + QUAD, + /// \qquad (2em) + QQUAD, + /// \enspace (0.5em unbreakable) + ENSPACE, + /// \enspace (0.5em breakable) + ENSKIP, + /// Negative thin space ('\negthinspace') + NEGTHIN + }; + + /// + InsetSpace() {} + /// + explicit + InsetSpace(Kind k); + /// + Kind kind() const; + /// + void dimension(BufferView *, LyXFont const &, Dimension &) const; + /// + void draw(BufferView *, LyXFont const &, int, float &) const; + /// + void write(Buffer const *, std::ostream &) const; + /// Will not be used when lyxf3 + void read(Buffer const *, LyXLex & lex); + /// + int latex(Buffer const *, std::ostream &, + bool fragile, bool free_spc) const; + /// + int ascii(Buffer const *, std::ostream &, int linelen) const; + /// + int linuxdoc(Buffer const *, std::ostream &) const; + /// + int docbook(Buffer const *, std::ostream &, bool mixcont) const; + /// + virtual Inset * clone(Buffer const &, bool same_id = false) const; + /// + Inset::Code lyxCode() const { return Inset::SPACE_CODE; } + /// We don't need \begin_inset and \end_inset + bool directWrite() const { return true; } + + // should this inset be handled like a normal charater + bool isChar() const; + /// is this equivalent to a letter? + bool isLetter() const; + /// is this equivalent to a space (which is BTW different from + // a line separator)? + bool isSpace() const; + // should we break lines after this inset? + bool isLineSeparator() const; +private: + /// And which kind is this? + Kind kind_; +}; + +#endif // INSET_SPACE_H diff --git a/src/insets/insetspecialchar.C b/src/insets/insetspecialchar.C index 8b2dcd46e4..ca09fa1f64 100644 --- a/src/insets/insetspecialchar.C +++ b/src/insets/insetspecialchar.C @@ -50,7 +50,7 @@ void InsetSpecialChar::dimension(BufferView *, LyXFont const & font, case END_OF_SENTENCE: s = "."; break; case LDOTS: s = ". . ."; break; case MENU_SEPARATOR: s = " x "; break; - case PROTECTED_SEPARATOR: s = "x"; break; + case HYPHENATION: s = "-"; break; } dim.w = font_metrics::width(s, font); if (kind_ == HYPHENATION && dim.w > 5) @@ -110,28 +110,6 @@ void InsetSpecialChar::draw(BufferView * bv, LyXFont const & f, x += width(bv, font); break; } - case PROTECTED_SEPARATOR: - { - float w = width(bv, font); - int h = font_metrics::ascent('x', font); - int xp[4], yp[4]; - - xp[0] = int(x); - yp[0] = baseline - max(h / 4, 1); - - xp[1] = int(x); - yp[1] = baseline; - - xp[2] = int(x + w); - yp[2] = baseline; - - xp[3] = int(x + w); - yp[3] = baseline - max(h / 4, 1); - - pain.lines(xp, yp, 4, LColor::special); - x += w; - break; - } } } @@ -156,9 +134,6 @@ void InsetSpecialChar::write(Buffer const *, ostream & os) const case MENU_SEPARATOR: command = "\\menuseparator"; break; - case PROTECTED_SEPARATOR: - command = "~"; - break; } os << "\\SpecialChar " << command << "\n"; } @@ -180,8 +155,6 @@ void InsetSpecialChar::read(Buffer const *, LyXLex & lex) kind_ = LDOTS; else if (command == "\\menuseparator") kind_ = MENU_SEPARATOR; - else if (command == "~") - kind_ = PROTECTED_SEPARATOR; else lex.printError("InsetSpecialChar: Unknown kind: `$$Token'"); } @@ -206,9 +179,6 @@ int InsetSpecialChar::latex(Buffer const *, ostream & os, bool /*fragile*/, case MENU_SEPARATOR: os << "\\lyxarrow{}"; break; - case PROTECTED_SEPARATOR: - os << (free_space ? ' ' : '~'); - break; } return 0; } @@ -229,9 +199,6 @@ int InsetSpecialChar::ascii(Buffer const *, ostream & os, int) const case MENU_SEPARATOR: os << "->"; break; - case PROTECTED_SEPARATOR: - os << ' '; - break; } return 0; } @@ -252,9 +219,6 @@ int InsetSpecialChar::linuxdoc(Buffer const *, ostream & os) const case MENU_SEPARATOR: os << "&lyxarrow;"; break; - case PROTECTED_SEPARATOR: - os << " "; - break; } return 0; } @@ -275,9 +239,6 @@ int InsetSpecialChar::docbook(Buffer const *, ostream & os, bool) const case MENU_SEPARATOR: os << "&lyxarrow;"; break; - case PROTECTED_SEPARATOR: - os << " "; - break; } return 0; } @@ -311,7 +272,7 @@ bool InsetSpecialChar::isLetter() const bool InsetSpecialChar::isSpace() const { - return kind_ == PROTECTED_SEPARATOR; + return false; } diff --git a/src/insets/insetspecialchar.h b/src/insets/insetspecialchar.h index e56b713a22..822cd39c9a 100644 --- a/src/insets/insetspecialchar.h +++ b/src/insets/insetspecialchar.h @@ -36,8 +36,6 @@ public: END_OF_SENTENCE, /// Menu separator MENU_SEPARATOR, - /// Protected Separator - PROTECTED_SEPARATOR }; /// diff --git a/src/lfuns.h b/src/lfuns.h index d8891495e4..f92ad52600 100644 --- a/src/lfuns.h +++ b/src/lfuns.h @@ -101,7 +101,7 @@ enum kb_action { // 60 LFUN_BEGINNINGBUFSEL, LFUN_ENDBUFSEL, - LFUN_PROTECTEDSPACE, + LFUN_SPACE_INSERT, // JSpitzm 20030520 LFUN_SETMARK, LFUN_DELETE, // 65 diff --git a/src/lyxfunc.C b/src/lyxfunc.C index c00c24694b..76dc5425ce 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -663,10 +663,10 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const case LFUN_END_OF_SENTENCE: code = Inset::SPECIALCHAR_CODE; break; - case LFUN_PROTECTEDSPACE: + case LFUN_SPACE_INSERT: // slight hack: we know this is allowed in math mode if (!mathcursor) - code = Inset::SPECIALCHAR_CODE; + code = Inset::SPACE_CODE; break; default: break; diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 816e81216d..42c6f32aae 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -637,7 +637,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) break; } - case LFUN_PROTECTEDSPACE: + case LFUN_SPACE_INSERT: case LFUN_MATH_SPACE: bv->lockedInsetStoreUndo(Undo::EDIT); mathcursor->insert(MathAtom(new MathSpaceInset(","))); diff --git a/src/paragraph_funcs.C b/src/paragraph_funcs.C index 19cc57f1c9..a9c851dcef 100644 --- a/src/paragraph_funcs.C +++ b/src/paragraph_funcs.C @@ -27,6 +27,7 @@ #include "insets/insetoptarg.h" #include "insets/insetcommandparams.h" #include "insets/insetbibitem.h" +#include "insets/insetspace.h" #include "insets/insetspecialchar.h" #include "insets/insetlatexaccent.h" #include "insets/insettabular.h" @@ -926,26 +927,30 @@ int readParToken(Buffer & buf, Paragraph & par, LyXLex & lex, string const & tok } else if (token == "\\color") { lex.next(); font.setLyXColor(lex.getString()); - } else if (token == "\\SpecialChar") { + } else if (token == "\\InsetSpace" || token == "\\SpecialChar") { LyXLayout_ptr const & layout = par.layout(); // Insets don't make sense in a free-spacing context! ---Kayvan if (layout->free_spacing || par.isFreeSpacing()) { - if (lex.isOK()) { + if (token == "\\InsetSpace") + par.insertChar(par.size(), ' ', font, change); + else if (lex.isOK()) { lex.next(); string const next_token = lex.getString(); - if (next_token == "\\-") { + if (next_token == "\\-") par.insertChar(par.size(), '-', font, change); - } else if (next_token == "~") { - par.insertChar(par.size(), ' ', font, change); - } else { + else { lex.printError("Token `$$Token' " "is in free space " "paragraph layout!"); } } } else { - Inset * inset = new InsetSpecialChar; + Inset * inset = 0; + if (token == "\\SpecialChar" ) + inset = new InsetSpecialChar; + else + inset = new InsetSpace; inset->read(&buf, lex); par.insertInset(par.size(), inset, font, change); } diff --git a/src/text3.C b/src/text3.C index cab4f23c0e..25e64e602b 100644 --- a/src/text3.C +++ b/src/text3.C @@ -930,12 +930,12 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) bv->switchKeyMap(); break; - case LFUN_PROTECTEDSPACE: + case LFUN_SPACE_INSERT: if (cursor.par()->layout()->free_spacing) { insertChar(' '); update(); } else { - specialChar(this, bv, InsetSpecialChar::PROTECTED_SEPARATOR); + doInsertInset(this, cmd, false, false); } moveCursorUpdate(bv, false); break;