From 0b25c68c4b4739bdc3793dcca9c539479a27e028 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Tue, 13 Nov 2001 14:47:35 +0000 Subject: [PATCH] popup fixes from Juergen ; insetgraphics fix from Herbert ; menus fix from Andre ; allow ligature breaks in spellchecker and fix smart quote after protected space (from me) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3019 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/ChangeLog | 6 ++++++ lib/ui/default.ui | 24 ++++++++++++++------- src/BufferView_pimpl.C | 16 ++++++++------ src/ChangeLog | 13 +++++++++++ src/frontends/xforms/ChangeLog | 5 +++++ src/frontends/xforms/form_external.C | 6 +++++- src/frontends/xforms/form_graphics.C | 2 +- src/frontends/xforms/forms/form_external.fd | 2 +- src/frontends/xforms/forms/form_graphics.fd | 2 +- src/insets/ChangeLog | 12 +++++++++++ src/insets/inset.h | 6 ++++++ src/insets/insetgraphics.C | 2 +- src/insets/insetspecialchar.C | 12 +++++++++++ src/insets/insetspecialchar.h | 4 ++++ src/paragraph.C | 8 +++---- src/text.C | 23 +++++--------------- 16 files changed, 101 insertions(+), 42 deletions(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index ad5c0fd277..364eb8f3c5 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,9 @@ +2001-11-13 André Pönitz + + * ui/default.ui: create a new Submenu Insert->Math, since placing + everything in the main insert menu seems not possible in the long + run... + 2001-11-08 Jean-Marc Lasgouttes * ui/default.ui: move math panel from Edit to Insert. diff --git a/lib/ui/default.ui b/lib/ui/default.ui index 6af054208c..9abaf12ea3 100644 --- a/lib/ui/default.ui +++ b/lib/ui/default.ui @@ -182,14 +182,7 @@ Menuset # INSERT MENU # Menu "insert" - Item "Math Formula|h" "math-mode" - Item "Display Formula|D" "math-display" - Item "Math Panel|l" "math-panel" - #Item "Display Formula|D" "math-mode display" - #Item "Change to Inline Math Formula|q" "math-mutate simple" - #Item "Change to Displayed Math Formula|q" "math-mutate equation" - #Item "Change to Eqnarray Environment|q" "math-mutate eqnarray" - #Item "Change to Align Environment|g" "math-mutate align" + Submenu "Math|h" "insert_math" Separator Submenu "Special Character|S" "insert_special" Item "Citation Reference...|C" "citation-insert" @@ -229,6 +222,21 @@ Menuset Item "Menu Separator|M" "menu-separator-insert" End + Menu "insert_math" + Item "Inline Formula|h" "math-mode" + Item "Display Formula|D" "math-display" + Item "Eqnarray environment|E" "command-sequence math-mode; math-mutate eqnarray;" + Item "AMS align environment|A" "command-sequence math-mode; math-mutate align;" + Item "AMS alignat environment|t" "command-sequence math-mode; math-mutate alignat;" + Item "AMS xalignat environment|x" "command-sequence math-mode; math-mutate xalignat;" + Item "AMS xxalignat environment" "command-sequence math-mode; math-mutate xxalignat;" + Separator + Item "Array environment|y" "math-insert matrix 2 2" + Item "Cases environment|C" "math-insert cases 2" + Separator + Item "Math Panel|l" "math-panel" + End + Menu "insert_floats" FloatInsert End diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 34814ff384..0a9200cfdb 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -3241,19 +3241,23 @@ void BufferView::Pimpl::specialChar(InsetSpecialChar::Kind kind) void BufferView::Pimpl::smartQuote() { + LyXText const * lt = bv_->getLyXText(); + Paragraph const * par = lt->cursor.par(); + Paragraph::size_type pos = lt->cursor.pos(); char c; - LyXText * lt = bv_->getLyXText(); - if (lt->cursor.pos()) - c = lt->cursor.par()->getChar(lt->cursor.pos() - 1); - else + if (!pos + || (par->isInset(pos - 1) + && par->getInset(pos - 1)->isSpace())) c = ' '; + else + c = par->getChar(pos - 1); + hideCursor(); LyXLayout const & style = textclasslist.Style( - bv_->buffer()->params.textclass, - lt->cursor.par()->getLayout()); + bv_->buffer()->params.textclass, par->getLayout()); if (style.pass_thru || (!insertInset(new InsetQuotes(c, bv_->buffer()->params)))) diff --git a/src/ChangeLog b/src/ChangeLog index 9879aa62fb..8132e4a034 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2001-11-13 Jean-Marc Lasgouttes + + * text.C (selectNextWordToSpellcheck): do not test explicitely for + insets which are part of a word. Paragraph::isLetter takes care of + that now. Use Paragraph::isInset to identify insets. + (selectSelectedWord): do not test for hyphenation break. + + * BufferView_pimpl.C (smartQuote): use Inset::isSpace, so + that protected spaces are considered as spaces. + + * paragraph.C (isLetter): cleanup the code for ispell extras; use + Inset::isLetter. + 2001-11-12 John Levon * lyxserver.h: diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index b7f4fab130..9f8fbf2323 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,8 @@ +2001-11-13 Jürgen Spitzmüller + + * forms/form_graphics.fd: fixed shortcut clash + * forms/form-external.fd: added shortcut for "Apply" + 2001-11-12 John Levon * FormFiledialog.C: don't reset path if new dir diff --git a/src/frontends/xforms/form_external.C b/src/frontends/xforms/form_external.C index ea9e8bbb37..2110fb7146 100644 --- a/src/frontends/xforms/form_external.C +++ b/src/frontends/xforms/form_external.C @@ -93,7 +93,11 @@ FD_form_external * FormExternal::build_external() fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); fl_set_object_callback(obj, C_FormBaseOKCB, 0); - fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 355, 270, 90, 30, _("Apply")); + { + char const * const dummy = N_("Apply|#A"); + fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 355, 270, 90, 30, idex(_(dummy))); + fl_set_button_shortcut(obj, scex(_(dummy)), 1); + } fl_set_object_color(obj, FL_COL1, FL_BLACK); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); diff --git a/src/frontends/xforms/form_graphics.C b/src/frontends/xforms/form_graphics.C index 776fc2021c..5c2619cbec 100644 --- a/src/frontends/xforms/form_graphics.C +++ b/src/frontends/xforms/form_graphics.C @@ -89,7 +89,7 @@ FD_form_graphics * FormGraphics::build_graphics() fl_set_object_callback(obj, C_FormBaseInputCB, 0); obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 20, 230, 450, 90, _("Subcaption")); { - char const * const dummy = N_("Subcaption|#S"); + char const * const dummy = N_("Subcaption|#u"); fdui->check_subcaption = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 110, 240, 30, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } diff --git a/src/frontends/xforms/forms/form_external.fd b/src/frontends/xforms/forms/form_external.fd index 5168cc6401..71ca5971c2 100644 --- a/src/frontends/xforms/forms/form_external.fd +++ b/src/frontends/xforms/forms/form_external.fd @@ -202,7 +202,7 @@ alignment: FL_ALIGN_CENTER style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Apply +label: Apply|#A shortcut: resize: FL_RESIZE_ALL gravity: FL_SouthEast FL_SouthEast diff --git a/src/frontends/xforms/forms/form_graphics.fd b/src/frontends/xforms/forms/form_graphics.fd index ce5001485a..fae87e132a 100644 --- a/src/frontends/xforms/forms/form_graphics.fd +++ b/src/frontends/xforms/forms/form_graphics.fd @@ -310,7 +310,7 @@ alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_DEFAULT_SIZE lcol: FL_BLACK -label: Subcaption|#S +label: Subcaption|#u shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 084358601e..130f235be2 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,15 @@ +2001-11-13 Herbert Voss + + * insetgraphic.C: fix scale bug + +2001-11-13 Jean-Marc Lasgouttes + + * inset.h (isSpace): + (isLetter): new virtual methods. + + * insetspecialchar.C (isSpace): + (isLetter): implement here. + 2001-11-04 John Levon * inset.h: new inline helpers diff --git a/src/insets/inset.h b/src/insets/inset.h index 49e38c05de..47ef8c9125 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -295,6 +295,12 @@ public: // needed for spellchecking text /// virtual bool allowSpellcheck() { return false; } + + // is this equivalent to a letter? + virtual bool isLetter() const { return false; } + // is this equivalent to a space? + virtual bool isSpace() const { return false; } + protected: /// mutable int top_x; diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index b0d556e9e0..264c83548f 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -514,7 +514,7 @@ void formatResize(ostream & os, string const & key, break; case InsetGraphicsParams::SCALE: - os << "scale" << '=' << size << ','; + os << "scale" << '=' << size/100 << ','; } } diff --git a/src/insets/insetspecialchar.C b/src/insets/insetspecialchar.C index 0524855dc0..a57eb58f51 100644 --- a/src/insets/insetspecialchar.C +++ b/src/insets/insetspecialchar.C @@ -321,3 +321,15 @@ void InsetSpecialChar::validate(LaTeXFeatures & features) const features.lyxarrow = true; } } + + +bool InsetSpecialChar::isLetter() const +{ + return kind_ == HYPHENATION || kind_ == LIGATURE_BREAK; +} + + +bool InsetSpecialChar::isSpace() const +{ + return kind_ == PROTECTED_SEPARATOR; +} diff --git a/src/insets/insetspecialchar.h b/src/insets/insetspecialchar.h index 6fcad6c89f..5acb4e22ac 100644 --- a/src/insets/insetspecialchar.h +++ b/src/insets/insetspecialchar.h @@ -82,6 +82,10 @@ public: }; /// void validate(LaTeXFeatures &) const; + /// is this equivalent to a letter? + bool isLetter() const; + /// is this equivalent to a space? + bool isSpace() const; private: /// And which kind is this? Kind kind_; diff --git a/src/paragraph.C b/src/paragraph.C index 8dd178d1de..ece9443eb4 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -1878,13 +1878,11 @@ bool Paragraph::isLetter(Paragraph::size_type pos) const value_type const c = getChar(pos); if (IsLetterChar(c)) return true; - // '\0' is not a letter, allthough every string contains "" (below) - if (c == '\0') - return false; + if (isInset(pos)) + return getInset(pos)->isLetter(); // We want to pass the ' and escape chars to ispell string const extra = lyxrc.isp_esc_chars + '\''; - char ch[2] = { c, 0 }; - return contains(extra, ch); + return contains(extra, c); } diff --git a/src/text.C b/src/text.C index f219950b13..2a4d25aff3 100644 --- a/src/text.C +++ b/src/text.C @@ -21,7 +21,6 @@ #include "support/lstrings.h" #include "insets/insetbib.h" #include "insets/insettext.h" -#include "insets/insetspecialchar.h" #include "lyx_gui_misc.h" #include "gettext.h" #include "bufferparams.h" @@ -2365,16 +2364,10 @@ string const LyXText::selectNextWordToSpellcheck(BufferView * bview, Inset * inset; - // and find the end of the word - // (optional hyphens are part of a word) + // and find the end of the word (insets like optional hyphens + // and ligature break are part of a word) while (cursor.pos() < cursor.par()->size() - && (cursor.par()->isLetter(cursor.pos())) - // assignment is intentional here - || ((inset = getInset()) - && inset->lyxCode() == Inset::SPECIALCHAR_CODE - && static_cast(inset)->kind() - == InsetSpecialChar::HYPHENATION - )) + && (cursor.par()->isLetter(cursor.pos()))) cursor.pos(cursor.pos() + 1); // Finally, we copy the word to a string and return it @@ -2382,7 +2375,7 @@ string const LyXText::selectNextWordToSpellcheck(BufferView * bview, if (selection.cursor.pos() < cursor.pos()) { Paragraph::size_type i; for (i = selection.cursor.pos(); i < cursor.pos(); ++i) { - if (cursor.par()->getChar(i) != Paragraph::META_INSET) + if (!cursor.par()->isInset(i)) str += cursor.par()->getChar(i); } } @@ -2406,13 +2399,7 @@ void LyXText::selectSelectedWord(BufferView * bview) // now find the end of the word while (cursor.pos() < cursor.par()->size() - && (cursor.par()->isLetter(cursor.pos()) - // assignment is intentional here - || ((inset = getInset()) - && inset->lyxCode() == Inset::SPECIALCHAR_CODE - && static_cast(inset)->kind() - == InsetSpecialChar::HYPHENATION - ))) + && (cursor.par()->isLetter(cursor.pos()))) cursor.pos(cursor.pos() + 1); setCursor(bview, cursor.par(), cursor.pos());