From 6d2589d149c4058c4978b370530bc17df30ba9c8 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Sun, 18 Sep 2016 23:29:40 -0400 Subject: [PATCH] rendering all bytes --- TODO.txt | 6 +- buffer/4coder_buffer_abstract.cpp | 93 +++++++++++++++++++------------ 2 files changed, 61 insertions(+), 38 deletions(-) diff --git a/TODO.txt b/TODO.txt index 18e21850..2c67a6e7 100644 --- a/TODO.txt +++ b/TODO.txt @@ -167,13 +167,13 @@ ; [] API docs have duplicate ids? ; [] introduce custom command line arguments ; [] control the file opening/start hook relationship better -; [] flag for hiding the *messages* buffer. ; [] get keyboard state on launch ; buffer behavior cleanup -; [] show all characters as \# if they can't be rendered +; [X] show all characters as \# if they can't be rendered +; [] binary buffer mode +; [] get the navigation working correctly around multi-glyph characters ; [] support full length unicode file names -; [] binary buffers ; meta programming system ; [X] condense system into single meta compiler diff --git a/buffer/4coder_buffer_abstract.cpp b/buffer/4coder_buffer_abstract.cpp index e3410c5e..cc89a2e0 100644 --- a/buffer/4coder_buffer_abstract.cpp +++ b/buffer/4coder_buffer_abstract.cpp @@ -1,12 +1,12 @@ /* -* Mr. 4th Dimention - Allen Webster -* Four Tech -* -* public domain -- no warranty is offered or implied; use this code at your own risk -* -* 24.10.2015 -* -*/ + * Mr. 4th Dimention - Allen Webster + * Four Tech + * + * public domain -- no warranty is offered or implied; use this code at your own risk + * + * 24.10.2015 + * + */ // TOP @@ -847,7 +847,7 @@ buffer_get_render_data(Buffer_Type *buffer, Buffer_Render_Item *items, int max, float x, y; int i, item_i; float ch_width, ch_width_sub; - char ch; + uint8_t ch; size = buffer_size(buffer); @@ -875,7 +875,7 @@ buffer_get_render_data(Buffer_Type *buffer, Buffer_Render_Item *items, int max, data = loop.data - loop.absolute_pos; for (i = loop.absolute_pos; i < end; ++i){ - ch = data[i]; + ch = (uint8_t)data[i]; ch_width = measure_character(advance_data, ch); if (ch_width + x > width + shift_x && wrapped && ch != '\n'){ @@ -897,24 +897,6 @@ buffer_get_render_data(Buffer_Type *buffer, Buffer_Render_Item *items, int max, } break; - case 0: - if (item < item_end){ - ch_width = write_render_item_inline(item, i, '\\', x, y, advance_data, font_height); - item->flags = BRFlag_Special_Character; - ++item_i; - ++item; - x += ch_width; - - if (item < item_end){ - ch_width = write_render_item_inline(item, i, '0', x, y, advance_data, font_height); - item->flags = BRFlag_Special_Character; - ++item_i; - ++item; - x += ch_width; - } - } - break; - case '\r': if (item < item_end){ ch_width = write_render_item_inline(item, i, '\\', x, y, advance_data, font_height); @@ -961,19 +943,59 @@ buffer_get_render_data(Buffer_Type *buffer, Buffer_Render_Item *items, int max, default: if (item < item_end){ - write_render_item(item, i, ch, x, y, ch_width, font_height); - item->flags = 0; - ++item_i; - ++item; - x += ch_width; + if (ch >= ' ' && ch <= '~'){ + write_render_item(item, i, ch, x, y, ch_width, font_height); + item->flags = 0; + ++item_i; + ++item; + x += ch_width; + } + else{ + ch_width = write_render_item_inline(item, i, '\\', x, y, advance_data, font_height); + item->flags = BRFlag_Special_Character; + ++item_i; + ++item; + x += ch_width; + + char C = '0' + (ch / 0x10); + if ((ch / 0x10) > 0x9){ + C = ('A' - 0xA) + (ch / 0x10); + } + + if (item < item_end){ + ch_width = write_render_item_inline(item, i, C, x, y, advance_data, font_height); + item->flags = BRFlag_Special_Character; + ++item_i; + ++item; + x += ch_width; + } + + ch = (ch % 0x10); + C = '0' + ch; + if (ch > 0x9){ + C = ('A' - 0xA) + ch; + } + + if (item < item_end){ + ch_width = write_render_item_inline(item, i, C, x, y, advance_data, font_height); + item->flags = BRFlag_Special_Character; + ++item_i; + ++item; + x += ch_width; + } + + } } break; } - if (y > height + shift_y) goto buffer_get_render_data_end; + + if (y > height + shift_y){ + goto buffer_get_render_data_end; + } } } - buffer_get_render_data_end: + buffer_get_render_data_end:; if (y <= height + shift_y || item == items){ if (item < item_end){ ch = 0; @@ -1004,5 +1026,6 @@ buffer_get_render_data(Buffer_Type *buffer, Buffer_Render_Item *items, int max, #ifndef NON_ABSTRACT_4TECH #define NON_ABSTRACT_4TECH 1 #endif + // BOTTOM