exit command

master
Allen Webster 2016-09-01 16:29:07 -04:00
parent 72ea42364d
commit f236e7c9d1
12 changed files with 67 additions and 33 deletions

View File

@ -91,6 +91,7 @@ Coming Soon</i><div>
<li><a href='#show_mouse_cursor_doc'>show_mouse_cursor</a></li> <li><a href='#show_mouse_cursor_doc'>show_mouse_cursor</a></li>
<li><a href='#toggle_fullscreen_doc'>toggle_fullscreen</a></li> <li><a href='#toggle_fullscreen_doc'>toggle_fullscreen</a></li>
<li><a href='#is_fullscreen_doc'>is_fullscreen</a></li> <li><a href='#is_fullscreen_doc'>is_fullscreen</a></li>
<li><a href='#send_exit_signal_doc'>send_exit_signal</a></li>
</ul> </ul>
<h3>&sect;3.2 Type List</h3> <h3>&sect;3.2 Type List</h3>
<ul> <ul>
@ -1066,12 +1067,21 @@ folders.</div></div><hr>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>void app->toggle_fullscreen( <div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>void app->toggle_fullscreen(
<div style='margin-left: 4mm;'>Application_Links *app<br></div>) <div style='margin-left: 4mm;'>Application_Links *app<br></div>)
</div> </div>
No documentation generated for this function, assume it is non-public.
</div><hr> </div><hr>
<div id='is_fullscreen_doc' style='margin-bottom: 1cm;'> <div id='is_fullscreen_doc' style='margin-bottom: 1cm;'>
<h4>&sect;3.3.59: is_fullscreen</h4> <h4>&sect;3.3.59: is_fullscreen</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>bool32 app->is_fullscreen( <div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>bool32 app->is_fullscreen(
<div style='margin-left: 4mm;'>Application_Links *app<br></div>) <div style='margin-left: 4mm;'>Application_Links *app<br></div>)
</div> </div>
No documentation generated for this function, assume it is non-public.
</div><hr>
<div id='send_exit_signal_doc' style='margin-bottom: 1cm;'>
<h4>&sect;3.3.60: send_exit_signal</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>void app->send_exit_signal(
<div style='margin-left: 4mm;'>Application_Links *app<br></div>)
</div>
No documentation generated for this function, assume it is non-public.
</div><hr> </div><hr>
<h3>&sect;3.4 Type Descriptions</h3> <h3>&sect;3.4 Type Descriptions</h3>
<h2 id='section_string_library'>&sect;4 String Library</h2> <h2 id='section_string_library'>&sect;4 String Library</h2>

View File

