[Adium-devl] Auto alignment of message input field

Evan Schoenberg evan.s at dreskin.net
Fri Jan 18 14:31:28 UTC 2008


On Jan 18, 2008, at 9:19 AM, Ofri Wolfus <ofri.wolfus at gmail.com> wrote:

> First, I'd like to correct. It's not for people who write in two
> languages in the same message, but for people who use different
> languages with different writing direction with the same person. Like
> first message in english, then another one in hebrew/arabic, and so
> on. It also forces consistency with the message view by auto aligning
> the message the user types to the same direction it'll later get
> displayed in.

That makes sense... So some characters don't provide a defined  
direction?  If a single character could determine desired direction,  
it seems like only checking at all when the current length of the  
string in the text view is 0 would accomplish that without scanning ok  
each typed char...but if the algorithm is quick (particularly using  
the stack rather than making extra allocations for the check) it  
probably makes no difference.
> Anyway, the source is at http://svn.dpompa.com/fribidi/trunk , but
> there's really no point for it living in a different repository. Would
> it be suitable to include it in the Adium repo?

Sounds good - it could compile as needed as AIHyperlinks.framework  
does. It's definitely better for the source to be obvious one way or  
another, as I had to ask to find it :)

-Evan



>
>
> As for the code itself of -[NSString baseWritingDirection], the
> algorithm is pretty simple. It goes over each character and sees if it
> knows its writing direction. As most messages are made of letters, the
> loop ends after the first character, and as you don't usually send
> stories made out of numbers only in IM, the loop is not likely to scan
> more than few characters. And again, this is the same method we use
> when displaying messages, although it's being run only once per  
> message.
>
> There are those two calloc calls for allocating fch and uch which can
> be allocated on the stack as well (it seems). I honestly don't know
> why I used calloc.
>
> Ofri
>
> On 18/01/2008, at 13:44, Evan Schoenberg wrote:
>
>>
>> On Jan 18, 2008, at 4:52 AM, Ofri Wolfus wrote:
>>
>>> So would anyone like to commit this patch?
>>
>> I'd still like to know more about something that's being proposed to
>> be run with every keystroke to benefit for a very very very small
>> minority of users ("people who type in two languages within a single
>> message, one of which is right-to-left and one of which is left-to-
>> right").  Where's the FriBidi framework's source code?
>>
>> -Evan
>>
>>>
>>>
>>> On 13/01/2008, at 00:00, Ofri Wolfus wrote:
>>>
>>>>
>>>> On 10/01/2008, at 02:17, Peter Hosey wrote:
>>>>
>>>>> On 2008-01-09, at 14:41, Ofri Wolfus wrote:
>>>>>> … the entire string is being sent a -baseWritingDirection  
>>>>>> which is
>>>>>> quite cheap in most cases.
>>>>>
>>>>> How cheap is -[NSTextStorage string]? Keeping in mind that, IIRC,
>>>>> insertText: gets called with nearly every keypress when the text
>>>>> view
>>>>> is active.
>>>>
>>>> NSTextStorage is an NSAttributedString subclass, and the docs of -
>>>> [NSAttributedString string] says the following: "For performance
>>>> reasons, this method returns the current backing store of the
>>>> attributed string object. ... This primitive method must guarantee
>>>> efficient access to an attributed string’s characters; subclasses
>>>> should implement it to execute in O(1) time."
>>>> So I believe it's fast enough. I haven't seen any performance  
>>>> change
>>>> on my macbook.
>>>>
>>>>>> This is needed in order to handle the case where a use types
>>>>>> something, deletes everything, and then types again in a  
>>>>>> different
>>>>>> language, or when moving the typing marker to the beginning and
>>>>>> inserting new text there.
>>>>>
>>>>> Is it broken currently? If so, is there a ticket?
>>>>
>>>> What is broken? This is a new feature, not a bug fix.
>>>
>>>
>>> _______________________________________________
>>> Adium-devl mailing list
>>> Adium-devl at adiumx.com
>>> http://adiumx.com/mailman/listinfo/adium-devl_adiumx.com
>>>
>>
>>
>> _______________________________________________
>> Adium-devl mailing list
>> Adium-devl at adiumx.com
>> http://adiumx.com/mailman/listinfo/adium-devl_adiumx.com
>
>
> _______________________________________________
> Adium-devl mailing list
> Adium-devl at adiumx.com
> http://adiumx.com/mailman/listinfo/adium-devl_adiumx.com
>




More information about the devel mailing list