fix a couple of hard crashes, constify local variables, whitespace changes, some changes to new code

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1215 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2000-11-14 02:01:57 +00:00
parent 000001c24b
commit a32d2c972f
34 changed files with 568 additions and 614 deletions

View File

@ -1,3 +1,67 @@
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

View File

@ -187,7 +187,7 @@ dnl Check the version of g++
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
@ -299,17 +299,15 @@ dnl count template, if not the old HP version is assumed.
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

View File

@ -1,7 +1,3 @@
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);
@ -16,7 +12,3 @@
> 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();

View File

@ -10,6 +10,7 @@ src/converter.C
src/credits.C
src/credits_form.C
src/CutAndPaste.C
src/debug.C
src/exporter.C
src/ext_l10n.h
src/filedlg.C
@ -47,35 +48,35 @@ src/frontends/kde/refdlg.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

View File

@ -47,6 +47,8 @@ using std::find_if;
using std::for_each;
using std::mem_fun;
extern BufferView * current_view;
//
// Class BufferStorage
//
@ -92,9 +94,6 @@ bool BufferList::empty() const
}
extern bool MenuWrite(Buffer *);
extern bool MenuWriteAs(Buffer *);
bool BufferList::QwriteAll()
{
bool askMoreConfirmation = false;
@ -114,9 +113,9 @@ bool BufferList::QwriteAll()
_("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
@ -190,7 +189,7 @@ bool BufferList::close(Buffer * buf)
_("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;

View File

@ -12,10 +12,12 @@
#endif
#include <config.h>
#include "debug.h"
#include <iomanip>
#include "debug.h"
#include "gettext.h"
using std::ostream;
using std::setw;
using std::endl;
@ -27,26 +29,27 @@ struct error_item {
};
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")}
};
@ -58,7 +61,7 @@ Debug::type const Debug::ANY = Debug::type(
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)
@ -94,8 +97,8 @@ void Debug::showLevel(ostream & o, Debug::type level)
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;
}
@ -104,6 +107,6 @@ void Debug::showTags(ostream & os)
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();
}

View File

@ -65,7 +65,9 @@ struct Debug {
///
DEPEND = (1 << 16),
///
INSETS = (1 << 17)
INSETS = (1 << 17),
///
FILES = (1 << 18)
};
///
// static const type ANY = type(INFO | INIT | KEY | GUI |

View File

@ -221,8 +221,10 @@ private:
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
*/
@ -256,16 +258,18 @@ private:
};
/** 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
*/
@ -300,14 +304,16 @@ private:
};
/** 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
*/
@ -342,7 +348,8 @@ private:
/** 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
*/
@ -374,7 +381,8 @@ private:
/** 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
*/
@ -407,7 +415,8 @@ private:
/** 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
*/

View File

@ -8,6 +8,7 @@
#include "ButtonController.h"
#include "support/LAssert.h"
//#include "debug.h"
ButtonController::ButtonController(ButtonPolicy * bp,
@ -88,6 +89,7 @@ void ButtonController::refresh()
void ButtonController::input(ButtonPolicy::SMInput in)
{
//lyxerr << "ButtonController::input: bp_[" << bp_ << "]" << endl;
bp_->input(in);
refresh();
}

View File

@ -28,29 +28,29 @@ using std::ofstream;
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;
@ -95,39 +95,39 @@ RGBColor::RGBColor( HSVColor const & hsv )
}
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;
}
}
@ -154,14 +154,14 @@ static const int xformCount = sizeof(xformTags) / sizeof(keyword_item);
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;
@ -172,13 +172,13 @@ bool XformColor::read(string const & filename)
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);
@ -207,14 +207,14 @@ bool XformColor::write(string const & filename)
<< "# 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";
}

View File

@ -20,16 +20,16 @@
#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 {
@ -37,8 +37,9 @@ 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;
@ -49,9 +50,9 @@ struct XformColor {
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

View File

@ -26,6 +26,7 @@
#include "FormTabularCreate.h"
#include "FormToc.h"
#include "FormUrl.h"
#include "debug.h"
#ifdef __GNUG__
#pragma implementation
@ -67,20 +68,12 @@ Dialogs::Dialogs(LyXView * lv)
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
}

View File

