fix parse error in FormPreferences, make LyX be able to compile with gcc 2.97, use mktemp if mkstemp is not available

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1218 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2000-11-15 03:22:08 +00:00
parent 8548953e99
commit 676e29b916
22 changed files with 389 additions and 502 deletions

View File

@ -1,4 +1,4 @@
Public release of LyX version 1.1.5cvs Public release of LyX version 1.1.6pre
=================================== ===================================
What is LyX? What is LyX?
@ -67,8 +67,8 @@ with mirrors at
The source code package is available at: The source code package is available at:
ftp://ftp.lyx.org/pub/lyx/stable/lyx-1.1.5.tar.gz ftp://ftp.lyx.org/pub/lyx/stable/lyx-1.1.6.tar.gz
ftp://ftp.devel.lyx.org/pub/lyx/lyx-1.1.5.tar.gz ftp://ftp.devel.lyx.org/pub/lyx/lyx-1.1.6.tar.gz
and at the mirrors listed above. and at the mirrors listed above.

View File

@ -1,3 +1,38 @@
2000-11-15 Lars Gullik Bjønnes <larsbj@lyx.org>
* src/support/lyxfunctional.h: make back_insert_fun_iterator(s)
match the requirements from the standard better. This is required
to work with gnu libstdc++-v3
* src/frontends/xforms/FormPreferences.C: add explict pair
arguments to browse calls. include support/lyxmanip.h remvoe
extern fmt. whitespace changes. reorder variables in
FormPreferences.h, to match initalizaton order.
* several files: constify more local variables.
* src/buffer.C: remove some commented functions.
* src/DepTable.C (remove_files_with_extension): temporary
work around for gcc 2.97
* src/filedlg.C (find): ditto
* src/Variables.C (set): ditto
* src/LyXAction.C (searchActionArg): ditto
(retrieveActionArg): ditto
* configure.in: check for mktemp too
* UPGRADING: prepare for 1.1.6
* Makefile.am (lgbtags): add backup tags for when etags are
different than usual.
* ANNOUNCE: prepare for 1.1.6
* src/support/tempname.C (make_tempfile): new function, wrapper
around mkstemp and mktemp. Only mkstemp has been tested.
(tempName): call it.
2000-11-14 Rob Lahaye <lahaye@postech.edu> 2000-11-14 Rob Lahaye <lahaye@postech.edu>
* default.ui: capitalized some menu items to improve shortcuts. * default.ui: capitalized some menu items to improve shortcuts.

View File

