fixed another issue with get_line_indentation_marks

This commit is contained in:
Allen Webster 2016-06-09 12:27:23 -04:00
parent 368e79e78c
commit c26bf843a9
1 changed files with 81 additions and 19 deletions

View File

@ -132,7 +132,8 @@ enum View_UI{
enum Debug_Mode{
DBG_Input,
DBG_Memory
DBG_Threads_And_Memory,
DBG_View_Inspection
};
enum Color_View_Mode{
@ -1018,8 +1019,8 @@ file_relex_parallel(System_Functions *system,
relex_space.max_count = state.space_request;
relex_space.tokens = push_array(part, Cpp_Token, relex_space.max_count);
// char *spare = push_array(part, char, cpp_file.size);
// if (cpp_relex_nonalloc_main(&state, &relex_space, &relex_end, spare)){
// char *spare = push_array(part, char, cpp_file.size);
// if (cpp_relex_nonalloc_main(&state, &relex_space, &relex_end, spare)){
if (cpp_relex_nonalloc_main(&state, &relex_space, &relex_end)){
inline_lex = 0;
}
@ -2767,7 +2768,11 @@ get_line_indentation_marks(Partition *part, Buffer *buffer, Cpp_Token_Stack toke
line_i = line_start;
}
i32 next_line_start = buffer->line_starts[line_i+1];
i32 next_line_start = buffer_size(buffer);
if (line_i+1 < buffer->line_count){
next_line_start = buffer->line_starts[line_i+1];
}
switch (token->type){
case CPP_TOKEN_BRACKET_OPEN: indent.current_indent += tab_width; break;
case CPP_TOKEN_BRACE_OPEN: indent.current_indent += tab_width; break;
@ -2797,9 +2802,8 @@ get_line_indentation_marks(Partition *part, Buffer *buffer, Cpp_Token_Stack toke
next_line_start = buffer_size(buffer);
}
// TODO(allen): Since this is called in one place we can probably go back
// to directly passing in next_line_start and this_line_start.
i32 this_indent = compute_this_indent(buffer, indent, T, prev_token, line_i, tab_width);
i32 this_indent =
compute_this_indent(buffer, indent, T, prev_token, line_i, tab_width);
// NOTE(allen): Rebase the paren anchor if the first token
// after an open paren is on the next line.
@ -2834,8 +2838,8 @@ get_line_indentation_marks(Partition *part, Buffer *buffer, Cpp_Token_Stack toke
i32 start = buffer->line_starts[line];
i32 char_pos = T.start - start;
Hard_Start_Result hard_start = buffer_find_hard_start(
buffer, start, tab_width);
Hard_Start_Result hard_start =
buffer_find_hard_start(buffer, start, tab_width);
i32 line_pos = hard_start.char_pos - start;
@ -4490,7 +4494,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
// TODO(allen):
// + Incoming input
// + Memory info
// - Thread info
// + Thread info
// - View inspection
// - Buffer inspection
// - Command maps inspection
@ -4523,7 +4527,10 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
view->debug_mode = DBG_Input;
}
if (key.keycode == 'm'){
view->debug_mode = DBG_Memory;
view->debug_mode = DBG_Threads_And_Memory;
}
if (key.keycode == 'v'){
view->debug_mode = DBG_View_Inspection;
}
}
}
@ -4622,8 +4629,34 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
}
}break;
case DBG_Memory:
case DBG_Threads_And_Memory:
{
b8 threads[4];
i32 pending = 0;
system->internal_get_thread_states(BACKGROUND_THREADS,
threads, &pending);
string.size = 0;
append(&string, "pending jobs: ");
append_int_to_str(&string, pending);
gui_do_text_field(target, string, empty_str);
for (i32 i = 0; i < 4; ++i){
string.size = 0;
append(&string, "thread ");
append_int_to_str(&string, i);
append(&string, ": ");
if (threads[i]){
append(&string, "running");
}
else{
append(&string, "waiting");
}
gui_do_text_field(target, string, empty_str);
}
Partition *part = &models->mem.part;
General_Memory *general = &models->mem.general;
@ -4652,6 +4685,35 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
gui_do_text_field(target, string, empty_str);
}
}break;
case DBG_View_Inspection:
{
Editing_Layout *layout = &models->layout;
Panel *panel, *sentinel;
sentinel = &layout->used_sentinel;
for (dll_items(panel, sentinel)){
View *view = panel->view;
string.size = 0;
append(&string, "view: ");
append_int_to_str(&string, view->persistent.id);
gui_do_text_field(target, string, empty_str);
string.size = 0;
Editing_File *file = view->file_data.file;
append(&string, " > buffer: ");
if (file){
append(&string, file->name.live_name);
gui_do_text_field(target, string, empty_str);
string.size = 0;
append(&string, " > buffer-slot-id: ");
append_int_to_str(&string, file->id.id);
}
else{
append(&string, "*NULL*");
gui_do_text_field(target, string, empty_str);
}
}
}break;
}
gui_end_scrollable(target);