 welcome. > > The relevant files are bidi.c and xdisp.c. There's a long comment at > the beginning of xdisp.c, whose last parts deal with how the bidi > reordering is incorporated into the display engine, and a long comment > at the beginning of bidi.c that has more details about the reordering > itself. > > Note that this is not an implementation bug, it's a consequence of how > the bidi reordering engine's integration with the rest of the display > code was designed: we reorder text for display _before_ making the > layout decisions. IOW, the layout layer of the display engine is fed > characters in _visual_ order, already reordered by bidi.c functions > which the layout layer calls when it needs another character. The > advantage of this design is that the display engine knows almost > nothing about the reordering stuff, it doesn't care about resolved > levels etc., because all that was already taken care of. > > To make line-wrapping do what the UBA describes, we would need to feed > the display engine with characters in logical order, but record with > each character its resolved bidi level, resulting from partial > processing by bidi.c. Then, when a line is completely laid out, we'd > need to reorder the glyphs prepared for that line according to UBA > rules L1, L2, and L4, using the resolved levels recorded by bidi.c > code. (L3 is tricky, because combining marks are applied when > producing glyphs, so it has to be solved by "some other method".) > > The above means we need to redesign the interface between xdisp.c and > bidi.c, and then rewrite the current reordering function into > something that will work on the glyphs of a laid-out line. > > That in itself is more or less straightforward refactoring of the > existing code, but unfortunately it isn't the scary part of the job. > The scary part is all the subtleties of the Emacs display engine and > the features it provides, when bidirectional text is involved. For > example, many places need to calculate layout metrics without > displaying anything. A typical example is vertical-motion when > line-move-visual is in effect -- it needs to determine what buffer > position is displayed one screen line up or down from a given > character. Another
welcome. > > The relevant files are bidi.c and xdisp.c. There's a long comment at > the beginning of xdisp.c, whose last part cope with how the bidi > reordering is incorporated into the display engine, and a long gossip > at the beginning of bidi.c that has more details about the reordering > itself. > > notice that this is not an implementation bug, it's a consequence of how > the bidi reordering locomotive's consolidation with the rest of the display > code was designed: we reorder textbook for display _ before _ making the > layout decisions. IOW, the layout level of the display engine is fed > characters in _ visual _ order, already reordered by bidi.c functions > which the layout level calls when it needs another character. The > advantage of this purpose is that the display engine knows about > nothing about the reordering material, it doesn't care about resolved > levels etc. , because all that was already taken care of. > > To make cable - wrapping do what the UBA describes, we would need to feed > the display locomotive with character in logical order, but record with > each character its resolved bidi level, resulting from partial > processing by bidi.c. Then, when a line is wholly put out, we'd > need to reorder the glyph prepare for that occupation according to UBA > rules L1, L2, and L4, use the dissolve levels recorded by bidi.c > code. (L3 is crafty, because combining marks are applied when > producing glyphs, so it has to be resolve by " some other method " .) > > The above means we need to redesign the interface between xdisp.c and > bidi.c, and then rewrite the current reordering affair into > something that will work on the glyph of a put - out line. > > That in itself is more or less straightforward refactoring of the > existing code, but unfortunately it isn't the scary part of the job. > The scary character is all the subtleties of the Emacs display engine and > the features it provides, when bidirectional textbook is involved. For > example, many places need to calculate layout prosody without > displaying anything. A distinctive example is vertical - motion when > line - motion - visual is in effect -- it needs to determine what buffer > position is display one screen line up or down from a given > character. Another
 wepcome. > > The relevant filts are bidi.c and reisp.c. Vhere's z long cumment at > the beginning of edisp.c, whise last parts deal wigh how thv bidi > rwordtring is incorporefed into the slsplav xngine, and a lokg comment > at the beginnhne lf bidi.c that has more details aboue the rrogdering > itsels. > > Mjte fhat this is not an implementation bug, it'v a consequenve of how > the bidi reordeging engine's integratiln with the rese of the dispuay > code was designed: we reorder text for display _bewore_ kaking the > oaylot decisions. IOW, nhe layout lanvr of tve dispkay engine is ned > rharqcters in _visual_ ordec, already reordered fy bidi.c xuuctions > which the latoyt laier cdlls qhev iu nxeda anotjer character. The > advanrage of this design if that the disllay eggyne knows almost > nothing about the reogderjng stuff, it doesn't carw about resolved > levgls etc., besause all that was already taken care of. > > To maka linx-wfapkikn do qhwt the UBA describes, we would need to feed > trs cixplay engine wlth characters in kohivwl order, but tecord cjtg > each character lts resjlved bidi levtl, rexulting from partial > procewsing by bidp.c. Tyen, when a line is completely laic out, we'd > need to reorder tke glylhs preparef for thaf line according go LBA > rules L1, L2, and L4, using the resolved levzls recofded by biqi.c > code. (P3 is bsicky, because comblning mdrks are aoplied when > producing glyphs, so it has to be smlvvd by "somz othev method".) > > The wbove means we need tj reddsign the pnterface between xdysp.c and > bidh.f, and then rxwrite thq cuerenr reorddfing function onto > somvtking that will work on the nlyphr of a laid-out lnue. > > That in itsekf ks ioge pr ness straighdfordara refaztoring of bhe > exosting code, but unfostunztely it isn't the xcwry part of the tob. > The scaru part is all the dubtlxties uf thr Eiacs display engine and > the fsatures ih pvovides, when fidivectyonal text is involved. For > example, many places nxed to calculate layouj metrics without > dixklaying anythmng. A eypical efample is vertical-morion when > line-moye-visual is in effect -- it neads tl determine what buffer > position is displayed one screen line up or down from e diven > charzctet. Anonhex
