From 2053d0df471fd8b893ccc3d1b471656ac98cb4cb Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Wed, 5 Oct 2016 21:38:08 -0400 Subject: [PATCH] minor cleanup of the code presentation stuff --- 4coder_default_include.cpp | 26 ++++++++++++++++++++++++-- 4ed_file_view.cpp | 7 ++++--- TODO.txt | 3 ++- buffer/4coder_buffer_abstract.cpp | 4 +++- 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/4coder_default_include.cpp b/4coder_default_include.cpp index 79147505..e21fe9cf 100644 --- a/4coder_default_include.cpp +++ b/4coder_default_include.cpp @@ -1493,7 +1493,7 @@ CUSTOM_COMMAND_SIG(seek_whitespace_down){ true); } -CUSTOM_COMMAND_SIG(seek_end_of_line){ +CUSTOM_COMMAND_SIG(seek_end_of_textual_line){ uint32_t access = AccessProtected; View_Summary view = get_active_view(app, access); Buffer_Summary buffer = get_buffer(app, view.buffer_id, access); @@ -1502,7 +1502,7 @@ CUSTOM_COMMAND_SIG(seek_end_of_line){ view_set_cursor(app, &view, seek_pos(new_pos), true); } -CUSTOM_COMMAND_SIG(seek_beginning_of_line){ +CUSTOM_COMMAND_SIG(seek_beginning_of_textual_line){ uint32_t access = AccessProtected; View_Summary view = get_active_view(app, access); Buffer_Summary buffer = get_buffer(app, view.buffer_id, access); @@ -1511,6 +1511,28 @@ CUSTOM_COMMAND_SIG(seek_beginning_of_line){ view_set_cursor(app, &view, seek_pos(new_pos), true); } +CUSTOM_COMMAND_SIG(seek_beginning_of_line){ + View_Summary view = get_active_view(app, AccessProtected); + + float y = view.cursor.wrapped_y; + if (view.unwrapped_lines){ + y = view.cursor.unwrapped_y; + } + + view_set_cursor(app, &view, seek_xy(0, y, 1, view.unwrapped_lines), 1); +} + +CUSTOM_COMMAND_SIG(seek_end_of_line){ + View_Summary view = get_active_view(app, AccessProtected); + + float y = view.cursor.wrapped_y; + if (view.unwrapped_lines){ + y = view.cursor.unwrapped_y; + } + + view_set_cursor(app, &view, seek_xy(100000.f, y, 1, view.unwrapped_lines), 1); +} + // TODO(allen): REDUCE DUPLICATION! static int32_t buffer_seek_whitespace_right(Application_Links *app, Buffer_Summary *buffer, int32_t pos){ diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp index 971de649..94d300dd 100644 --- a/4ed_file_view.cpp +++ b/4ed_file_view.cpp @@ -1138,6 +1138,7 @@ wrap_state_consume_token(Code_Wrap_State *state, i32 fixed_end_point){ }break; case CPP_TOKEN_PARENTHESE_OPEN: + case CPP_TOKEN_BRACKET_OPEN: { ++state->paren_top; @@ -1151,6 +1152,7 @@ wrap_state_consume_token(Code_Wrap_State *state, i32 fixed_end_point){ }break; case CPP_TOKEN_PARENTHESE_CLOSE: + case CPP_TOKEN_BRACKET_CLOSE: { --state->paren_top; @@ -1221,7 +1223,7 @@ file_measure_wraps(Models *models, Editing_File *file, f32 font_height, f32 *adv switch (stop.status){ case BLStatus_NeedWrapDetermination: { - if (use_tokens){ + if (use_tokens && 0){ Code_Wrap_Step step = wrap_state_consume_token(&wrap_state, -1); wrap_unit_end = step.position_end; @@ -5359,10 +5361,9 @@ draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target if (token_i < token_array.count){ if (ind >= token_array.tokens[token_i].start){ - while (ind >= token_array.tokens[token_i].start){ + for (;ind >= token_array.tokens[token_i].start && token_i < token_array.count; ++token_i){ main_color = *style_get_color(style, token_array.tokens[token_i]); current_token = token_array.tokens[token_i]; - ++token_i; } } else if (ind >= current_token.start + current_token.size){ diff --git a/TODO.txt b/TODO.txt index 394eb60d..1294ca6d 100644 --- a/TODO.txt +++ b/TODO.txt @@ -162,14 +162,15 @@ ; [X] get horizontal scrolling to work in line wrap mode ; [X] word level wrapping ; [X] ability to toggle virtual white space +; [X] home/end should go to the beginning/end of the visual line not the textual line ; [] command for setting wrap positions in views directly ; [] ability to see the wrap position as a number/line and adjust graphically -; [] home/end should go to the beginning/end of the visual line not the textual line ; [] code level wrapping ; [X] handle basic scope indents ; [X] handle parentheses ; [X] handle preprocessor ; [X] unify wrap rule parsing and indent rule parsing +; [X] handle square brackets ; [] smarter wrap rule ; [] handle unclosed statements ; [] handle comments diff --git a/buffer/4coder_buffer_abstract.cpp b/buffer/4coder_buffer_abstract.cpp index 3faaeeb5..f81ebf8e 100644 --- a/buffer/4coder_buffer_abstract.cpp +++ b/buffer/4coder_buffer_abstract.cpp @@ -1043,7 +1043,9 @@ buffer_cursor_seek(Buffer_Cursor_Seek_State *S_ptr, Buffer_Cursor_Seek_Params pa goto buffer_cursor_seek_end; } - S.this_cursor = S.prev_cursor; + if (py >= y){ + S.this_cursor = S.prev_cursor; + } goto buffer_cursor_seek_end; } }