command line ready, more linux shit done

This commit is contained in:
Allen Webster 2016-02-07 10:19:18 -05:00
parent 164a18c4a9
commit 959bdcd8cf
9 changed files with 349 additions and 195 deletions

View File

@ -1,81 +1,87 @@
/* "4cpp" Open C++ Parser v0.1: Config /* "4cpp" Open C++ Parser v0.1: Config
no warranty implied; use at your own risk no warranty implied; use at your own risk
NOTES ON USE: NOTES ON USE:
This file is used to configure 4cpp options at the begining of 4cpp files. This file is used to configure 4cpp options at the begining of 4cpp files.
It is not meant to be used directly. It is not meant to be used directly.
*/ */
#ifdef FCPP_NO_CRT #ifdef FCPP_NO_CRT
# ifndef FCPP_NO_MALLOC # ifndef FCPP_NO_MALLOC
# define FCPP_NO_MALLOC # define FCPP_NO_MALLOC
# endif # endif
# ifndef FCPP_NO_ASSERT # ifndef FCPP_NO_ASSERT
# define FCPP_NO_ASSERT # define FCPP_NO_ASSERT
# endif # endif
# ifndef FCPP_NO_STRING # ifndef FCPP_NO_STRING
# define FCPP_NO_STRING # define FCPP_NO_STRING
# endif # endif
#endif #endif
#ifdef FCPP_FORBID_MALLOC #ifdef FCPP_FORBID_MALLOC
# define FCPP_NO_MALLOC # define FCPP_NO_MALLOC
#endif #endif
#ifndef FCPP_NO_MALLOC #ifndef FCPP_NO_MALLOC
# include <stdlib.h> # include <stdlib.h>
#endif #endif
#ifndef FCPP_NO_ASSERT #ifndef FCPP_NO_ASSERT
# include <assert.h> # include <assert.h>
#endif #endif
#ifndef FCPP_NO_STRING #ifndef FCPP_NO_STRING
# include <string.h> # include <string.h>
#endif #endif
#ifndef FCPP_NO_MALLOC #ifndef FCPP_NO_MALLOC
# ifndef FCPP_GET_MEMORY # ifndef FCPP_GET_MEMORY
# define FCPP_GET_MEMORY malloc # define FCPP_GET_MEMORY malloc
# endif # endif
# ifndef FCPP_FREE_MEMORY # ifndef FCPP_FREE_MEMORY
# define FCPP_FREE_MEMORY free # define FCPP_FREE_MEMORY free
# endif # endif
#else #else
# ifndef FCPP_FORBID_MALLOC # ifndef FCPP_FORBID_MALLOC
# ifndef FCPP_GET_MEMORY # ifndef FCPP_GET_MEMORY
# error Missing definition for FCPP_GET_MEMORY # error Missing definition for FCPP_GET_MEMORY
# endif # endif
# ifndef FCPP_FREE_MEMORY # ifndef FCPP_FREE_MEMORY
# error Missing definition for FCPP_FREE_MEMORY # error Missing definition for FCPP_FREE_MEMORY
# endif # endif
# endif # endif
#endif #endif
#ifndef FCPP_NO_ASSERT #ifndef FCPP_NO_ASSERT
# ifndef FCPP_ASSERT # ifndef FCPP_ASSERT
# define FCPP_ASSERT assert # define FCPP_ASSERT assert
# endif # endif
#else #else
# ifndef FCPP_ASSERT # ifndef FCPP_ASSERT
# define FCPP_ASSERT(x) # define FCPP_ASSERT(x)
# endif # endif
#endif #endif
#ifndef FCPP_NO_STRING #ifndef FCPP_NO_STRING
# ifndef FCPP_MEM_COPY # ifndef FCPP_MEM_COPY
# define FCPP_MEM_COPY memcpy # define FCPP_MEM_COPY memcpy
# endif # endif
# ifndef FCPP_MEM_MOVE # ifndef FCPP_MEM_MOVE
# define FCPP_MEM_MOVE memmove # define FCPP_MEM_MOVE memmove
# endif # endif
#endif #endif
#ifndef FCPP_LINK #ifndef FCPP_LINK
# ifdef FCPP_EXTERN # ifdef FCPP_EXTERN
# define FCPP_LINK extern # define FCPP_LINK extern
# else # else
# define FCPP_LINK static # define FCPP_LINK static
# endif # endif
#endif #endif
#ifndef DrBegin
#define DrBegin() switch (s.__pc__){ case 0:;
#define DrEnd() default: Assert(!"Invalid __pc__"); }
#define DrYield(pc, n) { s.__pc__ = pc; *state = s; return(n); case pc:; }
#define DrReturn(n) { s.__pc__ = -1; return(n); }
#endif

