selection improvement + inset quote fixes

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2373 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2001-07-27 16:07:33 +00:00
parent 7fea2dad0f
commit bdba99dcf9
8 changed files with 111 additions and 62 deletions

View File

@ -10,8 +10,8 @@ src/CutAndPaste.C
src/debug.C src/debug.C
src/exporter.C src/exporter.C
src/ext_l10n.h src/ext_l10n.h
src/figure_form.C
src/figureForm.C src/figureForm.C
src/figure_form.C
src/FontLoader.C src/FontLoader.C
src/frontends/controllers/biblio.C src/frontends/controllers/biblio.C
src/frontends/controllers/ButtonController.h src/frontends/controllers/ButtonController.h
@ -49,67 +49,67 @@ src/frontends/qt2/paragraphdlgimpl.C
src/frontends/qt2/tabularcreatedlgimpl.C src/frontends/qt2/tabularcreatedlgimpl.C
src/frontends/xforms/combox.C src/frontends/xforms/combox.C
src/frontends/xforms/FileDialog.C src/frontends/xforms/FileDialog.C
src/frontends/xforms/form_aboutlyx.C
src/frontends/xforms/FormAboutlyx.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/FormBibitem.C
src/frontends/xforms/form_bibtex.C src/frontends/xforms/form_bibitem.C
src/frontends/xforms/FormBibtex.C src/frontends/xforms/FormBibtex.C
src/frontends/xforms/form_bibtex.C
src/frontends/xforms/form_browser.C src/frontends/xforms/form_browser.C
src/frontends/xforms/form_character.C
src/frontends/xforms/FormCharacter.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/FormCitation.C
src/frontends/xforms/form_document.C src/frontends/xforms/form_citation.C
src/frontends/xforms/FormDocument.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/FormError.C
src/frontends/xforms/form_external.C src/frontends/xforms/form_error.C
src/frontends/xforms/FormExternal.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/FormFiledialog.C
src/frontends/xforms/form_graphics.C src/frontends/xforms/form_filedialog.C
src/frontends/xforms/FormGraphics.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/FormInclude.C
src/frontends/xforms/form_index.C src/frontends/xforms/form_include.C
src/frontends/xforms/FormIndex.C src/frontends/xforms/FormIndex.C
src/frontends/xforms/form_index.C
src/frontends/xforms/FormLog.C src/frontends/xforms/FormLog.C
src/frontends/xforms/FormMathsBitmap.C src/frontends/xforms/FormMathsBitmap.C
src/frontends/xforms/form_maths_deco.C
src/frontends/xforms/FormMathsDeco.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/FormMathsDelim.C
src/frontends/xforms/form_maths_matrix.C src/frontends/xforms/form_maths_delim.C
src/frontends/xforms/FormMathsMatrix.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/FormMathsPanel.C
src/frontends/xforms/form_maths_space.C src/frontends/xforms/form_maths_panel.C
src/frontends/xforms/FormMathsSpace.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/FormMinipage.C
src/frontends/xforms/form_paragraph.C src/frontends/xforms/form_minipage.C
src/frontends/xforms/FormParagraph.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/FormPreamble.C
src/frontends/xforms/form_preferences.C src/frontends/xforms/form_preamble.C
src/frontends/xforms/FormPreferences.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/FormPrint.C
src/frontends/xforms/form_ref.C src/frontends/xforms/form_print.C
src/frontends/xforms/FormRef.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/FormSearch.C
src/frontends/xforms/form_spellchecker.C src/frontends/xforms/form_search.C
src/frontends/xforms/FormSpellchecker.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/FormTabular.C
src/frontends/xforms/form_tabular_create.C src/frontends/xforms/form_tabular.C
src/frontends/xforms/FormTabularCreate.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/FormToc.C
src/frontends/xforms/form_url.C src/frontends/xforms/form_toc.C
src/frontends/xforms/FormUrl.C src/frontends/xforms/FormUrl.C
src/frontends/xforms/form_url.C
src/frontends/xforms/FormVCLog.C src/frontends/xforms/FormVCLog.C
src/frontends/xforms/input_validators.C src/frontends/xforms/input_validators.C
src/frontends/xforms/Menubar_pimpl.C src/frontends/xforms/Menubar_pimpl.C
@ -130,7 +130,6 @@ src/insets/insetfoot.C
src/insets/insetgraphics.C src/insets/insetgraphics.C
src/insets/insetinclude.C src/insets/insetinclude.C
src/insets/insetindex.C src/insets/insetindex.C
src/insets/insetinfo.C
src/insets/insetlabel.C src/insets/insetlabel.C
src/insets/insetlist.C src/insets/insetlist.C
src/insets/insetmarginal.C src/insets/insetmarginal.C

