+2005-02-03 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+
+ * FORMAT: document change to format 241.
+
2005-01-24 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* FORMAT: document change to format 240.
LyX file-format changes
-----------------------
+2005-02-03 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+
+ * format incremented to 241.
+
+ All following changes apply only to text in ERT insets. The
+ rationale is that text in ERT is simply ASCII text, and nothing more.
+
+ * paragraph breaks are now a single newline in latex and not a
+ paragraph break anymore (bug 698).
+ * \newline is not allowed anymore, because it is redundant (see above)
+ * layouts other than Standard, paragraph parameters and font changes
+ are not allowed anymore. They never made sense and were ignored for
+ latex output, but now they can't be read or set anymore (bug 922).
+
+
2005-01-23 Jürgen Spitzmüller <j.spitzmüller@gmx.de>
* format incremented to 240.
-2005-01-15 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+2005-01-24 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* ui/classic.ui, ui/stdmenus.ui: add output-changes.
+2005-02-03 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+
+ * LyX.py: format up to 241
+ * lyx_1_4.py (convert_ert_paragraphs, revert_ert_paragraphs): new
+ * lyx_1_4.py, LyX.py: handle new format 241
+
2005-01-24 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* LyX.py: format up to 240.
("1_1_6fix3", [218], ["1.1.6fix3","1.1.6fix4","1.1"]),
("1_2", [220], ["1.2.0","1.2.1","1.2.3","1.2.4","1.2"]),
("1_3", [221], ["1.3.0","1.3.1","1.3.2","1.3.3","1.3.4","1.3.5","1.3"]),
- ("1_4", range(223,241), ["1.4.0cvs","1.4"])]
+ ("1_4", range(223,242), ["1.4.0cvs","1.4"])]
def formats_list():
del file.header[i]
+##
+# Convert paragraph breaks and sanitize paragraphs
+#
+def convert_ert_paragraphs(file):
+ forbidden_settings = [
+ # paragraph parameters
+ '\\paragraph_spacing', '\\labelwidthstring',
+ '\\start_of_appendix', '\\noindent',
+ '\\leftindent', '\\align',
+ # font settings
+ '\\family', '\\series', '\\shape', '\\size',
+ '\\emph', '\\numeric', '\\bar', '\\noun',
+ '\\color', '\\lang']
+ i = 0
+ while 1:
+ i = find_token(file.body, '\\begin_inset ERT', i)
+ if i == -1:
+ return
+ j = find_end_of_inset(file.body, i)
+ if j == -1:
+ file.warning("Malformed lyx file: Missing '\\end_inset'.")
+ i = i + 1
+ continue
+
+ # convert non-standard paragraphs to standard
+ k = i
+ while 1:
+ k = find_token(file.body, "\\begin_layout", k, j)
+ if k == -1:
+ break
+ file.body[k] = "\\begin_layout Standard"
+ k = k + 1
+
+ # remove all paragraph parameters and font settings
+ k = i
+ while k < j:
+ if (strip(file.body[k]) and
+ split(file.body[k])[0] in forbidden_settings):
+ del file.body[k]
+ j = j - 1
+ else:
+ k = k + 1
+
+ # insert an empty paragraph before each paragraph but the first
+ k = i
+ first_pagraph = 1
+ while 1:
+ k = find_token(file.body, "\\begin_layout Standard", k, j)
+ if k == -1:
+ break
+ if first_pagraph:
+ first_pagraph = 0
+ k = k + 1
+ continue
+ file.body[k:k] = ["\\begin_layout Standard", "",
+ "\\end_layout", ""]
+ k = k + 5
+ j = j + 4
+
+ # convert \\newline to new paragraph
+ k = i
+ while 1:
+ k = find_token(file.body, "\\newline", k, j)
+ if k == -1:
+ break
+ file.body[k:k+1] = ["\\end_layout", "", "\\begin_layout Standard"]
+ k = k + 4
+ j = j + 3
+ i = i + 1
+
+
+##
+# Remove double paragraph breaks
+#
+def revert_ert_paragraphs(file):
+ i = 0
+ while 1:
+ i = find_token(file.body, '\\begin_inset ERT', i)
+ if i == -1:
+ return
+ j = find_end_of_inset(file.body, i)
+ if j == -1:
+ file.warning("Malformed lyx file: Missing '\\end_inset'.")
+ i = i + 1
+ continue
+
+ # replace paragraph breaks with \newline
+ k = i
+ while 1:
+ k = find_token(file.body, "\\end_layout", k, j)
+ l = find_token(file.body, "\\begin_layout", k, j)
+ if k == -1 or l == -1:
+ break
+ file.body[k:l+1] = ["\\newline"]
+ j = j - l + k
+ k = k + 1
+
+ # replace double \newlines with paragraph breaks
+ k = i
+ while 1:
+ k = find_token(file.body, "\\newline", k, j)
+ if k == -1:
+ break
+ l = k + 1
+ while file.body[l] == "":
+ l = l + 1
+ if strip(file.body[l]) and split(file.body[l])[0] == "\\newline":
+ file.body[k:l+1] = ["\\end_layout", "",
+ "\\begin_layout Standard"]
+ j = j - l + k + 2
+ k = k + 3
+ else:
+ k = k + 1
+ i = i + 1
+
+
##
# Convertion hub
#
[237, [use_x_boolean]],
[238, [update_latexaccents]],
[239, [normalize_paragraph_params]],
- [240, [convert_output_changes]]]
+ [240, [convert_output_changes]],
+ [241, [convert_ert_paragraphs]]]
-revert = [[239, [revert_output_changes]],
+revert = [[240, [revert_ert_paragraphs]],
+ [239, [revert_output_changes]],
[238, []],
[237, []],
[236, [use_x_binary]],
+2005-02-03 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+
+ * buffer.C: format up to 241.
+ * CutAndPaste.C (pasteSelectionHelper): convert newline to paragraph
+ break if pasting into ERT
+ * lyxfunc.C (getStatus): suppress mathpanel and
+ LFUN_DIALOG_SHOW_NEW_INSET in ERT
+
2005-02-01 Angus Leeming <leeming@lyx.org>
* lyxrc.C (getDescription): add a description for RC_PATH_PREFIX.
// Now remove all out of the pars which is NOT allowed in the
// new environment and set also another font if that is required.
+ // Convert newline to paragraph break in ERT inset.
+ // This should not be here!
+ if (pars[pit].inInset()->lyxCode() == InsetBase::ERT_CODE) {
+ for (ParagraphList::size_type i = 0; i < insertion.size(); ++i) {
+ for (pos_type j = 0; j < insertion[i].size(); ++j) {
+ if (insertion[i].isNewline(j)) {
+ insertion[i].erase(j);
+ breakParagraphConservative(
+ buffer.params(),
+ insertion, i, j);
+ }
+ }
+ }
+ }
+
// Make sure there is no class difference.
lyx::cap::SwitchLayoutsBetweenClasses(textclass, tc, insertion,
errorlist);
// Set the inset owner of this paragraph.
tmpbuf->setInsetOwner(pars[pit].inInset());
for (pos_type i = 0; i < tmpbuf->size(); ++i) {
- if (tmpbuf->getChar(i) == Paragraph::META_INSET) {
- if (!pars[pit].insetAllowed(tmpbuf->getInset(i)->lyxCode()))
- tmpbuf->erase(i--);
- }
+ if (tmpbuf->getChar(i) == Paragraph::META_INSET &&
+ !pars[pit].insetAllowed(tmpbuf->getInset(i)->lyxCode()))
+ tmpbuf->erase(i--);
}
}
namespace {
-int const LYX_FORMAT = 240;
+int const LYX_FORMAT = 241;
} // namespace anon
+2005-02-03 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+
+ * insetert.C (latex, linuxdoc, docbook): remove newline handling
+ * insetert.C (doDispatch): clean pasted paragraphs
+ * insetert.C (getStatus): suppress more lfuns
+ * insetert.C (insetAllowed): return always false
+
2005-01-31 Asger Ottar Alstrup <aalstrup@laerdal.dk>
* inset.C:
#include "buffer.h"
#include "bufferparams.h"
#include "BufferView.h"
+#include "cursor.h"
#include "debug.h"
#include "dispatchresult.h"
#include "funcrequest.h"
#include "gettext.h"
#include "language.h"
#include "LColor.h"
+#include "LyXAction.h"
#include "lyxlex.h"
+#include "lyxtextclass.h"
#include "metricsinfo.h"
+#include "ParagraphParameters.h"
#include "paragraph.h"
#include "frontends/Alert.h"
#include <sstream>
using lyx::pos_type;
+using lyx::support::token;
using std::endl;
using std::min;
if (isDeletedText(*par, i))
continue;
- if (par->isNewline(i)) {
- os << '\n';
- ++lines;
- } else {
- os << par->getChar(i);
- }
+ os << par->getChar(i);
}
++par;
if (par != end) {
int lines = 0;
while (par != end) {
pos_type siz = par->size();
- for (pos_type i = 0; i < siz; ++i) {
- if (par->isNewline(i)) {
- os << '\n';
- ++lines;
- } else {
- os << par->getChar(i);
- }
- }
+ for (pos_type i = 0; i < siz; ++i)
+ os << par->getChar(i);
++par;
if (par != end) {
os << "\n";
int lines = 0;
while (par != end) {
pos_type siz = par->size();
- for (pos_type i = 0; i < siz; ++i) {
- if (par->isNewline(i)) {
- os << '\n';
- ++lines;
- } else {
- os << par->getChar(i);
- }
- }
+ for (pos_type i = 0; i < siz; ++i)
+ os << par->getChar(i);
++par;
if (par != end) {
os << "\n";
setStatus(st);
break;
}
+ case LFUN_PASTE:
+ case LFUN_PASTESELECTION: {
+ InsetCollapsable::doDispatch(cur, cmd);
+ // Since we can only store plain text, we must reset all
+ // attributes.
+ // FIXME: Change only the pasted paragraphs
+
+ BufferParams const & bp = cur.buffer().params();
+ LyXLayout_ptr const layout =
+ bp.getLyXTextClass().defaultLayout();
+ LyXFont font = layout->font;
+ // We need to set the language for non-english documents
+ font.setLanguage(bp.language);
+ ParagraphList::iterator const end = paragraphs().end();
+ for (ParagraphList::iterator par = paragraphs().begin();
+ par != end; ++par) {
+ par->layout(layout);
+ // in case par had a manual label
+ par->setBeginOfBody();
+ pos_type const siz = par->size();
+ for (pos_type i = 0; i < siz; ++i) {
+ par->setFont(i, font);
+ }
+ par->params().clear();
+ }
+ break;
+ }
default:
InsetCollapsable::doDispatch(cur, cmd);
break;
{
switch (cmd.action) {
// suppress these
- case LFUN_LAYOUT:
+ case LFUN_ACUTE:
+ case LFUN_BREVE:
+ case LFUN_CARON:
+ case LFUN_CEDILLA:
+ case LFUN_CIRCLE:
+ case LFUN_CIRCUMFLEX:
+ case LFUN_DOT:
+ case LFUN_GRAVE:
+ case LFUN_HUNG_UMLAUT:
+ case LFUN_MACRON:
+ case LFUN_OGONEK:
+ case LFUN_SPECIAL_CARON:
+ case LFUN_TIE:
+ case LFUN_TILDE:
+ case LFUN_UMLAUT:
+ case LFUN_UNDERBAR:
+ case LFUN_UNDERDOT:
+ case LFUN_APPENDIX:
+ case LFUN_BREAKLINE:
+ case LFUN_INSET_CAPTION:
+ case LFUN_DEPTH_MIN:
+ case LFUN_DEPTH_PLUS:
+ case LFUN_LDOTS:
+ case LFUN_END_OF_SENTENCE:
+ case LFUN_ENVIRONMENT_INSERT:
+ case LFUN_INSET_ERT:
+ case LFUN_FILE_INSERT:
+ case LFUN_INSET_FLOAT:
+ case LFUN_INSET_WIDE_FLOAT:
+ case LFUN_INSET_WRAP:
case LFUN_BOLD:
case LFUN_CODE:
case LFUN_DEFAULT:
case LFUN_FONT_SIZE:
case LFUN_FONT_STATE:
case LFUN_UNDERLINE:
+ case LFUN_INSET_FOOTNOTE:
+ case LFUN_HFILL:
+ case LFUN_HTMLURL:
+ case LFUN_HYPHENATION:
+ case LFUN_LIGATURE_BREAK:
+ case LFUN_INDEX_INSERT:
+ case LFUN_INDEX_PRINT:
+ case LFUN_INSERT_LABEL:
+ case LFUN_INSET_OPTARG:
+ case LFUN_INSERT_BIBITEM:
+ case LFUN_INSERT_LINE:
+ case LFUN_INSERT_PAGEBREAK:
+ case LFUN_LANGUAGE:
+ case LFUN_LAYOUT:
+ case LFUN_LAYOUT_PARAGRAPH:
+ case LFUN_LAYOUT_TABULAR:
+ case LFUN_INSET_MARGINAL:
+ case LFUN_MATH_DISPLAY:
+ case LFUN_INSERT_MATH:
+ case LFUN_INSERT_MATRIX:
+ case LFUN_MATH_MODE:
+ case LFUN_MENU_OPEN_BY_NAME:
+ case LFUN_MENU_SEPARATOR:
+ case LFUN_INSERT_BRANCH:
+ case LFUN_INSERT_CHARSTYLE:
+ case LFUN_INSERT_NOTE:
+ case LFUN_INSERT_BOX:
+ case LFUN_GOTONOTE:
+ case LFUN_PARAGRAPH_SPACING:
+ case LFUN_QUOTE:
+ case LFUN_REF_GOTO:
+ case LFUN_REFERENCE_GOTO:
+ case LFUN_SPACE_INSERT:
+ case LFUN_GOTOFILEROW:
+ case LFUN_NOTIFY:
+ case LFUN_SETXY:
+ case LFUN_TABULAR_INSERT:
+ case LFUN_TOC_INSERT:
+ case LFUN_URL:
+ case LFUN_FLOAT_LIST:
+ case LFUN_INSET_INSERT:
+ case LFUN_PARAGRAPH_APPLY:
+ case LFUN_PARAGRAPH_UPDATE:
+ case LFUN_NOACTION:
status.enabled(false);
return true;
+ // this one is difficult to get right. As a half-baked
+ // solution, we consider only the first action of the sequence
+ case LFUN_SEQUENCE: {
+ // argument contains ';'-terminated commands
+ string const firstcmd = token(cmd.argument, ';', 0);
+ FuncRequest func(lyxaction.lookupFunc(firstcmd));
+ func.origin = cmd.origin;
+ return getStatus(cur, func, status);
+ }
+
default:
return InsetCollapsable::getStatus(cur, cmd, status);
- }
+ }
}
}
-bool InsetERT::insetAllowed(InsetBase::Code code) const
+bool InsetERT::insetAllowed(InsetBase::Code /* code */) const
{
- return code == InsetBase::NEWLINE_CODE;
+ return false;
}
using bv_funcs::freefont2string;
+using lyx::support::AbsolutePath;
using lyx::support::AddName;
using lyx::support::AddPath;
using lyx::support::bformat;
else if (name == "print")
enable = Exporter::IsExportable(*buf, "dvi")
&& lyxrc.print_command != "none";
- else if (name == "character")
+ else if (name == "character" || name == "mathpanel")
enable = cur.inset().lyxCode() != InsetBase::ERT_CODE;
else if (name == "vclog")
enable = buf->lyxvc().inUse();
break;
}
+ case LFUN_DIALOG_SHOW_NEW_INSET:
+ enable = cur.inset().lyxCode() != InsetBase::ERT_CODE;
+ break;
+
case LFUN_DIALOG_UPDATE: {
string const name = cmd.getArg(0);
if (!buf)
case LFUN_NOTIFY:
case LFUN_GOTOFILEROW:
case LFUN_GOTO_PARAGRAPH:
- case LFUN_DIALOG_SHOW_NEW_INSET:
case LFUN_DIALOG_SHOW_NEXT_INSET:
case LFUN_DIALOG_HIDE:
case LFUN_DIALOG_DISCONNECT_INSET: