#include <ctime>
#include <unistd.h>
#include <sys/wait.h>
+#include <locale.h>
#ifdef __GNUG__
#pragma implementation
#include "insets/insettext.h"
/// added for Dispatch functions
#include "lyx_cb.h"
-#include "filedlg.h"
+#include "frontends/FileDialog.h"
#include "lyx_main.h"
#include "FloatList.h"
#include "support/filetools.h"
#include "insets/insetcaption.h"
#include "mathed/formulamacro.h"
extern LyXTextClass::size_type current_layout;
-extern void math_insert_symbol(BufferView *, string const &);
-extern bool math_insert_greek(BufferView *, char);
extern int greek_kb_flag;
-#ifdef SIGC_CXX_NAMESPACES
-using SigC::slot;
-#endif
-
+using std::vector;
using std::find_if;
using std::pair;
using std::endl;
using std::make_pair;
using std::min;
+using SigC::slot;
/* the selection possible is needed, that only motion events are
* used, where the bottom press event was on the drawing area too */
extern BufferList bufferlist;
extern char ascii_type;
+extern bool math_insert_greek(BufferView *, char);
extern void sigchldhandler(pid_t pid, int * status);
extern int bibitemMaxWidth(BufferView *, LyXFont const &);
const unsigned int saved_positions_num = 20;
-static inline
+namespace {
+
+inline
void waitForX()
{
XSync(fl_get_display(), 0);
}
-static
void SetXtermCursor(Window win)
{
static Cursor cursor;
XFlush(fl_get_display());
}
+} // anon namespace
+
BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o,
int xpos, int ypos, int width, int height)
current_scrollbar_value(0), cursor_timeout(400),
workarea_(xpos, ypos, width, height), using_xterm_cursor(false)
{
- //buffer_ = 0;
- //workarea_ = new WorkArea(xpos, ypos, width, height);
-
// Setup the signals
workarea_.scrollCB.connect(slot(this, &BufferView::Pimpl::scrollCB));
workarea_.workAreaExpose
LyXParagraph * selendpar = 0;
UpdatableInset * the_locking_inset = 0;
- int pos = 0;
- int selstartpos = 0;
- int selendpos = 0;
- int selection = 0;
- int mark_set = 0;
+ LyXParagraph::size_type pos = 0;
+ LyXParagraph::size_type selstartpos = 0;
+ LyXParagraph::size_type selendpos = 0;
+ bool selection = false;
+ bool mark_set = false;
ProhibitInput(bv_);
bv_->setState();
AllowInput(bv_);
- owner_->getDialogs()->hideSplash();
+ /// get rid of the splash screen if it's not gone already
+ owner_->getDialogs()->destroySplash();
return 0;
}
selection_possible = false;
- if (button >= 2) return;
+ if (button == 2)
+ return;
bv_->setState();
owner_->showState();
return;
}
+#ifndef NEW_INSETS
// check whether we want to open a float
if (bv_->text) {
bool hit = false;
c = bv_->text->cursor.par()->
GetChar(bv_->text->cursor.pos());
}
-#ifndef NEW_INSETS
if(!bv_->text->selection)
if (c == LyXParagraph::META_FOOTNOTE
|| c == LyXParagraph::META_MARGIN
|| c == LyXParagraph::META_ALGORITHM){
hit = true;
} else
-#endif
if (bv_->text->cursor.pos() - 1 >= 0) {
c = bv_->text->cursor.par()->
GetChar(bv_->text->cursor.pos() - 1);
-#ifndef NEW_INSETS
if (c == LyXParagraph::META_FOOTNOTE
|| c == LyXParagraph::META_MARGIN
|| c == LyXParagraph::META_FIG
bv_->text->CursorLeft(bv_);
hit = true;
}
-#endif
}
if (hit == true) {
-#ifndef NEW_INSETS
bv_->toggleFloat();
-#endif
selection_possible = false;
return;
}
}
-
-#ifndef NEW_INSETS
// Do we want to close a float? (click on the float-label)
if (bv_->text->cursor.row()->par()->footnoteflag ==
LyXParagraph::OPEN_FOOTNOTE
return;
}
}
+#else
+ // check whether we want to open a float
+ if (bv_->text) {
+ bool hit = false;
+ char c = ' ';
+ if (bv_->text->cursor.pos() <
+ bv_->text->cursor.par()->size()) {
+ c = bv_->text->cursor.par()->
+ GetChar(bv_->text->cursor.pos());
+ }
+ if (bv_->text->cursor.pos() - 1 >= 0) {
+ c = bv_->text->cursor.par()->
+ GetChar(bv_->text->cursor.pos() - 1);
+ }
+ if (hit == true) {
+ selection_possible = false;
+ return;
+ }
+ }
#endif
-
// Maybe we want to edit a bibitem ale970302
if (bv_->text->cursor.par()->bibkey && x < 20 +
bibitemMaxWidth(bv_, textclasslist.
LyXCursor cursor;
text->SetCursorFromCoordinates(bv_, cursor, x, y_tmp);
+ text->SetCursor(bv_, cursor, cursor.par(),cursor.pos(),true);
+
+#ifndef NEW_INSETS
if (cursor.pos() < cursor.par()->Last()
+#else
+ if (cursor.pos() < cursor.par()->size()
+#endif
&& cursor.par()->GetChar(cursor.pos()) == LyXParagraph::META_INSET
&& cursor.par()->GetInset(cursor.pos())
&& cursor.par()->GetInset(cursor.pos())->Editable()) {
if (x > start_x && x < end_x
&& y_tmp > cursor.y() - tmpinset->ascent(bv_, font)
- && y_tmp < cursor.y() + tmpinset->descent(bv_, font)) {
+ && y_tmp < cursor.y() + tmpinset->descent(bv_, font))
+ {
text->SetCursor(bv_, cursor.par(),cursor.pos(),true);
x = x - start_x;
// The origin of an inset is on the baseline
if (!par)
return;
+#ifndef NEW_INSETS
bv_->text->SetCursor(bv_, par,
min(par->Last(), saved_positions[i].par_pos));
+#else
+ bv_->text->SetCursor(bv_, par,
+ min(par->size(), saved_positions[i].par_pos));
+#endif
update(bv_->text, BufferView::SELECT|BufferView::FITCUR);
if (i > 0)
owner_->getMiniBuffer()->Set(_("Moved to bookmark ") + tostr(i));
LyXText * text = bv_->getLyXText();
if (text->real_current_font.isRightToLeft() &&
text->real_current_font.latex() != LyXFont::ON) {
- if (owner_->getIntl()->primarykeymap)
+ if (owner_->getIntl()->keymap == Intl::PRIMARY)
owner_->getIntl()->KeyMapSec();
} else {
- if (!owner_->getIntl()->primarykeymap)
+ if (owner_->getIntl()->keymap == Intl::SECONDARY)
owner_->getIntl()->KeyMapPrim();
}
}
if (filename.empty()) {
// Launch a file browser
string initpath = lyxrc.document_path;
- LyXFileDlg fileDlg;
if (available()) {
string const trypath = owner_->buffer()->filepath;
initpath = trypath;
}
- // launches dialog
- ProhibitInput(bv_);
- fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
- fileDlg.SetButton(1, _("Examples"),
- AddPath(system_lyxdir, "examples"));
- filename = fileDlg.Select(_("Select Document to Insert"),
- initpath, "*.lyx");
- AllowInput(bv_);
+ FileDialog fileDlg(bv_->owner(), _("Select LyX document to insert"),
+ LFUN_FILE_INSERT,
+ make_pair(string(_("Documents")), string(lyxrc.document_path)),
+ make_pair(string(_("Examples")), string(AddPath(system_lyxdir, "examples"))));
+
+ FileDialog::Result result = fileDlg.Select(initpath, _("*.lyx| LyX Documents (*.lyx)"));
+
+ if (result.first == FileDialog::Later)
+ return;
+
+ filename = result.second;
// check selected filename
if (filename.empty()) {
owner_->getMiniBuffer()->Set(_("Canceled."));
return;
}
- }
+ }
// get absolute path of file and make sure the filename ends
// with .lyx
}
break;
+ case LFUN_FILE_INSERT_ASCII_PARA:
+ InsertAsciiFile(bv_, argument, true);
+ break;
+
case LFUN_FILE_INSERT_ASCII:
- {
- bool asPara = (argument == "paragraph");
- InsertAsciiFile(bv_, string(), asPara);
- }
- break;
+ InsertAsciiFile(bv_, argument, false);
+ break;
case LFUN_LAYOUT:
{
update(TEXT(bv_), BufferView::SELECT|BufferView::FITCUR);
if (is_rtl)
TEXT(bv_)->CursorLeft(bv_, false);
+#ifndef NEW_INSETS
if (TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->Last()
+#else
+ if (TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->size()
+#endif
&& TEXT(bv_)->cursor.par()->GetChar(TEXT(bv_)->cursor.pos())
== LyXParagraph::META_INSET
&& TEXT(bv_)->cursor.par()->GetInset(TEXT(bv_)->cursor.pos())
if (!is_rtl)
TEXT(bv_)->CursorLeft(bv_, false);
if ((is_rtl || cur != TEXT(bv_)->cursor) && // only if really moved!
+#ifndef NEW_INSETS
TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->Last() &&
+#else
+ TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->size() &&
+#endif
(TEXT(bv_)->cursor.par()->GetChar(TEXT(bv_)->cursor.pos()) ==
LyXParagraph::META_INSET) &&
TEXT(bv_)->cursor.par()->GetInset(TEXT(bv_)->cursor.pos()) &&
LyXCursor cursor = TEXT(bv_)->cursor;
if (!TEXT(bv_)->selection) {
+#ifndef NEW_INSETS
if (cursor.pos() == cursor.par()->Last()) {
+#else
+ if (cursor.pos() == cursor.par()->size()) {
+#endif
TEXT(bv_)->CursorRight(bv_);
cursor = TEXT(bv_)->cursor;
if (cursor.pos() == 0
case LFUN_INSERT_MATH:
{
- math_insert_symbol(bv_, argument);
+ if (!available())
+ break;
+
+ InsetFormula * f = new InsetFormula(true);
+ bv_->open_new_inset(f);
+ f->LocalDispatch(bv_, LFUN_INSERT_MATH, argument);
}
break;
if (!bv_->insertInset(inset, "Standard", true))
delete inset;
}
+
break;
case LFUN_CHILD_INSERT:
{
- InsetCommandParams p;
- p.setFromString(argument);
+ InsetInclude::Params p;
+ p.cparams.setFromString(argument);
+ p.masterFilename_ = buffer_->fileName();
- InsetInclude * inset = new InsetInclude(p, *buffer_);
+ InsetInclude * inset = new InsetInclude(p);
if (!bv_->insertInset(inset))
delete inset;
- else
+ else {
bv_->updateInset(inset, true);
+ bv_->owner()->getDialogs()->showInclude(inset);
+ }
}
break;
for (string::size_type i = 0;
i < argument.length(); ++i) {
if (greek_kb_flag) {
- if (!math_insert_greek(bv_,
- argument[i]))
+ if (!math_insert_greek(bv_, argument[i]))
owner_->getIntl()->getTrans().TranslateAndInsert(argument[i], TEXT(bv_));
} else
owner_->getIntl()->getTrans().TranslateAndInsert(argument[i], TEXT(bv_));
} else {
// if we don't have an argument there was something
// strange going on so we just tell this to someone!
- owner_->getLyXFunc()->setErrorMessage(N_("No argument givven"));
+ owner_->getLyXFunc()->setErrorMessage(N_("No argument given"));
}
break;
}