Patch from John (figinset) and Dekel (RTL and spellchecker)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1257 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2000-12-05 14:15:44 +00:00
parent ed9d6acf84
commit 4789208ca1
6 changed files with 98 additions and 74 deletions

View File

@ -1,3 +1,27 @@
2000-12-02 Dekel Tsur <dekelts@tau.ac.il>
* src/BufferView_pimpl.C (workAreaMotionNotify): Fixed mouse
movement in inset in RTL text.
(checkInsetHit): Fixed mouse movement in scrolled inset in RTL text.
(workAreaButtonRelease): Do not open a float when there is a selection.
* src/insets/insettext.C (cx): Fixed for insets in RTL text.
* src/spellchecker.C (RunSpellChecker): Open all floats before
spellchecking.
* src/text.C (InsertChar): Consider "," as a part of a number
(for LTR numbers in RTL text code).
(IsBoundary): Fixed (and simplified).
(InsertChar): Recalculate cursor boundary.
(Backspace): Ditto.
2000-12-04 John Levon <moz@compsoc.man.ac.uk>
* src/spellchecker.C: fix figures with pspell enabled
* src/insets/figinset.C: workaround for gs hang xforms bug
2000-12-05 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* lib/bind/??_menus.bind: comment out the entries corresponding to

View File

