2020-05-15 21:59:10 +02:00
|
|
|
|
|
|
|
void ParseAndPaint()
|
|
|
|
{
|
|
|
|
Parse();
|
2021-02-06 18:26:52 +01:00
|
|
|
DrawPage();
|
2020-05-15 21:59:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Parse()
|
|
|
|
{
|
2021-02-06 18:26:52 +01:00
|
|
|
dword ptr;
|
2020-05-15 21:59:10 +02:00
|
|
|
int line_end;
|
2021-02-06 18:26:52 +01:00
|
|
|
|
|
|
|
list.count=0;
|
|
|
|
selection.cancel();
|
2022-01-08 20:52:20 +01:00
|
|
|
if (list.w != canvas.bufw) canvas.Init(list.x, list.y, list.w, screen.h);
|
2020-05-15 21:59:10 +02:00
|
|
|
|
|
|
|
lines.drop();
|
2021-02-06 18:26:52 +01:00
|
|
|
lines.add(textbuf.p);
|
2020-05-15 21:59:10 +02:00
|
|
|
|
2021-02-06 18:26:52 +01:00
|
|
|
for (ptr = textbuf.p; ptr < textbuf.p + textbuf.len; ptr++)
|
2020-05-15 21:59:10 +02:00
|
|
|
{
|
2021-06-21 23:32:40 +02:00
|
|
|
if (ptr - lines.get_last() * list.font_w + 16 >= list.w)
|
2020-05-15 21:59:10 +02:00
|
|
|
{
|
|
|
|
//searching a 'white' for a normal word-break
|
2021-06-21 23:32:40 +02:00
|
|
|
for(line_end = ptr; line_end != lines.get_last(); line_end--) {
|
|
|
|
if (__isWhite(ESBYTE[line_end])) {
|
|
|
|
ptr = line_end + 1;
|
|
|
|
break;
|
|
|
|
}
|
2020-05-15 21:59:10 +02:00
|
|
|
}
|
|
|
|
list.count++;
|
2021-02-06 18:26:52 +01:00
|
|
|
lines.add(ptr);
|
2021-06-21 23:32:40 +02:00
|
|
|
} else if (ESBYTE[ptr] == '\x0D') {
|
|
|
|
if (ESBYTE[ptr+1] == '\x0A') ptr++;
|
|
|
|
list.count++;
|
|
|
|
lines.add(ptr+1);
|
|
|
|
} else if (ESBYTE[ptr] == '\x0A') {
|
|
|
|
list.count++;
|
|
|
|
lines.add(ptr+1);
|
2020-05-15 21:59:10 +02:00
|
|
|
}
|
|
|
|
}
|
2021-02-06 18:26:52 +01:00
|
|
|
lines.add(ptr);
|
2020-05-15 21:59:10 +02:00
|
|
|
list.count++;
|
|
|
|
}
|
|
|
|
|
2021-02-06 18:26:52 +01:00
|
|
|
void DrawPage()
|
|
|
|
{
|
|
|
|
char t[64];
|
|
|
|
scroll.max_area = list.count;
|
|
|
|
scroll.cur_area = list.visible;
|
|
|
|
scroll.position = list.first;
|
|
|
|
scroll.all_redraw = 0;
|
|
|
|
scroll.start_x = list.x + list.w;
|
|
|
|
scroll.start_y = list.y;
|
|
|
|
scroll.size_y = list.h;
|
|
|
|
|
|
|
|
if (list.count <= list.visible) {
|
|
|
|
DrawBar(scroll.start_x, scroll.start_y, scroll.size_x,
|
|
|
|
scroll.size_y, theme.bg);
|
|
|
|
} else {
|
|
|
|
scrollbar_v_draw(#scroll);
|
|
|
|
}
|
|
|
|
DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x,
|
|
|
|
scroll.size_y-1, scroll.bckg_col);
|
|
|
|
|
|
|
|
PaintVisible();
|
|
|
|
|
|
|
|
sprintf(#t, #chars_selected, math.abs(selection.end_offset - selection.start_offset));
|
|
|
|
if (selection.is_active()) DrawStatusBar(#t); else DrawStatusBar(" ");
|
|
|
|
}
|
|
|
|
|
2020-05-15 21:59:10 +02:00
|
|
|
void PaintVisible()
|
|
|
|
{
|
2020-05-20 21:34:09 +02:00
|
|
|
int i, ff;
|
|
|
|
signed s1, s2;
|
2020-05-16 00:00:20 +02:00
|
|
|
dword ydraw, absolute_y;
|
2020-05-15 21:59:10 +02:00
|
|
|
dword line_bg;
|
2020-05-16 00:00:20 +02:00
|
|
|
bool swapped_selection = false;
|
2020-05-15 21:59:10 +02:00
|
|
|
|
2020-05-17 00:01:17 +02:00
|
|
|
list.column_max = lines.len(list.cur_y);
|
2020-05-15 21:59:10 +02:00
|
|
|
list.CheckDoesValuesOkey();
|
|
|
|
if (selection.end_offset < selection.start_offset) {
|
2020-05-16 00:00:20 +02:00
|
|
|
swapped_selection = selection.swap_start_end();
|
2020-05-15 21:59:10 +02:00
|
|
|
}
|
|
|
|
|
2020-05-16 00:00:20 +02:00
|
|
|
for ( i=0; i < list.visible+1; i++)
|
2020-05-15 21:59:10 +02:00
|
|
|
{
|
2020-05-16 00:00:20 +02:00
|
|
|
ydraw = i * list.item_h;
|
|
|
|
absolute_y = i + list.first;
|
2020-05-15 21:59:10 +02:00
|
|
|
line_bg = theme.bg;
|
|
|
|
|
2020-05-16 00:00:20 +02:00
|
|
|
if (selection.start_y < absolute_y) && (selection.end_y > absolute_y) line_bg = selection.color;
|
2020-12-18 00:01:09 +01:00
|
|
|
canvas.DrawBar(0, ydraw, list.w, list.item_h, line_bg);
|
2020-05-15 21:59:10 +02:00
|
|
|
|
2020-05-16 00:00:20 +02:00
|
|
|
selection.draw(absolute_y);
|
2020-05-15 21:59:10 +02:00
|
|
|
|
2020-05-24 02:18:40 +02:00
|
|
|
if (search.visible) || (search_next) for (ff=0; ff<search.found.count; ff++) {
|
2020-05-20 21:34:09 +02:00
|
|
|
s1 = search.found.get(ff) - lines.get(absolute_y);
|
|
|
|
s2 = search.found.get(ff) - lines.get(absolute_y+1);
|
|
|
|
|
|
|
|
if (s2 > 0) break;
|
|
|
|
|
|
|
|
if (s1 > 0) && (s2 < 0) {
|
2020-12-18 00:01:09 +01:00
|
|
|
canvas.DrawBar(search.found.get(ff) - lines.get(absolute_y) * list.font_w + 3,
|
2020-05-20 21:34:09 +02:00
|
|
|
ydraw, strlen(#found_text) * list.font_w, list.item_h, theme.found);
|
2020-05-24 02:18:40 +02:00
|
|
|
search_next = false;
|
2020-05-20 21:34:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-06 18:26:52 +01:00
|
|
|
if (absolute_y<list.count) canvas.WriteText(3, ydraw+3, list.font_type, theme.text,
|
2020-05-17 00:01:17 +02:00
|
|
|
lines.get(absolute_y), lines.len(absolute_y));
|
2020-05-15 21:59:10 +02:00
|
|
|
}
|
|
|
|
|
2020-12-18 00:01:09 +01:00
|
|
|
PutPaletteImage(buf_data+8, canvas.bufw, list.h, list.x, list.y, 32, 0);
|
2020-05-15 21:59:10 +02:00
|
|
|
|
2020-05-16 00:00:20 +02:00
|
|
|
if (swapped_selection) selection.swap_start_end();
|
2020-05-15 21:59:10 +02:00
|
|
|
}
|