MuGaB rendering and seeking
This commit is contained in:
parent
afbde90d9e
commit
e88b9ea324
8
4ed.cpp
8
4ed.cpp
|
@ -215,7 +215,7 @@ COMMAND_DECL(write_character){
|
|||
}
|
||||
|
||||
COMMAND_DECL(seek_whitespace_right){
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 1
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
ProfileMomentFunction();
|
||||
REQ_FILE_VIEW(view);
|
||||
REQ_FILE(file, view);
|
||||
|
@ -227,7 +227,7 @@ COMMAND_DECL(seek_whitespace_right){
|
|||
}
|
||||
|
||||
COMMAND_DECL(seek_whitespace_left){
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 1
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
ProfileMomentFunction();
|
||||
REQ_FILE_VIEW(view);
|
||||
REQ_FILE(file, view);
|
||||
|
@ -239,7 +239,7 @@ COMMAND_DECL(seek_whitespace_left){
|
|||
}
|
||||
|
||||
COMMAND_DECL(seek_whitespace_up){
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 1
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
ProfileMomentFunction();
|
||||
REQ_FILE_VIEW(view);
|
||||
REQ_FILE(file, view);
|
||||
|
@ -250,7 +250,7 @@ COMMAND_DECL(seek_whitespace_up){
|
|||
}
|
||||
|
||||
COMMAND_DECL(seek_whitespace_down){
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 1
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
ProfileMomentFunction();
|
||||
REQ_FILE_VIEW(view);
|
||||
REQ_FILE(file, view);
|
||||
|
|
|
@ -1155,7 +1155,7 @@ file_save_and_set_names(Partition *part, Editing_File *file, u8 *filename){
|
|||
|
||||
inline i32
|
||||
file_count_newlines(Editing_File *file, i32 start, i32 end){
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 1
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
i32 count = buffer_count_newlines(&file->buffer, start, end);
|
||||
#else
|
||||
i32 count = 0;
|
||||
|
@ -1183,7 +1183,7 @@ enum File_Bubble_Type{
|
|||
internal i32
|
||||
file_grow_starts_as_needed(General_Memory *general, Editing_File *file, i32 additional_lines){
|
||||
bool32 result = GROW_NOT_NEEDED;
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 1
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
i32 max = file->buffer.line_max;
|
||||
i32 count = file->buffer.line_count;
|
||||
i32 target_lines = count + additional_lines;
|
||||
|
@ -1207,7 +1207,7 @@ file_grow_starts_as_needed(General_Memory *general, Editing_File *file, i32 addi
|
|||
|
||||
internal void
|
||||
file_measure_starts(General_Memory *general, Editing_File *file){
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 1
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
ProfileMomentFunction();
|
||||
if (!file->buffer.line_starts){
|
||||
i32 max = file->buffer.line_max = Kbytes(1);
|
||||
|
@ -1240,7 +1240,7 @@ internal void
|
|||
file_remeasure_starts(General_Memory *general, Editing_File *file,
|
||||
i32 line_start, i32 line_end, i32 line_shift,
|
||||
i32 character_shift){
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 1
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
ProfileMomentFunction();
|
||||
|
||||
Assert(file->buffer.line_starts);
|
||||
|
@ -1265,7 +1265,7 @@ get_opaque_font_advance(Font *font){
|
|||
|
||||
internal void
|
||||
file_grow_widths_as_needed(General_Memory *general, Editing_File *file){
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 1
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
i32 line_count = file->buffer.line_count;
|
||||
if (line_count > file->buffer.widths_max){
|
||||
i32 new_max = LargeRoundUp(line_count, Kbytes(1));
|
||||
|
@ -1284,7 +1284,7 @@ file_grow_widths_as_needed(General_Memory *general, Editing_File *file){
|
|||
|
||||
internal void
|
||||
file_measure_widths(General_Memory *general, Editing_File *file, Font *font){
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 1
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
ProfileMomentFunction();
|
||||
|
||||
file_grow_widths_as_needed(general, file);
|
||||
|
@ -1296,7 +1296,7 @@ file_measure_widths(General_Memory *general, Editing_File *file, Font *font){
|
|||
internal void
|
||||
file_remeasure_widths(General_Memory *general, Editing_File *file, Font *font,
|
||||
i32 line_start, i32 line_end, i32 line_shift){
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 1
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
ProfileMomentFunction();
|
||||
|
||||
file_grow_widths_as_needed(general, file);
|
||||
|
@ -1316,7 +1316,7 @@ view_wrapped_line_span(real32 line_width, real32 max_width){
|
|||
internal i32
|
||||
view_compute_lowest_line(File_View *view){
|
||||
i32 lowest_line = 0;
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 1
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
i32 last_line = view->line_count - 1;
|
||||
if (last_line > 0){
|
||||
if (view->unwrapped_lines){
|
||||
|
@ -1342,7 +1342,7 @@ view_compute_lowest_line(File_View *view){
|
|||
|
||||
internal void
|
||||
view_measure_wraps(General_Memory *general, File_View *view){
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 1
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
ProfileMomentFunction();
|
||||
Editing_File *file = view->file;
|
||||
i32 line_count = file->buffer.line_count;
|
||||
|
@ -1389,10 +1389,6 @@ file_create_from_string(General_Memory *general, Editing_File *file, u8 *filenam
|
|||
}
|
||||
i32 init_success = buffer_end_init(&init);
|
||||
Assert(init_success);
|
||||
|
||||
#if 0
|
||||
buffer_initialize(&file->buffer, val.str, val.size);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
file_synchronize_times(file, filename);
|
||||
|
@ -1493,6 +1489,8 @@ file_close(General_Memory *general, Editing_File *file){
|
|||
general_memory_free(general, file->buffer.data);
|
||||
general_memory_free(general, file->buffer.line_starts);
|
||||
general_memory_free(general, file->buffer.line_widths);
|
||||
#elif BUFFER_EXPERIMENT_SCALPEL == 2
|
||||
// TODO
|
||||
#endif
|
||||
|
||||
general_memory_free(general, file->undo.undo.strings);
|
||||
|
@ -1999,7 +1997,7 @@ file_post_history(General_Memory *general, Editing_File *file,
|
|||
|
||||
inline Full_Cursor
|
||||
view_compute_cursor_from_pos(File_View *view, i32 pos){
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 1
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
Editing_File *file = view->file;
|
||||
Style *style = view->style;
|
||||
Font *font = style->font;
|
||||
|
@ -2017,7 +2015,7 @@ view_compute_cursor_from_pos(File_View *view, i32 pos){
|
|||
inline Full_Cursor
|
||||
view_compute_cursor_from_unwrapped_xy(File_View *view, real32 seek_x, real32 seek_y,
|
||||
bool32 round_down = 0){
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 1
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
Editing_File *file = view->file;
|
||||
Style *style = view->style;
|
||||
Font *font = style->font;
|
||||
|
@ -2035,7 +2033,7 @@ view_compute_cursor_from_unwrapped_xy(File_View *view, real32 seek_x, real32 see
|
|||
inline Full_Cursor
|
||||
view_compute_cursor_from_wrapped_xy(File_View *view, real32 seek_x, real32 seek_y,
|
||||
bool32 round_down = 0){
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 1
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
Editing_File *file = view->file;
|
||||
Style *style = view->style;
|
||||
Font *font = style->font;
|
||||
|
@ -2898,7 +2896,7 @@ working_set_lookup_file(Working_Set *working_set, String string){
|
|||
|
||||
internal void
|
||||
clipboard_copy(General_Memory *general, Working_Set *working, Range range, Editing_File *file){
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 1
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
i32 size = range.end - range.start;
|
||||
String *dest = working_set_next_clipboard_string(general, working, size);
|
||||
buffer_stringify(&file->buffer, range.start, range.end, dest->str);
|
||||
|
@ -3728,7 +3726,7 @@ draw_file_view(Thread_Context *thread, View *view_, i32_Rect rect, bool32 is_act
|
|||
bar.rect.y1 = bar.rect.y0 + font->height + 2;
|
||||
rect.y0 += font->height + 2;
|
||||
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 1
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
i32 max_x = rect.x1 - rect.x0;
|
||||
i32 max_y = rect.y1 - rect.y0 + font->height;
|
||||
|
||||
|
@ -3985,7 +3983,7 @@ HANDLE_COMMAND_SIG(handle_command_file_view){
|
|||
|
||||
case FWIDG_SEARCH:
|
||||
{
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 1
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
String *string = &file_view->isearch.str;
|
||||
Single_Line_Input_Step result =
|
||||
app_single_line_input_step(codes, key, string);
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
#define Buffer_Stringify_Type cat_4tech(Buffer_Type, _Stringify_Loop)
|
||||
#define Buffer_Backify_Type cat_4tech(Buffer_Type, _Backify_Loop)
|
||||
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 1
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
inline_4tech void
|
||||
buffer_stringify(Buffer_Type *buffer, int start, int end, char *out){
|
||||
for (Buffer_Stringify_Type loop = buffer_stringify_loop(buffer, start, end, end - start);
|
||||
for (Buffer_Stringify_Type loop = buffer_stringify_loop(buffer, start, end);
|
||||
buffer_stringify_good(&loop);
|
||||
buffer_stringify_next(&loop)){
|
||||
memcpy_4tech(out, loop.data, loop.size);
|
||||
|
@ -37,7 +37,7 @@ buffer_convert_out(Buffer_Type *buffer, char *dest, int max){
|
|||
assert_4tech(size + buffer->line_count < max);
|
||||
|
||||
pos = 0;
|
||||
for (loop = buffer_stringify_loop(buffer, 0, size, size);
|
||||
for (loop = buffer_stringify_loop(buffer, 0, size);
|
||||
buffer_stringify_good(&loop);
|
||||
buffer_stringify_next(&loop)){
|
||||
result = eol_convert_out(dest + pos, max - pos, loop.data, loop.size, &out_size);
|
||||
|
@ -60,7 +60,7 @@ buffer_count_newlines(Buffer_Type *buffer, int start, int end){
|
|||
|
||||
count = 0;
|
||||
|
||||
for (loop = buffer_stringify_loop(buffer, start, end, end - start);
|
||||
for (loop = buffer_stringify_loop(buffer, start, end);
|
||||
buffer_stringify_good(&loop);
|
||||
buffer_stringify_next(&loop)){
|
||||
for (i = 0; i < loop.size; ++i){
|
||||
|
@ -70,7 +70,9 @@ buffer_count_newlines(Buffer_Type *buffer, int start, int end){
|
|||
|
||||
return(count);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
internal_4tech int
|
||||
buffer_seek_whitespace_down(Buffer_Type *buffer, int pos){
|
||||
Buffer_Stringify_Type loop;
|
||||
|
@ -81,7 +83,7 @@ buffer_seek_whitespace_down(Buffer_Type *buffer, int pos){
|
|||
int prev_endline;
|
||||
|
||||
size = buffer_size(buffer);
|
||||
loop = buffer_stringify_loop(buffer, pos, size, size);
|
||||
loop = buffer_stringify_loop(buffer, pos, size);
|
||||
|
||||
for (;buffer_stringify_good(&loop);
|
||||
buffer_stringify_next(&loop)){
|
||||
|
@ -129,7 +131,7 @@ buffer_seek_whitespace_up(Buffer_Type *buffer, int pos){
|
|||
int no_hard;
|
||||
|
||||
size = buffer_size(buffer);
|
||||
loop = buffer_backify_loop(buffer, pos, 1, size);
|
||||
loop = buffer_backify_loop(buffer, pos, 1);
|
||||
|
||||
for (;buffer_backify_good(&loop);
|
||||
buffer_backify_next(&loop)){
|
||||
|
@ -171,7 +173,7 @@ buffer_seek_whitespace_right(Buffer_Type *buffer, int pos){
|
|||
int size;
|
||||
|
||||
size = buffer_size(buffer);
|
||||
loop = buffer_stringify_loop(buffer, pos, size, size);
|
||||
loop = buffer_stringify_loop(buffer, pos, size);
|
||||
|
||||
for (;buffer_stringify_good(&loop);
|
||||
buffer_stringify_next(&loop)){
|
||||
|
@ -202,7 +204,7 @@ buffer_seek_whitespace_left(Buffer_Type *buffer, int pos){
|
|||
--pos;
|
||||
if (pos > 0){
|
||||
size = buffer_size(buffer);
|
||||
loop = buffer_backify_loop(buffer, pos, 1, size);
|
||||
loop = buffer_backify_loop(buffer, pos, 1);
|
||||
|
||||
for (;buffer_backify_good(&loop);
|
||||
buffer_backify_next(&loop)){
|
||||
|
@ -237,7 +239,7 @@ buffer_seek_alphanumeric_right(Buffer_Type *buffer, int pos){
|
|||
int size;
|
||||
|
||||
size = buffer_size(buffer);
|
||||
loop = buffer_stringify_loop(buffer, pos, size, size);
|
||||
loop = buffer_stringify_loop(buffer, pos, size);
|
||||
|
||||
for (;buffer_stringify_good(&loop);
|
||||
buffer_stringify_next(&loop)){
|
||||
|
@ -268,7 +270,7 @@ buffer_seek_alphanumeric_left(Buffer_Type *buffer, int pos){
|
|||
--pos;
|
||||
if (pos >= 0){
|
||||
size = buffer_size(buffer);
|
||||
loop = buffer_backify_loop(buffer, pos, 1, size);
|
||||
loop = buffer_backify_loop(buffer, pos, 1);
|
||||
|
||||
for (;buffer_backify_good(&loop);
|
||||
buffer_backify_next(&loop)){
|
||||
|
@ -308,7 +310,7 @@ buffer_seek_alphanumeric_or_camel_right(Buffer_Type *buffer, int pos, int an_pos
|
|||
|
||||
++pos;
|
||||
if (pos < an_pos){
|
||||
loop = buffer_stringify_loop(buffer, pos, an_pos, size);
|
||||
loop = buffer_stringify_loop(buffer, pos, an_pos);
|
||||
if (buffer_stringify_good(&loop)){
|
||||
prev_ch = loop.data[0];
|
||||
++pos;
|
||||
|
@ -344,7 +346,7 @@ buffer_seek_alphanumeric_or_camel_left(Buffer_Type *buffer, int pos, int an_pos)
|
|||
assert_4tech(an_pos <= pos);
|
||||
assert_4tech(0 <= an_pos);
|
||||
|
||||
loop = buffer_backify_loop(buffer, pos, an_pos+1, size);
|
||||
loop = buffer_backify_loop(buffer, pos, an_pos+1);
|
||||
if (buffer_backify_good(&loop)){
|
||||
prev_ch = loop.data[0];
|
||||
--pos;
|
||||
|
@ -382,7 +384,7 @@ buffer_find_hard_start(Buffer_Type *buffer, int line_start, int *all_whitespace,
|
|||
tab_width -= 1;
|
||||
|
||||
result = line_start;
|
||||
for (loop = buffer_stringify_loop(buffer, line_start, size, size);
|
||||
for (loop = buffer_stringify_loop(buffer, line_start, size);
|
||||
buffer_stringify_good(&loop);
|
||||
buffer_stringify_next(&loop)){
|
||||
end = loop.size + loop.absolute_pos;
|
||||
|
@ -416,7 +418,7 @@ buffer_find_string(Buffer_Type *buffer, int start_pos, char *str, int len, char
|
|||
|
||||
pos = start_pos;
|
||||
if (len > 0){
|
||||
for (loop = buffer_stringify_loop(buffer, start_pos, size - len + 1, size);
|
||||
for (loop = buffer_stringify_loop(buffer, start_pos, size - len + 1);
|
||||
buffer_stringify_good(&loop);
|
||||
buffer_stringify_next(&loop)){
|
||||
end = loop.size + loop.absolute_pos;
|
||||
|
@ -449,7 +451,7 @@ buffer_rfind_string(Buffer_Type *buffer, int start_pos, char *str, int len, char
|
|||
if (pos > size - len) pos = size - len;
|
||||
|
||||
if (len > 0){
|
||||
for (loop = buffer_backify_loop(buffer, start_pos, 0, size);
|
||||
for (loop = buffer_backify_loop(buffer, start_pos, 0);
|
||||
buffer_backify_good(&loop);
|
||||
buffer_backify_next(&loop)){
|
||||
end = loop.absolute_pos;
|
||||
|
@ -467,7 +469,9 @@ buffer_rfind_string(Buffer_Type *buffer, int start_pos, char *str, int len, char
|
|||
buffer_rfind_string_end:
|
||||
return(pos);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
typedef struct{
|
||||
int i;
|
||||
int count;
|
||||
|
@ -494,7 +498,7 @@ buffer_measure_starts(Buffer_Measure_Starts *state, Buffer_Type *buffer){
|
|||
count = state->count;
|
||||
start = state->start;
|
||||
|
||||
for (loop = buffer_stringify_loop(buffer, i, size, size);
|
||||
for (loop = buffer_stringify_loop(buffer, i, size);
|
||||
buffer_stringify_good(&loop);
|
||||
buffer_stringify_next(&loop)){
|
||||
end = loop.size + loop.absolute_pos;
|
||||
|
@ -563,7 +567,7 @@ buffer_remeasure_starts(Buffer_Type *buffer, int line_start, int line_end, int l
|
|||
line_i = line_start;
|
||||
start = char_i;
|
||||
|
||||
for (loop = buffer_stringify_loop(buffer, char_i, size, size);
|
||||
for (loop = buffer_stringify_loop(buffer, char_i, size);
|
||||
buffer_stringify_good(&loop);
|
||||
buffer_stringify_next(&loop)){
|
||||
end = loop.size + loop.absolute_pos;
|
||||
|
@ -623,7 +627,7 @@ buffer_remeasure_widths(Buffer_Type *buffer, void *advance_data, int stride,
|
|||
|
||||
width = 0;
|
||||
|
||||
for (loop = buffer_stringify_loop(buffer, j, size, size);
|
||||
for (loop = buffer_stringify_loop(buffer, j, size);
|
||||
buffer_stringify_good(&loop);
|
||||
buffer_stringify_next(&loop)){
|
||||
end = loop.size + loop.absolute_pos;
|
||||
|
@ -703,6 +707,7 @@ buffer_get_line_index(Buffer_Type *buffer, int pos){
|
|||
result = buffer_get_line_index_range(buffer, pos, 0, buffer->line_count);
|
||||
return(result);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NON_ABSTRACT_4TECH
|
||||
internal_4tech int
|
||||
|
@ -841,6 +846,7 @@ cursor_seek_step_end:
|
|||
|
||||
#endif
|
||||
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
internal_4tech Full_Cursor
|
||||
buffer_cursor_seek(Buffer_Type *buffer, Buffer_Seek seek, float max_width, float font_height,
|
||||
void *advance_data, int stride, Full_Cursor cursor){
|
||||
|
@ -861,7 +867,7 @@ buffer_cursor_seek(Buffer_Type *buffer, Buffer_Seek seek, float max_width, float
|
|||
|
||||
result = 1;
|
||||
i = cursor.pos;
|
||||
for (loop = buffer_stringify_loop(buffer, i, size, size);
|
||||
for (loop = buffer_stringify_loop(buffer, i, size);
|
||||
buffer_stringify_good(&loop);
|
||||
buffer_stringify_next(&loop)){
|
||||
end = loop.size + loop.absolute_pos;
|
||||
|
@ -924,7 +930,9 @@ buffer_cursor_from_wrapped_xy(Buffer_Type *buffer, float x, float y, int round_d
|
|||
|
||||
return(result);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
internal_4tech void
|
||||
buffer_invert_edit_shift(Buffer_Type *buffer, Buffer_Edit edit, Buffer_Edit *inverse, char *strings,
|
||||
int *str_pos, int max, int shift_amount){
|
||||
|
@ -986,7 +994,9 @@ buffer_invert_batch(Buffer_Invert_Batch *state, Buffer_Type *buffer, Buffer_Edit
|
|||
|
||||
return(result);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 1
|
||||
internal_4tech void
|
||||
buffer_batch_edit(Buffer_Type *buffer, Buffer_Edit *sorted_edits, char *strings, int edit_count){
|
||||
Buffer_Batch_State state;
|
||||
|
@ -999,7 +1009,9 @@ buffer_batch_edit(Buffer_Type *buffer, Buffer_Edit *sorted_edits, char *strings,
|
|||
buffer_batch_edit_step(&state, buffer, sorted_edits, strings, edit_count);
|
||||
assert_4tech(result == 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 2
|
||||
internal_4tech void
|
||||
buffer_get_render_data(Buffer_Type *buffer, float *wraps, Buffer_Render_Item *items, int max, int *count,
|
||||
float port_x, float port_y, float scroll_x, float scroll_y, int wrapped,
|
||||
|
@ -1035,7 +1047,7 @@ buffer_get_render_data(Buffer_Type *buffer, float *wraps, Buffer_Render_Item *it
|
|||
item_i = 0;
|
||||
item = items + item_i;
|
||||
|
||||
for (loop = buffer_stringify_loop(buffer, start_cursor.pos, size, size);
|
||||
for (loop = buffer_stringify_loop(buffer, start_cursor.pos, size);
|
||||
buffer_stringify_good(&loop);
|
||||
buffer_stringify_next(&loop)){
|
||||
|
||||
|
|
|
@ -109,29 +109,6 @@ buffer_end_init(Gap_Buffer_Init *init){
|
|||
return(result);
|
||||
}
|
||||
|
||||
#if 0
|
||||
internal_4tech void
|
||||
buffer_initialize(Gap_Buffer *buffer, char *data, int size){
|
||||
int osize1, size1, size2;
|
||||
|
||||
assert_4tech(buffer->max >= size);
|
||||
size2 = size >> 1;
|
||||
size1 = osize1 = size - size2;
|
||||
|
||||
if (size1 > 0){
|
||||
size1 = eol_convert_in(buffer->data, data, size1);
|
||||
if (size2 > 0){
|
||||
size2 = eol_convert_in(buffer->data + size1, data + osize1, size2);
|
||||
}
|
||||
}
|
||||
|
||||
buffer->size1 = size1;
|
||||
buffer->size2 = size2;
|
||||
buffer->gap_size = buffer->max - size1 - size2;
|
||||
memmove_4tech(buffer->data + size1 + buffer->gap_size, buffer->data + size1, size2);
|
||||
}
|
||||
#endif
|
||||
|
||||
internal_4tech void*
|
||||
buffer_relocate(Gap_Buffer *buffer, char *new_data, int new_max){
|
||||
void *result;
|
||||
|
@ -157,17 +134,15 @@ typedef struct{
|
|||
int absolute_pos;
|
||||
int pos, end;
|
||||
int size;
|
||||
int page_size;
|
||||
int separated;
|
||||
} Gap_Buffer_Stringify_Loop;
|
||||
|
||||
inline_4tech Gap_Buffer_Stringify_Loop
|
||||
buffer_stringify_loop(Gap_Buffer *buffer, int start, int end, int page_size){
|
||||
internal_4tech Gap_Buffer_Stringify_Loop
|
||||
buffer_stringify_loop(Gap_Buffer *buffer, int start, int end){
|
||||
Gap_Buffer_Stringify_Loop result;
|
||||
if (0 <= start && start < end && end <= buffer->size1 + buffer->size2){
|
||||
result.buffer = buffer;
|
||||
result.base = buffer->data;
|
||||
result.page_size = page_size;
|
||||
result.absolute_pos = start;
|
||||
|
||||
if (end <= buffer->size1) result.end = end;
|
||||
|
@ -184,7 +159,6 @@ buffer_stringify_loop(Gap_Buffer *buffer, int start, int end, int page_size){
|
|||
}
|
||||
if (result.separated) result.size = buffer->size1 - start;
|
||||
else result.size = end - start;
|
||||
if (result.size > page_size) result.size = page_size;
|
||||
result.data = buffer->data + result.pos;
|
||||
}
|
||||
else result.buffer = 0;
|
||||
|
@ -198,36 +172,21 @@ buffer_stringify_good(Gap_Buffer_Stringify_Loop *loop){
|
|||
return(result);
|
||||
}
|
||||
|
||||
inline_4tech void
|
||||
internal_4tech void
|
||||
buffer_stringify_next(Gap_Buffer_Stringify_Loop *loop){
|
||||
int size1, temp_end;
|
||||
if (loop->separated){
|
||||
loop->separated = 0;
|
||||
size1 = loop->buffer->size1;
|
||||
if (loop->pos + loop->size == size1){
|
||||
loop->separated = 0;
|
||||
loop->pos = loop->buffer->gap_size + size1;
|
||||
loop->absolute_pos = size1;
|
||||
temp_end = loop->end;
|
||||
}
|
||||
else{
|
||||
loop->pos += loop->page_size;
|
||||
loop->absolute_pos += loop->page_size;
|
||||
temp_end = size1;
|
||||
}
|
||||
loop->pos = loop->buffer->gap_size + size1;
|
||||
loop->absolute_pos = size1;
|
||||
temp_end = loop->end;
|
||||
}
|
||||
else{
|
||||
if (loop->pos + loop->size == loop->end){
|
||||
loop->buffer = 0;
|
||||
temp_end = loop->pos;
|
||||
}
|
||||
else{
|
||||
loop->pos += loop->page_size;
|
||||
loop->absolute_pos += loop->page_size;
|
||||
temp_end = loop->end;
|
||||
}
|
||||
loop->buffer = 0;
|
||||
temp_end = loop->pos;
|
||||
}
|
||||
loop->size = temp_end - loop->pos;
|
||||
if (loop->size > loop->page_size) loop->size = loop->page_size;
|
||||
loop->data = loop->base + loop->pos;
|
||||
}
|
||||
|
||||
|
@ -237,41 +196,31 @@ typedef struct{
|
|||
int pos, end;
|
||||
int size;
|
||||
int absolute_pos;
|
||||
int page_size;
|
||||
int separated;
|
||||
} Gap_Buffer_Backify_Loop;
|
||||
|
||||
inline_4tech Gap_Buffer_Backify_Loop
|
||||
buffer_backify_loop(Gap_Buffer *buffer, int start, int end, int page_size){
|
||||
internal_4tech Gap_Buffer_Backify_Loop
|
||||
buffer_backify_loop(Gap_Buffer *buffer, int start, int end){
|
||||
Gap_Buffer_Backify_Loop result;
|
||||
int chunk2_start;
|
||||
|
||||
++start;
|
||||
if (0 <= end && end < start && start <= buffer->size1 + buffer->size2){
|
||||
chunk2_start = buffer->size1 + buffer->gap_size;
|
||||
|
||||
result.buffer = buffer;
|
||||
result.base = buffer->data;
|
||||
result.page_size = page_size;
|
||||
|
||||
if (end < buffer->size1) result.end = end;
|
||||
else result.end = end + buffer->gap_size;
|
||||
|
||||
if (start <= buffer->size1){
|
||||
result.separated = 0;
|
||||
result.pos = start - page_size;
|
||||
result.pos = 0;
|
||||
}
|
||||
else{
|
||||
if (end < buffer->size1) result.separated = 1;
|
||||
else result.separated = 0;
|
||||
result.pos = start - page_size + buffer->gap_size;
|
||||
}
|
||||
if (result.separated){
|
||||
if (result.pos < chunk2_start) result.pos = chunk2_start;
|
||||
}
|
||||
else{
|
||||
if (result.pos < result.end) result.pos = result.end;
|
||||
result.pos = buffer->size1 + buffer->gap_size;
|
||||
}
|
||||
if (!result.separated && result.pos < result.end) result.pos = result.end;
|
||||
result.size = start - result.pos;
|
||||
result.absolute_pos = result.pos;
|
||||
if (result.absolute_pos > buffer->size1) result.absolute_pos -= buffer->gap_size;
|
||||
|
@ -288,7 +237,7 @@ buffer_backify_good(Gap_Buffer_Backify_Loop *loop){
|
|||
return(result);
|
||||
}
|
||||
|
||||
inline_4tech void
|
||||
internal_4tech void
|
||||
buffer_backify_next(Gap_Buffer_Backify_Loop *loop){
|
||||
Gap_Buffer *buffer;
|
||||
int temp_end;
|
||||
|
@ -296,40 +245,18 @@ buffer_backify_next(Gap_Buffer_Backify_Loop *loop){
|
|||
buffer = loop->buffer;
|
||||
chunk2_start = buffer->size1 + buffer->gap_size;
|
||||
if (loop->separated){
|
||||
if (loop->pos == chunk2_start){
|
||||
loop->separated = 0;
|
||||
temp_end = buffer->size1;
|
||||
loop->pos = temp_end - loop->page_size;
|
||||
loop->absolute_pos = loop->pos;
|
||||
if (loop->pos < loop->end){
|
||||
loop->absolute_pos += (loop->end - loop->pos);
|
||||
loop->pos = loop->end;
|
||||
}
|
||||
}
|
||||
else{
|
||||
temp_end = loop->pos;
|
||||
loop->pos -= loop->page_size;
|
||||
loop->absolute_pos -= loop->page_size;
|
||||
if (loop->pos < chunk2_start){
|
||||
loop->pos = chunk2_start;
|
||||
loop->absolute_pos = buffer->size1;
|
||||
}
|
||||
loop->separated = 0;
|
||||
temp_end = buffer->size1;
|
||||
loop->pos = 0;
|
||||
loop->absolute_pos = 0;
|
||||
if (loop->pos < loop->end){
|
||||
loop->absolute_pos = loop->end;
|
||||
loop->pos = loop->end;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (loop->pos == loop->end){
|
||||
temp_end = 0;
|
||||
loop->buffer = 0;
|
||||
}
|
||||
else{
|
||||
temp_end = loop->pos;
|
||||
loop->pos -= loop->page_size;
|
||||
loop->absolute_pos -= loop->page_size;
|
||||
if (loop->pos < loop->end){
|
||||
loop->absolute_pos += (loop->end - loop->pos);
|
||||
loop->pos = loop->end;
|
||||
}
|
||||
}
|
||||
temp_end = 0;
|
||||
loop->buffer = 0;
|
||||
}
|
||||
loop->size = temp_end - loop->pos;
|
||||
loop->data = loop->base + loop->pos;
|
||||
|
|
|
@ -91,15 +91,6 @@ buffer_end_init(Buffer_Init *init){
|
|||
return(result);
|
||||
}
|
||||
|
||||
#if 0
|
||||
internal_4tech void
|
||||
buffer_initialize(Buffer *buffer, char *data, int size){
|
||||
assert_4tech(buffer->data);
|
||||
assert_4tech(size <= buffer->max);
|
||||
buffer->size = eol_convert_in(buffer->data, data, size);
|
||||
}
|
||||
#endif
|
||||
|
||||
internal_4tech void*
|
||||
buffer_relocate(Buffer *buffer, char *new_data, int new_max){
|
||||
void *result;
|
||||
|
@ -119,11 +110,10 @@ typedef struct{
|
|||
char *data, *end;
|
||||
int absolute_pos;
|
||||
int size;
|
||||
int page_size;
|
||||
} Buffer_Stringify_Loop;
|
||||
|
||||
inline_4tech Buffer_Stringify_Loop
|
||||
buffer_stringify_loop(Buffer *buffer, int start, int end, int page_size){
|
||||
buffer_stringify_loop(Buffer *buffer, int start, int end){
|
||||
Buffer_Stringify_Loop result;
|
||||
if (0 <= start && start < end && end <= buffer->size){
|
||||
result.buffer = buffer;
|
||||
|
@ -131,8 +121,6 @@ buffer_stringify_loop(Buffer *buffer, int start, int end, int page_size){
|
|||
result.data = buffer->data + start;
|
||||
result.size = end - start;
|
||||
result.end = buffer->data + end;
|
||||
result.page_size = page_size;
|
||||
if (result.size > page_size) result.size = page_size;
|
||||
}
|
||||
else result.buffer = 0;
|
||||
return(result);
|
||||
|
@ -147,13 +135,7 @@ buffer_stringify_good(Buffer_Stringify_Loop *loop){
|
|||
|
||||
inline_4tech void
|
||||
buffer_stringify_next(Buffer_Stringify_Loop *loop){
|
||||
if (loop->data + loop->size == loop->end) loop->buffer = 0;
|
||||
else{
|
||||
loop->data += loop->page_size;
|
||||
loop->absolute_pos += loop->page_size;
|
||||
loop->size = (int)(loop->end - loop->data);
|
||||
if (loop->size > loop->page_size) loop->size = loop->page_size;
|
||||
}
|
||||
loop->buffer = 0;
|
||||
}
|
||||
|
||||
typedef struct{
|
||||
|
@ -161,20 +143,17 @@ typedef struct{
|
|||
char *data, *end;
|
||||
int absolute_pos;
|
||||
int size;
|
||||
int page_size;
|
||||
} Buffer_Backify_Loop;
|
||||
|
||||
inline_4tech Buffer_Backify_Loop
|
||||
buffer_backify_loop(Buffer *buffer, int start, int end, int page_size){
|
||||
buffer_backify_loop(Buffer *buffer, int start, int end){
|
||||
Buffer_Backify_Loop result;
|
||||
|
||||
++start;
|
||||
if (0 <= end && end < start && start <= buffer->size){
|
||||
result.buffer = buffer;
|
||||
result.end = buffer->data + end;
|
||||
result.page_size = page_size;
|
||||
result.size = start - end;
|
||||
if (result.size > page_size) result.size = page_size;
|
||||
result.absolute_pos = start - result.size;
|
||||
result.data = buffer->data + result.absolute_pos;
|
||||
}
|
||||
|
@ -191,18 +170,7 @@ buffer_backify_good(Buffer_Backify_Loop *loop){
|
|||
|
||||
inline_4tech void
|
||||
buffer_backify_next(Buffer_Backify_Loop *loop){
|
||||
char *old_data;
|
||||
if (loop->data == loop->end) loop->buffer = 0;
|
||||
else{
|
||||
old_data = loop->data;
|
||||
loop->data -= loop->page_size;
|
||||
loop->absolute_pos -= loop->page_size;
|
||||
if (loop->data < loop->end){
|
||||
loop->size = (int)(old_data - loop->end);
|
||||
loop->data = loop->end;
|
||||
loop->absolute_pos = 0;
|
||||
}
|
||||
}
|
||||
loop->buffer = 0;
|
||||
}
|
||||
|
||||
internal_4tech int
|
||||
|
|
|
@ -30,6 +30,12 @@ typedef struct{
|
|||
int chunk_count;
|
||||
int chunk_max;
|
||||
int size;
|
||||
|
||||
float *line_widths;
|
||||
int *line_starts;
|
||||
int line_count;
|
||||
int line_max;
|
||||
int widths_max;
|
||||
} Multi_Gap_Buffer;
|
||||
|
||||
inline_4tech int
|
||||
|
@ -160,6 +166,201 @@ buffer_end_init(Multi_Gap_Buffer_Init *init){
|
|||
return(result);
|
||||
}
|
||||
|
||||
internal_4tech int
|
||||
buffer_find_chunk(Multi_Gap_Buffer *buffer, int pos){
|
||||
Fixed_Width_Gap_Buffer *gaps;
|
||||
int start, end, m, this_pos;
|
||||
|
||||
gaps = buffer->gaps;
|
||||
start = 0;
|
||||
end = buffer->chunk_count;
|
||||
for(;;){
|
||||
m = (start + end) / 2;
|
||||
this_pos = gaps[m].start_pos;
|
||||
if (this_pos < pos) start = m;
|
||||
else if (this_pos > pos) end = m;
|
||||
else break;
|
||||
if (start+1 == end){
|
||||
m = start; break;
|
||||
}
|
||||
assert_4tech(start < end);
|
||||
}
|
||||
return(m);
|
||||
}
|
||||
|
||||
typedef struct{
|
||||
Multi_Gap_Buffer *buffer;
|
||||
Fixed_Width_Gap_Buffer *gaps;
|
||||
char *data;
|
||||
int absolute_pos;
|
||||
int size;
|
||||
int chunk_i;
|
||||
int chunk_end;
|
||||
int pos, end;
|
||||
} Multi_Gap_Buffer_Stringify_Loop;
|
||||
|
||||
internal_4tech Multi_Gap_Buffer_Stringify_Loop
|
||||
buffer_stringify_loop(Multi_Gap_Buffer *buffer, int start, int end){
|
||||
Multi_Gap_Buffer_Stringify_Loop result;
|
||||
Fixed_Width_Gap_Buffer *gap;
|
||||
int temp_end;
|
||||
|
||||
if (0 <= start && start < end && end <= buffer->size){
|
||||
result.buffer = buffer;
|
||||
result.gaps = buffer->gaps;
|
||||
result.absolute_pos = start;
|
||||
|
||||
result.chunk_i = buffer_find_chunk(buffer, start);
|
||||
result.chunk_end = buffer_find_chunk(buffer, end-1);
|
||||
|
||||
gap = result.gaps + result.chunk_end;
|
||||
end -= gap->start_pos;
|
||||
if (end < gap->size1) result.end = end;
|
||||
else result.end = end + gap->gap_size;
|
||||
|
||||
gap = result.gaps + result.chunk_i;
|
||||
start -= gap->start_pos;
|
||||
if (start < gap->size1){
|
||||
result.pos = start;
|
||||
temp_end = gap->size1;
|
||||
}
|
||||
else{
|
||||
result.pos = start + gap->gap_size;
|
||||
temp_end = fixed_width_buffer_size;
|
||||
}
|
||||
|
||||
if (result.chunk_i == result.chunk_end && temp_end > result.end) temp_end = result.end;
|
||||
result.size = temp_end - result.pos;
|
||||
result.data = gap->data + result.pos;
|
||||
}
|
||||
else result.buffer = 0;
|
||||
return(result);
|
||||
}
|
||||
|
||||
inline_4tech int
|
||||
buffer_stringify_good(Multi_Gap_Buffer_Stringify_Loop *loop){
|
||||
int result;
|
||||
result = (loop->buffer != 0);
|
||||
return(result);
|
||||
}
|
||||
|
||||
internal_4tech void
|
||||
buffer_stringify_next(Multi_Gap_Buffer_Stringify_Loop *loop){
|
||||
Fixed_Width_Gap_Buffer *gap;
|
||||
int temp_end;
|
||||
|
||||
gap = loop->gaps + loop->chunk_i;
|
||||
if (loop->chunk_i == loop->chunk_end && loop->pos + loop->size == loop->end){
|
||||
loop->buffer = 0;
|
||||
}
|
||||
else{
|
||||
if (loop->pos < gap->size1){
|
||||
loop->pos = gap->size1 + gap->gap_size;
|
||||
loop->absolute_pos = gap->start_pos + gap->size1;
|
||||
temp_end = fixed_width_buffer_size;
|
||||
}
|
||||
else{
|
||||
++loop->chunk_i;
|
||||
++gap;
|
||||
loop->pos = 0;
|
||||
loop->absolute_pos = gap->start_pos;
|
||||
temp_end = gap->size1;
|
||||
}
|
||||
if (loop->chunk_i == loop->chunk_end && temp_end > loop->end) temp_end = loop->end;
|
||||
loop->size = temp_end - loop->pos;
|
||||
loop->data = gap->data + loop->pos;
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct{
|
||||
Multi_Gap_Buffer *buffer;
|
||||
Fixed_Width_Gap_Buffer *gaps;
|
||||
char *data;
|
||||
int absolute_pos;
|
||||
int size;
|
||||
int chunk_i;
|
||||
int chunk_end;
|
||||
int pos, end;
|
||||
} Multi_Gap_Buffer_Backify_Loop;
|
||||
|
||||
internal_4tech Multi_Gap_Buffer_Backify_Loop
|
||||
buffer_backify_loop(Multi_Gap_Buffer *buffer, int start, int end){
|
||||
Multi_Gap_Buffer_Backify_Loop result;
|
||||
Fixed_Width_Gap_Buffer *gap;
|
||||
int temp_end, temp_start;
|
||||
|
||||
++start;
|
||||
if (0 <= end && end < start && start <= buffer->size){
|
||||
result.buffer = buffer;
|
||||
result.gaps = buffer->gaps;
|
||||
|
||||
result.chunk_i = buffer_find_chunk(buffer, start);
|
||||
result.chunk_end = buffer_find_chunk(buffer, end);
|
||||
|
||||
gap = result.gaps + result.chunk_end;
|
||||
end -= gap->start_pos;
|
||||
if (end < gap->size1) result.end = end;
|
||||
else result.end = end + gap->gap_size;
|
||||
|
||||
gap = result.gaps + result.chunk_i;
|
||||
start -= gap->start_pos;
|
||||
if (start < gap->size1){
|
||||
temp_end = start;
|
||||
temp_start = 0;
|
||||
}
|
||||
else{
|
||||
temp_end = start + gap->gap_size;
|
||||
temp_start = gap->size1 + gap->gap_size;
|
||||
}
|
||||
|
||||
if (result.chunk_i == result.chunk_end && temp_start < result.end) temp_start = result.end;
|
||||
result.pos = temp_start;
|
||||
result.absolute_pos = temp_start + gap->start_pos;
|
||||
if (temp_start >= gap->size1) result.absolute_pos -= gap->gap_size;
|
||||
result.size = temp_end - temp_start;
|
||||
result.data = gap->data + result.pos;
|
||||
}
|
||||
else result.buffer = 0;
|
||||
return(result);
|
||||
}
|
||||
|
||||
inline_4tech int
|
||||
buffer_backify_good(Multi_Gap_Buffer_Backify_Loop *loop){
|
||||
int result;
|
||||
result = (loop->buffer != 0);
|
||||
return(result);
|
||||
}
|
||||
|
||||
internal_4tech void
|
||||
buffer_backify_next(Multi_Gap_Buffer_Backify_Loop *loop){
|
||||
Fixed_Width_Gap_Buffer *gap;
|
||||
int temp_end, temp_start;
|
||||
|
||||
gap = loop->gaps + loop->chunk_i;
|
||||
if (loop->chunk_i == loop->chunk_end && loop->pos == loop->end){
|
||||
loop->buffer = 0;
|
||||
}
|
||||
else{
|
||||
if (loop->pos < gap->size1){
|
||||
--gap;
|
||||
--loop->chunk_i;
|
||||
temp_start = gap->size1 + gap->gap_size;
|
||||
temp_end = fixed_width_buffer_size;
|
||||
}
|
||||
else{
|
||||
temp_start = 0;
|
||||
temp_end = gap->size1;
|
||||
}
|
||||
if (loop->chunk_i == loop->chunk_end && temp_start < loop->end) temp_start = loop->end;
|
||||
loop->absolute_pos = temp_start + gap->start_pos;
|
||||
if (temp_start >= gap->size1) loop->absolute_pos -= gap->gap_size;
|
||||
loop->pos = temp_start;
|
||||
loop->size = temp_end - temp_start;
|
||||
loop->data = gap->data + loop->pos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// BOTTOM
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue