The "I want this in now" patch.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7018 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2003-05-23 07:44:09 +00:00
parent 595c578923
commit 314b4903ac
16 changed files with 91 additions and 221 deletions

View File

@ -331,142 +331,6 @@ bool BufferView::insertLyXFile(string const & filen)
}
bool BufferView::removeAutoInsets()
{
// keep track of which pos and par the cursor was on
Paragraph * cursor_par = &*text->cursor.par();
Paragraph * cursor_par_prev = cursor_par ? cursor_par->previous() : 0;
Paragraph * cursor_par_next = cursor_par ? cursor_par->next() : 0;
pos_type cursor_pos = text->cursor.pos();
bool found = false;
// Trap the deletion of the paragraph the cursor is in.
// Iterate until we find a paragraph that won't be immediately deleted.
// In reality this should mean we only execute the body of the while
// loop once at most. However for safety we iterate rather than just
// make this an if () conditional.
while ((cursor_par_prev || cursor_par_next)
&& text->setCursor(
cursor_par_prev ? cursor_par_prev : cursor_par_next,
0)) {
// We just removed cursor_par so have to fix the "cursor"
if (cursor_par_prev) {
// '.' = cursor_par
// a -> a.
// .
cursor_par = cursor_par_prev;
cursor_pos = cursor_par->size();
} else {
// . -> .a
// a
cursor_par = cursor_par_next;
cursor_pos = 0;
}
cursor_par_prev = cursor_par->previous();
cursor_par_next = cursor_par->next();
}
// Iterate through the paragraphs removing autoDelete insets as we go.
// If the paragraph ends up empty after all the autoDelete insets are
// removed that paragraph will be removed by the next setCursor() call.
ParIterator it = buffer()->par_iterator_begin();
ParIterator end = buffer()->par_iterator_end();
for (; it != end; ++it) {
Paragraph * par = &*(*it);
Paragraph * par_prev = par ? par->previous() : 0;
bool removed = false;
if (text->setCursor(par, 0)
&& cursor_par == par_prev) {
// The previous setCursor line was deleted and that
// was the cursor_par line. This can only happen if an
// error box was the sole item on cursor_par.
// It is possible for cursor_par_prev to be stray if
// the line it pointed to only had a error box on it
// so we have to set it to a known correct value.
// This is often the same value it already had.
cursor_par_prev = par->previous();
if (cursor_par_prev) {
// '|' = par, '.' = cursor_par, 'E' = error box
// First step below may occur before while{}
// a |a a a a.
// E -> .E -> |.E -> . -> |b
// . b b |b
// b
cursor_par = cursor_par_prev;
cursor_pos = cursor_par_prev->size();
cursor_par_prev = cursor_par->previous();
// cursor_par_next remains the same
} else if (cursor_par_next) {
// First step below may occur before while{}
// .
// E -> |.E -> |. -> . -> .|a
// a a a |a
cursor_par = cursor_par_next;
cursor_pos = 0;
// cursor_par_prev remains unset
cursor_par_next = cursor_par->next();
} else {
// I can't find a way to trigger this
// so it should be unreachable code
// unless the buffer is corrupted.
lyxerr << "BufferView::removeAutoInsets() is bad\n";
}
}
InsetList::iterator pit = par->insetlist.begin();
InsetList::iterator pend = par->insetlist.end();
while (pit != pend) {
if (pit.getInset()->autoDelete()) {
removed = true;
pos_type const pos = pit.getPos();
par->erase(pos);
// We just invalidated par's inset iterators so
// we get the next valid iterator position
pit = par->insetlist.insetIterator(pos);
// and ensure we have a valid end iterator.
pend = par->insetlist.end();
if (cursor_par == par) {
// update the saved cursor position
if (cursor_pos > pos)
--cursor_pos;
}
} else {
++pit;
}
}
if (removed) {
found = true;
text->redoParagraph();
}
}
// It is possible that the last line is empty if it was cursor_par
// and/or only had an error inset on it. So we set the cursor to the
// start of the doc to force its removal and ensure a valid saved cursor
if (text->setCursor(&*text->ownerParagraphs().begin(), 0)
&& 0 == cursor_par_next) {
cursor_par = cursor_par_prev;
cursor_pos = cursor_par->size();
} else if (cursor_pos > cursor_par->size()) {
// Some C-Enter lines were removed by the setCursor call which
// then invalidated cursor_pos. It could still be "wrong" because
// the cursor may appear to have jumped but since we collapsed
// some C-Enter lines this should be a reasonable compromise.
cursor_pos = cursor_par->size();
}
// restore the original cursor in its corrected location.
text->setCursorIntern(cursor_par, cursor_pos);
return found;
}
void BufferView::resetErrorList()
{
pimpl_->errorlist_.clear();

View File

@ -153,8 +153,6 @@ public:
/// redo last action
void redo();
/// removes all autodeletable insets
bool removeAutoInsets();
/// get the stored error list
ErrorList const & getErrorList() const;
/// clears the stored error list

View File

@ -1,3 +1,23 @@
2003-05-23 Lars Gullik Bjønnes <larsbj@gullik.net>
* undo_funcs.C (textHandleUndo): comment out next/previous stuff
(createUndo): ditto
(textUndoOrRedo): comment out a currently unused var.
* paragraph.h (NO_NEXT): enable NO_NEXT
* lyxfunc.C (dispatch): remove LFUN_REMOVEERRORS
* lfuns.h: remove LFUN_REMOVEERRORS and adjust lfun numbers.
* exporter.C (Export): adjust for removeAutoInsets removal.
* buffer.C (runChktex): adjust for removeAutoInsets removal.
* LyXAction.C (init): remove LFUN_REMOVEERRORS
* BufferView.[Ch] (removeAutoInsets): delete function
2003-05-22 Angus Leeming <leeming@lyx.org>
* latexrunparams.h: add fragile and use_babel variables.

View File

@ -145,7 +145,6 @@ void LyXAction::init()
{ LFUN_END_OF_SENTENCE, "end-of-sentence-period-insert", Noop },
{ LFUN_ENVIRONMENT_INSERT, "environment-insert", Noop },
{ LFUN_GOTOERROR, "error-next", ReadOnly },
{ LFUN_REMOVEERRORS, "error-remove-all", ReadOnly },
{ LFUN_INSET_ERT, "ert-insert", Noop },
{ LFUN_FILE_INSERT, "file-insert", Noop },
{ LFUN_FILE_INSERT_ASCII, "file-insert-ascii", Noop },

View File

@ -1958,9 +1958,6 @@ int Buffer::runChktex()
Path p(path); // path to LaTeX file
users->owner()->message(_("Running chktex..."));
// Remove all error insets
bool const removedErrorInsets = users->removeAutoInsets();
// Generate the LaTeX file if neccessary
LatexRunParams runparams;
runparams.flavor = LatexRunParams::LATEX;
@ -1981,13 +1978,6 @@ int Buffer::runChktex()
users->showErrorList(_("ChkTeX"));
}
// if we removed error insets before we ran chktex or if we inserted
// error insets after we ran chktex, this must be run:
if (removedErrorInsets || res) {
#warning repaint needed here, or do you mean update() ?
users->repaint();
users->fitCursor();
}
users->owner()->busy(false);
return res;

