mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
Find selection inside InsetText and always leave pasted text selected.
(fix #100, #35) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3763 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
4f64ce3c22
commit
961b1a47ed
@ -393,7 +393,7 @@ void BufferView::pasteEnvironment()
|
||||
void BufferView::copy()
|
||||
{
|
||||
if (available()) {
|
||||
text->copySelection(this);
|
||||
getLyXText()->copySelection(this);
|
||||
owner()->message(_("Copy"));
|
||||
}
|
||||
}
|
||||
@ -413,7 +413,8 @@ void BufferView::cut(bool realcut)
|
||||
|
||||
void BufferView::paste()
|
||||
{
|
||||
if (!available()) return;
|
||||
if (!available())
|
||||
return;
|
||||
|
||||
owner()->message(_("Paste"));
|
||||
|
||||
@ -426,11 +427,14 @@ void BufferView::paste()
|
||||
// paste
|
||||
text->pasteSelection(this);
|
||||
update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
||||
|
||||
// why fake a selection only I think it should be a real one and not only
|
||||
// a painted one (Jug 20020318).
|
||||
#if 0
|
||||
// clear the selection
|
||||
toggleSelection();
|
||||
text->clearSelection();
|
||||
update(text, BufferView::SELECT|BufferView::FITCUR);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -589,7 +589,8 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
|
||||
void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
|
||||
unsigned int button)
|
||||
{
|
||||
if (!buffer_ || !screen_.get()) return;
|
||||
if (!buffer_ || !screen_.get())
|
||||
return;
|
||||
|
||||
Inset * inset_hit = checkInsetHit(bv_->text, xpos, ypos);
|
||||
|
||||
@ -605,6 +606,16 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
|
||||
}
|
||||
}
|
||||
|
||||
// Middle button press pastes if we have a selection
|
||||
// We do this here as if the selection was inside an inset
|
||||
// it could get cleared on the unlocking of the inset so
|
||||
// we have to check this first
|
||||
bool paste_internally = false;
|
||||
if (button == 2 && bv_->getLyXText()->selection.set()) {
|
||||
owner_->getLyXFunc()->dispatch(LFUN_COPY);
|
||||
paste_internally = true;
|
||||
}
|
||||
|
||||
if (bv_->theLockingInset()) {
|
||||
// We are in inset locking mode
|
||||
|
||||
@ -625,14 +636,6 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
|
||||
|
||||
int const screen_first = bv_->text->first_y;
|
||||
|
||||
// Middle button press pastes if we have a selection
|
||||
bool paste_internally = false;
|
||||
if (button == 2
|
||||
&& bv_->text->selection.set()) {
|
||||
owner_->getLyXFunc()->dispatch(LFUN_COPY);
|
||||
paste_internally = true;
|
||||
}
|
||||
|
||||
// Clear the selection
|
||||
screen_->toggleSelection(bv_->text, bv_);
|
||||
bv_->text->clearSelection();
|
||||
@ -679,7 +682,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
|
||||
owner_->getLyXFunc()->dispatch(LFUN_PASTE);
|
||||
else
|
||||
owner_->getLyXFunc()->dispatch(LFUN_PASTESELECTION,
|
||||
"paragraph");
|
||||
"paragraph");
|
||||
selection_possible = false;
|
||||
return;
|
||||
}
|
||||
@ -1388,14 +1391,16 @@ void BufferView::Pimpl::center()
|
||||
|
||||
void BufferView::Pimpl::pasteClipboard(bool asPara)
|
||||
{
|
||||
if (!buffer_) return;
|
||||
if (!buffer_)
|
||||
return;
|
||||
|
||||
screen_->hideCursor();
|
||||
beforeChange(bv_->text);
|
||||
|
||||
string const clip(workarea_.getClipboard());
|
||||
|
||||
if (clip.empty()) return;
|
||||
if (clip.empty())
|
||||
return;
|
||||
|
||||
if (asPara) {
|
||||
bv_->getLyXText()->insertStringAsParagraphs(bv_, clip);
|
||||
@ -1574,7 +1579,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
|
||||
|
||||
case LFUN_PASTESELECTION:
|
||||
{
|
||||
bool asPara = false;
|
||||
bool asPara = false;
|
||||
if (argument == "paragraph")
|
||||
asPara = true;
|
||||
pasteClipboard(asPara);
|
||||
|
@ -1,3 +1,16 @@
|
||||
2002-03-18 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* BufferView2.C (copy): use getLyXText() so that we do it inside an
|
||||
inset if we're there actually (probably not used right now but this
|
||||
is the direction to go for unifying code).
|
||||
(paste): disable code to clear the selection.
|
||||
|
||||
* BufferView_pimpl.C (workAreaButtonPress): check also for a selection
|
||||
inside an InsetText and move the check further up as it is in the
|
||||
wrong place.
|
||||
|
||||
* text2.C (pasteSelection): set a selection over the pasted text.
|
||||
|
||||
2002-03-14 Kayvan A. Sylvan <kayvan@sylvan.com>
|
||||
|
||||
* Makefile.am (lyx_DEPENDENCIES): Swap the order of libfrontend
|
||||
|
@ -1793,14 +1793,16 @@ void LyXText::pasteSelection(BufferView * bview)
|
||||
int pos = cursor.pos();
|
||||
|
||||
CutAndPaste::pasteSelection(&actpar, &endpar, pos,
|
||||
bview->buffer()->params.textclass);
|
||||
bview->buffer()->params.textclass);
|
||||
|
||||
redoParagraphs(bview, cursor, endpar);
|
||||
|
||||
setCursor(bview, cursor.par(), cursor.pos());
|
||||
clearSelection();
|
||||
|
||||
|
||||
selection.cursor = cursor;
|
||||
setCursor(bview, actpar, pos);
|
||||
setSelection(bview);
|
||||
updateCounters(bview, cursor.row());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user