[Monodevelop-devel] Text Editor API GetCharAt

IBBoard ibboard at gmail.com
Sat Jun 21 08:35:46 UTC 2014


I think it is obvious and intuitive at the Text level, but for Document
and Editor then it becomes a bit less intuitive.

As Mike said, the Document has lines as well as characters. How often is
someone going to want to use the index as a line vs as a character?
Which would you assume is which? I think it is probably clearer to keep
the methods at those levels so that you don't have to check the return
type to know what you're indexing.



On 20/06/14 19:21, Jeff Stedfast wrote:
> To be fair, it's also kinda obvious :-)
> 
> 
> On Fri, Jun 20, 2014 at 1:53 PM, Mike Krüger <mkrueger at xamarin.com
> <mailto:mkrueger at xamarin.com>> wrote:
> 
>     Hi
> 
>     To be fair it's something I've borrowed from Roslyn.
> 
>     Regards
>     Mike
> 
>>     Hi Mike,
>>
>>     I like the API change you are suggesting.
>>
>>     Jeff
>>
>>
>>
>>     On Fri, Jun 20, 2014 at 1:16 PM, Mike Krüger <mkrueger at xamarin.com
>>     <mailto:mkrueger at xamarin.com>> wrote:
>>
>>
>>         Hi
>>
>>         I'm currently reviewing the text editor API. We've a method
>>         called:
>>
>>         public char GetCharAt (int < span class="n" style="box-sizing:
>>         border-box; color: rgb(51, 51, 51);">offset)
>>
>>
>>         And atm I think about replacing it with :
>>
>>         public char this[int offset] 
>>
>>         Maybe even add a setter to that - then the editor may feel a
>>         bit more like a string from a certain PoV.
>>         The question is: Is that a good or bad choice - how are you
>>         feeling about it ?
>>
>>         The text editor has 3 layers: Text, Document and Editor - each
>>         layer adds something on top of the text. The GetCharAt is a
>>         functionality from the Text. On this level there is just text.
>>         I think the indexer makes sense there. But how about the upper
>>         layers? At Document level the editor becomes a collection of
>>         lines as well.
>>
>>         I would love to hear some opinions. (About the speed: In this
>>         is a very lightweight operation - in our current
>>         Implementation it's done in O(1) in the worst case I can
>>         imagine that it becomes an O(log N) one).
>>
>>         Regards
>>         Mike
>>
>>
>>
>>         _______________________________________________
>>         Monodevelop-devel-list mailing list
>>         Monodevelop-devel-list at lists.ximian.com
>>         <mailto:Monodevelop-devel-list at lists.ximian.com>
>>         http://lists.ximian.com/mailman/listinfo/monodevelop-devel-list
>>
>>
> 
> 
> 
> 
> _______________________________________________
> Monodevelop-devel-list mailing list
> Monodevelop-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monodevelop-devel-list
> 


More information about the Monodevelop-devel-list mailing list