cleanup
This commit is contained in:
@@ -333,7 +333,7 @@ S8 win_proc(void* hwnd, U4 msg, U8 wparam, S8 lparam)
|
|||||||
tape_ptr[cursor_idx] = pack_token(tag, val);
|
tape_ptr[cursor_idx] = pack_token(tag, val);
|
||||||
}
|
}
|
||||||
else if (tag != STag_Format) {
|
else if (tag != STag_Format) {
|
||||||
U8*r anno_ptr = C_(U8*r, anno_arena.start);
|
U8*r anno_ptr = u8_r(anno_arena.start);
|
||||||
char* anno_str = (char*) & anno_ptr[cursor_idx];
|
char* anno_str = (char*) & anno_ptr[cursor_idx];
|
||||||
int len = 0;
|
int len = 0;
|
||||||
while (len < 8 && anno_str[len] != '\0' && anno_str[len] != ' ') len ++;
|
while (len < 8 && anno_str[len] != '\0' && anno_str[len] != ' ') len ++;
|
||||||
@@ -369,7 +369,6 @@ S8 win_proc(void* hwnd, U4 msg, U8 wparam, S8 lparam)
|
|||||||
U8 line_start = cursor_idx;
|
U8 line_start = cursor_idx;
|
||||||
while (line_start > 0 && unpack_tag(tape_ptr[line_start - 1]) != STag_Format) line_start --;
|
while (line_start > 0 && unpack_tag(tape_ptr[line_start - 1]) != STag_Format) line_start --;
|
||||||
U8 col = cursor_idx - line_start;
|
U8 col = cursor_idx - line_start;
|
||||||
|
|
||||||
U8 next_line_start = cursor_idx;
|
U8 next_line_start = cursor_idx;
|
||||||
while (next_line_start < tape_count && unpack_tag(tape_ptr[next_line_start]) != STag_Format) next_line_start ++;
|
while (next_line_start < tape_count && unpack_tag(tape_ptr[next_line_start]) != STag_Format) next_line_start ++;
|
||||||
if (next_line_start < tape_count) {
|
if (next_line_start < tape_count) {
|
||||||
@@ -422,7 +421,7 @@ S8 win_proc(void* hwnd, U4 msg, U8 wparam, S8 lparam)
|
|||||||
if (is_shift) insert_idx ++;
|
if (is_shift) insert_idx ++;
|
||||||
|
|
||||||
if (tape_arena.used + sizeof(U4) <= tape_arena.capacity && anno_arena.used + sizeof(U8) <= anno_arena.capacity) {
|
if (tape_arena.used + sizeof(U4) <= tape_arena.capacity && anno_arena.used + sizeof(U8) <= anno_arena.capacity) {
|
||||||
U8*r anno_ptr = C_(U8*r, anno_arena.start);
|
U8*r anno_ptr = u8_r(anno_arena.start);
|
||||||
for (U8 i = tape_count; i > insert_idx; i--) {
|
for (U8 i = tape_count; i > insert_idx; i--) {
|
||||||
tape_ptr[i] = tape_ptr[i-1];
|
tape_ptr[i] = tape_ptr[i-1];
|
||||||
anno_ptr[i] = anno_ptr[i-1];
|
anno_ptr[i] = anno_ptr[i-1];
|
||||||
@@ -467,34 +466,34 @@ S8 win_proc(void* hwnd, U4 msg, U8 wparam, S8 lparam)
|
|||||||
S4 start_x = 40, start_y = 60, spacing_x = 110, spacing_y = 35;
|
S4 start_x = 40, start_y = 60, spacing_x = 110, spacing_y = 35;
|
||||||
S4 x = start_x, y = start_y;
|
S4 x = start_x, y = start_y;
|
||||||
|
|
||||||
U4*r tape_ptr = C_(U4*r, tape_arena.start);
|
U4*r tape_ptr = u4_r(tape_arena.start);
|
||||||
U8*r anno_ptr = C_(U8*r, anno_arena.start);
|
U8*r anno_ptr = u8_r(anno_arena.start);
|
||||||
|
|
||||||
// Render Tokens
|
// Render Tokens
|
||||||
for (U8 i = 0; i < tape_count; i++) {
|
for (U8 i = 0; i < tape_count; i++)
|
||||||
|
{
|
||||||
if (x >= start_x + (TOKENS_PER_ROW * spacing_x)) {
|
if (x >= start_x + (TOKENS_PER_ROW * spacing_x)) {
|
||||||
x = start_x; y += spacing_y;
|
x = start_x; y += spacing_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
S4 render_y = y - scroll_y_offset;
|
S4 render_y = y - scroll_y_offset;
|
||||||
|
|
||||||
if (i == cursor_idx && render_y >= 30 && render_y < 500) {
|
if (i == cursor_idx && render_y >= 30 && render_y < 500) {
|
||||||
ms_select_object(hdc, editor_mode == MODE_EDIT ? hBrushEdit : hBrushNav);
|
ms_select_object(hdc, editor_mode == MODE_EDIT ? hBrushEdit : hBrushNav);
|
||||||
ms_rectangle(hdc, x - 5, render_y - 2, x + 95, render_y + 22);
|
ms_rectangle(hdc, x - 5, render_y - 2, x + 95, render_y + 22);
|
||||||
}
|
}
|
||||||
|
if (render_y >= 30 && render_y < 500)
|
||||||
if (render_y >= 30 && render_y < 500) {
|
{
|
||||||
U4 t = tape_ptr[i];
|
U4 t = tape_ptr[i];
|
||||||
U4 tag = unpack_tag(t);
|
U4 tag = unpack_tag(t);
|
||||||
U4 val = unpack_val(t);
|
U4 val = unpack_val(t);
|
||||||
U8 anno = anno_ptr[i];
|
U8 anno = anno_ptr[i];
|
||||||
|
|
||||||
if (tag == STag_Format && val == 0xA) {
|
if (tag == STag_Format && val == 0xA) {
|
||||||
ms_set_text_color(hdc, 0x00444444);
|
ms_set_text_color(hdc, 0x00444444);
|
||||||
ms_text_out_a(hdc, x, render_y, " \\n ", 6);
|
ms_text_out_a(hdc, x, render_y, " \\n ", 6);
|
||||||
x = start_x;
|
x = start_x;
|
||||||
y += spacing_y;
|
y += spacing_y;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
U4 color = tag_colors[tag];
|
U4 color = tag_colors[tag];
|
||||||
const char* prefix = tag_prefixes[tag];
|
const char* prefix = tag_prefixes[tag];
|
||||||
|
|
||||||
@@ -504,10 +503,13 @@ S8 win_proc(void* hwnd, U4 msg, U8 wparam, S8 lparam)
|
|||||||
ms_set_text_color(hdc, 0x001E1E1E);
|
ms_set_text_color(hdc, 0x001E1E1E);
|
||||||
}
|
}
|
||||||
|
|
||||||
char val_str[9]; if (tag == STag_Data) {
|
char val_str[9];
|
||||||
|
if (tag == STag_Data) {
|
||||||
u64_to_hex(val, val_str, 6);
|
u64_to_hex(val, val_str, 6);
|
||||||
val_str[6] = '\0';
|
val_str[6] = '\0';
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// Extract annotation string
|
// Extract annotation string
|
||||||
char* a_str = (char*) & anno;
|
char* a_str = (char*) & anno;
|
||||||
if (a_str[0] == '\0') {
|
if (a_str[0] == '\0') {
|
||||||
@@ -516,12 +518,12 @@ S8 win_proc(void* hwnd, U4 msg, U8 wparam, S8 lparam)
|
|||||||
val_str[1] = (char)(val & 0xFF);
|
val_str[1] = (char)(val & 0xFF);
|
||||||
val_str[2] = ' '; val_str[3] = ' '; val_str[4] = ' '; val_str[5] = ' ';
|
val_str[2] = ' '; val_str[3] = ' '; val_str[4] = ' '; val_str[5] = ' ';
|
||||||
val_str[6] = '\0';
|
val_str[6] = '\0';
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
mem_copy(u8_(val_str), u8_(a_str), 8);
|
mem_copy(u8_(val_str), u8_(a_str), 8);
|
||||||
val_str[8] = '\0';
|
val_str[8] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char out_buf[12];
|
char out_buf[12];
|
||||||
out_buf[0] = prefix[0];
|
out_buf[0] = prefix[0];
|
||||||
out_buf[1] = ' ';
|
out_buf[1] = ' ';
|
||||||
@@ -531,10 +533,12 @@ S8 win_proc(void* hwnd, U4 msg, U8 wparam, S8 lparam)
|
|||||||
ms_text_out_a(hdc, x, render_y, out_buf, 10);
|
ms_text_out_a(hdc, x, render_y, out_buf, 10);
|
||||||
x += spacing_x;
|
x += spacing_x;
|
||||||
}
|
}
|
||||||
} else if (unpack_tag(tape_ptr[i]) == STag_Format && unpack_val(tape_ptr[i]) == 0xA) {
|
}
|
||||||
|
else if (unpack_tag(tape_ptr[i]) == STag_Format && unpack_val(tape_ptr[i]) == 0xA) {
|
||||||
x = start_x;
|
x = start_x;
|
||||||
y += spacing_y;
|
y += spacing_y;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
x += spacing_x;
|
x += spacing_x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -566,7 +570,6 @@ S8 win_proc(void* hwnd, U4 msg, U8 wparam, S8 lparam)
|
|||||||
U4 cur_tag = unpack_tag(tape_ptr[cursor_idx]);
|
U4 cur_tag = unpack_tag(tape_ptr[cursor_idx]);
|
||||||
const char* tag_name = tag_names [cur_tag];
|
const char* tag_name = tag_names [cur_tag];
|
||||||
U4 cur_color = tag_colors[cur_tag];
|
U4 cur_color = tag_colors[cur_tag];
|
||||||
|
|
||||||
char semantics_str[64] = "Current Tag: ";
|
char semantics_str[64] = "Current Tag: ";
|
||||||
U4 name_len = 0;
|
U4 name_len = 0;
|
||||||
while (tag_name[name_len]) {
|
while (tag_name[name_len]) {
|
||||||
@@ -574,7 +577,6 @@ S8 win_proc(void* hwnd, U4 msg, U8 wparam, S8 lparam)
|
|||||||
name_len ++;
|
name_len ++;
|
||||||
}
|
}
|
||||||
semantics_str[13 + name_len] = '\0';
|
semantics_str[13 + name_len] = '\0';
|
||||||
|
|
||||||
ms_set_text_color(hdc, cur_color);
|
ms_set_text_color(hdc, cur_color);
|
||||||
ms_text_out_a(hdc, 40, 580, semantics_str, 13 + name_len);
|
ms_text_out_a(hdc, 40, 580, semantics_str, 13 + name_len);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user