fix insertion of raw double quote, reading of Info inset, initial width of collapsed insets, insertion of index; better support for insetAllowed, for french quotes

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2300 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2001-07-23 09:11:14 +00:00
parent 3b49ef85f7
commit 55bf6460f3
38 changed files with 384 additions and 272 deletions

View 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

View 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"

View 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"

View 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"

View 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

View 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

View File

@ -133,8 +133,6 @@ public:
///
string const nextWord(float & value);
///
void insertCorrectQuote();
///
bool gotoLabel(string const & label);
///
void paste();

View 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)
{

View 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)
{

View 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);

View 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!

View 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) {

View 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: `"

View 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) {

View 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);

View 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

View File

@ -106,7 +106,9 @@ public:
///
CITE_CODE,
///
FLOAT_LIST_CODE
FLOAT_LIST_CODE,
///
INDEX_PRINT_CODE
};
///

View 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) +

View 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;
///

View 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);

View 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;
///

View 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);
}

View 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;
}

View File

@ -38,6 +38,8 @@ public:
void edit(BufferView *, int, int, unsigned int);
///
void edit(BufferView * bv, bool front = true);
///
Inset::Code lyxCode() const;
};

View 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"
@ -25,19 +26,34 @@
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
{

View File

@ -23,8 +23,10 @@
*/
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

View 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) {

View 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;
}
}

View 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

View 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_CHILD_INSERT:
code = Inset::CHILD_CODE;
case LFUN_INDEX_PRINT:
code = Inset::INDEX_PRINT_CODE;
break;
case LFUN_CHILD_INSERT:
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;
}

View 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;
}

View 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 {
///

View 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

View 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
{

View 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;

View 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());

View 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());

View 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.