View File

@ -678,10 +678,10 @@ void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, unsigned int button)
if (text->bv_owner) { if (text->bv_owner) {
screen_->hideCursor(); screen_->hideCursor();
screen_->toggleSelection(text, bv_); screen_->toggleSelection(text, bv_);
text->selectWord(bv_); text->selectWord(bv_, LyXText::WHOLE_WORD_STRICT);
screen_->toggleSelection(text, bv_, false); screen_->toggleSelection(text, bv_, false);
} else { } else {
text->selectWord(bv_); text->selectWord(bv_, LyXText::WHOLE_WORD_STRICT);
} }
/* This will fit the cursor on the screen /* This will fit the cursor on the screen
* if necessary */ * if necessary */
@ -2979,15 +2979,22 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
case LFUN_INDEX_CREATE: case LFUN_INDEX_CREATE:
{ {
InsetCommandParams p("index"); InsetCommandParams p("index");
LyXText * lt = bv_->getLyXText();
if (argument.empty()) { if (argument.empty()) {
// Get word or selection // Get word or selection
bv_->getLyXText()->selectWordWhenUnderCursor(bv_); lt->selectWordWhenUnderCursor(bv_, LyXText::PREVIOUS_WORD);
string const curstring = if (!lt->selection.set()) {
bv_->getLyXText()->selectionAsString(buffer_); owner_->message(_("Nothing to index!"));
break;
p.setContents(curstring); }
if (lt->selection.start.par() != lt->selection.end.par()) {
owner_->message(_("Cannot index more than one paragraph!"));
break;
}
p.setContents(lt->selectionAsString(buffer_));
} else { } else {
p.setContents(argument); p.setContents(argument);
} }
@ -3011,13 +3018,20 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
case LFUN_INDEX_INSERT_LAST: case LFUN_INDEX_INSERT_LAST:
{ {
LyXText * lt = bv_->getLyXText();
// Get word or selection // Get word or selection
bv_->getLyXText()->selectWordWhenUnderCursor(bv_); lt->selectWordWhenUnderCursor(bv_, LyXText::PREVIOUS_WORD);
string const curstring = if (!lt->selection.set()) {
bv_->getLyXText()->selectionAsString(buffer_); owner_->message(_("Nothing to index!"));
break;
InsetCommandParams p("index", curstring); }
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); InsetIndex * inset = new InsetIndex(p);
if (!insertInset(inset)) if (!insertInset(inset))

View File

@ -1,3 +1,15 @@
2001-07-27 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* 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 <jug@sad.it> 2001-07-27 Juergen Vigna <jug@sad.it>
* text2.C: font.realize function adaption. * text2.C: font.realize function adaption.

View File

@ -1,3 +1,8 @@
2001-07-26 Yves Bastide <stid@libd-pc11.univ-bpclermont.fr>
* insetquotes.C (dispString): display the right ISO8859-{1,9,15}
quotes
2001-07-27 Juergen Vigna <jug@sad.it> 2001-07-27 Juergen Vigna <jug@sad.it>
* inset.h: remove not used font variable in parameter. * inset.h: remove not used font variable in parameter.

View File

@ -153,11 +153,17 @@ string const InsetQuotes::dispString(Language const * loclang) const
disp += disp; disp += disp;
if (lyxrc.font_norm_type == LyXRC::ISO_8859_1 if (lyxrc.font_norm_type == LyXRC::ISO_8859_1
|| lyxrc.font_norm_type == LyXRC::ISO_8859_15) || lyxrc.font_norm_type == LyXRC::ISO_8859_9
if (disp == "<<") || lyxrc.font_norm_type == LyXRC::ISO_8859_15) {
if (disp == "'")
disp = "´";
else if (disp == "''")
disp = "´´";
else if (disp == "<<")
disp = '«'; disp = '«';
else if (disp == ">>") else if (disp == ">>")
disp = '»'; disp = '»';
}
// in french, spaces are added inside double quotes // in french, spaces are added inside double quotes
if (times_ == DoubleQ && prefixIs(loclang->code(), "fr")) { if (times_ == DoubleQ && prefixIs(loclang->code(), "fr")) {

View File

@ -48,10 +48,15 @@ public:
}; };
/// ///
enum word_location { 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, WHOLE_WORD,
/// the word begining from the cursor position /// the word begining from the cursor position
PARTIAL_WORD, PARTIAL_WORD,
/// the word around the cursor or before the cursor
PREVIOUS_WORD,
/// the next word (not yet used) /// the next word (not yet used)
NEXT_WORD NEXT_WORD
}; };
@ -272,7 +277,7 @@ public:
void getWord(LyXCursor & from, LyXCursor & to, void getWord(LyXCursor & from, LyXCursor & to,
word_location const) const; word_location const) const;
/// just selects the word the cursor is in /// 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 /// returns the inset at cursor (if it exists), 0 otherwise
Inset * getInset() const; Inset * getInset() const;
@ -354,7 +359,7 @@ public:
void deleteLineForward(BufferView *); void deleteLineForward(BufferView *);
/// ///
bool selectWordWhenUnderCursor(BufferView *, bool selectWordWhenUnderCursor(BufferView *,
word_location const = WHOLE_WORD); word_location const);
/// ///
enum TextCase { enum TextCase {
/// ///

View File

@ -2180,12 +2180,27 @@ void LyXText::getWord(LyXCursor & from, LyXCursor & to,
// first put the cursor where we wana start to select the word // first put the cursor where we wana start to select the word
from = cursor; from = cursor;
switch(loc) { 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: case WHOLE_WORD:
// Move cursor to the beginning, when not already there. // Move cursor to the beginning, when not already there.
if (from.pos() && !from.par()->isSeparator(from.pos() - 1) if (from.pos() && !from.par()->isSeparator(from.pos() - 1)
&& !from.par()->isKomma(from.pos() - 1)) && !from.par()->isKomma(from.pos() - 1))
cursorLeftOneWord(from); cursorLeftOneWord(from);
break; break;
case PREVIOUS_WORD:
// always move the cursor to the beginning of previous word
cursorLeftOneWord(from);
break;
case NEXT_WORD: case NEXT_WORD:
lyxerr << "LyXText::getWord: NEXT_WORD not implemented yet\n"; lyxerr << "LyXText::getWord: NEXT_WORD not implemented yet\n";
break; break;
@ -2210,29 +2225,22 @@ void LyXText::selectWord(BufferView * bview, word_location const loc)
getWord(from, to, loc); getWord(from, to, loc);
if (cursor != from) if (cursor != from)
setCursor(bview, from.par(), from.pos()); setCursor(bview, from.par(), from.pos());
if (to == from)
return;
selection.cursor = cursor; selection.cursor = cursor;
setCursor(bview, to.par(), to.pos() ); setCursor(bview, to.par(), to.pos() );
setSelection(bview); 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, bool LyXText::selectWordWhenUnderCursor(BufferView * bview,
word_location const loc) word_location const loc)
{ {
if (!selection.set() 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
) {
selectWord(bview, loc); selectWord(bview, loc);
return true; return selection.set();
} }
return false; return false;
} }

View File

@ -1040,7 +1040,7 @@ void LyXText::toggleFree(BufferView * bview,
LyXCursor resetCursor = cursor; LyXCursor resetCursor = cursor;
bool implicitSelection = (font.language() == ignore_language bool implicitSelection = (font.language() == ignore_language
&& font.number() == LyXFont::IGNORE) && font.number() == LyXFont::IGNORE)
? selectWordWhenUnderCursor(bview) : false; ? selectWordWhenUnderCursor(bview, WHOLE_WORD_STRICT) : false;
// Set font // Set font
setFont(bview, font, toggleall); setFont(bview, font, toggleall);