mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
more IU stuff
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8430 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
fcc89010ec
commit
2288d17247
@ -297,9 +297,9 @@ void BufferView::setCursorFromRow(int row)
|
|||||||
buffer()->texrow().getIdFromRow(row, tmpid, tmppos);
|
buffer()->texrow().getIdFromRow(row, tmpid, tmppos);
|
||||||
|
|
||||||
if (tmpid == -1)
|
if (tmpid == -1)
|
||||||
text()->setCursor(0, 0);
|
text()->setCursor(cursor(), 0, 0);
|
||||||
else
|
else
|
||||||
text()->setCursor(
|
text()->setCursor(cursor(),
|
||||||
text()->parOffset(buffer()->getParFromID(tmpid).pit()),
|
text()->parOffset(buffer()->getParFromID(tmpid).pit()),
|
||||||
tmppos);
|
tmppos);
|
||||||
}
|
}
|
||||||
@ -313,7 +313,7 @@ void BufferView::gotoLabel(string const & label)
|
|||||||
it->getLabelList(*buffer(), labels);
|
it->getLabelList(*buffer(), labels);
|
||||||
if (find(labels.begin(),labels.end(),label) != labels.end()) {
|
if (find(labels.begin(),labels.end(),label) != labels.end()) {
|
||||||
cursor().clearSelection();
|
cursor().clearSelection();
|
||||||
text()->setCursor(
|
text()->setCursor(cursor(),
|
||||||
distance(text()->paragraphs().begin(), it.getPar()),
|
distance(text()->paragraphs().begin(), it.getPar()),
|
||||||
it.getPos());
|
it.getPos());
|
||||||
cursor().resetAnchor();
|
cursor().resetAnchor();
|
||||||
@ -330,19 +330,6 @@ void BufferView::hideCursor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool BufferView::ChangeRefsIfUnique(string const & from, string const & to)
|
|
||||||
{
|
|
||||||
// Check if the label 'from' appears more than once
|
|
||||||
vector<string> labels;
|
|
||||||
buffer()->getLabelList(labels);
|
|
||||||
|
|
||||||
if (lyx::count(labels.begin(), labels.end(), from) > 1)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return pimpl_->ChangeInsets(InsetOld::REF_CODE, from, to);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
LyXText * BufferView::getLyXText() const
|
LyXText * BufferView::getLyXText() const
|
||||||
{
|
{
|
||||||
return cursor().innerText();
|
return cursor().innerText();
|
||||||
@ -399,7 +386,7 @@ void BufferView::setCursor(ParIterator const & par,
|
|||||||
(*positions[i].it)->inset->edit(cur, true);
|
(*positions[i].it)->inset->edit(cur, true);
|
||||||
cur.resetAnchor();
|
cur.resetAnchor();
|
||||||
LyXText * lt = par.text(*buffer());
|
LyXText * lt = par.text(*buffer());
|
||||||
lt->setCursor(lt->parOffset(par.pit()), pos);
|
lt->setCursor(cur, lt->parOffset(par.pit()), pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -431,7 +418,7 @@ void BufferView::putSelectionAt(PosIterator const & cur,
|
|||||||
if (par.inset())
|
if (par.inset())
|
||||||
top_y(par.outerPar()->y);
|
top_y(par.outerPar()->y);
|
||||||
update();
|
update();
|
||||||
text->setCursor(text->parOffset(cur.pit()), cur.pos());
|
text->setCursor(cursor(), text->parOffset(cur.pit()), cur.pos());
|
||||||
cursor().updatePos();
|
cursor().updatePos();
|
||||||
|
|
||||||
if (length) {
|
if (length) {
|
||||||
|
@ -154,9 +154,6 @@ public:
|
|||||||
/// switch between primary and secondary keymaps for RTL entry
|
/// switch between primary and secondary keymaps for RTL entry
|
||||||
void switchKeyMap();
|
void switchKeyMap();
|
||||||
|
|
||||||
/// FIXME
|
|
||||||
bool ChangeRefsIfUnique(std::string const & from, std::string const & to);
|
|
||||||
|
|
||||||
/// get the contents of the window system clipboard
|
/// get the contents of the window system clipboard
|
||||||
std::string const getClipboard() const;
|
std::string const getClipboard() const;
|
||||||
/// fill the window system clipboard
|
/// fill the window system clipboard
|
||||||
|
@ -77,6 +77,7 @@ using lyx::support::strToUnsignedInt;
|
|||||||
using lyx::support::system_lyxdir;
|
using lyx::support::system_lyxdir;
|
||||||
|
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
using std::istringstream;
|
||||||
using std::make_pair;
|
using std::make_pair;
|
||||||
using std::min;
|
using std::min;
|
||||||
using std::string;
|
using std::string;
|
||||||
@ -413,13 +414,13 @@ void BufferView::Pimpl::resizeCurrentBuffer()
|
|||||||
// Mechanism when setting the cursor.
|
// Mechanism when setting the cursor.
|
||||||
cur.mark() = mark_set;
|
cur.mark() = mark_set;
|
||||||
if (sel) {
|
if (sel) {
|
||||||
text->setCursor(selstartpar, selstartpos);
|
text->setCursor(cur, selstartpar, selstartpos);
|
||||||
cur.resetAnchor();
|
cur.resetAnchor();
|
||||||
text->setCursor(selendpar, selendpos);
|
text->setCursor(cur, selendpar, selendpos);
|
||||||
cur.setSelection();
|
cur.setSelection();
|
||||||
text->setCursor(par, pos);
|
text->setCursor(cur, par, pos);
|
||||||
} else {
|
} else {
|
||||||
text->setCursor(par, pos);
|
text->setCursor(cur, par, pos);
|
||||||
cur.resetAnchor();
|
cur.resetAnchor();
|
||||||
cur.selection() = false;
|
cur.selection() = false;
|
||||||
}
|
}
|
||||||
@ -474,11 +475,12 @@ void BufferView::Pimpl::scrollDocView(int value)
|
|||||||
int const last = top_y() + workarea().workHeight() - height;
|
int const last = top_y() + workarea().workHeight() - height;
|
||||||
|
|
||||||
LyXText * text = bv_->text();
|
LyXText * text = bv_->text();
|
||||||
int y = text->cursorY(bv_->cursor().cursor_.front());
|
CursorSlice & cur = bv_->cursor().cursor_.front();
|
||||||
|
int y = text->cursorY(cur);
|
||||||
if (y < first)
|
if (y < first)
|
||||||
text->setCursorFromCoordinates(0, first);
|
text->setCursorFromCoordinates(cur, 0, first);
|
||||||
else if (y > last)
|
else if (y > last)
|
||||||
text->setCursorFromCoordinates(0, last);
|
text->setCursorFromCoordinates(cur, 0, last);
|
||||||
|
|
||||||
owner_->updateLayoutChoice();
|
owner_->updateLayoutChoice();
|
||||||
}
|
}
|
||||||
@ -681,8 +683,10 @@ void BufferView::Pimpl::restorePosition(unsigned int i)
|
|||||||
if (par == buffer_->par_iterator_end())
|
if (par == buffer_->par_iterator_end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bv_->text()->setCursor(bv_->text()->parOffset(par.pit()),
|
bv_->text()->setCursor(
|
||||||
min(par->size(), saved_positions[i].par_pos));
|
bv_->cursor(),
|
||||||
|
bv_->text()->parOffset(par.pit()),
|
||||||
|
min(par->size(), saved_positions[i].par_pos));
|
||||||
|
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
owner_->message(bformat(_("Moved to bookmark %1$s"), tostr(i)));
|
owner_->message(bformat(_("Moved to bookmark %1$s"), tostr(i)));
|
||||||
@ -742,31 +746,28 @@ void BufferView::Pimpl::stuffClipboard(string const & stuff) const
|
|||||||
|
|
||||||
InsetBase * BufferView::Pimpl::getInsetByCode(InsetBase::Code code)
|
InsetBase * BufferView::Pimpl::getInsetByCode(InsetBase::Code code)
|
||||||
{
|
{
|
||||||
|
#warning Does not work for mathed
|
||||||
// Ok, this is a little bit too brute force but it
|
// Ok, this is a little bit too brute force but it
|
||||||
// should work for now. Better infrastructure is coming. (Lgb)
|
// should work for now. Better infrastructure is coming. (Lgb)
|
||||||
|
|
||||||
Buffer * b = bv_->buffer();
|
Buffer * buf = bv_->buffer();
|
||||||
LyXText * text = bv_->getLyXText();
|
Buffer::inset_iterator beg = buf->inset_iterator_begin();
|
||||||
|
Buffer::inset_iterator end = buf->inset_iterator_end();
|
||||||
Buffer::inset_iterator beg = b->inset_iterator_begin();
|
|
||||||
Buffer::inset_iterator end = b->inset_iterator_end();
|
|
||||||
|
|
||||||
bool cursor_par_seen = false;
|
bool cursor_par_seen = false;
|
||||||
|
|
||||||
for (; beg != end; ++beg) {
|
LCursor & cur = bv_->cursor();
|
||||||
if (beg.getPar() == text->cursorPar()) {
|
ParagraphList::iterator pit = bv_->getLyXText()->getPar(cur.par());
|
||||||
cursor_par_seen = true;
|
|
||||||
}
|
|
||||||
if (cursor_par_seen) {
|
|
||||||
if (beg.getPar() == text->cursorPar()
|
|
||||||
&& beg.getPos() >= text->cursor().pos()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (beg.getPar() != text->cursorPar()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
for (; beg != end; ++beg) {
|
||||||
|
if (beg.getPar() == pit)
|
||||||
|
cursor_par_seen = true;
|
||||||
|
if (cursor_par_seen) {
|
||||||
|
if (beg.getPar() == pit && beg.getPos() >= cur.pos())
|
||||||
|
break;
|
||||||
|
if (beg.getPar() != pit)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (beg != end) {
|
if (beg != end) {
|
||||||
// Now find the first inset that matches code.
|
// Now find the first inset that matches code.
|
||||||
@ -836,7 +837,7 @@ void BufferView::Pimpl::MenuInsertLyXFile(string const & filenm)
|
|||||||
void BufferView::Pimpl::trackChanges()
|
void BufferView::Pimpl::trackChanges()
|
||||||
{
|
{
|
||||||
Buffer * buf = bv_->buffer();
|
Buffer * buf = bv_->buffer();
|
||||||
bool const tracking(buf->params().tracking_changes);
|
bool const tracking = buf->params().tracking_changes;
|
||||||
|
|
||||||
if (!tracking) {
|
if (!tracking) {
|
||||||
ParIterator const end = buf->par_iterator_end();
|
ParIterator const end = buf->par_iterator_end();
|
||||||
@ -848,7 +849,7 @@ void BufferView::Pimpl::trackChanges()
|
|||||||
buf->undostack().clear();
|
buf->undostack().clear();
|
||||||
} else {
|
} else {
|
||||||
update();
|
update();
|
||||||
bv_->text()->setCursor(0, 0);
|
bv_->text()->setCursor(bv_->cursor(), 0, 0);
|
||||||
#warning changes FIXME
|
#warning changes FIXME
|
||||||
bool found = lyx::find::findNextChange(bv_);
|
bool found = lyx::find::findNextChange(bv_);
|
||||||
if (found) {
|
if (found) {
|
||||||
@ -929,10 +930,18 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
|
|||||||
text->setCursorFromCoordinates(cur.current(), cmd.x, cmd.y);
|
text->setCursorFromCoordinates(cur.current(), cmd.x, cmd.y);
|
||||||
lyxerr << "created temp cursor: " << cur << endl;
|
lyxerr << "created temp cursor: " << cur << endl;
|
||||||
|
|
||||||
|
// Try to dispatch to an non-editable inset near this position
|
||||||
|
DispatchResult res;
|
||||||
|
InsetBase * inset = cur.nextInset();
|
||||||
|
lyxerr << "next inset: " << inset << endl;
|
||||||
|
if (inset)
|
||||||
|
res = inset->dispatch(cur, cmd);
|
||||||
|
|
||||||
// Dispatch to the temp cursor.
|
// Dispatch to the temp cursor.
|
||||||
// An inset (or LyXText) can assign this to bv->cursor()
|
// An inset (or LyXText) can assign this to bv->cursor()
|
||||||
// if it wishes to do so.
|
// if it wishes to do so.
|
||||||
DispatchResult res = cur.dispatch(cmd);
|
if (!res.dispatched())
|
||||||
|
res = cur.dispatch(cmd);
|
||||||
|
|
||||||
if (fitCursor() || res.update())
|
if (fitCursor() || res.update())
|
||||||
update();
|
update();
|
||||||
@ -1049,10 +1058,6 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_PARAGRAPH_APPLY:
|
|
||||||
setParagraphParams(*bv_, cmd.argument);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LFUN_TRACK_CHANGES:
|
case LFUN_TRACK_CHANGES:
|
||||||
trackChanges();
|
trackChanges();
|
||||||
break;
|
break;
|
||||||
@ -1124,41 +1129,3 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool BufferView::Pimpl::ChangeInsets(InsetBase::Code code,
|
|
||||||
string const & from, string const & to)
|
|
||||||
{
|
|
||||||
bool need_update = false;
|
|
||||||
CursorSlice cur = bv_->text()->cursor();
|
|
||||||
|
|
||||||
ParIterator end = bv_->buffer()->par_iterator_end();
|
|
||||||
for (ParIterator it = bv_->buffer()->par_iterator_begin();
|
|
||||||
it != end; ++it) {
|
|
||||||
bool changed_inset = false;
|
|
||||||
for (InsetList::iterator it2 = it->insetlist.begin();
|
|
||||||
it2 != it->insetlist.end(); ++it2) {
|
|
||||||
if (it2->inset->lyxCode() == code) {
|
|
||||||
InsetCommand * inset = static_cast<InsetCommand *>(it2->inset);
|
|
||||||
if (inset->getContents() == from) {
|
|
||||||
inset->setContents(to);
|
|
||||||
changed_inset = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (changed_inset) {
|
|
||||||
need_update = true;
|
|
||||||
|
|
||||||
// FIXME
|
|
||||||
|
|
||||||
// The test it.size() == 1 was needed to prevent crashes.
|
|
||||||
// How to set the cursor correctly when it.size() > 1 ??
|
|
||||||
if (it.size() == 1) {
|
|
||||||
bv_->text()->setCursorIntern(bv_->text()->parOffset(it.pit()), 0);
|
|
||||||
bv_->text()->redoParagraph(bv_->text()->cursorPar());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bv_->text()->setCursorIntern(cur.par(), cur.pos());
|
|
||||||
return need_update;
|
|
||||||
}
|
|
||||||
|
@ -139,13 +139,6 @@ private:
|
|||||||
/// notify readonly status
|
/// notify readonly status
|
||||||
void showReadonly(bool);
|
void showReadonly(bool);
|
||||||
|
|
||||||
/**
|
|
||||||
* Change all insets with the given code's contents to a new
|
|
||||||
* string. May only be used with InsetCommand-derived insets
|
|
||||||
* Returns true if a screen update is needed.
|
|
||||||
*/
|
|
||||||
bool ChangeInsets(InsetBase::Code code, std::string const & from,
|
|
||||||
std::string const & to);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
friend class BufferView;
|
friend class BufferView;
|
||||||
|
@ -296,27 +296,6 @@ void ParagraphParameters::write(ostream & os) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void setParagraphParams(BufferView & bv, string const & data)
|
|
||||||
{
|
|
||||||
istringstream is(data);
|
|
||||||
LyXLex lex(0,0);
|
|
||||||
lex.setStream(is);
|
|
||||||
|
|
||||||
ParagraphParameters params;
|
|
||||||
params.read(lex);
|
|
||||||
|
|
||||||
LyXText * text = bv.getLyXText();
|
|
||||||
text->setParagraph(
|
|
||||||
params.spacing(),
|
|
||||||
params.align(),
|
|
||||||
params.labelWidthString(),
|
|
||||||
params.noindent());
|
|
||||||
|
|
||||||
bv.update();
|
|
||||||
bv.owner()->message(_("Paragraph layout set"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void params2string(Paragraph const & par, string & data)
|
void params2string(Paragraph const & par, string & data)
|
||||||
{
|
{
|
||||||
// A local copy
|
// A local copy
|
||||||
|
@ -29,6 +29,7 @@ class Paragraph;
|
|||||||
class ParameterStruct;
|
class ParameterStruct;
|
||||||
class Spacing;
|
class Spacing;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
class ParagraphParameters {
|
class ParagraphParameters {
|
||||||
public:
|
public:
|
||||||
@ -99,10 +100,4 @@ private:
|
|||||||
*/
|
*/
|
||||||
void params2string(Paragraph const & par, std::string & data);
|
void params2string(Paragraph const & par, std::string & data);
|
||||||
|
|
||||||
/** Given \param data, an encoding of the ParagraphParameters generated
|
|
||||||
in the Paragraph dialog, this function sets the current paragraph
|
|
||||||
appropriately.
|
|
||||||
*/
|
|
||||||
void setParagraphParams(BufferView & bv, std::string const & data);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,24 +16,19 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
class BufferView;
|
|
||||||
class LCursor;
|
class LCursor;
|
||||||
class LyXFont;
|
class LyXFont;
|
||||||
class LyXText;
|
class LyXText;
|
||||||
class PosIterator;
|
|
||||||
|
|
||||||
|
|
||||||
namespace bv_funcs {
|
namespace bv_funcs {
|
||||||
|
|
||||||
/** Set \param data using \param font and \param toggle.
|
/// Set \param data using \param font and \param toggle. Return success.
|
||||||
* If successful, returns true.
|
|
||||||
*/
|
|
||||||
bool font2string(LyXFont const & font, bool toggle, std::string & data);
|
bool font2string(LyXFont const & font, bool toggle, std::string & data);
|
||||||
/** Set \param font and \param toggle using \param data.
|
|
||||||
* If successful, returns true.
|
/// Set \param font and \param toggle using \param data. Return success.
|
||||||
*/
|
|
||||||
bool string2font(std::string const & data, LyXFont & font, bool & toggle);
|
bool string2font(std::string const & data, LyXFont & font, bool & toggle);
|
||||||
|
|
||||||
/** Returns the current freefont, encoded as a std::string to be passed to the
|
/** Returns the current freefont, encoded as a std::string to be passed to the
|
||||||
* frontends.
|
* frontends.
|
||||||
*/
|
*/
|
||||||
@ -49,6 +44,6 @@ enum DEPTH_CHANGE {
|
|||||||
/// Returns whether something would be changed by changeDepth
|
/// Returns whether something would be changed by changeDepth
|
||||||
bool changeDepthAllowed(LCursor & cur, LyXText * text, DEPTH_CHANGE);
|
bool changeDepthAllowed(LCursor & cur, LyXText * text, DEPTH_CHANGE);
|
||||||
|
|
||||||
}; // namespace bv_funcs
|
} // namespace bv_funcs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1932,3 +1932,8 @@ void LCursor::replaceWord(string const & replacestring)
|
|||||||
t->cursorLeft(*this, true);
|
t->cursorLeft(*this, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LCursor::update()
|
||||||
|
{
|
||||||
|
bv().update();
|
||||||
|
}
|
||||||
|
@ -287,6 +287,8 @@ public:
|
|||||||
void reset();
|
void reset();
|
||||||
/// for spellchecking
|
/// for spellchecking
|
||||||
void replaceWord(std::string const & replacestring);
|
void replaceWord(std::string const & replacestring);
|
||||||
|
/// update our view
|
||||||
|
void update();
|
||||||
|
|
||||||
/// output
|
/// output
|
||||||
friend std::ostream & operator<<(std::ostream & os, LCursor const & cur);
|
friend std::ostream & operator<<(std::ostream & os, LCursor const & cur);
|
||||||
|
@ -236,7 +236,7 @@ std::ostream & operator<<(std::ostream & os, CursorSlice const & item)
|
|||||||
os << "inset: " << item.inset_
|
os << "inset: " << item.inset_
|
||||||
<< " text: " << item.text()
|
<< " text: " << item.text()
|
||||||
<< " idx: " << item.idx_
|
<< " idx: " << item.idx_
|
||||||
// << " par: " << item.par_
|
<< " par: " << item.par_
|
||||||
<< " pos: " << item.pos_
|
<< " pos: " << item.pos_
|
||||||
// << " x: " << item.inset_->x()
|
// << " x: " << item.inset_->x()
|
||||||
// << " y: " << item.inset_->y()
|
// << " y: " << item.inset_->y()
|
||||||
|
@ -205,9 +205,7 @@ DispatchResult
|
|||||||
InsetCollapsable::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
|
InsetCollapsable::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
|
||||||
{
|
{
|
||||||
if (cmd.button() == mouse_button::button3) {
|
if (cmd.button() == mouse_button::button3) {
|
||||||
lyxerr << "InsetCollapsable::lfunMouseRelease 0" << endl;
|
|
||||||
showInsetDialog(&cur.bv());
|
showInsetDialog(&cur.bv());
|
||||||
return DispatchResult(true, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (status_) {
|
switch (status_) {
|
||||||
@ -331,16 +329,14 @@ InsetCollapsable::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
case LFUN_MOUSE_PRESS:
|
case LFUN_MOUSE_PRESS:
|
||||||
if (status_ == Inlined)
|
if (status_ == Inlined)
|
||||||
inset.dispatch(cur, cmd);
|
inset.dispatch(cur, cmd);
|
||||||
else if (status_ == Open
|
else if (status_ == Open && cmd.y > button_dim.y2)
|
||||||
&& cmd.y > button_dim.y2)
|
|
||||||
inset.dispatch(cur, cmd);
|
inset.dispatch(cur, cmd);
|
||||||
return DispatchResult(true, true);
|
return DispatchResult(true, true);
|
||||||
|
|
||||||
case LFUN_MOUSE_MOTION:
|
case LFUN_MOUSE_MOTION:
|
||||||
if (status_ == Inlined)
|
if (status_ == Inlined)
|
||||||
inset.dispatch(cur, cmd);
|
inset.dispatch(cur, cmd);
|
||||||
else if (status_ == Open
|
else if (status_ == Open && cmd.y > button_dim.y2)
|
||||||
&& cmd.y > button_dim.y2)
|
|
||||||
inset.dispatch(cur, cmd);
|
inset.dispatch(cur, cmd);
|
||||||
return DispatchResult(true, true);
|
return DispatchResult(true, true);
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public:
|
|||||||
///
|
///
|
||||||
void setLabel(std::string const & l);
|
void setLabel(std::string const & l);
|
||||||
///
|
///
|
||||||
virtual void setButtonLabel() {};
|
virtual void setButtonLabel() {}
|
||||||
///
|
///
|
||||||
void setLabelFont(LyXFont & f);
|
void setLabelFont(LyXFont & f);
|
||||||
/// Appends \c list with all labels found within this inset.
|
/// Appends \c list with all labels found within this inset.
|
||||||
|
@ -12,20 +12,26 @@
|
|||||||
|
|
||||||
#include "insetlabel.h"
|
#include "insetlabel.h"
|
||||||
|
|
||||||
|
#include "buffer.h"
|
||||||
#include "BufferView.h"
|
#include "BufferView.h"
|
||||||
#include "dispatchresult.h"
|
#include "dispatchresult.h"
|
||||||
#include "funcrequest.h"
|
#include "funcrequest.h"
|
||||||
|
#include "InsetList.h"
|
||||||
|
#include "iterators.h"
|
||||||
|
#include "lyxtext.h"
|
||||||
|
#include "paragraph.h"
|
||||||
|
|
||||||
#include "frontends/LyXView.h"
|
#include "frontends/LyXView.h"
|
||||||
|
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
|
#include "support/lyxalgo.h"
|
||||||
#include "support/std_ostream.h"
|
#include "support/std_ostream.h"
|
||||||
|
|
||||||
using lyx::support::escape;
|
using lyx::support::escape;
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
|
|
||||||
InsetLabel::InsetLabel(InsetCommandParams const & p)
|
InsetLabel::InsetLabel(InsetCommandParams const & p)
|
||||||
@ -51,6 +57,40 @@ string const InsetLabel::getScreenLabel(Buffer const &) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
void changeRefsIfUnique(BufferView & bv, string const & from, string const & to)
|
||||||
|
{
|
||||||
|
// Check if the label 'from' appears more than once
|
||||||
|
vector<string> labels;
|
||||||
|
bv.buffer()->getLabelList(labels);
|
||||||
|
|
||||||
|
if (lyx::count(labels.begin(), labels.end(), from) > 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
InsetBase::Code code = InsetBase::REF_CODE;
|
||||||
|
|
||||||
|
ParIterator it = bv.buffer()->par_iterator_begin();
|
||||||
|
ParIterator end = bv.buffer()->par_iterator_end();
|
||||||
|
for ( ; it != end; ++it) {
|
||||||
|
bool changed_inset = false;
|
||||||
|
for (InsetList::iterator it2 = it->insetlist.begin();
|
||||||
|
it2 != it->insetlist.end(); ++it2) {
|
||||||
|
if (it2->inset->lyxCode() == code) {
|
||||||
|
InsetCommand * inset = static_cast<InsetCommand *>(it2->inset);
|
||||||
|
if (inset->getContents() == from) {
|
||||||
|
inset->setContents(to);
|
||||||
|
//inset->setButtonLabel();
|
||||||
|
changed_inset = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace anon
|
||||||
|
|
||||||
|
|
||||||
DispatchResult
|
DispatchResult
|
||||||
InsetLabel::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
InsetLabel::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||||
{
|
{
|
||||||
@ -61,12 +101,10 @@ InsetLabel::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
InsetCommandMailer::string2params("label", cmd.argument, p);
|
InsetCommandMailer::string2params("label", cmd.argument, p);
|
||||||
if (p.getCmdName().empty())
|
if (p.getCmdName().empty())
|
||||||
return DispatchResult(false);
|
return DispatchResult(false);
|
||||||
bool clean = true;
|
|
||||||
if (p.getContents() != params().getContents())
|
if (p.getContents() != params().getContents())
|
||||||
clean = cur.bv().ChangeRefsIfUnique(params().getContents(),
|
changeRefsIfUnique(cur.bv(), params().getContents(),
|
||||||
p.getContents());
|
p.getContents());
|
||||||
setParams(p);
|
setParams(p);
|
||||||
cur.bv().update();
|
|
||||||
return DispatchResult(true, true);
|
return DispatchResult(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,8 +40,7 @@ InsetRef::InsetRef(InsetRef const & ir)
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
DispatchResult
|
DispatchResult InsetRef::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||||
InsetRef::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
|
||||||
{
|
{
|
||||||
switch (cmd.action) {
|
switch (cmd.action) {
|
||||||
case LFUN_MOUSE_PRESS:
|
case LFUN_MOUSE_PRESS:
|
||||||
@ -52,6 +51,9 @@ InsetRef::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
InsetCommandMailer("ref", *this).showDialog(&cur.bv());
|
InsetCommandMailer("ref", *this).showDialog(&cur.bv());
|
||||||
return DispatchResult(true, true);
|
return DispatchResult(true, true);
|
||||||
|
|
||||||
|
case LFUN_MOUSE_RELEASE:
|
||||||
|
return DispatchResult(true, true);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return InsetCommand::priv_dispatch(cur, cmd);
|
return InsetCommand::priv_dispatch(cur, cmd);
|
||||||
}
|
}
|
||||||
@ -61,15 +63,15 @@ InsetRef::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
string const InsetRef::getScreenLabel(Buffer const &) const
|
string const InsetRef::getScreenLabel(Buffer const &) const
|
||||||
{
|
{
|
||||||
string temp;
|
string temp;
|
||||||
for (int i = 0; !types[i].latex_name.empty(); ++ i)
|
for (int i = 0; !types[i].latex_name.empty(); ++i) {
|
||||||
if (getCmdName() == types[i].latex_name) {
|
if (getCmdName() == types[i].latex_name) {
|
||||||
temp = _(types[i].short_gui_name);
|
temp = _(types[i].short_gui_name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
temp += getContents();
|
temp += getContents();
|
||||||
|
|
||||||
if (!isLatex
|
if (!isLatex && !getOptions().empty()) {
|
||||||
&& !getOptions().empty()) {
|
|
||||||
temp += "||";
|
temp += "||";
|
||||||
temp += getOptions();
|
temp += getOptions();
|
||||||
}
|
}
|
||||||
|
@ -12,13 +12,10 @@
|
|||||||
#ifndef INSET_REF_H
|
#ifndef INSET_REF_H
|
||||||
#define INSET_REF_H
|
#define INSET_REF_H
|
||||||
|
|
||||||
|
|
||||||
#include "insetcommand.h"
|
#include "insetcommand.h"
|
||||||
|
|
||||||
struct LaTeXFeatures;
|
|
||||||
|
|
||||||
/** The reference inset
|
/// The reference inset
|
||||||
*/
|
|
||||||
class InsetRef : public InsetCommand {
|
class InsetRef : public InsetCommand {
|
||||||
public:
|
public:
|
||||||
struct type_info {
|
struct type_info {
|
||||||
@ -68,9 +65,7 @@ public:
|
|||||||
void validate(LaTeXFeatures & features) const;
|
void validate(LaTeXFeatures & features) const;
|
||||||
protected:
|
protected:
|
||||||
///
|
///
|
||||||
virtual
|
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||||
DispatchResult
|
|
||||||
priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
bool isLatex;
|
bool isLatex;
|
||||||
|
@ -398,7 +398,7 @@ void InsetTabular::lfunMousePress(LCursor & cur, FuncRequest const & cmd)
|
|||||||
cur.idx() = cell;
|
cur.idx() = cell;
|
||||||
} else {
|
} else {
|
||||||
tablemode = false;
|
tablemode = false;
|
||||||
setPos(cur.bv(), cmd.x, cmd.y);
|
setPos(cur, cmd.x, cmd.y);
|
||||||
//cur.cursor_ = theTempCursor;
|
//cur.cursor_ = theTempCursor;
|
||||||
cur.idx() = cell;
|
cur.idx() = cell;
|
||||||
}
|
}
|
||||||
@ -415,7 +415,7 @@ void InsetTabular::lfunMouseMotion(LCursor & cur, FuncRequest const & cmd)
|
|||||||
int const actcell = getCell(cmd.x + xo_, cmd.y + yo_);
|
int const actcell = getCell(cmd.x + xo_, cmd.y + yo_);
|
||||||
lyxerr << "# InsetTabular::lfunMouseMotion cell: " << actcell << endl;
|
lyxerr << "# InsetTabular::lfunMouseMotion cell: " << actcell << endl;
|
||||||
|
|
||||||
setPos(cur.bv(), cmd.x, cmd.y);
|
setPos(cur, cmd.x, cmd.y);
|
||||||
if (!hasSelection()) {
|
if (!hasSelection()) {
|
||||||
setSelection(actcell, actcell);
|
setSelection(actcell, actcell);
|
||||||
cur.setSelection();
|
cur.setSelection();
|
||||||
@ -467,7 +467,7 @@ void InsetTabular::edit(LCursor & cur, int x, int y)
|
|||||||
<< &tabular.cell_info[0][0].inset << endl;
|
<< &tabular.cell_info[0][0].inset << endl;
|
||||||
|
|
||||||
finishUndo();
|
finishUndo();
|
||||||
setPos(cur.bv(), x, y);
|
setPos(cur, x, y);
|
||||||
clearSelection();
|
clearSelection();
|
||||||
finishUndo();
|
finishUndo();
|
||||||
//int xx = cursorx_ - xo_ + tabular.getBeginningOfTextInCell(actcell);
|
//int xx = cursorx_ - xo_ + tabular.getBeginningOfTextInCell(actcell);
|
||||||
@ -972,14 +972,12 @@ void InsetTabular::getCursorPos(CursorSlice const & cur, int & x, int & y) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetTabular::setPos(BufferView & bv, int x, int y) const
|
void InsetTabular::setPos(LCursor & cur, int x, int y) const
|
||||||
{
|
{
|
||||||
lyxerr << "# InsetTabular::setPos() cursor: " << bv.cursor() << endl;
|
//lyxerr << "# InsetTabular::setPos() cursor: " << cur << endl;
|
||||||
int const cell = getCell(x + xo_, y + yo_);
|
int const cell = getCell(x + xo_, y + yo_);
|
||||||
lyxerr << "# InsetTabular::setPos() cell: " << cell << endl;
|
|
||||||
InsetText const & inset = tabular.getCellInset(cell);
|
InsetText const & inset = tabular.getCellInset(cell);
|
||||||
inset.text_.setCursorFromCoordinates(x, y);
|
inset.text_.setCursorFromCoordinates(cur.current(), x, y);
|
||||||
#if 0
|
|
||||||
cursory_ = 0;
|
cursory_ = 0;
|
||||||
int actcell = 0;
|
int actcell = 0;
|
||||||
int actrow = 0;
|
int actrow = 0;
|
||||||
@ -1005,8 +1003,7 @@ void InsetTabular::setPos(BufferView & bv, int x, int y) const
|
|||||||
+ tabular.getAdditionalWidth(actcell);
|
+ tabular.getAdditionalWidth(actcell);
|
||||||
|
|
||||||
cursorx_ = lx - tabular.getWidthOfColumn(actcell) + xo_ + 2;
|
cursorx_ = lx - tabular.getWidthOfColumn(actcell) + xo_ + 2;
|
||||||
#endif
|
resetPos(cur);
|
||||||
resetPos(bv.cursor());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1024,7 +1021,7 @@ int InsetTabular::getCellXPos(int cell) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetTabular::resetPos(LCursor &) const
|
void InsetTabular::resetPos(LCursor & cur) const
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
#ifdef WITH_WARNINGS
|
#ifdef WITH_WARNINGS
|
||||||
|
@ -179,7 +179,7 @@ private:
|
|||||||
void drawCellSelection(Painter &, int x, int baseline,
|
void drawCellSelection(Painter &, int x, int baseline,
|
||||||
int row, int column, int cell) const;
|
int row, int column, int cell) const;
|
||||||
///
|
///
|
||||||
void setPos(BufferView &, int x, int y) const;
|
void setPos(LCursor & cur, int x, int y) const;
|
||||||
///
|
///
|
||||||
bool moveRight(LCursor & cur);
|
bool moveRight(LCursor & cur);
|
||||||
///
|
///
|
||||||
|
@ -48,6 +48,11 @@ class VSpace;
|
|||||||
/// This class encapsulates the main text data and operations in LyX
|
/// This class encapsulates the main text data and operations in LyX
|
||||||
class LyXText {
|
class LyXText {
|
||||||
public:
|
public:
|
||||||
|
///
|
||||||
|
typedef lyx::pos_type pos_type;
|
||||||
|
///
|
||||||
|
typedef lyx::paroffset_type par_type;
|
||||||
|
|
||||||
/// constructor
|
/// constructor
|
||||||
LyXText(BufferView *, bool ininset);
|
LyXText(BufferView *, bool ininset);
|
||||||
///
|
///
|
||||||
@ -56,17 +61,16 @@ public:
|
|||||||
/// update y coordinate cache of all paragraphs
|
/// update y coordinate cache of all paragraphs
|
||||||
void updateParPositions();
|
void updateParPositions();
|
||||||
///
|
///
|
||||||
LyXFont getFont(ParagraphList::iterator pit, lyx::pos_type pos) const;
|
LyXFont getFont(ParagraphList::iterator pit, pos_type pos) const;
|
||||||
///
|
///
|
||||||
LyXFont getLayoutFont(ParagraphList::iterator pit) const;
|
LyXFont getLayoutFont(ParagraphList::iterator pit) const;
|
||||||
///
|
///
|
||||||
LyXFont getLabelFont(ParagraphList::iterator pit) const;
|
LyXFont getLabelFont(ParagraphList::iterator pit) const;
|
||||||
///
|
///
|
||||||
void setCharFont(ParagraphList::iterator pit,
|
void setCharFont(ParagraphList::iterator pit,
|
||||||
lyx::pos_type pos, LyXFont const & font);
|
pos_type pos, LyXFont const & font);
|
||||||
void setCharFont(ParagraphList::iterator pit,
|
void setCharFont(ParagraphList::iterator pit,
|
||||||
lyx::pos_type pos,
|
pos_type pos, LyXFont const & font, bool toggleall);
|
||||||
LyXFont const & font, bool toggleall);
|
|
||||||
|
|
||||||
/// what you expect when pressing <enter> at cursor position
|
/// what you expect when pressing <enter> at cursor position
|
||||||
void breakParagraph(LCursor & cur, char keep_layout = 0);
|
void breakParagraph(LCursor & cur, char keep_layout = 0);
|
||||||
@ -131,7 +135,7 @@ public:
|
|||||||
/// returns an iterator pointing to a cursor paragraph
|
/// returns an iterator pointing to a cursor paragraph
|
||||||
ParagraphList::iterator getPar(CursorSlice const & cursor) const;
|
ParagraphList::iterator getPar(CursorSlice const & cursor) const;
|
||||||
///
|
///
|
||||||
ParagraphList::iterator getPar(lyx::paroffset_type par) const;
|
ParagraphList::iterator getPar(par_type par) const;
|
||||||
///
|
///
|
||||||
int parOffset(ParagraphList::iterator pit) const;
|
int parOffset(ParagraphList::iterator pit) const;
|
||||||
/// # FIXME: should not be used
|
/// # FIXME: should not be used
|
||||||
@ -149,7 +153,7 @@ public:
|
|||||||
/** returns the column near the specified x-coordinate of the row
|
/** returns the column near the specified x-coordinate of the row
|
||||||
x is set to the real beginning of this column
|
x is set to the real beginning of this column
|
||||||
*/
|
*/
|
||||||
lyx::pos_type getColumnNearX(ParagraphList::iterator pit,
|
pos_type getColumnNearX(ParagraphList::iterator pit,
|
||||||
Row const & row, int & x, bool & boundary) const;
|
Row const & row, int & x, bool & boundary) const;
|
||||||
|
|
||||||
/** Find the word under \c from in the relative location
|
/** Find the word under \c from in the relative location
|
||||||
@ -167,23 +171,21 @@ public:
|
|||||||
void rejectChange(LCursor & cur);
|
void rejectChange(LCursor & cur);
|
||||||
|
|
||||||
/// returns true if par was empty and was removed
|
/// returns true if par was empty and was removed
|
||||||
bool setCursor(lyx::paroffset_type par, lyx::pos_type pos,
|
bool setCursor(LCursor & cur, par_type par, pos_type pos,
|
||||||
bool setfont = true, bool boundary = false);
|
bool setfont = true, bool boundary = false);
|
||||||
///
|
///
|
||||||
void setCursor(CursorSlice &, lyx::paroffset_type par,
|
void setCursor(CursorSlice &, par_type par,
|
||||||
lyx::pos_type pos, bool boundary = false);
|
pos_type pos, bool boundary = false);
|
||||||
///
|
///
|
||||||
void setCursorIntern(lyx::paroffset_type par, lyx::pos_type pos,
|
void setCursorIntern(LCursor & cur, par_type par,
|
||||||
bool setfont = true, bool boundary = false);
|
pos_type pos, bool setfont = true, bool boundary = false);
|
||||||
///
|
///
|
||||||
void setCurrentFont();
|
void setCurrentFont(LCursor & cur);
|
||||||
|
|
||||||
///
|
///
|
||||||
void recUndo(lyx::paroffset_type first, lyx::paroffset_type last) const;
|
void recUndo(par_type first, par_type last) const;
|
||||||
///
|
///
|
||||||
void recUndo(lyx::paroffset_type first) const;
|
void recUndo(par_type first) const;
|
||||||
///
|
|
||||||
void setCursorFromCoordinates(int x, int y);
|
|
||||||
///
|
///
|
||||||
void setCursorFromCoordinates(CursorSlice &, int x, int y);
|
void setCursorFromCoordinates(CursorSlice &, int x, int y);
|
||||||
///
|
///
|
||||||
@ -237,9 +239,9 @@ public:
|
|||||||
/// returns success
|
/// returns success
|
||||||
bool toggleInset(LCursor & cur);
|
bool toggleInset(LCursor & cur);
|
||||||
///
|
///
|
||||||
void cutSelection(bool doclear = true, bool realcut = true);
|
void cutSelection(LCursor & cur, bool doclear = true, bool realcut = true);
|
||||||
///
|
///
|
||||||
void copySelection();
|
void copySelection(LCursor & cur);
|
||||||
///
|
///
|
||||||
void pasteSelection(LCursor & cur, size_t sel_index = 0);
|
void pasteSelection(LCursor & cur, size_t sel_index = 0);
|
||||||
|
|
||||||
@ -248,7 +250,7 @@ public:
|
|||||||
last. When a paragraph is broken, the top settings rest, the bottom
|
last. When a paragraph is broken, the top settings rest, the bottom
|
||||||
settings are given to the new one.
|
settings are given to the new one.
|
||||||
*/
|
*/
|
||||||
void setParagraph(
|
void setParagraph(LCursor & cur,
|
||||||
Spacing const & spacing,
|
Spacing const & spacing,
|
||||||
LyXAlignment align,
|
LyXAlignment align,
|
||||||
std::string const & labelwidthstring,
|
std::string const & labelwidthstring,
|
||||||
@ -260,7 +262,7 @@ public:
|
|||||||
* Sets the selection from the current cursor position to length
|
* Sets the selection from the current cursor position to length
|
||||||
* characters to the right. No safety checks.
|
* characters to the right. No safety checks.
|
||||||
*/
|
*/
|
||||||
void setSelectionRange(LCursor & cur, lyx::pos_type length);
|
void setSelectionRange(LCursor & cur, pos_type length);
|
||||||
/// simply replace using the font of the first selected character
|
/// simply replace using the font of the first selected character
|
||||||
void replaceSelectionWithString(LCursor & cur, std::string const & str);
|
void replaceSelectionWithString(LCursor & cur, std::string const & str);
|
||||||
/// replace selection helper
|
/// replace selection helper
|
||||||
@ -272,13 +274,14 @@ public:
|
|||||||
void insertStringAsParagraphs(LCursor & cur, std::string const & str);
|
void insertStringAsParagraphs(LCursor & cur, std::string const & str);
|
||||||
|
|
||||||
/// Find next inset of some specified type.
|
/// Find next inset of some specified type.
|
||||||
bool gotoNextInset(std::vector<InsetOld_code> const & codes,
|
bool gotoNextInset(LCursor & cur,
|
||||||
std::string const & contents = std::string());
|
std::vector<InsetOld_code> const & codes,
|
||||||
|
std::string const & contents = std::string());
|
||||||
///
|
///
|
||||||
void gotoInset(std::vector<InsetOld_code> const & codes,
|
void gotoInset(LCursor & cur,
|
||||||
bool same_content);
|
std::vector<InsetOld_code> const & codes, bool same_content);
|
||||||
///
|
///
|
||||||
void gotoInset(InsetOld_code code, bool same_content);
|
void gotoInset(LCursor & cur, InsetOld_code code, bool same_content);
|
||||||
|
|
||||||
/// current max text width
|
/// current max text width
|
||||||
int textWidth() const;
|
int textWidth() const;
|
||||||
@ -289,10 +292,10 @@ public:
|
|||||||
InsetBase * checkInsetHit(int x, int y);
|
InsetBase * checkInsetHit(int x, int y);
|
||||||
|
|
||||||
///
|
///
|
||||||
int singleWidth(ParagraphList::iterator pit, lyx::pos_type pos) const;
|
int singleWidth(ParagraphList::iterator pit, pos_type pos) const;
|
||||||
///
|
///
|
||||||
int singleWidth(ParagraphList::iterator pit,
|
int singleWidth(ParagraphList::iterator pit,
|
||||||
lyx::pos_type pos, char c, LyXFont const & Font) const;
|
pos_type pos, char c, LyXFont const & Font) const;
|
||||||
|
|
||||||
/// return the color of the canvas
|
/// return the color of the canvas
|
||||||
LColor_color backgroundColor() const;
|
LColor_color backgroundColor() const;
|
||||||
@ -303,7 +306,7 @@ public:
|
|||||||
* in LaTeX the beginning of the text fits in some cases
|
* in LaTeX the beginning of the text fits in some cases
|
||||||
* (for example sections) exactly the label-width.
|
* (for example sections) exactly the label-width.
|
||||||
*/
|
*/
|
||||||
int leftMargin(ParagraphList::iterator pit, lyx::pos_type pos) const;
|
int leftMargin(ParagraphList::iterator pit, pos_type pos) const;
|
||||||
int leftMargin(ParagraphList::iterator pit) const;
|
int leftMargin(ParagraphList::iterator pit) const;
|
||||||
///
|
///
|
||||||
int rightMargin(Paragraph const & par) const;
|
int rightMargin(Paragraph const & par) const;
|
||||||
@ -452,9 +455,9 @@ private:
|
|||||||
///
|
///
|
||||||
void charInserted();
|
void charInserted();
|
||||||
/// set 'number' font property
|
/// set 'number' font property
|
||||||
void number();
|
void number(LCursor & cur);
|
||||||
/// is the cursor paragraph right-to-left?
|
/// is the cursor paragraph right-to-left?
|
||||||
bool rtl() const;
|
bool rtl(LCursor & cur) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// return the default height of a row in pixels, considering font zoom
|
/// return the default height of a row in pixels, considering font zoom
|
||||||
|
67
src/text.C
67
src/text.C
@ -758,6 +758,7 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, Row & row)
|
|||||||
|
|
||||||
void LyXText::breakParagraph(LCursor & cur, char keep_layout)
|
void LyXText::breakParagraph(LCursor & cur, char keep_layout)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
// allow only if at start or end, or all previous is new text
|
// allow only if at start or end, or all previous is new text
|
||||||
Paragraph & cpar = cur.paragraph();
|
Paragraph & cpar = cur.paragraph();
|
||||||
ParagraphList::iterator cpit = getPar(cur.par());
|
ParagraphList::iterator cpit = getPar(cur.par());
|
||||||
@ -831,18 +832,19 @@ void LyXText::breakParagraph(LCursor & cur, char keep_layout)
|
|||||||
// This check is necessary. Otherwise the new empty paragraph will
|
// This check is necessary. Otherwise the new empty paragraph will
|
||||||
// be deleted automatically. And it is more friendly for the user!
|
// be deleted automatically. And it is more friendly for the user!
|
||||||
if (cur.pos() != 0 || isempty)
|
if (cur.pos() != 0 || isempty)
|
||||||
setCursor(cur.par() + 1, 0);
|
setCursor(cur, cur.par() + 1, 0);
|
||||||
else
|
else
|
||||||
setCursor(cur.par(), 0);
|
setCursor(cur, cur.par(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// convenience function
|
// convenience function
|
||||||
void LyXText::redoParagraph(LCursor & cur)
|
void LyXText::redoParagraph(LCursor & cur)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
cur.clearSelection();
|
cur.clearSelection();
|
||||||
redoParagraph(getPar(cur.par()));
|
redoParagraph(getPar(cur.par()));
|
||||||
setCursorIntern(cur.par(), cur.pos());
|
setCursorIntern(cur, cur.par(), cur.pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -850,6 +852,7 @@ void LyXText::redoParagraph(LCursor & cur)
|
|||||||
// same Paragraph one to the right and make a rebreak
|
// same Paragraph one to the right and make a rebreak
|
||||||
void LyXText::insertChar(LCursor & cur, char c)
|
void LyXText::insertChar(LCursor & cur, char c)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
recordUndo(cur, Undo::INSERT);
|
recordUndo(cur, Undo::INSERT);
|
||||||
|
|
||||||
Paragraph & par = cur.paragraph();
|
Paragraph & par = cur.paragraph();
|
||||||
@ -872,10 +875,10 @@ void LyXText::insertChar(LCursor & cur, char c)
|
|||||||
getFont(pit, cur.pos()).number() == LyXFont::ON &&
|
getFont(pit, cur.pos()).number() == LyXFont::ON &&
|
||||||
getFont(pit, cur.pos() - 1).number() == LyXFont::ON)
|
getFont(pit, cur.pos() - 1).number() == LyXFont::ON)
|
||||||
)
|
)
|
||||||
number(); // Set current_font.number to OFF
|
number(cur); // Set current_font.number to OFF
|
||||||
} else if (IsDigit(c) &&
|
} else if (IsDigit(c) &&
|
||||||
real_current_font.isVisibleRightToLeft()) {
|
real_current_font.isVisibleRightToLeft()) {
|
||||||
number(); // Set current_font.number to ON
|
number(cur); // Set current_font.number to ON
|
||||||
|
|
||||||
if (cur.pos() != 0) {
|
if (cur.pos() != 0) {
|
||||||
char const c = par.getChar(cur.pos() - 1);
|
char const c = par.getChar(cur.pos() - 1);
|
||||||
@ -944,7 +947,7 @@ void LyXText::insertChar(LCursor & cur, char c)
|
|||||||
current_font = rawtmpfont;
|
current_font = rawtmpfont;
|
||||||
real_current_font = realtmpfont;
|
real_current_font = realtmpfont;
|
||||||
redoParagraph(cur);
|
redoParagraph(cur);
|
||||||
setCursor(cur.par(), cur.pos() + 1, false, cur.boundary());
|
setCursor(cur, cur.par(), cur.pos() + 1, false, cur.boundary());
|
||||||
charInserted();
|
charInserted();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1085,6 +1088,7 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit, Row & row) const
|
|||||||
|
|
||||||
void LyXText::cursorRightOneWord(LCursor & cur)
|
void LyXText::cursorRightOneWord(LCursor & cur)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
if (cur.pos() == cur.lastpos() && cur.par() != cur.lastpar()) {
|
if (cur.pos() == cur.lastpos() && cur.par() != cur.lastpar()) {
|
||||||
++cur.par();
|
++cur.par();
|
||||||
cur.pos() = 0;
|
cur.pos() = 0;
|
||||||
@ -1097,12 +1101,13 @@ void LyXText::cursorRightOneWord(LCursor & cur)
|
|||||||
while (cur.pos() != cur.lastpos() && cur.paragraph().isWord(cur.pos()))
|
while (cur.pos() != cur.lastpos() && cur.paragraph().isWord(cur.pos()))
|
||||||
++cur.pos();
|
++cur.pos();
|
||||||
}
|
}
|
||||||
setCursor(cur.par(), cur.pos());
|
setCursor(cur, cur.par(), cur.pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::cursorLeftOneWord(LCursor & cur)
|
void LyXText::cursorLeftOneWord(LCursor & cur)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
if (cur.pos() == 0 && cur.par() != 0) {
|
if (cur.pos() == 0 && cur.par() != 0) {
|
||||||
--cur.par();
|
--cur.par();
|
||||||
cur.pos() = cur.lastpos();
|
cur.pos() = cur.lastpos();
|
||||||
@ -1115,21 +1120,22 @@ void LyXText::cursorLeftOneWord(LCursor & cur)
|
|||||||
while (cur.pos() != 0 && cur.paragraph().isWord(cur.pos() - 1))
|
while (cur.pos() != 0 && cur.paragraph().isWord(cur.pos() - 1))
|
||||||
--cur.pos();
|
--cur.pos();
|
||||||
}
|
}
|
||||||
setCursor(cur.par(), cur.pos());
|
setCursor(cur, cur.par(), cur.pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::selectWord(LCursor & cur, word_location loc)
|
void LyXText::selectWord(LCursor & cur, word_location loc)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
CursorSlice from = cur.current();
|
CursorSlice from = cur.current();
|
||||||
CursorSlice to = cur.current();
|
CursorSlice to = cur.current();
|
||||||
getWord(from, to, loc);
|
getWord(from, to, loc);
|
||||||
if (cur.current() != from)
|
if (cur.current() != from)
|
||||||
setCursor(from.par(), from.pos());
|
setCursor(cur, from.par(), from.pos());
|
||||||
if (to == from)
|
if (to == from)
|
||||||
return;
|
return;
|
||||||
cur.resetAnchor();
|
cur.resetAnchor();
|
||||||
setCursor(to.par(), to.pos());
|
setCursor(cur, to.par(), to.pos());
|
||||||
cur.setSelection();
|
cur.setSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1138,6 +1144,7 @@ void LyXText::selectWord(LCursor & cur, word_location loc)
|
|||||||
// selection is currently set
|
// selection is currently set
|
||||||
bool LyXText::selectWordWhenUnderCursor(LCursor & cur, word_location loc)
|
bool LyXText::selectWordWhenUnderCursor(LCursor & cur, word_location loc)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
if (cur.selection())
|
if (cur.selection())
|
||||||
return false;
|
return false;
|
||||||
selectWord(cur, loc);
|
selectWord(cur, loc);
|
||||||
@ -1147,6 +1154,7 @@ bool LyXText::selectWordWhenUnderCursor(LCursor & cur, word_location loc)
|
|||||||
|
|
||||||
void LyXText::acceptChange(LCursor & cur)
|
void LyXText::acceptChange(LCursor & cur)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
if (!cur.selection() && cur.lastpos() != 0)
|
if (!cur.selection() && cur.lastpos() != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1158,7 +1166,7 @@ void LyXText::acceptChange(LCursor & cur)
|
|||||||
finishUndo();
|
finishUndo();
|
||||||
cur.clearSelection();
|
cur.clearSelection();
|
||||||
redoParagraph(getPar(startc));
|
redoParagraph(getPar(startc));
|
||||||
setCursorIntern(startc.par(), 0);
|
setCursorIntern(cur, startc.par(), 0);
|
||||||
}
|
}
|
||||||
#warning handle multi par selection
|
#warning handle multi par selection
|
||||||
}
|
}
|
||||||
@ -1166,6 +1174,7 @@ void LyXText::acceptChange(LCursor & cur)
|
|||||||
|
|
||||||
void LyXText::rejectChange(LCursor & cur)
|
void LyXText::rejectChange(LCursor & cur)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
if (!cur.selection() && cur.lastpos() != 0)
|
if (!cur.selection() && cur.lastpos() != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1177,7 +1186,7 @@ void LyXText::rejectChange(LCursor & cur)
|
|||||||
finishUndo();
|
finishUndo();
|
||||||
cur.clearSelection();
|
cur.clearSelection();
|
||||||
redoParagraph(getPar(startc));
|
redoParagraph(getPar(startc));
|
||||||
setCursorIntern(startc.par(), 0);
|
setCursorIntern(cur, startc.par(), 0);
|
||||||
}
|
}
|
||||||
#warning handle multi par selection
|
#warning handle multi par selection
|
||||||
}
|
}
|
||||||
@ -1186,6 +1195,7 @@ void LyXText::rejectChange(LCursor & cur)
|
|||||||
// Delete from cursor up to the end of the current or next word.
|
// Delete from cursor up to the end of the current or next word.
|
||||||
void LyXText::deleteWordForward(LCursor & cur)
|
void LyXText::deleteWordForward(LCursor & cur)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
if (cur.lastpos() == 0)
|
if (cur.lastpos() == 0)
|
||||||
cursorRight(cur, true);
|
cursorRight(cur, true);
|
||||||
else {
|
else {
|
||||||
@ -1193,7 +1203,7 @@ void LyXText::deleteWordForward(LCursor & cur)
|
|||||||
cur.selection() = true;
|
cur.selection() = true;
|
||||||
cursorRightOneWord(cur);
|
cursorRightOneWord(cur);
|
||||||
cur.setSelection();
|
cur.setSelection();
|
||||||
cutSelection(true, false);
|
cutSelection(cur, true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1201,6 +1211,7 @@ void LyXText::deleteWordForward(LCursor & cur)
|
|||||||
// Delete from cursor to start of current or prior word.
|
// Delete from cursor to start of current or prior word.
|
||||||
void LyXText::deleteWordBackward(LCursor & cur)
|
void LyXText::deleteWordBackward(LCursor & cur)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
if (cur.lastpos() == 0)
|
if (cur.lastpos() == 0)
|
||||||
cursorLeft(cur, true);
|
cursorLeft(cur, true);
|
||||||
else {
|
else {
|
||||||
@ -1208,7 +1219,7 @@ void LyXText::deleteWordBackward(LCursor & cur)
|
|||||||
cur.selection() = true;
|
cur.selection() = true;
|
||||||
cursorLeftOneWord(cur);
|
cursorLeftOneWord(cur);
|
||||||
cur.setSelection();
|
cur.setSelection();
|
||||||
cutSelection(true, false);
|
cutSelection(cur, true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1216,6 +1227,7 @@ void LyXText::deleteWordBackward(LCursor & cur)
|
|||||||
// Kill to end of line.
|
// Kill to end of line.
|
||||||
void LyXText::deleteLineForward(LCursor & cur)
|
void LyXText::deleteLineForward(LCursor & cur)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
if (cur.lastpos() == 0) {
|
if (cur.lastpos() == 0) {
|
||||||
// Paragraph is empty, so we just go to the right
|
// Paragraph is empty, so we just go to the right
|
||||||
cursorRight(cur, true);
|
cursorRight(cur, true);
|
||||||
@ -1228,13 +1240,14 @@ void LyXText::deleteLineForward(LCursor & cur)
|
|||||||
if (!cur.selection())
|
if (!cur.selection())
|
||||||
deleteWordForward(cur);
|
deleteWordForward(cur);
|
||||||
else
|
else
|
||||||
cutSelection(true, false);
|
cutSelection(cur, true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::changeCase(LCursor & cur, LyXText::TextCase action)
|
void LyXText::changeCase(LCursor & cur, LyXText::TextCase action)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
CursorSlice from;
|
CursorSlice from;
|
||||||
CursorSlice to;
|
CursorSlice to;
|
||||||
|
|
||||||
@ -1244,7 +1257,7 @@ void LyXText::changeCase(LCursor & cur, LyXText::TextCase action)
|
|||||||
} else {
|
} else {
|
||||||
from = cursor();
|
from = cursor();
|
||||||
getWord(from, to, lyx::PARTIAL_WORD);
|
getWord(from, to, lyx::PARTIAL_WORD);
|
||||||
setCursor(to.par(), to.pos() + 1);
|
setCursor(cur, to.par(), to.pos() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
recordUndoSelection(cur);
|
recordUndoSelection(cur);
|
||||||
@ -1284,6 +1297,7 @@ void LyXText::changeCase(LCursor & cur, LyXText::TextCase action)
|
|||||||
|
|
||||||
void LyXText::Delete(LCursor & cur)
|
void LyXText::Delete(LCursor & cur)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
// this is a very simple implementation
|
// this is a very simple implementation
|
||||||
// just move to the right
|
// just move to the right
|
||||||
// if you had success make a backspace
|
// if you had success make a backspace
|
||||||
@ -1297,6 +1311,7 @@ void LyXText::Delete(LCursor & cur)
|
|||||||
|
|
||||||
void LyXText::backspace(LCursor & cur)
|
void LyXText::backspace(LCursor & cur)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
if (cur.pos() == 0) {
|
if (cur.pos() == 0) {
|
||||||
// The cursor is at the beginning of a paragraph, so
|
// The cursor is at the beginning of a paragraph, so
|
||||||
// the the backspace will collapse two paragraphs into
|
// the the backspace will collapse two paragraphs into
|
||||||
@ -1335,7 +1350,7 @@ void LyXText::backspace(LCursor & cur)
|
|||||||
// without the dreaded mechanism. (JMarc)
|
// without the dreaded mechanism. (JMarc)
|
||||||
if (cur.par() != 0) {
|
if (cur.par() != 0) {
|
||||||
// steps into the above paragraph.
|
// steps into the above paragraph.
|
||||||
setCursorIntern(cur.par() - 1,
|
setCursorIntern(cur, cur.par() - 1,
|
||||||
getPar(cur.par() - 1)->size(),
|
getPar(cur.par() - 1)->size(),
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
@ -1360,7 +1375,7 @@ void LyXText::backspace(LCursor & cur)
|
|||||||
|
|
||||||
// the counters may have changed
|
// the counters may have changed
|
||||||
updateCounters();
|
updateCounters();
|
||||||
setCursor(cur.par(), cur.pos(), false);
|
setCursor(cur, cur.par(), cur.pos(), false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// this is the code for a normal backspace, not pasting
|
// this is the code for a normal backspace, not pasting
|
||||||
@ -1370,16 +1385,16 @@ void LyXText::backspace(LCursor & cur)
|
|||||||
// not a good idea since it triggers the auto-delete
|
// not a good idea since it triggers the auto-delete
|
||||||
// mechanism. So we do a cursorLeftIntern()-lite,
|
// mechanism. So we do a cursorLeftIntern()-lite,
|
||||||
// without the dreaded mechanism. (JMarc)
|
// without the dreaded mechanism. (JMarc)
|
||||||
setCursorIntern(cur.par(), cur.pos() - 1,
|
setCursorIntern(cur, cur.par(), cur.pos() - 1,
|
||||||
false, cur.boundary());
|
false, cur.boundary());
|
||||||
cur.paragraph().erase(cur.pos());
|
cur.paragraph().erase(cur.pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cur.pos() == cur.lastpos())
|
if (cur.pos() == cur.lastpos())
|
||||||
setCurrentFont();
|
setCurrentFont(cur);
|
||||||
|
|
||||||
redoParagraph(cur);
|
redoParagraph(cur);
|
||||||
setCursor(cur.par(), cur.pos(), false, cur.boundary());
|
setCursor(cur, cur.par(), cur.pos(), false, cur.boundary());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1593,9 +1608,9 @@ void LyXText::draw(PainterInfo & pi, int x, int y) const
|
|||||||
|
|
||||||
|
|
||||||
// only used for inset right now. should also be used for main text
|
// only used for inset right now. should also be used for main text
|
||||||
void LyXText::drawSelection(PainterInfo &, int x, int y) const
|
void LyXText::drawSelection(PainterInfo &, int, int) const
|
||||||
{
|
{
|
||||||
lyxerr << "LyXText::drawSelection at " << x << " " << y << endl;
|
//lyxerr << "LyXText::drawSelection at " << x << " " << y << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1856,9 +1871,10 @@ CursorSlice const & LyXText::cursor() const
|
|||||||
|
|
||||||
void LyXText::replaceSelection(LCursor & cur)
|
void LyXText::replaceSelection(LCursor & cur)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
if (cur.selection()) {
|
if (cur.selection()) {
|
||||||
cutSelection(true, false);
|
cutSelection(cur, true, false);
|
||||||
bv()->update();
|
cur.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1866,6 +1882,7 @@ void LyXText::replaceSelection(LCursor & cur)
|
|||||||
// Returns the current font and depth as a message.
|
// Returns the current font and depth as a message.
|
||||||
string LyXText::currentState(LCursor & cur)
|
string LyXText::currentState(LCursor & cur)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
Buffer * buffer = bv()->buffer();
|
Buffer * buffer = bv()->buffer();
|
||||||
Paragraph const & par = cur.paragraph();
|
Paragraph const & par = cur.paragraph();
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
|
130
src/text2.C
130
src/text2.C
@ -64,7 +64,6 @@
|
|||||||
#include <boost/tuple/tuple.hpp>
|
#include <boost/tuple/tuple.hpp>
|
||||||
|
|
||||||
using lyx::pos_type;
|
using lyx::pos_type;
|
||||||
using lyx::paroffset_type;
|
|
||||||
using lyx::support::bformat;
|
using lyx::support::bformat;
|
||||||
|
|
||||||
using std::endl;
|
using std::endl;
|
||||||
@ -281,6 +280,7 @@ LyXText::setLayout(ParagraphList::iterator start,
|
|||||||
// set layout over selection and make a total rebreak of those paragraphs
|
// set layout over selection and make a total rebreak of those paragraphs
|
||||||
void LyXText::setLayout(LCursor & cur, string const & layout)
|
void LyXText::setLayout(LCursor & cur, string const & layout)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
// special handling of new environment insets
|
// special handling of new environment insets
|
||||||
BufferParams const & params = bv()->buffer()->params();
|
BufferParams const & params = bv()->buffer()->params();
|
||||||
LyXLayout_ptr const & lyxlayout = params.getLyXTextClass()[layout];
|
LyXLayout_ptr const & lyxlayout = params.getLyXTextClass()[layout];
|
||||||
@ -342,6 +342,7 @@ bool changeDepthAllowed(bv_funcs::DEPTH_CHANGE type,
|
|||||||
|
|
||||||
bool LyXText::changeDepthAllowed(LCursor & cur, bv_funcs::DEPTH_CHANGE type)
|
bool LyXText::changeDepthAllowed(LCursor & cur, bv_funcs::DEPTH_CHANGE type)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
ParagraphList::iterator beg, end;
|
ParagraphList::iterator beg, end;
|
||||||
getSelectionSpan(cur, *this, beg, end);
|
getSelectionSpan(cur, *this, beg, end);
|
||||||
int max_depth = 0;
|
int max_depth = 0;
|
||||||
@ -359,6 +360,7 @@ bool LyXText::changeDepthAllowed(LCursor & cur, bv_funcs::DEPTH_CHANGE type)
|
|||||||
|
|
||||||
void LyXText::changeDepth(LCursor & cur, bv_funcs::DEPTH_CHANGE type)
|
void LyXText::changeDepth(LCursor & cur, bv_funcs::DEPTH_CHANGE type)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
ParagraphList::iterator beg, end;
|
ParagraphList::iterator beg, end;
|
||||||
getSelectionSpan(cur, *this, beg, end);
|
getSelectionSpan(cur, *this, beg, end);
|
||||||
recordUndoSelection(cur);
|
recordUndoSelection(cur);
|
||||||
@ -386,6 +388,7 @@ void LyXText::changeDepth(LCursor & cur, bv_funcs::DEPTH_CHANGE type)
|
|||||||
// set font over selection and make a total rebreak of those paragraphs
|
// set font over selection and make a total rebreak of those paragraphs
|
||||||
void LyXText::setFont(LCursor & cur, LyXFont const & font, bool toggleall)
|
void LyXText::setFont(LCursor & cur, LyXFont const & font, bool toggleall)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
// if there is no selection just set the current_font
|
// if there is no selection just set the current_font
|
||||||
if (!cur.selection()) {
|
if (!cur.selection()) {
|
||||||
// Determine basis font
|
// Determine basis font
|
||||||
@ -439,33 +442,38 @@ void LyXText::setFont(LCursor & cur, LyXFont const & font, bool toggleall)
|
|||||||
|
|
||||||
void LyXText::cursorHome(LCursor & cur)
|
void LyXText::cursorHome(LCursor & cur)
|
||||||
{
|
{
|
||||||
setCursor(cur.par(), cur.textRow().pos());
|
BOOST_ASSERT(this == cur.text());
|
||||||
|
setCursor(cur, cur.par(), cur.textRow().pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::cursorEnd(LCursor & cur)
|
void LyXText::cursorEnd(LCursor & cur)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
// if not on the last row of the par, put the cursor before
|
// if not on the last row of the par, put the cursor before
|
||||||
// the final space
|
// the final space
|
||||||
pos_type const end = cur.textRow().endpos();
|
pos_type const end = cur.textRow().endpos();
|
||||||
setCursor(cur.par(), end == cur.lastpos() ? end : end - 1);
|
setCursor(cur, cur.par(), end == cur.lastpos() ? end : end - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::cursorTop(LCursor &)
|
void LyXText::cursorTop(LCursor & cur)
|
||||||
{
|
{
|
||||||
setCursor(0, 0);
|
BOOST_ASSERT(this == cur.text());
|
||||||
|
setCursor(cur, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::cursorBottom(LCursor & cur)
|
void LyXText::cursorBottom(LCursor & cur)
|
||||||
{
|
{
|
||||||
setCursor(cur.lastpar(), boost::prior(paragraphs().end())->size());
|
BOOST_ASSERT(this == cur.text());
|
||||||
|
setCursor(cur, cur.lastpar(), boost::prior(paragraphs().end())->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::toggleFree(LCursor & cur, LyXFont const & font, bool toggleall)
|
void LyXText::toggleFree(LCursor & cur, LyXFont const & font, bool toggleall)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
// If the mask is completely neutral, tell user
|
// If the mask is completely neutral, tell user
|
||||||
if (font == LyXFont(LyXFont::ALL_IGNORE)) {
|
if (font == LyXFont(LyXFont::ALL_IGNORE)) {
|
||||||
// Could only happen with user style
|
// Could only happen with user style
|
||||||
@ -498,6 +506,7 @@ void LyXText::toggleFree(LCursor & cur, LyXFont const & font, bool toggleall)
|
|||||||
|
|
||||||
string LyXText::getStringToIndex(LCursor & cur)
|
string LyXText::getStringToIndex(LCursor & cur)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
// Try implicit word selection
|
// Try implicit word selection
|
||||||
// If there is a change in the language the implicit word selection
|
// If there is a change in the language the implicit word selection
|
||||||
// is disabled.
|
// is disabled.
|
||||||
@ -531,10 +540,11 @@ string LyXText::getStringToIndex(LCursor & cur)
|
|||||||
// they do not duplicate themself and you cannot play dirty tricks with
|
// they do not duplicate themself and you cannot play dirty tricks with
|
||||||
// them!
|
// them!
|
||||||
|
|
||||||
void LyXText::setParagraph(Spacing const & spacing, LyXAlignment align,
|
void LyXText::setParagraph(LCursor & cur,
|
||||||
|
Spacing const & spacing, LyXAlignment align,
|
||||||
string const & labelwidthstring, bool noindent)
|
string const & labelwidthstring, bool noindent)
|
||||||
{
|
{
|
||||||
LCursor & cur = bv()->cursor();
|
BOOST_ASSERT(cur.text());
|
||||||
// make sure that the depth behind the selection are restored, too
|
// make sure that the depth behind the selection are restored, too
|
||||||
ParagraphList::iterator undopit = undoSpan(getPar(cur.selEnd()));
|
ParagraphList::iterator undopit = undoSpan(getPar(cur.selEnd()));
|
||||||
recUndo(cur.selBegin().par(), parOffset(undopit) - 1);
|
recUndo(cur.selBegin().par(), parOffset(undopit) - 1);
|
||||||
@ -856,6 +866,7 @@ void LyXText::updateCounters()
|
|||||||
|
|
||||||
void LyXText::insertInset(LCursor & cur, InsetBase * inset)
|
void LyXText::insertInset(LCursor & cur, InsetBase * inset)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
recordUndo(cur);
|
recordUndo(cur);
|
||||||
freezeUndo();
|
freezeUndo();
|
||||||
cur.paragraph().insertInset(cur.pos(), inset);
|
cur.paragraph().insertInset(cur.pos(), inset);
|
||||||
@ -872,9 +883,9 @@ void LyXText::insertInset(LCursor & cur, InsetBase * inset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::cutSelection(bool doclear, bool realcut)
|
void LyXText::cutSelection(LCursor & cur, bool doclear, bool realcut)
|
||||||
{
|
{
|
||||||
LCursor & cur = bv()->cursor();
|
BOOST_ASSERT(this == cur.text());
|
||||||
// Stuff what we got on the clipboard. Even if there is no selection.
|
// Stuff what we got on the clipboard. Even if there is no selection.
|
||||||
|
|
||||||
// There is a problem with having the stuffing here in that the
|
// There is a problem with having the stuffing here in that the
|
||||||
@ -930,9 +941,9 @@ void LyXText::cutSelection(bool doclear, bool realcut)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::copySelection()
|
void LyXText::copySelection(LCursor & cur)
|
||||||
{
|
{
|
||||||
LCursor & cur = bv()->cursor();
|
BOOST_ASSERT(this == cur.text());
|
||||||
// stuff the selection onto the X clipboard, from an explicit copy request
|
// stuff the selection onto the X clipboard, from an explicit copy request
|
||||||
bv()->stuffClipboard(cur.selectionAsString(true));
|
bv()->stuffClipboard(cur.selectionAsString(true));
|
||||||
|
|
||||||
@ -974,17 +985,17 @@ void LyXText::pasteSelection(LCursor & cur, size_t sel_index)
|
|||||||
boost::tie(ppp, endpit) =
|
boost::tie(ppp, endpit) =
|
||||||
CutAndPaste::pasteSelection(*bv()->buffer(),
|
CutAndPaste::pasteSelection(*bv()->buffer(),
|
||||||
paragraphs(),
|
paragraphs(),
|
||||||
cursorPar(), cursor().pos(),
|
getPar(cur.par()), cur.pos(),
|
||||||
bv()->buffer()->params().textclass,
|
bv()->buffer()->params().textclass,
|
||||||
sel_index, el);
|
sel_index, el);
|
||||||
bufferErrors(*bv()->buffer(), el);
|
bufferErrors(*bv()->buffer(), el);
|
||||||
bv()->showErrorList(_("Paste"));
|
bv()->showErrorList(_("Paste"));
|
||||||
|
|
||||||
redoParagraphs(cursorPar(), endpit);
|
redoParagraphs(getPar(cur.par()), endpit);
|
||||||
|
|
||||||
cur.clearSelection();
|
cur.clearSelection();
|
||||||
cur.resetAnchor();
|
cur.resetAnchor();
|
||||||
setCursor(parOffset(ppp.first), ppp.second);
|
setCursor(cur, parOffset(ppp.first), ppp.second);
|
||||||
cur.setSelection();
|
cur.setSelection();
|
||||||
updateCounters();
|
updateCounters();
|
||||||
}
|
}
|
||||||
@ -1022,8 +1033,7 @@ void LyXText::replaceSelectionWithString(LCursor & cur, string const & str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cut the selection
|
// Cut the selection
|
||||||
cutSelection(true, false);
|
cutSelection(cur, true, false);
|
||||||
|
|
||||||
unFreezeUndo();
|
unFreezeUndo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1042,7 +1052,7 @@ void LyXText::insertStringAsLines(LCursor & cur, string const & str)
|
|||||||
|
|
||||||
redoParagraphs(getPar(cur.par()), endpit);
|
redoParagraphs(getPar(cur.par()), endpit);
|
||||||
cur.resetAnchor();
|
cur.resetAnchor();
|
||||||
setCursor(cur.par(), pos);
|
setCursor(cur, cur.par(), pos);
|
||||||
cur.setSelection();
|
cur.setSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1074,16 +1084,16 @@ void LyXText::insertStringAsParagraphs(LCursor & cur, string const & str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LyXText::setCursor(paroffset_type par, pos_type pos, bool setfont,
|
bool LyXText::setCursor(LCursor & cur, par_type par, pos_type pos,
|
||||||
bool boundary)
|
bool setfont, bool boundary)
|
||||||
{
|
{
|
||||||
CursorSlice old_cursor = cursor();
|
CursorSlice old_cursor = cur.current();
|
||||||
setCursorIntern(par, pos, setfont, boundary);
|
setCursorIntern(cur, par, pos, setfont, boundary);
|
||||||
return deleteEmptyParagraphMechanism(old_cursor);
|
return deleteEmptyParagraphMechanism(old_cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::setCursor(CursorSlice & cur, paroffset_type par,
|
void LyXText::setCursor(CursorSlice & cur, par_type par,
|
||||||
pos_type pos, bool boundary)
|
pos_type pos, bool boundary)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(par != int(paragraphs().size()));
|
BOOST_ASSERT(par != int(paragraphs().size()));
|
||||||
@ -1111,7 +1121,7 @@ void LyXText::setCursor(CursorSlice & cur, paroffset_type par,
|
|||||||
lyxerr << "dont like 1, pos: " << pos
|
lyxerr << "dont like 1, pos: " << pos
|
||||||
<< " size: " << para.size()
|
<< " size: " << para.size()
|
||||||
<< " row.pos():" << row.pos()
|
<< " row.pos():" << row.pos()
|
||||||
<< " paroffset: " << par << endl;
|
<< " par: " << par << endl;
|
||||||
pos = 0;
|
pos = 0;
|
||||||
cur.pos(0);
|
cur.pos(0);
|
||||||
BOOST_ASSERT(false);
|
BOOST_ASSERT(false);
|
||||||
@ -1125,7 +1135,7 @@ void LyXText::setCursor(CursorSlice & cur, paroffset_type par,
|
|||||||
lyxerr << "dont like 3 please report pos:" << pos
|
lyxerr << "dont like 3 please report pos:" << pos
|
||||||
<< " size: " << para.size()
|
<< " size: " << para.size()
|
||||||
<< " row.pos():" << row.pos()
|
<< " row.pos():" << row.pos()
|
||||||
<< " paroffset: " << par << endl;
|
<< " par: " << par << endl;
|
||||||
pos = row.pos();
|
pos = row.pos();
|
||||||
cur.pos(pos);
|
cur.pos(pos);
|
||||||
BOOST_ASSERT(false);
|
BOOST_ASSERT(false);
|
||||||
@ -1133,35 +1143,35 @@ void LyXText::setCursor(CursorSlice & cur, paroffset_type par,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::setCursorIntern(paroffset_type par,
|
void LyXText::setCursorIntern(LCursor & cur,
|
||||||
pos_type pos, bool setfont, bool boundary)
|
par_type par, pos_type pos, bool setfont, bool boundary)
|
||||||
{
|
{
|
||||||
setCursor(cursor(), par, pos, boundary);
|
setCursor(cur.current(), par, pos, boundary);
|
||||||
bv()->cursor().x_target() = cursorX(cursor());
|
cur.x_target() = cursorX(cur.current());
|
||||||
if (setfont)
|
if (setfont)
|
||||||
setCurrentFont();
|
setCurrentFont(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::setCurrentFont()
|
void LyXText::setCurrentFont(LCursor & cur)
|
||||||
{
|
{
|
||||||
LCursor & cur = bv()->cursor();
|
BOOST_ASSERT(this == cur.text());
|
||||||
pos_type pos = cur.pos();
|
pos_type pos = cur.pos();
|
||||||
ParagraphList::iterator pit = cursorPar();
|
ParagraphList::iterator pit = getPar(cur.par());
|
||||||
|
|
||||||
if (cursor().boundary() && pos > 0)
|
if (cur.boundary() && pos > 0)
|
||||||
--pos;
|
--pos;
|
||||||
|
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
if (pos == pit->size())
|
if (pos == cur.lastpos())
|
||||||
--pos;
|
--pos;
|
||||||
else // potentional bug... BUG (Lgb)
|
else // potentional bug... BUG (Lgb)
|
||||||
if (pit->isSeparator(pos)) {
|
if (pit->isSeparator(pos)) {
|
||||||
if (pos > pit->getRow(pos)->pos() &&
|
if (pos > cur.textRow().pos() &&
|
||||||
bidi.level(pos) % 2 ==
|
bidi.level(pos) % 2 ==
|
||||||
bidi.level(pos - 1) % 2)
|
bidi.level(pos - 1) % 2)
|
||||||
--pos;
|
--pos;
|
||||||
else if (pos + 1 < pit->size())
|
else if (pos + 1 < cur.lastpos())
|
||||||
++pos;
|
++pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1170,11 +1180,10 @@ void LyXText::setCurrentFont()
|
|||||||
current_font = pit->getFontSettings(bufparams, pos);
|
current_font = pit->getFontSettings(bufparams, pos);
|
||||||
real_current_font = getFont(pit, pos);
|
real_current_font = getFont(pit, pos);
|
||||||
|
|
||||||
if (cursor().pos() == pit->size() &&
|
if (cur.pos() == cur.lastpos()
|
||||||
bidi.isBoundary(*bv()->buffer(), *pit, cursor().pos()) &&
|
&& bidi.isBoundary(*bv()->buffer(), *pit, cur.pos())
|
||||||
!cursor().boundary()) {
|
&& !cur.boundary()) {
|
||||||
Language const * lang =
|
Language const * lang = pit->getParLanguage(bufparams);
|
||||||
pit->getParLanguage(bufparams);
|
|
||||||
current_font.setLanguage(lang);
|
current_font.setLanguage(lang);
|
||||||
current_font.setNumber(LyXFont::OFF);
|
current_font.setNumber(LyXFont::OFF);
|
||||||
real_current_font.setLanguage(lang);
|
real_current_font.setLanguage(lang);
|
||||||
@ -1288,18 +1297,10 @@ pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::setCursorFromCoordinates(int x, int y)
|
|
||||||
{
|
|
||||||
CursorSlice old_cursor = cursor();
|
|
||||||
setCursorFromCoordinates(cursor(), x, y);
|
|
||||||
setCurrentFont();
|
|
||||||
deleteEmptyParagraphMechanism(old_cursor);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// x,y are coordinates relative to this LyXText
|
// x,y are coordinates relative to this LyXText
|
||||||
void LyXText::setCursorFromCoordinates(CursorSlice & cur, int x, int y)
|
void LyXText::setCursorFromCoordinates(CursorSlice & cur, int x, int y)
|
||||||
{
|
{
|
||||||
|
CursorSlice old_cursor = cur;
|
||||||
ParagraphList::iterator pit;
|
ParagraphList::iterator pit;
|
||||||
Row const & row = *getRowNearY(y, pit);
|
Row const & row = *getRowNearY(y, pit);
|
||||||
bool bound = false;
|
bool bound = false;
|
||||||
@ -1308,6 +1309,7 @@ void LyXText::setCursorFromCoordinates(CursorSlice & cur, int x, int y)
|
|||||||
cur.par() = parOffset(pit);
|
cur.par() = parOffset(pit);
|
||||||
cur.pos() = pos;
|
cur.pos() = pos;
|
||||||
cur.boundary() = bound;
|
cur.boundary() = bound;
|
||||||
|
deleteEmptyParagraphMechanism(old_cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1422,16 +1424,16 @@ bool LyXText::cursorLeft(LCursor & cur, bool internal)
|
|||||||
{
|
{
|
||||||
if (cur.pos() != 0) {
|
if (cur.pos() != 0) {
|
||||||
bool boundary = cur.boundary();
|
bool boundary = cur.boundary();
|
||||||
setCursor(cur.par(), cur.pos() - 1, true, false);
|
setCursor(cur, cur.par(), cur.pos() - 1, true, false);
|
||||||
if (!internal && !boundary &&
|
if (!internal && !boundary &&
|
||||||
bidi.isBoundary(*bv()->buffer(), cur.paragraph(), cur.pos() + 1))
|
bidi.isBoundary(*bv()->buffer(), cur.paragraph(), cur.pos() + 1))
|
||||||
setCursor(cur.par(), cur.pos() + 1, true, true);
|
setCursor(cur, cur.par(), cur.pos() + 1, true, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cur.par() != 0) {
|
if (cur.par() != 0) {
|
||||||
// steps into the paragraph above
|
// steps into the paragraph above
|
||||||
setCursor(cur.par() - 1, boost::prior(cursorPar())->size());
|
setCursor(cur, cur.par() - 1, boost::prior(cursorPar())->size());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1442,20 +1444,20 @@ bool LyXText::cursorLeft(LCursor & cur, bool internal)
|
|||||||
bool LyXText::cursorRight(LCursor & cur, bool internal)
|
bool LyXText::cursorRight(LCursor & cur, bool internal)
|
||||||
{
|
{
|
||||||
if (!internal && cur.boundary()) {
|
if (!internal && cur.boundary()) {
|
||||||
setCursor(cur.par(), cur.pos(), true, false);
|
setCursor(cur, cur.par(), cur.pos(), true, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cur.pos() != cur.lastpos()) {
|
if (cur.pos() != cur.lastpos()) {
|
||||||
setCursor(cur.par(), cur.pos() + 1, true, false);
|
setCursor(cur, cur.par(), cur.pos() + 1, true, false);
|
||||||
if (!internal && bidi.isBoundary(*bv()->buffer(), cur.paragraph(),
|
if (!internal && bidi.isBoundary(*bv()->buffer(), cur.paragraph(),
|
||||||
cur.pos()))
|
cur.pos()))
|
||||||
setCursor(cur.par(), cur.pos(), true, true);
|
setCursor(cur, cur.par(), cur.pos(), true, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cur.par() != cur.lastpar()) {
|
if (cur.par() != cur.lastpar()) {
|
||||||
setCursor(cur.par() + 1, 0);
|
setCursor(cur, cur.par() + 1, 0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1496,18 +1498,18 @@ void LyXText::cursorDown(LCursor & cur, bool selecting)
|
|||||||
void LyXText::cursorUpParagraph(LCursor & cur)
|
void LyXText::cursorUpParagraph(LCursor & cur)
|
||||||
{
|
{
|
||||||
if (cur.pos() > 0)
|
if (cur.pos() > 0)
|
||||||
setCursor(cur.par(), 0);
|
setCursor(cur, cur.par(), 0);
|
||||||
else if (cur.par() != 0)
|
else if (cur.par() != 0)
|
||||||
setCursor(cur.par() - 1, 0);
|
setCursor(cur, cur.par() - 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::cursorDownParagraph(LCursor & cur)
|
void LyXText::cursorDownParagraph(LCursor & cur)
|
||||||
{
|
{
|
||||||
if (cur.par() != cur.lastpar())
|
if (cur.par() != cur.lastpar())
|
||||||
setCursor(cur.par() + 1, 0);
|
setCursor(cur, cur.par() + 1, 0);
|
||||||
else
|
else
|
||||||
setCursor(cur.par(), cur.lastpos());
|
setCursor(cur, cur.par(), cur.lastpos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1670,13 +1672,13 @@ ParagraphList & LyXText::paragraphs() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::recUndo(paroffset_type first, paroffset_type last) const
|
void LyXText::recUndo(par_type first, par_type last) const
|
||||||
{
|
{
|
||||||
recordUndo(bv()->cursor(), Undo::ATOMIC, first, last);
|
recordUndo(bv()->cursor(), Undo::ATOMIC, first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::recUndo(lyx::paroffset_type par) const
|
void LyXText::recUndo(par_type par) const
|
||||||
{
|
{
|
||||||
recordUndo(bv()->cursor(), Undo::ATOMIC, par, par);
|
recordUndo(bv()->cursor(), Undo::ATOMIC, par, par);
|
||||||
}
|
}
|
||||||
|
196
src/text3.C
196
src/text3.C
@ -30,6 +30,7 @@
|
|||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include "lyxfunc.h"
|
#include "lyxfunc.h"
|
||||||
|
#include "lyxlex.h"
|
||||||
#include "lyxrc.h"
|
#include "lyxrc.h"
|
||||||
#include "lyxrow.h"
|
#include "lyxrow.h"
|
||||||
#include "paragraph.h"
|
#include "paragraph.h"
|
||||||
@ -101,10 +102,10 @@ namespace {
|
|||||||
text->bidi.isBoundary(*cur.bv().buffer(), par,
|
text->bidi.isBoundary(*cur.bv().buffer(), par,
|
||||||
cur.pos(),
|
cur.pos(),
|
||||||
text->real_current_font))
|
text->real_current_font))
|
||||||
text->setCursor(cur.par(), cur.pos(),
|
text->setCursor(cur, cur.par(), cur.pos(),
|
||||||
false, !cur.boundary());
|
false, !cur.boundary());
|
||||||
}
|
}
|
||||||
cur.bv().update();
|
cur.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -126,7 +127,8 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void mathDispatch(LCursor & cur, FuncRequest const & cmd, bool display)
|
void mathDispatch(LCursor & cur, LyXText * text,
|
||||||
|
FuncRequest const & cmd, bool display)
|
||||||
{
|
{
|
||||||
string sel = cur.selectionAsString(false);
|
string sel = cur.selectionAsString(false);
|
||||||
lyxerr << "selection is: '" << sel << "'" << endl;
|
lyxerr << "selection is: '" << sel << "'" << endl;
|
||||||
@ -144,7 +146,7 @@ namespace {
|
|||||||
} else {
|
} else {
|
||||||
// create a macro if we see "\\newcommand" somewhere, and an ordinary
|
// create a macro if we see "\\newcommand" somewhere, and an ordinary
|
||||||
// formula otherwise
|
// formula otherwise
|
||||||
cur.bv().getLyXText()->cutSelection(true, true);
|
text->cutSelection(cur, true, true);
|
||||||
if (sel.find("\\newcommand") == string::npos &&
|
if (sel.find("\\newcommand") == string::npos &&
|
||||||
sel.find("\\def") == string::npos)
|
sel.find("\\def") == string::npos)
|
||||||
{
|
{
|
||||||
@ -212,12 +214,13 @@ InsetBase * LyXText::checkInsetHit(int x, int y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LyXText::gotoNextInset(vector<InsetOld_code> const & codes,
|
bool LyXText::gotoNextInset(LCursor & cur,
|
||||||
string const & contents)
|
vector<InsetOld_code> const & codes, string const & contents)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(this == cur.text());
|
||||||
ParagraphList::iterator end = paragraphs().end();
|
ParagraphList::iterator end = paragraphs().end();
|
||||||
ParagraphList::iterator pit = cursorPar();
|
ParagraphList::iterator pit = getPar(cur.par());
|
||||||
pos_type pos = cursor().pos();
|
pos_type pos = cur.pos();
|
||||||
|
|
||||||
InsetBase * inset;
|
InsetBase * inset;
|
||||||
do {
|
do {
|
||||||
@ -239,14 +242,14 @@ bool LyXText::gotoNextInset(vector<InsetOld_code> const & codes,
|
|||||||
if (pit == end)
|
if (pit == end)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
setCursor(parOffset(pit), pos, false);
|
setCursor(cur, parOffset(pit), pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::gotoInset(vector<InsetOld_code> const & codes, bool same_content)
|
void LyXText::gotoInset(LCursor & cur,
|
||||||
|
vector<InsetOld_code> const & codes, bool same_content)
|
||||||
{
|
{
|
||||||
LCursor & cur = bv()->cursor();
|
|
||||||
cur.clearSelection();
|
cur.clearSelection();
|
||||||
|
|
||||||
string contents;
|
string contents;
|
||||||
@ -259,12 +262,12 @@ void LyXText::gotoInset(vector<InsetOld_code> const & codes, bool same_content)
|
|||||||
contents = static_cast<InsetCommand const *>(inset)->getContents();
|
contents = static_cast<InsetCommand const *>(inset)->getContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gotoNextInset(codes, contents)) {
|
if (!gotoNextInset(cur, codes, contents)) {
|
||||||
if (cur.pos() || cur.par() != 0) {
|
if (cur.pos() || cur.par() != 0) {
|
||||||
CursorSlice tmp = cursor();
|
CursorSlice tmp = cur.current();
|
||||||
cur.par() = 0;
|
cur.par() = 0;
|
||||||
cur.pos() = 0;
|
cur.pos() = 0;
|
||||||
if (!gotoNextInset(codes, contents)) {
|
if (!gotoNextInset(cur, codes, contents)) {
|
||||||
cursor() = tmp;
|
cursor() = tmp;
|
||||||
cur.message(_("No more insets"));
|
cur.message(_("No more insets"));
|
||||||
}
|
}
|
||||||
@ -272,14 +275,14 @@ void LyXText::gotoInset(vector<InsetOld_code> const & codes, bool same_content)
|
|||||||
cur.message(_("No more insets"));
|
cur.message(_("No more insets"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cur.bv().update();
|
cur.update();
|
||||||
cur.resetAnchor();
|
cur.resetAnchor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::gotoInset(InsetOld_code code, bool same_content)
|
void LyXText::gotoInset(LCursor & cur, InsetOld_code code, bool same_content)
|
||||||
{
|
{
|
||||||
gotoInset(vector<InsetOld_code>(1, code), same_content);
|
gotoInset(cur, vector<InsetOld_code>(1, code), same_content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -290,7 +293,7 @@ void LyXText::cursorPrevious(LCursor & cur)
|
|||||||
|
|
||||||
int x = cur.x_target();
|
int x = cur.x_target();
|
||||||
int y = bv()->top_y();
|
int y = bv()->top_y();
|
||||||
setCursorFromCoordinates(x, y);
|
setCursorFromCoordinates(cur.current(), x, y);
|
||||||
|
|
||||||
if (cpar == cur.par() && cpos == cur.pos()) {
|
if (cpar == cur.par() && cpos == cur.pos()) {
|
||||||
// we have a row which is taller than the workarea. The
|
// we have a row which is taller than the workarea. The
|
||||||
@ -310,7 +313,7 @@ void LyXText::cursorNext(LCursor & cur)
|
|||||||
|
|
||||||
int x = cur.x_target();
|
int x = cur.x_target();
|
||||||
int y = bv()->top_y() + bv()->workHeight();
|
int y = bv()->top_y() + bv()->workHeight();
|
||||||
setCursorFromCoordinates(x, y);
|
setCursorFromCoordinates(cur.current(), x, y);
|
||||||
|
|
||||||
if (cpar == cur.par() && cpos == cur.pos()) {
|
if (cpar == cur.par() && cpos == cur.pos()) {
|
||||||
// we have a row which is taller than the workarea. The
|
// we have a row which is taller than the workarea. The
|
||||||
@ -325,49 +328,47 @@ void LyXText::cursorNext(LCursor & cur)
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void specialChar(LCursor & cur, LyXText * text, BufferView * bv,
|
void specialChar(LCursor & cur, LyXText * text, InsetSpecialChar::Kind kind)
|
||||||
InsetSpecialChar::Kind kind)
|
|
||||||
{
|
{
|
||||||
bv->update();
|
|
||||||
text->replaceSelection(cur);
|
text->replaceSelection(cur);
|
||||||
cur.insert(new InsetSpecialChar(kind));
|
cur.insert(new InsetSpecialChar(kind));
|
||||||
bv->update();
|
cur.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void doInsertInset(LCursor & cur, LyXText * text, BufferView * bv,
|
void doInsertInset(LCursor & cur, LyXText * text,
|
||||||
FuncRequest const & cmd, bool edit, bool pastesel)
|
FuncRequest const & cmd, bool edit, bool pastesel)
|
||||||
{
|
{
|
||||||
InsetBase * inset = createInset(bv, cmd);
|
InsetBase * inset = createInset(&cur.bv(), cmd);
|
||||||
if (!inset)
|
if (!inset)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool gotsel = false;
|
bool gotsel = false;
|
||||||
if (cur.selection()) {
|
if (cur.selection()) {
|
||||||
bv->owner()->dispatch(FuncRequest(LFUN_CUT));
|
cur.bv().owner()->dispatch(FuncRequest(LFUN_CUT));
|
||||||
gotsel = true;
|
gotsel = true;
|
||||||
}
|
}
|
||||||
text->insertInset(cur, inset);
|
text->insertInset(cur, inset);
|
||||||
if (edit)
|
if (edit)
|
||||||
inset->edit(cur, true);
|
inset->edit(cur, true);
|
||||||
if (gotsel && pastesel)
|
if (gotsel && pastesel)
|
||||||
bv->owner()->dispatch(FuncRequest(LFUN_PASTE));
|
cur.bv().owner()->dispatch(FuncRequest(LFUN_PASTE));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anon namespace
|
} // anon namespace
|
||||||
|
|
||||||
|
|
||||||
void LyXText::number()
|
void LyXText::number(LCursor & cur)
|
||||||
{
|
{
|
||||||
LyXFont font(LyXFont::ALL_IGNORE);
|
LyXFont font(LyXFont::ALL_IGNORE);
|
||||||
font.setNumber(LyXFont::TOGGLE);
|
font.setNumber(LyXFont::TOGGLE);
|
||||||
toggleAndShow(bv()->cursor(), this, font);
|
toggleAndShow(cur, this, font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LyXText::rtl() const
|
bool LyXText::rtl(LCursor & cur) const
|
||||||
{
|
{
|
||||||
return cursorPar()->isRightToLeftPar(bv()->buffer()->params());
|
return getPar(cur.par())->isRightToLeftPar(bv()->buffer()->params());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -403,7 +404,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
// we can set the refreshing parameters now
|
// we can set the refreshing parameters now
|
||||||
updateCounters();
|
updateCounters();
|
||||||
redoParagraph(cur);
|
redoParagraph(cur);
|
||||||
bv->update();
|
cur.update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,7 +429,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
case LFUN_WORDRIGHT:
|
case LFUN_WORDRIGHT:
|
||||||
if (!cur.mark())
|
if (!cur.mark())
|
||||||
cur.clearSelection();
|
cur.clearSelection();
|
||||||
if (rtl())
|
if (rtl(cur))
|
||||||
cursorLeftOneWord(cur);
|
cursorLeftOneWord(cur);
|
||||||
else
|
else
|
||||||
cursorRightOneWord(cur);
|
cursorRightOneWord(cur);
|
||||||
@ -438,7 +439,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
case LFUN_WORDLEFT:
|
case LFUN_WORDLEFT:
|
||||||
if (!cur.mark())
|
if (!cur.mark())
|
||||||
cur.clearSelection();
|
cur.clearSelection();
|
||||||
if (rtl())
|
if (rtl(cur))
|
||||||
cursorRightOneWord(cur);
|
cursorRightOneWord(cur);
|
||||||
else
|
else
|
||||||
cursorLeftOneWord(cur);
|
cursorLeftOneWord(cur);
|
||||||
@ -462,7 +463,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
case LFUN_RIGHTSEL:
|
case LFUN_RIGHTSEL:
|
||||||
if (!cur.selection())
|
if (!cur.selection())
|
||||||
cur.resetAnchor();
|
cur.resetAnchor();
|
||||||
if (rtl())
|
if (rtl(cur))
|
||||||
cursorLeft(cur, true);
|
cursorLeft(cur, true);
|
||||||
else
|
else
|
||||||
cursorRight(cur, true);
|
cursorRight(cur, true);
|
||||||
@ -472,7 +473,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
case LFUN_LEFTSEL:
|
case LFUN_LEFTSEL:
|
||||||
if (!cur.selection())
|
if (!cur.selection())
|
||||||
cur.resetAnchor();
|
cur.resetAnchor();
|
||||||
if (rtl())
|
if (rtl(cur))
|
||||||
cursorRight(cur, true);
|
cursorRight(cur, true);
|
||||||
else
|
else
|
||||||
cursorLeft(cur, true);
|
cursorLeft(cur, true);
|
||||||
@ -538,7 +539,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
case LFUN_WORDRIGHTSEL:
|
case LFUN_WORDRIGHTSEL:
|
||||||
if (!cur.selection())
|
if (!cur.selection())
|
||||||
cur.resetAnchor();
|
cur.resetAnchor();
|
||||||
if (rtl())
|
if (rtl(cur))
|
||||||
cursorLeftOneWord(cur);
|
cursorLeftOneWord(cur);
|
||||||
else
|
else
|
||||||
cursorRightOneWord(cur);
|
cursorRightOneWord(cur);
|
||||||
@ -548,7 +549,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
case LFUN_WORDLEFTSEL:
|
case LFUN_WORDLEFTSEL:
|
||||||
if (!cur.selection())
|
if (!cur.selection())
|
||||||
cur.resetAnchor();
|
cur.resetAnchor();
|
||||||
if (rtl())
|
if (rtl(cur))
|
||||||
cursorRightOneWord(cur);
|
cursorRightOneWord(cur);
|
||||||
else
|
else
|
||||||
cursorLeftOneWord(cur);
|
cursorLeftOneWord(cur);
|
||||||
@ -641,7 +642,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
// It is possible to make it a lot faster still
|
// It is possible to make it a lot faster still
|
||||||
// just comment out the line below...
|
// just comment out the line below...
|
||||||
} else {
|
} else {
|
||||||
cutSelection(true, false);
|
cutSelection(cur, true, false);
|
||||||
}
|
}
|
||||||
moveCursor(cur, false);
|
moveCursor(cur, false);
|
||||||
bv->owner()->view_state_changed();
|
bv->owner()->view_state_changed();
|
||||||
@ -657,9 +658,9 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
Delete(cur);
|
Delete(cur);
|
||||||
cur.resetAnchor();
|
cur.resetAnchor();
|
||||||
} else {
|
} else {
|
||||||
cutSelection(true, false);
|
cutSelection(cur, true, false);
|
||||||
}
|
}
|
||||||
bv->update();
|
cur.update();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
@ -672,11 +673,11 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
// just comment out the line below...
|
// just comment out the line below...
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cutSelection(true, false);
|
cutSelection(cur, true, false);
|
||||||
}
|
}
|
||||||
bv->owner()->view_state_changed();
|
bv->owner()->view_state_changed();
|
||||||
bv->switchKeyMap();
|
bv->switchKeyMap();
|
||||||
bv->update();
|
cur.update();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_BACKSPACE_SKIP:
|
case LFUN_BACKSPACE_SKIP:
|
||||||
@ -687,15 +688,15 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
backspace(cur);
|
backspace(cur);
|
||||||
//anchor() = cur;
|
//anchor() = cur;
|
||||||
} else {
|
} else {
|
||||||
cutSelection(true, false);
|
cutSelection(cur, true, false);
|
||||||
}
|
}
|
||||||
bv->update();
|
cur.update();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_BREAKPARAGRAPH:
|
case LFUN_BREAKPARAGRAPH:
|
||||||
replaceSelection(cur);
|
replaceSelection(cur);
|
||||||
breakParagraph(cur, 0);
|
breakParagraph(cur, 0);
|
||||||
bv->update();
|
cur.update();
|
||||||
cur.resetAnchor();
|
cur.resetAnchor();
|
||||||
bv->switchKeyMap();
|
bv->switchKeyMap();
|
||||||
bv->owner()->view_state_changed();
|
bv->owner()->view_state_changed();
|
||||||
@ -704,7 +705,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
|
case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
|
||||||
replaceSelection(cur);
|
replaceSelection(cur);
|
||||||
breakParagraph(cur, 1);
|
breakParagraph(cur, 1);
|
||||||
bv->update();
|
cur.update();
|
||||||
cur.resetAnchor();
|
cur.resetAnchor();
|
||||||
bv->switchKeyMap();
|
bv->switchKeyMap();
|
||||||
bv->owner()->view_state_changed();
|
bv->owner()->view_state_changed();
|
||||||
@ -714,18 +715,17 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
// When at the beginning of a paragraph, remove
|
// When at the beginning of a paragraph, remove
|
||||||
// indentation and add a "defskip" at the top.
|
// indentation and add a "defskip" at the top.
|
||||||
// Otherwise, do the same as LFUN_BREAKPARAGRAPH.
|
// Otherwise, do the same as LFUN_BREAKPARAGRAPH.
|
||||||
#warning look here
|
|
||||||
replaceSelection(cur);
|
replaceSelection(cur);
|
||||||
if (cur.pos() == 0) {
|
if (cur.pos() == 0) {
|
||||||
ParagraphParameters & params = cur.paragraph().params();
|
ParagraphParameters & params = cur.paragraph().params();
|
||||||
setParagraph(
|
setParagraph(cur,
|
||||||
params.spacing(),
|
params.spacing(),
|
||||||
params.align(),
|
params.align(),
|
||||||
params.labelWidthString(), 1);
|
params.labelWidthString(), 1);
|
||||||
} else {
|
} else {
|
||||||
breakParagraph(cur, 0);
|
breakParagraph(cur, 0);
|
||||||
}
|
}
|
||||||
bv->update();
|
cur.update();
|
||||||
// anchor() = cur;
|
// anchor() = cur;
|
||||||
bv->switchKeyMap();
|
bv->switchKeyMap();
|
||||||
bv->owner()->view_state_changed();
|
bv->owner()->view_state_changed();
|
||||||
@ -769,7 +769,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
if (cur_spacing != new_spacing || cur_value != new_value) {
|
if (cur_spacing != new_spacing || cur_value != new_value) {
|
||||||
par.params().spacing(Spacing(new_spacing, new_value));
|
par.params().spacing(Spacing(new_spacing, new_value));
|
||||||
redoParagraph(cur);
|
redoParagraph(cur);
|
||||||
bv->update();
|
cur.update();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -800,7 +800,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
cur.clearSelection();
|
cur.clearSelection();
|
||||||
if (!toggleInset(cur))
|
if (!toggleInset(cur))
|
||||||
return DispatchResult(false);
|
return DispatchResult(false);
|
||||||
bv->update();
|
cur.update();
|
||||||
bv->switchKeyMap();
|
bv->switchKeyMap();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -808,49 +808,49 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
if (cur.paragraph().layout()->free_spacing)
|
if (cur.paragraph().layout()->free_spacing)
|
||||||
insertChar(cur, ' ');
|
insertChar(cur, ' ');
|
||||||
else
|
else
|
||||||
doInsertInset(cur, this, bv, cmd, false, false);
|
doInsertInset(cur, this, cmd, false, false);
|
||||||
moveCursor(cur, false);
|
moveCursor(cur, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_HYPHENATION:
|
case LFUN_HYPHENATION:
|
||||||
specialChar(cur, this, bv, InsetSpecialChar::HYPHENATION);
|
specialChar(cur, this, InsetSpecialChar::HYPHENATION);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_LIGATURE_BREAK:
|
case LFUN_LIGATURE_BREAK:
|
||||||
specialChar(cur, this, bv, InsetSpecialChar::LIGATURE_BREAK);
|
specialChar(cur, this, InsetSpecialChar::LIGATURE_BREAK);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_LDOTS:
|
case LFUN_LDOTS:
|
||||||
specialChar(cur, this, bv, InsetSpecialChar::LDOTS);
|
specialChar(cur, this, InsetSpecialChar::LDOTS);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_END_OF_SENTENCE:
|
case LFUN_END_OF_SENTENCE:
|
||||||
specialChar(cur, this, bv, InsetSpecialChar::END_OF_SENTENCE);
|
specialChar(cur, this, InsetSpecialChar::END_OF_SENTENCE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_MENU_SEPARATOR:
|
case LFUN_MENU_SEPARATOR:
|
||||||
specialChar(cur, this, bv, InsetSpecialChar::MENU_SEPARATOR);
|
specialChar(cur, this, InsetSpecialChar::MENU_SEPARATOR);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_UPCASE_WORD:
|
case LFUN_UPCASE_WORD:
|
||||||
changeCase(cur, LyXText::text_uppercase);
|
changeCase(cur, LyXText::text_uppercase);
|
||||||
bv->update();
|
cur.update();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_LOWCASE_WORD:
|
case LFUN_LOWCASE_WORD:
|
||||||
changeCase(cur, LyXText::text_lowercase);
|
changeCase(cur, LyXText::text_lowercase);
|
||||||
bv->update();
|
cur.update();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_CAPITALIZE_WORD:
|
case LFUN_CAPITALIZE_WORD:
|
||||||
changeCase(cur, LyXText::text_capitalization);
|
changeCase(cur, LyXText::text_capitalization);
|
||||||
bv->update();
|
cur.update();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_TRANSPOSE_CHARS:
|
case LFUN_TRANSPOSE_CHARS:
|
||||||
recordUndo(cur);
|
recordUndo(cur);
|
||||||
redoParagraph(cur);
|
redoParagraph(cur);
|
||||||
bv->update();
|
cur.update();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_PASTE:
|
case LFUN_PASTE:
|
||||||
@ -862,19 +862,19 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
else
|
else
|
||||||
pasteSelection(cur, 0);
|
pasteSelection(cur, 0);
|
||||||
cur.clearSelection(); // bug 393
|
cur.clearSelection(); // bug 393
|
||||||
bv->update();
|
cur.update();
|
||||||
bv->switchKeyMap();
|
bv->switchKeyMap();
|
||||||
finishUndo();
|
finishUndo();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_CUT:
|
case LFUN_CUT:
|
||||||
cutSelection(true, true);
|
cutSelection(cur, true, true);
|
||||||
cur.message(_("Cut"));
|
cur.message(_("Cut"));
|
||||||
bv->update();
|
cur.update();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_COPY:
|
case LFUN_COPY:
|
||||||
copySelection();
|
copySelection(cur);
|
||||||
cur.message(_("Copy"));
|
cur.message(_("Copy"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -910,7 +910,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
lyxerr << "SETXY: Could not parse coordinates in '"
|
lyxerr << "SETXY: Could not parse coordinates in '"
|
||||||
<< cmd.argument << std::endl;
|
<< cmd.argument << std::endl;
|
||||||
else
|
else
|
||||||
setCursorFromCoordinates(x, y);
|
setCursorFromCoordinates(cur.current(), x, y);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -980,7 +980,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
current_layout = layout;
|
current_layout = layout;
|
||||||
setLayout(cur, layout);
|
setLayout(cur, layout);
|
||||||
bv->owner()->setLayout(layout);
|
bv->owner()->setLayout(layout);
|
||||||
bv->update();
|
cur.update();
|
||||||
bv->switchKeyMap();
|
bv->switchKeyMap();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -994,24 +994,24 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
insertStringAsParagraphs(cur, clip);
|
insertStringAsParagraphs(cur, clip);
|
||||||
else
|
else
|
||||||
insertStringAsLines(cur, clip);
|
insertStringAsLines(cur, clip);
|
||||||
bv->update();
|
cur.update();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_GOTOERROR:
|
case LFUN_GOTOERROR:
|
||||||
gotoInset(InsetBase::ERROR_CODE, false);
|
gotoInset(cur, InsetBase::ERROR_CODE, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_GOTONOTE:
|
case LFUN_GOTONOTE:
|
||||||
gotoInset(InsetBase::NOTE_CODE, false);
|
gotoInset(cur, InsetBase::NOTE_CODE, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_REFERENCE_GOTO: {
|
case LFUN_REFERENCE_GOTO: {
|
||||||
vector<InsetOld_code> tmp;
|
vector<InsetOld_code> tmp;
|
||||||
tmp.push_back(InsetBase::LABEL_CODE);
|
tmp.push_back(InsetBase::LABEL_CODE);
|
||||||
tmp.push_back(InsetBase::REF_CODE);
|
tmp.push_back(InsetBase::REF_CODE);
|
||||||
gotoInset(tmp, true);
|
gotoInset(cur, tmp, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1081,7 +1081,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
|
|
||||||
case LFUN_MOUSE_MOTION: {
|
case LFUN_MOUSE_MOTION: {
|
||||||
// Only use motion with button 1
|
// Only use motion with button 1
|
||||||
//if (ev.button() != mouse_button::button1)
|
//if (cmd.button() != mouse_button::button1)
|
||||||
// return false;
|
// return false;
|
||||||
// The test for not selection possible is needed, that
|
// The test for not selection possible is needed, that
|
||||||
// only motion events are used, where the bottom press
|
// only motion events are used, where the bottom press
|
||||||
@ -1092,9 +1092,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
CursorSlice old = cur.current();
|
CursorSlice old = cur.current();
|
||||||
|
setCursorFromCoordinates(cur.current(), cmd.x, cmd.y);
|
||||||
#warning
|
|
||||||
setCursorFromCoordinates(cmd.x, cmd.y);
|
|
||||||
|
|
||||||
// This is to allow jumping over large insets
|
// This is to allow jumping over large insets
|
||||||
// FIXME: shouldn't be top-text-specific
|
// FIXME: shouldn't be top-text-specific
|
||||||
@ -1108,7 +1106,6 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
// don't set anchor_
|
// don't set anchor_
|
||||||
bv->cursor().cursor_ = cur.cursor_;
|
bv->cursor().cursor_ = cur.cursor_;
|
||||||
bv->cursor().setSelection();
|
bv->cursor().setSelection();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1209,7 +1206,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
|
|
||||||
if (lyxrc.auto_region_delete) {
|
if (lyxrc.auto_region_delete) {
|
||||||
if (cur.selection())
|
if (cur.selection())
|
||||||
cutSelection(false, false);
|
cutSelection(cur, false, false);
|
||||||
bv->haveSelection(false);
|
bv->haveSelection(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1276,12 +1273,12 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
case LFUN_ENVIRONMENT_INSERT:
|
case LFUN_ENVIRONMENT_INSERT:
|
||||||
// Open the inset, and move the current selection
|
// Open the inset, and move the current selection
|
||||||
// inside it.
|
// inside it.
|
||||||
doInsertInset(cur, this, bv, cmd, true, true);
|
doInsertInset(cur, this, cmd, true, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_INDEX_INSERT:
|
case LFUN_INDEX_INSERT:
|
||||||
// Just open the inset
|
// Just open the inset
|
||||||
doInsertInset(cur, this, bv, cmd, true, false);
|
doInsertInset(cur, this, cmd, true, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_INDEX_PRINT:
|
case LFUN_INDEX_PRINT:
|
||||||
@ -1290,26 +1287,26 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
case LFUN_INSERT_LINE:
|
case LFUN_INSERT_LINE:
|
||||||
case LFUN_INSERT_PAGEBREAK:
|
case LFUN_INSERT_PAGEBREAK:
|
||||||
// do nothing fancy
|
// do nothing fancy
|
||||||
doInsertInset(cur, this, bv, cmd, false, false);
|
doInsertInset(cur, this, cmd, false, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_DEPTH_MIN:
|
case LFUN_DEPTH_MIN:
|
||||||
changeDepth(cur, bv_funcs::DEC_DEPTH);
|
changeDepth(cur, bv_funcs::DEC_DEPTH);
|
||||||
bv->update();
|
cur.update();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_DEPTH_PLUS:
|
case LFUN_DEPTH_PLUS:
|
||||||
changeDepth(cur, bv_funcs::INC_DEPTH);
|
changeDepth(cur, bv_funcs::INC_DEPTH);
|
||||||
bv->update();
|
cur.update();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_MATH_DISPLAY:
|
case LFUN_MATH_DISPLAY:
|
||||||
mathDispatch(cur, cmd, true);
|
mathDispatch(cur, this, cmd, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_MATH_IMPORT_SELECTION:
|
case LFUN_MATH_IMPORT_SELECTION:
|
||||||
case LFUN_MATH_MODE:
|
case LFUN_MATH_MODE:
|
||||||
mathDispatch(cur, cmd, false);
|
mathDispatch(cur, this, cmd, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_MATH_MACRO:
|
case LFUN_MATH_MACRO:
|
||||||
@ -1443,7 +1440,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
case LFUN_FINISHED_LEFT:
|
case LFUN_FINISHED_LEFT:
|
||||||
lyxerr << "handle LFUN_FINISHED_LEFT" << endl;
|
lyxerr << "handle LFUN_FINISHED_LEFT" << endl;
|
||||||
cur.pop(cur.currentDepth());
|
cur.pop(cur.currentDepth());
|
||||||
if (rtl())
|
if (rtl(cur))
|
||||||
cursorLeft(cur, true);
|
cursorLeft(cur, true);
|
||||||
cur.bv().cursor() = cur;
|
cur.bv().cursor() = cur;
|
||||||
break;
|
break;
|
||||||
@ -1451,7 +1448,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
case LFUN_FINISHED_RIGHT:
|
case LFUN_FINISHED_RIGHT:
|
||||||
lyxerr << "handle LFUN_FINISHED_RIGHT" << endl;
|
lyxerr << "handle LFUN_FINISHED_RIGHT" << endl;
|
||||||
cur.pop(cur.currentDepth());
|
cur.pop(cur.currentDepth());
|
||||||
if (!rtl())
|
if (!rtl(cur))
|
||||||
cursorRight(cur, true);
|
cursorRight(cur, true);
|
||||||
cur.bv().cursor() = cur;
|
cur.bv().cursor() = cur;
|
||||||
break;
|
break;
|
||||||
@ -1532,7 +1529,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
setLayout(cur, tclass.defaultLayoutName());
|
setLayout(cur, tclass.defaultLayoutName());
|
||||||
setParagraph(Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
|
setParagraph(cur, Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
|
||||||
cur.insert(new InsetFloatList(cmd.argument));
|
cur.insert(new InsetFloatList(cmd.argument));
|
||||||
unFreezeUndo();
|
unFreezeUndo();
|
||||||
} else {
|
} else {
|
||||||
@ -1544,13 +1541,13 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
|
|
||||||
case LFUN_ACCEPT_CHANGE: {
|
case LFUN_ACCEPT_CHANGE: {
|
||||||
acceptChange(cur);
|
acceptChange(cur);
|
||||||
bv->update();
|
cur.update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_REJECT_CHANGE: {
|
case LFUN_REJECT_CHANGE: {
|
||||||
rejectChange(cur);
|
rejectChange(cur);
|
||||||
bv->update();
|
cur.update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1569,6 +1566,25 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case LFUN_PARAGRAPH_APPLY: {
|
||||||
|
// Given data, an encoding of the ParagraphParameters
|
||||||
|
// generated in the Paragraph dialog, this function sets
|
||||||
|
// the current paragraph appropriately.
|
||||||
|
istringstream is(cmd.argument);
|
||||||
|
LyXLex lex(0, 0);
|
||||||
|
lex.setStream(is);
|
||||||
|
ParagraphParameters params;
|
||||||
|
params.read(lex);
|
||||||
|
setParagraph(cur,
|
||||||
|
params.spacing(),
|
||||||
|
params.align(),
|
||||||
|
params.labelWidthString(),
|
||||||
|
params.noindent());
|
||||||
|
cur.update();
|
||||||
|
cur.message(_("Paragraph layout set"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return DispatchResult(false);
|
return DispatchResult(false);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user