+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
\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"
\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"
\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"
\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"
\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"
\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
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
///
string const nextWord(float & value);
///
- void insertCorrectQuote();
- ///
bool gotoLabel(string const & label);
///
void 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)
{
break;
case LFUN_QUOTE:
- bv_->insertCorrectQuote();
+ smartQuote();
break;
case LFUN_HTMLURL:
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:
{
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:
{
}
break;
- case LFUN_INSERT_NOTE:
- insertNote();
- break;
-
case LFUN_SELFINSERT:
{
if (argument.empty()) break;
}
}
- bv_->beforeChange(lt);
+ beforeChange(lt);
LyXFont const old_font(lt->real_current_font);
string::const_iterator cit = argument.begin();
}
-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)
{
///
void hfill();
///
- void insertNote();
+ void smartQuote();
+ ///
+ void insertAndEditInset(Inset *);
///
void gotoInset(std::vector<Inset::Code> const & codes,
bool same_content);
+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!
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));
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;
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) {
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: `"
#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"
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();
}
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)
inset = new InsetParent(inscmd, *this);
}
} else {
+ bool alreadyread = false;
if (tmptok == "Quotes") {
inset = new InsetQuotes;
} else if (tmptok == "External") {
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" );
inset = new InsetFloatList;
}
- if (inset) inset->read(this, lex);
+ if (inset && !alreadyread) inset->read(this, lex);
}
if (inset) {
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);
+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
///
CITE_CODE,
///
- FLOAT_LIST_CODE
+ FLOAT_LIST_CODE,
+ ///
+ INDEX_PRINT_CODE
};
///
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;
}
int InsetCollapsable::width(BufferView * bv, LyXFont const & font) const
{
+ if (!widthCollapsed)
+ widthCollapsed = width_collapsed(bv->painter(), font);
+
if (collapsed_)
return widthCollapsed;
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) +
class Paragraph;
class LyXCursor;
-/** A colapsable text inset
+/** A collapsable text inset
*/
class InsetCollapsable : public UpdatableInset {
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 &);
///
///
bool autocollapse;
///
- int widthCollapsed;
+ mutable int widthCollapsed;
///
mutable int oldWidth;
///
}
-InsetERT::InsetERT(string const & contents)
+InsetERT::InsetERT(string const & contents, bool collapsed)
+ : InsetCollapsable(collapsed)
{
setLabel(_("666"));
LyXFont font(LyXFont::ALL_SANE);
///
InsetERT();
///
- InsetERT(string const & contents);
+ InsetERT(string const & contents, bool collapsed);
///
virtual void 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);
}
}
+Inset::Code InsetIndex::lyxCode() const
+{
+ return Inset::INDEX_CODE;
+}
+
+
InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p, bool)
: InsetCommand(p)
{}
Inset::Code InsetPrintIndex::lyxCode() const
{
- return Inset::INDEX_CODE;
+ return Inset::INDEX_PRINT_CODE;
}
void edit(BufferView *, int, int, unsigned int);
///
void edit(BufferView * bv, bool front = true);
+ ///
+ Inset::Code lyxCode() const;
};
#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
{
*/
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;
///
///
virtual int latex(Buffer const *, std::ostream &, bool, bool) const
{ return 0; }
+private:
+ /// used by the constructors
+ void init();
+
};
#endif
}
-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_]];
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
}
-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) {
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);
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");
}
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) {
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
{
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) {
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);
int InsetSpecialChar::width(BufferView *, LyXFont const & font) const
{
- switch (kind) {
+ switch (kind_) {
case HYPHENATION:
{
int w = lyxfont::width('-', font);
Painter & pain = bv->painter();
LyXFont font(f);
- switch (kind) {
+ switch (kind_) {
case HYPHENATION:
{
font.setColor(LColor::special);
void InsetSpecialChar::write(Buffer const *, ostream & os) const
{
string command;
- switch (kind) {
+ switch (kind_) {
case HYPHENATION:
command = "\\-";
break;
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'");
}
int InsetSpecialChar::latex(Buffer const *, ostream & os, bool /*fragile*/,
bool free_space) const
{
- switch (kind) {
+ switch (kind_) {
case HYPHENATION:
os << "\\-";
break;
int InsetSpecialChar::ascii(Buffer const *, ostream & os, int) const
{
- switch (kind) {
+ switch (kind_) {
case HYPHENATION:
case LIGATURE_BREAK:
break;
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;
}
}
explicit
InsetSpecialChar(Kind k);
///
+ Kind kind() const;
+ ///
int ascent(BufferView *, LyXFont const &) const;
///
int descent(BufferView *, LyXFont const &) const;
void validate(LaTeXFeatures &) const;
private:
/// And which kind is this?
- Kind kind;
+ Kind kind_;
};
#endif
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;
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;
case LFUN_REF_INSERT:
code = Inset::REF_CODE;
break;
+ case LFUN_CITATION_CREATE:
case LFUN_CITATION_INSERT:
code = Inset::CITE_CODE;
break;
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;
}
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;
}
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;
///
void deleteLineForward(BufferView *);
///
- bool selectWordWhenUnderCursor(BufferView *);
+ bool selectWordWhenUnderCursor(BufferView *,
+ word_location const = WHOLE_WORD);
///
enum TextCase {
///
+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
par()->Validate(features);
}
+bool InsetFormula::insetAllowed(Inset::Code code) const
+{
+ return code == Inset::LABEL_CODE;
+}
+
int InsetFormula::ascent(BufferView *, LyXFont const &) const
{
///
Inset::Code lyxCode() const;
///
+ bool insetAllowed(Inset::Code code) const;
+ ///
virtual RESULT localDispatch(BufferView *, kb_action, string const &);
///
std::vector<string> const getLabelList() const;
#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"
}
}
-/* -------> 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;
}
-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;
/* -------> 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;
// 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
// 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());
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());
#include "buffer.h"
#include "lyxrc.h"
#include "support/lstrings.h"
-#include "language.h"
using std::endl;
using std::pair;
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]);
}
}
{
// 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.