~samhsmith/edt

159821de244c1f71a3278d83c1ba8cde83fa3295 — Sam H Smith 2 years ago 316224b dev
changes I can't remember plus green
1 files changed, 108 insertions(+), 5 deletions(-)

M src/main.c
M src/main.c => src/main.c +108 -5
@@ 11,7 11,7 @@
#include <unistd.h>

#define JUMP_SIZE 20
#define CAMERA_SPEED 0.16
#define CAMERA_SPEED 0.19

u8* character_buffer;
u64 character_buffer_len;


@@ 118,6 118,100 @@ void insert_text(u8* o_text)
    }
}

void remove_behind()
{
    if(current_column == line_len_array[current_line])
    {
        line_len_array[current_line]--;
        current_column--;
        return;
    }
/*
    u64 o_text_len = strlen(o_text);
    u8 increment_column = 1;
 
    u64 total_len = o_text_len + line_len_array[current_line];
    u8 total_string[total_len];
    {
        u64 column = current_column;
        if(column > line_len_array[current_line])
        {
            increment_column = 0;
            column = line_len_array[current_line];
            if(character_buffer[line_index_array[current_line] + line_len_array[current_line] - 1] == '\n')
            { column--; }
        }
        u64 total_index = 0;
        for(u64 i = 0; i < column; i++)
        {
            total_string[total_index] = character_buffer[line_index_array[current_line] + i];
            total_index++;
        }
        for(u64 i = 0; i < o_text_len; i++)
        {
            total_string[total_index] = o_text[i];
            total_index++;
        }
        for(u64 i = column; i < line_len_array[current_line]; i++)
        {
            total_string[total_index] = character_buffer[line_index_array[current_line] + i];
            total_index++;
        }
    }
    if(increment_column) {current_column += o_text_len; }

    u64 o_index = 0;
    while(1)
    {
        if(o_index > 0 && (o_index < total_len || current_line + 1 == line_count)
             && total_string[o_index - 1] == '\n')
        {
            u64 t_index = 0;
            u64 t_len = 0;
            for(u64 i = current_line + 1; i < line_count; i++)
            {
                u64 temp_index = line_index_array[i];
                u64 temp_len = line_len_array[i];
                line_index_array[i] = t_index;
                line_len_array[i] = t_len;
                t_index = temp_index;
                t_len = temp_len;
            }
            line_count++;
            line_index_array = realloc(line_index_array, sizeof(u64) * line_count);
            line_len_array = realloc(line_len_array, sizeof(u64) * line_count);
 
            line_index_array[line_count-1] = t_index;
            line_len_array[line_count-1] = t_len;
            current_line++;
            current_column = 0;
        }
        if(o_index >= total_len) { break; }
        u8* text = total_string + o_index;
        u64 text_len = 0;
        u64 text_index = 0;
        for(u64 i = o_index; i < total_len; i++)
        {
            text_len++;
            o_index++;
            if(text[text_index] == '\n') { break; }
            text_index++;
        }
        {
            u64 new_index = more_chars(text_len);
            u64 offset = 0;
            for(u64 i = 0; i < text_len; i++)
            {
                character_buffer[new_index + offset] = text[i];
                offset++;
            }
            line_index_array[current_line] = new_index;
            line_len_array[current_line] = text_len;
        }
    }
*/
}

void re_line_heap(FC_Font* font, u64 screen_width)
{
    u8* new_char_buf = malloc(character_buffer_len);


@@ 305,6 399,15 @@ void main(s32 argc, u8** argv)
                            { current_column++; }
                        }
                    }
                    else if(event->keysym.scancode == SDL_SCANCODE_A && !is_inserting)
                    {
                        current_column = 0;
                    }
                    else if(event->keysym.scancode == SDL_SCANCODE_S && !is_inserting)
                    {
                        current_column = line_len_array[current_line];
                        if(current_column) { current_column--; }
                    }
                }
                else if(ev.type == SDL_KEYUP)
                {


@@ 357,7 460,7 @@ re_line_heap(font, viewport.w);
            }
            s64 real_camera_y = camera_y - viewport.h/2;

            SDL_SetRenderDrawColor(renderer, 0x12, 0x17, 0x29, 255);
            SDL_SetRenderDrawColor(renderer, 0x02, 0x0b, 0x02, 255);
            SDL_RenderClear(renderer);

            {


@@ 371,7 474,7 @@ re_line_heap(font, viewport.w);
                    rects[i].y = i*font_size*2 + line_offset;
                    rects[i].h = font_size;
                }
                SDL_SetRenderDrawColor(renderer, 0x14, 0x1e, 0x3f, 255);
                SDL_SetRenderDrawColor(renderer, 0x01, 0x0e, 0x01, 255);
                SDL_RenderFillRects(renderer, rects, total_lines);
            }
            {


@@ 384,7 487,7 @@ re_line_heap(font, viewport.w);
                rects[1].w = viewport.w;
                rects[1].h = viewport.h;
                rects[1].y = font_size*line_count - real_camera_y;
                SDL_SetRenderDrawColor(renderer, 0x10, 0x10, 0x14, 255);
                SDL_SetRenderDrawColor(renderer, 0x01, 0x04, 0x02, 255);
                SDL_RenderFillRects(renderer, rects, 2);
            }



@@ 405,7 508,7 @@ re_line_heap(font, viewport.w);
                rect.w = viewport.w;
                rect.h = font_size;
                rect.y = viewport.h / 2;
                SDL_SetRenderDrawColor(renderer, 0x1e, 0x3a, 0x95, 255);
                SDL_SetRenderDrawColor(renderer, 0x3d, 0x4b, 0x2f, 255);
                SDL_RenderFillRect(renderer, &rect);
            }