78
4ed.cpp
View File

@ -844,7 +844,6 @@ app_open_file(System_Functions *system, App_Vars *vars, Exchange *exchange,
return(result); return(result);
} }
COMMAND_DECL(interactive_open){ COMMAND_DECL(interactive_open){
ProfileMomentFunction(); ProfileMomentFunction();
USE_VARS(vars); USE_VARS(vars);
@ -2594,16 +2593,34 @@ app_setup_memory(Application_Memory *memory){
return(vars); return(vars);
} }
internal i32
execute_special_tool(void *memory, i32 size, Command_Line_Parameters clparams){
char message[] = "Hell World!";
i32 result = sizeof(message) - 1;
memcpy(memory, message, result);
return(result);
}
App_Read_Command_Line_Sig(app_read_command_line){ App_Read_Command_Line_Sig(app_read_command_line){
i32 output_size = 0; App_Vars *vars;
i32 out_size = 0;
App_Vars *vars = app_setup_memory(memory);
init_command_line_settings(&vars->settings, plat_settings, clparams); if (clparams.argc > 1 && match(clparams.argv[1], "-T")){
out_size = execute_special_tool(memory->target_memory, memory->target_memory_size, clparams);
*files = vars->settings.init_files; }
*file_count = &vars->settings.init_files_count; else{
vars = app_setup_memory(memory);
return(output_size); if (clparams.argc > 1){
init_command_line_settings(&vars->settings, plat_settings, clparams);
*files = vars->settings.init_files;
*file_count = &vars->settings.init_files_count;
}
else{
vars->settings = {};
}
}
return(out_size);
} }
App_Init_Sig(app_init){ App_Init_Sig(app_init){
@ -3289,16 +3306,23 @@ App_Step_Sig(app_step){
i32 i; i32 i;
String file_name; String file_name;
File_View *fview;
Editing_File *file;
Panel *panel = vars->layout.panels; Panel *panel = vars->layout.panels;
for (i = 0; i < vars->settings.init_files_count; ++i, ++panel){ for (i = 0; i < vars->settings.init_files_count; ++i, ++panel){
file_name = make_string_slowly(vars->settings.init_files[i]); file_name = make_string_slowly(vars->settings.init_files[i]);
if (i < vars->layout.panel_count){ if (i < vars->layout.panel_count){
app_open_file(system, vars, exchange, &vars->live_set, &vars->working_set, panel, fview = app_open_file(system, vars, exchange, &vars->live_set, &vars->working_set, panel,
&command_data, file_name); &command_data, file_name);
if (i == 0){ if (i == 0){
if (fview){
file = fview->file;
if (file){
file->preload.start_line = vars->settings.initial_line;
}
}
} }
} }
else{ else{
@ -3620,10 +3644,14 @@ App_Step_Sig(app_step){
byte *data; byte *data;
i32 size, max; i32 size, max;
Editing_File *ed_file;
Editing_File_Preload preload_settings;
char *filename;
if (exchange_file_ready(exchange, binding->sys_id, &data, &size, &max)){ if (exchange_file_ready(exchange, binding->sys_id, &data, &size, &max)){
Editing_File *ed_file = vars->working_set.files + binding->app_id; ed_file = vars->working_set.files + binding->app_id;
char *filename = exchange_file_filename(exchange, binding->sys_id); filename = exchange_file_filename(exchange, binding->sys_id);
preload_settings = ed_file->preload;
if (data){ if (data){
String val = make_string((char*)data, size); String val = make_string((char*)data, size);
file_create_from_string(system, &vars->mem, ed_file, filename, file_create_from_string(system, &vars->mem, ed_file, filename,
@ -3631,25 +3659,17 @@ App_Step_Sig(app_step){
if (ed_file->settings.tokens_exist) if (ed_file->settings.tokens_exist)
file_first_lex_parallel(system, &vars->mem.general, ed_file); file_first_lex_parallel(system, &vars->mem.general, ed_file);
for (File_View_Iter iter = file_view_iter_init(&vars->layout, ed_file, 0);
file_view_iter_good(iter);
iter = file_view_iter_next(iter)){
view_file_loaded_init(system, iter.view, 0);
}
} }
else{ else{
file_create_empty(system, &vars->mem, ed_file, filename, file_create_empty(system, &vars->mem, ed_file, filename,
vars->font_set, vars->style.font_id); vars->font_set, vars->style.font_id);
// }
i32 panel_count = vars->layout.panel_count;
Panel *current_panel = vars->layout.panels; for (File_View_Iter iter = file_view_iter_init(&vars->layout, ed_file, 0);
for (i32 i = 0; i < panel_count; ++i, ++current_panel){ file_view_iter_good(iter);
File_View *current_view = view_to_file_view(current_panel->view); iter = file_view_iter_next(iter)){
if (current_view && current_view->file == ed_file){ view_file_loaded_init(system, iter.view, 0);
view_measure_wraps(system, &vars->mem.general, current_view); view_cursor_move(iter.view, preload_settings.start_line, 0);
}
}
} }
exchange_free_file(exchange, binding->sys_id); exchange_free_file(exchange, binding->sys_id);

View File

@ -1,51 +1,51 @@
/* /*
* Mr. 4th Dimention - Allen Webster * Mr. 4th Dimention - Allen Webster
* *
* 13.11.2015 * 13.11.2015
* *
* Application layer build target * Application layer build target
* *
*/ */
// TOP // TOP
#include "4ed_config.h" #include "4ed_config.h"
#define BUFFER_EXPERIMENT_SCALPEL 0 #define BUFFER_EXPERIMENT_SCALPEL 0
#include "4ed_meta.h" #include "4ed_meta.h"
#include "4cpp_types.h" #include "4cpp_types.h"
#define FCPP_STRING_IMPLEMENTATION #define FCPP_STRING_IMPLEMENTATION
#include "4coder_string.h" #include "4coder_string.h"
#include "4ed_mem.cpp" #include "4ed_mem.cpp"
#include "4ed_math.cpp" #include "4ed_math.cpp"
#include "4coder_custom.h" #include "4coder_custom.h"
#include "4ed_system.h" #include "4ed_system.h"
#include "4ed_rendering.h" #include "4ed_rendering.h"
#include "4ed.h" #include "4ed.h"
#include "4ed_internal.h" #include "4ed_internal.h"
#define FCPP_LEXER_IMPLEMENTATION #define FCPP_LEXER_IMPLEMENTATION
#include "4cpp_lexer.h" #include "4cpp_lexer.h"
#include "4ed_exchange.cpp" #include "4ed_exchange.cpp"
#include "4ed_font_set.cpp" #include "4ed_font_set.cpp"
#include "4ed_rendering_helper.cpp" #include "4ed_rendering_helper.cpp"
#include "4ed_command.cpp" #include "4ed_command.cpp"
#include "4ed_layout.cpp" #include "4ed_layout.cpp"
#include "4ed_style.cpp" #include "4ed_style.cpp"
#include "4ed_file_view.cpp" #include "4ed_file_view.cpp"
#include "4ed_color_view.cpp" #include "4ed_color_view.cpp"
#include "4ed_interactive_view.cpp" #include "4ed_interactive_view.cpp"
#include "4ed_menu_view.cpp" #include "4ed_menu_view.cpp"
#include "4ed_app_settings.h" #include "4ed_app_settings.h"
#include "4ed_config_view.cpp" #include "4ed_config_view.cpp"
#include "4ed_debug_view.cpp" #include "4ed_debug_view.cpp"
#include "4ed.cpp" #include "4ed.cpp"
// BOTTOM // BOTTOM

View File

@ -132,6 +132,10 @@ struct Editing_File_State{
u64 last_sys_write_time; u64 last_sys_write_time;
}; };
struct Editing_File_Preload{
i32 start_line;
};
struct Editing_File_Name{ struct Editing_File_Name{
char live_name_[256]; char live_name_[256];
String live_name; String live_name;
@ -144,7 +148,10 @@ struct Editing_File_Name{
struct Editing_File{ struct Editing_File{
Editing_File_Settings settings; Editing_File_Settings settings;
Editing_File_State state; union{
Editing_File_State state;
Editing_File_Preload preload;
};
Editing_File_Name name; Editing_File_Name name;
}; };
@ -1494,22 +1501,26 @@ file_create_from_string(System_Functions *system, Mem_Options *mem,
Editing_File *file, char *filename, Editing_File *file, char *filename,
Font_Set *set, i16 font_id, Font_Set *set, i16 font_id,
String val, b8 super_locked = 0){ String val, b8 super_locked = 0){
file->state = {};
General_Memory *general = &mem->general; General_Memory *general = &mem->general;
Partition *part = &mem->part;
Buffer_Init_Type init;
i32 page_size, scratch_size, init_success;
file->state = {};
#if BUFFER_EXPERIMENT_SCALPEL <= 3 #if BUFFER_EXPERIMENT_SCALPEL <= 3
Buffer_Init_Type init = buffer_begin_init(&file->state.buffer, val.str, val.size); init = buffer_begin_init(&file->state.buffer, val.str, val.size);
for (; buffer_init_need_more(&init); ){ for (; buffer_init_need_more(&init); ){
i32 page_size = buffer_init_page_size(&init); page_size = buffer_init_page_size(&init);
page_size = LargeRoundUp(page_size, Kbytes(4)); page_size = LargeRoundUp(page_size, Kbytes(4));
if (page_size < Kbytes(4)) page_size = Kbytes(4); if (page_size < Kbytes(4)) page_size = Kbytes(4);
void *data = general_memory_allocate(general, page_size, BUBBLE_BUFFER); void *data = general_memory_allocate(general, page_size, BUBBLE_BUFFER);
buffer_init_provide_page(&init, data, page_size); buffer_init_provide_page(&init, data, page_size);
} }
Partition *part = &mem->part; scratch_size = partition_remaining(part);
i32 scratch_size = partition_remaining(part);
Assert(scratch_size > 0); Assert(scratch_size > 0);
i32 init_success = buffer_end_init(&init, part->base + part->pos, scratch_size); init_success = buffer_end_init(&init, part->base + part->pos, scratch_size);
AllowLocal(init_success); AllowLocal(init_success);
Assert(init_success); Assert(init_success);
#endif #endif
@ -1517,11 +1528,10 @@ file_create_from_string(System_Functions *system, Mem_Options *mem,
file_init_strings(file); file_init_strings(file);
file_set_name(file, (char*)filename); file_set_name(file, (char*)filename);
//file->settings.base_map_id = mapid_file;
file->state.font_id = font_id; file->state.font_id = font_id;
file_synchronize_times(system, file, filename); file_synchronize_times(system, file, filename);
Render_Font *font = get_font_info(set, font_id)->font; Render_Font *font = get_font_info(set, font_id)->font;
float *advance_data = 0; float *advance_data = 0;
if (font) advance_data = font->advance_data; if (font) advance_data = font->advance_data;
@ -1534,22 +1544,22 @@ file_create_from_string(System_Functions *system, Mem_Options *mem,
file->state.undo.undo.strings = (u8*)general_memory_allocate(general, request_size, BUBBLE_UNDO_STRING); file->state.undo.undo.strings = (u8*)general_memory_allocate(general, request_size, BUBBLE_UNDO_STRING);
file->state.undo.undo.edit_max = request_size / sizeof(Edit_Step); file->state.undo.undo.edit_max = request_size / sizeof(Edit_Step);
file->state.undo.undo.edits = (Edit_Step*)general_memory_allocate(general, request_size, BUBBLE_UNDO); file->state.undo.undo.edits = (Edit_Step*)general_memory_allocate(general, request_size, BUBBLE_UNDO);
file->state.undo.redo.max = request_size; file->state.undo.redo.max = request_size;
file->state.undo.redo.strings = (u8*)general_memory_allocate(general, request_size, BUBBLE_UNDO_STRING); file->state.undo.redo.strings = (u8*)general_memory_allocate(general, request_size, BUBBLE_UNDO_STRING);
file->state.undo.redo.edit_max = request_size / sizeof(Edit_Step); file->state.undo.redo.edit_max = request_size / sizeof(Edit_Step);
file->state.undo.redo.edits = (Edit_Step*)general_memory_allocate(general, request_size, BUBBLE_UNDO); file->state.undo.redo.edits = (Edit_Step*)general_memory_allocate(general, request_size, BUBBLE_UNDO);
file->state.undo.history.max = request_size; file->state.undo.history.max = request_size;
file->state.undo.history.strings = (u8*)general_memory_allocate(general, request_size, BUBBLE_UNDO_STRING); file->state.undo.history.strings = (u8*)general_memory_allocate(general, request_size, BUBBLE_UNDO_STRING);
file->state.undo.history.edit_max = request_size / sizeof(Edit_Step); file->state.undo.history.edit_max = request_size / sizeof(Edit_Step);
file->state.undo.history.edits = (Edit_Step*)general_memory_allocate(general, request_size, BUBBLE_UNDO); file->state.undo.history.edits = (Edit_Step*)general_memory_allocate(general, request_size, BUBBLE_UNDO);
file->state.undo.children.max = request_size; file->state.undo.children.max = request_size;
file->state.undo.children.strings = (u8*)general_memory_allocate(general, request_size, BUBBLE_UNDO_STRING); file->state.undo.children.strings = (u8*)general_memory_allocate(general, request_size, BUBBLE_UNDO_STRING);
file->state.undo.children.edit_max = request_size / sizeof(Buffer_Edit); file->state.undo.children.edit_max = request_size / sizeof(Buffer_Edit);
file->state.undo.children.edits = (Buffer_Edit*)general_memory_allocate(general, request_size, BUBBLE_UNDO); file->state.undo.children.edits = (Buffer_Edit*)general_memory_allocate(general, request_size, BUBBLE_UNDO);
file->state.undo.history_block_count = 1; file->state.undo.history_block_count = 1;
file->state.undo.history_head_block = 0; file->state.undo.history_head_block = 0;
file->state.undo.current_block_normal = 1; file->state.undo.current_block_normal = 1;

View File

@ -47,11 +47,6 @@ struct Data{
#define globalconst static const #define globalconst static const
#define DrBegin() switch (s.__pc__){ case 0:;
#define DrEnd() default: Assert(!"Invalid __pc__"); }
#define DrYield(pc, n) { s.__pc__ = pc; *state = s; return(n); case pc:; }
#define DrReturn(n) { s.__pc__ = -1; return(n); }
inline i32 inline i32
raw_ptr_dif(void *a, void *b) { return (i32)((u8*)a - (u8*)b); } raw_ptr_dif(void *a, void *b) { return (i32)((u8*)a - (u8*)b); }

View File

@ -27,6 +27,7 @@ struct File_List{
#define Sys_File_Time_Stamp_Sig(name) u64 name(char *filename) #define Sys_File_Time_Stamp_Sig(name) u64 name(char *filename)
typedef Sys_File_Time_Stamp_Sig(System_File_Time_Stamp); typedef Sys_File_Time_Stamp_Sig(System_File_Time_Stamp);
// TODO(allen): make directory a char* to signal that it must be null terminated
#define Sys_Set_File_List_Sig(name) void name(File_List *file_list, String directory) #define Sys_Set_File_List_Sig(name) void name(File_List *file_list, String directory)
typedef Sys_Set_File_List_Sig(System_Set_File_List); typedef Sys_Set_File_List_Sig(System_Set_File_List);

View File

@ -32,6 +32,9 @@
#include <math.h> #include <math.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <stdio.h> #include <stdio.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <GL/glx.h> #include <GL/glx.h>
@ -39,20 +42,126 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <X11/extensions/XInput2.h> #include <X11/extensions/XInput2.h>
#include <linux/input.h> #include <linux/input.h>
#include <time.h>
#include "4ed_internal.h" #include "4ed_internal.h"
#include "4ed_linux_keyboard.cpp" #include "4ed_linux_keyboard.cpp"
#include <stdlib.h>
void*
LinuxGetMemory(i32 size){
// TODO(allen): Implement without stdlib.h
return (malloc(size));
}
void
LinuxFreeMemory(void *block){
// TODO(allen): Implement without stdlib.h
free(block);
}
#if (defined(_BSD_SOURCE) || defined(_SVID_SOURCE))
#define TimeBySt
#endif
#if (_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700)
#define TimeBySt
#endif
#ifdef TimeBySt
#define nano_mtime_field st_mtim.tv_nsec
#undef TimeBySt
#else
#define nano_mtime_field st_mtimensec
#endif
Sys_File_Time_Stamp_Sig(system_file_time_stamp){
struct stat info;
i64 nanosecond_timestamp;
u64 result;
stat(filename, &info);
nanosecond_timestamp = info.nano_mtime_field;
if (nanosecond_timestamp != 0){
result = (u64)(nanosecond_timestamp / 1000);
}
else{
result = (u64)(info.st_mtime * 1000000);
}
return(result);
}
Sys_Time_Sig(system_time){
struct timespec spec;
u64 result;
clock_gettime(CLOCK_MONOTONIC, &spec);
result = (spec.tv_sec * 1000000) + (spec.tv_nsec / 1000);
return(result);
}
Sys_Set_File_List_Sig(system_set_file_list){
DIR *d;
struct dirent *entry;
char *fname, *cursor, *cursor_start;
File_Info *info_ptr;
i32 count, file_count, size, required_size;
terminate_with_null(&directory);
d = opendir(directory.str);
if (d){
count = 0;
for (entry = readdir(d);
entry != 0;
entry = readdir(d)){
fname = entry->d_name;
++file_count;
for (size = 0; fname[size]; ++size);
count += size + 1;
}
closedir(d);
required_size = count + file_count * sizeof(File_Info);
if (file_list->block_size < required_size){
if (file_list->block){
LinuxFreeMemory(file_list->block);
}
file_list->block = LinuxGetMemory(required_size);
}
file_list->infos = (File_Info*)file_list->block;
cursor = (char*)(file_list->infos + file_count);
d = opendir(directory.str);
if (d){
info_ptr = file_list->infos;
for (entry = readdir(d);
entry != 0;
entry = readdir(d), ++info_ptr){
fname = entry->d_name;
cursor_start = cursor;
for (; *fname; ) *cursor++ = *fname++;
*cursor++ = 0;
info_ptr->folder = 0;
info_ptr->filename.str = cursor_start;
info_ptr->filename.size = (i32)(cursor - cursor_start);
info_ptr->filename.memory_size = info_ptr->filename.size + 1;
}
}
closedir(d);
}
closedir(d);
}
Sys_Post_Clipboard_Sig(system_post_clipboard){
// TODO(allen): Implement
AllowLocal(str);
}
// NOTE(allen): Thanks to Casey for providing the linux OpenGL launcher. // NOTE(allen): Thanks to Casey for providing the linux OpenGL launcher.
/* TODO(allen):
1. get 4coder rendering it's blank self
2. get input working
(release linux version)
3. add in extra stuff as it is completed in windows
*/
static bool ctxErrorOccurred = false; static bool ctxErrorOccurred = false;
static int XInput2OpCode = 0; static int XInput2OpCode = 0;
internal int internal int

BIN
vc120.pdb

Binary file not shown.

View File

@ -317,8 +317,8 @@ system_save_file(char *filename, void *data, i32 size){
internal b32 internal b32
system_file_can_be_made(char *filename){ system_file_can_be_made(char *filename){
HANDLE file; HANDLE file;
file = CreateFile((char*)filename, GENERIC_WRITE, 0, 0, file = CreateFile((char*)filename, FILE_APPEND_DATA, 0, 0,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if (!file || file == INVALID_HANDLE_VALUE){ if (!file || file == INVALID_HANDLE_VALUE){
return 0; return 0;
@ -414,7 +414,7 @@ Sys_Set_File_List_Sig(system_set_file_list){
char *name_base = name; char *name_base = name;
i32 i = 0; i32 i = 0;
for(;find_data.cFileName[i];++i) *name++ = find_data.cFileName[i]; for(;find_data.cFileName[i];++i) *name++ = find_data.cFileName[i];
info->filename.size = (i32)(name - name_base); info->filename.size = i;
info->filename.memory_size = info->filename.size + 1; info->filename.memory_size = info->filename.size + 1;
*name++ = 0; *name++ = 0;
++info; ++info;
@ -1499,11 +1499,18 @@ UpdateLoop(LPVOID param){
return(0); return(0);
} }
#if 0
int int
WinMain(HINSTANCE hInstance, WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, LPSTR lpCmdLine,
int nCmdShow){ int nCmdShow){
#else
int
main(int argc, char **argv){
#endif
HINSTANCE hInstance = GetModuleHandle(0);
win32vars = {}; win32vars = {};
exchange_vars = {}; exchange_vars = {};
@ -1560,12 +1567,15 @@ WinMain(HINSTANCE hInstance,
terminate_with_null(&current_directory); terminate_with_null(&current_directory);
Command_Line_Parameters clparams; Command_Line_Parameters clparams;
clparams.argv = __argv; clparams.argv = argv;
clparams.argc = __argc; clparams.argc = argc;
char **files; char **files;
i32 *file_count; i32 *file_count;
files = 0;
file_count = 0;
i32 output_size = i32 output_size =
win32vars.app.read_command_line(system, win32vars.app.read_command_line(system,
&memory_vars, &memory_vars,
@ -1577,10 +1587,13 @@ WinMain(HINSTANCE hInstance,
if (output_size > 0){ if (output_size > 0){
// TODO // TODO
printf("%.*s", output_size, memory_vars.target_memory);
} }
if (output_size != 0) return 0; if (output_size != 0) return 0;
FreeConsole();
{ if (files){
i32 i, j; i32 i, j;
i32 end = *file_count; i32 end = *file_count;
for (i = 0, j = 0; i < end; ++i){ for (i = 0, j = 0; i < end; ++i){
@ -1623,7 +1636,7 @@ WinMain(HINSTANCE hInstance,
GetProcAddress(win32vars.custom, "get_bindings"); GetProcAddress(win32vars.custom, "get_bindings");
} }
#endif #endif
Thread_Context background[4]; Thread_Context background[4];
memset(background, 0, sizeof(background)); memset(background, 0, sizeof(background));
win32vars.groups[BACKGROUND_THREADS].threads = background; win32vars.groups[BACKGROUND_THREADS].threads = background;