Subversion Repositories Kolibri OS

Rev

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

  1. enum {
  2.         COUNT_BUF_HEIGHT,
  3.         DRAW_BUF
  4. };
  5.  
  6. void Parcer(byte mode)
  7. {
  8. dword bufoff, buflen;
  9. byte ch;
  10. char line[4096]=0;
  11. int srch_pos;
  12. dword stroka_y=5;
  13. dword line_length=30;
  14. dword line_start=io.buffer_data;
  15.  
  16.         buflen = strlen(io.buffer_data) + io.buffer_data;
  17.         for (bufoff=io.buffer_data; bufoff<buflen; bufoff++)
  18.         {
  19.                 ch = ESBYTE[bufoff];
  20.                 line_length += kfont_char_width[ch];
  21.                 if (line_length>=list.w) || (ch==10) {
  22.                         srch_pos = bufoff;
  23.                         loop()
  24.                         {
  25.                                 if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break
  26.                                 if (srch_pos == line_start) break; //no white space found in whole line
  27.                                 srch_pos--;
  28.                         }
  29.                         if (mode==COUNT_BUF_HEIGHT) {
  30.                                 line_start = bufoff;
  31.                                 line_length = 30;
  32.                                 list.count++;
  33.                         }
  34.                         if (mode==DRAW_BUF) {
  35.                                 EBX = bufoff-line_start;
  36.                                 strlcpy(#line, line_start, EBX);
  37.                                 kfont.WriteIntoBuffer(8,stroka_y,list.w,kfont.size.height, bg_color, text_color, kfont.size.pt, #line);
  38.                                 stroka_y += list.item_h;
  39.                                 line_start = bufoff;
  40.                                 line_length = 30;
  41.                         }
  42.                 }
  43.         }
  44.         if (mode==COUNT_BUF_HEIGHT) list.count+=2;
  45.         if (mode==DRAW_BUF) kfont.WriteIntoBuffer(8,stroka_y,list.w,kfont.size.height, bg_color, text_color, kfont.size.pt, line_start);
  46. }
  47.  
  48. void PreparePage()
  49. {
  50.         list.w = Form.cwidth-scroll.size_x-1;
  51.         list.count=0;
  52.         Parcer(COUNT_BUF_HEIGHT);
  53.        
  54.         //draw text in buffer
  55.         list.SetSizes(0, TOOLBAR_H, list.w, Form.cheight-TOOLBAR_H, kfont.size.pt+4);
  56.         if (list.count < list.visible) list.count = list.visible;
  57.         kfont.size.height = list.count+1*list.item_h;
  58.         kfont.raw_size = 0;
  59.         Parcer(DRAW_BUF);
  60.  
  61.         if (list.count > list.visible * 10) DrawPage();
  62.         //draw result
  63.         kfont.ApplySmooth();
  64.         DrawPage();
  65. }
  66.