Thread: RE: [PyCrust] FW: underscore kills command completion
Brought to you by:
pobrien
From: Patrick K. O'B. <po...@or...> - 2002-02-06 13:28:00
|
That solves one problem, but creates another. Apply the change and then run PyCrust and type: >>> shell._ This matches nothing, while this: >>> filling._ Matches just fine. (Well, sort of. See below.). Both objects have attributes with leading underscores at the end of their lists. Here are some more examples: >>> ''._ (fails) >>> []._ (succeeds on most, but fails to match on >>> [].__d) >>> {}._ (succeeds, sort of, but fails to match on >>> {}.__cmp) Something is still broken in the search routine. Any chance a linear search would be good enough for what is usually a fairly reasonable sized list? --- Patrick K. O'Brien Orbtech > -----Original Message----- > From: pyc...@li... > [mailto:pyc...@li...]On Behalf Of Neil > Hodgson > Sent: Wednesday, February 06, 2002 5:48 AM > To: po...@or...; Kevin Altis; pycr > Subject: Re: [PyCrust] FW: underscore kills command completion > > > Patrick K. O'Brien: > > > I'm seeing this same problem in Pythoncard with Python 2.2 using the > "Proof" > > application. But it isn't consistent. For example, the following worked: > > > > >>> bg.DLG_SZE > > > > but this failed to match: > > > > >>> bg.on_ > > > > The following also worked: > > > > >>> os.stat_result > > > > Those "on_" methods don't seem to want to match. I have no idea why. > > Replace the current sorting in getAttributeNames in introspect.py with > > attributes.sort(lambda x, y: cmp(x.upper(), y.upper())) > > so it is converting to upper case rather than lower case and > this moves > the on_* after on followed by a letter. The autocompletion box is assuming > that case insensitive order places the '_' after 'Z', can't find > any entries > that match and so dies. It uses a binary rather than linear > search so misses > the on_ earlier. Since it is a binary search, it may sometimes > find the on_ > even though it is in the wrong place as the binary search depends on order > and the order is inconsistent. > > With case insensitive code, the characters [\]^_` which are located > between Z and a have to sort somewhere, so Scintilla puts them after the > letters. > > Neil > > > > _______________________________________________ > PyCrust-users mailing list > PyC...@li... > https://lists.sourceforge.net/lists/listinfo/pycrust-users |
From: Patrick K. O'B. <po...@or...> - 2002-02-06 23:10:37
|
I don't have the tools to do this, plus it sounds like Robin's domain. Robin? --- Patrick K. O'Brien Orbtech > -----Original Message----- > From: pyc...@li... > [mailto:pyc...@li...]On Behalf Of Neil > Hodgson > Sent: Wednesday, February 06, 2002 3:10 PM > To: po...@or...; Kevin Altis; pycr > Subject: Re: [PyCrust] FW: underscore kills command completion > > > Me: > > > Something is still broken in the search routine. > > > > Yes, there is a bug here so I will look into it. > > I think changing the string comparison functions to compare > non-alphabetic to upper cased characters will fix this. If you have > facilities to build wxPython, then change scintilla/src/PropSet.cxx: > > int CompareCaseInsensitive(const char *a, const char *b) { > while (*a && *b) { > if (*a != *b) { > char upperA = MakeUpperCase(*a); > char upperB = MakeUpperCase(*b); > if (upperA != upperB) > return upperA - upperB; > } > a++; > b++; > } > // Either *a or *b is nul > return *a - *b; > } > > int CompareNCaseInsensitive(const char *a, const char *b, int len) { > while (*a && *b && len) { > if (*a != *b) { > char upperA = MakeUpperCase(*a); > char upperB = MakeUpperCase(*b); > if (upperA != upperB) > return upperA - upperB; > } > a++; > b++; > len--; > } > if (len == 0) > return 0; > else > // Either *a or *b is nul > return *a - *b; > } > > > Neil > > > > _______________________________________________ > PyCrust-users mailing list > PyC...@li... > https://lists.sourceforge.net/lists/listinfo/pycrust-users |
From: Robin D. <ro...@al...> - 2002-02-07 02:48:14
|
Will do. Neil, will this be going into a Scintilla release soon? --Robin ----- Original Message ----- From: "Patrick K. O'Brien" <po...@or...> To: "Neil Hodgson" <ne...@sc...>; "Kevin Altis" <al...@se...>; "pycr" <PyC...@li...> Cc: "Robin Dunn" <ro...@al...> Sent: Wednesday, February 06, 2002 2:48 PM Subject: RE: [PyCrust] FW: underscore kills command completion > I don't have the tools to do this, plus it sounds like Robin's domain. > Robin? > > --- > Patrick K. O'Brien > Orbtech > > > -----Original Message----- > > From: pyc...@li... > > [mailto:pyc...@li...]On Behalf Of Neil > > Hodgson > > Sent: Wednesday, February 06, 2002 3:10 PM > > To: po...@or...; Kevin Altis; pycr > > Subject: Re: [PyCrust] FW: underscore kills command completion > > > > > > Me: > > > > Something is still broken in the search routine. > > > > > > Yes, there is a bug here so I will look into it. > > > > I think changing the string comparison functions to compare > > non-alphabetic to upper cased characters will fix this. If you have > > facilities to build wxPython, then change scintilla/src/PropSet.cxx: > > > > int CompareCaseInsensitive(const char *a, const char *b) { > > while (*a && *b) { > > if (*a != *b) { > > char upperA = MakeUpperCase(*a); > > char upperB = MakeUpperCase(*b); > > if (upperA != upperB) > > return upperA - upperB; > > } > > a++; > > b++; > > } > > // Either *a or *b is nul > > return *a - *b; > > } > > > > int CompareNCaseInsensitive(const char *a, const char *b, int len) { > > while (*a && *b && len) { > > if (*a != *b) { > > char upperA = MakeUpperCase(*a); > > char upperB = MakeUpperCase(*b); > > if (upperA != upperB) > > return upperA - upperB; > > } > > a++; > > b++; > > len--; > > } > > if (len == 0) > > return 0; > > else > > // Either *a or *b is nul > > return *a - *b; > > } > > > > > > Neil > > > > > > > > _______________________________________________ > > PyCrust-users mailing list > > PyC...@li... > > https://lists.sourceforge.net/lists/listinfo/pycrust-users > > |
From: Neil H. <ne...@sc...> - 2002-02-07 06:10:16
|
Robin: > Will do. Neil, will this be going into a Scintilla release soon? It is in CVS but as I just released 1.44 a couple of days ago there probably won't be another release for two weeks. I hope to solve the limited line length problem along with caching LineLayout objects for that release. Neil |
From: Patrick K. O'B. <po...@or...> - 2002-02-08 15:33:01
|
Will this fix work if I keep the sort order the way it was - attributes.sort(lambda x, y: cmp(x.lower(), y.lower())) I kind of prefer this as it seems more "pythonic" to have the underscore attributes at the head of the list. Actually, I'm more partial to that in the namespace viewer, which I just changed to sort this way. I guess a case could be made that underscore attributes are less likely to be useful when called in the shell, and therefore should be at the end of the list. So it isn't a huge deal, I'm just curious. --- Patrick K. O'Brien Orbtech > -----Original Message----- > From: pyc...@li... > [mailto:pyc...@li...]On Behalf Of Neil > Hodgson > Sent: Thursday, February 07, 2002 12:10 AM > To: Robin Dunn; po...@or...; Kevin Altis; pycr > Subject: Re: [PyCrust] FW: underscore kills command completion > > > Robin: > > Will do. Neil, will this be going into a Scintilla release soon? > > It is in CVS but as I just released 1.44 a couple of days ago there > probably won't be another release for two weeks. I hope to solve > the limited > line length problem along with caching LineLayout objects for > that release. > > Neil > > > > _______________________________________________ > PyCrust-users mailing list > PyC...@li... > https://lists.sourceforge.net/lists/listinfo/pycrust-users |
From: Neil H. <ne...@sc...> - 2002-02-08 23:28:14
|
Patrick: > Will this fix work if I keep the sort order the way it was - > > attributes.sort(lambda x, y: cmp(x.lower(), y.lower())) No, as you are using an order that is not consistent with Scintilla. > I kind of prefer this as it seems more "pythonic" to have the underscore > attributes at the head of the list. Actually, I'm more partial to that in > the namespace viewer, which I just changed to sort this way. I guess a case > could be made that underscore attributes are less likely to be useful when > called in the shell, and therefore should be at the end of the list. So it > isn't a huge deal, I'm just curious. Alternate sorting orders could be options if anyone cares enough to implement them, but sorting orders should always be consistent. One aspect that still isn't handled is that strings that differ only in case should have a fixed ordering. As it is, I just consider it a limitation that Scintilla does not support lists with items that differ only in case. Neil |
From: Robin D. <ro...@al...> - 2002-02-09 02:58:39
|
> > Alternate sorting orders could be options if anyone cares enough to > implement them, but sorting orders should always be consistent. > > One aspect that still isn't handled is that strings that differ only in > case should have a fixed ordering. As it is, I just consider it a limitation > that Scintilla does not support lists with items that differ only in case. If Scintilla had a set of flags that could be set that determined how to perform the search it would be cool. Perhaps a flag for binary (as it is now), linear_till_greater (assumes sorted, searches until list item is > search item), and linear_till_end (searches until item is found or end of list). With the last one it wont matter if the list order matches the comparrison order as long the list is not huge. -- Robin Dunn Software Craftsman ro...@Al... Java give you jitters? http://wxPython.org Relax with wxPython! |
From: Neil H. <ne...@sc...> - 2002-02-06 20:08:20
|
Patrick: > That solves one problem, but creates another. Apply the change and then run > PyCrust and type: > > ... > > >>> ''._ (fails) > >>> []._ (succeeds on most, but fails to match on >>> [].__d) > >>> {}._ (succeeds, sort of, but fails to match on >>> {}.__cmp) > > Something is still broken in the search routine. Yes, there is a bug here so I will look into it. > Any chance a linear search > would be good enough for what is usually a fairly reasonable sized list? Some people have *megabytes* in autocompletion lists. There was even a patch submitted to process them on a separate thread because they were too slow. Neil |
From: Neil H. <ne...@sc...> - 2002-02-06 21:10:03
|
Me: > > Something is still broken in the search routine. > > Yes, there is a bug here so I will look into it. I think changing the string comparison functions to compare non-alphabetic to upper cased characters will fix this. If you have facilities to build wxPython, then change scintilla/src/PropSet.cxx: int CompareCaseInsensitive(const char *a, const char *b) { while (*a && *b) { if (*a != *b) { char upperA = MakeUpperCase(*a); char upperB = MakeUpperCase(*b); if (upperA != upperB) return upperA - upperB; } a++; b++; } // Either *a or *b is nul return *a - *b; } int CompareNCaseInsensitive(const char *a, const char *b, int len) { while (*a && *b && len) { if (*a != *b) { char upperA = MakeUpperCase(*a); char upperB = MakeUpperCase(*b); if (upperA != upperB) return upperA - upperB; } a++; b++; len--; } if (len == 0) return 0; else // Either *a or *b is nul return *a - *b; } Neil |