1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
1999-10-25 18:52:23 +00:00
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright (C) 1997-1999 The LyX Team.
|
|
|
|
*
|
|
|
|
* ======================================================*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-25 18:52:23 +00:00
|
|
|
#ifndef BACK_STACK_H
|
|
|
|
#define BACK_STACK_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#include "LString.h"
|
|
|
|
|
|
|
|
// Created by Alejandro Aguilar Sierra, 970806
|
|
|
|
|
|
|
|
/** Utility to get back from a reference or from a child document.
|
|
|
|
*/
|
|
|
|
class BackStack {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
struct BackStackItem {
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
void set(string f, int xx, int yy) {
|
1999-09-27 18:44:28 +00:00
|
|
|
fname = f; x = xx; y = yy;
|
|
|
|
}
|
|
|
|
/// Filename
|
1999-10-02 16:21:10 +00:00
|
|
|
string fname;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Cursor x-position
|
|
|
|
int x;
|
|
|
|
/// Cursor y-position
|
1999-10-25 18:52:23 +00:00
|
|
|
int y;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
///
|
1999-10-25 21:51:41 +00:00
|
|
|
BackStack(int n) : item(new BackStackItem[n]) , i(0), imax(n) {}
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
~BackStack() {
|
|
|
|
delete[] item;
|
|
|
|
}
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
void push(string f, int x, int y) {
|
1999-10-25 18:52:23 +00:00
|
|
|
if (i < imax)
|
1999-09-27 18:44:28 +00:00
|
|
|
item[i++].set(f, x, y);
|
|
|
|
}
|
|
|
|
///
|
1999-10-25 18:52:23 +00:00
|
|
|
string & pop(int *x, int *y) {
|
|
|
|
if (i > 0) i--;
|
1999-09-27 18:44:28 +00:00
|
|
|
*x = item[i].x;
|
|
|
|
*y = item[i].y;
|
|
|
|
return item[i].fname;
|
|
|
|
}
|
1999-10-25 18:52:23 +00:00
|
|
|
///
|
|
|
|
bool empty() const {
|
|
|
|
return i == 0;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
private:
|
|
|
|
///
|
|
|
|
BackStackItem *item;
|
|
|
|
///
|
|
|
|
int i;
|
|
|
|
///
|
|
|
|
int imax;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|