2000-02-04 09:38:32 +00:00
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 1995 Matthias Ettrich
|
2001-05-30 13:53:44 +00:00
|
|
|
* Copyright 1995-2001 The LyX Team.
|
2000-02-04 09:38:32 +00:00
|
|
|
*
|
|
|
|
* ====================================================== */
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
#include "BufferView.h"
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "lyxcursor.h"
|
|
|
|
#include "lyxtext.h"
|
|
|
|
#include "LyXView.h"
|
|
|
|
#include "bufferlist.h"
|
2000-02-17 19:59:08 +00:00
|
|
|
#include "lyxscreen.h"
|
2000-04-08 17:02:02 +00:00
|
|
|
#include "LaTeX.h"
|
|
|
|
#include "BufferView_pimpl.h"
|
2001-04-05 12:26:41 +00:00
|
|
|
#include "language.h"
|
2001-04-17 15:15:59 +00:00
|
|
|
#include "gettext.h"
|
2001-07-06 15:57:54 +00:00
|
|
|
#include "undo_funcs.h"
|
2001-07-29 15:34:18 +00:00
|
|
|
#include "debug.h"
|
2001-09-01 21:26:34 +00:00
|
|
|
#include "iterators.h"
|
2000-02-04 09:38:32 +00:00
|
|
|
|
2001-12-10 20:06:59 +00:00
|
|
|
#include "frontends/Alert.h"
|
|
|
|
|
|
|
|
#include "insets/insetcommand.h" //ChangeRefs
|
|
|
|
#include "insets/inseterror.h"
|
|
|
|
|
|
|
|
#include "support/FileInfo.h"
|
|
|
|
#include "support/filetools.h"
|
|
|
|
#include "support/lyxfunctional.h" //equal_1st_in_pair
|
2001-12-28 21:17:18 +00:00
|
|
|
#include "support/types.h"
|
2002-01-14 13:04:06 +00:00
|
|
|
#include "support/lyxalgo.h" // lyx_count
|
2001-12-10 20:06:59 +00:00
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
extern BufferList bufferlist;
|
|
|
|
|
2001-12-28 21:17:18 +00:00
|
|
|
using lyx::pos_type;
|
|
|
|
|
2000-04-04 00:19:15 +00:00
|
|
|
using std::pair;
|
2000-03-28 02:18:55 +00:00
|
|
|
using std::endl;
|
2000-02-08 15:13:01 +00:00
|
|
|
using std::ifstream;
|
2000-05-19 16:46:01 +00:00
|
|
|
using std::vector;
|
|
|
|
using std::find;
|
2001-01-31 20:39:53 +00:00
|
|
|
using std::count_if;
|
2000-02-08 15:13:01 +00:00
|
|
|
|
2001-05-29 09:50:02 +00:00
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
// Inserts a file into current document
|
|
|
|
bool BufferView::insertLyXFile(string const & filen)
|
|
|
|
//
|
2000-03-09 03:36:48 +00:00
|
|
|
// Copyright CHT Software Service GmbH
|
2000-02-04 09:38:32 +00:00
|
|
|
// Uwe C. Schroeder
|
|
|
|
//
|
|
|
|
// Insert a Lyxformat - file into current buffer
|
|
|
|
//
|
|
|
|
// Moved from lyx_cb.C (Lgb)
|
|
|
|
{
|
|
|
|
if (filen.empty()) return false;
|
|
|
|
|
2000-12-29 12:48:02 +00:00
|
|
|
string const fname = MakeAbsPath(filen);
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
|
|
// check if file exist
|
2000-12-29 12:48:02 +00:00
|
|
|
FileInfo const fi(fname);
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
|
|
if (!fi.readable()) {
|
2001-11-26 10:19:58 +00:00
|
|
|
Alert::alert(_("Error!"),
|
2000-02-04 09:38:32 +00:00
|
|
|
_("Specified file is unreadable: "),
|
|
|
|
MakeDisplayPath(fname, 50));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2001-02-14 10:11:22 +00:00
|
|
|
beforeChange(text);
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
|
|
ifstream ifs(fname.c_str());
|
|
|
|
if (!ifs) {
|
2001-11-26 10:19:58 +00:00
|
|
|
Alert::alert(_("Error!"),
|
2000-02-04 09:38:32 +00:00
|
|
|
_("Cannot open specified file: "),
|
|
|
|
MakeDisplayPath(fname, 50));
|
|
|
|
return false;
|
|
|
|
}
|
2000-07-31 16:39:50 +00:00
|
|
|
|
2001-10-01 15:31:59 +00:00
|
|
|
int const c = ifs.peek();
|
2000-07-31 16:39:50 +00:00
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
LyXLex lex(0, 0);
|
|
|
|
lex.setStream(ifs);
|
|
|
|
|
|
|
|
bool res = true;
|
|
|
|
|
|
|
|
if (c == '#') {
|
2001-06-27 14:10:35 +00:00
|
|
|
lyxerr[Debug::INFO] << "Will insert file with header" << endl;
|
2000-06-08 23:16:16 +00:00
|
|
|
res = buffer()->readFile(lex, text->cursor.par());
|
2000-02-04 09:38:32 +00:00
|
|
|
} else {
|
2001-06-27 14:10:35 +00:00
|
|
|
lyxerr[Debug::INFO] << "Will insert file without header"
|
|
|
|
<< endl;
|
2000-06-08 23:16:16 +00:00
|
|
|
res = buffer()->readLyXformat2(lex, text->cursor.par());
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resize();
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2000-12-29 12:48:02 +00:00
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
bool BufferView::removeAutoInsets()
|
|
|
|
{
|
2002-02-19 03:57:22 +00:00
|
|
|
// keep track of which pos and par the cursor was on
|
|
|
|
Paragraph * cursor_par = text->cursor.par();
|
|
|
|
Paragraph * cursor_par_prev = cursor_par ? cursor_par->previous() : 0;
|
|
|
|
Paragraph * cursor_par_next = cursor_par ? cursor_par->next() : 0;
|
|
|
|
pos_type cursor_pos = text->cursor.pos();
|
2002-01-12 21:03:30 +00:00
|
|
|
|
2001-12-07 18:40:24 +00:00
|
|
|
bool found = false;
|
2000-02-04 09:38:32 +00:00
|
|
|
|
2002-01-12 21:03:30 +00:00
|
|
|
// Trap the deletion of the paragraph the cursor is in.
|
2002-01-13 06:42:58 +00:00
|
|
|
// Iterate until we find a paragraph that won't be immediately deleted.
|
|
|
|
// In reality this should mean we only execute the body of the while
|
|
|
|
// loop once at most. However for safety we iterate rather than just
|
2002-02-16 15:59:55 +00:00
|
|
|
// make this an if () conditional.
|
2002-02-19 03:57:22 +00:00
|
|
|
while ((cursor_par_prev || cursor_par_next)
|
2002-01-12 21:03:30 +00:00
|
|
|
&& text->setCursor(this,
|
2002-02-19 03:57:22 +00:00
|
|
|
cursor_par_prev ? cursor_par_prev : cursor_par_next,
|
2002-01-12 21:03:30 +00:00
|
|
|
0)) {
|
2002-02-19 03:57:22 +00:00
|
|
|
// We just removed cursor_par so have to fix the "cursor"
|
|
|
|
if (cursor_par_prev) {
|
|
|
|
// '.' = cursor_par
|
2002-01-13 06:42:58 +00:00
|
|
|
// a -> a.
|
|
|
|
// .
|
2002-02-19 03:57:22 +00:00
|
|
|
cursor_par = cursor_par_prev;
|
|
|
|
cursor_pos = cursor_par->size();
|
2002-01-12 21:03:30 +00:00
|
|
|
} else {
|
2002-01-13 06:42:58 +00:00
|
|
|
// . -> .a
|
|
|
|
// a
|
2002-02-19 03:57:22 +00:00
|
|
|
cursor_par = cursor_par_next;
|
|
|
|
cursor_pos = 0;
|
2002-01-12 21:03:30 +00:00
|
|
|
}
|
2002-02-19 03:57:22 +00:00
|
|
|
cursor_par_prev = cursor_par->previous();
|
|
|
|
cursor_par_next = cursor_par->next();
|
2002-01-12 21:03:30 +00:00
|
|
|
}
|
|
|
|
|
2002-02-19 03:57:22 +00:00
|
|
|
// Iterate through the paragraphs removing autoDelete insets as we go.
|
|
|
|
// If the paragraph ends up empty after all the autoDelete insets are
|
|
|
|
// removed that paragraph will be removed by the next setCursor() call.
|
2001-12-28 21:17:18 +00:00
|
|
|
ParIterator it = buffer()->par_iterator_begin();
|
2001-12-07 18:40:24 +00:00
|
|
|
ParIterator end = buffer()->par_iterator_end();
|
2001-12-28 21:17:18 +00:00
|
|
|
for (; it != end; ++it) {
|
2001-12-07 18:40:24 +00:00
|
|
|
Paragraph * par = *it;
|
2002-01-12 21:03:30 +00:00
|
|
|
Paragraph * par_prev = par ? par->previous() : 0;
|
2001-12-28 21:17:18 +00:00
|
|
|
bool removed = false;
|
|
|
|
|
2002-01-13 04:56:48 +00:00
|
|
|
if (text->setCursor(this, par, 0)
|
2002-02-19 03:57:22 +00:00
|
|
|
&& cursor_par == par_prev) {
|
2002-01-13 04:56:48 +00:00
|
|
|
// The previous setCursor line was deleted and that
|
2002-02-19 03:57:22 +00:00
|
|
|
// was the cursor_par line. This can only happen if an
|
|
|
|
// error box was the sole item on cursor_par.
|
|
|
|
// It is possible for cursor_par_prev to be stray if
|
2002-01-15 11:44:16 +00:00
|
|
|
// the line it pointed to only had a error box on it
|
|
|
|
// so we have to set it to a known correct value.
|
|
|
|
// This is often the same value it already had.
|
2002-02-19 03:57:22 +00:00
|
|
|
cursor_par_prev = par->previous();
|
|
|
|
if (cursor_par_prev) {
|
|
|
|
// '|' = par, '.' = cursor_par, 'E' = error box
|
2002-01-13 04:56:48 +00:00
|
|
|
// First step below may occur before while{}
|
2002-01-13 06:42:58 +00:00
|
|
|
// a |a a a a.
|
2002-01-13 04:56:48 +00:00
|
|
|
// E -> .E -> |.E -> . -> |b
|
|
|
|
// . b b |b
|
|
|
|
// b
|
2002-02-19 03:57:22 +00:00
|
|
|
cursor_par = cursor_par_prev;
|
|
|
|
cursor_pos = cursor_par_prev->size();
|
|
|
|
cursor_par_prev = cursor_par->previous();
|
|
|
|
// cursor_par_next remains the same
|
|
|
|
} else if (cursor_par_next) {
|
2002-01-13 04:56:48 +00:00
|
|
|
// First step below may occur before while{}
|
|
|
|
// .
|
|
|
|
// E -> |.E -> |. -> . -> .|a
|
|
|
|
// a a a |a
|
2002-02-19 03:57:22 +00:00
|
|
|
cursor_par = cursor_par_next;
|
|
|
|
cursor_pos = 0;
|
|
|
|
// cursor_par_prev remains unset
|
|
|
|
cursor_par_next = cursor_par->next();
|
2002-01-13 04:56:48 +00:00
|
|
|
} else {
|
|
|
|
// I can't find a way to trigger this
|
|
|
|
// so it should be unreachable code
|
|
|
|
// unless the buffer is corrupted.
|
|
|
|
lyxerr << "BufferView::removeAutoInsets() is bad\n";
|
|
|
|
}
|
|
|
|
}
|
2002-01-12 21:03:30 +00:00
|
|
|
|
2001-12-28 21:17:18 +00:00
|
|
|
Paragraph::inset_iterator pit = par->inset_iterator_begin();
|
|
|
|
Paragraph::inset_iterator pend = par->inset_iterator_end();
|
|
|
|
while (pit != pend) {
|
|
|
|
if (pit->autoDelete()) {
|
|
|
|
removed = true;
|
|
|
|
pos_type const pos = pit.getPos();
|
2002-02-19 03:16:10 +00:00
|
|
|
|
2001-12-28 21:17:18 +00:00
|
|
|
par->erase(pos);
|
2002-02-19 03:57:22 +00:00
|
|
|
// We just invalidated par's inset iterators so
|
|
|
|
// we get the next valid iterator position
|
2002-02-19 03:16:10 +00:00
|
|
|
pit = par->InsetIterator(pos);
|
2002-02-19 03:57:22 +00:00
|
|
|
// and ensure we have a valid end iterator.
|
2002-02-19 03:16:10 +00:00
|
|
|
pend = par->inset_iterator_end();
|
|
|
|
|
2002-02-19 03:57:22 +00:00
|
|
|
if (cursor_par == par) {
|
|
|
|
// update the saved cursor position
|
|
|
|
if (cursor_pos > pos)
|
|
|
|
--cursor_pos;
|
2001-12-28 21:17:18 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
++pit;
|
2001-12-07 18:40:24 +00:00
|
|
|
}
|
2001-03-09 00:56:42 +00:00
|
|
|
}
|
2001-12-28 21:17:18 +00:00
|
|
|
if (removed) {
|
|
|
|
found = true;
|
|
|
|
text->redoParagraph(this);
|
|
|
|
}
|
2001-03-09 00:56:42 +00:00
|
|
|
}
|
|
|
|
|
2002-02-19 03:57:22 +00:00
|
|
|
// It is possible that the last line is empty if it was cursor_par
|
|
|
|
// and/or only had an error inset on it. So we set the cursor to the
|
|
|
|
// start of the doc to force its removal and ensure a valid saved cursor
|
2002-01-15 11:44:16 +00:00
|
|
|
if (text->setCursor(this, text->ownerParagraph(), 0)
|
2002-02-19 03:57:22 +00:00
|
|
|
&& 0 == cursor_par_next) {
|
|
|
|
cursor_par = cursor_par_prev;
|
|
|
|
cursor_pos = cursor_par->size();
|
|
|
|
} else if (cursor_pos > cursor_par->size()) {
|
2002-01-15 11:44:16 +00:00
|
|
|
// Some C-Enter lines were removed by the setCursor call which
|
2002-02-19 03:57:22 +00:00
|
|
|
// then invalidated cursor_pos. It could still be "wrong" because
|
2002-01-15 11:44:16 +00:00
|
|
|
// the cursor may appear to have jumped but since we collapsed
|
|
|
|
// some C-Enter lines this should be a reasonable compromise.
|
2002-02-19 03:57:22 +00:00
|
|
|
cursor_pos = cursor_par->size();
|
2002-01-15 11:44:16 +00:00
|
|
|
}
|
|
|
|
|
2002-02-19 03:57:22 +00:00
|
|
|
// restore the original cursor in its corrected location.
|
|
|
|
text->setCursorIntern(this, cursor_par, cursor_pos);
|
2000-02-04 09:38:32 +00:00
|
|
|
|
2001-12-07 18:40:24 +00:00
|
|
|
return found;
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::insertErrors(TeXErrors & terr)
|
|
|
|
{
|
|
|
|
// Save the cursor position
|
|
|
|
LyXCursor cursor = text->cursor;
|
|
|
|
|
2001-12-28 21:17:18 +00:00
|
|
|
TeXErrors::Errors::const_iterator cit = terr.begin();
|
|
|
|
TeXErrors::Errors::const_iterator end = terr.end();
|
|
|
|
for (; cit != end; ++cit) {
|
2001-07-12 11:11:10 +00:00
|
|
|
string const desctext(cit->error_desc);
|
|
|
|
string const errortext(cit->error_text);
|
2000-12-29 12:48:02 +00:00
|
|
|
string const msgtxt = desctext + '\n' + errortext;
|
2001-07-12 11:11:10 +00:00
|
|
|
int const errorrow = cit->error_in_line;
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
|
|
// Insert error string for row number
|
|
|
|
int tmpid = -1;
|
|
|
|
int tmppos = -1;
|
|
|
|
|
2000-08-05 05:17:18 +00:00
|
|
|
if (buffer()->texrow.getIdFromRow(errorrow, tmpid, tmppos)) {
|
|
|
|
buffer()->texrow.increasePos(tmpid, tmppos);
|
|
|
|
}
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
Paragraph * texrowpar = 0;
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
|
|
if (tmpid == -1) {
|
2002-01-13 00:33:21 +00:00
|
|
|
texrowpar = text->ownerParagraph();
|
2000-02-04 09:38:32 +00:00
|
|
|
tmppos = 0;
|
|
|
|
} else {
|
2001-07-09 09:16:00 +00:00
|
|
|
texrowpar = buffer()->getParFromID(tmpid);
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (texrowpar == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
InsetError * new_inset = new InsetError(msgtxt);
|
2001-06-25 00:06:33 +00:00
|
|
|
text->setCursorIntern(this, texrowpar, tmppos);
|
|
|
|
text->insertInset(this, new_inset);
|
|
|
|
text->fullRebreak(this);
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
// Restore the cursor position
|
2001-06-25 00:06:33 +00:00
|
|
|
text->setCursorIntern(this, cursor.par(), cursor.pos());
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::setCursorFromRow(int row)
|
|
|
|
{
|
|
|
|
int tmpid = -1;
|
|
|
|
int tmppos = -1;
|
|
|
|
|
|
|
|
buffer()->texrow.getIdFromRow(row, tmpid, tmppos);
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
Paragraph * texrowpar;
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
|
|
if (tmpid == -1) {
|
2002-01-13 00:33:21 +00:00
|
|
|
texrowpar = text->ownerParagraph();
|
2000-02-04 09:38:32 +00:00
|
|
|
tmppos = 0;
|
|
|
|
} else {
|
2001-07-09 09:16:00 +00:00
|
|
|
texrowpar = buffer()->getParFromID(tmpid);
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
text->setCursor(this, texrowpar, tmppos);
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
|
2000-10-03 18:38:10 +00:00
|
|
|
|
2001-06-04 23:57:32 +00:00
|
|
|
bool BufferView::insertInset(Inset * inset, string const & lout)
|
2000-02-04 09:38:32 +00:00
|
|
|
{
|
2001-06-04 23:57:32 +00:00
|
|
|
return pimpl_->insertInset(inset, lout);
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* This is also a buffer property (ale) */
|
|
|
|
// Not so sure about that. a goto Label function can not be buffer local, just
|
|
|
|
// think how this will work in a multiwindo/buffer environment, all the
|
|
|
|
// cursors in all the views showing this buffer will move. (Lgb)
|
|
|
|
// OK, then no cursor action should be allowed in buffer. (ale)
|
|
|
|
bool BufferView::gotoLabel(string const & label)
|
|
|
|
|
|
|
|
{
|
2000-05-19 16:46:01 +00:00
|
|
|
for (Buffer::inset_iterator it = buffer()->inset_iterator_begin();
|
|
|
|
it != buffer()->inset_iterator_end(); ++it) {
|
|
|
|
vector<string> labels = (*it)->getLabelList();
|
2000-11-04 10:00:12 +00:00
|
|
|
if (find(labels.begin(),labels.end(),label)
|
2000-05-19 16:46:01 +00:00
|
|
|
!= labels.end()) {
|
2001-02-14 10:11:22 +00:00
|
|
|
beforeChange(text);
|
2001-06-25 00:06:33 +00:00
|
|
|
text->setCursor(this, it.getPar(), it.getPos());
|
2001-05-31 02:23:46 +00:00
|
|
|
text->selection.cursor = text->cursor;
|
2001-02-14 08:38:21 +00:00
|
|
|
update(text, BufferView::SELECT|BufferView::FITCUR);
|
2000-05-19 16:46:01 +00:00
|
|
|
return true;
|
|
|
|
}
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2000-07-19 17:16:27 +00:00
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
void BufferView::menuUndo()
|
|
|
|
{
|
|
|
|
if (available()) {
|
2001-04-24 17:33:01 +00:00
|
|
|
owner()->message(_("Undo"));
|
2000-02-17 19:59:08 +00:00
|
|
|
hideCursor();
|
2001-02-14 10:11:22 +00:00
|
|
|
beforeChange(text);
|
2001-02-14 08:38:21 +00:00
|
|
|
update(text, BufferView::SELECT|BufferView::FITCUR);
|
2001-07-06 15:57:54 +00:00
|
|
|
if (!textUndo(this))
|
2001-09-20 10:16:24 +00:00
|
|
|
owner()->message(_("No further undo information"));
|
2000-02-04 09:38:32 +00:00
|
|
|
else
|
2001-02-14 08:38:21 +00:00
|
|
|
update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
2000-02-17 19:59:08 +00:00
|
|
|
setState();
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::menuRedo()
|
|
|
|
{
|
2001-12-14 11:55:58 +00:00
|
|
|
#if 0 // this should not be here (Jug 20011206)
|
2000-10-03 13:55:48 +00:00
|
|
|
if (theLockingInset()) {
|
2001-04-24 17:33:01 +00:00
|
|
|
owner()->message(_("Redo not yet supported in math mode"));
|
2000-02-04 09:38:32 +00:00
|
|
|
return;
|
2001-12-14 11:55:58 +00:00
|
|
|
}
|
|
|
|
#endif
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
|
|
if (available()) {
|
2001-04-24 17:33:01 +00:00
|
|
|
owner()->message(_("Redo"));
|
2000-02-17 19:59:08 +00:00
|
|
|
hideCursor();
|
2001-02-14 10:11:22 +00:00
|
|
|
beforeChange(text);
|
2001-02-14 08:38:21 +00:00
|
|
|
update(text, BufferView::SELECT|BufferView::FITCUR);
|
2001-07-06 15:57:54 +00:00
|
|
|
if (!textRedo(this))
|
2001-04-24 17:33:01 +00:00
|
|
|
owner()->message(_("No further redo information"));
|
2000-02-04 09:38:32 +00:00
|
|
|
else
|
2001-02-14 08:38:21 +00:00
|
|
|
update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
2000-02-17 19:59:08 +00:00
|
|
|
setState();
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::copyEnvironment()
|
|
|
|
{
|
|
|
|
if (available()) {
|
|
|
|
text->copyEnvironmentType();
|
2001-04-24 17:33:01 +00:00
|
|
|
owner()->message(_("Paragraph environment type copied"));
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::pasteEnvironment()
|
|
|
|
{
|
|
|
|
if (available()) {
|
2000-06-12 11:27:15 +00:00
|
|
|
text->pasteEnvironmentType(this);
|
2001-04-24 17:33:01 +00:00
|
|
|
owner()->message(_("Paragraph environment type set"));
|
2001-02-14 08:38:21 +00:00
|
|
|
update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::copy()
|
|
|
|
{
|
|
|
|
if (available()) {
|
2002-03-18 13:47:37 +00:00
|
|
|
getLyXText()->copySelection(this);
|
2001-04-24 17:33:01 +00:00
|
|
|
owner()->message(_("Copy"));
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-29 09:50:02 +00:00
|
|
|
|
2001-08-08 14:36:56 +00:00
|
|
|
void BufferView::cut(bool realcut)
|
2000-02-04 09:38:32 +00:00
|
|
|
{
|
|
|
|
if (available()) {
|
2000-02-17 19:59:08 +00:00
|
|
|
hideCursor();
|
2001-02-14 08:38:21 +00:00
|
|
|
update(text, BufferView::SELECT|BufferView::FITCUR);
|
2001-08-08 14:36:56 +00:00
|
|
|
text->cutSelection(this, true, realcut);
|
2001-02-14 08:38:21 +00:00
|
|
|
update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
2001-04-24 17:33:01 +00:00
|
|
|
owner()->message(_("Cut"));
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::paste()
|
|
|
|
{
|
2002-03-18 13:47:37 +00:00
|
|
|
if (!available())
|
|
|
|
return;
|
2001-04-17 15:15:59 +00:00
|
|
|
|
2001-04-24 17:33:01 +00:00
|
|
|
owner()->message(_("Paste"));
|
2001-04-17 15:15:59 +00:00
|
|
|
|
2000-02-17 19:59:08 +00:00
|
|
|
hideCursor();
|
2000-02-04 09:38:32 +00:00
|
|
|
// clear the selection
|
2000-02-17 19:59:08 +00:00
|
|
|
toggleSelection();
|
2001-08-01 15:42:53 +00:00
|
|
|
text->clearSelection();
|
2001-02-14 08:38:21 +00:00
|
|
|
update(text, BufferView::SELECT|BufferView::FITCUR);
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
|
|
// paste
|
2001-06-25 00:06:33 +00:00
|
|
|
text->pasteSelection(this);
|
2001-02-14 08:38:21 +00:00
|
|
|
update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
2002-03-18 13:47:37 +00:00
|
|
|
// why fake a selection only I think it should be a real one and not only
|
|
|
|
// a painted one (Jug 20020318).
|
|
|
|
#if 0
|
2000-02-04 09:38:32 +00:00
|
|
|
// clear the selection
|
2000-02-17 19:59:08 +00:00
|
|
|
toggleSelection();
|
2001-08-01 15:42:53 +00:00
|
|
|
text->clearSelection();
|
2001-02-14 08:38:21 +00:00
|
|
|
update(text, BufferView::SELECT|BufferView::FITCUR);
|
2002-03-18 13:47:37 +00:00
|
|
|
#endif
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* these functions are for the spellchecker */
|
2000-09-14 17:53:12 +00:00
|
|
|
string const BufferView::nextWord(float & value)
|
2000-02-04 09:38:32 +00:00
|
|
|
{
|
|
|
|
if (!available()) {
|
|
|
|
value = 1;
|
2000-10-23 22:36:52 +00:00
|
|
|
return string();
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
|
2001-09-21 16:21:23 +00:00
|
|
|
return text->selectNextWordToSpellcheck(this, value);
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::selectLastWord()
|
|
|
|
{
|
|
|
|
if (!available()) return;
|
|
|
|
|
2001-08-10 11:07:07 +00:00
|
|
|
LyXCursor cur = text->selection.cursor;
|
2000-02-17 19:59:08 +00:00
|
|
|
hideCursor();
|
2001-02-14 10:11:22 +00:00
|
|
|
beforeChange(text);
|
2001-08-10 11:07:07 +00:00
|
|
|
text->selection.cursor = cur;
|
2001-06-25 00:06:33 +00:00
|
|
|
text->selectSelectedWord(this);
|
2000-02-17 19:59:08 +00:00
|
|
|
toggleSelection(false);
|
2001-02-14 08:38:21 +00:00
|
|
|
update(text, BufferView::SELECT|BufferView::FITCUR);
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::endOfSpellCheck()
|
|
|
|
{
|
|
|
|
if (!available()) return;
|
|
|
|
|
2000-02-17 19:59:08 +00:00
|
|
|
hideCursor();
|
2001-02-14 10:11:22 +00:00
|
|
|
beforeChange(text);
|
2001-06-25 00:06:33 +00:00
|
|
|
text->selectSelectedWord(this);
|
2001-08-01 15:42:53 +00:00
|
|
|
text->clearSelection();
|
2001-02-14 08:38:21 +00:00
|
|
|
update(text, BufferView::SELECT|BufferView::FITCUR);
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
2000-02-17 19:59:08 +00:00
|
|
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
void BufferView::replaceWord(string const & replacestring)
|
|
|
|
{
|
2000-02-17 19:59:08 +00:00
|
|
|
if (!available()) return;
|
2000-02-04 09:38:32 +00:00
|
|
|
|
2001-07-17 15:39:12 +00:00
|
|
|
LyXText * tt = getLyXText();
|
2000-02-17 19:59:08 +00:00
|
|
|
hideCursor();
|
2001-07-17 15:39:12 +00:00
|
|
|
update(tt, BufferView::SELECT|BufferView::FITCUR);
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
|
|
/* clear the selection (if there is any) */
|
2000-02-17 19:59:08 +00:00
|
|
|
toggleSelection(false);
|
2001-07-17 15:39:12 +00:00
|
|
|
update(tt, BufferView::SELECT|BufferView::FITCUR);
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
|
|
/* clear the selection (if there is any) */
|
2000-02-17 19:59:08 +00:00
|
|
|
toggleSelection(false);
|
2001-07-17 15:39:12 +00:00
|
|
|
tt->replaceSelectionWithString(this, replacestring);
|
2000-02-04 09:38:32 +00:00
|
|
|
|
2001-07-17 15:39:12 +00:00
|
|
|
tt->setSelectionOverString(this, replacestring);
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
|
|
// Go back so that replacement string is also spellchecked
|
|
|
|
for (string::size_type i = 0; i < replacestring.length() + 1; ++i) {
|
2001-07-17 15:39:12 +00:00
|
|
|
tt->cursorLeft(this);
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
2001-07-17 15:39:12 +00:00
|
|
|
update(tt, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
// End of spellchecker stuff
|
|
|
|
|
|
|
|
|
2000-04-19 14:42:19 +00:00
|
|
|
bool BufferView::lockInset(UpdatableInset * inset)
|
2000-02-04 09:38:32 +00:00
|
|
|
{
|
2001-12-14 11:55:58 +00:00
|
|
|
if (!inset)
|
|
|
|
return false;
|
2001-11-29 12:58:59 +00:00
|
|
|
// don't relock if we're already locked
|
|
|
|
if (theLockingInset() == inset)
|
|
|
|
return true;
|
2001-12-14 11:55:58 +00:00
|
|
|
if (!theLockingInset()) {
|
|
|
|
// first check if it's the inset under the cursor we want lock
|
|
|
|
// should be most of the time
|
|
|
|
char const c = text->cursor.par()->getChar(text->cursor.pos());
|
|
|
|
if (c == Paragraph::META_INSET) {
|
|
|
|
Inset * in = text->cursor.par()->getInset(text->cursor.pos());
|
|
|
|
if (inset == in) {
|
|
|
|
theLockingInset(inset);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Then do a deep look of the inset and lock the right one
|
|
|
|
Paragraph * par = buffer()->paragraph;
|
|
|
|
int const id = inset->id();
|
|
|
|
while(par) {
|
|
|
|
Paragraph::inset_iterator it =
|
|
|
|
par->inset_iterator_begin();
|
|
|
|
Paragraph::inset_iterator const end =
|
|
|
|
par->inset_iterator_end();
|
|
|
|
for (; it != end; ++it) {
|
|
|
|
if ((*it) == inset) {
|
2002-01-04 16:03:53 +00:00
|
|
|
text->setCursorIntern(this, par, it.getPos());
|
2001-12-14 11:55:58 +00:00
|
|
|
theLockingInset(inset);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if ((*it)->getInsetFromID(id)) {
|
|
|
|
text->setCursorIntern(this, par, it.getPos());
|
2002-01-17 14:27:01 +00:00
|
|
|
(*it)->edit(this);
|
2001-12-14 11:55:58 +00:00
|
|
|
return theLockingInset()->lockInsetInInset(this, inset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
par = par->next();
|
|
|
|
}
|
|
|
|
return false;
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
2001-12-14 11:55:58 +00:00
|
|
|
return theLockingInset()->lockInsetInInset(this, inset);
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-29 18:44:07 +00:00
|
|
|
void BufferView::showLockedInsetCursor(int x, int y, int asc, int desc)
|
2000-02-04 09:38:32 +00:00
|
|
|
{
|
2002-01-06 19:34:30 +00:00
|
|
|
if (available() && theLockingInset() && !theLockingInset()->nodraw()) {
|
2000-04-19 14:42:19 +00:00
|
|
|
LyXCursor cursor = text->cursor;
|
2001-08-13 17:57:14 +00:00
|
|
|
Inset * locking_inset = theLockingInset()->getLockingInset();
|
|
|
|
|
2000-06-08 23:16:16 +00:00
|
|
|
if ((cursor.pos() - 1 >= 0) &&
|
2001-11-23 10:16:02 +00:00
|
|
|
cursor.par()->isInset(cursor.pos() - 1) &&
|
2001-06-25 00:06:33 +00:00
|
|
|
(cursor.par()->getInset(cursor.pos() - 1) ==
|
2001-08-13 17:57:14 +00:00
|
|
|
locking_inset))
|
2001-06-25 00:06:33 +00:00
|
|
|
text->setCursor(this, cursor,
|
2001-08-08 13:29:13 +00:00
|
|
|
cursor.par(), cursor.pos() - 1);
|
2000-12-17 06:09:35 +00:00
|
|
|
LyXScreen::Cursor_Shape shape = LyXScreen::BAR_SHAPE;
|
|
|
|
LyXText * txt = getLyXText();
|
2001-08-13 17:57:14 +00:00
|
|
|
if (locking_inset->isTextInset() &&
|
|
|
|
locking_inset->lyxCode() != Inset::ERT_CODE &&
|
2000-12-17 06:09:35 +00:00
|
|
|
(txt->real_current_font.language() !=
|
|
|
|
buffer()->params.language
|
|
|
|
|| txt->real_current_font.isVisibleRightToLeft()
|
|
|
|
!= buffer()->params.language->RightToLeft()))
|
|
|
|
shape = (txt->real_current_font.isVisibleRightToLeft())
|
|
|
|
? LyXScreen::REVERSED_L_SHAPE
|
|
|
|
: LyXScreen::L_SHAPE;
|
2001-06-28 10:25:20 +00:00
|
|
|
y += cursor.y() + theLockingInset()->insetInInsetY();
|
2001-07-04 07:19:09 +00:00
|
|
|
pimpl_->screen_->showManualCursor(text, x, y, asc, desc,
|
2000-12-17 06:09:35 +00:00
|
|
|
shape);
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-17 19:59:08 +00:00
|
|
|
void BufferView::hideLockedInsetCursor()
|
2000-02-04 09:38:32 +00:00
|
|
|
{
|
2000-10-03 13:55:48 +00:00
|
|
|
if (theLockingInset() && available()) {
|
2001-07-04 07:19:09 +00:00
|
|
|
pimpl_->screen_->hideCursor();
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-29 18:44:07 +00:00
|
|
|
void BufferView::fitLockedInsetCursor(int x, int y, int asc, int desc)
|
2000-02-04 09:38:32 +00:00
|
|
|
{
|
2000-12-29 12:48:02 +00:00
|
|
|
if (theLockingInset() && available()) {
|
2001-06-28 10:25:20 +00:00
|
|
|
y += text->cursor.y() + theLockingInset()->insetInInsetY();
|
2001-07-04 07:19:09 +00:00
|
|
|
if (pimpl_->screen_->fitManualCursor(text, this, x, y, asc, desc))
|
2000-02-04 09:38:32 +00:00
|
|
|
updateScrollbar();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int BufferView::unlockInset(UpdatableInset * inset)
|
|
|
|
{
|
2001-12-14 11:55:58 +00:00
|
|
|
if (!inset)
|
|
|
|
return 0;
|
2000-10-03 13:55:48 +00:00
|
|
|
if (inset && theLockingInset() == inset) {
|
2001-06-28 10:25:20 +00:00
|
|
|
inset->insetUnlock(this);
|
2000-10-03 13:55:48 +00:00
|
|
|
theLockingInset(0);
|
2001-12-05 23:16:13 +00:00
|
|
|
// make sure we update the combo !
|
2002-03-02 16:39:54 +00:00
|
|
|
owner()->setLayout(getLyXText()->cursor.par()->layout());
|
2001-07-06 15:57:54 +00:00
|
|
|
finishUndo();
|
2000-02-04 09:38:32 +00:00
|
|
|
return 0;
|
2000-10-03 13:55:48 +00:00
|
|
|
} else if (inset && theLockingInset() &&
|
2001-06-28 10:25:20 +00:00
|
|
|
theLockingInset()->unlockInsetInInset(this, inset)) {
|
2001-12-05 23:16:13 +00:00
|
|
|
// owner inset has updated the layout combo
|
2001-07-06 15:57:54 +00:00
|
|
|
finishUndo();
|
2000-04-10 14:29:05 +00:00
|
|
|
return 0;
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
|
|
|
return bufferlist.unlockInset(inset);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::lockedInsetStoreUndo(Undo::undo_kind kind)
|
|
|
|
{
|
2000-10-03 13:55:48 +00:00
|
|
|
if (!theLockingInset())
|
2000-02-04 09:38:32 +00:00
|
|
|
return; // shouldn't happen
|
|
|
|
if (kind == Undo::EDIT) // in this case insets would not be stored!
|
|
|
|
kind = Undo::FINISH;
|
2001-07-06 15:57:54 +00:00
|
|
|
setUndo(this, kind,
|
|
|
|
text->cursor.par(),
|
|
|
|
text->cursor.par()->next());
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
2000-02-23 16:39:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
void BufferView::updateInset(Inset * inset, bool mark_dirty)
|
|
|
|
{
|
2001-06-04 23:57:32 +00:00
|
|
|
pimpl_->updateInset(inset, mark_dirty);
|
2000-02-23 16:39:03 +00:00
|
|
|
}
|
2000-05-19 16:46:01 +00:00
|
|
|
|
2000-12-29 12:48:02 +00:00
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
bool BufferView::ChangeInsets(Inset::Code code,
|
|
|
|
string const & from, string const & to)
|
2000-05-19 16:46:01 +00:00
|
|
|
{
|
2001-12-05 23:16:13 +00:00
|
|
|
bool need_update = false;
|
2000-05-19 16:46:01 +00:00
|
|
|
LyXCursor cursor = text->cursor;
|
|
|
|
LyXCursor tmpcursor = cursor;
|
2000-07-24 21:49:58 +00:00
|
|
|
cursor.par(tmpcursor.par());
|
|
|
|
cursor.pos(tmpcursor.pos());
|
2000-05-19 16:46:01 +00:00
|
|
|
|
2001-09-01 21:26:34 +00:00
|
|
|
ParIterator end = buffer()->par_iterator_end();
|
|
|
|
for (ParIterator it = buffer()->par_iterator_begin();
|
|
|
|
it != end; ++it) {
|
|
|
|
Paragraph * par = *it;
|
2001-12-05 23:16:13 +00:00
|
|
|
bool changed_inset = false;
|
2001-09-01 21:26:34 +00:00
|
|
|
for (Paragraph::inset_iterator it2 = par->inset_iterator_begin();
|
|
|
|
it2 != par->inset_iterator_end(); ++it2) {
|
|
|
|
if ((*it2)->lyxCode() == code) {
|
|
|
|
InsetCommand * inset = static_cast<InsetCommand *>(*it2);
|
2000-05-19 16:46:01 +00:00
|
|
|
if (inset->getContents() == from) {
|
|
|
|
inset->setContents(to);
|
2001-12-05 23:16:13 +00:00
|
|
|
changed_inset = true;
|
2000-05-19 16:46:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-12-05 23:16:13 +00:00
|
|
|
if (changed_inset) {
|
|
|
|
need_update = true;
|
2002-03-12 17:15:44 +00:00
|
|
|
|
|
|
|
// FIXME
|
|
|
|
|
2001-09-01 21:26:34 +00:00
|
|
|
// The test it.size()==1 was needed to prevent crashes.
|
|
|
|
// How to set the cursor corretly when it.size()>1 ??
|
|
|
|
if (it.size() == 1) {
|
|
|
|
text->setCursorIntern(this, par, 0);
|
|
|
|
text->redoParagraphs(this, text->cursor,
|
|
|
|
text->cursor.par()->next());
|
|
|
|
text->fullRebreak(this);
|
|
|
|
}
|
2001-03-09 00:56:42 +00:00
|
|
|
}
|
2000-05-19 16:46:01 +00:00
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
text->setCursorIntern(this, cursor.par(), cursor.pos());
|
2001-12-05 23:16:13 +00:00
|
|
|
return need_update;
|
2000-05-19 16:46:01 +00:00
|
|
|
}
|
2000-10-03 13:55:48 +00:00
|
|
|
|
|
|
|
|
2000-12-11 09:46:09 +00:00
|
|
|
bool BufferView::ChangeRefsIfUnique(string const & from, string const & to)
|
|
|
|
{
|
|
|
|
// Check if the label 'from' appears more than once
|
|
|
|
vector<string> labels = buffer()->getLabelList();
|
2002-01-14 13:04:06 +00:00
|
|
|
|
|
|
|
if (lyx::count(labels.begin(), labels.end(), from) > 1)
|
2000-12-11 09:46:09 +00:00
|
|
|
return false;
|
|
|
|
|
2001-01-31 20:39:53 +00:00
|
|
|
return ChangeInsets(Inset::REF_CODE, from, to);
|
2000-12-11 09:46:09 +00:00
|
|
|
}
|
|
|
|
|
2000-12-29 12:48:02 +00:00
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
bool BufferView::ChangeCitationsIfUnique(string const & from,
|
|
|
|
string const & to)
|
2001-01-31 20:39:53 +00:00
|
|
|
{
|
2002-02-16 15:59:55 +00:00
|
|
|
typedef pair<string, string> StringPair;
|
|
|
|
|
|
|
|
vector<StringPair> keys = buffer()->getBibkeyList();
|
2001-01-31 20:39:53 +00:00
|
|
|
if (count_if(keys.begin(), keys.end(),
|
2002-02-16 15:59:55 +00:00
|
|
|
lyx::equal_1st_in_pair<StringPair>(from))
|
2001-01-31 20:39:53 +00:00
|
|
|
> 1)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return ChangeInsets(Inset::CITE_CODE, from, to);
|
|
|
|
}
|
|
|
|
|
2001-06-04 23:57:32 +00:00
|
|
|
|
2000-10-03 13:55:48 +00:00
|
|
|
UpdatableInset * BufferView::theLockingInset() const
|
|
|
|
{
|
2000-12-17 06:09:35 +00:00
|
|
|
// If NULL is not allowed we should put an Assert here. (Lgb)
|
|
|
|
if (text)
|
|
|
|
return text->the_locking_inset;
|
|
|
|
return 0;
|
2000-10-03 13:55:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-03 15:31:35 +00:00
|
|
|
void BufferView::theLockingInset(UpdatableInset * inset)
|
2000-10-03 13:55:48 +00:00
|
|
|
{
|
2001-04-26 19:17:50 +00:00
|
|
|
text->the_locking_inset = inset;
|
2000-10-03 13:55:48 +00:00
|
|
|
}
|
2000-12-17 06:09:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
LyXText * BufferView::getLyXText() const
|
|
|
|
{
|
|
|
|
if (theLockingInset()) {
|
2001-02-22 14:09:20 +00:00
|
|
|
LyXText * txt = theLockingInset()->getLyXText(this, true);
|
2000-12-17 06:09:35 +00:00
|
|
|
if (txt)
|
|
|
|
return txt;
|
|
|
|
}
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2001-01-08 16:14:09 +00:00
|
|
|
|
|
|
|
LyXText * BufferView::getParentText(Inset * inset) const
|
|
|
|
{
|
|
|
|
if (inset->owner()) {
|
|
|
|
LyXText * txt = inset->getLyXText(this);
|
|
|
|
inset = inset->owner();
|
|
|
|
while (inset && inset->getLyXText(this) == txt)
|
|
|
|
inset = inset->owner();
|
|
|
|
if (inset)
|
|
|
|
return inset->getLyXText(this);
|
|
|
|
}
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2001-04-04 21:37:14 +00:00
|
|
|
|
2001-01-08 16:14:09 +00:00
|
|
|
Language const * BufferView::getParentLanguage(Inset * inset) const
|
|
|
|
{
|
|
|
|
LyXText * text = getParentText(inset);
|
2001-06-25 00:06:33 +00:00
|
|
|
return text->cursor.par()->getFontSettings(buffer()->params,
|
2001-01-08 16:14:09 +00:00
|
|
|
text->cursor.pos()).language();
|
|
|
|
}
|