Source Code (Use browser search to find items of interest.)

Class Index

klyx'TexRow (./klyx/src/texrow.h:18)

class TexRow {
public:
	///
	TexRow() {
		count = 0;
		next = 0;
		lastpar = 0;
		lastpos = -1;
	}
	///
	~TexRow() {
		reset();
	}

	/// Clears structure
	void reset();

	/// Define what paragraph and position the next row will represent
	void start(LyXParagraph *par, int pos);

	/// Insert node when line is completed
	void newline();

	/// Returns paragraph id and position from a row number
	void getIdFromRow(int row, int &id, int &pos);

	/// Appends another TexRow
	TexRow & operator+=(const TexRow &);

private:
	/// Linked list of items
	struct TexRow_Item {
		///
		TexRow_Item() {
			id = -1;
			pos = -1;
			next = 0;
			rownumber = 0;
		}

		///
		int id;
		///
		int pos;
		///
		int rownumber;
		///
		TexRow_Item *next;
	};
	///
	unsigned int count;
	///
	TexRow_Item *next;
	/// Last paragraph
	LyXParagraph * lastpar;
	/// Last position
	int lastpos;
	
};

klyx'TexRow::reset() (./klyx/src/texrow.C:23)

void TexRow::reset()
{
	TexRow_Item *current, *iter = next;
	while (iter) {
		// Iterate through the list deleting as you go.
		// A bit easier to debug than recursive deletion.
		current = iter;
		iter = iter->next;
		delete current;
	}
	count = 0;
	next = 0;
	lastpar = 0;
	lastpos = -1;
}

// Defines paragraph and position for the beginning of this row

klyx'TexRow::start() (./klyx/src/texrow.C:40)

void TexRow::start(LyXParagraph *par, int pos) {
	lastpar = par;
	lastpos = pos;
}

// Insert node when line is completed

klyx'TexRow::newline() (./klyx/src/texrow.C:46)

void TexRow::newline()
{
	TexRow_Item *tmp = new TexRow_Item;
	tmp->pos = lastpos;
	
	if (lastpar)
		tmp->id = lastpar->GetID();
	else
		tmp->id = -1;

	// Inserts at the beginning of the list
	tmp->next = next;
	next = tmp;
	count++;
	tmp->rownumber = count;
}



klyx'TexRow::getIdFromRow() (./klyx/src/texrow.C:64)

void TexRow::getIdFromRow(int row, int &id, int &pos)
{
	TexRow_Item *tmp = next;
	while (tmp && tmp->rownumber != row) {
		tmp = tmp->next;
	}
	if (tmp) {
		TexRow_Item *tmp2 = next;
		// Increase the pos of all rows with the
		// same id (and where the pos is larger)
		// to avoid putting errorinsets at the
		// same pos.
		while (tmp2) {
			if (tmp2 != tmp &&
			    tmp2->id == tmp->id &&
			    tmp2->pos >= tmp->pos)
				tmp2->pos++;
			tmp2 = tmp2->next;
		}
		id = tmp->id;
		pos = tmp->pos;
	} else {
		id = -1;
		pos = 0;
	}
}