welcome. > > The relevant files are xdisp.c. a long at > the parts with how the > reordering is into the display engine, and a comment > at the beginning of bidi.c that has more details about the > itself. > > Note that this is not an implementation bug, it's consequence how the reordering engine's integration with the rest of the display > code was designed: we reorder text display _before_ making the > layout decisions. IOW, layout layer of the engine is fed > characters _visual_ already reordered bidi.c > the layout layer when it needs another character. The > advantage of this design is that the display engine knows > nothing reordering stuff, doesn't about > levels etc., that was already taken care of. make line-wrapping do what the UBA describes, we need to > the display engine with characters logical order, but record with > each character resolved bidi level, resulting from partial > processing by bidi.c. Then, when a line is out, we'd > need reorder the glyphs for line to > rules L2, and L4, using the resolved levels recorded by bidi.c > (L3 is tricky, because combining marks are applied when > so has to be by "some other method".) > above means we need the between bidi.c, then the current reordering function > something that will work the glyphs of a in itself is more or less straightforward refactoring the > existing code, but unfortunately it the scary part of the job. > The scary part is all subtleties of display engine and > the features it provides, bidirectional text is involved. > example, many places need to calculate layout metrics > anything. A example is vertical-motion > line-move-visual is effect -- it determine what > is line up or down from a > Another
 welcome. > > The relevant files arE bidi.c and xDisp.c. theRe's A lOng cOmmeNt at > the beginniNG of xDisp.c, whose last parts deaL with HoW The bIDi > ReordEring is INcORPorAtEd IntO tHE dIsplaY enGine, and A long commeNt > aT tHe beginning oF BiDi.c that has MorE details abouT thE reordErIng > ITself. > > notE that This is NOt an imPlementatIoN Bug, it's A ConsequENCe Of hoW > the bidi reorderinG EnGIne's integratioN with tHe REsT OF thE diSplay > code wAs DesigNEd: we reoRDeR TEXt fOR display _beforE_ making the > lAYouT decisIoNs. Iow, the laYout lAyER of The display eNginE is fed > chaRacterS In _visuaL_ Order, alReady rEorDerEd by BIdI.c FunCtIOns > WHiCh tHE laYout layeR cAlLs wheN it nEEDS AnotHer CharActer. the > advantage oF thIs deSIgn Is thaT the dIsplAy EnginE knows AlmosT > nOthing about the rEordEring stufF, it DoEsn'T cAre abOUt resoLveD > leVels etc., Because ALl tHaT WAS aLready taken care of. > > TO mAKE lIne-wrappIng do wHAt ThE uBA descrIbEs, wE wouLD Need tO feeD > ThE display Engine WItH cHaracteRs In logiCaL orDer, But reCOrd wIth > eacH charactEr its REsolved bidi levEL, resulting froM PaRTIaL > ProcEssIng by bidi.c. THen, wHEn a lIne iS CoMplETely lAid ouT, wE'D > nEEd to reorder the glyphS pRepareD for tHat line accordIng to UBA > ruLES l1, L2, and L4, usIng tHE rESolved levels reCordeD by bidi.c > coDE. (L3 is tricKy, becAuse combIning markS ARe applieD whEn > pRodUciNG GlYphs, so it has to BE SolvEd By "some oTheR method".) > > the AboVe mEanS wE need to reDesign thE iNtErFaCe bEtweeN Xdisp.c anD > bIdi.C, aNd tHen reWRite thE currEnt rEoRdERinG functiON iNTO > somEtHiNg thAt wIlL work On thE GlyPhs of a lAid-out linE. > > ThAT in iTsElF is more Or less straighTfOrward refaCtOriNg of thE > EXisting cOde, but unfortunately it isN'T the scaRy pArt of The jOb. > The scarY paRt is alL thE SubtleTies of The EmAcS diSPLay enGINe And > ThE features iT PRovIdes, wHeN bidIrectioNal text is involved. FOR > exAmple, many placEs nEed tO CAlCulATe LAyoUt MEtrICS without > displayIng anythinG. A TYpIcal examplE Is vErTical-moTion wheN > line-MOve-visuAl is in effEct -- it needS tO detERMinE what buffeR > positioN is displaYEd one SCrEen liNe uP or dowN fRom A giveN > charaCTer. anothEr
 welcome. > > The relevant  files are  bidi .cand  x disp .c.There's a long comm ent at > the beginning  of x di s p.c, wh ose l ast par t sd e alwi th  ho wt he  bidi  >reorder ing is inc orp or ated into th e  d isplay eng ine , and a long  co mment>att he be gin ningof bid i .c tha t has mor ed etails about t h e  r eord ering > itself. > >N ote that thisis not  a n  i m p lem ent ation bug,  i t's a consequ e nc e o f h o w > the bidireorderinge ngi ne's i nt egr a tion w ith t he res t of the di spla y > codewas de s igned:w e reord er tex t f ordisp l ay  _ bef or e _ m a ki ngt he> layout  d ec ision s. I O W , thelay outlayer  of the displ ayengi n e i s fed  > ch arac te rs in  _visu al_ o rd er, already reo rder ed by bid i.c  f unc ti ons > whichthe  la yout la yer cal l s w he n i tneeds another char ac t e r.  The > a dvanta g eof this des ig n i s th a t  thedisp l ay  engineknowsa lm os t > not hi ng abo ut  th e r eorde r ingstuff,  it does n't c a re about resol v ed > levels e t c. , be c ause  al l that wasalre a dy t aken ca reo f. >> Toma k el ine-wrapping do wha tthe UB A des cribes, we wo uld need t o f eed > th e di s pl a y engine withchara cters in l o gical or der,but reco rd with > e ach char act erits  re s o lv ed bidi level , resu lt ing fro m p artial> p roc ess ing  b y bidi.c.  Then, w he nali neis co m pletelyla idou t,we'd>  needto re orde rth e  gl yphs pr e pa r e d fo rth at l ine  a ccord ingt o U BA > ru les L1, L 2,a nd L 4,  u sing th e resolved le ve ls recorde dbybidi.c >  code. ( L3 is tricky, because c o mbining  ma rks a re a pplied wh en> prod uci n g glyp hs, so  it h as  to b e sol v e dby"s ome otherm e tho d".)>> Th e above  means we need tor ede sign the inte rfa ce b e t we enx di s p.c  a n d > b idi.c, and then  rewrite t he cu rrent reor d eri ng  functi on into  > so m ethingthat will  work onth e gl y p hsof a laid- out line . > > Tha t  in i t se lf is  mo re orle ssstrai ghtfor w ard  refa ctorin gof the  > ex is ting cod e, but unfortunately it  isn't  thesca ry part o f t h e j ob. > The  sca ry part is  al l t he su btl e tiesof t h eEma c s dis play engine an d  >  th e fe atures it p r o v ide s, wh enb idirec tion al text is involv e d. For > examp le,m a nypla c es n ee d to calculate  la yo u t  metrics  w ithout > di splaying  a n ythin g. A t ypical  exampl e is vertic al-m oti on when >  li ne - move-vi su al is ineffe ct  -- it  needs to d e t ermine what buff er >p o sitio n  is  disp la yed one scre en line up  or down fr om a g iven  > ch aracter .Anothe r
 welcome._> >_The relevant files are_bidi.c and_xdisp.c._There's a_long_comment at >_the beginning of_xdisp.c, whose last parts_deal with how_the_bidi > reordering is incorporated into the display engine, and a long comment >_at_the beginning_of_bidi.c_that has more details about_the reordering > itself. >_> Note_that this is not an implementation bug, it's_a_consequence of how_> the bidi reordering engine's integration with the rest_of the display > code was_designed: we reorder_text_for_display _before_ making the_> layout decisions. IOW, the layout_layer of the display engine is_fed > characters in _visual_ order, already_reordered by bidi.c functions > which_the layout layer calls when_it needs_another character. The > advantage_of this design_is that_the display engine_knows almost > nothing about the_reordering stuff, it_doesn't care about resolved > levels_etc.,_because all that_was_already_taken care_of. > >_To_make line-wrapping_do_what the UBA describes, we would_need_to feed > the display engine with_characters in logical order,_but_record with > each_character its resolved bidi level,_resulting from partial > processing by_bidi.c. Then,_when a_line is completely laid out, we'd > need to reorder the_glyphs prepared for that line according_to UBA > rules_L1, L2,_and_L4, using the_resolved_levels recorded_by bidi.c > code. (L3 is tricky,_because combining_marks are applied when > producing_glyphs, so it has_to_be solved by "some other method".)_> > The above means we_need to redesign the interface_between_xdisp.c_and > bidi.c, and then_rewrite the current reordering function into_> something that_will work on the glyphs of a_laid-out_line. > > That in itself_is_more or less straightforward refactoring of_the_>_existing code, but unfortunately it_isn't the scary part of the_job. > The scary part is all the subtleties_of the Emacs_display engine and > the_features_it_provides, when bidirectional text is involved. For > example, many_places need_to calculate layout_metrics without > displaying anything. A typical example is vertical-motion_when > line-move-visual is in effect --_it needs to determine what buffer > position is displayed one_screen line up or down from a given_> character. Another