2000-02-25 12:06:15 +00:00
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
2001-05-30 13:53:44 +00:00
|
|
|
* Copyright 1998-2001 The LyX Team.
|
2000-02-25 12:06:15 +00:00
|
|
|
*
|
|
|
|
* ======================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <fstream>
|
2000-03-08 01:45:25 +00:00
|
|
|
#include <algorithm>
|
2000-02-25 12:06:15 +00:00
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "insettext.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "paragraph.h"
|
2000-02-25 12:06:15 +00:00
|
|
|
#include "lyxlex.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "lyxfont.h"
|
|
|
|
#include "commandtags.h"
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "LyXView.h"
|
|
|
|
#include "BufferView.h"
|
|
|
|
#include "layout.h"
|
|
|
|
#include "LaTeXFeatures.h"
|
|
|
|
#include "Painter.h"
|
|
|
|
#include "lyx_gui_misc.h"
|
2000-03-28 16:18:02 +00:00
|
|
|
#include "lyxtext.h"
|
|
|
|
#include "lyxcursor.h"
|
2000-04-10 14:29:05 +00:00
|
|
|
#include "CutAndPaste.h"
|
2000-04-04 00:19:15 +00:00
|
|
|
#include "font.h"
|
2000-05-15 14:49:36 +00:00
|
|
|
#include "LColor.h"
|
|
|
|
#include "support/textutils.h"
|
|
|
|
#include "support/LAssert.h"
|
2000-06-12 11:27:15 +00:00
|
|
|
#include "lyxrow.h"
|
2000-06-16 15:13:25 +00:00
|
|
|
#include "lyxrc.h"
|
|
|
|
#include "intl.h"
|
|
|
|
#include "trans_mgr.h"
|
2000-06-19 15:33:58 +00:00
|
|
|
#include "lyxscreen.h"
|
2000-09-19 13:50:47 +00:00
|
|
|
#include "WorkArea.h"
|
2001-04-17 14:17:11 +00:00
|
|
|
#include "gettext.h"
|
2001-04-27 14:03:25 +00:00
|
|
|
#include "lyxfunc.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "ParagraphParameters.h"
|
2000-04-04 00:19:15 +00:00
|
|
|
|
|
|
|
using std::ostream;
|
|
|
|
using std::ifstream;
|
2000-04-24 20:58:23 +00:00
|
|
|
using std::endl;
|
2000-04-04 00:19:15 +00:00
|
|
|
using std::min;
|
|
|
|
using std::max;
|
2000-02-25 12:06:15 +00:00
|
|
|
|
|
|
|
extern unsigned char getCurrentTextClass(Buffer *);
|
2001-01-02 16:06:14 +00:00
|
|
|
extern bool math_insert_greek(BufferView *, char);
|
|
|
|
extern int greek_kb_flag;
|
2000-02-25 12:06:15 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
InsetText::InsetText()
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
par = new Paragraph;
|
2001-04-02 14:02:58 +00:00
|
|
|
init();
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-19 15:33:58 +00:00
|
|
|
InsetText::InsetText(InsetText const & ins)
|
|
|
|
: UpdatableInset()
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
par = 0;
|
|
|
|
init(&ins);
|
|
|
|
autoBreakRows = ins.autoBreakRows;
|
2000-03-28 16:18:02 +00:00
|
|
|
}
|
|
|
|
|
2000-04-24 20:58:23 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
InsetText & InsetText::operator=(InsetText const & it)
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
init(&it);
|
|
|
|
autoBreakRows = it.autoBreakRows;
|
|
|
|
return * this;
|
2000-06-12 11:27:15 +00:00
|
|
|
}
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
void InsetText::init(InsetText const * ins)
|
2000-03-28 16:18:02 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
top_y = 0;
|
|
|
|
last_width = 0;
|
|
|
|
last_height = 0;
|
|
|
|
insetAscent = 0;
|
|
|
|
insetDescent = 0;
|
|
|
|
insetWidth = 0;
|
|
|
|
the_locking_inset = 0;
|
2001-05-28 15:11:24 +00:00
|
|
|
old_max_width = 0;
|
2001-04-02 14:02:58 +00:00
|
|
|
no_selection = false;
|
|
|
|
need_update = INIT;
|
|
|
|
drawTextXOffset = 0;
|
|
|
|
drawTextYOffset = 0;
|
|
|
|
autoBreakRows = false;
|
2001-04-27 14:03:25 +00:00
|
|
|
drawFrame_ = NEVER;
|
2001-04-02 14:02:58 +00:00
|
|
|
xpos = 0.0;
|
|
|
|
if (ins) {
|
2001-06-28 10:25:20 +00:00
|
|
|
setParagraphData(ins->par);
|
2001-04-27 14:03:25 +00:00
|
|
|
autoBreakRows = ins->autoBreakRows;
|
|
|
|
drawFrame_ = ins->drawFrame_;
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
par->setInsetOwner(this);
|
2001-04-02 14:02:58 +00:00
|
|
|
frame_color = LColor::insetframe;
|
|
|
|
locked = false;
|
|
|
|
old_par = 0;
|
|
|
|
last_drawn_width = -1;
|
2001-04-27 14:03:25 +00:00
|
|
|
frame_is_visible = false;
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
InsetText::~InsetText()
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
// delete all instances of LyXText before deleting the paragraps used
|
|
|
|
// by it.
|
2001-04-06 12:47:50 +00:00
|
|
|
for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit) {
|
|
|
|
delete (*cit).second;
|
|
|
|
(*cit).second = 0;
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2001-05-03 14:31:33 +00:00
|
|
|
|
2001-04-06 12:47:50 +00:00
|
|
|
while (par) {
|
2001-06-25 00:06:33 +00:00
|
|
|
Paragraph * tmp = par->next();
|
2001-04-06 12:47:50 +00:00
|
|
|
delete par;
|
|
|
|
par = tmp;
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-14 14:57:20 +00:00
|
|
|
void InsetText::clear()
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
// delete all instances of LyXText before deleting the paragraps used
|
|
|
|
// by it.
|
2001-05-08 10:50:09 +00:00
|
|
|
for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit) {
|
2001-04-02 14:02:58 +00:00
|
|
|
delete (*cit).second;
|
|
|
|
(*cit).second = 0;
|
|
|
|
}
|
2001-05-03 14:31:33 +00:00
|
|
|
|
2001-04-06 12:47:50 +00:00
|
|
|
while (par) {
|
2001-06-25 00:06:33 +00:00
|
|
|
Paragraph * tmp = par->next();
|
2001-04-02 14:02:58 +00:00
|
|
|
delete par;
|
2001-04-06 12:47:50 +00:00
|
|
|
par = tmp;
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
par = new Paragraph;
|
2000-07-14 14:57:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
Inset * InsetText::clone(Buffer const &) const
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
InsetText * t = new InsetText(*this);
|
|
|
|
return t;
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::write(Buffer const * buf, ostream & os) const
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
os << "Text\n";
|
2001-06-28 10:25:20 +00:00
|
|
|
writeParagraphData(buf, os);
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
2000-03-02 02:19:43 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::writeParagraphData(Buffer const * buf, ostream & os) const
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-05-08 17:08:44 +00:00
|
|
|
par->writeFile(buf, os, buf->params, 0);
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
2000-03-02 02:19:43 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::read(Buffer const * buf, LyXLex & lex)
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
string token;
|
|
|
|
int pos = 0;
|
2001-06-25 00:06:33 +00:00
|
|
|
Paragraph * return_par = 0;
|
|
|
|
Paragraph::depth_type depth = 0;
|
2001-04-02 14:02:58 +00:00
|
|
|
LyXFont font(LyXFont::ALL_INHERIT);
|
2000-02-25 12:06:15 +00:00
|
|
|
|
2001-05-08 10:50:09 +00:00
|
|
|
clear();
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
while (lex.IsOK()) {
|
|
|
|
lex.nextToken();
|
|
|
|
token = lex.GetString();
|
|
|
|
if (token.empty())
|
|
|
|
continue;
|
|
|
|
if (token == "\\end_inset")
|
|
|
|
break;
|
|
|
|
if (const_cast<Buffer*>(buf)->
|
2001-04-06 12:47:50 +00:00
|
|
|
parseSingleLyXformat2Token(lex, par, return_par,
|
2001-05-03 14:31:33 +00:00
|
|
|
token, pos, depth, font)) {
|
2001-04-02 14:02:58 +00:00
|
|
|
// the_end read this should NEVER happen
|
|
|
|
lex.printError("\\the_end read in inset! Error in document!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!return_par)
|
|
|
|
return_par = par;
|
|
|
|
par = return_par;
|
|
|
|
while(return_par) {
|
2001-06-25 00:06:33 +00:00
|
|
|
return_par->setInsetOwner(this);
|
2001-04-02 14:02:58 +00:00
|
|
|
return_par = return_par->next();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (token != "\\end_inset") {
|
|
|
|
lex.printError("Missing \\end_inset at this point. "
|
|
|
|
"Read: `$$Token'");
|
|
|
|
}
|
|
|
|
need_update = INIT;
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-05 14:57:48 +00:00
|
|
|
int InsetText::ascent(BufferView * bv, LyXFont const &) const
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
int y_temp = 0;
|
2001-06-25 00:06:33 +00:00
|
|
|
Row * row = TEXT(bv)->getRowNearY(y_temp);
|
2001-04-02 14:02:58 +00:00
|
|
|
insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET;
|
|
|
|
return insetAscent;
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-05 14:57:48 +00:00
|
|
|
int InsetText::descent(BufferView * bv, LyXFont const &) const
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
int y_temp = 0;
|
2001-06-25 00:06:33 +00:00
|
|
|
Row * row = TEXT(bv)->getRowNearY(y_temp);
|
2001-04-02 14:02:58 +00:00
|
|
|
insetDescent = TEXT(bv)->height - row->ascent_of_text() +
|
2000-07-05 14:57:48 +00:00
|
|
|
TEXT_TO_INSET_OFFSET;
|
2001-04-02 14:02:58 +00:00
|
|
|
return insetDescent;
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-05 14:57:48 +00:00
|
|
|
int InsetText::width(BufferView * bv, LyXFont const &) const
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
insetWidth = max(textWidth(bv),
|
|
|
|
(int)TEXT(bv)->width + (2 * TEXT_TO_INSET_OFFSET));
|
|
|
|
return insetWidth;
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
|
2001-03-29 15:00:20 +00:00
|
|
|
int InsetText::textWidth(BufferView * bv) const
|
2000-06-23 15:02:46 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
int const w = getMaxWidth(bv, this);
|
|
|
|
return w;
|
2000-06-23 15:02:46 +00:00
|
|
|
}
|
|
|
|
|
2000-02-25 12:06:15 +00:00
|
|
|
|
2000-06-21 15:07:57 +00:00
|
|
|
void InsetText::draw(BufferView * bv, LyXFont const & f,
|
2001-04-13 14:49:58 +00:00
|
|
|
int baseline, float & x, bool cleared) const
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-27 14:03:25 +00:00
|
|
|
if (nodraw())
|
|
|
|
return;
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
Painter & pain = bv->painter();
|
2000-06-21 15:07:57 +00:00
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
// no draw is necessary !!!
|
2001-04-27 14:03:25 +00:00
|
|
|
if ((drawFrame_ == LOCKED) && !locked && !par->size()) {
|
|
|
|
top_x = int(x);
|
|
|
|
top_baseline = baseline;
|
|
|
|
x += width(bv, f);
|
|
|
|
if (!cleared && (need_update & CLEAR_FRAME))
|
|
|
|
clearFrame(pain, cleared);
|
2001-05-28 15:11:24 +00:00
|
|
|
else if (cleared)
|
|
|
|
frame_is_visible = false;
|
2001-04-27 14:03:25 +00:00
|
|
|
need_update = NONE;
|
|
|
|
return;
|
2000-08-09 13:51:59 +00:00
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
|
|
|
|
xpos = x;
|
2001-04-27 14:03:25 +00:00
|
|
|
#if 0
|
2001-04-02 14:02:58 +00:00
|
|
|
UpdatableInset::draw(bv, f, baseline, x, cleared);
|
2001-04-27 14:03:25 +00:00
|
|
|
#else
|
|
|
|
if (!owner())
|
|
|
|
x += static_cast<float>(scroll());
|
|
|
|
#endif
|
2001-05-28 15:11:24 +00:00
|
|
|
#if 0
|
2001-04-02 14:02:58 +00:00
|
|
|
// update insetWidth and insetHeight with dummy calls
|
|
|
|
(void)ascent(bv, f);
|
|
|
|
(void)descent(bv, f);
|
|
|
|
(void)width(bv, f);
|
2001-05-28 15:11:24 +00:00
|
|
|
#endif
|
2001-04-02 14:02:58 +00:00
|
|
|
|
|
|
|
// if top_x differs we have a rule down and we don't have to clear anything
|
|
|
|
if (!cleared && (top_x == int(x)) &&
|
2001-04-27 14:03:25 +00:00
|
|
|
((need_update&(INIT|FULL)) || (top_baseline!=baseline) ||
|
|
|
|
(last_drawn_width!=insetWidth)))
|
|
|
|
{
|
2001-06-01 15:10:26 +00:00
|
|
|
clearInset(pain, baseline, cleared);
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2001-05-28 15:11:24 +00:00
|
|
|
if (cleared)
|
|
|
|
frame_is_visible = false;
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
if (!cleared && (need_update == NONE))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (top_x != int(x)) {
|
2001-06-14 14:10:25 +00:00
|
|
|
if ((getMaxWidth(bv, this) > 0) &&
|
|
|
|
(TEXT(bv)->width != old_max_width))
|
|
|
|
{
|
2001-05-28 15:11:24 +00:00
|
|
|
resizeLyXText(bv);
|
|
|
|
need_update |= FULL;
|
|
|
|
old_max_width = TEXT(bv)->width;
|
|
|
|
bv->text->status = LyXText::CHANGED_IN_DRAW;
|
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
top_x = int(x);
|
2001-05-28 15:11:24 +00:00
|
|
|
#if 1
|
2001-06-01 15:10:26 +00:00
|
|
|
clearInset(pain, baseline, cleared);
|
2001-05-28 15:11:24 +00:00
|
|
|
#else
|
2001-04-02 14:02:58 +00:00
|
|
|
return;
|
2001-05-28 15:11:24 +00:00
|
|
|
#endif
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2001-04-27 14:03:25 +00:00
|
|
|
|
|
|
|
// lyxerr << "InsetText::draw[" << this << "](" << need_update << ":" << int(x) << ":" << top_x << ")\n";
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
if (cleared || (last_drawn_width != insetWidth)) {
|
|
|
|
need_update |= FULL;
|
|
|
|
last_drawn_width = insetWidth;
|
|
|
|
}
|
2000-06-26 15:10:49 +00:00
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
top_baseline = baseline;
|
|
|
|
top_y = baseline - ascent(bv, f);
|
|
|
|
last_width = width(bv, f);
|
|
|
|
last_height = ascent(bv, f) + descent(bv, f);
|
|
|
|
|
|
|
|
if (the_locking_inset && (cpar(bv) == inset_par) && (cpos(bv) == inset_pos)) {
|
|
|
|
inset_x = cx(bv) - top_x + drawTextXOffset;
|
|
|
|
inset_y = cy(bv) + drawTextYOffset;
|
|
|
|
}
|
2001-05-31 02:23:46 +00:00
|
|
|
if (!cleared && (need_update == CURSOR) && !TEXT(bv)->selection.set()) {
|
2001-04-27 14:03:25 +00:00
|
|
|
drawFrame(pain, cleared);
|
2001-06-25 00:06:33 +00:00
|
|
|
x += last_width; // was width(bv, f);
|
2001-04-02 14:02:58 +00:00
|
|
|
need_update = NONE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
x += TEXT_TO_INSET_OFFSET;
|
2001-04-06 12:47:50 +00:00
|
|
|
|
2000-10-19 09:11:39 +00:00
|
|
|
int y = 0;
|
2001-06-25 00:06:33 +00:00
|
|
|
Row * row = TEXT(bv)->getRowNearY(y);
|
2000-10-19 09:11:39 +00:00
|
|
|
int y_offset = baseline - row->ascent_of_text();
|
|
|
|
int ph = pain.paperHeight();
|
|
|
|
int first = 0;
|
|
|
|
y = y_offset;
|
|
|
|
while ((row != 0) && ((y+row->height()) <= 0)) {
|
2001-04-02 14:02:58 +00:00
|
|
|
y += row->height();
|
|
|
|
first += row->height();
|
|
|
|
row = row->next();
|
2000-06-21 15:07:57 +00:00
|
|
|
}
|
2000-10-19 09:11:39 +00:00
|
|
|
if (y_offset < 0)
|
2001-04-02 14:02:58 +00:00
|
|
|
y_offset = y;
|
2000-10-19 09:11:39 +00:00
|
|
|
TEXT(bv)->first = first;
|
2001-04-27 14:03:25 +00:00
|
|
|
if (cleared) {
|
2001-04-02 14:02:58 +00:00
|
|
|
int yf = y_offset;
|
|
|
|
y = 0;
|
|
|
|
while ((row != 0) && (yf < ph)) {
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->getVisibleRow(bv, y+y_offset, int(x), row,
|
2001-05-28 15:11:24 +00:00
|
|
|
y+first, cleared);
|
|
|
|
y += row->height();
|
|
|
|
yf += row->height();
|
|
|
|
row = row->next();
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2001-02-23 16:10:03 +00:00
|
|
|
} else if (!locked) {
|
2001-04-02 14:02:58 +00:00
|
|
|
if (need_update & CURSOR) {
|
|
|
|
bv->screen()->ToggleSelection(TEXT(bv), bv, true, y_offset,int(x));
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->clearSelection(bv);
|
2001-05-31 02:23:46 +00:00
|
|
|
TEXT(bv)->selection.cursor = TEXT(bv)->cursor;
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
|
|
|
bv->screen()->Update(TEXT(bv), bv, y_offset, int(x));
|
2000-10-19 09:11:39 +00:00
|
|
|
} else {
|
2001-04-02 14:02:58 +00:00
|
|
|
locked = false;
|
|
|
|
if (need_update & SELECTION)
|
|
|
|
bv->screen()->ToggleToggle(TEXT(bv), bv, y_offset, int(x));
|
|
|
|
else if (need_update & CURSOR) {
|
|
|
|
bv->screen()->ToggleSelection(TEXT(bv), bv, true, y_offset,int(x));
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->clearSelection(bv);
|
2001-05-31 02:23:46 +00:00
|
|
|
TEXT(bv)->selection.cursor = TEXT(bv)->cursor;
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
|
|
|
bv->screen()->Update(TEXT(bv), bv, y_offset, int(x));
|
|
|
|
locked = true;
|
|
|
|
}
|
2001-06-14 14:10:25 +00:00
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
TEXT(bv)->refresh_y = 0;
|
|
|
|
TEXT(bv)->status = LyXText::UNCHANGED;
|
|
|
|
if ((need_update != CURSOR_PAR) &&
|
2001-04-27 14:03:25 +00:00
|
|
|
((drawFrame_ == ALWAYS) || ((drawFrame_ == LOCKED) && locked)))
|
|
|
|
drawFrame(pain, cleared);
|
|
|
|
else if (need_update & CLEAR_FRAME)
|
|
|
|
clearFrame(pain, cleared);
|
2001-06-25 00:06:33 +00:00
|
|
|
x += last_width /* was width(bv, f) */ - TEXT_TO_INSET_OFFSET;
|
2001-04-02 14:02:58 +00:00
|
|
|
if (bv->text->status==LyXText::CHANGED_IN_DRAW) {
|
2001-04-27 14:03:25 +00:00
|
|
|
need_update |= INIT;
|
2001-04-02 14:02:58 +00:00
|
|
|
} else if (need_update != INIT)
|
|
|
|
need_update = NONE;
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-27 14:03:25 +00:00
|
|
|
void InsetText::drawFrame(Painter & pain, bool cleared) const
|
|
|
|
{
|
|
|
|
if (!frame_is_visible || cleared) {
|
|
|
|
pain.rectangle(top_x + 1, top_baseline - insetAscent + 1,
|
|
|
|
insetWidth - 1, insetAscent + insetDescent - 1,
|
|
|
|
frame_color);
|
|
|
|
frame_is_visible = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetText::clearFrame(Painter & pain, bool cleared) const
|
|
|
|
{
|
|
|
|
if (frame_is_visible) {
|
|
|
|
if (!cleared) {
|
|
|
|
pain.rectangle(top_x + 1, top_baseline - insetAscent + 1,
|
|
|
|
insetWidth - 1, insetAscent + insetDescent - 1,
|
|
|
|
LColor::background);
|
|
|
|
}
|
|
|
|
frame_is_visible = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-07 07:46:37 +00:00
|
|
|
void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
|
2000-06-16 15:13:25 +00:00
|
|
|
{
|
2001-06-07 14:51:20 +00:00
|
|
|
#if 0
|
|
|
|
int ww = TEXT(bv)->width;
|
|
|
|
TEXT(bv)->BreakParagraph(bv);
|
|
|
|
if (ww != TEXT(bv)->width)
|
|
|
|
reinit = true;
|
|
|
|
#endif
|
2001-04-27 14:03:25 +00:00
|
|
|
if (reinit) {
|
|
|
|
need_update |= INIT;
|
2001-04-02 14:02:58 +00:00
|
|
|
resizeLyXText(bv);
|
|
|
|
if (owner())
|
|
|
|
owner()->update(bv, font, true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (the_locking_inset) {
|
|
|
|
inset_x = cx(bv) - top_x + drawTextXOffset;
|
|
|
|
inset_y = cy(bv) + drawTextYOffset;
|
|
|
|
the_locking_inset->update(bv, font, reinit);
|
|
|
|
}
|
2001-04-27 14:03:25 +00:00
|
|
|
#if 0
|
2001-04-02 14:02:58 +00:00
|
|
|
if (need_update == INIT) {
|
|
|
|
resizeLyXText(bv);
|
2001-04-27 14:03:25 +00:00
|
|
|
need_update |= FULL;
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2001-04-27 14:03:25 +00:00
|
|
|
#endif
|
2001-04-02 14:02:58 +00:00
|
|
|
int oldw = insetWidth;
|
|
|
|
insetWidth = TEXT(bv)->width + (2 * TEXT_TO_INSET_OFFSET);
|
|
|
|
if (oldw != insetWidth) {
|
|
|
|
resizeLyXText(bv);
|
2001-04-27 14:03:25 +00:00
|
|
|
need_update |= FULL;
|
|
|
|
// update(bv, font, reinit);
|
2001-04-02 14:02:58 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-04-27 14:03:25 +00:00
|
|
|
if ((need_update&CURSOR_PAR) && (TEXT(bv)->status==LyXText::UNCHANGED) &&
|
2001-04-02 14:02:58 +00:00
|
|
|
the_locking_inset)
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->updateInset(bv, the_locking_inset);
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH)
|
2001-04-27 14:03:25 +00:00
|
|
|
need_update |= FULL;
|
|
|
|
#if 0
|
2001-04-02 14:02:58 +00:00
|
|
|
int y_temp = 0;
|
|
|
|
Row * row = TEXT(bv)->GetRowNearY(y_temp);
|
|
|
|
insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET;
|
|
|
|
insetDescent = TEXT(bv)->height - row->ascent_of_text() +
|
|
|
|
TEXT_TO_INSET_OFFSET;
|
2001-04-27 14:03:25 +00:00
|
|
|
#endif
|
2000-07-04 11:30:07 +00:00
|
|
|
}
|
|
|
|
|
2001-04-06 12:47:50 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::setUpdateStatus(BufferView * bv, int what) const
|
2001-02-14 08:38:21 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
need_update |= what;
|
|
|
|
if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH)
|
|
|
|
need_update |= FULL;
|
|
|
|
else if (TEXT(bv)->status == LyXText::NEED_VERY_LITTLE_REFRESH)
|
|
|
|
need_update |= CURSOR_PAR;
|
2001-02-22 14:33:08 +00:00
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
// this to not draw a selection when we redraw all of it!
|
|
|
|
if ((need_update & (INIT|FULL)) && (need_update & CURSOR))
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->clearSelection(bv);
|
2001-02-14 08:38:21 +00:00
|
|
|
}
|
2000-07-04 11:30:07 +00:00
|
|
|
|
2001-04-06 12:47:50 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty)
|
2000-07-04 11:30:07 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->fullRebreak(bv);
|
2001-06-28 10:25:20 +00:00
|
|
|
setUpdateStatus(bv, what);
|
2001-04-02 14:02:58 +00:00
|
|
|
if ((need_update != CURSOR) || (TEXT(bv)->status != LyXText::UNCHANGED) ||
|
2001-05-31 02:23:46 +00:00
|
|
|
TEXT(bv)->selection.set())
|
2001-04-02 14:02:58 +00:00
|
|
|
bv->updateInset(this, mark_dirty);
|
|
|
|
bv->owner()->showState();
|
|
|
|
if (old_par != cpar(bv)) {
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->owner()->setLayout(cpar(bv)->getLayout());
|
2001-04-02 14:02:58 +00:00
|
|
|
old_par = cpar(bv);
|
|
|
|
}
|
2000-06-16 15:13:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
string const InsetText::editMessage() const
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
return _("Opened Text Inset");
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::edit(BufferView * bv, int x, int y, unsigned int button)
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2000-06-21 15:07:57 +00:00
|
|
|
// par->SetInsetOwner(this);
|
2001-06-28 10:25:20 +00:00
|
|
|
UpdatableInset::edit(bv, x, y, button);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
|
|
|
if (!bv->lockInset(this)) {
|
|
|
|
lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
locked = true;
|
|
|
|
the_locking_inset = 0;
|
|
|
|
inset_pos = inset_x = inset_y = 0;
|
|
|
|
inset_boundary = false;
|
|
|
|
inset_par = 0;
|
|
|
|
old_par = 0;
|
2001-04-20 14:54:25 +00:00
|
|
|
int tmp_y = (y < 0)?0:y;
|
|
|
|
if (!checkAndActivateInset(bv, x, tmp_y, button))
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->setCursorFromCoordinates(bv, x - drawTextXOffset,
|
2001-04-06 12:47:50 +00:00
|
|
|
y + insetAscent);
|
2001-05-31 02:23:46 +00:00
|
|
|
TEXT(bv)->selection.cursor = TEXT(bv)->cursor;
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->text->finishUndo();
|
2001-06-28 10:25:20 +00:00
|
|
|
showInsetCursor(bv);
|
|
|
|
updateLocal(bv, CURSOR, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
|
|
|
// If the inset is empty set the language of the current font to the
|
2001-05-28 15:11:24 +00:00
|
|
|
// language to the surronding text (if different).
|
|
|
|
if (par->size() == 0 && !par->next() &&
|
|
|
|
bv->getParentLanguage(this) != TEXT(bv)->current_font.language())
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
font.setLanguage(bv->getParentLanguage(this));
|
2001-06-28 10:25:20 +00:00
|
|
|
setFont(bv, font, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::insetUnlock(BufferView * bv)
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (the_locking_inset) {
|
2001-06-28 10:25:20 +00:00
|
|
|
the_locking_inset->insetUnlock(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
the_locking_inset = 0;
|
|
|
|
}
|
2001-06-28 10:25:20 +00:00
|
|
|
hideInsetCursor(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
no_selection = false;
|
|
|
|
locked = false;
|
2001-05-28 15:11:24 +00:00
|
|
|
int code = CURSOR|CLEAR_FRAME;
|
2001-05-31 02:23:46 +00:00
|
|
|
if (TEXT(bv)->selection.set()) {
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->clearSelection(bv);
|
2001-05-28 15:11:24 +00:00
|
|
|
code = FULL;
|
|
|
|
} else if (owner())
|
2001-04-02 14:02:58 +00:00
|
|
|
bv->owner()->setLayout(owner()->getLyXText(bv)
|
2001-06-25 00:06:33 +00:00
|
|
|
->cursor.par()->getLayout());
|
2001-04-02 14:02:58 +00:00
|
|
|
else
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->owner()->setLayout(bv->text->cursor.par()->getLayout());
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, code, false);
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
2000-04-24 20:58:23 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
bool InsetText::lockInsetInInset(BufferView * bv, UpdatableInset * inset)
|
2000-04-19 14:42:19 +00:00
|
|
|
{
|
2001-04-06 12:47:50 +00:00
|
|
|
lyxerr[Debug::INSETS] << "InsetText::LockInsetInInset("
|
|
|
|
<< inset << "): ";
|
2001-04-02 14:02:58 +00:00
|
|
|
if (!inset)
|
|
|
|
return false;
|
2001-06-25 00:06:33 +00:00
|
|
|
if (inset == cpar(bv)->getInset(cpos(bv))) {
|
2001-04-02 14:02:58 +00:00
|
|
|
lyxerr[Debug::INSETS] << "OK" << endl;
|
|
|
|
the_locking_inset = inset;
|
|
|
|
inset_x = cx(bv) - top_x + drawTextXOffset;
|
|
|
|
inset_y = cy(bv) + drawTextYOffset;
|
|
|
|
inset_pos = cpos(bv);
|
|
|
|
inset_par = cpar(bv);
|
|
|
|
inset_boundary = cboundary(bv);
|
2001-02-22 14:09:20 +00:00
|
|
|
#if 0
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->clearSelection(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
|
|
|
|
TEXT(bv)->UpdateInset(bv, the_locking_inset);
|
2001-02-22 14:09:20 +00:00
|
|
|
#else
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR, false);
|
2001-02-22 14:09:20 +00:00
|
|
|
#endif
|
2001-04-02 14:02:58 +00:00
|
|
|
return true;
|
|
|
|
} else if (the_locking_inset && (the_locking_inset == inset)) {
|
|
|
|
if (cpar(bv) == inset_par && cpos(bv) == inset_pos) {
|
|
|
|
lyxerr[Debug::INSETS] << "OK" << endl;
|
|
|
|
inset_x = cx(bv) - top_x + drawTextXOffset;
|
|
|
|
inset_y = cy(bv) + drawTextYOffset;
|
|
|
|
} else {
|
|
|
|
lyxerr[Debug::INSETS] << "cursor.pos != inset_pos" << endl;
|
|
|
|
}
|
|
|
|
} else if (the_locking_inset) {
|
|
|
|
lyxerr[Debug::INSETS] << "MAYBE" << endl;
|
2001-06-28 10:25:20 +00:00
|
|
|
return the_locking_inset->lockInsetInInset(bv, inset);
|
2000-04-19 14:42:19 +00:00
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
lyxerr[Debug::INSETS] << "NOT OK" << endl;
|
|
|
|
return false;
|
2000-04-19 14:42:19 +00:00
|
|
|
}
|
2000-02-25 12:06:15 +00:00
|
|
|
|
2000-04-24 20:58:23 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
bool InsetText::unlockInsetInInset(BufferView * bv, UpdatableInset * inset,
|
2001-04-06 12:47:50 +00:00
|
|
|
bool lr)
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (!the_locking_inset)
|
|
|
|
return false;
|
|
|
|
if (the_locking_inset == inset) {
|
2001-06-28 10:25:20 +00:00
|
|
|
the_locking_inset->insetUnlock(bv);
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->updateInset(bv, inset);
|
2001-04-02 14:02:58 +00:00
|
|
|
the_locking_inset = 0;
|
|
|
|
if (lr)
|
|
|
|
moveRight(bv, false);
|
|
|
|
old_par = 0; // force layout setting
|
2001-04-27 14:03:25 +00:00
|
|
|
if (scroll())
|
|
|
|
scroll(bv, 0.0F);
|
|
|
|
else
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
return true;
|
|
|
|
}
|
2001-06-28 10:25:20 +00:00
|
|
|
return the_locking_inset->unlockInsetInInset(bv, inset, lr);
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
2000-02-25 13:35:38 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
bool InsetText::updateInsetInInset(BufferView * bv, Inset * inset)
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (!the_locking_inset)
|
|
|
|
return false;
|
|
|
|
if (the_locking_inset != inset) {
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->updateInset(bv, the_locking_inset);
|
2001-06-28 10:25:20 +00:00
|
|
|
setUpdateStatus(bv, CURSOR_PAR);
|
|
|
|
return the_locking_inset->updateInsetInInset(bv, inset);
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2001-06-28 10:25:20 +00:00
|
|
|
// updateLocal(bv, FULL, false);
|
2001-06-25 00:06:33 +00:00
|
|
|
if (TEXT(bv)->updateInset(bv, inset))
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR_PAR, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
if (cpar(bv) == inset_par && cpos(bv) == inset_pos) {
|
|
|
|
inset_x = cx(bv) - top_x + drawTextXOffset;
|
|
|
|
inset_y = cy(bv) + drawTextYOffset;
|
|
|
|
}
|
|
|
|
return true;
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
no_selection = true;
|
2000-07-04 11:30:07 +00:00
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
int tmp_x = x - drawTextXOffset;
|
|
|
|
int tmp_y = y + insetAscent - TEXT(bv)->first;
|
|
|
|
Inset * inset = bv->checkInsetHit(TEXT(bv), tmp_x, tmp_y, button);
|
2000-07-04 11:30:07 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
hideInsetCursor(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
if (the_locking_inset) {
|
|
|
|
if (the_locking_inset == inset) {
|
2001-06-28 10:25:20 +00:00
|
|
|
the_locking_inset->insetButtonPress(bv,x-inset_x,y-inset_y,button);
|
2001-04-02 14:02:58 +00:00
|
|
|
no_selection = false;
|
|
|
|
return;
|
|
|
|
} else if (inset) {
|
|
|
|
// otherwise unlock the_locking_inset and lock the new inset
|
2001-06-28 10:25:20 +00:00
|
|
|
the_locking_inset->insetUnlock(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
inset_x = cx(bv) - top_x + drawTextXOffset;
|
|
|
|
inset_y = cy(bv) + drawTextYOffset;
|
|
|
|
the_locking_inset = static_cast<UpdatableInset*>(inset);
|
2001-06-28 10:25:20 +00:00
|
|
|
inset->insetButtonPress(bv, x - inset_x, y - inset_y, button);
|
|
|
|
inset->edit(bv, x - inset_x, y - inset_y, button);
|
2001-04-02 14:02:58 +00:00
|
|
|
if (the_locking_inset)
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
no_selection = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// otherwise only unlock the_locking_inset
|
2001-06-28 10:25:20 +00:00
|
|
|
the_locking_inset->insetUnlock(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
the_locking_inset = 0;
|
2000-04-19 14:42:19 +00:00
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
if (bv->theLockingInset()) {
|
2001-06-28 10:25:20 +00:00
|
|
|
if (inset && inset->editable() == Inset::HIGHLY_EDITABLE) {
|
2001-04-02 14:02:58 +00:00
|
|
|
UpdatableInset * uinset = static_cast<UpdatableInset*>(inset);
|
|
|
|
inset_x = cx(bv) - top_x + drawTextXOffset;
|
|
|
|
inset_y = cy(bv) + drawTextYOffset;
|
|
|
|
inset_pos = cpos(bv);
|
|
|
|
inset_par = cpar(bv);
|
|
|
|
inset_boundary = cboundary(bv);
|
|
|
|
the_locking_inset = uinset;
|
2001-06-28 10:25:20 +00:00
|
|
|
uinset->insetButtonPress(bv, x - inset_x, y - inset_y,
|
2001-04-06 12:47:50 +00:00
|
|
|
button);
|
2001-06-28 10:25:20 +00:00
|
|
|
uinset->edit(bv, x - inset_x, y - inset_y, 0);
|
2001-04-02 14:02:58 +00:00
|
|
|
if (the_locking_inset)
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
no_selection = false;
|
|
|
|
return;
|
|
|
|
}
|
2000-09-19 13:50:47 +00:00
|
|
|
}
|
2001-04-20 14:54:25 +00:00
|
|
|
if (!inset) { // && (button == 2)) {
|
2001-04-02 14:02:58 +00:00
|
|
|
bool paste_internally = false;
|
2001-05-31 02:23:46 +00:00
|
|
|
if ((button == 2) && TEXT(bv)->selection.set()) {
|
2001-06-28 10:25:20 +00:00
|
|
|
localDispatch(bv, LFUN_COPY, "");
|
2001-04-02 14:02:58 +00:00
|
|
|
paste_internally = true;
|
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->setCursorFromCoordinates(bv, x-drawTextXOffset,
|
2001-04-06 12:47:50 +00:00
|
|
|
y + insetAscent);
|
2001-05-31 02:23:46 +00:00
|
|
|
TEXT(bv)->selection.cursor = TEXT(bv)->cursor;
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR, false);
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->owner()->setLayout(cpar(bv)->getLayout());
|
2001-04-02 14:02:58 +00:00
|
|
|
old_par = cpar(bv);
|
|
|
|
// Insert primary selection with middle mouse
|
|
|
|
// if there is a local selection in the current buffer,
|
|
|
|
// insert this
|
|
|
|
if (button == 2) {
|
|
|
|
if (paste_internally)
|
2001-06-28 10:25:20 +00:00
|
|
|
localDispatch(bv, LFUN_PASTE, "");
|
2001-04-02 14:02:58 +00:00
|
|
|
else
|
2001-06-28 10:25:20 +00:00
|
|
|
localDispatch(bv, LFUN_PASTESELECTION,
|
2001-04-06 12:47:50 +00:00
|
|
|
"paragraph");
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2000-09-19 13:50:47 +00:00
|
|
|
}
|
2001-06-28 10:25:20 +00:00
|
|
|
showInsetCursor(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
no_selection = false;
|
2000-04-19 14:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button)
|
2000-04-19 14:42:19 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
UpdatableInset * inset = 0;
|
2000-04-19 14:42:19 +00:00
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
if (the_locking_inset) {
|
2001-06-28 10:25:20 +00:00
|
|
|
the_locking_inset->insetButtonRelease(bv,
|
2001-04-06 12:47:50 +00:00
|
|
|
x - inset_x, y - inset_y,
|
|
|
|
button);
|
2001-04-02 14:02:58 +00:00
|
|
|
} else {
|
2001-06-25 00:06:33 +00:00
|
|
|
if (cpar(bv)->getChar(cpos(bv)) == Paragraph::META_INSET) {
|
|
|
|
inset = static_cast<UpdatableInset*>(cpar(bv)->getInset(cpos(bv)));
|
2001-06-28 10:25:20 +00:00
|
|
|
if (inset->editable() == Inset::HIGHLY_EDITABLE) {
|
|
|
|
inset->insetButtonRelease(bv,
|
2001-04-06 12:47:50 +00:00
|
|
|
x - inset_x,
|
|
|
|
y - inset_y, button);
|
2001-04-02 14:02:58 +00:00
|
|
|
} else {
|
|
|
|
inset_x = cx(bv) - top_x + drawTextXOffset;
|
|
|
|
inset_y = cy(bv) + drawTextYOffset;
|
2001-06-28 10:25:20 +00:00
|
|
|
inset->insetButtonRelease(bv,
|
2001-04-06 12:47:50 +00:00
|
|
|
x - inset_x,
|
|
|
|
y - inset_y, button);
|
2001-06-28 10:25:20 +00:00
|
|
|
inset->edit(bv,
|
2001-04-06 12:47:50 +00:00
|
|
|
x - inset_x, y - inset_y, button);
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR_PAR, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2000-04-19 14:42:19 +00:00
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
no_selection = false;
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::insetMotionNotify(BufferView * bv, int x, int y, int state)
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (no_selection)
|
|
|
|
return;
|
|
|
|
if (the_locking_inset) {
|
2001-06-28 10:25:20 +00:00
|
|
|
the_locking_inset->insetMotionNotify(bv, x - inset_x,
|
2001-04-06 12:47:50 +00:00
|
|
|
y - inset_y,state);
|
2001-04-02 14:02:58 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-06-28 10:25:20 +00:00
|
|
|
hideInsetCursor(bv);
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->setCursorFromCoordinates(bv, x - drawTextXOffset,
|
2001-04-06 12:47:50 +00:00
|
|
|
y + insetAscent);
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->setSelection(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
if (TEXT(bv)->toggle_cursor.par()!=TEXT(bv)->toggle_end_cursor.par() ||
|
|
|
|
TEXT(bv)->toggle_cursor.pos()!=TEXT(bv)->toggle_end_cursor.pos())
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, SELECTION, false);
|
|
|
|
showInsetCursor(bv);
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::insetKeyPress(XKeyEvent * xke)
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (the_locking_inset) {
|
2001-06-28 10:25:20 +00:00
|
|
|
the_locking_inset->insetKeyPress(xke);
|
2001-04-02 14:02:58 +00:00
|
|
|
return;
|
|
|
|
}
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-02 02:19:43 +00:00
|
|
|
UpdatableInset::RESULT
|
2001-06-28 10:25:20 +00:00
|
|
|
InsetText::localDispatch(BufferView * bv,
|
2001-06-25 00:06:33 +00:00
|
|
|
kb_action action, string const & arg)
|
2001-04-02 14:02:58 +00:00
|
|
|
{
|
|
|
|
no_selection = false;
|
|
|
|
UpdatableInset::RESULT
|
2001-06-28 10:25:20 +00:00
|
|
|
result= UpdatableInset::localDispatch(bv, action, arg);
|
2001-04-02 14:02:58 +00:00
|
|
|
if (result != UNDISPATCHED) {
|
2001-01-08 16:14:09 +00:00
|
|
|
return DISPATCHED;
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
|
2001-04-06 12:47:50 +00:00
|
|
|
result = DISPATCHED;
|
2001-04-02 14:02:58 +00:00
|
|
|
if ((action < 0) && arg.empty())
|
|
|
|
return FINISHED;
|
|
|
|
|
|
|
|
if (the_locking_inset) {
|
2001-06-28 10:25:20 +00:00
|
|
|
result = the_locking_inset->localDispatch(bv, action, arg);
|
2001-04-02 14:02:58 +00:00
|
|
|
if (result == DISPATCHED_NOUPDATE)
|
|
|
|
return result;
|
|
|
|
else if (result == DISPATCHED) {
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR_PAR, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
return result;
|
|
|
|
} else if (result == FINISHED) {
|
|
|
|
bool dispatched = false;
|
|
|
|
switch (action) {
|
|
|
|
case LFUN_UNKNOWN_ACTION:
|
|
|
|
case LFUN_BREAKPARAGRAPH:
|
|
|
|
case LFUN_BREAKLINE:
|
|
|
|
moveRightIntern(bv, false, false);
|
|
|
|
break;
|
|
|
|
case LFUN_RIGHT:
|
|
|
|
if (!TEXT(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
|
|
|
|
moveRightIntern(bv, false, false);
|
|
|
|
dispatched = true;
|
|
|
|
break;
|
|
|
|
case LFUN_LEFT:
|
|
|
|
if (TEXT(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
|
|
|
|
moveRightIntern(bv, false, false);
|
|
|
|
dispatched = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
the_locking_inset = 0;
|
|
|
|
if (dispatched)
|
|
|
|
return DISPATCHED;
|
|
|
|
}
|
|
|
|
}
|
2001-06-28 10:25:20 +00:00
|
|
|
hideInsetCursor(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
switch (action) {
|
2000-03-09 16:04:28 +00:00
|
|
|
// Normal chars
|
2001-06-25 00:06:33 +00:00
|
|
|
case LFUN_SELFINSERT:
|
2001-04-02 14:02:58 +00:00
|
|
|
if (bv->buffer()->isReadonly()) {
|
2000-06-16 15:13:25 +00:00
|
|
|
// setErrorMessage(N_("Document is read only"));
|
2001-04-02 14:02:58 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!arg.empty()) {
|
|
|
|
/* Automatically delete the currently selected
|
|
|
|
* text and replace it with what is being
|
|
|
|
* typed in now. Depends on lyxrc settings
|
|
|
|
* "auto_region_delete", which defaults to
|
|
|
|
* true (on). */
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->text->setUndo(bv->buffer(), Undo::INSERT,
|
2001-04-06 12:47:50 +00:00
|
|
|
bv->text->cursor.par()->previous(),
|
2001-05-03 14:31:33 +00:00
|
|
|
bv->text->cursor.par()->next());
|
2001-04-02 14:02:58 +00:00
|
|
|
bv->setState();
|
|
|
|
if (lyxrc.auto_region_delete) {
|
2001-05-31 02:23:46 +00:00
|
|
|
if (TEXT(bv)->selection.set()) {
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->cutSelection(bv, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->clearSelection(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
for (string::size_type i = 0; i < arg.length(); ++i) {
|
|
|
|
if (greek_kb_flag) {
|
|
|
|
if (!math_insert_greek(bv, arg[i])) {
|
|
|
|
bv->owner()->getIntl()->getTrans().TranslateAndInsert(arg[i], TEXT(bv));
|
|
|
|
} else if (!the_locking_inset) {
|
|
|
|
(void)moveRight(bv, false);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
bv->owner()->getIntl()->getTrans().TranslateAndInsert(arg[i], TEXT(bv));
|
|
|
|
}
|
|
|
|
}
|
2001-01-02 16:06:14 +00:00
|
|
|
}
|
2001-05-31 02:23:46 +00:00
|
|
|
TEXT(bv)->selection.cursor = TEXT(bv)->cursor;
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR_PAR, true);
|
2001-04-02 14:02:58 +00:00
|
|
|
result=DISPATCHED_NOUPDATE;
|
|
|
|
break;
|
2001-04-06 12:47:50 +00:00
|
|
|
// --- Cursor Movements -----------------------------------
|
2001-04-02 14:02:58 +00:00
|
|
|
case LFUN_RIGHTSEL:
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->text->finishUndo();
|
2001-04-02 14:02:58 +00:00
|
|
|
moveRight(bv, false, true);
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->setSelection(bv);
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, SELECTION, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
break;
|
|
|
|
case LFUN_RIGHT:
|
|
|
|
result = moveRight(bv);
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->text->finishUndo();
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
break;
|
|
|
|
case LFUN_LEFTSEL:
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->text->finishUndo();
|
2001-04-02 14:02:58 +00:00
|
|
|
moveLeft(bv, false, true);
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->setSelection(bv);
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, SELECTION, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
break;
|
|
|
|
case LFUN_LEFT:
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->text->finishUndo();
|
2001-04-02 14:02:58 +00:00
|
|
|
result = moveLeft(bv);
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
break;
|
|
|
|
case LFUN_DOWNSEL:
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->text->finishUndo();
|
2001-04-02 14:02:58 +00:00
|
|
|
moveDown(bv);
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->setSelection(bv);
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, SELECTION, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
break;
|
|
|
|
case LFUN_DOWN:
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->text->finishUndo();
|
2001-04-02 14:02:58 +00:00
|
|
|
result = moveDown(bv);
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
break;
|
|
|
|
case LFUN_UPSEL:
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->text->finishUndo();
|
2001-04-02 14:02:58 +00:00
|
|
|
moveUp(bv);
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->setSelection(bv);
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, SELECTION, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
break;
|
|
|
|
case LFUN_UP:
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->text->finishUndo();
|
2001-04-02 14:02:58 +00:00
|
|
|
result = moveUp(bv);
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
break;
|
|
|
|
case LFUN_HOME:
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->text->finishUndo();
|
|
|
|
TEXT(bv)->cursorHome(bv);
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
break;
|
|
|
|
case LFUN_END:
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->cursorEnd(bv);
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
break;
|
|
|
|
case LFUN_BACKSPACE:
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->text->setUndo(bv->buffer(), Undo::DELETE,
|
2001-04-06 12:47:50 +00:00
|
|
|
bv->text->cursor.par()->previous(),
|
2001-05-03 14:31:33 +00:00
|
|
|
bv->text->cursor.par()->next());
|
2001-05-31 02:23:46 +00:00
|
|
|
if (TEXT(bv)->selection.set())
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->cutSelection(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
else
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->backspace(bv);
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR_PAR, true);
|
2001-04-02 14:02:58 +00:00
|
|
|
break;
|
|
|
|
case LFUN_DELETE:
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->text->setUndo(bv->buffer(), Undo::DELETE,
|
2001-04-06 12:47:50 +00:00
|
|
|
bv->text->cursor.par()->previous(),
|
2001-05-03 14:31:33 +00:00
|
|
|
bv->text->cursor.par()->next());
|
2001-05-31 02:23:46 +00:00
|
|
|
if (TEXT(bv)->selection.set())
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->cutSelection(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
else
|
|
|
|
TEXT(bv)->Delete(bv);
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR_PAR, true);
|
2001-04-02 14:02:58 +00:00
|
|
|
break;
|
|
|
|
case LFUN_CUT:
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->text->setUndo(bv->buffer(), Undo::DELETE,
|
2001-04-06 12:47:50 +00:00
|
|
|
bv->text->cursor.par()->previous(),
|
2001-05-03 14:31:33 +00:00
|
|
|
bv->text->cursor.par()->next());
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->cutSelection(bv);
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR_PAR, true);
|
2001-04-02 14:02:58 +00:00
|
|
|
break;
|
|
|
|
case LFUN_COPY:
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->text->finishUndo();
|
|
|
|
TEXT(bv)->copySelection(bv);
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR_PAR, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
break;
|
|
|
|
case LFUN_PASTESELECTION:
|
|
|
|
{
|
2001-05-08 17:08:44 +00:00
|
|
|
string const clip(bv->getClipboard());
|
2000-09-19 13:50:47 +00:00
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
if (clip.empty())
|
|
|
|
break;
|
|
|
|
if (arg == "paragraph") {
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->insertStringAsParagraphs(bv, clip);
|
2001-04-02 14:02:58 +00:00
|
|
|
} else {
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->insertStringAsLines(bv, clip);
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR_PAR, true);
|
2000-07-14 14:57:20 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
case LFUN_PASTE:
|
|
|
|
if (!autoBreakRows) {
|
|
|
|
CutAndPaste cap;
|
|
|
|
|
|
|
|
if (cap.nrOfParagraphs() > 1) {
|
|
|
|
WriteAlert(_("Impossible operation"),
|
|
|
|
_("Cannot include more than one paragraph!"),
|
|
|
|
_("Sorry."));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->text->setUndo(bv->buffer(), Undo::INSERT,
|
2001-04-06 12:47:50 +00:00
|
|
|
bv->text->cursor.par()->previous(),
|
2001-05-03 14:31:33 +00:00
|
|
|
bv->text->cursor.par()->next());
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->pasteSelection(bv);
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR_PAR, true);
|
2001-04-02 14:02:58 +00:00
|
|
|
break;
|
|
|
|
case LFUN_BREAKPARAGRAPH:
|
|
|
|
if (!autoBreakRows)
|
|
|
|
return DISPATCHED;
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->breakParagraph(bv, 0);
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, FULL, true);
|
2001-04-02 14:02:58 +00:00
|
|
|
break;
|
|
|
|
case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
|
|
|
|
if (!autoBreakRows)
|
|
|
|
return DISPATCHED;
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->breakParagraph(bv, 1);
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, FULL, true);
|
2001-04-02 14:02:58 +00:00
|
|
|
break;
|
|
|
|
case LFUN_BREAKLINE:
|
|
|
|
if (!autoBreakRows)
|
|
|
|
return DISPATCHED;
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->text->setUndo(bv->buffer(), Undo::INSERT,
|
2001-04-06 12:47:50 +00:00
|
|
|
bv->text->cursor.par()->previous(),
|
2001-05-03 14:31:33 +00:00
|
|
|
bv->text->cursor.par()->next());
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->insertChar(bv, Paragraph::META_NEWLINE);
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR_PAR, true);
|
2001-04-02 14:02:58 +00:00
|
|
|
break;
|
|
|
|
case LFUN_LAYOUT:
|
|
|
|
// do not set layouts on non breakable textinsets
|
|
|
|
if (autoBreakRows) {
|
|
|
|
LyXTextClass::size_type cur_layout = cpar(bv)->layout;
|
|
|
|
|
|
|
|
// Derive layout number from given argument (string)
|
|
|
|
// and current buffer's textclass (number). */
|
|
|
|
LyXTextClassList::ClassList::size_type tclass =
|
|
|
|
bv->buffer()->params.textclass;
|
2001-04-27 14:03:25 +00:00
|
|
|
std::pair <bool, LyXTextClass::size_type> layout =
|
|
|
|
textclasslist.NumberOfLayout(tclass, arg);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
|
|
|
// If the entry is obsolete, use the new one instead.
|
|
|
|
if (layout.first) {
|
|
|
|
string obs = textclasslist.Style(tclass,layout.second).
|
|
|
|
obsoleted_by();
|
|
|
|
if (!obs.empty())
|
|
|
|
layout = textclasslist.NumberOfLayout(tclass, obs);
|
|
|
|
}
|
|
|
|
|
|
|
|
// see if we found the layout number:
|
|
|
|
if (!layout.first) {
|
2001-04-17 14:17:11 +00:00
|
|
|
string const msg = string(N_("Layout ")) + arg + N_(" not known");
|
2001-04-27 14:03:25 +00:00
|
|
|
bv->owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE, msg);
|
2001-04-02 14:02:58 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cur_layout != layout.second) {
|
|
|
|
cur_layout = layout.second;
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->setLayout(bv, layout.second);
|
|
|
|
bv->owner()->setLayout(cpar(bv)->getLayout());
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR_PAR, true);
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// reset the layout box
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->owner()->setLayout(cpar(bv)->getLayout());
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case LFUN_PARAGRAPH_SPACING:
|
|
|
|
// This one is absolutely not working. When fiddling with this
|
|
|
|
// it also seems to me that the paragraphs inside the insettext
|
|
|
|
// inherit bufferparams/paragraphparams in a strange way. (Lgb)
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
Paragraph * par = TEXT(bv)->cursor.par();
|
|
|
|
Spacing::Space cur_spacing = par->params().spacing().getSpace();
|
2001-04-02 14:02:58 +00:00
|
|
|
float cur_value = 1.0;
|
|
|
|
if (cur_spacing == Spacing::Other) {
|
2001-06-25 00:06:33 +00:00
|
|
|
cur_value = par->params().spacing().getValue();
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
|
|
|
|
2001-06-29 11:54:39 +00:00
|
|
|
std::istringstream istr(arg.c_str());
|
2001-04-02 14:02:58 +00:00
|
|
|
string tmp;
|
|
|
|
istr >> tmp;
|
|
|
|
Spacing::Space new_spacing = cur_spacing;
|
|
|
|
float new_value = cur_value;
|
|
|
|
if (tmp.empty()) {
|
|
|
|
lyxerr << "Missing argument to `paragraph-spacing'"
|
|
|
|
<< endl;
|
|
|
|
} else if (tmp == "single") {
|
|
|
|
new_spacing = Spacing::Single;
|
|
|
|
} else if (tmp == "onehalf") {
|
|
|
|
new_spacing = Spacing::Onehalf;
|
|
|
|
} else if (tmp == "double") {
|
|
|
|
new_spacing = Spacing::Double;
|
|
|
|
} else if (tmp == "other") {
|
|
|
|
new_spacing = Spacing::Other;
|
|
|
|
float tmpval = 0.0;
|
|
|
|
istr >> tmpval;
|
|
|
|
lyxerr << "new_value = " << tmpval << endl;
|
|
|
|
if (tmpval != 0.0)
|
|
|
|
new_value = tmpval;
|
|
|
|
} else if (tmp == "default") {
|
|
|
|
new_spacing = Spacing::Default;
|
|
|
|
} else {
|
|
|
|
lyxerr << _("Unknown spacing argument: ")
|
|
|
|
<< arg << endl;
|
|
|
|
}
|
|
|
|
if (cur_spacing != new_spacing || cur_value != new_value) {
|
2001-06-25 00:06:33 +00:00
|
|
|
par->params().spacing(Spacing(new_spacing, new_value));
|
2001-04-02 14:02:58 +00:00
|
|
|
//TEXT(bv)->RedoParagraph(owner->view());
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR_PAR, true);
|
2001-04-02 14:02:58 +00:00
|
|
|
//bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
|
|
|
}
|
2000-05-04 08:14:34 +00:00
|
|
|
}
|
2000-09-25 11:10:15 +00:00
|
|
|
break;
|
2000-06-28 13:35:52 +00:00
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
default:
|
|
|
|
if (!bv->Dispatch(action, arg))
|
|
|
|
result = UNDISPATCHED;
|
|
|
|
break;
|
|
|
|
}
|
2001-02-11 09:58:20 +00:00
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
/// If the action has deleted all text in the inset, we need to change the
|
|
|
|
// language to the language to the surronding text.
|
2001-05-03 14:31:33 +00:00
|
|
|
if (par->size() == 0 && !par->next()) {
|
2001-04-02 14:02:58 +00:00
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
font.setLanguage(bv->getParentLanguage(this));
|
2001-06-28 10:25:20 +00:00
|
|
|
setFont(bv, font, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2001-02-11 09:58:20 +00:00
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
if (result != FINISHED) {
|
2001-06-28 10:25:20 +00:00
|
|
|
showInsetCursor(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
} else
|
|
|
|
bv->unlockInset(this);
|
|
|
|
return result;
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
int InsetText::latex(Buffer const * buf, ostream & os, bool, bool) const
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
TexRow texrow;
|
|
|
|
buf->latexParagraphs(os, par, 0, texrow);
|
|
|
|
return texrow.rows();
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
int InsetText::ascii(Buffer const * buf, ostream & os, int linelen) const
|
2000-09-26 15:25:14 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
Paragraph * p = par;
|
2001-04-02 14:02:58 +00:00
|
|
|
unsigned int lines = 0;
|
|
|
|
|
|
|
|
while (p) {
|
2001-05-08 17:08:44 +00:00
|
|
|
string const tmp = buf->asciiParagraph(p, linelen);
|
2001-04-02 14:02:58 +00:00
|
|
|
lines += countChar(tmp, '\n');
|
|
|
|
os << tmp;
|
|
|
|
p = p->next();
|
|
|
|
}
|
|
|
|
return lines;
|
2000-09-26 15:25:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
int InsetText::docBook(Buffer const * buf, ostream & os) const
|
2000-10-27 10:04:51 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
Paragraph * p = par;
|
2001-04-02 14:02:58 +00:00
|
|
|
unsigned int lines = 0;
|
2001-05-08 17:08:44 +00:00
|
|
|
int desc = 0;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
|
|
|
string tmp;
|
|
|
|
while (p) {
|
2001-06-28 10:25:20 +00:00
|
|
|
buf->simpleDocBookOnePar(os, tmp, p, desc, 0);
|
2001-04-02 14:02:58 +00:00
|
|
|
p = p->next();
|
|
|
|
}
|
|
|
|
|
|
|
|
return lines;
|
2000-10-27 10:04:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::validate(LaTeXFeatures & features) const
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
Paragraph * p = par;
|
2001-05-08 17:08:44 +00:00
|
|
|
while (p) {
|
2001-04-02 14:02:58 +00:00
|
|
|
p->validate(features);
|
|
|
|
p = p->next();
|
|
|
|
}
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
int InsetText::beginningOfMainBody(Buffer const * buf, Paragraph * p) const
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (textclasslist.Style(buf->params.textclass,
|
2001-06-25 00:06:33 +00:00
|
|
|
p->getLayout()).labeltype != LABEL_MANUAL)
|
2001-04-02 14:02:58 +00:00
|
|
|
return 0;
|
|
|
|
else
|
2001-06-25 00:06:33 +00:00
|
|
|
return p->beginningOfMainBody();
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::getCursorPos(BufferView * bv,
|
2001-04-06 12:47:50 +00:00
|
|
|
int & x, int & y) const
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
x = cx(bv);
|
|
|
|
y = cy(bv);
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
unsigned int InsetText::insetInInsetY()
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (!the_locking_inset)
|
|
|
|
return 0;
|
2000-02-25 12:06:15 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
return (inset_y + the_locking_inset->insetInInsetY());
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::toggleInsetCursor(BufferView * bv)
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (the_locking_inset) {
|
2001-06-28 10:25:20 +00:00
|
|
|
the_locking_inset->toggleInsetCursor(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
return;
|
|
|
|
}
|
2000-02-25 12:06:15 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
LyXFont const font(TEXT(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv)));
|
2000-02-25 13:35:38 +00:00
|
|
|
|
2001-04-04 22:08:13 +00:00
|
|
|
int const asc = lyxfont::maxAscent(font);
|
|
|
|
int const desc = lyxfont::maxDescent(font);
|
2000-02-25 12:06:15 +00:00
|
|
|
|
2001-04-04 22:08:13 +00:00
|
|
|
if (isCursorVisible())
|
2001-04-02 14:02:58 +00:00
|
|
|
bv->hideLockedInsetCursor();
|
|
|
|
else
|
|
|
|
bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc);
|
2001-04-04 22:08:13 +00:00
|
|
|
toggleCursorVisible();
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::showInsetCursor(BufferView * bv, bool show)
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (the_locking_inset) {
|
2001-06-28 10:25:20 +00:00
|
|
|
the_locking_inset->showInsetCursor(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-04-04 22:08:13 +00:00
|
|
|
if (!isCursorVisible()) {
|
|
|
|
LyXFont const font =
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv));
|
2000-02-25 12:06:15 +00:00
|
|
|
|
2001-04-04 22:08:13 +00:00
|
|
|
int const asc = lyxfont::maxAscent(font);
|
|
|
|
int const desc = lyxfont::maxDescent(font);
|
2000-06-16 15:13:25 +00:00
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc);
|
|
|
|
if (show)
|
|
|
|
bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc);
|
2001-04-04 22:08:13 +00:00
|
|
|
setCursorVisible(true);
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::hideInsetCursor(BufferView * bv)
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-04 22:08:13 +00:00
|
|
|
if (isCursorVisible()) {
|
2001-04-02 14:02:58 +00:00
|
|
|
bv->hideLockedInsetCursor();
|
2001-04-04 22:08:13 +00:00
|
|
|
setCursorVisible(false);
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
|
|
|
if (the_locking_inset)
|
2001-06-28 10:25:20 +00:00
|
|
|
the_locking_inset->hideInsetCursor(bv);
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-19 14:42:19 +00:00
|
|
|
UpdatableInset::RESULT
|
2000-09-27 15:23:24 +00:00
|
|
|
InsetText::moveRight(BufferView * bv, bool activate_inset, bool selecting)
|
2001-01-08 16:14:09 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (TEXT(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
|
|
|
|
return moveLeftIntern(bv, false, activate_inset, selecting);
|
|
|
|
else
|
|
|
|
return moveRightIntern(bv, false, activate_inset, selecting);
|
2001-01-08 16:14:09 +00:00
|
|
|
}
|
|
|
|
|
2001-05-08 17:08:44 +00:00
|
|
|
|
2001-01-08 16:14:09 +00:00
|
|
|
UpdatableInset::RESULT
|
|
|
|
InsetText::moveLeft(BufferView * bv, bool activate_inset, bool selecting)
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (TEXT(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
|
|
|
|
return moveRightIntern(bv, true, activate_inset, selecting);
|
|
|
|
else
|
|
|
|
return moveLeftIntern(bv, true, activate_inset, selecting);
|
2001-01-08 16:14:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UpdatableInset::RESULT
|
|
|
|
InsetText::moveRightIntern(BufferView * bv, bool behind,
|
2001-04-06 12:47:50 +00:00
|
|
|
bool activate_inset, bool selecting)
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (!cpar(bv)->next() && (cpos(bv) >= cpar(bv)->size()))
|
|
|
|
return FINISHED;
|
|
|
|
if (activate_inset && checkAndActivateInset(bv, behind))
|
|
|
|
return DISPATCHED;
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->cursorRight(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
if (!selecting)
|
2001-05-31 02:23:46 +00:00
|
|
|
TEXT(bv)->selection.cursor = TEXT(bv)->cursor;
|
2001-04-02 14:02:58 +00:00
|
|
|
return DISPATCHED_NOUPDATE;
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-19 14:42:19 +00:00
|
|
|
UpdatableInset::RESULT
|
2001-01-08 16:14:09 +00:00
|
|
|
InsetText::moveLeftIntern(BufferView * bv, bool behind,
|
2001-04-06 12:47:50 +00:00
|
|
|
bool activate_inset, bool selecting)
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (!cpar(bv)->previous() && (cpos(bv) <= 0))
|
|
|
|
return FINISHED;
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->cursorLeft(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
if (!selecting)
|
2001-05-31 02:23:46 +00:00
|
|
|
TEXT(bv)->selection.cursor = TEXT(bv)->cursor;
|
2001-04-02 14:02:58 +00:00
|
|
|
if (activate_inset && checkAndActivateInset(bv, behind))
|
|
|
|
return DISPATCHED;
|
|
|
|
return DISPATCHED_NOUPDATE;
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-19 14:42:19 +00:00
|
|
|
UpdatableInset::RESULT
|
|
|
|
InsetText::moveUp(BufferView * bv)
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (!crow(bv)->previous())
|
|
|
|
return FINISHED;
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->cursorUp(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
return DISPATCHED_NOUPDATE;
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-19 14:42:19 +00:00
|
|
|
UpdatableInset::RESULT
|
|
|
|
InsetText::moveDown(BufferView * bv)
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (!crow(bv)->next())
|
|
|
|
return FINISHED;
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->cursorDown(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
return DISPATCHED_NOUPDATE;
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
bool InsetText::insertInset(BufferView * bv, Inset * inset)
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (the_locking_inset) {
|
2001-06-28 10:25:20 +00:00
|
|
|
if (the_locking_inset->insertInsetAllowed(inset))
|
|
|
|
return the_locking_inset->insertInset(bv, inset);
|
2001-04-02 14:02:58 +00:00
|
|
|
return false;
|
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->text->setUndo(bv->buffer(), Undo::INSERT,
|
2001-04-06 12:47:50 +00:00
|
|
|
bv->text->cursor.par()->previous(),
|
2001-05-03 14:31:33 +00:00
|
|
|
bv->text->cursor.par()->next());
|
2001-04-02 14:02:58 +00:00
|
|
|
inset->setOwner(this);
|
2001-06-28 10:25:20 +00:00
|
|
|
hideInsetCursor(bv);
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->insertInset(bv, inset);
|
2001-02-14 08:38:21 +00:00
|
|
|
#if 0
|
2001-06-25 00:06:33 +00:00
|
|
|
if ((cpar(bv)->GetChar(cpos(bv)) != Paragraph::META_INSET) ||
|
2001-04-02 14:02:58 +00:00
|
|
|
(cpar(bv)->GetInset(cpos(bv)) != inset))
|
|
|
|
TEXT(bv)->CursorLeft(bv);
|
2001-02-14 08:38:21 +00:00
|
|
|
#endif
|
2001-04-02 14:02:58 +00:00
|
|
|
bv->fitCursor(TEXT(bv));
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR_PAR|CURSOR, true);
|
|
|
|
showInsetCursor(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
return true;
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
UpdatableInset * InsetText::getLockingInset()
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-06-28 10:25:20 +00:00
|
|
|
return the_locking_inset ? the_locking_inset->getLockingInset() : this;
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
UpdatableInset * InsetText::getFirstLockingInsetOfType(Inset::Code c)
|
2000-05-15 14:49:36 +00:00
|
|
|
{
|
2001-06-28 10:25:20 +00:00
|
|
|
if (c == lyxCode())
|
2001-04-02 14:02:58 +00:00
|
|
|
return this;
|
|
|
|
if (the_locking_inset)
|
2001-06-28 10:25:20 +00:00
|
|
|
return the_locking_inset->getFirstLockingInsetOfType(c);
|
2001-04-02 14:02:58 +00:00
|
|
|
return 0;
|
2000-05-15 14:49:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
bool InsetText::showInsetDialog(BufferView * bv) const
|
2001-03-26 14:47:34 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (the_locking_inset)
|
2001-06-28 10:25:20 +00:00
|
|
|
return the_locking_inset->showInsetDialog(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
return false;
|
2001-03-26 14:47:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-05 08:03:26 +00:00
|
|
|
std::vector<string> const InsetText::getLabelList() const
|
2001-04-04 23:00:42 +00:00
|
|
|
{
|
2001-04-05 08:03:26 +00:00
|
|
|
std::vector<string> label_list;
|
2001-04-04 23:00:42 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
Paragraph * tpar = par;
|
2001-04-04 23:00:42 +00:00
|
|
|
while (tpar) {
|
2001-06-25 00:06:33 +00:00
|
|
|
Paragraph::inset_iterator beg = tpar->inset_iterator_begin();
|
|
|
|
Paragraph::inset_iterator end = tpar->inset_iterator_end();
|
2001-04-04 23:00:42 +00:00
|
|
|
for (; beg != end; ++beg) {
|
2001-04-05 08:03:26 +00:00
|
|
|
std::vector<string> const l = (*beg)->getLabelList();
|
2001-04-04 23:00:42 +00:00
|
|
|
label_list.insert(label_list.end(), l.begin(), l.end());
|
|
|
|
}
|
|
|
|
tpar = tpar->next();
|
|
|
|
}
|
|
|
|
return label_list;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::setFont(BufferView * bv, LyXFont const & font, bool toggleall,
|
2001-05-28 15:11:24 +00:00
|
|
|
bool selectall)
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-06-01 15:10:26 +00:00
|
|
|
if (the_locking_inset) {
|
2001-06-28 10:25:20 +00:00
|
|
|
the_locking_inset->setFont(bv, font, toggleall, selectall);
|
2001-06-01 15:10:26 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-05-31 02:23:46 +00:00
|
|
|
if (TEXT(bv)->selection.set()) {
|
2001-06-25 00:06:33 +00:00
|
|
|
bv->text->setUndo(bv->buffer(), Undo::EDIT,
|
2001-04-06 12:47:50 +00:00
|
|
|
bv->text->cursor.par()->previous(),
|
2001-05-03 14:31:33 +00:00
|
|
|
bv->text->cursor.par()->next());
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2001-05-28 15:11:24 +00:00
|
|
|
if (selectall)
|
|
|
|
selectAll(bv);
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->setFont(bv, font, toggleall);
|
2001-05-28 15:11:24 +00:00
|
|
|
if (selectall)
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->clearSelection(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
bv->fitCursor(TEXT(bv));
|
2001-05-31 02:23:46 +00:00
|
|
|
if (selectall || TEXT(bv)->selection.set())
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, FULL, true);
|
2001-05-28 15:11:24 +00:00
|
|
|
else
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR_PAR, true);
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-04 11:30:07 +00:00
|
|
|
bool InsetText::checkAndActivateInset(BufferView * bv, bool behind)
|
2000-03-08 13:52:57 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
if (cpar(bv)->getChar(cpos(bv)) == Paragraph::META_INSET) {
|
2001-04-02 14:02:58 +00:00
|
|
|
unsigned int x;
|
|
|
|
unsigned int y;
|
|
|
|
Inset * inset =
|
2001-06-25 00:06:33 +00:00
|
|
|
static_cast<UpdatableInset*>(cpar(bv)->getInset(cpos(bv)));
|
2001-06-28 10:25:20 +00:00
|
|
|
if (!inset || inset->editable() != Inset::HIGHLY_EDITABLE)
|
2001-04-02 14:02:58 +00:00
|
|
|
return false;
|
|
|
|
LyXFont const font =
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv));
|
2001-04-02 14:02:58 +00:00
|
|
|
if (behind) {
|
|
|
|
x = inset->width(bv, font);
|
|
|
|
y = font.isRightToLeft() ? 0 : inset->descent(bv, font);
|
|
|
|
} else {
|
|
|
|
x = 0;
|
|
|
|
y = font.isRightToLeft() ? inset->descent(bv, font) : 0;
|
|
|
|
}
|
|
|
|
//inset_x = cx(bv) - top_x + drawTextXOffset;
|
|
|
|
//inset_y = cy(bv) + drawTextYOffset;
|
2001-06-28 10:25:20 +00:00
|
|
|
inset->edit(bv, x, y, 0);
|
2001-04-02 14:02:58 +00:00
|
|
|
if (!the_locking_inset)
|
|
|
|
return false;
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
return true;
|
2000-07-04 11:30:07 +00:00
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
return false;
|
2000-03-27 15:13:47 +00:00
|
|
|
}
|
|
|
|
|
2000-04-24 20:58:23 +00:00
|
|
|
|
2000-04-19 14:42:19 +00:00
|
|
|
bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
|
2001-04-06 12:47:50 +00:00
|
|
|
int button)
|
2001-04-02 14:02:58 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
x -= drawTextXOffset;
|
|
|
|
int dummyx = x;
|
|
|
|
int dummyy = y + insetAscent;
|
2001-04-02 14:02:58 +00:00
|
|
|
Inset * inset = bv->checkInsetHit(TEXT(bv), dummyx, dummyy, button);
|
|
|
|
|
|
|
|
if (inset) {
|
|
|
|
if (x < 0)
|
|
|
|
x = insetWidth;
|
|
|
|
if (y < 0)
|
|
|
|
y = insetDescent;
|
|
|
|
inset_x = cx(bv) - top_x + drawTextXOffset;
|
|
|
|
inset_y = cy(bv) + drawTextYOffset;
|
2001-06-28 10:25:20 +00:00
|
|
|
inset->edit(bv, x - inset_x, y - inset_y, button);
|
2001-04-02 14:02:58 +00:00
|
|
|
if (!the_locking_inset)
|
|
|
|
return false;
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, CURSOR, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2000-04-19 14:42:19 +00:00
|
|
|
}
|
|
|
|
|
2000-04-24 20:58:23 +00:00
|
|
|
|
2001-03-29 15:00:20 +00:00
|
|
|
int InsetText::getMaxWidth(BufferView * bv, UpdatableInset const * inset) const
|
2000-04-19 14:42:19 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
int w = UpdatableInset::getMaxWidth(bv, inset);
|
|
|
|
if (w < 0) {
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
if (owner()) {
|
|
|
|
w = w - top_x + owner()->x();
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
w -= (2 * TEXT_TO_INSET_OFFSET);
|
|
|
|
return w - top_x;
|
2000-07-28 14:59:26 +00:00
|
|
|
// return w - (2*TEXT_TO_INSET_OFFSET);
|
2000-04-19 14:42:19 +00:00
|
|
|
}
|
2000-05-04 08:14:34 +00:00
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::setParagraphData(Paragraph * p)
|
2000-05-04 08:14:34 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
// delete all instances of LyXText before deleting the paragraps used
|
|
|
|
// by it.
|
|
|
|
for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit){
|
|
|
|
delete (*cit).second;
|
|
|
|
(*cit).second = 0;
|
|
|
|
}
|
2000-06-19 15:33:58 +00:00
|
|
|
|
2001-04-06 12:47:50 +00:00
|
|
|
while (par) {
|
2001-06-25 00:06:33 +00:00
|
|
|
Paragraph * tmp = par->next();
|
2001-04-02 14:02:58 +00:00
|
|
|
delete par;
|
2001-04-06 12:47:50 +00:00
|
|
|
par = tmp;
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2001-04-06 12:47:50 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
par = new Paragraph(*p);
|
|
|
|
par->setInsetOwner(this);
|
|
|
|
Paragraph * np = par;
|
2001-04-06 12:47:50 +00:00
|
|
|
while (p->next()) {
|
2001-04-02 14:02:58 +00:00
|
|
|
p = p->next();
|
2001-06-25 00:06:33 +00:00
|
|
|
np->next(new Paragraph(*p));
|
2001-04-02 14:02:58 +00:00
|
|
|
np->next()->previous(np);
|
|
|
|
np = np->next();
|
2001-06-25 00:06:33 +00:00
|
|
|
np->setInsetOwner(this);
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2001-05-03 14:31:33 +00:00
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
need_update = INIT;
|
2000-05-04 08:14:34 +00:00
|
|
|
}
|
2000-05-15 14:49:36 +00:00
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::setText(string const & data)
|
2001-01-03 16:04:05 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
clear();
|
|
|
|
LyXFont font(LyXFont::ALL_SANE);
|
2001-04-06 12:47:50 +00:00
|
|
|
for (unsigned int i=0; i < data.length(); ++i)
|
2001-06-25 00:06:33 +00:00
|
|
|
par->insertChar(i, data[i], font);
|
2001-01-03 16:04:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::setAutoBreakRows(bool flag)
|
2000-05-15 14:49:36 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (flag != autoBreakRows) {
|
|
|
|
autoBreakRows = flag;
|
|
|
|
need_update = FULL;
|
|
|
|
if (!flag)
|
|
|
|
removeNewlines();
|
|
|
|
}
|
2000-05-15 14:49:36 +00:00
|
|
|
}
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::setDrawFrame(BufferView * bv, DrawFrame how)
|
2000-05-15 14:49:36 +00:00
|
|
|
{
|
2001-04-27 14:03:25 +00:00
|
|
|
if (how != drawFrame_) {
|
|
|
|
drawFrame_ = how;
|
2001-04-02 14:02:58 +00:00
|
|
|
if (bv)
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, DRAW_FRAME, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2000-05-15 14:49:36 +00:00
|
|
|
}
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetText::setFrameColor(BufferView * bv, LColor::color col)
|
2000-05-15 14:49:36 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (frame_color != col) {
|
|
|
|
frame_color = col;
|
|
|
|
if (bv)
|
2001-06-28 10:25:20 +00:00
|
|
|
updateLocal(bv, DRAW_FRAME, false);
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2000-06-19 15:33:58 +00:00
|
|
|
}
|
2000-06-28 13:35:52 +00:00
|
|
|
|
2000-09-27 18:13:30 +00:00
|
|
|
|
2000-09-29 18:44:07 +00:00
|
|
|
int InsetText::cx(BufferView * bv) const
|
2000-06-16 15:13:25 +00:00
|
|
|
{
|
2000-12-05 14:15:44 +00:00
|
|
|
LyXText * text = TEXT(bv);
|
|
|
|
int x = text->cursor.x() + top_x + TEXT_TO_INSET_OFFSET;
|
|
|
|
if (the_locking_inset) {
|
2001-06-25 00:06:33 +00:00
|
|
|
LyXFont font = text->getFont(bv->buffer(),
|
2001-04-06 12:47:50 +00:00
|
|
|
text->cursor.par(),
|
|
|
|
text->cursor.pos());
|
2000-12-05 14:15:44 +00:00
|
|
|
if (font.isVisibleRightToLeft())
|
|
|
|
x -= the_locking_inset->width(bv, font);
|
|
|
|
}
|
|
|
|
return x;
|
2000-06-16 15:13:25 +00:00
|
|
|
}
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
|
2000-09-29 18:44:07 +00:00
|
|
|
int InsetText::cy(BufferView * bv) const
|
2000-06-16 15:13:25 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
LyXFont font;
|
|
|
|
return TEXT(bv)->cursor.y() - ascent(bv, font) + TEXT_TO_INSET_OFFSET;
|
2000-06-21 15:07:57 +00:00
|
|
|
}
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
Paragraph::size_type InsetText::cpos(BufferView * bv) const
|
2000-06-21 15:07:57 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
return TEXT(bv)->cursor.pos();
|
2000-06-21 15:07:57 +00:00
|
|
|
}
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
Paragraph * InsetText::cpar(BufferView * bv) const
|
2000-06-21 15:07:57 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
return TEXT(bv)->cursor.par();
|
2000-06-16 15:13:25 +00:00
|
|
|
}
|
|
|
|
|
2001-05-08 17:08:44 +00:00
|
|
|
|
2000-12-17 06:09:35 +00:00
|
|
|
bool InsetText::cboundary(BufferView * bv) const
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
return TEXT(bv)->cursor.boundary();
|
2000-12-17 06:09:35 +00:00
|
|
|
}
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
|
2000-06-21 15:07:57 +00:00
|
|
|
Row * InsetText::crow(BufferView * bv) const
|
2000-06-16 15:13:25 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
return TEXT(bv)->cursor.row();
|
2000-06-16 15:13:25 +00:00
|
|
|
}
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
|
2001-04-06 12:47:50 +00:00
|
|
|
LyXText * InsetText::getLyXText(BufferView const * lbv,
|
|
|
|
bool const recursive) const
|
2000-06-16 15:13:25 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
// Super UGLY! (Lgb)
|
|
|
|
BufferView * bv = const_cast<BufferView *>(lbv);
|
2000-12-17 06:09:35 +00:00
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
if ((cache.find(bv) != cache.end()) && cache[bv]) {
|
|
|
|
if (recursive && the_locking_inset)
|
|
|
|
return the_locking_inset->getLyXText(bv);
|
|
|
|
return cache[bv];
|
|
|
|
}
|
|
|
|
LyXText * lt = new LyXText(const_cast<InsetText *>(this));
|
|
|
|
lt->init(bv);
|
|
|
|
cache[bv] = lt;
|
|
|
|
if (the_locking_inset) {
|
2001-06-25 00:06:33 +00:00
|
|
|
lt->setCursor(bv, inset_par, inset_pos, true, inset_boundary);
|
2001-04-02 14:02:58 +00:00
|
|
|
if (recursive)
|
|
|
|
return the_locking_inset->getLyXText(bv);
|
|
|
|
}
|
|
|
|
return lt;
|
2000-06-16 15:13:25 +00:00
|
|
|
}
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
|
2000-07-14 14:57:20 +00:00
|
|
|
void InsetText::deleteLyXText(BufferView * bv, bool recursive) const
|
2000-06-16 15:13:25 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if ((cache.find(bv) == cache.end()) || !cache[bv])
|
|
|
|
return;
|
|
|
|
delete cache[bv];
|
|
|
|
cache.erase(bv);
|
|
|
|
if (recursive) {
|
|
|
|
/// then remove all LyXText in text-insets
|
2001-06-25 00:06:33 +00:00
|
|
|
Paragraph * p = par;
|
2001-04-02 14:02:58 +00:00
|
|
|
for (; p; p = p->next()) {
|
|
|
|
p->deleteInsetsLyXText(bv);
|
|
|
|
}
|
|
|
|
}
|
2000-07-14 14:57:20 +00:00
|
|
|
}
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
2001-06-07 14:51:20 +00:00
|
|
|
void InsetText::resizeLyXText(BufferView * bv, bool force) const
|
2000-07-14 14:57:20 +00:00
|
|
|
{
|
2001-05-28 15:11:24 +00:00
|
|
|
if (!par->next() && !par->size()) // no data, resize not neccessary!
|
|
|
|
return;
|
2001-06-07 14:51:20 +00:00
|
|
|
// one endless line, resize normally not necessary
|
|
|
|
if (!force && getMaxWidth(bv, this) < 0)
|
2001-04-02 14:02:58 +00:00
|
|
|
return;
|
|
|
|
if ((cache.find(bv) == cache.end()) || !cache[bv])
|
|
|
|
return;
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
Paragraph * lpar = 0;
|
|
|
|
Paragraph * selstartpar = 0;
|
|
|
|
Paragraph * selendpar = 0;
|
|
|
|
Paragraph::size_type pos = 0;
|
|
|
|
Paragraph::size_type selstartpos = 0;
|
|
|
|
Paragraph::size_type selendpos = 0;
|
2001-04-02 14:02:58 +00:00
|
|
|
bool boundary = false;
|
|
|
|
bool selstartboundary = false;
|
|
|
|
bool selendboundary = false;
|
2001-05-31 02:23:46 +00:00
|
|
|
bool selection = false;
|
|
|
|
bool mark_set = false;
|
2000-07-14 14:57:20 +00:00
|
|
|
|
|
|
|
// ProhibitInput(bv);
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
if (locked) {
|
|
|
|
lpar = TEXT(bv)->cursor.par();
|
|
|
|
pos = TEXT(bv)->cursor.pos();
|
|
|
|
boundary = TEXT(bv)->cursor.boundary();
|
2001-05-31 02:23:46 +00:00
|
|
|
selstartpar = TEXT(bv)->selection.start.par();
|
|
|
|
selstartpos = TEXT(bv)->selection.start.pos();
|
|
|
|
selstartboundary = TEXT(bv)->selection.start.boundary();
|
|
|
|
selendpar = TEXT(bv)->selection.end.par();
|
|
|
|
selendpos = TEXT(bv)->selection.end.pos();
|
|
|
|
selendboundary = TEXT(bv)->selection.end.boundary();
|
|
|
|
selection = TEXT(bv)->selection.set();
|
|
|
|
mark_set = TEXT(bv)->selection.mark();
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2001-06-07 14:51:20 +00:00
|
|
|
deleteLyXText(bv, (the_locking_inset == 0) || force);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
|
|
|
if (lpar) {
|
2001-05-31 02:23:46 +00:00
|
|
|
TEXT(bv)->selection.set(true);
|
2001-04-02 14:02:58 +00:00
|
|
|
/* at this point just to avoid the Delete-Empty-Paragraph
|
|
|
|
* Mechanism when setting the cursor */
|
2001-05-31 02:23:46 +00:00
|
|
|
TEXT(bv)->selection.mark(mark_set);
|
2001-04-02 14:02:58 +00:00
|
|
|
if (selection) {
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->setCursor(bv, selstartpar, selstartpos,
|
2001-04-06 12:47:50 +00:00
|
|
|
true, selstartboundary);
|
2001-05-31 02:23:46 +00:00
|
|
|
TEXT(bv)->selection.cursor = TEXT(bv)->cursor;
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->setCursor(bv, selendpar, selendpos,
|
2001-04-06 12:47:50 +00:00
|
|
|
true, selendboundary);
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->setSelection(bv);
|
|
|
|
TEXT(bv)->setCursor(bv, lpar, pos);
|
2001-04-02 14:02:58 +00:00
|
|
|
} else {
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->setCursor(bv, lpar, pos, true, boundary);
|
2001-05-31 02:23:46 +00:00
|
|
|
TEXT(bv)->selection.cursor = TEXT(bv)->cursor;
|
|
|
|
TEXT(bv)->selection.set(false);
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bv->screen())
|
|
|
|
TEXT(bv)->first = bv->screen()->TopCursorVisible(TEXT(bv));
|
|
|
|
// this will scroll the screen such that the cursor becomes visible
|
|
|
|
bv->updateScrollbar();
|
2000-07-14 14:57:20 +00:00
|
|
|
// AllowInput(bv);
|
2001-04-02 14:02:58 +00:00
|
|
|
if (the_locking_inset) {
|
|
|
|
/// then resize all LyXText in text-insets
|
|
|
|
inset_x = cx(bv) - top_x + drawTextXOffset;
|
|
|
|
inset_y = cy(bv) + drawTextYOffset;
|
2001-06-25 00:06:33 +00:00
|
|
|
for (Paragraph * p = par; p; p = p->next()) {
|
2001-04-02 14:02:58 +00:00
|
|
|
p->resizeInsetsLyXText(bv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
need_update = FULL;
|
2000-06-16 15:13:25 +00:00
|
|
|
}
|
2000-08-07 15:21:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
void InsetText::removeNewlines()
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
for (Paragraph * p = par; p; p = p->next()) {
|
2001-04-02 14:02:58 +00:00
|
|
|
for (int i = 0; i < p->size(); ++i) {
|
2001-06-25 00:06:33 +00:00
|
|
|
if (p->getChar(i) == Paragraph::META_NEWLINE)
|
|
|
|
p->erase(i);
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2000-08-07 15:21:05 +00:00
|
|
|
}
|
|
|
|
}
|
2001-04-27 14:03:25 +00:00
|
|
|
|
2001-05-08 17:08:44 +00:00
|
|
|
|
2001-04-27 14:03:25 +00:00
|
|
|
bool InsetText::nodraw() const
|
|
|
|
{
|
|
|
|
if (the_locking_inset)
|
|
|
|
return the_locking_inset->nodraw();
|
|
|
|
return UpdatableInset::nodraw();
|
|
|
|
}
|
|
|
|
|
2001-05-08 17:08:44 +00:00
|
|
|
|
2001-04-27 14:03:25 +00:00
|
|
|
int InsetText::scroll(bool recursive) const
|
|
|
|
{
|
|
|
|
int sx = UpdatableInset::scroll(false);
|
|
|
|
|
|
|
|
if (recursive && the_locking_inset)
|
|
|
|
sx += the_locking_inset->scroll(recursive);
|
|
|
|
|
|
|
|
return sx;
|
|
|
|
}
|
|
|
|
|
2001-05-08 17:08:44 +00:00
|
|
|
|
2001-04-27 14:03:25 +00:00
|
|
|
bool InsetText::doClearArea() const
|
|
|
|
{
|
|
|
|
return !locked || (need_update & (FULL|INIT));
|
|
|
|
}
|
2001-05-28 15:11:24 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2001-05-28 15:11:24 +00:00
|
|
|
void InsetText::selectAll(BufferView * bv)
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->cursorTop(bv);
|
2001-05-31 02:23:46 +00:00
|
|
|
TEXT(bv)->selection.cursor = TEXT(bv)->cursor;
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->cursorBottom(bv);
|
|
|
|
TEXT(bv)->setSelection(bv);
|
2001-05-28 15:11:24 +00:00
|
|
|
}
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2001-05-28 15:11:24 +00:00
|
|
|
void InsetText::clearSelection(BufferView * bv)
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(bv)->clearSelection(bv);
|
2001-05-28 15:11:24 +00:00
|
|
|
}
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2001-06-01 15:10:26 +00:00
|
|
|
void InsetText::clearInset(Painter & pain, int baseline, bool & cleared) const
|
|
|
|
{
|
|
|
|
int w = insetWidth;
|
|
|
|
int h = insetAscent + insetDescent;
|
|
|
|
int ty = baseline - insetAscent;
|
|
|
|
|
|
|
|
if (ty < 0) {
|
|
|
|
h += ty;
|
|
|
|
ty = 0;
|
|
|
|
}
|
|
|
|
if ((ty + h) > pain.paperHeight())
|
|
|
|
h = pain.paperHeight();
|
|
|
|
if ((top_x + drawTextXOffset + w) > pain.paperWidth())
|
|
|
|
w = pain.paperWidth();
|
|
|
|
pain.fillRectangle(top_x+drawTextXOffset, ty, w, h);
|
|
|
|
cleared = true;
|
|
|
|
need_update = FULL;
|
|
|
|
}
|
2001-04-27 14:03:25 +00:00
|
|
|
/* Emacs:
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* End:
|
|
|
|
* vi:set tabstop=4:
|
|
|
|
*/
|