1999-10-13 Lars Gullik Bjønnes <larsbj@lyx.org>
+ * src/LaTeXLog.C (ShowLatexLog): reordered som statements so that
+ Path would fit in more nicely.
+
+ * all files that used to use pathstack: uses now Path instead.
+ This change was a lot easier than expected.
+
+ * src/support/path.h: new file
+
+ * src/support/Makefile.am (libsupport_a_SOURCES): added path.h
+
+ * src/Makefile.am (lyx_SOURCES): removed pathstack.[Ch]
+
* src/support/lyxstring.C (getline): Default arg was given for
para 3. removed.
src/minibuffer.C
src/minibuffer.h
src/paragraph.C
-src/pathstack.C
src/print_form.C
src/sp_form.C
src/spellchecker.C
src/support/filetools.C
src/support/lyxlib.h
+src/support/path.h
src/text.C
src/text2.C
#include "debug.h"
#include "support/syscall.h"
#include "support/syscontr.h"
-#include "pathstack.h"
+#include "support/path.h"
#include "gettext.h"
/*
#include "support/lyxlib.h"
#include "support/syscall.h"
#include "support/syscontr.h"
-#include "pathstack.h"
+#include "support/path.h"
#include "bufferlist.h"
#include "minibuffer.h"
#include "gettext.h"
// found in the same dir
// as the .lyx file and
// should be inserted.
- PathPush(path);
+ Path p(path);
if (FileInfo(foundfile).exist()) {
lyxerr << "LyX Strange: this should actually never"
" happen anymore, this it should be"
lyxerr[Debug::LATEX] << "Same Directory file: "
<< foundfile << endl;
head.insert(foundfile);
- PathPop();
continue;
}
- PathPop();
lyxerr[Debug::LATEX]
<< "Not a file or we are unable to find it."
#include "LString.h"
#include "support/FileInfo.h"
#include "support/filetools.h"
-#include "pathstack.h"
+#include "support/path.h"
#include "lyxrc.h"
#include "BufferView.h"
#include "gettext.h"
void ShowLatexLog()
{
- string filename, fname, bname, path;
- bool use_build = false;
+ string filename, fname, bname, path;
+ bool use_build = false;
- filename = current_view->currentBuffer()->getFileName();
- if (!filename.empty()) {
- fname = SpaceLess(ChangeExtension(filename, ".log", true));
- bname = SpaceLess(ChangeExtension(filename, lyxrc->literate_extension + ".out", true));
- path = OnlyPath(filename);
- if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
- path = current_view->currentBuffer()->tmppath;
+ filename = current_view->currentBuffer()->getFileName();
+ if (!filename.empty()) {
+ fname = SpaceLess(ChangeExtension(filename, ".log", true));
+ bname = SpaceLess(ChangeExtension(filename,
+ lyxrc->literate_extension + ".out", true));
+ path = OnlyPath(filename);
+ if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
+ path = current_view->currentBuffer()->tmppath;
+ }
+ FileInfo f_fi(path + fname), b_fi(path + bname);
+ if (b_fi.exist())
+ if (!f_fi.exist()
+ || f_fi.getModificationTime() < b_fi.getModificationTime())
+ use_build = true; // If no Latex log or Build log is newer, show Build log
+ Path p(path); // path to LaTeX file
+ if (!fl_load_browser(fd_latex_log->browser_latexlog,
+ use_build ? bname.c_str() : fname.c_str()))
+ fl_add_browser_line(fd_latex_log->browser_latexlog,
+ _("Unable to show log file!"));
+ } else {
+ fl_add_browser_line(fd_latex_log->browser_latexlog,
+ _("NO LATEX LOG FILE!"));
+ }
+ if (fd_latex_log->LaTeXLog->visible) {
+ fl_raise_form(fd_latex_log->LaTeXLog);
+ } else {
+ fl_show_form(fd_latex_log->LaTeXLog,
+ FL_PLACE_MOUSE | FL_FREE_SIZE,FL_FULLBORDER,
+ use_build ? _("Build Program Log") : _("LaTeX Log"));
}
- FileInfo f_fi(path + fname), b_fi(path + bname);
- if (b_fi.exist())
- if ( ! f_fi.exist()
- || f_fi.getModificationTime() < b_fi.getModificationTime())
- use_build = true; // If no Latex log or Build log is newer, show Build log
- PathPush(path); // path to LaTeX file
- }
- if (!fl_load_browser(fd_latex_log->browser_latexlog,
- (use_build)?bname.c_str():fname.c_str()))
- fl_add_browser_line(fd_latex_log->browser_latexlog, _("NO LATEX LOG FILE!"));
- if (fd_latex_log->LaTeXLog->visible) {
- fl_raise_form(fd_latex_log->LaTeXLog);
- }
- else {
- fl_show_form(fd_latex_log->LaTeXLog,
- FL_PLACE_MOUSE | FL_FREE_SIZE,FL_FULLBORDER,
- (use_build)?_("Build Program Log"):_("LaTeX Log"));
- }
- if (!filename.empty())
- PathPop();
}
void LatexLogClose(FL_OBJECT *, long)
#include "support/lyxlib.h"
#include "support/syscall.h"
#include "support/syscontr.h"
-#include "pathstack.h"
+#include "support/path.h"
#include "bufferlist.h"
#include "minibuffer.h"
#include "gettext.h"
#include "lyxrc.h"
#include "LString.h"
#include "support/filetools.h"
-#include "pathstack.h"
+#include "support/path.h"
#include "buffer.h"
#include "lyx_gui_misc.h"
#include "support/syscall.h"
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
path = buffer->tmppath;
}
- PathPush(path);
+ Path p(path);
// save the .lyx file in tmp_dir if this filetype is requested
if (fl_get_button(fd_form_sendto->radio_ftype_lyx))
buffer->writeFile(fname,true);
if (fl_get_button(fd_form_sendto->radio_ftype_ascii))
buffer->writeFileAscii(fname, lyxrc->ascii_linelen);
Systemcalls one(Systemcalls::System, command);
- PathPop();
}
void SendtoCancelCB(FL_OBJECT *, long)
os2_defines.h \
os2_errortable.h \
paragraph.C \
- pathstack.C \
- pathstack.h \
print_form.C \
print_form.h \
screen.C \
#include "insets/insetspecialchar.h"
#include "insets/figinset.h"
#include "support/filetools.h"
-#include "pathstack.h"
+#include "support/path.h"
#include "LaTeX.h"
#include "Literate.h"
#include "Chktex.h"
path = tmppath;
}
- PathPush(path); // path to LaTeX file
+ Path p(path); // path to LaTeX file
users->getOwner()->getMiniBuffer()->Set(_("Running LaTeX..."));
// Remove all error insets
users->updateScrollbar();
}
AllowInput();
- PathPop(); // path to LaTeX file
return latex.getNumErrors();
}
path = tmppath;
}
- PathPush(path); // path to Literate file
+ Path p(path); // path to Literate file
users->getOwner()->getMiniBuffer()->Set(_("Running Literate..."));
// Remove all error insets
users->updateScrollbar();
}
AllowInput();
- PathPop(); // path to LaTeX file
return literate.getNumErrors();
}
path = tmppath;
}
- PathPush(path); // path to Literate file
+ Path p(path); // path to Literate file
users->getOwner()->getMiniBuffer()->Set(_("Building Program..."));
// Remove all error insets
users->updateScrollbar();
}
AllowInput();
- PathPop(); // path to LaTeX file
return literate.getNumErrors();
}
path = tmppath;
}
- PathPush(path); // path to LaTeX file
+ Path p(path); // path to LaTeX file
users->getOwner()->getMiniBuffer()->Set(_("Running chktex..."));
// Remove all error insets
users->updateScrollbar();
}
AllowInput();
- PathPop(); // path to LaTeX file
return res;
}
#include "combox.h"
#include "bufferlist.h"
#include "support/filetools.h"
-#include "pathstack.h"
+#include "support/path.h"
#include "filedlg.h"
#include "lyx_gui_misc.h"
#include "LyXView.h" // only because of form_main
path = buffer->tmppath;
}
if (!buffer->isDviClean()) {
- PathPush(path);
+ Path p(path);
ret = MenuRunLaTeX(buffer);
- PathPop();
}
return ret;
}
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
path = buffer->tmppath;
}
- PathPush(path);
+ Path p(path);
cmd = command + ' ' + SpaceLess(name);
Systemcalls one;
result = one.startscript(wait ? Systemcalls::Wait
: Systemcalls::DontWait, cmd);
}
- PathPop();
return (result==0);
}
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
path = buffer->tmppath;
}
- PathPush(path);
+ Path p(path);
bool ret = RunScript(buffer, wait, command);
AllowInput();
- PathPop();
return ret;
}
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
path = buffer->tmppath;
}
- PathPush(path);
+ Path p(path);
bool ret = RunScript(buffer, false, lyxrc->view_ps_command, ps);
- PathPop();
AllowInput();
return ret;
}
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
path = buffer->tmppath;
}
- PathPush(path);
+ Path p(path);
if (!lyxrc->fax_program.empty()) {
string help2 = lyxrc->fax_program;
subst(help2, "$$FName",ps);
Systemcalls one(Systemcalls::System, help2);
} else
send_fax(ps,lyxrc->fax_command);
- PathPop();
}
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
path = buffer->tmppath;
}
- PathPush(path);
+ Path p(path);
// Run dvi-viewer
string command = lyxrc->view_dvi_command + paper ;
bool ret = RunScript(buffer, false, command);
- PathPop();
return ret;
}
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
path = current_view->currentBuffer()->tmppath;
}
- PathPush (path);
+ Path p(path);
if (flag != -1) {
if (!current_view->available())
break;
}
- PathPop();
AllowInput();
current_view->currentBuffer()->redraw();
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
path = current_view->currentBuffer()->tmppath;
}
- PathPush (path);
+ Path p(path);
if (!current_view->available())
return 0;
break;
}
- PathPop();
AllowInput();
current_view->currentBuffer()->redraw();
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
path = buffer->tmppath;
}
- PathPush(path);
+ Path p(path);
bool result;
if (!lyxrc->print_spool_command.empty() &&
}
} else
result = RunScript(buffer, false, command);
- PathPop();
if (!result)
WriteAlert(_("Error:"),
minibuffer->Set(_("Running configure..."));
// Run configure in user lyx directory
- PathPush(user_lyxdir);
+ Path p(user_lyxdir);
Systemcalls one(Systemcalls::System,
AddName(system_lyxdir,"configure"));
- PathPop();
+ p.pop();
minibuffer->Set(_("Reloading configuration..."));
lyxrc->Read(LibFileSearch(string(), "lyxrc.defaults"));
WriteAlert(_("The system has been reconfigured."),
#include "lyx_gui.h"
#include "lyx_gui_misc.h"
#include "lyxrc.h"
-#include "pathstack.h"
+#include "support/path.h"
#include "support/filetools.h"
#include "bufferlist.h"
#include "debug.h"
}
// Run configure in user lyx directory
- PathPush(user_lyxdir);
+ Path p(user_lyxdir);
system(AddName(system_lyxdir,"configure").c_str());
- PathPop();
lyxerr << "LyX: " << _("Done!") << endl;
}
#include "lyx_main.h"
#include "intl.h"
#include "tex-strings.h"
-#include "pathstack.h"
+#include "support/path.h"
#include "support/filetools.h"
#include "lyxtext.h"
#include "lyx_gui_misc.h"
#include "bufferlist.h"
#include "support/syscall.h"
-#include "pathstack.h"
+#include "support/path.h"
#include "support/filetools.h"
#include "support/FileInfo.h"
#include "gettext.h"
{
lyxerr[Debug::LYXVC] << "doVCCommand: " << cmd << endl;
Systemcalls one;
- PathPush(_owner->filepath);
+ Path p(_owner->filepath);
int ret = one.startscript(Systemcalls::System, cmd);
- PathPop();
return ret;
}
///
typedef FL_OBJECT* FL_OBJECTP;
+extern "C" {
+ int peek_event(FL_FORM *, void *);
+}
+
/// Class to manage bitmap menu bars
class BitmapMenu {
///
return -1;
}
+extern "C" {
int peek_event(FL_FORM * /*form*/, void *xev)
{
if (BitmapMenu::active==0)
}
return 0;
}
+}
static void math_cb(FL_OBJECT* ob, long data)
{
+++ /dev/null
-// lyx-stack.C : implementation of PathStack class
-// this file is part of LyX, the High Level Word Processor
-// copyright (C) 1995-1996, Matthias Ettrich and the LyX Team
-
-#include <config.h>
-#include <unistd.h>
-
-#ifdef __GNUG__
-#pragma implementation "pathstack.h"
-#endif
-
-#include "pathstack.h"
-#include "support/filetools.h"
-#include "debug.h"
-#include "LString.h"
-#include "gettext.h"
-
-// temporary hack
-#include "lyx_gui_misc.h"
-
-// global path stack
-PathStack lyxPathStack;
-
-// Standard constructor
-PathStack::PathStack(string const & string)
- : Path(string)
-{
- Next = 0;
-}
-
-// Destructor
-PathStack::~PathStack()
-{
- if (Next)
- delete Next;
-}
-
-// Changes to directory
-int PathStack::PathPush(string const & Path)
-{
- // checks path string validity
- if (Path.empty()) return 1;
-
- PathStack *NewNode;
-
- // gets current directory and switch to new one
- string CurrentPath = GetCWD();
- if ((CurrentPath.empty()) || chdir(Path.c_str())) {
- WriteFSAlert(_("Error: Could not change to directory: "),
- Path);
- return 2;
- }
-
- lyxerr.debug() << "PathPush: " << Path << endl;
- // adds new node
- NewNode = new PathStack(CurrentPath);
- NewNode->Next = Next;
- Next = NewNode;
- return 0;
-}
-
-// Goes back to previous directory
-int PathStack::PathPop()
-{
- // checks stack validity and extracts old node
- PathStack *OldNode = Next;
- if (!OldNode) {
- WriteAlert (_("LyX Internal Error:"), _("Path Stack underflow."));
- return 1;
- }
- Next = OldNode->Next;
- OldNode->Next = 0;
-
- // switches to old directory
- int Result = 0;
- if (chdir(OldNode->Path.c_str())) {
- WriteFSAlert(_("Error: Could not change to directory: "),
- Path);
- Result = 2;
- }
- lyxerr.debug() << "PathPop: " << OldNode->Path << endl;
- delete OldNode;
-
- return Result;
-}
-
+++ /dev/null
-// -*- C++ -*-
-// lyx-stack.H : definition of PathStack class
-// this file is part of LyX, the High Level Word Processor
-// copyright (C) 1995-1996, Matthias Ettrich and the LyX Team
-
-#ifndef __LYX_STACK_H__
-#define __LYX_STACK_H__
-
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include "LString.h"
-
-/// Path stack class definition
-class PathStack {
-public:
- ///
- PathStack() {
- Next = 0;
- }
- ///
- PathStack(string const & Path);
- ///
- ~PathStack();
- ///
- int PathPush(string const & Path);
- ///
- int PathPop();
-private:
- ///
- string Path;
- ///
- PathStack *Next;
-};
-
-// global path stack
-extern PathStack lyxPathStack;
-
-/// some global wrapper functions
-inline int PathPush(string const & szPath) {
- return lyxPathStack.PathPush(szPath);
-}
-
-///
-inline int PathPop() {
- return lyxPathStack.PathPop();
-}
-
-#endif
lyxstring.C \
lyxstring.h \
lyxsum.C \
+ path.h \
syscall.C \
syscall.h \
syscontr.C \
#include "filetools.h"
#include "lyx_gui_misc.h"
#include "FileInfo.h"
-#include "pathstack.h" // I know it's OS/2 specific (SMiyata)
+#include "support/path.h" // I know it's OS/2 specific (SMiyata)
#include "gettext.h"
#include "LAssert.h"
--- /dev/null
+// -*- C++ -*-
+#ifndef PATH_H
+#define PATH_H
+
+#include <unistd.h>
+#include "LString.h"
+#include "gettext.h"
+#include "support/filetools.h"
+#include "lyx_gui_misc.h"
+
+class Path {
+public:
+ ///
+ Path(string const & path)
+ : popped_(false)
+ {
+ if (!path.empty()) {
+ pushedDir_ = GetCWD();
+ if (pushedDir_.empty() || chdir(path.c_str())) {
+ WriteFSAlert(_("Error: Could not change to directory: "),
+ path);
+ }
+ } else {
+ popped_ = true;
+ }
+ }
+ ///
+ ~Path()
+ {
+ if (!popped_) pop();
+ }
+ ///
+ int pop()
+ {
+ if (popped_) {
+ WriteFSAlert(_("Error: Dir already popped: "),
+ pushedDir_);
+ return 0;
+ }
+ if (chdir(pushedDir_.c_str())) {
+ WriteFSAlert(
+ _("Error: Could not change to directory: "),
+ pushedDir_);
+ }
+ popped_ = true;
+ return 0;
+ }
+private:
+ ///
+ bool popped_;
+ ///
+ string pushedDir_;
+};
+
+#endif