Mercurial
annotate postdog/main.c @ 144:043018c0f2f8
Fixed all debug loggers.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Fri, 09 Jan 2026 13:19:56 -0800 |
| parents | 249881ceff7b |
| children | 7387eec8e7f8 |
| rev | line source |
|---|---|
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1 #include <stdio.h> |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2 #include <stdlib.h> |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3 #include <string.h> |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4 #include <time.h> |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5 #include <sys/stat.h> |
|
111
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
6 #include "dowa/dowa.h" |
|
58
ccb42d5bf8fd
[PostDog] Somewhat working copy. That would use for testing.
June Park <parkjune1995@gmail.com>
parents:
57
diff
changeset
|
7 |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
8 #include <curl/curl.h> |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
9 #include "third_party/raylib/include/raylib.h" |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
10 #define RAYGUI_IMPLEMENTATION |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
11 #include "third_party/raylib/include/raygui.h" |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
12 |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
13 #ifndef POSTDOG_PATHS |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
14 #define POSTDOG_PATHS "/Users/mrjunejune/zenbu/postdog/history" |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
15 #endif |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
16 |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
17 #define SCREEN_WIDTH 1280 |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
18 #define SCREEN_HEIGHT 780 |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
19 #define MAX_SCROLL_HEIGHT 10000 |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
20 |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
21 #define HEADER_BUFFER_LENGTH 1024 * 4 |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
22 #define DEFAULT_TEXT_BUFFER_LENGTH 1024 * 4 |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
23 #define URL_TEXT_BUFFER_LENGTH 1024 * 10 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
24 #define BODY_BUFFER_LENGTH 1024 * 1024 * 5 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
25 #define RESULT_BUFFER_LENGTH 1024 * 1024 * 5 |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
26 |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
27 |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
28 #ifdef _WIN32 |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
29 #include <direct.h> |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
30 #include <io.h> |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
31 #define mkdir(path, mode) _mkdir(path) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
32 #define access _access |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
33 #define F_OK 0 |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
34 #else |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
35 #include <sys/stat.h> |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
36 #include <dirent.h> |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
37 #include <unistd.h> |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
38 #endif |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
39 |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
40 typedef Dowa_KV(char*, char*) INPUT_HASHMAP; |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
41 |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
42 typedef struct { |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
43 char *data; |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
44 size_t size; |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
45 } ResponseBuffer; |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
46 |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
47 typedef struct { |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
48 char *filename; |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
49 char *title; |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
50 Rectangle rect; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
51 long time_modified; |
|
117
b91f2dd6f84d
[PostDog] Fixed delete logic.
June Park <parkjune1995@gmail.com>
parents:
116
diff
changeset
|
52 boolean deleted; |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
53 } HistoryItem; |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
54 |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
55 typedef struct { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
56 Rectangle rectangle; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
57 char *label; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
58 bool active; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
59 } TabItem; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
60 |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
61 typedef enum { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
62 TAB_HEADER = 0, |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
63 TAB_BODY, |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
64 TAB_GET_PARAMS, |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
65 TAB_BAR, |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
66 TAB_LENGTH |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
67 } PostDog_Tab_Enum; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
68 |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
69 static uint32 counter = 0; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
70 HistoryItem *history_items = NULL; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
71 HistoryItem *new_history_items = NULL; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
72 |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
73 // Global UI state |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
74 char *url_input_text = NULL; |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
75 char *url_result_text = NULL; |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
76 char **url_body_map = NULL; |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
77 int active_method_dropdown = 0; |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
78 |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
79 int CompareHistoryItemsByDate(const void *a, const void *b) { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
80 HistoryItem *itemA = (HistoryItem *)a; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
81 HistoryItem *itemB = (HistoryItem *)b; |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
82 return (itemB->time_modified - itemA->time_modified); |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
83 } |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
84 |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
85 char *PostDog_Extract_Title(const char *filename) |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
86 { |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
87 char full_file_path[512] = {0}; |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
88 snprintf(full_file_path, 512, "%s/%s", POSTDOG_PATHS, filename); |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
89 FILE *file = fopen(full_file_path, "r"); |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
90 if (!file) |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
91 return strdup(filename); |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
92 |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
93 char *title = malloc(sizeof(char) * 512); |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
94 if (!fgets(title, 512, file)) { |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
95 fclose(file); |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
96 return strdup(filename); |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
97 } |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
98 |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
99 return title; |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
100 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
101 |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
102 // TODO: Make this into generic fucntion so I can use it across different thing. |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
103 void PostDog_List_Directory(const char *path, HistoryItem **p_file_arr) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
104 { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
105 HistoryItem *file_arr = *p_file_arr; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
106 #ifdef _WIN32 |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
107 struct _finddata_t fileinfo; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
108 intptr_t handle; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
109 char search_path[256]; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
110 sprintf(search_path, "%s\\*", path); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
111 |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
112 if ((handle = _findfirst(search_path, &fileinfo)) == -1L) { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
113 printf("Directory is empty or cannot be read.\n"); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
114 } else { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
115 do { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
116 HistoryItem item = {0}; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
117 item.filename = strdup(fileinfo.name); |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
118 item.title = PostDog_Extract_Title(fileinfo.name); |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
119 item.time_modified = fileinfo.time_write; |
|
117
b91f2dd6f84d
[PostDog] Fixed delete logic.
June Park <parkjune1995@gmail.com>
parents:
116
diff
changeset
|
120 item.deleted = FALSE; |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
121 Dowa_Array_Push(file_arr, item); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
122 } while (_findnext(handle, &fileinfo) == 0); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
123 _findclose(handle); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
124 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
125 #else |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
126 struct dirent *entry; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
127 struct stat file_stat; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
128 DIR *dp = opendir(path); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
129 if (dp == NULL) return; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
130 |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
131 char full_path[256]; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
132 while ((entry = readdir(dp))) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
133 { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
134 if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
135 continue; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
136 snprintf(full_path, sizeof(full_path), "%s/%s", path, entry->d_name); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
137 if (stat(full_path, &file_stat) == 0) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
138 { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
139 HistoryItem item = {0}; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
140 item.filename = strdup(entry->d_name); |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
141 item.title = PostDog_Extract_Title(entry->d_name); |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
142 item.time_modified = file_stat.st_mtime; |
|
117
b91f2dd6f84d
[PostDog] Fixed delete logic.
June Park <parkjune1995@gmail.com>
parents:
116
diff
changeset
|
143 item.deleted = FALSE; |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
144 Dowa_Array_Push(file_arr, item); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
145 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
146 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
147 closedir(dp); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
148 #endif |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
149 int count = Dowa_Array_Length(file_arr); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
150 if (count > 1) { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
151 qsort(file_arr, count, sizeof(HistoryItem), CompareHistoryItemsByDate); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
152 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
153 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
154 |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
155 int PostDog_History_Load(HistoryItem **p_history_files) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
156 { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
157 if (access(POSTDOG_PATHS, F_OK) == -1) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
158 { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
159 printf("Directory '%s' not found. Creating it...\n", POSTDOG_PATHS); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
160 if (mkdir(POSTDOG_PATHS, 0777) != 0) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
161 return -1; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
162 return 0; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
163 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
164 printf("Directory '%s' already exists.\n", POSTDOG_PATHS); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
165 PostDog_List_Directory(POSTDOG_PATHS, p_history_files); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
166 return 0; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
167 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
168 |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
169 bool InArea(Vector2 mouse_position, Rectangle area) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
170 { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
171 return ( |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
172 mouse_position.x >= area.x && |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
173 mouse_position.x < area.x + area.width && |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
174 mouse_position.y >= area.y && |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
175 mouse_position.y < area.y + area.height |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
176 ); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
177 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
178 |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
179 bool Clicked(Vector2 mouse_position, Rectangle area) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
180 { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
181 return (InArea(mouse_position, area) && IsMouseButtonPressed(MOUSE_BUTTON_LEFT)); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
182 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
183 |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
184 char *PostDog_Enum_To_String(int active_enum) |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
185 { |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
186 switch(active_enum) |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
187 { |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
188 case 0: return "GET"; |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
189 case 1: return "POST"; |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
190 case 2: return "PUT"; |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
191 case 3: return "DELETE"; |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
192 } |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
193 return 0; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
194 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
195 |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
196 char *PostDog_Construct_URL(char *filename) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
197 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
198 char full_file_path[512] = {0}; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
199 snprintf(full_file_path, 512, "%s/%s", POSTDOG_PATHS, filename); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
200 return &full_file_path; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
201 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
202 |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
203 void PostDog_History_CreateFile(char *filename, char* values) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
204 { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
205 char full_file_path[512] = {0}; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
206 snprintf(full_file_path, 512, "%s/%s", POSTDOG_PATHS, filename); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
207 FILE *file = fopen(full_file_path, "w"); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
208 if (!file) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
209 { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
210 printf("Failed to create a file: %s\n", full_file_path); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
211 return; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
212 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
213 fwrite(values, 1, strlen(values), file); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
214 fclose(file); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
215 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
216 |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
217 void PostDog_Request_SaveFile(void) |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
218 { |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
219 const char *method = PostDog_Enum_To_String(active_method_dropdown); |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
220 size_t new_file_size = 1024 * 1024; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
221 Dowa_Arena *arena = Dowa_Arena_Create(1024 * 1024 * 2); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
222 char *new_file = Dowa_Arena_Allocate(arena, 1024 * 1024); |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
223 char *title = malloc(strlen(method) + strlen(url_input_text) + 2); |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
224 sprintf(title, "%s %s", method, url_input_text); |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
225 snprintf( |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
226 new_file, |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
227 new_file_size, |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
228 "%s\n" |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
229 "---\n" |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
230 "%s\n" |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
231 "---\n" |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
232 "%s\n" |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
233 "---\n" |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
234 "%s\n" |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
235 "---\n" |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
236 "%s\n" |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
237 "---\n" |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
238 "%s\n" |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
239 "---\n" |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
240 "%s\n" |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
241 "---\n" |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
242 "%s\n", |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
243 title, |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
244 url_input_text, |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
245 method, |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
246 url_body_map[TAB_HEADER], |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
247 url_body_map[TAB_BODY], |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
248 url_body_map[TAB_GET_PARAMS], |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
249 url_body_map[TAB_BAR], |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
250 url_result_text |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
251 ); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
252 char *filename = Dowa_Arena_Allocate(arena, 1024); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
253 if (!filename) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
254 { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
255 perror("Error opening file"); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
256 exit(EXIT_FAILURE); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
257 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
258 char *uuid4 = (char *)Dowa_Arena_Allocate(arena, 37); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
259 if (!uuid4) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
260 { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
261 perror("Error uuid"); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
262 exit(EXIT_FAILURE); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
263 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
264 |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
265 int32 seed = (uint32)time(NULL) ^ counter++; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
266 Dowa_String_UUID(seed, uuid4); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
267 snprintf(filename, 1024, "%s.txt", uuid4); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
268 PostDog_History_CreateFile(filename, new_file); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
269 |
|
117
b91f2dd6f84d
[PostDog] Fixed delete logic.
June Park <parkjune1995@gmail.com>
parents:
116
diff
changeset
|
270 HistoryItem item = {0}; |
|
b91f2dd6f84d
[PostDog] Fixed delete logic.
June Park <parkjune1995@gmail.com>
parents:
116
diff
changeset
|
271 item.filename = strdup(filename); |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
272 item.title = title; |
|
117
b91f2dd6f84d
[PostDog] Fixed delete logic.
June Park <parkjune1995@gmail.com>
parents:
116
diff
changeset
|
273 item.deleted = FALSE; |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
274 Dowa_Array_Push(new_history_items, item); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
275 |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
276 Dowa_Arena_Free(arena); |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
277 } |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
278 |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
279 static size_t Postdog_Curl_Callback(void *contents, size_t size, size_t nmemb, void *userp) |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
280 { |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
281 size_t real_size = size * nmemb; |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
282 ResponseBuffer *buf = (ResponseBuffer *)userp; |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
283 |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
284 char *ptr = realloc(buf->data, buf->size + real_size + 1); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
285 if (ptr == NULL) |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
286 { |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
287 printf("Not enough memory for response\n"); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
288 return 0; |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
289 } |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
290 |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
291 buf->data = ptr; |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
292 memcpy(&(buf->data[buf->size]), contents, real_size); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
293 buf->size += real_size; |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
294 buf->data[buf->size] = 0; |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
295 |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
296 return real_size; |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
297 } |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
298 |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
299 int PostDog_Http_Request(void) |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
300 { |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
301 const char *method = PostDog_Enum_To_String(active_method_dropdown); |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
302 CURL *curl; |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
303 CURLcode res; |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
304 ResponseBuffer buffer = { .data = malloc(1), .size = 0 }; |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
305 |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
306 url_result_text[0] = '\n'; |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
307 |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
308 if (buffer.data == NULL) |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
309 { |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
310 snprintf(url_result_text, RESULT_BUFFER_LENGTH, "Error: Failed to allocate memory"); |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
311 return -1; |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
312 } |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
313 buffer.data[0] = '\0'; |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
314 |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
315 curl_global_init(CURL_GLOBAL_DEFAULT); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
316 curl = curl_easy_init(); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
317 |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
318 if (curl) |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
319 { |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
320 struct curl_slist *headerList = NULL; |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
321 |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
322 // Set URL |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
323 curl_easy_setopt(curl, CURLOPT_URL, url_input_text); |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
324 |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
325 // Set HTTP method |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
326 if (strcmp(method, "POST") == 0) |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
327 { |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
328 curl_easy_setopt(curl, CURLOPT_POST, 1L); |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
329 if (url_body_map[TAB_BODY] && strlen(url_body_map[TAB_BODY]) > 0) |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
330 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, url_body_map[TAB_BODY]); |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
331 } |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
332 else if (strcmp(method, "PUT") == 0) |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
333 { |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
334 curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
335 if (url_body_map[TAB_BODY] && strlen(url_body_map[TAB_BODY]) > 0) |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
336 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, url_body_map[TAB_BODY]); |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
337 } |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
338 else if (strcmp(method, "DELETE") == 0) |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
339 { |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
340 curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
341 } |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
342 // Default is GET |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
343 |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
344 // Parse and add headers |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
345 if (url_body_map[TAB_HEADER] && strlen(url_body_map[TAB_HEADER]) > 0) |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
346 { |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
347 char *headersCopy = strdup(url_body_map[TAB_HEADER]); |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
348 char *line = strtok(headersCopy, "\n"); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
349 while (line != NULL) { |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
350 while (*line == ' ' || *line == '\t') line++; |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
351 if (strlen(line) > 0) |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
352 headerList = curl_slist_append(headerList, line); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
353 line = strtok(NULL, "\n"); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
354 } |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
355 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerList); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
356 free(headersCopy); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
357 } |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
358 |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
359 // Set write callback |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
360 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, Postdog_Curl_Callback); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
361 curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&buffer); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
362 |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
363 // Follow redirects |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
364 curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
365 curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30L); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
366 res = curl_easy_perform(curl); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
367 |
|
111
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
368 if (res != CURLE_OK) |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
369 snprintf(url_result_text, RESULT_BUFFER_LENGTH, "Error: %s\n", curl_easy_strerror(res)); |
|
111
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
370 else |
|
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
371 { |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
372 long response_code; |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
373 curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
374 |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
375 if (buffer.size > RESULT_BUFFER_LENGTH) |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
376 printf("TODO: Realloc\n"); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
377 |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
378 snprintf(url_result_text, RESULT_BUFFER_LENGTH, "HTTP Status: %ld\n\n%s", |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
379 response_code, buffer.data ? buffer.data : ""); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
380 } |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
381 |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
382 if (headerList) curl_slist_free_all(headerList); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
383 curl_easy_cleanup(curl); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
384 } |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
385 else |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
386 snprintf(url_result_text, RESULT_BUFFER_LENGTH, "Error: Failed to initialize curl"); |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
387 |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
388 free(buffer.data); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
389 curl_global_cleanup(); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
390 |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
391 PostDog_Request_SaveFile(); |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
392 return 0; |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
393 } |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
394 |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
395 void PostDog_Update_URL(void) |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
396 { |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
397 // Save existing query string if present |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
398 char *question_mark = strchr(url_input_text, '?'); |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
399 if (question_mark) |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
400 *question_mark = '\0'; |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
401 |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
402 int get_params_length = (int)strlen(url_body_map[TAB_GET_PARAMS]); |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
403 if (get_params_length == 0) |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
404 return; |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
405 |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
406 char *separator = "?"; |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
407 |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
408 Dowa_Arena *arena = Dowa_Arena_Create(1024*1024); |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
409 char **lines = Dowa_String_Split(url_body_map[TAB_GET_PARAMS], "\n", get_params_length, 1, arena); |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
410 for (int i = 0; i < Dowa_Array_Length(lines); i++) |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
411 { |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
412 char *line = lines[i]; |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
413 char **key_value = Dowa_String_Split(line, " ", (int)strlen(line), 1, arena); |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
414 |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
415 if (Dowa_Array_Length(key_value) < 2) |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
416 break; |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
417 |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
418 strcat(url_input_text, separator); |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
419 strcat(url_input_text, key_value[0]); |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
420 strcat(url_input_text, "="); |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
421 for (int i = 1; i < Dowa_Array_Length(key_value); i++) |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
422 { |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
423 if (!key_value[i] || key_value[i][0] == '\0') |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
424 break; |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
425 if (i > 1) strcat(url_input_text, "%20"); |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
426 strcat(url_input_text, key_value[i]); |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
427 } |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
428 separator = "&"; |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
429 } |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
430 |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
431 Dowa_Arena_Free(arena); |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
432 } |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
433 |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
434 int PostDog_String_To_MethodEnum(char *value) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
435 { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
436 if (strstr(value, "GET")) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
437 return 0; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
438 if (strstr(value, "POST")) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
439 return 1; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
440 if (strstr(value, "PUT")) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
441 return 2; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
442 if (strstr(value, "DELETE")) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
443 return 3; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
444 return 0; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
445 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
446 |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
447 void PostDog_Params_Reset(void) |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
448 { |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
449 url_input_text[0] = '\0'; |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
450 url_result_text[0] = '\0'; |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
451 active_method_dropdown = 0; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
452 for (int i = 0; i < Dowa_Array_Length(url_body_map); i++) |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
453 url_body_map[i][0] = '\0'; |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
454 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
455 |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
456 void PostDog_Load_File(const char *filename) |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
457 { |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
458 char full_file_path[512] = {0}; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
459 snprintf(full_file_path, 512, "%s/%s", POSTDOG_PATHS, filename); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
460 FILE *file = fopen(full_file_path, "r"); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
461 if (!file) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
462 return; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
463 |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
464 fseek(file, 0, SEEK_END); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
465 size_t file_size = ftell(file); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
466 fseek(file, 0, SEEK_SET); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
467 |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
468 Dowa_Arena *init_arena = Dowa_Arena_Create(file_size + 2); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
469 Dowa_Arena *split_arena = Dowa_Arena_Create(file_size * 2); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
470 char *file_buffer = Dowa_Arena_Allocate(init_arena, file_size+1); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
471 fread(file_buffer, 1, file_size, file); |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
472 fclose(file); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
473 |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
474 char **values = Dowa_String_Split(file_buffer, "---\n", file_size, 4, split_arena); |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
475 |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
476 for (int i = 0; i < Dowa_Array_Length(values); i++) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
477 { |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
478 switch (i) |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
479 { |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
480 case 0: // Title - skip |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
481 break; |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
482 |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
483 case 1: // URL |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
484 snprintf(url_input_text, strlen(values[i]) + 1, "%s", values[i]); |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
485 url_input_text[strcspn(url_input_text, "\n")] = '\0'; |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
486 break; |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
487 |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
488 case 2: // Method |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
489 active_method_dropdown = PostDog_String_To_MethodEnum(values[i]); |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
490 break; |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
491 |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
492 case 3: // Headers (TAB_HEADER) |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
493 case 4: // Body (TAB_BODY) |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
494 case 5: // Get Params (TAB_GET_PARAMS) |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
495 case 6: // Bar (TAB_BAR) |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
496 { |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
497 int map_index = i - 3; // 3->0, 4->1, 5->2, 6->3 |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
498 snprintf(url_body_map[map_index], strlen(values[i]) + 1, "%s", values[i]); |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
499 // Trim trailing newlines |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
500 for (int j = strlen(values[i]); j > 0; j--) |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
501 { |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
502 if (url_body_map[map_index][j] == '\n') |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
503 { |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
504 url_body_map[map_index][j] = '\0'; |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
505 break; |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
506 } |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
507 } |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
508 break; |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
509 } |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
510 |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
511 default: // Response (index 7+) |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
512 snprintf(url_result_text, strlen(values[i]) + 1, "%s", values[i]); |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
513 break; |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
514 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
515 } |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
516 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
517 Dowa_Arena_Free(init_arena); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
518 Dowa_Arena_Free(split_arena); |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
519 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
520 |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
521 Rectangle AddPadding(Rectangle rect, float padding) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
522 { |
|
115
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
523 return (Rectangle){ |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
524 rect.x + padding, |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
525 rect.y + padding, |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
526 rect.width - (2 * padding), |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
527 rect.height - (2 * padding) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
528 }; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
529 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
530 |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
531 Rectangle AddPaddingHorizontal(Rectangle rect, float padding) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
532 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
533 return (Rectangle){ |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
534 rect.x + padding, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
535 rect.y, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
536 rect.width - (2 * padding), |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
537 rect.height |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
538 }; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
539 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
540 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
541 Rectangle AddPaddingVertical(Rectangle rect, float padding) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
542 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
543 return (Rectangle){ |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
544 rect.x, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
545 rect.y + padding, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
546 rect.width, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
547 rect.height - (2 * padding) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
548 }; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
549 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
550 |
|
115
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
551 // Layout helper functions |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
552 Rectangle RightOf(Rectangle ref, float padding) |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
553 { |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
554 return (Rectangle){ |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
555 .x = ref.x + ref.width + padding, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
556 .y = ref.y, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
557 .width = 0, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
558 .height = ref.height |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
559 }; |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
560 } |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
561 |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
562 Rectangle Below(Rectangle ref, float padding) |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
563 { |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
564 return (Rectangle){ |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
565 .x = ref.x, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
566 .y = ref.y + ref.height + padding, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
567 .width = ref.width, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
568 .height = 0 |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
569 }; |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
570 } |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
571 |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
572 Rectangle LeftColumn(Rectangle container, float ratio, float padding) |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
573 { |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
574 return (Rectangle){ |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
575 .x = container.x + padding, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
576 .y = container.y + padding, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
577 .width = (container.width * ratio) - padding, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
578 .height = container.height - (2 * padding) |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
579 }; |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
580 } |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
581 |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
582 Rectangle RightColumn(Rectangle container, Rectangle leftCol, float padding) |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
583 { |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
584 return (Rectangle){ |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
585 .x = leftCol.x + leftCol.width + padding, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
586 .y = container.y + padding, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
587 .width = container.width - leftCol.width - (3 * padding), |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
588 .height = container.height - (2 * padding) |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
589 }; |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
590 } |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
591 |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
592 Rectangle HorizontalSplit(Rectangle container, float ratio) |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
593 { |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
594 return (Rectangle){ |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
595 .x = container.x, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
596 .y = container.y, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
597 .width = container.width * ratio, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
598 .height = container.height |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
599 }; |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
600 } |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
601 |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
602 int main() |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
603 { |
|
111
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
604 // -- initizlied --// |
|
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
605 InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "PostDog"); |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
606 SetWindowState(FLAG_WINDOW_RESIZABLE); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
607 SetTargetFPS(60); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
608 |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
609 Font customFont = LoadFontEx("postdog/Roboto-Regular.ttf", 20, 0, 0); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
610 GuiSetFont(customFont); |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
611 GuiSetStyle(DEFAULT, TEXT_SIZE, 10); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
612 Image logo_original = LoadImage("postdog/epi_all_colors.png"); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
613 ImageResize(&logo_original, 60, 60); |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
614 SetWindowIcon(logo_original); |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
615 Texture2D logo_texture = LoadTextureFromImage(logo_original); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
616 UnloadImage(logo_original); |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
617 |
|
111
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
618 // -- Starting pos ---// |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
619 Rectangle history_sidebar = { 0 }; |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
620 Dowa_Array_Reserve(history_items, 10); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
621 Dowa_Array_Reserve(new_history_items, 10); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
622 PostDog_History_Load(&history_items); |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
623 int32 *history_deleted_items = NULL; |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
624 |
|
111
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
625 Rectangle url_area = { 0 }; |
|
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
626 Rectangle textBounds = { 0 }; |
|
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
627 Rectangle url_input_bounds = { 0 }; |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
628 bool url_input_edit = false; |
|
111
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
629 Rectangle url_text_bounds = { 0 }; |
|
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
630 Rectangle url_enter_button = { 0 }; |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
631 Rectangle method_dropdown = { 0 }; |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
632 |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
633 |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
634 // Initialize global UI state |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
635 url_input_text = (char *)malloc(sizeof(char) * URL_TEXT_BUFFER_LENGTH); |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
636 snprintf(url_input_text, URL_TEXT_BUFFER_LENGTH, "https://httpbin.org/get"); |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
637 |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
638 Dowa_Array_Push(url_body_map, (char *)malloc(sizeof(char) * HEADER_BUFFER_LENGTH)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
639 Dowa_Array_Push(url_body_map, (char *)malloc(sizeof(char) * BODY_BUFFER_LENGTH)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
640 Dowa_Array_Push(url_body_map, (char *)malloc(sizeof(char) * DEFAULT_TEXT_BUFFER_LENGTH)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
641 Dowa_Array_Push(url_body_map, (char *)malloc(sizeof(char) * DEFAULT_TEXT_BUFFER_LENGTH)); |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
642 |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
643 snprintf(url_body_map[TAB_HEADER], HEADER_BUFFER_LENGTH, "Content-Type: application/json"); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
644 snprintf(url_body_map[TAB_BODY], HEADER_BUFFER_LENGTH, ""); |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
645 |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
646 url_result_text = (char *)malloc(sizeof(char) * RESULT_BUFFER_LENGTH); |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
647 |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
648 bool method_edit = false; |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
649 |
|
111
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
650 int sendRequest; |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
651 |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
652 // -- input --// |
|
111
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
653 Rectangle input_area = { 0 }; |
|
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
654 Rectangle input_tab = { 0 }; |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
655 Rectangle input_tab_item = { 0 }; |
|
111
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
656 Rectangle input_body = { 0 }; |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
657 bool input_body_bool = false; |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
658 |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
659 // -- result --// |
|
111
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
660 Rectangle result_area = { 0 }; |
|
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
661 Rectangle result_body = { 0 }; |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
662 |
|
111
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
663 // General styling. |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
664 float padding = 10; // TODO make it % based? |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
665 int active_input_tab = 0; |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
666 int prev_input_tab = 0; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
667 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
668 // Scroll offsets |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
669 float history_scroll_offset = 0; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
670 float input_body_scroll_offset = 0; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
671 float result_body_scroll_offset = 0; |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
672 |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
673 while (!WindowShouldClose()) |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
674 { |
|
111
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
675 int screen_width = GetScreenWidth(); |
|
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
676 int screen_height = GetScreenHeight(); |
|
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
677 |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
678 if ((IsKeyDown(KEY_LEFT_SUPER) || IsKeyDown(KEY_LEFT_CONTROL)) && IsKeyDown(KEY_EQUAL)) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
679 GuiSetStyle(DEFAULT, TEXT_SIZE, GuiGetStyle(DEFAULT, TEXT_SIZE) + 1); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
680 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
681 if ((IsKeyDown(KEY_LEFT_SUPER) || IsKeyDown(KEY_LEFT_CONTROL)) && IsKeyDown(KEY_MINUS)) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
682 GuiSetStyle(DEFAULT, TEXT_SIZE, GuiGetStyle(DEFAULT, TEXT_SIZE) - 1); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
683 |
|
115
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
684 Rectangle screen = { 0, 0, screen_width, screen_height }; |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
685 |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
686 // -- Side bar --// |
|
115
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
687 history_sidebar = LeftColumn(screen, 0.15, padding); |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
688 Rectangle content_area = RightColumn(screen, history_sidebar, padding); |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
689 Rectangle logo_area = (Rectangle){ |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
690 .x = history_sidebar.x, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
691 .y = history_sidebar.y, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
692 .width = history_sidebar.width, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
693 .height = 80 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
694 }; |
|
115
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
695 |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
696 Rectangle history_list_area = Below(logo_area, padding); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
697 history_list_area.width = history_sidebar.width; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
698 history_list_area.height = history_sidebar.height - logo_area.height - padding; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
699 |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
700 int32 new_history_items_length = Dowa_Array_Length(new_history_items); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
701 int32 history_item_length = Dowa_Array_Length(history_items); |
|
115
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
702 int32 total = new_history_items_length + history_item_length; |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
703 float item_height = history_list_area.height * 0.10; |
|
115
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
704 |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
705 int32 number_of_skipped_items = 0; |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
706 for (int i = 0; i < total; i++) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
707 { |
|
115
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
708 HistoryItem *curr_history_items = i < new_history_items_length ? |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
709 &new_history_items[i - new_history_items_length - 1] : &history_items[i - new_history_items_length]; |
|
115
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
710 |
|
117
b91f2dd6f84d
[PostDog] Fixed delete logic.
June Park <parkjune1995@gmail.com>
parents:
116
diff
changeset
|
711 if (curr_history_items->deleted) |
|
b91f2dd6f84d
[PostDog] Fixed delete logic.
June Park <parkjune1995@gmail.com>
parents:
116
diff
changeset
|
712 { |
|
b91f2dd6f84d
[PostDog] Fixed delete logic.
June Park <parkjune1995@gmail.com>
parents:
116
diff
changeset
|
713 number_of_skipped_items++; |
|
b91f2dd6f84d
[PostDog] Fixed delete logic.
June Park <parkjune1995@gmail.com>
parents:
116
diff
changeset
|
714 continue; |
|
b91f2dd6f84d
[PostDog] Fixed delete logic.
June Park <parkjune1995@gmail.com>
parents:
116
diff
changeset
|
715 } |
|
b91f2dd6f84d
[PostDog] Fixed delete logic.
June Park <parkjune1995@gmail.com>
parents:
116
diff
changeset
|
716 |
|
115
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
717 curr_history_items->rect = (Rectangle){ |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
718 .x = history_list_area.x, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
719 .y = history_list_area.y + (padding + item_height) * (i - number_of_skipped_items) + history_scroll_offset, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
720 .width = history_list_area.width, |
|
115
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
721 .height = item_height |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
722 }; |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
723 } |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
724 |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
725 // --- URL --- // |
|
115
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
726 url_area = (Rectangle){ |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
727 .x = content_area.x, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
728 .y = content_area.y, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
729 .width = content_area.width, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
730 .height = content_area.height * 0.1 |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
731 }; |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
732 |
|
115
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
733 float url_control_y = url_area.y + (url_area.height - TEXT_SIZE * 2) / 2; |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
734 |
|
115
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
735 url_text_bounds = (Rectangle){ |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
736 .x = url_area.x + padding, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
737 .y = url_control_y, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
738 .width = 7 * (TEXT_SIZE / 2), |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
739 .height = TEXT_SIZE * 2 |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
740 }; |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
741 |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
742 url_input_bounds = RightOf(url_text_bounds, padding); |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
743 url_input_bounds.width = url_area.width * 0.7; |
|
111
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
744 url_input_bounds.height = TEXT_SIZE * 2; |
|
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
745 |
|
115
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
746 url_enter_button = RightOf(url_input_bounds, padding); |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
747 url_enter_button.width = url_area.width * 0.1; |
|
111
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
748 url_enter_button.height = TEXT_SIZE * 2; |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
749 |
|
115
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
750 method_dropdown = RightOf(url_enter_button, padding); |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
751 method_dropdown.width = url_area.width * 0.1; |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
752 method_dropdown.height = TEXT_SIZE * 2; |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
753 |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
754 // -- Body -- // |
|
115
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
755 Rectangle body_area = Below(url_area, 0); |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
756 body_area.height = content_area.height - url_area.height; |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
757 |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
758 input_area = HorizontalSplit(body_area, 0.5); |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
759 result_area = RightOf(input_area, 0); |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
760 result_area.width = body_area.width - input_area.width; |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
761 |
|
115
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
762 input_tab = (Rectangle){ |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
763 .x = input_area.x + padding, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
764 .y = input_area.y + padding, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
765 .width = input_area.width - (2 * padding), |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
766 .height = input_area.height * 0.1 |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
767 }; |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
768 |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
769 input_tab_item = input_tab; |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
770 input_tab_item.width = input_tab.width / 4; |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
771 |
|
115
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
772 input_body = Below(input_tab, 0); |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
773 input_body.width = input_tab.width; |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
774 input_body.height = input_area.height - input_tab.height - (2 * padding); |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
775 |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
776 // -- Result -- / |
|
115
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
777 result_body = (Rectangle){ |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
778 .x = result_area.x + padding, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
779 .y = input_body.y, |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
780 .width = result_area.width - (2 * padding), |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
781 .height = input_body.height |
|
96db6c3f38d6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
114
diff
changeset
|
782 }; |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
783 |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
784 Vector2 mouse_position = GetMousePosition(); |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
785 float mouse_wheel = GetMouseWheelMove(); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
786 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
787 // Reset input body scroll when tab changes |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
788 if (prev_input_tab != active_input_tab) { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
789 input_body_scroll_offset = 0; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
790 prev_input_tab = active_input_tab; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
791 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
792 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
793 // Handle scroll wheel for history |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
794 if (InArea(mouse_position, history_list_area) && mouse_wheel != 0) { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
795 history_scroll_offset += mouse_wheel * 30; // 30 pixels per wheel tick |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
796 // Clamp scroll offset |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
797 float max_scroll = (total * (item_height + padding)) - history_list_area.height; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
798 if (history_scroll_offset > 0) history_scroll_offset = 0; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
799 if (history_scroll_offset < -max_scroll && max_scroll > 0) history_scroll_offset = -max_scroll; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
800 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
801 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
802 // Handle scroll wheel for input body |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
803 if (InArea(mouse_position, input_body) && mouse_wheel != 0) { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
804 input_body_scroll_offset += mouse_wheel * 30; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
805 if (input_body_scroll_offset > 0) input_body_scroll_offset = 0; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
806 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
807 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
808 // Handle scroll wheel for result body |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
809 if (InArea(mouse_position, result_body) && mouse_wheel != 0) { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
810 result_body_scroll_offset += mouse_wheel * 30; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
811 if (result_body_scroll_offset > 0) result_body_scroll_offset = 0; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
812 } |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
813 |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
814 BeginDrawing(); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
815 ClearBackground(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR))); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
816 |
|
111
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
817 DrawRectangleRec(history_sidebar, Fade(GRAY, 0.1f)); |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
818 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
819 // DrawRectangleRec(logo_area, Fade(BLUE, 0.2f)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
820 Rectangle logo_image_rect = AddPadding(logo_area, padding); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
821 // Fit logo to area while maintaining aspect ratio |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
822 float logo_size = logo_image_rect.height < logo_image_rect.width ? logo_image_rect.height : logo_image_rect.width; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
823 Rectangle dest = { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
824 .x = logo_image_rect.x + (logo_image_rect.width - logo_size) / 2, // Center horizontally |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
825 .y = logo_image_rect.y, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
826 .width = logo_size, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
827 .height = logo_size |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
828 }; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
829 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
830 Rectangle source = { 0, 0, logo_texture.width, logo_texture.height }; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
831 DrawTexturePro(logo_texture, source, dest, (Vector2){0, 0}, 0.0f, WHITE); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
832 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
833 BeginScissorMode(history_list_area.x, history_list_area.y, history_list_area.width, history_list_area.height); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
834 for (int i = 0; i < total; i++) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
835 { |
|
117
b91f2dd6f84d
[PostDog] Fixed delete logic.
June Park <parkjune1995@gmail.com>
parents:
116
diff
changeset
|
836 HistoryItem *curr_history_items = i < new_history_items_length ? |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
837 &new_history_items[i - new_history_items_length - 1] : &history_items[i - new_history_items_length]; |
|
117
b91f2dd6f84d
[PostDog] Fixed delete logic.
June Park <parkjune1995@gmail.com>
parents:
116
diff
changeset
|
838 |
|
b91f2dd6f84d
[PostDog] Fixed delete logic.
June Park <parkjune1995@gmail.com>
parents:
116
diff
changeset
|
839 if (curr_history_items->deleted) |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
840 continue; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
841 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
842 float diff = curr_history_items->rect.height*0.3; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
843 // DrawRectangleRec(curr_history_items->rect, Fade(RED, 0.1f)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
844 Rectangle filename_area = curr_history_items->rect; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
845 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
846 filename_area.height -= diff; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
847 Rectangle icon_area = Below(filename_area, 0); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
848 icon_area.height = diff; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
849 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
850 DrawRectangleRec(filename_area, Fade(BLUE, 0.1f)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
851 DrawRectangleRec(icon_area, Fade(YELLOW, 0.1f)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
852 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
853 Rectangle icon_area_left_column = LeftColumn(icon_area, 0.5, 0); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
854 Rectangle icon_area_right_column = RightColumn(icon_area, icon_area_left_column, 0); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
855 |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
856 GuiDrawText(curr_history_items->title, AddPadding(filename_area, padding), TEXT_ALIGN_CENTER, RED); |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
857 if (GuiButton(AddPaddingHorizontal(icon_area_left_column, padding), "view")) |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
858 PostDog_Load_File(curr_history_items->filename); |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
859 if (GuiButton(AddPaddingHorizontal(icon_area_right_column,padding), "delete")) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
860 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
861 if (!remove(PostDog_Construct_URL(curr_history_items->filename))) |
|
117
b91f2dd6f84d
[PostDog] Fixed delete logic.
June Park <parkjune1995@gmail.com>
parents:
116
diff
changeset
|
862 curr_history_items->deleted = TRUE; |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
863 else |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
864 fprintf(stderr, "Wasn't able to delete file: %s \n", curr_history_items->filename); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
865 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
866 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
867 EndScissorMode(); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
868 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
869 if (total > 0) |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
870 { |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
871 float content_height = total * (item_height + padding); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
872 if (content_height > history_list_area.height) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
873 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
874 float scrollbar_height = (history_list_area.height / content_height) * history_list_area.height; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
875 float scrollbar_y = history_list_area.y - (history_scroll_offset / content_height) * history_list_area.height; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
876 Rectangle scrollbar = { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
877 history_list_area.x + history_list_area.width - 5, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
878 scrollbar_y, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
879 5, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
880 scrollbar_height |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
881 }; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
882 DrawRectangleRec(scrollbar, Fade(WHITE, 0.5f)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
883 } |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
884 } |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
885 |
|
111
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
886 // URL area Rect |
|
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
887 GuiDrawText("URL: ", url_text_bounds, TEXT_ALIGN_CENTER, RED); |
|
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
888 DrawRectangleRec(url_area, Fade(RED, 0.1f)); |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
889 if (GuiTextBox(url_input_bounds, url_input_text, DEFAULT_TEXT_BUFFER_LENGTH, url_input_edit)) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
890 url_input_edit = !url_input_edit; |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
891 |
|
111
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
892 sendRequest = GuiButton(url_enter_button, "ENTER"); |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
893 if (sendRequest) |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
894 PostDog_Http_Request(); |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
895 if (GuiDropdownBox(method_dropdown, "GET;POST;PUT;DELETE", &active_method_dropdown, method_edit)) |
|
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
896 method_edit = !method_edit; |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
897 |
|
111
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
898 // Input Tabs Rect |
|
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
899 DrawRectangleRec(input_area, Fade(BLUE, 0.1f)); |
|
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
900 DrawRectangleRec(input_tab, Fade(DARKBLUE, 0.1f)); |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
901 GuiSetStyle(TOGGLE, GROUP_PADDING, 0); |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
902 GuiDrawRectangle(input_body, 1, GetColor(GuiGetStyle(TEXTBOX, BORDER)), GetColor(GuiGetStyle(TEXTBOX, BASE_COLOR_PRESSED))); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
903 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
904 BeginScissorMode(input_body.x, input_body.y, input_body.width, input_body.height); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
905 Rectangle scrolled_input = AddPadding(input_body, padding * 2); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
906 scrolled_input.y += input_body_scroll_offset; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
907 scrolled_input.height = MAX_SCROLL_HEIGHT; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
908 if (JUNE_GuiTextBox(scrolled_input, url_body_map[active_input_tab], DEFAULT_TEXT_BUFFER_LENGTH, input_body_bool)) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
909 input_body_bool = !input_body_bool; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
910 EndScissorMode(); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
911 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
912 if (input_body_scroll_offset < 0) { |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
913 float scrollbar_height = 10; |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
914 float scrollbar_y = input_body.y - (input_body_scroll_offset / MAX_SCROLL_HEIGHT) * (input_body.height - scrollbar_height); |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
915 Rectangle scrollbar = { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
916 input_body.x + input_body.width - 5, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
917 scrollbar_y, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
918 5, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
919 scrollbar_height |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
920 }; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
921 DrawRectangleRec(scrollbar, Fade(BLUE, 0.5f)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
922 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
923 |
|
112
d6d578b49a19
[PostDog] Got CRUD working.
June Park <parkjune1995@gmail.com>
parents:
111
diff
changeset
|
924 GuiToggleGroup(input_tab_item, "Header;Body;Get Param;Bar", &active_input_tab); |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
925 |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
926 PostDog_Update_URL(); |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
927 |
|
111
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
928 // Result Rect |
|
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
929 DrawRectangleRec(result_area, Fade(GREEN, 0.1f)); |
|
48f260576059
[PostDog] Rewriting it from scratch as it is unreadable for me.
June Park <parkjune1995@gmail.com>
parents:
63
diff
changeset
|
930 DrawRectangleRec(result_body, Fade(DARKGREEN, 0.1f)); |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
931 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
932 // Create scrollable result body with offset |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
933 BeginScissorMode(result_body.x, result_body.y, result_body.width, result_body.height); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
934 Rectangle scrolled_result = result_body; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
935 scrolled_result.y += result_body_scroll_offset; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
936 scrolled_result.height = MAX_SCROLL_HEIGHT; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
937 GuiTextBoxMulti(scrolled_result, url_result_text, RESULT_BUFFER_LENGTH, false); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
938 EndScissorMode(); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
939 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
940 if (result_body_scroll_offset < 0) { |
|
118
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
941 float scrollbar_height = 10; |
|
249881ceff7b
[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
June Park <parkjune1995@gmail.com>
parents:
117
diff
changeset
|
942 float scrollbar_y = result_body.y - (result_body_scroll_offset / MAX_SCROLL_HEIGHT) * (result_body.height - scrollbar_height); |
|
116
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
943 Rectangle scrollbar = { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
944 result_body.x + result_body.width - 5, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
945 scrollbar_y, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
946 5, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
947 scrollbar_height |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
948 }; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
949 DrawRectangleRec(scrollbar, Fade(GREEN, 0.5f)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
115
diff
changeset
|
950 } |
|
114
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
951 |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
952 if (url_input_edit && (IsKeyDown(KEY_LEFT_SUPER) || IsKeyDown(KEY_LEFT_CONTROL)) && IsKeyPressed(KEY_C)) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
953 { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
954 SetClipboardText(url_input_text); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
955 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
956 else if (input_body_bool && (IsKeyDown(KEY_LEFT_SUPER) || IsKeyDown(KEY_LEFT_CONTROL)) && IsKeyPressed(KEY_C)) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
957 { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
958 SetClipboardText(url_body_map[active_input_tab]); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
959 } |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
960 else if (InArea(mouse_position, result_body)) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
961 { |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
962 DrawRectangleRec(result_body, Fade(GREEN, 0.3f)); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
963 if ((IsKeyDown(KEY_LEFT_SUPER) || IsKeyDown(KEY_LEFT_CONTROL)) && IsKeyPressed(KEY_C)) |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
964 SetClipboardText(url_result_text); |
|
e2a73e64e8e6
[Postdog] Got history working.
June Park <parkjune1995@gmail.com>
parents:
112
diff
changeset
|
965 } |
|
54
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
966 EndDrawing(); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
967 } |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
968 CloseWindow(); |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
969 return 0; |
|
b3e82d22f961
[PostDog] Initial commit BROKEN
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
970 } |