@ -22,6 +22,7 @@
#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?
@ -54,20 +55,21 @@ FormBase::FormBase(LyXView * lv, Dialogs * d, string const & t,
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_);
}
@ -79,9 +81,9 @@ void FormBase::show()
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());
@ -151,7 +153,7 @@ void FormBase::CancelCB(FL_OBJECT * ob, long)
}
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);
@ -173,7 +175,7 @@ void FormBase::RestoreCB(FL_OBJECT * ob, long)
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)
{}
@ -193,7 +195,7 @@ void FormBaseBI::disconnect()
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)
{}

View File

@ -112,8 +112,10 @@ protected: // methods
Connection h_;
/// dialog title, displayed by WM.
string title;
private:
///
ButtonPolicy * bp_;
public:
/// Overcome a dumb xforms sizing bug
mutable int minw_;
///
@ -129,7 +131,7 @@ class FormBaseBI : public FormBase {
protected:
/// Constructor
FormBaseBI(LyXView *, Dialogs *, string const &,
ButtonPolicy * bp = new OkApplyCancelPolicy,
ButtonPolicy * bp,
char const * close = N_("Close"),
char const * cancel = N_("Cancel"));
@ -146,7 +148,7 @@ class FormBaseBD : public FormBase {
protected:
/// Constructor
FormBaseBD(LyXView *, Dialogs *, string const &,
ButtonPolicy * bp = new OkApplyCancelReadOnlyPolicy,
ButtonPolicy * bp,
char const * close = N_("Close"),
char const * cancel = N_("Cancel"));

View File

@ -16,7 +16,8 @@
#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

View File

@ -23,7 +23,7 @@
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);

View File

@ -40,7 +40,7 @@ using std::endl;
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.

View File

@ -26,7 +26,8 @@
#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
@ -44,14 +45,14 @@ FormIndex::~FormIndex()
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();
}
@ -74,13 +75,13 @@ void FormIndex::update()
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);
}
}

View File

@ -25,7 +25,7 @@
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)
{}
@ -46,7 +46,7 @@ void FormInset::disconnect()
}
void FormInset::updateSlot( bool switched )
void FormInset::updateSlot(bool switched)
{
if (switched)
hide();
@ -55,10 +55,10 @@ void FormInset::updateSlot( bool switched )
}
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)
{}
@ -66,12 +66,12 @@ FormCommand::FormCommand( LyXView * lv, Dialogs * d, string const & t,
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?
@ -86,13 +86,13 @@ void FormCommand::showInset( InsetCommand * inset )
}
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();
}

View File

@ -25,10 +25,10 @@
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();
@ -49,18 +49,18 @@ protected:
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_;

View File

@ -118,29 +118,29 @@ FormPreferences::~FormPreferences()
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)
@ -159,9 +159,9 @@ void FormPreferences::ok()
{
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);

View File

