+2000-12-17 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * src/kbsequence.C (addkey): also clear sequence and modifiers if
+ length == 0
+
+ * src/BufferView2.C (theLockingInset): return 0 if text is 0
+
+2000-12-17 Dekel Tsur <dekelts@tau.ac.il>
+
+ * Many files: Fix RTL support for insettext.
+
2000-12-11 John Levon <moz@compsoc.man.ac.uk>
* README: add mention of broken ghostscript versions, remove
2000-12-11 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
+ * src/insets/insetexternal.C (getScreenLabel): Return a default
+ value if the template label is empty.
+
* src/lyxlookup.C: do not condition on FL_REVISION.
* forms/sp_form.fd:
src/frontends/kde/tocdlg.C
src/frontends/kde/urldlg.C
src/frontends/xforms/FormBase.h
-src/frontends/xforms/FormCitation.C
src/frontends/xforms/form_citation.C
-src/frontends/xforms/FormCopyright.C
+src/frontends/xforms/FormCitation.C
src/frontends/xforms/form_copyright.C
-src/frontends/xforms/FormDocument.C
+src/frontends/xforms/FormCopyright.C
src/frontends/xforms/form_document.C
-src/frontends/xforms/FormError.C
+src/frontends/xforms/FormDocument.C
src/frontends/xforms/form_error.C
-src/frontends/xforms/FormGraphics.C
+src/frontends/xforms/FormError.C
src/frontends/xforms/form_graphics.C
-src/frontends/xforms/FormIndex.C
+src/frontends/xforms/FormGraphics.C
src/frontends/xforms/form_index.C
+src/frontends/xforms/FormIndex.C
src/frontends/xforms/FormInset.h
-src/frontends/xforms/FormParagraph.C
src/frontends/xforms/form_paragraph.C
-src/frontends/xforms/FormPreferences.C
+src/frontends/xforms/FormParagraph.C
src/frontends/xforms/form_preferences.C
-src/frontends/xforms/FormPrint.C
+src/frontends/xforms/FormPreferences.C
src/frontends/xforms/form_print.C
-src/frontends/xforms/FormRef.C
+src/frontends/xforms/FormPrint.C
src/frontends/xforms/form_ref.C
-src/frontends/xforms/FormTabular.C
+src/frontends/xforms/FormRef.C
src/frontends/xforms/form_tabular.C
-src/frontends/xforms/FormTabularCreate.C
+src/frontends/xforms/FormTabular.C
src/frontends/xforms/form_tabular_create.C
-src/frontends/xforms/FormToc.C
+src/frontends/xforms/FormTabularCreate.C
src/frontends/xforms/form_toc.C
-src/frontends/xforms/FormUrl.C
+src/frontends/xforms/FormToc.C
src/frontends/xforms/form_url.C
+src/frontends/xforms/FormUrl.C
src/frontends/xforms/input_validators.C
src/frontends/xforms/Menubar_pimpl.C
src/frontends/xforms/xform_helpers.C
*/
LyXText * text;
///
+ LyXText * getLyXText() const;
+ ///
int workWidth() const;
///
UpdatableInset * theLockingInset() const;
theLockingInset()->GetLockingInset()))
text->SetCursor(this, cursor,
cursor.par(), cursor.pos() - 1);
+ LyXScreen::Cursor_Shape shape = LyXScreen::BAR_SHAPE;
+ LyXText * txt = getLyXText();
+ if (theLockingInset()->GetLockingInset()->LyxCode() ==
+ Inset::TEXT_CODE &&
+ (txt->real_current_font.language() !=
+ buffer()->params.language
+ || txt->real_current_font.isVisibleRightToLeft()
+ != buffer()->params.language->RightToLeft()))
+ shape = (txt->real_current_font.isVisibleRightToLeft())
+ ? LyXScreen::REVERSED_L_SHAPE
+ : LyXScreen::L_SHAPE;
y += cursor.y() + theLockingInset()->InsetInInsetY();
pimpl_->screen_->ShowManualCursor(text, x, y, asc, desc,
- LyXScreen::BAR_SHAPE);
+ shape);
}
}
UpdatableInset * BufferView::theLockingInset() const
{
- return text->the_locking_inset;
+ // If NULL is not allowed we should put an Assert here. (Lgb)
+ if (text)
+ return text->the_locking_inset;
+ return 0;
}
{
text->the_locking_inset = inset;
}
+
+
+LyXText * BufferView::getLyXText() const
+{
+ if (theLockingInset()) {
+ LyXText * txt = theLockingInset()->getLyXText(this);
+ if (txt)
+ return txt;
+ }
+ return text;
+}
+
if (!lyxrc.rtl_support)
return;
- if (bv_->text->real_current_font.isRightToLeft() &&
- bv_->text->real_current_font.latex() != LyXFont::ON) {
+ LyXText * text = bv_->getLyXText();
+ if (text->real_current_font.isRightToLeft() &&
+ text->real_current_font.latex() != LyXFont::ON) {
if (owner_->getIntl()->primarykeymap)
owner_->getIntl()->KeyMapSec();
} else {
if (lyxerr.debugging(Debug::KEY)) {
char const * tmp = XKeysymToString(key);
char const * tmp2 = XKeysymToString(keysym);
- string stm = (tmp ? tmp : "");
- string stm2 = (tmp2 ? tmp2 : "");
+ string const stm = (tmp ? tmp : "");
+ string const stm2 = (tmp2 ? tmp2 : "");
lyxerr << "WorkArea: Key is `" << stm << "' ["
<< key << "]" << endl;
}
#endif
- unsigned int ret_state = xke->state;
+ unsigned int const ret_state = xke->state;
// If you have a better way to handle "wild-output" of
// characters after the key has been released than the one
<< xke->time - last_time_pressed
<< endl;
if (xke->time - last_time_pressed < 35 // should perhaps be tunable
- && xke->state == last_state_pressed
+ && ret_state == last_state_pressed
&& xke->keycode == last_key_pressed) {
lyxerr[Debug::KEY]
<< "Workarea: Purging X events." << endl;
}
last_time_pressed = xke->time;
last_key_pressed = xke->keycode;
- last_state_pressed = xke->state;
+ last_state_pressed = ret_state;
area->workAreaKeyPress(ret_key, ret_state);
}
if (bv->available()) {
// I think we should only show changes from the default
// font. (Asger)
- LyXText *text = 0;
-
- if (bv->theLockingInset())
- text = bv->theLockingInset()->getLyXText(bv);
- if (!text)
- text = bv->text;
-
+ LyXText * text = bv->getLyXText();
Buffer * buffer = bv->buffer();
LyXFont font = text->real_current_font;
LyXFont const & defaultfont =
if (font.language() != ignore_language ||
font.latex() != LyXFont::IGNORE ||
font.number() != LyXFont::IGNORE) {
- LyXText * text = bv->text;
+ LyXText * text = bv->getLyXText();
LyXCursor & cursor = text->cursor;
text->ComputeBidiTables(bv->buffer(), cursor.row());
if (cursor.boundary() !=
}
-LyXText * Inset::getLyXText(BufferView * bv) const
+LyXText * Inset::getLyXText(BufferView const * bv) const
{
if (owner())
return owner()->getLyXText(bv);
}
-LyXText * InsetCollapsable::getLyXText(BufferView * bv) const
+LyXText * InsetCollapsable::getLyXText(BufferView const * bv) const
{
return inset->getLyXText(bv);
}
///
int getMaxWidth(Painter & pain, UpdatableInset const *) const;
///
- LyXText * getLyXText(BufferView *) const;
+ LyXText * getLyXText(BufferView const *) const;
///
void deleteLyXText(BufferView *, bool recursive=true) const;
///
return _("External");
} else {
ExternalTemplate const & et = getTemplate(templatename);
- return doSubstitution(0, et.guiName);
+ if (et.guiName.empty())
+ return "ext: ???";
+ else
+ return doSubstitution(0, et.guiName);
}
}
++i;
}
// This should never happen
- Assert(false);
+ /// This can happen if someone sends you a lyx file that uses
+ /// external templates that are defined only on his machine
+ //Assert(false);
return 0;
}
}
-LyXText * InsetTabular::getLyXText(BufferView * bv) const
+LyXText * InsetTabular::getLyXText(BufferView const * bv) const
{
if (the_locking_inset)
return the_locking_inset->getLyXText(bv);
///
Buffer * BufferOwner() const { return const_cast<Buffer *>(buffer); }
///
- LyXText * getLyXText(BufferView *) const;
+ LyXText * getLyXText(BufferView const *) const;
///
void resizeLyXText(BufferView *) const;
///
locked = true;
the_locking_inset = 0;
inset_pos = inset_x = inset_y = 0;
+ inset_boundary = false;
inset_par = 0;
old_par = 0;
if (!checkAndActivateInset(bv, x, y, button))
inset_y = cy(bv) + drawTextYOffset;
inset_pos = cpos(bv);
inset_par = cpar(bv);
+ inset_boundary = cboundary(bv);
TEXT(bv)->UpdateInset(bv, the_locking_inset);
return true;
} else if (the_locking_inset && (the_locking_inset == inset)) {
inset_y = cy(bv) + drawTextYOffset;
inset_pos = cpos(bv);
inset_par = cpar(bv);
+ inset_boundary = cboundary(bv);
the_locking_inset = uinset;
uinset->InsetButtonPress(bv, x - inset_x, y - inset_y, button);
uinset->Edit(bv, x - inset_x, y - inset_y, 0);
HideInsetCursor(bv);
switch (action) {
// Normal chars
- case -1:
+ case LFUN_UNKNOWN_ACTION:
if (bv->buffer()->isReadonly()) {
LyXBell();
// setErrorMessage(N_("Document is read only"));
font.setLanguage(text->cursor.par()->getParLanguage(bv->buffer()->params));
SetFont(bv, font, false);
}
+ bv->setState();
if (lyxrc.auto_region_delete) {
if (TEXT(bv)->selection){
TEXT(bv)->CutSelection(bv, false);
return TEXT(bv)->cursor.par();
}
+bool InsetText::cboundary(BufferView * bv) const
+{
+ return TEXT(bv)->cursor.boundary();
+}
+
Row * InsetText::crow(BufferView * bv) const
{
}
-LyXText * InsetText::getLyXText(BufferView * bv) const
+LyXText * InsetText::getLyXText(BufferView const * lbv) const
{
+ // Super UGLY! (Lgb)
+ BufferView * bv = const_cast<BufferView *>(lbv);
+
if ((cache.find(bv) != cache.end()) && cache[bv])
return cache[bv];
LyXText * lt = new LyXText(const_cast<InsetText *>(this));
lt->init(bv);
cache[bv] = lt;
if (the_locking_inset) {
- lt->SetCursor(bv, inset_par, inset_pos);
+ lt->SetCursor(bv, inset_par, inset_pos, true, inset_boundary);
}
return lt;
}
LyXParagraph::size_type pos = 0;
LyXParagraph::size_type selstartpos = 0;
LyXParagraph::size_type selendpos = 0;
+ bool boundary = false;
+ bool selstartboundary = false;
+ bool selendboundary = false;
int selection = 0;
int mark_set = 0;
if (locked) {
lpar = TEXT(bv)->cursor.par();
pos = TEXT(bv)->cursor.pos();
+ boundary = TEXT(bv)->cursor.boundary();
selstartpar = TEXT(bv)->sel_start_cursor.par();
selstartpos = TEXT(bv)->sel_start_cursor.pos();
+ selstartboundary = TEXT(bv)->sel_start_cursor.boundary();
selendpar = TEXT(bv)->sel_end_cursor.par();
selendpos = TEXT(bv)->sel_end_cursor.pos();
+ selendboundary = TEXT(bv)->sel_end_cursor.boundary();
selection = TEXT(bv)->selection;
mark_set = TEXT(bv)->mark_set;
}
* Mechanism when setting the cursor */
TEXT(bv)->mark_set = mark_set;
if (selection) {
- TEXT(bv)->SetCursor(bv, selstartpar, selstartpos);
+ TEXT(bv)->SetCursor(bv, selstartpar, selstartpos,true,
+ selstartboundary);
TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
- TEXT(bv)->SetCursor(bv, selendpar, selendpos);
+ TEXT(bv)->SetCursor(bv, selendpar, selendpos, true, selendboundary);
TEXT(bv)->SetSelection();
TEXT(bv)->SetCursor(bv, lpar, pos);
} else {
- TEXT(bv)->SetCursor(bv, lpar, pos);
+ TEXT(bv)->SetCursor(bv, lpar, pos, true, boundary);
TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
TEXT(bv)->selection = false;
}
///
void SetFrameColor(BufferView *, LColor::color);
///
- LyXText * getLyXText(BufferView *) const;
+ LyXText * getLyXText(BufferView const *) const;
///
void deleteLyXText(BufferView *, bool recursive=true) const;
///
///
LyXParagraph * cpar(BufferView *) const;
///
+ bool cboundary(BufferView *) const;
+ ///
Row * crow(BufferView *) const;
/// This instead of a macro
///
LyXParagraph::size_type inset_pos;
///
+ bool inset_boundary;
+ ///
mutable int inset_x;
///
mutable int inset_y;
// because we could have fake text insets and have to call this
// inside them without cast!!!
///
- virtual LyXText * getLyXText(BufferView *) const;
+ virtual LyXText * getLyXText(BufferView const *) const;
///
virtual void deleteLyXText(BufferView *, bool = true) const {}
///
// This binds a key to an action
int kb_keymap::bind(string const & seq, int action)
{
+ if (lyxerr.debugging(Debug::KBMAP)) {
+ lyxerr << "BIND: Sequence `"
+ << seq << "' Action `"
+ << action << "'" << endl;
+ }
+
kb_sequence k;
int const res = k.parse(seq);
int kb_sequence::addkey(unsigned int key,
unsigned int mod, unsigned int nmod /*= 0*/)
{
- if (length < 0) {
+ //lyxerr << "kb_sequence::addkey: length is [" << length << "]\n"
+ // << "kb_sequence::addkey::key == [" << key << "]\n"
+ // << "kb_sequence::addkey::mod == [" << mod << "]" << endl;
+
+ if (length <= 0) {
length = 0;
sequence.clear();
modifiers.clear();
Called by : [user]
Purpose : print the currently defined sequence into a string
Parameters: buf - string where the result goes
- maxlen - length of string (including '\0')
when_defined - only print when sequence is real: length > 0.
Returns : 0, if ok, -1 if string too long
\* ---F------------------------------------------------------------------- */
int kb_sequence::print(string & buf, bool when_defined) const
{
+ //lyxerr << "kb_sequence::print: length is [" << length << "]" << endl;
+
KeySym key;
unsigned int mod;
int l = length;
for (int i = 0; i < l; ++i) {
key = sequence[i];
mod = modifiers[i] & 0xffff;
+ //lyxerr << "kb_sequence::sequence[" << i << "] == [" << key << "]\n"
+ // << "kb_sequence::modifiers[" << i << "] == [" << mod << "]"
+ // << endl;
printKeysym(key, mod, buf); // RVDK_PATCH_5
if (lyxerr.debugging(Debug::KEY)) {
char * tmp = XKeysymToString(keysym);
- string stm = (tmp ? tmp : "");
+ string const stm = (tmp ? tmp : "");
lyxerr << "KeySym is "
<< stm
<< "["
- << keysym << "]"
+ << keysym << "] State is ["
+ << state << "]"
<< endl;
}
// Do nothing if we have nothing (JMarc)
int action = cancel_meta_seq.addkey(keysym, state
&(ShiftMask|ControlMask
|Mod1Mask));
-
+ if (lyxerr.debugging(Debug::KEY)) {
+ lyxerr << "action first set to [" << action << "]" << endl;
+ }
+
// When not cancel or meta-fake, do the normal lookup.
// Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
// Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
-
+ if (lyxerr.debugging(Debug::KEY)) {
+ lyxerr << "meta_fake_bit is [" << meta_fake_bit << "]" << endl;
+ }
// remove Caps Lock and Mod2 as a modifiers
action = keyseq.addkey(keysym,
(state | meta_fake_bit)
&(ShiftMask|ControlMask
- |Mod1Mask));
+ |Mod1Mask));
+ if (lyxerr.debugging(Debug::KEY)) {
+ lyxerr << "action now set to [" << action << "]" << endl;
+ }
}
// Dont remove this unless you know what you are doing.
meta_fake_bit = 0;
return 0;
}
- char isochar = keyseq.getiso();
+ char const isochar = keyseq.getiso();
if (!(state & ControlMask) &&
!(state & Mod1Mask) &&
(isochar && keysym < 0xF000)) {
if (buf) {
func_status box = LyXFunc::ToggleOff;
- LyXFont font;
- if (owner->view()->theLockingInset() &&
- owner->view()->theLockingInset()->getLyXText(owner->view()))
- font = owner->view()->theLockingInset()->
- getLyXText(owner->view())->real_current_font;
- else
- font = owner->view()->text->real_current_font;
+ LyXFont const & font =
+ owner->view()->getLyXText()->real_current_font;
switch (action) {
case LFUN_EMPH:
if (font.emph() == LyXFont::ON)
string argument;
kb_action action;
- LyXText * text = 0;
// we have not done anything wrong yet.
errorstat = false;
if (owner->view()->available())
owner->view()->hideCursor();
+ // We have to do this heare because of te goto below. (Lgb)
+ LyXText * text = owner->view()->getLyXText();
+
// We cannot use this function here
if (getStatus(ac) & Disabled)
goto exit_with_message;
}
}
- string shortcuts = toplevel_keymap->findbinding(pseudoaction);
+ string const shortcuts =
+ toplevel_keymap->findbinding(pseudoaction);
if (!shortcuts.empty()) {
comname += ": " + shortcuts;
}
}
}
- if (owner->view()->theLockingInset())
- text = owner->view()->theLockingInset()->
- getLyXText(owner->view());
}
- if (!text)
- text = owner->view()->text;
-
switch (action) {
// --- Misc -------------------------------------------
case LFUN_WORDFINDFORWARD :
#ifndef LYX_FUNCTIONAL_H
#define LYX_FUNCTIONAL_H
+/** \file lyxfunctional.h
+ \brief Convenient function objects for use with LyX
+ This is currently a small collection of small function objects for use
+ together with std::algorithms.
+**/
+
#include <iterator>
//namespace lyx {
+
template<class R, class C, class A>
class class_fun_t {
public:
void(C::*cmf)(A);
};
-
+
+/// Use to call a class method with a container element.
+/** Most easily used as a functor to std::algoritms.
+ Small example:
+ \verbatim
+ A a; // class that have a int print(string const &) method
+ vector<string> vs;
+ for_each(vs.begin(), vs.end(), class_fun(int, vs, &A::print);
+ \endverbatim
+**/
template <class R, class C, class A> class_fun_t<R, C, A>
class_fun(C & c, R(C::*f)(A))
{
// set the cursor again. Otherwise
// dangling pointers are possible
- SetCursor(bview, cursor.par(), cursor.pos());
+ SetCursor(bview, cursor.par(), cursor.pos(),
+ false, cursor.boundary());
sel_cursor = cursor;
return;
}
if (selection) {
tmpcursor = cursor;
- SetCursorIntern(bview, sel_cursor.par(), sel_cursor.pos());
+ SetCursorIntern(bview, sel_cursor.par(), sel_cursor.pos(),
+ false, sel_cursor.boundary());
sel_cursor = cursor;
SetCursorIntern(bview, sel_start_cursor.par(),
- sel_start_cursor.pos());
+ sel_start_cursor.pos(),
+ false, sel_start_cursor.boundary());
sel_start_cursor = cursor;
SetCursorIntern(bview, sel_end_cursor.par(),
- sel_end_cursor.pos());
+ sel_end_cursor.pos(),
+ false, sel_end_cursor.boundary());
sel_end_cursor = cursor;
SetCursorIntern(bview, last_sel_cursor.par(),
- last_sel_cursor.pos());
+ last_sel_cursor.pos(),
+ false, last_sel_cursor.boundary());
last_sel_cursor = cursor;
cursor = tmpcursor;
}
- SetCursorIntern(bview, cursor.par(), cursor.pos());
+ SetCursorIntern(bview, cursor.par(), cursor.pos(),
+ false, cursor.boundary());
}