View File

@ -33,14 +33,6 @@ bool Exporter::Export(Buffer * buffer, string const & format,
// from that the removal of auto insets is best done here. This ensures
// we always have a clean buffer for inserting errors found during export.
BufferView * bv = buffer->getUser();
if (bv) {
// Remove all error insets
if (bv->removeAutoInsets()) {
#warning repaint() or update() or nothing ?
bv->repaint();
bv->fitCursor();
}
}
string backend_format;
LatexRunParams runparams;

View File

@ -1,3 +1,7 @@
2003-05-23 Lars Gullik Bjønnes <larsbj@gullik.net>
* Toolbar_pimpl.C (displayToolbar): comment out unsused parameters.
2003-05-21 Alfredo Braunstein <abraunst@libero.it>
* FormBase.[Ch]:

View File

@ -59,8 +59,8 @@ Toolbar::Pimpl::toolbarItem::~toolbarItem()
/// Display toolbar, not implemented. But moved out of line so that
/// linking will work properly.
void Toolbar::Pimpl::displayToolbar(ToolbarBackend::Toolbar const & tb,
bool show)
void Toolbar::Pimpl::displayToolbar(ToolbarBackend::Toolbar const & /*tb*/,
bool /*show*/)
{}

View File

@ -1,3 +1,7 @@
2003-05-23 Lars Gullik Bjønnes <larsbj@gullik.net>
* inseterror.C (localDispatch): comment out unused var.
2003-05-22 Angus Leeming <leeming@lyx.org>
* inset*.[Ch] (latex): no longer has a fragile arg. Data is now passed

View File

@ -41,7 +41,7 @@ InsetError::~InsetError()
dispatch_result InsetError::localDispatch(FuncRequest const & cmd)
{
dispatch_result result = UNDISPATCHED;
// UNUSED: dispatch_result result = UNDISPATCHED;
switch (cmd.action) {
case LFUN_MOUSE_RELEASE:

View File

@ -722,7 +722,7 @@ Inset::RESULT InsetTabular::localDispatch(FuncRequest const & cmd)
BufferView * bv = cmd.view();
if (cmd.action == LFUN_INSET_EDIT) {
if (!bv->lockInset(this)) {
lyxerr[Debug::INSETTEXT] << "InsetTabular::Cannot lock inset" << endl;
return DISPATCHED;

View File

@ -243,97 +243,96 @@ enum kb_action {
LFUN_REF_GOTO, // Ale 970806
LFUN_PARENTINSERT, // Ale 970813
// 180
LFUN_REMOVEERRORS, // Asger 970906
LFUN_LDOTS, // Asger 970929
LFUN_END_OF_SENTENCE, // Asger 970929
LFUN_TOGGLECURSORFOLLOW, // ARRae 971202
LFUN_RUNCHKTEX, // Asger 971030
// 185
LFUN_HTMLURL, // CFO-G 971121
// 185
LFUN_URL, // CFO-G 971121
LFUN_WORDFINDFORWARD, // Etienne 980216
LFUN_WORDFINDBACKWARD, // Etienne 980220
LFUN_APPENDIX, // ettrich 980505
// 190
LFUN_IMPORT, // Asger 980724
// 190
LFUN_MENU_SEPARATOR, // Asger 990220
LFUN_SEQUENCE, // Andre' 991111
LFUN_DIALOG_PREFERENCES, // ARRae 20000726
LFUN_SAVEPREFERENCES, // Lgb 991127
// 195
LFUN_HELP_OPEN, // Jug 990627
// 195
LFUN_DATE_INSERT, // jdblair 20000131
LFUN_LANGUAGE, // Dekel 20000203
LFUN_INSET_ERT, // Jug 20000218
LFUN_INSET_FOOTNOTE, // Jug 20000307
// 200
LFUN_PARAGRAPH_SPACING, // Lgb 20000411
// 200
LFUN_TABULAR_INSERT, // Jug 20000412
LFUN_LOFVIEW, // Dekel 20000519
LFUN_LOTVIEW, // Dekel 20000519
LFUN_LOAVIEW, // Dekel 20000519
// 205
LFUN_SET_COLOR, // SLior 20000611
// 205
LFUN_INSET_MARGINAL, // Lgb 20000626
LFUN_INSET_MINIPAGE, // Lgb 20000627
LFUN_INSET_FLOAT, // Lgb 20000627
LFUN_INSET_WIDE_FLOAT, // Lgb 20010531
// 210
LFUN_INSET_CAPTION, // Lgb 20000718
// 210
LFUN_SWITCHBUFFER,
LFUN_TABULAR_FEATURE, // Jug 20000728
LFUN_LAYOUT_TABULAR, // Jug 20000731
LFUN_SCROLL_INSET, // Jug 20000801
// 215
LFUN_UPDATE, // Dekel 20000805
// 215
LFUN_INDEX_INSERT, // Angus 20000803
LFUN_SCREEN_FONT_UPDATE, // ARRae 20000813
LFUN_GOTO_PARAGRAPH, // Dekel 20000826
LFUN_REFERENCE_GOTO, // Dekel 20010114
// 220
LFUN_BOOKMARK_SAVE, // Dekel 20010127
// 220
LFUN_BOOKMARK_GOTO, // Dekel 20010127
LFUN_SELECT_FILE_SYNC, // Levon 20010214
LFUN_MESSAGE, // Lgb 20010408
LFUN_TRANSPOSE_CHARS, // Lgb 20010425
// 225
LFUN_ESCAPE, // Lgb 20010517
// 225
LFUN_HELP_ABOUTLYX, // Edwin 20010712
LFUN_THESAURUS_ENTRY, // Levon 20010720
LFUN_HELP_TEXINFO, // Herbert 20011001
LFUN_FORKS_SHOW, // Angus 16 Feb 2002
// 230
LFUN_FORKS_KILL, // Angus 16 Feb 2002
// 230
LFUN_TOOLTIPS_TOGGLE, // Angus 8 Mar 2002
LFUN_INSET_OPTARG, // Martin 12 Aug 2002
LFUN_MOUSE_PRESS, // André 9 Aug 2002
LFUN_MOUSE_MOTION, // André 9 Aug 2002
// 235
LFUN_MOUSE_RELEASE, // André 9 Aug 2002
// 235
LFUN_MOUSE_DOUBLE, // André 9 Aug 2002
LFUN_MOUSE_TRIPLE, // André 9 Aug 2002
LFUN_INSET_EDIT, // André 16 Aug 2002
LFUN_INSET_WRAP, // Dekel 7 Apr 2002
// 240
LFUN_TRACK_CHANGES, // Levon 20021001 (cool date !)
// 240
LFUN_MERGE_CHANGES, // Levon 20021016
LFUN_ACCEPT_CHANGE, // Levon 20021016
LFUN_REJECT_CHANGE, // Levon 20021016
LFUN_ACCEPT_ALL_CHANGES, // Levon 20021016
// 245
LFUN_REJECT_ALL_CHANGES, // Levon 20021016
// 245
LFUN_INSERT_BIBITEM, // André 14 Feb 2003
LFUN_DIALOG_SHOW_NEW_INSET,
LFUN_DIALOG_SHOW_NEXT_INSET,
LFUN_DIALOG_UPDATE,
// 250
LFUN_DIALOG_HIDE,
// 250
LFUN_DIALOG_DISCONNECT_INSET,
LFUN_INSET_APPLY,
LFUN_INSET_INSERT,
LFUN_INSET_MODIFY,
// 255
LFUN_INSET_DIALOG_UPDATE,
// 255
LFUN_INSET_SETTINGS,
LFUN_PARAGRAPH_APPLY,
LFUN_PARAGRAPH_UPDATE,

View File

@ -490,7 +490,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
case LFUN_INSET_SETTINGS: {
disable = true;
UpdatableInset * inset = view()->theLockingInset();
if (!inset)
break;
@ -1126,14 +1126,6 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
owner->getDialogs().showSearch();
break;
case LFUN_REMOVEERRORS:
if (view()->removeAutoInsets()) {
#warning repaint() or update() or nothing ?
view()->repaint();
view()->fitCursor();
}
break;
case LFUN_DEPTH_MIN:
changeDepth(view(), TEXT(false), DEC_DEPTH, false);
owner->view_state_changed();

View File

@ -34,7 +34,7 @@ class TexRow;
// Define this if you want to try out the new storage container for
// paragraphs. (Lgb)
// This is non working and far from finished.
// #define NO_NEXT 1
#define NO_NEXT 1
/// A Paragraph holds all text, attributes and insets in a text paragraph
class Paragraph {

View File

@ -427,10 +427,10 @@ LyXText::setLayout(LyXCursor & cur, LyXCursor & sstart_cur,
// set layout over selection and make a total rebreak of those paragraphs
void LyXText::setLayout(string const & layout)
{
LyXCursor tmpcursor = cursor; // store the current cursor
LyXCursor tmpcursor = cursor; // store the current cursor
// if there is no selection just set the layout
// of the current paragraph
// of the current paragraph
if (!selection.set()) {
selection.start = cursor; // dummy selection
selection.end = cursor;

View File

@ -145,18 +145,21 @@ bool textHandleUndo(BufferView * bv, Undo & undo)
// Thread the end of the undo onto the par in front if any.
if (!undo.pars.empty()) {
undo.pars.back()->next(&**behind);
if (behind != end)
(&**behind)->previous(undo.pars.back());
#warning FIXME
//undo.pars.back()->next(&**behind);
//if (behind != end)
//(&**behind)->previous(undo.pars.back());
}
// Put the new stuff in the list if there is one.
Paragraph * undopar = undo.pars.empty() ? 0 : undo.pars.front();
if (!undo.pars.empty()) {
undo.pars.front()->previous(&**before);
if (before != end)
(&**before)->next(undopar);
else {
#warning FIXME
//undo.pars.front()->previous(&**before);
if (before != end) {
#warning FIXME
//(&**before)->next(undopar);
} else {
int id = undoParagraphs(bv, undo.number_of_inset_id).front().id();
ParIterator op = bv->buffer()->getParFromID(id);
if (op != end && op->inInset()) {
@ -254,8 +257,9 @@ bool textHandleUndo(BufferView * bv, Undo & undo)
// And here it's safe enough to delete all removed paragraphs.
vector<Paragraph *>::iterator pit = deletelist.begin();
for(; pit != deletelist.end(); ++pit) {
(*pit)->previous(0);
(*pit)->next(0);
#warning FIXME
//(*pit)->previous(0);
//(*pit)->next(0);
delete (*pit);
}
@ -280,8 +284,9 @@ bool createUndo(BufferView * bv, Undo::undo_kind kind,
int behind_number = -1;
int inset_id = -1;
if (first->previous())
before_number = first->previous()->id();
#warning FIXME
//if (first->previous())
// before_number = first->previous()->id();
if (behind)
behind_number = behind->id();
if (first->inInset())
@ -312,28 +317,31 @@ bool createUndo(BufferView * bv, Undo::undo_kind kind,
Paragraph const * end = 0;
if (behind)
end = behind->previous();
else {
if (behind) {
#warning FIXME
//end = behind->previous();
}else {
end = first;
while (end->next())
end = end->next();
#warning FIXME
//while (end->next())
// end = end->next();
}
if (first && end && (first != end->next()) &&
((before_number != behind_number) ||
((before_number < 0) && (behind_number < 0))))
{
undo_pars.push_back(new Paragraph(*first, true));
for (Paragraph * tmppar = first; tmppar != end && tmppar->next(); ) {
tmppar = tmppar->next();
undo_pars.push_back(new Paragraph(*tmppar, true));
size_t const n = undo_pars.size();
undo_pars[n - 2]->next(undo_pars[n - 1]);
undo_pars[n - 1]->previous(undo_pars[n - 2]);
}
undo_pars.back()->next(0);
}
#warning FIXME
// if (first && end && (first != end->next()) &&
// ((before_number != behind_number) ||
// ((before_number < 0) && (behind_number < 0))))
// {
// undo_pars.push_back(new Paragraph(*first, true));
// for (Paragraph * tmppar = first; tmppar != end && tmppar->next(); ) {
// tmppar = tmppar->next();
// undo_pars.push_back(new Paragraph(*tmppar, true));
// size_t const n = undo_pars.size();
// undo_pars[n - 2]->next(undo_pars[n - 1]);
// undo_pars[n - 1]->previous(undo_pars[n - 2]);
// }
// undo_pars.back()->next(0);
// }
// A memory optimization: Just store the layout
// information when only edit.
@ -359,9 +367,9 @@ bool createUndo(BufferView * bv, Undo::undo_kind kind,
// Returns false if no undo possible.
bool textUndoOrRedo(BufferView * bv,
limited_stack<boost::shared_ptr<Undo> > & stack,
limited_stack<boost::shared_ptr<Undo> > & otherstack)
limited_stack<boost::shared_ptr<Undo> > & /*otherstack*/)
{
Buffer * b = bv->buffer();
//Buffer * b = bv->buffer();
if (stack.empty()) {
finishNoUndo(bv);