This commit is contained in:
Krzosa Karol
2024-08-16 07:23:50 +02:00
parent 2065c9ded7
commit afd4e1d21c
9 changed files with 44 additions and 20 deletions

View File

@@ -130,7 +130,9 @@ int CompileTextEditor() {
int result = 0;
Array<Library> libs = {};
libs.add(PrepareSDLDynamic());
// if (Profile == PROFILE_DEBUG) libs.add(PrepareSDLDynamic());
// else
libs.add(PrepareSDL());
libs.add(PrepareLua());
libs.add(PrepareGlad());

View File

@@ -796,23 +796,13 @@ int64_t CreateWidecharFromChar(wchar_t *buffer, int64_t buffer_size, char *i
inline bool operator==(String a, String b) { return AreEqual(a, b); }
inline bool operator!=(String a, String b) { return !AreEqual(a, b); }
#if defined(__has_attribute) && defined(_MSC_VER) && !defined(__clang__)
#if __has_attribute(format)
#define PrintfFormatAttribute(fmt, va) __attribute__((format(printf, fmt, va)))
#endif
#endif
#ifndef PrintfFormatAttribute
#define PrintfFormatAttribute(fmt, va)
#endif
#define STRING_FORMAT(allocator, data, result) \
va_list args1; \
va_start(args1, data); \
String result = FormatV(allocator, data, args1); \
va_end(args1)
String Format(Allocator allocator, const char *data, ...) PrintfFormatAttribute(2, 3);
String Format(Allocator allocator, const char *data, ...);
String FormatV(Allocator allocator, const char *data, va_list args1);
String ToString(Allocator allocator, String16 string);
String ToString(Allocator allocator, wchar_t *string, int64_t len);
@@ -1569,7 +1559,7 @@ String FormatV(Allocator allocator, const char *data, va_list args1) {
return res;
}
String Format(Allocator allocator, const char *data, ...) PrintfFormatAttribute(2, 3) {
String Format(Allocator allocator, const char *data, ...) {
STRING_FORMAT(allocator, data, result);
return result;
}

View File

@@ -237,7 +237,7 @@ bool StartsWith(String16 a, String16 start, unsigned ignore_case = false) {
return result;
}
String16 Copy(Allocator allocator, String16 string) {
String16 Copy16(Allocator allocator, String16 string) {
wchar_t *copy = (wchar_t *)AllocSize(allocator, sizeof(wchar_t) * (string.len + 1));
memcpy(copy, string.data, string.len);
copy[string.len] = 0;
@@ -245,7 +245,7 @@ String16 Copy(Allocator allocator, String16 string) {
return result;
}
String16 Copy(Allocator allocator, wchar_t *string) {
String16 Copy16(Allocator allocator, wchar_t *string) {
String16 s = {string, (int64_t)WideLength(string)};
return Copy(allocator, s);
}

View File

@@ -1,4 +1,4 @@
#if 1
#if DEBUG_BUILD
#include "spall.h"
static SpallProfile spall_ctx;

View File

@@ -28,6 +28,7 @@ void OffsetAllLinesForward(Buffer *buffer, Int line, Int *_offset) {
}
void UpdateLines(Buffer *buffer, Range range, String16 string) {
if (buffer->no_line_starts) return;
ProfileFunction();
Array<Int> &ls = buffer->line_starts;
Int min_line_number = PosToLine(buffer, range.min);
@@ -125,3 +126,22 @@ void IKnowWhatImDoing_Appendf(Buffer *buffer, const char *fmt, ...) {
String16 string16 = ToString16(scratch, string);
IKnowWhatImDoing_ReplaceText(buffer, GetEndAsRange(buffer), string16);
}
void IKnowWhatImDoing_Append(Buffer *buffer, Int num) {
IKnowWhatImDoing_Appendf(buffer, "%d", num);
}
// Buffer &operator<<(Buffer &buffer, Int num) {
// IKnowWhatImDoing_Appendf(&buffer, "%lld", (long long)num);
// return buffer;
// }
// Buffer &operator<<(Buffer &buffer, double num) {
// IKnowWhatImDoing_Appendf(&buffer, "%f", num);
// return buffer;
// }
// Buffer &operator<<(Buffer &buffer, String16 string) {
// IKnowWhatImDoing_Append(&buffer, string);
// return buffer;
// }

View File

@@ -101,7 +101,7 @@ void InitBuffer(Allocator allocator, Buffer *buffer, String name, Int size = 409
buffer->line_starts.allocator = allocator;
buffer->undo_stack.allocator = allocator;
buffer->redo_stack.allocator = allocator;
Add(&buffer->line_starts, (Int)0);
if (!buffer->no_line_starts) Add(&buffer->line_starts, (Int)0);
}
Buffer *CreateBuffer(Allocator allocator, String name, Int size) {
@@ -112,8 +112,9 @@ Buffer *CreateBuffer(Allocator allocator, String name, Int size) {
}
Buffer *CreateTempBuffer(Allocator allocator, Int size = 4096) {
Buffer *result = AllocType(allocator, Buffer);
result->no_history = true;
Buffer *result = AllocType(allocator, Buffer);
result->no_history = true;
result->no_line_starts = true;
InitBuffer(allocator, result, "*temp*", size);
return result;
}

View File

@@ -0,0 +1,10 @@
-- this is going to output all the enviroment variables into the bar after it executes vcvarsall.
-- Sentinel is for separating errors from data
local id = C '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64 && echo SOME_SENTINEL_VALUE && set'
local buffer_id = GetBufferID(id)
while ProcessIsRunning(id) do coroutine.yield() end
local string = GetBufferString(buffer_id)
local lines = SplitIntoLines(string)
Skip past sentinel value
Parse the enviroment and then pass that value into new processes

View File

@@ -226,9 +226,9 @@ int main(int argc, char **argv)
char **argv = __argv;
#endif
BeginProfiler();
InitScratch();
InitArena(&Perm);
WorkingDir = GetWorkingDir(Perm);
ExeDir = GetExeDir(Perm);
{

View File

@@ -41,6 +41,7 @@ struct Buffer {
int edit_phase;
struct {
int no_history : 1;
int no_line_starts : 1;
int dirty : 1;
int is_directory : 1;
int gc : 1;