2003-03-12 22:17:50 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file bufferview_funcs.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2003-03-12 22:17:50 +00:00
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author Angus Leeming
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-03-12 22:17:50 +00:00
|
|
|
|
*/
|
2000-07-24 13:53:19 +00:00
|
|
|
|
|
2000-04-12 15:11:29 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "bufferview_funcs.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
|
2003-09-09 17:00:19 +00:00
|
|
|
|
#include "author.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "buffer.h"
|
2003-09-09 11:24:33 +00:00
|
|
|
|
#include "bufferparams.h"
|
2000-04-12 15:11:29 +00:00
|
|
|
|
#include "BufferView.h"
|
2001-04-17 15:15:59 +00:00
|
|
|
|
#include "gettext.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "language.h"
|
2003-09-06 12:36:58 +00:00
|
|
|
|
#include "lyxlex.h"
|
|
|
|
|
#include "lyxrow.h"
|
2003-09-06 17:23:08 +00:00
|
|
|
|
#include "paragraph.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#include "ParagraphParameters.h"
|
2000-04-12 15:11:29 +00:00
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
|
#include "frontends/Alert.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "frontends/LyXView.h"
|
|
|
|
|
|
|
|
|
|
#include "insets/insettext.h"
|
|
|
|
|
|
2003-04-07 05:37:58 +00:00
|
|
|
|
#include "mathed/math_cursor.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2003-05-13 14:36:24 +00:00
|
|
|
|
#include "support/tostr.h"
|
2001-08-02 18:46:53 +00:00
|
|
|
|
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "support/std_sstream.h"
|
2003-02-20 17:39:48 +00:00
|
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
|
using namespace lyx::support;
|
|
|
|
|
|
2003-09-05 18:02:24 +00:00
|
|
|
|
using std::istringstream;
|
|
|
|
|
using std::ostringstream;
|
|
|
|
|
|
2002-11-21 18:33:09 +00:00
|
|
|
|
|
2003-03-12 22:17:50 +00:00
|
|
|
|
namespace {
|
2003-04-03 00:36:31 +00:00
|
|
|
|
|
2003-03-12 22:17:50 +00:00
|
|
|
|
LyXFont freefont(LyXFont::ALL_IGNORE);
|
|
|
|
|
bool toggleall(false);
|
2003-04-03 00:36:31 +00:00
|
|
|
|
|
2003-03-12 22:17:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-04-03 00:36:31 +00:00
|
|
|
|
namespace bv_funcs {
|
2003-03-12 22:17:50 +00:00
|
|
|
|
|
|
|
|
|
// Set data using font and toggle
|
|
|
|
|
// If successful, returns true
|
|
|
|
|
bool font2string(LyXFont const & font, bool toggle, string & data)
|
|
|
|
|
{
|
|
|
|
|
string lang = "ignore";
|
|
|
|
|
if (font.language())
|
|
|
|
|
lang = font.language()->lang();
|
|
|
|
|
|
|
|
|
|
ostringstream os;
|
|
|
|
|
os << "family " << font.family() << '\n'
|
|
|
|
|
<< "series " << font.series() << '\n'
|
|
|
|
|
<< "shape " << font.shape() << '\n'
|
|
|
|
|
<< "size " << font.size() << '\n'
|
|
|
|
|
<< "emph " << font.emph() << '\n'
|
|
|
|
|
<< "underbar " << font.underbar() << '\n'
|
|
|
|
|
<< "noun " << font.noun() << '\n'
|
|
|
|
|
<< "number " << font.number() << '\n'
|
|
|
|
|
<< "color " << font.color() << '\n'
|
|
|
|
|
<< "language " << lang << '\n'
|
|
|
|
|
<< "toggleall " << tostr(toggle);
|
2003-05-13 09:48:57 +00:00
|
|
|
|
data = STRCONV(os.str());
|
2003-03-12 22:17:50 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set font and toggle using data
|
|
|
|
|
// If successful, returns true
|
|
|
|
|
bool string2font(string const & data, LyXFont & font, bool & toggle)
|
|
|
|
|
{
|
2003-05-13 09:48:57 +00:00
|
|
|
|
istringstream is(STRCONV(data));
|
2003-03-12 22:17:50 +00:00
|
|
|
|
LyXLex lex(0,0);
|
|
|
|
|
lex.setStream(is);
|
|
|
|
|
|
|
|
|
|
int nset = 0;
|
|
|
|
|
while (lex.isOK()) {
|
2003-04-01 09:39:06 +00:00
|
|
|
|
string token;
|
|
|
|
|
if (lex.next())
|
|
|
|
|
token = lex.getString();
|
2003-03-12 22:17:50 +00:00
|
|
|
|
|
2003-04-01 09:39:06 +00:00
|
|
|
|
if (token.empty() || !lex.next())
|
2003-03-12 22:17:50 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (token == "family") {
|
2003-04-01 09:39:06 +00:00
|
|
|
|
int const next = lex.getInteger();
|
2003-04-01 10:07:08 +00:00
|
|
|
|
font.setFamily(LyXFont::FONT_FAMILY(next));
|
2003-03-30 21:42:09 +00:00
|
|
|
|
|
2003-03-12 22:17:50 +00:00
|
|
|
|
} else if (token == "series") {
|
2003-04-01 09:39:06 +00:00
|
|
|
|
int const next = lex.getInteger();
|
2003-04-01 10:07:08 +00:00
|
|
|
|
font.setSeries(LyXFont::FONT_SERIES(next));
|
2003-03-12 22:17:50 +00:00
|
|
|
|
|
|
|
|
|
} else if (token == "shape") {
|
2003-04-01 09:39:06 +00:00
|
|
|
|
int const next = lex.getInteger();
|
2003-04-01 10:07:08 +00:00
|
|
|
|
font.setShape(LyXFont::FONT_SHAPE(next));
|
2003-03-12 22:17:50 +00:00
|
|
|
|
|
|
|
|
|
} else if (token == "size") {
|
2003-04-01 09:39:06 +00:00
|
|
|
|
int const next = lex.getInteger();
|
2003-04-01 10:07:08 +00:00
|
|
|
|
font.setSize(LyXFont::FONT_SIZE(next));
|
2003-04-01 09:39:06 +00:00
|
|
|
|
|
|
|
|
|
} else if (token == "emph" || token == "underbar" ||
|
|
|
|
|
token == "noun" || token == "number") {
|
|
|
|
|
|
|
|
|
|
int const next = lex.getInteger();
|
|
|
|
|
LyXFont::FONT_MISC_STATE const misc =
|
2003-04-01 10:07:08 +00:00
|
|
|
|
LyXFont::FONT_MISC_STATE(next);
|
2003-04-01 09:39:06 +00:00
|
|
|
|
|
|
|
|
|
if (token == "emph")
|
|
|
|
|
font.setEmph(misc);
|
|
|
|
|
else if (token == "underbar")
|
|
|
|
|
font.setUnderbar(misc);
|
|
|
|
|
else if (token == "noun")
|
|
|
|
|
font.setNoun(misc);
|
|
|
|
|
else if (token == "number")
|
|
|
|
|
font.setNumber(misc);
|
2003-03-12 22:17:50 +00:00
|
|
|
|
|
|
|
|
|
} else if (token == "color") {
|
2003-04-01 09:39:06 +00:00
|
|
|
|
int const next = lex.getInteger();
|
2003-04-01 10:07:08 +00:00
|
|
|
|
font.setColor(LColor::color(next));
|
2003-03-12 22:17:50 +00:00
|
|
|
|
|
|
|
|
|
} else if (token == "language") {
|
2003-04-01 09:39:06 +00:00
|
|
|
|
string const next = lex.getString();
|
|
|
|
|
if (next == "ignore")
|
2003-03-12 22:17:50 +00:00
|
|
|
|
font.setLanguage(ignore_language);
|
|
|
|
|
else
|
2003-04-01 09:39:06 +00:00
|
|
|
|
font.setLanguage(languages.getLanguage(next));
|
2003-03-12 22:17:50 +00:00
|
|
|
|
|
|
|
|
|
} else if (token == "toggleall") {
|
2003-04-01 09:39:06 +00:00
|
|
|
|
toggle = lex.getBool();
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
// Unrecognised token
|
|
|
|
|
break;
|
2003-03-12 22:17:50 +00:00
|
|
|
|
}
|
2003-04-01 09:39:06 +00:00
|
|
|
|
|
|
|
|
|
++nset;
|
2003-03-12 22:17:50 +00:00
|
|
|
|
}
|
|
|
|
|
return (nset > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string const freefont2string()
|
|
|
|
|
{
|
|
|
|
|
string data;
|
|
|
|
|
if (font2string(freefont, toggleall, data))
|
|
|
|
|
return data;
|
|
|
|
|
return string();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void update_and_apply_freefont(BufferView * bv, string const & data)
|
|
|
|
|
{
|
|
|
|
|
LyXFont font;
|
|
|
|
|
bool toggle;
|
|
|
|
|
if (string2font(data, font, toggle)) {
|
|
|
|
|
freefont = font;
|
|
|
|
|
toggleall = toggle;
|
|
|
|
|
apply_freefont(bv);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void apply_freefont(BufferView * bv)
|
|
|
|
|
{
|
|
|
|
|
toggleAndShow(bv, freefont, toggleall);
|
|
|
|
|
bv->owner()->view_state_changed();
|
|
|
|
|
bv->owner()->message(_("Character set"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-08-02 18:46:53 +00:00
|
|
|
|
void emph(BufferView * bv)
|
2000-04-12 15:11:29 +00:00
|
|
|
|
{
|
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
|
font.setEmph(LyXFont::TOGGLE);
|
2001-08-02 18:46:53 +00:00
|
|
|
|
toggleAndShow(bv, font);
|
2000-04-12 15:11:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-08-02 18:46:53 +00:00
|
|
|
|
void bold(BufferView * bv)
|
2000-04-12 15:11:29 +00:00
|
|
|
|
{
|
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
|
font.setSeries(LyXFont::BOLD_SERIES);
|
2001-08-02 18:46:53 +00:00
|
|
|
|
toggleAndShow(bv, font);
|
2000-04-12 15:11:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-08-02 18:46:53 +00:00
|
|
|
|
void noun(BufferView * bv)
|
2000-04-12 15:11:29 +00:00
|
|
|
|
{
|
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
|
font.setNoun(LyXFont::TOGGLE);
|
2001-08-02 18:46:53 +00:00
|
|
|
|
toggleAndShow(bv, font);
|
2000-04-12 15:11:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-08-02 18:46:53 +00:00
|
|
|
|
void number(BufferView * bv)
|
2000-10-09 12:30:52 +00:00
|
|
|
|
{
|
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
|
font.setNumber(LyXFont::TOGGLE);
|
2001-08-02 18:46:53 +00:00
|
|
|
|
toggleAndShow(bv, font);
|
2000-10-09 12:30:52 +00:00
|
|
|
|
}
|
2000-04-12 15:11:29 +00:00
|
|
|
|
|
2003-08-11 09:09:01 +00:00
|
|
|
|
|
2001-08-02 18:46:53 +00:00
|
|
|
|
void lang(BufferView * bv, string const & l)
|
2000-04-12 15:11:29 +00:00
|
|
|
|
{
|
2000-10-10 12:36:36 +00:00
|
|
|
|
Language const * lang = languages.getLanguage(l);
|
2003-03-29 10:55:48 +00:00
|
|
|
|
if (!lang)
|
|
|
|
|
return;
|
|
|
|
|
|
2003-08-05 08:07:07 +00:00
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
2003-03-29 10:55:48 +00:00
|
|
|
|
font.setLanguage(lang);
|
|
|
|
|
toggleAndShow(bv, font);
|
2000-04-12 15:11:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-04-03 01:26:02 +00:00
|
|
|
|
bool changeDepth(BufferView * bv, LyXText * text, DEPTH_CHANGE type, bool test_only)
|
2000-04-12 15:11:29 +00:00
|
|
|
|
{
|
2000-12-22 14:44:29 +00:00
|
|
|
|
if (!bv->available() || !text)
|
2003-08-05 08:07:07 +00:00
|
|
|
|
return false;
|
2003-04-03 01:26:02 +00:00
|
|
|
|
|
|
|
|
|
if (test_only)
|
|
|
|
|
return text->changeDepth(type, true);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-04-03 01:26:02 +00:00
|
|
|
|
bool const changed = text->changeDepth(type, false);
|
2000-12-22 14:44:29 +00:00
|
|
|
|
if (text->inset_owner)
|
2003-08-27 13:51:18 +00:00
|
|
|
|
bv->updateInset(text->inset_owner);
|
2003-04-03 01:26:02 +00:00
|
|
|
|
return changed;
|
2000-04-12 15:11:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-08-02 18:46:53 +00:00
|
|
|
|
void code(BufferView * bv)
|
2000-04-12 15:11:29 +00:00
|
|
|
|
{
|
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
|
font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
|
2001-08-02 18:46:53 +00:00
|
|
|
|
toggleAndShow(bv, font);
|
2000-04-12 15:11:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-08-02 18:46:53 +00:00
|
|
|
|
void sans(BufferView * bv)
|
2000-04-12 15:11:29 +00:00
|
|
|
|
{
|
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
|
font.setFamily(LyXFont::SANS_FAMILY);
|
2001-08-02 18:46:53 +00:00
|
|
|
|
toggleAndShow(bv, font);
|
2000-04-12 15:11:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-08-02 18:46:53 +00:00
|
|
|
|
void roman(BufferView * bv)
|
2000-04-12 15:11:29 +00:00
|
|
|
|
{
|
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
|
font.setFamily(LyXFont::ROMAN_FAMILY);
|
2001-08-02 18:46:53 +00:00
|
|
|
|
toggleAndShow(bv, font);
|
2000-04-12 15:11:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-08-02 18:46:53 +00:00
|
|
|
|
void styleReset(BufferView * bv)
|
2000-04-12 15:11:29 +00:00
|
|
|
|
{
|
2001-08-11 18:31:14 +00:00
|
|
|
|
LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
|
2001-08-02 18:46:53 +00:00
|
|
|
|
toggleAndShow(bv, font);
|
2000-04-12 15:11:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-08-02 18:46:53 +00:00
|
|
|
|
void underline(BufferView * bv)
|
2000-04-12 15:11:29 +00:00
|
|
|
|
{
|
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
|
font.setUnderbar(LyXFont::TOGGLE);
|
2001-08-02 18:46:53 +00:00
|
|
|
|
toggleAndShow(bv, font);
|
2000-04-12 15:11:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-08-02 18:46:53 +00:00
|
|
|
|
void fontSize(BufferView * bv, string const & size)
|
2000-04-12 15:11:29 +00:00
|
|
|
|
{
|
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
2000-11-28 15:54:29 +00:00
|
|
|
|
font.setLyXSize(size);
|
2001-08-02 18:46:53 +00:00
|
|
|
|
toggleAndShow(bv, font);
|
2000-04-12 15:11:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
// Returns the current font and depth as a message.
|
2001-08-02 18:46:53 +00:00
|
|
|
|
string const currentState(BufferView * bv)
|
2000-04-12 15:11:29 +00:00
|
|
|
|
{
|
2002-08-24 22:02:30 +00:00
|
|
|
|
if (!bv->available())
|
2003-02-08 19:18:01 +00:00
|
|
|
|
return string();
|
2002-09-06 15:18:11 +00:00
|
|
|
|
|
2003-04-07 05:37:58 +00:00
|
|
|
|
if (mathcursor)
|
|
|
|
|
return mathcursor->info();
|
|
|
|
|
|
2003-02-20 17:39:48 +00:00
|
|
|
|
ostringstream state;
|
|
|
|
|
|
2002-08-24 22:02:30 +00:00
|
|
|
|
LyXText * text = bv->getLyXText();
|
|
|
|
|
Buffer * buffer = bv->buffer();
|
2003-02-08 19:18:01 +00:00
|
|
|
|
LyXCursor const & c(text->cursor);
|
|
|
|
|
|
2003-09-09 09:47:59 +00:00
|
|
|
|
bool const show_change = buffer->params().tracking_changes
|
2003-02-08 19:18:01 +00:00
|
|
|
|
&& c.pos() != c.par()->size()
|
|
|
|
|
&& c.par()->lookupChange(c.pos()) != Change::UNCHANGED;
|
|
|
|
|
|
|
|
|
|
if (show_change) {
|
|
|
|
|
Change change(c.par()->lookupChangeFull(c.pos()));
|
2003-09-09 17:00:19 +00:00
|
|
|
|
Author const & a(bv->buffer()->params().authors().get(change.author));
|
2003-02-08 19:18:01 +00:00
|
|
|
|
state << _("Change: ") << a.name();
|
|
|
|
|
if (!a.email().empty()) {
|
|
|
|
|
state << " (" << a.email() << ")";
|
|
|
|
|
}
|
|
|
|
|
if (change.changetime)
|
|
|
|
|
state << _(" at ") << ctime(&change.changetime);
|
|
|
|
|
state << " : ";
|
|
|
|
|
}
|
2003-03-04 09:27:27 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
// I think we should only show changes from the default
|
|
|
|
|
// font. (Asger)
|
2002-08-24 22:02:30 +00:00
|
|
|
|
LyXFont font = text->real_current_font;
|
|
|
|
|
LyXFont const & defaultfont =
|
2003-09-09 09:47:59 +00:00
|
|
|
|
buffer->params().getLyXTextClass().defaultfont();
|
2002-08-24 22:02:30 +00:00
|
|
|
|
font.reduce(defaultfont);
|
|
|
|
|
|
2003-05-16 14:35:15 +00:00
|
|
|
|
// avoid _(...) re-entrance problem
|
2003-09-09 09:47:59 +00:00
|
|
|
|
string const s = font.stateText(&buffer->params());
|
2003-05-16 14:35:15 +00:00
|
|
|
|
state << bformat(_("Font: %1$s"), s);
|
|
|
|
|
|
|
|
|
|
// state << bformat(_("Font: %1$s"), font.stateText(&buffer->params));
|
2002-08-24 22:02:30 +00:00
|
|
|
|
|
|
|
|
|
// The paragraph depth
|
|
|
|
|
int depth = text->getDepth();
|
2003-05-13 09:48:57 +00:00
|
|
|
|
if (depth > 0)
|
|
|
|
|
state << bformat(_(", Depth: %1$s"), tostr(depth));
|
2002-08-24 22:02:30 +00:00
|
|
|
|
|
|
|
|
|
// The paragraph spacing, but only if different from
|
|
|
|
|
// buffer spacing.
|
|
|
|
|
if (!text->cursor.par()->params().spacing().isDefault()) {
|
|
|
|
|
Spacing::Space cur_space =
|
|
|
|
|
text->cursor.par()->params().spacing().getSpace();
|
|
|
|
|
state << _(", Spacing: ");
|
|
|
|
|
|
|
|
|
|
switch (cur_space) {
|
|
|
|
|
case Spacing::Single:
|
|
|
|
|
state << _("Single");
|
|
|
|
|
break;
|
|
|
|
|
case Spacing::Onehalf:
|
2003-01-23 16:23:43 +00:00
|
|
|
|
state << _("OneHalf");
|
2002-08-24 22:02:30 +00:00
|
|
|
|
break;
|
|
|
|
|
case Spacing::Double:
|
|
|
|
|
state << _("Double");
|
|
|
|
|
break;
|
|
|
|
|
case Spacing::Other:
|
|
|
|
|
state << _("Other (")
|
|
|
|
|
<< text->cursor.par()->params().spacing().getValue()
|
2002-11-27 10:30:28 +00:00
|
|
|
|
<< ')';
|
2002-08-24 22:02:30 +00:00
|
|
|
|
break;
|
|
|
|
|
case Spacing::Default:
|
|
|
|
|
// should never happen, do nothing
|
|
|
|
|
break;
|
2000-04-12 15:11:29 +00:00
|
|
|
|
}
|
2002-08-24 22:02:30 +00:00
|
|
|
|
}
|
2002-03-27 10:27:59 +00:00
|
|
|
|
#ifdef DEVEL_VERSION
|
2002-08-24 22:02:30 +00:00
|
|
|
|
state << _(", Paragraph: ") << text->cursor.par()->id();
|
2003-09-04 13:00:12 +00:00
|
|
|
|
state << _(", Position: ") << text->cursor.pos();
|
2003-09-04 14:33:16 +00:00
|
|
|
|
RowList::iterator rit = text->cursorRow();
|
|
|
|
|
state << bformat(_(", Row b:%1$d e:%2$d"), rit->pos(), rit->end());
|
2003-09-04 13:00:12 +00:00
|
|
|
|
state << _(", Inset: ") <<
|
2003-06-04 16:14:36 +00:00
|
|
|
|
(text->cursor.par()->inInset() ? text->cursor.par()->inInset()->id() : -1);
|
2001-08-05 22:12:27 +00:00
|
|
|
|
#endif
|
2002-11-04 02:12:42 +00:00
|
|
|
|
return STRCONV(state.str());
|
2000-04-12 15:11:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-05-23 12:08:47 +00:00
|
|
|
|
/* Does the actual toggle job of the calls above.
|
2000-04-12 15:11:29 +00:00
|
|
|
|
* Also shows the current font state.
|
|
|
|
|
*/
|
2001-08-02 18:46:53 +00:00
|
|
|
|
void toggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
|
2000-04-12 15:11:29 +00:00
|
|
|
|
{
|
2002-08-09 00:42:12 +00:00
|
|
|
|
if (!bv->available())
|
|
|
|
|
return;
|
2002-09-06 15:18:11 +00:00
|
|
|
|
|
2002-08-09 00:42:12 +00:00
|
|
|
|
if (bv->theLockingInset()) {
|
|
|
|
|
bv->theLockingInset()->setFont(bv, font, toggleall);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2002-09-06 15:18:11 +00:00
|
|
|
|
|
2002-08-09 00:42:12 +00:00
|
|
|
|
LyXText * text = bv->getLyXText();
|
2003-03-17 16:25:00 +00:00
|
|
|
|
text->toggleFree(font, toggleall);
|
2003-08-04 09:06:35 +00:00
|
|
|
|
bv->update();
|
2002-08-09 00:42:12 +00:00
|
|
|
|
|
|
|
|
|
if (font.language() != ignore_language ||
|
|
|
|
|
font.number() != LyXFont::IGNORE) {
|
|
|
|
|
LyXCursor & cursor = text->cursor;
|
2003-08-28 07:41:31 +00:00
|
|
|
|
text->computeBidiTables(text->cursor.par(), *bv->buffer(),
|
2003-08-14 08:34:13 +00:00
|
|
|
|
text->cursorRow());
|
2002-08-09 00:42:12 +00:00
|
|
|
|
if (cursor.boundary() !=
|
2003-08-28 07:41:31 +00:00
|
|
|
|
text->isBoundary(*bv->buffer(), *cursor.par(), cursor.pos(),
|
2002-08-09 00:42:12 +00:00
|
|
|
|
text->real_current_font))
|
2003-03-17 16:25:00 +00:00
|
|
|
|
text->setCursor(cursor.par(), cursor.pos(),
|
2002-08-09 00:42:12 +00:00
|
|
|
|
false, !cursor.boundary());
|
2000-04-12 15:11:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-04-03 00:36:31 +00:00
|
|
|
|
|
2003-07-15 06:51:47 +00:00
|
|
|
|
|
|
|
|
|
// deletes a selection during an insertion
|
|
|
|
|
void replaceSelection(LyXText * lt)
|
|
|
|
|
{
|
|
|
|
|
if (lt->selection.set()) {
|
|
|
|
|
lt->cutSelection(true, false);
|
2003-08-11 09:09:01 +00:00
|
|
|
|
lt->bv()->update();
|
2003-07-15 06:51:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-03 00:36:31 +00:00
|
|
|
|
}; // namespace bv_funcs
|