@ -54,3 +54,6 @@ sourcedoc:
mkdir sourcedoc mkdir sourcedoc
cd sourcedoc ; \ cd sourcedoc ; \
doc++ -p `find ../$(top_srcdir)/src -name \*.h` doc++ -p `find ../$(top_srcdir)/src -name \*.h`
lgbtags:
etags --totals=yes --recurse=yes -o TAGS $(top_srcdir)/*

View File

@ -1,4 +1,4 @@
How do I upgrade my existing LyX system to version 1.1.5? How do I upgrade my existing LyX system to version 1.1.6?
--------------------------------------------------------- ---------------------------------------------------------
If you upgrade from version 0.12.0 or 1.0.x, you shouldn't have If you upgrade from version 0.12.0 or 1.0.x, you shouldn't have
@ -14,9 +14,9 @@ Document transfer
----------------- -----------------
In general, you don't need to convert any documents saved with LyX In general, you don't need to convert any documents saved with LyX
v0.10, v0.12.0 or v1.0.x to use them with LyX v1.1.5. v0.10, v0.12.0 or v1.0.x to use them with LyX v1.1.6.
LyX v1.1.5 can read all documents saved with lyx-0.12.0 and later correctly. LyX v1.1.6 can read all documents saved with lyx-0.12.0 and later correctly.
Documents saved with lyx-0.10.x are read correctly up to the old math Documents saved with lyx-0.10.x are read correctly up to the old math
mode, which is not supported anymore. If you have documents with such mode, which is not supported anymore. If you have documents with such
math formulas, you convert it using the program COLD, written by Preben math formulas, you convert it using the program COLD, written by Preben
@ -27,5 +27,5 @@ Rhandol. COLD can be found at:
or at one of LyX archive mirror sites listed in README. or at one of LyX archive mirror sites listed in README.
Documents saved with LyX version 1.1.5 can be read correctly by Documents saved with LyX version 1.1.6 can be read correctly by
LyX v0.12.0 and v1.0.x, except for new and a couple of changed features. LyX v0.12.0 and v1.0.x, except for new and a couple of changed features.

View File

@ -253,7 +253,7 @@ if test "x$lyx_broken_headers" = "xyes"; then
[Define on SunOS 4 and SCO, were some functions are missing from the headers]) [Define on SunOS 4 and SCO, were some functions are missing from the headers])
fi fi
AC_CHECK_FUNCS(memmove memset strchr putenv setenv mkfifo snprintf vsnprintf) AC_CHECK_FUNCS(memmove memset strchr putenv setenv mkfifo snprintf vsnprintf)
AC_CHECK_FUNCS(mkstemp) AC_CHECK_FUNCS(mkstemp mktemp)
dnl Until this is fixed in autoconf we provide our own version dnl Until this is fixed in autoconf we provide our own version
LYX_FUNC_SELECT_ARGTYPES LYX_FUNC_SELECT_ARGTYPES

View File

@ -113,7 +113,8 @@ bool DepTable::exist(string const & fil) const
void DepTable::remove_files_with_extension(string const & suf) void DepTable::remove_files_with_extension(string const & suf)
{ {
DepList tmp; DepList tmp;
for (DepList::const_iterator cit = deplist.begin(); // we want const_iterator (Lgb)
for (DepList::iterator cit = deplist.begin();
cit != deplist.end(); ++cit) { cit != deplist.end(); ++cit) {
if (!suffixIs((*cit).first, suf)) if (!suffixIs((*cit).first, suf))
tmp[(*cit).first] = (*cit).second; tmp[(*cit).first] = (*cit).second;

View File

@ -453,7 +453,8 @@ LyXAction::LyXAction()
// if it doesn't exist. // if it doesn't exist.
int LyXAction::searchActionArg(kb_action action, string const & arg) const int LyXAction::searchActionArg(kb_action action, string const & arg) const
{ {
arg_map::const_iterator pit = lyx_arg_map.find(action); // we really want to use const_iterator (Lgb)
arg_map::iterator pit = lyx_arg_map.find(action);
if (pit == lyx_arg_map.end()) { if (pit == lyx_arg_map.end()) {
// the action does not have any pseudoactions // the action does not have any pseudoactions
@ -462,8 +463,9 @@ int LyXAction::searchActionArg(kb_action action, string const & arg) const
<< endl; << endl;
return LFUN_UNKNOWN_ACTION; return LFUN_UNKNOWN_ACTION;
} }
arg_item::const_iterator aci = (*pit).second.find(arg); // we really want to use const_iterator (Lgb)
arg_item::iterator aci = (*pit).second.find(arg);
if (aci == (*pit).second.end()) { if (aci == (*pit).second.end()) {
// the action does not have any pseudoactions with this arg // the action does not have any pseudoactions with this arg
@ -518,8 +520,9 @@ int LyXAction::getPseudoAction(kb_action action, string const & arg) const
kb_action LyXAction::retrieveActionArg(int pseudo, string & arg) const kb_action LyXAction::retrieveActionArg(int pseudo, string & arg) const
{ {
arg.erase(); // clear it to be sure. arg.erase(); // clear it to be sure.
pseudo_map::const_iterator pit = lyx_pseudo_map.find(pseudo); // we really want to use const_iterator (Lgb)
pseudo_map::iterator pit = lyx_pseudo_map.find(pseudo);
if (pit != lyx_pseudo_map.end()) { if (pit != lyx_pseudo_map.end()) {
lyxerr[Debug::ACTION] << "Found the pseudoaction: [" lyxerr[Debug::ACTION] << "Found the pseudoaction: ["

View File

@ -20,10 +20,11 @@
void Variables::set(string const & var, string const & val) void Variables::set(string const & var, string const & val)
{ {
Vars::const_iterator cit = vars_.find(var); // We want to use const_iterator (Lgb)
if (cit != vars_.end()) Vars::iterator cit = vars_.find(var);
vars_.erase(var); if (cit != vars_.end())
vars_[var] = val;; vars_.erase(var);
vars_[var] = val;;
} }

View File

@ -1265,225 +1265,6 @@ bool Buffer::writeFile(string const & fname, bool flag) const
} }
#if 0
void Buffer::writeFileAscii(string const & fname, int linelen)
{
Inset * inset;
char c;
char footnoteflag = 0;
char depth = 0;
string tmp;
LyXParagraph::size_type i;
int j;
int ltype = 0;
int ltype_depth = 0;
int actcell = 0;
int actpos = 0;
int currlinelen = 0;
int fpos = 0;
bool ref_printed = false;
ofstream ofs(fname.c_str());
if (!ofs) {
WriteFSAlert(_("Error: Cannot write file:"), fname);
return;
}
string const fname1 = lyx::tempName(); //TmpFileName();
LyXParagraph * par = paragraph;
while (par) {
int noparbreak = 0;
int islatex = 0;
if (
#ifndef NEW_INSETS
par->footnoteflag != LyXParagraph::NO_FOOTNOTE ||
#endif
!par->previous
#ifndef NEW_INSETS
|| par->previous->footnoteflag == LyXParagraph::NO_FOOTNOTE
#endif
){
#ifndef NEW_INSETS
/* begins a footnote environment ? */
if (footnoteflag != par->footnoteflag) {
footnoteflag = par->footnoteflag;
if (footnoteflag) {
j = strlen(string_footnotekinds[par->footnotekind])+4;
if (currlinelen + j > linelen)
ofs << "\n";
ofs << "(["
<< string_footnotekinds[par->footnotekind] << "] ";
currlinelen += j;
}
}
#endif
/* begins or ends a deeper area ?*/
if (depth != par->depth) {
if (par->depth > depth) {
while (par->depth > depth) {
++depth;
}
}
else {
while (par->depth < depth) {
--depth;
}
}
}
/* First write the layout */
tmp = textclasslist.NameOfLayout(params.textclass, par->layout);
if (tmp == "Itemize") {
ltype = 1;
ltype_depth = depth+1;
} else if (tmp == "Enumerate") {
ltype = 2;
ltype_depth = depth+1;
} else if (contains(tmp, "ection")) {
ltype = 3;
ltype_depth = depth+1;
} else if (contains(tmp, "aragraph")) {
ltype = 4;
ltype_depth = depth+1;
} else if (tmp == "Description") {
ltype = 5;
ltype_depth = depth+1;
} else if (tmp == "Abstract") {
ltype = 6;
ltype_depth = 0;
} else if (tmp == "Bibliography") {
ltype = 7;
ltype_depth = 0;
} else {
ltype = 0;
ltype_depth = 0;
}
/* maybe some vertical spaces */
/* the labelwidthstring used in lists */
/* some lines? */
/* some pagebreaks? */
/* noindent ? */
/* what about the alignment */
} else {
#ifndef NEW_INSETS
/* dummy layout, that means a footnote ended */
footnoteflag = LyXParagraph::NO_FOOTNOTE;
ofs << ") ";
noparbreak = 1;
#else
lyxerr << "Should this ever happen?" << endl;
#endif
}
LyXFont font1 =
LyXFont(LyXFont::ALL_INHERIT, params.language);
actcell = 0;
for (i = 0, actpos = 1; i < par->size(); ++i, ++actpos) {
if (!i && !footnoteflag && !noparbreak){
ofs << "\n\n";
for (j = 0; j < depth; ++j)
ofs << " ";
currlinelen = depth * 2;
switch (ltype) {
case 0: /* Standard */
case 4: /* (Sub)Paragraph */
case 5: /* Description */
break;
case 6: /* Abstract */
ofs << "Abstract\n\n";
break;
case 7: /* Bibliography */
if (!ref_printed) {
ofs << "References\n\n";
ref_printed = true;
}
break;
default:
ofs << par->labelstring << " ";
break;
}
if (ltype_depth > depth) {
for (j = ltype_depth - 1; j > depth; --j)
ofs << " ";
currlinelen += (ltype_depth-depth)*2;
}
}
LyXFont font2 = par->GetFontSettings(params, i);
if (font1.latex() != font2.latex()) {
if (font2.latex() == LyXFont::OFF)
islatex = 0;
else
islatex = 1;
} else {
islatex = 0;
}
c = par->GetChar(i);
if (islatex)
continue;
switch (c) {
case LyXParagraph::META_INSET:
if ((inset = par->GetInset(i))) {
fpos = ofs.tellp();
inset->Ascii(this, ofs);
currlinelen += (ofs.tellp() - fpos);
actpos += (ofs.tellp() - fpos) - 1;
}
break;
case LyXParagraph::META_NEWLINE:
ofs << "\n";
for (j = 0; j < depth; ++j)
ofs << " ";
currlinelen = depth * 2;
if (ltype_depth > depth) {
for (j = ltype_depth;
j > depth; --j)
ofs << " ";
currlinelen += (ltype_depth - depth) * 2;
}
break;
case LyXParagraph::META_HFILL:
ofs << "\t";
break;
case '\\':
ofs << "\\";
break;
default:
if (currlinelen > linelen - 10
&& c == ' ' && i + 2 < par->size()) {
ofs << "\n";
for (j = 0; j < depth; ++j)
ofs << " ";
currlinelen = depth * 2;
if (ltype_depth > depth) {
for (j = ltype_depth;
j > depth; --j)
ofs << " ";
currlinelen += (ltype_depth-depth)*2;
}
} else if (c != '\0')
ofs << c;
else if (c == '\0')
lyxerr.debug() << "writeAsciiFile: NULL char in structure." << endl;
++currlinelen;
break;
}
}
par = par->next;
}
ofs << "\n";
}
//----------------------------------------------------------------------------
#else
//----------------------------------------------------------------------------
string const Buffer::asciiParagraph(LyXParagraph const * par, string const Buffer::asciiParagraph(LyXParagraph const * par,
unsigned int linelen) const unsigned int linelen) const
{ {
@ -1722,7 +1503,7 @@ void Buffer::writeFileAscii(ostream & ofs, int linelen)
} }
ofs << "\n"; ofs << "\n";
} }
#endif
void Buffer::makeLaTeXFile(string const & fname, void Buffer::makeLaTeXFile(string const & fname,
string const & original_path, string const & original_path,

View File

@ -72,8 +72,8 @@ Buffer * BufferStorage::newBuffer(string const & s, bool ronly)
{ {
Buffer * tmpbuf = new Buffer(s, ronly); Buffer * tmpbuf = new Buffer(s, ronly);
tmpbuf->params.useClassDefaults(); tmpbuf->params.useClassDefaults();
lyxerr.debug() << "Assigning to buffer " lyxerr[Debug::INFO] << "Assigning to buffer "
<< container.size() << endl; << container.size() << endl;
container.push_back(tmpbuf); container.push_back(tmpbuf);
return tmpbuf; return tmpbuf;
} }
@ -107,7 +107,7 @@ bool BufferList::QwriteAll()
else else
fname = MakeDisplayPath((*it)->fileName(), 50); fname = MakeDisplayPath((*it)->fileName(), 50);
bool reask = true; bool reask = true;
while(reask) { while (reask) {
switch (AskConfirmation(_("Changes in document:"), switch (AskConfirmation(_("Changes in document:"),
fname, fname,
_("Save document?"))) { _("Save document?"))) {

View File

@ -81,7 +81,8 @@ class UserCache {
public: public:
/// seeks user name from group ID /// seeks user name from group ID
string const & find(uid_t ID) const { string const & find(uid_t ID) const {
Users::const_iterator cit = users.find(ID); // We really want to use const_iterator. (Lgb)
Users::iterator cit = users.find(ID);
if (cit == users.end()) { if (cit == users.end()) {
add(ID); add(ID);
return users[ID]; return users[ID];
@ -97,6 +98,7 @@ private:
mutable Users users; mutable Users users;
}; };
void UserCache::add(uid_t ID) const void UserCache::add(uid_t ID) const
{ {
string pszNewName; string pszNewName;
@ -128,15 +130,19 @@ private:
mutable Groups groups; mutable Groups groups;
}; };
string const & GroupCache::find(gid_t ID) const
{ string const & GroupCache::find(gid_t ID) const
Groups::const_iterator cit = groups.find(ID); {
if (cit == groups.end()) { // We really want to use const_iterator. (Lgb)
add(ID); Groups::iterator cit = groups.find(ID);
return groups[ID]; if (cit == groups.end()) {
} add(ID);
return (*cit).second; return groups[ID];
} }
return (*cit).second;
}
void GroupCache::add(gid_t ID) const void GroupCache::add(gid_t ID) const
{ {
string pszNewName; string pszNewName;
@ -150,11 +156,13 @@ void GroupCache::add(gid_t ID) const
// adds new node // adds new node
groups[ID] = pszNewName; groups[ID] = pszNewName;
} }
// static instances // static instances
static UserCache lyxUserCache; static UserCache lyxUserCache;
static GroupCache lyxGroupCache; static GroupCache lyxGroupCache;
// some "C" wrappers around callbacks // some "C" wrappers around callbacks
extern "C" void C_LyXFileDlg_FileDlgCB(FL_OBJECT *, long lArgument); extern "C" void C_LyXFileDlg_FileDlgCB(FL_OBJECT *, long lArgument);
extern "C" void C_LyXFileDlg_DoubleClickCB(FL_OBJECT *, long); extern "C" void C_LyXFileDlg_DoubleClickCB(FL_OBJECT *, long);
@ -192,7 +200,7 @@ void LyXFileDlg::Reread()
if (!pDirectory) { if (!pDirectory) {
WriteFSAlert(_("Warning! Couldn't open directory."), WriteFSAlert(_("Warning! Couldn't open directory."),
pszDirectory); pszDirectory);
pszDirectory = lyx::getcwd(); //GetCWD(); pszDirectory = lyx::getcwd();
pDirectory = ::opendir(pszDirectory.c_str()); pDirectory = ::opendir(pszDirectory.c_str());
} }
@ -331,7 +339,7 @@ void LyXFileDlg::Reread()
// Add them to directory box // Add them to directory box
for (DirEntries::const_iterator cit = direntries.begin(); for (DirEntries::const_iterator cit = direntries.begin();
cit != direntries.end(); ++cit) { cit != direntries.end(); ++cit) {
string temp = line + (*cit).pszDisplayed; string const temp = line + (*cit).pszDisplayed;
fl_add_browser_line(pFileDlgForm->List, temp.c_str()); fl_add_browser_line(pFileDlgForm->List, temp.c_str());
} }
fl_set_browser_topline(pFileDlgForm->List, iDepth); fl_set_browser_topline(pFileDlgForm->List, iDepth);
@ -450,7 +458,6 @@ bool LyXFileDlg::RunDialog()
// event loop // event loop
while(true) { while(true) {
FL_OBJECT * pObject = fl_do_forms(); FL_OBJECT * pObject = fl_do_forms();
if (pObject == pFileDlgForm->Ready) { if (pObject == pFileDlgForm->Ready) {
@ -530,7 +537,7 @@ extern "C" void C_LyXFileDlg_FileDlgCB(FL_OBJECT * ob, long data)
void LyXFileDlg::HandleListHit() void LyXFileDlg::HandleListHit()
{ {
// set info line // set info line
int iSelect = fl_get_browser(pFileDlgForm->List); int const iSelect = fl_get_browser(pFileDlgForm->List);
if (iSelect > iDepth) { if (iSelect > iDepth) {
SetInfoLine(direntries[iSelect - iDepth - 1].pszLsEntry); SetInfoLine(direntries[iSelect - iDepth - 1].pszLsEntry);
} else { } else {
@ -547,11 +554,13 @@ void LyXFileDlg::DoubleClickCB(FL_OBJECT *, long)
pCurrentDlg->Force(false); pCurrentDlg->Force(false);
} }
extern "C" void C_LyXFileDlg_DoubleClickCB(FL_OBJECT * ob, long data) extern "C" void C_LyXFileDlg_DoubleClickCB(FL_OBJECT * ob, long data)
{ {
LyXFileDlg::DoubleClickCB(ob, data); LyXFileDlg::DoubleClickCB(ob, data);
} }
// Handle double click from list // Handle double click from list
bool LyXFileDlg::HandleDoubleClick() bool LyXFileDlg::HandleDoubleClick()
{ {
@ -559,7 +568,7 @@ bool LyXFileDlg::HandleDoubleClick()
// set info line // set info line
bool isDir = true; bool isDir = true;
int iSelect = fl_get_browser(pFileDlgForm->List); int const iSelect = fl_get_browser(pFileDlgForm->List);
if (iSelect > iDepth) { if (iSelect > iDepth) {
pszTemp = direntries[iSelect - iDepth - 1].pszName; pszTemp = direntries[iSelect - iDepth - 1].pszName;
SetInfoLine(direntries[iSelect - iDepth - 1].pszLsEntry); SetInfoLine(direntries[iSelect - iDepth - 1].pszLsEntry);
@ -608,7 +617,7 @@ bool LyXFileDlg::HandleOK()
{ {
// mask was changed // mask was changed
string pszTemp = fl_get_input(pFileDlgForm->PatBox); string pszTemp = fl_get_input(pFileDlgForm->PatBox);
if (pszTemp!= pszMask) { if (pszTemp != pszMask) {
SetMask(pszTemp); SetMask(pszTemp);
Reread(); Reread();
return false; return false;
@ -623,12 +632,13 @@ bool LyXFileDlg::HandleOK()
} }
// Handle return from list // Handle return from list
int select = fl_get_browser(pFileDlgForm->List); int const select = fl_get_browser(pFileDlgForm->List);
if (select > iDepth) { if (select > iDepth) {
string temp = direntries[select - iDepth - 1].pszName; string const temp = direntries[select - iDepth - 1].pszName;
if (!suffixIs(temp, '/')) { if (!suffixIs(temp, '/')) {
// If user didn't type anything, use browser // If user didn't type anything, use browser
string name = fl_get_input(pFileDlgForm->Filename); string const name =
fl_get_input(pFileDlgForm->Filename);
if (name.empty()) { if (name.empty()) {
fl_set_input(pFileDlgForm->Filename, temp.c_str()); fl_set_input(pFileDlgForm->Filename, temp.c_str());
} }
@ -689,21 +699,22 @@ string const LyXFileDlg::Select(string const & title, string const & path,
// highlight the suggested file in the browser, if it exists. // highlight the suggested file in the browser, if it exists.
int sel = 0; int sel = 0;
string filename = OnlyFilename(suggested); string const filename = OnlyFilename(suggested);
if( !filename.empty() ) { if (!filename.empty()) {
for( int i = 0; for (int i = 0;
i < fl_get_browser_maxline(pFileDlgForm->List); ++i ) { i < fl_get_browser_maxline(pFileDlgForm->List); ++i) {
string s = fl_get_browser_line(pFileDlgForm->List, i+1); string s =
fl_get_browser_line(pFileDlgForm->List, i + 1);
s = strip(frontStrip(s)); s = strip(frontStrip(s));
if( s == filename ) { if (s == filename) {
sel = i+1; sel = i + 1;
break; break;
} }
} }
} }
if( sel != 0 ) fl_select_browser_line(pFileDlgForm->List, sel); if (sel != 0) fl_select_browser_line(pFileDlgForm->List, sel);
int top = max(sel - 5, 1); int const top = max(sel - 5, 1);
fl_set_browser_topline(pFileDlgForm->List, top); fl_set_browser_topline(pFileDlgForm->List, top);
// checks whether dialog can be started // checks whether dialog can be started
@ -711,7 +722,7 @@ string const LyXFileDlg::Select(string const & title, string const & path,
pCurrentDlg = this; pCurrentDlg = this;
// runs dialog // runs dialog
SetInfoLine (string()); SetInfoLine(string());
fl_set_input(pFileDlgForm->Filename, suggested.c_str()); fl_set_input(pFileDlgForm->Filename, suggested.c_str());
fl_set_button(pFileDlgForm->Cancel, 0); fl_set_button(pFileDlgForm->Cancel, 0);
fl_set_button(pFileDlgForm->Ready, 0); fl_set_button(pFileDlgForm->Ready, 0);

View File

@ -26,7 +26,7 @@
#include "FormTabularCreate.h" #include "FormTabularCreate.h"
#include "FormToc.h" #include "FormToc.h"
#include "FormUrl.h" #include "FormUrl.h"
#include "debug.h" //#include "debug.h"
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation #pragma implementation
@ -73,7 +73,7 @@ Dialogs::~Dialogs()
for (vector<DialogBase *>::iterator iter = dialogs_.begin(); for (vector<DialogBase *>::iterator iter = dialogs_.begin();
iter != dialogs_.end(); iter != dialogs_.end();
++iter) { ++iter) {
lyxerr << "delete *iter" << endl; //lyxerr << "delete *iter" << endl;
delete *iter; delete *iter;
} }
} }

View File

@ -12,9 +12,10 @@
* FormPreferences Interface Class Implementation * FormPreferences Interface Class Implementation
*/ */
#include <utility>
#include <config.h> #include <config.h>
#include <utility>
#include FORMS_H_LOCATION #include FORMS_H_LOCATION
#ifdef __GNUG_ #ifdef __GNUG_
@ -42,6 +43,7 @@
#include "xform_macros.h" #include "xform_macros.h"
#include "converter.h" #include "converter.h"
#include "support/lyxfunctional.h" #include "support/lyxfunctional.h"
#include "support/lyxmanip.h"
#ifdef SIGC_CXX_NAMESPACES #ifdef SIGC_CXX_NAMESPACES
@ -55,8 +57,8 @@ using std::pair;
using std::max; using std::max;
using std::sort; using std::sort;
using std::vector; using std::vector;
using std::make_pair;
extern string fmt(char const * fmtstr ...);
extern string system_lyxdir; extern string system_lyxdir;
extern string user_lyxdir; extern string user_lyxdir;
extern Languages languages; extern Languages languages;
@ -517,8 +519,10 @@ bool FormPreferences::Colors::input( FL_OBJECT const * const ob )
return Database(); return Database();
} else if (ob == dialog_->button_browse) { } else if (ob == dialog_->button_browse) {
return parent_.browse( dialog_->input_name, return parent_.browse(dialog_->input_name,
_("X11 color database"), "*.txt" ); _("X11 color database"), "*.txt",
make_pair(string(), string()),
make_pair(string(), string()));
} else if (ob == dialog_->browser_lyx_objs) { } else if (ob == dialog_->browser_lyx_objs) {
return BrowserLyX(); return BrowserLyX();
@ -1670,20 +1674,22 @@ bool FormPreferences::Language::input( FL_OBJECT const * const ob )
} }
} }
if( ob == dialog_->button_kbmap1_browse ) { if (ob == dialog_->button_kbmap1_browse) {
string dir = system_lyxdir + string("kbd"); string dir = system_lyxdir + string("kbd");
string name = N_("Key maps"); string name = N_("Key maps");
pair<string,string> dir1(name, dir); pair<string, string> dir1(name, dir);
parent_.browse( dialog_->input_kbmap1, parent_.browse(dialog_->input_kbmap1,
_("Keyboard map"), "*.kmap", dir1 ); _("Keyboard map"), "*.kmap", dir1,
} else if( ob == dialog_->button_kbmap2_browse ) { pair<string, string>());
} else if (ob == dialog_->button_kbmap2_browse) {
string dir = system_lyxdir + string("kbd"); string dir = system_lyxdir + string("kbd");
string name = N_("Key maps"); string name = N_("Key maps");
pair<string,string> dir1(name, dir); pair<string, string> dir1(name, dir);
parent_.browse( dialog_->input_kbmap2, parent_.browse(dialog_->input_kbmap2,
_("Keyboard map"), "*.kmap", dir1 ); _("Keyboard map"), "*.kmap", dir1,
pair<string, string>());
} }
return activate; return activate;
@ -1722,7 +1728,7 @@ void FormPreferences::Language::update()
// Activate/Deactivate the input fields dependent on the state of the // Activate/Deactivate the input fields dependent on the state of the
// buttons. // buttons.
input( 0 ); input(0);
} }
@ -1731,7 +1737,7 @@ void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
FormPreferences * pre = static_cast<FormPreferences*>(v); FormPreferences * pre = static_cast<FormPreferences*>(v);
// This is safe, as nothing is done to the pointer, other than // This is safe, as nothing is done to the pointer, other than
// to use its address in a block-if statement. // to use its address in a block-if statement.
pre->bc_.valid( pre->input( reinterpret_cast<FL_OBJECT *>(combox), 0 )); pre->bc_.valid(pre->input( reinterpret_cast<FL_OBJECT *>(combox), 0));
} }
@ -1767,14 +1773,14 @@ void FormPreferences::LnFmisc::build()
fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED); fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
// set up the feedback mechanism // set up the feedback mechanism
parent_.setPreHandler( dialog_->check_banner ); parent_.setPreHandler(dialog_->check_banner);
parent_.setPreHandler( dialog_->check_auto_region_delete ); parent_.setPreHandler(dialog_->check_auto_region_delete);
parent_.setPreHandler( dialog_->check_exit_confirm ); parent_.setPreHandler(dialog_->check_exit_confirm);
parent_.setPreHandler( dialog_->check_display_shrtcuts ); parent_.setPreHandler(dialog_->check_display_shrtcuts);
parent_.setPreHandler( dialog_->counter_autosave ); parent_.setPreHandler(dialog_->counter_autosave);
parent_.setPreHandler( dialog_->check_ask_new_file ); parent_.setPreHandler(dialog_->check_ask_new_file);
parent_.setPreHandler( dialog_->check_cursor_follows_scrollbar ); parent_.setPreHandler(dialog_->check_cursor_follows_scrollbar);
parent_.setPreHandler( dialog_->counter_wm_jump ); parent_.setPreHandler(dialog_->counter_wm_jump);
} }
@ -1783,22 +1789,22 @@ FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
{ {
string str; string str;
if (ob == dialog_->check_banner ) if (ob == dialog_->check_banner)
str = lyxrc.getDescription( LyXRC::RC_SHOW_BANNER ); str = lyxrc.getDescription(LyXRC::RC_SHOW_BANNER);
else if (ob == dialog_->check_auto_region_delete ) else if (ob == dialog_->check_auto_region_delete)
str = lyxrc.getDescription( LyXRC::RC_AUTOREGIONDELETE ); str = lyxrc.getDescription(LyXRC::RC_AUTOREGIONDELETE);
else if (ob == dialog_->check_exit_confirm ) else if (ob == dialog_->check_exit_confirm)
str = lyxrc.getDescription( LyXRC::RC_EXIT_CONFIRMATION ); str = lyxrc.getDescription(LyXRC::RC_EXIT_CONFIRMATION);
else if (ob == dialog_->check_display_shrtcuts ) else if (ob == dialog_->check_display_shrtcuts)
str = lyxrc.getDescription( LyXRC::RC_DISPLAY_SHORTCUTS ); str = lyxrc.getDescription(LyXRC::RC_DISPLAY_SHORTCUTS);
else if (ob == dialog_->check_ask_new_file ) else if (ob == dialog_->check_ask_new_file)
str = lyxrc.getDescription( LyXRC::RC_NEW_ASK_FILENAME ); str = lyxrc.getDescription(LyXRC::RC_NEW_ASK_FILENAME);
else if (ob == dialog_->check_cursor_follows_scrollbar ) else if (ob == dialog_->check_cursor_follows_scrollbar)
str = lyxrc.getDescription( LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR ); str = lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
else if (ob == dialog_->counter_autosave ) else if (ob == dialog_->counter_autosave)
str = lyxrc.getDescription( LyXRC::RC_AUTOSAVE ); str = lyxrc.getDescription(LyXRC::RC_AUTOSAVE);
else if (ob == dialog_->counter_wm_jump ) else if (ob == dialog_->counter_wm_jump)
str = lyxrc.getDescription( LyXRC::RC_WHEEL_JUMP ); str = lyxrc.getDescription(LyXRC::RC_WHEEL_JUMP);
return str; return str;
} }
@ -1831,7 +1837,7 @@ void FormPreferences::OutputsMisc::apply() const
(fl_get_counter_value(dialog_->counter_line_len)); (fl_get_counter_value(dialog_->counter_line_len));
lyxrc.fontenc = fl_get_input(dialog_->input_tex_encoding); lyxrc.fontenc = fl_get_input(dialog_->input_tex_encoding);
int choice = int const choice =
fl_get_choice(dialog_->choice_default_papersize) - 1; fl_get_choice(dialog_->choice_default_papersize) - 1;
lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice); lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
@ -1869,16 +1875,16 @@ FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
{ {
string str; string str;
if (ob == dialog_->counter_line_len ) if (ob == dialog_->counter_line_len)
str = lyxrc.getDescription( LyXRC::RC_ASCII_LINELEN ); str = lyxrc.getDescription(LyXRC::RC_ASCII_LINELEN);
else if (ob == dialog_->input_tex_encoding ) else if (ob == dialog_->input_tex_encoding)
str = lyxrc.getDescription( LyXRC::RC_FONT_ENCODING ); str = lyxrc.getDescription(LyXRC::RC_FONT_ENCODING);
else if (ob == dialog_->input_ascii_roff ) else if (ob == dialog_->input_ascii_roff)
str = lyxrc.getDescription( LyXRC::RC_ASCIIROFF_COMMAND ); str = lyxrc.getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
else if (ob == dialog_->input_checktex ) else if (ob == dialog_->input_checktex)
str = lyxrc.getDescription( LyXRC::RC_CHKTEX_COMMAND ); str = lyxrc.getDescription(LyXRC::RC_CHKTEX_COMMAND);
else if (ob == dialog_->choice_default_papersize ) else if (ob == dialog_->choice_default_papersize)
str = lyxrc.getDescription( LyXRC::RC_DEFAULT_PAPERSIZE ); str = lyxrc.getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
return str; return str;
} }
@ -1953,36 +1959,36 @@ void FormPreferences::Paths::build()
fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED); fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
// set up the feedback mechanism // set up the feedback mechanism
parent_.setPreHandler( dialog_->input_default_path ); parent_.setPreHandler(dialog_->input_default_path);
parent_.setPreHandler( dialog_->counter_lastfiles ); parent_.setPreHandler(dialog_->counter_lastfiles);
parent_.setPreHandler( dialog_->input_template_path ); parent_.setPreHandler(dialog_->input_template_path);
parent_.setPreHandler( dialog_->check_last_files ); parent_.setPreHandler(dialog_->check_last_files);
parent_.setPreHandler( dialog_->input_lastfiles ); parent_.setPreHandler(dialog_->input_lastfiles);
parent_.setPreHandler( dialog_->check_make_backups ); parent_.setPreHandler(dialog_->check_make_backups);
parent_.setPreHandler( dialog_->input_backup_path ); parent_.setPreHandler(dialog_->input_backup_path);
parent_.setPreHandler( dialog_->input_serverpipe ); parent_.setPreHandler(dialog_->input_serverpipe);
parent_.setPreHandler( dialog_->input_temp_dir ); parent_.setPreHandler(dialog_->input_temp_dir);
parent_.setPreHandler( dialog_->check_use_temp_dir ); parent_.setPreHandler(dialog_->check_use_temp_dir);
} }
string const string const
FormPreferences::Paths::feedback( FL_OBJECT const * const ob ) const FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
{ {
string str; string str;
if (ob == dialog_->input_default_path ) if (ob == dialog_->input_default_path)
str = lyxrc.getDescription( LyXRC::RC_DOCUMENTPATH ); str = lyxrc.getDescription(LyXRC::RC_DOCUMENTPATH);
else if (ob == dialog_->input_template_path ) else if (ob == dialog_->input_template_path)
str = lyxrc.getDescription( LyXRC::RC_TEMPLATEPATH ); str = lyxrc.getDescription(LyXRC::RC_TEMPLATEPATH);
else if (ob == dialog_->check_use_temp_dir ) else if (ob == dialog_->check_use_temp_dir )
str = lyxrc.getDescription( LyXRC::RC_USETEMPDIR ); str = lyxrc.getDescription(LyXRC::RC_USETEMPDIR);
else if (ob == dialog_->input_temp_dir ) else if (ob == dialog_->input_temp_dir)
str = lyxrc.getDescription( LyXRC::RC_TEMPDIRPATH ); str = lyxrc.getDescription(LyXRC::RC_TEMPDIRPATH);
else if (ob == dialog_->check_last_files ) else if (ob == dialog_->check_last_files)
str = lyxrc.getDescription( LyXRC::RC_CHECKLASTFILES ); str = lyxrc.getDescription(LyXRC::RC_CHECKLASTFILES);
else if (ob == dialog_->input_lastfiles ) else if (ob == dialog_->input_lastfiles)
str = lyxrc.getDescription( LyXRC::RC_LASTFILES ); str = lyxrc.getDescription(LyXRC::RC_LASTFILES);
else if (ob == dialog_->counter_lastfiles ) else if (ob == dialog_->counter_lastfiles )
str = lyxrc.getDescription( LyXRC::RC_NUMLASTFILES ); str = lyxrc.getDescription( LyXRC::RC_NUMLASTFILES );
else if (ob == dialog_->check_make_backups ) else if (ob == dialog_->check_make_backups )
@ -1996,7 +2002,7 @@ FormPreferences::Paths::feedback( FL_OBJECT const * const ob ) const
} }
bool FormPreferences::Paths::input( FL_OBJECT const * const ob ) bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
{ {
bool activate = true; bool activate = true;
@ -2085,24 +2091,33 @@ bool FormPreferences::Paths::input( FL_OBJECT const * const ob )
} }
} }
if( ob == dialog_->button_default_path_browse ) { if (ob == dialog_->button_default_path_browse) {
parent_.browse( dialog_->input_default_path, parent_.browse(dialog_->input_default_path,
_("Default path"), string() ); _("Default path"), string(),
} else if( ob == dialog_->button_template_path_browse ) { pair<string, string>(),
parent_.browse( dialog_->input_template_path, pair<string, string>());
_("Template path"), string() ); } else if (ob == dialog_->button_template_path_browse) {
} else if( ob == dialog_->button_temp_dir_browse ) { parent_.browse(dialog_->input_template_path,
parent_.browse( dialog_->input_temp_dir, _("Template path"), string(),
_("Temp dir"), string() ); pair<string, string>(),
} else if( ob == dialog_->button_lastfiles_browse ) { pair<string, string>());
pair<string,string> dir(_("User"), user_lyxdir); } else if (ob == dialog_->button_temp_dir_browse) {
parent_.browse(dialog_->input_temp_dir,
_("Temp dir"), string(),
pair<string, string>(),
pair<string, string>());
} else if (ob == dialog_->button_lastfiles_browse) {
pair<string, string> dir(_("User"), user_lyxdir);
parent_.browse( dialog_->input_lastfiles, parent_.browse(dialog_->input_lastfiles,
_("Lastfiles"), string(), dir ); _("Lastfiles"), string(), dir,
} else if( ob == dialog_->button_backup_path_browse ) { pair<string, string>());
} else if (ob == dialog_->button_backup_path_browse) {
parent_.browse( dialog_->input_backup_path, parent_.browse( dialog_->input_backup_path,
_("Backup path"), string() ); _("Backup path"), string(),
} else if( ob == dialog_->button_serverpipe_browse ) { pair<string, string>(),
pair<string, string>());
} else if (ob == dialog_->button_serverpipe_browse) {
// Not sure how to do this!!! // Not sure how to do this!!!
} }
@ -2480,23 +2495,23 @@ void FormPreferences::ScreenFonts::build()
fl_unsigned_int_filter); fl_unsigned_int_filter);
// set up the feedback mechanism // set up the feedback mechanism
parent_.setPreHandler( dialog_->input_roman ); parent_.setPreHandler(dialog_->input_roman);
parent_.setPreHandler( dialog_->input_sans ); parent_.setPreHandler(dialog_->input_sans);
parent_.setPreHandler( dialog_->input_typewriter ); parent_.setPreHandler(dialog_->input_typewriter);
parent_.setPreHandler( dialog_->counter_zoom ); parent_.setPreHandler(dialog_->counter_zoom);
parent_.setPreHandler( dialog_->counter_dpi ); parent_.setPreHandler(dialog_->counter_dpi);
parent_.setPreHandler( dialog_->check_scalable ); parent_.setPreHandler(dialog_->check_scalable);
parent_.setPreHandler( dialog_->input_screen_encoding ); parent_.setPreHandler(dialog_->input_screen_encoding);
parent_.setPreHandler( dialog_->input_tiny ); parent_.setPreHandler(dialog_->input_tiny);
parent_.setPreHandler( dialog_->input_script ); parent_.setPreHandler(dialog_->input_script);
parent_.setPreHandler( dialog_->input_footnote ); parent_.setPreHandler(dialog_->input_footnote);
parent_.setPreHandler( dialog_->input_small ); parent_.setPreHandler(dialog_->input_small);
parent_.setPreHandler( dialog_->input_large ); parent_.setPreHandler(dialog_->input_large);
parent_.setPreHandler( dialog_->input_larger ); parent_.setPreHandler(dialog_->input_larger);
parent_.setPreHandler( dialog_->input_largest ); parent_.setPreHandler(dialog_->input_largest);
parent_.setPreHandler( dialog_->input_normal ); parent_.setPreHandler(dialog_->input_normal);
parent_.setPreHandler( dialog_->input_huge ); parent_.setPreHandler(dialog_->input_huge);
parent_.setPreHandler( dialog_->input_huger ); parent_.setPreHandler(dialog_->input_huger);
} }
@ -2581,7 +2596,7 @@ bool FormPreferences::ScreenFonts::input()
} }
if (!activate) if (!activate)
parent_.printWarning( str ); parent_.printWarning(str);
return activate; return activate;
} }
@ -2634,7 +2649,7 @@ void FormPreferences::SpellChecker::apply()
{ {
string choice = fl_get_choice_text(dialog_->choice_spell_command); string choice = fl_get_choice_text(dialog_->choice_spell_command);
choice = strip( frontStrip( choice ) ); choice = strip(frontStrip(choice));
lyxrc.isp_command = choice; lyxrc.isp_command = choice;
@ -2702,16 +2717,16 @@ void FormPreferences::SpellChecker::build()
FL_RETURN_CHANGED); FL_RETURN_CHANGED);
// set up the feedback mechanism // set up the feedback mechanism
parent_.setPreHandler( dialog_->choice_spell_command ); parent_.setPreHandler(dialog_->choice_spell_command);
parent_.setPreHandler( dialog_->check_alt_lang ); parent_.setPreHandler(dialog_->check_alt_lang);
parent_.setPreHandler( dialog_->input_alt_lang ); parent_.setPreHandler(dialog_->input_alt_lang);
parent_.setPreHandler( dialog_->check_escape_chars ); parent_.setPreHandler(dialog_->check_escape_chars);
parent_.setPreHandler( dialog_->input_escape_chars ); parent_.setPreHandler(dialog_->input_escape_chars);
parent_.setPreHandler( dialog_->check_personal_dict ); parent_.setPreHandler(dialog_->check_personal_dict);
parent_.setPreHandler( dialog_->input_personal_dict ); parent_.setPreHandler(dialog_->input_personal_dict);
parent_.setPreHandler( dialog_->button_personal_dict ); parent_.setPreHandler(dialog_->button_personal_dict);
parent_.setPreHandler( dialog_->check_compound_words ); parent_.setPreHandler(dialog_->check_compound_words);
parent_.setPreHandler( dialog_->check_input_enc ); parent_.setPreHandler(dialog_->check_input_enc);
} }
@ -2720,24 +2735,24 @@ FormPreferences::SpellChecker::feedback(FL_OBJECT const * const ob) const
{ {
string str; string str;
if (ob == dialog_->choice_spell_command ) if (ob == dialog_->choice_spell_command)
str = lyxrc.getDescription( LyXRC::RC_SPELL_COMMAND ); str = lyxrc.getDescription(LyXRC::RC_SPELL_COMMAND);
else if (ob == dialog_->check_alt_lang ) else if (ob == dialog_->check_alt_lang)
str = lyxrc.getDescription( LyXRC::RC_USE_ALT_LANG ); str = lyxrc.getDescription(LyXRC::RC_USE_ALT_LANG);
else if (ob == dialog_->input_alt_lang ) else if (ob == dialog_->input_alt_lang)
str = lyxrc.getDescription( LyXRC::RC_ALT_LANG ); str = lyxrc.getDescription(LyXRC::RC_ALT_LANG);
else if (ob == dialog_->check_escape_chars ) else if (ob == dialog_->check_escape_chars)
str = lyxrc.getDescription( LyXRC::RC_USE_ESC_CHARS ); str = lyxrc.getDescription(LyXRC::RC_USE_ESC_CHARS);
else if (ob == dialog_->input_escape_chars ) else if (ob == dialog_->input_escape_chars)
str = lyxrc.getDescription( LyXRC::RC_ESC_CHARS ); str = lyxrc.getDescription(LyXRC::RC_ESC_CHARS);
else if (ob == dialog_->check_personal_dict ) else if (ob == dialog_->check_personal_dict )
str = lyxrc.getDescription( LyXRC::RC_USE_PERS_DICT ); str = lyxrc.getDescription(LyXRC::RC_USE_PERS_DICT);
else if (ob == dialog_->input_personal_dict ) else if (ob == dialog_->input_personal_dict)
str = lyxrc.getDescription( LyXRC::RC_PERS_DICT ); str = lyxrc.getDescription(LyXRC::RC_PERS_DICT);
else if (ob == dialog_->check_compound_words ) else if (ob == dialog_->check_compound_words )
str = lyxrc.getDescription( LyXRC::RC_ACCEPT_COMPOUND ); str = lyxrc.getDescription(LyXRC::RC_ACCEPT_COMPOUND);
else if (ob == dialog_->check_input_enc ) else if (ob == dialog_->check_input_enc)
str = lyxrc.getDescription( LyXRC::RC_USE_INP_ENC ); str = lyxrc.getDescription(LyXRC::RC_USE_INP_ENC);
return str; return str;
} }
@ -2807,8 +2822,10 @@ bool FormPreferences::SpellChecker::input( FL_OBJECT const * const ob )
} }
if( ob == dialog_->button_personal_dict) { if( ob == dialog_->button_personal_dict) {
parent_.browse( dialog_->input_personal_dict, parent_.browse(dialog_->input_personal_dict,
_("Personal dictionary"), "*.ispell" ); _("Personal dictionary"), "*.ispell",
pair<string, string>(),
pair<string, string>());
} }
return true; // All input is valid! return true; // All input is valid!
@ -2858,7 +2875,7 @@ void FormPreferences::SpellChecker::update()
} }
bool FormPreferences::WriteableDir( string const & name ) bool FormPreferences::WriteableDir(string const & name)
{ {
bool success = true; bool success = true;
string str; string str;
@ -2880,13 +2897,13 @@ bool FormPreferences::WriteableDir( string const & name )
} }
if (!success) if (!success)
printWarning( str ); printWarning(str);
return success; return success;
} }
bool FormPreferences::ReadableDir( string const & name ) bool FormPreferences::ReadableDir(string const & name)
{ {
bool success = true; bool success = true;
string str; string str;
@ -2936,25 +2953,11 @@ bool FormPreferences::WriteableFile(string const & name,
str = N_("WARNING! The absolute path is required."); str = N_("WARNING! The absolute path is required.");
} }
#if 0
// This is not a nice way to use FileInfo (Lgb)
FileInfo d;
{
FileInfo d1(dir);
FileInfo d2(name);
if (d2.isDir() )
d = d2;
else
d = d1;
}
#else
// This should be equivalent (Lgb)
FileInfo d(name); FileInfo d(name);
if (!d.isDir()) { if (!d.isDir()) {
d.newFile(dir); d.newFile(dir);
} }
#endif
if (success && !d.isDir()) { if (success && !d.isDir()) {
success = false; success = false;
str = N_("WARNING! Directory does not exist."); str = N_("WARNING! Directory does not exist.");
@ -2965,7 +2968,7 @@ bool FormPreferences::WriteableFile(string const & name,
str = N_("WARNING! Cannot write to this directory."); str = N_("WARNING! Cannot write to this directory.");
} }
FileInfo f(name+suffix); FileInfo f(name + suffix);
if (success && (dir == name || f.isDir())) { if (success && (dir == name || f.isDir())) {
success = false; success = false;
str = N_("WARNING! A file is required, not a directory."); str = N_("WARNING! A file is required, not a directory.");
@ -3015,7 +3018,7 @@ bool FormPreferences::ReadableFile(string const & name,
str = N_("WARNING! Cannot read from this directory."); str = N_("WARNING! Cannot read from this directory.");
} }
FileInfo f(name+suffix); FileInfo f(name + suffix);
if (success && (dir == name || f.isDir())) { if (success && (dir == name || f.isDir())) {
success = false; success = false;
str = N_("WARNING! A file is required, not a directory."); str = N_("WARNING! A file is required, not a directory.");
@ -3038,35 +3041,35 @@ bool FormPreferences::ReadableFile(string const & name,
} }
void FormPreferences::printWarning( string const & warning ) void FormPreferences::printWarning(string const & warning)
{ {
warningPosted = true; warningPosted = true;
string str = formatted( warning, dialog_->text_warning->w-10, string const str = formatted(warning, dialog_->text_warning->w - 10,
FL_SMALL_SIZE, FL_NORMAL_STYLE ); FL_SMALL_SIZE, FL_NORMAL_STYLE);
fl_set_object_label(dialog_->text_warning, str.c_str()); fl_set_object_label(dialog_->text_warning, str.c_str());
fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE); fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
} }
bool FormPreferences::browse( FL_OBJECT * inpt, bool FormPreferences::browse(FL_OBJECT * inpt,
string const & title, string const & title,
string const & pattern, string const & pattern,
pair<string,string> const & dir1, pair<string,string> const & dir1,
pair<string,string> const & dir2 ) pair<string,string> const & dir2)
{ {
// Get the filename from the dialog // Get the filename from the dialog
string const filename = fl_get_input(inpt); string const filename = fl_get_input(inpt);
// Show the file browser dialog // Show the file browser dialog
string const new_filename = string const new_filename =
browseFile(filename, title, pattern, dir1, dir2 ); browseFile(filename, title, pattern, dir1, dir2);
// Save the filename to the dialog // Save the filename to the dialog
if (new_filename != filename && ! new_filename.empty()) { if (new_filename != filename && !new_filename.empty()) {
fl_set_input(inpt, new_filename.c_str()); fl_set_input(inpt, new_filename.c_str());
input( inpt, 0 ); input(inpt, 0);
} }
return true; return true;
@ -3074,35 +3077,35 @@ bool FormPreferences::browse( FL_OBJECT * inpt,
string const string const
FormPreferences::browseFile( string const & filename, FormPreferences::browseFile(string const & filename,
string const & title, string const & title,
string const & pattern, string const & pattern,
pair<string,string> const & dir1, pair<string,string> const & dir1,
pair<string,string> const & dir2 ) const pair<string,string> const & dir2) const
{ {
string lastPath = "."; string lastPath = ".";
if( !filename.empty() ) lastPath = OnlyPath(filename); if (!filename.empty()) lastPath = OnlyPath(filename);
LyXFileDlg fileDlg; LyXFileDlg fileDlg;
if( !dir1.second.empty() ) { if (!dir1.second.empty()) {
FileInfo fileInfo( dir1.second ); FileInfo fileInfo(dir1.second);
if( fileInfo.isOK() && fileInfo.isDir() ) if (fileInfo.isOK() && fileInfo.isDir())
fileDlg.SetButton( 0, dir1.first, dir1.second ); fileDlg.SetButton(0, dir1.first, dir1.second);
} }
if( !dir2.second.empty() ) { if (!dir2.second.empty()) {
FileInfo fileInfo( dir2.second ); FileInfo fileInfo(dir2.second);
if( fileInfo.isOK() && fileInfo.isDir() ) if (fileInfo.isOK() && fileInfo.isDir())
fileDlg.SetButton( 1, dir2.first, dir2.second ); fileDlg.SetButton(1, dir2.first, dir2.second);
} }
bool error = false; bool error = false;
string buf; string buf;
do { do {
string p = fileDlg.Select(title, string const p = fileDlg.Select(title,
lastPath, lastPath,
pattern, filename ); pattern, filename);
if (p.empty()) return p; if (p.empty()) return p;
@ -3136,7 +3139,7 @@ int FormPreferences::FeedbackCB(FL_OBJECT * ob, int event,
// Don't Assert this one, as it can happen quite reasonably when things // Don't Assert this one, as it can happen quite reasonably when things
// are being deleted in the d-tor. // are being deleted in the d-tor.
//Assert(ob->form); //Assert(ob->form);
if( !ob->form ) return 0; if (!ob->form) return 0;
FormPreferences * pre = FormPreferences * pre =
static_cast<FormPreferences*>(ob->form->u_vdata); static_cast<FormPreferences*>(ob->form->u_vdata);
@ -3150,15 +3153,15 @@ void FormPreferences::Feedback(FL_OBJECT * ob, int event)
{ {
Assert(ob); Assert(ob);
switch( event ) { switch (event) {
case FL_ENTER: case FL_ENTER:
warningPosted = false; warningPosted = false;
feedback( ob ); feedback(ob);
break; break;
case FL_LEAVE: case FL_LEAVE:
if( !warningPosted ) if (!warningPosted)
fl_set_object_label( dialog_->text_warning, "" ); fl_set_object_label(dialog_->text_warning, "");
break; break;
default: default:
@ -3170,5 +3173,6 @@ void FormPreferences::Feedback(FL_OBJECT * ob, int event)
void FormPreferences::setPreHandler(FL_OBJECT * ob) const void FormPreferences::setPreHandler(FL_OBJECT * ob) const
{ {
Assert(ob); Assert(ob);
fl_set_object_prehandler( ob, C_FormPreferencesFeedbackCB ); fl_set_object_prehandler(ob, C_FormPreferencesFeedbackCB);
} }

View File

@ -21,6 +21,7 @@
#include "FormBase.h" #include "FormBase.h"
#include "Color.h" #include "Color.h"
#include "LString.h"
#ifdef __GNUG_ #ifdef __GNUG_
#pragma interface #pragma interface
@ -104,22 +105,20 @@ private:
*/ */
/// ///
bool browse( FL_OBJECT * input, bool browse(FL_OBJECT * input,
string const & title, string const & pattern, string const & title, string const & pattern,
std::pair<string,string> const & dir1 = std::pair<string,string> const & dir1 //=
std::pair<string,string>(), //std::pair<string,string>()
std::pair<string,string> const & dir2 = ,
std::pair<string,string>() ); std::pair<string,string> const & dir2 //=
//std::pair<string,string>()
);
/// called from browse() /// called from browse()
string const browseFile( string const & filename, string const browseFile( string const & filename,
string const & title, string const & pattern, string const & title, string const & pattern,
std::pair<string,string> const & dir1, std::pair<string,string> const & dir1,
std::pair<string,string> const & dir2 ) const; std::pair<string,string> const & dir2 ) const;
/** Flag whether a warning has been posted to the text window.
If so, don't redraw the window when the mouse leaves an object. */
bool warningPosted;
/// Type definitions from the fdesign produced header file. /// Type definitions from the fdesign produced header file.
FD_form_preferences * build_preferences(); FD_form_preferences * build_preferences();
/// ///
@ -151,17 +150,21 @@ private:
/// Real GUI implementation. /// Real GUI implementation.
FD_form_preferences * dialog_; FD_form_preferences * dialog_;
/// Converters tabfolder
FD_form_outer_tab * converters_tab_;
/// reLyX and other import/input stuff /// reLyX and other import/input stuff
FD_form_outer_tab * inputs_tab_; FD_form_outer_tab * inputs_tab_;
/// HCI configuration /// HCI configuration
FD_form_outer_tab * look_n_feel_tab_; FD_form_outer_tab * look_n_feel_tab_;
/// Converters tabfolder
FD_form_outer_tab * converters_tab_;
/// Outputs tabfolder /// Outputs tabfolder
FD_form_outer_tab * outputs_tab_; FD_form_outer_tab * outputs_tab_;
/// Spellchecker, language stuff, etc /// Spellchecker, language stuff, etc
FD_form_outer_tab * usage_tab_; FD_form_outer_tab * usage_tab_;
/** Flag whether a warning has been posted to the text window.
If so, don't redraw the window when the mouse leaves an object. */
bool warningPosted;
/** Each tab folder is encapsulated in its own class. /** Each tab folder is encapsulated in its own class.
*/ */
@ -571,10 +574,10 @@ private:
/// ///
Converters converters_; Converters converters_;
/// ///
Formats formats_;
///
InputsMisc inputs_misc_; InputsMisc inputs_misc_;
/// ///
Formats formats_;
///
Interface interface_; Interface interface_;
/// ///
Language language_; Language language_;

View File

@ -339,7 +339,9 @@ void InsetGraphicsParams::Write(Buffer const * buf, ostream & os) const
os << " rotateAngle " << rotateAngle << endl; os << " rotateAngle " << rotateAngle << endl;
} }
static void readResize(InsetGraphicsParams * igp, bool height,
static
void readResize(InsetGraphicsParams * igp, bool height,
string const & token) string const & token)
{ {
InsetGraphicsParams::Resize resize = InsetGraphicsParams::DEFAULT_SIZE; InsetGraphicsParams::Resize resize = InsetGraphicsParams::DEFAULT_SIZE;
@ -369,7 +371,9 @@ static void readResize(InsetGraphicsParams * igp, bool height,
igp->widthResize = resize; igp->widthResize = resize;
} }
static void readOrigin(InsetGraphicsParams * igp, string const & token)
static
void readOrigin(InsetGraphicsParams * igp, string const & token)
{ // TODO: complete this function. { // TODO: complete this function.
igp->rotateOrigin = originTranslator.find(token); igp->rotateOrigin = originTranslator.find(token);
} }

View File

@ -54,7 +54,6 @@ using std::isdigit;
using std::isalpha; using std::isalpha;
#endif #endif
//extern char * mathed_label;
extern string mathed_label; extern string mathed_label;
extern char const * latex_special_chars; extern char const * latex_special_chars;

View File

@ -175,7 +175,7 @@ string const lowercase(string const & a)
} }
#else #else
// We want to use this one. (Lgb) // We want to use this one. (Lgb)
transform(tmp.begin(), tmp.end(), tmp.begin(), tolower); transform(tmp.begin(), tmp.end(), tmp.begin(), lowercase);
#endif #endif
return tmp; return tmp;
} }
@ -193,7 +193,7 @@ string const uppercase(string const & a)
} }
#else #else
// We want to use this one. (Lgb) // We want to use this one. (Lgb)
transform(tmp.begin(), tmp.end(), tmp.begin(), toupper); transform(tmp.begin(), tmp.end(), tmp.begin(), uppercase);
#endif #endif
return tmp; return tmp;
} }

View File

@ -3,6 +3,8 @@
#ifndef LYX_FUNCTIONAL_H #ifndef LYX_FUNCTIONAL_H
#define LYX_FUNCTIONAL_H #define LYX_FUNCTIONAL_H
#include <iterator>
//namespace lyx { //namespace lyx {
template<class R, class C, class A> template<class R, class C, class A>
@ -50,21 +52,28 @@ class_fun(C & c, void(C::*f)(A))
template <class Cont, class Type, class MemRet> template <class Cont, class Type, class MemRet>
class back_insert_fun_iterator { class back_insert_fun_iterator {
protected: protected:
Cont & container; Cont * container;
MemRet(Type::*pmf)(); MemRet(Type::*pmf)();
public: public:
typedef Cont container_type;
typedef std::output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
back_insert_fun_iterator(Cont & x, MemRet(Type::*p)()) back_insert_fun_iterator(Cont & x, MemRet(Type::*p)())
: container(x), pmf(p) {} : container(&x), pmf(p) {}
back_insert_fun_iterator & back_insert_fun_iterator &
operator=(Type * val) { operator=(Type * val) {
container.push_back((val->*pmf)()); container->push_back((val->*pmf)());
return *this; return *this;
} }
back_insert_fun_iterator & back_insert_fun_iterator &
operator=(Type & val) { operator=(Type & val) {
container.push_back((val.*pmf)()); container->push_back((val.*pmf)());
return *this; return *this;
} }
@ -83,21 +92,30 @@ public:
template <class Cont, class Type, class MemRet> template <class Cont, class Type, class MemRet>
class const_back_insert_fun_iterator { class const_back_insert_fun_iterator {
protected: protected:
Cont & container; Cont * container;
MemRet(Type::*pmf)() const; MemRet(Type::*pmf)() const;
public: public:
typedef Cont container_type;
typedef std::output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
const_back_insert_fun_iterator(Cont & x, MemRet(Type::*p)() const) const_back_insert_fun_iterator(Cont & x, MemRet(Type::*p)() const)
: container(x), pmf(p) {} : container(&x), pmf(p) {}
~const_back_insert_fun_iterator() {}
const_back_insert_fun_iterator & const_back_insert_fun_iterator &
operator=(Type const * val) { operator=(Type const * val) {
container.push_back((val->*pmf)()); container->push_back((val->*pmf)());
return *this; return *this;
} }
const_back_insert_fun_iterator & const_back_insert_fun_iterator &
operator=(Type const & val) { operator=(Type const & val) {
container.push_back((val.*pmf)()); container->push_back((val.*pmf)());
return *this; return *this;
} }

View File

@ -12,6 +12,22 @@ using std::endl;
extern string system_tempdir; extern string system_tempdir;
static inline
int make_tempfile(char * templ)
{
#ifdef HAVE_MKSTEMP
return ::mkstemp(templ);
#else
#ifdef HAVE_MKTEMP
// This probably just barely works...
::mktemp(templ);
return ::open(templ, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
#else
#warning FIX FIX FIX
#endif
#endif
}
string const lyx::tempName(string const & dir, string const & mask) string const lyx::tempName(string const & dir, string const & mask)
{ {
string const tmpdir(dir.empty() ? system_tempdir : dir); string const tmpdir(dir.empty() ? system_tempdir : dir);
@ -24,7 +40,7 @@ string const lyx::tempName(string const & dir, string const & mask)
tmpfl.copy(tmpl, string::npos); tmpfl.copy(tmpl, string::npos);
tmpl[tmpfl.length()] = '\0'; // terminator tmpl[tmpfl.length()] = '\0'; // terminator
int const tmpf = ::mkstemp(tmpl); int const tmpf = make_tempfile(tmpl);
if (tmpf != -1) { if (tmpf != -1) {
string const t(tmpl); string const t(tmpl);
::close(tmpf); ::close(tmpf);

View File

@ -342,6 +342,8 @@ void LyXTabular::set_row_column_number_info(bool oldformat)
} }
#else #else
// Isn't this the same as the while above? (Lgb) // Isn't this the same as the while above? (Lgb)
#warning Please check this Jürgen.
// if ok please delete the #if 0 section above. (Lgb)
for (int row = 0, column = 0, c = 0; for (int row = 0, column = 0, c = 0;
c < numberofcells && row < rows_ && column < columns_;) { c < numberofcells && row < rows_ && column < columns_;) {
rowofcell[c] = row; rowofcell[c] = row;
@ -2364,12 +2366,7 @@ static
inline inline
void print_n_chars(ostream & os, unsigned char ch, int n) void print_n_chars(ostream & os, unsigned char ch, int n)
{ {
#if 0
for (int i = 0; i < n; ++i)
os << ch;
#else
os << string(n, ch); os << string(n, ch);
#endif
} }
@ -2390,6 +2387,8 @@ int LyXTabular::AsciiTopHLine(ostream & os, int row,
return 0; return 0;
#else #else
// Isn't this equivalent? (Lgb) // Isn't this equivalent? (Lgb)
#warning Please check this Jürgen.
// If ok please delete the abofe #if 0 section. (Lgb)
for (int i = fcell; i < n; ++i) { for (int i = fcell; i < n; ++i) {
if (TopLine(i)) if (TopLine(i))
return 0; return 0;
@ -2444,6 +2443,8 @@ int LyXTabular::AsciiBottomHLine(ostream & os, int row,
return 0; return 0;
#else #else
// Isn't this equivalent? (Lgb) // Isn't this equivalent? (Lgb)
#warning Please check this Jürgen.
// If ok, please delete the above #if 0 section. (Lgb)
for (int i = fcell; i < n; ++i) { for (int i = fcell; i < n; ++i) {
if (BottomLine(i)) if (BottomLine(i))
return 0; return 0;

View File

@ -18,4 +18,4 @@
#include "tracer.h" #include "tracer.h"
int DebugTracer::depth = 0; int Trace::depth = 0;

View File

@ -20,20 +20,20 @@
#include "LString.h" #include "LString.h"
/// ///
class DebugTracer { class Trace {
public: public:
/// ///
explicit explicit
DebugTracer(string const & s) : str(s) { Trace(string const & s) : str(s) {
lyxerr << string(depth, ' ') << "Trace begin : " lyxerr << string(depth, ' ') << "TRACE IN: "
<< str << std::endl; << str << std::endl;
++depth; depth += 2;
} }
/// ///
~DebugTracer() { ~Trace() {
--depth; depth -= 2;
lyxerr << string(depth, ' ') << "Trace end : " lyxerr << string(depth, ' ') << "TRACE OUT: "
<< str << std::endl; << str << std::endl;
} }
private: private:
@ -43,4 +43,11 @@ private:
static int depth; static int depth;
}; };
// To avoid wrong usage:
// Trace("BufferView::update"); // wrong
// Trace t("BufferView::update"); // right
// we add this macro:
///
#define Trace(x) unnamed_Trace;
// Tip gotten from Bobby Schmidt's column in C/C++ Users Journal
#endif #endif