#include "lyxrow.h"
#include "bufferlist.h"
#include "BufferView.h"
-#include "frontends/xforms/ColorHandler.h"
#include "lyxserver.h"
#include "intl.h"
#include "lyx_main.h"
#include "layout.h"
#include "bufferview_funcs.h"
#include "frontends/MiniBuffer.h"
-#include "vspace.h"
#include "frontends/LyXView.h"
+#include "frontends/lyx_gui.h"
+#include "vspace.h"
#include "FloatList.h"
#include "converter.h"
#include "exporter.h"
#include "importer.h"
-#include "frontends/font_loader.h"
#include "TextCache.h"
#include "lyxfind.h"
#include "undo_funcs.h"
#include <utility>
#include <algorithm>
-
using std::pair;
using std::make_pair;
using std::endl;
extern void ShowLatexLog();
-#if 0
-
-///
-class MiniBufferController : public SigC::Object {
-public:
- ///
- MiniBufferController() {
- minibuffer
- .cmdReady
- .connect(slot(this,
- &MiniBufferController::receiveCommand));
- minibuffer
- .argReady
- .connect(slot(this,
- &MiniBufferController::receiveArg));
- }
- ///
- void receiveCmd(string const & cmd) {}
- ///
- void receiveArg(string const & arg) {}
-
-
-private:
-};
-
-namespace {
-
-MiniBufferController mb_ctrl;
-
-}
-#endif
-
-
/* === globals =========================================================== */
goto exit_with_message;
// If UNDISPATCHED, just soldier on
else if (result == UpdatableInset::FINISHED) {
- if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
- TEXT()->cursorRight(owner->view());
- moveCursorUpdate(true, false);
- owner->showState();
- }
- goto exit_with_message;
+ goto exit_with_message;
+ // We do not need special RTL handling here:
+ // FINISHED means that the cursor should be
+ // one position after the inset.
} else if (result == UpdatableInset::FINISHED_RIGHT) {
- if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
- TEXT()->cursorRight(owner->view());
- moveCursorUpdate(true, false);
- owner->showState();
- }
+ TEXT()->cursorRight(owner->view());
+ moveCursorUpdate(true, false);
+ owner->showState();
goto exit_with_message;
} else if (result == UpdatableInset::FINISHED_UP) {
if (TEXT()->cursor.irow()->previous()) {
// --- Menus -----------------------------------------------
case LFUN_MENUNEW:
- menuNew(false);
+ menuNew(argument, false);
break;
case LFUN_MENUNEWTMPLT:
- menuNew(true);
+ menuNew(argument, true);
break;
case LFUN_CLOSEBUFFER:
owner->view()->buffer(bufferlist.loadLyXFile(s));
}
- // Set the cursor
owner->view()->setCursorFromRow(row);
- // Recenter screen
owner->view()->center();
+ // see BufferView_pimpl::center()
+ owner->view()->updateScrollbar();
}
break;
owner->view()->setState();
owner->showState();
- // Recenter screen
owner->view()->center();
+ // see BufferView_pimpl::center()
+ owner->view()->updateScrollbar();
}
break;
case LFUN_SEQUENCE:
{
// argument contains ';'-terminated commands
- while (argument.find(';') != string::npos) {
+ while (!argument.empty()) {
string first;
argument = split(argument, first, ';');
verboseDispatch(first, false);
// handle the screen font changes.
//
lyxrc.set_font_norm_type();
- fontloader.update();
+ lyx_gui::update_fonts();
// Of course we should only do the resize and the textcache.clear
// if values really changed...but not very important right now. (Lgb)
// All visible buffers will need resize
owner->view()->resize();
+ owner->view()->repaint();
// We also need to empty the textcache so that
// the buffer will be formatted correctly after
// a zoom change.
break;
}
- lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
+ lyx_gui::update_color(lcolor.getFromLyXName(lyx_name));
if (graphicsbg_changed) {
#ifdef WITH_WARNINGS
}
-void LyXFunc::menuNew(bool fromTemplate)
+void LyXFunc::menuNew(string const & name, bool fromTemplate)
{
string initpath = lyxrc.document_path;
+ string filename(name);
if (owner->view()->available()) {
string const trypath = owner->buffer()->filePath();
}
static int newfile_number;
- string s;
- if (lyxrc.new_ask_filename) {
- FileDialog fileDlg(owner, _("Enter filename for new document"),
- LFUN_SELECT_FILE_SYNC,
- make_pair(string(_("Documents|#o#O")),
- string(lyxrc.document_path)),
- make_pair(string(_("Templates|#T#t")),
- string(lyxrc.template_path)));
-
- FileDialog::Result result =
- fileDlg.Select(initpath,
- _("*.lyx|LyX Documents (*.lyx)"),
- _("newfile"));
-
- if (result.second.empty()) {
- owner->message(_("Canceled."));
- lyxerr[Debug::INFO] << "New Document Cancelled." << endl;
- return;
- }
-
- // get absolute path of file and make sure the filename ends
- // with .lyx
- s = MakeAbsPath(result.second);
- if (!IsLyXFilename(s))
- s += ".lyx";
-
- // Check if the document already is open
- if (bufferlist.exists(s)) {
- switch (Alert::askConfirmation(_("Document is already open:"),
- MakeDisplayPath(s, 50),
- _("Do you want to close that document now?\n"
- "('No' will just switch to the open version)")))
- {
- case 1: // Yes: close the document
- if (!bufferlist.close(bufferlist.getBuffer(s)))
- // If close is canceled, we cancel here too.
- return;
- break;
- case 2: // No: switch to the open document
- owner->view()->buffer(bufferlist.getBuffer(s));
- return;
- case 3: // Cancel: Do nothing
- owner->message(_("Canceled."));
- return;
- }
- }
- // Check whether the file already exists
- FileInfo fi(s);
- if (fi.readable() &&
- Alert::askQuestion(_("File already exists:"),
- MakeDisplayPath(s, 50),
- _("Do you want to open the document?"))) {
- // loads document
- string const disp_fn(MakeDisplayPath(s));
-
- ostringstream str;
- str << _("Opening document") << ' '
- << disp_fn << "...";
-
- owner->message(str.str().c_str());
- owner->view()->buffer(bufferlist.loadLyXFile(s));
- ostringstream str2;
- str2 << _("Document") << ' '
- << disp_fn << ' ' << _("opened.");
-
- owner->message(str2.str().c_str());
-
- return;
- }
- } else {
- s = AddName(lyxrc.document_path,
+ if (filename.empty()) {
+ filename = AddName(lyxrc.document_path,
"newfile" + tostr(++newfile_number) + ".lyx");
- FileInfo fi(s);
- while (bufferlist.exists(s) || fi.readable()) {
+ FileInfo fi(filename);
+ while (bufferlist.exists(filename) || fi.readable()) {
++newfile_number;
- s = AddName(lyxrc.document_path,
+ filename = AddName(lyxrc.document_path,
"newfile" + tostr(newfile_number) +
".lyx");
- fi.newFile(s);
+ fi.newFile(filename);
}
}
templname = fname;
}
- // find a free buffer
- lyxerr[Debug::INFO] << "Find a free buffer." << endl;
- owner->view()->buffer(bufferlist.newFile(s, templname));
+ owner->view()->buffer(bufferlist.newFile(filename, templname, !name.empty()));
}