replace LyXCursor by CursorSlice

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8338 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2004-01-13 14:13:51 +00:00
parent 7f48aeeab1
commit d8f81752eb
19 changed files with 93 additions and 245 deletions

View File

@ -739,7 +739,7 @@ void BufferView::Pimpl::stuffClipboard(string const & stuff) const
InsetOld * BufferView::Pimpl::getInsetByCode(InsetOld::Code code) InsetOld * BufferView::Pimpl::getInsetByCode(InsetOld::Code code)
{ {
#if 0 #if 0
LyXCursor cursor = bv_->getLyXText()->cursor; CursorSlice cursor = bv_->getLyXText()->cursor;
Buffer::inset_iterator it = Buffer::inset_iterator it =
find_if(Buffer::inset_iterator( find_if(Buffer::inset_iterator(
cursorPar(), cursor().pos()), cursorPar(), cursor().pos()),
@ -1286,7 +1286,7 @@ bool BufferView::Pimpl::ChangeInsets(InsetOld::Code code,
string const & from, string const & to) string const & from, string const & to)
{ {
bool need_update = false; bool need_update = false;
LyXCursor cur = bv_->text()->cursor(); CursorSlice cur = bv_->text()->cursor();
ParIterator end = bv_->buffer()->par_iterator_end(); ParIterator end = bv_->buffer()->par_iterator_end();
for (ParIterator it = bv_->buffer()->par_iterator_begin(); for (ParIterator it = bv_->buffer()->par_iterator_begin();

View File

@ -41,6 +41,7 @@ class WorkArea;
class LyXScreen; class LyXScreen;
class FuncRequest; class FuncRequest;
/// ///
struct BufferView::Pimpl : public boost::signals::trackable { struct BufferView::Pimpl : public boost::signals::trackable {
/// ///
@ -195,8 +196,8 @@ private:
WorkArea & workarea() const; WorkArea & workarea() const;
/// this is used to handle XSelection events in the right manner /// this is used to handle XSelection events in the right manner
struct { struct {
LyXCursor cursor; CursorSlice cursor;
LyXCursor anchor; CursorSlice anchor;
bool set; bool set;
} xsel_cache_; } xsel_cache_;
/// ///

View File

@ -19,6 +19,18 @@
* cursor.h: * cursor.h:
* cursor_slice.[Ch]: some integer type changes for inset unification * cursor_slice.[Ch]: some integer type changes for inset unification
* lyxcursor.[hC]: remove, it's CursorSlice now.
* Makefile.am:
* BufferView_pimpl.[Ch]:
* bufferview_funcs.C:
* cursor_slice.C:
* lyxtext.h:
* text.C:
* text2.C:
* text3.C:
* textcursor.[Ch]: adjust
2004-01-08 Alfredo Braunstein <abraunst@lyx.org> 2004-01-08 Alfredo Braunstein <abraunst@lyx.org>
* text2.C (undoSpan): add and use * text2.C (undoSpan): add and use

View File

@ -182,8 +182,6 @@ lyx_SOURCES = \
lyx_main.h \ lyx_main.h \
lyx_sty.C \ lyx_sty.C \
lyx_sty.h \ lyx_sty.h \
lyxcursor.C \
lyxcursor.h \
lyxfont.C \ lyxfont.C \
lyxfont.h \ lyxfont.h \
lyxfind.C \ lyxfind.C \

View File

@ -179,7 +179,7 @@ string const currentState(BufferView * bv)
LyXText * text = bv->getLyXText(); LyXText * text = bv->getLyXText();
Buffer * buffer = bv->buffer(); Buffer * buffer = bv->buffer();
LyXCursor const & c = text->cursor(); CursorSlice const & c = text->cursor();
bool const show_change = buffer->params().tracking_changes bool const show_change = buffer->params().tracking_changes
&& text->cursor().pos() != text->cursorPar()->size() && text->cursor().pos() != text->cursorPar()->size()

View File

@ -149,6 +149,12 @@ bool operator<(CursorSlice const & p, CursorSlice const & q)
} }
bool operator>(CursorSlice const & p, CursorSlice const & q)
{
return q < p;
}
//std::ostream & operator<<(std::ostream & os, CursorSlice const & p) //std::ostream & operator<<(std::ostream & os, CursorSlice const & p)
//{ //{
// os << "(par: " << p.inset_ << " idx: " << p.idx_ << " pos: " << p.pos_ << ')'; // os << "(par: " << p.inset_ << " idx: " << p.idx_ << " pos: " << p.pos_ << ')';

View File

@ -14,7 +14,7 @@
#define SCREEN_H #define SCREEN_H
class LyXText; class LyXText;
class LyXCursor; class CursorSlice;
class WorkArea; class WorkArea;
class BufferView; class BufferView;

View File

@ -24,7 +24,7 @@ class Buffer;
class LColor_color; class LColor_color;
class FuncRequest; class FuncRequest;
class OutputParams; class OutputParams;
class LyXCursor; class CursorSlice;
class LyXLex; class LyXLex;
class LyXText; class LyXText;
class Painter; class Painter;

View File

@ -23,7 +23,7 @@
class Painter; class Painter;
class LyXText; class LyXText;
class Paragraph; class Paragraph;
class LyXCursor; class CursorSlice;
/** A collapsable text inset /** A collapsable text inset

View File

@ -28,7 +28,7 @@ class BufferParams;
class BufferView; class BufferView;
class Dimension; class Dimension;
class LColor_color; class LColor_color;
class LyXCursor; class CursorSlice;
class Painter; class Painter;
class Paragraph; class Paragraph;
class Row; class Row;

View File

@ -1,85 +0,0 @@
/**
* \file lyxcursor.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Lars Gullik Bjønnes
* \author Matthias Ettrich
* \author André Pönitz
* \author Jürgen Vigna
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "lyxcursor.h"
LyXCursor::LyXCursor()
: par_(0), pos_(0), boundary_(false)
{}
void LyXCursor::par(lyx::paroffset_type par)
{
par_ = par;
}
lyx::paroffset_type LyXCursor::par() const
{
return par_;
}
void LyXCursor::pos(lyx::pos_type pos)
{
pos_ = pos;
}
lyx::pos_type LyXCursor::pos() const
{
return pos_;
}
void LyXCursor::boundary(bool boundary)
{
boundary_ = boundary;
}
bool LyXCursor::boundary() const
{
return boundary_;
}
bool operator==(LyXCursor const & a, LyXCursor const & b)
{
return a.par() == b.par()
&& a.pos() == b.pos()
&& a.boundary() == b.boundary();
}
bool operator!=(LyXCursor const & a, LyXCursor const & b)
{
return !(a == b);
}
bool operator<(LyXCursor const & a, LyXCursor const & b)
{
return (a.par() < b.par() ||
(a.par() == b.par() && a.pos() < b.pos()));
}
bool operator>(LyXCursor const & a, LyXCursor const & b)
{
return (a.par() > b.par() ||
(a.par() == b.par() && a.pos() > b.pos()));
}

View File

@ -1,77 +0,0 @@
// -*- C++ -*-
/**
* \file lyxcursor.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Lars Gullik Bjønnes
* \author Matthias Ettrich
* \author John Levon
* \author André Pönitz
* \author Dekel Tsur
* \author Jürgen Vigna
*
* Full author contact details are available in file CREDITS.
*/
#ifndef LYXCURSOR_H
#define LYXCURSOR_H
#include "support/types.h"
/**
* The cursor class describes the position of a cursor within a document.
* Several cursors exist within LyX; for example, when locking an inset,
* the position of the cursor in the containing inset is stored.
*
* FIXME: true ?
*/
class LyXCursor {
public:
LyXCursor();
/// set the paragraph that contains this cursor
void par(lyx::paroffset_type pit);
/// return the paragraph this cursor is in
lyx::paroffset_type par() const;
/// set the position within the paragraph
void pos(lyx::pos_type p);
/// return the position within the paragraph
lyx::pos_type pos() const;
/// FIXME
void boundary(bool b);
/// FIXME
bool boundary() const;
private:
/// The paragraph the cursor is in.
lyx::paroffset_type par_;
/// The position inside the paragraph
lyx::pos_type pos_;
/**
* When the cursor position is i, is the cursor is after the i-th char
* or before the i+1-th char ? Normally, these two interpretations are
* equivalent, except when the fonts of the i-th and i+1-th char
* differ.
* We use boundary_ to distinguish between the two options:
* If boundary_=true, then the cursor is after the i-th char
* and if boundary_=false, then the cursor is before the i+1-th char.
*
* We currently use the boundary only when the language direction of
* the i-th char is different than the one of the i+1-th char.
* In this case it is important to distinguish between the two
* cursor interpretations, in order to give a reasonable behavior to
* the user.
*/
bool boundary_;
};
///
bool operator==(LyXCursor const & a, LyXCursor const & b);
///
bool operator!=(LyXCursor const & a, LyXCursor const & b);
///
bool operator<(LyXCursor const & a, LyXCursor const & b);
///
bool operator>(LyXCursor const & a, LyXCursor const & b);
#endif // LYXCURSOR_H

View File

@ -32,7 +32,7 @@ class BufferParams;
class BufferView; class BufferView;
class Dimension; class Dimension;
class LColor_color; class LColor_color;
class LyXCursor; class CursorSlice;
class MetricsInfo; class MetricsInfo;
class Paragraph; class Paragraph;
class Row; class Row;
@ -141,7 +141,7 @@ public:
friend class LyXScreen; friend class LyXScreen;
/// returns an iterator pointing to a cursor paragraph /// returns an iterator pointing to a cursor paragraph
ParagraphList::iterator getPar(LyXCursor const & cursor) const; ParagraphList::iterator getPar(CursorSlice const & cursor) const;
/// ///
ParagraphList::iterator getPar(lyx::paroffset_type par) const; ParagraphList::iterator getPar(lyx::paroffset_type par) const;
/// ///
@ -170,7 +170,7 @@ public:
void clearSelection(); void clearSelection();
/// select the word we need depending on word_location /// select the word we need depending on word_location
void getWord(LyXCursor & from, LyXCursor & to, lyx::word_location const); void getWord(CursorSlice & from, CursorSlice & to, lyx::word_location const);
/// just selects the word the cursor is in /// just selects the word the cursor is in
void selectWord(lyx::word_location loc); void selectWord(lyx::word_location loc);
/// returns the inset at cursor (if it exists), 0 otherwise /// returns the inset at cursor (if it exists), 0 otherwise
@ -188,7 +188,7 @@ public:
bool setCursor(lyx::paroffset_type par, lyx::pos_type pos, bool setCursor(lyx::paroffset_type par, lyx::pos_type pos,
bool setfont = true, bool boundary = false); bool setfont = true, bool boundary = false);
/// ///
void setCursor(LyXCursor &, lyx::paroffset_type par, void setCursor(CursorSlice &, lyx::paroffset_type par,
lyx::pos_type pos, bool boundary = false); lyx::pos_type pos, bool boundary = false);
/// ///
void setCursorIntern(lyx::paroffset_type par, lyx::pos_type pos, void setCursorIntern(lyx::paroffset_type par, lyx::pos_type pos,
@ -203,7 +203,7 @@ public:
/// ///
void setCursorFromCoordinates(int x, int y); void setCursorFromCoordinates(int x, int y);
/// ///
void setCursorFromCoordinates(LyXCursor &, int x, int y); void setCursorFromCoordinates(CursorSlice &, int x, int y);
/// ///
void cursorUp(bool selecting = false); void cursorUp(bool selecting = false);
/// ///
@ -367,9 +367,9 @@ public:
/// ///
double spacing(Paragraph const &) const; double spacing(Paragraph const &) const;
/// ///
void cursorLeftOneWord(LyXCursor &); void cursorLeftOneWord(CursorSlice &);
/// ///
void cursorRightOneWord(LyXCursor &); void cursorRightOneWord(CursorSlice &);
/// ///
DispatchResult moveRight(); DispatchResult moveRight();
@ -402,18 +402,18 @@ public:
/// ///
int cursorY() const; int cursorY() const;
/// ///
int cursorX(LyXCursor const & cursor) const; int cursorX(CursorSlice const & cursor) const;
/// ///
int cursorY(LyXCursor const & cursor) const; int cursorY(CursorSlice const & cursor) const;
/// the topmost cursor slice /// the topmost cursor slice
LyXCursor & cursor(); CursorSlice & cursor();
/// the topmost cursor slice /// the topmost cursor slice
LyXCursor const & cursor() const; CursorSlice const & cursor() const;
/// access to the selection anchor /// access to the selection anchor
LyXCursor & anchor(); CursorSlice & anchor();
/// access to the selection anchor /// access to the selection anchor
LyXCursor const & anchor() const; CursorSlice const & anchor() const;
public: public:
@ -465,10 +465,10 @@ private:
// fix the cursor `cur' after a characters has been deleted at `where' // fix the cursor `cur' after a characters has been deleted at `where'
// position. Called by deleteEmptyParagraphMechanism // position. Called by deleteEmptyParagraphMechanism
void fixCursorAfterDelete(LyXCursor & cur, LyXCursor const & where); void fixCursorAfterDelete(CursorSlice & cur, CursorSlice const & where);
/// delete double space (false) or empty paragraphs (true) around old_cursor /// delete double space (false) or empty paragraphs (true) around old_cursor
bool deleteEmptyParagraphMechanism(LyXCursor const & old_cursor); bool deleteEmptyParagraphMechanism(CursorSlice const & old_cursor);
/// ///
void setCounter(Buffer const &, ParagraphList::iterator pit); void setCounter(Buffer const &, ParagraphList::iterator pit);

View File

@ -174,13 +174,6 @@ void InsetFormula::read(Buffer const &, LyXLex & lex)
} }
//ostream & operator<<(ostream & os, LyXCursor const & c)
//{
// os << '[' << c.x() << ' ' << c.y() << ' ' << c.pos() << ']';
// return os;
//}
namespace { namespace {
bool editing_inset(InsetFormula const * inset) bool editing_inset(InsetFormula const * inset)

View File

@ -1088,7 +1088,7 @@ void LyXText::cursorRightOneWord()
// of prior word, not to end of next prior word. // of prior word, not to end of next prior word.
void LyXText::cursorLeftOneWord() void LyXText::cursorLeftOneWord()
{ {
LyXCursor tmpcursor = cursor(); CursorSlice tmpcursor = cursor();
cursorLeftOneWord(tmpcursor); cursorLeftOneWord(tmpcursor);
setCursor(getPar(tmpcursor), tmpcursor.pos()); setCursor(getPar(tmpcursor), tmpcursor.pos());
} }
@ -1096,8 +1096,8 @@ void LyXText::cursorLeftOneWord()
void LyXText::selectWord(word_location loc) void LyXText::selectWord(word_location loc)
{ {
LyXCursor from = cursor(); CursorSlice from = cursor();
LyXCursor to = cursor(); CursorSlice to = cursor();
getWord(from, to, loc); getWord(from, to, loc);
if (cursor() != from) if (cursor() != from)
setCursor(from.par(), from.pos()); setCursor(from.par(), from.pos());
@ -1127,8 +1127,8 @@ void LyXText::acceptChange()
return; return;
if (selStart().par() == selEnd().par()) { if (selStart().par() == selEnd().par()) {
LyXCursor const & startc = selStart(); CursorSlice const & startc = selStart();
LyXCursor const & endc = selEnd(); CursorSlice const & endc = selEnd();
recordUndo(Undo::INSERT, this, startc.par()); recordUndo(Undo::INSERT, this, startc.par());
getPar(startc)->acceptChange(startc.pos(), endc.pos()); getPar(startc)->acceptChange(startc.pos(), endc.pos());
finishUndo(); finishUndo();
@ -1146,8 +1146,8 @@ void LyXText::rejectChange()
return; return;
if (selStart().par() == selEnd().par()) { if (selStart().par() == selEnd().par()) {
LyXCursor const & startc = selStart(); CursorSlice const & startc = selStart();
LyXCursor const & endc = selEnd(); CursorSlice const & endc = selEnd();
recordUndo(Undo::INSERT, this, startc.par()); recordUndo(Undo::INSERT, this, startc.par());
getPar(startc)->rejectChange(startc.pos(), endc.pos()); getPar(startc)->rejectChange(startc.pos(), endc.pos());
finishUndo(); finishUndo();
@ -1165,7 +1165,7 @@ void LyXText::deleteWordForward()
if (cursorPar()->empty()) if (cursorPar()->empty())
cursorRight(bv()); cursorRight(bv());
else { else {
LyXCursor tmpcursor = cursor(); CursorSlice tmpcursor = cursor();
selection.set(true); // to avoid deletion selection.set(true); // to avoid deletion
cursorRightOneWord(); cursorRightOneWord();
setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos()); setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos());
@ -1183,7 +1183,7 @@ void LyXText::deleteWordBackward()
if (cursorPar()->empty()) if (cursorPar()->empty())
cursorLeft(bv()); cursorLeft(bv());
else { else {
LyXCursor tmpcursor = cursor(); CursorSlice tmpcursor = cursor();
selection.set(true); // to avoid deletion selection.set(true); // to avoid deletion
cursorLeftOneWord(); cursorLeftOneWord();
setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos()); setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos());
@ -1202,7 +1202,7 @@ void LyXText::deleteLineForward()
// Paragraph is empty, so we just go to the right // Paragraph is empty, so we just go to the right
cursorRight(bv()); cursorRight(bv());
} else { } else {
LyXCursor tmpcursor = cursor(); CursorSlice tmpcursor = cursor();
selection.set(true); // to avoid deletion selection.set(true); // to avoid deletion
cursorEnd(); cursorEnd();
setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos()); setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos());
@ -1220,8 +1220,8 @@ void LyXText::deleteLineForward()
void LyXText::changeCase(LyXText::TextCase action) void LyXText::changeCase(LyXText::TextCase action)
{ {
LyXCursor from; CursorSlice from;
LyXCursor to; CursorSlice to;
if (selection.set()) { if (selection.set()) {
from = selStart(); from = selStart();
@ -1270,7 +1270,7 @@ void LyXText::changeCase(LyXText::TextCase action)
void LyXText::Delete() void LyXText::Delete()
{ {
// this is a very easy implementation // this is a very easy implementation
LyXCursor old_cursor = cursor(); CursorSlice old_cursor = cursor();
// just move to the right // just move to the right
cursorRight(true); cursorRight(true);
@ -1387,7 +1387,7 @@ RowList::iterator LyXText::cursorRow() const
} }
ParagraphList::iterator LyXText::getPar(LyXCursor const & cur) const ParagraphList::iterator LyXText::getPar(CursorSlice const & cur) const
{ {
return getPar(cur.par()); return getPar(cur.par());
} }
@ -1646,7 +1646,7 @@ bool LyXText::isFirstRow(ParagraphList::iterator pit, Row const & row) const
} }
void LyXText::cursorLeftOneWord(LyXCursor & cur) void LyXText::cursorLeftOneWord(CursorSlice & cur)
{ {
// treat HFills, floats and Insets as words // treat HFills, floats and Insets as words
@ -1680,7 +1680,7 @@ void LyXText::cursorLeftOneWord(LyXCursor & cur)
} }
void LyXText::cursorRightOneWord(LyXCursor & cur) void LyXText::cursorRightOneWord(CursorSlice & cur)
{ {
// treat floats, HFills and Insets as words // treat floats, HFills and Insets as words
ParagraphList::iterator pit = cursorPar(); ParagraphList::iterator pit = cursorPar();
@ -1706,7 +1706,7 @@ void LyXText::cursorRightOneWord(LyXCursor & cur)
} }
void LyXText::getWord(LyXCursor & from, LyXCursor & to, word_location const loc) void LyXText::getWord(CursorSlice & from, CursorSlice & to, word_location const loc)
{ {
ParagraphList::iterator from_par = getPar(from); ParagraphList::iterator from_par = getPar(from);
ParagraphList::iterator to_par = getPar(to); ParagraphList::iterator to_par = getPar(to);
@ -1865,7 +1865,7 @@ int LyXText::cursorY() const
} }
int LyXText::cursorX(LyXCursor const & cur) const int LyXText::cursorX(CursorSlice const & cur) const
{ {
ParagraphList::iterator pit = getPar(cur); ParagraphList::iterator pit = getPar(cur);
if (pit->rows.empty()) if (pit->rows.empty())
@ -1926,7 +1926,7 @@ int LyXText::cursorX(LyXCursor const & cur) const
} }
int LyXText::cursorY(LyXCursor const & cur) const int LyXText::cursorY(CursorSlice const & cur) const
{ {
Paragraph & par = *getPar(cur); Paragraph & par = *getPar(cur);
Row & row = *par.getRow(cur.pos()); Row & row = *par.getRow(cur.pos());
@ -1934,25 +1934,25 @@ int LyXText::cursorY(LyXCursor const & cur) const
} }
LyXCursor & LyXText::cursor() CursorSlice & LyXText::cursor()
{ {
return cursor_; return cursor_;
} }
LyXCursor const & LyXText::cursor() const CursorSlice const & LyXText::cursor() const
{ {
return cursor_; return cursor_;
} }
LyXCursor & LyXText::anchor() CursorSlice & LyXText::anchor()
{ {
return anchor_; return anchor_;
} }
LyXCursor const & LyXText::anchor() const CursorSlice const & LyXText::anchor() const
{ {
return anchor_; return anchor_;
} }

View File

@ -538,7 +538,7 @@ void LyXText::toggleFree(LyXFont const & font, bool toggleall)
// 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.
LyXCursor resetCursor = cursor(); CursorSlice resetCursor = cursor();
bool implicitSelection = bool implicitSelection =
font.language() == ignore_language font.language() == ignore_language
&& font.number() == LyXFont::IGNORE && font.number() == LyXFont::IGNORE
@ -562,7 +562,7 @@ string LyXText::getStringToIndex()
// 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.
LyXCursor const reset_cursor = cursor(); CursorSlice const reset_cursor = cursor();
bool const implicitSelection = bool const implicitSelection =
selectWordWhenUnderCursor(lyx::PREVIOUS_WORD); selectWordWhenUnderCursor(lyx::PREVIOUS_WORD);
@ -1150,13 +1150,13 @@ void LyXText::setCursor(ParagraphList::iterator pit, pos_type pos)
bool LyXText::setCursor(paroffset_type par, pos_type pos, bool setfont, bool LyXText::setCursor(paroffset_type par, pos_type pos, bool setfont,
bool boundary) bool boundary)
{ {
LyXCursor old_cursor = cursor(); CursorSlice old_cursor = cursor();
setCursorIntern(par, pos, setfont, boundary); setCursorIntern(par, pos, setfont, boundary);
return deleteEmptyParagraphMechanism(old_cursor); return deleteEmptyParagraphMechanism(old_cursor);
} }
void LyXText::setCursor(LyXCursor & cur, paroffset_type par, void LyXText::setCursor(CursorSlice & cur, paroffset_type par,
pos_type pos, bool boundary) pos_type pos, bool boundary)
{ {
BOOST_ASSERT(par != int(paragraphs().size())); BOOST_ASSERT(par != int(paragraphs().size()));
@ -1362,7 +1362,7 @@ pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
void LyXText::setCursorFromCoordinates(int x, int y) void LyXText::setCursorFromCoordinates(int x, int y)
{ {
LyXCursor old_cursor = cursor(); CursorSlice old_cursor = cursor();
setCursorFromCoordinates(cursor(), x, y); setCursorFromCoordinates(cursor(), x, y);
setCurrentFont(); setCurrentFont();
deleteEmptyParagraphMechanism(old_cursor); deleteEmptyParagraphMechanism(old_cursor);
@ -1370,7 +1370,7 @@ void LyXText::setCursorFromCoordinates(int x, int y)
// x,y are coordinates relative to this LyXText // x,y are coordinates relative to this LyXText
void LyXText::setCursorFromCoordinates(LyXCursor & cur, int x, int y) void LyXText::setCursorFromCoordinates(CursorSlice & cur, int x, int y)
{ {
ParagraphList::iterator pit; ParagraphList::iterator pit;
Row const & row = *getRowNearY(y, pit); Row const & row = *getRowNearY(y, pit);
@ -1562,7 +1562,7 @@ void LyXText::cursorDownParagraph()
// fix the cursor `cur' after a characters has been deleted at `where' // fix the cursor `cur' after a characters has been deleted at `where'
// position. Called by deleteEmptyParagraphMechanism // position. Called by deleteEmptyParagraphMechanism
void LyXText::fixCursorAfterDelete(LyXCursor & cur, LyXCursor const & where) void LyXText::fixCursorAfterDelete(CursorSlice & cur, CursorSlice const & where)
{ {
// if cursor is not in the paragraph where the delete occured, // if cursor is not in the paragraph where the delete occured,
// do nothing // do nothing
@ -1581,7 +1581,7 @@ void LyXText::fixCursorAfterDelete(LyXCursor & cur, LyXCursor const & where)
} }
bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor) bool LyXText::deleteEmptyParagraphMechanism(CursorSlice const & old_cursor)
{ {
// Would be wrong to delete anything if we have a selection. // Would be wrong to delete anything if we have a selection.
if (selection.set()) if (selection.set())
@ -1637,7 +1637,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
#warning This will not work anymore when we have multiple views of the same buffer #warning This will not work anymore when we have multiple views of the same buffer
// In this case, we will have to correct also the cursors held by // In this case, we will have to correct also the cursors held by
// other bufferviews. It will probably be easier to do that in a more // other bufferviews. It will probably be easier to do that in a more
// automated way in LyXCursor code. (JMarc 26/09/2001) // automated way in CursorSlice code. (JMarc 26/09/2001)
#endif #endif
// correct all cursors held by the LyXText // correct all cursors held by the LyXText
fixCursorAfterDelete(cursor(), old_cursor); fixCursorAfterDelete(cursor(), old_cursor);
@ -1665,7 +1665,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
if (old_pit->empty() if (old_pit->empty()
|| (old_pit->size() == 1 && old_pit->isLineSeparator(0))) { || (old_pit->size() == 1 && old_pit->isLineSeparator(0))) {
// ok, we will delete something // ok, we will delete something
LyXCursor tmpcursor; CursorSlice tmpcursor;
deleted = true; deleted = true;

View File

@ -91,7 +91,7 @@ namespace {
if (font.language() != ignore_language || if (font.language() != ignore_language ||
font.number() != LyXFont::IGNORE) { font.number() != LyXFont::IGNORE) {
LyXCursor & cur = text->cursor(); CursorSlice & cur = text->cursor();
Paragraph & par = *text->cursorPar(); Paragraph & par = *text->cursorPar();
text->bidi.computeTables(par, *bv->buffer(), text->bidi.computeTables(par, *bv->buffer(),
*par.getRow(cur.pos())); *par.getRow(cur.pos()));
@ -337,7 +337,7 @@ void LyXText::gotoInset(vector<InsetOld::Code> const & codes,
if (!gotoNextInset(codes, contents)) { if (!gotoNextInset(codes, contents)) {
if (cursor().pos() || cursorPar() != paragraphs().begin()) { if (cursor().pos() || cursorPar() != paragraphs().begin()) {
LyXCursor tmp = cursor(); CursorSlice tmp = cursor();
cursor().par(0); cursor().par(0);
cursor().pos(0); cursor().pos(0);
if (!gotoNextInset(codes, contents)) { if (!gotoNextInset(codes, contents)) {
@ -634,8 +634,8 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
break; break;
case LFUN_WORDSEL: { case LFUN_WORDSEL: {
LyXCursor cur1 = cursor(); CursorSlice cur1 = cursor();
LyXCursor cur2; CursorSlice cur2;
getWord(cur1, cur2, lyx::WHOLE_WORD); getWord(cur1, cur2, lyx::WHOLE_WORD);
setCursor(cur1.par(), cur1.pos()); setCursor(cur1.par(), cur1.pos());
clearSelection(); clearSelection();
@ -770,7 +770,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
case LFUN_BACKSPACE_SKIP: case LFUN_BACKSPACE_SKIP:
// Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP. // Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
if (!selection.set()) { if (!selection.set()) {
LyXCursor cur = cursor(); CursorSlice cur = cursor();
backspace(); backspace();
anchor() = cur; anchor() = cur;
} else { } else {
@ -801,7 +801,7 @@ DispatchResult LyXText::dispatch(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.
LyXCursor cur = cursor(); CursorSlice cur = cursor();
replaceSelection(bv->getLyXText()); replaceSelection(bv->getLyXText());
if (cur.pos() == 0) { if (cur.pos() == 0) {
ParagraphParameters & params = getPar(cur)->params(); ParagraphParameters & params = getPar(cur)->params();

View File

@ -13,7 +13,7 @@
#include "textcursor.h" #include "textcursor.h"
LyXCursor const & TextCursor::selStart() const CursorSlice const & TextCursor::selStart() const
{ {
if (!selection.set()) if (!selection.set())
return cursor_; return cursor_;
@ -22,7 +22,7 @@ LyXCursor const & TextCursor::selStart() const
} }
LyXCursor const & TextCursor::selEnd() const CursorSlice const & TextCursor::selEnd() const
{ {
if (!selection.set()) if (!selection.set())
return cursor_; return cursor_;
@ -30,7 +30,7 @@ LyXCursor const & TextCursor::selEnd() const
} }
LyXCursor & TextCursor::selStart() CursorSlice & TextCursor::selStart()
{ {
if (!selection.set()) if (!selection.set())
return cursor_; return cursor_;
@ -38,7 +38,7 @@ LyXCursor & TextCursor::selStart()
} }
LyXCursor & TextCursor::selEnd() CursorSlice & TextCursor::selEnd()
{ {
if (!selection.set()) if (!selection.set())
return cursor_; return cursor_;

View File

@ -15,7 +15,7 @@
#ifndef TEXTCURSOR_H #ifndef TEXTCURSOR_H
#define TEXTCURSOR_H #define TEXTCURSOR_H
#include "lyxcursor.h" #include "cursor_slice.h"
// Do not even think of forward declaring LyXText/BufferView etc here! // Do not even think of forward declaring LyXText/BufferView etc here!
// If you need Paragraph proper, go to text_func.h // If you need Paragraph proper, go to text_func.h
@ -63,16 +63,16 @@ struct TextCursor {
void clearSelection(); void clearSelection();
// actual cursor position // actual cursor position
LyXCursor cursor_; CursorSlice cursor_;
// the other end of the selection // the other end of the selection
LyXCursor anchor_; CursorSlice anchor_;
Selection selection; Selection selection;
LyXCursor const & selStart() const; CursorSlice const & selStart() const;
LyXCursor const & selEnd() const; CursorSlice const & selEnd() const;
LyXCursor & selStart(); CursorSlice & selStart();
LyXCursor & selEnd(); CursorSlice & selEnd();
}; };
#endif #endif