Success running on linux
This commit is contained in:
6
build.sh
Normal file
6
build.sh
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
mkdir build
|
||||||
|
pushd build
|
||||||
|
clang -o build_tool.exe ../src/build_tool/build_tool_main.cpp -fdiagnostics-absolute-paths -g -nostdlib++ -fno-exceptions
|
||||||
|
popd
|
||||||
|
|
||||||
|
build/build_tool.exe
|
||||||
106
build_file.cpp
106
build_file.cpp
@@ -5,32 +5,44 @@ enum {
|
|||||||
PROFILE_RELEASE,
|
PROFILE_RELEASE,
|
||||||
};
|
};
|
||||||
int Profile = PROFILE_DEBUG;
|
int Profile = PROFILE_DEBUG;
|
||||||
|
#if OS_WINDOWS
|
||||||
S8_String Compiler = "cl.exe";
|
S8_String Compiler = "cl.exe";
|
||||||
|
#else
|
||||||
|
S8_String Compiler = "clang";
|
||||||
|
#endif
|
||||||
|
|
||||||
void AddCommonFlags(Array<S8_String> *cmd) {
|
void AddCommonFlags(Array<S8_String> *cmd) {
|
||||||
if (Compiler == "cl.exe") {
|
if (Compiler == "clang") {
|
||||||
cmd->add("/MP");
|
cmd->add("-g");
|
||||||
}
|
cmd->add("-Wno-writable-strings");
|
||||||
cmd->add("/Zi /FC /nologo");
|
cmd->add("-fdiagnostics-absolute-paths");
|
||||||
cmd->add("/WX /W3 /wd4200 /diagnostics:column");
|
cmd->add("-nostdlib++");
|
||||||
if (Compiler == "clang-cl.exe") {
|
cmd->add("-fno-exceptions");
|
||||||
cmd->add("-fdiagnostics-absolute-paths");
|
|
||||||
cmd->add("-Wno-missing-braces");
|
|
||||||
cmd->add("-Wno-writable-strings");
|
|
||||||
cmd->add("-Wno-unused-function");
|
|
||||||
}
|
|
||||||
cmd->add("/Oi");
|
|
||||||
cmd->add("-D_CRT_SECURE_NO_WARNINGS");
|
|
||||||
if (Profile == PROFILE_DEBUG) {
|
|
||||||
cmd->add("-DDEBUG_BUILD=1");
|
|
||||||
cmd->add("-DRELEASE_BUILD=0");
|
|
||||||
// cmd->add("-fsanitize=address");
|
|
||||||
// cmd->add("-DUSE_ADDRESS_SANITIZER");
|
|
||||||
// cmd->add("/MDd");
|
|
||||||
} else {
|
} else {
|
||||||
cmd->add("-DDEBUG_BUILD=0");
|
if (Compiler == "cl.exe") {
|
||||||
cmd->add("-DRELEASE_BUILD=1");
|
cmd->add("/MP");
|
||||||
cmd->add("/O2 /MT /DNDEBUG /GL");
|
}
|
||||||
|
cmd->add("/Zi /FC /nologo");
|
||||||
|
cmd->add("/WX /W3 /wd4200 /diagnostics:column");
|
||||||
|
if (Compiler == "clang-cl.exe") {
|
||||||
|
cmd->add("-fdiagnostics-absolute-paths");
|
||||||
|
cmd->add("-Wno-missing-braces");
|
||||||
|
cmd->add("-Wno-writable-strings");
|
||||||
|
cmd->add("-Wno-unused-function");
|
||||||
|
}
|
||||||
|
cmd->add("/Oi");
|
||||||
|
cmd->add("-D_CRT_SECURE_NO_WARNINGS");
|
||||||
|
if (Profile == PROFILE_DEBUG) {
|
||||||
|
cmd->add("-DDEBUG_BUILD=1");
|
||||||
|
cmd->add("-DRELEASE_BUILD=0");
|
||||||
|
// cmd->add("-fsanitize=address");
|
||||||
|
// cmd->add("-DUSE_ADDRESS_SANITIZER");
|
||||||
|
// cmd->add("/MDd");
|
||||||
|
} else {
|
||||||
|
cmd->add("-DDEBUG_BUILD=0");
|
||||||
|
cmd->add("-DRELEASE_BUILD=1");
|
||||||
|
cmd->add("/O2 /MT /DNDEBUG /GL");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,18 +82,6 @@ Library PrepareSDLDynamic() {
|
|||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
Library PrepareRaylib() {
|
|
||||||
Library l = {};
|
|
||||||
l.include_paths.add("../src/external/raylib/include");
|
|
||||||
if (0) {
|
|
||||||
l.objects.add("../src/external/raylib/lib/raylib.lib");
|
|
||||||
} else {
|
|
||||||
l.objects.add("../src/external/raylib/lib/raylibdll.lib");
|
|
||||||
OS_CopyFile("../src/external/raylib/lib/raylib.dll", "./raylib.dll", false);
|
|
||||||
}
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
Library PrepareLua() {
|
Library PrepareLua() {
|
||||||
Library l = {};
|
Library l = {};
|
||||||
l.include_paths.add("../src/external/lua/src");
|
l.include_paths.add("../src/external/lua/src");
|
||||||
@@ -93,7 +93,7 @@ Library PrepareLua() {
|
|||||||
if (S8_EndsWith(it.filename, ".c", true)) {
|
if (S8_EndsWith(it.filename, ".c", true)) {
|
||||||
l.sources.add(it.absolute_path);
|
l.sources.add(it.absolute_path);
|
||||||
S8_String file = S8_ChopLastPeriod(it.filename);
|
S8_String file = S8_ChopLastPeriod(it.filename);
|
||||||
l.objects.add(Fmt("%.*s.obj", S8_Expand(file)));
|
l.objects.add(Fmt("%.*s" IF_WINDOWS_ELSE(".obj", ".o"), S8_Expand(file)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +113,11 @@ Library PrepareGlad() {
|
|||||||
Library l = {};
|
Library l = {};
|
||||||
l.sources.add("../src/external/glad/glad.c");
|
l.sources.add("../src/external/glad/glad.c");
|
||||||
l.include_paths.add("../src/external/glad/");
|
l.include_paths.add("../src/external/glad/");
|
||||||
|
#if OS_WINDOWS
|
||||||
l.objects.add("glad.obj");
|
l.objects.add("glad.obj");
|
||||||
|
#else
|
||||||
|
l.objects.add("glad.o");
|
||||||
|
#endif
|
||||||
if (!OS_FileExists(l.objects[0])) {
|
if (!OS_FileExists(l.objects[0])) {
|
||||||
Array<S8_String> cmd = {};
|
Array<S8_String> cmd = {};
|
||||||
cmd.add(Compiler);
|
cmd.add(Compiler);
|
||||||
@@ -126,6 +130,33 @@ Library PrepareGlad() {
|
|||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CompileTextEditorLinux() {
|
||||||
|
Array<S8_String> cmd = {};
|
||||||
|
|
||||||
|
Array<Library> libs = {};
|
||||||
|
libs.add(PrepareLua());
|
||||||
|
libs.add(PrepareGlad());
|
||||||
|
|
||||||
|
cmd.add("clang");
|
||||||
|
cmd.add("../src/text_editor/text_editor.cpp");
|
||||||
|
cmd.add("../src/basic/unix.cpp");
|
||||||
|
cmd.add("-o te_linux.exe");
|
||||||
|
cmd.add("-I../src");
|
||||||
|
// cmd.add("-Wall");
|
||||||
|
AddCommonFlags(&cmd);
|
||||||
|
For2(lib, libs) For(lib.include_paths) cmd.add(Fmt("-I %.*s", S8_Expand(it)));
|
||||||
|
For2(lib, libs) For(lib.defines) cmd.add(it);
|
||||||
|
// cmd.add("-L../src/external/SDL/build/");
|
||||||
|
cmd.add("-I../src/external/SDL/build/include");
|
||||||
|
cmd.add("-lm");
|
||||||
|
cmd.add("../src/external/SDL/build/libSDL3.a");
|
||||||
|
For2(lib, libs) For(lib.link) cmd.add(it);
|
||||||
|
For(libs) For2(o, it.objects) cmd.add(o);
|
||||||
|
|
||||||
|
int result = Run(cmd);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
int CompileTextEditor() {
|
int CompileTextEditor() {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
@@ -354,7 +385,12 @@ int main() {
|
|||||||
|
|
||||||
GenerateLuaApi();
|
GenerateLuaApi();
|
||||||
GenerateConfig();
|
GenerateConfig();
|
||||||
|
|
||||||
|
#if OS_WINDOWS
|
||||||
int result = CompileTextEditor();
|
int result = CompileTextEditor();
|
||||||
|
#else
|
||||||
|
int result = CompileTextEditorLinux();
|
||||||
|
#endif
|
||||||
// int result = CompileNewPlatform();
|
// int result = CompileNewPlatform();
|
||||||
|
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ Style.TrimWhitespaceOnSave = true
|
|||||||
Style.ClangFormatOnSave = false
|
Style.ClangFormatOnSave = false
|
||||||
|
|
||||||
INTERNET_BROWSER = 'C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe'
|
INTERNET_BROWSER = 'C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe'
|
||||||
|
OS_WINDOWS = 0
|
||||||
|
OS_UNIX = 1
|
||||||
|
|
||||||
SDLK_CTRL = 1073742048
|
SDLK_CTRL = 1073742048
|
||||||
SDLK_PAGE_DOWN = 1073741902
|
SDLK_PAGE_DOWN = 1073741902
|
||||||
@@ -144,7 +146,7 @@ function SkipDrive(s)
|
|||||||
return new_s, drive, true
|
return new_s, drive, true
|
||||||
end
|
end
|
||||||
|
|
||||||
function SkipPathCell(s)
|
function WindowsSkipPathCell(s)
|
||||||
local i, j = s:find("^[%w_%.-% +]+")
|
local i, j = s:find("^[%w_%.-% +]+")
|
||||||
if not i then return s, nil, false end
|
if not i then return s, nil, false end
|
||||||
|
|
||||||
@@ -155,7 +157,7 @@ function SkipPathCell(s)
|
|||||||
return new_s, word, found_slash
|
return new_s, word, found_slash
|
||||||
end
|
end
|
||||||
|
|
||||||
function SkipPath(s)
|
function WindowsSkipPath(s)
|
||||||
local input_s = s
|
local input_s = s
|
||||||
local s, drive, ok = SkipDrive(s)
|
local s, drive, ok = SkipDrive(s)
|
||||||
if not ok then return s end
|
if not ok then return s end
|
||||||
@@ -166,7 +168,7 @@ function SkipPath(s)
|
|||||||
end
|
end
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
s, word, slash_eaten = SkipPathCell(s)
|
s, word, slash_eaten = WindowsSkipPathCell(s)
|
||||||
if word then cells[#cells + 1] = word end
|
if word then cells[#cells + 1] = word end
|
||||||
if not slash_eaten then break end
|
if not slash_eaten then break end
|
||||||
end
|
end
|
||||||
@@ -179,7 +181,7 @@ function SkipPath(s)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function MatchWindowsPath(_s, meta)
|
function MatchWindowsPath(_s, meta)
|
||||||
local s, file_path, drive = SkipPath(_s)
|
local s, file_path, drive = WindowsSkipPath(_s)
|
||||||
|
|
||||||
if not file_path and FileExists(drive) then
|
if not file_path and FileExists(drive) then
|
||||||
return {kind = "text", file_path = drive, line = line, col = col}
|
return {kind = "text", file_path = drive, line = line, col = col}
|
||||||
@@ -201,6 +203,22 @@ function MatchWindowsPath(_s, meta)
|
|||||||
return {kind = "text", file_path = file_path, line = line, col = col}
|
return {kind = "text", file_path = file_path, line = line, col = col}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function MatchUnixPath(s, meta)
|
||||||
|
local i, j = s:find("^[%w_%.-% %/]+")
|
||||||
|
local path = s:sub(i, j)
|
||||||
|
local rest = s:sub(j + 1, -1)
|
||||||
|
local line, col, s = SkipLineAndColumn(rest)
|
||||||
|
Print(path, rest, line, col)
|
||||||
|
|
||||||
|
return {kind = "text", file_path = path, line = line, col = col}
|
||||||
|
end
|
||||||
|
|
||||||
|
if OS_VALUE == OS_WINDOWS then
|
||||||
|
MatchPath = MatchWindowsPath
|
||||||
|
else
|
||||||
|
MatchPath = MatchUnixPath
|
||||||
|
end
|
||||||
|
|
||||||
function MatchGitCommit(s, meta)
|
function MatchGitCommit(s, meta)
|
||||||
local i, j = string.find(s, "^commit ([a-zA-Z0-9]+)")
|
local i, j = string.find(s, "^commit ([a-zA-Z0-9]+)")
|
||||||
if i then
|
if i then
|
||||||
@@ -255,7 +273,7 @@ function MatchExec(s, meta)
|
|||||||
end
|
end
|
||||||
|
|
||||||
BuiltinOnOpenMatchers = {
|
BuiltinOnOpenMatchers = {
|
||||||
MatchWindowsPath,
|
MatchPath,
|
||||||
MatchGitCommit,
|
MatchGitCommit,
|
||||||
MatchURL,
|
MatchURL,
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,9 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#define Assert(x) \
|
#include <signal.h>
|
||||||
if (!(x)) { \
|
#include <stddef.h>
|
||||||
__debugbreak(); \
|
|
||||||
}
|
|
||||||
#define InvalidCodepath() Assert(!"invalid codepath")
|
|
||||||
#define ElseInvalidCodepath() else {InvalidCodepath()}
|
|
||||||
|
|
||||||
#if defined(__APPLE__) && defined(__MACH__)
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
#define OS_MAC 1
|
#define OS_MAC 1
|
||||||
@@ -62,6 +59,19 @@
|
|||||||
#define COMPILER_GCC 0
|
#define COMPILER_GCC 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if OS_WINDOWS
|
||||||
|
#define DebugBreak() __debugbreak()
|
||||||
|
#elif OS_LINUX
|
||||||
|
#define DebugBreak() raise(SIGTRAP)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define Assert(x) \
|
||||||
|
if (!(x)) { \
|
||||||
|
DebugBreak(); \
|
||||||
|
}
|
||||||
|
#define InvalidCodepath() Assert(!"invalid codepath")
|
||||||
|
#define ElseInvalidCodepath() else {InvalidCodepath()}
|
||||||
|
|
||||||
#define KiB(x) ((x##ull) * 1024ull)
|
#define KiB(x) ((x##ull) * 1024ull)
|
||||||
#define MiB(x) (KiB(x) * 1024ull)
|
#define MiB(x) (KiB(x) * 1024ull)
|
||||||
#define GiB(x) (MiB(x) * 1024ull)
|
#define GiB(x) (MiB(x) * 1024ull)
|
||||||
@@ -710,48 +720,6 @@ ReverseIter<T> IterateInReverse(Slice<T> *slice) {
|
|||||||
return {slice->end() - 1, slice};
|
return {slice->end() - 1, slice};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
|
||||||
struct CircularArray {
|
|
||||||
Allocator allocator;
|
|
||||||
T *data;
|
|
||||||
int16_t cap;
|
|
||||||
int16_t write;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
CircularArray<T> MakeCircularArray(Allocator allocator, int size) {
|
|
||||||
CircularArray<T> arr = {allocator};
|
|
||||||
arr.data = AllocArray(allocator, T, size);
|
|
||||||
arr.cap = size;
|
|
||||||
return arr;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void Add(CircularArray<T> *arr, T item) {
|
|
||||||
if (arr->cap == 0) {
|
|
||||||
arr->allocator = GetSystemAllocator();
|
|
||||||
arr->cap = 128;
|
|
||||||
arr->data = AllocArray(arr->allocator, T, arr->cap);
|
|
||||||
}
|
|
||||||
int16_t i = arr->write;
|
|
||||||
arr->write = (arr->write + 1) % arr->cap;
|
|
||||||
arr->data[i] = item;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int GetCircularIndex(int cap, int idx) {
|
|
||||||
int result = idx % cap;
|
|
||||||
if (result < 0) result = cap + result;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
T Get(CircularArray<T> *arr, int idx, T default_value) {
|
|
||||||
int idx = circ->write - 1 - i;
|
|
||||||
idx = GetCircularIndex(circ->size, idx);
|
|
||||||
int result = circ->data[idx];
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct UTF32Result {
|
struct UTF32Result {
|
||||||
uint32_t out_str;
|
uint32_t out_str;
|
||||||
int64_t advance;
|
int64_t advance;
|
||||||
@@ -1063,7 +1031,7 @@ inline void Clear(Arena *arena) { SetLen(arena, 0); }
|
|||||||
|
|
||||||
void *VReserve(size_t size);
|
void *VReserve(size_t size);
|
||||||
bool VCommit(void *p, size_t size);
|
bool VCommit(void *p, size_t size);
|
||||||
bool VRelease(void *p);
|
bool VRelease(void *p, size_t size);
|
||||||
bool VDecommit(void *p, size_t size);
|
bool VDecommit(void *p, size_t size);
|
||||||
|
|
||||||
void InitArena(Arena *arena, size_t reserve = GiB(4));
|
void InitArena(Arena *arena, size_t reserve = GiB(4));
|
||||||
@@ -1662,7 +1630,7 @@ Arena *AllocArena(size_t reserve) {
|
|||||||
|
|
||||||
bool success = VCommit(data, PAGE_SIZE);
|
bool success = VCommit(data, PAGE_SIZE);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
VRelease(data);
|
VRelease(data, reserve);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1711,7 +1679,7 @@ void *PushSize(Arena *arena, size_t size) {
|
|||||||
void Release(Arena *arena) {
|
void Release(Arena *arena) {
|
||||||
if (arena == NULL || arena->data == NULL) return;
|
if (arena == NULL || arena->data == NULL) return;
|
||||||
bool zero_memory = (uint8_t *)arena != arena->data;
|
bool zero_memory = (uint8_t *)arena != arena->data;
|
||||||
VRelease(arena->data);
|
VRelease(arena->data, arena->reserve);
|
||||||
if (zero_memory) MemoryZero(arena, sizeof(Arena));
|
if (zero_memory) MemoryZero(arena, sizeof(Arena));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ void Advance(FileIter *it);
|
|||||||
FileIter IterateFiles(Allocator allocator, String path);
|
FileIter IterateFiles(Allocator allocator, String path);
|
||||||
void InitOS(void (*error_proc)(const char *, ...));
|
void InitOS(void (*error_proc)(const char *, ...));
|
||||||
|
|
||||||
|
bool DeleteFile(String path);
|
||||||
String GetExePath(Allocator allocator);
|
String GetExePath(Allocator allocator);
|
||||||
String GetExeDir(Allocator allocator);
|
String GetExeDir(Allocator allocator);
|
||||||
bool FileExists(String path);
|
bool FileExists(String path);
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ Int SkipNumber(String16 *string) {
|
|||||||
String16 SkipUntil(String16 *string, String16 str) {
|
String16 SkipUntil(String16 *string, String16 str) {
|
||||||
String16 begin = *string;
|
String16 begin = *string;
|
||||||
begin.len = 0;
|
begin.len = 0;
|
||||||
for (Int i = 0; string->len; begin.len += 1) {
|
for (; string->len; begin.len += 1) {
|
||||||
String16 match = GetPrefix(*string, str.len);
|
String16 match = GetPrefix(*string, str.len);
|
||||||
if (StartsWith(match, str)) break;
|
if (StartsWith(match, str)) break;
|
||||||
*string = Skip(*string, 1);
|
*string = Skip(*string, 1);
|
||||||
|
|||||||
239
src/basic/unix.cpp
Normal file
239
src/basic/unix.cpp
Normal file
@@ -0,0 +1,239 @@
|
|||||||
|
#include "filesystem.h"
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/syscall.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <linux/limits.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
void (*Error)(const char *, ...);
|
||||||
|
|
||||||
|
void *VReserve(size_t size) {
|
||||||
|
void *result = mmap(0, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, (off_t)0);
|
||||||
|
return result == (void *)-1 ? 0 : result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VCommit(void *p, size_t size) {
|
||||||
|
int result = mprotect(p, size, PROT_READ | PROT_WRITE);
|
||||||
|
return result == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VRelease(void *p, size_t size) {
|
||||||
|
int result = munmap(p, size);
|
||||||
|
return result == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VDecommit(void *p, size_t size) {
|
||||||
|
mprotect(p, size, PROT_NONE);
|
||||||
|
madvise(p, size, MADV_DONTNEED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitOS(void (*error_proc)(const char *, ...)) {
|
||||||
|
Error = error_proc;
|
||||||
|
}
|
||||||
|
|
||||||
|
String ReadFile(Allocator al, String path) {
|
||||||
|
Scratch scratch(al);
|
||||||
|
String null_term = Copy(scratch, path);
|
||||||
|
String result = {};
|
||||||
|
FILE *f = fopen(null_term.data, "rb");
|
||||||
|
if (f) {
|
||||||
|
fseek(f, 0, SEEK_END);
|
||||||
|
result.len = ftell(f);
|
||||||
|
fseek(f, 0, SEEK_SET);
|
||||||
|
|
||||||
|
result.data = (char *)AllocSize(al, result.len + 1);
|
||||||
|
fread(result.data, result.len, 1, f);
|
||||||
|
result.data[result.len] = 0;
|
||||||
|
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WriteFile(String path, String data) {
|
||||||
|
Scratch scratch;
|
||||||
|
String null_term = Copy(scratch, path);
|
||||||
|
bool result = false;
|
||||||
|
FILE *f = fopen((const char *)null_term.data, "w");
|
||||||
|
if (f) {
|
||||||
|
size_t written = fwrite(data.data, 1, data.len, f);
|
||||||
|
if (written == data.len) {
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeleteFile(String path) {
|
||||||
|
Scratch scratch;
|
||||||
|
String null_term = Copy(scratch, path);
|
||||||
|
int result = unlink(null_term.data);
|
||||||
|
return result == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MakeDirResult MakeDir(String path) {
|
||||||
|
Scratch scratch;
|
||||||
|
String null_term = Copy(scratch, path);
|
||||||
|
int error = mkdir(null_term.data, 0755);
|
||||||
|
MakeDirResult result = MakeDirResult_Success;
|
||||||
|
if (error != 0) {
|
||||||
|
result = MakeDirResult_ErrorOther;
|
||||||
|
if (errno == EEXIST) result = MakeDirResult_Exists;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t GetFileModTime(String path) {
|
||||||
|
Scratch scratch;
|
||||||
|
String null_term = Copy(scratch, path);
|
||||||
|
struct stat attrib = {};
|
||||||
|
stat(null_term.data, &attrib);
|
||||||
|
struct timespec ts = attrib.st_mtim;
|
||||||
|
int64_t result = (((int64_t)ts.tv_sec) * 1000000ll) + ((int64_t)ts.tv_nsec) / 1000ll;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
String GetAbsolutePath(Allocator al, String path) {
|
||||||
|
Scratch scratch(al);
|
||||||
|
String null_term = Copy(scratch, path);
|
||||||
|
char *buffer = AllocArray(al, char, PATH_MAX);
|
||||||
|
realpath(null_term.data, buffer);
|
||||||
|
String result = buffer;
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FileExists(String path) {
|
||||||
|
Scratch scratch;
|
||||||
|
String null_term = Copy(scratch, path);
|
||||||
|
bool result = false;
|
||||||
|
if (access((char *)null_term.data, F_OK) == 0) {
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsDir(String path) {
|
||||||
|
Scratch scratch;
|
||||||
|
String null_term = Copy(scratch, path);
|
||||||
|
struct stat s;
|
||||||
|
if (stat(null_term.data, &s) != 0)
|
||||||
|
return false;
|
||||||
|
return S_ISDIR(s.st_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsFile(String path) {
|
||||||
|
Scratch scratch;
|
||||||
|
String null_term = Copy(scratch, path);
|
||||||
|
struct stat s;
|
||||||
|
if (stat(null_term.data, &s) != 0)
|
||||||
|
return false;
|
||||||
|
return S_ISREG(s.st_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsAbsolute(String path) {
|
||||||
|
bool result = path.len && path.data[0] == '/';
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
String GetWorkingDir(Allocator al) {
|
||||||
|
char *buffer = AllocArray(al, char, PATH_MAX);
|
||||||
|
char *cwd = getcwd(buffer, PATH_MAX);
|
||||||
|
return cwd;
|
||||||
|
}
|
||||||
|
|
||||||
|
String GetExePath(Allocator al) {
|
||||||
|
char *buffer = AllocArray(al, char, PATH_MAX);
|
||||||
|
readlink("/proc/self/exe", buffer, PATH_MAX);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
String GetExeDir(Allocator al) {
|
||||||
|
Scratch scratch(al);
|
||||||
|
String exe_path = GetExePath(scratch);
|
||||||
|
String dir = ChopLastSlash(exe_path);
|
||||||
|
String result = Copy(al, dir);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
double get_time_in_micros(void) {
|
||||||
|
struct timespec spec;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &spec);
|
||||||
|
return (((double)spec.tv_sec) * 1000000) + (((double)spec.tv_nsec) / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsValid(const FileIter &it) {
|
||||||
|
return it.is_valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Advance(FileIter *it) {
|
||||||
|
struct dirent *file = NULL;
|
||||||
|
while ((file = readdir((DIR *)it->dir)) != NULL) {
|
||||||
|
if (file->d_name[0] == '.' && file->d_name[1] == '.' && file->d_name[2] == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (file->d_name[0] == '.' && file->d_name[1] == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
it->is_directory = file->d_type == DT_DIR;
|
||||||
|
it->filename = Copy(it->allocator, file->d_name);
|
||||||
|
|
||||||
|
const char *dir_char_ending = it->is_directory ? "/" : "";
|
||||||
|
const char *separator = it->path.data[it->path.len - 1] == '/' ? "" : "/";
|
||||||
|
it->relative_path = Format(it->allocator, "%.*s%s%s%s", FmtString(it->path), separator, file->d_name, dir_char_ending);
|
||||||
|
it->absolute_path = GetAbsolutePath(it->allocator, it->relative_path);
|
||||||
|
if (it->is_directory) it->absolute_path = Format(it->allocator, "%.*s/", FmtString(it->absolute_path));
|
||||||
|
it->is_valid = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
it->is_valid = false;
|
||||||
|
closedir((DIR *)it->dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
FileIter IterateFiles(Allocator alo, String path) {
|
||||||
|
FileIter it = {};
|
||||||
|
it.allocator = alo;
|
||||||
|
it.path = path;
|
||||||
|
Scratch scratch(alo);
|
||||||
|
String null_term = Copy(scratch, path);
|
||||||
|
it.dir = (void *)opendir((char *)null_term.data);
|
||||||
|
if (it.dir) {
|
||||||
|
Advance(&it);
|
||||||
|
}
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct UnixProcess {
|
||||||
|
pid_t pid;
|
||||||
|
};
|
||||||
|
|
||||||
|
Process SpawnProcess(String command_line, String working_dir, String write_stdin, Array<String> enviroment) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsValid(Process *process) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KillProcess(Process *process) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
String PollStdout(Allocator allocator, Process *process) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteStdin(Process *process, String string) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloseStdin(Process *process) {
|
||||||
|
}
|
||||||
@@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
void (*Error)(const char *, ...);
|
void (*Error)(const char *, ...);
|
||||||
|
|
||||||
// Basic begin
|
|
||||||
void *VReserve(size_t size) {
|
void *VReserve(size_t size) {
|
||||||
void *result = (uint8_t *)VirtualAlloc(0, size, MEM_RESERVE, PAGE_READWRITE);
|
void *result = (uint8_t *)VirtualAlloc(0, size, MEM_RESERVE, PAGE_READWRITE);
|
||||||
return result;
|
return result;
|
||||||
@@ -26,7 +25,7 @@ bool VCommit(void *p, size_t size) {
|
|||||||
return result ? true : false;
|
return result ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VRelease(void *p) {
|
bool VRelease(void *p, size_t size) {
|
||||||
BOOL result = VirtualFree(p, 0, MEM_RELEASE);
|
BOOL result = VirtualFree(p, 0, MEM_RELEASE);
|
||||||
return result ? true : false;
|
return result ? true : false;
|
||||||
}
|
}
|
||||||
@@ -35,7 +34,6 @@ bool VDecommit(void *p, size_t size) {
|
|||||||
BOOL result = VirtualFree(p, size, MEM_DECOMMIT);
|
BOOL result = VirtualFree(p, size, MEM_DECOMMIT);
|
||||||
return result ? true : false;
|
return result ? true : false;
|
||||||
}
|
}
|
||||||
// Basic end
|
|
||||||
|
|
||||||
void InitOS(void (*error_proc)(const char *, ...)) {
|
void InitOS(void (*error_proc)(const char *, ...)) {
|
||||||
Error = error_proc;
|
Error = error_proc;
|
||||||
@@ -146,8 +144,6 @@ FileIter IterateFiles(Allocator alo, String path) {
|
|||||||
return it;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if _WIN32
|
|
||||||
#include <Windows.h>
|
|
||||||
double get_time_in_micros(void) {
|
double get_time_in_micros(void) {
|
||||||
static double invfreq;
|
static double invfreq;
|
||||||
if (!invfreq) {
|
if (!invfreq) {
|
||||||
@@ -159,14 +155,6 @@ double get_time_in_micros(void) {
|
|||||||
QueryPerformanceCounter(&counter);
|
QueryPerformanceCounter(&counter);
|
||||||
return counter.QuadPart * invfreq;
|
return counter.QuadPart * invfreq;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
#include <unistd.h>
|
|
||||||
double get_time_in_micros(void) {
|
|
||||||
struct timespec spec;
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &spec);
|
|
||||||
return (((double)spec.tv_sec) * 1000000) + (((double)spec.tv_nsec) / 1000);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool WriteFile(String path, String data) {
|
bool WriteFile(String path, String data) {
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|||||||
@@ -14,7 +14,11 @@ void PushWork(WorkQueue *wq, void *data, WorkQueueCallback *callback) {
|
|||||||
entry->data = data;
|
entry->data = data;
|
||||||
entry->callback = callback;
|
entry->callback = callback;
|
||||||
|
|
||||||
wq->completion_goal += 1;
|
wq->completion_goal += 1;dex_to_read + 1) % Lengthof(wq->entries);
|
||||||
|
if (original_index_to_read != wq->index_to_write) {
|
||||||
|
int64_t index = AtomicCompareAndSwap(&wq->index_to_read, new_index_to_read, original_index_to_read);
|
||||||
|
if (index == original_index_to_read) {
|
||||||
|
WorkQueueEntry *entry = wq->entries +
|
||||||
_WriteBarrier();
|
_WriteBarrier();
|
||||||
wq->index_to_write = new_index;
|
wq->index_to_write = new_index;
|
||||||
ReleaseSemaphore(wq->semaphore, 1, 0);
|
ReleaseSemaphore(wq->semaphore, 1, 0);
|
||||||
@@ -23,11 +27,7 @@ void PushWork(WorkQueue *wq, void *data, WorkQueueCallback *callback) {
|
|||||||
bool TryDoingWork(WorkQueue *wq) {
|
bool TryDoingWork(WorkQueue *wq) {
|
||||||
bool should_sleep = false;
|
bool should_sleep = false;
|
||||||
int64_t original_index_to_read = wq->index_to_read;
|
int64_t original_index_to_read = wq->index_to_read;
|
||||||
int64_t new_index_to_read = (original_index_to_read + 1) % Lengthof(wq->entries);
|
int64_t new_index_to_read = (original_inindex;
|
||||||
if (original_index_to_read != wq->index_to_write) {
|
|
||||||
int64_t index = AtomicCompareAndSwap(&wq->index_to_read, new_index_to_read, original_index_to_read);
|
|
||||||
if (index == original_index_to_read) {
|
|
||||||
WorkQueueEntry *entry = wq->entries + index;
|
|
||||||
entry->callback(entry->data);
|
entry->callback(entry->data);
|
||||||
AtomicIncrement(&wq->completion_index);
|
AtomicIncrement(&wq->completion_index);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ int main(int argument_count, char **arguments) {
|
|||||||
IO_Printf("WORKING DIR: %.*s\n", S8_Expand(working_dir));
|
IO_Printf("WORKING DIR: %.*s\n", S8_Expand(working_dir));
|
||||||
|
|
||||||
Array<S8_String> cmd = CMD_Make(arguments, argument_count);
|
Array<S8_String> cmd = CMD_Make(arguments, argument_count);
|
||||||
S8_String cc = CMD_Get(cmd, "cc", IF_WINDOWS("cl") IF_MAC("clang") IF_LINUX("gcc"));
|
S8_String cc = CMD_Get(cmd, "cc", IF_WINDOWS("cl") IF_MAC("clang") IF_LINUX("clang"));
|
||||||
|
|
||||||
// Search for build file in the project directory
|
// Search for build file in the project directory
|
||||||
S8_String build_file = {};
|
S8_String build_file = {};
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ void PlayTestOpen(mco_coro *co) {
|
|||||||
Assert(main.view->carets[0].range.min == 0);
|
Assert(main.view->carets[0].range.min == 0);
|
||||||
Assert(main.view->carets[0].range.max == 0);
|
Assert(main.view->carets[0].range.max == 0);
|
||||||
}
|
}
|
||||||
ReportConsolef(__FUNCTION__ " DONE");
|
ReportConsolef("%s DONE", __FUNCTION__);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1104,7 +1104,7 @@ int Lua_C(lua_State *L) {
|
|||||||
BSet Command_Open(Window *window, String path, String meta, bool set_active = true) {
|
BSet Command_Open(Window *window, String path, String meta, bool set_active = true) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
BSet set = GetBSet(window);
|
BSet set = GetBSet(window);
|
||||||
OnOpenResult ores = CallOnOpen(path, meta);
|
OnOpenResult ores = CallOnOpen(scratch, path, meta);
|
||||||
if (ores.kind == "text") {
|
if (ores.kind == "text") {
|
||||||
if (set_active) {
|
if (set_active) {
|
||||||
ActiveWindow = set.window->id;
|
ActiveWindow = set.window->id;
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ Style.TrimWhitespaceOnSave = true
|
|||||||
Style.ClangFormatOnSave = false
|
Style.ClangFormatOnSave = false
|
||||||
|
|
||||||
INTERNET_BROWSER = 'C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe'
|
INTERNET_BROWSER = 'C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe'
|
||||||
|
OS_WINDOWS = 0
|
||||||
|
OS_UNIX = 1
|
||||||
|
|
||||||
SDLK_CTRL = 1073742048
|
SDLK_CTRL = 1073742048
|
||||||
SDLK_PAGE_DOWN = 1073741902
|
SDLK_PAGE_DOWN = 1073741902
|
||||||
@@ -214,7 +216,7 @@ function SkipDrive(s)
|
|||||||
return new_s, drive, true
|
return new_s, drive, true
|
||||||
end
|
end
|
||||||
|
|
||||||
function SkipPathCell(s)
|
function WindowsSkipPathCell(s)
|
||||||
local i, j = s:find("^[%w_%.-% +]+")
|
local i, j = s:find("^[%w_%.-% +]+")
|
||||||
if not i then return s, nil, false end
|
if not i then return s, nil, false end
|
||||||
|
|
||||||
@@ -225,7 +227,7 @@ function SkipPathCell(s)
|
|||||||
return new_s, word, found_slash
|
return new_s, word, found_slash
|
||||||
end
|
end
|
||||||
|
|
||||||
function SkipPath(s)
|
function WindowsSkipPath(s)
|
||||||
local input_s = s
|
local input_s = s
|
||||||
local s, drive, ok = SkipDrive(s)
|
local s, drive, ok = SkipDrive(s)
|
||||||
if not ok then return s end
|
if not ok then return s end
|
||||||
@@ -236,7 +238,7 @@ function SkipPath(s)
|
|||||||
end
|
end
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
s, word, slash_eaten = SkipPathCell(s)
|
s, word, slash_eaten = WindowsSkipPathCell(s)
|
||||||
if word then cells[#cells + 1] = word end
|
if word then cells[#cells + 1] = word end
|
||||||
if not slash_eaten then break end
|
if not slash_eaten then break end
|
||||||
end
|
end
|
||||||
@@ -249,7 +251,7 @@ function SkipPath(s)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function MatchWindowsPath(_s, meta)
|
function MatchWindowsPath(_s, meta)
|
||||||
local s, file_path, drive = SkipPath(_s)
|
local s, file_path, drive = WindowsSkipPath(_s)
|
||||||
|
|
||||||
if not file_path and FileExists(drive) then
|
if not file_path and FileExists(drive) then
|
||||||
return {kind = "text", file_path = drive, line = line, col = col}
|
return {kind = "text", file_path = drive, line = line, col = col}
|
||||||
@@ -271,6 +273,22 @@ function MatchWindowsPath(_s, meta)
|
|||||||
return {kind = "text", file_path = file_path, line = line, col = col}
|
return {kind = "text", file_path = file_path, line = line, col = col}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function MatchUnixPath(s, meta)
|
||||||
|
local i, j = s:find("^[%w_%.-% %/]+")
|
||||||
|
local path = s:sub(i, j)
|
||||||
|
local rest = s:sub(j + 1, -1)
|
||||||
|
local line, col, s = SkipLineAndColumn(rest)
|
||||||
|
Print(path, rest, line, col)
|
||||||
|
|
||||||
|
return {kind = "text", file_path = path, line = line, col = col}
|
||||||
|
end
|
||||||
|
|
||||||
|
if OS_VALUE == OS_WINDOWS then
|
||||||
|
MatchPath = MatchWindowsPath
|
||||||
|
else
|
||||||
|
MatchPath = MatchUnixPath
|
||||||
|
end
|
||||||
|
|
||||||
function MatchGitCommit(s, meta)
|
function MatchGitCommit(s, meta)
|
||||||
local i, j = string.find(s, "^commit ([a-zA-Z0-9]+)")
|
local i, j = string.find(s, "^commit ([a-zA-Z0-9]+)")
|
||||||
if i then
|
if i then
|
||||||
@@ -325,7 +343,7 @@ function MatchExec(s, meta)
|
|||||||
end
|
end
|
||||||
|
|
||||||
BuiltinOnOpenMatchers = {
|
BuiltinOnOpenMatchers = {
|
||||||
MatchWindowsPath,
|
MatchPath,
|
||||||
MatchGitCommit,
|
MatchGitCommit,
|
||||||
MatchURL,
|
MatchURL,
|
||||||
|
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ struct OnOpenResult {
|
|||||||
String cmd;
|
String cmd;
|
||||||
};
|
};
|
||||||
|
|
||||||
OnOpenResult CallOnOpen(String path, String meta) {
|
OnOpenResult CallOnOpen(Allocator allocator, String path, String meta) {
|
||||||
lua_getglobal(LuaState, "OnOpen");
|
lua_getglobal(LuaState, "OnOpen");
|
||||||
lua_pushlstring(LuaState, path.data, path.len);
|
lua_pushlstring(LuaState, path.data, path.len);
|
||||||
lua_pushlstring(LuaState, meta.data, meta.len);
|
lua_pushlstring(LuaState, meta.data, meta.len);
|
||||||
@@ -326,6 +326,10 @@ OnOpenResult CallOnOpen(String path, String meta) {
|
|||||||
result.cmd = cmd;
|
result.cmd = cmd;
|
||||||
result.working_dir = working_dir;
|
result.working_dir = working_dir;
|
||||||
result.file_path = file_path;
|
result.file_path = file_path;
|
||||||
|
if (!IsAbsolute(result.file_path)) {
|
||||||
|
String dir = Command_GetMainDir();
|
||||||
|
result.file_path = Format(allocator, "%.*s/%.*s", FmtString(dir), FmtString(result.file_path));
|
||||||
|
}
|
||||||
if (col_string.len) {
|
if (col_string.len) {
|
||||||
result.col = strtoll(col_string.data, NULL, 10);
|
result.col = strtoll(col_string.data, NULL, 10);
|
||||||
} else {
|
} else {
|
||||||
@@ -338,6 +342,7 @@ OnOpenResult CallOnOpen(String path, String meta) {
|
|||||||
}
|
}
|
||||||
result.kind = kind;
|
result.kind = kind;
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -390,6 +395,13 @@ void InitLuaConfig() {
|
|||||||
lua_setglobal(LuaState, LuaFunctions[i].name);
|
lua_setglobal(LuaState, LuaFunctions[i].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if OS_WINDOWS
|
||||||
|
lua_pushinteger(LuaState, 0);
|
||||||
|
#else
|
||||||
|
lua_pushinteger(LuaState, 1);
|
||||||
|
#endif
|
||||||
|
lua_setglobal(LuaState, "OS_VALUE");
|
||||||
|
|
||||||
// Init base config, test that it works and initialize the lua stuff
|
// Init base config, test that it works and initialize the lua stuff
|
||||||
ReportConsolef("load base lua config");
|
ReportConsolef("load base lua config");
|
||||||
if (!luaL_dostring(LuaState, BaseLuaConfig.data) == LUA_OK) {
|
if (!luaL_dostring(LuaState, BaseLuaConfig.data) == LUA_OK) {
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ int main(int argc, char **argv)
|
|||||||
int xhalf = whalf;
|
int xhalf = whalf;
|
||||||
int yhalf = 30;
|
int yhalf = 30;
|
||||||
|
|
||||||
Uint32 window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
Uint32 window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
||||||
SDLWindow = SDL_CreateWindow("Text editor", whalf, hhalf, window_flags);
|
SDLWindow = SDL_CreateWindow("Text editor", whalf, hhalf, window_flags);
|
||||||
if (SDLWindow == NULL) {
|
if (SDLWindow == NULL) {
|
||||||
ReportErrorf("Couldn't create window! %s", SDL_GetError());
|
ReportErrorf("Couldn't create window! %s", SDL_GetError());
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ void ReplaceTitleBarData(Window *window) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// replace data up to separator with filename and stuff
|
// replace data up to separator with filename and stuff
|
||||||
char *reopen = main.buffer->changed_on_disk ? " Reopen()" : "";
|
const char *reopen = main.buffer->changed_on_disk ? " Reopen()" : "";
|
||||||
String s = Format(scratch, "%.*s:%lld:%lld%s", FmtString(main.buffer->name), (long long)xy.line + 1ll, (long long)xy.col + 1ll, reopen);
|
String s = Format(scratch, "%.*s:%lld:%lld%s", FmtString(main.buffer->name), (long long)xy.line + 1ll, (long long)xy.col + 1ll, reopen);
|
||||||
String16 string = ToString16(scratch, s);
|
String16 string = ToString16(scratch, s);
|
||||||
String16 string_to_replace = GetString(title.buffer, replace_range);
|
String16 string_to_replace = GetString(title.buffer, replace_range);
|
||||||
|
|||||||
Reference in New Issue
Block a user