@ -34,7 +34,8 @@ static int const minw_hb = 250;
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
@ -52,14 +53,14 @@ FormRef::~FormRef()
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();
}
@ -85,16 +86,16 @@ void FormRef::build()
// 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();
}
@ -105,7 +106,7 @@ void FormRef::update()
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"));
@ -113,82 +114,83 @@ void FormRef::update()
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_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_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;
@ -205,26 +207,26 @@ void FormRef::setSize( int w, int dx ) const
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);
}
@ -256,9 +258,9 @@ void FormRef::apply()
// 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:
@ -293,31 +295,31 @@ bool FormRef::input( FL_OBJECT *, long data )
// 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;
@ -325,8 +327,8 @@ bool FormRef::input( FL_OBJECT *, long data )
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;
}
@ -363,7 +365,7 @@ FormRef::Type FormRef::getType() const
}
string FormRef::getName( Type type ) const
string const FormRef::getName(Type type) const
{
string name;

View File

@ -29,7 +29,7 @@ public:
~FormRef();
private:
///
enum Type{
enum Type {
///
REF,
///
@ -42,7 +42,7 @@ private:
PRETTYREF
};
///
enum Goto{
enum Goto {
///
GOREF,
///
@ -59,7 +59,7 @@ private:
/// 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
@ -68,19 +68,19 @@ private:
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;

View File

@ -23,7 +23,7 @@
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)
@ -48,20 +48,20 @@ FormTabular::~FormTabular()
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;
}
@ -73,7 +73,7 @@ void FormTabular::disconnect()
}
void FormTabular::showInset( InsetTabular * inset )
void FormTabular::showInset(InsetTabular * inset)
{
if (inset == 0) return;
@ -88,7 +88,7 @@ void FormTabular::showInset( InsetTabular * inset )
}
void FormTabular::updateInset( InsetTabular * inset )
void FormTabular::updateInset(InsetTabular * inset)
{
if (inset == 0 || inset_ == 0) return;
@ -140,19 +140,17 @@ void FormTabular::update()
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);
@ -160,7 +158,7 @@ void FormTabular::update()
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);
@ -430,18 +428,12 @@ bool FormTabular::input(FL_OBJECT * ob, long)
if (!inset_)
return false;
LyXTabular
* tabular = inset_->tabular;
int
cell,
s;
LyXTabular::Feature
num = LyXTabular::LAST_ACTION;
string
special,
str;
LyXTabular * tabular = inset_->tabular;
int s;
LyXTabular::Feature num = LyXTabular::LAST_ACTION;
string special;;
cell = inset_->GetActCell();
int cell = inset_->GetActCell();
if (actCell_ != cell) {
update();
fl_set_object_label(dialog_->text_warning,
@ -456,9 +448,7 @@ bool FormTabular::input(FL_OBJECT * ob, long)
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)"));
@ -470,9 +460,7 @@ bool FormTabular::input(FL_OBJECT * ob, long)
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)"));
@ -483,7 +471,7 @@ bool FormTabular::input(FL_OBJECT * ob, long)
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,
@ -526,7 +514,7 @@ bool FormTabular::input(FL_OBJECT * ob, long)
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);
@ -567,13 +555,13 @@ bool FormTabular::input(FL_OBJECT * ob, long)
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

View File

@ -26,7 +26,8 @@
#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
@ -44,7 +45,7 @@ FormTabularCreate::~FormTabularCreate()
FL_FORM * FormTabularCreate::form() const
{
if (dialog_ ) return dialog_->form;
if (dialog_) return dialog_->form;
return 0;
}

View File

@ -26,7 +26,8 @@
#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
@ -51,7 +52,7 @@ FL_FORM * FormUrl::form() const
void FormUrl::connect()
{
fl_set_form_maxsize( form(), 2*minw_, minh_ );
fl_set_form_maxsize(form(), 2 * minw_, minh_);
FormCommand::connect();
}
@ -74,23 +75,23 @@ void FormUrl::update()
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);
}
}

View File

