1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/*
|
|
|
|
* File: math_cursor.h
|
|
|
|
* Purpose: Declaration of interaction classes for mathed
|
|
|
|
* Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
|
|
|
|
* Created: January 1996
|
|
|
|
* Description: MathCursor control all user interaction
|
|
|
|
*
|
|
|
|
* Dependencies: Xlib, XForms
|
|
|
|
*
|
2000-03-09 03:36:48 +00:00
|
|
|
* Copyright: 1996, Alejandro Aguilar Sierra
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
|
|
|
* You are free to use and modify this code under the terms of
|
|
|
|
* the GNU General Public Licence version 2 or later.
|
|
|
|
*/
|
|
|
|
|
1999-11-15 11:06:41 +00:00
|
|
|
#ifndef MATH_CURSOR
|
|
|
|
#define MATH_CURSOR
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "math_defs.h"
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
class MathInset;
|
2001-02-13 13:28:32 +00:00
|
|
|
class MathFuncInset;
|
2001-06-25 00:06:33 +00:00
|
|
|
class MathScriptInset;
|
|
|
|
class InsetFormulaBase;
|
|
|
|
class MathArray;
|
|
|
|
class MathXArray;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
/// This is the external interface of Math's subkernel
|
|
|
|
class MathCursor {
|
2001-02-13 13:28:32 +00:00
|
|
|
public:
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
explicit MathCursor(InsetFormulaBase *);
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
void insert(char, MathTextCodes t = LM_TC_MIN);
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
void insert(MathInset *);
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
|
|
|
void Home();
|
|
|
|
///
|
|
|
|
void End();
|
|
|
|
///
|
|
|
|
bool Right(bool sel = false);
|
|
|
|
///
|
|
|
|
bool Left(bool sel = false);
|
|
|
|
///
|
|
|
|
bool Up(bool sel = false);
|
|
|
|
///
|
|
|
|
bool Down(bool sel = false);
|
2001-06-25 00:06:33 +00:00
|
|
|
/// Put the cursor in the first position
|
|
|
|
void first();
|
|
|
|
/// Put the cursor in the last position
|
|
|
|
void last();
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
2001-06-27 14:10:35 +00:00
|
|
|
bool plainRight();
|
|
|
|
///
|
2001-02-13 13:28:32 +00:00
|
|
|
void Delete();
|
|
|
|
///
|
|
|
|
void DelLine();
|
2001-06-25 00:06:33 +00:00
|
|
|
/// This is in pixels from (maybe?) the top of inset
|
2001-02-13 13:28:32 +00:00
|
|
|
void SetPos(int, int);
|
|
|
|
///
|
2001-02-13 19:10:18 +00:00
|
|
|
void GetPos(int & x, int & y);
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
MathInset * par() const;
|
|
|
|
/// return the next enclosing par of the given type and the cursor's
|
|
|
|
//index in it
|
|
|
|
MathInset * enclosing(MathInsetTypes, int &) const;
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
InsetFormulaBase const * formula();
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
int pos() const;
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
|
|
|
void Interpret(string const &);
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
void SetSize(MathStyles);
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
bool toggleLimits();
|
2001-02-13 13:28:32 +00:00
|
|
|
/// Set accent: if argument = 0 it's considered consumed
|
|
|
|
void setAccent(int ac = 0);
|
|
|
|
/// Returns last accent
|
|
|
|
int getAccent() const;
|
|
|
|
///
|
|
|
|
// Macro mode methods
|
|
|
|
void MacroModeOpen();
|
|
|
|
///
|
|
|
|
void MacroModeClose();
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
bool InMacroMode() const;
|
2001-02-13 13:28:32 +00:00
|
|
|
|
|
|
|
// Local selection methods
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
bool Selection() const;
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
|
|
|
void SelCopy();
|
|
|
|
///
|
|
|
|
void SelCut();
|
|
|
|
///
|
|
|
|
void SelDel();
|
|
|
|
///
|
|
|
|
void SelPaste();
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
void SelHandle(bool);
|
|
|
|
///
|
2001-02-13 13:28:32 +00:00
|
|
|
void SelStart();
|
|
|
|
///
|
|
|
|
void SelClear();
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
void SelGetArea(int * xp, int * yp, int & n);
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
2001-02-13 19:10:18 +00:00
|
|
|
void clearLastCode();
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
void setLastCode(MathTextCodes t);
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
2001-07-03 07:56:55 +00:00
|
|
|
void handleFont(MathTextCodes t);
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
MathTextCodes getLastCode() const;
|
|
|
|
///
|
|
|
|
int idx() const { return idx_; }
|
|
|
|
///
|
|
|
|
void idxRight();
|
|
|
|
///
|
|
|
|
void pullArg();
|
|
|
|
///
|
|
|
|
bool isInside(MathInset *) const;
|
|
|
|
///
|
|
|
|
MathTextCodes nextCode() const;
|
|
|
|
///
|
|
|
|
MathTextCodes prevCode() const;
|
|
|
|
///
|
|
|
|
void selArray(MathArray &) const;
|
2001-06-27 14:10:35 +00:00
|
|
|
///
|
|
|
|
char valign() const;
|
|
|
|
///
|
|
|
|
char halign() const;
|
|
|
|
///
|
|
|
|
int col() const;
|
|
|
|
///
|
|
|
|
int row() const;
|
|
|
|
|
2001-04-24 16:13:38 +00:00
|
|
|
//protected:
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
|
|
|
bool macro_mode;
|
|
|
|
|
|
|
|
// Selection stuff
|
|
|
|
///
|
|
|
|
bool selection;
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
int anchor_;
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
int cursor_;
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
int idx_;
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
MathInset * par_;
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
InsetFormulaBase * const formula_;
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
void doAccent(char c, MathTextCodes t);
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
void doAccent(MathInset * p);
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
|
|
|
int accent;
|
|
|
|
///
|
|
|
|
int nestaccent[8];
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
MathTextCodes lastcode;
|
|
|
|
|
|
|
|
///
|
|
|
|
MathArray & array() const;
|
|
|
|
///
|
|
|
|
MathXArray & xarray() const;
|
|
|
|
|
|
|
|
///
|
|
|
|
MathStyles style() const;
|
2001-06-27 14:10:35 +00:00
|
|
|
/// Make sure cursor position is valid
|
2001-06-25 00:06:33 +00:00
|
|
|
void normalize() const;
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-06-27 14:10:35 +00:00
|
|
|
/// Enter a new MathInset from the front or the back
|
|
|
|
void push(MathInset * par, bool first);
|
|
|
|
/// Leave current MathInset
|
|
|
|
bool pop();
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
private:
|
2001-06-25 00:06:33 +00:00
|
|
|
/// Description of a position
|
|
|
|
struct MathIter {
|
|
|
|
MathInset * par_;
|
|
|
|
int idx_;
|
|
|
|
int cursor_;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// MathPath
|
|
|
|
std::vector<MathIter> path_;
|
|
|
|
|
|
|
|
///
|
|
|
|
int last() const;
|
|
|
|
///
|
|
|
|
MathInset * parInset(int i) const;
|
|
|
|
///
|
|
|
|
void seldump(char const * str) const;
|
|
|
|
///
|
|
|
|
void dump(char const * str) const;
|
|
|
|
|
|
|
|
///
|
|
|
|
int xpos() const;
|
|
|
|
///
|
|
|
|
void gotoX(int x);
|
|
|
|
|
|
|
|
///
|
|
|
|
bool nextIsInset() const;
|
|
|
|
///
|
|
|
|
bool nextIsActive() const;
|
|
|
|
///
|
|
|
|
bool prevIsInset() const;
|
|
|
|
///
|
|
|
|
bool prevIsActive() const;
|
|
|
|
///
|
|
|
|
bool IsFont() const;
|
|
|
|
///
|
|
|
|
bool IsScript() const;
|
|
|
|
///
|
|
|
|
void merge(MathArray const & arr);
|
|
|
|
///
|
|
|
|
MathInset * nextInset() const;
|
|
|
|
///
|
|
|
|
MathInset * nextActiveInset() const;
|
|
|
|
///
|
|
|
|
MathInset * prevInset() const;
|
|
|
|
///
|
|
|
|
MathInset * prevActiveInset() const;
|
|
|
|
///
|
2001-06-27 14:10:35 +00:00
|
|
|
MathScriptInset * nearbyScriptInset() const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
|
|
|
MathFuncInset * imacro;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
extern MathCursor * mathcursor;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#endif
|