Move LFUN_CHANGES_TRACK and LFUN_CHANGES_OUTPUT to Buffer.cpp,

and record an undo call. This deals with the problem of marking
the Buffer dirty, as well.

Move LFUN_BUFFER_TOGGLE_COMPRESSION and LFUN_BUFFER_TOGGLE_OUTPUT_SYNC
to Buffer.cpp, and add an undo call.
This commit is contained in:
Richard Heck 2015-11-05 16:42:30 -05:00
parent ba99ea5b88
commit 2c4ec33591
2 changed files with 60 additions and 56 deletions

View File

@ -2445,6 +2445,26 @@ bool Buffer::getStatus(FuncRequest const & cmd, FuncStatus & flag)
enable = (d->preview_file_).exists() && !(d->preview_file_).isFileEmpty();
break;
case LFUN_CHANGES_TRACK:
flag.setEnabled(true);
flag.setOnOff(params().track_changes);
break;
case LFUN_CHANGES_OUTPUT:
flag.setEnabled(true);
flag.setOnOff(params().output_changes);
break;
case LFUN_BUFFER_TOGGLE_COMPRESSION: {
flag.setOnOff(params().compressed);
break;
}
case LFUN_BUFFER_TOGGLE_OUTPUT_SYNC: {
flag.setOnOff(params().output_sync);
break;
}
default:
return false;
}
@ -2674,6 +2694,46 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
dr.setMessage(_("Error viewing the output file."));
break;
case LFUN_CHANGES_TRACK:
undo().recordUndoBufferParams(CursorData());
params().track_changes = !params().track_changes;
break;
case LFUN_CHANGES_OUTPUT:
undo().recordUndoBufferParams(CursorData());
params().output_changes = !params().output_changes;
if (params().output_changes) {
bool dvipost = LaTeXFeatures::isAvailable("dvipost");
bool xcolorulem = LaTeXFeatures::isAvailable("ulem") &&
LaTeXFeatures::isAvailable("xcolor");
if (!dvipost && !xcolorulem) {
Alert::warning(_("Changes not shown in LaTeX output"),
_("Changes will not be highlighted in LaTeX output, "
"because neither dvipost nor xcolor/ulem are installed.\n"
"Please install these packages or redefine "
"\\lyxadded and \\lyxdeleted in the LaTeX preamble."));
} else if (!xcolorulem) {
Alert::warning(_("Changes not shown in LaTeX output"),
_("Changes will not be highlighted in LaTeX output "
"when using pdflatex, because xcolor and ulem are not installed.\n"
"Please install both packages or redefine "
"\\lyxadded and \\lyxdeleted in the LaTeX preamble."));
}
}
break;
case LFUN_BUFFER_TOGGLE_COMPRESSION:
// turn compression on/off
undo().recordUndoBufferParams(CursorData());
params().compressed = !params().compressed;
break;
case LFUN_BUFFER_TOGGLE_OUTPUT_SYNC:
undo().recordUndoBufferParams(CursorData());
params().output_sync = !params().output_sync;
break;
default:
dispatched = false;
break;

View File

@ -1124,16 +1124,6 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
|| getInsetByCode<InsetRef>(cur, REF_CODE));
break;
case LFUN_CHANGES_TRACK:
flag.setEnabled(true);
flag.setOnOff(buffer_.params().track_changes);
break;
case LFUN_CHANGES_OUTPUT:
flag.setEnabled(true);
flag.setOnOff(buffer_.params().output_changes);
break;
case LFUN_CHANGES_MERGE:
case LFUN_CHANGE_NEXT:
case LFUN_CHANGE_PREVIOUS:
@ -1146,16 +1136,6 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
flag.setEnabled(true);
break;
case LFUN_BUFFER_TOGGLE_COMPRESSION: {
flag.setOnOff(buffer_.params().compressed);
break;
}
case LFUN_BUFFER_TOGGLE_OUTPUT_SYNC: {
flag.setOnOff(buffer_.params().output_sync);
break;
}
case LFUN_SCREEN_UP:
case LFUN_SCREEN_DOWN:
case LFUN_SCROLL:
@ -1458,33 +1438,6 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
break;
}
case LFUN_CHANGES_TRACK:
buffer_.params().track_changes = !buffer_.params().track_changes;
break;
case LFUN_CHANGES_OUTPUT:
buffer_.params().output_changes = !buffer_.params().output_changes;
if (buffer_.params().output_changes) {
bool dvipost = LaTeXFeatures::isAvailable("dvipost");
bool xcolorulem = LaTeXFeatures::isAvailable("ulem") &&
LaTeXFeatures::isAvailable("xcolor");
if (!dvipost && !xcolorulem) {
Alert::warning(_("Changes not shown in LaTeX output"),
_("Changes will not be highlighted in LaTeX output, "
"because neither dvipost nor xcolor/ulem are installed.\n"
"Please install these packages or redefine "
"\\lyxadded and \\lyxdeleted in the LaTeX preamble."));
} else if (!xcolorulem) {
Alert::warning(_("Changes not shown in LaTeX output"),
_("Changes will not be highlighted in LaTeX output "
"when using pdflatex, because xcolor and ulem are not installed.\n"
"Please install both packages or redefine "
"\\lyxadded and \\lyxdeleted in the LaTeX preamble."));
}
}
break;
case LFUN_CHANGE_NEXT:
findNextChange(this);
// FIXME: Move this LFUN to Buffer so that we don't have to do this:
@ -1724,15 +1677,6 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
}
break;
case LFUN_BUFFER_TOGGLE_COMPRESSION:
// turn compression on/off
buffer_.params().compressed = !buffer_.params().compressed;
break;
case LFUN_BUFFER_TOGGLE_OUTPUT_SYNC:
buffer_.params().output_sync = !buffer_.params().output_sync;
break;
case LFUN_SCREEN_UP:
case LFUN_SCREEN_DOWN: {
Point p = getPos(cur);