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 string const BufferView::getClipboard() const
{ {
return pimpl_->workarea().getClipboard(); return pimpl_->workarea().getClipboard();
@ -260,9 +254,3 @@ void BufferView::moveCursorUpdate(bool selecting, bool fitcur = true)
{ {
pimpl_->moveCursorUpdate(selecting, fitcur); 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); bool gotoLabel(string const & label);
/// ///
void message(string const & msg) const;
///
void paste(); void paste();
/// ///
void cut(bool realcut = true); void cut(bool realcut = true);
@ -156,15 +154,11 @@ public:
/// ///
void setCursorFromRow(int row); void setCursorFromRow(int row);
/** Insert an inset into the buffer. /** 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. 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()); bool insertInset(Inset * inset, string const & lout = string());
/** Inserts a lyx file at cursor position. /// Inserts a lyx file at cursor position. return #false# if it fails
\return #false# if it fails.
*/
bool insertLyXFile(string const & file); bool insertLyXFile(string const & file);
/// ///
bool lockInset(UpdatableInset * inset); bool lockInset(UpdatableInset * inset);
@ -205,8 +199,6 @@ public:
/// ///
string const getClipboard() const; string const getClipboard() const;
/// ///
void pasteClipboard(bool asPara);
///
void stuffClipboard(string const &) const; void stuffClipboard(string const &) const;
/// ///
bool dispatch(FuncRequest const & argument); bool dispatch(FuncRequest const & argument);

View File

@ -87,8 +87,6 @@
#include <clocale> #include <clocale>
extern string current_layout;
#ifndef CXX_GLOBAL_CSTD #ifndef CXX_GLOBAL_CSTD
using std::tm; using std::tm;
using std::localtime; using std::localtime;
@ -1279,7 +1277,7 @@ void BufferView::Pimpl::switchKeyMap()
LyXText * text = bv_->getLyXText(); LyXText * text = bv_->getLyXText();
if (text->real_current_font.isRightToLeft() if (text->real_current_font.isRightToLeft()
&& !(bv_->theLockingInset() && !(bv_->theLockingInset()
&& bv_->theLockingInset()->lyxCode()== Inset::ERT_CODE)) && bv_->theLockingInset()->lyxCode() == Inset::ERT_CODE))
{ {
if (owner_->getIntl().keymap == Intl::PRIMARY) if (owner_->getIntl().keymap == Intl::PRIMARY)
owner_->getIntl().KeyMapSec(); 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 void BufferView::Pimpl::stuffClipboard(string const & stuff) const
{ {
workarea().putClipboard(stuff); workarea().putClipboard(stuff);
@ -1542,10 +1517,6 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
switchKeyMap(); switchKeyMap();
break; break;
case LFUN_PASTESELECTION:
pasteClipboard(ev.argument == "paragraph");
break;
case LFUN_CUT: case LFUN_CUT:
bv_->cut(); bv_->cut();
break; break;
@ -1604,72 +1575,6 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
InsertAsciiFile(bv_, ev.argument, false); InsertAsciiFile(bv_, ev.argument, false);
break; 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: case LFUN_LANGUAGE:
lang(bv_, ev.argument); lang(bv_, ev.argument);
switchKeyMap(); switchKeyMap();
@ -1775,281 +1680,6 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
} }
break; 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: case LFUN_QUOTE:
smartQuote(); smartQuote();
break; break;
@ -2289,9 +1919,8 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
case LFUN_INDEX_INSERT: case LFUN_INDEX_INSERT:
{ {
string entry = ev.argument; string entry = ev.argument;
if (entry.empty()) { if (entry.empty())
entry = bv_->getLyXText()->getStringToIndex(bv_); entry = bv_->getLyXText()->getStringToIndex(bv_);
}
if (entry.empty()) { if (entry.empty()) {
owner_->getDialogs().createIndex(); owner_->getDialogs().createIndex();
@ -2405,7 +2034,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
break; break;
case LFUN_UNKNOWN_ACTION: case LFUN_UNKNOWN_ACTION:
owner_->getLyXFunc().setErrorMessage(N_("Unknown function!")); ev.errorMessage(N_("Unknown function!"));
break; break;
default: default:
@ -2651,9 +2280,3 @@ void BufferView::Pimpl::gotoInset(Inset::Code code, bool same_content)
{ {
gotoInset(vector<Inset::Code>(1, code), 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); void updateInset(Inset * inset, bool mark_dirty);
/// ///
bool dispatch(FuncRequest const & ev); bool dispatch(FuncRequest const & ev);
///
void message(string const & msg);
private: private:
/** /**
* Return the on-screen dimensions of the inset at the cursor. * Return the on-screen dimensions of the inset at the cursor.
@ -170,8 +168,6 @@ private:
/// ///
Timeout cursor_timeout; Timeout cursor_timeout;
/// ///
void pasteClipboard(bool asPara);
///
void stuffClipboard(string const &) const; void stuffClipboard(string const &) const;
/// ///
bool using_xterm_cursor; bool using_xterm_cursor;

View File

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

View File

@ -29,6 +29,9 @@
#include "insets/insettext.h" #include "insets/insettext.h"
extern string current_layout;
void LyXText::update(BufferView * bv, bool changed) void LyXText::update(BufferView * bv, bool changed)
{ {
BufferView::UpdateCodes c = BufferView::SELECT | BufferView::FITCUR; BufferView::UpdateCodes c = BufferView::SELECT | BufferView::FITCUR;
@ -75,7 +78,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
updateCounters(cmd.view()); updateCounters(cmd.view());
setCursor(cmd.view(), cursor.par(), cursor.pos()); setCursor(cmd.view(), cursor.par(), cursor.pos());
update(bv); update(bv);
return Inset::DISPATCHED; break;
} }
case LFUN_DELETE_WORD_FORWARD: case LFUN_DELETE_WORD_FORWARD:
@ -84,7 +87,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
deleteWordForward(bv); deleteWordForward(bv);
update(bv); update(bv);
bv->finishChange(); bv->finishChange();
return Inset::DISPATCHED; break;
case LFUN_DELETE_WORD_BACKWARD: case LFUN_DELETE_WORD_BACKWARD:
bv->beforeChange(this); bv->beforeChange(this);
@ -92,7 +95,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
deleteWordBackward(bv); deleteWordBackward(bv);
update(bv, true); update(bv, true);
bv->finishChange(); bv->finishChange();
return Inset::DISPATCHED; break;
case LFUN_DELETE_LINE_FORWARD: case LFUN_DELETE_LINE_FORWARD:
bv->beforeChange(this); bv->beforeChange(this);
@ -100,7 +103,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
deleteLineForward(bv); deleteLineForward(bv);
update(bv); update(bv);
bv->finishChange(); bv->finishChange();
return Inset::DISPATCHED; break;
case LFUN_SHIFT_TAB: case LFUN_SHIFT_TAB:
case LFUN_TAB: case LFUN_TAB:
@ -109,7 +112,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
update(bv, false); update(bv, false);
cursorTab(bv); cursorTab(bv);
bv->finishChange(); bv->finishChange();
return Inset::DISPATCHED; break;
case LFUN_WORDRIGHT: case LFUN_WORDRIGHT:
if (!selection.mark()) if (!selection.mark())
@ -120,7 +123,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
else else
cursorRightOneWord(bv); cursorRightOneWord(bv);
bv->finishChange(); bv->finishChange();
return Inset::DISPATCHED; break;
case LFUN_WORDLEFT: case LFUN_WORDLEFT:
if (!selection.mark()) if (!selection.mark())
@ -131,7 +134,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
else else
cursorLeftOneWord(bv); cursorLeftOneWord(bv);
bv->finishChange(); bv->finishChange();
return Inset::DISPATCHED; break;
case LFUN_BEGINNINGBUF: case LFUN_BEGINNINGBUF:
if (!selection.mark()) if (!selection.mark())
@ -139,7 +142,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
update(bv, false); update(bv, false);
cursorTop(bv); cursorTop(bv);
bv->finishChange(); bv->finishChange();
return Inset::DISPATCHED; break;
case LFUN_ENDBUF: case LFUN_ENDBUF:
if (selection.mark()) if (selection.mark())
@ -147,7 +150,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
update(bv, false); update(bv, false);
cursorBottom(bv); cursorBottom(bv);
bv->finishChange(); bv->finishChange();
return Inset::DISPATCHED; break;
case LFUN_RIGHTSEL: case LFUN_RIGHTSEL:
update(bv, false); update(bv, false);
@ -156,7 +159,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
else else
cursorRight(bv); cursorRight(bv);
bv->finishChange(true); bv->finishChange(true);
return Inset::DISPATCHED; break;
case LFUN_LEFTSEL: case LFUN_LEFTSEL:
update(bv, false); update(bv, false);
@ -165,55 +168,55 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
else else
cursorLeft(bv); cursorLeft(bv);
bv->finishChange(true); bv->finishChange(true);
return Inset::DISPATCHED; break;
case LFUN_UPSEL: case LFUN_UPSEL:
update(bv, false); update(bv, false);
cursorUp(bv, true); cursorUp(bv, true);
bv->finishChange(true); bv->finishChange(true);
return Inset::DISPATCHED; break;
case LFUN_DOWNSEL: case LFUN_DOWNSEL:
update(bv, false); update(bv, false);
cursorDown(bv, true); cursorDown(bv, true);
bv->finishChange(true); bv->finishChange(true);
return Inset::DISPATCHED; break;
case LFUN_UP_PARAGRAPHSEL: case LFUN_UP_PARAGRAPHSEL:
update(bv, false); update(bv, false);
cursorUpParagraph(bv); cursorUpParagraph(bv);
bv->finishChange(true); bv->finishChange(true);
return Inset::DISPATCHED; break;
case LFUN_DOWN_PARAGRAPHSEL: case LFUN_DOWN_PARAGRAPHSEL:
update(bv, false); update(bv, false);
cursorDownParagraph(bv); cursorDownParagraph(bv);
bv->finishChange(true); bv->finishChange(true);
return Inset::DISPATCHED; break;
case LFUN_PRIORSEL: case LFUN_PRIORSEL:
update(bv, false); update(bv, false);
bv->cursorPrevious(this); bv->cursorPrevious(this);
bv->finishChange(true); bv->finishChange(true);
return Inset::DISPATCHED; break;
case LFUN_NEXTSEL: case LFUN_NEXTSEL:
update(bv, false); update(bv, false);
bv->cursorNext(this); bv->cursorNext(this);
bv->finishChange(); bv->finishChange();
return Inset::DISPATCHED; break;
case LFUN_HOMESEL: case LFUN_HOMESEL:
update(bv, false); update(bv, false);
cursorHome(bv); cursorHome(bv);
bv->finishChange(true); bv->finishChange(true);
return Inset::DISPATCHED; break;
case LFUN_ENDSEL: case LFUN_ENDSEL:
update(bv, false); update(bv, false);
cursorEnd(bv); cursorEnd(bv);
bv->finishChange(true); bv->finishChange(true);
return Inset::DISPATCHED; break;
case LFUN_WORDRIGHTSEL: case LFUN_WORDRIGHTSEL:
update(bv, false); update(bv, false);
@ -222,7 +225,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
else else
cursorRightOneWord(bv); cursorRightOneWord(bv);
bv->finishChange(true); bv->finishChange(true);
return Inset::DISPATCHED; break;
case LFUN_WORDLEFTSEL: case LFUN_WORDLEFTSEL:
update(bv, false); update(bv, false);
@ -231,7 +234,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
else else
cursorLeftOneWord(bv); cursorLeftOneWord(bv);
bv->finishChange(true); bv->finishChange(true);
return Inset::DISPATCHED; break;
case LFUN_RIGHT: { case LFUN_RIGHT: {
bool is_rtl = cursor.par()->isRightToLeftPar(bv->buffer()->params); 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()))) { && isHighlyEditableInset(cursor.par()->getInset(cursor.pos()))) {
Inset * tmpinset = cursor.par()->getInset(cursor.pos()); Inset * tmpinset = cursor.par()->getInset(cursor.pos());
cmd.message(tmpinset->editMessage()); cmd.message(tmpinset->editMessage());
if (is_rtl) tmpinset->edit(bv, !is_rtl);
tmpinset->edit(bv, false); break;
else
tmpinset->edit(bv);
return Inset::DISPATCHED;
} }
if (!is_rtl) if (!is_rtl)
cursorRight(bv, false); cursorRight(bv, false);
bv->finishChange(false); bv->finishChange(false);
return Inset::DISPATCHED; break;
} }
case LFUN_LEFT: { case LFUN_LEFT: {
@ -273,17 +273,13 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
isHighlyEditableInset(cursor.par()->getInset(cursor.pos()))) { isHighlyEditableInset(cursor.par()->getInset(cursor.pos()))) {
Inset * tmpinset = cursor.par()->getInset(cursor.pos()); Inset * tmpinset = cursor.par()->getInset(cursor.pos());
cmd.message(tmpinset->editMessage()); cmd.message(tmpinset->editMessage());
if (is_rtl) tmpinset->edit(bv, is_rtl);
tmpinset->edit(bv);
else
tmpinset->edit(bv, false);
break; break;
return Inset::DISPATCHED;
} }
if (is_rtl) if (is_rtl)
cursorRight(bv, false); cursorRight(bv, false);
bv->finishChange(false); bv->finishChange(false);
return Inset::DISPATCHED; break;
} }
case LFUN_UP: case LFUN_UP:
@ -292,7 +288,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
bv->update(this, BufferView::UPDATE); bv->update(this, BufferView::UPDATE);
cursorUp(bv); cursorUp(bv);
bv->finishChange(false); bv->finishChange(false);
return Inset::DISPATCHED; break;
case LFUN_DOWN: case LFUN_DOWN:
if (!selection.mark()) if (!selection.mark())
@ -300,7 +296,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
bv->update(this, BufferView::UPDATE); bv->update(this, BufferView::UPDATE);
cursorDown(bv); cursorDown(bv);
bv->finishChange(); bv->finishChange();
return Inset::DISPATCHED; break;
case LFUN_UP_PARAGRAPH: case LFUN_UP_PARAGRAPH:
if (!selection.mark()) if (!selection.mark())
@ -308,7 +304,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
bv->update(this, BufferView::UPDATE); bv->update(this, BufferView::UPDATE);
cursorUpParagraph(bv); cursorUpParagraph(bv);
bv->finishChange(); bv->finishChange();
return Inset::DISPATCHED; break;
case LFUN_DOWN_PARAGRAPH: case LFUN_DOWN_PARAGRAPH:
if (!selection.mark()) if (!selection.mark())
@ -316,7 +312,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
bv->update(this, BufferView::UPDATE); bv->update(this, BufferView::UPDATE);
cursorDownParagraph(bv); cursorDownParagraph(bv);
bv->finishChange(false); bv->finishChange(false);
return Inset::DISPATCHED; break;
case LFUN_PRIOR: case LFUN_PRIOR:
if (!selection.mark()) if (!selection.mark())
@ -328,7 +324,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
// finishUndo(); // finishUndo();
// moveCursorUpdate(false, false); // moveCursorUpdate(false, false);
// owner_->view_state_changed(); // owner_->view_state_changed();
return Inset::DISPATCHED; break;
case LFUN_NEXT: case LFUN_NEXT:
if (!selection.mark()) if (!selection.mark())
@ -336,7 +332,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
bv->update(this, BufferView::UPDATE); bv->update(this, BufferView::UPDATE);
bv->cursorNext(this); bv->cursorNext(this);
bv->finishChange(false); bv->finishChange(false);
return Inset::DISPATCHED; break;
case LFUN_HOME: case LFUN_HOME:
if (!selection.mark()) if (!selection.mark())
@ -344,7 +340,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
update(bv); update(bv);
cursorHome(bv); cursorHome(bv);
bv->finishChange(false); bv->finishChange(false);
return Inset::DISPATCHED; break;
case LFUN_END: case LFUN_END:
if (!selection.mark()) if (!selection.mark())
@ -352,7 +348,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
update(bv); update(bv);
cursorEnd(bv); cursorEnd(bv);
bv->finishChange(false); bv->finishChange(false);
return Inset::DISPATCHED; break;
case LFUN_BREAKLINE: case LFUN_BREAKLINE:
bv->beforeChange(this); bv->beforeChange(this);
@ -360,7 +356,203 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
update(bv, true); update(bv, true);
setCursor(bv, cursor.par(), cursor.pos()); setCursor(bv, cursor.par(), cursor.pos());
bv->moveCursorUpdate(false); 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: case LFUN_PROTECTEDSPACE:
if (cursor.par()->layout()->free_spacing) { if (cursor.par()->layout()->free_spacing) {
@ -370,41 +562,41 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
specialChar(this, bv, InsetSpecialChar::PROTECTED_SEPARATOR); specialChar(this, bv, InsetSpecialChar::PROTECTED_SEPARATOR);
} }
bv->moveCursorUpdate(false); bv->moveCursorUpdate(false);
return Inset::DISPATCHED; break;
case LFUN_HYPHENATION: case LFUN_HYPHENATION:
specialChar(this, bv, InsetSpecialChar::HYPHENATION); specialChar(this, bv, InsetSpecialChar::HYPHENATION);
return Inset::DISPATCHED; break;
case LFUN_LIGATURE_BREAK: case LFUN_LIGATURE_BREAK:
specialChar(this, bv, InsetSpecialChar::LIGATURE_BREAK); specialChar(this, bv, InsetSpecialChar::LIGATURE_BREAK);
return Inset::DISPATCHED; break;
case LFUN_LDOTS: case LFUN_LDOTS:
specialChar(this, bv, InsetSpecialChar::LDOTS); specialChar(this, bv, InsetSpecialChar::LDOTS);
return Inset::DISPATCHED; break;
case LFUN_HFILL: case LFUN_HFILL:
bv->hideCursor(); bv->hideCursor();
update(bv, false); update(bv, false);
insertChar(bv, Paragraph::META_HFILL); insertChar(bv, Paragraph::META_HFILL);
update(bv); update(bv);
return Inset::DISPATCHED; break;
case LFUN_END_OF_SENTENCE: case LFUN_END_OF_SENTENCE:
specialChar(this, bv, InsetSpecialChar::END_OF_SENTENCE); specialChar(this, bv, InsetSpecialChar::END_OF_SENTENCE);
return Inset::DISPATCHED; break;
case LFUN_MENU_SEPARATOR: case LFUN_MENU_SEPARATOR:
specialChar(this, bv, InsetSpecialChar::MENU_SEPARATOR); specialChar(this, bv, InsetSpecialChar::MENU_SEPARATOR);
return Inset::DISPATCHED; break;
case LFUN_MARK_OFF: case LFUN_MARK_OFF:
bv->beforeChange(this); bv->beforeChange(this);
update(bv, false); update(bv, false);
selection.cursor = cursor; selection.cursor = cursor;
cmd.message(N_("Mark off")); cmd.message(N_("Mark off"));
return Inset::DISPATCHED; break;
case LFUN_MARK_ON: case LFUN_MARK_ON:
bv->beforeChange(this); bv->beforeChange(this);
@ -412,7 +604,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
update(bv, false); update(bv, false);
selection.cursor = cursor; selection.cursor = cursor;
cmd.message(N_("Mark on")); cmd.message(N_("Mark on"));
return Inset::DISPATCHED; break;
case LFUN_SETMARK: case LFUN_SETMARK:
bv->beforeChange(this); bv->beforeChange(this);
@ -425,7 +617,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
cmd.message(N_("Mark set")); cmd.message(N_("Mark set"));
} }
selection.cursor = cursor; selection.cursor = cursor;
return Inset::DISPATCHED; break;
case LFUN_UPCASE_WORD: case LFUN_UPCASE_WORD:
update(bv, false); update(bv, false);
@ -433,7 +625,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
if (inset_owner) if (inset_owner)
bv->updateInset(inset_owner, true); bv->updateInset(inset_owner, true);
update(bv); update(bv);
return Inset::DISPATCHED; break;
case LFUN_LOWCASE_WORD: case LFUN_LOWCASE_WORD:
update(bv, false); update(bv, false);
@ -441,7 +633,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
if (inset_owner) if (inset_owner)
bv->updateInset(inset_owner, true); bv->updateInset(inset_owner, true);
update(bv); update(bv);
return Inset::DISPATCHED; break;
case LFUN_CAPITALIZE_WORD: case LFUN_CAPITALIZE_WORD:
update(bv, false); update(bv, false);
@ -449,7 +641,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
if (inset_owner) if (inset_owner)
bv->updateInset(inset_owner, true); bv->updateInset(inset_owner, true);
update(bv); update(bv);
return Inset::DISPATCHED; break;
case LFUN_TRANSPOSE_CHARS: case LFUN_TRANSPOSE_CHARS:
update(bv, false); update(bv, false);
@ -457,7 +649,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
if (inset_owner) if (inset_owner)
bv->updateInset(inset_owner, true); bv->updateInset(inset_owner, true);
update(bv); update(bv);
return Inset::DISPATCHED; break;
case LFUN_BEGINNINGBUFSEL: case LFUN_BEGINNINGBUFSEL:
if (inset_owner) if (inset_owner)
@ -465,7 +657,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
update(bv, false); update(bv, false);
cursorTop(bv); cursorTop(bv);
bv->finishChange(true); bv->finishChange(true);
return Inset::DISPATCHED; break;
case LFUN_ENDBUFSEL: case LFUN_ENDBUFSEL:
if (inset_owner) if (inset_owner)
@ -473,11 +665,11 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
update(bv, false); update(bv, false);
cursorBottom(bv); cursorBottom(bv);
bv->finishChange(true); bv->finishChange(true);
return Inset::DISPATCHED; break;
case LFUN_GETXY: case LFUN_GETXY:
cmd.message(tostr(cursor.x()) + ' ' + tostr(cursor.y())); cmd.message(tostr(cursor.x()) + ' ' + tostr(cursor.y()));
return Inset::DISPATCHED; break;
case LFUN_SETXY: { case LFUN_SETXY: {
int x = 0; int x = 0;
@ -486,7 +678,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
lyxerr << "SETXY: Could not parse coordinates in '" lyxerr << "SETXY: Could not parse coordinates in '"
<< cmd.argument << std::endl; << cmd.argument << std::endl;
setCursorFromCoordinates(bv, x, y); setCursorFromCoordinates(bv, x, y);
return Inset::DISPATCHED; break;
} }
case LFUN_GETFONT: case LFUN_GETFONT:
@ -496,15 +688,92 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
cmd.message("N"); cmd.message("N");
else else
cmd.message("0"); cmd.message("0");
return Inset::DISPATCHED; break;
case LFUN_GETLAYOUT: case LFUN_GETLAYOUT:
cmd.message(tostr(cursor.par()->layout())); 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: { case LFUN_SELFINSERT: {
if (cmd.argument.empty()) if (cmd.argument.empty())
return Inset::DISPATCHED; break;
// Automatically delete the currently selected // Automatically delete the currently selected
// text and replace it with what is being // text and replace it with what is being
@ -537,13 +806,12 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
// update the minibuffer // update the minibuffer
if (old_font != real_current_font) if (old_font != real_current_font)
bv->owner()->view_state_changed(); bv->owner()->view_state_changed();
return Inset::DISPATCHED; break;
} }
default: default:
return Inset::UNDISPATCHED; return Inset::UNDISPATCHED;
} }
// shut up compiler return Inset::DISPATCHED;
return Inset::UNDISPATCHED;
} }