Cleaning up linex_index -> line_number naming

master
Allen Webster 2017-11-28 15:16:53 -05:00
parent aa74d71e0e
commit d4df1af8ea
8 changed files with 66 additions and 65 deletions

View File

@ -192,17 +192,16 @@ seek_matching_token_backwards(Cpp_Token_Array tokens, Cpp_Token *token, Cpp_Toke
static Cpp_Token* static Cpp_Token*
find_anchor_token(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Array tokens, int32_t line_start, int32_t tab_width, int32_t *current_indent_out){ find_anchor_token(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Array tokens, int32_t line_start, int32_t tab_width, int32_t *current_indent_out){
Cpp_Token *token = get_first_token_at_line(app, buffer, tokens, line_start); Cpp_Token *token = 0;
if (tokens.count != 0){
token = get_first_token_at_line(app, buffer, tokens, line_start);
if (token == 0 && tokens.count == 0){
// In this case just let the null token pointer be returned.
}
else{
if (token == 0){ if (token == 0){
token = tokens.tokens + (tokens.count - 1); token = tokens.tokens + (tokens.count - 1);
} }
if (token != tokens.tokens){ if (token > tokens.tokens){
--token; --token;
for (; token > tokens.tokens; --token){ for (; token > tokens.tokens; --token){
if (!(token->flags & CPP_TFLAG_PP_BODY)){ if (!(token->flags & CPP_TFLAG_PP_BODY)){
@ -219,7 +218,7 @@ find_anchor_token(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Arra
int32_t current_indent = 0; int32_t current_indent = 0;
int32_t found_safe_start_position = 0; int32_t found_safe_start_position = 0;
do{ do{
int32_t line = buffer_get_line_index(app, buffer, token->start); int32_t line = buffer_get_line_number(app, buffer, token->start);
int32_t start = buffer_get_line_start(app, buffer, line); int32_t start = buffer_get_line_start(app, buffer, line);
Hard_Start_Result hard_start = buffer_find_hard_start(app, buffer, start, tab_width); Hard_Start_Result hard_start = buffer_find_hard_start(app, buffer, start, tab_width);
@ -244,8 +243,9 @@ find_anchor_token(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Arra
case CPP_TOKEN_PARENTHESE_CLOSE: case CPP_TOKEN_PARENTHESE_CLOSE:
case CPP_TOKEN_BRACKET_CLOSE: case CPP_TOKEN_BRACKET_CLOSE:
case CPP_TOKEN_BRACE_CLOSE: case CPP_TOKEN_BRACE_CLOSE:
{
close = token->type; close = token->type;
goto out_of_loop2; }goto out_of_loop2;
} }
} }
out_of_loop2:; out_of_loop2:;
@ -253,22 +253,29 @@ find_anchor_token(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Arra
Cpp_Token_Type open_type = CPP_TOKEN_JUNK; Cpp_Token_Type open_type = CPP_TOKEN_JUNK;
Cpp_Token_Type close_type = CPP_TOKEN_JUNK; Cpp_Token_Type close_type = CPP_TOKEN_JUNK;
switch (close){ switch (close){
case 0: token = start_token; found_safe_start_position = true; break; case 0:
{
token = start_token;
found_safe_start_position = true;
}break;
case CPP_TOKEN_PARENTHESE_CLOSE: case CPP_TOKEN_PARENTHESE_CLOSE:
{
open_type = CPP_TOKEN_PARENTHESE_OPEN; open_type = CPP_TOKEN_PARENTHESE_OPEN;
close_type = CPP_TOKEN_PARENTHESE_CLOSE; close_type = CPP_TOKEN_PARENTHESE_CLOSE;
break; }break;
case CPP_TOKEN_BRACKET_CLOSE: case CPP_TOKEN_BRACKET_CLOSE:
{
open_type = CPP_TOKEN_BRACKET_OPEN; open_type = CPP_TOKEN_BRACKET_OPEN;
close_type = CPP_TOKEN_BRACKET_CLOSE; close_type = CPP_TOKEN_BRACKET_CLOSE;
break; }break;
case CPP_TOKEN_BRACE_CLOSE: case CPP_TOKEN_BRACE_CLOSE:
{
open_type = CPP_TOKEN_BRACE_OPEN; open_type = CPP_TOKEN_BRACE_OPEN;
close_type = CPP_TOKEN_BRACE_CLOSE; close_type = CPP_TOKEN_BRACE_CLOSE;
break; }break;
} }
if (open_type != CPP_TOKEN_JUNK){ if (open_type != CPP_TOKEN_JUNK){
token = seek_matching_token_backwards(tokens, token-1, open_type, close_type); token = seek_matching_token_backwards(tokens, token-1, open_type, close_type);
@ -313,22 +320,22 @@ get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *b
} }
} }
else{ else{
int32_t line_index = buffer_get_line_index(app, buffer, token_ptr->start); int32_t line_number = buffer_get_line_number(app, buffer, token_ptr->start);
if (line_index > line_start){ if (line_number > line_start){
line_index = line_start; line_number = line_start;
} }
if (token_ptr == tokens.tokens){ if (token_ptr == tokens.tokens){
indent.current_indent = 0; indent.current_indent = 0;
} }
int32_t next_line_start_pos = buffer_get_line_start(app, buffer, line_index); int32_t next_line_start_pos = buffer_get_line_start(app, buffer, line_number);
indent.previous_line_indent = indent.current_indent; indent.previous_line_indent = indent.current_indent;
Cpp_Token prev_token = {0}; Cpp_Token prev_token = {0};
Cpp_Token token = {0}; Cpp_Token token = {0};
--token_ptr; --token_ptr;
for (;line_index < line_end;){ for (;line_number < line_end;){
prev_token = token; prev_token = token;
++token_ptr; ++token_ptr;
if (token_ptr < tokens.tokens + tokens.count){ if (token_ptr < tokens.tokens + tokens.count){
@ -340,15 +347,15 @@ get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *b
token.flags = 0; token.flags = 0;
} }
for (;token.start >= next_line_start_pos && line_index < line_end;){ for (;token.start >= next_line_start_pos && line_number < line_end;){
next_line_start_pos = buffer_get_line_start(app, buffer, line_index+1); next_line_start_pos = buffer_get_line_start(app, buffer, line_number+1);
int32_t this_indent = 0; int32_t this_indent = 0;
{ {
int32_t previous_indent = indent.previous_line_indent; int32_t previous_indent = indent.previous_line_indent;
int32_t this_line_start = buffer_get_line_start(app, buffer, line_index); int32_t this_line_start = buffer_get_line_start(app, buffer, line_number);
int32_t next_line_start = buffer_get_line_start(app, buffer, line_index+1); int32_t next_line_start = buffer_get_line_start(app, buffer, line_number+1);
bool32 did_special_behavior = false; bool32 did_special_behavior = false;
@ -373,7 +380,7 @@ get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *b
} }
if (!hard_start.all_whitespace){ if (!hard_start.all_whitespace){
if (line_index >= line_start){ if (line_number >= line_start){
indent.previous_comment_indent = this_indent; indent.previous_comment_indent = this_indent;
} }
else{ else{
@ -439,10 +446,10 @@ get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *b
} }
} }
if (line_index >= line_start){ if (line_number >= line_start){
indent_marks[line_index] = this_indent; indent_marks[line_number] = this_indent;
} }
++line_index; ++line_number;
indent.previous_line_indent = this_indent; indent.previous_line_indent = this_indent;
} }
@ -456,7 +463,7 @@ get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *b
case CPP_TOKEN_COMMENT: case CPP_TOKEN_COMMENT:
{ {
int32_t line = buffer_get_line_index(app, buffer, token.start); int32_t line = buffer_get_line_number(app, buffer, token.start);
int32_t start = buffer_get_line_start(app, buffer, line); int32_t start = buffer_get_line_start(app, buffer, line);
indent.comment_shift = (indent.current_indent - (token.start - start)); indent.comment_shift = (indent.current_indent - (token.start - start));
@ -467,7 +474,7 @@ get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *b
{ {
if (!(token.flags & CPP_TFLAG_PP_BODY)){ if (!(token.flags & CPP_TFLAG_PP_BODY)){
if (indent.paren_nesting < ArrayCount(indent.paren_anchor_indent)){ if (indent.paren_nesting < ArrayCount(indent.paren_anchor_indent)){
int32_t line = buffer_get_line_index(app, buffer, token.start); int32_t line = buffer_get_line_number(app, buffer, token.start);
int32_t start = buffer_get_line_start(app, buffer, line); int32_t start = buffer_get_line_start(app, buffer, line);
int32_t char_pos = token.start - start; int32_t char_pos = token.start - start;
@ -500,8 +507,8 @@ get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *b
static void static void
get_indent_lines_minimum(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, int32_t end_pos, int32_t *line_start_out, int32_t *line_end_out){ get_indent_lines_minimum(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, int32_t end_pos, int32_t *line_start_out, int32_t *line_end_out){
int32_t line_start = buffer_get_line_index(app, buffer, start_pos); int32_t line_start = buffer_get_line_number(app, buffer, start_pos);
int32_t line_end = buffer_get_line_index(app, buffer, end_pos) + 1; int32_t line_end = buffer_get_line_number(app, buffer, end_pos) + 1;
*line_start_out = line_start; *line_start_out = line_start;
*line_end_out = line_end; *line_end_out = line_end;
@ -509,14 +516,14 @@ get_indent_lines_minimum(Application_Links *app, Buffer_Summary *buffer, int32_t
static void static void
get_indent_lines_whole_tokens(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Array tokens, int32_t start_pos, int32_t end_pos, int32_t *line_start_out, int32_t *line_end_out){ get_indent_lines_whole_tokens(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Array tokens, int32_t start_pos, int32_t end_pos, int32_t *line_start_out, int32_t *line_end_out){
int32_t line_start = buffer_get_line_index(app, buffer, start_pos); int32_t line_start = buffer_get_line_number(app, buffer, start_pos);
int32_t line_end = buffer_get_line_index(app, buffer, end_pos); int32_t line_end = buffer_get_line_number(app, buffer, end_pos);
for (;line_start > 1;){ for (;line_start > 1;){
int32_t line_start_pos = 0; int32_t line_start_pos = 0;
Cpp_Token *token = get_first_token_at_line(app, buffer, tokens, line_start, &line_start_pos); Cpp_Token *token = get_first_token_at_line(app, buffer, tokens, line_start, &line_start_pos);
if (token && token->start < line_start_pos){ if (token && token->start < line_start_pos){
line_start = buffer_get_line_index(app, buffer, token->start); line_start = buffer_get_line_number(app, buffer, token->start);
} }
else{ else{
break; break;
@ -527,7 +534,7 @@ get_indent_lines_whole_tokens(Application_Links *app, Buffer_Summary *buffer, Cp
int32_t next_line_start_pos = 0; int32_t next_line_start_pos = 0;
Cpp_Token *token = get_first_token_at_line(app, buffer, tokens, line_end+1, &next_line_start_pos); Cpp_Token *token = get_first_token_at_line(app, buffer, tokens, line_end+1, &next_line_start_pos);
if (token && token->start < next_line_start_pos){ if (token && token->start < next_line_start_pos){
line_end = buffer_get_line_index(app, buffer, token->start+token->size); line_end = buffer_get_line_number(app, buffer, token->start+token->size);
} }
else{ else{
break; break;

View File

@ -268,7 +268,7 @@ print_positions(Application_Links *app, Buffer_Summary *buffer, Function_Positio
int32_t sig_size = extra_memory->pos; int32_t sig_size = extra_memory->pos;
String sig = make_string(extra_memory->base, sig_size); String sig = make_string(extra_memory->base, sig_size);
int32_t line_number = buffer_get_line_index(app, buffer, open_paren_pos); int32_t line_number = buffer_get_line_number(app, buffer, open_paren_pos);
int32_t line_number_len = int_to_str_size(line_number); int32_t line_number_len = int_to_str_size(line_number);
int32_t append_len = buffer_name.size + 1 + line_number_len + 1 + 1 + sig_size + 1; int32_t append_len = buffer_name.size + 1 + line_number_len + 1 + 1 + sig_size + 1;

View File

@ -206,9 +206,9 @@ int32_t line_number;
}; };
static Command_Metadata fcoder_metacmd_table[185] = { static Command_Metadata fcoder_metacmd_table[185] = {
{ PROC_LINKS(allow_mouse, 0), "allow_mouse", 11, "Shows the mouse and causes all mouse input to be processed normally.", 68, "C:\\work\\4ed\\code\\4coder_default_framework.h", 47, 230 }, { PROC_LINKS(allow_mouse, 0), "allow_mouse", 11, "Shows the mouse and causes all mouse input to be processed normally.", 68, "C:\\work\\4ed\\code\\4coder_default_framework.h", 47, 230 },
{ PROC_LINKS(auto_tab_line_at_cursor, 0), "auto_tab_line_at_cursor", 23, "Auto-indents the line on which the cursor sits.", 47, "C:\\work\\4ed\\code\\4coder_auto_indent.cpp", 43, 618 }, { PROC_LINKS(auto_tab_line_at_cursor, 0), "auto_tab_line_at_cursor", 23, "Auto-indents the line on which the cursor sits.", 47, "C:\\work\\4ed\\code\\4coder_auto_indent.cpp", 43, 625 },
{ PROC_LINKS(auto_tab_range, 0), "auto_tab_range", 14, "Auto-indents the range between the cursor and the mark.", 55, "C:\\work\\4ed\\code\\4coder_auto_indent.cpp", 43, 629 }, { PROC_LINKS(auto_tab_range, 0), "auto_tab_range", 14, "Auto-indents the range between the cursor and the mark.", 55, "C:\\work\\4ed\\code\\4coder_auto_indent.cpp", 43, 636 },
{ PROC_LINKS(auto_tab_whole_file, 0), "auto_tab_whole_file", 19, "Audo-indents the entire current buffer.", 39, "C:\\work\\4ed\\code\\4coder_auto_indent.cpp", 43, 608 }, { PROC_LINKS(auto_tab_whole_file, 0), "auto_tab_whole_file", 19, "Audo-indents the entire current buffer.", 39, "C:\\work\\4ed\\code\\4coder_auto_indent.cpp", 43, 615 },
{ PROC_LINKS(backspace_char, 0), "backspace_char", 14, "Deletes the character to the left of the cursor.", 48, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 81 }, { PROC_LINKS(backspace_char, 0), "backspace_char", 14, "Deletes the character to the left of the cursor.", 48, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 81 },
{ PROC_LINKS(backspace_word, 0), "backspace_word", 14, "Delete characters between the cursor position and the first alphanumeric boundary to the left.", 94, "C:\\work\\4ed\\code\\4coder_default_include.cpp", 47, 147 }, { PROC_LINKS(backspace_word, 0), "backspace_word", 14, "Delete characters between the cursor position and the first alphanumeric boundary to the left.", 94, "C:\\work\\4ed\\code\\4coder_default_include.cpp", 47, 147 },
{ PROC_LINKS(basic_change_active_panel, 0), "basic_change_active_panel", 25, "Change the currently active panel, moving to the panel with the next highest view_id. Will not skipe the build panel if it is open.", 132, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 514 }, { PROC_LINKS(basic_change_active_panel, 0), "basic_change_active_panel", 25, "Change the currently active panel, moving to the panel with the next highest view_id. Will not skipe the build panel if it is open.", 132, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 514 },
@ -230,7 +230,7 @@ static Command_Metadata fcoder_metacmd_table[185] = {
{ PROC_LINKS(decrease_face_size, 0), "decrease_face_size", 18, "Decrease the size of the face used by the current buffer.", 57, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 615 }, { PROC_LINKS(decrease_face_size, 0), "decrease_face_size", 18, "Decrease the size of the face used by the current buffer.", 57, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 615 },
{ PROC_LINKS(decrease_line_wrap, 0), "decrease_line_wrap", 18, "Decrases the current buffer's width for line wrapping.", 54, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 592 }, { PROC_LINKS(decrease_line_wrap, 0), "decrease_line_wrap", 18, "Decrases the current buffer's width for line wrapping.", 54, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 592 },
{ PROC_LINKS(delete_char, 0), "delete_char", 11, "Deletes the character to the right of the cursor.", 49, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 63 }, { PROC_LINKS(delete_char, 0), "delete_char", 11, "Deletes the character to the right of the cursor.", 49, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 63 },
{ PROC_LINKS(delete_current_scope, 0), "delete_current_scope", 20, "Deletes the braces surrounding the currently selected scope. Leaves the contents within the scope.", 99, "C:\\work\\4ed\\code\\4coder_scope_commands.cpp", 46, 479 }, { PROC_LINKS(delete_current_scope, 0), "delete_current_scope", 20, "Deletes the braces surrounding the currently selected scope. Leaves the contents within the scope.", 99, "C:\\work\\4ed\\code\\4coder_scope_commands.cpp", 46, 472 },
{ PROC_LINKS(delete_file_query, 0), "delete_file_query", 17, "Deletes the file of the current buffer if 4coder has the appropriate access rights. Will ask the user for confirmation first.", 125, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1061 }, { PROC_LINKS(delete_file_query, 0), "delete_file_query", 17, "Deletes the file of the current buffer if 4coder has the appropriate access rights. Will ask the user for confirmation first.", 125, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1061 },
{ PROC_LINKS(delete_line, 0), "delete_line", 11, "Delete the line the on which the cursor sits.", 45, "C:\\work\\4ed\\code\\4coder_default_include.cpp", 47, 351 }, { PROC_LINKS(delete_line, 0), "delete_line", 11, "Delete the line the on which the cursor sits.", 45, "C:\\work\\4ed\\code\\4coder_default_include.cpp", 47, 351 },
{ PROC_LINKS(delete_range, 0), "delete_range", 12, "Deletes the text in the range between the cursor and the mark.", 62, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 121 }, { PROC_LINKS(delete_range, 0), "delete_range", 12, "Deletes the text in the range between the cursor and the mark.", 62, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 121 },
@ -339,7 +339,7 @@ static Command_Metadata fcoder_metacmd_table[185] = {
{ PROC_LINKS(reverse_search_identifier, 0), "reverse_search_identifier", 25, "Begins an incremental search up through the current buffer for the word or token under the cursor.", 98, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 869 }, { PROC_LINKS(reverse_search_identifier, 0), "reverse_search_identifier", 25, "Begins an incremental search up through the current buffer for the word or token under the cursor.", 98, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 869 },
{ PROC_LINKS(save, 0), "save", 4, "Saves the current buffer.", 25, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1212 }, { PROC_LINKS(save, 0), "save", 4, "Saves the current buffer.", 25, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1212 },
{ PROC_LINKS(save_all_dirty_buffers, 0), "save_all_dirty_buffers", 22, "Saves all buffers marked dirty (showing the '*' indicator).", 59, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1026 }, { PROC_LINKS(save_all_dirty_buffers, 0), "save_all_dirty_buffers", 22, "Saves all buffers marked dirty (showing the '*' indicator).", 59, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1026 },
{ PROC_LINKS(scope_absorb_down, 0), "scope_absorb_down", 17, "If a scope is currently selected, and a statement or block statement is present below the current scope, the statement is moved into the scope.", 143, "C:\\work\\4ed\\code\\4coder_scope_commands.cpp", 46, 738 }, { PROC_LINKS(scope_absorb_down, 0), "scope_absorb_down", 17, "If a scope is currently selected, and a statement or block statement is present below the current scope, the statement is moved into the scope.", 143, "C:\\work\\4ed\\code\\4coder_scope_commands.cpp", 46, 731 },
{ PROC_LINKS(search, 0), "search", 6, "Begins an incremental search down through the current buffer for a user specified string.", 89, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 844 }, { PROC_LINKS(search, 0), "search", 6, "Begins an incremental search down through the current buffer for a user specified string.", 89, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 844 },
{ PROC_LINKS(search_identifier, 0), "search_identifier", 17, "Begins an incremental search down through the current buffer for the word or token under the cursor.", 100, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 858 }, { PROC_LINKS(search_identifier, 0), "search_identifier", 17, "Begins an incremental search down through the current buffer for the word or token under the cursor.", 100, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 858 },
{ PROC_LINKS(seek_alphanumeric_left, 0), "seek_alphanumeric_left", 22, "Seek left for boundary between alphanumeric characters and non-alphanumeric characters.", 87, "C:\\work\\4ed\\code\\4coder_default_include.cpp", 47, 128 }, { PROC_LINKS(seek_alphanumeric_left, 0), "seek_alphanumeric_left", 22, "Seek left for boundary between alphanumeric characters and non-alphanumeric characters.", 87, "C:\\work\\4ed\\code\\4coder_default_include.cpp", 47, 128 },
@ -381,7 +381,7 @@ static Command_Metadata fcoder_metacmd_table[185] = {
{ PROC_LINKS(toggle_virtual_whitespace, 0), "toggle_virtual_whitespace", 25, "Toggles the current buffer's virtual whitespace status.", 55, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 627 }, { PROC_LINKS(toggle_virtual_whitespace, 0), "toggle_virtual_whitespace", 25, "Toggles the current buffer's virtual whitespace status.", 55, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 627 },
{ PROC_LINKS(undo, 0), "undo", 4, "Advances backwards through the undo history.", 44, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1164 }, { PROC_LINKS(undo, 0), "undo", 4, "Advances backwards through the undo history.", 44, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1164 },
{ PROC_LINKS(word_complete, 0), "word_complete", 13, "Iteratively tries completing the word to the left of the cursor with other words in open buffers that have the same prefix string.", 130, "C:\\work\\4ed\\code\\4coder_search.cpp", 38, 786 }, { PROC_LINKS(word_complete, 0), "word_complete", 13, "Iteratively tries completing the word to the left of the cursor with other words in open buffers that have the same prefix string.", 130, "C:\\work\\4ed\\code\\4coder_search.cpp", 38, 786 },
{ PROC_LINKS(write_and_auto_tab, 0), "write_and_auto_tab", 18, "Inserts a character and auto-indents the line on which the cursor sits.", 71, "C:\\work\\4ed\\code\\4coder_auto_indent.cpp", 43, 641 }, { PROC_LINKS(write_and_auto_tab, 0), "write_and_auto_tab", 18, "Inserts a character and auto-indents the line on which the cursor sits.", 71, "C:\\work\\4ed\\code\\4coder_auto_indent.cpp", 43, 648 },
{ PROC_LINKS(write_block, 0), "write_block", 11, "At the cursor, insert a block comment.", 38, "C:\\work\\4ed\\code\\4coder_default_include.cpp", 47, 534 }, { PROC_LINKS(write_block, 0), "write_block", 11, "At the cursor, insert a block comment.", 38, "C:\\work\\4ed\\code\\4coder_default_include.cpp", 47, 534 },
{ PROC_LINKS(write_character, 0), "write_character", 15, "Inserts whatever character was used to trigger this command.", 60, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 47 }, { PROC_LINKS(write_character, 0), "write_character", 15, "Inserts whatever character was used to trigger this command.", 60, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 47 },
{ PROC_LINKS(write_explicit_enum_values, 0), "write_explicit_enum_values", 26, "If the cursor is found to be on the '{' of an enum definition, the values of the enum will be filled in sequentially starting from zero. Existing values are overwritten.", 170, "C:\\work\\4ed\\code\\power\\4coder_experiments.cpp", 50, 496 }, { PROC_LINKS(write_explicit_enum_values, 0), "write_explicit_enum_values", 26, "If the cursor is found to be on the '{' of an enum definition, the values of the enum will be filled in sequentially starting from zero. Existing values are overwritten.", 170, "C:\\work\\4ed\\code\\power\\4coder_experiments.cpp", 50, 496 },

View File

@ -1023,7 +1023,7 @@ buffer_line_is_blank(Application_Links *app, Buffer_Summary *buffer, int32_t lin
} }
static int32_t static int32_t
buffer_get_line_index(Application_Links *app, Buffer_Summary *buffer, int32_t pos){ buffer_get_line_number(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
Partial_Cursor partial_cursor; Partial_Cursor partial_cursor;
buffer_compute_cursor(app, buffer, seek_pos(pos), &partial_cursor); buffer_compute_cursor(app, buffer, seek_pos(pos), &partial_cursor);
return(partial_cursor.line); return(partial_cursor.line);
@ -1044,7 +1044,7 @@ get_first_token_at_line(Application_Links *app, Buffer_Summary *buffer, Cpp_Toke
Cpp_Token *result = 0; Cpp_Token *result = 0;
if (get_token.token_index < tokens.count){ if (get_token.token_index < tokens.count){
result = tokens.tokens + get_token.token_index; result = &tokens.tokens[get_token.token_index];
} }
return(result); return(result);

View File

@ -407,22 +407,15 @@ CUSTOM_DOC("Wraps the code contained in the range between cursor and mark with a
View_Summary view = get_active_view(app, access); View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access); Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
Range lines; Range lines = {0};
Range range = get_range(&view); Range range = get_range(&view);
lines.min = buffer_get_line_index(app, &buffer, range.min); lines.min = buffer_get_line_number(app, &buffer, range.min);
range.min = buffer_get_line_start(app, &buffer, lines.min); range.min = buffer_get_line_start(app, &buffer, lines.min);
lines.max = buffer_get_line_index(app, &buffer, range.max); lines.max = buffer_get_line_number(app, &buffer, range.max);
range.max = buffer_get_line_end(app, &buffer, lines.max); range.max = buffer_get_line_end(app, &buffer, lines.max);
bool32 do_full = false; bool32 do_full = (lines.min < lines.max) || (!buffer_line_is_blank(app, &buffer, lines.min));
if (lines.min < lines.max){
do_full = true;
}
else if (!buffer_line_is_blank(app, &buffer, lines.min)){
do_full = true;
}
if (do_full){ if (do_full){
Buffer_Edit edits[2]; Buffer_Edit edits[2];

View File

@ -1194,6 +1194,7 @@ binary_search(i32 *array, i32 value, i32 l_bound, i32 u_bound){
return(i); return(i);
} }
// TODO(allen): CHECK
inline i32 inline i32
buffer_get_line_index_range(Gap_Buffer *buffer, i32 pos, i32 l_bound, i32 u_bound){ buffer_get_line_index_range(Gap_Buffer *buffer, i32 pos, i32 l_bound, i32 u_bound){
Assert(0 <= l_bound); Assert(0 <= l_bound);
@ -1207,7 +1208,7 @@ buffer_get_line_index_range(Gap_Buffer *buffer, i32 pos, i32 l_bound, i32 u_boun
} }
inline i32 inline i32
buffer_get_line_index(Gap_Buffer *buffer, i32 pos){ buffer_get_line_number(Gap_Buffer *buffer, i32 pos){
i32 result = buffer_get_line_index_range(buffer, pos, 0, buffer->line_count); i32 result = buffer_get_line_index_range(buffer, pos, 0, buffer->line_count);
return(result); return(result);
} }
@ -1363,7 +1364,7 @@ buffer_cursor_seek(Buffer_Cursor_Seek_State *S_ptr, Buffer_Cursor_Seek_Params pa
{ {
params.seek.pos = clamp(0, params.seek.pos, S.size); params.seek.pos = clamp(0, params.seek.pos, S.size);
line_index = buffer_get_line_index(params.buffer, params.seek.pos); line_index = buffer_get_line_number(params.buffer, params.seek.pos);
}break; }break;
case buffer_seek_character_pos: case buffer_seek_character_pos:

View File

@ -3143,8 +3143,8 @@ file_do_single_edit(System_Functions *system, Models *models, Editing_File *file
// NOTE(allen): meta data // NOTE(allen): meta data
Gap_Buffer *buffer = &file->state.buffer; Gap_Buffer *buffer = &file->state.buffer;
i32 line_start = buffer_get_line_index(&file->state.buffer, start); i32 line_start = buffer_get_line_number(&file->state.buffer, start);
i32 line_end = buffer_get_line_index(&file->state.buffer, end); i32 line_end = buffer_get_line_number(&file->state.buffer, end);
i32 replaced_line_count = line_end - line_start; i32 replaced_line_count = line_end - line_start;
i32 new_line_count = buffer_count_newlines(&file->state.buffer, start, start+str_len); i32 new_line_count = buffer_count_newlines(&file->state.buffer, start, start+str_len);
i32 line_shift = new_line_count - replaced_line_count; i32 line_shift = new_line_count - replaced_line_count;

View File

@ -1318,7 +1318,7 @@ casey_list_all_functions(Application_Links *app, Partition *part, Buffer_Summary
int32_t sig_size = extra_memory->pos; int32_t sig_size = extra_memory->pos;
String sig = make_string(extra_memory->base, sig_size); String sig = make_string(extra_memory->base, sig_size);
int32_t line_number = buffer_get_line_index(app, buffer, open_paren_pos); int32_t line_number = buffer_get_line_number(app, buffer, open_paren_pos);
int32_t line_number_len = int_to_str_size(line_number); int32_t line_number_len = int_to_str_size(line_number);
int32_t append_len = buffer_name.size + 1 + line_number_len + 1 + 1 + sig_size + 1; int32_t append_len = buffer_name.size + 1 + line_number_len + 1 + 1 + sig_size + 1;