Dne 27. 12. 2012 11:47, piše Aleksandar Popadić:
Inverse colours with a 256 palette don't work. Try this command
echo -e "\e[7m\e[38;5;240m\e[48;5;255m####\e[0m"

What's been done in the patch:
- the colours setting was rewritten;
- removed some repeated code:
- "if ((!cells) || (x >= w))" and "if (cells[j].att.invisible)" blocks were identical - moved the double width setting out a level, it was needlessly repeated in every block - in "if (!cells)" ch1 and ch2 weren't getting updated if inv and tc[x].bg == COL_INVIS
- moved tc[x] setting in a level next to ch1 and ch2 updating
- took out if codepoint is 0: fg = COL_INVIS. It doesn't do anything (there is no character to make invisible). Whitespace will get properly underlined this way.

As far as I've tested it, it works as it should.
Bold and faint affect only fg. If inverse is set then bold affects fg after the inversion and faint prior to it. Intense behaves as faint.

I also have some questions.
What is intense, what escape code is it? Also the colour table is missing either intense or faint. Right now it has 12 offset for bright/bold and 24 for intense by the comment in col.c or faint by the code in termio.c. There's nothing offset by 48 in the colour table. I'd comment out the intense setting but I'm not sure it's the right thing to do. The way it's set up now, it's possible to fall out of the colour table.
Why doesn't tc[x].bold = bold work?


I've also added a patch to ecore version checking in main.c. The way it's set up now it always comes out true.


Sasha
Never mind about the intense. I looked around and it's just extra 8 colours. The colour table is also taken care of when putting the colours in the textgrid palette.

I've fixed the patch so that intense affects both foreground and background (both prior to the inversion). My decision on the behaviour of bold and faint is based on how it's done in linux terminal.

If I made some bad decisions in the patch please let me know. Please do at least look at the ecore version checking patch.

