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

Display hide a char ?



Bram - I've been giving some thought to the Arabic requirement in which
some characters need to be combined in order to make them readable and
correct (namely LAM-ALEF --> LAA or in encodings 0x644, 0x0627 --> 0xfefb).
Its a nicety that a number of people have repeatedly asked for :-)

I realize that you are not familiar with Arabic, as such - I'd like to
offer an example with pseudo-characters.

Let's assume I have these two Arabic characters 'A' and 'B' which are
valid characters when they are not next to each other - but when I
put AB (A followed by B), I'm supposed to see 'C' and NOT simply 'AB'.

After some studying and adding a bit to the vim code already, I was
thinking of a solution along the lines of something that would fit-in
with the existing vim code.  A new "attribute" call it 'display-skip'
(pick any encoding that makes sense) would be nice to have which would
let the display engine to simply pass-over that array element whenever
it sees it (ie. a new encoding to ScreenAttrs[] or another global array)
without advancing the display cursor.

The reason this is different from simply setting that character as a
don't display char (-1) is that its location should not be voided and
not be left blank.  In other words, in the example above when 'AB' is
combined it should look like 'C' and not ' C' or 'C ' (note spaces).

A contextualized example,

 user enters     -> 'AXBY ZABK JM'
 user should see -> 'AXBY ZCK JM'  (note "C")

I've played some tricks with shaping (patch mailed awhile back) in which
I'm able to morph/change the character shapes/encodings, my one
remaining issue is the need for a way to skip over a valid character
in display ONLY (this is all done to display only of course).  Searching
should also work without a problem with this proposed new 'display-skip'
since the bytes searched would NOT care about the new attribute
(cut-n-paste, yank, etc should still see AB).

In others words, do something along these lines -

  #define ATTR_DISP_SKIP		0x40

  if ( display_skip should be inserted /* LAM-ALEF -> LAA */ )
    ScreenAttrs[off] = ATTR_DISP_SKIP

  /* elsewhere - where display is done/manipulated */
  if ( ScreenAttrs[off] == ATTR_DISP_SKIP )
  {
    /* - Assume I'm hiding/display-skip'ing the previous char;
         not sure why this is not working, this simply shifts the
         character forwards (what am I missing ?)
       - There are too many "columns" in various contexts :-) */

    ScreenAttrs[off-1] = (sattr_T)-1;	/* takes up display space */
    mb_dec(&curwin->w_cursor);
  }

After a few hours of hacking (screen.c) - this is proving to be more
difficult than first anticipated (ScreenAttrs doesn't OR attributes
and I don't think it was meant as a general attribute flag holder, no
problem :-)  How can I fake the 'display-skip' through the manipulation
of ScreenLines/ScreenLinesUC ?  I'm sure its doable...

Any thoughts/ideas and more importantly pointers/direction (which
functions should I concentrate on) ?  I realize this is a sensitive
area for me to work in and thus the questions (I don't want to break
folding, etc, etc) ?

Thanks...

 - Nadim


__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/