mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-26 14:15:32 +00:00
Implemented spellchecking inside insets. Small fixes. Baruchs fix.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2265 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
30f11bef59
commit
2c5ab94d01
@ -384,24 +384,25 @@ void BufferView::replaceWord(string const & replacestring)
|
||||
{
|
||||
if (!available()) return;
|
||||
|
||||
LyXText * tt = getLyXText();
|
||||
hideCursor();
|
||||
update(text, BufferView::SELECT|BufferView::FITCUR);
|
||||
update(tt, BufferView::SELECT|BufferView::FITCUR);
|
||||
|
||||
/* clear the selection (if there is any) */
|
||||
toggleSelection(false);
|
||||
update(text, BufferView::SELECT|BufferView::FITCUR);
|
||||
update(tt, BufferView::SELECT|BufferView::FITCUR);
|
||||
|
||||
/* clear the selection (if there is any) */
|
||||
toggleSelection(false);
|
||||
text->replaceSelectionWithString(this, replacestring);
|
||||
tt->replaceSelectionWithString(this, replacestring);
|
||||
|
||||
text->setSelectionOverString(this, replacestring);
|
||||
tt->setSelectionOverString(this, replacestring);
|
||||
|
||||
// Go back so that replacement string is also spellchecked
|
||||
for (string::size_type i = 0; i < replacestring.length() + 1; ++i) {
|
||||
text->cursorLeft(this);
|
||||
tt->cursorLeft(this);
|
||||
}
|
||||
update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
||||
update(tt, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
||||
}
|
||||
// End of spellchecker stuff
|
||||
|
||||
|
@ -1266,8 +1266,11 @@ void BufferView::Pimpl::hideCursor()
|
||||
|
||||
void BufferView::Pimpl::toggleSelection(bool b)
|
||||
{
|
||||
if (screen_.get())
|
||||
if (screen_.get()) {
|
||||
if (bv_->theLockingInset())
|
||||
bv_->theLockingInset()->toggleSelection(bv_, b);
|
||||
screen_->toggleSelection(bv_->text, bv_, b);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,3 +1,14 @@
|
||||
2001-07-17 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* BufferView_pimpl.C (toggleSelection): adapted too.
|
||||
|
||||
* text.C (selectNextWord): adapted for use with insets.
|
||||
(selectSelectedWord): ditto
|
||||
|
||||
2001-07-17 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* sp_spell.C (PSpell): fix initialitation order.
|
||||
|
||||
2001-07-17 Lars Gullik Bjønnes <larsbj@birdstep.com>
|
||||
|
||||
* paragraph.C: spacing
|
||||
|
@ -1,3 +1,7 @@
|
||||
2001-07-16 Baruch Even <baruch@lyx.org>
|
||||
|
||||
* ControlVCLog.h: Added Lsstream.h to includes.
|
||||
|
||||
2001-07-17 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* ControlSpellchecker.[Ch]: remove d-tor.
|
||||
|
@ -21,6 +21,7 @@
|
||||
#endif
|
||||
|
||||
#include "ControlDialogs.h"
|
||||
#include "Lsstream.h"
|
||||
|
||||
/**
|
||||
* A controller for the Version Control log viewer.
|
||||
|
@ -1,3 +1,13 @@
|
||||
2001-07-17 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* various files: implemented the below functions.
|
||||
|
||||
* inset.h: added functions
|
||||
- virtual string selectNextWord(BufferView *, float & value) const;
|
||||
- virtual void selectSelectedWord(BufferView *) { return; }
|
||||
- virtual void toggleSelection(BufferView *, bool /*kill_selection*/)
|
||||
needed for spellchecking correctly!
|
||||
|
||||
2001-07-16 Lars Gullik Bjønnes <larsbj@birdstep.com>
|
||||
|
||||
* insetert.C (latex): write out all paragraphs.
|
||||
|
@ -258,3 +258,11 @@ LyXCursor const & Inset::cursor(BufferView * bv) const
|
||||
{
|
||||
return bv->text->cursor;
|
||||
}
|
||||
|
||||
string UpdatableInset::selectNextWord(BufferView *bv, float & value) const
|
||||
{
|
||||
// we have to unlock ourself in this function by default!
|
||||
bv->unlockInset(const_cast<UpdatableInset *>(this));
|
||||
value = 0;
|
||||
return string();
|
||||
}
|
||||
|
@ -414,6 +414,14 @@ public:
|
||||
///
|
||||
virtual bool collapsed() const { return false; }
|
||||
virtual void collapsed(BufferView *, bool) {}
|
||||
///
|
||||
// needed for spellchecking text
|
||||
///
|
||||
virtual string selectNextWord(BufferView *, float & value) const;
|
||||
virtual void selectSelectedWord(BufferView *) { return; }
|
||||
virtual void toggleSelection(BufferView *, bool /*kill_selection*/) {
|
||||
return;
|
||||
}
|
||||
|
||||
protected:
|
||||
///
|
||||
|
@ -160,6 +160,16 @@ public:
|
||||
bool isCollapsable() const { return true; }
|
||||
bool collapsed() const { return collapsed_; }
|
||||
void collapsed(BufferView *, bool);
|
||||
///
|
||||
string selectNextWord(BufferView * bv, float & value) const {
|
||||
return inset.selectNextWord(bv, value);
|
||||
}
|
||||
void selectSelectedWord(BufferView * bv) {
|
||||
return inset.selectSelectedWord(bv);
|
||||
}
|
||||
void toggleSelection(BufferView * bv, bool kill_selection) {
|
||||
return inset.toggleSelection(bv, kill_selection);
|
||||
}
|
||||
|
||||
protected:
|
||||
///
|
||||
|
@ -1173,9 +1173,12 @@ bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv,
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::getCursorPos(BufferView *,
|
||||
int & x, int & y) const
|
||||
void InsetTabular::getCursorPos(BufferView * bv, int & x, int & y) const
|
||||
{
|
||||
if (the_locking_inset) {
|
||||
the_locking_inset->getCursorPos(bv, x, y);
|
||||
return;
|
||||
}
|
||||
x = cursor_.x() - top_x;
|
||||
y = cursor_.y();
|
||||
}
|
||||
@ -2431,3 +2434,64 @@ Inset * InsetTabular::getInsetFromID(int id_arg) const
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
string InsetTabular::selectNextWord(BufferView * bv, float & value) const
|
||||
{
|
||||
if (the_locking_inset) {
|
||||
string str;
|
||||
str = the_locking_inset->selectNextWord(bv, value);
|
||||
if (!str.empty())
|
||||
return str;
|
||||
}
|
||||
if (tabular->IsLastCell(actcell)) {
|
||||
bv->unlockInset(const_cast<InsetTabular *>(this));
|
||||
return string();
|
||||
}
|
||||
|
||||
// otherwise we have to lock the next inset and ask for it's selecttion
|
||||
UpdatableInset * inset =
|
||||
static_cast<UpdatableInset*>(tabular->GetCellInset(++actcell));
|
||||
inset->edit(bv, 0, 0, 0);
|
||||
string str = selectNextWordInt(bv, value);
|
||||
if (!str.empty())
|
||||
resetPos(bv);
|
||||
return str;
|
||||
}
|
||||
|
||||
string InsetTabular::selectNextWordInt(BufferView * bv, float & value) const
|
||||
{
|
||||
if (the_locking_inset) {
|
||||
string str;
|
||||
str = the_locking_inset->selectNextWord(bv, value);
|
||||
if (!str.empty())
|
||||
return str;
|
||||
}
|
||||
if (tabular->IsLastCell(actcell)) {
|
||||
bv->unlockInset(const_cast<InsetTabular *>(this));
|
||||
return string();
|
||||
}
|
||||
|
||||
// otherwise we have to lock the next inset and ask for it's selecttion
|
||||
UpdatableInset * inset =
|
||||
static_cast<UpdatableInset*>(tabular->GetCellInset(++actcell));
|
||||
inset->edit(bv, 0, 0, 0);
|
||||
return selectNextWordInt(bv, value);
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::selectSelectedWord(BufferView * bv)
|
||||
{
|
||||
if (the_locking_inset) {
|
||||
the_locking_inset->selectSelectedWord(bv);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void InsetTabular::toggleSelection(BufferView * bv, bool kill_selection)
|
||||
{
|
||||
if (the_locking_inset) {
|
||||
the_locking_inset->toggleSelection(bv, kill_selection);
|
||||
}
|
||||
}
|
||||
|
@ -209,6 +209,10 @@ public:
|
||||
Paragraph * firstParagraph() const;
|
||||
///
|
||||
LyXCursor const & cursor(BufferView *) const;
|
||||
///
|
||||
string selectNextWord(BufferView *, float & value) const;
|
||||
void selectSelectedWord(BufferView *);
|
||||
void toggleSelection(BufferView *, bool kill_selection);
|
||||
|
||||
//
|
||||
// Public structures and variables
|
||||
@ -284,6 +288,8 @@ private:
|
||||
bool isRightToLeft(BufferView *);
|
||||
///
|
||||
void getSelection(int & scol, int & ecol, int & srow, int & erow) const;
|
||||
///
|
||||
string selectNextWordInt(BufferView *, float & value) const;
|
||||
|
||||
//
|
||||
// Private structures and variables
|
||||
|
@ -1267,6 +1267,10 @@ int InsetText::beginningOfMainBody(Buffer const * buf, Paragraph * p) const
|
||||
void InsetText::getCursorPos(BufferView * bv,
|
||||
int & x, int & y) const
|
||||
{
|
||||
if (the_locking_inset) {
|
||||
the_locking_inset->getCursorPos(bv, x, y);
|
||||
return;
|
||||
}
|
||||
x = cx(bv);
|
||||
y = cy(bv);
|
||||
}
|
||||
@ -1960,3 +1964,76 @@ Inset * InsetText::getInsetFromID(int id_arg) const
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
string InsetText::selectNextWord(BufferView * bv, float & value) const
|
||||
{
|
||||
bool clear = false;
|
||||
string str;
|
||||
|
||||
if (!lt) {
|
||||
lt = getLyXText(bv);
|
||||
clear = true;
|
||||
}
|
||||
if (the_locking_inset) {
|
||||
str = the_locking_inset->selectNextWord(bv, value);
|
||||
if (!str.empty()) {
|
||||
value += cy(bv);
|
||||
if (clear)
|
||||
lt = 0;
|
||||
return str;
|
||||
}
|
||||
#warning Dekel please have a look on this one RTL? (Jug)
|
||||
// we have to go on checking so move cusor to the right
|
||||
lt->cursor.pos(lt->cursor.pos() + 1);
|
||||
}
|
||||
str = lt->selectNextWord(bv, value);
|
||||
if (str.empty())
|
||||
bv->unlockInset(const_cast<InsetText *>(this));
|
||||
else
|
||||
value = cy(bv);
|
||||
if (clear)
|
||||
lt = 0;
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
void InsetText::selectSelectedWord(BufferView * bv)
|
||||
{
|
||||
if (the_locking_inset) {
|
||||
the_locking_inset->selectSelectedWord(bv);
|
||||
return;
|
||||
}
|
||||
getLyXText(bv)->selectSelectedWord(bv);
|
||||
updateLocal(bv, SELECTION, false);
|
||||
}
|
||||
|
||||
|
||||
void InsetText::toggleSelection(BufferView * bv, bool kill_selection)
|
||||
{
|
||||
if (the_locking_inset) {
|
||||
the_locking_inset->toggleSelection(bv, kill_selection);
|
||||
}
|
||||
bool clear = false;
|
||||
if (!lt) {
|
||||
lt = getLyXText(bv);
|
||||
clear = true;
|
||||
}
|
||||
|
||||
int x = top_x + TEXT_TO_INSET_OFFSET;
|
||||
|
||||
int y = 0;
|
||||
Row * row = lt->getRowNearY(y);
|
||||
int y_offset = top_baseline - row->ascent_of_text();
|
||||
y = y_offset;
|
||||
while ((row != 0) && ((y+row->height()) <= 0)) {
|
||||
y += row->height();
|
||||
row = row->next();
|
||||
}
|
||||
if (y_offset < 0)
|
||||
y_offset = y;
|
||||
|
||||
bv->screen()->toggleSelection(lt, bv, kill_selection, y_offset, x);
|
||||
if (clear)
|
||||
lt = 0;
|
||||
}
|
||||
|
@ -218,6 +218,10 @@ public:
|
||||
///
|
||||
void paragraph(Paragraph *);
|
||||
///
|
||||
string selectNextWord(BufferView *, float & value) const;
|
||||
void selectSelectedWord(BufferView *);
|
||||
void toggleSelection(BufferView *, bool kill_selection);
|
||||
///
|
||||
mutable int need_update;
|
||||
|
||||
protected:
|
||||
|
@ -11,8 +11,8 @@ class ISpell : public SpellBase
|
||||
public:
|
||||
|
||||
enum ActualSpellChecker {
|
||||
ASC_ISPELL,
|
||||
ASC_ASPELL
|
||||
ASC_ISPELL,
|
||||
ASC_ASPELL
|
||||
};
|
||||
|
||||
ISpell();
|
||||
|
@ -74,12 +74,12 @@ extern void sigchldchecker(pid_t pid, int * status);
|
||||
|
||||
|
||||
PSpell::PSpell()
|
||||
: els(0), sc(0), spell_error_object(0), flag(ISP_UNKNOWN)
|
||||
: sc(0), els(0), spell_error_object(0), flag(ISP_UNKNOWN)
|
||||
{
|
||||
}
|
||||
|
||||
PSpell::PSpell(BufferParams const & params, string const & lang)
|
||||
: els(0), sc(0), spell_error_object(0), flag(ISP_UNKNOWN)
|
||||
: sc(0), els(0), spell_error_object(0), flag(ISP_UNKNOWN)
|
||||
{
|
||||
initialize(params, lang);
|
||||
}
|
||||
|
@ -1730,6 +1730,7 @@ int LyXTabular::GetLastCellBelow(int cell) const
|
||||
|
||||
int LyXTabular::GetCellNumber(int row, int column) const
|
||||
{
|
||||
#if 1
|
||||
if (column >= columns_)
|
||||
column = columns_ - 1;
|
||||
else if (column < 0)
|
||||
@ -1738,7 +1739,9 @@ int LyXTabular::GetCellNumber(int row, int column) const
|
||||
row = rows_ - 1;
|
||||
else if (row < 0)
|
||||
row = 0;
|
||||
|
||||
#else
|
||||
lyx::Assert(column < 0 || column >= columns_ || row < 0 || row >= rows_);
|
||||
#endif
|
||||
return cell_info[row][column].cellno;
|
||||
}
|
||||
|
||||
@ -2534,11 +2537,6 @@ InsetText * LyXTabular::GetCellInset(int cell) const
|
||||
|
||||
InsetText * LyXTabular::GetCellInset(int row, int column) const
|
||||
{
|
||||
#ifdef WITH_WARNINGS
|
||||
#warning Juergen, should we check whether the row/column values are correct?
|
||||
// If we do not need to do that, the tests in GetCellNumber should be
|
||||
// changed to asserts.
|
||||
#endif
|
||||
cur_cell = GetCellNumber(row, column);
|
||||
return & cell_info[row][column].inset;
|
||||
}
|
||||
|
39
src/text.C
39
src/text.C
@ -2224,6 +2224,22 @@ bool LyXText::selectWordWhenUnderCursor(BufferView * bview)
|
||||
string const LyXText::selectNextWord(BufferView * bview,
|
||||
float & value) const
|
||||
{
|
||||
if (the_locking_inset) {
|
||||
string str = the_locking_inset->selectNextWord(bview, value);
|
||||
if (!str.empty()) {
|
||||
value += float(cursor.y())/float(height);
|
||||
return str;
|
||||
}
|
||||
#warning Dekel please have a look on this one RTL? (Jug)
|
||||
// we have to go on checking so move cusor to the right
|
||||
if (cursor.pos() == cursor.par()->size()) {
|
||||
if (!cursor.par()->next())
|
||||
return str;
|
||||
cursor.par(cursor.par()->next());
|
||||
cursor.pos(0);
|
||||
} else
|
||||
cursor.pos(cursor.pos() + 1);
|
||||
}
|
||||
Paragraph * tmppar = cursor.par();
|
||||
|
||||
// If this is not the very first word, skip rest of
|
||||
@ -2237,20 +2253,33 @@ string const LyXText::selectNextWord(BufferView * bview,
|
||||
|
||||
// Now, skip until we have real text (will jump paragraphs)
|
||||
while ((cursor.par()->size() > cursor.pos()
|
||||
&& (!cursor.par()->isLetter(cursor.pos())
|
||||
&& (!cursor.par()->isLetter(cursor.pos())
|
||||
#ifndef NO_LATEX
|
||||
|| cursor.par()->getFont(bview->buffer()->params, cursor.pos())
|
||||
.latex() == LyXFont::ON
|
||||
#endif
|
||||
))
|
||||
)
|
||||
&& (!cursor.par()->isInset(cursor.pos()) ||
|
||||
!cursor.par()->getInset(cursor.pos())->isTextInset()))
|
||||
|| (cursor.par()->size() == cursor.pos()
|
||||
&& cursor.par()->next())){
|
||||
&& cursor.par()->next()))
|
||||
{
|
||||
if (cursor.pos() == cursor.par()->size()) {
|
||||
cursor.par(cursor.par()->next());
|
||||
cursor.pos(0);
|
||||
} else
|
||||
cursor.pos(cursor.pos() + 1);
|
||||
}
|
||||
|
||||
// now check if we hit an inset so it has to be a inset containing text!
|
||||
if (cursor.pos() < cursor.par()->size() &&
|
||||
cursor.par()->isInset(cursor.pos()))
|
||||
{
|
||||
// lock the inset!
|
||||
cursor.par()->getInset(cursor.pos())->edit(bview, 0, 0, 0);
|
||||
// now call us again to do the above trick
|
||||
return selectNextWord(bview, value);
|
||||
}
|
||||
|
||||
// Update the value if we changed paragraphs
|
||||
if (cursor.par() != tmppar){
|
||||
@ -2290,6 +2319,10 @@ string const LyXText::selectNextWord(BufferView * bview,
|
||||
// This one is also only for the spellchecker
|
||||
void LyXText::selectSelectedWord(BufferView * bview)
|
||||
{
|
||||
if (the_locking_inset) {
|
||||
the_locking_inset->selectSelectedWord(bview);
|
||||
return;
|
||||
}
|
||||
// move cursor to the beginning
|
||||
setCursor(bview, selection.cursor.par(), selection.cursor.pos());
|
||||
|
||||
|
19
src/text2.C
19
src/text2.C
@ -2493,12 +2493,27 @@ void LyXText::status(BufferView * bview, LyXText::text_status st) const
|
||||
}
|
||||
}
|
||||
#else
|
||||
#warning Please tell what the intention is here.
|
||||
#warning Please tell what the intention is here. (Lgb)
|
||||
// The above does not make any sense, I changed it to what is here,
|
||||
// but it still does not make much sense. (Lgb)
|
||||
#warning Sure have a look now! (Jug)
|
||||
// well as much as I know && binds more then || so the above and the
|
||||
// below are identical (this for your known use of parentesis!)
|
||||
// Now some explanation:
|
||||
// We should only go up with refreshing code so this means that if
|
||||
// we have a MORE refresh we should never set it to LITTLE if we still
|
||||
// didn't handle it (and then it will be UNCHANGED. Now as long as
|
||||
// we stay inside one LyXText this may work but we need to tell the
|
||||
// outermost LyXText that it should REALLY draw us if there is some
|
||||
// change in a Inset::LyXText. So you see that when we are inside a
|
||||
// inset's LyXText we give the LITTLE to the outermost LyXText to
|
||||
// tell'em that it should redraw the actual row (where the inset
|
||||
// resides! Capito?!
|
||||
|
||||
if ((status_ != NEED_MORE_REFRESH)
|
||||
|| (status_ == NEED_MORE_REFRESH
|
||||
&& st != NEED_VERY_LITTLE_REFRESH)) {
|
||||
&& st != NEED_VERY_LITTLE_REFRESH))
|
||||
{
|
||||
status_ = st;
|
||||
if (inset_owner && st != UNCHANGED) {
|
||||
bview->text->status(bview, NEED_VERY_LITTLE_REFRESH);
|
||||
|
Loading…
Reference in New Issue
Block a user