another 100+ lines bite the dust...

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5035 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2002-08-20 15:26:52 +00:00
parent c69f29dda7
commit 1d4154f333
6 changed files with 343 additions and 472 deletions

View File

@ -224,12 +224,6 @@ void BufferView::center()
}
void BufferView::pasteClipboard(bool asPara)
{
pimpl_->pasteClipboard(asPara);
}
string const BufferView::getClipboard() const
{
return pimpl_->workarea().getClipboard();
@ -260,9 +254,3 @@ void BufferView::moveCursorUpdate(bool selecting, bool fitcur = true)
{
pimpl_->moveCursorUpdate(selecting, fitcur);
}
void BufferView::message(string const & msg) const
{
owner()->message(msg);
}

View File

@ -134,8 +134,6 @@ public:
///
bool gotoLabel(string const & label);
///
void message(string const & msg) const;
///
void paste();
///
void cut(bool realcut = true);
@ -156,15 +154,11 @@ public:
///
void setCursorFromRow(int row);
/** Insert an inset into the buffer.
Placie it in a layout of lout,
Place it in a layout of lout,
if no_table make sure that it doesn't end up in a table.
*/
//bool insertInset(Inset * inset, string const & lout = string(),
// bool no_table = false);
bool insertInset(Inset * inset, string const & lout = string());
/** Inserts a lyx file at cursor position.
\return #false# if it fails.
*/
/// Inserts a lyx file at cursor position. return #false# if it fails
bool insertLyXFile(string const & file);
///
bool lockInset(UpdatableInset * inset);
@ -205,8 +199,6 @@ public:
///
string const getClipboard() const;
///
void pasteClipboard(bool asPara);
///
void stuffClipboard(string const &) const;
///
bool dispatch(FuncRequest const & argument);

View File

@ -87,8 +87,6 @@
#include <clocale>
extern string current_layout;
#ifndef CXX_GLOBAL_CSTD
using std::tm;
using std::localtime;
@ -1279,7 +1277,7 @@ void BufferView::Pimpl::switchKeyMap()
LyXText * text = bv_->getLyXText();
if (text->real_current_font.isRightToLeft()
&& !(bv_->theLockingInset()
&& bv_->theLockingInset()->lyxCode()== Inset::ERT_CODE))
&& bv_->theLockingInset()->lyxCode() == Inset::ERT_CODE))
{
if (owner_->getIntl().keymap == Intl::PRIMARY)
owner_->getIntl().KeyMapSec();
@ -1357,29 +1355,6 @@ void BufferView::Pimpl::center()
}
void BufferView::Pimpl::pasteClipboard(bool asPara)
{
if (!buffer_)
return;
screen().hideCursor();
beforeChange(bv_->text);
string const clip(workarea().getClipboard());
if (clip.empty())
return;
if (asPara) {
bv_->getLyXText()->insertStringAsParagraphs(bv_, clip);
} else {
bv_->getLyXText()->insertStringAsLines(bv_, clip);
}
bv_->getLyXText()->clearSelection();
update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
}
void BufferView::Pimpl::stuffClipboard(string const & stuff) const
{
workarea().putClipboard(stuff);
@ -1542,10 +1517,6 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
switchKeyMap();
break;
case LFUN_PASTESELECTION:
pasteClipboard(ev.argument == "paragraph");
break;
case LFUN_CUT:
bv_->cut();
break;
@ -1604,72 +1575,6 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
InsertAsciiFile(bv_, ev.argument, false);
break;
case LFUN_LAYOUT:
{
lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
<< ev.argument << endl;
// This is not the good solution to the empty argument
// problem, but it will hopefully suffice for 1.2.0.
// The correct solution would be to augument the
// function list/array with information about what
// functions needs arguments and their type.
if (ev.argument.empty()) {
owner_->getLyXFunc().setErrorMessage(
_("LyX function 'layout' needs an argument."));
break;
}
// Derive layout number from given argument (string)
// and current buffer's textclass (number). */
bool hasLayout = tclass.hasLayout(ev.argument);
string layout = ev.argument;
// If the entry is obsolete, use the new one instead.
if (hasLayout) {
string const & obs = tclass[layout]->obsoleted_by();
if (!obs.empty())
layout = obs;
}
if (!hasLayout) {
owner_->getLyXFunc().setErrorMessage(
string(N_("Layout ")) + ev.argument +
N_(" not known"));
break;
}
bool change_layout = (current_layout != layout);
LyXText * lt = bv_->getLyXText();
if (!change_layout && lt->selection.set() &&
lt->selection.start.par() != lt->selection.end.par())
{
Paragraph * spar = lt->selection.start.par();
Paragraph * epar = lt->selection.end.par()->next();
while(spar != epar) {
if (spar->layout()->name() != current_layout) {
change_layout = true;
break;
}
}
}
if (change_layout) {
hideCursor();
current_layout = layout;
update(lt,
BufferView::SELECT
| BufferView::FITCUR);
lt->setLayout(bv_, layout);
owner_->setLayout(layout);
update(lt,
BufferView::SELECT
| BufferView::FITCUR
| BufferView::CHANGE);
switchKeyMap();
}
}
break;
case LFUN_LANGUAGE:
lang(bv_, ev.argument);
switchKeyMap();
@ -1775,281 +1680,6 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
}
break;
case LFUN_DELETE:
{
LyXText * lt = bv_->getLyXText();
if (!lt->selection.set()) {
lt->Delete(bv_);
lt->selection.cursor = lt->cursor;
update(lt,
BufferView::SELECT
| BufferView::FITCUR
| BufferView::CHANGE);
// It is possible to make it a lot faster still
// just comment out the line below...
showCursor();
} else {
bv_->cut(false);
}
moveCursorUpdate(false);
owner_->view_state_changed();
switchKeyMap();
}
break;
case LFUN_DELETE_SKIP:
{
LyXText * lt = bv_->getLyXText();
// Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
LyXCursor cursor = lt->cursor;
if (!lt->selection.set()) {
if (cursor.pos() == cursor.par()->size()) {
lt->cursorRight(bv_);
cursor = lt->cursor;
if (cursor.pos() == 0
&& !(cursor.par()->params().spaceTop()
== VSpace (VSpace::NONE))) {
lt->setParagraph
(bv_,
cursor.par()->params().lineTop(),
cursor.par()->params().lineBottom(),
cursor.par()->params().pagebreakTop(),
cursor.par()->params().pagebreakBottom(),
VSpace(VSpace::NONE),
cursor.par()->params().spaceBottom(),
cursor.par()->params().spacing(),
cursor.par()->params().align(),
cursor.par()->params().labelWidthString(), 0);
lt->cursorLeft(bv_);
update(lt,
BufferView::SELECT
| BufferView::FITCUR
| BufferView::CHANGE);
} else {
lt->cursorLeft(bv_);
lt->Delete(bv_);
lt->selection.cursor = lt->cursor;
update(lt,
BufferView::SELECT
| BufferView::FITCUR
| BufferView::CHANGE);
}
} else {
lt->Delete(bv_);
lt->selection.cursor = lt->cursor;
update(lt,
BufferView::SELECT
| BufferView::FITCUR
| BufferView::CHANGE);
}
} else {
bv_->cut(false);
}
}
break;
case LFUN_BACKSPACE:
{
LyXText * lt = bv_->getLyXText();
if (!lt->selection.set()) {
if (owner_->getIntl().getTransManager().backspace()) {
lt->backspace(bv_);
lt->selection.cursor = lt->cursor;
update(lt,
BufferView::SELECT
| BufferView::FITCUR
| BufferView::CHANGE);
// It is possible to make it a lot faster still
// just comment out the line below...
showCursor();
}
} else {
bv_->cut(false);
}
owner_->view_state_changed();
switchKeyMap();
}
break;
case LFUN_BACKSPACE_SKIP:
{
// Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
LyXText * lt = bv_->getLyXText();
LyXCursor cursor = lt->cursor;
if (!lt->selection.set()) {
if (cursor.pos() == 0
&& !(cursor.par()->params().spaceTop()
== VSpace (VSpace::NONE))) {
lt->setParagraph
(bv_,
cursor.par()->params().lineTop(),
cursor.par()->params().lineBottom(),
cursor.par()->params().pagebreakTop(),
cursor.par()->params().pagebreakBottom(),
VSpace(VSpace::NONE), cursor.par()->params().spaceBottom(),
cursor.par()->params().spacing(),
cursor.par()->params().align(),
cursor.par()->params().labelWidthString(), 0);
update(lt,
BufferView::SELECT
| BufferView::FITCUR
| BufferView::CHANGE);
} else {
lt->backspace(bv_);
lt->selection.cursor = cursor;
update(lt,
BufferView::SELECT
| BufferView::FITCUR
| BufferView::CHANGE);
}
} else
bv_->cut(false);
}
break;
case LFUN_BREAKPARAGRAPH:
{
LyXText * lt = bv_->getLyXText();
beforeChange(lt);
lt->breakParagraph(bv_, 0);
update(lt,
BufferView::SELECT
| BufferView::FITCUR
| BufferView::CHANGE);
lt->selection.cursor = lt->cursor;
switchKeyMap();
owner_->view_state_changed();
break;
}
case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
{
LyXText * lt = bv_->getLyXText();
beforeChange(lt);
lt->breakParagraph(bv_, 1);
update(lt,
BufferView::SELECT
| BufferView::FITCUR
| BufferView::CHANGE);
lt->selection.cursor = lt->cursor;
switchKeyMap();
owner_->view_state_changed();
break;
}
case LFUN_BREAKPARAGRAPH_SKIP:
{
// When at the beginning of a paragraph, remove
// indentation and add a "defskip" at the top.
// Otherwise, do the same as LFUN_BREAKPARAGRAPH.
LyXText * lt = bv_->getLyXText();
LyXCursor cursor = lt->cursor;
beforeChange(lt);
if (cursor.pos() == 0) {
if (cursor.par()->params().spaceTop() == VSpace(VSpace::NONE)) {
lt->setParagraph
(bv_,
cursor.par()->params().lineTop(),
cursor.par()->params().lineBottom(),
cursor.par()->params().pagebreakTop(),
cursor.par()->params().pagebreakBottom(),
VSpace(VSpace::DEFSKIP), cursor.par()->params().spaceBottom(),
cursor.par()->params().spacing(),
cursor.par()->params().align(),
cursor.par()->params().labelWidthString(), 1);
//update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
}
}
else {
lt->breakParagraph(bv_, 0);
//update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
}
update(lt,
BufferView::SELECT
| BufferView::FITCUR
| BufferView::CHANGE);
lt->selection.cursor = cursor;
switchKeyMap();
owner_->view_state_changed();
}
break;
case LFUN_PARAGRAPH_SPACING:
{
LyXText * lt = bv_->getLyXText();
Paragraph * par = lt->cursor.par();
Spacing::Space cur_spacing = par->params().spacing().getSpace();
float cur_value = 1.0;
if (cur_spacing == Spacing::Other) {
cur_value = par->params().spacing().getValue();
}
istringstream istr(ev.argument.c_str());
string tmp;
istr >> tmp;
Spacing::Space new_spacing = cur_spacing;
float new_value = cur_value;
if (tmp.empty()) {
lyxerr << "Missing argument to `paragraph-spacing'"
<< endl;
} else if (tmp == "single") {
new_spacing = Spacing::Single;
} else if (tmp == "onehalf") {
new_spacing = Spacing::Onehalf;
} else if (tmp == "double") {
new_spacing = Spacing::Double;
} else if (tmp == "other") {
new_spacing = Spacing::Other;
float tmpval = 0.0;
istr >> tmpval;
lyxerr << "new_value = " << tmpval << endl;
if (tmpval != 0.0)
new_value = tmpval;
} else if (tmp == "default") {
new_spacing = Spacing::Default;
} else {
lyxerr << _("Unknown spacing argument: ")
<< ev.argument << endl;
}
if (cur_spacing != new_spacing || cur_value != new_value) {
par->params().spacing(Spacing(new_spacing, new_value));
lt->redoParagraph(bv_);
update(lt,
BufferView::SELECT
| BufferView::FITCUR
| BufferView::CHANGE);
}
}
break;
case LFUN_INSET_TOGGLE:
{
LyXText * lt = bv_->getLyXText();
hideCursor();
beforeChange(lt);
update(lt, BufferView::SELECT|BufferView::FITCUR);
lt->toggleInset(bv_);
update(lt, BufferView::SELECT|BufferView::FITCUR);
switchKeyMap();
}
break;
case LFUN_QUOTE:
smartQuote();
break;
@ -2289,9 +1919,8 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
case LFUN_INDEX_INSERT:
{
string entry = ev.argument;
if (entry.empty()) {
if (entry.empty())
entry = bv_->getLyXText()->getStringToIndex(bv_);
}
if (entry.empty()) {
owner_->getDialogs().createIndex();
@ -2405,7 +2034,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
break;
case LFUN_UNKNOWN_ACTION:
owner_->getLyXFunc().setErrorMessage(N_("Unknown function!"));
ev.errorMessage(N_("Unknown function!"));
break;
default:
@ -2651,9 +2280,3 @@ void BufferView::Pimpl::gotoInset(Inset::Code code, bool same_content)
{
gotoInset(vector<Inset::Code>(1, code), same_content);
}
void BufferView::Pimpl::message(string const & msg)
{
bv_->owner()->getLyXFunc().setMessage(msg);
}

View File

@ -127,8 +127,6 @@ struct BufferView::Pimpl : public boost::signals::trackable {
void updateInset(Inset * inset, bool mark_dirty);
///
bool dispatch(FuncRequest const & ev);
///
void message(string const & msg);
private:
/**
* Return the on-screen dimensions of the inset at the cursor.
@ -170,8 +168,6 @@ private:
///
Timeout cursor_timeout;
///
void pasteClipboard(bool asPara);
///
void stuffClipboard(string const &) const;
///
bool using_xterm_cursor;

View File

@ -60,6 +60,10 @@ public:
///
void push_back(Paragraph *);
///
Paragraph const * back() const;
///
Paragraph * back();
///
int size() const;
///
bool empty() const;

View File

@ -29,6 +29,9 @@
#include "insets/insettext.h"
extern string current_layout;
void LyXText::update(BufferView * bv, bool changed)
{
BufferView::UpdateCodes c = BufferView::SELECT | BufferView::FITCUR;
@ -75,7 +78,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
updateCounters(cmd.view());
setCursor(cmd.view(), cursor.par(), cursor.pos());
update(bv);
return Inset::DISPATCHED;
break;
}
case LFUN_DELETE_WORD_FORWARD:
@ -84,7 +87,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
deleteWordForward(bv);
update(bv);
bv->finishChange();
return Inset::DISPATCHED;
break;
case LFUN_DELETE_WORD_BACKWARD:
bv->beforeChange(this);
@ -92,7 +95,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
deleteWordBackward(bv);
update(bv, true);
bv->finishChange();
return Inset::DISPATCHED;
break;
case LFUN_DELETE_LINE_FORWARD:
bv->beforeChange(this);
@ -100,7 +103,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
deleteLineForward(bv);
update(bv);
bv->finishChange();
return Inset::DISPATCHED;
break;
case LFUN_SHIFT_TAB:
case LFUN_TAB:
@ -109,7 +112,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
update(bv, false);
cursorTab(bv);
bv->finishChange();
return Inset::DISPATCHED;
break;
case LFUN_WORDRIGHT:
if (!selection.mark())
@ -120,7 +123,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
else
cursorRightOneWord(bv);
bv->finishChange();
return Inset::DISPATCHED;
break;
case LFUN_WORDLEFT:
if (!selection.mark())
@ -131,7 +134,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
else
cursorLeftOneWord(bv);
bv->finishChange();
return Inset::DISPATCHED;
break;
case LFUN_BEGINNINGBUF:
if (!selection.mark())
@ -139,7 +142,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
update(bv, false);
cursorTop(bv);
bv->finishChange();
return Inset::DISPATCHED;
break;
case LFUN_ENDBUF:
if (selection.mark())
@ -147,7 +150,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
update(bv, false);
cursorBottom(bv);
bv->finishChange();
return Inset::DISPATCHED;
break;
case LFUN_RIGHTSEL:
update(bv, false);
@ -156,7 +159,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
else
cursorRight(bv);
bv->finishChange(true);
return Inset::DISPATCHED;
break;
case LFUN_LEFTSEL:
update(bv, false);
@ -165,55 +168,55 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
else
cursorLeft(bv);
bv->finishChange(true);
return Inset::DISPATCHED;
break;
case LFUN_UPSEL:
update(bv, false);
cursorUp(bv, true);
bv->finishChange(true);
return Inset::DISPATCHED;
break;
case LFUN_DOWNSEL:
update(bv, false);
cursorDown(bv, true);
bv->finishChange(true);
return Inset::DISPATCHED;
break;
case LFUN_UP_PARAGRAPHSEL:
update(bv, false);
cursorUpParagraph(bv);
bv->finishChange(true);
return Inset::DISPATCHED;
break;
case LFUN_DOWN_PARAGRAPHSEL:
update(bv, false);
cursorDownParagraph(bv);
bv->finishChange(true);
return Inset::DISPATCHED;
break;
case LFUN_PRIORSEL:
update(bv, false);
bv->cursorPrevious(this);
bv->finishChange(true);
return Inset::DISPATCHED;
break;
case LFUN_NEXTSEL:
update(bv, false);
bv->cursorNext(this);
bv->finishChange();
return Inset::DISPATCHED;
break;
case LFUN_HOMESEL:
update(bv, false);
cursorHome(bv);
bv->finishChange(true);
return Inset::DISPATCHED;
break;
case LFUN_ENDSEL:
update(bv, false);
cursorEnd(bv);
bv->finishChange(true);
return Inset::DISPATCHED;
break;
case LFUN_WORDRIGHTSEL:
update(bv, false);
@ -222,7 +225,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
else
cursorRightOneWord(bv);
bv->finishChange(true);
return Inset::DISPATCHED;
break;
case LFUN_WORDLEFTSEL:
update(bv, false);
@ -231,7 +234,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
else
cursorLeftOneWord(bv);
bv->finishChange(true);
return Inset::DISPATCHED;
break;
case LFUN_RIGHT: {
bool is_rtl = cursor.par()->isRightToLeftPar(bv->buffer()->params);
@ -245,16 +248,13 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
&& isHighlyEditableInset(cursor.par()->getInset(cursor.pos()))) {
Inset * tmpinset = cursor.par()->getInset(cursor.pos());
cmd.message(tmpinset->editMessage());
if (is_rtl)
tmpinset->edit(bv, false);
else
tmpinset->edit(bv);
return Inset::DISPATCHED;
tmpinset->edit(bv, !is_rtl);
break;
}
if (!is_rtl)
cursorRight(bv, false);
bv->finishChange(false);
return Inset::DISPATCHED;
break;
}
case LFUN_LEFT: {
@ -273,17 +273,13 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
isHighlyEditableInset(cursor.par()->getInset(cursor.pos()))) {
Inset * tmpinset = cursor.par()->getInset(cursor.pos());
cmd.message(tmpinset->editMessage());
if (is_rtl)
tmpinset->edit(bv);
else
tmpinset->edit(bv, false);
tmpinset->edit(bv, is_rtl);
break;
return Inset::DISPATCHED;
}
if (is_rtl)
cursorRight(bv, false);
bv->finishChange(false);
return Inset::DISPATCHED;
break;
}
case LFUN_UP:
@ -292,7 +288,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
bv->update(this, BufferView::UPDATE);
cursorUp(bv);
bv->finishChange(false);
return Inset::DISPATCHED;
break;
case LFUN_DOWN:
if (!selection.mark())
@ -300,7 +296,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
bv->update(this, BufferView::UPDATE);
cursorDown(bv);
bv->finishChange();
return Inset::DISPATCHED;
break;
case LFUN_UP_PARAGRAPH:
if (!selection.mark())
@ -308,7 +304,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
bv->update(this, BufferView::UPDATE);
cursorUpParagraph(bv);
bv->finishChange();
return Inset::DISPATCHED;
break;
case LFUN_DOWN_PARAGRAPH:
if (!selection.mark())
@ -316,7 +312,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
bv->update(this, BufferView::UPDATE);
cursorDownParagraph(bv);
bv->finishChange(false);
return Inset::DISPATCHED;
break;
case LFUN_PRIOR:
if (!selection.mark())
@ -328,7 +324,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
// finishUndo();
// moveCursorUpdate(false, false);
// owner_->view_state_changed();
return Inset::DISPATCHED;
break;
case LFUN_NEXT:
if (!selection.mark())
@ -336,7 +332,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
bv->update(this, BufferView::UPDATE);
bv->cursorNext(this);
bv->finishChange(false);
return Inset::DISPATCHED;
break;
case LFUN_HOME:
if (!selection.mark())
@ -344,7 +340,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
update(bv);
cursorHome(bv);
bv->finishChange(false);
return Inset::DISPATCHED;
break;
case LFUN_END:
if (!selection.mark())
@ -352,7 +348,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
update(bv);
cursorEnd(bv);
bv->finishChange(false);
return Inset::DISPATCHED;
break;
case LFUN_BREAKLINE:
bv->beforeChange(this);
@ -360,7 +356,203 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
update(bv, true);
setCursor(bv, cursor.par(), cursor.pos());
bv->moveCursorUpdate(false);
return Inset::DISPATCHED;
break;
case LFUN_DELETE:
if (!selection.set()) {
Delete(bv);
selection.cursor = cursor;
update(bv);
// It is possible to make it a lot faster still
// just comment out the line below...
bv->showCursor();
} else {
bv->cut(false);
}
bv->moveCursorUpdate(false);
bv->owner()->view_state_changed();
bv->switchKeyMap();
break;
case LFUN_DELETE_SKIP:
// Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
if (!selection.set()) {
LyXCursor cur = cursor;
if (cur.pos() == cur.par()->size()) {
cursorRight(bv);
cur = cursor;
if (cur.pos() == 0
&& !(cur.par()->params().spaceTop()
== VSpace (VSpace::NONE))) {
setParagraph(bv,
cur.par()->params().lineTop(),
cur.par()->params().lineBottom(),
cur.par()->params().pagebreakTop(),
cur.par()->params().pagebreakBottom(),
VSpace(VSpace::NONE),
cur.par()->params().spaceBottom(),
cur.par()->params().spacing(),
cur.par()->params().align(),
cur.par()->params().labelWidthString(), 0);
cursorLeft(bv);
update(bv);
} else {
cursorLeft(bv);
Delete(bv);
selection.cursor = cursor;
update(bv);
}
} else {
Delete(bv);
selection.cursor = cursor;
update(bv);
}
} else
bv->cut(false);
break;
case LFUN_BACKSPACE:
if (!selection.set()) {
if (bv->owner()->getIntl().getTransManager().backspace()) {
backspace(bv);
selection.cursor = cursor;
update(bv);
// It is possible to make it a lot faster still
// just comment out the line below...
bv->showCursor();
}
} else
bv->cut(false);
bv->owner()->view_state_changed();
bv->switchKeyMap();
break;
case LFUN_BACKSPACE_SKIP:
// Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
if (!selection.set()) {
LyXCursor cur = cursor;
if (cur.pos() == 0
&& !(cur.par()->params().spaceTop()
== VSpace (VSpace::NONE))) {
setParagraph(bv,
cur.par()->params().lineTop(),
cur.par()->params().lineBottom(),
cur.par()->params().pagebreakTop(),
cur.par()->params().pagebreakBottom(),
VSpace(VSpace::NONE), cur.par()->params().spaceBottom(),
cur.par()->params().spacing(),
cur.par()->params().align(),
cur.par()->params().labelWidthString(), 0);
update(bv);
} else {
backspace(bv);
selection.cursor = cur;
update(bv);
}
} else
bv->cut(false);
break;
case LFUN_BREAKPARAGRAPH:
bv->beforeChange(this);
breakParagraph(bv, 0);
update(bv);
selection.cursor = cursor;
bv->switchKeyMap();
bv->owner()->view_state_changed();
break;
case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
bv->beforeChange(this);
breakParagraph(bv, 1);
update(bv);
selection.cursor = cursor;
bv->switchKeyMap();
bv->owner()->view_state_changed();
break;
case LFUN_BREAKPARAGRAPH_SKIP: {
// When at the beginning of a paragraph, remove
// indentation and add a "defskip" at the top.
// Otherwise, do the same as LFUN_BREAKPARAGRAPH.
LyXCursor cur = cursor;
bv->beforeChange(this);
if (cur.pos() == 0) {
if (cur.par()->params().spaceTop() == VSpace(VSpace::NONE)) {
setParagraph(bv,
cur.par()->params().lineTop(),
cur.par()->params().lineBottom(),
cur.par()->params().pagebreakTop(),
cur.par()->params().pagebreakBottom(),
VSpace(VSpace::DEFSKIP), cur.par()->params().spaceBottom(),
cur.par()->params().spacing(),
cur.par()->params().align(),
cur.par()->params().labelWidthString(), 1);
//update(bv);
}
}
else {
breakParagraph(bv, 0);
//update(bv);
}
update(bv);
selection.cursor = cur;
bv->switchKeyMap();
bv->owner()->view_state_changed();
break;
}
case LFUN_PARAGRAPH_SPACING: {
Paragraph * par = cursor.par();
Spacing::Space cur_spacing = par->params().spacing().getSpace();
float cur_value = 1.0;
if (cur_spacing == Spacing::Other)
cur_value = par->params().spacing().getValue();
istringstream is(cmd.argument.c_str());
string tmp;
is >> tmp;
Spacing::Space new_spacing = cur_spacing;
float new_value = cur_value;
if (tmp.empty()) {
lyxerr << "Missing argument to `paragraph-spacing'"
<< endl;
} else if (tmp == "single") {
new_spacing = Spacing::Single;
} else if (tmp == "onehalf") {
new_spacing = Spacing::Onehalf;
} else if (tmp == "double") {
new_spacing = Spacing::Double;
} else if (tmp == "other") {
new_spacing = Spacing::Other;
float tmpval = 0.0;
is >> tmpval;
lyxerr << "new_value = " << tmpval << endl;
if (tmpval != 0.0)
new_value = tmpval;
} else if (tmp == "default") {
new_spacing = Spacing::Default;
} else {
lyxerr << _("Unknown spacing argument: ")
<< cmd.argument << endl;
}
if (cur_spacing != new_spacing || cur_value != new_value) {
par->params().spacing(Spacing(new_spacing, new_value));
redoParagraph(bv);
update(bv);
}
break;
}
case LFUN_INSET_TOGGLE:
bv->hideCursor();
bv->beforeChange(this);
update(bv, false);
toggleInset(bv);
update(bv, false);
bv->switchKeyMap();
break;
case LFUN_PROTECTEDSPACE:
if (cursor.par()->layout()->free_spacing) {
@ -370,41 +562,41 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
specialChar(this, bv, InsetSpecialChar::PROTECTED_SEPARATOR);
}
bv->moveCursorUpdate(false);
return Inset::DISPATCHED;
break;
case LFUN_HYPHENATION:
specialChar(this, bv, InsetSpecialChar::HYPHENATION);
return Inset::DISPATCHED;
break;
case LFUN_LIGATURE_BREAK:
specialChar(this, bv, InsetSpecialChar::LIGATURE_BREAK);
return Inset::DISPATCHED;
break;
case LFUN_LDOTS:
specialChar(this, bv, InsetSpecialChar::LDOTS);
return Inset::DISPATCHED;
break;
case LFUN_HFILL:
bv->hideCursor();
update(bv, false);
insertChar(bv, Paragraph::META_HFILL);
update(bv);
return Inset::DISPATCHED;
break;
case LFUN_END_OF_SENTENCE:
specialChar(this, bv, InsetSpecialChar::END_OF_SENTENCE);
return Inset::DISPATCHED;
break;
case LFUN_MENU_SEPARATOR:
specialChar(this, bv, InsetSpecialChar::MENU_SEPARATOR);
return Inset::DISPATCHED;
break;
case LFUN_MARK_OFF:
bv->beforeChange(this);
update(bv, false);
selection.cursor = cursor;
cmd.message(N_("Mark off"));
return Inset::DISPATCHED;
break;
case LFUN_MARK_ON:
bv->beforeChange(this);
@ -412,7 +604,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
update(bv, false);
selection.cursor = cursor;
cmd.message(N_("Mark on"));
return Inset::DISPATCHED;
break;
case LFUN_SETMARK:
bv->beforeChange(this);
@ -425,7 +617,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
cmd.message(N_("Mark set"));
}
selection.cursor = cursor;
return Inset::DISPATCHED;
break;
case LFUN_UPCASE_WORD:
update(bv, false);
@ -433,7 +625,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
if (inset_owner)
bv->updateInset(inset_owner, true);
update(bv);
return Inset::DISPATCHED;
break;
case LFUN_LOWCASE_WORD:
update(bv, false);
@ -441,7 +633,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
if (inset_owner)
bv->updateInset(inset_owner, true);
update(bv);
return Inset::DISPATCHED;
break;
case LFUN_CAPITALIZE_WORD:
update(bv, false);
@ -449,7 +641,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
if (inset_owner)
bv->updateInset(inset_owner, true);
update(bv);
return Inset::DISPATCHED;
break;
case LFUN_TRANSPOSE_CHARS:
update(bv, false);
@ -457,7 +649,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
if (inset_owner)
bv->updateInset(inset_owner, true);
update(bv);
return Inset::DISPATCHED;
break;
case LFUN_BEGINNINGBUFSEL:
if (inset_owner)
@ -465,7 +657,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
update(bv, false);
cursorTop(bv);
bv->finishChange(true);
return Inset::DISPATCHED;
break;
case LFUN_ENDBUFSEL:
if (inset_owner)
@ -473,11 +665,11 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
update(bv, false);
cursorBottom(bv);
bv->finishChange(true);
return Inset::DISPATCHED;
break;
case LFUN_GETXY:
cmd.message(tostr(cursor.x()) + ' ' + tostr(cursor.y()));
return Inset::DISPATCHED;
break;
case LFUN_SETXY: {
int x = 0;
@ -486,7 +678,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
lyxerr << "SETXY: Could not parse coordinates in '"
<< cmd.argument << std::endl;
setCursorFromCoordinates(bv, x, y);
return Inset::DISPATCHED;
break;
}
case LFUN_GETFONT:
@ -496,15 +688,92 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
cmd.message("N");
else
cmd.message("0");
return Inset::DISPATCHED;
break;
case LFUN_GETLAYOUT:
cmd.message(tostr(cursor.par()->layout()));
return Inset::DISPATCHED;
break;
case LFUN_LAYOUT: {
lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
<< cmd.argument << endl;
// This is not the good solution to the empty argument
// problem, but it will hopefully suffice for 1.2.0.
// The correct solution would be to augument the
// function list/array with information about what
// functions needs arguments and their type.
if (cmd.argument.empty()) {
cmd.errorMessage(_("LyX function 'layout' needs an argument."));
break;
}
// Derive layout number from given argument (string)
// and current buffer's textclass (number)
LyXTextClass const & tclass = bv->buffer()->params.getLyXTextClass();
bool hasLayout = tclass.hasLayout(cmd.argument);
string layout = cmd.argument;
// If the entry is obsolete, use the new one instead.
if (hasLayout) {
string const & obs = tclass[layout]->obsoleted_by();
if (!obs.empty())
layout = obs;
}
if (!hasLayout) {
cmd.errorMessage(string(N_("Layout ")) + cmd.argument +
N_(" not known"));
break;
}
bool change_layout = (current_layout != layout);
if (!change_layout && selection.set() &&
selection.start.par() != selection.end.par())
{
Paragraph * spar = selection.start.par();
Paragraph * epar = selection.end.par()->next();
while (spar != epar) {
if (spar->layout()->name() != current_layout) {
change_layout = true;
break;
}
}
}
if (change_layout) {
bv->hideCursor();
current_layout = layout;
update(bv, false);
setLayout(bv, layout);
bv->owner()->setLayout(layout);
update(bv);
bv->switchKeyMap();
}
break;
}
case LFUN_PASTESELECTION: {
if (!bv->buffer())
break;
bv->hideCursor();
// this was originally a beforeChange(bv->text), i.e
// the outermost LyXText!
bv->beforeChange(this);
string const clip(bv->workarea().getClipboard());
if (!clip.empty()) {
if (cmd.argument == "paragraph")
insertStringAsParagraphs(bv, clip);
else
insertStringAsLines(bv, clip);
clearSelection();
update(bv);
}
break;
}
case LFUN_SELFINSERT: {
if (cmd.argument.empty())
return Inset::DISPATCHED;
break;
// Automatically delete the currently selected
// text and replace it with what is being
@ -537,13 +806,12 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
// update the minibuffer
if (old_font != real_current_font)
bv->owner()->view_state_changed();
return Inset::DISPATCHED;
break;
}
default:
return Inset::UNDISPATCHED;
}
// shut up compiler
return Inset::UNDISPATCHED;
return Inset::DISPATCHED;
}