Fixing issues, enabled warnings and fixing on linux
This commit is contained in:
@@ -92,6 +92,7 @@ API bool VDecommit(void *p, size_t size) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
API void *SystemAllocatorProc(void *object, int kind, void *p, size_t size) {
|
API void *SystemAllocatorProc(void *object, int kind, void *p, size_t size) {
|
||||||
|
Unused(object);
|
||||||
void *result = NULL;
|
void *result = NULL;
|
||||||
if (kind == AllocatorKind_Allocate) {
|
if (kind == AllocatorKind_Allocate) {
|
||||||
result = malloc(size);
|
result = malloc(size);
|
||||||
@@ -125,6 +126,7 @@ thread_local Array<MemoryRecord> MemoryTrackingRecord;
|
|||||||
|
|
||||||
|
|
||||||
API void *TrackingAllocatorProc(void *object, int kind, void *p, size_t size) {
|
API void *TrackingAllocatorProc(void *object, int kind, void *p, size_t size) {
|
||||||
|
Unused(object);
|
||||||
void *result = NULL;
|
void *result = NULL;
|
||||||
|
|
||||||
if (kind == AllocatorKind_Allocate) {
|
if (kind == AllocatorKind_Allocate) {
|
||||||
@@ -249,6 +251,7 @@ API void PopToPos(VirtualArena *arena, size_t pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
API void *ArenaAllocatorProc(void *object, int kind, void *p, size_t size) {
|
API void *ArenaAllocatorProc(void *object, int kind, void *p, size_t size) {
|
||||||
|
Unused(p);
|
||||||
if (kind == AllocatorKind_Allocate) {
|
if (kind == AllocatorKind_Allocate) {
|
||||||
return PushSize((VirtualArena *)object, size);
|
return PushSize((VirtualArena *)object, size);
|
||||||
} else if (AllocatorKind_Deallocate) {
|
} else if (AllocatorKind_Deallocate) {
|
||||||
@@ -316,6 +319,7 @@ API void Unwind(BlockArena *arena, U8 *pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
API void *BlockArenaAllocatorProc(void *object, int kind, void *p, size_t size) {
|
API void *BlockArenaAllocatorProc(void *object, int kind, void *p, size_t size) {
|
||||||
|
Unused(p);
|
||||||
BlockArena *arena = (BlockArena *)object;
|
BlockArena *arena = (BlockArena *)object;
|
||||||
if (kind == AllocatorKind_Allocate) {
|
if (kind == AllocatorKind_Allocate) {
|
||||||
return PushSize(arena, size);
|
return PushSize(arena, size);
|
||||||
|
|||||||
@@ -28,9 +28,13 @@ API Allocator GetTrackingAllocator();
|
|||||||
|
|
||||||
#define MemoryZero(x, size) memset(x, 0, size)
|
#define MemoryZero(x, size) memset(x, 0, size)
|
||||||
#define MemoryZeroStruct(x) memset(x, 0, sizeof(*x))
|
#define MemoryZeroStruct(x) memset(x, 0, sizeof(*x))
|
||||||
#define MemoryCopy(dst, src, size) memcpy(dst, src, size)
|
|
||||||
#define MemoryMove(dst, src, size) memmove(dst, src, size)
|
#define MemoryMove(dst, src, size) memmove(dst, src, size)
|
||||||
|
|
||||||
|
static inline void MemoryCopy(void *dst, void *src, size_t size) {
|
||||||
|
if (src == NULL) return;
|
||||||
|
memcpy(dst, src, size);
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
// Block Arena
|
// Block Arena
|
||||||
///////////////////
|
///////////////////
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ Slice<T> GetSlice(Slice<T> &arr, int64_t first_index = 0, int64_t one_past_last_
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make arrays resize on every item
|
// Make arrays resize on every item
|
||||||
#define ARRAY_DEBUG BUILD_SLOW
|
#define ARRAY_DEBUG 0
|
||||||
#if ARRAY_DEBUG
|
#if ARRAY_DEBUG
|
||||||
#define ARRAY_IF_DEBUG_ELSE(IF, ELSE) IF
|
#define ARRAY_IF_DEBUG_ELSE(IF, ELSE) IF
|
||||||
#else
|
#else
|
||||||
@@ -211,12 +211,11 @@ void Reserve(Array<T> *arr, int64_t size) {
|
|||||||
|
|
||||||
T *new_data = AllocArray(arr->allocator, T, size);
|
T *new_data = AllocArray(arr->allocator, T, size);
|
||||||
Assert(new_data);
|
Assert(new_data);
|
||||||
memcpy(new_data, arr->data, arr->len * sizeof(T));
|
MemoryCopy(new_data, arr->data, arr->len * sizeof(T));
|
||||||
Dealloc(arr->allocator, arr->data);
|
if (arr->data) Dealloc(arr->allocator, arr->data);
|
||||||
|
|
||||||
arr->data = new_data;
|
arr->data = new_data;
|
||||||
arr->cap = size;
|
arr->cap = size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
@@ -493,16 +492,16 @@ struct ReverseIter {
|
|||||||
friend bool operator==(const ReverseIter &a, const ReverseIter &b) { return a.data == b.data; };
|
friend bool operator==(const ReverseIter &a, const ReverseIter &b) { return a.data == b.data; };
|
||||||
friend bool operator!=(const ReverseIter &a, const ReverseIter &b) { return a.data != b.data; };
|
friend bool operator!=(const ReverseIter &a, const ReverseIter &b) { return a.data != b.data; };
|
||||||
|
|
||||||
ReverseIter begin() { return ReverseIter{arr->end() - 1, arr}; }
|
ReverseIter begin() { return ReverseIter{arr->end() ? arr->end() - 1 : NULL, arr}; }
|
||||||
ReverseIter end() { return ReverseIter{arr->begin() - 1, arr}; }
|
ReverseIter end() { return ReverseIter{arr->begin() ? arr->begin() - 1 : NULL, arr}; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
ReverseIter<T> IterateInReverse(Array<T> *arr) {
|
ReverseIter<T> IterateInReverse(Array<T> *arr) {
|
||||||
return {arr->end() - 1, &arr->slice};
|
return {arr->end() ? arr->end() - 1 : NULL, &arr->slice};
|
||||||
}
|
}
|
||||||
template <class T>
|
template <class T>
|
||||||
ReverseIter<T> IterateInReverse(Slice<T> *slice) {
|
ReverseIter<T> IterateInReverse(Slice<T> *slice) {
|
||||||
return {slice->end() - 1, slice};
|
return {slice->end ? slice->end() - 1 : NULL, slice};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,8 +117,9 @@ EM_JS(void, JS_Breakpoint, (), {
|
|||||||
#define MiB(x) (KiB(x) * 1024ull)
|
#define MiB(x) (KiB(x) * 1024ull)
|
||||||
#define GiB(x) (MiB(x) * 1024ull)
|
#define GiB(x) (MiB(x) * 1024ull)
|
||||||
#define TiB(x) (GiB(x) * 1024ull)
|
#define TiB(x) (GiB(x) * 1024ull)
|
||||||
#define Lengthof(x) ((int64_t)((sizeof(x) / sizeof((x)[0]))))
|
|
||||||
#define SLICE_LAST INT64_MAX
|
#define SLICE_LAST INT64_MAX
|
||||||
|
#define Lengthof(x) ((int64_t)((sizeof(x) / sizeof((x)[0]))))
|
||||||
|
#define Unused(x) (void)(x)
|
||||||
|
|
||||||
using U8 = uint8_t;
|
using U8 = uint8_t;
|
||||||
using U16 = uint16_t;
|
using U16 = uint16_t;
|
||||||
@@ -132,6 +133,8 @@ using Int = S64;
|
|||||||
using UInt = U64;
|
using UInt = U64;
|
||||||
using Float = double;
|
using Float = double;
|
||||||
|
|
||||||
|
#define IntMax INT64_MAX
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
T Min(T a, T b) {
|
T Min(T a, T b) {
|
||||||
if (a > b) return b;
|
if (a > b) return b;
|
||||||
@@ -247,3 +250,14 @@ inline uint64_t GetRandomU64(RandomSeed *state) {
|
|||||||
#define STRINGIFY(x) STRINGIFY_(x)
|
#define STRINGIFY(x) STRINGIFY_(x)
|
||||||
#define CONCAT_(a, b) a ## b
|
#define CONCAT_(a, b) a ## b
|
||||||
#define CONCAT(a, b) CONCAT_(a, b)
|
#define CONCAT(a, b) CONCAT_(a, b)
|
||||||
|
|
||||||
|
Int SizeToInt(size_t size) {
|
||||||
|
Assert(size <= (size_t)IntMax);
|
||||||
|
return (Int)size;
|
||||||
|
}
|
||||||
|
|
||||||
|
Int Strlen(const char *string) {
|
||||||
|
size_t size = strlen(string);
|
||||||
|
Int result = SizeToInt(size);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -24,10 +24,12 @@ API void (*Error)(const char *, ...);
|
|||||||
struct backtrace_state *backtrace_state = NULL;
|
struct backtrace_state *backtrace_state = NULL;
|
||||||
|
|
||||||
void BacktraceOnError(void *data, const char *msg, int errnum) {
|
void BacktraceOnError(void *data, const char *msg, int errnum) {
|
||||||
|
Unused(data);
|
||||||
Error("libbacktrace error: %s (errnum: %d)\n", msg, errnum);
|
Error("libbacktrace error: %s (errnum: %d)\n", msg, errnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BacktraceOnPrint(void *data, uintptr_t pc, const char *filename, int lineno, const char *function) {
|
int BacktraceOnPrint(void *data, uintptr_t pc, const char *filename, int lineno, const char *function) {
|
||||||
|
Unused(data); Unused(pc);
|
||||||
bool printed = false;
|
bool printed = false;
|
||||||
if (filename != NULL) {
|
if (filename != NULL) {
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
@@ -46,6 +48,7 @@ int BacktraceOnPrint(void *data, uintptr_t pc, const char *filename, int lineno,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CrashHandler(int signal, siginfo_t* info, void* context) {
|
void CrashHandler(int signal, siginfo_t* info, void* context) {
|
||||||
|
Unused(signal); Unused(info); Unused(context);
|
||||||
backtrace_full(backtrace_state, 2, BacktraceOnPrint, BacktraceOnError, NULL);
|
backtrace_full(backtrace_state, 2, BacktraceOnPrint, BacktraceOnError, NULL);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -102,7 +105,7 @@ API bool WriteFile(String path, String data) {
|
|||||||
FILE *f = fopen((const char *)null_term.data, "w");
|
FILE *f = fopen((const char *)null_term.data, "w");
|
||||||
if (f) {
|
if (f) {
|
||||||
size_t written = fwrite(data.data, 1, data.len, f);
|
size_t written = fwrite(data.data, 1, data.len, f);
|
||||||
if (written == data.len) {
|
if (SizeToInt(written) == data.len) {
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ API String Copy(Allocator allocator, String string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
API String Copy(Allocator allocator, char *string) {
|
API String Copy(Allocator allocator, char *string) {
|
||||||
return Copy(allocator, {string, (int64_t)strlen(string)});
|
return Copy(allocator, {string, Strlen(string)});
|
||||||
}
|
}
|
||||||
|
|
||||||
API void NormalizePathInPlace(String s) {
|
API void NormalizePathInPlace(String s) {
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ struct String {
|
|||||||
int64_t len;
|
int64_t len;
|
||||||
|
|
||||||
String() = default;
|
String() = default;
|
||||||
String(char *s) : data(s), len(strlen(s)) {}
|
String(char *s) : data(s), len(Strlen(s)) {}
|
||||||
String(char *s, int64_t l) : data((char *)s), len(l) {}
|
String(char *s, int64_t l) : data((char *)s), len(l) {}
|
||||||
String(const char *s) : data((char *)s), len(strlen((char *)s)) {}
|
String(const char *s) : data((char *)s), len(Strlen((char *)s)) {}
|
||||||
String(const char *s, int64_t l) : data((char *)s), len(l) {}
|
String(const char *s, int64_t l) : data((char *)s), len(l) {}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ API bool IsDigit(char16_t a) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
API bool IsHexDigit(char16_t a) {
|
API bool IsHexDigit(char16_t a) {
|
||||||
bool result = a >= u'0' && a <= u'9' || a == 'a' || a == 'b' || a == 'c' || a == 'd' || a == 'e' || a == 'f';
|
bool result = (a >= u'0' && a <= u'9') || a == 'a' || a == 'b' || a == 'c' || a == 'd' || a == 'e' || a == 'f';
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
src/external/minicoro.h
vendored
4
src/external/minicoro.h
vendored
@@ -429,8 +429,8 @@ MCO_API const char *mco_result_description(mco_result res); /* Get the descripti
|
|||||||
#else
|
#else
|
||||||
#ifdef thread_local
|
#ifdef thread_local
|
||||||
#define MCO_THREAD_LOCAL thread_local
|
#define MCO_THREAD_LOCAL thread_local
|
||||||
#elif __STDC_VERSION__ >= 201112 && !defined(__STDC_NO_THREADS__)
|
// #elif __STDC_VERSION__ >= 201112 && !defined(__STDC_NO_THREADS__)
|
||||||
#define MCO_THREAD_LOCAL _Thread_local
|
// #define MCO_THREAD_LOCAL _Thread_local
|
||||||
#elif defined(_WIN32) && (defined(_MSC_VER) || defined(__ICL) || defined(__DMC__) || defined(__BORLANDC__))
|
#elif defined(_WIN32) && (defined(_MSC_VER) || defined(__ICL) || defined(__DMC__) || defined(__BORLANDC__))
|
||||||
#define MCO_THREAD_LOCAL __declspec(thread)
|
#define MCO_THREAD_LOCAL __declspec(thread)
|
||||||
#elif defined(__GNUC__) || defined(__SUNPRO_C) || defined(__xlC__)
|
#elif defined(__GNUC__) || defined(__SUNPRO_C) || defined(__xlC__)
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ static const char *glsl_fshader_es3 = R"==(#version 300 es
|
|||||||
|
|
||||||
void ReportWarningf(const char *fmt, ...);
|
void ReportWarningf(const char *fmt, ...);
|
||||||
void GLDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *user) {
|
void GLDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *user) {
|
||||||
|
Unused(source); Unused(type); Unused(id); Unused(length); Unused(user);
|
||||||
ReportWarningf("OpenGL message: %s", message);
|
ReportWarningf("OpenGL message: %s", message);
|
||||||
if (severity == GL_DEBUG_SEVERITY_HIGH || severity == GL_DEBUG_SEVERITY_MEDIUM) {
|
if (severity == GL_DEBUG_SEVERITY_HIGH || severity == GL_DEBUG_SEVERITY_MEDIUM) {
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OpenGL error", message, NULL);
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OpenGL error", message, NULL);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ void Wait(mco_coro *co) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlayTestOpen(mco_coro *co) {
|
void PlayTestOpen(mco_coro *co) {
|
||||||
|
Unused(co);
|
||||||
// Open file, move a little, then open again and verify the caret didn't move
|
// Open file, move a little, then open again and verify the caret didn't move
|
||||||
// String basic_env_cpp = Format(SysAllocator, "%S/test_env", TestDir);
|
// String basic_env_cpp = Format(SysAllocator, "%S/test_env", TestDir);
|
||||||
|
|
||||||
|
|||||||
@@ -64,11 +64,6 @@ API Range GetBufferEndAsRange(Buffer *buffer) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
API Range GetBufferBeginAsRange(Buffer *buffer) {
|
|
||||||
Range result = {0, 0};
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
API Range GetRange(Buffer *buffer) {
|
API Range GetRange(Buffer *buffer) {
|
||||||
Range result = {0, buffer->len};
|
Range result = {0, buffer->len};
|
||||||
return result;
|
return result;
|
||||||
@@ -467,10 +462,6 @@ API Int GetBufferEnd(Buffer *buffer) {
|
|||||||
return buffer->len;
|
return buffer->len;
|
||||||
}
|
}
|
||||||
|
|
||||||
API Int GetBufferStart(Buffer *buffer) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
API Int GetNextEmptyLineStart(Buffer *buffer, Int pos) {
|
API Int GetNextEmptyLineStart(Buffer *buffer, Int pos) {
|
||||||
Int result = pos;
|
Int result = pos;
|
||||||
Int next_line = PosToLine(buffer, pos) + 1;
|
Int next_line = PosToLine(buffer, pos) + 1;
|
||||||
@@ -903,7 +894,7 @@ API void RedoEdit(Buffer *buffer, Array<Caret> *carets) {
|
|||||||
ProfileFunction();
|
ProfileFunction();
|
||||||
if (buffer->no_history) return;
|
if (buffer->no_history) return;
|
||||||
|
|
||||||
for (int i = 0; buffer->redo_stack.len > 0; i += 1) {
|
for (;buffer->redo_stack.len > 0;) {
|
||||||
HistoryEntry entry = Pop(&buffer->redo_stack);
|
HistoryEntry entry = Pop(&buffer->redo_stack);
|
||||||
HistoryEntry *e = SaveHistoryBeforeMergeCursor(buffer, &buffer->undo_stack, *carets);
|
HistoryEntry *e = SaveHistoryBeforeMergeCursor(buffer, &buffer->undo_stack, *carets);
|
||||||
e->time = entry.time;
|
e->time = entry.time;
|
||||||
@@ -1251,7 +1242,7 @@ void RunBufferTest() {
|
|||||||
Assert(buffer.data[15] == L'\n');
|
Assert(buffer.data[15] == L'\n');
|
||||||
Assert(buffer.data[16] == L't');
|
Assert(buffer.data[16] == L't');
|
||||||
|
|
||||||
RawReplaceText(&buffer, GetBufferBeginAsRange(&buffer), u"Things as is\nand stuff\n");
|
RawReplaceText(&buffer, {}, u"Things as is\nand stuff\n");
|
||||||
Assert(buffer.line_starts.len == 4);
|
Assert(buffer.line_starts.len == 4);
|
||||||
Assert(PosToLine(&buffer, 12) == 0);
|
Assert(PosToLine(&buffer, 12) == 0);
|
||||||
Assert(buffer.data[12] == L'\n');
|
Assert(buffer.data[12] == L'\n');
|
||||||
@@ -1266,7 +1257,7 @@ void RunBufferTest() {
|
|||||||
Assert(PosToLine(&buffer, 39) == 3);
|
Assert(PosToLine(&buffer, 39) == 3);
|
||||||
Assert(buffer.data[39] == L't');
|
Assert(buffer.data[39] == L't');
|
||||||
|
|
||||||
RawReplaceText(&buffer, GetBufferBeginAsRange(&buffer), u"a");
|
RawReplaceText(&buffer, {}, u"a");
|
||||||
Assert(buffer.line_starts.len == 4);
|
Assert(buffer.line_starts.len == 4);
|
||||||
Assert(PosToLine(&buffer, 13) == 0);
|
Assert(PosToLine(&buffer, 13) == 0);
|
||||||
Assert(PosToLine(&buffer, 14) == 1);
|
Assert(PosToLine(&buffer, 14) == 1);
|
||||||
@@ -1458,7 +1449,7 @@ Int ConvertUTF8ToUTF16UnixLine(String string, char16_t *buffer, Int buffer_cap)
|
|||||||
}
|
}
|
||||||
if (string.data[i] == '\t') {
|
if (string.data[i] == '\t') {
|
||||||
// @WARNING: DONT INCREASE THE SIZE CARELESSLY, WE NEED TO ADJUST BUFFER SIZE
|
// @WARNING: DONT INCREASE THE SIZE CARELESSLY, WE NEED TO ADJUST BUFFER SIZE
|
||||||
for (Int i = 0; i < 4; i += 1) buffer[buffer_len++] = u' ';
|
for (Int ii = 0; ii < 4; ii += 1) buffer[buffer_len++] = u' ';
|
||||||
i += 1;
|
i += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,8 +75,12 @@ void ReportErrorf(const char *fmt, ...) {
|
|||||||
BREAK();
|
BREAK();
|
||||||
}
|
}
|
||||||
|
|
||||||
Appendf(LogView, "%S\n", string);
|
if (LogView) {
|
||||||
ShowUIMessagef("%S", string);
|
Appendf(LogView, "%S\n", string);
|
||||||
|
ShowUIMessagef("%S", string);
|
||||||
|
} else {
|
||||||
|
printf("%.*s\n", (int)string.len, string.data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportConsolef(const char *fmt, ...) {
|
void ReportConsolef(const char *fmt, ...) {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ void ClipboardCopy(View *view) {
|
|||||||
Range line_range = GetLineRange(buffer, line, &eof);
|
Range line_range = GetLineRange(buffer, line, &eof);
|
||||||
it.range = line_range;
|
it.range = line_range;
|
||||||
if (eof) {
|
if (eof) {
|
||||||
it.range.min = ClampBottom(0ll, it.range.min - 1);
|
it.range.min = ClampBottom(0ll, it.range.min - 1ll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,9 +84,9 @@ void ClipboardPaste(View *view) {
|
|||||||
Array<Edit> edits = BeginEdit(scratch, buffer, view->carets);
|
Array<Edit> edits = BeginEdit(scratch, buffer, view->carets);
|
||||||
MergeCarets(buffer, &view->carets);
|
MergeCarets(buffer, &view->carets);
|
||||||
for (int64_t i = 0; i < view->carets.len; i += 1) {
|
for (int64_t i = 0; i < view->carets.len; i += 1) {
|
||||||
String16 string = SavedClipboardCarets[i];
|
String16 saved_string = SavedClipboardCarets[i];
|
||||||
Caret &it = view->carets[i];
|
Caret &it = view->carets[i];
|
||||||
AddEdit(&edits, it.range, string);
|
AddEdit(&edits, it.range, saved_string);
|
||||||
}
|
}
|
||||||
EndEdit(buffer, &edits, &view->carets, EndEdit_KillSelection);
|
EndEdit(buffer, &edits, &view->carets, EndEdit_KillSelection);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ void TestParser() {
|
|||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
{
|
{
|
||||||
char *cmd = "ctrl-b";
|
char *cmd = "ctrl-b";
|
||||||
Lexer base_lex = {scratch, cmd, cmd, cmd + strlen(cmd), "keybinding"};
|
Lexer base_lex = {scratch, cmd, cmd, cmd + Strlen(cmd), "keybinding"};
|
||||||
Trigger *trigger = ParseKeyCatchAll(&base_lex);
|
Trigger *trigger = ParseKeyCatchAll(&base_lex);
|
||||||
Assert(trigger->kind == TriggerKind_Key);
|
Assert(trigger->kind == TriggerKind_Key);
|
||||||
Assert(trigger->key == SDLK_B);
|
Assert(trigger->key == SDLK_B);
|
||||||
@@ -237,7 +237,7 @@ void TestParser() {
|
|||||||
|
|
||||||
{
|
{
|
||||||
char *cmd = "ctrl-b shift-ctrl-a";
|
char *cmd = "ctrl-b shift-ctrl-a";
|
||||||
Lexer base_lex = {scratch, cmd, cmd, cmd + strlen(cmd), "keybinding"};
|
Lexer base_lex = {scratch, cmd, cmd, cmd + Strlen(cmd), "keybinding"};
|
||||||
Trigger *trigger = ParseKeyCatchAll(&base_lex);
|
Trigger *trigger = ParseKeyCatchAll(&base_lex);
|
||||||
Assert(trigger->kind == TriggerKind_Binary);
|
Assert(trigger->kind == TriggerKind_Binary);
|
||||||
Assert(trigger->key == ' ');
|
Assert(trigger->key == ' ');
|
||||||
@@ -253,7 +253,7 @@ void TestParser() {
|
|||||||
|
|
||||||
{
|
{
|
||||||
char *cmd = "ctrl-b shift-ctrl-a | ctrl-c | ctrl-d";
|
char *cmd = "ctrl-b shift-ctrl-a | ctrl-c | ctrl-d";
|
||||||
Lexer base_lex = {scratch, cmd, cmd, cmd + strlen(cmd), "keybinding"};
|
Lexer base_lex = {scratch, cmd, cmd, cmd + Strlen(cmd), "keybinding"};
|
||||||
Trigger *trigger = ParseKeyCatchAll(&base_lex);
|
Trigger *trigger = ParseKeyCatchAll(&base_lex);
|
||||||
Assert(trigger->kind == TriggerKind_Binary);
|
Assert(trigger->kind == TriggerKind_Binary);
|
||||||
Assert(trigger->key == '|');
|
Assert(trigger->key == '|');
|
||||||
|
|||||||
@@ -212,9 +212,7 @@ void DrawWindow(Window *window, Event &event) {
|
|||||||
Vec2I mouse = MouseVec2I();
|
Vec2I mouse = MouseVec2I();
|
||||||
bool mouse_in_document = AreOverlapping(mouse, window->document_rect);
|
bool mouse_in_document = AreOverlapping(mouse, window->document_rect);
|
||||||
if (mouse_in_document) {
|
if (mouse_in_document) {
|
||||||
View *view = GetView(window->active_view);
|
Int p = ScreenSpaceToBufferPosErrorOutOfBounds(window, view, buffer, mouse);
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
|
||||||
Int p = ScreenSpaceToBufferPosErrorOutOfBounds(window, view, buffer, mouse);
|
|
||||||
if (p != -1) {
|
if (p != -1) {
|
||||||
Range range = EncloseLoadWord(buffer, p);
|
Range range = EncloseLoadWord(buffer, p);
|
||||||
if (InBounds(caret.range, p)) range = caret.range;
|
if (InBounds(caret.range, p)) range = caret.range;
|
||||||
|
|||||||
@@ -347,18 +347,18 @@ struct { String string; SDL_Keycode value; } SDLKeycodeConversionTable[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void FillEventWithBasicData(Event *event) {
|
void FillEventWithBasicData(Event *event) {
|
||||||
if (OS_WINDOWS) {
|
#if OS_WINDOWS
|
||||||
if (GetKeyState(VK_SHIFT) & 0x8000) event->shift = 1;
|
if (GetKeyState(VK_SHIFT) & 0x8000) event->shift = 1;
|
||||||
if (GetKeyState(VK_CONTROL) & 0x8000) event->ctrl = 1;
|
if (GetKeyState(VK_CONTROL) & 0x8000) event->ctrl = 1;
|
||||||
if (GetKeyState(VK_MENU) & 0x8000) event->alt = 1;
|
if (GetKeyState(VK_MENU) & 0x8000) event->alt = 1;
|
||||||
if (GetKeyState(VK_LWIN) & 0x8000) event->super = 1;
|
if (GetKeyState(VK_LWIN) & 0x8000) event->super = 1;
|
||||||
} else {
|
#else
|
||||||
SDL_Keymod mod = SDL_GetModState();
|
SDL_Keymod mod = SDL_GetModState();
|
||||||
event->shift = (mod & SDL_KMOD_SHIFT) != 0;
|
event->shift = (mod & SDL_KMOD_SHIFT) != 0;
|
||||||
event->ctrl = (mod & SDL_KMOD_CTRL) != 0;
|
event->ctrl = (mod & SDL_KMOD_CTRL) != 0;
|
||||||
event->alt = (mod & SDL_KMOD_ALT) != 0;
|
event->alt = (mod & SDL_KMOD_ALT) != 0;
|
||||||
event->super = (mod & SDL_KMOD_GUI) != 0;
|
event->super = (mod & SDL_KMOD_GUI) != 0;
|
||||||
}
|
#endif
|
||||||
|
|
||||||
float xmouse, ymouse;
|
float xmouse, ymouse;
|
||||||
SDL_GetMouseState(&xmouse, &ymouse);
|
SDL_GetMouseState(&xmouse, &ymouse);
|
||||||
@@ -499,10 +499,10 @@ void GetEventsForFrame(Array<Event> *events) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (events->len == 0) {
|
if (events->len == 0) {
|
||||||
Event event = {};
|
Event ev = {};
|
||||||
FillEventWithBasicData(&event);
|
FillEventWithBasicData(&ev);
|
||||||
event.kind = EVENT_UPDATE;
|
ev.kind = EVENT_UPDATE;
|
||||||
Add(events, event);
|
Add(events, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert(events->len);
|
Assert(events->len);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
float NewFuzzyRate(String16 s, String16 p) {
|
// float NewFuzzyRate(String16 s, String16 p) {
|
||||||
float score = 0;
|
// float score = 0;
|
||||||
// try to do this: https://github.com/junegunn/fzf/blob/master/src/algo/algo.go
|
// // try to do this: https://github.com/junegunn/fzf/blob/master/src/algo/algo.go
|
||||||
return score;
|
// return score;
|
||||||
}
|
// }
|
||||||
|
|
||||||
float FuzzyRate(String16 s, String16 p) {
|
float FuzzyRate(String16 s, String16 p) {
|
||||||
float score = 0;
|
float score = 0;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ void InitBuildWindow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LayoutBuildWindow(Rect2I *rect, int16_t wx, int16_t wy) {
|
void LayoutBuildWindow(Rect2I *rect, int16_t wx, int16_t wy) {
|
||||||
|
Unused(wx); Unused(wy);
|
||||||
Window *window = GetWindow(BuildWindowID);
|
Window *window = GetWindow(BuildWindowID);
|
||||||
Rect2I copy_rect = *rect;
|
Rect2I copy_rect = *rect;
|
||||||
if (!window->visible) {
|
if (!window->visible) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ void CMD_ShowCommands() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
command_bar.view->update_scroll = true;
|
command_bar.view->update_scroll = true;
|
||||||
SelectRange(command_bar.view, GetBufferBeginAsRange(command_bar.buffer));
|
SelectRange(command_bar.view, Range{});
|
||||||
} RegisterCommand(CMD_ShowCommands, "ctrl-shift-p", "List available commands and their documentation inside the command window");
|
} RegisterCommand(CMD_ShowCommands, "ctrl-shift-p", "List available commands and their documentation inside the command window");
|
||||||
|
|
||||||
void CMD_ShowDebugBufferList() {
|
void CMD_ShowDebugBufferList() {
|
||||||
@@ -31,7 +31,7 @@ void CMD_ShowDebugBufferList() {
|
|||||||
RawAppendf(command_bar.buffer, "\n%S", it->name);
|
RawAppendf(command_bar.buffer, "\n%S", it->name);
|
||||||
}
|
}
|
||||||
command_bar.view->update_scroll = true;
|
command_bar.view->update_scroll = true;
|
||||||
SelectRange(command_bar.view, GetBufferBeginAsRange(command_bar.buffer));
|
SelectRange(command_bar.view, Range{});
|
||||||
} RegisterCommand(CMD_ShowDebugBufferList, "ctrl-shift-alt-p", "Show full list of buffers, including the special ones that normally just clutter list");
|
} RegisterCommand(CMD_ShowDebugBufferList, "ctrl-shift-alt-p", "Show full list of buffers, including the special ones that normally just clutter list");
|
||||||
|
|
||||||
void CMD_ShowBufferList() {
|
void CMD_ShowBufferList() {
|
||||||
@@ -50,10 +50,11 @@ void CMD_ShowBufferList() {
|
|||||||
RawAppendf(command_bar.buffer, "\n%S", it->name);
|
RawAppendf(command_bar.buffer, "\n%S", it->name);
|
||||||
}
|
}
|
||||||
command_bar.view->update_scroll = true;
|
command_bar.view->update_scroll = true;
|
||||||
SelectRange(command_bar.view, GetBufferBeginAsRange(command_bar.buffer));
|
SelectRange(command_bar.view, Range{});
|
||||||
} RegisterCommand(CMD_ShowBufferList, "ctrl-p", "List open buffers inside the command window that you can fuzzy search over");
|
} RegisterCommand(CMD_ShowBufferList, "ctrl-p", "List open buffers inside the command window that you can fuzzy search over");
|
||||||
|
|
||||||
void LayoutCommandWindow(Rect2I *rect, int16_t wx, int16_t wy) {
|
void LayoutCommandWindow(Rect2I *rect, int16_t wx, int16_t wy) {
|
||||||
|
Unused(wy);
|
||||||
Window *window = GetWindow(CommandWindowID);
|
Window *window = GetWindow(CommandWindowID);
|
||||||
Rect2I copy_rect = *rect;
|
Rect2I copy_rect = *rect;
|
||||||
if (!window->visible) {
|
if (!window->visible) {
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ BufferID LoadConfig(String config_path) {
|
|||||||
|
|
||||||
#define ExpectP(x, ...) \
|
#define ExpectP(x, ...) \
|
||||||
if (!(x)) { \
|
if (!(x)) { \
|
||||||
ReportErrorf("Failed to parse '" __FUNCTION__ "' command, " __VA_ARGS__); \
|
ReportErrorf("Failed to parse command " __VA_ARGS__); \
|
||||||
return; \
|
return; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ void InitDebugWindow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LayoutDebugWindow(Rect2I *rect, int16_t wx, int16_t wy) {
|
void LayoutDebugWindow(Rect2I *rect, int16_t wx, int16_t wy) {
|
||||||
|
Unused(rect);
|
||||||
Window *window = GetWindow(DebugWindowID);
|
Window *window = GetWindow(DebugWindowID);
|
||||||
Rect2 screen_rect = Rect0Size((float)wx, (float)wy);
|
Rect2 screen_rect = Rect0Size((float)wx, (float)wy);
|
||||||
Vec2 size = GetSize(screen_rect);
|
Vec2 size = GetSize(screen_rect);
|
||||||
@@ -47,9 +48,7 @@ void UpdateDebugWindow() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BSet main = GetBSet(PrimaryWindowID);
|
|
||||||
RawReplaceText(set.buffer, GetRange(set.buffer), u"Active buffers and views:\n");
|
RawReplaceText(set.buffer, GetRange(set.buffer), u"Active buffers and views:\n");
|
||||||
|
|
||||||
For (Views) {
|
For (Views) {
|
||||||
Buffer *buffer = GetBuffer(it->active_buffer);
|
Buffer *buffer = GetBuffer(it->active_buffer);
|
||||||
RawAppendf(set.buffer, "view->id:%lld, buffer->id:%lld, buffer->name:%S\n", (long long)it->id.id, (long long)buffer->id.id, buffer->name);
|
RawAppendf(set.buffer, "view->id:%lld, buffer->id:%lld, buffer->name:%S\n", (long long)it->id.id, (long long)buffer->id.id, buffer->name);
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ void OpenDirectoryNavigation(View *view) {
|
|||||||
// view->update_hook = UpdateDirectoryNavigation;
|
// view->update_hook = UpdateDirectoryNavigation;
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
InsertDirectoryNavigation(buffer);
|
InsertDirectoryNavigation(buffer);
|
||||||
SelectRange(view, GetBufferBeginAsRange(buffer));
|
SelectRange(view, Range{});
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|||||||
@@ -108,7 +108,6 @@ void CO_Close(mco_coro *co) {
|
|||||||
|
|
||||||
void CMD_DeleteFile() {
|
void CMD_DeleteFile() {
|
||||||
BSet main = GetBSet(PrimaryWindowID);
|
BSet main = GetBSet(PrimaryWindowID);
|
||||||
String buffer_name = main.buffer->name;
|
|
||||||
DeleteFile(main.buffer->name);
|
DeleteFile(main.buffer->name);
|
||||||
Close(main.buffer->id);
|
Close(main.buffer->id);
|
||||||
} RegisterCommand(CMD_DeleteFile, "", "Close the open buffer and delete it's corresponding file on disk");
|
} RegisterCommand(CMD_DeleteFile, "", "Close the open buffer and delete it's corresponding file on disk");
|
||||||
|
|||||||
@@ -294,6 +294,7 @@ SPALL_FN bool spall_flush(SpallProfile *ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SPALL_FN bool spall_buffer_init(SpallProfile *ctx, SpallBuffer *wb) {
|
SPALL_FN bool spall_buffer_init(SpallProfile *ctx, SpallBuffer *wb) {
|
||||||
|
(void)(ctx);
|
||||||
// Fails if buffer is not big enough to contain at least one event!
|
// Fails if buffer is not big enough to contain at least one event!
|
||||||
if (wb->length < sizeof(SpallBufferHeader) + sizeof(SpallBeginEventMax)) {
|
if (wb->length < sizeof(SpallBufferHeader) + sizeof(SpallBeginEventMax)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ void InitSearchWindow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LayoutSearchWindow(Rect2I *rect, int16_t wx, int16_t wy) {
|
void LayoutSearchWindow(Rect2I *rect, int16_t wx, int16_t wy) {
|
||||||
|
Unused(wx); Unused(wy);
|
||||||
Window *window = GetWindow(SearchWindowID);
|
Window *window = GetWindow(SearchWindowID);
|
||||||
Rect2I copy_rect = *rect;
|
Rect2I copy_rect = *rect;
|
||||||
if (!window->visible) {
|
if (!window->visible) {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ void InitStatusWindow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LayoutStatusWindow(Rect2I *rect, int16_t wx, int16_t wy) {
|
void LayoutStatusWindow(Rect2I *rect, int16_t wx, int16_t wy) {
|
||||||
|
Unused(wx); Unused(wy);
|
||||||
Window *window = GetWindow(StatusWindowID);
|
Window *window = GetWindow(StatusWindowID);
|
||||||
Rect2I copy_rect = *rect;
|
Rect2I copy_rect = *rect;
|
||||||
if (!window->visible) {
|
if (!window->visible) {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ void CWSLexIdentifiers(Array<StringAndDistance> *out_idents, Buffer *buffer) {
|
|||||||
Array<StringAndDistance> idents = {CWS.arena};
|
Array<StringAndDistance> idents = {CWS.arena};
|
||||||
String16 string = GetString(buffer);
|
String16 string = GetString(buffer);
|
||||||
Lexer2 lexer = BeginLexing(string.data);
|
Lexer2 lexer = BeginLexing(string.data);
|
||||||
for (int i = 0;; i += 1) {
|
for (;;) {
|
||||||
String16 token = Next(&lexer);
|
String16 token = Next(&lexer);
|
||||||
if (token.len <= 0) {
|
if (token.len <= 0) {
|
||||||
break;
|
break;
|
||||||
@@ -141,12 +141,9 @@ void WordComplete(mco_coro *co) {
|
|||||||
goto yield;
|
goto yield;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StringAndDistance it = idents[i];
|
CWS.last_string = Copy16(CWS.arena, idents[i].string);
|
||||||
String16 ident = Copy16(CWS.arena, it.string);
|
SelectRange(CWS.view, EncloseWord(CWS.buffer, CWS.original_caret_pos));
|
||||||
CWS.last_string = ident;
|
Replace(CWS.view, CWS.last_string);
|
||||||
Range range = EncloseWord(CWS.buffer, CWS.original_caret_pos);
|
|
||||||
SelectRange(CWS.view, range);
|
|
||||||
Replace(CWS.view, ident);
|
|
||||||
yield:;
|
yield:;
|
||||||
mco_yield(co);
|
mco_yield(co);
|
||||||
if (CWS.direction == -1 && i > 0 && i == idents.len) {
|
if (CWS.direction == -1 && i > 0 && i == idents.len) {
|
||||||
@@ -155,7 +152,7 @@ void WordComplete(mco_coro *co) {
|
|||||||
i -= 1;
|
i -= 1;
|
||||||
}
|
}
|
||||||
i += CWS.direction;
|
i += CWS.direction;
|
||||||
i = Clamp(i, 0ll, idents.len);
|
i = Clamp(i, (Int)0, idents.len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +180,7 @@ void WordComplete(View *view, Int pos) {
|
|||||||
CWS.original_caret_pos = pos;
|
CWS.original_caret_pos = pos;
|
||||||
CWS.prefix_string = Copy16(CWS.arena, prefix);
|
CWS.prefix_string = Copy16(CWS.arena, prefix);
|
||||||
|
|
||||||
mco_desc desc = mco_desc_init(WordComplete, NULL);
|
mco_desc desc = mco_desc_init(WordComplete, 0);
|
||||||
mco_result res = mco_create(&CWS.co, &desc);
|
mco_result res = mco_create(&CWS.co, &desc);
|
||||||
Assert(res == MCO_SUCCESS);
|
Assert(res == MCO_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -408,9 +408,7 @@ void OnCommand(Event event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BSet main = GetBSet(PrimaryWindowID);
|
|
||||||
BSet active = GetBSet(ActiveWindowID);
|
BSet active = GetBSet(ActiveWindowID);
|
||||||
|
|
||||||
bool executed = false;
|
bool executed = false;
|
||||||
For (active.view->commands) {
|
For (active.view->commands) {
|
||||||
if (it.trigger && MatchEvent(it.trigger, &event)) {
|
if (it.trigger && MatchEvent(it.trigger, &event)) {
|
||||||
@@ -459,8 +457,11 @@ void OnCommand(Event event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IF_SLOW_BUILD(AssertRanges(main.view->carets));
|
#if SLOW_BUILD
|
||||||
IF_SLOW_BUILD(AssertRanges(active.view->carets));
|
BSet main = GetBSet(PrimaryWindowID);
|
||||||
|
AssertRanges(main.view->carets);
|
||||||
|
AssertRanges(active.view->carets);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalCommand(String command) {
|
void EvalCommand(String command) {
|
||||||
@@ -845,7 +846,7 @@ void MainLoop() {
|
|||||||
SDL_GL_SwapWindow(SDLWindow);
|
SDL_GL_SwapWindow(SDLWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if _WIN32
|
#if OS_WINDOWS
|
||||||
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
|
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
|
||||||
#else
|
#else
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
@@ -853,7 +854,7 @@ int main(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
InitScratch();
|
InitScratch();
|
||||||
InitOS((OSErrorReport *)printf);
|
InitOS(ReportErrorf);
|
||||||
#if OS_WINDOWS
|
#if OS_WINDOWS
|
||||||
int argc = __argc;
|
int argc = __argc;
|
||||||
char **argv = __argv;
|
char **argv = __argv;
|
||||||
@@ -912,8 +913,6 @@ int main(int argc, char **argv)
|
|||||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
||||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
||||||
|
|
||||||
SDL_DisplayID primary_display_id = SDL_GetPrimaryDisplay();
|
|
||||||
const SDL_DisplayMode *display_mode = SDL_GetCurrentDisplayMode(primary_display_id);
|
|
||||||
|
|
||||||
// int w8 = (int)(display_mode->w * 0.8);
|
// int w8 = (int)(display_mode->w * 0.8);
|
||||||
// int h8 = (int)(display_mode->h * 0.8);
|
// int h8 = (int)(display_mode->h * 0.8);
|
||||||
@@ -923,6 +922,8 @@ int main(int argc, char **argv)
|
|||||||
int xhalf = 100;
|
int xhalf = 100;
|
||||||
int yhalf = 100;
|
int yhalf = 100;
|
||||||
#else
|
#else
|
||||||
|
SDL_DisplayID primary_display_id = SDL_GetPrimaryDisplay();
|
||||||
|
const SDL_DisplayMode *display_mode = SDL_GetCurrentDisplayMode(primary_display_id);
|
||||||
int whalf = (int)(display_mode->w * 0.5) - 10;
|
int whalf = (int)(display_mode->w * 0.5) - 10;
|
||||||
int hhalf = (int)(display_mode->h) - 120;
|
int hhalf = (int)(display_mode->h) - 120;
|
||||||
int xhalf = whalf;
|
int xhalf = whalf;
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ void DetectUserFileCallback(Window *window, ResolvedOpen *resolved) {
|
|||||||
|
|
||||||
String16 QueryUserString(mco_coro *co, String ask) {
|
String16 QueryUserString(mco_coro *co, String ask) {
|
||||||
BSet main = GetBSet(PrimaryWindowID);
|
BSet main = GetBSet(PrimaryWindowID);
|
||||||
Buffer *original_buffer = main.buffer;
|
|
||||||
JumpTempBuffer(&main);
|
JumpTempBuffer(&main);
|
||||||
NextActiveWindowID = main.window->id;
|
NextActiveWindowID = main.window->id;
|
||||||
RawAppendf(main.buffer, R"==(
|
RawAppendf(main.buffer, R"==(
|
||||||
|
|||||||
@@ -618,18 +618,18 @@ void IndentSelectedLines(View *view, bool shift = false) {
|
|||||||
indent_string.len = IndentSize;
|
indent_string.len = IndentSize;
|
||||||
if (!shift) {
|
if (!shift) {
|
||||||
AddEdit(&edits, {pos_range_of_line.min, pos_range_of_line.min}, indent_string);
|
AddEdit(&edits, {pos_range_of_line.min, pos_range_of_line.min}, indent_string);
|
||||||
For (saved_xy) {
|
ForItem (xy, saved_xy) {
|
||||||
if (it.front.y == i) it.front.x += indent_string.len;
|
if (xy.front.y == i) xy.front.x += indent_string.len;
|
||||||
if (it.back.y == i) it.back.x += indent_string.len;
|
if (xy.back.y == i) xy.back.x += indent_string.len;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Int whitespace_len = 0;
|
Int whitespace_len = 0;
|
||||||
for (Int i = 0; i < IndentSize && i < string.len && string.data[i] == u' '; i += 1) {
|
for (Int ii = 0; ii < IndentSize && ii < string.len && string.data[ii] == u' '; ii += 1) {
|
||||||
whitespace_len += 1;
|
whitespace_len += 1;
|
||||||
}
|
}
|
||||||
For (saved_xy) {
|
ForItem (xy, saved_xy) {
|
||||||
if (it.front.y == i) it.front.x -= whitespace_len;
|
if (xy.front.y == i) xy.front.x -= whitespace_len;
|
||||||
if (it.back.y == i) it.back.x -= whitespace_len;
|
if (xy.back.y == i) xy.back.x -= whitespace_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddEdit(&edits, {pos_range_of_line.min, pos_range_of_line.min + whitespace_len}, u"");
|
AddEdit(&edits, {pos_range_of_line.min, pos_range_of_line.min + whitespace_len}, u"");
|
||||||
|
|||||||
@@ -279,30 +279,29 @@ void GotoNextInList(Window *window, Int line_offset = 1) {
|
|||||||
bool opened = false;
|
bool opened = false;
|
||||||
for (Int i = line + line_offset; i >= 0 && i < buffer_goto->line_starts.len; i += line_offset) {
|
for (Int i = line + line_offset; i >= 0 && i < buffer_goto->line_starts.len; i += line_offset) {
|
||||||
Range line_range = GetLineRangeWithoutNL(buffer_goto, i);
|
Range line_range = GetLineRangeWithoutNL(buffer_goto, i);
|
||||||
String16 line = GetString(buffer_goto, line_range);
|
String16 string_line = GetString(buffer_goto, line_range);
|
||||||
|
|
||||||
{
|
{
|
||||||
Int idx = 0;
|
Int idx = 0;
|
||||||
String16 delim = u"||>";
|
String16 delim = u"||>";
|
||||||
if (Seek(line, delim, &idx, SeekFlag_None)) {
|
if (Seek(string_line, delim, &idx, SeekFlag_None)) {
|
||||||
line = Skip(line, idx + delim.len);
|
string_line = Skip(string_line, idx + delim.len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
view_goto->carets[0] = MakeCaret(line_range.min);
|
view_goto->carets[0] = MakeCaret(line_range.min);
|
||||||
window->goto_list_pos = line_range.min;
|
window->goto_list_pos = line_range.min;
|
||||||
line = Trim(line);
|
string_line = Trim(string_line);
|
||||||
|
|
||||||
MergeCarets(buffer_goto, &view_goto->carets);
|
MergeCarets(buffer_goto, &view_goto->carets);
|
||||||
IF_DEBUG(AssertRanges(view_goto->carets));
|
IF_DEBUG(AssertRanges(view_goto->carets));
|
||||||
if (line.len == 0) {
|
if (string_line.len == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer *active_view_buffer = GetBuffer(active_view->active_buffer);
|
|
||||||
Range before_jump_range = active_view->carets[0].range;
|
Range before_jump_range = active_view->carets[0].range;
|
||||||
|
|
||||||
BSet set = Open(line, ResolveOpenMeta_DontError | ResolveOpenMeta_DontExec);
|
BSet set = Open(string_line, ResolveOpenMeta_DontError | ResolveOpenMeta_DontExec);
|
||||||
if (set.window == NULL) {
|
if (set.window == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -402,12 +401,12 @@ BSet GetBSet(WindowID window_id) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
String GetPrimaryDirectory() {
|
String GetDirectory(Window *window) {
|
||||||
BSet main = GetBSet(PrimaryWindowID);
|
BSet set = GetBSet(window->id);
|
||||||
return GetDirectory(main.buffer);
|
return GetDirectory(set.buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
String GetDirectory(Window *window) {
|
String GetPrimaryDirectory() {
|
||||||
BSet main = GetBSet(PrimaryWindowID);
|
BSet main = GetBSet(PrimaryWindowID);
|
||||||
return GetDirectory(main.buffer);
|
return GetDirectory(main.buffer);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user