+2000-11-08 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * src/support/filetools.C (DirList): implement using system functions
+
+ * src/support/tempname.C: new file
+
+ * src/support/Makefile.am (libsupport_la_SOURCES): add tempname.C
+
+ * src/insets/insetexternal.C (InsetExternal): use lyx::tempName
+
+ * src/graphics/GraphicsCacheItem_pimpl.C (renderXPM): use
+ lyx::tempName
+
+ * src/frontends/xforms/ButtonController.C: new file
+
+ * src/os2_defines.h: remove getcwd define
+
+ * src/lyxvc.C: include support/lyxlib.h
+ (showLog): use lyx::tempName
+
+ * src/lyx_cb.C: comment out includes that we don't need
+ (AutoSave): use lyx::tempName
+
+ * src/filedlg.C: include support/lyxlib.h
+ (Reread): use lyx::getcwd
+
+ * src/converter.C: include support/filetools.h
+ (add_options): change to static inline, make tail const
+ (Add): make old_viewer const
+ (GetAllFormats): make it a const method, use const_iterator
+ (enable): make static inline
+ (SplitFormat): make using_format const
+
+ * src/LaTeX.C (run): use lyx::getcwd
+
+ * configure.in: check for mkstemp as well
+
+2000-11-07 Angus Leeming <a.leeming@ic.ac.uk>
+
+ * src/converter.[Ch] (GetAllCommands): new method.
+
+ * src/support/filetools.[Ch] (DirList): new method.
+
+ * src/frontends/xforms/FormPreferences.C: started (just!) adding
+ functionality to the converters tab.
+ The formats tab is now nearly complete.
+ The kbmap choices in Languages tab now display the contents of
+ system_lyxdir/kbd/*.kmap in readable form.
+
+ * src/frontends/xforms/FormPreferences.h: made struct RGB private.
+ Moved some variables into the class.
+
+ * src/frontends/xforms/forms/form_preferences.fd: Revert colour of
+ inactive tab folder to FL_COL1. Haven't yet worked out how to change
+ colour of active folder to lighter grey instead. Any takers?
+ (form_colours): added an "Apply" button.
+ (form_converters): added a "Flags" input field.
+ (form_formats): added a "Shortcut" input field. Note that we can't use
+ names such as "input_shortcut" as this buggers up the sed script stuff.
+
+ * src/frontends/xforms/FormPreferences.C
+
+2000-11-07 Angus Leeming <a.leeming@ic.ac.uk>
+
+ * src/LaTeXLog.C:
+ * src/LyXSendto.C:
+ * src/credits.C:
+ * src/filedlg.C:
+ * src/intl.C:
+ * src/lyx_cb.C:
+ * src/lyx_sendfax_main.C:
+ * src/lyxfr0.C:
+ * src/lyxvc.C:
+ * src/spellchecker.C:
+ * src/insets/figinset.C:
+ * src/insets/insetbib.C:
+ * src/insets/insetexternal.C:
+ * src/insets/insetinclude.C:
+ * src/insets/insetinfo.C:
+ * src/mathed/math_panel.C:
+ use FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT in fl_show_form(), so
+ all "daughter" dialogs now have identical "feel".
+
+2000-11-07 Angus Leeming <a.leeming@ic.ac.uk>
+
+ * src/lyx_gui_misc.[Ch] (IgnoreCloseBoxCB): removed as it's no longer
+ used (and was only used in one place prior to this patch. Incorrectly!)
+
+ * src/frontends/xforms/FormDocument.C: changed some instances of
+ FL_RETURN_ALWAYS to FL_RETURN_CHANGED as I think that this makes more
+ sense. Also added fl_set_input_return() for class_->input_doc_extra and
+ for options_->input_float_placement. This fixes a bug reported by
+ Rob Lahaye.
+
+ * src/frontends/xforms/FormGraphics.[Ch] (free): removed. Placed
+ functionality into d-tor.
+
+ * src/frontends/xforms/input_validators.c (fl_lowercase_filter): allow
+ input of numerals also.
+
+ * src/insets/insetinclude.C (Edit): use CancelCloseBoxCB in
+ fl_set_form_atclose(). Can now close dialog from window manager,
+ fixing a bug reported by Rob Lahaye.
+
+2000-11-06 Angus Leeming <a.leeming@ic.ac.uk>
+
+ * src/frontends/xforms/forms/form_preferences.fd: Inactive tab folders
+ are no longer dark. Haven't yet worked out how to lighten the colour of
+ the active tabfolder. Any ideas anybody?
+ Adjusted Colours tab a little.
+ Added Shortcut field to converters tab. Note that we can't create an
+ fdesign label like "input_shortcut" as this buggers up the sed-script
+ stuff.
+
+ * src/frontends/xforms/FormPreferences.[Ch]:
+ (feedback): fixed crash due to to ob=0.
+ (LanguagesXXX): the kbmap choices now contain the files
+ sytem_lyxdir/kbd/*.kmap. I think that these choices should eventually
+ be replaced by an input with a file browse button, but since the browse
+ buttons don'y yet work, this'll do for the moment.
+ (FormatsXXX): think that this is now nearly fully functional.
+ Some points/questions though:
+ 1. Does "Apply" remove formats if no longer present?
+ 2. I think that the browser should list the GUI names rather than the
+ format names.
+ 3. Must ensure that we can't delete Formats used by an existing
+ Converter.
+
+ * src/support/filetools.[Ch] (DirList): new function. Not at all sure
+ if this is the best way to do this.
+
2000-11-07 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* lib/reLyX/acinclude.m4 (RELYX_CHECK_ERRORS): remove useless message.
[Define on SunOS 4 and SCO, were some functions are missing from the headers])
fi
AC_CHECK_FUNCS(memmove memset strchr putenv setenv mkfifo snprintf vsnprintf)
+AC_CHECK_FUNCS(mkstemp)
dnl Until this is fixed in autoconf we provide our own version
LYX_FUNC_SELECT_ARGTYPES
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
bool rerun = false; // rerun requested
// The class LaTeX does not know the temp path.
- bufferlist.updateIncludedTeXfiles(GetCWD());
+ bufferlist.updateIncludedTeXfiles(lyx::getcwd()); //GetCWD());
// Never write the depfile if an error was encountered.
fl_raise_form(fd_latex_log->LaTeXLog);
} else {
fl_show_form(fd_latex_log->LaTeXLog,
- FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
use_build ? _("Build Program Log") : _("LaTeX Log"));
if (ow < 0) {
ow = fd_latex_log->LaTeXLog->w;
fl_raise_form(fd_form_sendto->form_sendto);
} else {
fl_show_form(fd_form_sendto->form_sendto,
- FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
_("Send Document to Command"));
if (ow < 0) {
ow = fd_form_sendto->form_sendto->w;
return;
}
- string const fname1 = TmpFileName();
+ string const fname1 = lyx::tempName(); //TmpFileName();
LyXParagraph * par = paragraph;
while (par) {
int noparbreak = 0;
#include "lyxrc.h"
#include "support/syscall.h"
#include "support/path.h"
+#include "support/filetools.h"
#include "buffer.h"
#include "bufferview_funcs.h"
#include "LaTeX.h"
vector<Command> Converter::commands;
string Converter::latex_command;
-inline
+static inline
string const add_options(string const & command, string const & options)
{
string head;
- string tail = split(command, head, ' ');
+ string const tail = split(command, head, ' ');
return head + ' ' + options + ' ' + tail;
}
return;
}
- string old_viewer = formats[name].viewer;
+ string const old_viewer = formats[name].viewer;
formats[name] = Format(name, extension, prettyname, shortcut,
old_viewer);
}
}
+// This method should return a reference, and throw an exception
+// if the format named name cannot be found (Lgb)
Format * Formats::GetFormat(string const & name)
{
FormatList::iterator it = formats.find(name);
vector<Format>
-const Formats::GetAllFormats()
+const Formats::GetAllFormats() const
{
vector<Format> result;
- for (FormatList::iterator it = formats.begin();
- it != formats.end(); ++it)
- result.push_back(it->second);
+ for (FormatList::const_iterator cit = formats.begin();
+ cit != formats.end(); ++cit)
+ result.push_back(cit->second);
return result;
}
//////////////////////////////////////////////////////////////////////////////
+// Instead of storing an object we could just store an const reference.
+// _but_ that is not guaranteed to work in all cases. (Lgb)
class compare_Command {
public:
compare_Command(Command const & c) : com(c) {}
}
-inline
+static inline
bool enable(vector<Command>::iterator it, string const & from)
{
return find(it->disable.begin(), it->disable.end(), from)
string const Converter::SplitFormat(string const & str, string & format)
{
- string using_format = split(str, format, ':');
+ string const using_format = split(str, format, ':');
if (format.empty())
format = "dvi";
return using_format;
{
}
+vector<Command> const Converter::GetAllCommands()
+{
+ vector<Command> result;
+ for (vector<Command>::iterator it = commands.begin();
+ it != commands.end(); ++it)
+ result.push_back(*it);
+ return result;
+}
+
+
/// The global instance
Formats formats;
///
string const Extension(string const & name);
///
- std::vector<Format> const GetAllFormats();
+ std::vector<Format> const GetAllFormats() const;
private:
///
FormatList formats;
///
static
void init();
+ ///
+ static
+ std::vector<Command> const GetAllCommands();
private:
///
static
fl_raise_form(fd_form_credits->form_credits);
} else {
fl_show_form(fd_form_credits->form_credits,
- FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
_("Credits"));
}
}
#include "lyx_gui_misc.h" // CancelCloseCB
#include "support/FileInfo.h"
+#include "support/lyxlib.h"
#include "gettext.h"
#ifdef HAVE_ERRNO_H
if (!pDirectory) {
WriteFSAlert(_("Warning! Couldn't open directory."),
pszDirectory);
- pszDirectory = GetCWD();
+ pszDirectory = lyx::getcwd(); //GetCWD();
pDirectory = ::opendir(pszDirectory.c_str());
}
fl_set_button(pFileDlgForm->Ready, 0);
fl_set_focus_object(pFileDlgForm->FileDlg, pFileDlgForm->Filename);
fl_deactivate_all_forms();
- fl_show_form(pFileDlgForm->FileDlg, FL_PLACE_MOUSE | FL_FREE_SIZE,
- FL_FULLBORDER, title.c_str());
+ fl_show_form(pFileDlgForm->FileDlg,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
+ title.c_str());
isOk = RunDialog();
void PreferencesPolicy::input(SMInput input)
{
+ lyxerr << "PreferencesPolicy::input" << endl;
// CANCEL and HIDE always take us to INITIAL for all cases.
// Note that I didn't put that special case in the helper function
// because it doesn't belong there. Some other
void OkCancelPolicy::input(SMInput input)
{
+ lyxerr << "OkCancelPolicy::input" << endl;
+
// CANCEL and HIDE always take us to INITIAL for all cases
if (SMI_CANCEL == input
|| SMI_HIDE == input) {
void OkCancelReadOnlyPolicy::input(SMInput input)
{
+ lyxerr << "OkCancelReadOnlyPolicy" << endl;
+
// CANCEL and HIDE always take us to INITIAL for all cases
if (SMI_CANCEL == input
|| SMI_HIDE == input) {
void NoRepeatedApplyReadOnlyPolicy::input(SMInput input)
{
+ lyxerr << "NoReapeatedApplyReadOnlyPolicy::input" << endl;
+
// CANCEL and HIDE always take us to INITIAL for all cases
if (SMI_CANCEL == input
|| SMI_HIDE == input) {
void OkApplyCancelReadOnlyPolicy::input(SMInput input)
{
+ lyxerr << "OkApplyCancelReadOnlyPolicy::input" << endl;
+
// CANCEL and HIDE always take us to INITIAL for all cases
if (SMI_CANCEL == input
|| SMI_HIDE == input) {
void OkApplyCancelPolicy::input(SMInput input)
{
+ lyxerr << "OkApplyCancelPolicy::input" << endl;
+
// CANCEL and HIDE always take us to INITIAL for all cases
if (SMI_CANCEL == input
|| SMI_HIDE == input) {
void NoRepeatedApplyPolicy::input(SMInput input)
{
+ lyxerr << "NoRepeatedApplyPolicy::input" << endl;
+
// CANCEL and HIDE always take us to INITIAL for all cases
if (SMI_CANCEL == input
|| SMI_HIDE == input) {
///
OkCancelPolicy();
///
- virtual ~OkCancelPolicy() {}
+ //virtual ~OkCancelPolicy() {}
/// Trigger a transition with this input.
virtual void input(SMInput);
///
OkCancelReadOnlyPolicy();
///
- virtual ~OkCancelReadOnlyPolicy() {}
+ //virtual ~OkCancelReadOnlyPolicy() {}
/// Trigger a transition with this input.
virtual void input(SMInput);
///
NoRepeatedApplyReadOnlyPolicy();
///
- virtual ~NoRepeatedApplyReadOnlyPolicy() {}
+ //virtual ~NoRepeatedApplyReadOnlyPolicy() {}
/// Trigger a transition with this input.
virtual void input(SMInput);
///
OkApplyCancelReadOnlyPolicy();
///
- virtual ~OkApplyCancelReadOnlyPolicy() {}
+ //virtual ~OkApplyCancelReadOnlyPolicy() {}
/// Trigger a transition with this input.
virtual void input(SMInput);
///
OkApplyCancelPolicy();
///
- virtual ~OkApplyCancelPolicy() {}
+ //virtual ~OkApplyCancelPolicy() {}
/// Trigger a transition with this input.
virtual void input(SMInput);
///
NoRepeatedApplyPolicy();
///
- virtual ~NoRepeatedApplyPolicy() {}
+ //virtual ~NoRepeatedApplyPolicy() {}
/// Trigger a transition with this input.
virtual void input(SMInput);
///
PreferencesPolicy();
///
- virtual ~PreferencesPolicy() {}
+ //virtual ~PreferencesPolicy() {}
/// Trigger a transition with this input.
virtual void input(SMInput);
*/
class IgnorantPolicy : public ButtonPolicy {
public:
- virtual ~IgnorantPolicy() {}
+ //virtual ~IgnorantPolicy() {}
/// Trigger a transition with this input.
virtual void input(SMInput) {}
--- /dev/null
+#include <config.h>
+
+#include FORMS_H_LOCATION
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "ButtonController.h"
+#include "support/LAssert.h"
+
+
+ButtonController::ButtonController(ButtonPolicy * bp,
+ char const * cancel, char const * close)
+ : bp_(bp), okay_(0), apply_(0), cancel_(0), undo_all_(0),
+ read_only_(), cancel_label(cancel), close_label(close)
+{
+ Assert(bp);
+}
+
+
+void ButtonController::refresh()
+{
+ if (okay_) {
+ if (bp_->buttonStatus(ButtonPolicy::OKAY)) {
+ fl_activate_object(okay_);
+ fl_set_object_lcol(okay_, FL_BLACK);
+ } else {
+ fl_deactivate_object(okay_);
+ fl_set_object_lcol(okay_, FL_INACTIVE);
+ }
+ }
+ if (apply_) {
+ if (bp_->buttonStatus(ButtonPolicy::APPLY)) {
+ fl_activate_object(apply_);
+ fl_set_object_lcol(apply_, FL_BLACK);
+ } else {
+ fl_deactivate_object(apply_);
+ fl_set_object_lcol(apply_, FL_INACTIVE);
+ }
+ }
+ if (undo_all_) {
+ if (bp_->buttonStatus(ButtonPolicy::UNDO_ALL)) {
+ fl_activate_object(undo_all_);
+ fl_set_object_lcol(undo_all_, FL_BLACK);
+ } else {
+ fl_deactivate_object(undo_all_);
+ fl_set_object_lcol(undo_all_,
+ FL_INACTIVE);
+ }
+ }
+ if (cancel_) {
+ if (bp_->buttonStatus(ButtonPolicy::CANCEL)) {
+ fl_set_object_label(cancel_,
+ cancel_label);
+ } else {
+ fl_set_object_label(cancel_,
+ close_label);
+ }
+ }
+ if (!read_only_.empty()) {
+ if (bp_->isReadOnly()) {
+ std::list<FL_OBJECT *>::iterator
+ end = read_only_.end();
+ for (std::list<FL_OBJECT *>::iterator
+ iter = read_only_.begin();
+ iter != end;
+ ++iter) {
+ fl_deactivate_object(*iter);
+ fl_set_object_lcol(*iter,
+ FL_INACTIVE);
+ }
+ } else {
+ std::list<FL_OBJECT *>::iterator
+ end = read_only_.end();
+ for (std::list<FL_OBJECT *>::iterator
+ iter = read_only_.begin();
+ iter != end;
+ ++iter) {
+ fl_activate_object(*iter);
+ fl_set_object_lcol(*iter,
+ FL_BLACK);
+ }
+ }
+ }
+}
+
+
+void ButtonController::input(ButtonPolicy::SMInput in)
+{
+ bp_->input(in);
+ refresh();
+}
+
+
+void ButtonController::ok()
+{
+ input(ButtonPolicy::SMI_OKAY);
+}
+
+
+void ButtonController::apply()
+{
+ input(ButtonPolicy::SMI_APPLY);
+}
+
+
+void ButtonController::cancel()
+{
+ input(ButtonPolicy::SMI_CANCEL);
+}
+
+
+void ButtonController::undoAll()
+{
+ input(ButtonPolicy::SMI_UNDO_ALL);
+}
+
+
+void ButtonController::hide()
+{
+ input(ButtonPolicy::SMI_HIDE);
+}
+
+
+bool ButtonController::readOnly(bool ro)
+{
+ if (ro) {
+ input(ButtonPolicy::SMI_READ_ONLY);
+ } else {
+ input(ButtonPolicy::SMI_READ_WRITE);
+ }
+ return ro;
+}
+
+
+void ButtonController::readWrite()
+{
+ readOnly(false);
+}
+
+
+bool ButtonController::valid(bool v)
+{
+ if (v) {
+ input(ButtonPolicy::SMI_VALID);
+ } else {
+ input(ButtonPolicy::SMI_INVALID);
+ }
+ return v;
+}
+
+
+void ButtonController::invalid()
+{
+ valid(false);
+}
#include "ButtonPolicies.h"
#include <list>
+#ifdef __GNUG__
+#pragma interface
+#endif
+
/** General purpose button controller for up to four buttons.
Controls the activation of the OK, Apply and Cancel buttons.
Actually supports 4 buttons in all and it's up to the user to decide on
you can just assign "Cancel" to both labels. Or even reuse this
class for something completely different.
*/
- ButtonController(ButtonPolicy * bp, char const * cancel, char const * close)
- : bp_(bp), okay_(0), apply_(0), cancel_(0), undo_all_(0),
- read_only_(), cancel_label(cancel), close_label(close) {}
- /// Somebody else owns the FL_OBJECTs we just manipulate them.
- ~ButtonController() {}
+ ButtonController(ButtonPolicy * bp,
+ char const * cancel, char const * close);
+
+ // Somebody else owns the FL_OBJECTs we just manipulate them.
+ // so? (Lgb)
+ //~ButtonController() {}
/* Initialise Button Functions */
/// Call refresh() when finished setting the buttons.
/* Action Functions */
/// force a refresh of the buttons
- void refresh() {
- if (okay_) {
- if (bp_->buttonStatus(ButtonPolicy::OKAY)) {
- fl_activate_object(okay_);
- fl_set_object_lcol(okay_, FL_BLACK);
- } else {
- fl_deactivate_object(okay_);
- fl_set_object_lcol(okay_, FL_INACTIVE);
- }
- }
- if (apply_) {
- if (bp_->buttonStatus(ButtonPolicy::APPLY)) {
- fl_activate_object(apply_);
- fl_set_object_lcol(apply_, FL_BLACK);
- } else {
- fl_deactivate_object(apply_);
- fl_set_object_lcol(apply_, FL_INACTIVE);
- }
- }
- if (undo_all_) {
- if (bp_->buttonStatus(ButtonPolicy::UNDO_ALL)) {
- fl_activate_object(undo_all_);
- fl_set_object_lcol(undo_all_, FL_BLACK);
- } else {
- fl_deactivate_object(undo_all_);
- fl_set_object_lcol(undo_all_,
- FL_INACTIVE);
- }
- }
- if (cancel_) {
- if (bp_->buttonStatus(ButtonPolicy::CANCEL)) {
- fl_set_object_label(cancel_,
- cancel_label);
- } else {
- fl_set_object_label(cancel_,
- close_label);
- }
- }
- if (!read_only_.empty()) {
- if (bp_->isReadOnly()) {
- std::list<FL_OBJECT *>::iterator
- end = read_only_.end();
- for (std::list<FL_OBJECT *>::iterator
- iter = read_only_.begin();
- iter != end;
- ++iter) {
- fl_deactivate_object(*iter);
- fl_set_object_lcol(*iter,
- FL_INACTIVE);
- }
- } else {
- std::list<FL_OBJECT *>::iterator
- end = read_only_.end();
- for (std::list<FL_OBJECT *>::iterator
- iter = read_only_.begin();
- iter != end;
- ++iter) {
- fl_activate_object(*iter);
- fl_set_object_lcol(*iter,
- FL_BLACK);
- }
- }
- }
- }
+ void refresh();
+
///
- void input(ButtonPolicy::SMInput in) {
- bp_->input(in);
- refresh();
- }
+ void input(ButtonPolicy::SMInput in);
///
- void ok() {
- input(ButtonPolicy::SMI_OKAY);
- }
+ void ok();
///
- void apply() {
- input(ButtonPolicy::SMI_APPLY);
- }
+ void apply();
///
- void cancel() {
- input(ButtonPolicy::SMI_CANCEL);
- }
+ void cancel();
///
- void undoAll() {
- input(ButtonPolicy::SMI_UNDO_ALL);
- }
+ void undoAll();
///
- void hide() {
- input(ButtonPolicy::SMI_HIDE);
- }
+ void hide();
/// Passthrough function -- returns its input value
- bool readOnly(bool ro = true) {
- if (ro) {
- input(ButtonPolicy::SMI_READ_ONLY);
- } else {
- input(ButtonPolicy::SMI_READ_WRITE);
- }
- return ro;
- }
+ bool readOnly(bool ro = true);
///
- void readWrite() {
- readOnly(false);
- }
+ void readWrite();
/// Passthrough function -- returns its input value
- bool valid(bool v = true) {
- if (v) {
- input(ButtonPolicy::SMI_VALID);
- } else {
- input(ButtonPolicy::SMI_INVALID);
- }
- return v;
- }
+ bool valid(bool v = true);
///
- void invalid() {
- valid(false);
- }
+ void invalid();
private:
///
ButtonPolicy * bp_;
hideAll.connect(hideBufferDependent.slot());
}
+
Dialogs::~Dialogs()
{
+#if 0
+ // I belive that this is unsafe...
for (vector<DialogBase *>::iterator iter = dialogs_.begin();
iter != dialogs_.end();
++iter) {
delete *iter;
}
+#else
+ // I think this is better...
+ while (!dialogs_.empty()) {
+ delete dialogs_.back();
+ dialogs_.erase(dialogs_.end() - 1);
+ }
+#endif
}
#include "FormBase.h"
#include "LyXView.h"
#include "xform_macros.h"
+#include "support/LAssert.h"
+
+// The current scheme muddles debugging.
+// Can we please use some other means to create these functions?
+// I really don't like to use the preprossessor for this.
+// My suggestion: First of all move these functions into their own
+// file (that can be included here if wanted, and use m4 to expand
+// that file. So create a m4 function to do the expansion, a file
+// that contains the calls to to this function and a script to run
+// it and create the C++ file with the expanded functions. (Lgb)
+// Possible startoff point:
+// define([C_RETURNCB],[extern "C" int C_$1$2(FL_FORM * ob, void * d) { return $1::$2(ob, d); }])
C_RETURNCB (FormBase, WMHideCB)
C_GENERICCB(FormBase, ApplyCB)
ButtonPolicy * bp, char const * close, char const * cancel)
: lv_(lv), bc_(bp, cancel, close), d_(d), h_(0), title(t), bp_(bp),
minw_(0), minh_(0)
-{}
+{
+ Assert(lv && d && bp);
+}
FormBase::~FormBase()
int FormBase::WMHideCB(FL_FORM * form, void *)
{
+ Assert(form);
// Ensure that the signals (u and h) are disconnected even if the
// window manager is used to close the dialog.
FormBase * pre = static_cast<FormBase*>(form->u_vdata);
+ Assert(pre);
pre->hide();
pre->bc_.hide();
return FL_CANCEL;
void FormBase::ApplyCB(FL_OBJECT * ob, long)
{
+ Assert(ob && ob->form);
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
+ Assert(pre);
pre->apply();
pre->bc_.apply();
}
void FormBase::OKCB(FL_OBJECT * ob, long)
{
+ Assert(ob && ob->form);
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
+ Assert(pre);
pre->ok();
pre->bc_.ok();
}
void FormBase::CancelCB(FL_OBJECT * ob, long)
{
+ Assert(ob && ob->form);
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
+ Assert(pre);
pre->cancel();
pre->bc_.cancel();
}
void FormBase::InputCB(FL_OBJECT * ob, long data )
{
+ Assert(ob && ob->form);
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
- pre->bc_.valid( pre->input( ob, data ) );
+ Assert(ob);
+ pre->bc_.valid(pre->input(ob, data));
}
void FormBase::RestoreCB(FL_OBJECT * ob, long)
{
+ Assert(ob && ob->form);
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
+ Assert(ob);
pre->restore();
pre->bc_.undoAll();
}
ButtonPolicy * bp,
char const * close, char const * cancel)
: FormBase( lv, d, t, bp, close, cancel )
-{}
+{
+ Assert(lv && d && bp);
+}
void FormBaseBI::connect()
char const * close, char const * cancel)
: FormBase( lv, d, t, bp, close, cancel ),
u_(0)
-{}
+{
+ Assert(lv && d && bp);
+}
void FormBaseBD::connect()
#endif
/** This class is an XForms GUI base class.
- It is meant to be used solely as the parent class to FormBaseBI and FormBaseBD
+ It is meant to be used solely as the parent class to FormBaseBI
+ and FormBaseBD.
@author Angus Leeming
*/
class FormBase : public DialogBase, public noncopyable {
"| A4 small Margins (only portrait) "
"| A4 very small Margins (only portrait) "
"| A4 very wide margins (only portrait) "));
- fl_set_input_return(paper_->input_custom_width, FL_RETURN_ALWAYS);
- fl_set_input_return(paper_->input_custom_height, FL_RETURN_ALWAYS);
- fl_set_input_return(paper_->input_top_margin, FL_RETURN_ALWAYS);
- fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_ALWAYS);
- fl_set_input_return(paper_->input_left_margin, FL_RETURN_ALWAYS);
- fl_set_input_return(paper_->input_right_margin, FL_RETURN_ALWAYS);
- fl_set_input_return(paper_->input_head_height, FL_RETURN_ALWAYS);
- fl_set_input_return(paper_->input_head_sep, FL_RETURN_ALWAYS);
- fl_set_input_return(paper_->input_foot_skip, FL_RETURN_ALWAYS);
+ fl_set_input_return(paper_->input_custom_width, FL_RETURN_CHANGED);
+ fl_set_input_return(paper_->input_custom_height, FL_RETURN_CHANGED);
+ fl_set_input_return(paper_->input_top_margin, FL_RETURN_CHANGED);
+ fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_CHANGED);
+ fl_set_input_return(paper_->input_left_margin, FL_RETURN_CHANGED);
+ fl_set_input_return(paper_->input_right_margin, FL_RETURN_CHANGED);
+ fl_set_input_return(paper_->input_head_height, FL_RETURN_CHANGED);
+ fl_set_input_return(paper_->input_head_sep, FL_RETURN_CHANGED);
+ fl_set_input_return(paper_->input_foot_skip, FL_RETURN_CHANGED);
bc_.addReadOnly (paper_->choice_paperpackage);
bc_.addReadOnly (paper_->greoup_radio_orientation);
"default|empty|plain|headings|fancy");
fl_addto_choice(class_->choice_doc_skip,
_(" Smallskip | Medskip | Bigskip | Length "));
- fl_set_input_return(class_->input_doc_skip, FL_RETURN_ALWAYS);
- fl_set_input_return(class_->input_doc_spacing, FL_RETURN_ALWAYS);
+ fl_set_input_return(class_->input_doc_extra, FL_RETURN_CHANGED);
+ fl_set_input_return(class_->input_doc_skip, FL_RETURN_CHANGED);
+ fl_set_input_return(class_->input_doc_spacing, FL_RETURN_CHANGED);
bc_.addReadOnly (class_->radio_doc_indent);
bc_.addReadOnly (class_->radio_doc_skip);
// the document options form
options_ = build_doc_options();
+ fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
fl_set_counter_bounds(options_->slider_secnumdepth,-2,5);
fl_set_counter_bounds(options_->slider_tocdepth,-1,5);
fl_set_counter_step(options_->slider_secnumdepth,1,1);
#include "FormError.h"
#include "form_error.h"
#include "insets/inseterror.h"
+#include "support/LAssert.h"
-FormError::FormError( LyXView * lv, Dialogs * d )
- : FormInset( lv, d, _("LaTeX Error") ),
+
+FormError::FormError(LyXView * lv, Dialogs * d)
+ : FormInset( lv, d, _("LaTeX Error")),
dialog_(0), inset_(0)
{
+ Assert(lv && d);
// let the dialog be shown
// This is a permanent connection so we won't bother
// storing a copy because we won't be disconnecting.
FL_FORM * FormError::form() const
{
- if (dialog_ ) return dialog_->form;
+ if (dialog_) return dialog_->form;
return 0;
}
}
-void FormError::showInset( InsetError * inset )
+void FormError::showInset(InsetError * inset)
{
- if (inset == 0) return;
+ if (inset == 0) return; // Is this _really_ allowed? (Lgb)
// If connected to another inset, disconnect from it.
if (inset_)
virtual void disconnect();
/// Slot launching dialog to an existing inset
- void showInset( InsetError * );
+ void showInset(InsetError *);
/// Update dialog before showing it
virtual void update();
/// Build the dialog
FormGraphics::~FormGraphics()
{
- free();
+ // Remove all associations for the radio buttons
+ widthButtons.reset();
+ heightButtons.reset();
+ displayButtons.reset();
+
+ // Free the form.
+ delete dialog_;
}
}
-void FormGraphics::free()
-{
- // Remove all associations for the radio buttons
- widthButtons.reset();
- heightButtons.reset();
- displayButtons.reset();
-
-
- // Free the form.
- delete dialog_;
- dialog_ = 0;
-}
-
-
void FormGraphics::apply()
{
Assert(inset_ != 0);
/// Save the active inset and show the dialog.
void showDialog(InsetGraphics *);
- /// Explicitly free the dialog.
- void free();
/// Verify that the input is correct. If not disable ok/apply buttons.
bool checkInput();
/// Open the file browse dialog to select an image file.
#endif
using std::find;
+using std::find_if;
using std::getline;
using std::istream;
using std::pair;
+using std::sort;
using std::vector;
-using std::find_if;
extern string fmt(char const * fmtstr ...);
+extern string system_lyxdir;
extern Languages languages;
-typedef pair<string, FormPreferences::RGB> X11Colour;
-
-static vector<X11Colour> colourDB;
static string const colourFile("/usr/lib/X11/rgb.txt");
-
+vector<FormPreferences::X11Colour> FormPreferences::colourDB;
+pair<vector<string>, vector<string> > FormPreferences::dirlist;
+
FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
: FormBaseBI(lv, d, _("Preferences"), new PreferencesPolicy),
dialog_(0),
void FormPreferences::feedback( FL_OBJECT * ob )
{
- // Angus, do you really want to allow ob to be 0?
- // You set this in feedbackPost. Why?
- if (!ob) return; // stop a segfault below.
- // an alternative to the above is to check feedbackObj in
- // FeedbackCB and not call this function at all. But that's a
- // matter of deciding who should be checking the parameters for this
- // function.
+ if( !ob ) return;
string str;
bool FormPreferences::input(FL_OBJECT * ob, long)
{
+ Assert(ob);
+
// whatever checks you need to ensure the user hasn't entered
// some totally ridiculous value somewhere. Change activate to suit.
// comments before each test describe what is _valid_
{
colours_ = build_colours();
- FL_OBJECT *obj;
- obj = colours_->valslider_red;
+ FL_OBJECT * obj = colours_->valslider_red;
fl_set_slider_bounds(obj, 0, 255);
fl_set_slider_precision(obj, 0);
fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
}
-string const FormPreferences::feedbackColours( FL_OBJECT const * const ) const
+string const
+FormPreferences::feedbackColours(FL_OBJECT const * const ob) const
{
+ Assert(ob);
return string();
}
bool FormPreferences::inputColours( FL_OBJECT const * const ob )
{
+ Assert(ob);
bool activate = true;
if (ob == colours_->browser_x11) {
// remove redundant entries on the fly
bool add = cols.empty();
if (!add) {
- vector<RGB>::const_iterator it =
+ vector<RGB>::const_iterator it =
find( cols.begin(), cols.end(), col );
add = (it == cols.end());
}
}
-void FormPreferences::ColoursUpdateBrowser( int i )
+void FormPreferences::ColoursUpdateBrowser(int i)
{
fl_freeze_form(colours_->form);
RGB col = colourDB[i].second;
- fl_mapcolor(FL_FREE_COL4+i, col.r, col.g, col.b);
- fl_mapcolor(FL_FREE_COL4, col.r, col.g, col.b);
+ fl_mapcolor(FL_FREE_COL4 + i, col.r, col.g, col.b);
+ fl_mapcolor(FL_FREE_COL4, col.r, col.g, col.b);
fl_set_slider_value(colours_->valslider_red, col.r);
fl_set_slider_value(colours_->valslider_green, col.g);
fl_set_slider_value(colours_->valslider_blue, col.b);
fl_mapcolor(FL_FREE_COL4, col.r, col.g, col.b);
fl_redraw_object(colours_->button_colour);
- int i = ColoursSearchEntry( col );
+ int const i = ColoursSearchEntry( col );
// change topline only if necessary
// int top = fl_get_browser_topline(colours_->browser_x11);
// if (i < top || i > (top+15))
- fl_set_browser_topline(colours_->browser_x11, i-5);
+ fl_set_browser_topline(colours_->browser_x11, i - 5);
fl_select_browser_line(colours_->browser_x11, i + 1);
fl_unfreeze_form(colours_->form);
void FormPreferences::buildConverters()
{
converters_ = build_converters();
-
+
+ fl_set_input_return(converters_->input_converter, FL_RETURN_CHANGED);
+ fl_set_input_return(converters_->input_flags, FL_RETURN_CHANGED);
+
+ updateConverters();
}
string const
-FormPreferences::feedbackConverters( FL_OBJECT const * const ) const
+FormPreferences::feedbackConverters( FL_OBJECT const * const ob) const
{
+ Assert(ob);
return string();
}
void FormPreferences::updateConverters()
-{}
+{
+ vector<Command> commands = Converter::GetAllCommands();
+
+ vector<string> names;
+ for(vector<Command>::const_iterator cit = commands.begin();
+ cit != commands.end(); ++cit) {
+ string from = cit->from->prettyname;
+ string to = cit->to->prettyname;
+ string name = from + " -> " + to;
+ names.push_back(name);
+ }
+ sort(names.begin(), names.end());
+
+ fl_clear_browser(converters_->browser_converters);
+ for (vector<string>::const_iterator cit = names.begin();
+ cit != names.end(); ++cit)
+ fl_addto_browser(converters_->browser_converters,
+ cit->c_str());
+ fl_deactivate_object(converters_->button_add);
+ fl_set_object_lcol(converters_->button_add, FL_INACTIVE);
+
+ fl_deactivate_object(converters_->button_delete);
+ fl_set_object_lcol(converters_->button_delete, FL_INACTIVE);
+}
void FormPreferences::applyFormats() const
fl_set_input_return(formats_->input_format, FL_RETURN_CHANGED);
fl_set_input_return(formats_->input_viewer, FL_RETURN_CHANGED);
+ fl_set_input_return(formats_->input_shrtcut, FL_RETURN_CHANGED);
fl_set_input_return(formats_->input_gui_name, FL_RETURN_CHANGED);
fl_set_input_return(formats_->input_extension, FL_RETURN_CHANGED);
fl_set_input_filter(formats_->input_format, fl_lowercase_filter);
- formats_vec = formats.GetAllFormats();
- for (vector<Format>::const_iterator it = formats_vec.begin();
- it != formats_vec.end(); ++it)
- fl_addto_browser(formats_->browser_formats, it->name.c_str());
+ updateFormats();
}
-string const FormPreferences::feedbackFormats( FL_OBJECT const * const ) const
+string const
+FormPreferences::feedbackFormats(FL_OBJECT const * const ob) const
{
+ Assert(ob);
+
+ //if( !ob ) return;
+
string str;
return str;
bool FormPreferences::inputFormats(FL_OBJECT const * const ob)
{
+ Assert(ob);
+
+ //if( !ob ) return false;
+
if (ob == formats_->browser_formats) {
- int i = fl_get_browser(formats_->browser_formats);
- if (i > 0) {
- Format const & f = formats_vec[i-1];
- fl_set_input(formats_->input_format, f.name.c_str());
- fl_set_input(formats_->input_gui_name, f.prettyname.c_str());
- fl_set_input(formats_->input_extension, f.extension.c_str());
- fl_set_input(formats_->input_viewer, f.viewer.c_str());
- }
+ FormatsInputBrowser();
+
+ } else if (ob == formats_->input_format) {
+ FormatsInputInput();
+
} else if (ob == formats_->button_add) {
- string name = fl_get_input(formats_->input_format);
- string prettyname = fl_get_input(formats_->input_gui_name);
- string extension = fl_get_input(formats_->input_extension);
- string viewer = fl_get_input(formats_->input_viewer);
- string shortcut;
- if (prettyname.empty())
- return false;
- Format format(name, extension, prettyname, shortcut, viewer);
- vector<Format>::iterator it = find_if(formats_vec.begin(),
- formats_vec.end(),
- compare_memfun(&Format::getname, name));
- if (it == formats_vec.end()) {
- formats_vec.push_back(format);
- fl_add_browser_line(formats_->browser_formats,
- name.c_str());
- } else {
- //if (*it == format)
- // return false;
- *it = format;
- }
- return true;
+ FormatsInputAdd();
+
+ } else if (ob == formats_->button_delete) {
+ FormatsInputDelete();
}
return true;
}
void FormPreferences::updateFormats()
-{}
+{
+ formats_vec = formats.GetAllFormats();
+
+ vector<string> names;
+ for (vector<Format>::const_iterator it = formats_vec.begin();
+ it != formats_vec.end(); ++it)
+ names.push_back( it->name.c_str() );
+ sort(names.begin(), names.end());
+
+ fl_clear_browser(formats_->browser_formats);
+ for (vector<string>::const_iterator it = names.begin();
+ it != names.end(); ++it)
+ fl_addto_browser(formats_->browser_formats, it->c_str());
+
+ fl_deactivate_object(formats_->button_add);
+ fl_set_object_lcol(formats_->button_add, FL_INACTIVE);
+
+ fl_deactivate_object(formats_->button_delete);
+ fl_set_object_lcol(formats_->button_delete, FL_INACTIVE);
+}
+
+
+bool FormPreferences::FormatsInputAdd()
+{
+ string name = fl_get_input(formats_->input_format);
+ string prettyname = fl_get_input(formats_->input_gui_name);
+ string extension = fl_get_input(formats_->input_extension);
+ string viewer = fl_get_input(formats_->input_viewer);
+ string shortcut = fl_get_input(formats_->input_shrtcut);
+ if (prettyname.empty())
+ return false;
+
+ Format format(name, extension, prettyname, shortcut, viewer);
+ vector<Format>::iterator it =
+ find_if(formats_vec.begin(), formats_vec.end(),
+ compare_memfun(&Format::getname, name));
+
+ if (it == formats_vec.end()) {
+ fl_freeze_form(formats_->form);
+
+ formats_vec.push_back(format);
+
+ vector<string> names;
+ for (vector<Format>::const_iterator it = formats_vec.begin();
+ it != formats_vec.end(); ++it)
+ names.push_back( it->name.c_str() );
+
+ sort( names.begin(), names.end() );
+
+ fl_clear_browser( formats_->browser_formats );
+ for (vector<string>::const_iterator it = names.begin();
+ it != names.end(); ++it)
+ fl_addto_browser(formats_->browser_formats,
+ it->c_str());
+
+ fl_set_input(formats_->input_format, "");
+ fl_set_input(formats_->input_gui_name, "");
+ fl_set_input(formats_->input_shrtcut, "");
+ fl_set_input(formats_->input_extension, "");
+ fl_set_input(formats_->input_viewer, "");
+
+ fl_set_object_label( formats_->button_add,
+ idex(_("Add|#A")) );
+ fl_set_button_shortcut( formats_->button_add,
+ scex(_("Add|#A")), 1);
+
+ fl_deactivate_object(formats_->button_add);
+ fl_set_object_lcol(formats_->button_add, FL_INACTIVE);
+
+ fl_deactivate_object(formats_->button_delete);
+ fl_set_object_lcol(formats_->button_delete, FL_INACTIVE);
+
+ fl_unfreeze_form(formats_->form);
+
+ } else {
+ //if (*it == format)
+ // return false;
+ *it = format;
+ }
+ return true;
+}
+
+
+bool FormPreferences::FormatsInputDelete()
+{
+ string name = fl_get_input(formats_->input_format);
+ vector<Format>::iterator it =
+ find_if(formats_vec.begin(), formats_vec.end(),
+ compare_memfun(&Format::getname, name));
+
+ fl_freeze_form(formats_->form);
+
+ if (it == formats_vec.end()) {
+ fl_deactivate_object(formats_->button_delete);
+ fl_set_object_lcol(formats_->button_delete, FL_INACTIVE);
+
+ } else {
+ int sel = 0;
+ for( int i = 0;
+ i < fl_get_browser_maxline(formats_->browser_formats);
+ ++i ) {
+ string str = fl_get_browser_line( formats_->browser_formats, i+1 );
+ if( str == name ) {
+ sel = i+1;
+ break;
+ }
+ }
+
+ if( sel != 0 ) {
+ fl_delete_browser_line(formats_->browser_formats, sel );
+
+ fl_set_input(formats_->input_format, "");
+ fl_set_input(formats_->input_gui_name, "");
+ fl_set_input(formats_->input_shrtcut, "");
+ fl_set_input(formats_->input_extension, "");
+ fl_set_input(formats_->input_viewer, "");
+
+ fl_set_object_label( formats_->button_add,
+ idex(_("Add|#A")) );
+ fl_set_button_shortcut( formats_->button_add,
+ scex(_("Add|#A")), 1);
+
+ fl_deactivate_object(formats_->button_add);
+ fl_set_object_lcol(formats_->button_add, FL_INACTIVE);
+
+ fl_deactivate_object(formats_->button_delete);
+ fl_set_object_lcol(formats_->button_delete,
+ FL_INACTIVE);
+ }
+ }
+
+ fl_unfreeze_form(formats_->form);
+
+ return true;
+}
+
+
+bool FormPreferences::FormatsInputBrowser()
+{
+ int const i = fl_get_browser(formats_->browser_formats);
+ if( i <= 0 ) return true;
+
+ string name = fl_get_browser_line(formats_->browser_formats, i);
+ vector<Format>::iterator it =
+ find_if(formats_vec.begin(), formats_vec.end(),
+ compare_memfun(&Format::getname, name));
+
+ if (it != formats_vec.end()) {
+ fl_freeze_form(formats_->form);
+
+ fl_set_input(formats_->input_format, it->name.c_str());
+ fl_set_input(formats_->input_gui_name, it->prettyname.c_str());
+ fl_set_input(formats_->input_shrtcut, it->shortcut.c_str());
+ fl_set_input(formats_->input_extension, it->extension.c_str());
+ fl_set_input(formats_->input_viewer, it->viewer.c_str());
+
+ fl_set_object_label( formats_->button_add,
+ idex(_("Modify|#M")) );
+ fl_set_button_shortcut( formats_->button_add,
+ scex(_("Modify|#M")), 1);
+
+ fl_activate_object(formats_->button_add);
+ fl_set_object_lcol(formats_->button_add, FL_BLACK);
+
+ fl_activate_object(formats_->button_delete);
+ fl_set_object_lcol(formats_->button_delete, FL_BLACK);
+
+ fl_unfreeze_form(formats_->form);
+ }
+ return true;
+}
+
+
+bool FormPreferences::FormatsInputInput()
+{
+ string const name = fl_get_input(formats_->input_format);
+ vector<Format>::iterator it =
+ find_if(formats_vec.begin(), formats_vec.end(),
+ compare_memfun(&Format::getname, name));
+
+ fl_freeze_form(formats_->form);
+
+ if (it == formats_vec.end()) {
+ fl_set_object_label( formats_->button_add,
+ idex(_("Add|#A")) );
+ fl_set_button_shortcut( formats_->button_add,
+ scex(_("Add|#A")), 1);
+
+ if( name.empty() ) {
+ fl_deactivate_object(formats_->button_add);
+ fl_set_object_lcol(formats_->button_add, FL_INACTIVE);
+ } else {
+ fl_activate_object(formats_->button_add);
+ fl_set_object_lcol(formats_->button_add, FL_BLACK);
+ }
+
+ fl_deselect_browser(formats_->browser_formats);
+
+ fl_deactivate_object(formats_->button_delete);
+ fl_set_object_lcol(formats_->button_delete, FL_INACTIVE);
+
+ } else {
+ fl_set_object_label( formats_->button_add,
+ idex(_("Modify|#M")) );
+ fl_set_button_shortcut( formats_->button_add,
+ scex(_("Modify|#M")), 1);
+
+ int sel = 0;
+ for( int i = 0;
+ i < fl_get_browser_maxline(formats_->browser_formats);
+ ++i ) {
+ string str = fl_get_browser_line( formats_->browser_formats, i+1 );
+ if( str == name ) {
+ sel = i+1;
+ break;
+ }
+ }
+
+ int top = sel - 6;
+ if( top < 1 ) top = 0;
+ fl_set_browser_topline(formats_->browser_formats, top);
+ fl_select_browser_line(formats_->browser_formats, sel);
+
+ fl_activate_object(formats_->button_add);
+ fl_set_object_lcol(formats_->button_add, FL_BLACK);
+
+ fl_activate_object(formats_->button_delete);
+ fl_set_object_lcol(formats_->button_delete, FL_BLACK);
+ }
+
+ fl_unfreeze_form(formats_->form);
+ return true;
+}
void FormPreferences::applyInputsMisc() const
string const
FormPreferences::feedbackInputsMisc(FL_OBJECT const * const ob) const
{
+ Assert(ob);
+
+ //if( !ob ) return string();
+
string str;
if (ob == inputs_misc_->input_date_format )
string const
FormPreferences::feedbackInterface( FL_OBJECT const * const ob ) const
{
+ Assert(ob);
+
+ //if( !ob ) return string();
+
string str;
if (ob == interface_->input_popup_font )
}
-void FormPreferences::applyLanguage() const
+void FormPreferences::applyLanguage()
{
lyxrc.default_language = combo_default_lang->getline();
int button = fl_get_button(language_->check_use_kbmap);
+ string name_1 = combo_kbmap_1->getline();
+ string name_2 = combo_kbmap_2->getline();
+ if( button )
+ button = ( !name_1.empty() && !name_2.empty() );
lyxrc.use_kbmap = static_cast<bool>(button);
if (button) {
- lyxrc.primary_kbmap = combo_kbmap_1->getline();
- lyxrc.secondary_kbmap = combo_kbmap_2->getline();
+ vector<string>::iterator it =
+ find( dirlist.second.begin(), dirlist.second.end(),
+ name_1 );
+ vector<string>::size_type sel = it - dirlist.second.begin();
+ lyxrc.primary_kbmap = dirlist.first[sel];
+
+ it = find( dirlist.second.begin(), dirlist.second.end(),
+ name_2 );
+ sel = it - dirlist.second.begin();
+ lyxrc.secondary_kbmap = dirlist.first[sel];
}
button = fl_get_button(language_->check_rtl_support);
lyxrc.language_package = fl_get_input(language_->input_package);
lyxrc.language_command_begin = fl_get_input(language_->input_command_begin);
lyxrc.language_command_end = fl_get_input(language_->input_command_end);
+
+ // Ensure that all is self-consistent.
+ updateLanguage();
}
combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400);
combo_default_lang->shortcut("#L",1);
combo_default_lang->setcallback(ComboLanguageCB, this);
- LanguagesAdd( *combo_default_lang );
-
+
+ for (Languages::const_iterator cit = languages.begin();
+ cit != languages.end(); cit++) {
+ combo_default_lang->addto((*cit).second.lang());
+ }
+
// ditto kbmap_1
+ string dir = AddPath(system_lyxdir, "kbd");
+ vector<string> dirlist = DirList(dir , "kmap");
+
obj = language_->choice_kbmap_1;
fl_deactivate_object(language_->choice_kbmap_1);
combo_kbmap_1 = new Combox(FL_COMBOX_DROPLIST);
combo_kbmap_1->add(obj->x, obj->y, obj->w, obj->h, 400);
combo_kbmap_1->shortcut("#1",1);
combo_kbmap_1->setcallback(ComboLanguageCB, this);
- LanguagesAdd( *combo_kbmap_1 );
-
+
+ for (vector<string>::const_iterator cit = dirlist.begin();
+ cit != dirlist.end(); cit++) {
+ combo_kbmap_1->addto(*cit);
+ }
+
// ditto kbmap_2
obj = language_->choice_kbmap_2;
fl_deactivate_object(language_->choice_kbmap_2);
combo_kbmap_2->add(obj->x, obj->y, obj->w, obj->h, 400);
combo_kbmap_2->shortcut("#2",1);
combo_kbmap_2->setcallback(ComboLanguageCB, this);
- LanguagesAdd( *combo_kbmap_2 );
+
+ for (vector<string>::const_iterator cit = dirlist.begin();
+ cit != dirlist.end(); cit++) {
+ combo_kbmap_2->addto(*cit);
+ }
fl_end_form();
fl_unfreeze_form(language_->form);
setPostHandler( language_->input_command_end );
fl_end_form();
+
+ // Activate/Deactivate the input fields dependent on the state of the
+ // buttons.
+ inputLanguage( 0 );
}
string const
FormPreferences::feedbackLanguage(FL_OBJECT const * const ob) const
{
+ Assert(ob);
+
+ //if( !ob ) return string();
+
string str;
if (reinterpret_cast<Combox const *>(ob) == combo_default_lang )
combo_default_lang->select_text( lyxrc.default_language );
if (lyxrc.use_kbmap) {
- combo_kbmap_1->select_text( lyxrc.primary_kbmap );
- combo_kbmap_2->select_text( lyxrc.secondary_kbmap );
+ string fullpath = lyxrc.primary_kbmap;
+ vector<string>::iterator it =
+ find( dirlist.first.begin(), dirlist.first.end(),
+ fullpath );
+ vector<string>::size_type sel = it - dirlist.first.begin();
+ combo_kbmap_1->select_text( dirlist.second[sel] );
+
+ fullpath = lyxrc.secondary_kbmap;
+ it = find( dirlist.first.begin(), dirlist.first.end(),
+ fullpath );
+ sel = it - dirlist.first.begin();
+ combo_kbmap_2->select_text( dirlist.second[sel] );
} else {
- combo_kbmap_1->select_text( lyxrc.default_language );
- combo_kbmap_2->select_text( lyxrc.default_language );
+ combo_kbmap_1->select_text( "" );
+ combo_kbmap_2->select_text( "" );
}
fl_set_button(language_->check_rtl_support, lyxrc.rtl_support);
}
-void FormPreferences::LanguagesAdd( Combox & combo ) const
-{
- for (Languages::const_iterator cit = languages.begin();
- cit != languages.end(); cit++) {
- combo.addto((*cit).second.lang());
- }
-}
-
-
void FormPreferences::applyLnFmisc() const
{
lyxrc.show_banner = fl_get_button(lnf_misc_->check_banner);
check_auto_region_delete);
lyxrc.exit_confirmation = fl_get_button(lnf_misc_->check_exit_confirm);
lyxrc.display_shortcuts =
- fl_get_button(lnf_misc_->check_display_shortcuts);
+ fl_get_button(lnf_misc_->check_display_shrtcuts);
lyxrc.new_ask_filename = fl_get_button(lnf_misc_->check_ask_new_file);
lyxrc.cursor_follows_scrollbar =
fl_get_button(lnf_misc_->check_cursor_follows_scrollbar);
setPostHandler( lnf_misc_->check_banner );
setPostHandler( lnf_misc_->check_auto_region_delete );
setPostHandler( lnf_misc_->check_exit_confirm );
- setPostHandler( lnf_misc_->check_display_shortcuts );
+ setPostHandler( lnf_misc_->check_display_shrtcuts );
setPostHandler( lnf_misc_->counter_autosave );
setPostHandler( lnf_misc_->check_ask_new_file );
setPostHandler( lnf_misc_->check_cursor_follows_scrollbar );
string const FormPreferences::feedbackLnFmisc(FL_OBJECT const * const ob) const
{
+ Assert(ob);
+
+ //if( !ob ) return string();
+
string str;
if (ob == lnf_misc_->check_banner )
str = lyxrc.getDescription( LyXRC::RC_AUTOREGIONDELETE );
else if (ob == lnf_misc_->check_exit_confirm )
str = lyxrc.getDescription( LyXRC::RC_EXIT_CONFIRMATION );
- else if (ob == lnf_misc_->check_display_shortcuts )
+ else if (ob == lnf_misc_->check_display_shrtcuts )
str = lyxrc.getDescription( LyXRC::RC_DISPLAY_SHORTCUTS );
else if (ob == lnf_misc_->check_ask_new_file )
str = lyxrc.getDescription( LyXRC::RC_NEW_ASK_FILENAME );
lyxrc.auto_region_delete);
fl_set_button(lnf_misc_->check_exit_confirm,
lyxrc.exit_confirmation);
- fl_set_button(lnf_misc_->check_display_shortcuts,
+ fl_set_button(lnf_misc_->check_display_shrtcuts,
lyxrc.display_shortcuts);
fl_set_button(lnf_misc_->check_ask_new_file,
lyxrc.new_ask_filename);
string const
FormPreferences::feedbackOutputsMisc(FL_OBJECT const * const ob) const
{
+ Assert(ob);
+
+ //if( !ob ) return string();
+
string str;
if (ob == outputs_misc_->counter_line_len )
string const FormPreferences::feedbackPaths( FL_OBJECT const * const ob ) const
{
+ Assert(ob);
+
+ //if( !ob ) return string();
+
string str;
if (ob == paths_->input_default_path )
bool FormPreferences::inputPaths( FL_OBJECT const * const ob )
{
+ // what kind of coding is this? Do you plan for a ob == NULL?
+ // When is that allowed? (Lgb)
+ //Assert(ob);
+
bool activate = true;
if (!ob || ob == paths_->check_use_temp_dir) {
}
-string const FormPreferences::feedbackPrinter(FL_OBJECT const * const ob) const
+string const
+FormPreferences::feedbackPrinter(FL_OBJECT const * const ob) const
{
+ Assert(ob);
+
+ //if( !ob ) return string();
+
string str;
if (ob == printer_->input_command )
string const
FormPreferences::feedbackScreenFonts(FL_OBJECT const * const ob ) const
{
+ Assert(ob);
+
+ //if( !ob ) return string();
+
string str;
if (ob == screen_fonts_->input_roman )
string const
FormPreferences::feedbackSpellChecker(FL_OBJECT const * const ob) const
{
+ Assert(ob);
+
+ //if( !ob ) return string();
+
string str;
if (ob == spellchecker_->choice_spell_command )
bool FormPreferences::inputSpellChecker( FL_OBJECT const * const ob )
{
+ // ditto ob! (Lgb)
+
// Allow/dissallow input
// If spell checker == "none", disable all input.
choice = 3;
fl_set_choice(spellchecker_->choice_spell_command, choice);
- string str = string();
+ string str;
if (lyxrc.isp_use_alt_lang ) str = lyxrc.isp_alt_lang;
fl_set_button(spellchecker_->check_alt_lang,
}
-bool FormPreferences::WriteableDir( string const & name ) const
+bool FormPreferences::WriteableDir(string const & name) const
{
bool success = true;
string str;
}
-bool FormPreferences::ReadableDir( string const & name ) const
+bool FormPreferences::ReadableDir(string const & name) const
{
bool success = true;
string str;
str = N_("WARNING! The absolute path is required.");
}
- // This is not a nice way to use FileInfo (Lgb)
#if 0
+ // This is not a nice way to use FileInfo (Lgb)
FileInfo d;
{
void FormPreferences::ComboLanguageCB(int, void * v, Combox * combox)
{
- FormPreferences * pre = static_cast<FormPreferences*>(v);
- // This is safe, as nothing is done to the pointer, other than
- // to use its address in a block-if statement.
- pre->bc_.valid( pre->input( reinterpret_cast<FL_OBJECT *>(combox), 0 ));
+ Assert(v && combox);
+ FormPreferences * pre = static_cast<FormPreferences*>(v);
+ // This is safe, as nothing is done to the pointer, other than
+ // to use its address in a block-if statement.
+ pre->bc_.valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
}
void FormPreferences::FeedbackCB(FL_OBJECT * ob, long)
{
+ Assert(ob);
+
+ //if( !ob ) return;
+
FormPreferences * pre =
static_cast<FormPreferences*>(ob->form->u_vdata);
+ Assert(pre);
+
pre->feedback( pre->feedbackObj );
}
// can occur when form is being deleted. This seems an easier fix than
// a call "fl_set_object_posthandler(ob, 0)" for each and every object
// in the destructor.
+ if (!ob ) return 0;
if (!ob->form ) return 0;
FormPreferences * pre =
// post_handler for feedback messages
void FormPreferences::feedbackPost(FL_OBJECT * ob, int event)
{
+ Assert(ob);
+
+ //if( !ob ) return;
+
// We do not test for empty help here, since this can never happen
- if (event == FL_ENTER){
+ if (event == FL_ENTER) {
// Used as a placeholder for ob, so that we don't have to
// a horrible reinterpret_cast to long and pass it as an
// argument in fl_set_object_callback.
C_FormPreferencesFeedbackCB,
0);
fl_set_timer(dialog_->timer_feedback, 0.5);
- }
- else if (event != FL_MOTION){
+ } else if (event != FL_MOTION) {
fl_set_timer(dialog_->timer_feedback, 0);
feedbackObj = 0;
fl_set_object_label(dialog_->text_warning, "");
void FormPreferences::setPostHandler(FL_OBJECT * ob) const
{
+ Assert(ob);
+
+ //if( !ob ) return;
+
fl_set_object_posthandler(ob, C_FormPreferencesFeedbackPost);
}
///
void feedbackPost(FL_OBJECT *, int);
+private:
/// helper struct for Colours
struct RGB {
int r;
RGB() : r(0), g(0), b(0) {}
RGB(int red, int green, int blue) : r(red), g(green), b(blue) {}
};
+ ///
+ friend bool operator==(RGB const &, RGB const &);
+ ///
+ friend bool operator!=(RGB const &, RGB const &);
+ ///
+ typedef std::pair<string, RGB> X11Colour;
-private:
/// Update the dialog.
virtual void update();
///
///
void applyInterface() const;
///
- void applyLanguage() const;
+ void applyLanguage(); // not const because calls updateLanguage!
///
void applyLnFmisc() const;
///
/** Some helper functions for specific folders.
*/
- ///
- void LanguagesAdd( Combox & ) const;
///
bool ColoursLoadBrowser( string const & );
///
void ColoursUpdateBrowser( int );
///
void ColoursUpdateRGB();
+ ///
+ bool FormatsInputAdd();
+ ///
+ bool FormatsInputBrowser();
+ ///
+ bool FormatsInputDelete();
+ ///
+ bool FormatsInputInput();
///
bool WriteableDir( string const & ) const;
Combox * combo_kbmap_1;
///
Combox * combo_kbmap_2;
- ///
+ ///
FL_OBJECT * feedbackObj;
- ///
- std::vector<Format> formats_vec;
+ /// A vector of Formats, to be manipulated in the Format browser.
+ std::vector<Format> formats_vec;
+ /// A vector of RGB colours and associated name.
+ static std::vector<X11Colour> colourDB;
+ /** A collection of kmap files.
+ First entry is the file name, full path.
+ Second entry is the shorthand, as appears in the fl_choice.
+ Eg, system_lyxdir/kbd/american2.kmap, american2
+ */
+ static std::pair<std::vector<string>, std::vector<string> > dirlist;
};
-
inline
bool operator==(FormPreferences::RGB const & c1,
FormPreferences::RGB const & c2)
ETAGS_ARGS = --lang=c++
# Alphabetical order please. It makes it easier to figure out what's missing.
libxforms_la_SOURCES = \
+ ButtonController.C \
ButtonController.h \
Dialogs.C \
GUIRunTime.C \
obj = fl_add_box(FL_UP_BOX, 0, 0, 470, 500, "");
fdui->tabfolder_prefs = obj = fl_add_tabfolder(FL_TOP_TABFOLDER, 5, 10, 455, 375, "");
fl_set_object_boxtype(obj, FL_FLAT_BOX);
- fl_set_object_color(obj, FL_BOTTOM_BCOL, FL_COL1);
fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 270, 390, 90, 30, idex(_("Apply|#A")));
fl_set_button_shortcut(obj, scex(_("Apply|#A")), 1);
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
obj = fl_add_box(FL_FLAT_BOX, 0, 0, 455, 375, "");
fdui->tabfolder_outer = obj = fl_add_tabfolder(FL_TOP_TABFOLDER, 0, 0, 455, 375, "");
fl_set_object_boxtype(obj, FL_FLAT_BOX);
- fl_set_object_color(obj, FL_BOTTOM_BCOL, FL_COL1);
fl_end_form();
fdui->form->fdui = fdui;
fl_set_button_shortcut(obj, scex(_("Browse|#B")), 1);
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
- fdui->button_colour = obj = fl_add_button(FL_NORMAL_BUTTON, 290, 230, 150, 30, "");
+ fdui->button_colour = obj = fl_add_button(FL_NORMAL_BUTTON, 180, 230, 90, 30, "");
fl_set_object_boxtype(obj, FL_BORDER_BOX);
fl_set_object_color(obj, FL_WHITE, FL_COL1);
- fdui->valslider_red = obj = fl_add_valslider(FL_VERT_FILL_SLIDER, 180, 25, 30, 235, idex(_("R|#R")));
+ fdui->valslider_red = obj = fl_add_valslider(FL_VERT_FILL_SLIDER, 180, 25, 30, 200, idex(_("R|#R")));
fl_set_button_shortcut(obj, scex(_("R|#R")), 1);
fl_set_object_color(obj, FL_COL1, FL_RED);
fl_set_object_lalign(obj, FL_ALIGN_TOP);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fl_set_slider_size(obj, 0.15);
- fdui->valslider_green = obj = fl_add_valslider(FL_VERT_FILL_SLIDER, 210, 25, 30, 235, idex(_("G|#G")));
+ fdui->valslider_green = obj = fl_add_valslider(FL_VERT_FILL_SLIDER, 210, 25, 30, 200, idex(_("G|#G")));
fl_set_button_shortcut(obj, scex(_("G|#G")), 1);
fl_set_object_color(obj, FL_COL1, FL_GREEN);
fl_set_object_lalign(obj, FL_ALIGN_TOP);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fl_set_slider_size(obj, 0.15);
- fdui->valslider_blue = obj = fl_add_valslider(FL_VERT_FILL_SLIDER, 240, 25, 30, 235, idex(_("B|#B")));
+ fdui->valslider_blue = obj = fl_add_valslider(FL_VERT_FILL_SLIDER, 240, 25, 30, 200, idex(_("B|#B")));
fl_set_button_shortcut(obj, scex(_("B|#B")), 1);
fl_set_object_color(obj, FL_COL1, FL_BLUE);
fl_set_object_lalign(obj, FL_ALIGN_TOP);
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_lalign(obj, FL_ALIGN_TOP);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+ fdui->button_modify = obj = fl_add_button(FL_NORMAL_BUTTON, 350, 230, 90, 30, idex(_("Modify|#M")));
+ fl_set_button_shortcut(obj, scex(_("Modify|#M")), 1);
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fl_end_form();
fdui->form->fdui = fdui;
fl_set_button_shortcut(obj, scex(_("To|#T")), 1);
fl_set_object_boxtype(obj, FL_FRAME_BOX);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+ fdui->input_flags = obj = fl_add_input(FL_NORMAL_INPUT, 280, 150, 150, 30, idex(_("Flags|#F")));
+ fl_set_button_shortcut(obj, scex(_("Flags|#F")), 1);
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fl_end_form();
fdui->form->fdui = fdui;
fl_set_button_shortcut(obj, scex(_("Add|#A")), 1);
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
- fdui->input_extension = obj = fl_add_input(FL_NORMAL_INPUT, 280, 110, 150, 30, idex(_("Extension|#E")));
+ fdui->input_extension = obj = fl_add_input(FL_NORMAL_INPUT, 280, 150, 150, 30, idex(_("Extension|#E")));
fl_set_button_shortcut(obj, scex(_("Extension|#E")), 1);
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
- fdui->input_viewer = obj = fl_add_input(FL_NORMAL_INPUT, 280, 150, 150, 30, idex(_("Viewer|#V")));
+ fdui->input_viewer = obj = fl_add_input(FL_NORMAL_INPUT, 280, 190, 150, 30, idex(_("Viewer|#V")));
fl_set_button_shortcut(obj, scex(_("Viewer|#V")), 1);
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+ fdui->input_shrtcut = obj = fl_add_input(FL_NORMAL_INPUT, 280, 110, 150, 30, idex(_("Shortcut|#S")));
+ fl_set_button_shortcut(obj, scex(_("Shortcut|#S")), 1);
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fl_end_form();
fdui->form->fdui = fdui;
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fl_set_button(obj, 1);
- fdui->check_display_shortcuts = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 15, 105, 310, 30, _("Display keyboard shortcuts"));
+ fdui->check_display_shrtcuts = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 15, 105, 310, 30, _("Display keyboard shortcuts"));
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fl_set_button(obj, 1);
FL_OBJECT *valslider_green;
FL_OBJECT *valslider_blue;
FL_OBJECT *browser_lyx_objs;
+ FL_OBJECT *button_modify;
};
struct FD_form_converters {
~FD_form_converters();
FL_OBJECT *input_converter;
FL_OBJECT *choice_from;
FL_OBJECT *choice_to;
+ FL_OBJECT *input_flags;
};
struct FD_form_formats {
~FD_form_formats();
FL_OBJECT *button_add;
FL_OBJECT *input_extension;
FL_OBJECT *input_viewer;
+ FL_OBJECT *input_shrtcut;
};
struct FD_form_lnf_misc {
~FD_form_lnf_misc();
FL_OBJECT *check_banner;
FL_OBJECT *check_auto_region_delete;
FL_OBJECT *check_exit_confirm;
- FL_OBJECT *check_display_shortcuts;
+ FL_OBJECT *check_display_shrtcuts;
FL_OBJECT *counter_autosave;
FL_OBJECT *check_ask_new_file;
FL_OBJECT *check_cursor_follows_scrollbar;
int c)
{
if (c == 0 /* final test before handing contents to app */
- || strchr("abcdefghijklmnopqrstuvwxyz", c)) {
+ || strchr("abcdefghijklmnopqrstuvwxyz0123456789", c)) {
/* since we only accept numerals then it must be valid */
return FL_VALID;
}
temp = ChangeExtension(filename, string());
// Add some stuff to have it a unique temp file.
- xpmfile = TmpFileName(string(), temp);
+ xpmfile = lyx::tempName(string(), temp); //TmpFileName(string(), temp);
xpmfile = ChangeExtension(xpmfile, ".xpm");
command += xpmfile;
#include "ExternalTemplate.h"
#include "lyxlex.h"
+#include "debug.h"
#include "support/path.h"
#include "support/LAssert.h"
+#include "support/filetools.h"
using std::endl;
using std::ostream;
if (form->Figure->visible) {
fl_raise_form(form->Figure);
} else {
- fl_show_form(form->Figure, FL_PLACE_MOUSE | FL_PLACE_SIZE,
- FL_FULLBORDER, _("Figure"));
+ fl_show_form(form->Figure,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
+ _("Figure"));
}
}
if (bibitem_form->bibitem_form->visible) {
fl_raise_form(bibitem_form->bibitem_form);
} else {
- fl_show_form(bibitem_form->bibitem_form, FL_PLACE_MOUSE,
- FL_FULLBORDER,
+ fl_show_form(bibitem_form->bibitem_form,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
_("Bibliography item"));
}
}
fl_raise_form(bibitem_form->bibitem_form);
} else {
fl_show_form(bibitem_form->bibitem_form,
- FL_PLACE_MOUSE, FL_FULLBORDER,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
_("BibTeX"));
}
}
InsetExternal::InsetExternal()
: form_external(0)
{
- tempname = TmpFileName();
+ tempname = lyx::tempName(); //TmpFileName();
}
fl_raise_form(form_external->form_external);
} else {
fl_show_form(form_external->form_external,
- FL_PLACE_MOUSE | FL_FREE_SIZE,
- FL_FULLBORDER, _("Insert external inset"));
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
+ _("Insert external inset"));
if (ow < 0) {
ow = form_external->form_external->w;
oh = form_external->form_external->h;
if (!form) {
form = create_form_include();
- fl_set_form_atclose(form->include, IgnoreCloseBoxCB, 0);
+ fl_set_form_atclose(form->include, CancelCloseBoxCB, 0);
}
form->include->u_vdata = this;
if (form->include->visible) {
fl_raise_form(form->include);
} else {
- fl_show_form(form->include, FL_PLACE_MOUSE, FL_FULLBORDER,
+ fl_show_form(form->include,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
_("Include"));
}
}
if (form->visible) {
fl_raise_form(form);
} else {
- fl_show_form(form, FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
+ fl_show_form(form,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
_("Note"));
if (ow < 0) {
ow = form->w;
{
if (fd_form_keymap->KeyMap->visible) {
fl_raise_form(fd_form_keymap->KeyMap);
- } else fl_show_form(fd_form_keymap->KeyMap, FL_PLACE_MOUSE,
- FL_FULLBORDER, _("Key Mappings"));
+ } else fl_show_form(fd_form_keymap->KeyMap,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
+ _("Key Mappings"));
}
#include FORMS_H_LOCATION
#include "lyx.h"
#include "layout_forms.h"
-#include "form1.h"
+//#include "form1.h"
#include "lyx_main.h"
#include "lyx_cb.h"
-#include "insets/insetref.h"
+//#include "insets/insetref.h"
#include "insets/insetlabel.h"
#include "insets/figinset.h"
#include "lyxfunc.h"
#include "filedlg.h"
#include "lyx_gui_misc.h"
#include "LyXView.h"
-#include "BufferView.h"
+//#include "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 "lyxserver.h"
+//#include "support/lyxlib.h"
+//#include "lyxserver.h"
#include "lyxrc.h"
#include "lyxtext.h"
-#include "CutAndPaste.h"
-#include "exporter.h"
+//#include "CutAndPaste.h"
+//#include "exporter.h"
using std::ifstream;
using std::copy;
extern void MenuSendto();
-extern LyXServer * lyxserver;
+//extern LyXServer * lyxserver;
// this should be static, but I need it in buffer.C
bool quitting; // flag, that we are quitting the program
// tmp_ret will be located (usually) in /tmp
// will that be a problem?
- string tmp_ret = tmpnam(0);
-
pid_t pid = fork(); // If you want to debug the autosave
// you should set pid to -1, and comment out the
// fork.
// to fork. But we will do the save
// anyway.
bool failed = false;
+
+ string tmp_ret = lyx::tempName();
if (!tmp_ret.empty()) {
bv->buffer()->writeFile(tmp_ret, 1);
// assume successful write of tmp_ret
fl_raise_form(fd_form_character->form_character);
} else {
fl_show_form(fd_form_character->form_character,
- FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
_("Character Style"));
if (ow < 0) {
ow = fd_form_character->form_character->w;
} else {
fl_show_form(fd_form_preamble->form_preamble,
FL_PLACE_MOUSE | FL_FREE_SIZE,
- FL_FULLBORDER,
+ FL_TRANSIENT,
_("LaTeX Preamble"));
if (ow < 0) {
ow = fd_form_preamble->form_preamble->w;
fl_raise_form(fd_form_figure->form_figure);
} else {
fl_show_form(fd_form_figure->form_figure,
- FL_PLACE_MOUSE, FL_FULLBORDER,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
_("Insert Figure"));
}
}
}
-// Prevents LyX from being killed when the close box is pressed in a popup.
-extern "C" int IgnoreCloseBoxCB(FL_FORM *, void *)
-{
- return FL_IGNORE;
-}
-
-
// Prevents LyX from crashing when no buffers available
// This is also one of the functions that we _really_ dont want
// we should try to finds way to help us with that.
/// Prevents LyX from being killed when the close box is pressed in a popup.
extern "C" int CancelCloseBoxCB(FL_FORM *, void *);
-/// Prevents LyX from being killed when the close box is pressed in a popup.
-extern "C" int IgnoreCloseBoxCB(FL_FORM *, void *);
/// Prevents LyX from crashing when no buffers available
void CloseAllBufferRelatedDialogs();
return false;
path = OnlyPath(fname);
if (path.empty() || path == "./")
- filename = GetCWD() + "/" + fname;
+ filename = lyx::getcwd() /*GetCWD()*/ + "/" + fname;
else
filename = fname;
/* show the first form */
fl_show_form(fd_xsendfax->xsendfax,
- FL_PLACE_MOUSE, FL_FULLBORDER, title.c_str());
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
+ title.c_str());
/*
while(true) {
obj = fl_do_forms();
if (phone.empty())
return false;
- string logfile = TmpFileName(OnlyPath(fname), "FAX");
+ string logfile = lyx::tempName(OnlyPath(fname), "FAX"); //TmpFileName(OnlyPath(fname), "FAX");
string cmd = sendcmd + " >";
cmd += logfile + " 2>";
cmd += logfile;
fl_raise_form(fd_logfile->logfile);
} else {
fl_show_form(fd_logfile->logfile,
- FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
_("Message-Window"));
}
}
if (!n)
fl_addto_browser(fd_phonebook->browser, _("@L@b@cEmpty Phonebook"));
- fl_show_form(fd_phonebook->phonebook, FL_PLACE_MOUSE, FL_FULLBORDER,
+ fl_show_form(fd_phonebook->phonebook,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
_("Phonebook"));
}
fl_raise_form(search_form->form_search);
} else {
fl_show_form(search_form->form_search,
- FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
_("Find & Replace")); // RVDK_PATCH_5
if (ow < 0) {
ow = search_form->form_search->w;
#include "buffer.h"
#include "gettext.h"
#include "support/filetools.h"
+#include "support/lyxlib.h"
#include "lyxfunc.h"
#include "LyXView.h"
fl_raise_form(browser->LaTeXLog);
} else {
fl_show_form(browser->LaTeXLog,
- FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
_("VC History"));
if (ow < 0) {
ow = browser->LaTeXLog->w;
void LyXVC::showLog()
{
- string tmpf = tmpnam(0);
+ string tmpf = lyx::tempName();
vcs->getLog(tmpf);
viewLog(tmpf);
lyx::unlink(tmpf);
lyxfunc->Dispatch(LFUN_INSERT_MATH, "sqrt");
break;
case MM_DELIM:
- fl_show_form(fd_delim->delim, FL_PLACE_MOUSE, FL_FULLBORDER, _("Delimiter"));
+ fl_show_form(fd_delim->delim,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
+ _("Delimiter"));
fl_set_form_atclose(fd_delim->delim, CancelCloseBoxCB, 0);
break;
case MM_DECO:
- fl_show_form(fd_deco->deco, FL_PLACE_MOUSE, FL_FULLBORDER, _("Decoration"));
+ fl_show_form(fd_deco->deco,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
+ _("Decoration"));
fl_set_form_atclose(fd_deco->deco, CancelCloseBoxCB, 0);
break;
case MM_SPACE:
- fl_show_form(fd_space->space, FL_PLACE_MOUSE, FL_FULLBORDER, _("Spacing"));
+ fl_show_form(fd_space->space,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
+ _("Spacing"));
fl_set_form_atclose(fd_space->space, CancelCloseBoxCB, 0);
break;
case MM_MATRIX:
- fl_show_form(fd_matrix->matrix, FL_PLACE_MOUSE, FL_FULLBORDER, _("Matrix"));
+ fl_show_form(fd_matrix->matrix,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
+ _("Matrix"));
fl_set_form_atclose(fd_matrix->matrix, CancelCloseBoxCB, 0);
break;
case MM_EQU:
if (fd_panel->panel->visible) {
fl_raise_form(fd_panel->panel);
} else {
- fl_show_form(fd_panel->panel, FL_PLACE_MOUSE,
- FL_FULLBORDER, _("Math Panel"));
+ fl_show_form(fd_panel->panel,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
+ _("Math Panel"));
}
}
#define S_ISBLK(x) false
#define readlink(s, t, l) (strcpy(t, s), strlen(t))
/*#define mkfifo(p, m) (0) *//* LyXserver is temporary disabled. */
-#define getcwd _getcwd2
#define chdir _chdir2
#define strcasecmp stricmp
#if defined (__cplusplus)
fl_raise_form(fd_form_spell_options->form_spell_options);
} else {
fl_show_form(fd_form_spell_options->form_spell_options,
- FL_PLACE_MOUSE, FL_FULLBORDER,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
_("Spellchecker Options"));
}
}
fl_raise_form(fd_form_spell_check->form_spell_check);
} else {
fl_show_form(fd_form_spell_check->form_spell_check,
- FL_PLACE_MOUSE, FL_FULLBORDER,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
_("Spellchecker"));
}
fl_deactivate_object(fd_form_spell_check->slider);
syscontr.C \
syscontr.h \
syssingleton.C \
+ tempname.C \
translator.h \
textutils.h \
unlink.C
#include "lyx_gui_misc.h"
#include "FileInfo.h"
#include "support/path.h" // I know it's OS/2 specific (SMiyata)
+#include "support/syscall.h"
#include "gettext.h"
#include "lyxlib.h"
using std::pair;
using std::endl;
using std::ifstream;
+using std::vector;
#if 0
using std::getenv;
}
+#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)
lyxerr << "Not able to find a uniq tmpfile name." << endl;
return string();
}
+#endif
// Is a file readable ?
// -1: error- couldn't find out
int IsDirWriteable (string const & path)
{
- string const tmpfl(TmpFileName(path));
+ string const tmpfl(lyx::tempName(path)); //TmpFileName(path));
if (tmpfl.empty()) {
WriteFSAlert(_("LyX Internal Error!"),
}
+/// Returns a vector of all files in directory dir having extension 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] != '.') extension.insert(0u, 1u, '.');
+ vector<string> dirlist;
+ DIR * dirp = ::opendir(dir.c_str());
+ dirent * dire;
+ while ((dire = ::readdir(dirp))) {
+ string fil = dire->d_name;
+ if (prefixIs(fil, extension)) {
+ dirlist.push_back(fil);
+ }
+ }
+ ::closedir(dirp);
+ return dirlist;
+ /* A C++ implementaion will look like this:
+ if (ext[0] != '.') ext.insert(0u, 1u, '.');
+ directory_iterator dit("dir");
+ while (dit != directory_iterator()) {
+ string fil = (*dit).filename;
+ if (prefixIs(fil, ext)) {
+ dirlist.push_back(fil);
+ }
+ ++dit;
+ }
+ */
+#endif
+}
+
+
// Returns the real name of file name in directory path, with optional
// extension ext.
string const FileSearch(string const & path, string const & name,
static
string const CreateTmpDir(string const & tempdir, string const & mask)
{
- string const tmpfl(TmpFileName(tempdir, mask));
+#warning Possibly buggy (Lgb)
+ lyxerr << "CreateTmpDir: tempdir=`" << tempdir << "'" << endl;
+ lyxerr << "CreateTmpDir: mask=`" << mask << "'" << endl;
+
+ string const tmpfl(lyx::tempName(tempdir, mask));
+ // lyx::tempName actually creates a file to make sure that it
+ // stays unique. So we have to delete it before we can create
+ // a dir with the same name. Note also that we are not thread
+ // safe because of the gap between unlink and mkdir. (Lgb)
+ lyx::unlink(tmpfl.c_str());
- if ((tmpfl.empty()) || lyx::mkdir(tmpfl, 0777)) {
+ if (tmpfl.empty() || lyx::mkdir(tmpfl, 0777)) {
WriteFSAlert(_("Error! Couldn't create temporary directory:"),
tempdir);
return string();
string const CreateBufferTmpDir(string const & pathfor)
{
- return CreateTmpDir(pathfor, "lyx_bufrtmp");
+ return CreateTmpDir(pathfor, "lyx_tmpbuf");
}
#ifdef __EMX__
Path p(user_lyxdir);
#endif
- string const t(CreateTmpDir(deflt, "lyx_tmp"));
+ string const t(CreateTmpDir(deflt, "lyx_tmpdir"));
return t;
} else
return deflt;
#ifdef __EMX__
Path p(user_lyxdir);
#endif
- string const t(CreateTmpDir("/tmp", "lyx_tmp"));
+ string const t(CreateTmpDir("/tmp", "lyx_tmpdir"));
return t;
}
}
}
+#if 0
// Returns current working directory
string const GetCWD ()
{
delete[] tbuf;
return result;
}
+#endif
// Strip filename from path name
delete[] with_drive;
#endif
} else
- TempBase = GetCWD();
+ TempBase = lyx::getcwd(); //GetCWD();
#ifdef __EMX__
if (AbsolutePath(TempRel))
return TempBase.substr(0, 2) + TempRel;
RTemp = split(RTemp, Temp, '/');
if (Temp == ".") {
- return GetCWD() + '/' + RTemp;
+ return lyx::getcwd() /*GetCWD()*/ + '/' + RTemp;
} else if (Temp == "~") {
return GetEnvPath("HOME") + '/' + RTemp;
} else if (Temp == "..") {
#include <fcntl.h>
#include <cerrno>
+#include <vector>
+
#include "debug.h"
#include "LString.h"
#include "support/lstrings.h"
string const FileSearch(string const & path, string const & name,
string const & ext = string());
+/// Returns a vector of all files in directory dir having extension ext.
+std::vector<string> const DirList(string const & dir,
+ string const & ext = string());
+
/** Is directory read only?
returns
1: dir writeable
/// Put the name in quotes suitable for the current shell
string const QuoteName(string const & file);
+#if 0
/** Returns an unique name to be used as a temporary file. If given,
'mask' should the prefix to the temporary file, the rest of the
temporary filename will be made from the pid and three letters.
string const
TmpFileName(string const & dir = string(),
string const & mask = "lyx_tmp");
+#endif
/// Is a filename/path absolute?
bool AbsolutePath(string const & path);
/// Create absolute path. If impossible, don't do anything
string const ExpandPath(string const & path);
+#if 0
/// gets current working directory
string const GetCWD();
-
+#endif
/** Convert relative path into absolute path based on a basepath.
If relpath is absolute, just use that.
If basepath doesn't exist use CWD.
*/
string const MakeAbsPath(string const & RelPath = string(),
- string const & BasePath = string());
+ string const & BasePath = string());
/** Creates a nice compact path for displaying. The parameter
threshold, if given, specifies the maximal length of the path.
#include <config.h>
+#include <cerrno>
#include <unistd.h>
#include "support/lyxlib.h"
-char * lyx::getcwd(char * buffer, size_t size)
+static inline
+char * l_getcwd(char * buffer, size_t size)
{
#ifndef __EMX__
return ::getcwd(buffer, size);
return ::_getcwd2(buffer, size);
#endif
}
+
+
+// Returns current working directory
+string const lyx::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 = l_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;
+}
struct lyx {
#endif
///
- OPT_STATIC char * getcwd(char * buffer, size_t size);
+ OPT_STATIC string const getcwd();
///
OPT_STATIC int chdir(string const & name);
/// Returns false if it fails
OPT_STATIC int rmdir(string const & file);
///
OPT_STATIC int atoi(string const & nstr);
+ ///
+ OPT_STATIC string const tempName(string const & dir = string(),
+ string const & mask = string());
#ifdef CXX_WORKING_NAMESPACES
}
#else
#define PATH_H
#include "LString.h"
-#include "filetools.h"
+//#include "filetools.h"
#include "lyxlib.h"
#include <boost/utility.hpp>
: popped_(false)
{
if (!path.empty()) {
- pushedDir_ = GetCWD();
+ pushedDir_ = lyx::getcwd(); // GetCWD();
if (pushedDir_.empty() || lyx::chdir(path)) {
// should throw an exception
// throw DirChangeError();
--- /dev/null
+#include <config.h>
+
+#include "LString.h"
+
+#include <cstdlib>
+
+#include <unistd.h>
+
+#include "lyxlib.h"
+#include "debug.h"
+#include "filetools.h"
+
+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 tmpfl(AddName(tmpdir, mask));
+ tmpfl += tostr(getpid());
+
+ // the supposedly safer mkstemp version
+ char * tmpl = new char[256];
+ tmpfl += ".XXXXXX";
+ ::strcpy(tmpl, tmpfl.c_str());
+ int tmpf = ::mkstemp(tmpl);
+ if (tmpf != -1) {
+ string const t(tmpl);
+ ::close(tmpf);
+ delete [] tmpl;
+ lyxerr << "Temporary file `" << t << "' created." << endl;
+ return t;
+ } else {
+ lyxerr << "LyX Error: Unable to create temporary file."
+ << endl;
+ delete [] tmpl;
+ return string();
+ }
+#endif
+}
#include "support/LRegex.h"
#include "support/LSubstring.h"
#include "support/path.h"
+#include "support/filetools.h"
#include "buffer.h"
#include "LyXView.h"
#include "lyxfunc.h"