@ -524,10 +524,15 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
// Check for inset locking
if (bv_->theLockingInset()) {
LyXCursor cursor = bv_->text->cursor;
LyXFont font = bv_->text->GetFont(bv_->buffer(),
cursor.par(), cursor.pos());
int width = bv_->theLockingInset()->width(bv_, font);
int inset_x = font.isVisibleRightToLeft()
? cursor.x() - width : cursor.x();
int start_x = inset_x + bv_->theLockingInset()->scroll();
bv_->theLockingInset()->
InsetMotionNotify(bv_,
x - cursor.x() -
bv_->theLockingInset()->scroll(),
x - start_x,
y - cursor.y() + bv_->text->first,
state);
return;
@ -784,6 +789,7 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
GetChar(bv_->text->cursor.pos());
}
#ifndef NEW_INSETS
if(!bv_->text->selection)
if (c == LyXParagraph::META_FOOTNOTE
|| c == LyXParagraph::META_MARGIN
|| c == LyXParagraph::META_FIG
@ -885,17 +891,11 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y,
Inset * tmpinset = cursor.par()->GetInset(cursor.pos());
LyXFont font = text->GetFont(bv_->buffer(),
cursor.par(), cursor.pos());
bool is_rtl = font.isVisibleRightToLeft();
int start_x;
int end_x;
if (is_rtl) {
start_x = cursor.x() - tmpinset->width(bv_, font) + tmpinset->scroll();
end_x = cursor.x() + tmpinset->scroll();
} else {
start_x = cursor.x() + tmpinset->scroll();
end_x = cursor.x() + tmpinset->width(bv_, font) + tmpinset->scroll();
}
int width = tmpinset->width(bv_, font);
int inset_x = font.isVisibleRightToLeft()
? cursor.x() - width : cursor.x();
int start_x = inset_x + tmpinset->scroll();
int end_x = inset_x + width;
if (x > start_x && x < end_x
&& y_tmp > cursor.y() - tmpinset->ascent(bv_, font)
@ -915,19 +915,12 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y,
Inset * tmpinset = cursor.par()->GetInset(cursor.pos()-1);
LyXFont font = text->GetFont(bv_->buffer(), cursor.par(),
cursor.pos()-1);
bool is_rtl = font.isVisibleRightToLeft();
int start_x;
int end_x;
int width = tmpinset->width(bv_, font);
int inset_x = font.isVisibleRightToLeft()
? cursor.x() : cursor.x() - width;
int start_x = inset_x + tmpinset->scroll();
int end_x = inset_x + width;
if (!is_rtl) {
start_x = cursor.x() - tmpinset->width(bv_, font) +
tmpinset->scroll();
end_x = cursor.x() + tmpinset->scroll();
} else {
start_x = cursor.x() + tmpinset->scroll();
end_x = cursor.x() + tmpinset->width(bv_, font) +
tmpinset->scroll();
}
if (x > start_x && x < end_x
&& y_tmp > cursor.y() - tmpinset->ascent(bv_, font)
&& y_tmp < cursor.y() + tmpinset->descent(bv_, font)) {

View File

@ -167,10 +167,14 @@ void kill_gs(int pid, int sig)
}
extern "C" // static
int GhostscriptMsg(FL_OBJECT *, Window, int, int,
XEvent * ev, void *)
extern "C" {
static
int GhostscriptMsg(XEvent * ev, void *)
{
// bin all events not of interest
if (ev->type != ClientMessage)
return FL_PREEMPT;
XClientMessageEvent * e = reinterpret_cast<XClientMessageEvent*>(ev);
if (lyxerr.debugging()) {
@ -297,7 +301,8 @@ int GhostscriptMsg(FL_OBJECT *, Window, int, int,
}
break;
}
return 0;
return FL_PREEMPT;
}
}
@ -378,6 +383,9 @@ void AllocGrays(int num)
}
// xforms doesn't define this
extern "C" FL_APPEVENT_CB fl_set_preemptive_callback(Window, FL_APPEVENT_CB, void *);
static
void InitFigures()
{
@ -389,9 +397,10 @@ void InitFigures()
// first get visual
gs_color = false;
if (lyxrc.use_gui) {
fl_add_canvas_handler(figinset_canvas, ClientMessage,
GhostscriptMsg,
current_view->owner()->getForm());
/* we want to capture every event, in order to work around an
* xforms bug.
*/
fl_set_preemptive_callback(fl_get_canvas_id(figinset_canvas), GhostscriptMsg, 0);
local_gc_copy = createGC();
@ -430,9 +439,6 @@ void DoneFigures()
figures.clear();
lyxerr.debug() << "Unregistering figures..." << endl;
fl_remove_canvas_handler(figinset_canvas, ClientMessage,
GhostscriptMsg);
}

View File

@ -1450,7 +1450,15 @@ LyXFont InsetText::GetDrawFont(BufferView * bv, LyXParagraph * p, int pos) const
int InsetText::cx(BufferView * bv) const
{
return TEXT(bv)->cursor.x() + top_x + TEXT_TO_INSET_OFFSET;
LyXText * text = TEXT(bv);
int x = text->cursor.x() + top_x + TEXT_TO_INSET_OFFSET;
if (the_locking_inset) {
LyXFont font = text->GetFont(bv->buffer(),
text->cursor.par(), text->cursor.pos());
if (font.isVisibleRightToLeft())
x -= the_locking_inset->width(bv, font);
}
return x;
}

View File

@ -65,12 +65,8 @@
#include "encoding.h"
#include "support/lstrings.h"
//#define USE_PSPELL 1
#ifdef USE_PSPELL
#include <pspell/pspell.h>
# include <pspell/pspell.h>
#endif
using std::reverse;
@ -110,10 +106,8 @@ PspellManager * sc;
FD_form_spell_options *fd_form_spell_options = 0;
FD_form_spell_check *fd_form_spell_check = 0;
//void sigchldhandler(int sig);
void sigchldhandler(pid_t pid, int *status);
//extern void sigchldchecker(int sig);
extern void sigchldchecker(pid_t pid, int *status);
#ifndef USE_PSPELL
@ -628,7 +622,7 @@ void sc_clean_up_after_error()
// Send word to ispell and get reply
// Send word to pspell and get reply
static
isp_result * sc_check_word(string const & word)
{
@ -805,6 +799,12 @@ bool RunSpellChecker(BufferView * bv)
int newvalue;
FL_OBJECT * obj;
#ifndef NEW_INSETS
// Open all floats
bv->allFloats(1, 0);
bv->allFloats(1, 1);
#endif
#ifdef USE_PSPELL
string tmp = (lyxrc.isp_use_alt_lang) ?
lyxrc.isp_alt_lang : bv->buffer()->params.language->code();
@ -966,9 +966,7 @@ bool RunSpellChecker(BufferView * bv)
}
}
#ifndef USE_PSPELL
#warning should go somewhere more sensible
void sigchldhandler(pid_t pid, int * status)
{
if (isp_pid > 0)
@ -980,12 +978,3 @@ void sigchldhandler(pid_t pid, int * status)
}
sigchldchecker(pid, status);
}
#else
void sigchldhandler(pid_t, int *)
{
// do nothing
}
#endif

