#define LYXTEXT_H
#include "bufferview_funcs.h"
-#include "cursor_slice.h"
#include "Bidi.h"
-#include "layout.h"
+#include "dispatchresult.h"
#include "lyxfont.h"
-#include "lyxtextclass.h"
+#include "layout.h"
+#include "lyxlayout_ptr_fwd.h"
#include "ParagraphList_fwd.h"
#include "RowList_fwd.h"
-#include "insets/inset.h"
-
#include <iosfwd>
class Buffer;
class BufferParams;
class BufferView;
+class CursorSlice;
class Dimension;
+class InsetBase;
+class InsetOld_code;
+class FuncRequest;
class LColor_color;
-class CursorSlice;
+class LCursor;
+class LyXTextClass;
class MetricsInfo;
+class PainterInfo;
class Paragraph;
class Row;
class Spacing;
class VSpace;
-// The structure that keeps track of the selections set.
-struct Selection {
- Selection()
- : set_(false), mark_(false)
- {}
- bool set() const {
- return set_;
- }
- void set(bool s) {
- set_ = s;
- }
- bool mark() const {
- return mark_;
- }
- void mark(bool m) {
- mark_ = m;
- }
-private:
- bool set_; // former selection
- bool mark_; // former mark_set
-};
-
-
/// This class encapsulates the main text data and operations in LyX
class LyXText {
public:
- /// Constructor
+ /// constructor
LyXText(BufferView *, bool ininset);
///
void init(BufferView *);
-
/// update y coordinate cache of all paragraphs
void updateParPositions();
///
ParagraphList::iterator end);
/// rebreaks the given par
void redoParagraph(ParagraphList::iterator pit);
-
/// rebreaks the cursor par
void redoParagraph();
///
std::string getStringToIndex();
- /** insert a character, moves all the following breaks in the
- same Paragraph one to the right and make a little rebreak
- */
+ /// insert a character at cursor position
void insertChar(char c);
- ///
- void insertInset(InsetOld * inset);
+ /// insert an inset at cursor position
+ void insertInset(InsetBase * inset);
/// a full rebreak of the whole text
void fullRebreak();
void draw(PainterInfo & pi, int x, int y) const;
/// try to handle that request
- DispatchResult dispatch(FuncRequest const & cmd);
-
+ DispatchResult dispatch(LCursor & cur, FuncRequest const & cmd);
+ /// access to out BufferView. This should go...
BufferView * bv();
-
+ /// access to out BufferView. This should go...
BufferView * bv() const;
- friend class LyXScreen;
-
/// returns an iterator pointing to a cursor paragraph
ParagraphList::iterator getPar(CursorSlice const & cursor) const;
///
void getWord(CursorSlice & from, CursorSlice & to, lyx::word_location const);
/// just selects the word the cursor is in
void selectWord(lyx::word_location loc);
- /// returns the inset at cursor (if it exists), 0 otherwise
- InsetOld * getInset() const;
/// accept selected change
void acceptChange();
-
/// reject selected change
void rejectChange();
///
void setCursorFromCoordinates(CursorSlice &, int x, int y);
///
+ void edit(LCursor & cur, int x, int y);
+ ///
void cursorUp(bool selecting = false);
///
void cursorDown(bool selecting = false);
* characters to the right. No safety checks.
*/
void setSelectionRange(lyx::pos_type length);
-
/** simple replacing. The font of the first selected character
is used
*/
void insertStringAsParagraphs(std::string const & str);
/// Find next inset of some specified type.
- bool gotoNextInset(std::vector<InsetOld::Code> const & codes,
+ bool gotoNextInset(std::vector<InsetOld_code> const & codes,
std::string const & contents = std::string());
///
- void gotoInset(std::vector<InsetOld::Code> const & codes,
+ void gotoInset(std::vector<InsetOld_code> const & codes,
bool same_content);
///
- void gotoInset(InsetOld::Code code, bool same_content);
+ void gotoInset(InsetOld_code code, bool same_content);
/// current max text width
int textWidth() const;
/// updates all counters
void updateCounters();
/// Returns an inset if inset was hit, or 0 if not.
- InsetOld * checkInsetHit(int x, int y);
+ InsetBase * checkInsetHit(int x, int y);
///
int singleWidth(ParagraphList::iterator pit, lyx::pos_type pos) const;
* the cursor and when creating a visible row */
void prepareToPrint(ParagraphList::iterator pit, Row & row) const;
- //
- // special owner functions
- ///
+ /// access to our paragraphs
ParagraphList & paragraphs() const;
-
/// return true if this is owned by an inset.
bool isInInset() const;
-
- ///
- ParagraphList::iterator firstPar() const;
- ///
- ParagraphList::iterator lastPar() const;
- ///
- ParagraphList::iterator endPar() const;
/// return first row of text
RowList::iterator firstRow() const;
///
int descent() const;
///
- int cursorX() const;
- ///
- int cursorY() const;
- ///
int cursorX(CursorSlice const & cursor) const;
///
int cursorY(CursorSlice const & cursor) const;
- /// the topmost cursor slice
+ /// the current cursor slice
CursorSlice & cursor();
- /// the topmost cursor slice
+ /// the current cursor slice
CursorSlice const & cursor() const;
- /// access to the selection anchor
- CursorSlice & anchor();
- /// access to the selection anchor
- CursorSlice const & anchor() const;
-
- ///
- void setSelection();
- ///
- void clearSelection();
- ///
- CursorSlice const & selStart() const;
- ///
- CursorSlice const & selEnd() const;
- ///
- CursorSlice & selStart();
- ///
- CursorSlice & selEnd();
+ friend class LyXScreen;
public:
-/** The cursor.
- Later this variable has to be removed. There should be no internal
- cursor in a text (and thus not in a buffer). By keeping this it is
- (I think) impossible to have several views with the same buffer, but
- the cursor placed at different places.
- [later]
- Since the LyXText now has been moved from Buffer to BufferView
- it should not be absolutely needed to move the cursor...
- [even later]
- Nevertheless, it should still be moved, in order to keep classes
- and interdependencies small.
- */
- // the other end of the selection
- CursorSlice anchor_;
- //
- Selection selection;
-
///
int height;
///
/// sets row.end to the pos value *after* which a row should break.
/// for example, the pos after which isNewLine(pos) == true
void rowBreakPoint(ParagraphList::iterator pit, Row & row) const;
-
/// sets row.witdh to the minimum space a row needs on the screen in pixel
void fill(ParagraphList::iterator pit, Row & row, int workwidth) const;
-
- /**
- * returns the minimum space a manual label needs on the
- * screen in pixels
- */
+ /// the minimum space a manual label needs on the screen in pixels
int labelFill(ParagraphList::iterator pit, Row const & row) const;
-
/// FIXME
int labelEnd(ParagraphList::iterator pit) const;
};
/// return the default height of a row in pixels, considering font zoom
-extern int defaultRowHeight();
+int defaultRowHeight();
///
std::string expandLabel(LyXTextClass const & textclass,