fstr_bool string_set_match(
String *str_set,
int32_t count,
String str,
int32_t *match_index
)
diff --git a/4coder_jump_parsing.cpp b/4coder_jump_parsing.cpp
index 3be9f794..9de0631d 100644
--- a/4coder_jump_parsing.cpp
+++ b/4coder_jump_parsing.cpp
@@ -440,10 +440,10 @@ CUSTOM_COMMAND_SIG(goto_first_jump){
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
+#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
diff --git a/4coder_string.h b/4coder_string.h
index e561f4e8..c6bbdfc9 100644
--- a/4coder_string.h
+++ b/4coder_string.h
@@ -157,6 +157,7 @@ FSTRING_INLINE String path_of_directory(String dir);
FSTRING_LINK fstr_bool set_last_folder_sc(String *dir, char *folder_name, char slash);
FSTRING_LINK fstr_bool set_last_folder_ss(String *dir, String folder_name, char slash);
FSTRING_LINK String file_extension(String str);
+FSTRING_LINK fstr_bool remove_extension(String *str);
FSTRING_LINK fstr_bool remove_last_folder(String *str);
FSTRING_LINK fstr_bool string_set_match(String *str_set, int32_t count, String str, int32_t *match_index);
@@ -1854,6 +1855,22 @@ file_extension(String str){
}
#endif
+#if defined(FSTRING_IMPLEMENTATION)
+FSTRING_LINK fstr_bool
+remove_extension(String *str){
+ fstr_bool result = 0;
+ int32_t i;
+ for (i = str->size - 1; i >= 0; --i){
+ if (str->str[i] == '.') break;
+ }
+ if (i >= 0){
+ result = 1;
+ str->size = i + 1;
+ }
+ return(result);
+}
+#endif
+
#if defined(FSTRING_IMPLEMENTATION)
FSTRING_LINK fstr_bool
remove_last_folder(String *str){
diff --git a/4ed.cpp b/4ed.cpp
index 08555bd6..119cbd27 100644
--- a/4ed.cpp
+++ b/4ed.cpp
@@ -1088,6 +1088,7 @@ enum Command_Line_Action{
CLAct_WindowMaximize,
CLAct_WindowPosition,
CLAct_WindowFullscreen,
+ CLAct_WindowStreamMode,
CLAct_FontSize,
CLAct_FontStopHinting,
CLAct_Count
@@ -1123,6 +1124,7 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
case 'W': action = CLAct_WindowMaximize; break;
case 'p': action = CLAct_WindowPosition; break;
case 'F': action = CLAct_WindowFullscreen; break;
+ case 'S': action = CLAct_WindowStreamMode; break;
case 'f': action = CLAct_FontSize; break;
case 'h': action = CLAct_FontStopHinting; --i; break;
@@ -1197,6 +1199,14 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
{
--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;
@@ -2481,6 +2491,7 @@ App_Step_Sig(app_step){
"-4coder now supports proper, borderless, fullscreen with the flag -F\n"
" and fullscreen can be toggled with
.\n"
" (This sometimes causes artifacts on the Windows task bar)\n"
+ "- to exit\n"
"\n"
"New in alpha 4.0.10:\n"
"- list all locations of a string across all open buffers\n"
diff --git a/4ed.h b/4ed.h
index b5915718..eccc2a29 100644
--- a/4ed.h
+++ b/4ed.h
@@ -67,6 +67,7 @@ typedef struct Plat_Settings{
char *custom_dll;
b32 custom_dll_is_strict;
b32 fullscreen_window;
+ b32 stream_mode;
i32 window_w, window_h;
i32 window_x, window_y;
diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp
index 244d6f73..5038a30a 100644
--- a/4ed_api_implementation.cpp
+++ b/4ed_api_implementation.cpp
@@ -164,7 +164,7 @@ DOC_SEE(Command_ID)
result = true;
}
else{
- app->print_message(app, literal("CUSTOM WARNING: An invalid Command_ID was passed to exec_command."));
+ app->print_message(app, literal("WARNING: An invalid Command_ID was passed to exec_command."));
}
return(result);
diff --git a/build.c b/build.c
index ab7c51e9..23f1aa7c 100644
--- a/build.c
+++ b/build.c
@@ -294,7 +294,7 @@ standard_build(char *cdir, uint32_t flags){
}
#endif
-#if 1
+#if 0
{
BEGIN_TIME_SECTION();
//buildsuper(cdir, BUILD_DIR, "../code/4coder_default_bindings.cpp");
diff --git a/internal_4coder_string.cpp b/internal_4coder_string.cpp
index d42b08f0..54294541 100644
--- a/internal_4coder_string.cpp
+++ b/internal_4coder_string.cpp
@@ -1580,6 +1580,22 @@ DOC_SEE(substr) */{
return(make_string(str.str+i, str.size-i));
}
+FSTRING_LINK fstr_bool
+remove_extension(String *str)/*
+DOC(This call attemps to delete a file extension off the end of a filename.
+This call returns non-zero on success.) */{
+ fstr_bool result = 0;
+ int32_t i;
+ for (i = str->size - 1; i >= 0; --i){
+ if (str->str[i] == '.') break;
+ }
+ if (i >= 0){
+ result = 1;
+ str->size = i + 1;
+ }
+ return(result);
+}
+
FSTRING_LINK fstr_bool
remove_last_folder(String *str)/*
DOC(This call attemps to delete a folder or filename off the end of a path string.
diff --git a/win32_4ed.cpp b/win32_4ed.cpp
index 7e788e45..0543a503 100644
--- a/win32_4ed.cpp
+++ b/win32_4ed.cpp
@@ -45,7 +45,7 @@ struct Custom_API{
typedef void Custom_Command_Function;
#include "4coder_types.h"
struct Application_Links;
-# include "4ed_os_custom_api.h"
+# include "4coder_custom_api.h"
//# include "4coder_custom.h"
#else
@@ -1141,40 +1141,6 @@ Win32ToggleFullscreen(void){
}
}
-/*
-NOTE(allen):
-This is the crazy hacky nonsense I came up with to get alt-tab
-working in full screen mode. It puts the window back into
-bordered mode when the alt-tabbing begins. When the window regains
-focus it is automatically refullscreened.
-*/
-
-internal void
-Win32FixFullscreenLoseFocus(b32 lose_focus){
- if (win32vars.full_screen){
-
- HWND Window = win32vars.window_handle;
- LONG_PTR Style = GetWindowLongPtr(Window, GWL_STYLE);
-
- MONITORINFO MonitorInfo = {sizeof(MonitorInfo)};
- if(GetMonitorInfo(MonitorFromWindow(Window, MONITOR_DEFAULTTOPRIMARY), &MonitorInfo))
- {
- if (lose_focus){
- SetWindowLongPtr(Window, GWL_STYLE, Style | WS_OVERLAPPEDWINDOW);
- }
- else{
- SetWindowLongPtr(Window, GWL_STYLE, Style & ~WS_OVERLAPPEDWINDOW);
- }
-
- SetWindowPos(Window, HWND_TOP,
- MonitorInfo.rcMonitor.left, MonitorInfo.rcMonitor.top,
- MonitorInfo.rcMonitor.right - MonitorInfo.rcMonitor.left,
- MonitorInfo.rcMonitor.bottom - MonitorInfo.rcMonitor.top,
- SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
- }
- }
-}
-
#include "win32_api_impl.cpp"
//
@@ -1871,10 +1837,6 @@ Win32Callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
win32vars.input_chunk.pers.mouse_r = 0;
win32vars.input_chunk.pers.controls = control_keys_zero();
-
- if (uMsg == WM_SETFOCUS){
- Win32FixFullscreenLoseFocus(false);
- }
}break;
case WM_SIZE:
@@ -1910,7 +1872,6 @@ Win32Callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
case WM_CANCELMODE:
{
- Win32FixFullscreenLoseFocus(true);
result = DefWindowProc(hwnd, uMsg, wParam, lParam);
}break;
@@ -2234,10 +2195,18 @@ WinMain(HINSTANCE hInstance,
GetClientRect(win32vars.window_handle, &window_rect);
+ DWORD pfd_flags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
+
+ // NOTE(allen): This is probably not an issue on linux and
+ // does not need to be ported.
+ if (!win32vars.settings.stream_mode){
+ pfd_flags |= PFD_DOUBLEBUFFER;
+ }
+
static PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
- PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
+ pfd_flags,
PFD_TYPE_RGBA,
32,
0, 0, 0, 0, 0, 0,
@@ -2356,33 +2325,40 @@ WinMain(HINSTANCE hInstance,
// Looks like we can ReadFile with a size of zero
// in an IOCP for this effect.
- system_release_lock(FRAME_LOCK);
-
- if (win32vars.running_cli == 0){
- win32vars.got_useful_event = 0;
- for (;win32vars.got_useful_event == 0;){
- if (GetMessage(&msg, 0, 0, 0)){
- if (msg.message == WM_QUIT){
- keep_playing = 0;
- }else{
- TranslateMessage(&msg);
- DispatchMessage(&msg);
+ // NOTE(allen): When we're in stream mode we don't have
+ // double buffering so we need to move ahead and call
+ // the first step right away so it will render into the
+ // window. With double buffering this is not an issue
+ // for reasons I cannot at all comprehend.
+ if (!(win32vars.first && win32vars.settings.stream_mode)){
+ system_release_lock(FRAME_LOCK);
+
+ if (win32vars.running_cli == 0){
+ win32vars.got_useful_event = 0;
+ for (;win32vars.got_useful_event == 0;){
+ if (GetMessage(&msg, 0, 0, 0)){
+ if (msg.message == WM_QUIT){
+ keep_playing = 0;
+ }else{
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
}
}
}
- }
-
- while (PeekMessage(&msg, 0, 0, 0, 1)){
- if (msg.message == WM_QUIT){
- keep_playing = 0;
- }else{
- TranslateMessage(&msg);
- DispatchMessage(&msg);
+
+ while (PeekMessage(&msg, 0, 0, 0, 1)){
+ if (msg.message == WM_QUIT){
+ keep_playing = 0;
+ }else{
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
}
+
+ system_acquire_lock(FRAME_LOCK);
}
- system_acquire_lock(FRAME_LOCK);
-
POINT mouse_point;
if (GetCursorPos(&mouse_point) &&
ScreenToClient(win32vars.window_handle, &mouse_point)){
diff --git a/win32_api_impl.cpp b/win32_api_impl.cpp
index 631f54d1..13b937f4 100644
--- a/win32_api_impl.cpp
+++ b/win32_api_impl.cpp
@@ -182,12 +182,19 @@ Toggle_Fullscreen(Application_Links *app){
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
mid step, it messes up the rendering rules and stuff. */
- win32vars.do_toggle = !win32vars.do_toggle;
+
+ // NOTE(allen): On windows we must be in stream mode to go fullscreen.
+ if (win32vars.settings.stream_mode){
+ win32vars.do_toggle = !win32vars.do_toggle;
+ }
+ else{
+ app->print_message(app, literal("WARNING: Cannot go full screen unless 4coder is in stream mode\n Use the flag -S to put 4coder in stream mode.\n"));
+ }
}
API_EXPORT bool32
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 to say 'full_screen XOR do_toggle'
This way this function can always report the state the fullscreen
will have when the next frame runs, given the number of toggles
that have occurred this frame and the original value. */