@ -11,9 +11,6 @@ extern "C" void PreambleOKCB(FL_OBJECT *, long);
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 {

View File

@ -17,10 +17,8 @@
#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"
@ -30,19 +28,14 @@
#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;
@ -75,8 +68,6 @@ extern bool send_fax(string const & fname, string const & sendcmd);
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.
@ -148,15 +139,6 @@ void ToggleLockedInsetCursor(int x, int y, int asc, int desc);
-----------------------------------------------------------------------
*/
/* 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,
@ -180,16 +162,16 @@ void ShowMessage(Buffer const * buf,
//
// 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 {
@ -201,7 +183,7 @@ bool MenuWrite(Buffer * buffer)
// 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)
@ -211,7 +193,7 @@ bool MenuWriteAs(Buffer * buffer)
string oldname = fname;
LyXFileDlg fileDlg;
ProhibitInput(current_view);
ProhibitInput(bv);
fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
fileDlg.SetButton(1, _("Templates"), lyxrc.template_path);
@ -223,7 +205,7 @@ bool MenuWriteAs(Buffer * buffer)
"*.lyx",
OnlyFilename(fname));
AllowInput(current_view);
AllowInput(bv);
if (fname.empty())
return false;
@ -259,7 +241,7 @@ bool MenuWriteAs(Buffer * buffer)
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?")))
@ -275,7 +257,7 @@ bool MenuWriteAs(Buffer * buffer)
// 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!"),
@ -318,6 +300,7 @@ int MenuRunChktex(Buffer * buffer)
return ret;
}
#if 0
void MenuFax(Buffer * buffer)
{
@ -393,7 +376,7 @@ void AutoSave(BufferView * bv)
// 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) {
@ -402,7 +385,7 @@ void AutoSave(BufferView * bv)
// 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
@ -530,10 +513,10 @@ void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
}
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:"));
@ -544,9 +527,9 @@ void MenuInsertLabel(string const & arg)
if (!label.empty()) {
InsetCommandParams p( "label", label );
InsetLabel * inset = new InsetLabel( p );
current_view->insertInset( inset );
bv->insertInset( inset );
}
AllowInput(current_view);
AllowInput(bv);
}
@ -554,7 +537,7 @@ void MenuInsertLabel(string const & arg)
// 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);
}
@ -579,24 +562,23 @@ void MenuLayoutCharacter()
}
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);
@ -614,7 +596,7 @@ void MenuLayoutPreamble()
{
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 {
@ -633,15 +615,15 @@ void MenuLayoutPreamble()
}
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();
}
@ -742,7 +724,8 @@ LyXFont const UserFreeFont(BufferParams const & params)
/* 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
@ -759,7 +742,8 @@ extern "C" void TimerCB(FL_OBJECT *, long)
/* 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)
@ -770,13 +754,15 @@ extern "C" void CharacterApplyCB(FL_OBJECT *, long)
}
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);
@ -785,13 +771,15 @@ extern "C" void CharacterOKCB(FL_OBJECT *ob, long 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;
@ -803,7 +791,8 @@ extern "C" void PreambleApplyCB(FL_OBJECT *, long)
}
extern "C" void PreambleOKCB(FL_OBJECT * ob, long data)
extern "C"
void PreambleOKCB(FL_OBJECT * ob, long data)
{
PreambleApplyCB(ob, data);
PreambleCancelCB(ob, data);

View File

@ -6,6 +6,8 @@
#include "lyxfont.h"
class BufferParams;
class BufferView;
class Combox;
///
extern bool quitting;
@ -23,6 +25,39 @@ void ShowMessage(Buffer const * buf,
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

View File

@ -139,7 +139,7 @@ void CloseAllBufferRelatedDialogs()
void updateAllVisibleBufferRelatedDialogs(bool)
{
if (fd_form_preamble->form_preamble->visible) {
UpdateLayoutPreamble();
UpdateLayoutPreamble(current_view);
}
if (fd_latex_log->LaTeXLog->visible) {
LatexLogUpdate(0,0);

View File

@ -91,7 +91,6 @@ using std::pair;
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;
@ -101,14 +100,6 @@ extern bool selection_possible;
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
@ -118,19 +109,7 @@ extern LyXAction lyxaction;
// (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();
@ -773,7 +752,7 @@ string const LyXFunc::Dispatch(int ac,
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()));
@ -781,12 +760,12 @@ string const LyXFunc::Dispatch(int ac,
//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:
@ -1287,7 +1266,7 @@ string const LyXFunc::Dispatch(int ac,
break;
case LFUN_LAYOUT_SAVE_DEFAULT:
MenuLayoutSave();
MenuLayoutSave(owner->view());
break;
case LFUN_DROP_LAYOUTS_CHOICE:
@ -1375,7 +1354,7 @@ string const LyXFunc::Dispatch(int ac,
break;
case LFUN_INSERT_LABEL:
MenuInsertLabel(argument);
MenuInsertLabel(owner->view(), argument);
break;
case LFUN_REF_INSERT:
@ -2506,8 +2485,8 @@ string const LyXFunc::Dispatch(int ac,
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));
}
@ -2571,7 +2550,7 @@ string const LyXFunc::Dispatch(int ac,
// 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";
@ -2644,13 +2623,13 @@ string const LyXFunc::Dispatch(int ac,
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;
@ -2660,24 +2639,24 @@ string const LyXFunc::Dispatch(int ac,
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;
@ -2707,7 +2686,7 @@ string const LyXFunc::Dispatch(int ac,
case LFUN_CHILDOPEN:
{
string filename =
string const filename =
MakeAbsPath(argument,
OnlyPath(owner->buffer()->fileName()));
setMessage(N_("Opening child document ") +
@ -2727,21 +2706,21 @@ string const LyXFunc::Dispatch(int ac,
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;
}
@ -2773,7 +2752,7 @@ string const LyXFunc::Dispatch(int ac,
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
@ -2815,7 +2794,8 @@ string const LyXFunc::Dispatch(int ac,
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);
@ -2856,8 +2836,8 @@ string const LyXFunc::Dispatch(int ac,
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>"
@ -2866,11 +2846,12 @@ string const LyXFunc::Dispatch(int ac,
}
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));
@ -2908,7 +2889,7 @@ string const LyXFunc::Dispatch(int ac,
}
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) {
@ -2945,11 +2926,12 @@ string const LyXFunc::Dispatch(int ac,
} // 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
+ " " +
@ -2980,7 +2962,7 @@ void LyXFunc::MenuNew(bool fromTemplate)
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;
@ -2988,7 +2970,7 @@ void LyXFunc::MenuNew(bool fromTemplate)
static int newfile_number = 0;
string s;
if (lyxrc.new_ask_filename) {
ProhibitInput(owner->view());
fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
@ -3065,9 +3047,9 @@ void LyXFunc::MenuNew(bool fromTemplate)
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;
@ -3085,7 +3067,7 @@ void LyXFunc::MenuOpen()
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;
@ -3127,6 +3109,7 @@ void LyXFunc::MenuOpen()
}
}
// checks for running without gui are missing.
void LyXFunc::doImport(string const & argument)
{
@ -3140,7 +3123,7 @@ 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;
@ -3151,9 +3134,9 @@ void LyXFunc::doImport(string const & argument)
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());
@ -3169,7 +3152,7 @@ void LyXFunc::doImport(string const & argument)
// 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)) {
@ -3193,7 +3176,7 @@ void LyXFunc::doImport(string const & argument)
}
// 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?"))) {
@ -3216,7 +3199,7 @@ void LyXFunc::MenuInsertLyXFile(string const & filen)
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;
@ -3247,7 +3230,7 @@ void LyXFunc::MenuInsertLyXFile(string const & filen)
// 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),
@ -3261,7 +3244,7 @@ void LyXFunc::MenuInsertLyXFile(string const & filen)
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));
}
@ -3275,8 +3258,7 @@ void LyXFunc::CloseBuffer()
// set variables that don't exist
// since there's no current buffer
owner->getDialogs()->hideBufferDependent();
}
else {
} else {
owner->view()->buffer(bufferlist.first());
}
}

View File

@ -120,39 +120,6 @@ string const QuoteName(string const & name)
}
#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)
{
@ -238,73 +205,44 @@ string const FileOpenSearch (string const & path, string const & name,
/// 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
}
@ -498,9 +436,9 @@ int DeleteAllFilesInDir (string const & path)
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
@ -567,7 +505,7 @@ string const CreateLyXTmpDir(string const & deflt)
}
int DestroyLyXTmpDir (string const & tmpdir)
int DestroyLyXTmpDir(string const & tmpdir)
{
return DestroyTmpDir (tmpdir, false); // Why false?
}
@ -592,30 +530,6 @@ bool createDirectory(string const & path, int permission)
}
#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)
{
@ -962,8 +876,8 @@ string const MakeRelPath(string const & abspath0, string const & basepath0)
// 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>";
@ -976,8 +890,8 @@ string const MakeRelPath(string const & abspath0, string const & basepath0)
// 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;
@ -1026,12 +940,10 @@ string const AddPath(string const & path, string const & path_2)
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;
@ -1115,10 +1027,10 @@ MakeDisplayPath (string const & path, unsigned int threshold)
// 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;
}
@ -1135,7 +1047,7 @@ bool LyXReadLink(string const & File, string & Link)
LinkBuffer, sizeof(LinkBuffer) - 1);
if (nRead <= 0)
return false;
LinkBuffer[nRead] = 0;
LinkBuffer[nRead] = '\0'; // terminator
Link = LinkBuffer;
return true;
}
@ -1157,7 +1069,7 @@ cmdret const do_popen(string const & cmd)
ret += static_cast<char>(c);
c = fgetc(inf);
}
int pret = pclose(inf);
int const pret = pclose(inf);
return make_pair(pret, ret);
}
@ -1216,7 +1128,7 @@ void removeAutosaveFile(string const & filename)
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);

View File

@ -124,16 +124,6 @@ string const MakeLatexName(string const & file);
/// 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);
@ -156,11 +146,6 @@ string const GetExtension(string const & name);
/// 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.

View File

@ -1,14 +1,12 @@
#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;
@ -16,35 +14,29 @@ extern string system_tempdir;
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());
tmpfl += "XXXXXX";
// the supposedly safer mkstemp version
char * tmpl = new char[256];
tmpfl += ".XXXXXX";
::strcpy(tmpl, tmpfl.c_str());
int tmpf = ::mkstemp(tmpl);
// 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
}