]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
Move LFUN_CHANGES_TRACK and LFUN_CHANGES_OUTPUT to Buffer.cpp,
[lyx.git] / src / Buffer.cpp
index e6096af747d328d284e3c8d13eb62744cb13c989..cfc442c2031984a8c4ba0f0e5009d02c748e2380 100644 (file)
@@ -1675,6 +1675,8 @@ void Buffer::writeLaTeXSource(otexstream & os,
 
        // XeTeX with TeX fonts is only safe with ASCII encoding,
        // See #9740 and FIXME in BufferParams::encoding()
+       // FIXME: when only the current paragraph is shown, this seems to be ignored:
+       //   characters encodable in the current encoding are not converted to ASCII-representation.
        if (!params().useNonTeXFonts && (runparams.flavor == OutputParams::XETEX))
                runparams.encoding = encodings.fromLyXName("ascii");
 
@@ -2443,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;
        }
@@ -2672,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;
@@ -3435,7 +3497,7 @@ Buffer::References & Buffer::getReferenceCache(docstring const & label)
                return it->second.second;
 
        static InsetLabel const * dummy_il = 0;
-       static References const dummy_refs;
+       static References const dummy_refs = References();
        it = d->ref_cache_.insert(
                make_pair(label, make_pair(dummy_il, dummy_refs))).first;
        return it->second.second;