ready for distribution

master
Allen Webster 2016-05-10 13:36:53 -04:00
parent 353d08fa2b
commit bdd3bbe0d9
5 changed files with 90 additions and 45 deletions

View File

@ -67,7 +67,7 @@ HOOK_SIG(my_file_settings){
}
push_parameter(app, par_lex_as_cpp_file, treat_as_code);
push_parameter(app, par_wrap_lines, !treat_as_code);
push_parameter(app, par_wrap_lines, wrap_lines);
push_parameter(app, par_key_mapid, (treat_as_code)?((int)my_code_map):((int)mapid_file));
exec_command(app, cmdid_set_settings);
@ -293,6 +293,7 @@ int get_bindings(void *data, int size){
bind(context, 'm', MDFR_ALT, build_search);
bind(context, 'x', MDFR_ALT, execute_arbitrary_command);
bind(context, 'z', MDFR_ALT, execute_any_cli);
bind(context, 'Z', MDFR_ALT, execute_previous_cli);
// NOTE(allen): These callbacks may not actually be useful to you, but
// go look at them and see what they do.

View File

@ -513,20 +513,21 @@ CUSTOM_COMMAND_SIG(open_all_code){
app->free_file_list(app, list);
}
char out_buffer_space[1024], command_space[1024], hot_directory_space[1024];
CUSTOM_COMMAND_SIG(execute_any_cli){
Query_Bar bar_out, bar_cmd;
String hot_directory;
char space[1024], more_space[1024], even_more_space[1024];
bar_out.prompt = make_lit_string("Output Buffer: ");
bar_out.string = make_fixed_width_string(space);
bar_out.string = make_fixed_width_string(out_buffer_space);
if (!query_user_string(app, &bar_out)) return;
bar_cmd.prompt = make_lit_string("Command: ");
bar_cmd.string = make_fixed_width_string(more_space);
bar_cmd.string = make_fixed_width_string(command_space);
if (!query_user_string(app, &bar_cmd)) return;
hot_directory = make_fixed_width_string(even_more_space);
hot_directory = make_fixed_width_string(hot_directory_space);
hot_directory.size = app->directory_get_hot(app, hot_directory.str, hot_directory.memory_size);
push_parameter(app, par_flags, CLI_OverlapWithConflict);
@ -534,6 +535,26 @@ CUSTOM_COMMAND_SIG(execute_any_cli){
push_parameter(app, par_cli_path, hot_directory.str, hot_directory.size);
push_parameter(app, par_cli_command, bar_cmd.string.str, bar_cmd.string.size);
exec_command(app, cmdid_command_line);
terminate_with_null(&bar_out.string);
terminate_with_null(&bar_cmd.string);
terminate_with_null(&hot_directory);
}
CUSTOM_COMMAND_SIG(execute_previous_cli){
String out_buffer, cmd, hot_directory;
out_buffer = make_string_slowly(out_buffer_space);
cmd = make_string_slowly(command_space);
hot_directory = make_string_slowly(hot_directory_space);
if (out_buffer.size > 0 && cmd.size > 0 && hot_directory.size > 0){
push_parameter(app, par_flags, CLI_OverlapWithConflict);
push_parameter(app, par_name, out_buffer.str, out_buffer.size);
push_parameter(app, par_cli_path, hot_directory.str, hot_directory.size);
push_parameter(app, par_cli_command, cmd.str, cmd.size);
exec_command(app, cmdid_command_line);
}
}
CUSTOM_COMMAND_SIG(execute_arbitrary_command){

View File

@ -4783,7 +4783,7 @@ search_hit_add(General_Memory *general, Table *hits, String_Space *space, char *
*hits = new_hits;
}
if (table_add(hits, &ostring, space->space, tbl_offset_string_hash, tbl_offset_string_compare)){
if (!table_add(hits, &ostring, space->space, tbl_offset_string_hash, tbl_offset_string_compare)){
result = 1;
strspace_keep_prev(space);
}

View File

@ -1166,7 +1166,7 @@ gui_standard_list(GUI_Target *target, GUI_id id,
++*list_i;
break;
case '\n':
case '\n': case '\t':
indirectly_activate = 1;
break;
}

View File

@ -166,6 +166,8 @@ struct Win32_Vars{
// will involve more coroutines.
Win32_Coroutine coroutine_data[18];
Win32_Coroutine *coroutine_free;
i32 running_cli;
};
globalvar Win32_Vars win32vars;
@ -932,6 +934,8 @@ Sys_CLI_Call_Sig(system_cli_call){
*(HANDLE*)&cli_out->proc = info.hProcess;
*(HANDLE*)&cli_out->out_read = out_read;
*(HANDLE*)&cli_out->out_write = out_write;
++win32vars.running_cli;
}
else{
CloseHandle(out_read);
@ -943,6 +947,11 @@ Sys_CLI_Call_Sig(system_cli_call){
}
else{
// TODO(allen): failed SetHandleInformation
CloseHandle(out_read);
CloseHandle(out_write);
*(HANDLE*)&cli_out->proc = INVALID_HANDLE_VALUE;
*(HANDLE*)&cli_out->out_read = INVALID_HANDLE_VALUE;
*(HANDLE*)&cli_out->out_write = INVALID_HANDLE_VALUE;
}
}
else{
@ -1016,6 +1025,8 @@ Sys_CLI_End_Update_Sig(system_cli_end_update){
CloseHandle(*(HANDLE*)&cli->proc);
CloseHandle(*(HANDLE*)&cli->out_read);
CloseHandle(*(HANDLE*)&cli->out_write);
--win32vars.running_cli;
}
return close_me;
}
@ -1708,17 +1719,22 @@ UpdateLoop(LPVOID param){
#include <stdio.h>
#endif
#if 0
#if 1
int
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow){
int argc = __argc;
char **argv = __argv;
#else
int main(int argc, char **argv){
#endif
HINSTANCE hInstance = GetModuleHandle(0);
#endif
HANDLE original_out = GetStdHandle(STD_OUTPUT_HANDLE);
win32vars = {};
@ -1841,7 +1857,7 @@ int main(int argc, char **argv){
}
#endif
//FreeConsole();
FreeConsole();
sysshared_filter_real_files(files, file_count);
@ -2068,24 +2084,31 @@ int main(int argc, char **argv){
SetForegroundWindow(window_handle);
SetActiveWindow(window_handle);
#if 0
ResumeThread(win32vars.update_loop_thread);
#endif
MSG msg;
for (;win32vars.input_chunk.pers.keep_playing;){
win32vars.got_useful_event = 0;
for (;win32vars.got_useful_event == 0;){
system_release_lock(FRAME_LOCK);
if (GetMessage(&msg, 0, 0, 0)){
system_acquire_lock(FRAME_LOCK);
if (msg.message == WM_QUIT){
win32vars.input_chunk.pers.keep_playing = 0;
}else{
TranslateMessage(&msg);
DispatchMessage(&msg);
// TODO(allen): Find a good way to wait on a pipe
// without interfering with the reading process
if (win32vars.running_cli == 0){
win32vars.got_useful_event = 0;
for (;win32vars.got_useful_event == 0;){
system_release_lock(FRAME_LOCK);
if (GetMessage(&msg, 0, 0, 0)){
system_acquire_lock(FRAME_LOCK);
if (msg.message == WM_QUIT){
win32vars.input_chunk.pers.keep_playing = 0;
}else{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else{
system_acquire_lock(FRAME_LOCK);
}
}
else{
system_acquire_lock(FRAME_LOCK);
}
}