/* This file is part of
-* ======================================================
-*
-* LyX, The Document Processor
-*
-* Copyright (C) 1995 Matthias Ettrich,
-* Copyright (C) 1995-1998 The LyX Team.
-*
-*======================================================*/
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 1995 Matthias Ettrich,
+ * Copyright 1995-1999 The LyX Team.
+ *
+ * ======================================================*/
#include <config.h>
-#include <ctype.h>
+#include <cctype>
#include <unistd.h>
-#include <signal.h>
-#include <string.h>
-#include <stdlib.h>
+#include <csignal>
+#include <cstring>
+#include <cstdlib>
#include "LString.h"
+#include "support/lstrings.h"
#include "lyx_main.h"
#include FORMS_H_LOCATION
#include "lyx.h"
#include "minibuffer.h"
#include "combox.h"
#include "bufferlist.h"
-#include "filetools.h"
-#include "pathstack.h"
+#include "support/filetools.h"
+#include "support/path.h"
#include "filedlg.h"
#include "lyx_gui_misc.h"
#include "LyXView.h" // only because of form_main
#include "lastfiles.h"
-#include "FileInfo.h"
+#include "support/FileInfo.h"
#include "lyxscreen.h"
-#include "error.h"
-#include "syscall.h"
-#include "lyxlib.h"
+#include "debug.h"
+#include "support/syscall.h"
+#include "support/lyxlib.h"
#include "lyxserver.h"
#include "FontLoader.h"
#include "lyxrc.h"
#include "lyxtext.h"
#include "gettext.h"
-// $Id: lyx_cb.C,v 1.1 1999/09/27 18:44:37 larsbj Exp $
-
-#if !defined(lint) && !defined(WITH_WARNINGS)
-static char vcid[] = "$Id: lyx_cb.C,v 1.1 1999/09/27 18:44:37 larsbj Exp $";
-#endif /* lint */
-
extern MiniBuffer *minibuffer;
extern Combox *combo_language;
extern BufferList bufferlist;
extern void DeleteSimpleCutBuffer(); /* for the cleanup when exiting */
-extern bool send_fax(LString const &fname, LString const &sendcmd);
+extern bool send_fax(string const &fname, string const &sendcmd);
extern LyXServer *lyxserver;
extern FontLoader fontloader;
void UpdateInsetUpdateList();
void PutInsetIntoInsetUpdateList(Inset* inset);
-InsetUpdateStruct *InsetUpdateList = NULL;
+InsetUpdateStruct *InsetUpdateList = 0;
/*
void Newline();
void ProtectedBlank();
void CopyCB();
-int RunLinuxDoc(int, LString const &);
-int RunDocBook(int, LString const &);
+int RunLinuxDoc(int, string const &);
+int RunDocBook(int, string const &);
void MenuWrite(Buffer* buf);
void MenuWriteAs(Buffer *buffer);
void MenuReload(Buffer *buf);
{
XFlush(fl_display);
if (!bufferlist.write(buf)) {
- LString fname = buf->getFileName();
- LString s = MakeAbsPath(fname);
+ string fname = buf->getFileName();
+ string s = MakeAbsPath(fname);
if (AskQuestion(_("Save failed. Rename and try again?"),
MakeDisplayPath(s,50),
_("(If not, document is not saved.)"))) {
{
if (!buffer->text) return;
- LString fname = buffer->getFileName();
- LString oldname = fname;
+ string fname = buffer->getFileName();
+ string oldname = fname;
LyXFileDlg fileDlg;
ProhibitInput();
}
// Make sure the absolute filename ends with appropriate suffix
- LString s= MakeAbsPath(fname);
+ string s= MakeAbsPath(fname);
if (!IsLyXFilename(s))
s += ".lyx";
ret = buffer->runLaTeX();
if (ret > 0) {
- LString s;
- LString t;
+ string s;
+ string t;
if (ret == 1) {
s = _("One error detected");
t = _("You should try to fix it.");
if (buffer->isLiterate())
ret = buffer->buildProgram();
else {
- LString s;
- LString t;
+ string s;
+ string t;
s = _("Wrong type of document");
t = _("The Build operation is not allowed in this document");
WriteAlert(_("There were errors during the Build process."), s, t);
}
if (ret > 0) {
- LString s;
- LString t;
+ string s;
+ string t;
if (ret == 1) {
s = _("One error detected");
t = _("You should try to fix it.");
ret = buffer->runChktex();
if (ret >= 0) {
- LString s;
- LString t;
+ string s;
+ string t;
if (ret == 0) {
s = _("No warnings found.");
} else if (ret == 1) {
int ret = 0;
- LString path = OnlyPath(buffer->getFileName());
+ string path = OnlyPath(buffer->getFileName());
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
path = buffer->tmppath;
}
if (!buffer->isDviClean()) {
- PathPush(path);
+ Path p(path);
ret = MenuRunLaTeX(buffer);
- PathPop();
}
return ret;
}
// The bool should be placed last on the argument line. (Lgb)
// Returns false if we fail.
bool RunScript(Buffer *buffer, bool wait,
- LString const & command, LString const & orgname = LString(),
+ string const & command, string const & orgname = string(),
bool need_shell=true)
{
- LString path;
- LString cmd;
- LString name= orgname;
+ string path;
+ string cmd;
+ string name= orgname;
int result = 0;
if (MakeDVIOutput(buffer) > 0)
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
path = buffer->tmppath;
}
- PathPush(path);
+ Path p(path);
cmd = command + ' ' + SpaceLess(name);
Systemcalls one;
// OS/2 cmd.exe has another use for '&'
if (!wait) {
// This is not NLS safe, but it's OK, I think.
- LString sh = OnlyFilename(getEnvPath("EMXSHELL"));
+ string sh = OnlyFilename(GetEnvPath("EMXSHELL"));
if (sh.empty()) {
// COMSPEC is set, unless user unsets
- sh = OnlyFilename(getEnvPath("COMSPEC"));
+ sh = OnlyFilename(GetEnvPath("COMSPEC"));
if (sh.empty())
sh = "cmd.exe";
}
- sh.lowercase();
+ sh = lowercase(sh);
if (sh.contains("cmd.exe") || sh.contains("4os2.exe"))
cmd = "start /min/n " + cmd;
else
#warning What should we do here?
#endif
minibuffer->Set(_("Executing command:"), cmd);
- result = one.Startscript(Systemcalls::System, cmd);
+ result = one.startscript(Systemcalls::System, cmd);
} else {
minibuffer->Set(_("Executing command:"), cmd);
- result = one.Startscript(wait ? Systemcalls::Wait
+ result = one.startscript(wait ? Systemcalls::Wait
: Systemcalls::DontWait, cmd);
}
- PathPop();
return (result==0);
}
return false;
}
// Generate postscript file
- LString ps = ChangeExtension (buffer->getFileName(),
+ string ps = ChangeExtension (buffer->getFileName(),
".ps_tmp", true);
- LString paper;
+ string paper;
char real_papersize = buffer->params.papersize;
if (real_papersize == PAPER_DEFAULT)
}
// Make postscript file.
- LString command = "dvips " + lyxrc->print_to_file + ' ';
+ string command = "dvips " + lyxrc->print_to_file + ' ';
command += SpaceLess(ps);
if (buffer->params.use_geometry
&& buffer->params.papersize2 == VM_PAPER_CUSTOM
command += lyxrc->print_landscape_flag;
}
// push directorypath, if necessary
- LString path = OnlyPath(buffer->getFileName());
+ string path = OnlyPath(buffer->getFileName());
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;
}
// Start postscript viewer
ProhibitInput();
- LString ps = ChangeExtension (buffer->getFileName(),
+ string ps = ChangeExtension (buffer->getFileName(),
".ps_tmp", true);
// push directorypath, if necessary
- LString path = OnlyPath(buffer->getFileName());
+ string path = OnlyPath(buffer->getFileName());
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;
}
}
// Send fax
- LString ps = ChangeExtension (buffer->getFileName(), ".ps_tmp", true);
- LString path = OnlyPath (buffer->getFileName());
+ string ps = ChangeExtension (buffer->getFileName(), ".ps_tmp", true);
+ string path = OnlyPath (buffer->getFileName());
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
path = buffer->tmppath;
}
- PathPush(path);
+ Path p(path);
if (!lyxrc->fax_program.empty()) {
- LString help2 = lyxrc->fax_program;
- help2.subst("$$FName",ps);
+ string help2 = lyxrc->fax_program;
+ subst(help2, "$$FName",ps);
help2 += " &";
Systemcalls one(Systemcalls::System, help2);
} else
send_fax(ps,lyxrc->fax_command);
- PathPop();
}
if (!buffer->text)
return false;
- LString paper;
+ string paper;
char real_papersize = buffer->params.papersize;
if (real_papersize == PAPER_DEFAULT)
}
// push directorypath, if necessary
- LString path = OnlyPath(buffer->getFileName());
+ string path = OnlyPath(buffer->getFileName());
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
path = buffer->tmppath;
}
- PathPush(path);
+ Path p(path);
// Run dvi-viewer
- LString command = lyxrc->view_dvi_command + paper ;
+ string command = lyxrc->view_dvi_command + paper ;
bool ret = RunScript(buffer, false, command);
- PathPop();
return ret;
}
{
if (buffer->text) {
// Get LaTeX-Filename
- LString s = SpaceLess(ChangeExtension(
+ string s = SpaceLess(ChangeExtension(
buffer->getFileName(),
".tex", false));
if (buffer->isLinuxDoc())
RunLinuxDoc(0, buffer->getFileName());
else
- buffer->makeLaTeXFile(s, LString(), true);
+ buffer->makeLaTeXFile(s, string(), true);
minibuffer->Set(_("Nice LaTeX file saved as"),
MakeDisplayPath(s));
buffer->markDviDirty();
}
// Get LinuxDoc-Filename
- LString s = ChangeExtension (buffer->getFileName(),
+ string s = ChangeExtension (buffer->getFileName(),
".sgml", false);
FilePtr myfile(s, FilePtr::read);
}
// Get DocBook-Filename
- LString s = ChangeExtension (buffer->getFileName(),
+ string s = ChangeExtension (buffer->getFileName(),
".sgml", false);
FilePtr myfile(s, FilePtr::read);
{
if (buffer->text) {
/* get LaTeX-Filename */
- LString s = ChangeExtension (buffer->getFileName(),
+ string s = ChangeExtension (buffer->getFileName(),
".txt", false);
FilePtr myfile(s, FilePtr::read);
void MenuPrint(Buffer *buffer)
{
- LString input_file;
+ string input_file;
if (!buffer->text)
return;
void QuitLyX()
{
- lyxerr.debug("Running QuitLyX.");
+ lyxerr.debug() << "Running QuitLyX." << endl;
if (!bufferlist.QwriteAll())
return;
bufferlist.closeAll();
// do any other cleanup procedures now
- lyxerr.debug("Deleting tmp dir " + system_tempdir);
+ lyxerr.debug() << "Deleting tmp dir " << system_tempdir << endl;
DestroyLyXTmpDir(system_tempdir);
minibuffer->Set(_("Autosaving current document..."));
// create autosave filename
- LString fname = OnlyPath(current_view->currentBuffer()->getFileName());
+ string fname = OnlyPath(current_view->currentBuffer()->getFileName());
fname += "#";
fname += OnlyFilename(current_view->currentBuffer()->getFileName());
fname += "#";
// tmp_ret will be located (usually) in /tmp
// will that be a problem?
- LString tmp_ret = tmpnam(NULL);
+ 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
// create new file with template
// SERVERCMD !
//
-Buffer * NewLyxFile(LString const & filename)
+Buffer * NewLyxFile(string const & filename)
{
// Split argument by :
- LString tmpname = filename;
- LString name;
- tmpname.split(name, ':');
+ string name;
+ string tmpname=split(filename, name, ':');
#ifdef __EMX__ // Fix me! lyx_cb.C may not be low level enough to allow this.
if (name.length() == 1 && isalpha((unsigned char) name[0]) &&
(tmpname.prefixIs("/") || tmpname.prefixIs("\\"))) {
name += ':';
name += tmpname.token(':');
- tmpname.split(':');
+ tmpname = split(tmpname, ':');
}
#endif
- lyxerr.debug("Arg is " + filename);
- lyxerr.debug("Name is " + name);
- lyxerr.debug("Template is " + tmpname);
+ lyxerr.debug() << "Arg is " << filename
+ << "\nName is " << name
+ << "\nTemplate is " << tmpname << endl;
// find a free buffer
Buffer *tmpbuf = bufferlist.newFile(name,tmpname);
// Insert ascii file (if filename is empty, prompt for one)
-void InsertAsciiFile(LString const & f, bool asParagraph)
+void InsertAsciiFile(string const & f, bool asParagraph)
{
- LString fname = f;
+ string fname = f;
LyXParagraph *tmppar;
LyXFileDlg fileDlg;
void MenuShowTableOfContents()
{
- TocUpdateCB(NULL, 0);
+ TocUpdateCB(0, 0);
if (fd_form_toc->form_toc->visible) {
fl_raise_form(fd_form_toc->form_toc);
} else {
void MenuInsertLabel(const char *arg)
{
- LString label = arg;
+ string label = arg;
ProhibitInput();
- //LString label = fl_show_input(_("Enter new label to insert:"),"");
+ //string label = fl_show_input(_("Enter new label to insert:"),"");
if (label.empty())
- label = askForText(_("Enter new label to insert:"));
- label.strip();
- label.frontStrip();
+ label = frontStrip(strip(askForText(_("Enter new label to insert:"))));
if (!label.empty()) {
InsetLabel *new_inset = new InsetLabel;
new_inset->setContents(label);
void MenuInsertRef()
{
- RefUpdateCB(NULL, 0);
+ RefUpdateCB(0, 0);
if (fd_form_ref->form_ref->visible) {
fl_raise_form(fd_form_ref->form_ref);
} else {
void LayoutsCB(int sel, void *)
{
- LString tmp;
- tmp += sel;
+ string tmp = tostr(sel);
current_view->getOwner()->getLyXFunc()->Dispatch(LFUN_LAYOUTNO,
tmp.c_str());
}
* (flag == 0) make TeX output
* (flag == 1) make dvi output
*/
-int RunLinuxDoc(int flag, LString const & filename)
+int RunLinuxDoc(int flag, string const & filename)
{
- LString name;
- LString s2;
- LString path;
- LString add_flags;
+ string name;
+ string s2;
+ string path;
+ string add_flags;
int errorcode = 0;
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
path = current_view->currentBuffer()->tmppath;
}
- PathPush (path);
+ Path p(path);
if (flag != -1) {
if (!current_view->available())
MakeDisplayPath(filename), "'...");
s2 = "sgml2lyx " + lyxrc->sgml_extra_options + ' '
+ name;
- if (one.Startscript(Systemcalls::System, s2))
+ if (one.startscript(Systemcalls::System, s2))
errorcode = 1;
break;
case 0: /* TeX output asked */
minibuffer->Set(_("Converting LinuxDoc SGML to TeX file..."));
s2 = "sgml2latex " + add_flags + " -o tex "
+ lyxrc->sgml_extra_options + ' ' + name;
- if (one.Startscript(Systemcalls::System, s2))
+ if (one.startscript(Systemcalls::System, s2))
errorcode = 1;
break;
case 1: /* dvi output asked */
minibuffer->Set(_("Converting LinuxDoc SGML to dvi file..."));
s2 = "sgml2latex " + add_flags + " -o dvi "
+ lyxrc->sgml_extra_options + ' ' + name;
- if (one.Startscript(Systemcalls::System, s2)) {
+ if (one.startscript(Systemcalls::System, s2)) {
errorcode = 1;
} else
current_view->currentBuffer()->markDviClean();
break;
}
- PathPop();
AllowInput();
current_view->currentBuffer()->redraw();
* SGML DocBook support:
* (flag == 1) make dvi output
*/
-int RunDocBook(int flag, LString const & filename)
+int RunDocBook(int flag, string const & filename)
{
- LString name;
- LString s2;
- LString path;
+ string name;
+ string s2;
+ string path;
int errorcode = 0;
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
path = current_view->currentBuffer()->tmppath;
}
- PathPush (path);
+ Path p(path);
if (!current_view->available())
return 0;
current_view->currentBuffer()->makeDocBookFile(name,0);
#if 0
- LString add_flags;
+ string add_flags;
LYX_PAPER_SIZE ps = (LYX_PAPER_SIZE) current_view->currentBuffer()->params.papersize;
switch (ps) {
case PAPER_A4PAPER: add_flags = "-p a4"; break;
case 1: /* dvi output asked */
minibuffer->Set(_("Converting DocBook SGML to dvi file..."));
s2 = "sgmltools --backend dvi " + name;
- if (one.Startscript(Systemcalls::System, s2)) {
+ if (one.startscript(Systemcalls::System, s2)) {
errorcode = 1;
} else
current_view->currentBuffer()->markDviClean();
break;
}
- PathPop();
AllowInput();
current_view->currentBuffer()->redraw();
return false;
}
- if (params == NULL)
+ if (params == 0)
params = ¤t_view->currentBuffer()->params;
LyXTextClass *tclass = lyxstyle.TextClass(params->textclass);
fl_addto_choice(fd_form_document->choice_fontsize,
tclass->opt_fontsize.c_str());
fl_set_choice(fd_form_document->choice_fontsize,
- tclass->opt_fontsize.tokenPos('|', params->fontsize) + 2);
+ tokenPos(tclass->opt_fontsize, '|', params->fontsize) + 2);
// ale970405+lasgoutt970513
fl_clear_choice(fd_form_document->choice_pagestyle);
tclass->opt_pagestyle.c_str());
fl_set_choice(fd_form_document->choice_pagestyle,
- tclass->opt_pagestyle.tokenPos('|', params->pagestyle) + 2);
+ tokenPos(tclass->opt_pagestyle, '|', params->pagestyle) + 2);
fl_set_button(fd_form_document->radio_indent, 0);
fl_set_button(fd_form_document->radio_skip, 0);
void ToggleAndShow(LyXFont const &);
-void FontSizeCB(LString const & size)
+void FontSizeCB(string const & size)
{
LyXFont font(LyXFont::ALL_IGNORE);
font.setGUISize(size);
* future perhaps we could try to implement a callback to the button-bar.
* That is, `light' the bold button when the font is currently bold, etc.
*/
-LString CurrentState()
+string CurrentState()
{
- LString state;
+ string state;
if (current_view->available()) {
// I think we should only show changes from the default
// font. (Asger)
int depth = buffer->text->GetDepth();
if (depth>0)
- state += LString(_(", Depth: ")) + depth;
+ state += string(_(", Depth: ")) + tostr(depth);
}
return state;
}
void TimerCB(FL_OBJECT *, long)
{
// only if the form still exists
- if (fd_form_title->form_title != NULL) {
+ if (fd_form_title->form_title != 0) {
if (fd_form_title->form_title->visible) {
fl_hide_form(fd_form_title->form_title);
}
fl_free_form(fd_form_title->form_title);
- fd_form_title->form_title = NULL;
+ fd_form_title->form_title = 0;
}
}
ActivateParagraphButtons();
}
} else if (obj == fp->input_space_above) {
- LString input = fl_get_input (fp->input_space_above);
+ string input = fl_get_input (fp->input_space_above);
if (input.empty()) {
fl_set_choice (fp->choice_space_above, 1);
DeactivateParagraphButtons();
}
} else if (obj == fp->input_space_below) {
- LString input = fl_get_input (fp->input_space_below);
+ string input = fl_get_input (fp->input_space_below);
if (input.empty()) {
fl_set_choice (fp->choice_space_below, 1);
bool pagebreak_top, pagebreak_bottom;
VSpace space_top, space_bottom;
char align;
- LString labelwidthstring;
+ string labelwidthstring;
bool noindent;
// If a vspace kind is "Length" but there's no text in
paragraph);
if (ret){
- LString s;
+ string s;
if (ret==1)
s= _("One paragraph couldn't be converted");
else {
Spacing tmpSpacing = params->spacing;
switch(fl_get_choice(fd_form_document->choice_spacing)) {
case 1:
- lyxerr.debug("Spacing: SINGLE");
+ lyxerr.debug() << "Spacing: SINGLE" << endl;
params->spacing.set(Spacing::Single);
break;
case 2:
- lyxerr.debug("Spacing: ONEHALF");
+ lyxerr.debug() << "Spacing: ONEHALF" << endl;
params->spacing.set(Spacing::Onehalf);
break;
case 3:
- lyxerr.debug("Spacing: DOUBLE");
+ lyxerr.debug() << "Spacing: DOUBLE" << endl;
params->spacing.set(Spacing::Double);
break;
case 4:
- lyxerr.debug("Spacing: OTHER");
+ lyxerr.debug() << "Spacing: OTHER" << endl;
params->spacing.set(Spacing::Other,
fl_get_input(fd_form_document->input_spacing));
break;
params.spacing.getValue(),
LyXLength::CM),
LYX_ALIGN_CENTER,
- LString(),
+ string(),
0);
}
else
VSpace(VSpace::NONE),
VSpace(VSpace::NONE),
LYX_ALIGN_CENTER,
- LString(),
+ string(),
0);
current_view->currentBuffer()->text->cursor.par->table = new LyXTable(xsize, ysize);
fl_hide_form(fd_form_print->form_print);
}
-static bool LStringOnlyContains (LString const & LStr, const char * cset)
+static bool stringOnlyContains (string const & LStr, const char * cset)
{
const char * cstr = LStr.c_str() ;
if (!current_view->available())
return;
Buffer *buffer = current_view->currentBuffer();
- LString path = OnlyPath(buffer->getFileName());
+ string path = OnlyPath(buffer->getFileName());
- LString pageflag;
+ string pageflag;
if (fl_get_button(fd_form_print->radio_even_pages))
pageflag = lyxrc->print_evenpage_flag + ' ';
else if (fl_get_button(fd_form_print->radio_odd_pages))
// Changes by Stephan Witt (stephan.witt@beusen.de), 19-Jan-99
// User may give a page (range) list
// User may print multiple (unsorted) copies
- LString pages = fl_get_input(fd_form_print->input_pages);
- pages.subst(';',',');
- pages.subst('+',',');
- pages.strip () ;
- pages.frontStrip () ;
+ string pages = fl_get_input(fd_form_print->input_pages);
+ subst(pages, ';',',');
+ subst(pages, '+',',');
+ pages = strip (pages) ;
+ pages = frontStrip (pages) ;
while (!pages.empty()) { // a page range was given
- LString piece ;
- //int dashpos ; // unused
- pages = pages.split (piece, ',') ;
- piece.strip () ;
- piece.frontStrip () ;
- if ( !LStringOnlyContains (piece, "0123456789-") ) {
+ string piece ;
+ pages = split (pages, piece, ',') ;
+ piece = strip(piece) ;
+ piece = frontStrip(piece) ;
+ if ( !stringOnlyContains (piece, "0123456789-") ) {
WriteAlert(_("ERROR! Unable to print!"),
_("Check 'range of pages'!"));
return;
}
- if ( -1 == piece.charPos ('-') ) { // not found
+ if (piece.find('-') == string::npos) { // not found
pageflag += lyxrc->print_pagerange_flag + piece + '-' + piece + ' ' ;
- } else if ( piece.suffixIs("-") ) { // missing last page
- pageflag += lyxrc->print_pagerange_flag + piece + 1000 + ' ' ;
- } else if ( piece.prefixIs("-") ) { // missing first page
- pageflag += lyxrc->print_pagerange_flag + 1 + piece + ' ' ;
+ } else if (suffixIs(piece, "-") ) { // missing last page
+ pageflag += lyxrc->print_pagerange_flag + piece + "1000 ";
+ } else if (prefixIs(piece, "-") ) { // missing first page
+ pageflag += lyxrc->print_pagerange_flag + '1' + piece + ' ' ;
} else {
pageflag += lyxrc->print_pagerange_flag + piece + ' ' ;
}
}
- LString copies = fl_get_input(fd_form_print->input_copies);
- copies.strip () ;
- copies.frontStrip () ;
+ string copies = frontStrip(strip(fl_get_input(fd_form_print->input_copies)));
if (!copies.empty()) { // a number of copies was given
- if ( !LStringOnlyContains (copies, "0123456789") ) {
+ if ( !stringOnlyContains (copies, "0123456789") ) {
WriteAlert(_("ERROR! Unable to print!"),
_("Check 'number of copies'!"));
return;
pageflag += " " + copies + ' ' ;
}
- LString reverseflag;
+ string reverseflag;
if (fl_get_button(fd_form_print->radio_order_reverse))
reverseflag = lyxrc->print_reverse_flag + ' ';
- LString orientationflag;
+ string orientationflag;
if (buffer->params.orientation == ORIENTATION_LANDSCAPE)
orientationflag = lyxrc->print_landscape_flag + ' ';
- LString ps_file = SpaceLess(fl_get_input(fd_form_print->input_file));
- LString printer = fl_get_input(fd_form_print->input_printer);
- printer.strip();
+ string ps_file = SpaceLess(fl_get_input(fd_form_print->input_file));
+ string printer = strip(fl_get_input(fd_form_print->input_printer));
- LString printerflag;
+ string printerflag;
if (lyxrc->print_adapt_output // printer name should be passed to dvips
&& ! printer.empty()) // a printer name has been given
printerflag = lyxrc->print_to_printer + printer + ' ';
- LString extraflags;
+ string extraflags;
if (!lyxrc->print_extra_options.empty())
extraflags = lyxrc->print_extra_options + ' ';
- LString command = lyxrc->print_command + ' '
+ string command = lyxrc->print_command + ' '
+ printerflag + pageflag + reverseflag
+ orientationflag + extraflags;
char real_papersize = buffer->params.papersize;
if (real_papersize == PAPER_DEFAULT)
real_papersize = lyxrc->default_papersize;
- LString
+ string
paper;
switch (real_papersize) {
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
path = buffer->tmppath;
}
- PathPush(path);
+ Path p(path);
bool result;
if (!lyxrc->print_spool_command.empty() &&
!fl_get_button(fd_form_print->radio_file)) {
- LString command2 = lyxrc->print_spool_command + ' ';
+ string command2 = lyxrc->print_spool_command + ' ';
if (!printer.empty())
command2 += lyxrc->print_spool_printerprefix
+ printer;
}
} else
result = RunScript(buffer, false, command);
- PathPop();
if (!result)
WriteAlert(_("Error:"),
VSpace (0.3 *
buffer->params.spacing.getValue(),
LyXLength::CM),
- LYX_ALIGN_CENTER, LString(), 0);
+ LYX_ALIGN_CENTER, string(), 0);
} else
buffer->text->SetParagraph(0, 0,
0, 0,
VSpace(VSpace::NONE),
VSpace(VSpace::NONE),
LYX_ALIGN_CENTER,
- LString(),
+ string(),
0);
buffer->update(-1);
- Inset *new_inset = NULL;
+ Inset *new_inset = 0;
new_inset = new InsetFig(100, 100, buffer);
buffer->insertInset(new_inset);
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(LString(), "lyxrc.defaults"));
+ lyxrc->Read(LibFileSearch(string(), "lyxrc.defaults"));
WriteAlert(_("The system has been reconfigured."),
_("You need to restart LyX to make use of any"),
_("updated document class specifications."));
{
if (!current_view->available()){
value = 1;
- return NULL;
+ return 0;
}
char* string = current_view->currentBuffer()->text->SelectNextWord(value);
}
-void ReplaceWord(LString const & replacestring)
+void ReplaceWord(string const & replacestring)
{
if (!current_view->getScreen())
return;
current_view->currentBuffer()->text->SetSelectionOverString(replacestring.c_str());
// Go back so that replacement string is also spellchecked
- for (int i=-1; i< replacestring.length(); i++) {
+ for (string::size_type i = 0; i < replacestring.length() + 1; ++i) {
current_view->currentBuffer()->text->CursorLeftIntern();
}
current_view->currentBuffer()->update(1);
};
-static TocList* toclist = NULL;
+static TocList* toclist = 0;
void TocSelectCB(FL_OBJECT *ob, long)
void TocUpdateCB(FL_OBJECT *, long)
{
- static LyXParagraph* stapar = NULL;
- TocList *tmptoclist = NULL;
+ static LyXParagraph* stapar = 0;
+ TocList *tmptoclist = 0;
/* deleted the toclist */
if (toclist){
toclist = tmptoclist;
}
}
- toclist = NULL;
+ toclist = 0;
tmptoclist = toclist;
LyXParagraph *par = current_view->currentBuffer()->paragraph;
char labeltype;
char* line = new char[200];
- int i = 0;
+ //int i = 0;
int pos = 0;
unsigned char c;
int topline = 0;
pos++)
line[pos] = ' ';
- /* then the labelstring */
- i = 0;
+ // Then the labestring
+ //i = 0;
if (!par->labelstring.empty()) {
+ string::size_type i = 0;
while (pos < 199 && i < par->labelstring.length()) {
line[pos] = par->labelstring[i];
i++;
pos++;
/* now the contents */
- i = 0;
+ int i = 0;
while (pos < 199 && i < par->last) {
c = par->GetChar(i);
if (isprint((unsigned char) c) || c >= 128) {
tmptoclist = tmptoclist->next;
}
- tmptoclist->next = NULL;
+ tmptoclist->next = 0;
int a = 0;
for (a=0; a<6; a++){
tmptoclist->counter[a] = par->GetFirstCounter(a);
if (!current_view->available())
return;
- LString s =
+ string s =
fl_get_browser_line(fd_form_ref->browser_ref,
fl_get_browser(fd_form_ref->browser_ref));
- LString u = fl_get_input(fd_form_ref->ref_name);
- u.strip();
- u.frontStrip();
+ string u = frontStrip(strip(fl_get_input(fd_form_ref->ref_name)));
+
if (s.empty())
return;
return;
}
- LString t;
+ string t;
if (data==0)
t += "\\ref";
else
FL_OBJECT * brow = fd_form_ref->browser_ref;
// Get the current line, in order to restore it later
- LString currentstr = fl_get_browser_line(brow,
- fl_get_browser(brow));
+ char const * const btmp=fl_get_browser_line(brow,
+ fl_get_browser(brow));
+ string currentstr=btmp ? btmp : "";
+ //string currentstr = fl_get_browser_line(brow,
+ // fl_get_browser(brow));
fl_clear_browser(brow);
- LString refs = current_view->currentBuffer()->getReferenceList('\n');
+ string refs = current_view->currentBuffer()->getReferenceList('\n');
int topline = 1;
#if FL_REVISION > 85
fl_set_browser_topline(brow, topline);
#else
// Keep the old ugly code for xforms 0.81 compatibility
- LString curr_ref;
+ string curr_ref;
int ref_num = 0;
while(true) {
if (inset &&
current_view->currentBuffer()->the_locking_inset == inset){
inset->InsetUnlock();
- current_view->currentBuffer()->the_locking_inset = NULL;
+ current_view->currentBuffer()->the_locking_inset = 0;
current_view->currentBuffer()->text->FinishUndo();
return 0;
}
InsetUpdateList = InsetUpdateList->next;
delete tmp;
}
- InsetUpdateList = NULL;
+ InsetUpdateList = 0;
}
#warning UGLY!!
// I know we shouldn't put anything in here but this seems the fastest
// way to do this (and the cleanest for now). This function just inserts
-// a newline in the LString and the inserts 'depth'-spaces so that the
+// a newline in the string and the inserts 'depth'-spaces so that the
// code is indented in the right way!!!
-void addNewlineAndDepth(LString &file, int const depth)
+void addNewlineAndDepth(string &file, int const depth)
{
file += '\n';
for (int j=0;j< depth;j++)