Subversion Repositories Kolibri OS

Rev

Rev 7924 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. void ParseAndPaint()
  3. {
  4.         //search.clear();
  5.         list.KeyHome();
  6.         list.count=0;
  7.  
  8.         Parse();
  9.  
  10.         list.visible = list.h / list.item_h;
  11.         if (list.count < list.visible) {
  12.                 DrawBuf.bufh = list.visible;
  13.         } else {
  14.                 DrawBuf.bufh = list.count;
  15.         }
  16.  
  17.         DrawBuf.Init(list.x, list.y, list.w, DrawBuf.bufh+1*list.item_h);
  18.         DrawPage();    
  19. }
  20.  
  21. void Parse()
  22. {
  23. dword off;
  24. int line_end;
  25. dword line_length=0;
  26. dword line_start = io.buffer_data;
  27. dword buflen = strlen(io.buffer_data) + io.buffer_data;
  28.  
  29.         lines.drop();
  30.         lines.add(io.buffer_data);
  31.         selection.cancel();
  32.  
  33.         for (off = io.buffer_data; off < buflen; off++)
  34.         {
  35.                 line_length += list.font_w;
  36.                 if (line_length + 30 >= list.w) || (ESBYTE[off] == 10)
  37.                 {
  38.                         //searching a 'white' for a normal word-break
  39.                         for(line_end = off; line_end != line_start; line_end--)
  40.                         {
  41.                                 if (__isWhite(ESBYTE[line_end])) { off=line_end+1; break; }
  42.                         }
  43.                         line_length = off - line_start * list.font_w;
  44.                         list.count++;
  45.                         lines.add(off);
  46.                         line_start = off;
  47.                         line_length = 0;
  48.                 }
  49.         }
  50.         lines.add(buflen);
  51.         list.count++;
  52. }
  53.  
  54. void PaintVisible()
  55. {
  56.         int i;
  57.         dword y;
  58.         dword line_bg;
  59.         bool swapped = false;
  60.  
  61.         list.column_max = lines.get(list.cur_y+1) - lines.get(list.cur_y);
  62.         list.CheckDoesValuesOkey();
  63.         if (selection.end_offset < selection.start_offset) {
  64.                 swapped = selection.swap_start_end();
  65.         }
  66.  
  67.         for ( i=list.first; i < list.first+list.visible+1; i++)
  68.         {
  69.                 y = i * list.item_h;
  70.                 line_bg = theme.bg;
  71.  
  72.                 if (selection.start_y < i) && (selection.end_y > i) line_bg = selection.color;
  73.                 DrawBuf.DrawBar(0, y, list.w, list.item_h, line_bg);
  74.  
  75.                 selection.draw(i);
  76.  
  77.                 if (i<list.count) DrawBuf.WriteText(3, y+3, list.font_type, theme.text,
  78.                         lines.get(i), lines.get(i+1) - lines.get(i));
  79.         }
  80.  
  81.         PutPaletteImage(list.first * DrawBuf.bufw * list.item_h * 4 + buf_data+8,
  82.                 DrawBuf.bufw, list.h, list.x, list.y, 32, 0);
  83.  
  84.         if (swapped) selection.swap_start_end();
  85. }
  86.  
  87.