Mercurial
changeset 172:0face9898d04
[PostDog] Small changes.
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Mon, 19 Jan 2026 18:56:54 -0800 |
| parents | 295ac2e5ec00 |
| children | 827c6ac504cd 24fe8ff94056 |
| files | postdog/main.c seobeo/s_websocket.c |
| diffstat | 2 files changed, 12 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/postdog/main.c Mon Jan 19 17:33:18 2026 -0800 +++ b/postdog/main.c Mon Jan 19 18:56:54 2026 -0800 @@ -25,7 +25,7 @@ #include "third_party/raylib/custom.h" #ifndef POSTDOG_PATHS - #define POSTDOG_PATHS "/Users/mrjunejune/zenbu/postdog/history" + #define POSTDOG_PATHS "/home/june/zenbu/postdog/history" #endif #define SCREEN_WIDTH 1280 @@ -38,7 +38,8 @@ #define BODY_BUFFER_LENGTH 1024 * 1024 * 5 #define RESULT_BUFFER_LENGTH 1024 * 1024 * 5 -#define URL_TEXT_DEFAULT "https://httpbin.org/get" +// #define URL_TEXT_DEFAULT "https://httpbin.org/get" +#define URL_TEXT_DEFAULT "wss://mrjunejune.com/echo" #define HEADER_TEXT_DEFAULT "Content-Type: application/json" #define BODY_TEXT_DEFAULT "" #define GET_PARAM_TEXT_DEFAULT "foo bar" @@ -47,7 +48,7 @@ // TextArea Component // ============================================================================ -#define TEXT_SIZE_DEFAULT 10 // used to calcualte spacing +#define TEXT_SIZE_DEFAULT 20 // used to calcualte spacing #define TEXT_AREA_LINE_HEIGHT GuiGetStyle(DEFAULT, TEXT_SIZE) #define TEXT_AREA_PADDING 30 #define TEXT_AREA_CURSOR_WIDTH 2 @@ -1550,9 +1551,9 @@ if (uv_thread_create(&thread_id, PostDog_Websocket_Start, NULL) != 0) { - perror("Failed to create thread"); - memset(&thread_id, 0, sizeof(thread_id)); - return thread_id; + perror("Failed to create thread"); + memset(&thread_id, 0, sizeof(thread_id)); + return thread_id; } return thread_id; @@ -2179,7 +2180,7 @@ // Send button DrawRectangleRounded(layout->send_button, 0.3f, 8, g_colors.primary); Rectangle btn_text_rect = layout->send_button; - const char *btn_text = "Send"; + char *btn_text = "Send"; int text_width = MeasureText(btn_text, GuiGetStyle(DEFAULT, TEXT_SIZE)); DrawTextEx(GuiGetFont(), btn_text, @@ -2225,7 +2226,7 @@ }; DrawRectangleRounded(ws_send_btn, 0.3f, 8, g_colors.highlight); - const char *ws_text = "Send"; + char *ws_text = !ws ? "Connect" : "Send"; int ws_text_width = MeasureText(ws_text, GuiGetStyle(DEFAULT, TEXT_SIZE)); DrawTextEx(GuiGetFont(), ws_text, @@ -2247,8 +2248,6 @@ else { WS_BREAK = TRUE; - if (websocket_thread_id) - PostDog_Websocket_Destroy(websocket_thread_id); } // Result tabs @@ -2274,6 +2273,7 @@ // ======================================================================== // INITIALIZATION // ======================================================================== + SetConfigFlags(FLAG_WINDOW_UNDECORATED); // Initialize libuv main_loop = uv_default_loop(); @@ -2290,7 +2290,7 @@ // Load resources Font customFont = LoadFontEx("postdog/Roboto-Regular.ttf", 20, 0, 0); GuiSetFont(customFont); - GuiSetStyle(DEFAULT, TEXT_SIZE, 16); + GuiSetStyle(DEFAULT, TEXT_SIZE, TEXT_SIZE_DEFAULT); Image logo_original = LoadImage("postdog/logo_bigger.png"); ImageResize(&logo_original, 200, 200); @@ -2319,6 +2319,7 @@ snprintf(input_body_array[TAB_HEADER], HEADER_BUFFER_LENGTH, HEADER_TEXT_DEFAULT); snprintf(input_body_array[TAB_BODY], BODY_BUFFER_LENGTH, BODY_TEXT_DEFAULT); snprintf(input_body_array[TAB_GET_PARAMS], DEFAULT_TEXT_BUFFER_LENGTH, GET_PARAM_TEXT_DEFAULT); + snprintf(input_body_array[TAB_WEBSOCKET], DEFAULT_TEXT_BUFFER_LENGTH, GET_PARAM_TEXT_DEFAULT); // Initialize result buffers (body and headers tabs) Dowa_Array_Push(result_body_array, (char *)malloc(sizeof(char) * RESULT_BUFFER_LENGTH)); @@ -2391,7 +2392,6 @@ DrawHistoryList(&layout, mouse_pos, padding, ui_state.history_scroll_offset); DrawBodyPanels(&layout, &ui_state, padding); DrawURLBar(&layout, &ui_state, padding); - EndDrawing(); }
--- a/seobeo/s_websocket.c Mon Jan 19 17:33:18 2026 -0800 +++ b/seobeo/s_websocket.c Mon Jan 19 18:56:54 2026 -0800 @@ -134,26 +134,20 @@ "Sec-WebSocket-Version: 13\r\n", p_ws->path, p_ws->host, ws_key); - // Add custom headers if provided if (headers && strlen(headers) > 0) { - // Parse newline-separated headers and convert to HTTP format const char *line_start = headers; while (*line_start) { - // Skip leading whitespace while (*line_start == ' ' || *line_start == '\t') line_start++; if (*line_start == '\0') break; - // Find end of line const char *line_end = line_start; while (*line_end && *line_end != '\n') line_end++; - // Copy line if it contains a colon (valid header) size_t line_len = line_end - line_start; if (line_len > 0 && memchr(line_start, ':', line_len) != NULL) { - // Remove trailing whitespace/CR while (line_len > 0 && (line_start[line_len-1] == '\r' || line_start[line_len-1] == ' ' || line_start[line_len-1] == '\t')) line_len--; @@ -167,12 +161,10 @@ } } - // Move to next line line_start = (*line_end == '\n') ? line_end + 1 : line_end; } } - // End headers handshake[handshake_len++] = '\r'; handshake[handshake_len++] = '\n'; handshake[handshake_len] = '\0'; @@ -238,8 +230,6 @@ return Seobeo_WebSocket_Connect_With_Headers(url, NULL); } -// Seobeo_WebSocket_Mask_Data moved to s_websocket_common.c - static int32 Seobeo_WebSocket_Send_Frame(Seobeo_WebSocket *p_ws, Seobeo_WebSocket_Opcode opcode, const uint8 *payload, size_t payload_length, boolean fin) { @@ -528,8 +518,6 @@ return p_msg; } -// Seobeo_WebSocket_Message_Destroy moved to s_websocket_common.c - int32 Seobeo_WebSocket_Close(Seobeo_WebSocket *p_ws, uint16 code, const char *reason) { if (!p_ws || p_ws->state == SEOBEO_WS_STATE_CLOSED)