Subversion Repositories Kolibri OS

Rev

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

  1.  
  2. void ParseAndPaint()
  3. {
  4.         Parse();
  5.         DrawPage();
  6. }
  7.  
  8. void Parse()
  9. {
  10. dword ptr;
  11. int line_end;
  12.  
  13.         list.count=0;
  14.         selection.cancel();
  15.         if (list.w != canvas.bufw) canvas.Init(list.x, list.y, list.w, screen.height);
  16.  
  17.         lines.drop();
  18.         lines.add(textbuf.p);
  19.  
  20.         for (ptr = textbuf.p;    ptr < textbuf.p + textbuf.len;    ptr++)
  21.         {
  22.                 if (ptr - lines.get_last() * list.font_w + 16 >= list.w)
  23.                 {
  24.                         //searching a 'white' for a normal word-break
  25.                         for(line_end = ptr; line_end != lines.get_last(); line_end--)                   {
  26.                                 if (__isWhite(ESBYTE[line_end])) {
  27.                                         ptr = line_end + 1;
  28.                                         break;
  29.                                 }
  30.                         }
  31.                         list.count++;
  32.                         lines.add(ptr);
  33.                 } else if (ESBYTE[ptr] == '\x0D') {
  34.                         if (ESBYTE[ptr+1] == '\x0A') ptr++;
  35.                         list.count++;
  36.                         lines.add(ptr+1);
  37.                 } else if (ESBYTE[ptr] == '\x0A') {
  38.                         list.count++;
  39.                         lines.add(ptr+1);
  40.                 }
  41.         }
  42.         lines.add(ptr);
  43.         list.count++;
  44. }
  45.  
  46. void DrawPage()
  47. {
  48.         char t[64];
  49.         scroll.max_area = list.count;
  50.         scroll.cur_area = list.visible;
  51.         scroll.position = list.first;
  52.         scroll.all_redraw = 0;
  53.         scroll.start_x = list.x + list.w;
  54.         scroll.start_y = list.y;
  55.         scroll.size_y = list.h;
  56.  
  57.         if (list.count <= list.visible) {
  58.                 DrawBar(scroll.start_x, scroll.start_y, scroll.size_x,
  59.                 scroll.size_y, theme.bg);
  60.         } else {
  61.                 scrollbar_v_draw(#scroll);
  62.         }
  63.         DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x,
  64.                 scroll.size_y-1, scroll.bckg_col);
  65.  
  66.         PaintVisible();
  67.  
  68.         sprintf(#t, #chars_selected, math.abs(selection.end_offset - selection.start_offset));
  69.         if (selection.is_active()) DrawStatusBar(#t); else DrawStatusBar(" ");
  70. }
  71.  
  72. void PaintVisible()
  73. {
  74.         int i, ff;
  75.         signed s1, s2;
  76.         dword ydraw, absolute_y;
  77.         dword line_bg;
  78.         bool swapped_selection = false;
  79.  
  80.         list.column_max = lines.len(list.cur_y);
  81.         list.CheckDoesValuesOkey();
  82.         if (selection.end_offset < selection.start_offset) {
  83.                 swapped_selection = selection.swap_start_end();
  84.         }
  85.  
  86.         for ( i=0; i < list.visible+1; i++)
  87.         {
  88.                 ydraw = i * list.item_h;
  89.                 absolute_y = i + list.first;
  90.                 line_bg = theme.bg;
  91.  
  92.                 if (selection.start_y < absolute_y) && (selection.end_y > absolute_y) line_bg = selection.color;
  93.                 canvas.DrawBar(0, ydraw, list.w, list.item_h, line_bg);
  94.  
  95.                 selection.draw(absolute_y);
  96.  
  97.                 if (search.visible) || (search_next) for (ff=0; ff<search.found.count; ff++) {
  98.                         s1 = search.found.get(ff) - lines.get(absolute_y);
  99.                         s2 = search.found.get(ff) - lines.get(absolute_y+1);
  100.  
  101.                         if (s2 > 0) break;
  102.  
  103.                         if (s1 > 0) && (s2 < 0) {
  104.                                 canvas.DrawBar(search.found.get(ff) - lines.get(absolute_y) * list.font_w + 3,
  105.                                         ydraw, strlen(#found_text) * list.font_w, list.item_h, theme.found);
  106.                                 search_next = false;
  107.                         }
  108.                 }
  109.  
  110.                 if (absolute_y<list.count) canvas.WriteText(3, ydraw+3, list.font_type, theme.text,
  111.                         lines.get(absolute_y), lines.len(absolute_y));
  112.         }
  113.  
  114.         PutPaletteImage(buf_data+8, canvas.bufw, list.h, list.x, list.y, 32, 0);
  115.  
  116.         if (swapped_selection) selection.swap_start_end();
  117. }
  118.