Re: Smart quotes generating selection events

From: Bobby Weinmann <bobby.weinmann_at_gmail.com>
Date: Tue Dec 08 2009 - 21:30:32 CET

When I worked on smart quotes, one of the requests I received was the
ability to undo it into a regular quote. Will this patch do that?

It didn't matter to me either way, since smart quotes can be turned
off, but it was important to somebody.

Bobby

On Tue, Dec 8, 2009 at 10:58 AM, Daniel Drake <dsd@laptop.org> wrote:
>
> Hi,
>
> When using pyabiword, the text-selected signal is raised every time " is
> pressed. This is causing a strange user experience in Sugar's Write activity,
> which switches to the "Edit" toolbar tab every time a selection is made.
>
> This signal generation originates from smart quotes: when smart quotes tries
> to change a boring quote mark into a curly one, it does so by selecting the
> old/boring character and then inserting a curly one. This also creates an undo
> point, but does raise the selection event.
>
> Here is a quick patch that I briefly discussed with Marco to solve this, which
> says that the smart quotes selection should not generate an event. We'd like
> to start a discussion on whether this is OK, or if there is a better way we
> can solve this.
>
> Thoughts?
>
> cheers
> Daniel
>
>
> Index: abiword-2.8.1/src/text/fmt/xp/fv_View_cmd.cpp
> ===================================================================
> --- abiword-2.8.1.orig/src/text/fmt/xp/fv_View_cmd.cpp
> +++ abiword-2.8.1/src/text/fmt/xp/fv_View_cmd.cpp
> @@ -4023,7 +4023,7 @@ void FV_View::cmdScroll(AV_ScrollCmd cmd
>  }
>
>
> -void FV_View::cmdSelect(PT_DocPosition dpBeg, PT_DocPosition dpEnd)
> +void FV_View::cmdSelect(PT_DocPosition dpBeg, PT_DocPosition dpEnd, bool notify)
>  {
>
>        if (!isSelectionEmpty())
> @@ -4053,7 +4053,8 @@ void FV_View::cmdSelect(PT_DocPosition d
>                return;
>        }
>        _drawSelection();
> -       notifyListeners(AV_CHG_EMPTYSEL);
> +       if (notify)
> +               notifyListeners(AV_CHG_EMPTYSEL);
>  }
>
>  #define IS_SELECTALL(a, b) ((a) == FV_DOCPOS_BOD && (b) == FV_DOCPOS_EOD)
> Index: abiword-2.8.1/src/text/fmt/xp/fl_DocLayout.cpp
> ===================================================================
> --- abiword-2.8.1.orig/src/text/fmt/xp/fl_DocLayout.cpp
> +++ abiword-2.8.1/src/text/fmt/xp/fl_DocLayout.cpp
> @@ -4622,7 +4622,8 @@ void FL_DocLayout::considerSmartQuoteCan
>
>                        m_pView->moveInsPtTo(quotable_at);
>                        // delete/insert create change records for UNDO
> -                       m_pView->cmdSelect(quotable_at, quotable_at + 1);
> +                       // be careful not to cause selection event to be notified
> +                       m_pView->cmdSelect(quotable_at, quotable_at + 1, false);
>                        m_pView->cmdCharInsert(&replacement, 1);
>                        m_pView->moveInsPtTo(saved_pos);
>                }
> Index: abiword-2.8.1/src/text/fmt/xp/fv_View.h
> ===================================================================
> --- abiword-2.8.1.orig/src/text/fmt/xp/fv_View.h
> +++ abiword-2.8.1/src/text/fmt/xp/fv_View.h
> @@ -414,7 +414,7 @@ public:
>        bool            isTOCSelected(void) const;
>        bool            setTOCProps(PT_DocPosition pos, const char * szProps);
>
> -       void                    cmdSelect(PT_DocPosition dpBeg, PT_DocPosition dpEnd);
> +       void                    cmdSelect(PT_DocPosition dpBeg, PT_DocPosition dpEnd, bool notify = true);
>        void                    cmdCharMotion(bool bForward, UT_uint32 count);
>        bool                    cmdCharInsert(const UT_UCSChar * text, UT_uint32 count, bool bForce = false);
>        void                    cmdCharDelete(bool bForward, UT_uint32 count);
>
Received on Tue Dec 8 21:30:49 2009

This archive was generated by hypermail 2.1.8 : Tue Dec 08 2009 - 21:30:49 CET