Re: Smart quotes generating selection events

From: Martin Sevior <msevior_at_gmail.com>
Date: Mon Dec 14 2009 - 23:17:33 CET

On Tue, Dec 15, 2009 at 12:59 AM, J.M. Maurer <uwog@uwog.net> wrote:
>
> On Tue, 2009-12-08 at 15:30 -0500, Bobby Weinmann wrote:
>> 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.
>
> Martin: Can't we fix it by using a lower level action than "selecting
> the quote and replacing it"? It has to be something that generates a
> changerecord... do we have any other mechanisms?
>
>  Marc
>

Hi Marc,
            I'm pretty sure we can work around it. I'm just building a
sugar instance now. I'll use this to debug the problem as well as
providing print support.

Cheers

Martin

>
>>
>> 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 Mon Dec 14 23:17:49 2009

This archive was generated by hypermail 2.1.8 : Mon Dec 14 2009 - 23:17:49 CET