/* 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 <stdlib.h>
-#include <ctype.h>
-#include <string.h>
+#include <cstdlib>
+#include <cctype>
+#include <cstring>
#ifdef __GNUG__
#pragma implementation
#include "insets/insetinclude.h"
#include "filedlg.h"
#include "lyx_gui_misc.h"
-#include "filetools.h"
-#include "FileInfo.h"
+#include "support/filetools.h"
+#include "support/FileInfo.h"
#include "lyxscreen.h"
-#include "error.h"
+#include "debug.h"
#include "lyxrc.h"
#include "lyxtext.h"
#include "gettext.h"
#include "trans_mgr.h"
#include "ImportLaTeX.h"
#include "ImportNoweb.h"
-
-// $Id: lyxfunc.C,v 1.1 1999/09/27 18:44:37 larsbj Exp $
-
-#if !defined(lint) && !defined(WITH_WARNINGS)
-static char vcid[] = "$Id: lyxfunc.C,v 1.1 1999/09/27 18:44:37 larsbj Exp $";
-#endif /* lint */
+#include "support/syscall.h"
+#include "support/lstrings.h"
extern bool cursor_follows_scrollbar;
-extern void InsertAsciiFile(LString const &, bool);
+extern void InsertAsciiFile(string const &, bool);
extern void math_insert_symbol(char const*);
extern Bool math_insert_greek(char const); // why "Bool"?
extern BufferList bufferlist;
extern void MenuLayoutSave();
extern void bulletForm();
-extern Buffer * NewLyxFile(LString const &);
-extern void LoadLyXFile(LString const &);
+extern Buffer * NewLyxFile(string const &);
+extern void LoadLyXFile(string const &);
extern void Reconfigure();
extern int current_layout;
}
-LString LyXFunc::argAsString(char const *const argument)
-{
- LString tmp(argument);
-
- if (tmp.empty()) {
- // get the arg from somewhere else, a popup, or ask for
- // it in the minibuffer.
- }
- lyxerr.debug("argAsString: <" + tmp + '>');
- return tmp;
-}
-
-
// I changed this func slightly. I commented out the ...FinishUndo(),
// this means that all places that used to have a moveCursorUpdate, now
// have a ...FinishUndo() as the preceeding statement. I have also added
s_r[9] = '\0';
int num_bytes;
int action;
- char *argument = 0;
+ string argument;
XKeyEvent *keyevent = &ev->xkey;
KeySym keysym_return;
num_bytes = LyXLookupString(ev, s_r, 10, &keysym_return);
- if (lyxerr.debugging(Error::KEY)) {
- lyxerr.print(LString("KeySym is ")
- + XKeysymToString(keysym_return)
- + "["
- + int(keysym_return) + "]"
- + " and num_bytes is "
- + num_bytes
- + " the string returned is \""
- + LString(s_r) + '\"');
+ if (lyxerr.debugging(Debug::KEY)) {
+ lyxerr << "KeySym is "
+ << XKeysymToString(keysym_return)
+ << "["
+ << keysym_return << "]"
+ << " and num_bytes is "
+ << num_bytes
+ << " the string returned is \""
+ << s_r << '\"' << endl;
}
// Do nothing if we have nothing (JMarc)
if (num_bytes == 0 && keysym_return == NoSymbol) {
- lyxerr.debug("Empty kbd action (probably composing)",
- Error::KEY);
+ lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
+ << endl;
return 0;
}
if (action == 0) action = LFUN_PREFIX;
- if (lyxerr.debugging(Error::KEY)) {
+ if (lyxerr.debugging(Debug::KEY)) {
char buf[100];
keyseq.print(buf,100);
- lyxerr.print(LString("Key [")
- + int(action) + "]["
- + buf + "]["
- + num_bytes +"]");
+ lyxerr << "Key ["
+ << action << "]["
+ << buf << "]["
+ << num_bytes << "]" << endl;
}
// already here we know if it any point in going further
if (!(keyevent->state&ControlMask) &&
!(keyevent->state&Mod1Mask) &&
(isochar && keysym_return < 0xF000)) {
- argument = &s_r[0]; // shall this be here
- argument[0] = isochar;
- argument[1] = 0;
+ argument += isochar;
}
- if (!argument) {
- lyxerr.debug("Empty argument!");
+ if (argument.empty()) {
+ lyxerr.debug() << "Empty argument!" << endl;
// This can`t possibly be of any use
// so we`ll skip the dispatch.
return 0;
}
} else
if (action==LFUN_SELFINSERT) {
- argument = &s_r[0];
- argument[1] = 0;
+ argument = s_r[0];
}
bool tmp_sc = show_sc;
show_sc = false;
- Dispatch(action, argument);
+ Dispatch(action, argument.c_str());
show_sc = tmp_sc;
- // Need this for deadkeys (alkis)
- //keyseq.length=0;
- // ...but that breaks the minibuffer's display of "M-"...
-#ifdef WITH_WARNINGS
-#warning How does the deadkeys react to this?
-#endif
return 0;
}
-LString LyXFunc::Dispatch(LString const &cmd, LString const &arg)
+string LyXFunc::Dispatch(string const &cmd, string const &arg)
{
return Dispatch(lyxaction.LookupFunc(cmd.c_str()),
arg.c_str());
}
-LString LyXFunc::Dispatch(int ac,
+string LyXFunc::Dispatch(int ac,
char const *do_not_use_this_arg)
{
- char const * argument = 0;
+ string argument;
kb_action action;
// we have not done anything wrong yet.
errorstat = false;
- dispatch_buffer = LString();
+ dispatch_buffer = string();
// if action is a pseudo-action, we need the real action
if (lyxaction.isPseudoAction(ac)) {
argument = tmparg;
} else {
action = (kb_action)ac;
- argument = do_not_use_this_arg; // except here
+ if (do_not_use_this_arg)
+ argument = do_not_use_this_arg; // except here
}
selection_possible = false;
}
}
- commandshortcut = LString();
+ commandshortcut = string();
if (lyxrc->display_shortcuts && show_sc) {
if (action != LFUN_SELFINSERT) {
// Put name of command and list of shortcuts
// for it in minibuffer
- LString comname = lyxaction.getActionName(action);
+ string comname = lyxaction.getActionName(action);
int pseudoaction = action;
bool argsadded = false;
- LString argu = argument;
- if (!argu.empty()) {
+ if (!argument.empty()) {
// If we have the command with argument,
// this is better
pseudoaction =
lyxaction.searchActionArg(action,
- argument);
+ argument.c_str());
if (pseudoaction == -1) {
pseudoaction = action;
} else {
- comname += " " + argu;
+ comname += " " + argument;
argsadded = true;
}
}
- LString shortcuts = toplevel_keymap->findbinding(pseudoaction);
+ string shortcuts = toplevel_keymap->findbinding(pseudoaction);
if (!shortcuts.empty()) {
comname += ": " + shortcuts;
} else if (!argsadded) {
- comname += " " + argu;
+ comname += " " + argument;
}
if (!comname.empty()) {
- comname.strip();
+ comname = strip(comname);
commandshortcut = "(" + comname + ')';
owner->getMiniBuffer()->Set(commandshortcut);
// Here we could even add a small pause,
owner->currentBuffer()->isReadonly() &&
lyxaction.isFuncRO(action)) {
setErrorMessage(N_("Document is read-only"));
- lyxerr.debug("Error: Document is read-only.");
+ lyxerr.debug() << "Error: Document is read-only." << endl;
goto exit_with_message;
}
if (owner->currentView()->available() &&
owner->currentBuffer()->the_locking_inset) {
if (action>1 || (action==LFUN_UNKNOWN_ACTION && keyseq.length>=-1)) {
- char s[8]="";
- if (action==LFUN_UNKNOWN_ACTION && !argument) {
- sprintf(s, "%c", keyseq.getiso());
- argument = &s[0];
+ if (action==LFUN_UNKNOWN_ACTION && argument.empty()) {
+ argument = keyseq.getiso();
}
// Undo/Redo pre 0.13 is a bit tricky for insets.
if (action==LFUN_UNDO) {
inset = (UpdatableInset*)owner->currentBuffer()->text->cursor.par->GetInset(owner->currentBuffer()->text->cursor.pos);
if (inset)
inset->Edit(slx, sly);
- return LString();
+ return string();
} else
if (action==LFUN_REDO) {
int slx, sly;
inset = (UpdatableInset*)owner->currentBuffer()->text->cursor.par->GetInset(owner->currentBuffer()->text->cursor.pos);
if (inset)
inset->Edit(slx, sly);
- return LString();
+ return string();
} else
- if (owner->currentBuffer()->the_locking_inset->LocalDispatch(action, argument))
- return LString();
+ if (owner->currentBuffer()->the_locking_inset->LocalDispatch(action, argument.c_str()))
+ return string();
else {
setMessage(N_("Text mode"));
if (action==LFUN_RIGHT || action==-1)
owner->currentBuffer()->text->CursorRight();
if (action==LFUN_LEFT || action==LFUN_RIGHT)
- return LString();
+ return string();
}
}
}
case LFUN_WORDFINDFORWARD :
case LFUN_WORDFINDBACKWARD : {
LyXText *ltCur;
- static LString last_search;
- LString searched_string;
+ static string last_search;
+ string searched_string;
- LString arg = argAsString(argument);
-
- if (!arg.empty()) {
- last_search = arg;
- searched_string = arg;
+ if (!argument.empty()) {
+ last_search = argument;
+ searched_string = argument;
} else {
searched_string = last_search;
}
}
char buf[100];
keyseq.print(buf,100, true);
- owner->getMiniBuffer()->Set(buf, LString(), LString(), 1);
+ owner->getMiniBuffer()->Set(buf, string(), string(), 1);
}
break;
meta_fake_bit = 0;
if(owner->currentView()->available())
// cancel any selection
- Dispatch(int(LFUN_MARK_OFF), NULL);
+ Dispatch(int(LFUN_MARK_OFF), 0);
setMessage(N_("Cancel"));
break;
meta_fake_bit = Mod1Mask;
char buf[100];
keyseq.print(buf, 98, true);
- LString res = LString("M-") + buf;
+ string res = string("M-") + buf;
setMessage(buf); // RVDK_PATCH_5
}
break;
case LFUN_EXPORT:
{
//needs argument as string
- LString extyp=argAsString(argument);
+ string extyp=argument;
// latex
if (extyp == "latex") {
MenuSendto();
break;
}
+ // HTML
+ else if (extyp == "html") {
+ // First, create LaTeX file
+ MenuMakeLaTeX(owner->currentBuffer());
+
+ // And now, run tth
+ string file = owner->currentBuffer()->getFileName();
+ file = ChangeExtension(file, ".tex", false);
+ string result = ChangeExtension(file, ".html", false);
+ string tmp = lyxrc->tth_command + " < " + file
+ + " > " + result ;
+ Systemcalls one;
+ int res = one.startscript(Systemcalls::System, tmp);
+ if (res == 0) {
+ setMessage(string(
+ _("Document exported as HTML to file: ")) + result);
+ } else {
+ setErrorMessage(string(
+ _("An unexpected error occured while converting document to HTML in file:")) + result);
+ }
+ }
else {
- setErrorMessage(LString(N_("Unknown export type: "))
+ setErrorMessage(string(_("Unknown export type: "))
+ extyp);
}
}
case LFUN_IMPORT:
{
//needs argument as string
- LString imtyp=argAsString(argument);
+ string imtyp=argument;
// latex
if (imtyp == "latex") {
} else if (imtyp == "noweb") {
doImportLaTeX(true);
} else {
- setErrorMessage(LString(N_("Unknown import type: "))
+ setErrorMessage(string(N_("Unknown import type: "))
+ imtyp);
}
break;
if (fd_form_toc->form_toc->visible) {
fl_raise_form(fd_form_toc->form_toc);
} else {
+ static int ow = -1, oh;
fl_show_form(fd_form_toc->form_toc,
FL_PLACE_MOUSE |
FL_FREE_SIZE, FL_FULLBORDER,
_("Table of Contents"));
+ if (ow < 0) {
+ ow = fd_form_toc->form_toc->w;
+ oh = fd_form_toc->form_toc->h;
+ }
+ fl_set_form_minsize(fd_form_toc->form_toc, ow, oh);
}
break;
case LFUN_PASTESELECTION:
{
bool asPara = false;
- if (LString(argument) == "paragraph") asPara = true;
+ if (string(argument) == "paragraph") asPara = true;
MenuPasteSelection(asPara);
break;
}
case LFUN_FILE_INSERT:
{
- // needs argument as string
- LString fil = argAsString(argument);
- MenuInsertLyXFile(fil);
+ MenuInsertLyXFile(argument);
}
break;
case LFUN_FILE_INSERT_ASCII:
{
bool asPara = false;
- asPara = (LString(argument) == "paragraph");
- InsertAsciiFile(LString(), asPara);
+ asPara = (string(argument) == "paragraph");
+ InsertAsciiFile(string(), asPara);
}
break;
case LFUN_LAYOUTNO:
{
- lyxerr.debug("LFUN_LAYOUTNO: (arg) " + LString(argument));
- int sel = atoi(argument);
- lyxerr.debug(LString("LFUN_LAYOUTNO: (sel) ") + int(sel));
+ lyxerr.debug() << "LFUN_LAYOUTNO: (arg) " << argument << endl;
+ int sel = strToInt(argument);
+ lyxerr.debug() << "LFUN_LAYOUTNO: (sel) "<< sel << endl;
// Should this give a setMessage instead?
if (sel == 0)
- return LString(); // illegal argument
+ return string(); // illegal argument
sel--; // sel 1..., but layout 0...
text->parameters->
textclass,
sel).c_str());
- return LString();
+ return string();
}
case LFUN_LAYOUT:
{
- lyxerr.debug("LFUN_LAYOUT: (arg) "
- + LString(argument));
+ lyxerr.debug() << "LFUN_LAYOUT: (arg) "
+ << argument << endl;
// Derive layout number from given argument (string)
// and current buffer's textclass (number). */
// see if we found the layout number:
if (layoutno == -1) {
- setErrorMessage(LString(N_("Layout ")) + argument +
+ setErrorMessage(string(N_("Layout ")) + argument +
N_(" not known"));
break;
}
case LFUN_LAYOUT_TABLE:
{
int flag = 0;
- if (LString(argument) == "true") flag = 1;
+ if (string(argument) == "true") flag = 1;
MenuLayoutTable(flag);
}
break;
break;
case LFUN_INSERT_LABEL:
- MenuInsertLabel(argument);
+ MenuInsertLabel(argument.c_str());
break;
case LFUN_INSERT_REF:
case LFUN_REFGOTO:
{
- LString label(argument);
+ string label(argument);
if (label.empty()) {
InsetRef *inset =
(InsetRef*)getInsetByCode(Inset::REF_CODE);
break;
case LFUN_GETXY:
- dispatch_buffer = LString()
- + owner->currentBuffer()->text->cursor.x + ' '
- + owner->currentBuffer()->text->cursor.y;
+ dispatch_buffer =
+ tostr(owner->currentBuffer()->text->cursor.x) + ' '
+ + tostr(owner->currentBuffer()->text->cursor.y);
break;
case LFUN_SETXY:
{
int x;
long y;
- sscanf(argument, " %d %ld", &x, &y);
+ sscanf(argument.c_str(), " %d %ld", &x, &y);
owner->currentBuffer()->text->SetCursorFromCoordinates(x, y);
}
break;
case LFUN_GETLAYOUT:
- dispatch_buffer = LString() +
- int(owner->currentBuffer()->text->cursor.par->layout);
+ dispatch_buffer =
+ tostr(owner->currentBuffer()->text->cursor.par->layout);
break;
case LFUN_GETFONT:
case LFUN_GETNAME:
setMessage(owner->currentBuffer()->getFileName());
- lyxerr.debug(LString("FNAME[") +
- owner->currentBuffer()->getFileName() +
- "] ");
+ lyxerr.debug() << "FNAME["
+ << owner->currentBuffer()->getFileName()
+ << "] " << endl;
break;
case LFUN_NOTIFY:
{
char file_name[100];
int row;
- sscanf(argument, " %s %d", file_name, &row);
+ sscanf(argument.c_str(), " %s %d", file_name, &row);
// Must replace extension of the file to be .lyx and get full path
- LString s = ChangeExtension(LString(file_name), ".lyx", false);
+ string s = ChangeExtension(string(file_name), ".lyx", false);
// Either change buffer or load the file
if (bufferlist.exists(s))
case LFUN_APROPOS:
case LFUN_GETTIP:
{
- int qa = lyxaction.LookupFunc((const char*)argument);
+ int qa = lyxaction.LookupFunc(argument.c_str());
setMessage(lyxaction.helpText((kb_action)qa));
}
break;
// --- toolbar ----------------------------------
case LFUN_PUSH_TOOLBAR:
{
- int nth = atoi(argument);
- if (lyxerr.debugging(Error::TOOLBAR)) {
- lyxerr.print(LString("LFUN_PUSH_TOOLBAR: argument = `")
- + argument + "'");
- lyxerr.print(LString("LFUN_PUSH_TOOLBAR: nth = `")
- + nth + "'");
+ int nth = strToInt(argument);
+ if (lyxerr.debugging(Debug::TOOLBAR)) {
+ lyxerr << "LFUN_PUSH_TOOLBAR: argument = `"
+ << argument << "'\n"
+ << "LFUN_PUSH_TOOLBAR: nth = `"
+ << nth << "'" << endl;
}
if (nth <= 0) {
case LFUN_ADD_TO_TOOLBAR:
{
- if (lyxerr.debugging(Error::TOOLBAR)) {
- lyxerr.print(LString("LFUN_ADD_TO_TOOLBAR:"
- "argument = `")+ argument + '\'');
+ if (lyxerr.debugging(Debug::TOOLBAR)) {
+ lyxerr << "LFUN_ADD_TO_TOOLBAR:"
+ "argument = `" << argument << '\'' << endl;
}
- LString tmp(argument);
- //lyxerr.print(LString("Argument: ") + argument);
- //lyxerr.print(LString("Tmp : ") + tmp);
+ string tmp(argument);
+ //lyxerr <<string("Argument: ") + argument);
+ //lyxerr <<string("Tmp : ") + tmp);
if (tmp.empty()) {
LyXBell();
setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
owner->currentBuffer()->
open_new_inset(new InsetFormula(false));
owner->currentBuffer()->
- the_locking_inset->LocalDispatch(action, argument);
+ the_locking_inset->LocalDispatch(action, argument.c_str());
}
}
break;
case LFUN_INSERT_MATH:
{
- math_insert_symbol(argument);
+ math_insert_symbol(argument.c_str());
}
break;
case LFUN_MATH_MACRO:
{
if (owner->currentView()->available()) {
- LString s(argument);
+ string s(argument);
if (s.empty())
setErrorMessage(N_("Missing argument"));
else {
- LString s1 = s.token(' ', 1);
+ string s1 = token(s, ' ', 1);
int na = s1.empty() ? 0: atoi(s1.c_str());
owner->currentBuffer()->
- open_new_inset(new InsetFormulaMacro(s.token(' ', 0), na));
+ open_new_inset(new InsetFormulaMacro(token(s, ' ', 0), na));
}
}
}
// ale970405
// The note, if any, must be after the key, delimited
// by a | so both key and remark can have spaces.
- if (argument) {
- LString lsarg(argument);
- if (lsarg.contains("|")) {
- new_inset->setContents(lsarg.token('|', 0));
- new_inset->setOptions(lsarg.token('|', 1));
+ if (!argument.empty()) {
+ string lsarg(argument);
+ if (contains(lsarg, "|")) {
+ new_inset->setContents(token(lsarg, '|', 0));
+ new_inset->setOptions(token(lsarg, '|', 1));
} else
new_inset->setContents(lsarg);
owner->currentBuffer()->insertInset(new_inset);
// ale970405+lasgoutt970425
// The argument can be up to two tokens separated
// by a space. The first one is the bibstyle.
- LString lsarg(argument);
- LString bibstyle = lsarg.token(' ', 1);
+ string lsarg(argument);
+ string bibstyle = token(lsarg, ' ', 1);
if (bibstyle.empty())
bibstyle = "plain";
InsetBibtex *new_inset
- = new InsetBibtex(lsarg.token(' ', 0),
+ = new InsetBibtex(token(lsarg, ' ', 0),
bibstyle,
owner->currentBuffer());
case LFUN_INDEX_INSERT_LAST:
{
InsetIndex *new_inset = new InsetIndex();
- if (argument) {
- LString lsarg(argument);
+ if (!argument.empty()) {
+ string lsarg(argument);
new_inset->setContents(lsarg);
owner->currentBuffer()->insertInset(new_inset);
} else {
// note that this must be done before
// inserting the inset, or the inset will break
// the word
- LString curstring(owner->currentBuffer()->text->cursor.par->GetWord(lastpos));
+ string curstring(owner->currentBuffer()->text->cursor.par->GetWord(lastpos));
//make the new inset and write the current word into it
InsetIndex *new_inset = new InsetIndex();
case LFUN_PARENTINSERT:
{
- lyxerr.print(LString("arg ") + argument);
+ lyxerr << "arg " << argument << endl;
Inset *new_inset = new InsetParent(argument, owner->currentBuffer());
owner->currentBuffer()->insertInset(new_inset, "Standard", true);
}
case LFUN_CHILDOPEN:
{
- LString filename = MakeAbsPath(argument,
+ string filename = MakeAbsPath(argument,
OnlyPath(owner->currentBuffer()->getFileName()));
setMessage(N_("Opening child document ") +
MakeDisplayPath(filename) + "...");
case LFUN_INSERTFOOTNOTE:
{
LyXParagraph::footnote_kind kind;
- LString arg = argument;
- if (arg == "footnote")
+ if (argument == "footnote")
{ kind = LyXParagraph::FOOTNOTE; }
- else if (arg == "margin")
+ else if (argument == "margin")
{ kind = LyXParagraph::MARGIN; }
- else if (arg == "figure")
+ else if (argument == "figure")
{ kind = LyXParagraph::FIG; }
- else if (arg == "table")
+ else if (argument == "table")
{ kind = LyXParagraph::TAB; }
- else if (arg == "wide-fig")
+ else if (argument == "wide-fig")
{ kind = LyXParagraph::WIDE_FIG; }
- else if (arg == "wide-tab")
+ else if (argument == "wide-tab")
{ kind = LyXParagraph::WIDE_TAB; }
- else if (arg == "algorithm")
+ else if (argument == "algorithm")
{ kind = LyXParagraph::ALGORITHM; }
else {
setErrorMessage(N_("Unknown kind of footnote"));
case LFUN_SELFINSERT:
{
- LString const text = argument;
- for (int i=0; i<text.length(); i++) {
- owner->currentBuffer()->text->InsertChar(text[i]);
+ for (string::size_type i = 0; i < argument.length(); ++i) {
+ owner->currentBuffer()->text->InsertChar(argument[i]);
// This needs to be in the loop, or else we
// won't break lines correctly. (Asger)
SmallUpdate(1);
break;
}
- if (argument) {
+ if (!argument.empty()) {
/* Automatically delete the currently selected
* text and replace it with what is being
}
BeforeChange();
- for(char const *p = argument; *p; p++) {
+ for (string::size_type i = 0; i < argument.length(); ++i) {
if (greek_kb_flag) {
- if (!math_insert_greek(*p))
- owner->getIntl()->getTrans()->TranslateAndInsert(*p, owner->currentBuffer()->text);
+ if (!math_insert_greek(argument[i]))
+ owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->currentBuffer()->text);
} else
- owner->getIntl()->getTrans()->TranslateAndInsert(*p, owner->currentBuffer()->text);
+ owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->currentBuffer()->text);
}
SmallUpdate(1);
owner->currentBuffer()->text->sel_cursor =
owner->currentBuffer()->text->cursor;
moveCursorUpdate(false);
- return LString();
+ return string();
} else {
// why is an "Unknown action" with empty
// argument even dispatched in the first
}
break;
default:
- lyxerr.print("A truly unknown func!");
+ lyxerr << "A truly unknown func!" << endl;
break;
}
} // end of switch
exit_with_message:
- LString res=getMessage();
+ string res=getMessage();
if (res.empty()) {
if (!commandshortcut.empty()) {
- LString newbuf = owner->getMiniBuffer()->GetText();
+ string newbuf = owner->getMiniBuffer()->GetText();
if (newbuf != commandshortcut) {
owner->getMiniBuffer()->Set(newbuf
+ " " +
}
}
} else {
- owner->getMiniBuffer()->Set(LString(_(res.c_str()))
+ owner->getMiniBuffer()->Set(string(_(res.c_str()))
+ " " + commandshortcut);
}
void LyXFunc::MenuNew(bool fromTemplate)
{
- LString fname, initpath = lyxrc->document_path;
+ string fname, initpath = lyxrc->document_path;
LyXFileDlg fileDlg;
if (owner->currentView()->available()) {
- LString trypath = owner->currentBuffer()->filepath;
+ string trypath = owner->currentBuffer()->filepath;
// If directory is writeable, use this as default.
if (IsDirWriteable(trypath) == 1)
initpath = trypath;
if (fname.empty()) {
owner->getMiniBuffer()->Set(_("Canceled."));
- lyxerr.debug("New Document Cancelled.");
+ lyxerr.debug() << "New Document Cancelled." << endl;
return;
}
// get absolute path of file and make sure the filename ends
// with .lyx
- LString s = MakeAbsPath(fname);
+ string s = MakeAbsPath(fname);
if (!IsLyXFilename(s))
s += ".lyx";
}
// The template stuff
- LString templname;
+ string templname;
if (fromTemplate) {
ProhibitInput();
fname = fileDlg.Select(_("Choose template"),
}
// find a free buffer
- lyxerr.debug("Find a free buffer.");
+ lyxerr.debug() << "Find a free buffer." << endl;
owner->currentView()->setBuffer(bufferlist.newFile(s,templname));
}
void LyXFunc::MenuOpen()
{
- LString initpath = lyxrc->document_path;
+ string initpath = lyxrc->document_path;
LyXFileDlg fileDlg;
if (owner->currentView()->available()) {
- LString trypath = owner->currentBuffer()->filepath;
+ string trypath = owner->currentBuffer()->filepath;
// If directory is writeable, use this as default.
if (IsDirWriteable(trypath) == 1)
initpath = trypath;
fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
fileDlg.SetButton(1, _("Examples"),
AddPath(system_lyxdir, "examples"));
- LString filename = fileDlg.Select(_("Select Document to Open"),
+ string filename = fileDlg.Select(_("Select Document to Open"),
initpath, "*.lyx");
AllowInput();
void LyXFunc::doImportASCII(bool linorpar)
{
- LString initpath = lyxrc->document_path;
+ string initpath = lyxrc->document_path;
LyXFileDlg fileDlg;
if (owner->currentView()->available()) {
- LString trypath = owner->currentBuffer()->filepath;
+ string trypath = owner->currentBuffer()->filepath;
// If directory is writeable, use this as default.
if (IsDirWriteable(trypath) == 1)
initpath = trypath;
fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
fileDlg.SetButton(1, _("Examples"),
AddPath(system_lyxdir, "examples"));
- LString filename = fileDlg.Select(_("Select ASCII file to Import"),
+ string filename = fileDlg.Select(_("Select ASCII file to Import"),
initpath, "*.txt");
AllowInput();
// get absolute path of file
filename = MakeAbsPath(filename);
- LString s = ChangeExtension(filename, ".lyx", false);
+ string s = ChangeExtension(filename, ".lyx", false);
// Check if the document already is open
if (bufferlist.exists(s)){
return;
}
- owner->currentView()->setBuffer(bufferlist.newFile(s,LString()));
+ owner->currentView()->setBuffer(bufferlist.newFile(s,string()));
owner->getMiniBuffer()->Set(_("Importing ASCII file"),
MakeDisplayPath(filename), "...");
// Insert ASCII file
void LyXFunc::doImportLaTeX(bool isnoweb)
{
- LString initpath = lyxrc->document_path;
+ string initpath = lyxrc->document_path;
LyXFileDlg fileDlg;
if (owner->currentView()->available()) {
- LString trypath = owner->currentBuffer()->filepath;
+ string trypath = owner->currentBuffer()->filepath;
// If directory is writeable, use this as default.
if (IsDirWriteable(trypath) == 1)
initpath = trypath;
fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
fileDlg.SetButton(1, _("Examples"),
AddPath(system_lyxdir, "examples"));
- LString filename;
+ string filename;
if (isnoweb) {
filename = fileDlg.Select(_("Select Noweb file to Import"),
initpath, "*.nw");
filename = MakeAbsPath(filename);
// Check if the document already is open
- LString LyXfilename = ChangeExtension(filename, ".lyx", false);
+ string LyXfilename = ChangeExtension(filename, ".lyx", false);
if (bufferlist.exists(LyXfilename)){
switch(AskConfirmation(_("Document is already open:"),
MakeDisplayPath(LyXfilename,50),
}
-void LyXFunc::MenuInsertLyXFile(LString const & filen)
+void LyXFunc::MenuInsertLyXFile(string const & filen)
{
- LString filename = filen;
+ string filename = filen;
if (filename.empty()) {
// Launch a file browser
- LString initpath = lyxrc->document_path;
+ string initpath = lyxrc->document_path;
LyXFileDlg fileDlg;
if (owner->currentView()->available()) {
- LString trypath = owner->currentBuffer()->filepath;
+ string trypath = owner->currentBuffer()->filepath;
// If directory is writeable, use this as default.
if (IsDirWriteable(trypath) == 1)
initpath = trypath;
void LyXFunc::reloadBuffer()
{
- LString fn = owner->currentBuffer()->getFileName();
+ string fn = owner->currentBuffer()->getFileName();
if (bufferlist.close(owner->currentBuffer()))
owner->currentView()->setBuffer(bufferlist.loadLyXFile(fn));
}
// This func is bit problematic when it comes to NLS, to make the
// lyx servers client be language indepenent we must not translate
// strings sent to this func.
-void LyXFunc::setErrorMessage(LString const &m)
+void LyXFunc::setErrorMessage(string const &m)
{
dispatch_buffer = m;
errorstat = true;
}
-void LyXFunc::setMessage(LString const & m)
+void LyXFunc::setMessage(string const & m)
{
dispatch_buffer = m;
}