passing the command line parameters to the application
							parent
							
								
									b4d1a2205d
								
							
						
					
					
						commit
						803f486973
					
				
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
						 | 
					@ -57,7 +57,7 @@ ENUM(uint64_t, Command_ID){
 | 
				
			||||||
    cmdid_redo,
 | 
					    cmdid_redo,
 | 
				
			||||||
    /* DOC(cmdid_history_backward performs a step backwards through the file history, which includes previously lost redo branches.) */
 | 
					    /* DOC(cmdid_history_backward performs a step backwards through the file history, which includes previously lost redo branches.) */
 | 
				
			||||||
    cmdid_history_backward,
 | 
					    cmdid_history_backward,
 | 
				
			||||||
    /* DOC(cmdid_history_forward unperforms the previous cmdid_history_backward step if possib.e) */
 | 
					    /* DOC(cmdid_history_forward unperforms the previous cmdid_history_backward step if possible.) */
 | 
				
			||||||
    cmdid_history_forward,
 | 
					    cmdid_history_forward,
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    /* DOC(cmdid_interactive_new begins an interactive dialogue to create a new buffer.) */
 | 
					    /* DOC(cmdid_interactive_new begins an interactive dialogue to create a new buffer.) */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1034,7 +1034,7 @@ DOC_SEE(Cpp_Lex_Data)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
FCPP_LINK Cpp_Lex_Data
 | 
					FCPP_LINK Cpp_Lex_Data
 | 
				
			||||||
cpp_lex_data_init(char *mem_buffer)/*
 | 
					cpp_lex_data_init(char *mem_buffer)/*
 | 
				
			||||||
DOC_PARAM(tb, The memory to use for initializing the lex state's temp memory buffer.)
 | 
					DOC_PARAM(mem_buffer, The memory to use for initializing the lex state's temp memory buffer.)
 | 
				
			||||||
DOC_RETURN(A brand new lex state ready to begin lexing a file from the beginning.)
 | 
					DOC_RETURN(A brand new lex state ready to begin lexing a file from the beginning.)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DOC(Creates a new lex state in the form of a Cpp_Lex_Data struct and returns the struct.
 | 
					DOC(Creates a new lex state in the form of a Cpp_Lex_Data struct and returns the struct.
 | 
				
			||||||
| 
						 | 
					@ -1081,6 +1081,7 @@ FCPP_LINK void
 | 
				
			||||||
cpp_lex_data_new_temp(Cpp_Lex_Data *lex_data, char *new_buffer)/*
 | 
					cpp_lex_data_new_temp(Cpp_Lex_Data *lex_data, char *new_buffer)/*
 | 
				
			||||||
DOC_PARAM(lex_data, The lex state that will receive the new temporary buffer.)
 | 
					DOC_PARAM(lex_data, The lex state that will receive the new temporary buffer.)
 | 
				
			||||||
DOC_PARAM(new_buffer, The new temporary buffer that has the same contents as the old temporary buffer.)
 | 
					DOC_PARAM(new_buffer, The new temporary buffer that has the same contents as the old temporary buffer.)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DOC(This call can be used to set a new temporary buffer for the lex state.  In cases where you want to
 | 
					DOC(This call can be used to set a new temporary buffer for the lex state.  In cases where you want to
 | 
				
			||||||
discontinue lexing, store the state, and resume later. In such a situation it may be necessary for you
 | 
					discontinue lexing, store the state, and resume later. In such a situation it may be necessary for you
 | 
				
			||||||
to free the temp buffer that was originally used to make the lex state. This call allows you to supply
 | 
					to free the temp buffer that was originally used to make the lex state. This call allows you to supply
 | 
				
			||||||
| 
						 | 
					@ -1089,6 +1090,7 @@ a new temp buffer when you are ready to resume lexing.
 | 
				
			||||||
However the new buffer needs to have the same contents the old buffer had.  To ensure this you have to
 | 
					However the new buffer needs to have the same contents the old buffer had.  To ensure this you have to
 | 
				
			||||||
use cpp_lex_data_temp_size and cpp_lex_data_temp_read to get the relevant contents of the temp buffer
 | 
					use cpp_lex_data_temp_size and cpp_lex_data_temp_read to get the relevant contents of the temp buffer
 | 
				
			||||||
before you free it.)
 | 
					before you free it.)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DOC_SEE(cpp_lex_data_temp_size)
 | 
					DOC_SEE(cpp_lex_data_temp_size)
 | 
				
			||||||
DOC_SEE(cpp_lex_data_temp_read)
 | 
					DOC_SEE(cpp_lex_data_temp_read)
 | 
				
			||||||
*/{
 | 
					*/{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										257
									
								
								4ed.cpp
								
								
								
								
							
							
						
						
									
										257
									
								
								4ed.cpp
								
								
								
								
							| 
						 | 
					@ -1125,134 +1125,165 @@ enum Command_Line_Action{
 | 
				
			||||||
    CLAct_Count
 | 
					    CLAct_Count
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enum Command_Line_Mode{
 | 
				
			||||||
 | 
					    CLMode_App,
 | 
				
			||||||
 | 
					    CLMode_Custom
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
 | 
					init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
 | 
				
			||||||
                           Command_Line_Parameters clparams){
 | 
					                           Command_Line_Parameters clparams){
 | 
				
			||||||
    char *arg;
 | 
					    char *arg = 0;
 | 
				
			||||||
 | 
					    Command_Line_Mode mode = CLMode_App;
 | 
				
			||||||
    Command_Line_Action action = CLAct_Nothing;
 | 
					    Command_Line_Action action = CLAct_Nothing;
 | 
				
			||||||
    i32 i,index;
 | 
					    i32 i = 0, index = 0;
 | 
				
			||||||
    b32 strict = 0;
 | 
					    b32 strict = 0;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    settings->init_files_max = ArrayCount(settings->init_files);
 | 
					    settings->init_files_max = ArrayCount(settings->init_files);
 | 
				
			||||||
    for (i = 1; i <= clparams.argc; ++i){
 | 
					    for (i = 1; i <= clparams.argc; ++i){
 | 
				
			||||||
        if (i == clparams.argc) arg = "";
 | 
					        if (i == clparams.argc){
 | 
				
			||||||
        else arg = clparams.argv[i];
 | 
					            arg = "";
 | 
				
			||||||
        switch (action){
 | 
					        }
 | 
				
			||||||
            case CLAct_Nothing:
 | 
					        else{
 | 
				
			||||||
 | 
					            arg = clparams.argv[i];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (arg[0] == '-' && arg[1] == '-'){
 | 
				
			||||||
 | 
					            char *long_arg_name = arg+2;
 | 
				
			||||||
 | 
					            if (match_cc(long_arg_name, "custom")){
 | 
				
			||||||
 | 
					                mode = CLMode_Custom;
 | 
				
			||||||
 | 
					                settings->custom_arg_start = i+1;
 | 
				
			||||||
 | 
					                settings->custom_arg_end = i+1;
 | 
				
			||||||
 | 
					                continue;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        switch (mode){
 | 
				
			||||||
 | 
					            case CLMode_App:
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (arg[0] == '-'){
 | 
					                switch (action){
 | 
				
			||||||
                    action = CLAct_Ignore;
 | 
					                    case CLAct_Nothing:
 | 
				
			||||||
                    switch (arg[1]){
 | 
					                    {
 | 
				
			||||||
                        case 'u': action = CLAct_UserFile; strict = false;      break;
 | 
					                        if (arg[0] == '-'){
 | 
				
			||||||
                        case 'U': action = CLAct_UserFile; strict = true;       break;
 | 
					                            action = CLAct_Ignore;
 | 
				
			||||||
                        
 | 
					                            switch (arg[1]){
 | 
				
			||||||
                        case 'd': action = CLAct_CustomDLL; strict = false;     break;
 | 
					                                case 'u': action = CLAct_UserFile; strict = false;      break;
 | 
				
			||||||
                        case 'D': action = CLAct_CustomDLL; strict = true;      break;
 | 
					                                case 'U': action = CLAct_UserFile; strict = true;       break;
 | 
				
			||||||
                        
 | 
					                                
 | 
				
			||||||
                        case 'i': action = CLAct_InitialFilePosition;           break;
 | 
					                                case 'd': action = CLAct_CustomDLL; strict = false;     break;
 | 
				
			||||||
                        
 | 
					                                case 'D': action = CLAct_CustomDLL; strict = true;      break;
 | 
				
			||||||
                        case 'w': action = CLAct_WindowSize;                    break;
 | 
					                                
 | 
				
			||||||
                        case 'W': action = CLAct_WindowMaximize;                break;
 | 
					                                case 'i': action = CLAct_InitialFilePosition;           break;
 | 
				
			||||||
                        case 'p': action = CLAct_WindowPosition;                break;
 | 
					                                
 | 
				
			||||||
                        case 'F': action = CLAct_WindowFullscreen;              break;
 | 
					                                case 'w': action = CLAct_WindowSize;                    break;
 | 
				
			||||||
                        case 'S': action = CLAct_WindowStreamMode;              break;
 | 
					                                case 'W': action = CLAct_WindowMaximize;                break;
 | 
				
			||||||
                        
 | 
					                                case 'p': action = CLAct_WindowPosition;                break;
 | 
				
			||||||
                        case 'f': action = CLAct_FontSize;                      break;
 | 
					                                case 'F': action = CLAct_WindowFullscreen;              break;
 | 
				
			||||||
                        case 'h': action = CLAct_FontStopHinting; --i;          break;
 | 
					                                case 'S': action = CLAct_WindowStreamMode;              break;
 | 
				
			||||||
                    }
 | 
					                                
 | 
				
			||||||
                }
 | 
					                                case 'f': action = CLAct_FontSize;                      break;
 | 
				
			||||||
                else if (arg[0] != 0){
 | 
					                                case 'h': action = CLAct_FontStopHinting; --i;          break;
 | 
				
			||||||
                    if (settings->init_files_count < settings->init_files_max){
 | 
					                            }
 | 
				
			||||||
                        index = settings->init_files_count++;
 | 
					                        }
 | 
				
			||||||
                        settings->init_files[index] = arg;
 | 
					                        else if (arg[0] != 0){
 | 
				
			||||||
                    }
 | 
					                            if (settings->init_files_count < settings->init_files_max){
 | 
				
			||||||
                }
 | 
					                                index = settings->init_files_count++;
 | 
				
			||||||
            }break;
 | 
					                                settings->init_files[index] = arg;
 | 
				
			||||||
            
 | 
					                            }
 | 
				
			||||||
            case CLAct_UserFile:
 | 
					                        }
 | 
				
			||||||
            {
 | 
					                    }break;
 | 
				
			||||||
                settings->user_file_is_strict = strict;
 | 
					 | 
				
			||||||
                if (i < clparams.argc){
 | 
					 | 
				
			||||||
                    settings->user_file = clparams.argv[i];
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                action = CLAct_Nothing;
 | 
					 | 
				
			||||||
            }break;
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            case CLAct_CustomDLL:
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                plat_settings->custom_dll_is_strict = strict;
 | 
					 | 
				
			||||||
                if (i < clparams.argc){
 | 
					 | 
				
			||||||
                    plat_settings->custom_dll = clparams.argv[i];
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                action = CLAct_Nothing;
 | 
					 | 
				
			||||||
            }break;
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            case CLAct_InitialFilePosition:
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (i < clparams.argc){
 | 
					 | 
				
			||||||
                    settings->initial_line = str_to_int_c(clparams.argv[i]);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                action = CLAct_Nothing;
 | 
					 | 
				
			||||||
            }break;
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            case CLAct_WindowSize:
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (i + 1 < clparams.argc){
 | 
					 | 
				
			||||||
                    plat_settings->set_window_size  = true;
 | 
					 | 
				
			||||||
                    plat_settings->window_w = str_to_int_c(clparams.argv[i]);
 | 
					 | 
				
			||||||
                    plat_settings->window_h = str_to_int_c(clparams.argv[i+1]);
 | 
					 | 
				
			||||||
                    
 | 
					                    
 | 
				
			||||||
                    ++i;
 | 
					                    case CLAct_UserFile:
 | 
				
			||||||
                }
 | 
					                    {
 | 
				
			||||||
                action = CLAct_Nothing;
 | 
					                        settings->user_file_is_strict = strict;
 | 
				
			||||||
            }break;
 | 
					                        if (i < clparams.argc){
 | 
				
			||||||
            
 | 
					                            settings->user_file = clparams.argv[i];
 | 
				
			||||||
            case CLAct_WindowMaximize:
 | 
					                        }
 | 
				
			||||||
            {
 | 
					                        action = CLAct_Nothing;
 | 
				
			||||||
                --i;
 | 
					                    }break;
 | 
				
			||||||
                plat_settings->maximize_window = true;
 | 
					 | 
				
			||||||
                action = CLAct_Nothing;
 | 
					 | 
				
			||||||
            }break;
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            case CLAct_WindowPosition:
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (i + 1 < clparams.argc){
 | 
					 | 
				
			||||||
                    plat_settings->set_window_pos  = true;
 | 
					 | 
				
			||||||
                    plat_settings->window_x = str_to_int_c(clparams.argv[i]);
 | 
					 | 
				
			||||||
                    plat_settings->window_y = str_to_int_c(clparams.argv[i+1]);
 | 
					 | 
				
			||||||
                    
 | 
					                    
 | 
				
			||||||
                    ++i;
 | 
					                    case CLAct_CustomDLL:
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        plat_settings->custom_dll_is_strict = strict;
 | 
				
			||||||
 | 
					                        if (i < clparams.argc){
 | 
				
			||||||
 | 
					                            plat_settings->custom_dll = clparams.argv[i];
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        action = CLAct_Nothing;
 | 
				
			||||||
 | 
					                    }break;
 | 
				
			||||||
 | 
					                    
 | 
				
			||||||
 | 
					                    case CLAct_InitialFilePosition:
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (i < clparams.argc){
 | 
				
			||||||
 | 
					                            settings->initial_line = str_to_int_c(clparams.argv[i]);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        action = CLAct_Nothing;
 | 
				
			||||||
 | 
					                    }break;
 | 
				
			||||||
 | 
					                    
 | 
				
			||||||
 | 
					                    case CLAct_WindowSize:
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (i + 1 < clparams.argc){
 | 
				
			||||||
 | 
					                            plat_settings->set_window_size  = true;
 | 
				
			||||||
 | 
					                            plat_settings->window_w = str_to_int_c(clparams.argv[i]);
 | 
				
			||||||
 | 
					                            plat_settings->window_h = str_to_int_c(clparams.argv[i+1]);
 | 
				
			||||||
 | 
					                            
 | 
				
			||||||
 | 
					                            ++i;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        action = CLAct_Nothing;
 | 
				
			||||||
 | 
					                    }break;
 | 
				
			||||||
 | 
					                    
 | 
				
			||||||
 | 
					                    case CLAct_WindowMaximize:
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        --i;
 | 
				
			||||||
 | 
					                        plat_settings->maximize_window = true;
 | 
				
			||||||
 | 
					                        action = CLAct_Nothing;
 | 
				
			||||||
 | 
					                    }break;
 | 
				
			||||||
 | 
					                    
 | 
				
			||||||
 | 
					                    case CLAct_WindowPosition:
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (i + 1 < clparams.argc){
 | 
				
			||||||
 | 
					                            plat_settings->set_window_pos  = true;
 | 
				
			||||||
 | 
					                            plat_settings->window_x = str_to_int_c(clparams.argv[i]);
 | 
				
			||||||
 | 
					                            plat_settings->window_y = str_to_int_c(clparams.argv[i+1]);
 | 
				
			||||||
 | 
					                            
 | 
				
			||||||
 | 
					                            ++i;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        action = CLAct_Nothing;
 | 
				
			||||||
 | 
					                    }break;
 | 
				
			||||||
 | 
					                    
 | 
				
			||||||
 | 
					                    case CLAct_WindowFullscreen:
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        --i;
 | 
				
			||||||
 | 
					                        plat_settings->fullscreen_window = true;
 | 
				
			||||||
 | 
					                        plat_settings->stream_mode = true;
 | 
				
			||||||
 | 
					                        action = CLAct_Nothing;
 | 
				
			||||||
 | 
					                    }break;
 | 
				
			||||||
 | 
					                    
 | 
				
			||||||
 | 
					                    case CLAct_WindowStreamMode:
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        --i;
 | 
				
			||||||
 | 
					                        plat_settings->stream_mode = true;
 | 
				
			||||||
 | 
					                        action = CLAct_Nothing;
 | 
				
			||||||
 | 
					                    }break;
 | 
				
			||||||
 | 
					                    
 | 
				
			||||||
 | 
					                    case CLAct_FontSize:
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (i < clparams.argc){
 | 
				
			||||||
 | 
					                            settings->font_size = str_to_int_c(clparams.argv[i]);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        action = CLAct_Nothing;
 | 
				
			||||||
 | 
					                    }break;
 | 
				
			||||||
 | 
					                    
 | 
				
			||||||
 | 
					                    case CLAct_FontStopHinting:
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        plat_settings->use_hinting = true;
 | 
				
			||||||
 | 
					                        action = CLAct_Nothing;
 | 
				
			||||||
 | 
					                    }break;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                action = CLAct_Nothing;
 | 
					 | 
				
			||||||
            }break;
 | 
					            }break;
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            case CLAct_WindowFullscreen:
 | 
					            case CLMode_Custom:
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                --i;
 | 
					                settings->custom_arg_end = i+1;
 | 
				
			||||||
                plat_settings->fullscreen_window = true;
 | 
					 | 
				
			||||||
                plat_settings->stream_mode = true;
 | 
					 | 
				
			||||||
                action = CLAct_Nothing;
 | 
					 | 
				
			||||||
            }break;
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            case CLAct_WindowStreamMode:
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                --i;
 | 
					 | 
				
			||||||
                plat_settings->stream_mode = true;
 | 
					 | 
				
			||||||
                action = CLAct_Nothing;
 | 
					 | 
				
			||||||
            }break;
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            case CLAct_FontSize:
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (i < clparams.argc){
 | 
					 | 
				
			||||||
                    settings->font_size = str_to_int_c(clparams.argv[i]);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                action = CLAct_Nothing;
 | 
					 | 
				
			||||||
            }break;
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            case CLAct_FontStopHinting:
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                plat_settings->use_hinting = true;
 | 
					 | 
				
			||||||
                action = CLAct_Nothing;
 | 
					 | 
				
			||||||
            }break;
 | 
					            }break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										13
									
								
								4ed.h
								
								
								
								
							
							
						
						
									
										13
									
								
								4ed.h
								
								
								
								
							| 
						 | 
					@ -121,12 +121,13 @@ struct Application_Step_Input{
 | 
				
			||||||
    String clipboard;
 | 
					    String clipboard;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define App_Step_Sig(name) void                        \
 | 
					#define App_Step_Sig(name) void      \
 | 
				
			||||||
name(System_Functions *system,                         \
 | 
					name(System_Functions *system,       \
 | 
				
			||||||
    Render_Target *target,                             \
 | 
					    Render_Target *target,           \
 | 
				
			||||||
    Application_Memory *memory,                        \
 | 
					    Application_Memory *memory,      \
 | 
				
			||||||
    Application_Step_Input *input,                     \
 | 
					    Application_Step_Input *input,   \
 | 
				
			||||||
    Application_Step_Result *result)
 | 
					    Application_Step_Result *result, \
 | 
				
			||||||
 | 
					    Command_Line_Parameters params)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef App_Step_Sig(App_Step);
 | 
					typedef App_Step_Sig(App_Step);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -657,6 +657,7 @@ DOC_SEE(Partial_Cursor)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
API_EXPORT bool32
 | 
					API_EXPORT bool32
 | 
				
			||||||
Buffer_Batch_Edit(Application_Links *app, Buffer_Summary *buffer, char *str, int32_t str_len, Buffer_Edit *edits, int32_t edit_count, Buffer_Batch_Edit_Type type)/*
 | 
					Buffer_Batch_Edit(Application_Links *app, Buffer_Summary *buffer, char *str, int32_t str_len, Buffer_Edit *edits, int32_t edit_count, Buffer_Batch_Edit_Type type)/*
 | 
				
			||||||
 | 
					DOC_PARAM(buffer, The buffer on which to apply the batch of edits.)
 | 
				
			||||||
DOC_PARAM(str, This parameter provides all of the source string for the edits in the batch.)
 | 
					DOC_PARAM(str, This parameter provides all of the source string for the edits in the batch.)
 | 
				
			||||||
DOC_PARAM(str_len, This parameter specifies the length of the str string.)
 | 
					DOC_PARAM(str_len, This parameter specifies the length of the str string.)
 | 
				
			||||||
DOC_PARAM(edits, This parameter provides about the source string and destination range of each edit as an array.)
 | 
					DOC_PARAM(edits, This parameter provides about the source string and destination range of each edit as an array.)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,6 +21,9 @@ struct App_Settings{
 | 
				
			||||||
    b32 lctrl_lalt_is_altgr;
 | 
					    b32 lctrl_lalt_is_altgr;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    i32 font_size;
 | 
					    i32 font_size;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    i32 custom_arg_start;
 | 
				
			||||||
 | 
					    i32 custom_arg_end;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct Debug_Input_Event{
 | 
					struct Debug_Input_Event{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2970,9 +2970,9 @@ generate_custom_headers(){
 | 
				
			||||||
                  "<body>"
 | 
					                  "<body>"
 | 
				
			||||||
                  "<div style='font-family:Arial; margin: 0 auto; "
 | 
					                  "<div style='font-family:Arial; margin: 0 auto; "
 | 
				
			||||||
                  "width: 800px; text-align: justify; line-height: 1.25;'>"
 | 
					                  "width: 800px; text-align: justify; line-height: 1.25;'>"
 | 
				
			||||||
                  "<h1 style='margin-top: 5mm; margin-bottom: 5mm;'>4cpp Lexing Library</h1>");
 | 
					//                  "<h1 style='margin-top: 5mm; margin-bottom: 5mm;'>4cpp Lexing Library</h1>");
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
//                "<h1 style='margin-top: 5mm; margin-bottom: 5mm;'>4coder API</h1>");
 | 
					                  "<h1 style='margin-top: 5mm; margin-bottom: 5mm;'>4coder API</h1>");
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        struct Section{
 | 
					        struct Section{
 | 
				
			||||||
            char *id_string;
 | 
					            char *id_string;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										7
									
								
								TODO.txt
								
								
								
								
							
							
						
						
									
										7
									
								
								TODO.txt
								
								
								
								
							| 
						 | 
					@ -163,7 +163,12 @@
 | 
				
			||||||
; [] the "main_4coder" experiment
 | 
					; [] the "main_4coder" experiment
 | 
				
			||||||
; [] multi-line editing
 | 
					; [] multi-line editing
 | 
				
			||||||
; [] multi-cursor editing
 | 
					; [] multi-cursor editing
 | 
				
			||||||
;
 | 
					
 | 
				
			||||||
 | 
					; [] API docs have duplicate ids?
 | 
				
			||||||
 | 
					; [] introduce custom command line arguments
 | 
				
			||||||
 | 
					; [] control the file opening/start hook relationship better
 | 
				
			||||||
 | 
					; [] flag for hiding the *messages* buffer.
 | 
				
			||||||
 | 
					; [] get keyboard state on launch
 | 
				
			||||||
 | 
					
 | 
				
			||||||
; buffer behavior cleanup
 | 
					; buffer behavior cleanup
 | 
				
			||||||
;    [] show all characters as \# if they can't be rendered
 | 
					;    [] show all characters as \# if they can't be rendered
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,341 +1,355 @@
 | 
				
			||||||
/* 
 | 
					/* 
 | 
				
			||||||
 * Mr. 4th Dimention - Allen Webster
 | 
					 * Mr. 4th Dimention - Allen Webster
 | 
				
			||||||
 *  Four Tech
 | 
					 *  Four Tech
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * public domain -- no warranty is offered or implied; use this code at your own risk
 | 
					 * public domain -- no warranty is offered or implied; use this code at your own risk
 | 
				
			||||||
 * 
 | 
					 * 
 | 
				
			||||||
 * 23.10.2015
 | 
					 * 23.10.2015
 | 
				
			||||||
 * 
 | 
					 * 
 | 
				
			||||||
 * Buffer data object
 | 
					 * Buffer data object
 | 
				
			||||||
 *  type - Gap Buffer
 | 
					 *  type - Gap Buffer
 | 
				
			||||||
 * 
 | 
					 * 
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TOP
 | 
					// TOP
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct Gap_Buffer{
 | 
					typedef struct Gap_Buffer{
 | 
				
			||||||
    char *data;
 | 
					    char *data;
 | 
				
			||||||
    int size1, gap_size, size2, max;
 | 
					    int size1;
 | 
				
			||||||
    
 | 
					    int gap_size;
 | 
				
			||||||
    float *line_widths;
 | 
					    int size2;
 | 
				
			||||||
    int *line_starts;
 | 
					    int max;
 | 
				
			||||||
    int line_count;
 | 
					    
 | 
				
			||||||
    int widths_count;
 | 
					    float *line_widths;
 | 
				
			||||||
    int line_max;
 | 
					    int *line_starts;
 | 
				
			||||||
    int widths_max;
 | 
					    int line_count;
 | 
				
			||||||
} Gap_Buffer;
 | 
					    int widths_count;
 | 
				
			||||||
 | 
					    int line_max;
 | 
				
			||||||
inline_4tech int
 | 
					    int widths_max;
 | 
				
			||||||
buffer_good(Gap_Buffer *buffer){
 | 
					} Gap_Buffer;
 | 
				
			||||||
    int good;
 | 
					
 | 
				
			||||||
    good = (buffer->data != 0);
 | 
					inline_4tech int
 | 
				
			||||||
    return(good);
 | 
					buffer_good(Gap_Buffer *buffer){
 | 
				
			||||||
}
 | 
					    int good = (buffer->data != 0);
 | 
				
			||||||
 | 
					    return(good);
 | 
				
			||||||
inline_4tech int
 | 
					}
 | 
				
			||||||
buffer_size(Gap_Buffer *buffer){
 | 
					
 | 
				
			||||||
    int size;
 | 
					inline_4tech int
 | 
				
			||||||
    size = buffer->size1 + buffer->size2;
 | 
					buffer_size(Gap_Buffer *buffer){
 | 
				
			||||||
    return(size);
 | 
					    int size = buffer->size1 + buffer->size2;
 | 
				
			||||||
}
 | 
					    return(size);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
typedef struct Gap_Buffer_Init{
 | 
					
 | 
				
			||||||
    Gap_Buffer *buffer;
 | 
					typedef struct Gap_Buffer_Init{
 | 
				
			||||||
    char *data;
 | 
					    Gap_Buffer *buffer;
 | 
				
			||||||
    int size;
 | 
					    char *data;
 | 
				
			||||||
} Gap_Buffer_Init;
 | 
					    int size;
 | 
				
			||||||
 | 
					} Gap_Buffer_Init;
 | 
				
			||||||
internal_4tech Gap_Buffer_Init
 | 
					
 | 
				
			||||||
buffer_begin_init(Gap_Buffer *buffer, char *data, int size){
 | 
					internal_4tech Gap_Buffer_Init
 | 
				
			||||||
    Gap_Buffer_Init init;
 | 
					buffer_begin_init(Gap_Buffer *buffer, char *data, int size){
 | 
				
			||||||
    init.buffer = buffer;
 | 
					    Gap_Buffer_Init init;
 | 
				
			||||||
    init.data = data;
 | 
					    init.buffer = buffer;
 | 
				
			||||||
    init.size = size;
 | 
					    init.data = data;
 | 
				
			||||||
    return(init);
 | 
					    init.size = size;
 | 
				
			||||||
}
 | 
					    return(init);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
internal_4tech int
 | 
					
 | 
				
			||||||
buffer_init_need_more(Gap_Buffer_Init *init){
 | 
					internal_4tech int
 | 
				
			||||||
    int result;
 | 
					buffer_init_need_more(Gap_Buffer_Init *init){
 | 
				
			||||||
    result = 1;
 | 
					    int result = 1;
 | 
				
			||||||
    if (init->buffer->data) result = 0;
 | 
					    if (init->buffer->data) result = 0;
 | 
				
			||||||
    return(result);
 | 
					    return(result);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
internal_4tech int
 | 
					internal_4tech int
 | 
				
			||||||
buffer_init_page_size(Gap_Buffer_Init *init){
 | 
					buffer_init_page_size(Gap_Buffer_Init *init){
 | 
				
			||||||
    int result;
 | 
					    int result = init->size * 2;
 | 
				
			||||||
    result = init->size * 2;
 | 
					    return(result);
 | 
				
			||||||
    return(result);
 | 
					}
 | 
				
			||||||
}
 | 
					
 | 
				
			||||||
 | 
					internal_4tech void
 | 
				
			||||||
internal_4tech void
 | 
					buffer_init_provide_page(Gap_Buffer_Init *init, void *page, int page_size){
 | 
				
			||||||
buffer_init_provide_page(Gap_Buffer_Init *init, void *page, int page_size){
 | 
					    Gap_Buffer *buffer = init->buffer;
 | 
				
			||||||
    Gap_Buffer *buffer;
 | 
					    buffer->data = (char*)page;
 | 
				
			||||||
    buffer = init->buffer;
 | 
					    buffer->max = page_size;
 | 
				
			||||||
    buffer->data = (char*)page;
 | 
					}
 | 
				
			||||||
    buffer->max = page_size;
 | 
					
 | 
				
			||||||
}
 | 
					internal_4tech int
 | 
				
			||||||
 | 
					buffer_end_init(Gap_Buffer_Init *init, void *scratch, int scratch_size){
 | 
				
			||||||
internal_4tech int
 | 
					    Gap_Buffer *buffer = init->buffer;
 | 
				
			||||||
buffer_end_init(Gap_Buffer_Init *init, void *scratch, int scratch_size){
 | 
					    int osize1 = 0, size1 = 0, size2 = 0, size = init->size;
 | 
				
			||||||
    Gap_Buffer *buffer;
 | 
					    int result = 0;
 | 
				
			||||||
    int osize1, size1, size2, size;
 | 
					    
 | 
				
			||||||
    int result;
 | 
					    if (buffer->data){
 | 
				
			||||||
 | 
					        if (buffer->max >= init->size){
 | 
				
			||||||
    result = 0;
 | 
					            size2 = size >> 1;
 | 
				
			||||||
    buffer = init->buffer;
 | 
					            size1 = osize1 = size - size2;
 | 
				
			||||||
    size = init->size;
 | 
					            
 | 
				
			||||||
    if (buffer->data){
 | 
					            if (size1 > 0){
 | 
				
			||||||
        if (buffer->max >= init->size){
 | 
					                size1 = eol_convert_in(buffer->data, init->data, size1);
 | 
				
			||||||
            size2 = size >> 1;
 | 
					                if (size2 > 0){
 | 
				
			||||||
            size1 = osize1 = size - size2;
 | 
					                    size2 = eol_convert_in(buffer->data + size1, init->data + osize1, size2);
 | 
				
			||||||
            
 | 
					                }
 | 
				
			||||||
            if (size1 > 0){
 | 
					            }
 | 
				
			||||||
                size1 = eol_convert_in(buffer->data, init->data, size1);
 | 
					            
 | 
				
			||||||
                if (size2 > 0){
 | 
					            buffer->size1 = size1;
 | 
				
			||||||
                    size2 = eol_convert_in(buffer->data + size1, init->data + osize1, size2);
 | 
					            buffer->size2 = size2;
 | 
				
			||||||
                }
 | 
					            buffer->gap_size = buffer->max - size1 - size2;
 | 
				
			||||||
            }
 | 
					            memmove_4tech(buffer->data + size1 + buffer->gap_size, buffer->data + size1, size2);
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            buffer->size1 = size1;
 | 
					            result = 1;
 | 
				
			||||||
            buffer->size2 = size2;
 | 
					        }
 | 
				
			||||||
            buffer->gap_size = buffer->max - size1 - size2;
 | 
					    }
 | 
				
			||||||
            memmove_4tech(buffer->data + size1 + buffer->gap_size, buffer->data + size1, size2);
 | 
					    
 | 
				
			||||||
            
 | 
					    return(result);
 | 
				
			||||||
            result = 1;
 | 
					}
 | 
				
			||||||
        }
 | 
					
 | 
				
			||||||
    }
 | 
					typedef struct Gap_Buffer_Stringify_Loop{
 | 
				
			||||||
    
 | 
					    Gap_Buffer *buffer;
 | 
				
			||||||
    return(result);
 | 
					    char *data, *base;
 | 
				
			||||||
}
 | 
					    int absolute_pos;
 | 
				
			||||||
 | 
					    int pos, end;
 | 
				
			||||||
typedef struct Gap_Buffer_Stringify_Loop{
 | 
					    int size;
 | 
				
			||||||
    Gap_Buffer *buffer;
 | 
					    int separated;
 | 
				
			||||||
    char *data, *base;
 | 
					} Gap_Buffer_Stringify_Loop;
 | 
				
			||||||
    int absolute_pos;
 | 
					
 | 
				
			||||||
    int pos, end;
 | 
					internal_4tech Gap_Buffer_Stringify_Loop
 | 
				
			||||||
    int size;
 | 
					buffer_stringify_loop(Gap_Buffer *buffer, int start, int end){
 | 
				
			||||||
    int separated;
 | 
					    Gap_Buffer_Stringify_Loop result = {0};
 | 
				
			||||||
} Gap_Buffer_Stringify_Loop;
 | 
					    
 | 
				
			||||||
 | 
					    if (0 <= start && start < end && end <= buffer->size1 + buffer->size2){
 | 
				
			||||||
internal_4tech Gap_Buffer_Stringify_Loop
 | 
					        result.buffer = buffer;
 | 
				
			||||||
buffer_stringify_loop(Gap_Buffer *buffer, int start, int end){
 | 
					        result.base = buffer->data;
 | 
				
			||||||
    Gap_Buffer_Stringify_Loop result;
 | 
					        result.absolute_pos = start;
 | 
				
			||||||
    if (0 <= start && start < end && end <= buffer->size1 + buffer->size2){
 | 
					        
 | 
				
			||||||
        result.buffer = buffer;
 | 
					        if (end <= buffer->size1){
 | 
				
			||||||
        result.base = buffer->data;
 | 
					            result.end = end;
 | 
				
			||||||
        result.absolute_pos = start;
 | 
					        }
 | 
				
			||||||
        
 | 
					        else{
 | 
				
			||||||
        if (end <= buffer->size1) result.end = end;
 | 
					            result.end = end + buffer->gap_size;
 | 
				
			||||||
        else result.end = end + buffer->gap_size;
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        if (start < buffer->size1){
 | 
					        if (start < buffer->size1){
 | 
				
			||||||
            if (end <= buffer->size1) result.separated = 0;
 | 
					            if (end <= buffer->size1){
 | 
				
			||||||
            else result.separated = 1;
 | 
					                result.separated = 0;
 | 
				
			||||||
            result.pos = start;
 | 
					            }
 | 
				
			||||||
        }
 | 
					            else{
 | 
				
			||||||
        else{
 | 
					                result.separated = 1;
 | 
				
			||||||
            result.separated = 0;
 | 
					            }
 | 
				
			||||||
            result.pos = start + buffer->gap_size;
 | 
					            result.pos = start;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (result.separated) result.size = buffer->size1 - start;
 | 
					        else{
 | 
				
			||||||
        else result.size = end - start;
 | 
					            result.separated = 0;
 | 
				
			||||||
        result.data = buffer->data + result.pos;
 | 
					            result.pos = start + buffer->gap_size;
 | 
				
			||||||
    }
 | 
					        }
 | 
				
			||||||
    else result.buffer = 0;
 | 
					        
 | 
				
			||||||
    return(result);
 | 
					        if (result.separated){
 | 
				
			||||||
}
 | 
					            result.size = buffer->size1 - start;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
inline_4tech int
 | 
					        else{
 | 
				
			||||||
buffer_stringify_good(Gap_Buffer_Stringify_Loop *loop){
 | 
					            result.size = end - start;
 | 
				
			||||||
    int result;
 | 
					        }
 | 
				
			||||||
    result = (loop->buffer != 0);
 | 
					        
 | 
				
			||||||
    return(result);
 | 
					        result.data = buffer->data + result.pos;
 | 
				
			||||||
}
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
internal_4tech void
 | 
					    return(result);
 | 
				
			||||||
buffer_stringify_next(Gap_Buffer_Stringify_Loop *loop){
 | 
					}
 | 
				
			||||||
    int size1, temp_end;
 | 
					
 | 
				
			||||||
    if (loop->separated){
 | 
					inline_4tech int
 | 
				
			||||||
        loop->separated = 0;
 | 
					buffer_stringify_good(Gap_Buffer_Stringify_Loop *loop){
 | 
				
			||||||
        size1 = loop->buffer->size1;
 | 
					    int result = (loop->buffer != 0);
 | 
				
			||||||
        loop->pos = loop->buffer->gap_size + size1;
 | 
					    return(result);
 | 
				
			||||||
        loop->absolute_pos = size1;
 | 
					}
 | 
				
			||||||
        temp_end = loop->end;
 | 
					
 | 
				
			||||||
    }
 | 
					internal_4tech void
 | 
				
			||||||
    else{
 | 
					buffer_stringify_next(Gap_Buffer_Stringify_Loop *loop){
 | 
				
			||||||
        loop->buffer = 0;
 | 
					    int size1 = 0, temp_end = 0;
 | 
				
			||||||
        temp_end = loop->pos;
 | 
					    if (loop->separated){
 | 
				
			||||||
    }
 | 
					        loop->separated = 0;
 | 
				
			||||||
    loop->size = temp_end - loop->pos;
 | 
					        size1 = loop->buffer->size1;
 | 
				
			||||||
    loop->data = loop->base + loop->pos;
 | 
					        loop->pos = loop->buffer->gap_size + size1;
 | 
				
			||||||
}
 | 
					        loop->absolute_pos = size1;
 | 
				
			||||||
 | 
					        temp_end = loop->end;
 | 
				
			||||||
typedef struct Gap_Buffer_Backify_Loop{
 | 
					    }
 | 
				
			||||||
    Gap_Buffer *buffer;
 | 
					    else{
 | 
				
			||||||
    char *data, *base;
 | 
					        loop->buffer = 0;
 | 
				
			||||||
    int pos, end;
 | 
					        temp_end = loop->pos;
 | 
				
			||||||
    int size;
 | 
					    }
 | 
				
			||||||
    int absolute_pos;
 | 
					    loop->size = temp_end - loop->pos;
 | 
				
			||||||
    int separated;
 | 
					    loop->data = loop->base + loop->pos;
 | 
				
			||||||
} Gap_Buffer_Backify_Loop;
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
internal_4tech Gap_Buffer_Backify_Loop
 | 
					typedef struct Gap_Buffer_Backify_Loop{
 | 
				
			||||||
buffer_backify_loop(Gap_Buffer *buffer, int start, int end){
 | 
					    Gap_Buffer *buffer;
 | 
				
			||||||
    Gap_Buffer_Backify_Loop result;
 | 
					    char *data, *base;
 | 
				
			||||||
    
 | 
					    int pos, end;
 | 
				
			||||||
    ++start;
 | 
					    int size;
 | 
				
			||||||
    if (0 <= end && end < start && start <= buffer->size1 + buffer->size2){
 | 
					    int absolute_pos;
 | 
				
			||||||
        result.buffer = buffer;
 | 
					    int separated;
 | 
				
			||||||
        result.base = buffer->data;
 | 
					} Gap_Buffer_Backify_Loop;
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        if (end < buffer->size1) result.end = end;
 | 
					internal_4tech Gap_Buffer_Backify_Loop
 | 
				
			||||||
        else result.end = end + buffer->gap_size;
 | 
					buffer_backify_loop(Gap_Buffer *buffer, int start, int end){
 | 
				
			||||||
        
 | 
					    Gap_Buffer_Backify_Loop result = {0};
 | 
				
			||||||
        if (start <= buffer->size1){
 | 
					    
 | 
				
			||||||
            result.separated = 0;
 | 
					    ++start;
 | 
				
			||||||
            result.pos = 0;
 | 
					    if (0 <= end && end < start && start <= buffer->size1 + buffer->size2){
 | 
				
			||||||
        }
 | 
					        result.buffer = buffer;
 | 
				
			||||||
        else{
 | 
					        result.base = buffer->data;
 | 
				
			||||||
            if (end < buffer->size1) result.separated = 1;
 | 
					        
 | 
				
			||||||
            else result.separated = 0;
 | 
					        if (end < buffer->size1){
 | 
				
			||||||
            result.pos = buffer->size1 + buffer->gap_size;
 | 
					            result.end = end;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (!result.separated && result.pos < result.end) result.pos = result.end;
 | 
					        else{
 | 
				
			||||||
        result.size = start - result.pos;
 | 
					            result.end = end + buffer->gap_size;
 | 
				
			||||||
        result.absolute_pos = result.pos;
 | 
					        }
 | 
				
			||||||
        if (result.absolute_pos > buffer->size1) result.absolute_pos -= buffer->gap_size;
 | 
					        
 | 
				
			||||||
        result.data = result.base + result.pos;
 | 
					        if (start <= buffer->size1){
 | 
				
			||||||
    }
 | 
					            result.separated = 0;
 | 
				
			||||||
    else result.buffer = 0;
 | 
					            result.pos = 0;
 | 
				
			||||||
    return(result);
 | 
					        }
 | 
				
			||||||
}
 | 
					        else{
 | 
				
			||||||
 | 
					            if (end < buffer->size1){
 | 
				
			||||||
inline_4tech int
 | 
					                result.separated = 1;
 | 
				
			||||||
buffer_backify_good(Gap_Buffer_Backify_Loop *loop){
 | 
					            }
 | 
				
			||||||
    int result;
 | 
					            else{
 | 
				
			||||||
    result = (loop->buffer != 0);
 | 
					                result.separated = 0;
 | 
				
			||||||
    return(result);
 | 
					            }
 | 
				
			||||||
}
 | 
					            result.pos = buffer->size1 + buffer->gap_size;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
internal_4tech void
 | 
					        
 | 
				
			||||||
buffer_backify_next(Gap_Buffer_Backify_Loop *loop){
 | 
					        if (!result.separated && result.pos < result.end){
 | 
				
			||||||
    Gap_Buffer *buffer;
 | 
					            result.pos = result.end;
 | 
				
			||||||
    int temp_end;
 | 
					        }
 | 
				
			||||||
    int chunk2_start;
 | 
					        
 | 
				
			||||||
    buffer = loop->buffer;
 | 
					        result.size = start - result.pos;
 | 
				
			||||||
    chunk2_start = buffer->size1 + buffer->gap_size;
 | 
					        result.absolute_pos = result.pos;
 | 
				
			||||||
    if (loop->separated){
 | 
					        if (result.absolute_pos > buffer->size1){
 | 
				
			||||||
        loop->separated = 0;
 | 
					            result.absolute_pos -= buffer->gap_size;
 | 
				
			||||||
        temp_end = buffer->size1;
 | 
					        }
 | 
				
			||||||
        loop->pos = 0;
 | 
					        result.data = result.base + result.pos;
 | 
				
			||||||
        loop->absolute_pos = 0;
 | 
					    }
 | 
				
			||||||
        if (loop->pos < loop->end){
 | 
					    
 | 
				
			||||||
            loop->absolute_pos = loop->end;
 | 
					    return(result);
 | 
				
			||||||
            loop->pos = loop->end;
 | 
					}
 | 
				
			||||||
        }
 | 
					
 | 
				
			||||||
    }
 | 
					inline_4tech int
 | 
				
			||||||
    else{
 | 
					buffer_backify_good(Gap_Buffer_Backify_Loop *loop){
 | 
				
			||||||
        temp_end = 0;
 | 
					    int result = (loop->buffer != 0);
 | 
				
			||||||
        loop->buffer = 0;
 | 
					    return(result);
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
    loop->size = temp_end - loop->pos;
 | 
					
 | 
				
			||||||
    loop->data = loop->base + loop->pos;
 | 
					internal_4tech void
 | 
				
			||||||
}
 | 
					buffer_backify_next(Gap_Buffer_Backify_Loop *loop){
 | 
				
			||||||
 | 
					    Gap_Buffer *buffer = loop->buffer;
 | 
				
			||||||
internal_4tech int
 | 
					    int temp_end = 0;
 | 
				
			||||||
buffer_replace_range(Gap_Buffer *buffer, int start, int end, char *str, int len, int *shift_amount,
 | 
					    
 | 
				
			||||||
                     void *scratch, int scratch_memory, int *request_amount){
 | 
					    if (loop->separated){
 | 
				
			||||||
    char *data;
 | 
					        loop->separated = 0;
 | 
				
			||||||
    int result;
 | 
					        temp_end = buffer->size1;
 | 
				
			||||||
    int size;
 | 
					        loop->pos = 0;
 | 
				
			||||||
    int move_size;
 | 
					        loop->absolute_pos = 0;
 | 
				
			||||||
    
 | 
					        if (loop->pos < loop->end){
 | 
				
			||||||
    size = buffer_size(buffer);
 | 
					            loop->absolute_pos = loop->end;
 | 
				
			||||||
    assert_4tech(0 <= start);
 | 
					            loop->pos = loop->end;
 | 
				
			||||||
    assert_4tech(start <= end);
 | 
					        }
 | 
				
			||||||
    assert_4tech(end <= size);
 | 
					    }
 | 
				
			||||||
    
 | 
					    else{
 | 
				
			||||||
    *shift_amount = (len - (end - start));
 | 
					        temp_end = 0;
 | 
				
			||||||
    if (*shift_amount + size <= buffer->max){
 | 
					        loop->buffer = 0;
 | 
				
			||||||
        data = buffer->data;
 | 
					    }
 | 
				
			||||||
        if (end < buffer->size1){
 | 
					    
 | 
				
			||||||
            move_size = buffer->size1 - end;
 | 
					    loop->size = temp_end - loop->pos;
 | 
				
			||||||
            memmove_4tech(data + buffer->size1 + buffer->gap_size - move_size, data + end, move_size);
 | 
					    loop->data = loop->base + loop->pos;
 | 
				
			||||||
            buffer->size1 -= move_size;
 | 
					}
 | 
				
			||||||
            buffer->size2 += move_size;
 | 
					
 | 
				
			||||||
        }
 | 
					internal_4tech int
 | 
				
			||||||
        if (start > buffer->size1){
 | 
					buffer_replace_range(Gap_Buffer *buffer, int start, int end, char *str, int len, int *shift_amount,
 | 
				
			||||||
            move_size = start - buffer->size1;
 | 
					                     void *scratch, int scratch_memory, int *request_amount){
 | 
				
			||||||
            memmove_4tech(data + buffer->size1, data + buffer->size1 + buffer->gap_size, move_size);
 | 
					    char *data = buffer->data;
 | 
				
			||||||
            buffer->size1 += move_size;
 | 
					    int size = buffer_size(buffer);
 | 
				
			||||||
            buffer->size2 -= move_size;
 | 
					    int result = 0;
 | 
				
			||||||
        }
 | 
					    int move_size = 0;
 | 
				
			||||||
        
 | 
					    
 | 
				
			||||||
        memcpy_4tech(data + start, str, len);
 | 
					    assert_4tech(0 <= start);
 | 
				
			||||||
        buffer->size2 = size - end;
 | 
					    assert_4tech(start <= end);
 | 
				
			||||||
        buffer->size1 = start + len;
 | 
					    assert_4tech(end <= size);
 | 
				
			||||||
        buffer->gap_size -= *shift_amount;
 | 
					    
 | 
				
			||||||
        
 | 
					    *shift_amount = (len - (end - start));
 | 
				
			||||||
        assert_4tech(buffer->size1 + buffer->size2 == size + *shift_amount);
 | 
					    if (*shift_amount + size <= buffer->max){
 | 
				
			||||||
        assert_4tech(buffer->size1 + buffer->gap_size + buffer->size2 == buffer->max);
 | 
					        if (end < buffer->size1){
 | 
				
			||||||
        
 | 
					            move_size = buffer->size1 - end;
 | 
				
			||||||
        result = 0;
 | 
					            memmove_4tech(data + buffer->size1 + buffer->gap_size - move_size, data + end, move_size);
 | 
				
			||||||
    }
 | 
					            buffer->size1 -= move_size;
 | 
				
			||||||
    else{
 | 
					            buffer->size2 += move_size;
 | 
				
			||||||
        *request_amount = round_up_4tech(2*(*shift_amount + size), 4 << 10);
 | 
					        }
 | 
				
			||||||
        result = 1;
 | 
					        if (start > buffer->size1){
 | 
				
			||||||
    }
 | 
					            move_size = start - buffer->size1;
 | 
				
			||||||
 | 
					            memmove_4tech(data + buffer->size1, data + buffer->size1 + buffer->gap_size, move_size);
 | 
				
			||||||
    return(result);
 | 
					            buffer->size1 += move_size;
 | 
				
			||||||
}
 | 
					            buffer->size2 -= move_size;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
// NOTE(allen): This could should be optimized for Gap_Buffer
 | 
					        
 | 
				
			||||||
internal_4tech int
 | 
					        memcpy_4tech(data + start, str, len);
 | 
				
			||||||
buffer_batch_edit_step(Buffer_Batch_State *state, Gap_Buffer *buffer, Buffer_Edit *sorted_edits,
 | 
					        buffer->size2 = size - end;
 | 
				
			||||||
                       char *strings, int edit_count, void *scratch, int scratch_size, int *request_amount){
 | 
					        buffer->size1 = start + len;
 | 
				
			||||||
    Buffer_Edit *edit;
 | 
					        buffer->gap_size -= *shift_amount;
 | 
				
			||||||
    int i, result;
 | 
					        
 | 
				
			||||||
    int shift_total, shift_amount;
 | 
					        assert_4tech(buffer->size1 + buffer->size2 == size + *shift_amount);
 | 
				
			||||||
    
 | 
					        assert_4tech(buffer->size1 + buffer->gap_size + buffer->size2 == buffer->max);
 | 
				
			||||||
    result = 0;
 | 
					    }
 | 
				
			||||||
    shift_total = state->shift_total;
 | 
					    else{
 | 
				
			||||||
    i = state->i;
 | 
					        *request_amount = round_up_4tech(2*(*shift_amount + size), 4 << 10);
 | 
				
			||||||
    
 | 
					        result = 1;
 | 
				
			||||||
    edit = sorted_edits + i;
 | 
					    }
 | 
				
			||||||
    for (; i < edit_count; ++i, ++edit){
 | 
					
 | 
				
			||||||
        result = buffer_replace_range(buffer, edit->start + shift_total, edit->end + shift_total,
 | 
					    return(result);
 | 
				
			||||||
                                      strings + edit->str_start, edit->len, &shift_amount,
 | 
					}
 | 
				
			||||||
                                      scratch, scratch_size, request_amount);
 | 
					
 | 
				
			||||||
        if (result) break;
 | 
					// NOTE(allen): This could should be optimized for Gap_Buffer
 | 
				
			||||||
        shift_total += shift_amount;
 | 
					internal_4tech int
 | 
				
			||||||
    }
 | 
					buffer_batch_edit_step(Buffer_Batch_State *state, Gap_Buffer *buffer, Buffer_Edit *sorted_edits,
 | 
				
			||||||
    
 | 
					                       char *strings, int edit_count, void *scratch, int scratch_size, int *request_amount){
 | 
				
			||||||
    state->shift_total = shift_total;
 | 
					    Buffer_Edit *edit = 0;
 | 
				
			||||||
    state->i = i;
 | 
					    int i = state->i;
 | 
				
			||||||
    
 | 
					    int shift_total = state->shift_total;
 | 
				
			||||||
    return(result);
 | 
					    int shift_amount = 0;
 | 
				
			||||||
}
 | 
					    int result = 0;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
internal_4tech void*
 | 
					    edit = sorted_edits + i;
 | 
				
			||||||
buffer_edit_provide_memory(Gap_Buffer *buffer, void *new_data, int new_max){
 | 
					    for (; i < edit_count; ++i, ++edit){
 | 
				
			||||||
    void *result;
 | 
					        result = buffer_replace_range(buffer, edit->start + shift_total, edit->end + shift_total,
 | 
				
			||||||
    int new_gap_size;
 | 
					                                      strings + edit->str_start, edit->len, &shift_amount,
 | 
				
			||||||
    
 | 
					                                      scratch, scratch_size, request_amount);
 | 
				
			||||||
    assert_4tech(new_max >= buffer_size(buffer));
 | 
					        if (result) break;
 | 
				
			||||||
    
 | 
					        shift_total += shift_amount;
 | 
				
			||||||
    result = buffer->data;
 | 
					    }
 | 
				
			||||||
    new_gap_size = new_max - buffer_size(buffer);
 | 
					    
 | 
				
			||||||
    memcpy_4tech(new_data, buffer->data, buffer->size1);
 | 
					    state->shift_total = shift_total;
 | 
				
			||||||
    memcpy_4tech((char*)new_data + buffer->size1 + new_gap_size, buffer->data + buffer->size1 + buffer->gap_size, buffer->size2);
 | 
					    state->i = i;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    buffer->data = (char*)new_data;
 | 
					    return(result);
 | 
				
			||||||
    buffer->gap_size = new_gap_size;
 | 
					}
 | 
				
			||||||
    buffer->max = new_max;
 | 
					
 | 
				
			||||||
    
 | 
					internal_4tech void*
 | 
				
			||||||
    return(result);
 | 
					buffer_edit_provide_memory(Gap_Buffer *buffer, void *new_data, int new_max){
 | 
				
			||||||
}
 | 
					    void *result = buffer->data;
 | 
				
			||||||
 | 
					    int size = buffer_size(buffer);
 | 
				
			||||||
// BOTTOM
 | 
					    int new_gap_size = new_max - size;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    assert_4tech(new_max >= size);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    memcpy_4tech(new_data, buffer->data, buffer->size1);
 | 
				
			||||||
 | 
					    memcpy_4tech((char*)new_data + buffer->size1 + new_gap_size, buffer->data + buffer->size1 + buffer->gap_size, buffer->size2);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    buffer->data = (char*)new_data;
 | 
				
			||||||
 | 
					    buffer->gap_size = new_gap_size;
 | 
				
			||||||
 | 
					    buffer->max = new_max;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    return(result);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// BOTTOM
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2438,7 +2438,8 @@ WinMain(HINSTANCE hInstance,
 | 
				
			||||||
                           &win32vars.target,
 | 
					                           &win32vars.target,
 | 
				
			||||||
                           &memory_vars,
 | 
					                           &memory_vars,
 | 
				
			||||||
                           &input,
 | 
					                           &input,
 | 
				
			||||||
                           &result);
 | 
					                           &result,
 | 
				
			||||||
 | 
					                           clparams);
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        if (result.perform_kill){
 | 
					        if (result.perform_kill){
 | 
				
			||||||
            keep_playing = 0;
 | 
					            keep_playing = 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue