[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [putty]PuTTY's Arabic patch





From: Simon Tatham <anakin at pobox dot com>
"ahmad khalifa" <ahmadkhalifa at hotmail dot com> wrote:

> im guessing that simon is moving the Shaping/Bidi calls to a less frequently
> called function. i.e Bidi/Shaping is called only when the Actual text buffer
> changes. that would be more efficient.


That's certainly something I want to do. Currently, the bidi and
shaping routines are called for the whole window on _every_ call to
do_paint(), and since those happen on a timer, they really need to
be doing less when there's no change.

I'm not sure how best to do that in the current architecture. I
suspect it's going to be necessary to cache each line of the
terminal both before _and_ after doing bidi, so that the `before'
cache tells you whether you need to run the bidi algorithm at all,
and the `after' cache tells you precisely which characters on the
line actually need redrawing.

instead of that, cant you just call bidi/shaping on buffer change ? i.e on WM_KEYDOWN and on 'receive()' ? or maybe a separate timer with a bigger interval ? but some flickering would occur.

ofcourse your expertise on putty would be best for tackling this
issue, but if you want i could look into it...

> i dont convert the whole string to unicode and then back, i lookup
> the unicode value for each char as needed,

Yes. The trouble is that PuTTY _already_ does character set
conversion code, so doing your own entirely separately is a complete
waste of space (not to mention that your implementation used a
global variable in minibidi.h, which is a serious portability
hazard).

What _should_ be happening is that minibidi.c shouldn't be directly
handling an array of wchar_t. Instead, it should be handling an
array of structures containing both a wchar_t and an index back into
the original ldata array. Those wchar_t are set up before calilng
do_bidi(), using PuTTY's own character set conversion (so it doesn't
just work in UTF-8, CP1256 and CP1255 - it also works in ISO-8859-6
and ISO-8859-8, and any other character set we might later support
in PuTTY).

This allows the maximum amount of information to be preserved from
the original ldata. In particular, it allows the bidi algorithm to
move the character attributes (bold, underline, colours etc) along
with the displayed character, because for every bidi_char output
from the bidi routine there is an index parameter pointing back to
the original ldata entry which contains all the attribute data.

I've prepared my own version of the patch which demonstrates this.
You can download it at

http://www.tartarus.org/~simon/arabic-putty/patch.arabic.20040501.simon

Alongside that is a demonstration text file, which I downloaded from
the Web and added colour escape sequences to. You can download this
test file, in three different character sets, from:

  http://www.tartarus.org/~simon/arabic-putty/buniya.utf
  http://www.tartarus.org/~simon/arabic-putty/buniya.win1256
  http://www.tartarus.org/~simon/arabic-putty/buniya.iso88596

You should find that my patch supports ISO-8859-6 as well as Win1256
and UTF-8. You should also find that two words near the top of the
file are highlighted red and blue, and that the red and blue
highlights move _with_ the text when you turn bidi on and off.

I'm still not ready to check this patch in, because I haven't yet
fixed the speed problem caused by running the bidi algorithm all the
time. But I'd like to know what you think of the changes so far.

Great, i think you just finished Phase-2 !! and you also gave me a good idea of how to deal with cursors inside bidi. anything we can do to speed up the process ? as i said if you're busy i can look into the On-Buffer-Change.


ak.


_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail