made win32 C++98
This commit is contained in:
parent
56d716dde4
commit
399b7aaa23
210
4coder_custom.h
210
4coder_custom.h
|
@ -367,218 +367,8 @@ extern "C"{
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Application_Links;
|
struct Application_Links;
|
||||||
|
|
||||||
#include "4coder_custom_api.h"
|
#include "4coder_custom_api.h"
|
||||||
|
|
||||||
#if 0
|
|
||||||
// Command exectuion
|
|
||||||
#define PUSH_PARAMETER_SIG(n) void n(Application_Links *app, Dynamic param, Dynamic value)
|
|
||||||
#define PUSH_MEMORY_SIG(n) char* n(Application_Links *app, int len)
|
|
||||||
#define EXECUTE_COMMAND_SIG(n) void n(Application_Links *app, int command_id)
|
|
||||||
#define CLEAR_PARAMETERS_SIG(n) void n(Application_Links *app)
|
|
||||||
|
|
||||||
// File system navigation
|
|
||||||
#define DIRECTORY_GET_HOT_SIG(n) int n(Application_Links *app, char *out, int capacity)
|
|
||||||
#define GET_4ED_PATH_SIG(n) int n(Application_Links *app, char *out, int capacity)
|
|
||||||
#define FILE_EXISTS_SIG(n) int n(Application_Links *app, char *filename, int len)
|
|
||||||
#define DIRECTORY_CD_SIG(n) int n(Application_Links *app, char *dir, int *len, int capacity, char *rel_path, int rel_len)
|
|
||||||
#define GET_FILE_LIST_SIG(n) File_List n(Application_Links *app, char *dir, int len)
|
|
||||||
#define FREE_FILE_LIST_SIG(n) void n(Application_Links *app, File_List list)
|
|
||||||
|
|
||||||
// Direct buffer manipulation
|
|
||||||
#define GET_BUFFER_FIRST_SIG(n) Buffer_Summary n(Application_Links *app)
|
|
||||||
#define GET_BUFFER_NEXT_SIG(n) void n(Application_Links *app, Buffer_Summary *buffer)
|
|
||||||
|
|
||||||
#define GET_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, int index)
|
|
||||||
#define GET_ACTIVE_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app)
|
|
||||||
#define GET_PARAMETER_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, int param_index)
|
|
||||||
#define GET_BUFFER_BY_NAME(n) Buffer_Summary n(Application_Links *app, char *filename, int len)
|
|
||||||
|
|
||||||
// TODO(allen): Need more flexible seek system somehow. Regex? Just expose the text stream to the user?
|
|
||||||
#define BUFFER_SEEK_DELIMITER_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, char delim, int seek_forward, int *out)
|
|
||||||
#define BUFFER_SEEK_STRING_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, char *str, int len, int seek_forward, int *out)
|
|
||||||
#define BUFFER_SEEK_STRING_INSENSITIVE_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, char *str, int len, int seek_forward, int *out)
|
|
||||||
|
|
||||||
#define REFRESH_BUFFER_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer)
|
|
||||||
#define BUFFER_READ_RANGE_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *out)
|
|
||||||
#define BUFFER_REPLACE_RANGE_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *str, int len)
|
|
||||||
#define BUFFER_SET_POS_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int pos)
|
|
||||||
|
|
||||||
// File view manipulation
|
|
||||||
#define GET_VIEW_FIRST_SIG(n) View_Summary n(Application_Links *app)
|
|
||||||
#define GET_VIEW_NEXT_SIG(n) void n(Application_Links *app, View_Summary *view)
|
|
||||||
|
|
||||||
#define GET_VIEW_SIG(n) View_Summary n(Application_Links *app, int index)
|
|
||||||
#define GET_ACTIVE_VIEW_SIG(n) View_Summary n(Application_Links *app)
|
|
||||||
|
|
||||||
#define REFRESH_VIEW_SIG(n) int n(Application_Links *app, View_Summary *view)
|
|
||||||
#define VIEW_COMPUTE_CURSOR_SIG(n) Full_Cursor n(Application_Links *app, View_Summary *view, Buffer_Seek seek)
|
|
||||||
#define VIEW_SET_CURSOR_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek, int set_preferred_x)
|
|
||||||
#define VIEW_SET_MARK_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek)
|
|
||||||
#define VIEW_SET_HIGHLIGHT_SIG(n) int n(Application_Links *app, View_Summary *view, int start, int end, int turn_on)
|
|
||||||
#define VIEW_SET_BUFFER_SIG(n) int n(Application_Links *app, View_Summary *view, int buffer_id)
|
|
||||||
|
|
||||||
// Directly get user input
|
|
||||||
#define GET_USER_INPUT_SIG(n) User_Input n(Application_Links *app, unsigned int get_type, unsigned int abort_type)
|
|
||||||
#define GET_COMMAND_INPUT_SIG(n) User_Input n(Application_Links *app)
|
|
||||||
#define GET_EVENT_MESSAGE_SIG(n) Event_Message n(Application_Links *app)
|
|
||||||
|
|
||||||
// Queries and information display
|
|
||||||
#define START_QUERY_BAR_SIG(n) int n(Application_Links *app, Query_Bar *bar, unsigned int flags)
|
|
||||||
#define END_QUERY_BAR_SIG(n) void n(Application_Links *app, Query_Bar *bar, unsigned int flags)
|
|
||||||
#define PRINT_MESSAGE_SIG(n) void n(Application_Links *app, char *string, int len)
|
|
||||||
#define GET_GUI_FUNCTIONS_SIG(n) GUI_Functions* n(Application_Links *app)
|
|
||||||
#define GET_GUI_SIG(n) GUI* n(Application_Links *app, int view_id)
|
|
||||||
|
|
||||||
// Color settings
|
|
||||||
#define CHANGE_THEME_SIG(n) void n(Application_Links *app, char *name, int len)
|
|
||||||
#define CHANGE_FONT_SIG(n) void n(Application_Links *app, char *name, int len)
|
|
||||||
#define SET_THEME_COLORS_SIG(n) void n(Application_Links *app, Theme_Color *colors, int count)
|
|
||||||
|
|
||||||
extern "C"{
|
|
||||||
// Command exectuion
|
|
||||||
typedef EXECUTE_COMMAND_SIG(Exec_Command_Function);
|
|
||||||
typedef PUSH_PARAMETER_SIG(Push_Parameter_Function);
|
|
||||||
typedef PUSH_MEMORY_SIG(Push_Memory_Function);
|
|
||||||
typedef CLEAR_PARAMETERS_SIG(Clear_Parameters_Function);
|
|
||||||
|
|
||||||
// File system navigation
|
|
||||||
typedef DIRECTORY_GET_HOT_SIG(Directory_Get_Hot_Function);
|
|
||||||
typedef GET_4ED_PATH_SIG(Get_4ed_Path_Function);
|
|
||||||
typedef FILE_EXISTS_SIG(File_Exists_Function);
|
|
||||||
typedef DIRECTORY_CD_SIG(Directory_CD_Function);
|
|
||||||
typedef GET_FILE_LIST_SIG(Get_File_List_Function);
|
|
||||||
typedef FREE_FILE_LIST_SIG(Free_File_List_Function);
|
|
||||||
|
|
||||||
// Buffer manipulation
|
|
||||||
typedef GET_BUFFER_FIRST_SIG(Get_Buffer_First_Function);
|
|
||||||
typedef GET_BUFFER_NEXT_SIG(Get_Buffer_Next_Function);
|
|
||||||
|
|
||||||
typedef GET_BUFFER_SIG(Get_Buffer_Function);
|
|
||||||
typedef GET_ACTIVE_BUFFER_SIG(Get_Active_Buffer_Function);
|
|
||||||
typedef GET_PARAMETER_BUFFER_SIG(Get_Parameter_Buffer_Function);
|
|
||||||
typedef GET_BUFFER_BY_NAME(Get_Buffer_By_Name_Function);
|
|
||||||
|
|
||||||
typedef BUFFER_SEEK_DELIMITER_SIG(Buffer_Seek_Delimiter_Function);
|
|
||||||
typedef BUFFER_SEEK_STRING_SIG(Buffer_Seek_String_Function);
|
|
||||||
typedef BUFFER_SEEK_STRING_INSENSITIVE_SIG(Buffer_Seek_String_Insensitive_Function);
|
|
||||||
|
|
||||||
typedef REFRESH_BUFFER_SIG(Refresh_Buffer_Function);
|
|
||||||
typedef BUFFER_READ_RANGE_SIG(Buffer_Read_Range_Function);
|
|
||||||
typedef BUFFER_REPLACE_RANGE_SIG(Buffer_Replace_Range_Function);
|
|
||||||
typedef BUFFER_SET_POS_SIG(Buffer_Set_Pos_Function);
|
|
||||||
|
|
||||||
// View manipulation
|
|
||||||
typedef GET_VIEW_FIRST_SIG(Get_View_First_Function);
|
|
||||||
typedef GET_VIEW_NEXT_SIG(Get_View_Next_Function);
|
|
||||||
|
|
||||||
typedef GET_VIEW_SIG(Get_View_Function);
|
|
||||||
typedef GET_ACTIVE_VIEW_SIG(Get_Active_View_Function);
|
|
||||||
|
|
||||||
typedef REFRESH_VIEW_SIG(Refresh_View_Function);
|
|
||||||
typedef VIEW_COMPUTE_CURSOR_SIG(View_Compute_Cursor_Function);
|
|
||||||
typedef VIEW_SET_CURSOR_SIG(View_Set_Cursor_Function);
|
|
||||||
typedef VIEW_SET_MARK_SIG(View_Set_Mark_Function);
|
|
||||||
typedef VIEW_SET_HIGHLIGHT_SIG(View_Set_Highlight_Function);
|
|
||||||
typedef VIEW_SET_BUFFER_SIG(View_Set_Buffer_Function);
|
|
||||||
|
|
||||||
// Directly get user input
|
|
||||||
typedef GET_USER_INPUT_SIG(Get_User_Input_Function);
|
|
||||||
typedef GET_COMMAND_INPUT_SIG(Get_Command_Input_Function);
|
|
||||||
typedef GET_EVENT_MESSAGE_SIG(Get_Event_Message_Function);
|
|
||||||
|
|
||||||
// GUI
|
|
||||||
typedef START_QUERY_BAR_SIG(Start_Query_Bar_Function);
|
|
||||||
typedef END_QUERY_BAR_SIG(End_Query_Bar_Function);
|
|
||||||
typedef PRINT_MESSAGE_SIG(Print_Message_Function);
|
|
||||||
typedef GET_GUI_FUNCTIONS_SIG(Get_GUI_Functions_Function);
|
|
||||||
typedef GET_GUI_SIG(Get_GUI_Function);
|
|
||||||
|
|
||||||
// Color settings
|
|
||||||
typedef CHANGE_THEME_SIG(Change_Theme_Function);
|
|
||||||
typedef CHANGE_FONT_SIG(Change_Font_Function);
|
|
||||||
typedef SET_THEME_COLORS_SIG(Set_Theme_Colors_Function);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Application_Links{
|
|
||||||
// User data
|
|
||||||
void *memory;
|
|
||||||
int memory_size;
|
|
||||||
|
|
||||||
// Command exectuion
|
|
||||||
Exec_Command_Function *exec_command_keep_stack;
|
|
||||||
Push_Parameter_Function *push_parameter;
|
|
||||||
Push_Memory_Function *push_memory;
|
|
||||||
Clear_Parameters_Function *clear_parameters;
|
|
||||||
|
|
||||||
// File system navigation
|
|
||||||
Directory_Get_Hot_Function *directory_get_hot;
|
|
||||||
Get_4ed_Path_Function *get_4ed_path;
|
|
||||||
File_Exists_Function *file_exists;
|
|
||||||
Directory_CD_Function *directory_cd;
|
|
||||||
Get_File_List_Function *get_file_list;
|
|
||||||
Free_File_List_Function *free_file_list;
|
|
||||||
|
|
||||||
// Buffer manipulation
|
|
||||||
Get_Buffer_First_Function *get_buffer_first;
|
|
||||||
Get_Buffer_Next_Function *get_buffer_next;
|
|
||||||
|
|
||||||
Get_Buffer_Function *get_buffer;
|
|
||||||
Get_Active_Buffer_Function *get_active_buffer;
|
|
||||||
Get_Parameter_Buffer_Function *get_parameter_buffer;
|
|
||||||
Get_Buffer_By_Name_Function *get_buffer_by_name;
|
|
||||||
|
|
||||||
Buffer_Seek_Delimiter_Function *buffer_seek_delimiter;
|
|
||||||
Buffer_Seek_String_Function *buffer_seek_string;
|
|
||||||
Buffer_Seek_String_Insensitive_Function *buffer_seek_string_insensitive;
|
|
||||||
|
|
||||||
Refresh_Buffer_Function *refresh_buffer;
|
|
||||||
Buffer_Read_Range_Function *buffer_read_range;
|
|
||||||
Buffer_Replace_Range_Function *buffer_replace_range;
|
|
||||||
Buffer_Set_Pos_Function *buffer_set_pos;
|
|
||||||
|
|
||||||
// View manipulation
|
|
||||||
Get_View_First_Function *get_view_first;
|
|
||||||
Get_View_Next_Function *get_view_next;
|
|
||||||
|
|
||||||
Get_View_Function *get_view;
|
|
||||||
Get_Active_View_Function *get_active_view;
|
|
||||||
|
|
||||||
Refresh_View_Function *refresh_view;
|
|
||||||
View_Compute_Cursor_Function *view_compute_cursor;
|
|
||||||
View_Set_Cursor_Function *view_set_cursor;
|
|
||||||
View_Set_Mark_Function *view_set_mark;
|
|
||||||
View_Set_Highlight_Function *view_set_highlight;
|
|
||||||
View_Set_Buffer_Function *view_set_buffer;
|
|
||||||
|
|
||||||
// Directly get user input
|
|
||||||
Get_User_Input_Function *get_user_input;
|
|
||||||
Get_Command_Input_Function *get_command_input;
|
|
||||||
|
|
||||||
Get_Event_Message_Function *get_event_message;
|
|
||||||
|
|
||||||
// Queries
|
|
||||||
Start_Query_Bar_Function *start_query_bar;
|
|
||||||
End_Query_Bar_Function *end_query_bar;
|
|
||||||
Print_Message_Function *print_message;
|
|
||||||
|
|
||||||
Get_GUI_Functions_Function *get_gui_functions;
|
|
||||||
Get_GUI_Function *get_gui;
|
|
||||||
|
|
||||||
// Theme
|
|
||||||
Change_Theme_Function *change_theme;
|
|
||||||
Change_Font_Function *change_font;
|
|
||||||
Set_Theme_Colors_Function *set_theme_colors;
|
|
||||||
|
|
||||||
// Internal
|
|
||||||
void *cmd_context;
|
|
||||||
void *system_links;
|
|
||||||
void *current_coroutine;
|
|
||||||
int type_coroutine;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Boundry type flags
|
// Boundry type flags
|
||||||
#define BoundryWhitespace 0x1
|
#define BoundryWhitespace 0x1
|
||||||
|
|
|
@ -36,6 +36,11 @@ struct File_Data{
|
||||||
Data data;
|
Data data;
|
||||||
b32 got_file;
|
b32 got_file;
|
||||||
};
|
};
|
||||||
|
inline File_Data
|
||||||
|
file_data_zero(){
|
||||||
|
File_Data result = {0};
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
#define Sys_Get_Memory_Sig(name) void* name(i32 size, i32 line_number, char *file_name)
|
#define Sys_Get_Memory_Sig(name) void* name(i32 size, i32 line_number, char *file_name)
|
||||||
#define Sys_Free_Memory_Sig(name) void name(void *block)
|
#define Sys_Free_Memory_Sig(name) void name(void *block)
|
||||||
|
|
|
@ -77,6 +77,11 @@ struct Control_Keys{
|
||||||
b8 l_alt;
|
b8 l_alt;
|
||||||
b8 r_alt;
|
b8 r_alt;
|
||||||
};
|
};
|
||||||
|
inline Control_Keys
|
||||||
|
control_keys_zero(){
|
||||||
|
Control_Keys result = {0};
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
struct Win32_Input_Chunk_Transient{
|
struct Win32_Input_Chunk_Transient{
|
||||||
Key_Input_Data key_data;
|
Key_Input_Data key_data;
|
||||||
|
@ -88,6 +93,11 @@ struct Win32_Input_Chunk_Transient{
|
||||||
|
|
||||||
b8 trying_to_kill;
|
b8 trying_to_kill;
|
||||||
};
|
};
|
||||||
|
inline Win32_Input_Chunk_Transient
|
||||||
|
win32_input_chunk_transient_zero(){
|
||||||
|
Win32_Input_Chunk_Transient result = {0};
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
struct Win32_Input_Chunk_Persistent{
|
struct Win32_Input_Chunk_Persistent{
|
||||||
i32 mouse_x, mouse_y;
|
i32 mouse_x, mouse_y;
|
||||||
|
@ -301,7 +311,7 @@ system_load_file(char *filename){
|
||||||
|
|
||||||
if (!result.data.data){
|
if (!result.data.data){
|
||||||
CloseHandle(file);
|
CloseHandle(file);
|
||||||
result = {0};
|
result = file_data_zero();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +323,7 @@ system_load_file(char *filename){
|
||||||
if (!read_result || read_size != (u32)result.data.size){
|
if (!read_result || read_size != (u32)result.data.size){
|
||||||
CloseHandle(file);
|
CloseHandle(file);
|
||||||
Win32FreeMemory(result.data.data);
|
Win32FreeMemory(result.data.data);
|
||||||
result = {0};
|
result = file_data_zero();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1506,7 +1516,7 @@ Win32Callback(HWND hwnd, UINT uMsg,
|
||||||
|
|
||||||
b8 *control_keys = win32vars.input_chunk.pers.control_keys;
|
b8 *control_keys = win32vars.input_chunk.pers.control_keys;
|
||||||
for (int i = 0; i < MDFR_INDEX_COUNT; ++i) control_keys[i] = 0;
|
for (int i = 0; i < MDFR_INDEX_COUNT; ++i) control_keys[i] = 0;
|
||||||
win32vars.input_chunk.pers.controls = {};
|
win32vars.input_chunk.pers.controls = control_keys_zero();
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
|
@ -1600,7 +1610,7 @@ Win32Callback(HWND hwnd, UINT uMsg,
|
||||||
result = DefWindowProc(hwnd, uMsg, wParam, lParam);
|
result = DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
return result;
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
|
@ -1608,7 +1618,7 @@ UpdateStep(){
|
||||||
i64 timer_start = system_time();
|
i64 timer_start = system_time();
|
||||||
|
|
||||||
Win32_Input_Chunk input_chunk = win32vars.input_chunk;
|
Win32_Input_Chunk input_chunk = win32vars.input_chunk;
|
||||||
win32vars.input_chunk.trans = {};
|
win32vars.input_chunk.trans = win32_input_chunk_transient_zero();
|
||||||
|
|
||||||
input_chunk.pers.control_keys[MDFR_CAPS_INDEX] = GetKeyState(VK_CAPITAL) & 0x1;
|
input_chunk.pers.control_keys[MDFR_CAPS_INDEX] = GetKeyState(VK_CAPITAL) & 0x1;
|
||||||
|
|
||||||
|
@ -1623,7 +1633,7 @@ UpdateStep(){
|
||||||
input_chunk.trans.out_of_window = 1;
|
input_chunk.trans.out_of_window = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
win32vars.clipboard_contents = {};
|
win32vars.clipboard_contents = string_zero();
|
||||||
if (win32vars.clipboard_sequence != 0){
|
if (win32vars.clipboard_sequence != 0){
|
||||||
DWORD new_number = GetClipboardSequenceNumber();
|
DWORD new_number = GetClipboardSequenceNumber();
|
||||||
if (new_number != win32vars.clipboard_sequence){
|
if (new_number != win32vars.clipboard_sequence){
|
||||||
|
@ -1803,8 +1813,8 @@ int main(int argc, char **argv){
|
||||||
|
|
||||||
HANDLE original_out = GetStdHandle(STD_OUTPUT_HANDLE);
|
HANDLE original_out = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
|
||||||
win32vars = {};
|
memset(&win32vars, 0, sizeof(win32vars));
|
||||||
exchange_vars = {};
|
memset(&exchange_vars, 0, sizeof(exchange_vars));
|
||||||
|
|
||||||
#if FRED_INTERNAL
|
#if FRED_INTERNAL
|
||||||
win32vars.internal_bubble.next = &win32vars.internal_bubble;
|
win32vars.internal_bubble.next = &win32vars.internal_bubble;
|
||||||
|
@ -1965,7 +1975,7 @@ int main(int argc, char **argv){
|
||||||
thread->id = i + 1;
|
thread->id = i + 1;
|
||||||
|
|
||||||
Thread_Memory *memory = win32vars.thread_memory + i;
|
Thread_Memory *memory = win32vars.thread_memory + i;
|
||||||
*memory = {};
|
*memory = thread_memory_zero();
|
||||||
memory->id = thread->id;
|
memory->id = thread->id;
|
||||||
|
|
||||||
thread->queue = &exchange_vars.thread.queues[BACKGROUND_THREADS];
|
thread->queue = &exchange_vars.thread.queues[BACKGROUND_THREADS];
|
||||||
|
|
Loading…
Reference in New Issue