@ -57,6 +57,7 @@
#define SHOW_MOUSE_CURSOR_SIG(n) void n(Application_Links *app, Mouse_Cursor_Show_Type show) #define SHOW_MOUSE_CURSOR_SIG(n) void n(Application_Links *app, Mouse_Cursor_Show_Type show)
#define TOGGLE_FULLSCREEN_SIG(n) void n(Application_Links *app) #define TOGGLE_FULLSCREEN_SIG(n) void n(Application_Links *app)
#define IS_FULLSCREEN_SIG(n) bool32 n(Application_Links *app) #define IS_FULLSCREEN_SIG(n) bool32 n(Application_Links *app)
#define SEND_EXIT_SIGNAL_SIG(n) void n(Application_Links *app)
typedef EXEC_COMMAND_SIG(Exec_Command_Function); typedef EXEC_COMMAND_SIG(Exec_Command_Function);
typedef EXEC_SYSTEM_COMMAND_SIG(Exec_System_Command_Function); typedef EXEC_SYSTEM_COMMAND_SIG(Exec_System_Command_Function);
typedef CLIPBOARD_POST_SIG(Clipboard_Post_Function); typedef CLIPBOARD_POST_SIG(Clipboard_Post_Function);
@ -116,6 +117,7 @@ typedef GET_4ED_PATH_SIG(Get_4ed_Path_Function);
typedef SHOW_MOUSE_CURSOR_SIG(Show_Mouse_Cursor_Function); typedef SHOW_MOUSE_CURSOR_SIG(Show_Mouse_Cursor_Function);
typedef TOGGLE_FULLSCREEN_SIG(Toggle_Fullscreen_Function); typedef TOGGLE_FULLSCREEN_SIG(Toggle_Fullscreen_Function);
typedef IS_FULLSCREEN_SIG(Is_Fullscreen_Function); typedef IS_FULLSCREEN_SIG(Is_Fullscreen_Function);
typedef SEND_EXIT_SIGNAL_SIG(Send_Exit_Signal_Function);
struct Application_Links{ struct Application_Links{
void *memory; void *memory;
int32_t memory_size; int32_t memory_size;
@ -178,6 +180,7 @@ struct Application_Links{
Show_Mouse_Cursor_Function *show_mouse_cursor; Show_Mouse_Cursor_Function *show_mouse_cursor;
Toggle_Fullscreen_Function *toggle_fullscreen; Toggle_Fullscreen_Function *toggle_fullscreen;
Is_Fullscreen_Function *is_fullscreen; Is_Fullscreen_Function *is_fullscreen;
Send_Exit_Signal_Function *send_exit_signal;
void *cmd_context; void *cmd_context;
void *system_links; void *system_links;
void *current_coroutine; void *current_coroutine;
@ -242,4 +245,5 @@ app_links->directory_cd = Directory_CD;\
app_links->get_4ed_path = Get_4ed_Path;\ app_links->get_4ed_path = Get_4ed_Path;\
app_links->show_mouse_cursor = Show_Mouse_Cursor;\ app_links->show_mouse_cursor = Show_Mouse_Cursor;\
app_links->toggle_fullscreen = Toggle_Fullscreen;\ app_links->toggle_fullscreen = Toggle_Fullscreen;\
app_links->is_fullscreen = Is_Fullscreen; } while(false) app_links->is_fullscreen = Is_Fullscreen;\
app_links->send_exit_signal = Send_Exit_Signal; } while(false)

View File

@ -277,6 +277,7 @@ default_keys(Bind_Helper *context){
bind(context, key_f2, MDFR_NONE, toggle_mouse); bind(context, key_f2, MDFR_NONE, toggle_mouse);
bind(context, key_page_up, MDFR_CTRL, toggle_fullscreen); bind(context, key_page_up, MDFR_CTRL, toggle_fullscreen);
bind(context, key_f4, MDFR_ALT, exit_4coder);
end_map(context); end_map(context);

View File

@ -2108,6 +2108,10 @@ CUSTOM_COMMAND_SIG(eol_nixify){
app->buffer_set_setting(app, &buffer, BufferSetting_Eol, false); app->buffer_set_setting(app, &buffer, BufferSetting_Eol, false);
} }
CUSTOM_COMMAND_SIG(exit_4coder){
app->send_exit_signal(app);
}
// //
// "Full Search" Based Commands // "Full Search" Based Commands

View File

@ -399,35 +399,35 @@ seek_error(Application_Links *app,
} }
CUSTOM_COMMAND_SIG(goto_next_error){ CUSTOM_COMMAND_SIG(goto_next_jump){
int32_t skip_repeats = true; int32_t skip_repeats = true;
int32_t skip_sub_errors = true; int32_t skip_sub_errors = true;
int32_t dir = 1; int32_t dir = 1;
seek_error(app, &global_part, skip_repeats, skip_sub_errors, dir); seek_error(app, &global_part, skip_repeats, skip_sub_errors, dir);
} }
CUSTOM_COMMAND_SIG(goto_prev_error){ CUSTOM_COMMAND_SIG(goto_prev_jump){
int32_t skip_repeats = true; int32_t skip_repeats = true;
int32_t skip_sub_errors = true; int32_t skip_sub_errors = true;
int32_t dir = -1; int32_t dir = -1;
seek_error(app, &global_part, skip_repeats, skip_sub_errors, dir); seek_error(app, &global_part, skip_repeats, skip_sub_errors, dir);
} }
CUSTOM_COMMAND_SIG(goto_next_error_no_skips){ CUSTOM_COMMAND_SIG(goto_next_jump_no_skips){
int32_t skip_repeats = false; int32_t skip_repeats = false;
int32_t skip_sub_errors = true; int32_t skip_sub_errors = true;
int32_t dir = 1; int32_t dir = 1;
seek_error(app, &global_part, skip_repeats, skip_sub_errors, dir); seek_error(app, &global_part, skip_repeats, skip_sub_errors, dir);
} }
CUSTOM_COMMAND_SIG(goto_prev_error_no_skips){ CUSTOM_COMMAND_SIG(goto_prev_jump_no_skips){
int32_t skip_repeats = false; int32_t skip_repeats = false;
int32_t skip_sub_errors = true; int32_t skip_sub_errors = true;
int32_t dir = -1; int32_t dir = -1;
seek_error(app, &global_part, skip_repeats, skip_sub_errors, dir); seek_error(app, &global_part, skip_repeats, skip_sub_errors, dir);
} }
CUSTOM_COMMAND_SIG(goto_first_error){ CUSTOM_COMMAND_SIG(goto_first_jump){
Temp_Memory temp = begin_temp_memory(&global_part); Temp_Memory temp = begin_temp_memory(&global_part);
View_Summary view = get_view_for_locked_jump_buffer(app); View_Summary view = get_view_for_locked_jump_buffer(app);
@ -440,5 +440,10 @@ CUSTOM_COMMAND_SIG(goto_first_error){
end_temp_memory(temp); end_temp_memory(temp);
} }
#define goto_next_error goto_next_jump
#define goto_prev_error goto_prev_jump
#define goto_next_error_no_skips goto_next_jump_no_skips
#define goto_first_error goto_first_jump
#endif #endif

View File

@ -2053,6 +2053,7 @@ directories controlled on the custom side.
#define Toggle_Fullscreen system->toggle_fullscreen #define Toggle_Fullscreen system->toggle_fullscreen
#define Is_Fullscreen system->is_fullscreen #define Is_Fullscreen system->is_fullscreen
#define Send_Exit_Signal system->send_exit_signal
API_EXPORT File_List API_EXPORT File_List
Get_File_List(Application_Links *app, char *dir, int32_t len)/* Get_File_List(Application_Links *app, char *dir, int32_t len)/*

View File

@ -7,6 +7,7 @@
#define SHOW_MOUSE_CURSOR_SIG(n) void n(Application_Links *app, Mouse_Cursor_Show_Type show) #define SHOW_MOUSE_CURSOR_SIG(n) void n(Application_Links *app, Mouse_Cursor_Show_Type show)
#define TOGGLE_FULLSCREEN_SIG(n) void n(Application_Links *app) #define TOGGLE_FULLSCREEN_SIG(n) void n(Application_Links *app)
#define IS_FULLSCREEN_SIG(n) bool32 n(Application_Links *app) #define IS_FULLSCREEN_SIG(n) bool32 n(Application_Links *app)
#define SEND_EXIT_SIGNAL_SIG(n) void n(Application_Links *app)
typedef MEMORY_ALLOCATE_SIG(Memory_Allocate_Function); typedef MEMORY_ALLOCATE_SIG(Memory_Allocate_Function);
typedef MEMORY_SET_PROTECTION_SIG(Memory_Set_Protection_Function); typedef MEMORY_SET_PROTECTION_SIG(Memory_Set_Protection_Function);
typedef MEMORY_FREE_SIG(Memory_Free_Function); typedef MEMORY_FREE_SIG(Memory_Free_Function);
@ -16,3 +17,4 @@ typedef GET_4ED_PATH_SIG(Get_4ed_Path_Function);
typedef SHOW_MOUSE_CURSOR_SIG(Show_Mouse_Cursor_Function); typedef SHOW_MOUSE_CURSOR_SIG(Show_Mouse_Cursor_Function);
typedef TOGGLE_FULLSCREEN_SIG(Toggle_Fullscreen_Function); typedef TOGGLE_FULLSCREEN_SIG(Toggle_Fullscreen_Function);
typedef IS_FULLSCREEN_SIG(Is_Fullscreen_Function); typedef IS_FULLSCREEN_SIG(Is_Fullscreen_Function);
typedef SEND_EXIT_SIGNAL_SIG(Send_Exit_Signal_Function);

View File

@ -237,6 +237,7 @@ struct System_Functions{
Show_Mouse_Cursor_Function *show_mouse_cursor; Show_Mouse_Cursor_Function *show_mouse_cursor;
Toggle_Fullscreen_Function *toggle_fullscreen; Toggle_Fullscreen_Function *toggle_fullscreen;
Is_Fullscreen_Function *is_fullscreen; Is_Fullscreen_Function *is_fullscreen;
Send_Exit_Signal_Function *send_exit_signal;
// clipboard: 1 // clipboard: 1
System_Post_Clipboard *post_clipboard; System_Post_Clipboard *post_clipboard;

View File

@ -86,6 +86,7 @@
; [X] flag in create buffer to prevent making new files ; [X] flag in create buffer to prevent making new files
; [X] locking to a view for next position jumping ; [X] locking to a view for next position jumping
; [X] break down the build system and get away from the preproc hack ; [X] break down the build system and get away from the preproc hack
; [X] exit command
; [X] full screen option ; [X] full screen option
; [X] add to APIs ; [X] add to APIs
; [] try to make win32 version better ; [] try to make win32 version better
@ -101,7 +102,6 @@
; [] user file bar string ; [] user file bar string
; [] mouse down/up distinction ; [] mouse down/up distinction
; [] hook on exit ; [] hook on exit
; [] exit command
; [] read only files ; [] read only files
; ;

View File

@ -305,7 +305,7 @@ standard_build(char *cdir, uint32_t flags){
} }
#endif #endif
#if 0 #if 1
{ {
BEGIN_TIME_SECTION(); BEGIN_TIME_SECTION();
build(OPTS | INCLUDES | SHARED_CODE | flags, cdir, "4ed_app_target.cpp", build(OPTS | INCLUDES | SHARED_CODE | flags, cdir, "4ed_app_target.cpp",

View File

@ -125,11 +125,7 @@ struct Win32_Input_Chunk_Transient{
i8 mouse_wheel; i8 mouse_wheel;
b8 trying_to_kill; b8 trying_to_kill;
}; };
inline Win32_Input_Chunk_Transient static Win32_Input_Chunk_Transient null_input_chunk_transient = {0};
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;
@ -197,6 +193,10 @@ typedef struct Win32_Vars{
b32 lctrl_lalt_is_altgr; b32 lctrl_lalt_is_altgr;
b32 got_useful_event; b32 got_useful_event;
b32 full_screen;
b32 do_toggle;
WINDOWPLACEMENT GlobalWindowPosition;
b32 send_exit_signal;
HCURSOR cursor_ibeam; HCURSOR cursor_ibeam;
HCURSOR cursor_arrow; HCURSOR cursor_arrow;
@ -907,7 +907,7 @@ win32_init_drive_strings(Drive_Strings *dstrings){
// a little ground on always recognizing files as equivalent in exchange // a little ground on always recognizing files as equivalent in exchange
// for the ability to handle them very quickly when nothing strange is // for the ability to handle them very quickly when nothing strange is
// going on. // going on.
static int32_t internal int32_t
win32_canonical_ansi_name(Drive_Strings *dstrings, char *src, i32 len, char *dst, i32 max){ win32_canonical_ansi_name(Drive_Strings *dstrings, char *src, i32 len, char *dst, i32 max){
char *wrt = dst; char *wrt = dst;
char *wrt_stop = dst + max; char *wrt_stop = dst + max;
@ -1113,18 +1113,13 @@ for fullscreen toggling, see:
http://blogs.msdn.com/b/oldnewthing/archive/2010/04/12/9994016.aspx http://blogs.msdn.com/b/oldnewthing/archive/2010/04/12/9994016.aspx
*/ */
// TODO(allen): Move these into win32vars
static b32 full_screen = 0;
static b32 do_toggle = 0;
static WINDOWPLACEMENT GlobalWindowPosition = {sizeof(GlobalWindowPosition)};
internal void internal void
Win32ToggleFullscreen(void){ Win32ToggleFullscreen(void){
HWND Window = win32vars.window_handle; HWND Window = win32vars.window_handle;
LONG_PTR Style = GetWindowLongPtr(Window, GWL_STYLE); LONG_PTR Style = GetWindowLongPtr(Window, GWL_STYLE);
if (Style & WS_OVERLAPPEDWINDOW){ if (Style & WS_OVERLAPPEDWINDOW){
MONITORINFO MonitorInfo = {sizeof(MonitorInfo)}; MONITORINFO MonitorInfo = {sizeof(MonitorInfo)};
if(GetWindowPlacement(Window, &GlobalWindowPosition) && if(GetWindowPlacement(Window, &win32vars.GlobalWindowPosition) &&
GetMonitorInfo(MonitorFromWindow(Window, MONITOR_DEFAULTTOPRIMARY), &MonitorInfo)) GetMonitorInfo(MonitorFromWindow(Window, MONITOR_DEFAULTTOPRIMARY), &MonitorInfo))
{ {
SetWindowLongPtr(Window, GWL_STYLE, Style & ~WS_OVERLAPPEDWINDOW); SetWindowLongPtr(Window, GWL_STYLE, Style & ~WS_OVERLAPPEDWINDOW);
@ -1133,16 +1128,16 @@ Win32ToggleFullscreen(void){
MonitorInfo.rcMonitor.right - MonitorInfo.rcMonitor.left, MonitorInfo.rcMonitor.right - MonitorInfo.rcMonitor.left,
MonitorInfo.rcMonitor.bottom - MonitorInfo.rcMonitor.top, MonitorInfo.rcMonitor.bottom - MonitorInfo.rcMonitor.top,
SWP_NOOWNERZORDER | SWP_FRAMECHANGED); SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
full_screen = 1; win32vars.full_screen = 1;
} }
} }
else{ else{
SetWindowLongPtr(Window, GWL_STYLE, Style | WS_OVERLAPPEDWINDOW); SetWindowLongPtr(Window, GWL_STYLE, Style | WS_OVERLAPPEDWINDOW);
SetWindowPlacement(Window, &GlobalWindowPosition); SetWindowPlacement(Window, &win32vars.GlobalWindowPosition);
SetWindowPos(Window, 0, 0, 0, 0, 0, SetWindowPos(Window, 0, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
SWP_NOOWNERZORDER | SWP_FRAMECHANGED); SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
full_screen = 0; win32vars.full_screen = 0;
} }
} }
@ -1156,7 +1151,7 @@ focus it is automatically refullscreened.
internal void internal void
Win32FixFullscreenLoseFocus(b32 lose_focus){ Win32FixFullscreenLoseFocus(b32 lose_focus){
if (full_screen){ if (win32vars.full_screen){
HWND Window = win32vars.window_handle; HWND Window = win32vars.window_handle;
LONG_PTR Style = GetWindowLongPtr(Window, GWL_STYLE); LONG_PTR Style = GetWindowLongPtr(Window, GWL_STYLE);
@ -1491,6 +1486,7 @@ Win32LoadSystemCode(){
win32vars.system.toggle_fullscreen = Toggle_Fullscreen; win32vars.system.toggle_fullscreen = Toggle_Fullscreen;
win32vars.system.is_fullscreen = Is_Fullscreen; win32vars.system.is_fullscreen = Is_Fullscreen;
win32vars.system.send_exit_signal = Send_Exit_Signal;
win32vars.system.post_clipboard = system_post_clipboard; win32vars.system.post_clipboard = system_post_clipboard;
@ -1953,6 +1949,8 @@ WinMain(HINSTANCE hInstance,
memset(&win32vars, 0, sizeof(win32vars)); memset(&win32vars, 0, sizeof(win32vars));
win32vars.GlobalWindowPosition.length = sizeof(win32vars.GlobalWindowPosition);
// //
// Threads and Coroutines // Threads and Coroutines
// //
@ -2404,7 +2402,7 @@ WinMain(HINSTANCE hInstance,
} }
Win32_Input_Chunk input_chunk = win32vars.input_chunk; Win32_Input_Chunk input_chunk = win32vars.input_chunk;
win32vars.input_chunk.trans = win32_input_chunk_transient_zero(); win32vars.input_chunk.trans = null_input_chunk_transient;
input_chunk.pers.control_keys[MDFR_CAPS_INDEX] = GetKeyState(VK_CAPITAL) & 0x1; input_chunk.pers.control_keys[MDFR_CAPS_INDEX] = GetKeyState(VK_CAPITAL) & 0x1;
@ -2455,6 +2453,11 @@ WinMain(HINSTANCE hInstance,
result.trying_to_kill = input_chunk.trans.trying_to_kill; result.trying_to_kill = input_chunk.trans.trying_to_kill;
result.perform_kill = 0; result.perform_kill = 0;
if (win32vars.send_exit_signal){
result.trying_to_kill = 1;
win32vars.send_exit_signal = 0;
}
win32vars.app.step(&win32vars.system, win32vars.app.step(&win32vars.system,
&win32vars.target, &win32vars.target,
&memory_vars, &memory_vars,
@ -2465,9 +2468,9 @@ WinMain(HINSTANCE hInstance,
keep_playing = 0; keep_playing = 0;
} }
if (do_toggle){ if (win32vars.do_toggle){
Win32ToggleFullscreen(); Win32ToggleFullscreen();
do_toggle = 0; win32vars.do_toggle = 0;
} }
Win32SetCursorFromUpdate(result.mouse_cursor_type); Win32SetCursorFromUpdate(result.mouse_cursor_type);

View File

@ -177,25 +177,28 @@ DOC_SEE(Mouse_Cursor_Show_Type)
} }
API_EXPORT void API_EXPORT void
Toggle_Fullscreen(Application_Links *app)/* Toggle_Fullscreen(Application_Links *app){
*/{
/* NOTE(allen): Don't actually change window size now! /* NOTE(allen): Don't actually change window size now!
Tell the platform layer to do the toggle (or to cancel the toggle) Tell the platform layer to do the toggle (or to cancel the toggle)
later when the app.step function isn't running. If the size changes later when the app.step function isn't running. If the size changes
mid step, it messes up the rendering rules and stuff. */ mid step, it messes up the rendering rules and stuff. */
do_toggle = !do_toggle; win32vars.do_toggle = !win32vars.do_toggle;
} }
API_EXPORT bool32 API_EXPORT bool32
Is_Fullscreen(Application_Links *app)/* Is_Fullscreen(Application_Links *app){
*/{
/* NOTE(allen): This is a fancy way of say 'full_screen XOR do_toggle' /* NOTE(allen): This is a fancy way of say 'full_screen XOR do_toggle'
This way this function can always report the state the fullscreen This way this function can always report the state the fullscreen
will have when the next frame runs, given the number of toggles will have when the next frame runs, given the number of toggles
that have occurred this frame and the original value. */ that have occurred this frame and the original value. */
bool32 result = (full_screen + do_toggle) & 1; bool32 result = (win32vars.full_screen + win32vars.do_toggle) & 1;
return(result); return(result);
} }
API_EXPORT void
Send_Exit_Signal(Application_Links *app){
win32vars.send_exit_signal = 1;
}
// BOTTOM // BOTTOM