- /// Method to check if a file is externally modified, used by
+ /// Method to check if a file is externally modified, used by
/// isExternallyModified()
/**
* timestamp is fast but inaccurate. For example, the granularity
* of timestamp on a FAT filesystem is 2 second. Also, various operations
* may touch the timestamp of a file even when its content is unchanged.
*
/// isExternallyModified()
/**
* timestamp is fast but inaccurate. For example, the granularity
* of timestamp on a FAT filesystem is 2 second. Also, various operations
* may touch the timestamp of a file even when its content is unchanged.
*
- * checksum is accurate but slow, which can be a problem when it is
+ * checksum is accurate but slow, which can be a problem when it is
* frequently used, or used for a large file on a slow (network) file
* system.
*
* frequently used, or used for a large file on a slow (network) file
* system.
*
checksum_method, ///< Use file checksum
timestamp_method, ///< Use timestamp, and checksum if timestamp has changed
};
checksum_method, ///< Use file checksum
timestamp_method, ///< Use timestamp, and checksum if timestamp has changed
};
/** Constructor
\param file
\param b optional \c false by default
/** Constructor
\param file
\param b optional \c false by default
/// Write file. Returns \c false if unsuccesful.
bool writeFile(support::FileName const &) const;
/// Write file. Returns \c false if unsuccesful.
bool writeFile(support::FileName const &) const;
- /// Loads LyX file \c filename into buffer, * and \return success
+ /// Loads LyX file \c filename into buffer, * and \return success
bool loadLyXFile(support::FileName const & s);
/// Fill in the ErrorList with the TeXErrors
bool loadLyXFile(support::FileName const & s);
/// Fill in the ErrorList with the TeXErrors
void updateMacros(DocIterator & it,
DocIterator & scope) const;
void updateMacros(DocIterator & it,
DocIterator & scope) const;
bool readFileHelper(support::FileName const & s);
///
std::vector<std::string> backends() const;
bool readFileHelper(support::FileName const & s);
///
std::vector<std::string> backends() const;
}
} else {
if (reverseDirectionNeeded(cur)) {
}
} else {
if (reverseDirectionNeeded(cur)) {
- cmd.action = cmd.action == LFUN_CHAR_LEFT_SELECT ?
+ cmd.action = cmd.action == LFUN_CHAR_LEFT_SELECT ?
LFUN_CHAR_FORWARD_SELECT : LFUN_CHAR_FORWARD;
} else {
LFUN_CHAR_FORWARD_SELECT : LFUN_CHAR_FORWARD;
} else {
- cmd.action = cmd.action == LFUN_CHAR_LEFT_SELECT ?
+ cmd.action = cmd.action == LFUN_CHAR_LEFT_SELECT ?
LFUN_CHAR_BACKWARD_SELECT : LFUN_CHAR_BACKWARD;
}
dispatch(cur, cmd);
LFUN_CHAR_BACKWARD_SELECT : LFUN_CHAR_BACKWARD;
}
dispatch(cur, cmd);
}
} else {
if (reverseDirectionNeeded(cur)) {
}
} else {
if (reverseDirectionNeeded(cur)) {
- cmd.action = cmd.action == LFUN_CHAR_RIGHT_SELECT ?
+ cmd.action = cmd.action == LFUN_CHAR_RIGHT_SELECT ?
LFUN_CHAR_BACKWARD_SELECT : LFUN_CHAR_BACKWARD;
} else {
LFUN_CHAR_BACKWARD_SELECT : LFUN_CHAR_BACKWARD;
} else {
- cmd.action = cmd.action == LFUN_CHAR_RIGHT_SELECT ?
+ cmd.action = cmd.action == LFUN_CHAR_RIGHT_SELECT ?
LFUN_CHAR_FORWARD_SELECT : LFUN_CHAR_FORWARD;
}
dispatch(cur, cmd);
return;
}
break;
LFUN_CHAR_FORWARD_SELECT : LFUN_CHAR_FORWARD;
}
dispatch(cur, cmd);
return;
}
break;
case LFUN_UP_SELECT:
case LFUN_DOWN_SELECT:
case LFUN_UP_SELECT:
case LFUN_DOWN_SELECT:
bool select = cmd.action == LFUN_DOWN_SELECT ||
cmd.action == LFUN_UP_SELECT;
cur.selHandle(select);
bool select = cmd.action == LFUN_DOWN_SELECT ||
cmd.action == LFUN_UP_SELECT;
cur.selHandle(select);
// move cursor up/down
bool up = cmd.action == LFUN_UP_SELECT || cmd.action == LFUN_UP;
bool const successful = cur.upDownInText(up, needsUpdate);
// move cursor up/down
bool up = cmd.action == LFUN_UP_SELECT || cmd.action == LFUN_UP;
bool const successful = cur.upDownInText(up, needsUpdate);
needsUpdate |= cur.beforeDispatchCursor().inMathed();
} else
cur.undispatched();
needsUpdate |= cur.beforeDispatchCursor().inMathed();
} else
cur.undispatched();
moveCursor(cur, false);
break;
}
moveCursor(cur, false);
break;
}
case LFUN_CHAR_DELETE_FORWARD:
if (!cur.selection()) {
if (cur.pos() == cur.paragraph().size())
case LFUN_CHAR_DELETE_FORWARD:
if (!cur.selection()) {
if (cur.pos() == cur.paragraph().size())
if (layout.empty())
layout = tclass.defaultLayoutName();
if (layout.empty())
layout = tclass.defaultLayoutName();
- if (para.forcePlainLayout())
+ if (para.forcePlainLayout())
// in this case only the empty layout is allowed
layout = tclass.plainLayoutName();
else if (para.usePlainLayout()) {
// in this case only the empty layout is allowed
layout = tclass.plainLayoutName();
else if (para.usePlainLayout()) {
- // in this case, default layout maps to empty layout
+ // in this case, default layout maps to empty layout
if (layout == tclass.defaultLayoutName())
layout = tclass.plainLayoutName();
if (layout == tclass.defaultLayoutName())
layout = tclass.plainLayoutName();
// otherwise, the empty layout maps to the default
if (layout == tclass.plainLayoutName())
layout = tclass.defaultLayoutName();
// otherwise, the empty layout maps to the default
if (layout == tclass.plainLayoutName())
layout = tclass.defaultLayoutName();
// Set the cursor
if (!bv->mouseSetCursor(cur, cmd.argument() == "region-select"))
cur.updateFlags(Update::SinglePar | Update::FitCursor);
// Set the cursor
if (!bv->mouseSetCursor(cur, cmd.argument() == "region-select"))
cur.updateFlags(Update::SinglePar | Update::FitCursor);
case mouse_button::button2:
// Middle mouse pasting.
bv->mouseSetCursor(cur);
case mouse_button::button2:
// Middle mouse pasting.
bv->mouseSetCursor(cur);
- if (!cap::selection()) {
+ if (!cap::selection()) {
// There is no local selection in the current buffer, so try to
// paste primary selection instead.
lyx::dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE,
// There is no local selection in the current buffer, so try to
// paste primary selection instead.
lyx::dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE,
}
if (!bv->mouseSetCursor(cur, false))
cur.updateFlags(Update::SinglePar | Update::FitCursor);
}
if (!bv->mouseSetCursor(cur, false))
cur.updateFlags(Update::SinglePar | Update::FitCursor);
else
p["symbol"] = cmd.argument();
string const data = InsetCommand::params2string("nomenclature", p);
else
p["symbol"] = cmd.argument();
string const data = InsetCommand::params2string("nomenclature", p);
- bv->showDialog("nomenclature", data);
+ bv->showDialog("nomenclature", data);
case LFUN_FINISHED_LEFT:
LYXERR(Debug::DEBUG, "handle LFUN_FINISHED_LEFT:\n" << cur);
case LFUN_FINISHED_LEFT:
LYXERR(Debug::DEBUG, "handle LFUN_FINISHED_LEFT:\n" << cur);
- // We're leaving an inset, going left. If the inset is LTR, we're
+ // We're leaving an inset, going left. If the inset is LTR, we're
// leaving from the front, so we should not move (remain at --- but
// leaving from the front, so we should not move (remain at --- but
- // not in --- the inset). If the inset is RTL, move left, without
+ // not in --- the inset). If the inset is RTL, move left, without
// entering the inset itself; i.e., move to after the inset.
if (cur.paragraph().getFontSettings(
cur.bv().buffer().params(), cur.pos()).isRightToLeft())
// entering the inset itself; i.e., move to after the inset.
if (cur.paragraph().getFontSettings(
cur.bv().buffer().params(), cur.pos()).isRightToLeft())
case LFUN_FINISHED_RIGHT:
LYXERR(Debug::DEBUG, "handle LFUN_FINISHED_RIGHT:\n" << cur);
case LFUN_FINISHED_RIGHT:
LYXERR(Debug::DEBUG, "handle LFUN_FINISHED_RIGHT:\n" << cur);
- // We're leaving an inset, going right. If the inset is RTL, we're
+ // We're leaving an inset, going right. If the inset is RTL, we're
// leaving from the front, so we should not move (remain at --- but
// leaving from the front, so we should not move (remain at --- but
- // not in --- the inset). If the inset is LTR, move right, without
+ // not in --- the inset). If the inset is LTR, move right, without
// entering the inset itself; i.e., move to after the inset.
if (!cur.paragraph().getFontSettings(
cur.bv().buffer().params(), cur.pos()).isRightToLeft())
// entering the inset itself; i.e., move to after the inset.
if (!cur.paragraph().getFontSettings(
cur.bv().buffer().params(), cur.pos()).isRightToLeft())
params2string(cur.paragraph(), data);
// Will the paragraph accept changes from the dialog?
params2string(cur.paragraph(), data);
// Will the paragraph accept changes from the dialog?
cur.inset().allowParagraphCustomization(cur.idx());
data = "update " + convert<string>(accept) + '\n' + data;
cur.inset().allowParagraphCustomization(cur.idx());
data = "update " + convert<string>(accept) + '\n' + data;
// FIXME If this call were replaced with one to clearParagraphParams(),
// then we could get rid of this method altogether.
setParagraphs(cur, p);
// FIXME If this call were replaced with one to clearParagraphParams(),
// then we could get rid of this method altogether.
setParagraphs(cur, p);
- // FIXME This should be simplified when InsetFloatList takes a
+ // FIXME This should be simplified when InsetFloatList takes a
// Buffer in its constructor.
InsetFloatList * ifl = new InsetFloatList(to_utf8(cmd.argument()));
ifl->setBuffer(bv->buffer());
// Buffer in its constructor.
InsetFloatList * ifl = new InsetFloatList(to_utf8(cmd.argument()));
ifl->setBuffer(bv->buffer());
// Given data, an encoding of the ParagraphParameters
// generated in the Paragraph dialog, this function sets
// the current paragraph, or currently selected paragraphs,
// Given data, an encoding of the ParagraphParameters
// generated in the Paragraph dialog, this function sets
// the current paragraph, or currently selected paragraphs,
// NOTE: This function overrides all existing settings.
setParagraphs(cur, cmd.argument());
cur.message(_("Paragraph layout set"));
break;
}
// NOTE: This function overrides all existing settings.
setParagraphs(cur, cmd.argument());
cur.message(_("Paragraph layout set"));
break;
}
case LFUN_PARAGRAPH_PARAMS: {
// Given data, an encoding of the ParagraphParameters as we'd
case LFUN_PARAGRAPH_PARAMS: {
// Given data, an encoding of the ParagraphParameters as we'd
- // find them in a LyX file, this function modifies the current paragraph,
- // or currently selected paragraphs.
+ // find them in a LyX file, this function modifies the current paragraph,
+ // or currently selected paragraphs.
// NOTE: This function only modifies, and does not override, existing
// settings.
setParagraphs(cur, cmd.argument(), true);
// NOTE: This function only modifies, and does not override, existing
// settings.
setParagraphs(cur, cmd.argument(), true);
case LFUN_FLEX_INSERT: {
code = FLEX_CODE;
string s = cmd.getArg(0);
case LFUN_FLEX_INSERT: {
code = FLEX_CODE;
string s = cmd.getArg(0);
cur.buffer().params().documentClass().insetLayout(from_utf8(s));
if (il.lyxtype() != "charstyle" &&
il.lyxtype() != "custom" &&
cur.buffer().params().documentClass().insetLayout(from_utf8(s));
if (il.lyxtype() != "charstyle" &&
il.lyxtype() != "custom" &&
enable = !theClipboard().empty();
break;
}
enable = !theClipboard().empty();
break;
}
// we have an argument
string const arg = to_utf8(cmd.argument());
if (isStrUnsignedInt(arg)) {
// we have an argument
string const arg = to_utf8(cmd.argument());
if (isStrUnsignedInt(arg)) {
enable = cap::numberOfSelections() > n;
break;
}
enable = cap::numberOfSelections() > n;
break;
}
// explicit graphics type?
if ((arg == "pdf" && theClipboard().hasGraphicsContents(Clipboard::PdfGraphicsType))
|| (arg == "png" && theClipboard().hasGraphicsContents(Clipboard::PngGraphicsType))
// explicit graphics type?
if ((arg == "pdf" && theClipboard().hasGraphicsContents(Clipboard::PdfGraphicsType))
|| (arg == "png" && theClipboard().hasGraphicsContents(Clipboard::PngGraphicsType))
// unknown argument
enable = false;
break;
// unknown argument
enable = false;
break;
enable = cur.inset().lyxCode() == FLEX_CODE
&& il.lyxtype() == to_utf8(cmd.argument());
} else {
enable = cur.inset().lyxCode() == FLEX_CODE
&& il.lyxtype() == to_utf8(cmd.argument());
} else {
- enable = !isMainText(cur.bv().buffer())
+ enable = !isMainText(cur.bv().buffer())
&& cur.inset().nargs() == 1;
}
break;
&& cur.inset().nargs() == 1;
}
break;
case LFUN_SET_GRAPHICS_GROUP: {
InsetGraphics * ins = graphics::getCurrentGraphicsInset(cur);
case LFUN_SET_GRAPHICS_GROUP: {
InsetGraphics * ins = graphics::getCurrentGraphicsInset(cur);
enable = false;
else
flag.setOnOff(to_utf8(cmd.argument()) == ins->getParams().groupId);
enable = false;
else
flag.setOnOff(to_utf8(cmd.argument()) == ins->getParams().groupId);
void handleRegularEvents();
///
void onLastWindowClosed();
void handleRegularEvents();
///
void onLastWindowClosed();
private:
///
bool closeAllViews();
private:
///
bool closeAllViews();
int const TabIndicatorWidth = 3;
#undef KeyPress
int const TabIndicatorWidth = 3;
#undef KeyPress
using namespace std;
using namespace lyx::support;
using namespace std;
using namespace lyx::support;
{
if (!show_ || !rect_.isValid())
return;
{
if (!show_ || !rect_.isValid())
return;
int y = rect_.top();
int l = x_ - rect_.left();
int r = rect_.right() - x_;
int y = rect_.top();
int l = x_ - rect_.left();
int r = rect_.right() - x_;
// draw vertica linel
painter.fillRect(x_, y, CursorWidth, rect_.height(), color_);
// draw vertica linel
painter.fillRect(x_, y, CursorWidth, rect_.height(), color_);
// draw RTL/LTR indication
painter.setPen(color_);
if (l_shape_) {
// draw RTL/LTR indication
painter.setPen(color_);
if (l_shape_) {
else
painter.drawLine(x_, bot, x_ + CursorWidth + r, bot);
}
else
painter.drawLine(x_, bot, x_ + CursorWidth + r, bot);
}
// draw completion triangle
if (completable_) {
int m = y + rect_.height() / 2;
// draw completion triangle
if (completable_) {
int m = y + rect_.height() / 2;
rtl_ = rtl;
completable_ = completable;
x_ = x;
rtl_ = rtl;
completable_ = completable;
x_ = x;
// extension to left and right
int l = 0;
int r = 0;
// extension to left and right
int l = 0;
int r = 0;
// completion triangle
if (completable_) {
if (rtl)
// completion triangle
if (completable_) {
if (rtl)
// Setup the signals
connect(&cursor_timeout_, SIGNAL(timeout()),
this, SLOT(toggleCursor()));
// Setup the signals
connect(&cursor_timeout_, SIGNAL(timeout()),
this, SLOT(toggleCursor()));
int const time = QApplication::cursorFlashTime() / 2;
if (time > 0) {
cursor_timeout_.setInterval(time);
int const time = QApplication::cursorFlashTime() / 2;
if (time > 0) {
cursor_timeout_.setInterval(time);
setMouseTracking(true);
setMinimumSize(100, 70);
#ifdef Q_WS_MACX
setMouseTracking(true);
setMinimumSize(100, 70);
#ifdef Q_WS_MACX
- setFrameStyle(QFrame::NoFrame);
+ setFrameStyle(QFrame::NoFrame);
#else
setFrameStyle(QFrame::Box);
#endif
#else
setFrameStyle(QFrame::Box);
#endif
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
} else {
#ifdef Q_WS_MACX
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
} else {
#ifdef Q_WS_MACX
- setFrameStyle(QFrame::NoFrame);
+ setFrameStyle(QFrame::NoFrame);
#else
setFrameStyle(QFrame::Box);
#endif
#else
setFrameStyle(QFrame::Box);
#endif
hideCursor();
showCursor();
}
hideCursor();
showCursor();
}
LYXERR(Debug::WORKAREA, "WorkArea::redraw screen");
updateScreen();
update(0, 0, viewport()->width(), viewport()->height());
LYXERR(Debug::WORKAREA, "WorkArea::redraw screen");
updateScreen();
update(0, 0, viewport()->width(), viewport()->height());
- bool const notJustMovingTheMouse =
+ bool const notJustMovingTheMouse =
cmd.action != LFUN_MOUSE_MOTION || cmd.button() != mouse_button::none;
cmd.action != LFUN_MOUSE_MOTION || cmd.button() != mouse_button::none;
// In order to avoid bad surprise in the middle of an operation, we better stop
// the blinking cursor.
if (notJustMovingTheMouse)
// In order to avoid bad surprise in the middle of an operation, we better stop
// the blinking cursor.
if (notJustMovingTheMouse)
updateScreen();
// Update scrollbars which might have changed due different
updateScreen();
// Update scrollbars which might have changed due different
- // BufferView dimension. This is especially important when the
+ // BufferView dimension. This is especially important when the
// BufferView goes from zero-size to the real-size for the first time,
// as the scrollbar paramters are then set for the first time.
updateScrollbar();
// BufferView goes from zero-size to the real-size for the first time,
// as the scrollbar paramters are then set for the first time.
updateScrollbar();
lyx_view_->updateLayoutList();
lyx_view_->setBusy(false);
need_resize_ = false;
lyx_view_->updateLayoutList();
lyx_view_->setBusy(false);
need_resize_ = false;
// (the auto repeated events come too fast)
// \todo FIXME: remove hard coded Qt keys, process the key binding
#ifdef Q_WS_X11
// (the auto repeated events come too fast)
// \todo FIXME: remove hard coded Qt keys, process the key binding
#ifdef Q_WS_X11
- if (XEventsQueued(QX11Info::display(), 0) > 1 && ev->isAutoRepeat()
+ if (XEventsQueued(QX11Info::display(), 0) > 1 && ev->isAutoRepeat()
&& (Qt::Key_PageDown || Qt::Key_PageUp)) {
LYXERR(Debug::KEY, "system is busy: scroll key event ignored");
ev->ignore();
&& (Qt::Key_PageDown || Qt::Key_PageUp)) {
LYXERR(Debug::KEY, "system is busy: scroll key event ignored");
ev->ignore();
////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////
//
//
////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////
{
QRect rect = QMacStyle::subElementRect(element, option, widget);
bool noBar = static_cast<QTabWidget const *>(widget)->count() <= 1;
{
QRect rect = QMacStyle::subElementRect(element, option, widget);
bool noBar = static_cast<QTabWidget const *>(widget)->count() <= 1;
// The Qt Mac style puts the contents into a 3 pixel wide box
// which looks very ugly and not like other Mac applications.
// Hence we remove this here, and moreover the 16 pixel round
// The Qt Mac style puts the contents into a 3 pixel wide box
// which looks very ugly and not like other Mac applications.
// Hence we remove this here, and moreover the 16 pixel round
QObject::connect(closeBufferButton, SIGNAL(clicked()),
this, SLOT(closeCurrentBuffer()));
setCornerWidget(closeBufferButton, Qt::TopRightCorner);
QObject::connect(closeBufferButton, SIGNAL(clicked()),
this, SLOT(closeCurrentBuffer()));
setCornerWidget(closeBufferButton, Qt::TopRightCorner);
// setup drag'n'drop
QTabBar* tb = new DragTabBar;
connect(tb, SIGNAL(tabMoveRequested(int, int)),
// setup drag'n'drop
QTabBar* tb = new DragTabBar;
connect(tb, SIGNAL(tabMoveRequested(int, int)),
tb->setContextMenuPolicy(Qt::CustomContextMenu);
connect(tb, SIGNAL(customContextMenuRequested(const QPoint &)),
this, SLOT(showContextMenu(const QPoint &)));
tb->setContextMenuPolicy(Qt::CustomContextMenu);
connect(tb, SIGNAL(customContextMenuRequested(const QPoint &)),
this, SLOT(showContextMenu(const QPoint &)));
setUsesScrollButtons(true);
}
setUsesScrollButtons(true);
}
if (count() == 0)
return 0;
if (count() == 0)
return 0;
- GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(currentWidget());
+ GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(currentWidget());
LASSERT(wa, /**/);
return wa;
}
LASSERT(wa, /**/);
return wa;
}
showBar(count() > 1);
updateTabTexts();
showBar(count() > 1);
updateTabTexts();
if (clicked_tab_ == -1)
removeWorkArea(currentWorkArea());
else {
if (clicked_tab_ == -1)
removeWorkArea(currentWorkArea());
else {
- GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(widget(clicked_tab_));
+ GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(widget(clicked_tab_));
LASSERT(wa, /**/);
removeWorkArea(wa);
}
LASSERT(wa, /**/);
removeWorkArea(wa);
}
abs_ = toqstr(filename.absoluteFilePath());
dottedPrefix_ = false;
}
abs_ = toqstr(filename.absoluteFilePath());
dottedPrefix_ = false;
}
/// Absolute path for debugging.
QString abs() const
{
/// Absolute path for debugging.
QString abs() const
{
{
if (postfix_.count() == 0)
return displayString();
{
if (postfix_.count() == 0)
return displayString();
return prefix_
+ (dottedPrefix_ ? ".../" : "")
+ postfix_.front() + "/";
return prefix_
+ (dottedPrefix_ ? ".../" : "")
+ postfix_.front() + "/";
bool final() const { return postfix_.empty(); }
///
int tab() const { return tab_; }
bool final() const { return postfix_.empty(); }
///
int tab() const { return tab_; }
private:
///
QString prefix_;
private:
///
QString prefix_;
return;
std::list<DisplayPath> paths;
typedef std::list<DisplayPath>::iterator It;
return;
std::list<DisplayPath> paths;
typedef std::list<DisplayPath>::iterator It;
-
- // collect full names first: path into postfix, empty prefix and
+
+ // collect full names first: path into postfix, empty prefix and
// filename without extension
for (size_t i = 0; i < n; ++i) {
// filename without extension
for (size_t i = 0; i < n; ++i) {
- GuiWorkArea * i_wa = dynamic_cast<GuiWorkArea *>(widget(i));
+ GuiWorkArea * i_wa = dynamic_cast<GuiWorkArea *>(widget(i));
FileName const fn = i_wa->bufferView().buffer().fileName();
paths.push_back(DisplayPath(i, fn));
}
FileName const fn = i_wa->bufferView().buffer().fileName();
paths.push_back(DisplayPath(i, fn));
}
// go through path segments and see if it helps to make the path more unique
bool somethingChanged = true;
bool allFinal = false;
while (somethingChanged && !allFinal) {
// adding path segments changes order
paths.sort();
// go through path segments and see if it helps to make the path more unique
bool somethingChanged = true;
bool allFinal = false;
while (somethingChanged && !allFinal) {
// adding path segments changes order
paths.sort();
LYXERR(Debug::GUI, "updateTabTexts() iteration start");
somethingChanged = false;
allFinal = true;
LYXERR(Debug::GUI, "updateTabTexts() iteration start");
somethingChanged = false;
allFinal = true;
// find segments which are not unique (i.e. non-atomic)
It it = paths.begin();
It segStart = it;
// find segments which are not unique (i.e. non-atomic)
It it = paths.begin();
It segStart = it;
// look to the next item
It next = it;
++next;
// look to the next item
It next = it;
++next;
// final?
allFinal = allFinal && it->final();
// final?
allFinal = allFinal && it->final();
LYXERR(Debug::GUI, "it = " << it->abs()
<< " => " << it->displayString());
LYXERR(Debug::GUI, "it = " << it->abs()
<< " => " << it->displayString());
// still the same segment?
QString nextString;
if ((next != paths.end()
&& (nextString = next->displayString()) == segString))
continue;
LYXERR(Debug::GUI, "segment ended");
// still the same segment?
QString nextString;
if ((next != paths.end()
&& (nextString = next->displayString()) == segString))
continue;
LYXERR(Debug::GUI, "segment ended");
// only a trivial one with one element?
if (it == segStart) {
// start new segment
// only a trivial one with one element?
if (it == segStart) {
// start new segment
segString = nextString;
continue;
}
segString = nextString;
continue;
}
// we found a non-atomic segment segStart <= sit <= it < next.
// Shift path segments and hope for the best
// that it makes the path more unique.
// we found a non-atomic segment segStart <= sit <= it < next.
// Shift path segments and hope for the best
// that it makes the path more unique.
LYXERR(Debug::GUI, "same forecast found for "
<< sit->abs() << " => " << dspString);
}
LYXERR(Debug::GUI, "same forecast found for "
<< sit->abs() << " => " << dspString);
}
// if the path segment helped, add it. Otherwise add dots
bool dots = !moreUnique;
LYXERR(Debug::GUI, "using dots = " << dots);
// if the path segment helped, add it. Otherwise add dots
bool dots = !moreUnique;
LYXERR(Debug::GUI, "using dots = " << dots);
segString = nextString;
}
}
segString = nextString;
}
}
// set new tab titles
for (It it = paths.begin(); it != paths.end(); ++it) {
// set new tab titles
for (It it = paths.begin(); it != paths.end(); ++it) {
- GuiWorkArea * i_wa = dynamic_cast<GuiWorkArea *>(widget(it->tab()));
+ GuiWorkArea * i_wa = dynamic_cast<GuiWorkArea *>(widget(it->tab()));
Buffer & buf = i_wa->bufferView().buffer();
if (!buf.fileName().empty() && !buf.isClean())
setTabText(it->tab(), it->displayString() + "*");
Buffer & buf = i_wa->bufferView().buffer();
if (!buf.fileName().empty() && !buf.isClean())
setTabText(it->tab(), it->displayString() + "*");
clicked_tab_ = static_cast<DragTabBar *>(tabBar())->tabAt(pos);
if (clicked_tab_ == -1)
return;
clicked_tab_ = static_cast<DragTabBar *>(tabBar())->tabAt(pos);
if (clicked_tab_ == -1)
return;
// show tab popup
QMenu popup;
popup.addAction(QIcon(":/images/hidetab.png"),
// show tab popup
QMenu popup;
popup.addAction(QIcon(":/images/hidetab.png"),
insertTab(toIndex, w, icon, text);
setCurrentIndex(toIndex);
}
insertTab(toIndex, w, icon, text);
setCurrentIndex(toIndex);
}
DragTabBar::DragTabBar(QWidget* parent)
: QTabBar(parent)
DragTabBar::DragTabBar(QWidget* parent)
: QTabBar(parent)
// If the left button isn't pressed anymore then return
if (!(event->buttons() & Qt::LeftButton))
return;
// If the left button isn't pressed anymore then return
if (!(event->buttons() & Qt::LeftButton))
return;
// If the distance is too small then return
if ((event->pos() - dragStartPos_).manhattanLength()
< QApplication::startDragDistance())
// If the distance is too small then return
if ((event->pos() - dragStartPos_).manhattanLength()
< QApplication::startDragDistance())
int tab = tabAt(dragStartPos_);
if (tab == -1)
return;
int tab = tabAt(dragStartPos_);
if (tab == -1)
return;
// simulate button release to remove highlight from button
int i = currentIndex();
QMouseEvent me(QEvent::MouseButtonRelease, dragStartPos_,
event->button(), event->buttons(), 0);
QTabBar::mouseReleaseEvent(&me);
setCurrentIndex(i);
// simulate button release to remove highlight from button
int i = currentIndex();
QMouseEvent me(QEvent::MouseButtonRelease, dragStartPos_,
event->button(), event->buttons(), 0);
QTabBar::mouseReleaseEvent(&me);
setCurrentIndex(i);
// initiate Drag
QDrag * drag = new QDrag(this);
QMimeData * mimeData = new QMimeData;
// a crude way to distinguish tab-reodering drops from other ones
mimeData->setData("action", "tab-reordering") ;
drag->setMimeData(mimeData);
// initiate Drag
QDrag * drag = new QDrag(this);
QMimeData * mimeData = new QMimeData;
// a crude way to distinguish tab-reodering drops from other ones
mimeData->setData("action", "tab-reordering") ;
drag->setMimeData(mimeData);
#if QT_VERSION >= 0x040300
// get tab pixmap as cursor
QRect r = tabRect(tab);
#if QT_VERSION >= 0x040300
// get tab pixmap as cursor
QRect r = tabRect(tab);
#else
drag->start(Qt::MoveAction);
#endif
#else
drag->start(Qt::MoveAction);
#endif
// Only accept if it's an tab-reordering request
QMimeData const * m = event->mimeData();
QStringList formats = m->formats();
// Only accept if it's an tab-reordering request
QMimeData const * m = event->mimeData();
QStringList formats = m->formats();
- if (formats.contains("action")
+ if (formats.contains("action")
&& m->data("action") == "tab-reordering")
event->acceptProposedAction();
}
&& m->data("action") == "tab-reordering")
event->acceptProposedAction();
}
{
int fromIndex = tabAt(dragStartPos_);
int toIndex = tabAt(event->pos());
{
int fromIndex = tabAt(dragStartPos_);
int toIndex = tabAt(event->pos());
-
- // Tell interested objects that
+
+ // Tell interested objects that
if (fromIndex != toIndex)
tabMoveRequested(fromIndex, toIndex);
event->acceptProposedAction();
if (fromIndex != toIndex)
tabMoveRequested(fromIndex, toIndex);
event->acceptProposedAction();
}
*/
metricsMarkers2(dim);
}
*/
metricsMarkers2(dim);
- // Cache the inset dimension.
+ // Cache the inset dimension.
dim.wid += 1;
if (display())
dim.des += displayMargin();
dim.wid += 1;
if (display())
dim.des += displayMargin();
- // Cache the inset dimension.
+ // Cache the inset dimension.
setDimCache(mi, dim);
return;
}
setDimCache(mi, dim);
return;
}
else
for (row_type row = 0; row < nrows(); ++row)
numbered(row, !old);
else
for (row_type row = 0; row < nrows(); ++row)
numbered(row, !old);
cur.message(old ? _("No number") : _("Number"));
break;
}
cur.message(old ? _("No number") : _("Number"));
break;
}
}
if (cur.pos() > cur.lastpos())
cur.pos() = cur.lastpos();
}
if (cur.pos() > cur.lastpos())
cur.pos() = cur.lastpos();
// FIXME: find some more clever handling of the selection,
// i.e. preserve it.
cur.clearSelection();
// FIXME: find some more clever handling of the selection,
// i.e. preserve it.
cur.clearSelection();
void InsetMathHull::edit(Cursor & cur, bool front, EntryDirection entry_from)
{
cur.push(*this);
void InsetMathHull::edit(Cursor & cur, bool front, EntryDirection entry_from)
{
cur.push(*this);
- bool enter_front = (entry_from == Inset::ENTRY_DIRECTION_LEFT ||
+ bool enter_front = (entry_from == Inset::ENTRY_DIRECTION_LEFT ||
(entry_from == Inset::ENTRY_DIRECTION_IGNORE && front));
enter_front ? idxFirst(cur) : idxLast(cur);
// The inset formula dimension is not necessarily the same as the
(entry_from == Inset::ENTRY_DIRECTION_IGNORE && front));
enter_front ? idxFirst(cur) : idxLast(cur);
// The inset formula dimension is not necessarily the same as the
cur.insert(arg);
return;
}
cur.insert(arg);
return;
}
// multiple selected cells in a simple non-grid inset
if (i1.asInsetMath()->nrows() == 0 || i1.asInsetMath()->ncols() == 0) {
for (idx_type i = i1.idx(); i <= i2.idx(); ++i) {
// multiple selected cells in a simple non-grid inset
if (i1.asInsetMath()->nrows() == 0 || i1.asInsetMath()->ncols() == 0) {
for (idx_type i = i1.idx(); i <= i2.idx(); ++i) {
cur.resetAnchor();
cur.pos() = cur.lastpos();
cur.setSelection();
cur.resetAnchor();
cur.pos() = cur.lastpos();
cur.setSelection();
// change font of cell
cur.handleNest(nest);
cur.insert(arg);
// change font of cell
cur.handleNest(nest);
cur.insert(arg);
// cur is in the font inset now. If the loop continues,
// we need to get outside again for the next cell
if (i + 1 <= i2.idx())
// cur is in the font inset now. If the loop continues,
// we need to get outside again for the next cell
if (i + 1 <= i2.idx())
// the complicated case with multiple selected cells in a grid
row_type r1, r2;
col_type c1, c2;
// the complicated case with multiple selected cells in a grid
row_type r1, r2;
col_type c1, c2;
cur.resetAnchor();
cur.pos() = cur.lastpos();
cur.setSelection();
cur.resetAnchor();
cur.pos() = cur.lastpos();
cur.setSelection();
cur.handleNest(nest);
cur.insert(arg);
cur.handleNest(nest);
cur.insert(arg);
// cur is in the font inset now. If the loop continues,
// we need to get outside again for the next cell
if (col + 1 <= c2 || row + 1 <= r2)
// cur is in the font inset now. If the loop continues,
// we need to get outside again for the next cell
if (col + 1 <= c2 || row + 1 <= r2)
if (font.fontInfo().color() != Color_inherit &&
font.fontInfo().color() != Color_ignore)
handleNest(cur, MathAtom(new InsetMathColor(true, font.fontInfo().color())));
if (font.fontInfo().color() != Color_inherit &&
font.fontInfo().color() != Color_ignore)
handleNest(cur, MathAtom(new InsetMathColor(true, font.fontInfo().color())));
// FIXME: support other font changes here as well?
}
// FIXME: support other font changes here as well?
}
case LFUN_CHAR_BACKWARD_SELECT:
case LFUN_CHAR_FORWARD_SELECT: {
// are we in a selection?
case LFUN_CHAR_BACKWARD_SELECT:
case LFUN_CHAR_FORWARD_SELECT: {
// are we in a selection?
- bool select = (cmd.action == LFUN_CHAR_RIGHT_SELECT
+ bool select = (cmd.action == LFUN_CHAR_RIGHT_SELECT
|| cmd.action == LFUN_CHAR_LEFT_SELECT
|| cmd.action == LFUN_CHAR_BACKWARD_SELECT
|| cmd.action == LFUN_CHAR_FORWARD_SELECT);
|| cmd.action == LFUN_CHAR_LEFT_SELECT
|| cmd.action == LFUN_CHAR_BACKWARD_SELECT
|| cmd.action == LFUN_CHAR_FORWARD_SELECT);
- // are we moving forward or backwards?
+ // are we moving forward or backwards?
// If the command was RIGHT or LEFT, then whether we're moving forward
// or backwards depends on the cursor movement mode (logical or visual):
// If the command was RIGHT or LEFT, then whether we're moving forward
// or backwards depends on the cursor movement mode (logical or visual):
- // * in visual mode, since math is always LTR, right -> forward,
+ // * in visual mode, since math is always LTR, right -> forward,
// left -> backwards
// * in logical mode, the mapping is determined by the
// reverseDirectionNeeded() function
// left -> backwards
// * in logical mode, the mapping is determined by the
// reverseDirectionNeeded() function
bool forward;
FuncCode finish_lfun;
bool forward;
FuncCode finish_lfun;
- if (cmd.action == LFUN_CHAR_FORWARD
+ if (cmd.action == LFUN_CHAR_FORWARD
|| cmd.action == LFUN_CHAR_FORWARD_SELECT) {
forward = true;
finish_lfun = LFUN_FINISHED_FORWARD;
|| cmd.action == LFUN_CHAR_FORWARD_SELECT) {
forward = true;
finish_lfun = LFUN_FINISHED_FORWARD;
|| cmd.action == LFUN_CHAR_RIGHT);
if (lyxrc.visual_cursor || !reverseDirectionNeeded(cur))
forward = right;
|| cmd.action == LFUN_CHAR_RIGHT);
if (lyxrc.visual_cursor || !reverseDirectionNeeded(cur))
forward = right;
forward = !right;
if (right)
forward = !right;
if (right)
cur.macroModeClose();
break;
}
cur.macroModeClose();
break;
}
// stop/start the selection
bool select = cmd.action == LFUN_DOWN_SELECT ||
cmd.action == LFUN_UP_SELECT;
cur.selHandle(select);
// stop/start the selection
bool select = cmd.action == LFUN_DOWN_SELECT ||
cmd.action == LFUN_UP_SELECT;
cur.selHandle(select);
// go up/down
bool up = cmd.action == LFUN_UP || cmd.action == LFUN_UP_SELECT;
bool successful = cur.upDownInMath(up);
if (successful)
break;
// go up/down
bool up = cmd.action == LFUN_UP || cmd.action == LFUN_UP_SELECT;
bool successful = cur.upDownInMath(up);
if (successful)
break;
if (cur.fixIfBroken())
// FIXME: Something bad happened. We pass the corrected Cursor
// instead of letting things go worse.
if (cur.fixIfBroken())
// FIXME: Something bad happened. We pass the corrected Cursor
// instead of letting things go worse.
case LFUN_WORD_BACKWARD_SELECT:
case LFUN_WORD_LEFT_SELECT:
cur.selHandle(cmd.action == LFUN_WORD_BACKWARD_SELECT ||
case LFUN_WORD_BACKWARD_SELECT:
case LFUN_WORD_LEFT_SELECT:
cur.selHandle(cmd.action == LFUN_WORD_BACKWARD_SELECT ||
- cmd.action == LFUN_WORD_LEFT_SELECT ||
+ cmd.action == LFUN_WORD_LEFT_SELECT ||
cmd.action == LFUN_LINE_BEGIN_SELECT);
cur.macroModeClose();
if (cur.pos() != 0) {
cmd.action == LFUN_LINE_BEGIN_SELECT);
cur.macroModeClose();
if (cur.pos() != 0) {
cur.recordUndoSelection();
interpretChar(cur, '^');
break;
cur.recordUndoSelection();
interpretChar(cur, '^');
break;
case LFUN_MATH_MACRO_FOLD:
case LFUN_MATH_MACRO_UNFOLD: {
Cursor it = cur;
case LFUN_MATH_MACRO_FOLD:
case LFUN_MATH_MACRO_UNFOLD: {
Cursor it = cur;
bool InsetMathNest::findMacroToFoldUnfold(Cursor & it, bool fold) const {
// look for macro to open/close, but stay in mathed
for (; !it.empty(); it.pop_back()) {
bool InsetMathNest::findMacroToFoldUnfold(Cursor & it, bool fold) const {
// look for macro to open/close, but stay in mathed
for (; !it.empty(); it.pop_back()) {
// go backward through the current cell
Inset * inset = it.nextInset();
while (inset && inset->asInsetMath()) {
// go backward through the current cell
Inset * inset = it.nextInset();
while (inset && inset->asInsetMath()) {
// found the an macro to open/close?
if (macro->folded() != fold)
return true;
// found the an macro to open/close?
if (macro->folded() != fold)
return true;
// Wrong folding state.
// If this was the first we see in this slice, look further left,
// otherwise go up.
if (inset != it.nextInset())
break;
}
// Wrong folding state.
// If this was the first we see in this slice, look further left,
// otherwise go up.
if (inset != it.nextInset())
break;
}
// go up if this was the left most position
if (it.pos() == 0)
break;
// go up if this was the left most position
if (it.pos() == 0)
break;
// go left
it.pos()--;
inset = it.nextInset();
}
}
// go left
it.pos()--;
inset = it.nextInset();
}
}
// Don't do this with multi-cell selections
flag.setEnabled(cur.selBegin().idx() == cur.selEnd().idx());
break;
// Don't do this with multi-cell selections
flag.setEnabled(cur.selBegin().idx() == cur.selEnd().idx());
break;
case LFUN_MATH_MACRO_FOLD:
case LFUN_MATH_MACRO_UNFOLD: {
Cursor it = cur;
case LFUN_MATH_MACRO_FOLD:
case LFUN_MATH_MACRO_UNFOLD: {
Cursor it = cur;
flag.setEnabled(found);
break;
}
flag.setEnabled(found);
break;
}
case LFUN_SPECIALCHAR_INSERT:
// FIXME: These would probably make sense in math-text mode
flag.setEnabled(false);
case LFUN_SPECIALCHAR_INSERT:
// FIXME: These would probably make sense in math-text mode
flag.setEnabled(false);
void InsetMathNest::edit(Cursor & cur, bool front, EntryDirection entry_from)
{
cur.push(*this);
void InsetMathNest::edit(Cursor & cur, bool front, EntryDirection entry_from)
{
cur.push(*this);
- bool enter_front = (entry_from == Inset::ENTRY_DIRECTION_RIGHT ||
+ bool enter_front = (entry_from == Inset::ENTRY_DIRECTION_RIGHT ||
(entry_from == Inset::ENTRY_DIRECTION_IGNORE && front));
cur.idx() = enter_front ? 0 : cur.lastidx();
cur.pos() = enter_front ? 0 : cur.lastpos();
(entry_from == Inset::ENTRY_DIRECTION_IGNORE && front));
cur.idx() = enter_front ? 0 : cur.lastidx();
cur.pos() = enter_front ? 0 : cur.lastpos();
// Update::FitCursor: adjust the screen to the cursor
// position if needed
// cur.result().update(): don't overwrite previously set flags.
// Update::FitCursor: adjust the screen to the cursor
// position if needed
// cur.result().update(): don't overwrite previously set flags.
- cur.updateFlags(Update::Decoration | Update::FitCursor
+ cur.updateFlags(Update::Decoration | Update::FitCursor
| cur.result().update());
} else if (cmd.button() == mouse_button::button2) {
if (cap::selection()) {
| cur.result().update());
} else if (cmd.button() == mouse_button::button2) {
if (cap::selection()) {
{
if (!cur.inMacroMode())
return 0;
{
if (!cur.inMacroMode())
return 0;
return new MathCompletionList(cur);
}
return new MathCompletionList(cur);
}
{
if (!cur.inMacroMode())
return docstring();
{
if (!cur.inMacroMode())
return docstring();
return cur.activeMacro()->name();
}
return cur.activeMacro()->name();
}
-void InsetMathNest::completionPosAndDim(Cursor const & cur, int & x, int & y,
+void InsetMathNest::completionPosAndDim(Cursor const & cur, int & x, int & y,
Dimension & dim) const
{
Inset const * inset = cur.activeMacro();
Dimension & dim) const
{
Inset const * inset = cur.activeMacro();
cur.pushBackward(*cur.nextAtom().nucleus());
cur.inset().idxFirst(cur);
return true;
cur.pushBackward(*cur.nextAtom().nucleus());
cur.inset().idxFirst(cur);
return true;
if (cur.posForward() || idxForward(cur))
return true;
// try to pop forwards --- but don't pop out of math! leave that to
if (cur.posForward() || idxForward(cur))
return true;
// try to pop forwards --- but don't pop out of math! leave that to
cur.push(*cur.nextAtom().nucleus());
cur.inset().idxLast(cur);
return true;
cur.push(*cur.nextAtom().nucleus());
cur.inset().idxLast(cur);
return true;
if (cur.posBackward() || idxBackward(cur))
return true;
if (cur.posBackward() || idxBackward(cur))
return true;
- // try to pop backwards --- but don't pop out of math! leave that to
+ // try to pop backwards --- but don't pop out of math! leave that to
// the FINISH lfuns
int s = cur.depth() - 2;
if (s >= 0 && cur[s].inset().asInsetMath())
// the FINISH lfuns
int s = cur.depth() - 2;
if (s >= 0 && cur[s].inset().asInsetMath())
-std::string MathCompletionList::icon(size_t idx) const
+std::string MathCompletionList::icon(size_t idx) const
{
// get the latex command
docstring cmd;
{
// get the latex command
docstring cmd;
cmd = globals[idx - lsize];
else
cmd = locals[idx];
cmd = globals[idx - lsize];
else
cmd = locals[idx];
// get the icon resource name by stripping the backslash
return "images/math/" + to_utf8(cmd.substr(1)) + ".png";
}
// get the icon resource name by stripping the backslash
return "images/math/" + to_utf8(cmd.substr(1)) + ".png";
}
Language const * const par_language = pit->getParLanguage(bparams);
// The document's language
Language const * const doc_language = bparams.language;
Language const * const par_language = pit->getParLanguage(bparams);
// The document's language
Language const * const doc_language = bparams.language;
- // The language that was in effect when the environment this paragraph is
+ // The language that was in effect when the environment this paragraph is
- Language const * const outer_language =
+ Language const * const outer_language =
(runparams.local_font != 0) ?
runparams.local_font->language() : doc_language;
// The previous language that was in effect is either the language of
(runparams.local_font != 0) ?
runparams.local_font->language() : doc_language;
// The previous language that was in effect is either the language of
- // We need to open a new language if we couldn't close the previous
+ // We need to open a new language if we couldn't close the previous
// one (because there's no language_command_end); and even if we closed
// the previous one, if the current language is different than the
// outer_language (which is currently in effect once the previous one
// one (because there's no language_command_end); and even if we closed
// the previous one, if the current language is different than the
// outer_language (which is currently in effect once the previous one
// are we in an inset?
runparams.local_font != 0 &&
// is the inset within an \L or \R?
// are we in an inset?
runparams.local_font != 0 &&
// is the inset within an \L or \R?
// FIXME: currently, we don't check this; this means that
// FIXME: currently, we don't check this; this means that
- // we'll have unnnecessary \L and \R commands, but that
+ // we'll have unnnecessary \L and \R commands, but that
// doesn't seem to hurt (though latex will complain)
// doesn't seem to hurt (though latex will complain)
// is this paragraph in the opposite direction?
runparams.local_font->isRightToLeft() !=
par_language->rightToLeft()
// is this paragraph in the opposite direction?
runparams.local_font->isRightToLeft() !=
par_language->rightToLeft()
// Closing the language is needed for the last paragraph; it is also
// needed if we're within an \L or \R that we may have opened above (not
// necessarily in this paragraph) and are about to close.
// Closing the language is needed for the last paragraph; it is also
// needed if we're within an \L or \R that we may have opened above (not
// necessarily in this paragraph) and are about to close.
- bool closing_rtl_ltr_environment =
+ bool closing_rtl_ltr_environment =
// not for ArabTeX
(par_language->lang() != "arabic_arabtex" &&
outer_language->lang() != "arabic_arabtex") &&
// not for ArabTeX
(par_language->lang() != "arabic_arabtex" &&
outer_language->lang() != "arabic_arabtex") &&
runparams.local_font->isRightToLeft() != par_language->rightToLeft() &&
// are we about to close the language?
((nextpit != paragraphs.end() &&
runparams.local_font->isRightToLeft() != par_language->rightToLeft() &&
// are we about to close the language?
((nextpit != paragraphs.end() &&
- par_language->babel() !=
+ par_language->babel() !=
(nextpit->getParLanguage(bparams))->babel()) ||
(nextpit == paragraphs.end() &&
par_language->babel() != outer_language->babel()));
(nextpit->getParLanguage(bparams))->babel()) ||
(nextpit == paragraphs.end() &&
par_language->babel() != outer_language->babel()));
}
case Encoding::CJK: {
int count = inputenc_arg.length();
}
case Encoding::CJK: {
int count = inputenc_arg.length();
- if (oldEnc.package() == Encoding::CJK &&
+ if (oldEnc.package() == Encoding::CJK &&
open_encoding_ == CJK) {
os << "\\end{CJK}";
count += 9;
}
open_encoding_ == CJK) {
os << "\\end{CJK}";
count += 9;
}
- if (oldEnc.package() == Encoding::inputenc &&
+ if (oldEnc.package() == Encoding::inputenc &&
open_encoding_ == inputenc) {
os << "\\egroup";
count += 7;
open_encoding_ == inputenc) {
os << "\\egroup";
count += 7;