2020-04-21 22:49:38 +02:00
|
|
|
void ParseAndPaint()
|
|
|
|
{
|
|
|
|
dword start_time = GetStartTime();
|
|
|
|
search.clear();
|
|
|
|
Parse();
|
|
|
|
Paint();
|
|
|
|
debugln("\nTextRead statistics in miliseconds...");
|
|
|
|
debugval("Page generate time", GetStartTime() - start_time);
|
|
|
|
if (list.count > list.visible * 10) DrawPage();
|
|
|
|
start_time = GetStartTime();
|
|
|
|
kfont.ApplySmooth();
|
|
|
|
debugval("Smooth", GetStartTime() - start_time);
|
|
|
|
DrawPage();
|
|
|
|
}
|
|
|
|
|
2015-12-24 18:04:29 +01:00
|
|
|
|
2018-11-04 01:20:00 +01:00
|
|
|
#define DRAW_PADDING 12
|
|
|
|
|
2020-04-21 22:49:38 +02:00
|
|
|
void Parse()
|
2015-12-17 16:48:28 +01:00
|
|
|
{
|
2015-12-24 18:04:29 +01:00
|
|
|
dword bufoff, buflen;
|
|
|
|
byte ch;
|
|
|
|
char line[4096]=0;
|
|
|
|
int srch_pos;
|
2018-11-04 01:20:00 +01:00
|
|
|
dword stroka_y=DRAW_PADDING-3;
|
2015-12-24 18:04:29 +01:00
|
|
|
dword line_length=30;
|
|
|
|
dword line_start=io.buffer_data;
|
2015-12-21 13:13:21 +01:00
|
|
|
|
2020-04-21 22:49:38 +02:00
|
|
|
list.count=0;
|
2015-12-21 13:13:21 +01:00
|
|
|
buflen = strlen(io.buffer_data) + io.buffer_data;
|
|
|
|
for (bufoff=io.buffer_data; bufoff<buflen; bufoff++)
|
2015-12-17 16:48:28 +01:00
|
|
|
{
|
|
|
|
ch = ESBYTE[bufoff];
|
2018-05-22 14:04:44 +02:00
|
|
|
line_length += kfont_char_width[ch];
|
2015-12-17 16:48:28 +01:00
|
|
|
if (line_length>=list.w) || (ch==10) {
|
|
|
|
srch_pos = bufoff;
|
|
|
|
loop()
|
|
|
|
{
|
|
|
|
if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break
|
|
|
|
if (srch_pos == line_start) break; //no white space found in whole line
|
|
|
|
srch_pos--;
|
|
|
|
}
|
2020-04-21 22:49:38 +02:00
|
|
|
list.count++;
|
|
|
|
strlcpy(#line, line_start, bufoff-line_start);
|
|
|
|
search.add(stroka_y, #line);
|
|
|
|
stroka_y += list.item_h;
|
|
|
|
line_start = bufoff;
|
|
|
|
line_length = 30;
|
2015-12-17 16:48:28 +01:00
|
|
|
}
|
|
|
|
}
|
2020-04-21 22:49:38 +02:00
|
|
|
list.count+=2;
|
|
|
|
list.visible = list.h / list.item_h;
|
2015-12-17 16:48:28 +01:00
|
|
|
if (list.count < list.visible) list.count = list.visible;
|
2016-12-21 20:50:13 +01:00
|
|
|
kfont.size.height = list.count+1*list.item_h;
|
|
|
|
kfont.raw_size = 0;
|
2020-04-21 22:49:38 +02:00
|
|
|
search.add(stroka_y, line_start);
|
|
|
|
}
|
2015-12-17 16:48:28 +01:00
|
|
|
|
2020-04-21 22:49:38 +02:00
|
|
|
void Paint()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int cur_pos;
|
|
|
|
dword cur_line;
|
|
|
|
for ( i=0; i < search.lines.count; i++)
|
|
|
|
{
|
|
|
|
cur_pos = atoi(search.pos.get(i));
|
|
|
|
cur_line = search.lines.get(i);
|
|
|
|
kfont.WriteIntoBuffer(DRAW_PADDING, cur_pos, list.w,
|
|
|
|
kfont.size.height, bg_color, text_color, kfont.size.pt, cur_line);
|
|
|
|
}
|
2015-12-17 16:48:28 +01:00
|
|
|
}
|
2020-04-21 22:49:38 +02:00
|
|
|
|
|
|
|
:void PaintVisible()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
dword cur_pos;
|
|
|
|
dword cur_line;
|
|
|
|
for ( i=0; i < list.visible; i++)
|
|
|
|
{
|
|
|
|
cur_pos = atoi(search.pos.get(i + list.first));
|
|
|
|
cur_line = search.lines.get(i + list.first);
|
|
|
|
kfont.WriteIntoBuffer(DRAW_PADDING, cur_pos, list.w,
|
|
|
|
kfont.size.height, bg_color, text_color, kfont.size.pt, cur_line);
|
|
|
|
}
|
|
|
|
kfont.ApplySmooth();
|
|
|
|
}
|