Change the LyX file format, adding a "preview" flag to Include insets.

Document this change in a new file FORMAT.
Enable the user to toggle preview status by modifying the Include dialog.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4849 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2002-08-02 18:25:25 +00:00
parent b95e7efe2e
commit 5e802bab4d
9 changed files with 100 additions and 12 deletions

View File

@ -1,3 +1,8 @@
2002-08-02 Angus Leeming <leeming@lyx.org>
* FORMAT: a new file to document changes in the LyX file format.
Start it off with a change to Include insets.
2002-06-26 André Pönitz <poenitz@gmx.de>
* development/Win32/lyxwin32.c: Win32 specific patch from Claus

17
development/FORMAT Normal file
View File

@ -0,0 +1,17 @@
Changes to the LyX format since version 220 (LyX 1.2.0) was released.
=====================================================================
2002-08-02 Angus Leeming <leeming@lyx.org>
Added a boolean "preview" flag to InsetCommandParams.
Currently it is written only by InsetInclude, because only this
class can generate a preview of its contents.
The LyX file now contains:
\begin_inset Include \input{snapshot_t=40.tex}
+preview true
\end_inset
Earlier versions of LyX just swallow this extra token silently.

View File

@ -1,3 +1,9 @@
2002-08-02 Angus Leeming <leeming@lyx.org>
* FormInclude.C:
* forms/form_include.fd: added a check_preview button and controlling
logic. The user can now choose to preview a \input-ed file.
2002-08-02 Angus Leeming <leeming@lyx.org>
* FormTabular.C (input):

View File

@ -76,6 +76,14 @@ void FormInclude::update()
fl_set_button(dialog_->check_typeset,
int(controller().params().noload));
if (cmdname == "input")
fl_set_button(dialog_->check_preview,
int(controller().params().cparams.preview()));
else
fl_set_button(dialog_->check_preview, 0);
setEnabled(dialog_->check_preview, (cmdname == "input"));
fl_set_button(dialog_->radio_useinput, cmdname == "input");
fl_set_button(dialog_->radio_useinclude, cmdname == "include");
if (cmdname == "verbatiminput" || cmdname == "verbatiminput*") {
@ -97,6 +105,8 @@ void FormInclude::update()
void FormInclude::apply()
{
controller().params().noload = fl_get_button(dialog_->check_typeset);
controller().params().cparams
.preview(fl_get_button(dialog_->check_preview));
string const file = fl_get_input(dialog_->input_filename);
if (controller().fileExists(file))
@ -161,5 +171,13 @@ ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long)
action = ButtonPolicy::SMI_INVALID;
}
if (ob == dialog_->radio_useinput) {
setEnabled(dialog_->check_preview, true);
} else if (ob == dialog_->radio_verbatim ||
ob == dialog_->radio_useinclude) {
fl_set_button(dialog_->check_preview, 0);
setEnabled(dialog_->check_preview, false);
}
return action;
}

View File

@ -9,13 +9,13 @@ Unit of measure: FL_COORD_PIXEL
=============== FORM ===============
Name: form_include
Width: 340
Height: 210
Number of Objects: 14
Height: 250
Number of Objects: 15
--------------------
class: FL_BOX
type: UP_BOX
box: 0 0 340 210
box: 0 0 340 250
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -87,7 +87,7 @@ argument: 0
--------------------
class: FL_BUTTON
type: RETURN_BUTTON
box: 120 170 100 30
box: 120 210 100 30
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -105,7 +105,7 @@ argument: 0
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 230 170 100 30
box: 230 210 100 30
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -123,7 +123,7 @@ argument: 0
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 230 130 100 30
box: 230 170 100 30
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -177,7 +177,7 @@ argument: 0
--------------------
class: FL_BEGIN_GROUP
type: 0
box: 0 0 0 0
box: 0 10 10 0
boxtype: FL_NO_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_CENTER
@ -264,5 +264,23 @@ name:
callback:
argument:
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 180 130 150 30
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Preview|#p
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_NoGravity FL_NoGravity
name: check_preview
callback: C_FormBaseInputCB
argument: 0
==============================
create_the_forms

View File

@ -1,3 +1,13 @@
2002-08-02 Angus Leeming <leeming@lyx.org>
* insetcommandparams.[Ch] (preview): new methods returning and setting
a new bool preview_ flag.
(read): read this flag.
(operator==): add flag to check.
* insetinclude.C (write): output new preview() flag.
(previewWanted): use this flag.
2002-08-02 Angus Leeming <leeming@lyx.org>
* insetcollapsable.[Ch] (addPreview):

View File

@ -29,7 +29,7 @@ InsetCommandParams::InsetCommandParams()
InsetCommandParams::InsetCommandParams(string const & n,
string const & c,
string const & o)
: cmdname(n), contents(c), options(o)
: cmdname(n), contents(c), options(o), preview_(false)
{}
@ -137,10 +137,14 @@ void InsetCommandParams::read(LyXLex & lex)
}
while (lex.isOK()) {
lex.nextToken();
lex.next();
token = lex.getString();
if (token == "\\end_inset")
break;
if (token == "preview") {
lex.next();
preview_ = lex.getBool();
}
}
if (token != "\\end_inset") {
lex.printError("Missing \\end_inset at this point. "
@ -170,7 +174,8 @@ bool operator==(InsetCommandParams const & o1,
{
return o1.getCmdName() == o2.getCmdName()
&& o1.getContents() == o2.getContents()
&& o1.getOptions() == o2.getOptions();
&& o1.getOptions() == o2.getOptions()
&& o1.preview() == o2.preview();
}

View File

@ -56,6 +56,11 @@ public:
string const getAsString() const;
///
void setFromString(string const &);
///
bool preview() const { return preview_; }
///
void preview(bool p) { preview_ = p; }
private:
///
string cmdname;
@ -63,6 +68,8 @@ private:
string contents;
///
string options;
///
bool preview_;
};

View File

@ -162,7 +162,8 @@ void InsetInclude::edit(BufferView * bv, bool)
void InsetInclude::write(Buffer const *, ostream & os) const
{
os << "Include " << params_.cparams.getCommand() << "\n";
os << "Include " << params_.cparams.getCommand() << '\n'
<< "preview " << tostr(params_.cparams.preview()) << '\n';
}
@ -528,7 +529,8 @@ void InsetInclude::addPreview(grfx::PreviewLoader & ploader) const
bool InsetInclude::PreviewImpl::previewWanted() const
{
return parent().params_.flag == InsetInclude::INPUT;
return parent().params_.flag == InsetInclude::INPUT &&
parent().params_.cparams.preview();
}