From 9e499117e3ecae7c61ec0e5bd5a7d54791f3cacf Mon Sep 17 00:00:00 2001 From: Stefan Schimanski Date: Sun, 16 Mar 2008 17:07:10 +0000 Subject: [PATCH] * possibility to disable the completion cursor in text. All those "*supported" methods maybe should be merged with a bit-enum as return value. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23776 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LyXFunc.cpp | 1 + src/LyXRC.cpp | 20 ++++++++++++++++++++ src/LyXRC.h | 3 +++ src/frontends/qt4/GuiPrefs.cpp | 4 ++++ src/frontends/qt4/GuiWorkArea.cpp | 3 ++- src/frontends/qt4/ui/PrefInputUi.ui | 12 +++++++++++- src/insets/Inset.h | 2 ++ src/insets/InsetTabular.cpp | 6 ++++++ src/insets/InsetTabular.h | 2 ++ src/insets/InsetText.cpp | 6 ++++++ src/insets/InsetText.h | 2 ++ 11 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index 8ef6ceca17..2bf6e8334a 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -1882,6 +1882,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_BIBTEX_COMMAND: case LyXRC::RC_BINDFILE: case LyXRC::RC_CHECKLASTFILES: + case LyXRC::RC_COMPLETION_CURSOR_TEXT: case LyXRC::RC_COMPLETION_INLINE_DELAY: case LyXRC::RC_COMPLETION_INLINE_DOTS: case LyXRC::RC_COMPLETION_INLINE_MATH: diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 484edb4220..92c95b0d1e 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -63,6 +63,7 @@ keyword_item lyxrcTags[] = { { "\\bind_file", LyXRC::RC_BINDFILE }, { "\\check_lastfiles", LyXRC::RC_CHECKLASTFILES }, { "\\chktex_command", LyXRC::RC_CHKTEX_COMMAND }, + { "\\completion_cursor_text", LyXRC::RC_COMPLETION_CURSOR_TEXT }, { "\\completion_inline_delay", LyXRC::RC_COMPLETION_INLINE_DELAY }, { "\\completion_inline_dots", LyXRC::RC_COMPLETION_INLINE_DOTS }, { "\\completion_inline_math", LyXRC::RC_COMPLETION_INLINE_MATH }, @@ -308,6 +309,7 @@ void LyXRC::setDefaults() { full_screen_scrollbar = true; full_screen_width = 700; + completion_cursor_text = true; completion_popup_math = true; completion_popup_text = false; completion_popup_delay = 2.0; @@ -823,6 +825,12 @@ int LyXRC::read(Lexer & lexrc) } break; + case RC_COMPLETION_CURSOR_TEXT: + if (lexrc.next()) { + completion_cursor_text = lexrc.getBool(); + } + break; + case RC_COMPLETION_POPUP_AFTER_COMPLETE: if (lexrc.next()) { completion_popup_after_complete = lexrc.getBool(); @@ -2206,6 +2214,14 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c } if (tag != RC_LAST) break; + case RC_COMPLETION_CURSOR_TEXT: + if (ignore_system_lyxrc || + completion_cursor_text != system_lyxrc.completion_cursor_text) { + os << "\\completion_cursor_text " + << convert(completion_cursor_text) << '\n'; + } + if (tag != RC_LAST) + break; case RC_COMPLETION_POPUP_AFTER_COMPLETE: if (ignore_system_lyxrc || completion_popup_after_complete @@ -2831,6 +2847,10 @@ string const LyXRC::getDescription(LyXRCTags tag) str = _("Show the completion popup without delay after non-unique completion attempt."); break; + case RC_COMPLETION_POPUP_TEXT: + str = _("Show a small triangle on the cursor to indicate that a completion is available."); + break; + case RC_COMPLETION_POPUP_DELAY: str = _("The inline completion delay."); break; diff --git a/src/LyXRC.h b/src/LyXRC.h index 68dcdfba60..3b5daaedbe 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -49,6 +49,7 @@ public: RC_BINDFILE, RC_CHECKLASTFILES, RC_CHKTEX_COMMAND, + RC_COMPLETION_CURSOR_TEXT, RC_COMPLETION_INLINE_DELAY, RC_COMPLETION_INLINE_MATH, RC_COMPLETION_INLINE_TEXT, @@ -423,6 +424,8 @@ public: /// Width of limited screen (in pixels) in fullscreen mode int full_screen_width; /// + bool completion_cursor_text; + /// double completion_inline_delay; /// bool completion_inline_math; diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 47a9c5a2c4..6bf30bc31b 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -406,6 +406,8 @@ PrefInput::PrefInput(GuiPreferences * form, QWidget * parent) this, SIGNAL(changed())); connect(popupAfterCompleteCB, SIGNAL(clicked()), this, SIGNAL(changed())); + connect(cursorTextCB, SIGNAL(clicked()), + this, SIGNAL(changed())); connect(mouseWheelSpeedSB, SIGNAL(valueChanged(double)), this, SIGNAL(changed())); } @@ -424,6 +426,7 @@ void PrefInput::apply(LyXRC & rc) const rc.completion_popup_delay = popupDelaySB->value(); rc.completion_popup_math = popupMathCB->isChecked(); rc.completion_popup_text = popupTextCB->isChecked(); + rc.completion_cursor_text = cursorTextCB->isChecked(); rc.completion_popup_after_complete = popupAfterCompleteCB->isChecked(); rc.mouse_wheel_speed = mouseWheelSpeedSB->value(); @@ -443,6 +446,7 @@ void PrefInput::update(LyXRC const & rc) popupDelaySB->setValue(rc.completion_popup_delay); popupMathCB->setChecked(rc.completion_popup_math); popupTextCB->setChecked(rc.completion_popup_text); + cursorTextCB->setChecked(rc.completion_cursor_text); popupAfterCompleteCB->setChecked(rc.completion_popup_after_complete); mouseWheelSpeedSB->setValue(rc.mouse_wheel_speed); } diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index 16f2135a1f..0ea217d112 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -505,7 +505,8 @@ void GuiWorkArea::showCursor() cursorInView = false; // show cursor on screen - bool completable = completer_.completionAvailable() + bool completable = cur.inset().showCompletionCursor() + && completer_.completionAvailable() && !completer_.popupVisible() && !completer_.inlineVisible(); if (cursorInView) { diff --git a/src/frontends/qt4/ui/PrefInputUi.ui b/src/frontends/qt4/ui/PrefInputUi.ui index aeed705c2a..3d525662f2 100644 --- a/src/frontends/qt4/ui/PrefInputUi.ui +++ b/src/frontends/qt4/ui/PrefInputUi.ui @@ -142,6 +142,16 @@ + + + + Show a small triangle on the cursor if a completion is available in text mode. + + + Cursor indicator + + + @@ -180,7 +190,7 @@ - General[[PrefInput]] + General diff --git a/src/insets/Inset.h b/src/insets/Inset.h index 1b50280be5..fb9c03710d 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -322,6 +322,8 @@ public: virtual bool automaticInlineCompletion() const { return true; } /// Return true if the popup completion should be automatic. virtual bool automaticPopupCompletion() const { return true; } + /// Return true if the cursor should indicate a completion. + virtual bool showCompletionCursor() const { return true; } /// Returns completion suggestions at cursor position. Return an /// null pointer if no completion is a available or possible. /// The caller is responsible to free the returned object! diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 6e16f2d516..5207a74df7 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -4822,6 +4822,12 @@ bool InsetTabular::automaticPopupCompletion() const } +bool InsetTabular::showCompletionCursor() const +{ + return lyxrc.completion_cursor_text; +} + + CompletionList const * InsetTabular::createCompletionList(Cursor const & cur) const { return completionSupported(cur) ? cur.text()->createCompletionList(cur) : 0; diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index c5af279f35..a4ec860ba4 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -760,6 +760,8 @@ public: /// bool automaticPopupCompletion() const; /// + bool showCompletionCursor() const; + /// CompletionList const * createCompletionList(Cursor const & cur) const; /// docstring completionPrefix(Cursor const & cur) const; diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 1b0435b0a0..d556b2898d 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -495,6 +495,12 @@ bool InsetText::automaticPopupCompletion() const } +bool InsetText::showCompletionCursor() const +{ + return lyxrc.completion_cursor_text; +} + + CompletionList const * InsetText::createCompletionList(Cursor const & cur) const { return completionSupported(cur) ? text_.createCompletionList(cur) : 0; diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h index 5bb93e3e7c..8168a71f5d 100644 --- a/src/insets/InsetText.h +++ b/src/insets/InsetText.h @@ -154,6 +154,8 @@ public: /// bool automaticPopupCompletion() const; /// + bool showCompletionCursor() const; + /// CompletionList const * createCompletionList(Cursor const & cur) const; /// docstring completionPrefix(Cursor const & cur) const;