View File

@ -347,15 +347,15 @@ bool LyXText::IsBoundary(Buffer const * buf, LyXParagraph * par,
if (!lyxrc.rtl_support)
return false; // This is just for speedup
if (!bidi_InRange(pos - 1))
if (!bidi_InRange(pos - 1)) {
lyxerr << "LyXText::IsBoundary This shouldn't happen\n";
return false;
}
bool const rtl = bidi_level(pos - 1) % 2;
bool rtl2 = rtl;
if (pos == par->Last())
rtl2 = par->isRightToLeftPar(buf->params);
else if (bidi_InRange(pos))
rtl2 = bidi_level(pos) % 2;
bool rtl2 = bidi_InRange(pos)
? bidi_level(pos) % 2
: par->isRightToLeftPar(buf->params);
return rtl != rtl2;
}
@ -368,11 +368,9 @@ bool LyXText::IsBoundary(Buffer const * buf, LyXParagraph * par,
return false; // This is just for speedup
bool const rtl = font.isVisibleRightToLeft();
bool rtl2 = rtl;
if (pos == par->Last())
rtl2 = par->isRightToLeftPar(buf->params);
else if (bidi_InRange(pos))
rtl2 = bidi_level(pos) % 2;
bool rtl2 = bidi_InRange(pos)
? bidi_level(pos) % 2
: par->isRightToLeftPar(buf->params);
return rtl != rtl2;
}
@ -1913,7 +1911,7 @@ void LyXText::InsertChar(BufferView * bview, char c)
if (lyxrc.auto_number) {
if (current_font.number() == LyXFont::ON) {
if (!isdigit(c) && !strchr("+-/*", c) &&
!(strchr(".",c) &&
!(strchr(".,",c) &&
cursor.pos() >= 1 &&
cursor.pos() < cursor.par()->size() &&
GetFont(bview->buffer(),
@ -1939,7 +1937,7 @@ void LyXText::InsertChar(BufferView * bview, char c)
cursor.par(),
cursor.pos() - 1,
current_font);
} else if (strchr(".", c) &&
} else if (strchr(".,", c) &&
cursor.pos() >= 2 &&
GetFont(bview->buffer(),
cursor.par(),
@ -2113,6 +2111,10 @@ void LyXText::InsertChar(BufferView * bview, char c)
SetCursor(bview, cursor.par(), cursor.pos() + 1, false,
cursor.boundary());
if (IsBoundary(bview->buffer(), cursor.par(), cursor.pos())
!= cursor.boundary())
SetCursor(bview, cursor.par(), cursor.pos(), false,
!cursor.boundary());
if (row->next() && row->next()->par() == row->par())
need_break_row = row->next();
else
@ -3000,14 +3002,16 @@ void LyXText::Backspace(BufferView * bview)
// current_font = rawtmpfont;
// real_current_font = realtmpfont;
if (IsBoundary(bview->buffer(), cursor.par(), cursor.pos())
!= cursor.boundary())
SetCursor(bview, cursor.par(), cursor.pos(), false,
!cursor.boundary());
lastpos = cursor.par()->Last();
if (cursor.pos() == lastpos) {
if (IsBoundary(bview->buffer(), cursor.par(), cursor.pos()) != cursor.boundary())
SetCursor(bview, cursor.par(), cursor.pos(), false, !cursor.boundary());
if (cursor.pos() == lastpos)
SetCurrentFont(bview);
}
// check, wether the last characters font has changed.
// check, whether the last characters font has changed.
if (rawparfont !=
cursor.par()->GetFontSettings(bview->buffer()->params, lastpos - 1)) {
RedoHeightOfParagraph(bview, cursor);