Subversion Repositories Kolibri OS

Rev

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