Subversion Repositories Kolibri OS

Rev

Rev 7798 | Blame | Last modification | View Log | Download | RSS feed

  1. void ParseAndPaint()
  2. {
  3.         dword start_time = GetStartTime();
  4.         search.clear();
  5.         Parse();
  6.         Paint();
  7.         debugln("\nTextRead statistics in miliseconds...");
  8.         debugval("Page generate time", GetStartTime() - start_time);
  9.         if (list.count > list.visible * 10) DrawPage();
  10.         start_time = GetStartTime();
  11.         kfont.ApplySmooth();
  12.         debugval("Smooth", GetStartTime() - start_time);
  13.         DrawPage();
  14. }
  15.  
  16.  
  17. #define DRAW_PADDING 12
  18.  
  19. void Parse()
  20. {
  21. dword bufoff, buflen;
  22. byte ch;
  23. char line[4096]=0;
  24. int srch_pos;
  25. dword stroka_y=DRAW_PADDING-3;
  26. dword line_length=30;
  27. dword line_start=io.buffer_data;
  28.  
  29.         list.count=0;
  30.         buflen = strlen(io.buffer_data) + io.buffer_data;
  31.         for (bufoff=io.buffer_data; bufoff<buflen; bufoff++)
  32.         {
  33.                 ch = ESBYTE[bufoff];
  34.                 line_length += kfont_char_width[ch];
  35.                 if (line_length>=list.w) || (ch==10) {
  36.                         srch_pos = bufoff;
  37.                         loop()
  38.                         {
  39.                                 if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break
  40.                                 if (srch_pos == line_start) break; //no white space found in whole line
  41.                                 srch_pos--;
  42.                         }
  43.                         list.count++;
  44.                         strlcpy(#line, line_start, bufoff-line_start);
  45.                         search.add(stroka_y, #line);
  46.                         stroka_y += list.item_h;
  47.                         line_start = bufoff;
  48.                         line_length = 30;
  49.                 }
  50.         }
  51.         list.count+=2;
  52.         list.visible = list.h / list.item_h;
  53.         if (list.count < list.visible) list.count = list.visible;
  54.         kfont.size.height = list.count+1*list.item_h;
  55.         kfont.raw_size = 0;
  56.         search.add(stroka_y, line_start);
  57. }
  58.  
  59. void Paint()
  60. {
  61.         int i;
  62.         int cur_pos;
  63.         dword cur_line;
  64.         for ( i=0; i < search.lines.count; i++)
  65.         {
  66.                 cur_pos = atoi(search.pos.get(i));
  67.                 cur_line = search.lines.get(i);
  68.                 kfont.WriteIntoBuffer(DRAW_PADDING, cur_pos, list.w,
  69.                         kfont.size.height, bg_color, text_color, kfont.size.pt, cur_line);
  70.         }
  71. }
  72.  
  73. :void PaintVisible()
  74. {
  75.         int i;
  76.         dword cur_pos;
  77.         dword cur_line;
  78.         for ( i=0; i < list.visible; i++)
  79.         {
  80.                 cur_pos = atoi(search.pos.get(i + list.first));
  81.                 cur_line = search.lines.get(i + list.first);
  82.                 kfont.WriteIntoBuffer(DRAW_PADDING, cur_pos, list.w,
  83.                         kfont.size.height, bg_color, text_color, kfont.size.pt, cur_line);
  84.         }
  85.         kfont.ApplySmooth();
  86. }