implemented windows fullscreen (hacking alt tab), improved the next error part of the jump parsing
parent
df236e44b5
commit
084d45b530
|
@ -102,7 +102,7 @@ CUSTOM_COMMAND_SIG(rewrite_as_single_caps){
|
||||||
CUSTOM_COMMAND_SIG(open_my_files){
|
CUSTOM_COMMAND_SIG(open_my_files){
|
||||||
uint32_t access = AccessAll;
|
uint32_t access = AccessAll;
|
||||||
View_Summary view = app->get_active_view(app, access);
|
View_Summary view = app->get_active_view(app, access);
|
||||||
view_open_file(app, &view, literal("w:/4ed/data/test/basic.cpp"), false);
|
view_open_file(app, &view, literal("w:/4ed/data/test/basic.cpp"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(build_at_launch_location){
|
CUSTOM_COMMAND_SIG(build_at_launch_location){
|
||||||
|
@ -160,6 +160,7 @@ CUSTOM_COMMAND_SIG(newline_or_goto_position){
|
||||||
|
|
||||||
if (buffer.lock_flags & AccessProtected){
|
if (buffer.lock_flags & AccessProtected){
|
||||||
exec_command(app, goto_jump_at_cursor);
|
exec_command(app, goto_jump_at_cursor);
|
||||||
|
lock_jump_buffer(buffer);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
exec_command(app, write_character);
|
exec_command(app, write_character);
|
||||||
|
|
|
@ -15,8 +15,10 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(build_in_build_panel){
|
CUSTOM_COMMAND_SIG(build_in_build_panel){
|
||||||
|
String comp_name = make_lit_string("*compilation*");
|
||||||
|
|
||||||
Buffer_Summary buffer =
|
Buffer_Summary buffer =
|
||||||
app->get_buffer_by_name(app, literal("*compilation*"), AccessAll);
|
app->get_buffer_by_name(app, comp_name.str, comp_name.size, AccessAll);
|
||||||
View_Summary build_view = {0};
|
View_Summary build_view = {0};
|
||||||
|
|
||||||
View_Summary original_view = app->get_active_view(app, AccessAll);
|
View_Summary original_view = app->get_active_view(app, AccessAll);
|
||||||
|
@ -37,10 +39,12 @@ CUSTOM_COMMAND_SIG(build_in_build_panel){
|
||||||
|
|
||||||
execute_standard_build(app, &build_view, &original_buffer);
|
execute_standard_build(app, &build_view, &original_buffer);
|
||||||
|
|
||||||
buffer = app->get_buffer_by_name(app, literal("*compilation*"), AccessAll);
|
buffer = app->get_buffer_by_name(app, comp_name.str, comp_name.size, AccessAll);
|
||||||
app->buffer_set_font(app, &buffer, literal("Inconsolata"));
|
app->buffer_set_font(app, &buffer, literal("Inconsolata"));
|
||||||
|
|
||||||
prev_location = null_location;
|
prev_location = null_location;
|
||||||
|
|
||||||
|
lock_jump_buffer(comp_name.str, comp_name.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(allen): This is a bit nasty. I want a system for picking
|
// TODO(allen): This is a bit nasty. I want a system for picking
|
||||||
|
@ -133,7 +137,7 @@ CUSTOM_COMMAND_SIG(open_file_in_quotes_build){
|
||||||
if (file_name_in_quotes(app, &file_name)){
|
if (file_name_in_quotes(app, &file_name)){
|
||||||
exec_command(app, change_active_panel_build);
|
exec_command(app, change_active_panel_build);
|
||||||
View_Summary view = app->get_active_view(app, AccessAll);
|
View_Summary view = app->get_active_view(app, AccessAll);
|
||||||
view_open_file(app, &view, expand_str(file_name), false);
|
view_open_file(app, &view, expand_str(file_name), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,97 @@
|
||||||
# define DEF_TAB_WIDTH 4
|
# define DEF_TAB_WIDTH 4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
// Useful helper functions
|
||||||
|
//
|
||||||
|
|
||||||
|
static int32_t
|
||||||
|
open_file(Application_Links *app,
|
||||||
|
Buffer_Summary *buffer_out,
|
||||||
|
char *filename,
|
||||||
|
int32_t filename_len,
|
||||||
|
int32_t background,
|
||||||
|
int32_t never_new){
|
||||||
|
int32_t result = false;
|
||||||
|
Buffer_Summary buffer =
|
||||||
|
app->get_buffer_by_name(app, filename, filename_len,
|
||||||
|
AccessProtected|AccessHidden);
|
||||||
|
|
||||||
|
if (buffer.exists){
|
||||||
|
if (buffer_out) *buffer_out = buffer;
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Buffer_Create_Flag flags = 0;
|
||||||
|
if (background){
|
||||||
|
flags |= BufferCreate_Background;
|
||||||
|
}
|
||||||
|
if (never_new){
|
||||||
|
flags |= BufferCreate_NeverNew;
|
||||||
|
}
|
||||||
|
buffer = app->create_buffer(app, filename, filename_len, flags);
|
||||||
|
if (buffer.exists){
|
||||||
|
if (buffer_out) *buffer_out = buffer;
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t
|
||||||
|
view_open_file(Application_Links *app,
|
||||||
|
View_Summary *view,
|
||||||
|
char *filename,
|
||||||
|
int32_t filename_len,
|
||||||
|
int32_t never_new){
|
||||||
|
int32_t result = false;
|
||||||
|
|
||||||
|
if (view){
|
||||||
|
Buffer_Summary buffer = {0};
|
||||||
|
if (open_file(app, &buffer, filename, filename_len, false, never_new)){
|
||||||
|
app->view_set_buffer(app, view, buffer.buffer_id, 0);
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t
|
||||||
|
read_line(Application_Links *app,
|
||||||
|
Partition *part,
|
||||||
|
Buffer_Summary *buffer,
|
||||||
|
int32_t line,
|
||||||
|
String *str){
|
||||||
|
|
||||||
|
Partial_Cursor begin = {0};
|
||||||
|
Partial_Cursor end = {0};
|
||||||
|
|
||||||
|
int32_t success = false;
|
||||||
|
|
||||||
|
if (app->buffer_compute_cursor(app, buffer,
|
||||||
|
seek_line_char(line, 1), &begin)){
|
||||||
|
if (app->buffer_compute_cursor(app, buffer,
|
||||||
|
seek_line_char(line, 65536), &end)){
|
||||||
|
if (begin.line == line){
|
||||||
|
if (0 <= begin.pos && begin.pos <= end.pos && end.pos <= buffer->size){
|
||||||
|
int32_t size = (end.pos - begin.pos);
|
||||||
|
*str = make_string(push_array(part, char, size+1), size+1);
|
||||||
|
if (str->str){
|
||||||
|
success = true;
|
||||||
|
app->buffer_read_range(app, buffer, begin.pos, end.pos, str->str);
|
||||||
|
str->size = size;
|
||||||
|
terminate_with_null(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(success);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Memory
|
// Memory
|
||||||
|
@ -1571,7 +1662,7 @@ CUSTOM_COMMAND_SIG(open_file_in_quotes_regular){
|
||||||
if (file_name_in_quotes(app, &file_name)){
|
if (file_name_in_quotes(app, &file_name)){
|
||||||
exec_command(app, change_active_panel_regular);
|
exec_command(app, change_active_panel_regular);
|
||||||
View_Summary view = app->get_active_view(app, AccessAll);
|
View_Summary view = app->get_active_view(app, AccessAll);
|
||||||
view_open_file(app, &view, expand_str(file_name), false);
|
view_open_file(app, &view, expand_str(file_name), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2241,6 +2332,7 @@ CUSTOM_COMMAND_SIG(eol_nixify){
|
||||||
|
|
||||||
#include "4coder_table.cpp"
|
#include "4coder_table.cpp"
|
||||||
#include "4coder_search.cpp"
|
#include "4coder_search.cpp"
|
||||||
|
#include "4coder_jump_parsing.cpp"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
generic_search_all_buffers(Application_Links *app, General_Memory *general, Partition *part,
|
generic_search_all_buffers(Application_Links *app, General_Memory *general, Partition *part,
|
||||||
|
@ -2265,9 +2357,12 @@ generic_search_all_buffers(Application_Links *app, General_Memory *general, Part
|
||||||
|
|
||||||
Search_Range *ranges = set.ranges;
|
Search_Range *ranges = set.ranges;
|
||||||
|
|
||||||
Buffer_Summary search_buffer = app->get_buffer_by_name(app, literal("*search*"), AccessAll);
|
String search_name = make_lit_string("*search*");
|
||||||
|
|
||||||
|
Buffer_Summary search_buffer = app->get_buffer_by_name(app, search_name.str, search_name.size,
|
||||||
|
AccessAll);
|
||||||
if (!search_buffer.exists){
|
if (!search_buffer.exists){
|
||||||
search_buffer = app->create_buffer(app, literal("*search*"), BufferCreate_AlwaysNew);
|
search_buffer = app->create_buffer(app, search_name.str, search_name.size, BufferCreate_AlwaysNew);
|
||||||
app->buffer_set_setting(app, &search_buffer, BufferSetting_Unimportant, true);
|
app->buffer_set_setting(app, &search_buffer, BufferSetting_Unimportant, true);
|
||||||
app->buffer_set_setting(app, &search_buffer, BufferSetting_ReadOnly, true);
|
app->buffer_set_setting(app, &search_buffer, BufferSetting_ReadOnly, true);
|
||||||
app->buffer_set_setting(app, &search_buffer, BufferSetting_WrapLine, false);
|
app->buffer_set_setting(app, &search_buffer, BufferSetting_WrapLine, false);
|
||||||
|
@ -2370,6 +2465,8 @@ generic_search_all_buffers(Application_Links *app, General_Memory *general, Part
|
||||||
View_Summary view = app->get_active_view(app, AccessAll);
|
View_Summary view = app->get_active_view(app, AccessAll);
|
||||||
app->view_set_buffer(app, &view, search_buffer.buffer_id, 0);
|
app->view_set_buffer(app, &view, search_buffer.buffer_id, 0);
|
||||||
|
|
||||||
|
lock_jump_buffer(search_name.str, search_name.size);
|
||||||
|
|
||||||
end_temp_memory(temp);
|
end_temp_memory(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -418,65 +418,4 @@ buffer_identifier(int32_t id){
|
||||||
return(identifier);
|
return(identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t
|
|
||||||
view_open_file(Application_Links *app, View_Summary *view,
|
|
||||||
char *filename, int32_t filename_len, int32_t do_in_background){
|
|
||||||
int32_t result = false;
|
|
||||||
Buffer_Summary buffer = app->get_buffer_by_name(app, filename, filename_len, AccessProtected|AccessHidden);
|
|
||||||
if (buffer.exists){
|
|
||||||
if (!do_in_background){
|
|
||||||
if (view){
|
|
||||||
app->view_set_buffer(app, view, buffer.buffer_id, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
buffer = app->create_buffer(app, filename, filename_len, do_in_background);
|
|
||||||
if (!do_in_background){
|
|
||||||
if (buffer.exists){
|
|
||||||
if (view){
|
|
||||||
app->view_set_buffer(app, view, buffer.buffer_id, 0);
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t
|
|
||||||
read_line(Application_Links *app,
|
|
||||||
Partition *part,
|
|
||||||
Buffer_Summary *buffer,
|
|
||||||
int32_t line,
|
|
||||||
String *str){
|
|
||||||
|
|
||||||
Partial_Cursor begin = {0};
|
|
||||||
Partial_Cursor end = {0};
|
|
||||||
|
|
||||||
int32_t success = false;
|
|
||||||
|
|
||||||
if (app->buffer_compute_cursor(app, buffer,
|
|
||||||
seek_line_char(line, 1), &begin)){
|
|
||||||
if (app->buffer_compute_cursor(app, buffer,
|
|
||||||
seek_line_char(line, 65536), &end)){
|
|
||||||
if (begin.line == line){
|
|
||||||
if (0 <= begin.pos && begin.pos <= end.pos && end.pos <= buffer->size){
|
|
||||||
int32_t size = (end.pos - begin.pos);
|
|
||||||
*str = make_string(push_array(part, char, size+1), size+1);
|
|
||||||
if (str->str){
|
|
||||||
success = true;
|
|
||||||
app->buffer_read_range(app, buffer, begin.pos, end.pos, str->str);
|
|
||||||
str->size = size;
|
|
||||||
terminate_with_null(str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return(success);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2,16 +2,24 @@
|
||||||
#ifndef FCODER_JUMP_PARSING
|
#ifndef FCODER_JUMP_PARSING
|
||||||
#define FCODER_JUMP_PARSING
|
#define FCODER_JUMP_PARSING
|
||||||
|
|
||||||
struct Jump_Location{
|
typedef struct Name_Based_Jump_Location{
|
||||||
String file;
|
String file;
|
||||||
int32_t line;
|
int32_t line;
|
||||||
int32_t column;
|
int32_t column;
|
||||||
};
|
} Name_Based_Jump_Location;
|
||||||
|
|
||||||
|
typedef struct ID_Based_Jump_Location{
|
||||||
|
int32_t buffer_id;
|
||||||
|
int32_t line;
|
||||||
|
int32_t column;
|
||||||
|
} ID_Based_Jump_Location;
|
||||||
|
static ID_Based_Jump_Location null_location = {0};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
jump_to_location(Application_Links *app, View_Summary *view, Jump_Location *l){
|
jump_to_location(Application_Links *app, View_Summary *view, Name_Based_Jump_Location *l){
|
||||||
view_open_file(app, view, l->file.str, l->file.size, false);
|
if (view_open_file(app, view, l->file.str, l->file.size, true)){
|
||||||
app->view_set_cursor(app, view, seek_line_char(l->line, l->column), true);
|
app->view_set_cursor(app, view, seek_line_char(l->line, l->column), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t
|
static int32_t
|
||||||
|
@ -30,8 +38,8 @@ ms_style_verify(String line, int32_t paren_pos){
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t
|
static int32_t
|
||||||
parse_error(String line, Jump_Location *location,
|
parse_jump_location(String line, Name_Based_Jump_Location *location,
|
||||||
int32_t skip_sub_errors, int32_t *colon_char){
|
int32_t skip_sub_errors, int32_t *colon_char){
|
||||||
int32_t result = false;
|
int32_t result = false;
|
||||||
|
|
||||||
String original_line = line;
|
String original_line = line;
|
||||||
|
@ -151,18 +159,19 @@ parse_error(String line, Jump_Location *location,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t
|
static int32_t
|
||||||
goto_error(Application_Links *app,
|
parse_jump_from_buffer_line(Application_Links *app,
|
||||||
Partition *part,
|
Partition *part,
|
||||||
View_Summary *view, int32_t line,
|
int32_t buffer_id,
|
||||||
Jump_Location *location,
|
int32_t line,
|
||||||
int32_t skip_sub_errors){
|
int32_t skip_sub_errors,
|
||||||
|
Name_Based_Jump_Location *location){
|
||||||
|
|
||||||
int32_t result = false;
|
int32_t result = false;
|
||||||
String line_str = {0};
|
String line_str = {0};
|
||||||
Buffer_Summary buffer = app->get_buffer(app, view->buffer_id, AccessAll);
|
Buffer_Summary buffer = app->get_buffer(app, buffer_id, AccessAll);
|
||||||
if (read_line(app, part, &buffer, line, &line_str)){
|
if (read_line(app, part, &buffer, line, &line_str)){
|
||||||
int32_t colon_char = 0;
|
int32_t colon_char = 0;
|
||||||
if (parse_error(line_str, location, skip_sub_errors, &colon_char)){
|
if (parse_jump_location(line_str, location, skip_sub_errors, &colon_char)){
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,10 +183,10 @@ CUSTOM_COMMAND_SIG(goto_jump_at_cursor){
|
||||||
Temp_Memory temp = begin_temp_memory(&global_part);
|
Temp_Memory temp = begin_temp_memory(&global_part);
|
||||||
View_Summary view = app->get_active_view(app, AccessProtected);
|
View_Summary view = app->get_active_view(app, AccessProtected);
|
||||||
|
|
||||||
Jump_Location location = {0};
|
Name_Based_Jump_Location location = {0};
|
||||||
if (goto_error(app, &global_part,
|
if (parse_jump_from_buffer_line(app, &global_part,
|
||||||
&view, view.cursor.line,
|
view.buffer_id, view.cursor.line, false,
|
||||||
&location, false)){
|
&location)){
|
||||||
|
|
||||||
exec_command(app, change_active_panel);
|
exec_command(app, change_active_panel);
|
||||||
view = app->get_active_view(app, AccessAll);
|
view = app->get_active_view(app, AccessAll);
|
||||||
|
@ -185,38 +194,33 @@ CUSTOM_COMMAND_SIG(goto_jump_at_cursor){
|
||||||
}
|
}
|
||||||
|
|
||||||
end_temp_memory(temp);
|
end_temp_memory(temp);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Error Jumping
|
// Error Jumping
|
||||||
//
|
//
|
||||||
|
|
||||||
struct Prev_Jump{
|
|
||||||
int32_t buffer_id;
|
|
||||||
int32_t line;
|
|
||||||
};
|
|
||||||
|
|
||||||
static Prev_Jump null_location = {0};
|
|
||||||
static Prev_Jump prev_location = {0};
|
|
||||||
|
|
||||||
// TODO(allen): GIVE THESE THINGS NAMES I CAN FUCKING UNDERSTAND
|
|
||||||
static int32_t
|
static int32_t
|
||||||
next_error(Application_Links *app,
|
seek_next_jump_in_buffer(Application_Links *app,
|
||||||
Partition *part,
|
Partition *part,
|
||||||
View_Summary *comp_out, int32_t *start_line,
|
int32_t buffer_id,
|
||||||
Jump_Location *location,
|
int32_t first_line,
|
||||||
int32_t skip_sub_errors,
|
bool32 skip_sub_errors,
|
||||||
int32_t direction,
|
int32_t direction,
|
||||||
int32_t *colon_char){
|
int32_t *line_out,
|
||||||
|
int32_t *colon_index_out,
|
||||||
|
Name_Based_Jump_Location *location_out){
|
||||||
|
|
||||||
|
Assert(direction == 1 || direction == -1);
|
||||||
|
|
||||||
int32_t result = false;
|
int32_t result = false;
|
||||||
int32_t line = *start_line + direction;
|
int32_t line = first_line;
|
||||||
String line_str = {0};
|
String line_str = {0};
|
||||||
Buffer_Summary buffer = app->get_buffer(app, comp_out->buffer_id, AccessAll);
|
Buffer_Summary buffer = app->get_buffer(app, buffer_id, AccessAll);
|
||||||
for (;;){
|
for (;;){
|
||||||
if (read_line(app, part, &buffer, line, &line_str)){
|
if (read_line(app, part, &buffer, line, &line_str)){
|
||||||
if (parse_error(line_str, location, skip_sub_errors, colon_char)){
|
if (parse_jump_location(line_str, location_out, skip_sub_errors, colon_index_out)){
|
||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -231,79 +235,86 @@ next_error(Application_Links *app,
|
||||||
line = 0;
|
line = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
*start_line = line;
|
*line_out = line;
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Prev_Jump
|
static ID_Based_Jump_Location
|
||||||
jump_location_store(Application_Links *app, Jump_Location loc){
|
convert_name_based_to_id_based(Application_Links *app, Name_Based_Jump_Location loc){
|
||||||
Prev_Jump result = {0};
|
ID_Based_Jump_Location result = {0};
|
||||||
Buffer_Summary buffer =
|
Buffer_Summary buffer =
|
||||||
app->get_buffer_by_name(app, loc.file.str, loc.file.size, AccessAll);
|
app->get_buffer_by_name(app, loc.file.str, loc.file.size, AccessAll);
|
||||||
|
|
||||||
if (buffer.exists){
|
if (buffer.exists){
|
||||||
result.buffer_id = buffer.buffer_id;
|
result.buffer_id = buffer.buffer_id;
|
||||||
result.line = loc.line;
|
result.line = loc.line;
|
||||||
|
result.column = loc.column;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t
|
static int32_t
|
||||||
seek_error_internal(Application_Links *app, Partition *part,
|
seek_next_jump_in_view(Application_Links *app,
|
||||||
int32_t skip_sub_errors, int32_t dir, Jump_Location *loc){
|
Partition *part,
|
||||||
|
View_Summary *view,
|
||||||
|
int32_t skip_sub_errors,
|
||||||
|
int32_t direction,
|
||||||
|
int32_t *line_out,
|
||||||
|
int32_t *colon_index_out,
|
||||||
|
Name_Based_Jump_Location *location_out){
|
||||||
int32_t result = false;
|
int32_t result = false;
|
||||||
|
|
||||||
Jump_Location location = {0};
|
Name_Based_Jump_Location location = {0};
|
||||||
Buffer_Summary buffer = app->get_buffer_by_name(app, literal("*compilation*"), AccessAll);
|
int32_t line = view->cursor.line;
|
||||||
if (buffer.exists){
|
int32_t colon_index = 0;
|
||||||
View_Summary view = get_first_view_with_buffer(app, buffer.buffer_id);
|
if (seek_next_jump_in_buffer(app, part, view->buffer_id,
|
||||||
int32_t line = view.cursor.line;
|
line+direction, skip_sub_errors, direction,
|
||||||
|
&line, &colon_index, &location)){
|
||||||
int32_t colon_char = 0;
|
result = true;
|
||||||
if (next_error(app, part, &view, &line, &location,
|
*line_out = line;
|
||||||
skip_sub_errors, dir, &colon_char)){
|
*colon_index_out = colon_index;
|
||||||
|
*location_out = location;
|
||||||
View_Summary active_view = app->get_active_view(app, AccessAll);
|
|
||||||
if (active_view.view_id == view.view_id){
|
|
||||||
exec_command(app, change_active_panel_regular);
|
|
||||||
active_view = app->get_active_view(app, AccessAll);
|
|
||||||
}
|
|
||||||
|
|
||||||
jump_to_location(app, &active_view, &location);
|
|
||||||
app->view_set_cursor(app, &view, seek_line_char(line, colon_char+1), true);
|
|
||||||
result = true;
|
|
||||||
if (loc){
|
|
||||||
*loc = location;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int32_t
|
static int32_t
|
||||||
skip_this_jump(Prev_Jump prev, Prev_Jump jump){
|
skip_this_jump(ID_Based_Jump_Location prev, ID_Based_Jump_Location jump){
|
||||||
int32_t result = false;
|
int32_t result = false;
|
||||||
if (prev.buffer_id != 0 && prev.buffer_id == jump.buffer_id &&
|
if (prev.buffer_id != 0 &&
|
||||||
prev.line == jump.line){
|
prev.buffer_id == jump.buffer_id &&
|
||||||
|
prev.line == jump.line &&
|
||||||
|
prev.column <= jump.column){
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ID_Based_Jump_Location prev_location = {0};
|
||||||
|
|
||||||
static int32_t
|
static int32_t
|
||||||
seek_error_skip_repeats(Application_Links *app, Partition *part,
|
advance_cursor_in_jump_view(Application_Links *app,
|
||||||
int32_t skip_sub_error, int32_t dir){
|
Partition *part,
|
||||||
|
View_Summary *view,
|
||||||
|
int32_t skip_repeats,
|
||||||
|
int32_t skip_sub_error,
|
||||||
|
int32_t direction,
|
||||||
|
Name_Based_Jump_Location *location_out){
|
||||||
int32_t result = true;
|
int32_t result = true;
|
||||||
Jump_Location location = {0};
|
|
||||||
Prev_Jump jump = {0};
|
Name_Based_Jump_Location location = {0};
|
||||||
|
ID_Based_Jump_Location jump = {0};
|
||||||
|
int32_t line = 0, colon_index = 0;
|
||||||
|
|
||||||
do{
|
do{
|
||||||
Temp_Memory temp = begin_temp_memory(part);
|
Temp_Memory temp = begin_temp_memory(part);
|
||||||
if (seek_error_internal(app, part, skip_sub_error, dir, &location)){
|
if (seek_next_jump_in_view(app, part, view,
|
||||||
jump = jump_location_store(app, location);
|
skip_sub_error, direction,
|
||||||
|
&line, &colon_index, &location)){
|
||||||
|
jump = convert_name_based_to_id_based(app, location);
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -311,68 +322,121 @@ seek_error_skip_repeats(Application_Links *app, Partition *part,
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
end_temp_memory(temp);
|
end_temp_memory(temp);
|
||||||
}while(skip_this_jump(prev_location, jump));
|
}while(skip_repeats && skip_this_jump(prev_location, jump));
|
||||||
|
|
||||||
|
if (result){
|
||||||
|
*location_out = location;
|
||||||
|
app->view_set_cursor(app, view, seek_line_char(line, colon_index+1), true);
|
||||||
|
}
|
||||||
|
|
||||||
prev_location = jump;
|
prev_location = jump;
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t
|
static char locked_buffer_space[256];
|
||||||
seek_error_no_skip(Application_Links *app, Partition *part,
|
static String locked_buffer = make_fixed_width_string(locked_buffer_space);
|
||||||
int32_t skip_sub_error, int32_t dir){
|
|
||||||
int32_t result = true;
|
static void
|
||||||
Jump_Location location = {0};
|
unlock_jump_buffer(){
|
||||||
Prev_Jump jump = {0};
|
locked_buffer.size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
lock_jump_buffer(char *name, int32_t size){
|
||||||
|
copy(&locked_buffer, make_string(name, size));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
lock_jump_buffer(Buffer_Summary buffer){
|
||||||
|
copy(&locked_buffer, make_string(buffer.buffer_name, buffer.buffer_name_len));
|
||||||
|
}
|
||||||
|
|
||||||
|
static View_Summary
|
||||||
|
get_view_for_locked_jump_buffer(Application_Links *app){
|
||||||
|
View_Summary view = {0};
|
||||||
|
|
||||||
Temp_Memory temp = begin_temp_memory(part);
|
if (locked_buffer.size > 0){
|
||||||
if (seek_error_internal(app, part, skip_sub_error, dir, &location)){
|
Buffer_Summary buffer = app->get_buffer_by_name(app, locked_buffer.str, locked_buffer.size, AccessAll);
|
||||||
jump = jump_location_store(app, location);
|
if (buffer.exists){
|
||||||
result = true;
|
view = get_first_view_with_buffer(app, buffer.buffer_id);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
unlock_jump_buffer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
end_temp_memory(temp);
|
|
||||||
|
|
||||||
prev_location = jump;
|
return(view);
|
||||||
return(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t
|
static int32_t
|
||||||
seek_error(Application_Links *app, Partition *part,
|
seek_error(Application_Links *app,
|
||||||
int32_t skip_sub_error, int32_t skip_same_line, int32_t dir){
|
Partition *part,
|
||||||
if (skip_same_line){
|
int32_t skip_repeats,
|
||||||
seek_error_skip_repeats(app, part, skip_sub_error, dir);
|
int32_t skip_sub_errors,
|
||||||
}
|
int32_t direction){
|
||||||
else{
|
int32_t result = 0;
|
||||||
seek_error_no_skip(app, part, skip_sub_error, dir);
|
|
||||||
|
View_Summary view = get_view_for_locked_jump_buffer(app);
|
||||||
|
if (view.exists){
|
||||||
|
|
||||||
|
Name_Based_Jump_Location location = {0};
|
||||||
|
if (advance_cursor_in_jump_view(app, &global_part, &view,
|
||||||
|
skip_repeats, skip_sub_errors, direction,
|
||||||
|
&location)){
|
||||||
|
View_Summary active_view = app->get_active_view(app, AccessAll);
|
||||||
|
if (active_view.view_id == view.view_id){
|
||||||
|
exec_command(app, change_active_panel_regular);
|
||||||
|
active_view = app->get_active_view(app, AccessAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
jump_to_location(app, &active_view, &location);
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(goto_next_error){
|
CUSTOM_COMMAND_SIG(goto_next_error){
|
||||||
seek_error_skip_repeats(app, &global_part, true, 1);
|
int32_t skip_repeats = true;
|
||||||
|
int32_t skip_sub_errors = true;
|
||||||
|
int32_t dir = 1;
|
||||||
|
seek_error(app, &global_part, skip_repeats, skip_sub_errors, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(goto_prev_error){
|
CUSTOM_COMMAND_SIG(goto_prev_error){
|
||||||
seek_error_skip_repeats(app, &global_part, true, -1);
|
int32_t skip_repeats = true;
|
||||||
|
int32_t skip_sub_errors = true;
|
||||||
|
int32_t dir = -1;
|
||||||
|
seek_error(app, &global_part, skip_repeats, skip_sub_errors, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(goto_next_error_no_skips){
|
CUSTOM_COMMAND_SIG(goto_next_error_no_skips){
|
||||||
seek_error_no_skip(app, &global_part, true, 1);
|
int32_t skip_repeats = false;
|
||||||
|
int32_t skip_sub_errors = true;
|
||||||
|
int32_t dir = 1;
|
||||||
|
seek_error(app, &global_part, skip_repeats, skip_sub_errors, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(goto_prev_error_no_skips){
|
CUSTOM_COMMAND_SIG(goto_prev_error_no_skips){
|
||||||
seek_error_no_skip(app, &global_part, true, -1);
|
int32_t skip_repeats = false;
|
||||||
|
int32_t skip_sub_errors = true;
|
||||||
|
int32_t dir = -1;
|
||||||
|
seek_error(app, &global_part, skip_repeats, skip_sub_errors, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(goto_first_error){
|
CUSTOM_COMMAND_SIG(goto_first_error){
|
||||||
Temp_Memory temp = begin_temp_memory(&global_part);
|
Temp_Memory temp = begin_temp_memory(&global_part);
|
||||||
View_Summary active_view = app->get_active_view(app, AccessAll);
|
|
||||||
app->view_set_cursor(app, &active_view, seek_pos(0), true);
|
|
||||||
|
|
||||||
Jump_Location location = {0};
|
View_Summary view = get_view_for_locked_jump_buffer(app);
|
||||||
prev_location = null_location;
|
if (view.exists){
|
||||||
seek_error_internal(app, &global_part, true, 1, &location);
|
app->view_set_cursor(app, &view, seek_pos(0), true);
|
||||||
prev_location = jump_location_store(app, location);
|
|
||||||
|
prev_location = null_location;
|
||||||
|
seek_error(app, &global_part, false, true, 1);
|
||||||
|
}
|
||||||
end_temp_memory(temp);
|
end_temp_memory(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,9 +93,9 @@ ENUM(uint64_t, Command_ID){
|
||||||
/* DOC(TODO) */
|
/* DOC(TODO) */
|
||||||
FLAGENUM(Memory_Protect_Flags){
|
FLAGENUM(Memory_Protect_Flags){
|
||||||
/* DOC(TODO) */
|
/* DOC(TODO) */
|
||||||
MemProtect_Read = 0x1,
|
MemProtect_Read = 0x1,
|
||||||
/* DOC(TODO) */
|
/* DOC(TODO) */
|
||||||
MemProtect_Write = 0x2,
|
MemProtect_Write = 0x2,
|
||||||
/* DOC(TODO) */
|
/* DOC(TODO) */
|
||||||
MemProtect_Execute = 0x4,
|
MemProtect_Execute = 0x4,
|
||||||
};
|
};
|
||||||
|
@ -189,6 +189,9 @@ FLAGENUM(Buffer_Create_Flag){
|
||||||
/* DOC(When BufferCreate_AlwaysNew is set it indicates the buffer should be
|
/* DOC(When BufferCreate_AlwaysNew is set it indicates the buffer should be
|
||||||
cleared to empty even if it's associated file already has content.) */
|
cleared to empty even if it's associated file already has content.) */
|
||||||
BufferCreate_AlwaysNew = 0x2,
|
BufferCreate_AlwaysNew = 0x2,
|
||||||
|
/* DOC(When BufferCreate_NeverNew is set it indicates that the buffer should
|
||||||
|
only be created if it is an existing file or an open buffer.) */
|
||||||
|
BufferCreate_NeverNew = 0x4,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* DOC(A Buffer_Kill_Flag field specifies how a buffer should be killed.) */
|
/* DOC(A Buffer_Kill_Flag field specifies how a buffer should be killed.) */
|
||||||
|
|
|
@ -1046,7 +1046,7 @@ DOC_SEE(Buffer_Create_Flag)
|
||||||
|
|
||||||
system->load_close(handle);
|
system->load_close(handle);
|
||||||
}
|
}
|
||||||
else{
|
else if (!(flags & BufferCreate_NeverNew)){
|
||||||
file = working_set_alloc_always(working_set, general);
|
file = working_set_alloc_always(working_set, general);
|
||||||
if (file){
|
if (file){
|
||||||
buffer_bind_name(general, working_set, file, fname);
|
buffer_bind_name(general, working_set, file, fname);
|
||||||
|
|
6
TODO.txt
6
TODO.txt
|
@ -83,13 +83,16 @@
|
||||||
|
|
||||||
; BEFORE I SHIP
|
; BEFORE I SHIP
|
||||||
;
|
;
|
||||||
|
; [X] flag in create buffer to prevent making new files
|
||||||
|
; [X] full screen option
|
||||||
|
; [] add to APIs
|
||||||
|
;
|
||||||
; [] tokens in the custom API
|
; [] tokens in the custom API
|
||||||
; [] auto indent on the custom side
|
; [] auto indent on the custom side
|
||||||
; [] expose dirty flags
|
; [] expose dirty flags
|
||||||
; [] option to not open *messages* every startup
|
; [] option to not open *messages* every startup
|
||||||
; [] command for resizing panels
|
; [] command for resizing panels
|
||||||
; [] control over how mouse effects panel focus
|
; [] control over how mouse effects panel focus
|
||||||
; [] full screen option
|
|
||||||
; [] API docs as text file
|
; [] API docs as text file
|
||||||
; [] user file bar string
|
; [] user file bar string
|
||||||
; [] mouse down/up distinction
|
; [] mouse down/up distinction
|
||||||
|
@ -98,7 +101,6 @@
|
||||||
; [] read only files
|
; [] read only files
|
||||||
; [] break down the build system and get away from the preproc hack
|
; [] break down the build system and get away from the preproc hack
|
||||||
; [] locking to a view for next position jumping
|
; [] locking to a view for next position jumping
|
||||||
; [] flag in create buffer to prevent making new files
|
|
||||||
;
|
;
|
||||||
|
|
||||||
; TODOS
|
; TODOS
|
||||||
|
|
10
build.c
10
build.c
|
@ -1,7 +1,5 @@
|
||||||
/*
|
/*
|
||||||
|
|
||||||
4coder development build rule.
|
4coder development build rule.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TOP
|
// TOP
|
||||||
|
@ -266,7 +264,7 @@ buildsuper(char *code_path, char *out_path, char *filename){
|
||||||
|
|
||||||
static void
|
static void
|
||||||
standard_build(char *cdir, uint32_t flags){
|
standard_build(char *cdir, uint32_t flags){
|
||||||
#if 1
|
#if 0
|
||||||
{
|
{
|
||||||
BEGIN_TIME_SECTION();
|
BEGIN_TIME_SECTION();
|
||||||
build(OPTS, cdir, "fsm_table_generator.cpp",
|
build(OPTS, cdir, "fsm_table_generator.cpp",
|
||||||
|
@ -281,7 +279,7 @@ standard_build(char *cdir, uint32_t flags){
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 1
|
#if 0
|
||||||
{
|
{
|
||||||
BEGIN_TIME_SECTION();
|
BEGIN_TIME_SECTION();
|
||||||
build(OPTS | DEBUG_INFO, cdir, "4ed_metagen.cpp",
|
build(OPTS | DEBUG_INFO, cdir, "4ed_metagen.cpp",
|
||||||
|
@ -294,7 +292,9 @@ standard_build(char *cdir, uint32_t flags){
|
||||||
execute(cdir, META_DIR"/metagen");
|
execute(cdir, META_DIR"/metagen");
|
||||||
END_TIME_SECTION("run metagen");
|
END_TIME_SECTION("run metagen");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1
|
||||||
{
|
{
|
||||||
BEGIN_TIME_SECTION();
|
BEGIN_TIME_SECTION();
|
||||||
//buildsuper(cdir, BUILD_DIR, "../code/4coder_default_bindings.cpp");
|
//buildsuper(cdir, BUILD_DIR, "../code/4coder_default_bindings.cpp");
|
||||||
|
@ -303,7 +303,9 @@ standard_build(char *cdir, uint32_t flags){
|
||||||
//buildsuper(cdir, BUILD_DIR, "../4vim/4coder_chronal.cpp");
|
//buildsuper(cdir, BUILD_DIR, "../4vim/4coder_chronal.cpp");
|
||||||
END_TIME_SECTION("build custom");
|
END_TIME_SECTION("build custom");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
{
|
{
|
||||||
BEGIN_TIME_SECTION();
|
BEGIN_TIME_SECTION();
|
||||||
build(OPTS | INCLUDES | SHARED_CODE | flags, cdir, "4ed_app_target.cpp",
|
build(OPTS | INCLUDES | SHARED_CODE | flags, cdir, "4ed_app_target.cpp",
|
||||||
|
|
|
@ -128,11 +128,14 @@
|
||||||
#include "4coder_default_include.cpp"
|
#include "4coder_default_include.cpp"
|
||||||
#include "4coder_jump_parsing.cpp"
|
#include "4coder_jump_parsing.cpp"
|
||||||
|
|
||||||
#ifndef Assert
|
#if !defined(Assert)
|
||||||
#define internal static
|
|
||||||
#define Assert assert
|
#define Assert assert
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(internal)
|
||||||
|
#define internal static
|
||||||
|
#endif
|
||||||
|
|
||||||
struct Parsed_Error
|
struct Parsed_Error
|
||||||
{
|
{
|
||||||
int exists;
|
int exists;
|
||||||
|
@ -514,7 +517,7 @@ SwitchToOrLoadFile(struct Application_Links *app, String FileName, bool CreateIf
|
||||||
{
|
{
|
||||||
// NOTE(allen): This opens the file and puts it in &view
|
// NOTE(allen): This opens the file and puts it in &view
|
||||||
// This returns false if the open fails.
|
// This returns false if the open fails.
|
||||||
view_open_file(app, &view, expand_str(FileName), false);
|
view_open_file(app, &view, FileName.str, FileName.size, true);
|
||||||
|
|
||||||
Result.buffer = app->get_buffer_by_name(app, FileName.str, FileName.size, access);
|
Result.buffer = app->get_buffer_by_name(app, FileName.str, FileName.size, access);
|
||||||
|
|
||||||
|
@ -1122,8 +1125,8 @@ OpenProject(Application_Links *app, char *ProjectFileName)
|
||||||
// was originally, so that new appends overwrite old ones.
|
// was originally, so that new appends overwrite old ones.
|
||||||
dir.size = dir_size;
|
dir.size = dir_size;
|
||||||
append(&dir, info->filename);
|
append(&dir, info->filename);
|
||||||
|
|
||||||
view_open_file(app, 0, dir.str, dir.size, true);
|
open_file(app, 0, dir.str, dir.size, true, true);
|
||||||
++TotalOpenAttempts;
|
++TotalOpenAttempts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,11 +184,11 @@ CUSTOM_COMMAND_SIG(multi_line_edit){
|
||||||
// TODO(allen): Both of these brace related commands would work better
|
// TODO(allen): Both of these brace related commands would work better
|
||||||
// if the API exposed access to the tokens in a code file.
|
// if the API exposed access to the tokens in a code file.
|
||||||
CUSTOM_COMMAND_SIG(mark_matching_brace){
|
CUSTOM_COMMAND_SIG(mark_matching_brace){
|
||||||
unsigned int access = AccessProtected;
|
uint32_t access = AccessProtected;
|
||||||
View_Summary view = app->get_active_view(app, access);
|
View_Summary view = app->get_active_view(app, access);
|
||||||
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
|
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
|
||||||
|
|
||||||
int start_pos = view.cursor.pos;
|
int32_t start_pos = view.cursor.pos;
|
||||||
|
|
||||||
// NOTE(allen): The user provides the memory that the chunk uses,
|
// NOTE(allen): The user provides the memory that the chunk uses,
|
||||||
// this chunk will then be filled at each step of the text stream loop.
|
// this chunk will then be filled at each step of the text stream loop.
|
||||||
|
@ -197,12 +197,12 @@ CUSTOM_COMMAND_SIG(mark_matching_brace){
|
||||||
Stream_Chunk chunk;
|
Stream_Chunk chunk;
|
||||||
char chunk_space[(1 << 10)];
|
char chunk_space[(1 << 10)];
|
||||||
|
|
||||||
int result = 0;
|
int32_t result = 0;
|
||||||
int found_result = 0;
|
int32_t found_result = 0;
|
||||||
|
|
||||||
int i = start_pos;
|
int32_t i = start_pos;
|
||||||
int still_looping = 1;
|
int32_t still_looping = 1;
|
||||||
int nesting_counter = 0;
|
int32_t nesting_counter = 0;
|
||||||
char at_cursor = 0;
|
char at_cursor = 0;
|
||||||
|
|
||||||
if (init_stream_chunk(&chunk, app, &buffer, i,
|
if (init_stream_chunk(&chunk, app, &buffer, i,
|
||||||
|
@ -404,8 +404,8 @@ get_bindings(void *data, int size){
|
||||||
end_map(context);
|
end_map(context);
|
||||||
|
|
||||||
begin_map(context, my_code_map);
|
begin_map(context, my_code_map);
|
||||||
bind(context, '/', MDFR_ALT, mark_matching_brace);
|
bind(context, ']', MDFR_ALT, mark_matching_brace);
|
||||||
bind(context, '\'', MDFR_ALT, cursor_to_surrounding_scope);
|
bind(context, '[', MDFR_ALT, cursor_to_surrounding_scope);
|
||||||
end_map(context);
|
end_map(context);
|
||||||
|
|
||||||
BIND_4CODER_TESTS(context);
|
BIND_4CODER_TESTS(context);
|
||||||
|
|
111
win32_4ed.cpp
111
win32_4ed.cpp
|
@ -139,22 +139,23 @@ struct Win32_Input_Chunk_Persistent{
|
||||||
b8 control_keys[MDFR_INDEX_COUNT];
|
b8 control_keys[MDFR_INDEX_COUNT];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Win32_Input_Chunk{
|
typedef struct Win32_Input_Chunk{
|
||||||
Win32_Input_Chunk_Transient trans;
|
Win32_Input_Chunk_Transient trans;
|
||||||
Win32_Input_Chunk_Persistent pers;
|
Win32_Input_Chunk_Persistent pers;
|
||||||
};
|
} Win32_Input_Chunk;
|
||||||
|
|
||||||
struct Win32_Coroutine{
|
typedef struct Win32_Coroutine{
|
||||||
Coroutine coroutine;
|
Coroutine coroutine;
|
||||||
Win32_Coroutine *next;
|
Win32_Coroutine *next;
|
||||||
i32 done;
|
i32 done;
|
||||||
};
|
} Win32_Coroutine;
|
||||||
|
|
||||||
#if FRED_INTERNAL
|
#if FRED_INTERNAL
|
||||||
struct Sys_Bubble : public Bubble{
|
struct Sys_Bubble : public Bubble{
|
||||||
i32 line_number;
|
i32 line_number;
|
||||||
char *file_name;
|
char *file_name;
|
||||||
};
|
};
|
||||||
|
typedef struct Sys_Bubble Sys_Bubble;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum CV_ID{
|
enum CV_ID{
|
||||||
|
@ -169,12 +170,12 @@ enum CV_ID{
|
||||||
CV_COUNT
|
CV_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Drive_Strings{
|
typedef struct Drive_Strings{
|
||||||
char *prefix_[26];
|
char *prefix_[26];
|
||||||
char **prefix;
|
char **prefix;
|
||||||
};
|
} Drive_Strings;
|
||||||
|
|
||||||
struct Win32_Vars{
|
typedef struct Win32_Vars{
|
||||||
System_Functions system;
|
System_Functions system;
|
||||||
App_Functions app;
|
App_Functions app;
|
||||||
Custom_API custom_api;
|
Custom_API custom_api;
|
||||||
|
@ -223,7 +224,7 @@ struct Win32_Vars{
|
||||||
CRITICAL_SECTION DEBUG_sysmem_lock;
|
CRITICAL_SECTION DEBUG_sysmem_lock;
|
||||||
Sys_Bubble internal_bubble;
|
Sys_Bubble internal_bubble;
|
||||||
#endif
|
#endif
|
||||||
};
|
} Win32_Vars;
|
||||||
|
|
||||||
globalvar Win32_Vars win32vars;
|
globalvar Win32_Vars win32vars;
|
||||||
globalvar Application_Memory memory_vars;
|
globalvar Application_Memory memory_vars;
|
||||||
|
@ -271,7 +272,6 @@ internal
|
||||||
Sys_Get_Memory_Sig(system_get_memory_){
|
Sys_Get_Memory_Sig(system_get_memory_){
|
||||||
void *ptr = 0;
|
void *ptr = 0;
|
||||||
if (size > 0){
|
if (size > 0){
|
||||||
|
|
||||||
#if FRED_INTERNAL
|
#if FRED_INTERNAL
|
||||||
ptr = VirtualAlloc(0, size + sizeof(Sys_Bubble), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
ptr = VirtualAlloc(0, size + sizeof(Sys_Bubble), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||||
Sys_Bubble *bubble = (Sys_Bubble*)ptr;
|
Sys_Bubble *bubble = (Sys_Bubble*)ptr;
|
||||||
|
@ -289,6 +289,7 @@ Sys_Get_Memory_Sig(system_get_memory_){
|
||||||
}
|
}
|
||||||
return(ptr);
|
return(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal
|
internal
|
||||||
Sys_Free_Memory_Sig(system_free_memory){
|
Sys_Free_Memory_Sig(system_free_memory){
|
||||||
if (block){
|
if (block){
|
||||||
|
@ -1510,6 +1511,69 @@ Win32Resize(i32 width, i32 height){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
NOTE(casey): This follows Raymond Chen's prescription
|
||||||
|
for fullscreen toggling, see:
|
||||||
|
http://blogs.msdn.com/b/oldnewthing/archive/2010/04/12/9994016.aspx
|
||||||
|
*/
|
||||||
|
|
||||||
|
static b32 full_screen = 0;
|
||||||
|
static WINDOWPLACEMENT GlobalWindowPosition = {sizeof(GlobalWindowPosition)};
|
||||||
|
|
||||||
|
internal void
|
||||||
|
Win32ToggleFullscreen(void){
|
||||||
|
HWND Window = win32vars.window_handle;
|
||||||
|
LONG_PTR Style = GetWindowLongPtr(Window, GWL_STYLE);
|
||||||
|
if (Style & WS_OVERLAPPEDWINDOW){
|
||||||
|
MONITORINFO MonitorInfo = {sizeof(MonitorInfo)};
|
||||||
|
if(GetWindowPlacement(Window, &GlobalWindowPosition) &&
|
||||||
|
GetMonitorInfo(MonitorFromWindow(Window, MONITOR_DEFAULTTOPRIMARY), &MonitorInfo))
|
||||||
|
{
|
||||||
|
SetWindowLongPtr(Window, GWL_STYLE, Style & ~WS_OVERLAPPEDWINDOW);
|
||||||
|
SetWindowPos(Window, HWND_TOP,
|
||||||
|
MonitorInfo.rcMonitor.left, MonitorInfo.rcMonitor.top,
|
||||||
|
MonitorInfo.rcMonitor.right - MonitorInfo.rcMonitor.left,
|
||||||
|
MonitorInfo.rcMonitor.bottom - MonitorInfo.rcMonitor.top,
|
||||||
|
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||||
|
full_screen = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
SetWindowLongPtr(Window, GWL_STYLE, Style | WS_OVERLAPPEDWINDOW);
|
||||||
|
SetWindowPlacement(Window, &GlobalWindowPosition);
|
||||||
|
SetWindowPos(Window, 0, 0, 0, 0, 0,
|
||||||
|
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
|
||||||
|
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||||
|
full_screen = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void
|
||||||
|
Win32FixFullscreenLoseFocus(b32 lose_focus){
|
||||||
|
if (full_screen){
|
||||||
|
|
||||||
|
HWND Window = win32vars.window_handle;
|
||||||
|
LONG_PTR Style = GetWindowLongPtr(Window, GWL_STYLE);
|
||||||
|
|
||||||
|
MONITORINFO MonitorInfo = {sizeof(MonitorInfo)};
|
||||||
|
if(GetMonitorInfo(MonitorFromWindow(Window, MONITOR_DEFAULTTOPRIMARY), &MonitorInfo))
|
||||||
|
{
|
||||||
|
if (lose_focus){
|
||||||
|
SetWindowLongPtr(Window, GWL_STYLE, Style | WS_OVERLAPPEDWINDOW);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
SetWindowLongPtr(Window, GWL_STYLE, Style & ~WS_OVERLAPPEDWINDOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
SetWindowPos(Window, HWND_TOP,
|
||||||
|
MonitorInfo.rcMonitor.left, MonitorInfo.rcMonitor.top,
|
||||||
|
MonitorInfo.rcMonitor.right - MonitorInfo.rcMonitor.left,
|
||||||
|
MonitorInfo.rcMonitor.bottom - MonitorInfo.rcMonitor.top,
|
||||||
|
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
Win32SetCursorFromUpdate(Application_Mouse_Cursor cursor){
|
Win32SetCursorFromUpdate(Application_Mouse_Cursor cursor){
|
||||||
switch (cursor){
|
switch (cursor){
|
||||||
|
@ -1542,6 +1606,7 @@ Win32HighResolutionTime(){
|
||||||
internal LRESULT
|
internal LRESULT
|
||||||
Win32Callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
|
Win32Callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
|
||||||
LRESULT result = 0;
|
LRESULT result = 0;
|
||||||
|
|
||||||
switch (uMsg){
|
switch (uMsg){
|
||||||
case WM_MENUCHAR:
|
case WM_MENUCHAR:
|
||||||
case WM_SYSCHAR:break;
|
case WM_SYSCHAR:break;
|
||||||
|
@ -1792,9 +1857,11 @@ Win32Callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
|
||||||
win32vars.input_chunk.pers.mouse_l = 0;
|
win32vars.input_chunk.pers.mouse_l = 0;
|
||||||
win32vars.input_chunk.pers.mouse_r = 0;
|
win32vars.input_chunk.pers.mouse_r = 0;
|
||||||
|
|
||||||
b8 *control_keys = win32vars.input_chunk.pers.control_keys;
|
|
||||||
for (i32 i = 0; i < MDFR_INDEX_COUNT; ++i) control_keys[i] = 0;
|
|
||||||
win32vars.input_chunk.pers.controls = control_keys_zero();
|
win32vars.input_chunk.pers.controls = control_keys_zero();
|
||||||
|
|
||||||
|
if (uMsg == WM_SETFOCUS){
|
||||||
|
Win32FixFullscreenLoseFocus(false);
|
||||||
|
}
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
|
@ -1828,11 +1895,18 @@ Win32Callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
|
||||||
win32vars.got_useful_event = 1;
|
win32vars.got_useful_event = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WM_CANCELMODE:
|
||||||
|
{
|
||||||
|
Win32FixFullscreenLoseFocus(true);
|
||||||
|
result = DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||||
|
}break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
result = DefWindowProc(hwnd, uMsg, wParam, lParam);
|
result = DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2071,7 +2145,7 @@ WinMain(HINSTANCE hInstance,
|
||||||
win32vars.custom_api.view_routine = (View_Routine_Function*)view_routine;
|
win32vars.custom_api.view_routine = (View_Routine_Function*)view_routine;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Window and GL Initialization
|
// Window and GL Initialization
|
||||||
|
@ -2105,20 +2179,15 @@ WinMain(HINSTANCE hInstance,
|
||||||
|
|
||||||
#define WINDOW_NAME "4coder-window: " VERSION
|
#define WINDOW_NAME "4coder-window: " VERSION
|
||||||
|
|
||||||
i32 window_x;
|
i32 window_x = CW_USEDEFAULT;
|
||||||
i32 window_y;
|
i32 window_y = CW_USEDEFAULT;
|
||||||
i32 window_style;
|
|
||||||
|
|
||||||
if (win32vars.settings.set_window_pos){
|
if (win32vars.settings.set_window_pos){
|
||||||
window_x = win32vars.settings.window_x;
|
window_x = win32vars.settings.window_x;
|
||||||
window_y = win32vars.settings.window_y;
|
window_y = win32vars.settings.window_y;
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
window_x = CW_USEDEFAULT;
|
|
||||||
window_y = CW_USEDEFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
window_style = WS_OVERLAPPEDWINDOW | WS_VISIBLE;
|
i32 window_style = WS_OVERLAPPEDWINDOW;
|
||||||
if (win32vars.settings.maximize_window){
|
if (win32vars.settings.maximize_window){
|
||||||
window_style |= WS_MAXIMIZE;
|
window_style |= WS_MAXIMIZE;
|
||||||
}
|
}
|
||||||
|
@ -2238,7 +2307,6 @@ WinMain(HINSTANCE hInstance,
|
||||||
win32vars.count_per_usecond = 1;
|
win32vars.count_per_usecond = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Main Loop
|
// Main Loop
|
||||||
//
|
//
|
||||||
|
@ -2259,6 +2327,7 @@ WinMain(HINSTANCE hInstance,
|
||||||
|
|
||||||
SetForegroundWindow(win32vars.window_handle);
|
SetForegroundWindow(win32vars.window_handle);
|
||||||
SetActiveWindow(win32vars.window_handle);
|
SetActiveWindow(win32vars.window_handle);
|
||||||
|
ShowWindow(win32vars.window_handle, SW_SHOW);
|
||||||
|
|
||||||
u64 timer_start = Win32HighResolutionTime();
|
u64 timer_start = Win32HighResolutionTime();
|
||||||
system_acquire_lock(FRAME_LOCK);
|
system_acquire_lock(FRAME_LOCK);
|
||||||
|
|
Loading…
Reference in New Issue