+2000-11-14 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * src/support/tempname.C (tempName): small changes to make it
+ safer. remove the '.' before XXXXXX
+
+ * src/support/filetools.C (TmpFileName): remove func
+ (GetCWD): ditto
+
+ * src/frontends/xforms/FormRef.C (FormRef): explicit call the bp
+ * src/frontends/xforms/FormUrl.C (FormUrl): ditto
+ * src/frontends/xforms/FormTabularCreate.C (FormTabularCreate): ditto
+ * src/frontends/xforms/FormTabular.C (FormTabular): ditto
+
+ * src/frontends/xforms/FormInset.h (FormInset): remove default for bp
+ (FormCommand): ditto
+
+ * src/frontends/xforms/FormGraphics.C (FormGraphics): explicit
+ call the bp
+
+ * src/frontends/xforms/FormError.C (FormError): use IgnorantPolicy
+ for bp (this fixes a reproducible hard crash)
+
+ * src/frontends/xforms/FormCopyright.C (FormCopyright): explicit
+ call the bp
+
+ * src/frontends/xforms/FormBase.h: make bp_ private
+ (FormBaseBI): remove default for bp
+ (FormBaseBD): ditto
+
+ * src/frontends/xforms/Dialogs.C (Dialogs): use the old method it
+ is safe enough.
+
+ * src/frontends/xforms/Color.C (RGBColor): made several vars
+ const, changed initialization of j to allow it to be const
+ (HSVColor): similar
+
+ * several files: added const to local variables.
+
+ * src/lyx_cb.C: removed several function prototypes and moved them
+ to lyx_cb.h
+ (MenuWrite):
+ (MenuWriteAs):
+ (UpdateLayoutPreamble):
+ (MenuLayoutSave):
+ (MenuInsertLabel): add BufferView as arguemnt
+ (LayoutsCB): make tmp const
+
+ * src/layout_forms.h: regenerated
+
+ * src/debug.C: add Debug::FILES
+ (showLevel) (showTags): translate the desc
+
+ * src/debug.h: add FILES as debug target
+
+ * src/bufferlist.C: use current_view as an interim measure becuase
+ of added arguments to MenuWrite and MenuWriteAs
+
+ * forms/layout_forms.h.patch: make the patch more correct and more appalyable
+
+ * config/lyxinclude.m4 (LYX_STD_COUNT): change test to not involve
+ string.
+ (LYX_PROG_CXX): change 2.97 rules to include the -f.. that
+ libstdc++ is compiled with.
+
2000-11-13 José Abílio Matos <jamatos@fep.up.pt>
* lib/layouts/docbook-book.layout
2.95.1) CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti -fno-exceptions";;
2.95.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
2.96*) CXXFLAGS="-g $lyx_opt -fno-exceptions";;
- 2.97*) CXXFLAGS="-g $lyx_opt -fhonor-std -fno-builtin -ffunction-sectons -fdata-sections";;
+ 2.97*) CXXFLAGS="-g $lyx_opt -fvtable-thunks -fno-builtin -ffunction-sections -fdata-sections";;
*2.91.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
esac
AC_DEFUN(LYX_STD_COUNT,[
AC_CACHE_CHECK(for conforming std::count,lyx_cv_std_count,
[AC_TRY_COMPILE([
-#include <string>
#include <algorithm>
-using std::string;
using std::count;
-int countChar(string const & a, char const c)
+int countChar(char * b, char * e, char const c)
{
- return count(a.begin(), a.end(), c);
+ return count(b, e, c);
}
],[
- string a("hello");
- int i = countChar(a, 'l');
+ char a[] = "hello";
+ int i = countChar(a, a + 5, 'l');
],lyx_cv_std_count=yes,lyx_cv_std_count=no)
])
if test $lyx_cv_std_count = yes ; then
-1c1
-< /** Header file generated with fdesign on Tue Sep 26 15:14:15 2000.**/
----
-> /** Header file generated with fdesign **/
7,8c7,8
< extern void CharacterApplyCB(FL_OBJECT *, long);
< extern void CharacterCloseCB(FL_OBJECT *, long);
> extern "C" void PreambleOKCB(FL_OBJECT *, long);
> extern "C" void PreambleApplyCB(FL_OBJECT *, long);
> extern "C" void PreambleCancelCB(FL_OBJECT *, long);
-13a14,16
-> /* Some extra funcs */
->
-> extern bool UpdateLayoutPreamble();
src/credits.C
src/credits_form.C
src/CutAndPaste.C
+src/debug.C
src/exporter.C
src/ext_l10n.h
src/filedlg.C
src/frontends/kde/tocdlg.C
src/frontends/kde/urldlg.C
src/frontends/xforms/FormBase.h
-src/frontends/xforms/FormCitation.C
src/frontends/xforms/form_citation.C
-src/frontends/xforms/FormCopyright.C
+src/frontends/xforms/FormCitation.C
src/frontends/xforms/form_copyright.C
-src/frontends/xforms/FormDocument.C
+src/frontends/xforms/FormCopyright.C
src/frontends/xforms/form_document.C
-src/frontends/xforms/FormError.C
+src/frontends/xforms/FormDocument.C
src/frontends/xforms/form_error.C
-src/frontends/xforms/FormGraphics.C
+src/frontends/xforms/FormError.C
src/frontends/xforms/form_graphics.C
-src/frontends/xforms/FormIndex.C
+src/frontends/xforms/FormGraphics.C
src/frontends/xforms/form_index.C
+src/frontends/xforms/FormIndex.C
src/frontends/xforms/FormInset.h
-src/frontends/xforms/FormParagraph.C
src/frontends/xforms/form_paragraph.C
-src/frontends/xforms/FormPreferences.C
+src/frontends/xforms/FormParagraph.C
src/frontends/xforms/form_preferences.C
-src/frontends/xforms/FormPrint.C
+src/frontends/xforms/FormPreferences.C
src/frontends/xforms/form_print.C
-src/frontends/xforms/FormRef.C
+src/frontends/xforms/FormPrint.C
src/frontends/xforms/form_ref.C
-src/frontends/xforms/FormTabular.C
+src/frontends/xforms/FormRef.C
src/frontends/xforms/form_tabular.C
-src/frontends/xforms/FormTabularCreate.C
+src/frontends/xforms/FormTabular.C
src/frontends/xforms/form_tabular_create.C
-src/frontends/xforms/FormToc.C
+src/frontends/xforms/FormTabularCreate.C
src/frontends/xforms/form_toc.C
-src/frontends/xforms/FormUrl.C
+src/frontends/xforms/FormToc.C
src/frontends/xforms/form_url.C
+src/frontends/xforms/FormUrl.C
src/frontends/xforms/Menubar_pimpl.C
src/gettext.h
src/importer.C
using std::for_each;
using std::mem_fun;
+extern BufferView * current_view;
+
//
// Class BufferStorage
//
}
-extern bool MenuWrite(Buffer *);
-extern bool MenuWriteAs(Buffer *);
-
bool BufferList::QwriteAll()
{
bool askMoreConfirmation = false;
_("Save document?"))) {
case 1: // Yes
if ((*it)->isUnnamed())
- reask = !MenuWriteAs((*it));
+ reask = !MenuWriteAs(current_view, (*it));
else {
- reask = !MenuWrite((*it));
+ reask = !MenuWrite(current_view, (*it));
}
break;
case 2: // No
_("Save document?"))){
case 1: // Yes
if (buf->isUnnamed())
- reask = !MenuWriteAs(buf);
+ reask = !MenuWriteAs(current_view, buf);
else if (buf->save()) {
lastfiles->newFile(buf->fileName());
reask = false;
#endif
#include <config.h>
-#include "debug.h"
#include <iomanip>
+#include "debug.h"
+#include "gettext.h"
+
using std::ostream;
using std::setw;
using std::endl;
};
static error_item errorTags[] = {
- { Debug::NONE, "none", "No debugging message"},
- { Debug::INFO, "info", "General information"},
- { Debug::INIT, "init", "Program initialisation"},
- { Debug::KEY, "key", "Keyboard events handling"},
- { Debug::GUI, "gui", "GUI handling"},
- { Debug::PARSER, "parser", "Lyxlex grammer parser"},
- { Debug::LYXRC, "lyxrc", "Configuration files reading"},
- { Debug::KBMAP, "kbmap", "Custom keyboard definition"},
- { Debug::LATEX, "latex", "LaTeX generation/execution"},
- { Debug::MATHED, "mathed", "Math editor"},
- { Debug::FONT, "font", "Font handling"},
- { Debug::TCLASS, "tclass", "Textclass files reading"},
- { Debug::LYXVC, "lyxvc", "Version control"},
- { Debug::LYXSERVER, "lyxserver", "External control interface"},
- { Debug::ROFF, "roff", "Keep *roff temporary files"},
- { Debug::ACTION, "action", "User commands"},
- { Debug::LYXLEX, "lyxlex", "The LyX Lexxer"},
- { Debug::DEPEND, "depend", "Dependency information"},
- { Debug::INSETS, "insets", "LyX Insets"},
- { Debug::ANY, "any", "All debugging messages"}
+ { Debug::NONE, "none", N_("No debugging message")},
+ { Debug::INFO, "info", N_("General information")},
+ { Debug::INIT, "init", N_("Program initialisation")},
+ { Debug::KEY, "key", N_("Keyboard events handling")},
+ { Debug::GUI, "gui", N_("GUI handling")},
+ { Debug::PARSER, "parser", N_("Lyxlex grammer parser")},
+ { Debug::LYXRC, "lyxrc", N_("Configuration files reading")},
+ { Debug::KBMAP, "kbmap", N_("Custom keyboard definition")},
+ { Debug::LATEX, "latex", N_("LaTeX generation/execution")},
+ { Debug::MATHED, "mathed", N_("Math editor")},
+ { Debug::FONT, "font", N_("Font handling")},
+ { Debug::TCLASS, "tclass", N_("Textclass files reading")},
+ { Debug::LYXVC, "lyxvc", N_("Version control")},
+ { Debug::LYXSERVER, "lyxserver", N_("External control interface")},
+ { Debug::ROFF, "roff", N_("Keep *roff temporary files")},
+ { Debug::ACTION, "action", N_("User commands")},
+ { Debug::LYXLEX, "lyxlex", N_("The LyX Lexxer")},
+ { Debug::DEPEND, "depend", N_("Dependency information")},
+ { Debug::INSETS, "insets", N_("LyX Insets")},
+ { Debug::FILES, "files", N_("Files used by LyX")},
+ { Debug::ANY, "any", N_("All debugging messages")}
};
Debug::PARSER | Debug::LYXRC | Debug::KBMAP | Debug::LATEX |
Debug::MATHED | Debug::FONT | Debug::TCLASS | Debug::LYXVC |
Debug::LYXSERVER | Debug::ROFF | Debug::ACTION | Debug::LYXLEX |
- Debug::DEPEND | Debug::INSETS);
+ Debug::DEPEND | Debug::INSETS | Debug::FILES);
Debug::type Debug::value(string const & val)
if (errorTags[i].level != Debug::ANY
&& errorTags[i].level != Debug::NONE
&& errorTags[i].level & level)
- o << "Debugging `" << errorTags[i].name
- << "' (" << errorTags[i].desc << ')' << endl;
+ o << _("Debugging `") << errorTags[i].name
+ << "' (" << _(errorTags[i].desc) << ')' << endl;
}
for (int i = 0 ; i < numErrorTags ; ++i)
os << setw(7) << errorTags[i].level
<< setw(10) << errorTags[i].name
- << " " << errorTags[i].desc << '\n';
+ << " " << _(errorTags[i].desc) << '\n';
os.flush();
}
///
DEPEND = (1 << 16),
///
- INSETS = (1 << 17)
+ INSETS = (1 << 17),
+ ///
+ FILES = (1 << 18)
};
///
// static const type ANY = type(INFO | INIT | KEY | GUI |
The state machine design for this policy allows changes to occur within
the dialog while a file is read-only -- the okay button is disabled until
a read-write input is given. When the file is made read-write the dialog
- will then be in the correct state (as if the file had always been read-write).
- Note: This scheme supports the relabelling of Cancel to Close and vice versa.
+ will then be in the correct state (as if the file had always been
+ read-write).
+ Note: This scheme supports the relabelling of Cancel to Close
+ and vice versa.
This is based on the value of the bool state of the Button::CANCEL.
true == Cancel, false == Close
*/
};
-/** Ok, Apply and Cancel buttons for dialogs where read-only operation is blocked.
+/** Ok, Apply and Cancel buttons for dialogs where read-only operation
+ is blocked.
Repeated Apply are not allowed. Likewise, Ok cannot follow Apply without
- some valid input. That is, the dialog contents must change between each Apply
- or Apply and Ok.
+ some valid input. That is, the dialog contents must change between
+ each Apply or Apply and Ok.
The state machine design for this policy allows changes to occur within
the dialog while a file is read-only -- the Ok+Apply buttons are disabled
until a read-write input is given. When the file is made read-write the
dialog will then be in the correct state (as if the file had always been
read-write).
- Note: This scheme supports the relabelling of Cancel to Close and vice versa.
+ Note: This scheme supports the relabelling of Cancel to Close
+ and vice versa.
This is based on the value of the bool state of the Button::CANCEL.
true == Cancel, false == Close
*/
};
-/** Ok, Apply and Cancel buttons for dialogs where read-only operation is blocked.
+/** Ok, Apply and Cancel buttons for dialogs where read-only
+ operation is blocked.
Repeated Apply is allowed. Likewise, Ok can follow Apply.
The state machine design for this policy allows changes to occur within
the dialog while a file is read-only -- the Ok+Apply buttons are disabled
until a read-write input is given. When the file is made read-write the
dialog will then be in the correct state (as if the file had always been
read-write).
- Note: This scheme supports the relabelling of Cancel to Close and vice versa.
+ Note: This scheme supports the relabelling of Cancel to Close
+ and vice versa.
This is based on the value of the bool state of the Button::CANCEL.
true == Cancel, false == Close
*/
/** Ok, Apply and Cancel buttons for dialogs where repeated Apply is allowed.
- Note: This scheme supports the relabelling of Cancel to Close and vice versa.
+ Note: This scheme supports the relabelling of Cancel to Close
+ and vice versa.
This is based on the value of the bool state of the Button::CANCEL.
true == Cancel, false == Close
*/
/** Ok, Apply and Cancel buttons for dialogs with no repeated Apply.
- Note: This scheme supports the relabelling of Cancel to Close and vice versa.
+ Note: This scheme supports the relabelling of Cancel to Close
+ and vice versa.
This is based on the value of the bool state of the Button::CANCEL.
true == Cancel, false == Close
*/
/** Defines the policy used by the Preferences dialog.
Four buttons: Ok (Save), Apply, Cancel/Close, Restore.
- Note: This scheme supports the relabelling of Cancel to Close and vice versa.
+ Note: This scheme supports the relabelling of Cancel to Close
+ and vice versa.
This is based on the value of the bool state of the Button::CANCEL.
true == Cancel, false == Close
*/
#include "ButtonController.h"
#include "support/LAssert.h"
+//#include "debug.h"
ButtonController::ButtonController(ButtonPolicy * bp,
void ButtonController::input(ButtonPolicy::SMInput in)
{
+ //lyxerr << "ButtonController::input: bp_[" << bp_ << "]" << endl;
bp_->input(in);
refresh();
}
static int const nohue = -1;
-RGBColor::RGBColor( HSVColor const & hsv )
+RGBColor::RGBColor(HSVColor const & hsv)
{
double h = hsv.h;
- double s = hsv.s;
- double v = hsv.v;
+ double const s = hsv.s;
+ double const v = hsv.v;
double rd, gd, bd;
- if( h == nohue || s == 0.0 ) {
+ if (h == nohue || s == 0.0) {
rd = gd = bd = v;
} else {
- if( h == 360.0 ) h = 0.0;
+ if (h == 360.0) h = 0.0;
h /= 60.0;
- int j = static_cast<int>( ::floor(h) );
- if( j < 0 ) j = 0;
+ int const j = max(0, static_cast<int>(::floor(h)));
+ //if( j < 0 ) j = 0;
- double f = h - j;
- double p = v * (1.0 - s);
- double q = v * (1.0 - (s*f));
- double t = v * (1.0 - (s*(1.0 - f)));
+ double const f = h - j;
+ double const p = v * (1.0 - s);
+ double const q = v * (1.0 - (s * f));
+ double const t = v * (1.0 - (s * (1.0 - f)));
- switch( j ) {
+ switch (j) {
case 0:
rd = v;
gd = t;
}
-HSVColor::HSVColor( RGBColor const & rgb )
+HSVColor::HSVColor(RGBColor const & rgb)
{
// r, g, b lie in the range 0-1, not 0-255.
- double r = rgb.r / 255.0;
- double g = rgb.g / 255.0;
- double b = rgb.b / 255.0;
+ double const r = rgb.r / 255.0;
+ double const g = rgb.g / 255.0;
+ double const b = rgb.b / 255.0;
- double maxval = max( max( r, g ), b );
- double minval = max( min( r, g ), b );
+ double const maxval = max( max( r, g ), b );
+ double const minval = max( min( r, g ), b );
v = maxval;
- double diff = maxval - minval;
- if( maxval != 0.0 )
+ double const diff = maxval - minval;
+ if (maxval != 0.0)
s = diff / maxval;
else
s = 0.0;
h = nohue;
- if( s != 0.0 ) {
- double rc = (maxval - r) / diff;
- double gc = (maxval - g) / diff;
- double bc = (maxval - b) / diff;
+ if (s != 0.0) {
+ double const rc = (maxval - r) / diff;
+ double const gc = (maxval - g) / diff;
+ double const bc = (maxval - b) / diff;
- if( r == maxval )
+ if (r == maxval)
h = bc - gc;
- else if( g == maxval )
+ else if (g == maxval)
h = 2.0 + rc - bc;
- else if( b == maxval )
+ else if (b == maxval)
h = 4.0 + gc - rc;
h *= 60.0;
- if ( h < 0 )
+ if (h < 0)
h += 360;
}
}
bool XformColor::read(string const & filename)
{
- LyXLex lexrc( xformTags, xformCount );
- if( !lexrc.setFile( filename ) )
+ LyXLex lexrc(xformTags, xformCount);
+ if (!lexrc.setFile(filename))
return false;
- while( lexrc.IsOK() ) {
- int le = lexrc.lex();
+ while (lexrc.IsOK()) {
+ int const le = lexrc.lex();
- switch( le ) {
+ switch (le) {
case LyXLex::LEX_UNDEF:
lexrc.printError("Unknown tag `$$Token'");
continue;
RGBColor col;
- if( !lexrc.next() ) break;
+ if (!lexrc.next()) break;
col.r = lexrc.GetInteger();
- if( !lexrc.next() ) break;
+ if (!lexrc.next()) break;
col.g = lexrc.GetInteger();
- if( !lexrc.next() ) break;
+ if (!lexrc.next()) break;
col.b = lexrc.GetInteger();
fl_mapcolor(le, col.r, col.g, col.b);
<< "# modifications you should do them from inside LyX and save\n"
<< "\n";
- for( int i = 0; i < xformCount; ++i ) {
- string tag = xformTags[i].tag;
- int colorID = xformTags[i].code;
+ for (int i = 0; i < xformCount; ++i) {
+ string const tag = xformTags[i].tag;
+ int const colorID = xformTags[i].code;
RGBColor color;
fl_getmcolor(colorID, &color.r, &color.g, &color.b);
- os << tag + " "
+ os << tag << " "
<< color.r << " " << color.g << " " << color.b << "\n";
}
#include "LString.h"
-class HSVColor;
-class RGBColor;
+struct RGBColor;
struct HSVColor {
double h;
double s;
double v;
HSVColor() : h(0.0), s(0.0), v(0.0) {}
- HSVColor(double hue, double sat, double val) : h(hue), s(sat), v(val) {}
- HSVColor( RGBColor const & );
+ HSVColor(double hue, double sat, double val)
+ : h(hue), s(sat), v(val) {}
+ HSVColor(RGBColor const &);
};
struct RGBColor {
int g;
int b;
RGBColor() : r(0), g(0), b(0) {}
- RGBColor(int red, int green, int blue) : r(red), g(green), b(blue) {}
- RGBColor( HSVColor const & );
+ RGBColor(int red, int green, int blue)
+ : r(red), g(green), b(blue) {}
+ RGBColor(HSVColor const &);
};
typedef std::pair<string, RGBColor> X11Color;
int colorID;
RGBColor col;
XformColor() : colorID(0) {}
- string const getname() { return name; }
- static bool read( string const & );
- static bool write( string const & );
+ string const & getname() const { return name; }
+ static bool read(string const &);
+ static bool write(string const &);
};
inline
#include "FormTabularCreate.h"
#include "FormToc.h"
#include "FormUrl.h"
+#include "debug.h"
#ifdef __GNUG__
#pragma implementation
Dialogs::~Dialogs()
{
-#if 0
- // I belive that this is unsafe...
for (vector<DialogBase *>::iterator iter = dialogs_.begin();
iter != dialogs_.end();
++iter) {
+ lyxerr << "delete *iter" << endl;
delete *iter;
}
-#else
- // I think this is better...
- while (!dialogs_.empty()) {
- delete dialogs_.back();
- dialogs_.erase(dialogs_.end() - 1);
- }
-#endif
}
#include "LyXView.h"
#include "xform_macros.h"
#include "support/LAssert.h"
+//#include "debug.h"
// The current scheme muddles debugging.
// Can we please use some other means to create these functions?
FormBase::~FormBase()
{
+ //lyxerr << "bp_[" << bp_ << "]" << endl;
delete bp_;
}
void FormBase::redraw()
{
- if( form() && form()->visible )
- fl_redraw_form( form() );
+ if (form() && form()->visible)
+ fl_redraw_form(form());
}
void FormBase::connect()
{
- fl_set_form_minsize( form(), minw_, minh_ );
+ fl_set_form_minsize(form(), minw_, minh_);
}
C_FormBaseWMHideCB, 0);
}
- fl_freeze_form( form() );
+ fl_freeze_form(form());
update(); // make sure its up-to-date
- fl_unfreeze_form( form() );
+ fl_unfreeze_form(form());
if (form()->visible) {
fl_raise_form(form());
}
-void FormBase::InputCB(FL_OBJECT * ob, long data )
+void FormBase::InputCB(FL_OBJECT * ob, long data)
{
Assert(ob && ob->form);
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
FormBaseBI::FormBaseBI(LyXView * lv, Dialogs * d, string const & t,
ButtonPolicy * bp,
char const * close, char const * cancel)
- : FormBase( lv, d, t, bp, close, cancel )
+ : FormBase(lv, d, t, bp, close, cancel)
{}
FormBaseBD::FormBaseBD(LyXView * lv, Dialogs * d, string const & t,
ButtonPolicy * bp,
char const * close, char const * cancel)
- : FormBase( lv, d, t, bp, close, cancel ),
+ : FormBase(lv, d, t, bp, close, cancel),
u_(0)
{}
Connection h_;
/// dialog title, displayed by WM.
string title;
+private:
///
ButtonPolicy * bp_;
+public:
/// Overcome a dumb xforms sizing bug
mutable int minw_;
///
protected:
/// Constructor
FormBaseBI(LyXView *, Dialogs *, string const &,
- ButtonPolicy * bp = new OkApplyCancelPolicy,
+ ButtonPolicy * bp,
char const * close = N_("Close"),
char const * cancel = N_("Cancel"));
protected:
/// Constructor
FormBaseBD(LyXView *, Dialogs *, string const &,
- ButtonPolicy * bp = new OkApplyCancelReadOnlyPolicy,
+ ButtonPolicy * bp,
char const * close = N_("Close"),
char const * cancel = N_("Cancel"));
#include "FormCopyright.h"
FormCopyright::FormCopyright( LyXView * lv, Dialogs * d )
- : FormBaseBI( lv, d, _("Copyright and Warranty") ),
+ : FormBaseBI(lv, d, _("Copyright and Warranty"),
+ new OkApplyCancelPolicy),
dialog_(0)
{
// let the dialog be shown
FormError::FormError(LyXView * lv, Dialogs * d)
- : FormInset( lv, d, _("LaTeX Error")),
+ : FormInset( lv, d, _("LaTeX Error"), new IgnorantPolicy),
dialog_(0), inset_(0)
{
Assert(lv && d);
FormGraphics::FormGraphics(LyXView * lv, Dialogs * d)
- : FormInset( lv, d, _("Graphics"), new NoRepeatedApplyReadOnlyPolicy ),
+ : FormInset(lv, d, _("Graphics"), new NoRepeatedApplyReadOnlyPolicy),
dialog_(0), inset_(0),
// The buttons c-tor values are the number of buttons we use
// This is only to reduce memory waste.
#include "lyxfunc.h"
FormIndex::FormIndex(LyXView * lv, Dialogs * d)
- : FormCommand(lv, d, _("Index")), dialog_(0)
+ : FormCommand(lv, d, _("Index"), new OkCancelReadOnlyPolicy),
+ dialog_(0)
{
// let the dialog be shown
// These are permanent connections so we won't bother
FL_FORM * FormIndex::form() const
{
- if (dialog_ ) return dialog_->form;
+ if (dialog_) return dialog_->form;
return 0;
}
void FormIndex::connect()
{
- fl_set_form_maxsize( form(), 2*minw_, minh_ );
+ fl_set_form_maxsize(form(), 2 * minw_, minh_);
FormCommand::connect();
}
fl_set_input(dialog_->key, params.getContents().c_str());
if (lv_->buffer()->isReadonly()) {
- fl_deactivate_object( dialog_->key );
- fl_deactivate_object( dialog_->ok );
- fl_set_object_lcol( dialog_->ok, FL_INACTIVE );
+ fl_deactivate_object(dialog_->key);
+ fl_deactivate_object(dialog_->ok);
+ fl_set_object_lcol(dialog_->ok, FL_INACTIVE);
} else {
- fl_activate_object( dialog_->key );
- fl_activate_object( dialog_->ok );
- fl_set_object_lcol( dialog_->ok, FL_BLACK );
+ fl_activate_object(dialog_->key);
+ fl_activate_object(dialog_->ok);
+ fl_set_object_lcol(dialog_->ok, FL_BLACK);
}
}
FormInset::FormInset(LyXView * lv, Dialogs * d, string const & t,
ButtonPolicy * bp,
char const * close, char const * cancel)
- : FormBaseBD( lv, d, t, bp, close, cancel ), ih_(0)
+ : FormBaseBD(lv, d, t, bp, close, cancel), ih_(0)
{}
}
-void FormInset::updateSlot( bool switched )
+void FormInset::updateSlot(bool switched)
{
if (switched)
hide();
}
-FormCommand::FormCommand( LyXView * lv, Dialogs * d, string const & t,
- ButtonPolicy * bp,
- char const * close, char const * cancel)
- : FormInset( lv, d, t, bp, close, cancel ),
+FormCommand::FormCommand(LyXView * lv, Dialogs * d, string const & t,
+ ButtonPolicy * bp,
+ char const * close, char const * cancel)
+ : FormInset(lv, d, t, bp, close, cancel),
inset_(0)
{}
void FormCommand::disconnect()
{
inset_ = 0;
- params = InsetCommandParams( string() );
+ params = InsetCommandParams(string());
FormInset::disconnect();
}
-void FormCommand::showInset( InsetCommand * inset )
+void FormCommand::showInset(InsetCommand * inset)
{
if (inset == 0) return; // maybe we should Assert this?
}
-void FormCommand::createInset( string const & arg )
+void FormCommand::createInset(string const & arg)
{
if (inset_) {
ih_.disconnect();
inset_ = 0;
}
- params.setFromString( arg );
+ params.setFromString(arg);
show();
}
class FormInset : public FormBaseBD {
protected:
/// Constructor
- FormInset( LyXView *, Dialogs *, string const &,
- ButtonPolicy * bp = new OkCancelReadOnlyPolicy,
- char const * close = N_("Close"),
- char const * cancel = N_("Cancel"));
+ FormInset(LyXView *, Dialogs *, string const &,
+ ButtonPolicy * bp,
+ char const * close = N_("Close"),
+ char const * cancel = N_("Cancel"));
/// Connect signals. Also perform any necessary initialisation.
virtual void connect();
class FormCommand : public FormInset {
protected:
/// Constructor
- FormCommand( LyXView *, Dialogs *, string const &,
- ButtonPolicy * = new OkCancelReadOnlyPolicy,
- char const * close = N_("Close"),
- char const * cancel = N_("Cancel"));
+ FormCommand(LyXView *, Dialogs *, string const &,
+ ButtonPolicy *,
+ char const * close = N_("Close"),
+ char const * cancel = N_("Cancel"));
/// Disconnect signals. Also perform any necessary housekeeping.
virtual void disconnect();
/// Slot launching dialog to (possibly) create a new inset
- void createInset( string const & );
+ void createInset(string const &);
/// Slot launching dialog to an existing inset
- void showInset( InsetCommand * );
+ void showInset(InsetCommand *);
/// pointer to the inset passed through showInset
InsetCommand * inset_;
void FormPreferences::redraw()
{
- if( !(form() && form()->visible) )
+ if (!(form() && form()->visible))
return;
- fl_redraw_form( form() );
+ fl_redraw_form(form());
FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
- if( !(form2 && form2->visible) )
+ if (!(form2 && form2->visible))
return;
- fl_redraw_form( form2 );
+ fl_redraw_form(form2);
FL_FORM * form3 = 0;
- if( form2 == converters_tab_->form )
+ if (form2 == converters_tab_->form)
form3 = fl_get_active_folder(converters_tab_->tabfolder_outer);
- else if( form2 == look_n_feel_tab_->form )
+ else if (form2 == look_n_feel_tab_->form)
form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_outer);
- else if( form2 == inputs_tab_->form )
+ else if (form2 == inputs_tab_->form)
form3 = fl_get_active_folder(inputs_tab_->tabfolder_outer);
- else if( form2 == outputs_tab_->form )
+ else if (form2 == outputs_tab_->form)
form3 = fl_get_active_folder(outputs_tab_->tabfolder_outer);
- else if( form2 == usage_tab_->form )
+ else if (form2 == usage_tab_->form)
form3 = fl_get_active_folder(usage_tab_->tabfolder_outer);
if (form3 && form3->visible)
{
FormBase::ok();
- if( modifiedXformPrefs ) {
+ if (modifiedXformPrefs) {
string filename = user_lyxdir + "/preferences.xform";
- modifiedXformPrefs = ! XformColor::write( filename );
+ modifiedXformPrefs = ! XformColor::write(filename);
}
lv_->getLyXFunc()->Dispatch(LFUN_SAVEPREFERENCES);
static int minw_sb;
FormRef::FormRef(LyXView * lv, Dialogs * d)
- : FormCommand(lv, d, _("Reference")), toggle(GOBACK), dialog_(0)
+ : FormCommand(lv, d, _("Reference"), new OkCancelReadOnlyPolicy),
+ toggle(GOBACK), dialog_(0)
{
// let the dialog be shown
// These are permanent connections so we won't bother
FL_FORM * FormRef::form() const
{
- if (dialog_ ) return dialog_->form;
+ if (dialog_) return dialog_->form;
return 0;
}
void FormRef::connect()
{
- fl_set_form_maxsize( form(), 2*minw_, minh_ );
+ fl_set_form_maxsize(form(), 2 * minw_, minh_);
FormCommand::connect();
}
// Name is irrelevant to LaTeX documents
if (lv_->buffer()->isLatex()) {
- fl_deactivate_object( dialog_->name );
- fl_set_object_lcol( dialog_->name, FL_INACTIVE );
+ fl_deactivate_object(dialog_->name);
+ fl_set_object_lcol(dialog_->name, FL_INACTIVE);
}
// Can change reference only through browser
- fl_deactivate_object( dialog_->ref );
+ fl_deactivate_object(dialog_->ref);
- bc_.setOK( dialog_->button_ok );
- bc_.setCancel( dialog_->button_cancel );
- bc_.addReadOnly( dialog_->type );
+ bc_.setOK(dialog_->button_ok);
+ bc_.setCancel(dialog_->button_cancel);
+ bc_.addReadOnly(dialog_->type);
bc_.refresh();
}
fl_set_input(dialog_->name, params.getOptions().c_str());
Type type = getType();
- fl_set_choice( dialog_->type, type+1 );
+ fl_set_choice(dialog_->type, type + 1);
toggle = GOBACK;
fl_set_object_label(dialog_->button_go, _("Goto reference"));
refs.clear();
if (inset_ == 0) {
refs = lv_->buffer()->getLabelList();
- updateBrowser( refs );
+ updateBrowser(refs);
showBrowser();
} else {
hideBrowser();
}
- bc_.readOnly( lv_->buffer()->isReadonly() );
+ bc_.readOnly(lv_->buffer()->isReadonly());
}
-void FormRef::updateBrowser( vector<string> keys ) const
+void FormRef::updateBrowser(vector<string> const & akeys) const
{
- if (fl_get_button( dialog_->sort ) )
- sort( keys.begin(), keys.end() );
+ vector<string> keys(akeys);
+ if (fl_get_button( dialog_->sort))
+ sort(keys.begin(), keys.end());
- fl_clear_browser( dialog_->browser );
+ fl_clear_browser(dialog_->browser);
for (vector<string>::const_iterator it = keys.begin();
- it != keys.end(); ++it )
- fl_add_browser_line( dialog_->browser, (*it).c_str());
+ it != keys.end(); ++it)
+ fl_add_browser_line(dialog_->browser, (*it).c_str());
if (keys.empty()) {
- fl_add_browser_line( dialog_->browser,
- _("*** No labels found in document ***"));
-
- fl_deactivate_object( dialog_->browser );
- fl_deactivate_object( dialog_->button_update );
- fl_deactivate_object( dialog_->sort );
- fl_set_object_lcol( dialog_->browser, FL_INACTIVE );
- fl_set_object_lcol( dialog_->button_update, FL_INACTIVE );
- fl_set_object_lcol( dialog_->sort, FL_INACTIVE );
+ fl_add_browser_line(dialog_->browser,
+ _("*** No labels found in document ***"));
+
+ fl_deactivate_object(dialog_->browser);
+ fl_deactivate_object(dialog_->button_update);
+ fl_deactivate_object(dialog_->sort);
+ fl_set_object_lcol(dialog_->browser, FL_INACTIVE);
+ fl_set_object_lcol(dialog_->button_update, FL_INACTIVE);
+ fl_set_object_lcol(dialog_->sort, FL_INACTIVE);
} else {
- fl_set_browser_topline( dialog_->browser, 1 );
- fl_activate_object( dialog_->browser );
- fl_set_object_lcol( dialog_->browser, FL_BLACK );
- fl_activate_object( dialog_->button_update );
- fl_set_object_lcol( dialog_->button_update, FL_BLACK );
- fl_activate_object( dialog_->sort );
- fl_set_object_lcol( dialog_->sort, FL_BLACK );
+ fl_set_browser_topline(dialog_->browser, 1);
+ fl_activate_object(dialog_->browser);
+ fl_set_object_lcol(dialog_->browser, FL_BLACK);
+ fl_activate_object(dialog_->button_update);
+ fl_set_object_lcol(dialog_->button_update, FL_BLACK);
+ fl_activate_object(dialog_->sort);
+ fl_set_object_lcol(dialog_->sort, FL_BLACK);
}
}
void FormRef::showBrowser() const
{
- fl_show_object( dialog_->browser );
- fl_show_object( dialog_->button_update );
- fl_show_object( dialog_->sort );
+ fl_show_object(dialog_->browser);
+ fl_show_object(dialog_->button_update);
+ fl_show_object(dialog_->sort);
- setSize( minw_sb, 0 );
+ setSize(minw_sb, 0);
- fl_deactivate_object( dialog_->type );
- fl_set_object_lcol( dialog_->type, FL_INACTIVE );
- fl_deactivate_object( dialog_->button_go );
- fl_set_object_lcol( dialog_->button_go, FL_INACTIVE );
- fl_set_object_lcol( dialog_->ref, FL_INACTIVE );
+ fl_deactivate_object(dialog_->type);
+ fl_set_object_lcol(dialog_->type, FL_INACTIVE);
+ fl_deactivate_object(dialog_->button_go);
+ fl_set_object_lcol(dialog_->button_go, FL_INACTIVE);
+ fl_set_object_lcol(dialog_->ref, FL_INACTIVE);
bc_.valid(false);
}
void FormRef::hideBrowser() const
{
- fl_hide_object( dialog_->browser );
- fl_hide_object( dialog_->button_update );
- fl_hide_object( dialog_->sort );
+ fl_hide_object(dialog_->browser);
+ fl_hide_object(dialog_->button_update);
+ fl_hide_object(dialog_->sort);
- setSize( minw_hb, 280 );
+ setSize(minw_hb, 280);
- fl_activate_object( dialog_->type );
- fl_set_object_lcol( dialog_->type, FL_BLACK );
- fl_activate_object( dialog_->button_go );
- fl_set_object_lcol( dialog_->button_go, FL_BLACK );
- fl_set_object_lcol( dialog_->ref, FL_BLACK );
+ fl_activate_object(dialog_->type);
+ fl_set_object_lcol(dialog_->type, FL_BLACK);
+ fl_activate_object(dialog_->button_go);
+ fl_set_object_lcol(dialog_->button_go, FL_BLACK);
+ fl_set_object_lcol(dialog_->ref, FL_BLACK);
bc_.invalid();
}
-void FormRef::setSize( int w, int dx ) const
+void FormRef::setSize(int w, int dx) const
{
static int x1 = dialog_->name->x;
static int y1 = dialog_->name->y;
if (form()->w != w) {
minw_ = w;
- fl_set_form_size( form(), minw_, minh_ );
+ fl_set_form_size(form(), minw_, minh_);
} else
return;
- fl_set_object_position( dialog_->name, x1-dx, y1 );
- fl_set_object_position( dialog_->ref, x2-dx, y2 );
- fl_set_object_position( dialog_->type, x3-dx, y3 );
- fl_set_object_position( dialog_->button_go, x4-dx, y4 );
- fl_set_object_position( dialog_->button_ok, x5-dx, y5 );
- fl_set_object_position( dialog_->button_cancel, x6-dx, y6 );
+ fl_set_object_position(dialog_->name, x1 - dx, y1);
+ fl_set_object_position(dialog_->ref, x2 - dx, y2);
+ fl_set_object_position(dialog_->type, x3 - dx, y3);
+ fl_set_object_position(dialog_->button_go, x4 - dx, y4);
+ fl_set_object_position(dialog_->button_ok, x5 - dx, y5);
+ fl_set_object_position(dialog_->button_cancel, x6 - dx, y6);
// These two must be reset apparently
// Name is irrelevant to LaTeX documents
if (lv_->buffer()->isLatex()) {
- fl_deactivate_object( dialog_->name );
- fl_set_object_lcol( dialog_->name, FL_INACTIVE );
+ fl_deactivate_object(dialog_->name);
+ fl_set_object_lcol(dialog_->name, FL_INACTIVE);
}
// Can change reference only through browser
- fl_deactivate_object( dialog_->ref );
+ fl_deactivate_object(dialog_->ref);
}
// Seems okay except that goref and goback shouldn't
// affect the status of ok.
#endif
-bool FormRef::input( FL_OBJECT *, long data )
+bool FormRef::input(FL_OBJECT *, long data)
{
- bool activate( true );
+ bool activate(true);
switch (data) {
// goto reference / go back
case 1:
// choose browser key
case 2:
{
- unsigned int sel = fl_get_browser( dialog_->browser );
- if (sel < 1 || sel > refs.size() ) break;
+ unsigned int sel = fl_get_browser(dialog_->browser);
+ if (sel < 1 || sel > refs.size()) break;
- string s = fl_get_browser_line( dialog_->browser, sel );
- fl_set_input( dialog_->ref, s.c_str());
- params.setContents( s );
+ string s = fl_get_browser_line(dialog_->browser, sel);
+ fl_set_input(dialog_->ref, s.c_str());
+ params.setContents(s);
toggle = GOBACK;
lv_->getLyXFunc()->Dispatch(LFUN_REF_BACK);
fl_set_object_label(dialog_->button_go, _("Goto reference"));
- fl_activate_object( dialog_->type );
- fl_set_object_lcol( dialog_->type, FL_BLACK );
- fl_activate_object( dialog_->button_go );
- fl_set_object_lcol( dialog_->button_go, FL_BLACK );
- fl_set_object_lcol( dialog_->ref, FL_BLACK );
+ fl_activate_object(dialog_->type);
+ fl_set_object_lcol(dialog_->type, FL_BLACK);
+ fl_activate_object(dialog_->button_go);
+ fl_set_object_lcol(dialog_->button_go, FL_BLACK);
+ fl_set_object_lcol(dialog_->ref, FL_BLACK);
}
break;
// update or sort
case 3:
{
- fl_freeze_form( form() );
- updateBrowser( refs );
- fl_unfreeze_form( form() );
+ fl_freeze_form(form());
+ updateBrowser(refs);
+ fl_unfreeze_form(form());
}
break;
case 4:
{
Type type = static_cast<Type>(
- fl_get_choice(dialog_->type) - 1 );
- if (params.getCmdName() == getName( type )
+ fl_get_choice(dialog_->type) - 1);
+ if (params.getCmdName() == getName(type)
&& inset_) {
activate = false;
}
}
-string FormRef::getName( Type type ) const
+string const FormRef::getName(Type type) const
{
string name;
~FormRef();
private:
///
- enum Type{
+ enum Type {
///
REF,
///
PRETTYREF
};
///
- enum Goto{
+ enum Goto {
///
GOREF,
///
/// Build the dialog
virtual void build();
/// Filter the input
- virtual bool input( FL_OBJECT *, long );
+ virtual bool input(FL_OBJECT *, long);
/// Update dialog before showing it
virtual void update();
/// Not used but must be instantiated
virtual FL_FORM * form() const;
///
- void updateBrowser( std::vector<string> ) const;
+ void updateBrowser(std::vector<string> const &) const;
///
void showBrowser() const;
///
void hideBrowser() const;
///
- void setSize( int, int ) const;
+ void setSize(int, int) const;
///
FD_form_ref * build_ref();
///
Type getType() const;
///
- string getName( Type type ) const;
+ string const getName(Type type) const;
///
Goto toggle;
FormTabular::FormTabular(LyXView * lv, Dialogs * d)
- : FormInset( lv, d, _("Tabular Layout") ),
+ : FormInset(lv, d, _("Tabular Layout"), new OkCancelReadOnlyPolicy),
dialog_(0), tabular_options_(0), column_options_(0),
cell_options_(0), longtable_options_(0),
inset_(0), actCell_(-1)
void FormTabular::redraw()
{
- if( form() && form()->visible )
- fl_redraw_form( form() );
+ if(form() && form()->visible)
+ fl_redraw_form(form());
else
return;
FL_FORM * outer_form = fl_get_active_folder(dialog_->tabFolder);
if (outer_form && outer_form->visible)
- fl_redraw_form( outer_form );
+ fl_redraw_form(outer_form);
}
FL_FORM * FormTabular::form() const
{
- if (dialog_ ) return dialog_->form;
+ if (dialog_) return dialog_->form;
return 0;
}
}
-void FormTabular::showInset( InsetTabular * inset )
+void FormTabular::showInset(InsetTabular * inset)
{
if (inset == 0) return;
}
-void FormTabular::updateInset( InsetTabular * inset )
+void FormTabular::updateInset(InsetTabular * inset)
{
if (inset == 0 || inset_ == 0) return;
if (!inset_ || !inset_->tabular)
return;
- LyXTabular
- * tabular = inset_->tabular;
+ LyXTabular * tabular = inset_->tabular;
int
align,
- cell,
- column,row;
+ cell;
char
buf[12];
string
pwidth, special;
actCell_ = cell = inset_->GetActCell();
- column = tabular->column_of_cell(cell)+1;
+ int column = tabular->column_of_cell(cell)+1;
fl_set_object_label(dialog_->text_warning,"");
fl_activate_object(column_options_->input_special_alignment);
fl_activate_object(cell_options_->input_special_multialign);
sprintf(buf,"%d",column);
fl_set_input(dialog_->input_tabular_column, buf);
fl_deactivate_object(dialog_->input_tabular_column);
- row = tabular->row_of_cell(cell)+1;
+ int row = tabular->row_of_cell(cell)+1;
sprintf(buf,"%d",row);
fl_set_input(dialog_->input_tabular_row, buf);
fl_deactivate_object(dialog_->input_tabular_row);
if (!inset_)
return false;
- LyXTabular
- * tabular = inset_->tabular;
- int
- cell,
- s;
- LyXTabular::Feature
- num = LyXTabular::LAST_ACTION;
- string
- special,
- str;
-
- cell = inset_->GetActCell();
+ LyXTabular * tabular = inset_->tabular;
+ int s;
+ LyXTabular::Feature num = LyXTabular::LAST_ACTION;
+ string special;;
+
+ int cell = inset_->GetActCell();
if (actCell_ != cell) {
update();
fl_set_object_label(dialog_->text_warning,
return false;
}
if (ob == column_options_->input_column_width) {
- string
- str;
- str = fl_get_input(ob);
+ string str = fl_get_input(ob);
if (!str.empty() && !isValidLength(str)) {
fl_set_object_label(dialog_->text_warning,
_("Warning: Invalid Length (valid example: 10mm)"));
return true;
}
if (ob == cell_options_->input_mcolumn_width) {
- string
- str;
- str = fl_get_input(ob);
+ string str = fl_get_input(ob);
if (!str.empty() && !isValidLength(str)) {
fl_set_object_label(dialog_->text_warning,
_("Warning: Invalid Length (valid example: 10mm)"));
update(); // update for alignment
return true;
}
- str = fl_get_input(column_options_->input_column_width);
+ string str = fl_get_input(column_options_->input_column_width);
if (!str.empty() && !isValidLength(str)) {
fl_set_object_label(
dialog_->text_warning,
else if (ob == cell_options_->radio_multicolumn)
num = LyXTabular::MULTICOLUMN;
else if (ob == tabular_options_->radio_longtable) {
- s=fl_get_button(tabular_options_->radio_longtable);
+ s = fl_get_button(tabular_options_->radio_longtable);
if (s) {
num = LyXTabular::SET_LONGTABULAR;
fl_activate_object(longtable_options_->radio_lt_firsthead);
FL_INACTIVE);
}
} else if (ob == tabular_options_->radio_rotate_tabular) {
- s=fl_get_button(tabular_options_->radio_rotate_tabular);
+ s = fl_get_button(tabular_options_->radio_rotate_tabular);
if (s)
num = LyXTabular::SET_ROTATE_TABULAR;
else
num = LyXTabular::UNSET_ROTATE_TABULAR;
} else if (ob == cell_options_->radio_rotate_cell) {
- s=fl_get_button(cell_options_->radio_rotate_cell);
+ s = fl_get_button(cell_options_->radio_rotate_cell);
if (s)
num = LyXTabular::SET_ROTATE_CELL;
else
#include "insets/insettabular.h"
FormTabularCreate::FormTabularCreate(LyXView * lv, Dialogs * d)
- : FormBaseBD(lv, d, _("Insert Tabular")),
+ : FormBaseBD(lv, d, _("Insert Tabular"),
+ new OkApplyCancelReadOnlyPolicy),
dialog_(0)
{
// let the dialog be shown
FL_FORM * FormTabularCreate::form() const
{
- if (dialog_ ) return dialog_->form;
+ if (dialog_) return dialog_->form;
return 0;
}
#include "lyxfunc.h"
FormUrl::FormUrl(LyXView * lv, Dialogs * d)
- : FormCommand(lv, d, _("Url")), dialog_(0)
+ : FormCommand(lv, d, _("Url"), new OkCancelReadOnlyPolicy),
+ dialog_(0)
{
// let the dialog be shown
// These are permanent connections so we won't bother
void FormUrl::connect()
{
- fl_set_form_maxsize( form(), 2*minw_, minh_ );
+ fl_set_form_maxsize(form(), 2 * minw_, minh_);
FormCommand::connect();
}
fl_set_input(dialog_->url, params.getContents().c_str());
fl_set_input(dialog_->name, params.getOptions().c_str());
- if (params.getCmdName() == "url" )
+ if (params.getCmdName() == "url")
fl_set_button(dialog_->radio_html, 0);
else
fl_set_button(dialog_->radio_html, 1);
if (lv_->buffer()->isReadonly()) {
- fl_deactivate_object( dialog_->url );
- fl_deactivate_object( dialog_->name );
- fl_deactivate_object( dialog_->radio_html );
- fl_deactivate_object( dialog_->button_ok );
- fl_set_object_lcol( dialog_->button_ok, FL_INACTIVE );
+ fl_deactivate_object(dialog_->url);
+ fl_deactivate_object(dialog_->name);
+ fl_deactivate_object(dialog_->radio_html);
+ fl_deactivate_object(dialog_->button_ok);
+ fl_set_object_lcol(dialog_->button_ok, FL_INACTIVE);
} else {
- fl_activate_object( dialog_->url );
- fl_activate_object( dialog_->name );
- fl_activate_object( dialog_->radio_html );
- fl_activate_object( dialog_->button_ok );
- fl_set_object_lcol( dialog_->button_ok, FL_BLACK );
+ fl_activate_object(dialog_->url);
+ fl_activate_object(dialog_->name);
+ fl_activate_object(dialog_->radio_html);
+ fl_activate_object(dialog_->button_ok);
+ fl_set_object_lcol(dialog_->button_ok, FL_BLACK);
}
}
extern "C" void PreambleApplyCB(FL_OBJECT *, long);
extern "C" void PreambleCancelCB(FL_OBJECT *, long);
-/* Some extra funcs */
-
-extern bool UpdateLayoutPreamble();
/**** Forms and Objects ****/
typedef struct {
#include FORMS_H_LOCATION
#include "lyx.h"
#include "layout_forms.h"
-//#include "form1.h"
#include "lyx_main.h"
#include "lyx_cb.h"
-//#include "insets/insetref.h"
#include "insets/insetlabel.h"
#include "insets/figinset.h"
#include "lyxfunc.h"
#include "filedlg.h"
#include "lyx_gui_misc.h"
#include "LyXView.h"
-//#include "BufferView.h"
#include "lastfiles.h"
#include "bufferview_funcs.h"
#include "support/FileInfo.h"
#include "support/syscall.h"
#include "support/filetools.h"
#include "support/path.h"
-//#include "support/lyxlib.h"
-//#include "lyxserver.h"
#include "lyxrc.h"
#include "lyxtext.h"
-//#include "CutAndPaste.h"
-//#include "exporter.h"
using std::ifstream;
using std::copy;
extern void MenuSendto();
-//extern LyXServer * lyxserver;
-
// this should be static, but I need it in buffer.C
bool quitting; // flag, that we are quitting the program
extern bool finished; // all cleanup done just let it run through now.
-----------------------------------------------------------------------
*/
-/* some function prototypes */
-
-int RunLinuxDoc(BufferView *, int, string const &);
-int RunDocBook(int, string const &);
-bool MenuWrite(Buffer * buf);
-bool MenuWriteAs(Buffer * buffer);
-void MenuReload(Buffer * buf);
-void MenuLayoutSave();
-
void ShowMessage(Buffer const * buf,
string const & msg1,
//
// should be moved to lyxfunc.C
-bool MenuWrite(Buffer * buffer)
+bool MenuWrite(BufferView * bv, Buffer * buffer)
{
XFlush(fl_get_display());
if (!buffer->save()) {
- string fname = buffer->fileName();
- string s = MakeAbsPath(fname);
+ string const fname = buffer->fileName();
+ string const s = MakeAbsPath(fname);
if (AskQuestion(_("Save failed. Rename and try again?"),
MakeDisplayPath(s, 50),
_("(If not, document is not saved.)"))) {
- return MenuWriteAs(buffer);
+ return MenuWriteAs(bv, buffer);
}
return false;
} else {
// should be moved to BufferView.C
// Half of this func should be in LyXView, the rest in BufferView.
-bool MenuWriteAs(Buffer * buffer)
+bool MenuWriteAs(BufferView * bv, Buffer * buffer)
{
// Why do we require BufferView::text to be able to write a
// document? I see no point in that. (Lgb)
string oldname = fname;
LyXFileDlg fileDlg;
- ProhibitInput(current_view);
+ ProhibitInput(bv);
fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
fileDlg.SetButton(1, _("Templates"), lyxrc.template_path);
"*.lyx",
OnlyFilename(fname));
- AllowInput(current_view);
+ AllowInput(bv);
if (fname.empty())
return false;
return false;
} // Check whether the file exists
else {
- FileInfo myfile(s);
+ FileInfo const myfile(s);
if (myfile.isOK() && !AskQuestion(_("Document already exists:"),
MakeDisplayPath(s, 50),
_("Replace file?")))
// Small bug: If the save fails, we have irreversible changed the name
// of the document.
// Hope this is fixed this way! (Jug)
- if (!MenuWrite(buffer)) {
+ if (!MenuWrite(bv, buffer)) {
buffer->setFileName(oldname);
buffer->setUnnamed(unnamed);
ShowMessage(buffer, _("Document could not be saved!"),
return ret;
}
+
#if 0
void MenuFax(Buffer * buffer)
{
// tmp_ret will be located (usually) in /tmp
// will that be a problem?
- pid_t pid = fork(); // If you want to debug the autosave
+ pid_t const pid = fork(); // If you want to debug the autosave
// you should set pid to -1, and comment out the
// fork.
if (pid == 0 || pid == -1) {
// anyway.
bool failed = false;
- string tmp_ret = lyx::tempName();
+ string const tmp_ret = lyx::tempName();
if (!tmp_ret.empty()) {
bv->buffer()->writeFile(tmp_ret, 1);
// assume successful write of tmp_ret
}
-void MenuInsertLabel(string const & arg)
+void MenuInsertLabel(BufferView * bv, string const & arg)
{
string label(arg);
- ProhibitInput(current_view);
+ ProhibitInput(bv);
if (label.empty()) {
pair<bool, string>
result = askForText(_("Enter new label to insert:"));
if (!label.empty()) {
InsetCommandParams p( "label", label );
InsetLabel * inset = new InsetLabel( p );
- current_view->insertInset( inset );
+ bv->insertInset( inset );
}
- AllowInput(current_view);
+ AllowInput(bv);
}
// current_view. (Lgb)
void LayoutsCB(int sel, void *, Combox *)
{
- string tmp = tostr(sel);
+ string const tmp = tostr(sel);
current_view->owner()->getLyXFunc()->Dispatch(LFUN_LAYOUTNO,
tmp);
}
}
-bool UpdateLayoutPreamble()
+bool UpdateLayoutPreamble(BufferView * bv)
{
bool update = true;
- if (!current_view->available())
+ if (!bv->available())
update = false;
if (update) {
fl_set_input(fd_form_preamble->input_preamble,
- current_view->buffer()->params.preamble.c_str());
+ bv->buffer()->params.preamble.c_str());
- if (current_view->buffer()->isReadonly()) {
+ if (bv->buffer()->isReadonly()) {
fl_deactivate_object(fd_form_preamble->input_preamble);
fl_deactivate_object(fd_form_preamble->button_ok);
fl_deactivate_object(fd_form_preamble->button_apply);
fl_set_object_lcol(fd_form_preamble->button_ok, FL_INACTIVE);
fl_set_object_lcol(fd_form_preamble->button_apply, FL_INACTIVE);
- }
- else {
+ } else {
fl_activate_object(fd_form_preamble->input_preamble);
fl_activate_object(fd_form_preamble->button_ok);
fl_activate_object(fd_form_preamble->button_apply);
{
static int ow = -1, oh;
- if (UpdateLayoutPreamble()) {
+ if (UpdateLayoutPreamble(current_view)) {
if (fd_form_preamble->form_preamble->visible) {
fl_raise_form(fd_form_preamble->form_preamble);
} else {
}
-void MenuLayoutSave()
+void MenuLayoutSave(BufferView * bv)
{
- if (!current_view->available())
+ if (!bv->available())
return;
if (AskQuestion(_("Do you want to save the current settings"),
_("for Character, Document, Paper and Quotes"),
_("as default for new documents?")))
- current_view->buffer()->saveParamsAsDefaults();
+ bv->buffer()->saveParamsAsDefaults();
}
/* callbacks for form form_title */
-extern "C" void TimerCB(FL_OBJECT *, long)
+extern "C"
+void TimerCB(FL_OBJECT *, long)
{
// only if the form still exists
if (lyxrc.show_banner
/* callbacks for form form_character */
-extern "C" void CharacterApplyCB(FL_OBJECT *, long)
+extern "C"
+void CharacterApplyCB(FL_OBJECT *, long)
{
// we set toggleall locally here, since it should be true for
// all other uses of ToggleAndShow() (JMarc)
}
-extern "C" void CharacterCloseCB(FL_OBJECT *, long)
+extern "C"
+void CharacterCloseCB(FL_OBJECT *, long)
{
fl_hide_form(fd_form_character->form_character);
}
-extern "C" void CharacterOKCB(FL_OBJECT *ob, long data)
+extern "C"
+void CharacterOKCB(FL_OBJECT * ob, long data)
{
CharacterApplyCB(ob, data);
CharacterCloseCB(ob, data);
/* callbacks for form form_preamble */
-extern "C" void PreambleCancelCB(FL_OBJECT *, long)
+extern "C"
+void PreambleCancelCB(FL_OBJECT *, long)
{
fl_hide_form(fd_form_preamble->form_preamble);
}
-extern "C" void PreambleApplyCB(FL_OBJECT *, long)
+extern "C"
+void PreambleApplyCB(FL_OBJECT *, long)
{
if (!current_view->available())
return;
}
-extern "C" void PreambleOKCB(FL_OBJECT * ob, long data)
+extern "C"
+void PreambleOKCB(FL_OBJECT * ob, long data)
{
PreambleApplyCB(ob, data);
PreambleCancelCB(ob, data);
#include "lyxfont.h"
class BufferParams;
+class BufferView;
+class Combox;
///
extern bool quitting;
string const & msg1,
string const & msg2 = string(),
string const & msg3 = string(), int delay = 6);
+///
+bool MenuWrite(BufferView * bv, Buffer * buffer);
+///
+bool MenuWriteAs(BufferView * bv, Buffer * buffer);
+///
+int MenuRunChktex(Buffer * buffer);
+///
+void QuitLyX();
+///
+void AutoSave(BufferView * bv);
+///
+Buffer * NewLyxFile(string const & filename);
+///
+void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph);
+///
+void MenuInsertLabel(BufferView * bv, string const & arg);
+///
+void LayoutsCB(int sel, void *, Combox *);
+///
+void MenuLayoutCharacter();
+///
+bool UpdateLayoutPreamble(BufferView * bv);
+///
+void MenuLayoutPreamble();
+///
+void MenuLayoutSave(BufferView * bv);
+///
+LyXFont const UserFreeFont(BufferParams const & params);
+///
+void Figure();
+///
+void Reconfigure(BufferView * bv);
+
#endif
void updateAllVisibleBufferRelatedDialogs(bool)
{
if (fd_form_preamble->form_preamble->visible) {
- UpdateLayoutPreamble();
+ UpdateLayoutPreamble(current_view);
}
if (fd_latex_log->LaTeXLog->visible) {
LatexLogUpdate(0,0);
using std::endl;
using std::find_if;
-extern void InsertAsciiFile(BufferView *, string const &, bool);
extern void math_insert_symbol(string const &);
extern bool math_insert_greek(char);
extern BufferList bufferlist;
extern kb_keymap * toplevel_keymap;
-extern bool MenuWrite(Buffer *);
-extern bool MenuWriteAs(Buffer *);
-extern int MenuRunLaTeX(Buffer *);
-extern int MenuBuildProg(Buffer *);
-extern int MenuRunChktex(Buffer *);
-extern void MenuPrint(Buffer *);
-extern void MenuSendto();
-extern void QuitLyX();
#if 0
extern void MenuFax(Buffer *);
#endif
// (alkis)
extern tex_accent_struct get_accent(kb_action action);
-extern void AutoSave(BufferView *);
-extern void MenuInsertLabel(string const &);
-extern void MenuLayoutCharacter();
-extern void MenuLayoutParagraph();
-extern void MenuLayoutPreamble();
-extern void MenuLayoutSave();
-
-extern Buffer * NewLyxFile(string const &);
-extern void LoadLyXFile(string const &);
-extern void Reconfigure(BufferView *);
-
extern LyXTextClass::size_type current_layout;
-extern int getISOCodeFromLaTeX(char *);
extern void ShowLatexLog();
owner->getMiniBuffer()->Set(_("Saving document"),
MakeDisplayPath(owner->buffer()->fileName()),
"...");
- MenuWrite(owner->buffer());
+ MenuWrite(owner->view(), owner->buffer());
//owner->getMiniBuffer()-> {
// Set(_("Document saved as"),
// MakeDisplayPath(owner->buffer()->fileName()));
//owner->getMiniBuffer()->Set(_("Save failed!"));
//}
} else {
- MenuWriteAs(owner->buffer());
+ MenuWriteAs(owner->view(), owner->buffer());
}
break;
case LFUN_MENUWRITEAS:
- MenuWriteAs(owner->buffer());
+ MenuWriteAs(owner->view(), owner->buffer());
break;
case LFUN_MENURELOAD:
break;
case LFUN_LAYOUT_SAVE_DEFAULT:
- MenuLayoutSave();
+ MenuLayoutSave(owner->view());
break;
case LFUN_DROP_LAYOUTS_CHOICE:
break;
case LFUN_INSERT_LABEL:
- MenuInsertLabel(argument);
+ MenuInsertLabel(owner->view(), argument);
break;
case LFUN_REF_INSERT:
if (s.empty())
setErrorMessage(N_("Missing argument"));
else {
- string s1 = token(s, ' ', 1);
- int na = s1.empty() ? 0 : lyx::atoi(s1);
+ string const s1 = token(s, ' ', 1);
+ int const na = s1.empty() ? 0 : lyx::atoi(s1);
owner->view()->
open_new_inset(new InsetFormulaMacro(token(s, ' ', 0), na));
}
// ale970405+lasgoutt970425
// The argument can be up to two tokens separated
// by a space. The first one is the bibstyle.
- string db = token(argument, ' ', 0);
+ string const db = token(argument, ' ', 0);
string bibstyle = token(argument, ' ', 1);
if (bibstyle.empty())
bibstyle = "plain";
case LFUN_INDEX_INSERT:
{
InsetCommandParams p;
- p.setFromString( argument );
- InsetIndex * inset = new InsetIndex( p );
+ p.setFromString(argument);
+ InsetIndex * inset = new InsetIndex(p);
if (!owner->view()->insertInset(inset))
delete inset;
else
- owner->view()->updateInset( inset, true );
+ owner->view()->updateInset(inset, true);
}
break;
LyXParagraph::size_type curpos =
owner->view()->text->cursor.pos() - 1;
// Can't do that at the beginning of a paragraph
- if (curpos < 0 ) break;
+ if (curpos < 0) break;
- string curstring( owner->view()->text
- ->cursor.par()->GetWord(curpos) );
+ string const curstring(owner->view()->text
+ ->cursor.par()->GetWord(curpos));
- InsetCommandParams p( "index", curstring );
- InsetIndex * inset = new InsetIndex( p );
+ InsetCommandParams p("index", curstring);
+ InsetIndex * inset = new InsetIndex(p);
if (!owner->view()->insertInset(inset))
delete inset;
else
- owner->view()->updateInset( inset, true );
+ owner->view()->updateInset(inset, true);
}
break;
case LFUN_INDEX_PRINT:
{
- InsetCommandParams p( "printindex" );
+ InsetCommandParams p("printindex");
Inset * inset = new InsetPrintIndex(p);
if (!owner->view()->insertInset(inset, "Standard", true))
delete inset;
case LFUN_CHILDOPEN:
{
- string filename =
+ string const filename =
MakeAbsPath(argument,
OnlyPath(owner->buffer()->fileName()));
setMessage(N_("Opening child document ") +
case LFUN_INSERTFOOTNOTE:
{
LyXParagraph::footnote_kind kind;
- if (argument == "footnote")
- { kind = LyXParagraph::FOOTNOTE; }
- else if (argument == "margin")
- { kind = LyXParagraph::MARGIN; }
- else if (argument == "figure")
- { kind = LyXParagraph::FIG; }
- else if (argument == "table")
- { kind = LyXParagraph::TAB; }
- else if (argument == "wide-fig")
- { kind = LyXParagraph::WIDE_FIG; }
- else if (argument == "wide-tab")
- { kind = LyXParagraph::WIDE_TAB; }
- else if (argument == "algorithm")
- { kind = LyXParagraph::ALGORITHM; }
- else {
+ if (argument == "footnote") {
+ kind = LyXParagraph::FOOTNOTE;
+ } else if (argument == "margin") {
+ kind = LyXParagraph::MARGIN;
+ } else if (argument == "figure") {
+ kind = LyXParagraph::FIG;
+ } else if (argument == "table") {
+ kind = LyXParagraph::TAB;
+ } else if (argument == "wide-fig") {
+ kind = LyXParagraph::WIDE_FIG;
+ } else if (argument == "wide-tab") {
+ kind = LyXParagraph::WIDE_TAB;
+ } else if (argument == "algorithm") {
+ kind = LyXParagraph::ALGORITHM;
+ } else {
setErrorMessage(N_("Unknown kind of footnote"));
break;
}
case LFUN_SELFINSERT:
{
- LyXFont old_font(owner->view()->text->real_current_font);
+ LyXFont const old_font(owner->view()->text->real_current_font);
for (string::size_type i = 0; i < argument.length(); ++i) {
owner->view()->text->InsertChar(owner->view(), argument[i]);
// This needs to be in the loop, or else we
else
arg = lyxrc.date_insert_format;
char datetmp[32];
- int datetmp_len = ::strftime(datetmp, 32, arg.c_str(), now_tm);
+ int const datetmp_len =
+ ::strftime(datetmp, 32, arg.c_str(), now_tm);
for (int i = 0; i < datetmp_len; i++) {
owner->view()->text->InsertChar(owner->view(), datetmp[i]);
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
case LFUN_SET_COLOR:
{
- string lyx_name, x11_name;
- x11_name = split(argument, lyx_name, ' ');
+ string lyx_name;
+ string const x11_name = split(argument, lyx_name, ' ');
if (lyx_name.empty() || x11_name.empty()) {
LyXBell();
setErrorMessage(N_("Syntax: set-color <lyx_name>"
}
if (!lcolor.setColor(lyx_name, x11_name)) {
- static string err1 (N_("Set-color \""));
- static string err2 (N_("\" failed - color is undefined "
- "or may not be redefined"));
+ static string const err1 (N_("Set-color \""));
+ static string const err2 (
+ N_("\" failed - color is undefined "
+ "or may not be redefined"));
LyXBell();
- setErrorMessage(err1 + lyx_name + err2);
+ setErrorMessage(_(err1) + lyx_name + _(err2));
break;
}
lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
}
owner->view()->beforeChange();
- LyXFont old_font(owner->view()->text->real_current_font);
+ LyXFont const old_font(owner->view()->text->real_current_font);
for (string::size_type i = 0;
i < argument.length(); ++i) {
if (greek_kb_flag) {
} // end of switch
exit_with_message:
- string res = getMessage();
+ string const res = getMessage();
if (res.empty()) {
if (!commandshortcut.empty()) {
- string newbuf = owner->getMiniBuffer()->GetText();
+ string const newbuf =
+ owner->getMiniBuffer()->GetText();
if (newbuf != commandshortcut) {
owner->getMiniBuffer()->Set(newbuf
+ " " +
LyXFileDlg fileDlg;
if (owner->view()->available()) {
- string trypath = owner->buffer()->filepath;
+ string const trypath = owner->buffer()->filepath;
// If directory is writeable, use this as default.
if (IsDirWriteable(trypath) == 1)
initpath = trypath;
static int newfile_number = 0;
string s;
-
+
if (lyxrc.new_ask_filename) {
ProhibitInput(owner->view());
fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
string templname;
if (fromTemplate) {
ProhibitInput(owner->view());
- string fname = fileDlg.Select(_("Choose template"),
- lyxrc.template_path,
- "*.lyx");
+ string const fname = fileDlg.Select(_("Choose template"),
+ lyxrc.template_path,
+ "*.lyx");
AllowInput(owner->view());
if (fname.empty()) return;
templname = fname;
LyXFileDlg fileDlg;
if (owner->view()->available()) {
- string trypath = owner->buffer()->filepath;
+ string const trypath = owner->buffer()->filepath;
// If directory is writeable, use this as default.
if (IsDirWriteable(trypath) == 1)
initpath = trypath;
}
}
+
// checks for running without gui are missing.
void LyXFunc::doImport(string const & argument)
{
LyXFileDlg fileDlg;
if (owner->view()->available()) {
- string trypath = owner->buffer()->filepath;
+ string const trypath = owner->buffer()->filepath;
// If directory is writeable, use this as default.
if (IsDirWriteable(trypath) == 1)
initpath = trypath;
fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
fileDlg.SetButton(1, _("Examples"),
AddPath(system_lyxdir, "examples"));
- string text = _("Select ") + formats.PrettyName(format)
+ string const text = _("Select ") + formats.PrettyName(format)
+ _(" file to import");
- string extension = "*." + formats.Extension(format);
+ string const extension = "*." + formats.Extension(format);
filename = fileDlg.Select(text, initpath, extension);
AllowInput(owner->view());
// get absolute path of file
filename = MakeAbsPath(filename);
- string lyxfile = ChangeExtension(filename, ".lyx");
+ string const lyxfile = ChangeExtension(filename, ".lyx");
// Check if the document already is open
if (bufferlist.exists(lyxfile)) {
}
// Check if a LyX document by the same root exists in filesystem
- FileInfo f(lyxfile, true);
+ FileInfo const f(lyxfile, true);
if (f.exist() && !AskQuestion(_("A document by the name"),
MakeDisplayPath(lyxfile),
_("already exists. Overwrite?"))) {
LyXFileDlg fileDlg;
if (owner->view()->available()) {
- string trypath = owner->buffer()->filepath;
+ string const trypath = owner->buffer()->filepath;
// If directory is writeable, use this as default.
if (IsDirWriteable(trypath) == 1)
initpath = trypath;
// Inserts document
owner->getMiniBuffer()->Set(_("Inserting document"),
MakeDisplayPath(filename), "...");
- bool res = owner->view()->insertLyXFile(filename);
+ bool const res = owner->view()->insertLyXFile(filename);
if (res) {
owner->getMiniBuffer()->Set(_("Document"),
MakeDisplayPath(filename),
void LyXFunc::reloadBuffer()
{
- string fn = owner->buffer()->fileName();
+ string const fn = owner->buffer()->fileName();
if (bufferlist.close(owner->buffer()))
owner->view()->buffer(bufferlist.loadLyXFile(fn));
}
// set variables that don't exist
// since there's no current buffer
owner->getDialogs()->hideBufferDependent();
- }
- else {
+ } else {
owner->view()->buffer(bufferlist.first());
}
}
}
-#if 0
-// Returns an unique name to be used as a temporary file.
-string const TmpFileName(string const & dir, string const & mask)
-{// With all these temporary variables, it should be safe enough :-) (JMarc)
- string tmpdir;
- if (dir.empty())
- tmpdir = system_tempdir;
- else
- tmpdir = dir;
- string tmpfl(AddName(tmpdir, mask));
-
- // find a uniq postfix for the filename...
- // using the pid, and...
- tmpfl += tostr(getpid());
- // a short string...
- string ret;
- FileInfo fnfo;
- for (int a = 'a'; a <= 'z'; ++a)
- for (int b = 'a'; b <= 'z'; ++b)
- for (int c = 'a'; c <= 'z'; ++c) {
- // if this is not enough I have no idea what
- // to do.
- ret = tmpfl + char(a) + char(b) + char(c);
- // check if the file exist
- if (!fnfo.newFile(ret).exist())
- return ret;
- }
- lyxerr << "Not able to find a uniq tmpfile name." << endl;
- return string();
-}
-#endif
-
-
// Is a file readable ?
bool IsFileReadable (string const & path)
{
/// Returns a vector of all files in directory dir having extension ext.
-vector<string> const DirList( string const & dir, string const & ext)
+vector<string> const DirList(string const & dir, string const & ext)
{
- // What what what????
- // where you tinking when you implemented this?
-#if 0
- string lsCommand = "ls " + dir;
- if (!ext.empty()) {
- string::size_type sz = lsCommand.size();
- if (lsCommand[sz - 1] != '/')
- lsCommand += '/';
- lsCommand += '*';
- if (ext[0] != '.')
- lsCommand += '.';
- lsCommand += ext;
- }
- string tmpfile = system_tempdir + "/dirlist";
- lsCommand += " > " + tmpfile;
-
- Systemcalls(Systemcalls::System, lsCommand);
-
- string contents = GetFileContents(tmpfile);
- string rmCommand = "rm " + tmpfile;
- Systemcalls(Systemcalls::System, rmCommand);
-
- string tmp = strip(contents);
- vector<string> dirlist;
-
- while (!tmp.empty()) {
- string file;
- tmp = frontStrip(split(tmp, file, '\n'));
- dirlist.push_back( file );
- }
- return dirlist;
-#else
// This is a non-error checking C/system implementation
- // of the above.
string extension(ext);
if (extension[0] != '.')
- // If I do not use the explicit cast below, compaq cxx
- // is not able to guess between
- // insert(size_type, size_type, value_type)
- // and
- // insert(iterator, size_type, value_type)
- extension.insert(string::size_type(0), 1u, '.');
+ extension.insert(0, ".");
vector<string> dirlist;
DIR * dirp = ::opendir(dir.c_str());
dirent * dire;
while ((dire = ::readdir(dirp))) {
- string fil = dire->d_name;
+ string const fil = dire->d_name;
if (prefixIs(fil, extension)) {
dirlist.push_back(fil);
}
}
::closedir(dirp);
return dirlist;
+ /* I would have prefered to take a vector<string>& as parameter so
+ that we could avoid the copy of the vector when returning.
+ Then we would use:
+ dirlist.swap(argvec);
+ to avoid the copy. (Lgb)
+ */
/* A C++ implementaion will look like this:
- if (ext[0] != '.') ext.insert(0u, 1u, '.');
+ string extension(ext);
+ if (extension[0] != '.') extension.insert(0, ".");
+ vector<string> dirlist;
directory_iterator dit("dir");
while (dit != directory_iterator()) {
string fil = (*dit).filename;
- if (prefixIs(fil, ext)) {
+ if (prefixIs(fil, extension)) {
dirlist.push_back(fil);
}
++dit;
}
+ dirlist.swap(argvec);
+ return;
*/
-#endif
}
static
string const CreateTmpDir(string const & tempdir, string const & mask)
{
-#warning Possibly buggy (Lgb)
- lyxerr << "CreateTmpDir: tempdir=`" << tempdir << "'" << endl;
- lyxerr << "CreateTmpDir: mask=`" << mask << "'" << endl;
+ lyxerr[Debug::FILES]
+ << "CreateTmpDir: tempdir=`" << tempdir << "'\n"
+ << "CreateTmpDir: mask=`" << mask << "'" << endl;
string const tmpfl(lyx::tempName(tempdir, mask));
// lyx::tempName actually creates a file to make sure that it
}
-int DestroyLyXTmpDir (string const & tmpdir)
+int DestroyLyXTmpDir(string const & tmpdir)
{
return DestroyTmpDir (tmpdir, false); // Why false?
}
}
-#if 0
-// Returns current working directory
-string const GetCWD ()
-{
- int n = 256; // Assume path is less than 256 chars
- char * err;
- char * tbuf = new char[n];
-
- // Safe. Hopefully all getcwds behave this way!
- while (((err = lyx::getcwd(tbuf, n)) == 0) && (errno == ERANGE)) {
- // Buffer too small, double the buffersize and try again
- delete[] tbuf;
- n = 2 * n;
- tbuf = new char[n];
- }
-
- string result;
- if (err) result = tbuf;
- delete[] tbuf;
- return result;
-}
-#endif
-
-
// Strip filename from path name
string const OnlyPath(string const & Filename)
{
// different, then the absolute path will be used as relative path.
{
// This is a hack. It should probaly be done in another way. Lgb.
- string abspath = CleanupPath(abspath0);
- string basepath = CleanupPath(basepath0);
+ string const abspath = CleanupPath(abspath0);
+ string const basepath = CleanupPath(basepath0);
if (abspath.empty())
return "<unknown_path>";
// Go back to last /
if (i < abslen && i < baselen
- || (i<abslen && abspath[i] != '/' && i == baselen)
- || (i<baselen && basepath[i] != '/' && i == abslen))
+ || (i < abslen && abspath[i] != '/' && i == baselen)
+ || (i < baselen && basepath[i] != '/' && i == abslen))
{
if (i) --i; // here was the last match
while (i && abspath[i] != '/') --i;
buf += '/';
}
- if (!path2.empty()){
- string::size_type p2start = path2.find_first_not_of('/');
-
- string::size_type p2end = path2.find_last_not_of('/');
-
- string tmp = path2.substr(p2start, p2end - p2start + 1);
+ if (!path2.empty()) {
+ string::size_type const p2start = path2.find_first_not_of('/');
+ string::size_type const p2end = path2.find_last_not_of('/');
+ string const tmp = path2.substr(p2start, p2end - p2start + 1);
buf += tmp + '/';
}
return buf;
// Yes, filename in itself is too long.
// Pick the start and the end of the filename.
relhome = OnlyFilename(path);
- string head = relhome.substr(0, threshold/2 - 3);
+ string const head = relhome.substr(0, threshold/2 - 3);
l2 = relhome.length();
- string tail =
+ string const tail =
relhome.substr(l2 - threshold/2 - 2, l2 - 1);
relhome = head + "..." + tail;
}
LinkBuffer, sizeof(LinkBuffer) - 1);
if (nRead <= 0)
return false;
- LinkBuffer[nRead] = 0;
+ LinkBuffer[nRead] = '\0'; // terminator
Link = LinkBuffer;
return true;
}
ret += static_cast<char>(c);
c = fgetc(inf);
}
- int pret = pclose(inf);
+ int const pret = pclose(inf);
return make_pair(pret, ret);
}
a += '#';
a += OnlyFilename(filename);
a += '#';
- FileInfo fileinfo(a);
+ FileInfo const fileinfo(a);
if (fileinfo.exist()) {
if (lyx::unlink(a) != 0) {
WriteFSAlert(_("Could not delete auto-save file!"), a);
/// Put the name in quotes suitable for the current shell
string const QuoteName(string const & file);
-#if 0
-/** Returns an unique name to be used as a temporary file. If given,
- 'mask' should the prefix to the temporary file, the rest of the
- temporary filename will be made from the pid and three letters.
- */
-string const
-TmpFileName(string const & dir = string(),
- string const & mask = "lyx_tmp");
-#endif
-
/// Is a filename/path absolute?
bool AbsolutePath(string const & path);
/// Create absolute path. If impossible, don't do anything
string const ExpandPath(string const & path);
-#if 0
-/// gets current working directory
-string const GetCWD();
-#endif
-
/** Convert relative path into absolute path based on a basepath.
If relpath is absolute, just use that.
If basepath doesn't exist use CWD.
#include <config.h>
-#include "LString.h"
-
#include <cstdlib>
-
#include <unistd.h>
-#include "lyxlib.h"
+#include "LString.h"
+#include "support/lyxlib.h"
+#include "support/filetools.h"
#include "debug.h"
-#include "filetools.h"
using std::endl;
string const lyx::tempName(string const & dir, string const & mask)
{
-#if 0
- // the tmpnam version...
- char const * const tmp = ::tmpnam(0);
- return (tmp) ? tmp : string ();
-#else
- string tmpdir;
- if (dir.empty())
- tmpdir = system_tempdir;
- else
- tmpdir = dir;
+ string const tmpdir(dir.empty() ? system_tempdir : dir);
string tmpfl(AddName(tmpdir, mask));
tmpfl += tostr(getpid());
-
- // the supposedly safer mkstemp version
- char * tmpl = new char[256];
- tmpfl += ".XXXXXX";
- ::strcpy(tmpl, tmpfl.c_str());
- int tmpf = ::mkstemp(tmpl);
+ tmpfl += "XXXXXX";
+
+ // The supposedly safe mkstemp version
+ char * tmpl = new char[tmpfl.length() + 1]; // + 1 for '\0'
+ tmpfl.copy(tmpl, string::npos);
+ tmpl[tmpfl.length()] = '\0'; // terminator
+
+ int const tmpf = ::mkstemp(tmpl);
if (tmpf != -1) {
string const t(tmpl);
::close(tmpf);
delete [] tmpl;
- lyxerr << "Temporary file `" << t << "' created." << endl;
+ lyxerr[Debug::FILES] << "Temporary file `" << t
+ << "' created." << endl;
return t;
} else {
- lyxerr << "LyX Error: Unable to create temporary file."
- << endl;
+ lyxerr[Debug::FILES]
+ << "LyX Error: Unable to create temporary file."
+ << endl;
delete [] tmpl;
return string();
}
-#endif
}