From: Angus Leeming Date: Fri, 2 Aug 2002 18:25:25 +0000 (+0000) Subject: Change the LyX file format, adding a "preview" flag to Include insets. X-Git-Tag: 1.6.10~18692 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=5e802bab4d0e96ccfa67a76cbab2086f8380895d;p=lyx.git 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 --- diff --git a/development/ChangeLog b/development/ChangeLog index b82dec864d..1e7ae0d90e 100644 --- a/development/ChangeLog +++ b/development/ChangeLog @@ -1,3 +1,8 @@ +2002-08-02 Angus Leeming + + * 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 * development/Win32/lyxwin32.c: Win32 specific patch from Claus diff --git a/development/FORMAT b/development/FORMAT new file mode 100644 index 0000000000..0688503884 --- /dev/null +++ b/development/FORMAT @@ -0,0 +1,17 @@ +Changes to the LyX format since version 220 (LyX 1.2.0) was released. +===================================================================== + +2002-08-02 Angus Leeming + +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. diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 5f660da64e..e60397101b 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,9 @@ +2002-08-02 Angus Leeming + + * 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 * FormTabular.C (input): diff --git a/src/frontends/xforms/FormInclude.C b/src/frontends/xforms/FormInclude.C index fc5edcd837..fcf18e902c 100644 --- a/src/frontends/xforms/FormInclude.C +++ b/src/frontends/xforms/FormInclude.C @@ -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; } diff --git a/src/frontends/xforms/forms/form_include.fd b/src/frontends/xforms/forms/form_include.fd index dc0bd01d3a..191d673725 100644 --- a/src/frontends/xforms/forms/form_include.fd +++ b/src/frontends/xforms/forms/form_include.fd @@ -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 diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index b75d552a6f..ab522377b0 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,13 @@ +2002-08-02 Angus Leeming + + * 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 * insetcollapsable.[Ch] (addPreview): diff --git a/src/insets/insetcommandparams.C b/src/insets/insetcommandparams.C index d3879d0ae0..5da44d6bf9 100644 --- a/src/insets/insetcommandparams.C +++ b/src/insets/insetcommandparams.C @@ -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(); } diff --git a/src/insets/insetcommandparams.h b/src/insets/insetcommandparams.h index b6c3b75ded..481151c119 100644 --- a/src/insets/insetcommandparams.h +++ b/src/insets/insetcommandparams.h @@ -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_; }; diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 6ecc614219..dfc699a713 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -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(); }