Sasha
Index: src/bin/termio.c
===================================================================
--- src/bin/termio.c	(revision 81791)
+++ src/bin/termio.c	(working copy)
@@ -388,7 +388,7 @@ _smart_apply(Evas_Object *obj)
 {
    Termio *sd = evas_object_smart_data_get(obj);
    Evas_Coord ox, oy, ow, oh;
-   int j, x, y, w, ch1 = 0, ch2 = 0, inv = 0;
+   int x, y, w, ch1 = 0, ch2 = 0, inv = 0;
 
    if (!sd) return;
    evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
@@ -399,144 +399,93 @@ _smart_apply(Evas_Object *obj)
         Termcell *cells;
         Evas_Textgrid_Cell *tc;
 
-        w = 0; j = 0;
+        w = 0;
         cells = termpty_cellrow_get(sd->pty, y - sd->scroll, &w);
         tc = evas_object_textgrid_cellrow_get(sd->grid.obj, y);
         if (!tc) continue;
         ch1 = -1;
         for (x = 0; x < sd->grid.w; x++)
           {
-             if ((!cells) || (x >= w))
+             if ((!cells) || (x >= w) || (cells[x].att.invisible))
                {
-                  if ((tc[x].codepoint != 0) ||
-                      (tc[x].bg != COL_INVIS) ||
-                      (tc[x].bg_extended))
+                  if ((tc[x].codepoint) || (tc[x].bg_extended) ||
+                      (!(((!inv) && (tc[x].bg == COL_INVIS)) ||
+                         ((inv) && (tc[x].bg == COL_INVERSEBG)))))
                     {
                        if (ch1 < 0) ch1 = x;
                        ch2 = x;
+                       tc[x].codepoint = 0;
+                       tc[x].bg_extended = 0;
+                       if (inv) tc[x].bg = COL_INVERSEBG;
+                       else tc[x].bg = COL_INVIS;
                     }
-                  tc[x].codepoint = 0;
-                  if (inv) tc[x].bg = COL_INVERSEBG;
-                  else tc[x].bg = COL_INVIS;
-                  tc[x].bg_extended = 0;
-#if defined(SUPPORT_DBLWIDTH)
-                  tc[x].double_width = cells[j].att.dblwidth;
-#endif
-                  if ((tc[x].double_width) && (tc[x].codepoint == 0) &&
-                      (ch2 == x - 1))
-                    ch2 = x;
                }
              else
                {
-                  if (cells[j].att.invisible)
+                  int bold, fg, bg, fgext, bgext, codepoint;
+                  
+                  // colors
+                  bold = cells[x].att.bold;
+                  codepoint = cells[x].codepoint;
+                  fgext = cells[x].att.fg256;
+                  bgext = cells[x].att.bg256;
+                  fg = cells[x].att.fg;
+                  bg = cells[x].att.bg;
+
+                  if (!fgext)
                     {
-                       if ((tc[x].codepoint != 0) ||
-                           (tc[x].bg != COL_INVIS) ||
-                           (tc[x].bg_extended))
+                       if (cells[x].att.inverse ^ inv)
                          {
-                            if (ch1 < 0) ch1 = x;
-                            ch2 = x;
+                            if (fg == COL_DEF) fg = COL_INVERSEBG;
                          }
-                       tc[x].codepoint = 0;
-                       if (inv) tc[x].bg = COL_INVERSEBG;
-                       else tc[x].bg = COL_INVIS;
-                       tc[x].bg_extended = 0;
-#if defined(SUPPORT_DBLWIDTH)
-                       tc[x].double_width = cells[j].att.dblwidth;
-#endif
-                       if ((tc[x].double_width) && (tc[x].codepoint == 0) &&
-                           (ch2 == x - 1))
-                         ch2 = x;
+                       else if (bold) fg += 12;
+                       if (cells[x].att.faint) fg += 24;
+                       if (cells[x].att.fgintense) fg += 48;
                     }
-                  else
+                  if (!bgext)
                     {
-                       int bold, fg, bg, fgext, bgext, codepoint;
-                       
-                       // colors
-                       bold = cells[j].att.bold;
-                       fgext = cells[j].att.fg256;
-                       bgext = cells[j].att.bg256;
-                       codepoint = cells[j].codepoint;
-                       
-                       if (cells[j].att.inverse ^ inv)
+                       if (cells[x].att.inverse ^ inv)
                          {
-                            int t;
-                            
-                            fgext = 0;
-                            bgext = 0;
-                            fg = cells[j].att.fg;
-                            bg = cells[j].att.bg;
-                            if (fg == COL_DEF) fg = COL_INVERSEBG;
                             if (bg == COL_DEF) bg = COL_INVERSE;
-                            t = bg; bg = fg; fg = t;
-                            if (bold)
-                              {
-                                 fg += 12;
-                                 bg += 12;
-                              }
-                            if (cells[j].att.faint)
-                              {
-                                 fg += 24;
-                                 bg += 24;
-                              }
-                            if (cells[j].att.fgintense) fg += 48;
-                            if (cells[j].att.bgintense) bg += 48;
+                            if (bold) bg += 12;
                          }
-                       else
-                         {
-                            fg = cells[j].att.fg;
-                            bg = cells[j].att.bg;
-                            
-                            if (!fgext)
-                              {
-                                 if (bold) fg += 12;
-                              }
-                            if (!bgext)
-                              {
-                                 if (bg == COL_DEF) bg = COL_INVIS;
-                              }
-                            if (cells[j].att.faint)
-                              {
-                                 if (!fgext) fg += 24;
-                                 if (!bgext) bg += 24;
-                              }
-                            if (cells[j].att.fgintense) fg += 48;
-                            if (cells[j].att.bgintense) bg += 48;
-                            if (((codepoint == ' ') || (codepoint == 0)) &&
-                                (!cells[j].att.strike) &&
-                                (!cells[j].att.underline))
-                              fg = COL_INVIS;
-                         }
-                       if ((tc[x].codepoint != codepoint) ||
-                           (tc[x].fg != fg) ||
-                           (tc[x].bg != bg) ||
-                           (tc[x].fg_extended != fgext) ||
-                           (tc[x].bg_extended != bgext) ||
-                           (tc[x].underline != cells[j].att.underline) ||
-                           (tc[x].strikethrough != cells[j].att.strike))
-                         {
-                            if (ch1 < 0) ch1 = x;
-                            ch2 = x;
-                         }
+                       else if (bg == COL_DEF) bg = COL_INVIS;
+		       if (cells[x].att.bgintense) bg += 48;
+                    }
+                  if (cells[x].att.inverse ^ inv)
+                    {
+                       int t;
+                       t = fgext; fgext = bgext; bgext = t;
+                       t = fg; fg = bg; bg = t;
+                    }
+                  if ((tc[x].codepoint != codepoint) ||
+                      (tc[x].fg != fg) ||
+                      (tc[x].bg != bg) ||
+                      (tc[x].fg_extended != fgext) ||
+                      (tc[x].bg_extended != bgext) ||
+                      (tc[x].underline != cells[x].att.underline) ||
+                      (tc[x].strikethrough != cells[x].att.strike))
+                    {
+                       if (ch1 < 0) ch1 = x;
+                       ch2 = x;
                        tc[x].fg_extended = fgext;
                        tc[x].bg_extended = bgext;
-                       tc[x].underline = cells[j].att.underline;
-                       tc[x].strikethrough = cells[j].att.strike;
+                       tc[x].underline = cells[x].att.underline;
+                       tc[x].strikethrough = cells[x].att.strike;
                        tc[x].fg = fg;
                        tc[x].bg = bg;
                        tc[x].codepoint = codepoint;
+                       // cells[x].att.italic // never going 2 support
+                       // cells[x].att.blink
+                       // cells[x].att.blink2
+                    }
+               }
 #if defined(SUPPORT_DBLWIDTH)
-                       tc[x].double_width = cells[j].att.dblwidth;
+             tc[x].double_width = cells[x].att.dblwidth;
 #endif
-                       if ((tc[x].double_width) && (tc[x].codepoint == 0) &&
-                           (ch2 == x - 1))
-                         ch2 = x;
-                       // cells[j].att.italic // never going 2 support
-                       // cells[j].att.blink
-                       // cells[j].att.blink2
-                    }
-               }
-             j++;
+             if ((tc[x].double_width) && (tc[x].codepoint == 0) &&
+                 (ch2 == x - 1))
+               ch2 = x;
           }
         evas_object_textgrid_cellrow_set(sd->grid.obj, y, tc);
         /* only bothering to keep 1 change span per row - not worth doing
------------------------------------------------------------------------------
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122812
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to