From: Jean-Marc Lasgouttes Date: Fri, 27 Jul 2001 16:07:33 +0000 (+0000) Subject: selection improvement + inset quote fixes X-Git-Tag: 1.6.10~20972 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=bdba99dcf94c7e12f34add5050416fd7632650a6;p=lyx.git selection improvement + inset quote fixes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2373 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/po/POTFILES.in b/po/POTFILES.in index 1e07b1cca4..15d17461eb 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -10,8 +10,8 @@ src/CutAndPaste.C src/debug.C src/exporter.C src/ext_l10n.h -src/figure_form.C src/figureForm.C +src/figure_form.C src/FontLoader.C src/frontends/controllers/biblio.C src/frontends/controllers/ButtonController.h @@ -49,67 +49,67 @@ src/frontends/qt2/paragraphdlgimpl.C src/frontends/qt2/tabularcreatedlgimpl.C src/frontends/xforms/combox.C src/frontends/xforms/FileDialog.C -src/frontends/xforms/form_aboutlyx.C src/frontends/xforms/FormAboutlyx.C -src/frontends/xforms/form_bibitem.C +src/frontends/xforms/form_aboutlyx.C src/frontends/xforms/FormBibitem.C -src/frontends/xforms/form_bibtex.C +src/frontends/xforms/form_bibitem.C src/frontends/xforms/FormBibtex.C +src/frontends/xforms/form_bibtex.C src/frontends/xforms/form_browser.C -src/frontends/xforms/form_character.C src/frontends/xforms/FormCharacter.C -src/frontends/xforms/form_citation.C +src/frontends/xforms/form_character.C src/frontends/xforms/FormCitation.C -src/frontends/xforms/form_document.C +src/frontends/xforms/form_citation.C src/frontends/xforms/FormDocument.C -src/frontends/xforms/form_error.C +src/frontends/xforms/form_document.C src/frontends/xforms/FormError.C -src/frontends/xforms/form_external.C +src/frontends/xforms/form_error.C src/frontends/xforms/FormExternal.C -src/frontends/xforms/form_filedialog.C +src/frontends/xforms/form_external.C src/frontends/xforms/FormFiledialog.C -src/frontends/xforms/form_graphics.C +src/frontends/xforms/form_filedialog.C src/frontends/xforms/FormGraphics.C -src/frontends/xforms/form_include.C +src/frontends/xforms/form_graphics.C src/frontends/xforms/FormInclude.C -src/frontends/xforms/form_index.C +src/frontends/xforms/form_include.C src/frontends/xforms/FormIndex.C +src/frontends/xforms/form_index.C src/frontends/xforms/FormLog.C src/frontends/xforms/FormMathsBitmap.C -src/frontends/xforms/form_maths_deco.C src/frontends/xforms/FormMathsDeco.C -src/frontends/xforms/form_maths_delim.C +src/frontends/xforms/form_maths_deco.C src/frontends/xforms/FormMathsDelim.C -src/frontends/xforms/form_maths_matrix.C +src/frontends/xforms/form_maths_delim.C src/frontends/xforms/FormMathsMatrix.C -src/frontends/xforms/form_maths_panel.C +src/frontends/xforms/form_maths_matrix.C src/frontends/xforms/FormMathsPanel.C -src/frontends/xforms/form_maths_space.C +src/frontends/xforms/form_maths_panel.C src/frontends/xforms/FormMathsSpace.C -src/frontends/xforms/form_minipage.C +src/frontends/xforms/form_maths_space.C src/frontends/xforms/FormMinipage.C -src/frontends/xforms/form_paragraph.C +src/frontends/xforms/form_minipage.C src/frontends/xforms/FormParagraph.C -src/frontends/xforms/form_preamble.C +src/frontends/xforms/form_paragraph.C src/frontends/xforms/FormPreamble.C -src/frontends/xforms/form_preferences.C +src/frontends/xforms/form_preamble.C src/frontends/xforms/FormPreferences.C -src/frontends/xforms/form_print.C +src/frontends/xforms/form_preferences.C src/frontends/xforms/FormPrint.C -src/frontends/xforms/form_ref.C +src/frontends/xforms/form_print.C src/frontends/xforms/FormRef.C -src/frontends/xforms/form_search.C +src/frontends/xforms/form_ref.C src/frontends/xforms/FormSearch.C -src/frontends/xforms/form_spellchecker.C +src/frontends/xforms/form_search.C src/frontends/xforms/FormSpellchecker.C -src/frontends/xforms/form_tabular.C +src/frontends/xforms/form_spellchecker.C src/frontends/xforms/FormTabular.C -src/frontends/xforms/form_tabular_create.C +src/frontends/xforms/form_tabular.C src/frontends/xforms/FormTabularCreate.C -src/frontends/xforms/form_toc.C +src/frontends/xforms/form_tabular_create.C src/frontends/xforms/FormToc.C -src/frontends/xforms/form_url.C +src/frontends/xforms/form_toc.C src/frontends/xforms/FormUrl.C +src/frontends/xforms/form_url.C src/frontends/xforms/FormVCLog.C src/frontends/xforms/input_validators.C src/frontends/xforms/Menubar_pimpl.C @@ -130,7 +130,6 @@ src/insets/insetfoot.C src/insets/insetgraphics.C src/insets/insetinclude.C src/insets/insetindex.C -src/insets/insetinfo.C src/insets/insetlabel.C src/insets/insetlist.C src/insets/insetmarginal.C diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index e3a4b0f8a1..f52dd19560 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -678,10 +678,10 @@ void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, unsigned int button) if (text->bv_owner) { screen_->hideCursor(); screen_->toggleSelection(text, bv_); - text->selectWord(bv_); + text->selectWord(bv_, LyXText::WHOLE_WORD_STRICT); screen_->toggleSelection(text, bv_, false); } else { - text->selectWord(bv_); + text->selectWord(bv_, LyXText::WHOLE_WORD_STRICT); } /* This will fit the cursor on the screen * if necessary */ @@ -2979,15 +2979,22 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) case LFUN_INDEX_CREATE: { InsetCommandParams p("index"); + LyXText * lt = bv_->getLyXText(); if (argument.empty()) { // Get word or selection - bv_->getLyXText()->selectWordWhenUnderCursor(bv_); + lt->selectWordWhenUnderCursor(bv_, LyXText::PREVIOUS_WORD); - string const curstring = - bv_->getLyXText()->selectionAsString(buffer_); - - p.setContents(curstring); + if (!lt->selection.set()) { + owner_->message(_("Nothing to index!")); + break; + } + if (lt->selection.start.par() != lt->selection.end.par()) { + owner_->message(_("Cannot index more than one paragraph!")); + break; + } + + p.setContents(lt->selectionAsString(buffer_)); } else { p.setContents(argument); } @@ -3011,13 +3018,20 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) case LFUN_INDEX_INSERT_LAST: { + LyXText * lt = bv_->getLyXText(); // Get word or selection - bv_->getLyXText()->selectWordWhenUnderCursor(bv_); - - string const curstring = - bv_->getLyXText()->selectionAsString(buffer_); + lt->selectWordWhenUnderCursor(bv_, LyXText::PREVIOUS_WORD); - InsetCommandParams p("index", curstring); + if (!lt->selection.set()) { + owner_->message(_("Nothing to index!")); + break; + } + if (lt->selection.start.par() != lt->selection.end.par()) { + owner_->message(_("Cannot index more than one paragraph!")); + break; + } + + InsetCommandParams p("index", lt->selectionAsString(buffer_)); InsetIndex * inset = new InsetIndex(p); if (!insertInset(inset)) diff --git a/src/ChangeLog b/src/ChangeLog index 087933c379..0990cc7243 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,15 @@ +2001-07-27 Jean-Marc Lasgouttes + + * BufferView_pimpl.C (Dispatch): use WHOLE_WORD selection for + index; also, check that there is something to index, and that it + does not span over several paragraphs. + (doubleClick): use WHOLE_WORD_STRICT for double click. + + * text.C (getWord): handle new WHOLE_WORD_STRICT word_location value. + + * text2.C (toggleFree): do selection with WHOLE_WORD_STRICT + scheme. + 2001-07-27 Juergen Vigna * text2.C: font.realize function adaption. diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 13fc1ad36f..fa4c5b4a58 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2001-07-26 Yves Bastide + + * insetquotes.C (dispString): display the right ISO8859-{1,9,15} + quotes + 2001-07-27 Juergen Vigna * inset.h: remove not used font variable in parameter. diff --git a/src/insets/insetquotes.C b/src/insets/insetquotes.C index 6ae646b0bb..3c6c1d1e81 100644 --- a/src/insets/insetquotes.C +++ b/src/insets/insetquotes.C @@ -153,11 +153,17 @@ string const InsetQuotes::dispString(Language const * loclang) const disp += disp; if (lyxrc.font_norm_type == LyXRC::ISO_8859_1 - || lyxrc.font_norm_type == LyXRC::ISO_8859_15) - if (disp == "<<") + || lyxrc.font_norm_type == LyXRC::ISO_8859_9 + || lyxrc.font_norm_type == LyXRC::ISO_8859_15) { + if (disp == "'") + disp = "´"; + else if (disp == "''") + disp = "´´"; + else if (disp == "<<") disp = '«'; else if (disp == ">>") disp = '»'; + } // in french, spaces are added inside double quotes if (times_ == DoubleQ && prefixIs(loclang->code(), "fr")) { diff --git a/src/lyxtext.h b/src/lyxtext.h index 0cb33eac0d..e446658a6d 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -48,10 +48,15 @@ public: }; /// enum word_location { - /// the word around the cursor + // the word around the cursor, only if the cursor is + //not at a boundary + WHOLE_WORD_STRICT, + // the word around the cursor WHOLE_WORD, /// the word begining from the cursor position PARTIAL_WORD, + /// the word around the cursor or before the cursor + PREVIOUS_WORD, /// the next word (not yet used) NEXT_WORD }; @@ -272,7 +277,7 @@ public: void getWord(LyXCursor & from, LyXCursor & to, word_location const) const; /// just selects the word the cursor is in - void selectWord(BufferView *, word_location const = WHOLE_WORD); + void selectWord(BufferView *, word_location const); /// returns the inset at cursor (if it exists), 0 otherwise Inset * getInset() const; @@ -354,7 +359,7 @@ public: void deleteLineForward(BufferView *); /// bool selectWordWhenUnderCursor(BufferView *, - word_location const = WHOLE_WORD); + word_location const); /// enum TextCase { /// diff --git a/src/text.C b/src/text.C index 303559a852..bda7eb5ce3 100644 --- a/src/text.C +++ b/src/text.C @@ -2180,12 +2180,27 @@ void LyXText::getWord(LyXCursor & from, LyXCursor & to, // first put the cursor where we wana start to select the word from = cursor; switch(loc) { + case WHOLE_WORD_STRICT: + if (cursor.pos() == 0 || cursor.pos() == cursor.par()->size() + || cursor.par()->isSeparator(cursor.pos()) + || cursor.par()->isKomma(cursor.pos()) + || cursor.par()->isSeparator(cursor.pos() -1) + || cursor.par()->isKomma(cursor.pos() -1)) { + to = from; + return; + } + // no break here, we go to the next + case WHOLE_WORD: // Move cursor to the beginning, when not already there. if (from.pos() && !from.par()->isSeparator(from.pos() - 1) && !from.par()->isKomma(from.pos() - 1)) cursorLeftOneWord(from); break; + case PREVIOUS_WORD: + // always move the cursor to the beginning of previous word + cursorLeftOneWord(from); + break; case NEXT_WORD: lyxerr << "LyXText::getWord: NEXT_WORD not implemented yet\n"; break; @@ -2210,29 +2225,22 @@ void LyXText::selectWord(BufferView * bview, word_location const loc) getWord(from, to, loc); if (cursor != from) setCursor(bview, from.par(), from.pos()); + if (to == from) + return; selection.cursor = cursor; setCursor(bview, to.par(), to.pos() ); setSelection(bview); } -/* -------> Select the word currently under the cursor when: - 1: no selection is currently set, - [disabled] 2: the cursor is not at the borders of the word. */ +/* -------> Select the word currently under the cursor when no + selection is currently set */ bool LyXText::selectWordWhenUnderCursor(BufferView * bview, word_location const loc) { - if (!selection.set() -#if 0 - && cursor.pos() > 0 && cursor.pos() < cursor.par()->size() - && !cursor.par()->isSeparator(cursor.pos()) - && !cursor.par()->isKomma(cursor.pos()) - && !cursor.par()->isSeparator(cursor.pos() -1) - && !cursor.par()->isKomma(cursor.pos() -1) -#endif - ) { + if (!selection.set()) { selectWord(bview, loc); - return true; + return selection.set(); } return false; } diff --git a/src/text2.C b/src/text2.C index c61d56219e..1d4b918dfe 100644 --- a/src/text2.C +++ b/src/text2.C @@ -1040,7 +1040,7 @@ void LyXText::toggleFree(BufferView * bview, LyXCursor resetCursor = cursor; bool implicitSelection = (font.language() == ignore_language && font.number() == LyXFont::IGNORE) - ? selectWordWhenUnderCursor(bview) : false; + ? selectWordWhenUnderCursor(bview, WHOLE_WORD_STRICT) : false; // Set font setFont(bview, font, toggleall);